@@ -7,66 +7,61 @@ uint16_t getPinCfg(const uint16_t *cfg, PinCfgReq_t req, bool prefer_sci /*= fal
7
7
}
8
8
bool thats_all = false ;
9
9
uint8_t index = 0 ;
10
- while (!thats_all) {
11
-
12
- /* usually not SCI peripheral have higher priority (they came
13
- first in the table) but it is possible to prefer SCI peripheral */
14
- if (prefer_sci && !IS_SCI (*(cfg + index))) {
15
- if (IS_LAST_ITEM (*(cfg + index))) {
16
- thats_all = true ;
17
- }
18
- else {
19
- index++;
20
- }
21
- continue ;
22
- }
23
10
24
- if (!prefer_sci && IS_SCI (*(cfg + index))) {
25
- if (IS_LAST_ITEM (*(cfg + index))) {
26
- thats_all = true ;
27
- }
28
- else {
29
- index++;
30
- }
31
- continue ;
32
- }
11
+ uint16_t config = 0 ;
12
+ uint16_t config_sci = 0 ;
33
13
14
+ while (!thats_all) {
34
15
35
16
if (PIN_CFG_REQ_UART_TX == req && IS_PIN_UART_TX (*(cfg + index))) {
36
- return *(cfg + index);
17
+ config = *(cfg + index);
37
18
}
38
19
else if (PIN_CFG_REQ_UART_RX == req && IS_PIN_UART_RX (*(cfg + index))) {
39
- return *(cfg + index);
20
+ config = *(cfg + index);
40
21
}
41
22
else if (PIN_CFG_REQ_SCL == req && IS_PIN_SCL (*(cfg + index))) {
42
- return *(cfg + index);
23
+ if (IS_SCI (*(cfg + index))) {
24
+ config_sci = *(cfg + index);
25
+ } else {
26
+ config = *(cfg + index);
27
+ }
43
28
}
44
29
else if (PIN_CFG_REQ_SDA == req && IS_PIN_SDA (*(cfg + index))) {
45
- return *(cfg + index);
30
+ if (IS_SCI (*(cfg + index))) {
31
+ config_sci = *(cfg + index);
32
+ } else {
33
+ config = *(cfg + index);
34
+ }
46
35
}
47
36
else if (PIN_CFG_REQ_MISO == req && IS_PIN_MISO (*(cfg + index))) {
48
- return *(cfg + index);
37
+ if (IS_SCI (*(cfg + index))) {
38
+ config_sci = *(cfg + index);
39
+ } else {
40
+ config = *(cfg + index);
41
+ }
49
42
}
50
43
else if (PIN_CFG_REQ_MOSI == req && IS_PIN_MOSI (*(cfg + index))) {
51
- return *(cfg + index);
44
+ if (IS_SCI (*(cfg + index))) {
45
+ config_sci = *(cfg + index);
46
+ } else {
47
+ config = *(cfg + index);
48
+ }
52
49
}
53
50
else if (PIN_CFG_REQ_SCK == req && IS_PIN_SCK (*(cfg + index))) {
54
- return *(cfg + index);
51
+ if (IS_SCI (*(cfg + index))) {
52
+ config_sci = *(cfg + index);
53
+ } else {
54
+ config = *(cfg + index);
55
+ }
55
56
}
56
57
else if (PIN_CFG_REQ_PWM == req && IS_PIN_PWM (*(cfg + index))) {
57
- return *(cfg + index);
58
+ config = *(cfg + index);
58
59
}
59
60
else if (PIN_CFG_REQ_INTERRUPT == req && IS_PIN_INTERRUPT (*(cfg + index))) {
60
- return *(cfg + index);
61
+ config = *(cfg + index);
61
62
}
62
63
else if (PIN_CFG_REQ_ADC == req && IS_PIN_ANALOG (*(cfg + index))) {
63
- return *(cfg + index);
64
- }
65
- else if (PIN_CFG_REQ_CAN_RX == req && IS_PIN_CAN_RX (*(cfg + index))) {
66
- return *(cfg + index);
67
- }
68
- else if (PIN_CFG_REQ_CAN_TX == req && IS_PIN_CAN_TX (*(cfg + index))) {
69
- return *(cfg + index);
64
+ config = *(cfg + index);
70
65
}
71
66
72
67
if (IS_LAST_ITEM (*(cfg + index))) {
@@ -76,10 +71,11 @@ uint16_t getPinCfg(const uint16_t *cfg, PinCfgReq_t req, bool prefer_sci /*= fal
76
71
index++;
77
72
}
78
73
}
79
- return 0 ;
80
- }
81
-
82
-
74
+ if (config_sci != 0 && (prefer_sci || config == 0 )) {
75
+ config = config_sci;
76
+ }
77
+ return config;
78
+ }
83
79
84
80
extern " C" const PinMuxCfg_t g_pin_cfg[] = {
85
81
{ BSP_IO_PORT_03_PIN_01, P301 }, /* (0) D0 ------------------------- DIGITAL */
0 commit comments