@@ -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*/
168159ErrStatus 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)
738729ErrStatus 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