Skip to content

Commit 7e8695a

Browse files
committed
Add HAL API for can pinmap
Add the functions can_rd_pinmap and can_td_pinmap to all targets.
1 parent 3bd3aca commit 7e8695a

File tree

14 files changed

+150
-1
lines changed

14 files changed

+150
-1
lines changed

hal/can_api.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define MBED_CAN_API_H
2222

2323
#include "device.h"
24+
#include "pinmap.h"
2425

2526
#if DEVICE_CAN
2627

@@ -76,6 +77,24 @@ unsigned char can_rderror(can_t *obj);
7677
unsigned char can_tderror(can_t *obj);
7778
void can_monitor(can_t *obj, int silent);
7879

80+
/** Get the pins that support CAN RD
81+
*
82+
* Return a PinMap array of pins that support CAN RD. The
83+
* array is terminated with {NC, NC, 0}.
84+
*
85+
* @return PinMap array
86+
*/
87+
const PinMap *can_rd_pinmap(void);
88+
89+
/** Get the pins that support CAN TD
90+
*
91+
* Return a PinMap array of pins that support CAN TD. The
92+
* array is terminated with {NC, NC, 0}.
93+
*
94+
* @return PinMap array
95+
*/
96+
const PinMap *can_td_pinmap(void);
97+
7998
#ifdef __cplusplus
8099
};
81100
#endif

targets/TARGET_GigaDevice/TARGET_GD32E10X/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,14 @@ void can_monitor(can_t *obj, int silent)
630630
}
631631
}
632632

633+
const PinMap *can_rd_pinmap()
634+
{
635+
return PinMap_CAN_TD;
636+
}
637+
638+
const PinMap *can_td_pinmap()
639+
{
640+
return PinMap_CAN_RD;
641+
}
642+
633643
#endif

targets/TARGET_GigaDevice/TARGET_GD32F30X/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,4 +629,14 @@ int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t
629629
return handle;
630630
}
631631

632+
const PinMap *can_rd_pinmap()
633+
{
634+
return PinMap_CAN_TD;
635+
}
636+
637+
const PinMap *can_td_pinmap()
638+
{
639+
return PinMap_CAN_RD;
640+
}
641+
632642
#endif

targets/TARGET_GigaDevice/TARGET_GD32F4XX/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,4 +628,14 @@ int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t
628628
return handle;
629629
}
630630

631+
const PinMap *can_rd_pinmap()
632+
{
633+
return PinMap_CAN_TD;
634+
}
635+
636+
const PinMap *can_td_pinmap()
637+
{
638+
return PinMap_CAN_RD;
639+
}
640+
631641
#endif

targets/TARGET_NUVOTON/TARGET_M451/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,5 +308,15 @@ void can_monitor(can_t *obj, int silent)
308308
{
309309
CAN_EnterTestMode((CAN_T *)NU_MODBASE(obj->can), CAN_TEST_SILENT_Msk);
310310
}
311+
312+
const PinMap *can_rd_pinmap()
313+
{
314+
return PinMap_CAN_TD;
315+
}
316+
317+
const PinMap *can_td_pinmap()
318+
{
319+
return PinMap_CAN_RD;
320+
}
311321

312322
#endif // DEVICE_CAN

targets/TARGET_NUVOTON/TARGET_M480/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,4 +352,14 @@ void can_monitor(can_t *obj, int silent)
352352
CAN_EnterTestMode((CAN_T *)NU_MODBASE(obj->can), CAN_TEST_SILENT_Msk);
353353
}
354354

355+
const PinMap *can_rd_pinmap()
356+
{
357+
return PinMap_CAN_TD;
358+
}
359+
360+
const PinMap *can_td_pinmap()
361+
{
362+
return PinMap_CAN_RD;
363+
}
364+
355365
#endif // DEVICE_CAN

targets/TARGET_NUVOTON/TARGET_NUC472/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,5 +356,15 @@ void can_monitor(can_t *obj, int silent)
356356
{
357357
CAN_EnterTestMode((CAN_T *)NU_MODBASE(obj->can), CAN_TEST_SILENT_Msk);
358358
}
359+
360+
const PinMap *can_rd_pinmap()
361+
{
362+
return PinMap_CAN_TD;
363+
}
364+
365+
const PinMap *can_td_pinmap()
366+
{
367+
return PinMap_CAN_RD;
368+
}
359369

360370
#endif // DEVICE_CAN

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,3 +461,13 @@ void can_monitor(can_t *obj, int silent) {
461461
LPC_CAN->CNTL |= CANCNTL_INIT;
462462
}
463463
}
464+
465+
const PinMap *can_rd_pinmap()
466+
{
467+
return PinMap_CAN_TD;
468+
}
469+
470+
const PinMap *can_td_pinmap()
471+
{
472+
return PinMap_CAN_RD;
473+
}

targets/TARGET_NXP/TARGET_LPC15XX/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,3 +626,13 @@ void can_monitor(can_t *obj, int silent) {
626626
LPC_C_CAN0->CANCNTL |= (1UL << 0);
627627
}
628628
}
629+
630+
const PinMap *can_rd_pinmap()
631+
{
632+
return PinMap_CAN_TD;
633+
}
634+
635+
const PinMap *can_td_pinmap()
636+
{
637+
return PinMap_CAN_RD;
638+
}

targets/TARGET_NXP/TARGET_LPC176X/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,13 @@ void can_monitor(can_t *obj, int silent) {
452452
can_enable(obj);
453453
}
454454
}
455+
456+
const PinMap *can_rd_pinmap()
457+
{
458+
return PinMap_CAN_TD;
459+
}
460+
461+
const PinMap *can_td_pinmap()
462+
{
463+
return PinMap_CAN_RD;
464+
}

targets/TARGET_NXP/TARGET_LPC408X/TARGET_LPC4088/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,13 @@ void can_monitor(can_t *obj, int silent) {
393393
can_enable(obj);
394394
}
395395
}
396+
397+
const PinMap *can_rd_pinmap()
398+
{
399+
return PinMap_CAN_TD;
400+
}
401+
402+
const PinMap *can_td_pinmap()
403+
{
404+
return PinMap_CAN_RD;
405+
}

targets/TARGET_NXP/TARGET_LPC408X/TARGET_LPC4088_DM/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,13 @@ void can_monitor(can_t *obj, int silent) {
390390
can_enable(obj);
391391
}
392392
}
393+
394+
const PinMap *can_rd_pinmap()
395+
{
396+
return PinMap_CAN_TD;
397+
}
398+
399+
const PinMap *can_td_pinmap()
400+
{
401+
return PinMap_CAN_RD;
402+
}

targets/TARGET_RENESAS/TARGET_RZ_A1XX/can_api.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static void can_err_irq(uint32_t ch, CanIrqType type) {
388388
*dmy_erfl &= 0xFFFFFF7F; // Clear ALF
389389
break;
390390
case IRQ_BUS:
391-
*dmy_erfl &= 0xFFFF00FF; // Clear ADERRAB0ERRAB1ERRACERRAAERRAFERRASERR
391+
*dmy_erfl &= 0xFFFF00FF; // Clear ADERRAB0ERRAB1ERRACERRAAERRAFERRASERR
392392
*dmy_erfl &= 0xFFFFFFFE; // Clear BEF
393393
break;
394394
case IRQ_WAKEUP:
@@ -1033,3 +1033,13 @@ static void can_set_channel_mode(uint32_t ch, int mode) {
10331033
}
10341034
}
10351035

1036+
const PinMap *can_rd_pinmap()
1037+
{
1038+
return PinMap_CAN_TD;
1039+
}
1040+
1041+
const PinMap *can_td_pinmap()
1042+
{
1043+
return PinMap_CAN_RD;
1044+
}
1045+

targets/TARGET_STM/can_api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,4 +1205,14 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable)
12051205

12061206
#endif /* FDCAN1 */
12071207

1208+
const PinMap *can_rd_pinmap()
1209+
{
1210+
return PinMap_CAN_TD;
1211+
}
1212+
1213+
const PinMap *can_td_pinmap()
1214+
{
1215+
return PinMap_CAN_RD;
1216+
}
1217+
12081218
#endif // DEVICE_CAN

0 commit comments

Comments
 (0)