|
24 | 24 | #include "analogout_api.h"
|
25 | 25 | #include "i2c_api.h"
|
26 | 26 | #include "serial_api.h"
|
| 27 | +#include "qspi_api.h" |
| 28 | +#include "can_api.h" |
27 | 29 | #include <mstd_cstddef>
|
28 | 30 |
|
29 | 31 | #if EXPLICIT_PINMAP_READY
|
@@ -196,6 +198,92 @@ MSTD_CONSTEXPR_FN_14 spi_pinmap_t get_spi_pinmap(const PinName mosi, const PinNa
|
196 | 198 | }
|
197 | 199 | #endif // DEVICE_SPI
|
198 | 200 |
|
| 201 | +#if DEVICE_CAN |
| 202 | +MSTD_CONSTEXPR_FN_14 can_pinmap_t get_can_pinmap(const PinName rd, const PinName td) |
| 203 | +{ |
| 204 | + const PinMap *rd_map = nullptr; |
| 205 | + for (const PinMap &pinmap : PINMAP_CAN_RD) { |
| 206 | + if (pinmap.pin == rd) { |
| 207 | + rd_map = &pinmap; |
| 208 | + break; |
| 209 | + } |
| 210 | + } |
| 211 | + |
| 212 | + const PinMap *td_map = nullptr; |
| 213 | + for (const PinMap &pinmap : PINMAP_CAN_TD) { |
| 214 | + if (pinmap.pin == td) { |
| 215 | + td_map = &pinmap; |
| 216 | + break; |
| 217 | + } |
| 218 | + } |
| 219 | + |
| 220 | + if (!rd_map || !td_map || rd_map->peripheral != td_map->peripheral) { |
| 221 | + return {(int) NC, NC, (int) NC, NC, (int) NC}; |
| 222 | + } |
| 223 | + |
| 224 | + return {rd_map->peripheral, rd_map->pin, rd_map->function, td_map->pin, td_map->function}; |
| 225 | +} |
| 226 | +#endif //DEVICE_CAN |
| 227 | + |
| 228 | +#if DEVICE_QSPI |
| 229 | +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) |
| 230 | +{ |
| 231 | + const PinMap *data0_map = nullptr; |
| 232 | + for (const PinMap &pinmap : PINMAP_QSPI_DATA0) { |
| 233 | + if (pinmap.pin == data0) { |
| 234 | + data0_map = &pinmap; |
| 235 | + break; |
| 236 | + } |
| 237 | + } |
| 238 | + |
| 239 | + const PinMap *data1_map = nullptr; |
| 240 | + for (const PinMap &pinmap : PINMAP_QSPI_DATA1) { |
| 241 | + if (pinmap.pin == data1) { |
| 242 | + data1_map = &pinmap; |
| 243 | + break; |
| 244 | + } |
| 245 | + } |
| 246 | + |
| 247 | + const PinMap *data2_map = nullptr; |
| 248 | + for (const PinMap &pinmap : PINMAP_QSPI_DATA2) { |
| 249 | + if (pinmap.pin == data2) { |
| 250 | + data2_map = &pinmap; |
| 251 | + break; |
| 252 | + } |
| 253 | + } |
| 254 | + |
| 255 | + const PinMap *data3_map = nullptr; |
| 256 | + for (const PinMap &pinmap : PINMAP_QSPI_DATA3) { |
| 257 | + if (pinmap.pin == data3) { |
| 258 | + data3_map = &pinmap; |
| 259 | + break; |
| 260 | + } |
| 261 | + } |
| 262 | + |
| 263 | + const PinMap *sclk_map = nullptr; |
| 264 | + for (const PinMap &pinmap : PINMAP_QSPI_SCLK) { |
| 265 | + if (pinmap.pin == sclk) { |
| 266 | + sclk_map = &pinmap; |
| 267 | + break; |
| 268 | + } |
| 269 | + } |
| 270 | + |
| 271 | + const PinMap *ssel_map = nullptr; |
| 272 | + for (const PinMap &pinmap : PINMAP_QSPI_SSEL) { |
| 273 | + if (pinmap.pin == ssel) { |
| 274 | + ssel_map = &pinmap; |
| 275 | + break; |
| 276 | + } |
| 277 | + } |
| 278 | + |
| 279 | + 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) { |
| 280 | + return {(int) NC, NC, (int) NC, NC, (int) NC, NC, (int) NC, NC, (int) NC}; |
| 281 | + } |
| 282 | + |
| 283 | + 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}; |
| 284 | +} |
| 285 | +#endif //DEVICE_QSPI |
| 286 | + |
199 | 287 | #else // EXPLICIT_PINMAP_READY
|
200 | 288 |
|
201 | 289 | #if DEVICE_PWMOUT
|
@@ -247,6 +335,20 @@ MSTD_CONSTEXPR_FN_14 spi_pinmap_t get_spi_pinmap(const PinName mosi, const PinNa
|
247 | 335 | }
|
248 | 336 | #endif // DEVICE_SERIAL
|
249 | 337 |
|
| 338 | +#if DEVICE_CAN |
| 339 | +MSTD_CONSTEXPR_FN_14 can_pinmap_t get_can_pinmap(const PinName rd, const PinName td) |
| 340 | +{ |
| 341 | + return {(int) NC, rd, (int) NC, td, (int) NC}; |
| 342 | +} |
| 343 | +#endif //DEVICE_CAN |
| 344 | + |
| 345 | +#if DEVICE_QSPI |
| 346 | +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) |
| 347 | +{ |
| 348 | + return {(int) NC, data0, (int) NC, data1, (int) NC, data2, (int) NC, data3, (int) NC, sclk, (int) NC, ssel, (int) NC}; |
| 349 | +} |
| 350 | +#endif //DEVICE_QSPI |
| 351 | + |
250 | 352 | #endif // EXPLICIT_PINMAP_READY
|
251 | 353 |
|
252 | 354 | #endif // EXPLICIT_PINMAP_H
|
0 commit comments