From cea27724d72663ea45278fc0f4beecaad12bfbc2 Mon Sep 17 00:00:00 2001 From: tomoyuki yamanaka Date: Thu, 1 Dec 2016 11:41:20 +0900 Subject: [PATCH] Fix frequency function of CAN driver. Until now, when the frequency function of CAN driver was executed, signal no output, and the frequency could not be changed. Since there was an error in the frequency changing procedure I modified it. --- targets/TARGET_RENESAS/TARGET_RZ_A1H/can_api.c | 7 +++++++ targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/can_api.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/targets/TARGET_RENESAS/TARGET_RZ_A1H/can_api.c b/targets/TARGET_RENESAS/TARGET_RZ_A1H/can_api.c index 10fb22aa6b..1c22489be2 100644 --- a/targets/TARGET_RENESAS/TARGET_RZ_A1H/can_api.c +++ b/targets/TARGET_RENESAS/TARGET_RZ_A1H/can_api.c @@ -581,6 +581,7 @@ void can_free(can_t *obj) { } int can_frequency(can_t *obj, int f) { + __IO uint32_t *dmy_cfcc; int retval = 0; if (f <= 1000000) { @@ -590,6 +591,12 @@ int can_frequency(can_t *obj, int f) { can_set_frequency(obj, f); /* set Channel Communication mode */ can_set_channel_mode(obj->ch, CH_COMM); + /* restore CFE bit since it is cleared */ + /* Use send/receive FIFO buffer */ + dmy_cfcc = CFCC_TBL[obj->ch][CAN_SEND]; + *dmy_cfcc |= 0x01; + dmy_cfcc = CFCC_TBL[obj->ch][CAN_RECV]; + *dmy_cfcc |= 0x01; retval = 1; } diff --git a/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/can_api.c b/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/can_api.c index e003b8bb94..7b6cf12e4e 100644 --- a/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/can_api.c +++ b/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/can_api.c @@ -598,6 +598,7 @@ void can_free(can_t *obj) { } int can_frequency(can_t *obj, int f) { + __IO uint32_t *dmy_cfcc; int retval = 0; if (f <= 1000000) { @@ -607,6 +608,12 @@ int can_frequency(can_t *obj, int f) { can_set_frequency(obj, f); /* set Channel Communication mode */ can_set_channel_mode(obj->ch, CH_COMM); + /* restore CFE bit since it is cleared */ + /* Use send/receive FIFO buffer */ + dmy_cfcc = CFCC_TBL[obj->ch][CAN_SEND]; + *dmy_cfcc |= 0x01; + dmy_cfcc = CFCC_TBL[obj->ch][CAN_RECV]; + *dmy_cfcc |= 0x01; retval = 1; }