17 #ifndef STATIC_PINMAP_H 18 #define STATIC_PINMAP_H 22 #include "pwmout_api.h" 23 #include "analogin_api.h" 24 #include "analogout_api.h" 26 #include "serial_api.h" 30 #include <mstd_cstddef> 32 #if STATIC_PINMAP_READY 33 #include "PeripheralPinMaps.h" 36 #if defined(DEVICE_PWMOUT) && defined(PINMAP_PWM) 37 MSTD_CONSTEXPR_FN_14
PinMap get_pwm_pinmap(
const PinName pin)
39 for (
const PinMap &pinmap : PINMAP_PWM) {
40 if (pinmap.pin == pin) {
41 return {pin, pinmap.peripheral, pinmap.function};
44 return {NC, (int) NC, (
int) NC};
46 #endif // DEVICE_PWMOUT 48 #if defined(DEVICE_ANALOGIN) && defined(PINMAP_ANALOGIN) 49 MSTD_CONSTEXPR_FN_14
PinMap get_analogin_pinmap(
const PinName pin)
51 for (
const PinMap &pinmap : PINMAP_ANALOGIN) {
52 if (pinmap.pin == pin) {
53 return {pin, pinmap.peripheral, pinmap.function};
57 #if PINMAP_ANALOGIN_INTERNAL 58 for (
const PinMap &pinmap : PINMAP_ANALOGIN_INTERNAL) {
59 if (pinmap.pin == pin) {
60 return {pin, pinmap.peripheral, pinmap.function};
65 return {NC, (int) NC, (
int) NC};
67 #endif // DEVICE_ANALOGIN 69 #if defined(DEVICE_ANALOGOUT) && defined(PINMAP_ANALOGOUT) 70 MSTD_CONSTEXPR_FN_14
PinMap get_analogout_pinmap(
const PinName pin)
72 for (
const PinMap &pinmap : PINMAP_ANALOGOUT) {
73 if (pinmap.pin == pin) {
74 return {pin, pinmap.peripheral, pinmap.function};
77 return {NC, (int) NC, (
int) NC};
79 #endif // DEVICE_ANALOGOUT 81 #if defined(DEVICE_I2C) && defined(PINMAP_I2C_SDA) && defined(PINMAP_I2C_SCL) 82 MSTD_CONSTEXPR_FN_14
i2c_pinmap_t get_i2c_pinmap(
const PinName sda,
const PinName scl)
84 const PinMap *sda_map =
nullptr;
85 for (
const PinMap &pinmap : PINMAP_I2C_SDA) {
86 if (pinmap.pin == sda) {
92 const PinMap *scl_map =
nullptr;
93 for (
const PinMap &pinmap : PINMAP_I2C_SCL) {
94 if (pinmap.pin == scl) {
100 if (!sda_map || !scl_map || sda_map->peripheral != scl_map->peripheral) {
101 return {(int) NC, NC, (
int) NC, NC, (int) NC};
104 return {sda_map->peripheral, sda_map->pin, sda_map->function, scl_map->pin, scl_map->function};
108 #if defined(DEVICE_SERIAL) && defined(PINMAP_UART_TX) && defined(PINMAP_UART_RX) 109 MSTD_CONSTEXPR_FN_14
serial_pinmap_t get_uart_pinmap(
const PinName tx,
const PinName rx)
111 const PinMap *tx_map =
nullptr;
112 for (
const PinMap &pinmap : PINMAP_UART_TX) {
113 if (pinmap.pin == tx) {
119 const PinMap *rx_map =
nullptr;
120 for (
const PinMap &pinmap : PINMAP_UART_RX) {
121 if (pinmap.pin == rx) {
127 if (!tx_map || !rx_map || rx_map->peripheral != tx_map->peripheral) {
128 return {(int) NC, NC, (
int) NC, NC, (int) NC,
false};
131 if (tx_map->pin == STDIO_UART_TX && rx_map->pin == STDIO_UART_RX) {
132 return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function,
true};
134 return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function,
false};
138 #if defined(DEVICE_SERIAL_FC) && defined(PINMAP_UART_RTS) && defined(PINMAP_UART_CTS) 139 MSTD_CONSTEXPR_FN_14
serial_fc_pinmap_t get_uart_fc_pinmap(
const PinName rxflow,
const PinName txflow)
141 const PinMap *rts_map =
nullptr;
142 for (
const PinMap &pinmap : PINMAP_UART_RTS) {
143 if (pinmap.pin == rxflow) {
149 const PinMap *cts_map =
nullptr;
150 for (
const PinMap &pinmap : PINMAP_UART_CTS) {
151 if (pinmap.pin == txflow) {
157 if ((!rts_map || !cts_map) || (rts_map->peripheral != cts_map->peripheral)) {
158 return {(int) NC, NC, (
int) NC, NC, (int) NC};
161 return {cts_map->peripheral, cts_map->pin, cts_map->function, rts_map->pin, rts_map->function};
163 #endif // DEVICE_SERIAL_FC 164 #endif // DEVICE_SERIAL 166 #if defined(DEVICE_SPI) && defined(PINMAP_SPI_MOSI) && defined(PINMAP_SPI_MISO) && defined(PINMAP_SPI_SCLK) && defined(PINMAP_SPI_SSEL) 167 MSTD_CONSTEXPR_FN_14
spi_pinmap_t get_spi_pinmap(
const PinName mosi,
const PinName miso,
const PinName sclk,
const PinName ssel)
169 const PinMap *mosi_map =
nullptr;
170 for (
const PinMap &pinmap : PINMAP_SPI_MOSI) {
171 if (pinmap.pin == mosi) {
177 const PinMap *miso_map =
nullptr;
178 for (
const PinMap &pinmap : PINMAP_SPI_MISO) {
179 if (pinmap.pin == miso) {
185 const PinMap *sclk_map =
nullptr;
186 for (
const PinMap &pinmap : PINMAP_SPI_SCLK) {
187 if (pinmap.pin == sclk) {
193 const PinMap *ssel_map =
nullptr;
194 for (
const PinMap &pinmap : PINMAP_SPI_SSEL) {
195 if (pinmap.pin == ssel) {
201 if ((!mosi_map || !miso_map || !sclk_map || !ssel_map) ||
202 (mosi_map->peripheral != miso_map->peripheral || mosi_map->peripheral != sclk_map->peripheral) ||
203 (ssel_map->pin != NC && mosi_map->peripheral != ssel_map->peripheral)) {
204 return {(int) NC, NC, (
int) NC, NC, (int) NC, NC, (
int) NC, NC, (int) NC};
207 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};
211 #if defined(DEVICE_CAN) && defined(PINMAP_CAN_RD) && defined(PINMAP_CAN_TD) 212 MSTD_CONSTEXPR_FN_14
can_pinmap_t get_can_pinmap(
const PinName rd,
const PinName td)
214 const PinMap *rd_map =
nullptr;
215 for (
const PinMap &pinmap : PINMAP_CAN_RD) {
216 if (pinmap.pin == rd) {
222 const PinMap *td_map =
nullptr;
223 for (
const PinMap &pinmap : PINMAP_CAN_TD) {
224 if (pinmap.pin == td) {
230 if (!rd_map || !td_map || rd_map->peripheral != td_map->peripheral) {
231 return {(int) NC, NC, (
int) NC, NC, (int) NC};
234 return {rd_map->peripheral, rd_map->pin, rd_map->function, td_map->pin, td_map->function};
238 #if defined(DEVICE_QSPI) && defined(PINMAP_QSPI_DATA0) && defined(PINMAP_QSPI_DATA1) && defined(PINMAP_QSPI_DATA2) && defined(PINMAP_QSPI_DATA3) && defined(PINMAP_QSPI_SCLK) && defined(PINMAP_QSPI_SSEL) 239 MSTD_CONSTEXPR_FN_14
qspi_pinmap_t get_qspi_pinmap(
const PinName data0,
const PinName data1,
const PinName data2,
const PinName data3,
const PinName sclk,
const PinName ssel)
241 const PinMap *data0_map =
nullptr;
242 for (
const PinMap &pinmap : PINMAP_QSPI_DATA0) {
243 if (pinmap.pin == data0) {
249 const PinMap *data1_map =
nullptr;
250 for (
const PinMap &pinmap : PINMAP_QSPI_DATA1) {
251 if (pinmap.pin == data1) {
257 const PinMap *data2_map =
nullptr;
258 for (
const PinMap &pinmap : PINMAP_QSPI_DATA2) {
259 if (pinmap.pin == data2) {
265 const PinMap *data3_map =
nullptr;
266 for (
const PinMap &pinmap : PINMAP_QSPI_DATA3) {
267 if (pinmap.pin == data3) {
273 const PinMap *sclk_map =
nullptr;
274 for (
const PinMap &pinmap : PINMAP_QSPI_SCLK) {
275 if (pinmap.pin == sclk) {
281 const PinMap *ssel_map =
nullptr;
282 for (
const PinMap &pinmap : PINMAP_QSPI_SSEL) {
283 if (pinmap.pin == ssel) {
289 if (!data0_map || !data1_map || !data2_map || !data3_map || !sclk_map || !ssel_map || data0_map->peripheral != data1_map->peripheral || data0_map->peripheral != data2_map->peripheral || data0_map->peripheral != data3_map->peripheral || data0_map->peripheral != sclk_map->peripheral || data0_map->peripheral != ssel_map->peripheral) {
290 return {(int) NC, NC, (
int) NC, NC, (int) NC, NC, (
int) NC, NC, (int) NC};
293 return {data0_map->peripheral, data0_map->pin, data0_map->function, data1_map->pin, data1_map->function, data2_map->pin, data2_map->function, data3_map->pin, data3_map->function, sclk_map->pin, sclk_map->function, ssel_map->pin, ssel_map->function};
297 #if defined(DEVICE_OSPI) && defined(PINMAP_OSPI_DATA0) && defined(PINMAP_OSPI_DATA1) && defined(PINMAP_OSPI_DATA2) && defined(PINMAP_OSPI_DATA3) && defined(PINMAP_OSPI_DATA4) && defined(PINMAP_OSPI_DATA5) && defined(PINMAP_OSPI_DATA6) && defined(PINMAP_OSPI_DATA7) && defined(PINMAP_OSPI_SCLK) && defined(PINMAP_OSPI_SSEL) && defined(PINMAP_OSPI_DQS) 298 MSTD_CONSTEXPR_FN_14 ospi_pinmap_t get_ospi_pinmap(
const PinName data0,
const PinName data1,
const PinName data2,
const PinName data3,
const PinName data4,
const PinName data5,
const PinName data6,
const PinName data7,
const PinName sclk,
const PinName ssel,
const PinName dqs)
300 const PinMap *data0_map =
nullptr;
301 for (
const PinMap &pinmap : PINMAP_OSPI_DATA0) {
302 if (pinmap.pin == data0) {
308 const PinMap *data1_map =
nullptr;
309 for (
const PinMap &pinmap : PINMAP_OSPI_DATA1) {
310 if (pinmap.pin == data1) {
316 const PinMap *data2_map =
nullptr;
317 for (
const PinMap &pinmap : PINMAP_OSPI_DATA2) {
318 if (pinmap.pin == data2) {
324 const PinMap *data3_map =
nullptr;
325 for (
const PinMap &pinmap : PINMAP_OSPI_DATA3) {
326 if (pinmap.pin == data3) {
332 const PinMap *data4_map =
nullptr;
333 for (
const PinMap &pinmap : PINMAP_OSPI_DATA4) {
334 if (pinmap.pin == data4) {
340 const PinMap *data5_map =
nullptr;
341 for (
const PinMap &pinmap : PINMAP_OSPI_DATA5) {
342 if (pinmap.pin == data5) {
348 const PinMap *data6_map =
nullptr;
349 for (
const PinMap &pinmap : PINMAP_OSPI_DATA6) {
350 if (pinmap.pin == data6) {
356 const PinMap *data7_map =
nullptr;
357 for (
const PinMap &pinmap : PINMAP_OSPI_DATA7) {
358 if (pinmap.pin == data7) {
364 const PinMap *sclk_map =
nullptr;
365 for (
const PinMap &pinmap : PINMAP_OSPI_SCLK) {
366 if (pinmap.pin == sclk) {
372 const PinMap *ssel_map =
nullptr;
373 for (
const PinMap &pinmap : PINMAP_OSPI_SSEL) {
374 if (pinmap.pin == ssel) {
380 const PinMap *dqs_map =
nullptr;
381 for (
const PinMap &pinmap : PINMAP_OSPI_DQS) {
382 if (pinmap.pin == dqs) {
389 if (!data0_map || !data1_map || !data2_map || !data3_map || !data4_map || !data5_map || !data6_map || !data7_map || !sclk_map || !ssel_map || !dqs_map || data0_map->peripheral != data1_map->peripheral || data0_map->peripheral != data2_map->peripheral || data0_map->peripheral != data3_map->peripheral || data0_map->peripheral != data4_map->peripheral || data0_map->peripheral != data5_map->peripheral || data0_map->peripheral != data6_map->peripheral || data0_map->peripheral != data7_map->peripheral || data0_map->peripheral != sclk_map->peripheral || data0_map->peripheral != ssel_map->peripheral || data0_map->peripheral != dqs_map->peripheral) {
390 return {(int) NC, NC, (
int) NC, NC, (int) NC, NC, (
int) NC, NC, (int) NC, NC, (
int) NC, NC, (int) NC, NC, (
int) NC, NC, (int) NC};
393 return {data0_map->peripheral, data0_map->pin, data0_map->function, data1_map->pin, data1_map->function, data2_map->pin, data2_map->function, data3_map->pin, data3_map->function, data4_map->pin, data4_map->function, data5_map->pin, data5_map->function, data6_map->pin, data6_map->function, data7_map->pin, data7_map->function, sclk_map->pin, sclk_map->function, ssel_map->pin, ssel_map->function, dqs_map->pin, dqs_map->function};
397 #else // STATIC_PINMAP_READY 400 MSTD_CONSTEXPR_FN_14
PinMap get_pwm_pinmap(
const PinName pin)
402 return {pin, (int) NC, (
int) NC};
404 #endif // DEVICE_PWMOUT 407 MSTD_CONSTEXPR_FN_14
PinMap get_analogin_pinmap(
const PinName pin)
409 return {pin, (int) NC, (
int) NC};
411 #endif // DEVICE_ANALOGIN 414 MSTD_CONSTEXPR_FN_14
PinMap get_analogout_pinmap(
const PinName pin)
416 return {pin, (int) NC, (
int) NC};
418 #endif // DEVICE_ANALOGOUT 421 MSTD_CONSTEXPR_FN_14
i2c_pinmap_t get_i2c_pinmap(
const PinName sda,
const PinName scl)
423 return {(int) NC, sda, (
int) NC, scl, (int) NC};
428 MSTD_CONSTEXPR_FN_14
serial_pinmap_t get_uart_pinmap(
const PinName tx,
const PinName rx)
430 return {(int) NC, tx, (
int) NC, rx, (int) NC,
false};
434 MSTD_CONSTEXPR_FN_14
serial_fc_pinmap_t get_uart_fc_pinmap(
const PinName rxflow,
const PinName txflow)
436 return {(int) NC, txflow, (
int) NC, rxflow, (int) NC};
438 #endif // DEVICE_SERIAL_FC 439 #endif // DEVICE_SERIAL 442 MSTD_CONSTEXPR_FN_14
spi_pinmap_t get_spi_pinmap(
const PinName mosi,
const PinName miso,
const PinName sclk,
const PinName ssel)
444 return {(int) NC, mosi, (
int) NC, miso, (int) NC, sclk, (
int) NC, ssel, (int) NC};
446 #endif // DEVICE_SERIAL 449 MSTD_CONSTEXPR_FN_14
can_pinmap_t get_can_pinmap(
const PinName rd,
const PinName td)
451 return {(int) NC, rd, (
int) NC, td, (int) NC};
456 MSTD_CONSTEXPR_FN_14
qspi_pinmap_t get_qspi_pinmap(
const PinName data0,
const PinName data1,
const PinName data2,
const PinName data3,
const PinName sclk,
const PinName ssel)
458 return {(int) NC, data0, (
int) NC, data1, (int) NC, data2, (
int) NC, data3, (int) NC, sclk, (
int) NC, ssel, (int) NC};
463 MSTD_CONSTEXPR_FN_14 ospi_pinmap_t get_ospi_pinmap(
const PinName data0,
const PinName data1,
const PinName data2,
const PinName data3,
const PinName data4,
const PinName data5,
const PinName data6,
const PinName data7,
const PinName sclk,
const PinName ssel,
const PinName dqs)
465 return {(int) NC, data0, (
int) NC, data1, (int) NC, data2, (
int) NC, data3, (int) NC, data4, (
int) NC, data5, (int) NC, data6, (
int) NC, data7, (int) NC, sclk, (
int) NC, ssel, (int) NC, dqs, (
int) NC};
469 #endif // STATIC_PINMAP_READY 471 #endif // STATIC_PINMAP_H