Skip to content

Commit e09600c

Browse files
committed
gd32f4xx: can: Rename CAN macro name
GD32 CAN have some name conflict with Zephyr. Add prefix '__' to these GD32 CAN macro name. Signed-off-by: HaiLong Yang <[email protected]>
1 parent f8c8eda commit e09600c

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

GD32F403/standard_peripheral/Include/gd32f403_can.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ typedef enum
592592

593593
#define CAN_STATE_PENDING ((uint32_t)0x00000000U) /*!< CAN pending */
594594

595+
/* CAN communication mode */
596+
#define __CAN_NORMAL_MODE ((uint8_t)0x00U) /*!< normal communication mode */
597+
#define __CAN_LOOPBACK_MODE ((uint8_t)0x01U) /*!< loopback communication mode */
598+
#define __CAN_SILENT_MODE ((uint8_t)0x02U) /*!< silent communication mode */
599+
#define __CAN_SILENT_LOOPBACK_MODE ((uint8_t)0x03U) /*!< loopback and silent communication mode */
600+
595601
/* CAN resynchronisation jump width */
596602
#define CAN_BT_SJW_1TQ ((uint8_t)0x00U) /*!< 1 time quanta */
597603
#define CAN_BT_SJW_2TQ ((uint8_t)0x01U) /*!< 2 time quanta */
@@ -666,6 +672,9 @@ typedef enum
666672
#define CAN_FT_DATA ((uint32_t)0x00000000U) /*!< data frame */
667673
#define CAN_FT_REMOTE ((uint32_t)0x00000002U) /*!< remote frame */
668674

675+
/* CAN timeout */
676+
#define __CAN_TIMEOUT ((uint32_t)0x0000FFFFU) /*!< timeout value */
677+
669678
/* interrupt enable bits */
670679
#define CAN_INT_TME CAN_INTEN_TMEIE /*!< transmit mailbox empty interrupt enable */
671680
#define CAN_INT_RFNE0 CAN_INTEN_RFNEIE0 /*!< receive FIFO0 not empty interrupt enable */

GD32F403/standard_peripheral/Source/gd32f403_can.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ OF SUCH DAMAGE.
3838

3939
#include "gd32f403_can.h"
4040

41-
/* CAN communication mode */
42-
#define CAN_NORMAL_MODE ((uint8_t)0x00U) /*!< normal communication mode */
43-
#define CAN_LOOPBACK_MODE ((uint8_t)0x01U) /*!< loopback communication mode */
44-
#define CAN_SILENT_MODE ((uint8_t)0x02U) /*!< silent communication mode */
45-
#define CAN_SILENT_LOOPBACK_MODE ((uint8_t)0x03U) /*!< loopback and silent communication mode */
46-
47-
/* CAN timeout */
48-
#define CAN_TIMEOUT ((uint32_t)0x0000FFFFU) /*!< timeout value */
49-
5041
#define CAN_ERROR_HANDLE(s) do{}while(1)
5142

5243
/*!
@@ -97,7 +88,7 @@ void can_struct_para_init(can_struct_type_enum type, void* p_struct)
9788
((can_parameter_struct*)p_struct)->time_segment_2 = CAN_BT_BS2_1TQ;
9889
((can_parameter_struct*)p_struct)->time_triggered = DISABLE;
9990
((can_parameter_struct*)p_struct)->trans_fifo_order = DISABLE;
100-
((can_parameter_struct*)p_struct)->working_mode = CAN_NORMAL_MODE;
91+
((can_parameter_struct*)p_struct)->working_mode = __CAN_NORMAL_MODE;
10192

10293
break;
10394
/* used for can_filter_init() */
@@ -151,7 +142,7 @@ void can_struct_para_init(can_struct_type_enum type, void* p_struct)
151142
\param[in] can_periph
152143
\arg CANx(x=0,1)
153144
\param[in] can_parameter_init: parameters for CAN initializtion
154-
\arg working_mode: CAN_NORMAL_MODE, CAN_LOOPBACK_MODE, CAN_SILENT_MODE, CAN_SILENT_LOOPBACK_MODE
145+
\arg working_mode: __CAN_NORMAL_MODE, __CAN_LOOPBACK_MODE, __CAN_SILENT_MODE, __CAN_SILENT_LOOPBACK_MODE
155146
\arg resync_jump_width: CAN_BT_SJW_xTQ(x=1, 2, 3, 4)
156147
\arg time_segment_1: CAN_BT_BS1_xTQ(1..16)
157148
\arg time_segment_2: CAN_BT_BS2_xTQ(1..8)
@@ -167,7 +158,7 @@ void can_struct_para_init(can_struct_type_enum type, void* p_struct)
167158
*/
168159
ErrStatus can_init(uint32_t can_periph, can_parameter_struct* can_parameter_init)
169160
{
170-
uint32_t timeout = CAN_TIMEOUT;
161+
uint32_t timeout = __CAN_TIMEOUT;
171162
ErrStatus flag = ERROR;
172163

173164
/* disable sleep mode */
@@ -227,7 +218,7 @@ ErrStatus can_init(uint32_t can_periph, can_parameter_struct* can_parameter_init
227218
}
228219
/* disable initialize mode */
229220
CAN_CTL(can_periph) &= ~CAN_CTL_IWMOD;
230-
timeout = CAN_TIMEOUT;
221+
timeout = __CAN_TIMEOUT;
231222
/* wait the ACK */
232223
while((CAN_STAT_IWS == (CAN_STAT(can_periph) & CAN_STAT_IWS)) && (0U != timeout)){
233224
timeout--;
@@ -680,7 +671,7 @@ ErrStatus can_working_mode_set(uint32_t can_periph, uint8_t working_mode)
680671
{
681672
ErrStatus flag = ERROR;
682673
/* timeout for IWS or also for SLPWS bits */
683-
uint32_t timeout = CAN_TIMEOUT;
674+
uint32_t timeout = __CAN_TIMEOUT;
684675

685676
if(CAN_MODE_INITIALIZE == working_mode){
686677
/* disable sleep mode */
@@ -738,7 +729,7 @@ ErrStatus can_working_mode_set(uint32_t can_periph, uint8_t working_mode)
738729
ErrStatus can_wakeup(uint32_t can_periph)
739730
{
740731
ErrStatus flag = ERROR;
741-
uint32_t timeout = CAN_TIMEOUT;
732+
uint32_t timeout = __CAN_TIMEOUT;
742733

743734
/* wakeup */
744735
CAN_CTL(can_periph) &= ~CAN_CTL_SLPWMOD;

GD32F4XX/standard_peripheral/Include/gd32f4xx_can.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,10 @@ typedef enum
594594
#define CAN_STATE_PENDING ((uint32_t)0x00000000U) /*!< CAN pending */
595595

596596
/* CAN communication mode */
597-
#define CAN_NORMAL_MODE ((uint8_t)0x00U) /*!< normal communication mode */
598-
#define CAN_LOOPBACK_MODE ((uint8_t)0x01U) /*!< loopback communication mode */
599-
#define CAN_SILENT_MODE ((uint8_t)0x02U) /*!< silent communication mode */
600-
#define CAN_SILENT_LOOPBACK_MODE ((uint8_t)0x03U) /*!< loopback and silent communication mode */
597+
#define __CAN_NORMAL_MODE ((uint8_t)0x00U) /*!< normal communication mode */
598+
#define __CAN_LOOPBACK_MODE ((uint8_t)0x01U) /*!< loopback communication mode */
599+
#define __CAN_SILENT_MODE ((uint8_t)0x02U) /*!< silent communication mode */
600+
#define __CAN_SILENT_LOOPBACK_MODE ((uint8_t)0x03U) /*!< loopback and silent communication mode */
601601

602602
/* CAN resynchronisation jump width */
603603
#define CAN_BT_SJW_1TQ ((uint8_t)0x00U) /*!< 1 time quanta */
@@ -674,7 +674,7 @@ typedef enum
674674
#define CAN_FT_REMOTE ((uint32_t)0x00000002U) /*!< remote frame */
675675

676676
/* CAN timeout */
677-
#define CAN_TIMEOUT ((uint32_t)0x0000FFFFU) /*!< timeout value */
677+
#define __CAN_TIMEOUT ((uint32_t)0x0000FFFFU) /*!< timeout value */
678678

679679
/* interrupt enable bits */
680680
#define CAN_INT_TME CAN_INTEN_TMEIE /*!< transmit mailbox empty interrupt enable */

GD32F4XX/standard_peripheral/Source/gd32f4xx_can.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void can_struct_para_init(can_struct_type_enum type, void* p_struct)
8888
((can_parameter_struct*)p_struct)->time_segment_2 = CAN_BT_BS2_1TQ;
8989
((can_parameter_struct*)p_struct)->time_triggered = DISABLE;
9090
((can_parameter_struct*)p_struct)->trans_fifo_order = DISABLE;
91-
((can_parameter_struct*)p_struct)->working_mode = CAN_NORMAL_MODE;
91+
((can_parameter_struct*)p_struct)->working_mode = __CAN_NORMAL_MODE;
9292

9393
break;
9494
/* used for can_filter_init() */
@@ -142,7 +142,7 @@ void can_struct_para_init(can_struct_type_enum type, void* p_struct)
142142
\param[in] can_periph
143143
\arg CANx(x=0,1)
144144
\param[in] can_parameter_init: parameters for CAN initializtion
145-
\arg working_mode: CAN_NORMAL_MODE, CAN_LOOPBACK_MODE, CAN_SILENT_MODE, CAN_SILENT_LOOPBACK_MODE
145+
\arg working_mode: __CAN_NORMAL_MODE, __CAN_LOOPBACK_MODE, __CAN_SILENT_MODE, __CAN_SILENT_LOOPBACK_MODE
146146
\arg resync_jump_width: CAN_BT_SJW_xTQ(x=1, 2, 3, 4)
147147
\arg time_segment_1: CAN_BT_BS1_xTQ(1..16)
148148
\arg time_segment_2: CAN_BT_BS2_xTQ(1..8)
@@ -158,7 +158,7 @@ void can_struct_para_init(can_struct_type_enum type, void* p_struct)
158158
*/
159159
ErrStatus can_init(uint32_t can_periph, can_parameter_struct* can_parameter_init)
160160
{
161-
uint32_t timeout = CAN_TIMEOUT;
161+
uint32_t timeout = __CAN_TIMEOUT;
162162
ErrStatus flag = ERROR;
163163

164164
/* disable sleep mode */
@@ -218,7 +218,7 @@ ErrStatus can_init(uint32_t can_periph, can_parameter_struct* can_parameter_init
218218
}
219219
/* disable initialize mode */
220220
CAN_CTL(can_periph) &= ~CAN_CTL_IWMOD;
221-
timeout = CAN_TIMEOUT;
221+
timeout = __CAN_TIMEOUT;
222222
/* wait the ACK */
223223
while((CAN_STAT_IWS == (CAN_STAT(can_periph) & CAN_STAT_IWS)) && (0U != timeout)){
224224
timeout--;
@@ -671,7 +671,7 @@ ErrStatus can_working_mode_set(uint32_t can_periph, uint8_t working_mode)
671671
{
672672
ErrStatus flag = ERROR;
673673
/* timeout for IWS or also for SLPWS bits */
674-
uint32_t timeout = CAN_TIMEOUT;
674+
uint32_t timeout = __CAN_TIMEOUT;
675675

676676
if(CAN_MODE_INITIALIZE == working_mode){
677677
/* disable sleep mode */
@@ -729,7 +729,7 @@ ErrStatus can_working_mode_set(uint32_t can_periph, uint8_t working_mode)
729729
ErrStatus can_wakeup(uint32_t can_periph)
730730
{
731731
ErrStatus flag = ERROR;
732-
uint32_t timeout = CAN_TIMEOUT;
732+
uint32_t timeout = __CAN_TIMEOUT;
733733

734734
/* wakeup */
735735
CAN_CTL(can_periph) &= ~CAN_CTL_SLPWMOD;

GD32VF103/standard_peripheral/Include/gd32vf103_can.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ typedef enum
592592

593593
#define CAN_STATE_PENDING ((uint32_t)0x00000000U) /*!< CAN pending */
594594

595+
/* CAN communication mode */
596+
#define __CAN_NORMAL_MODE ((uint8_t)0x00U) /*!< normal communication mode */
597+
#define __CAN_LOOPBACK_MODE ((uint8_t)0x01U) /*!< loopback communication mode */
598+
#define __CAN_SILENT_MODE ((uint8_t)0x02U) /*!< silent communication mode */
599+
#define __CAN_SILENT_LOOPBACK_MODE ((uint8_t)0x03U) /*!< loopback and silent communication mode */
600+
595601
/* CAN resynchronisation jump width */
596602
#define CAN_BT_SJW_1TQ ((uint8_t)0x00U) /*!< 1 time quanta */
597603
#define CAN_BT_SJW_2TQ ((uint8_t)0x01U) /*!< 2 time quanta */
@@ -666,6 +672,9 @@ typedef enum
666672
#define CAN_FT_DATA ((uint32_t)0x00000000U) /*!< data frame */
667673
#define CAN_FT_REMOTE ((uint32_t)0x00000002U) /*!< remote frame */
668674

675+
/* CAN timeout */
676+
#define __CAN_TIMEOUT ((uint32_t)0x0000FFFFU) /*!< timeout value */
677+
669678
/* interrupt enable bits */
670679
#define CAN_INT_TME CAN_INTEN_TMEIE /*!< transmit mailbox empty interrupt enable */
671680
#define CAN_INT_RFNE0 CAN_INTEN_RFNEIE0 /*!< receive FIFO0 not empty interrupt enable */

GD32VF103/standard_peripheral/Source/gd32vf103_can.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ OF SUCH DAMAGE.
3838

3939
#include "gd32vf103_can.h"
4040

41-
/* CAN communication mode */
42-
#define CAN_NORMAL_MODE ((uint8_t)0x00U) /*!< normal communication mode */
43-
#define CAN_LOOPBACK_MODE ((uint8_t)0x01U) /*!< loopback communication mode */
44-
#define CAN_SILENT_MODE ((uint8_t)0x02U) /*!< silent communication mode */
45-
#define CAN_SILENT_LOOPBACK_MODE ((uint8_t)0x03U) /*!< loopback and silent communication mode */
46-
47-
/* CAN timeout */
48-
#define CAN_TIMEOUT ((uint32_t)0x0000FFFFU) /*!< timeout value */
49-
5041
#define CAN_ERROR_HANDLE(s) do{}while(1)
5142

5243
/*!
@@ -97,7 +88,7 @@ void can_struct_para_init(can_struct_type_enum type, void* p_struct)
9788
((can_parameter_struct*)p_struct)->time_segment_2 = CAN_BT_BS2_1TQ;
9889
((can_parameter_struct*)p_struct)->time_triggered = DISABLE;
9990
((can_parameter_struct*)p_struct)->trans_fifo_order = DISABLE;
100-
((can_parameter_struct*)p_struct)->working_mode = CAN_NORMAL_MODE;
91+
((can_parameter_struct*)p_struct)->working_mode = __CAN_NORMAL_MODE;
10192

10293
break;
10394
/* used for can_filter_init() */
@@ -151,7 +142,7 @@ void can_struct_para_init(can_struct_type_enum type, void* p_struct)
151142
\param[in] can_periph
152143
\arg CANx(x=0,1)
153144
\param[in] can_parameter_init: parameters for CAN initializtion
154-
\arg working_mode: CAN_NORMAL_MODE, CAN_LOOPBACK_MODE, CAN_SILENT_MODE, CAN_SILENT_LOOPBACK_MODE
145+
\arg working_mode: __CAN_NORMAL_MODE, __CAN_LOOPBACK_MODE, __CAN_SILENT_MODE, __CAN_SILENT_LOOPBACK_MODE
155146
\arg resync_jump_width: CAN_BT_SJW_xTQ(x=1, 2, 3, 4)
156147
\arg time_segment_1: CAN_BT_BS1_xTQ(1..16)
157148
\arg time_segment_2: CAN_BT_BS2_xTQ(1..8)
@@ -167,7 +158,7 @@ void can_struct_para_init(can_struct_type_enum type, void* p_struct)
167158
*/
168159
ErrStatus can_init(uint32_t can_periph, can_parameter_struct* can_parameter_init)
169160
{
170-
uint32_t timeout = CAN_TIMEOUT;
161+
uint32_t timeout = __CAN_TIMEOUT;
171162
ErrStatus flag = ERROR;
172163

173164
/* disable sleep mode */
@@ -227,7 +218,7 @@ ErrStatus can_init(uint32_t can_periph, can_parameter_struct* can_parameter_init
227218
}
228219
/* disable initialize mode */
229220
CAN_CTL(can_periph) &= ~CAN_CTL_IWMOD;
230-
timeout = CAN_TIMEOUT;
221+
timeout = __CAN_TIMEOUT;
231222
/* wait the ACK */
232223
while((CAN_STAT_IWS == (CAN_STAT(can_periph) & CAN_STAT_IWS)) && (0U != timeout)){
233224
timeout--;
@@ -680,7 +671,7 @@ ErrStatus can_working_mode_set(uint32_t can_periph, uint8_t working_mode)
680671
{
681672
ErrStatus flag = ERROR;
682673
/* timeout for IWS or also for SLPWS bits */
683-
uint32_t timeout = CAN_TIMEOUT;
674+
uint32_t timeout = __CAN_TIMEOUT;
684675

685676
if(CAN_MODE_INITIALIZE == working_mode){
686677
/* disable sleep mode */
@@ -738,7 +729,7 @@ ErrStatus can_working_mode_set(uint32_t can_periph, uint8_t working_mode)
738729
ErrStatus can_wakeup(uint32_t can_periph)
739730
{
740731
ErrStatus flag = ERROR;
741-
uint32_t timeout = CAN_TIMEOUT;
732+
uint32_t timeout = __CAN_TIMEOUT;
742733

743734
/* wakeup */
744735
CAN_CTL(can_periph) &= ~CAN_CTL_SLPWMOD;

0 commit comments

Comments
 (0)