Skip to content

Commit 3d44a3f

Browse files
committed
add can_init_freq for NUVOTON platforms
1 parent 1fe20b2 commit 3d44a3f

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

targets/TARGET_NUVOTON/TARGET_M451/can_api.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
};
4343

4444

45-
void can_init(can_t *obj, PinName rd, PinName td)
46-
{
45+
void can_init_freq(can_t *obj, PinName rd, PinName td, int hz)
46+
{
4747
uint32_t can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD);
4848
uint32_t can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD);
4949
obj->can = (CANName)pinmap_merge(can_td, can_rd);
@@ -69,12 +69,18 @@
6969
PA0 = 0x00;
7070
PA1 = 0x00;
7171

72-
CAN_Open((CAN_T *)NU_MODBASE(obj->can), 500000, CAN_NORMAL_MODE);
72+
CAN_Open((CAN_T *)NU_MODBASE(obj->can), hz, CAN_NORMAL_MODE);
7373

7474
can_filter(obj, 0, 0, CANStandard, 0);
7575
}
76-
77-
76+
77+
78+
void can_init(can_t *obj, PinName rd, PinName td)
79+
{
80+
can_init_freq(obj, rd, td, 500000);
81+
}
82+
83+
7884
void can_free(can_t *obj)
7985
{
8086

targets/TARGET_NUVOTON/TARGET_NUC472/can_api.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
{NC, 0, 0, 0, 0, (IRQn_Type) 0, NULL}
4444
};
4545

46-
47-
void can_init(can_t *obj, PinName rd, PinName td)
46+
47+
void can_init_freq(can_t *obj, PinName rd, PinName td, int hz)
4848
{
4949
uint32_t can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD);
5050
uint32_t can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD);
@@ -75,12 +75,18 @@
7575
PA2 = 0x00;
7676
PA3 = 0x00;
7777

78-
CAN_Open((CAN_T *)NU_MODBASE(obj->can), 500000, CAN_NORMAL_MODE);
78+
CAN_Open((CAN_T *)NU_MODBASE(obj->can), hz, CAN_NORMAL_MODE);
7979

8080
can_filter(obj, 0, 0, CANStandard, 0);
8181
}
82-
83-
82+
83+
84+
void can_init(can_t *obj, PinName rd, PinName td)
85+
{
86+
can_init_freq(obj, rd, td, 500000);
87+
}
88+
89+
8490
void can_free(can_t *obj)
8591
{
8692

0 commit comments

Comments
 (0)