Skip to content

Commit 6eacece

Browse files
committed
gd32f4xx: can: Rename preprocessor
The GigaDevices CAN driver uses similar names defined in Zephyr. This add prefix '__' to solve the conflict. Signed-off-by: HaiLong Yang <[email protected]>
1 parent db8c7aa commit 6eacece

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

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;

0 commit comments

Comments
 (0)