Skip to content

Commit bd00170

Browse files
committed
[pinmap] Reformatting code using astyle
Signed-off-by: Frederic.Pillon <[email protected]>
1 parent a97e0db commit bd00170

File tree

2 files changed

+56
-40
lines changed

2 files changed

+56
-40
lines changed

cores/arduino/stm32/pinmap.c

+44-28
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,20 @@ const uint32_t pin_map_ll[16] = {
3838
LL_GPIO_PIN_15
3939
};
4040

41-
void* pinmap_find_peripheral(PinName pin, const PinMap* map) {
41+
void *pinmap_find_peripheral(PinName pin, const PinMap *map)
42+
{
4243
while (map->pin != NC) {
43-
if (map->pin == pin)
44+
if (map->pin == pin) {
4445
return map->peripheral;
46+
}
4547
map++;
4648
}
4749
return NP;
4850
}
4951

50-
void* pinmap_peripheral(PinName pin, const PinMap* map) {
51-
void* peripheral = NP;
52+
void *pinmap_peripheral(PinName pin, const PinMap *map)
53+
{
54+
void *peripheral = NP;
5255

5356
if (pin != (PinName)NC) {
5457
peripheral = pinmap_find_peripheral(pin, map);
@@ -57,16 +60,19 @@ void* pinmap_peripheral(PinName pin, const PinMap* map) {
5760
return peripheral;
5861
}
5962

60-
PinName pinmap_find_pin(void* peripheral, const PinMap* map) {
63+
PinName pinmap_find_pin(void *peripheral, const PinMap *map)
64+
{
6165
while (map->peripheral != NP) {
62-
if (map->peripheral == peripheral)
66+
if (map->peripheral == peripheral) {
6367
return map->pin;
68+
}
6469
map++;
6570
}
6671
return NC;
6772
}
6873

69-
PinName pinmap_pin(void* peripheral, const PinMap* map) {
74+
PinName pinmap_pin(void *peripheral, const PinMap *map)
75+
{
7076
PinName pin = NC;
7177

7278
if (peripheral != NP) {
@@ -76,16 +82,19 @@ PinName pinmap_pin(void* peripheral, const PinMap* map) {
7682
return pin;
7783
}
7884

79-
uint32_t pinmap_find_function(PinName pin, const PinMap* map) {
85+
uint32_t pinmap_find_function(PinName pin, const PinMap *map)
86+
{
8087
while (map->pin != NC) {
81-
if (map->pin == pin)
88+
if (map->pin == pin) {
8289
return map->function;
90+
}
8391
map++;
8492
}
8593
return (uint32_t)NC;
8694
}
8795

88-
uint32_t pinmap_function(PinName pin, const PinMap* map) {
96+
uint32_t pinmap_function(PinName pin, const PinMap *map)
97+
{
8998
uint32_t function = (uint32_t)NC;
9099

91100
if (pin != (PinName)NC) {
@@ -95,36 +104,43 @@ uint32_t pinmap_function(PinName pin, const PinMap* map) {
95104
return function;
96105
}
97106

98-
bool pin_in_pinmap(PinName pin, const PinMap* map) {
107+
bool pin_in_pinmap(PinName pin, const PinMap *map)
108+
{
99109
if (pin != (PinName)NC) {
100110
while (map->pin != NC) {
101-
if (map->pin == pin)
111+
if (map->pin == pin) {
102112
return true;
113+
}
103114
map++;
104115
}
105116
}
106117
return false;
107118
}
108119

109120
// Merge peripherals
110-
void* pinmap_merge_peripheral(void* a, void* b) {
111-
// both are the same (inc both NP)
112-
if (a == b)
113-
return a;
114-
115-
// one (or both) is not set
116-
if (a == NP)
117-
return b;
118-
if (b == NP)
119-
return a;
120-
121-
// mis-match error case
122-
// error("pinmap mis-match");
123-
return NP;
121+
void *pinmap_merge_peripheral(void *a, void *b)
122+
{
123+
// both are the same (inc both NP)
124+
if (a == b) {
125+
return a;
126+
}
127+
128+
// one (or both) is not set
129+
if (a == NP) {
130+
return b;
131+
}
132+
if (b == NP) {
133+
return a;
134+
}
135+
136+
// mis-match error case
137+
// error("pinmap mis-match");
138+
return NP;
124139
}
125140

126-
PinName pin_pinName(const PinMap* map) {
127-
if(map->pin != (PinName)NC) {
141+
PinName pin_pinName(const PinMap *map)
142+
{
143+
if (map->pin != (PinName)NC) {
128144
return map->pin;
129145
} else {
130146
return (PinName)NC;

cores/arduino/stm32/pinmap.h

+12-12
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,23 @@ extern const uint32_t pin_map_ll[16];
3535
#define NP 0U
3636

3737
typedef struct {
38-
PinName pin;
39-
void* peripheral;
40-
int function;
38+
PinName pin;
39+
void *peripheral;
40+
int function;
4141
} PinMap;
4242

43-
bool pin_in_pinmap(PinName pin, const PinMap* map);
43+
bool pin_in_pinmap(PinName pin, const PinMap *map);
4444
void pin_function(PinName pin, int function);
4545

46-
PinName pin_pinName(const PinMap* map);
46+
PinName pin_pinName(const PinMap *map);
4747

48-
void* pinmap_find_peripheral(PinName pin, const PinMap* map);
49-
void* pinmap_peripheral(PinName pin, const PinMap* map);
50-
PinName pinmap_find_pin(void* peripheral, const PinMap* map);
51-
PinName pinmap_pin(void* peripheral, const PinMap* map);
52-
uint32_t pinmap_find_function(PinName pin, const PinMap* map);
53-
uint32_t pinmap_function(PinName pin, const PinMap* map);
54-
void* pinmap_merge_peripheral(void* a, void* b);
48+
void *pinmap_find_peripheral(PinName pin, const PinMap *map);
49+
void *pinmap_peripheral(PinName pin, const PinMap *map);
50+
PinName pinmap_find_pin(void *peripheral, const PinMap *map);
51+
PinName pinmap_pin(void *peripheral, const PinMap *map);
52+
uint32_t pinmap_find_function(PinName pin, const PinMap *map);
53+
uint32_t pinmap_function(PinName pin, const PinMap *map);
54+
void *pinmap_merge_peripheral(void *a, void *b);
5555

5656
#ifdef __cplusplus
5757
}

0 commit comments

Comments
 (0)