Skip to content

Commit 4e8222a

Browse files
committed
Explicit pinmap: Fix build failures reported by CI
1 parent bdff956 commit 4e8222a

File tree

4 files changed

+35
-23
lines changed

4 files changed

+35
-23
lines changed

hal/explicit_pinmap.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#if EXPLICIT_PINMAP_READY
3030
#include "PeripheralPinMaps.h"
3131

32+
3233
#if DEVICE_PWMOUT
3334
MSTD_CONSTEXPR_FN_14 PinMap get_pwm_pinmap(const PinName pin)
3435
{
@@ -37,7 +38,7 @@ MSTD_CONSTEXPR_FN_14 PinMap get_pwm_pinmap(const PinName pin)
3738
return {pin, pinmap.peripheral, pinmap.function};
3839
}
3940
}
40-
return {NC, NC, NC};
41+
return {NC, (int) NC, (int) NC};
4142
}
4243
#endif // DEVICE_PWMOUT
4344

@@ -49,7 +50,7 @@ MSTD_CONSTEXPR_FN_14 PinMap get_analogin_pinmap(const PinName pin)
4950
return {pin, pinmap.peripheral, pinmap.function};
5051
}
5152
}
52-
return {NC, NC, NC};
53+
return {NC, (int) NC, (int) NC};
5354
}
5455
#endif // DEVICE_ANALOGIN
5556

@@ -61,7 +62,7 @@ MSTD_CONSTEXPR_FN_14 PinMap get_analogout_pinmap(const PinName pin)
6162
return {pin, pinmap.peripheral, pinmap.function};
6263
}
6364
}
64-
return {NC, NC, NC};
65+
return {NC, (int) NC, (int) NC};
6566
}
6667
#endif // DEVICE_ANALOGOUT
6768

@@ -85,7 +86,7 @@ MSTD_CONSTEXPR_FN_14 i2c_pinmap_t get_i2c_pinmap(const PinName sda, const PinNam
8586
}
8687

8788
if (!sda_map || !scl_map || sda_map->peripheral != scl_map->peripheral) {
88-
return {NC, NC, NC, NC, NC};
89+
return {(int) NC, NC, (int) NC, NC, (int) NC};
8990
}
9091

9192
return {sda_map->peripheral, sda_map->pin, sda_map->function, scl_map->pin, scl_map->function};
@@ -112,7 +113,7 @@ MSTD_CONSTEXPR_FN_14 serial_pinmap_t get_uart_pinmap(const PinName tx, const Pin
112113
}
113114

114115
if (!tx_map || !rx_map || rx_map->peripheral != tx_map->peripheral) {
115-
return {NC, NC, NC, NC, NC, false};
116+
return {(int) NC, NC, (int) NC, NC, (int) NC, false};
116117
}
117118

118119
if (tx_map->pin == STDIO_UART_TX && rx_map->pin == STDIO_UART_RX) {
@@ -142,7 +143,7 @@ MSTD_CONSTEXPR_FN_14 serial_fc_pinmap_t get_uart_fc_pinmap(const PinName rxflow,
142143
}
143144

144145
if ((!rts_map || !cts_map) || (rts_map->peripheral != cts_map->peripheral)) {
145-
return {NC, NC, NC, NC, NC};
146+
return {(int) NC, NC, (int) NC, NC, (int) NC};
146147
}
147148

148149
return {cts_map->peripheral, cts_map->pin, cts_map->function, rts_map->pin, rts_map->function};
@@ -188,7 +189,7 @@ MSTD_CONSTEXPR_FN_14 spi_pinmap_t get_spi_pinmap(const PinName mosi, const PinNa
188189
if ((!mosi_map || !miso_map || !sclk_map || !ssel_map) ||
189190
(mosi_map->peripheral != miso_map->peripheral || mosi_map->peripheral != sclk_map->peripheral) ||
190191
(ssel_map->pin != NC && mosi_map->peripheral != ssel_map->peripheral)) {
191-
return {NC, NC, NC, NC, NC, NC, NC, NC, NC};
192+
return {(int) NC, NC, (int) NC, NC, (int) NC, NC, (int) NC, NC, (int) NC};
192193
}
193194

194195
return {mosi_map->peripheral, mosi_map->pin, mosi_map->function, miso_map->pin, miso_map->function, sclk_map->pin, sclk_map->function, ssel_map->pin, ssel_map->function};
@@ -200,49 +201,49 @@ MSTD_CONSTEXPR_FN_14 spi_pinmap_t get_spi_pinmap(const PinName mosi, const PinNa
200201
#if DEVICE_PWMOUT
201202
MSTD_CONSTEXPR_FN_14 PinMap get_pwm_pinmap(const PinName pin)
202203
{
203-
return {pin, NC, NC};
204+
return {pin, (int) NC, (int) NC};
204205
}
205206
#endif // DEVICE_PWMOUT
206207

207208
#if DEVICE_ANALOGIN
208209
MSTD_CONSTEXPR_FN_14 PinMap get_analogin_pinmap(const PinName pin)
209210
{
210-
return {pin, NC, NC};
211+
return {pin, (int) NC, (int) NC};
211212
}
212213
#endif // DEVICE_ANALOGIN
213214

214215
#if DEVICE_ANALOGOUT
215216
MSTD_CONSTEXPR_FN_14 PinMap get_analogout_pinmap(const PinName pin)
216217
{
217-
return {pin, NC, NC};
218+
return {pin, (int) NC, (int) NC};
218219
}
219220
#endif // DEVICE_ANALOGOUT
220221

221222
#if DEVICE_I2C
222223
MSTD_CONSTEXPR_FN_14 i2c_pinmap_t get_i2c_pinmap(const PinName sda, const PinName scl)
223224
{
224-
return {NC, sda, NC, scl, NC};
225+
return {(int) NC, sda, (int) NC, scl, (int) NC};
225226
}
226227
#endif //DEVICE_I2C
227228

228229
#if DEVICE_SERIAL
229230
MSTD_CONSTEXPR_FN_14 serial_pinmap_t get_uart_pinmap(const PinName tx, const PinName rx)
230231
{
231-
return {NC, tx, NC, rx, NC, false};
232+
return {(int) NC, tx, (int) NC, rx, (int) NC, false};
232233
}
233234

234235
#if DEVICE_SERIAL_FC
235236
MSTD_CONSTEXPR_FN_14 serial_fc_pinmap_t get_uart_fc_pinmap(const PinName rxflow, const PinName txflow)
236237
{
237-
return {NC, txflow, NC, rxflow, NC};
238+
return {(int) NC, txflow, (int) NC, rxflow, (int) NC};
238239
}
239240
#endif // DEVICE_SERIAL_FC
240241
#endif // DEVICE_SERIAL
241242

242243
#if DEVICE_SPI
243244
MSTD_CONSTEXPR_FN_14 spi_pinmap_t get_spi_pinmap(const PinName mosi, const PinName miso, const PinName sclk, const PinName ssel)
244245
{
245-
return {NC, mosi, NC, miso, NC, sclk, NC, ssel, NC};
246+
return {(int) NC, mosi, (int) NC, miso, (int) NC, sclk, (int) NC, ssel, (int) NC};
246247
}
247248
#endif // DEVICE_SERIAL
248249

platform/source/mbed_retarget.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,13 @@ DirectSerial::DirectSerial(PinName tx, PinName rx, int baud)
175175

176176
#if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
177177
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, NC);
178-
serial_set_flow_control_direct(&stdio_uart, FlowControlRTS, fc_pinmap);
178+
serial_set_flow_control_direct(&stdio_uart, FlowControlRTS, &fc_pinmap);
179179
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_CTS
180180
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(NC, STDIO_UART_CTS);
181-
serial_set_flow_control_direct(&stdio_uart, FlowControlCTS, fc_pinmap);
181+
serial_set_flow_control_direct(&stdio_uart, FlowControlCTS, &fc_pinmap);
182182
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTSCTS
183183
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, STDIO_UART_CTS);
184-
serial_set_flow_control_direct(&stdio_uart, FlowControlRTSCTS, fc_pinmap);
184+
serial_set_flow_control_direct(&stdio_uart, FlowControlRTSCTS, &fc_pinmap);
185185
#endif
186186
}
187187

@@ -195,13 +195,13 @@ DirectSerial::DirectSerial(const serial_pinmap_t &explicit_pinmap, int baud)
195195

196196
#if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
197197
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, NC);
198-
serial_set_flow_control_direct(&stdio_uart, FlowControlRTS, fc_pinmap);
198+
serial_set_flow_control_direct(&stdio_uart, FlowControlRTS, &fc_pinmap);
199199
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_CTS
200200
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(NC, STDIO_UART_CTS);
201-
serial_set_flow_control_direct(&stdio_uart, FlowControlCTS, fc_pinmap);
201+
serial_set_flow_control_direct(&stdio_uart, FlowControlCTS, &fc_pinmap);
202202
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTSCTS
203203
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, STDIO_UART_CTS);
204-
serial_set_flow_control_direct(&stdio_uart, FlowControlRTSCTS, fc_pinmap);
204+
serial_set_flow_control_direct(&stdio_uart, FlowControlRTSCTS, &fc_pinmap);
205205
#endif
206206
}
207207

targets/TARGET_ONSEMI/TARGET_NCS36510/objects.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ extern "C" {
4040
#include "PortNames.h"
4141
#include "PeripheralNames.h"
4242
#include "target_config.h"
43-
#include "spi.h"
4443

4544
typedef enum {
4645
FlowControlNone_1,

targets/TARGET_STM/i2c_api.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,10 @@ void i2c_init_internal(i2c_t *obj, const i2c_pinmap_t *pinmap)
279279
if (pinmap != NULL) {
280280
obj_s->sda = pinmap->sda_pin;
281281
obj_s->scl = pinmap->scl_pin;
282+
#if EXPLICIT_PINMAP_READY
282283
obj_s->sda_func = pinmap->sda_function;
283284
obj_s->scl_func = pinmap->scl_function;
284-
285+
#endif
285286
obj_s->i2c = (I2CName)pinmap->peripheral;
286287
MBED_ASSERT(obj_s->i2c != (I2CName)NC);
287288
}
@@ -334,8 +335,13 @@ void i2c_init_internal(i2c_t *obj, const i2c_pinmap_t *pinmap)
334335
#endif
335336

336337
// Configure I2C pins
338+
#if EXPLICIT_PINMAP_READY
337339
pin_function(obj_s->sda, obj_s->sda_func);
338340
pin_function(obj_s->scl, obj_s->scl_func);
341+
#else
342+
pinmap_pinout(obj_s->sda, PinMap_I2C_SDA);
343+
pinmap_pinout(obj_s->scl, PinMap_I2C_SCL);
344+
#endif
339345
pin_mode(obj_s->sda, OpenDrainNoPull);
340346
pin_mode(obj_s->scl, OpenDrainNoPull);
341347

@@ -364,7 +370,13 @@ void i2c_init_internal(i2c_t *obj, const i2c_pinmap_t *pinmap)
364370
#endif
365371
}
366372

373+
#if EXPLICIT_PINMAP_READY
374+
#define I2C_INIT_DIRECT i2c_init_direct
367375
void i2c_init_direct(i2c_t *obj, const i2c_pinmap_t *pinmap)
376+
#else
377+
#define I2C_INIT_DIRECT _i2c_init_direct
378+
static void _i2c_init_direct(i2c_t *obj, const i2c_pinmap_t *pinmap)
379+
#endif
368380
{
369381
memset(obj, 0, sizeof(*obj));
370382
i2c_init_internal(obj, pinmap);
@@ -382,7 +394,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
382394

383395
const i2c_pinmap_t explicit_i2c_pinmap = {peripheral, sda, sda_function, scl, scl_function};
384396

385-
i2c_init_direct(obj, &explicit_i2c_pinmap);
397+
I2C_INIT_DIRECT(obj, &explicit_i2c_pinmap);
386398
}
387399

388400

0 commit comments

Comments
 (0)