Rscan.c 66.6 KB
Newer Older
hu's avatar
hu committed
1 2 3


/*-----------------use for RH850_D1M1A_1441 --------------------*/
4 5
#include "r_typedefs.h"
#include "dr7f701441.dvf.h"
hu's avatar
hu committed
6 7 8
#include "r_dev_api.h"

#include "RSCAN.h"
9 10
#include "RSCAN_Table.h"

hu's avatar
hu committed
11 12 13 14 15 16 17 18 19 20 21 22 23
#define RSCAN_C_ISO_RSCAN_CLKC 40000000UL          /* PLLFIXCLK /12 (default)*/
#define RSCAN_C_ISO_RSCANXIN_CLK_XIN_CAN 8000000UL /*MainOSC*/
#define RSCAN_F_CAN RSCAN_C_ISO_RSCANXIN_CLK_XIN_CAN

#define RSCAN0_BASE_ADDRESS 0xFFD00000UL

/*--------------500K-----------------------------*/
#define RSCAN0_500K_BAUD_RATE 500U //波特率,单位kbps
#define RSCAN0_500K_T_SEG1 12U     //时间段1的Tq数
#define RSCAN0_500K_T_SEG2 3U      //时间段2的Tq数
#define RSCAN0_500K_SJW 3U         //同步跳转宽度

#define RSCAN_500K_BIT_RATE_DIV (RSCAN_F_CAN / (RSCAN0_500K_BAUD_RATE) / (RSCAN0_500K_T_SEG1 + RSCAN0_500K_T_SEG2 + 1UL) / 1000UL)
24

hu's avatar
hu committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
/*-----------------250K---------------------------------*/
#define RSCAN0_250K_BAUD_RATE 250U //波特率,单位kbps
#define RSCAN0_250K_T_SEG1 13U     //11 //时间段1的Tq数
#define RSCAN0_250K_T_SEG2 2U      //4	 //时间段2的Tq数
#define RSCAN0_250K_SJW 1U         //2 //3

#define RSCAN_250K_BIT_RATE_DIV (RSCAN_F_CAN / (RSCAN0_250K_BAUD_RATE) / (RSCAN0_250K_T_SEG1 + RSCAN0_250K_T_SEG2 + 1UL) / 1000UL)

/*-----------------125K---------------------------------*/
#define RSCAN0_125K_BAUD_RATE 125U //波特率,单位kbps
#define RSCAN0_125K_T_SEG1 13U     //11 //时间段1的Tq数
#define RSCAN0_125K_T_SEG2 2U      //4	 //时间段2的Tq数
#define RSCAN0_125K_SJW 1U         //2 //3

#define RSCAN_125K_BIT_RATE_DIV (RSCAN_F_CAN / (RSCAN0_125K_BAUD_RATE) / (RSCAN0_125K_T_SEG1 + RSCAN0_125K_T_SEG2 + 1UL) / 1000UL)
/*------------------------------------------------*/

#if ((RSCAN0_500K_T_SEG2 < 2U) || (RSCAN0_250K_T_SEG2 < 2U) || (RSCAN0_125K_T_SEG2 < 2U) || (RSCAN0_500K_T_SEG2 > 8U) || (RSCAN0_250K_T_SEG2 > 8U) || (RSCAN0_125K_T_SEG2 > 8U))
#error RSCAN0 Time Segment 2 error!!!
#endif
#if ((RSCAN0_500K_T_SEG1 < 4U) || (RSCAN0_250K_T_SEG1 < 4U) || (RSCAN0_125K_T_SEG1 < 4U) || (RSCAN0_500K_T_SEG1 > 16U) || (RSCAN0_250K_T_SEG1 > 16U) || (RSCAN0_125K_T_SEG1 > 16U))
#error RSCAN0 Time Segment 1 error!!!
#endif
#if ((RSCAN0_500K_SJW < 1U) || (RSCAN0_250K_SJW < 1U) || (RSCAN0_125K_SJW < 1U) || (RSCAN0_500K_SJW > 4U) || (RSCAN0_250K_SJW > 4U) || (RSCAN0_125K_SJW > 4U))
#error RSCAN0 Resynchronization Jump Width error!!!
#endif
#if ((RSCAN_500K_BIT_RATE_DIV < 1U) || (RSCAN_250K_BIT_RATE_DIV < 1U) || (RSCAN_125K_BIT_RATE_DIV < 1U) || (RSCAN_500K_BIT_RATE_DIV > 1024U) || (RSCAN_250K_BIT_RATE_DIV > 1024U) || (RSCAN_125K_BIT_RATE_DIV > 1024U))
#error RSCAN0 Communication speed  error!!!
53 54
#endif

hu's avatar
hu committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
/*---------------------------------------*/

/*---------------------------------------*/

/***************************************************/
/**COMPLETE**/
#define RSCAN_ABORT_CPLT_AND 0X06U
#define RSCAN_ABORT_CPLT 0X02U
#define RSCAN_TX_CPLT_AND 0X04U
#define RSCAN_TX_CPLT 0X04U
/***************************************************/

/*RSCAN0GCFG*/
/*DCS*/
#define RSCAN_CLOCK_SOURCE_CLKC (0U << 4U)
#define RSCAN_CLOCK_SOURCE_CLK_XINCAN (1U << 4U)
/*DCE*/
#define RSCAN_DLC_CHECK_DISABLE (0U << 1U)
#define RSCAN_DLC_CHECK_ENABLE (1U << 1U)
/*TPRI*/
#define RSCAN_TX_PRIORITY_ID (0U)
#define RSCAN_TX_PRIORITY_BUFFER_NUM (1U)

/*RSCAN0C0CFG*/
#define RSCAN_500K_NTSEG2 ((RSCAN0_500K_T_SEG2 - 1U) << 20U)
#define RSCAN_500K_NTSEG1 ((RSCAN0_500K_T_SEG1 - 1U) << 16U)
#define RSCAN_500K_NSJW ((RSCAN0_500K_SJW - 1U) << 24U)
#define RSCAN_500K_NBRP (RSCAN_500K_BIT_RATE_DIV - 1U)

#define RSCAN_250K_NTSEG2 ((RSCAN0_250K_T_SEG2 - 1U) << 20U)
#define RSCAN_250K_NTSEG1 ((RSCAN0_250K_T_SEG1 - 1U) << 16U)
#define RSCAN_250K_NSJW ((RSCAN0_250K_SJW - 1U) << 24U)
#define RSCAN_250K_NBRP (RSCAN_250K_BIT_RATE_DIV - 1U)

#define RSCAN_125K_NTSEG2 ((RSCAN0_125K_T_SEG2 - 1U) << 20U)
#define RSCAN_125K_NTSEG1 ((RSCAN0_125K_T_SEG1 - 1U) << 16U)
#define RSCAN_125K_NSJW ((RSCAN0_125K_SJW - 1U) << 24U)
#define RSCAN_125K_NBRP (RSCAN_125K_BIT_RATE_DIV - 1U)

/*RSCANnCFCCk*/

/*Transmit/Receive FIFO Buffer Depth Configuration*/
#define RSCAN_TR_FIFO_DEPTH_0 (0UL << 8UL)
#define RSCAN_TR_FIFO_DEPTH_4 (1UL << 8UL)
#define RSCAN_TR_FIFO_DEPTH_8 (2UL << 8UL)
#define RSCAN_TR_FIFO_DEPTH_16 (3UL << 8UL)
#define RSCAN_TR_FIFO_DEPTH_32 (4UL << 8UL)
#define RSCAN_TR_FIFO_DEPTH_48 (5UL << 8UL)
#define RSCAN_TR_FIFO_DEPTH_64 (6UL << 8UL)
#define RSCAN_TR_FIFO_DEPTH_128 (7UL << 8UL)
/*Transmit/Receive FIFO Mode Select*/
#define RSCAN_TR_FIFO_MODE_RX (0UL << 16UL)
#define RSCAN_TR_FIFO_MODE_TX (1UL << 16UL)
/*Transmit/Receive FIFO Transmit Interrupt Enable*/
#define RSCAN_TR_FIFO_TX_INT_DIS (0UL << 2UL)
#define RSCAN_TR_FIFO_TX_INT_EN (1UL << 2UL)
/*Transmit/Receive FIFO Receive Interrupt Enable*/
#define RSCAN_TR_FIFO_RX_INT_DIS (0UL << 1UL)
#define RSCAN_TR_FIFO_RX_INT_EN (1UL << 1UL)
/*Transmit/Receive FIFO Buffer Enable*/
#define RSCAN_TR_FIFO_DIS (0UL)
#define RSCAN_TR_FIFO_EN (1UL)

/*RCFDCnCFDCmCTR*/
/*Transmit Abort Interrupt Enable*/
#define RSCAN_ABORT_INT_DIS (0UL << 16U)
#define RSCAN_ABORT_INT_EN (1UL << 16U)
/*Bus Off Recovery Mode Select*/
#define RSCAN_RECOVER_11898 (0UL << 21U)
#define RSCAN_RECOVER_ENTRY_HALT_AT_BUSOFF_ENTRY (1UL << 21U)
#define RSCAN_RECOVER_ENTRY_HALT_AT_BUSOFF_END (1UL << 21U)
#define RSCAN_RECOVER_ENTRY_HALT_BY_PROGRAM_REQUEST (1UL << 21U)

typedef struct
129 130
{

hu's avatar
hu committed
131 132 133 134 135 136 137 138
    /*具体接收内容*/
    CAN_Frame_st_t stReceiveContent;
    /*是否接收到新数据
    0:数据没有更新
    1:接收到新数据,已更新*/
    uint8_t u8CANReceiveStatus;

} CAN_Frame_Receive_st_t;
139

hu's avatar
hu committed
140 141 142
/*------------------------------------------------------------*/
RSCAN0_Config_st_t g_stRSCAN0Config;
/*------------------------------------------------------------*/
143

hu's avatar
hu committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
static uint32_t RSCAN0_CH_Baud_Rate_Cal(RSCAN_Channel_Config_st_t *pstRSCANChannelConfig)
{
    uint32_t u32RegisterBuf = 0UL;
    if (pstRSCANChannelConfig->u32RSCANChEn)
    {
        if (pstRSCANChannelConfig->enRSCANChBps == RSCAN_Baud_Rate_500K)
        {
            u32RegisterBuf = (RSCAN_500K_NTSEG2 | RSCAN_500K_NTSEG1 | RSCAN_500K_NSJW | RSCAN_500K_NBRP);
        }
        else if (pstRSCANChannelConfig->enRSCANChBps == RSCAN_Baud_Rate_250K)
        {
            u32RegisterBuf = (RSCAN_250K_NTSEG2 | RSCAN_250K_NTSEG1 | RSCAN_250K_NSJW | RSCAN_250K_NBRP);
        }
        else if (pstRSCANChannelConfig->enRSCANChBps == RSCAN_Baud_Rate_125K)
        {
            u32RegisterBuf = (RSCAN_125K_NTSEG2 | RSCAN_125K_NTSEG1 | RSCAN_125K_NSJW | RSCAN_125K_NBRP);
        }
    }
162

hu's avatar
hu committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176
    return u32RegisterBuf;
}
/*
返回值:
0:设置失败
1:设置成功
*/
uint8_t RSCAN0_CH_Init(const RSCANFD_Filter_st_t pstRSCANFilter[], RSCAN0_Config_st_t *pstRSCANConfig)
{
    uint32_t i = 0UL;
    uint8_t j = 0UL;
    uint32_t u32CANFDCalBuf = 0UL;
    uint8_t u8Status = 1U;
    uint32_t u32RSCANChannelRuleTotal = 0UL;
177

hu's avatar
hu committed
178
    volatile RSCANFD_Filter_st_t *pstCANFDRule;
179

hu's avatar
hu committed
180
    if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
181
    {
hu's avatar
hu committed
182 183 184 185
        if (pstRSCANConfig->stRSCANCh0.u32RSCANChRuleSize > 128)
        {
            u8Status = 0U;
        }
186
    }
hu's avatar
hu committed
187
    if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
188
    {
hu's avatar
hu committed
189 190 191 192
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChRuleSize > 128)
        {
            u8Status = 0U;
        }
193
    }
hu's avatar
hu committed
194
    if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
195
    {
hu's avatar
hu committed
196 197 198 199
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChRuleSize > 128)
        {
            u8Status = 0U;
        }
200 201
    }

hu's avatar
hu committed
202
    if (u8Status == 1U)
203
    {
hu's avatar
hu committed
204 205
        u32RSCANChannelRuleTotal = pstRSCANConfig->stRSCANCh0.u32RSCANChRuleSize + pstRSCANConfig->stRSCANCh1.u32RSCANChRuleSize + pstRSCANConfig->stRSCANCh2.u32RSCANChRuleSize;
        if (u32RSCANChannelRuleTotal > 192)
206
        {
hu's avatar
hu committed
207
            u8Status = 0UL;
208 209
        }
    }
hu's avatar
hu committed
210 211

    if (u8Status == 1U)
212
    {
hu's avatar
hu committed
213 214
        /* Waiting for CAN RAM initialization is completed */
        while (RSCAN0GSTS & 0x08UL)
215
        {
hu's avatar
hu committed
216
            ;
217
        }
hu's avatar
hu committed
218 219 220 221 222 223

        /* Waiting for CAN entry global reset mdoe */
        RSCAN0GCTR &= 0xfffffff9UL;
        RSCAN0GCTR |= 0x01UL;

        while ((RSCAN0GSTS & 0x07UL) != 0X01UL)
224
        {
hu's avatar
hu committed
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
            ;
        }

        /* Waiting for CAN entry channel reset mdoe */
        /* CHANNEL 0*/
        if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
        {
            RSCAN0C0CTR &= 0xfffffff9UL;
            RSCAN0C0CTR |= 0x01UL;
        }
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
        {
            RSCAN0C1CTR &= 0xfffffff9UL;
            RSCAN0C1CTR |= 0x01UL;
        }
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
        {
            RSCAN0C2CTR &= 0xfffffff9UL;
            RSCAN0C2CTR |= 0x01UL;
244 245
        }

hu's avatar
hu committed
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
        /*  waiting */
        if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
        {
            while ((RSCAN0C0STS & 0x07UL) != 0X01UL)
            {
                ;
            }
        }
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
        {
            while ((RSCAN0C1STS & 0x07UL) != 0X01UL)
            {
                ;
            }
        }
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
        {
            while ((RSCAN0C2STS & 0x07UL) != 0X01UL)
            {
                ;
            }
        }
268

hu's avatar
hu committed
269 270
        /* Global Configuration Register*/
        RSCAN0GCFG = (RSCAN_DLC_CHECK_ENABLE | RSCAN_CLOCK_SOURCE_CLK_XINCAN | RSCAN_TX_PRIORITY_ID);
271

hu's avatar
hu committed
272 273 274 275
        /*Channel Nominal Bit Rate Configuration Register*/
        RSCAN0C0CFG = RSCAN0_CH_Baud_Rate_Cal(&(pstRSCANConfig->stRSCANCh0));
        RSCAN0C1CFG = RSCAN0_CH_Baud_Rate_Cal(&(pstRSCANConfig->stRSCANCh1));
        RSCAN0C2CFG = RSCAN0_CH_Baud_Rate_Cal(&(pstRSCANConfig->stRSCANCh2));
276

hu's avatar
hu committed
277
        /*-------Receive rule setting----*/
278

hu's avatar
hu committed
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
        pstCANFDRule = (volatile RSCANFD_Filter_st_t *)(&(RSCAN0GAFLID0));

        /*Receive Rule Configuration Register */
        RSCAN0GAFLCFG0 = 0UL;

        u32CANFDCalBuf = 0UL;

        u32CANFDCalBuf |= (uint32_t)(pstRSCANConfig->stRSCANCh0.u32RSCANChRuleSize << 24U); /* Channel0 Filter num */
        u32CANFDCalBuf |= (uint32_t)(pstRSCANConfig->stRSCANCh1.u32RSCANChRuleSize << 16U); /* Channel1 Filter num */
        u32CANFDCalBuf |= (uint32_t)(pstRSCANConfig->stRSCANCh2.u32RSCANChRuleSize << 8U);  /* Channel2 Filter num */

        RSCAN0GAFLCFG0 = u32CANFDCalBuf;

        /*Receive Rule Entry Control Register*/
        RSCAN0GAFLECTR |= 0x00000100UL; /* Enable receive rule */

        for (i = 0UL; i < u32RSCANChannelRuleTotal; i++)
296
        {
hu's avatar
hu committed
297 298 299 300 301 302
            j = (uint8_t)(i & 0x0FUL);
            if (j == 0UL)
            {
                RSCAN0GAFLECTRLL = (i >> 4U); /* Configuration Page  AFLPN[5:0]*/
            }
            pstCANFDRule[j] = pstRSCANFilter[i];
303
        }
hu's avatar
hu committed
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
        /*disable writing data to the receive rule table.*/
        RSCAN0GAFLECTR &= 0xFFFFFEFFUL;

        /*-------Buffer setting----*/
        /*receive buffer*/
        RSCAN0RMNB = 0x00UL; /*no use*/
        /*receive FIFO buffer*/
        RSCAN0RFCC0 = 0x00UL; /*no use*/
        RSCAN0RFCC1 = 0x00UL;
        RSCAN0RFCC2 = 0x00UL;
        RSCAN0RFCC3 = 0x00UL;
        RSCAN0RFCC4 = 0x00UL;
        RSCAN0RFCC5 = 0x00UL;
        RSCAN0RFCC6 = 0x00UL;
        RSCAN0RFCC7 = 0x00UL;

        /*transmit/receive FIFO buffer*/
        if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
        {
323

hu's avatar
hu committed
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
            RSCAN0CFCC0 = (RSCAN_TR_FIFO_DEPTH_32 | (0x0FUL << 20UL) | 0X1000UL | RSCAN_TR_FIFO_MODE_TX);
            RSCAN0CFCC1 = (RSCAN_TR_FIFO_DEPTH_16 | (0x0EUL << 20UL) | 0X1000UL | RSCAN_TR_FIFO_MODE_TX);
            RSCAN0CFCC2 = (RSCAN_TR_FIFO_DEPTH_16 | 0X1000UL | RSCAN_TR_FIFO_MODE_RX);
        }
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
        {
            RSCAN0CFCC3 = (RSCAN_TR_FIFO_DEPTH_32 | (0x0FUL << 20UL) | 0X1000UL | RSCAN_TR_FIFO_MODE_TX);
            RSCAN0CFCC4 = (RSCAN_TR_FIFO_DEPTH_16 | (0x0EUL << 20UL) | 0X1000UL | RSCAN_TR_FIFO_MODE_TX);
            RSCAN0CFCC5 = (RSCAN_TR_FIFO_DEPTH_16 | 0X1000UL | RSCAN_TR_FIFO_MODE_RX);
        }
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
        {
            RSCAN0CFCC6 = (RSCAN_TR_FIFO_DEPTH_32 | (0x0FUL << 20UL) | 0X1000UL | RSCAN_TR_FIFO_MODE_TX);
            RSCAN0CFCC7 = (RSCAN_TR_FIFO_DEPTH_16 | (0x0EUL << 20UL) | 0X1000UL | RSCAN_TR_FIFO_MODE_TX);
            RSCAN0CFCC8 = (RSCAN_TR_FIFO_DEPTH_16 | 0X1000UL | RSCAN_TR_FIFO_MODE_RX);
        }
340

hu's avatar
hu committed
341 342 343 344
        /* transmit queue*/
        RSCAN0TXQCC0 = 0UL; /*no use*/
        RSCAN0TXQCC1 = 0UL;
        RSCAN0TXQCC2 = 0UL;
345

hu's avatar
hu committed
346 347 348 349
        /*transmit history buffer*/
        RSCAN0THLCC0 = 0UL; /*no use*/
        RSCAN0THLCC1 = 0UL;
        RSCAN0THLCC2 = 0UL;
350

hu's avatar
hu committed
351 352 353
        /*Enable interrupt of buffer to be used*/
        /*transmit/receive FIFO */
        if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
354
        {
hu's avatar
hu committed
355 356 357 358 359
            RSCAN0CFCC0 |= RSCAN_TR_FIFO_TX_INT_EN;
            RSCAN0CFCC1 |= RSCAN_TR_FIFO_TX_INT_EN;
            RSCAN0CFCC2 |= RSCAN_TR_FIFO_RX_INT_EN;
        }
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
360
        {
hu's avatar
hu committed
361 362 363 364 365 366 367 368 369 370
            RSCAN0CFCC3 |= RSCAN_TR_FIFO_TX_INT_EN;
            RSCAN0CFCC4 |= RSCAN_TR_FIFO_TX_INT_EN;
            RSCAN0CFCC5 |= RSCAN_TR_FIFO_RX_INT_EN;
        }
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
        {
            RSCAN0CFCC6 |= RSCAN_TR_FIFO_TX_INT_EN;
            RSCAN0CFCC7 |= RSCAN_TR_FIFO_TX_INT_EN;
            RSCAN0CFCC8 |= RSCAN_TR_FIFO_RX_INT_EN;
        }
371

hu's avatar
hu committed
372 373 374 375 376 377
        /** transmit abort interrupts**/
        if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
        {
            RSCAN0C0CTR |= RSCAN_ABORT_INT_EN;
        }
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
378
        {
hu's avatar
hu committed
379 380 381
            RSCAN0C1CTR |= RSCAN_ABORT_INT_EN;
        }
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
382
        {
hu's avatar
hu committed
383 384
            RSCAN0C2CTR |= RSCAN_ABORT_INT_EN;
        }
385

hu's avatar
hu committed
386 387 388 389 390 391 392 393 394 395 396 397 398 399
        RSCAN0TMIEC0 = 0UL;
        /* transmit complete interrupts */
        if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
        {
            RSCAN0TMIEC0 |= 0xFFFFUL;
        }
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
        {
            RSCAN0TMIEC0 |= 0xFFFF0000UL;
        }
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
        {
            RSCAN0TMIEC1 = 0xFFFFUL;
        }
400

hu's avatar
hu committed
401 402
        /*Global interrupt*/
        /*	RSCAN0GCTR = 0UL;*/
403

hu's avatar
hu committed
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
        /*Channel interrupt, bus off recovery, error indication*/
        if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
        {
            RSCAN0C0CTR |= RSCAN_RECOVER_ENTRY_HALT_AT_BUSOFF_END;
        }
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
        {
            RSCAN0C1CTR |= RSCAN_RECOVER_ENTRY_HALT_AT_BUSOFF_END;
        }
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
        {
            RSCAN0C2CTR |= RSCAN_RECOVER_ENTRY_HALT_AT_BUSOFF_END;
        }

        /*Interrupt control register of interrupt controller*/

        if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
        {
            R_DEV_IntEnable(R_DEV_INT_RCAN0REC, 1U);
            R_DEV_IntEnable(R_DEV_INT_RCAN0TRX, 1U);
        }
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
        {
            R_DEV_IntEnable(R_DEV_INT_RCAN1REC, 1U);
            R_DEV_IntEnable(R_DEV_INT_RCAN1TRX, 1U);
        }
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
        {
            R_DEV_IntEnable(R_DEV_INT_RCAN2REC, 1U);
            R_DEV_IntEnable(R_DEV_INT_RCAN2TRX, 1U);
        }

        /*Transition to global operating mode*/
        RSCAN0GCTR &= 0xFFFFFFFCUL;
        while ((RSCAN0GSTS & 0x07UL) != 0X00UL)
        {
            ;
        }

        /*Transition to channel communication mode*/
        if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
        {
            RSCAN0C0CTR &= 0xFFFFFFFCUL;
        }
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
        {
            RSCAN0C1CTR &= 0xFFFFFFFCUL;
        }
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
        {
            RSCAN0C2CTR &= 0xFFFFFFFCUL;
        }

        if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
        {
            while ((RSCAN0C0STS & 0x80UL) == 0x0UL)
            {
            }
        }
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
        {
            while ((RSCAN0C1STS & 0x80UL) == 0x0UL)
            {
            }
        }
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
        {
            while ((RSCAN0C2STS & 0x80UL) == 0x0UL)
            {
            }
        }

        /*Enable the applied receive FIFO buffer, transmit/receive
		FIFO, transmit queue or transmit history buffer*/

        /*transmit/receive FIFO */
        if (pstRSCANConfig->stRSCANCh0.u32RSCANChEn)
        {
            RSCAN0CFCC0 |= RSCAN_TR_FIFO_EN;
            RSCAN0CFCC1 |= RSCAN_TR_FIFO_EN;
            RSCAN0CFCC2 |= RSCAN_TR_FIFO_EN;
        }
        if (pstRSCANConfig->stRSCANCh1.u32RSCANChEn)
        {
            RSCAN0CFCC3 |= RSCAN_TR_FIFO_EN;
            RSCAN0CFCC4 |= RSCAN_TR_FIFO_EN;
            RSCAN0CFCC5 |= RSCAN_TR_FIFO_EN;
        }
        if (pstRSCANConfig->stRSCANCh2.u32RSCANChEn)
        {
            RSCAN0CFCC6 |= RSCAN_TR_FIFO_EN;
            RSCAN0CFCC7 |= RSCAN_TR_FIFO_EN;
            RSCAN0CFCC8 |= RSCAN_TR_FIFO_EN;
        }

        g_stRSCAN0Config = *pstRSCANConfig;
500
    }
hu's avatar
hu committed
501 502 503 504 505 506
    return u8Status;
}

void RSCAN0_CH0_Receive(CAN_Frame_st_t *pstCANFrame)
{
    if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANReadMsgCallBack)
507
    {
hu's avatar
hu committed
508
        g_stRSCAN0Config.stRSCANCh0.pfnRSCANReadMsgCallBack(pstCANFrame->u32CANID, pstCANFrame->u8CANLEN, pstCANFrame->unCANData.u8CANData);
509 510
    }
}
hu's avatar
hu committed
511
void RSCAN0_CH1_Receive(CAN_Frame_st_t *pstCANFrame)
512
{
hu's avatar
hu committed
513
    if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANReadMsgCallBack)
514
    {
hu's avatar
hu committed
515
        g_stRSCAN0Config.stRSCANCh1.pfnRSCANReadMsgCallBack(pstCANFrame->u32CANID, pstCANFrame->u8CANLEN, pstCANFrame->unCANData.u8CANData);
516
    }
hu's avatar
hu committed
517 518 519 520
}
void RSCAN0_CH2_Receive(CAN_Frame_st_t *pstCANFrame)
{
    if (g_stRSCAN0Config.stRSCANCh2.pfnRSCANReadMsgCallBack)
521
    {
hu's avatar
hu committed
522
        g_stRSCAN0Config.stRSCANCh2.pfnRSCANReadMsgCallBack(pstCANFrame->u32CANID, pstCANFrame->u8CANLEN, pstCANFrame->unCANData.u8CANData);
523 524 525
    }
}

hu's avatar
hu committed
526
RSCAN_SetState RSCAN0_CH0_Set_FIFO0_Data(CAN_Frame_st_t *pstCANFrame)
527
{
hu's avatar
hu committed
528 529 530 531 532
    uint32_t u32RSCANDataBuf = 0UL;
    uint32_t u32RSCANBufIndexK = (0UL + 3UL * 0UL);
    uint32_t u32RSCANAddress = 0UL;

    RSCAN_SetState enRSCANStatus = RSCAN_SET_COMPLETE;
533

hu's avatar
hu committed
534
    if ((pstCANFrame->u8CANLEN > 8U) || (pstCANFrame == 0UL))
535
    {
hu's avatar
hu committed
536
        enRSCANStatus = RSCAN_SET_ERROR_PARAMETER;
537
    }
hu's avatar
hu committed
538
    if (enRSCANStatus == RSCAN_SET_COMPLETE)
539
    {
hu's avatar
hu committed
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575
        u32RSCANAddress = u32RSCANBufIndexK * 4UL + 0X178UL + RSCAN0_BASE_ADDRESS;

        if (((*((uint32_t *)(u32RSCANAddress))) & 0x00000002UL) == 0x0U)
        //if ((RSCAN0CFSTS3 & 0x00000002UL) == 0x0U)
        {

            u32RSCANDataBuf = pstCANFrame->u8CANFrameIDE;
            u32RSCANDataBuf = u32RSCANDataBuf << 31U;
            u32RSCANDataBuf |= pstCANFrame->u32CANID;

            u32RSCANAddress = u32RSCANBufIndexK * 0x10UL + 0XE80UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = u32RSCANDataBuf;
            //RCFDC0CFDCFID3 = u32RSCANDataBuf;

            u32RSCANDataBuf = pstCANFrame->u8CANLEN;
            u32RSCANAddress = u32RSCANBufIndexK * 0x10UL + 0XE84UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = ((u32RSCANDataBuf) << 28U);
            //RCFDC0CFDCFPTR3 = ((u32RSCANDataBuf) << 28U);

            u32RSCANAddress = u32RSCANBufIndexK * 0x10UL + 0XE88UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = pstCANFrame->unCANData.u32CANData[0U];
            //RCFDC0CFDCFDF0_3 = pstCANFrame->unCANData.u32CANData[0U];
            u32RSCANAddress += 0X04UL;
            (*((uint32_t *)(u32RSCANAddress))) = pstCANFrame->unCANData.u32CANData[1U];
            //RCFDC0CFDCFDF1_3 = pstCANFrame->unCANData.u32CANData[1U];

            u32RSCANAddress = u32RSCANBufIndexK * 0x4UL + 0X1D8UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = 0XFFUL;
            //RCFDC0CFDCFPCTR3 = 0XFFUL;

            enRSCANStatus = RSCAN_SET_COMPLETE;
        }
        else
        {
            enRSCANStatus = RSCAN_SET_ERROR_MSGFULL;
        }
576
    }
hu's avatar
hu committed
577 578

    return enRSCANStatus;
579
}
hu's avatar
hu committed
580 581

RSCAN_SetState RSCAN0_CH1_Set_FIFO0_Data(CAN_Frame_st_t *pstCANFrame)
582
{
hu's avatar
hu committed
583 584 585
    uint32_t u32RSCANDataBuf = 0UL;
    uint32_t u32RSCANBufIndexK = (0UL + 3UL * 1UL);
    uint32_t u32RSCANAddress = 0UL;
586

hu's avatar
hu committed
587 588 589
    RSCAN_SetState enRSCANStatus = RSCAN_SET_COMPLETE;

    if ((pstCANFrame->u8CANLEN > 8U) || (pstCANFrame == 0UL))
590
    {
hu's avatar
hu committed
591
        enRSCANStatus = RSCAN_SET_ERROR_PARAMETER;
592
    }
hu's avatar
hu committed
593
    if (enRSCANStatus == RSCAN_SET_COMPLETE)
594
    {
hu's avatar
hu committed
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
        u32RSCANAddress = u32RSCANBufIndexK * 4UL + 0X178UL + RSCAN0_BASE_ADDRESS;

        if (((*((uint32_t *)(u32RSCANAddress))) & 0x00000002UL) == 0x0U)
        //if ((RSCAN0CFSTS3 & 0x00000002UL) == 0x0U)
        {

            u32RSCANDataBuf = pstCANFrame->u8CANFrameIDE;
            u32RSCANDataBuf = u32RSCANDataBuf << 31U;
            u32RSCANDataBuf |= pstCANFrame->u32CANID;

            u32RSCANAddress = u32RSCANBufIndexK * 0x10UL + 0XE80UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = u32RSCANDataBuf;
            //RCFDC0CFDCFID3 = u32RSCANDataBuf;

            u32RSCANDataBuf = pstCANFrame->u8CANLEN;
            u32RSCANAddress = u32RSCANBufIndexK * 0x10UL + 0XE84UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = ((u32RSCANDataBuf) << 28U);
            //RCFDC0CFDCFPTR3 = ((u32RSCANDataBuf) << 28U);

            u32RSCANAddress = u32RSCANBufIndexK * 0x10UL + 0XE88UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = pstCANFrame->unCANData.u32CANData[0U];
            //RCFDC0CFDCFDF0_3 = pstCANFrame->unCANData.u32CANData[0U];
            u32RSCANAddress += 0X04UL;
            (*((uint32_t *)(u32RSCANAddress))) = pstCANFrame->unCANData.u32CANData[1U];
            //RCFDC0CFDCFDF1_3 = pstCANFrame->unCANData.u32CANData[1U];

            u32RSCANAddress = u32RSCANBufIndexK * 0x4UL + 0X1D8UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = 0XFFUL;
            //RCFDC0CFDCFPCTR3 = 0XFFUL;

            enRSCANStatus = RSCAN_SET_COMPLETE;
        }
        else
        {
            enRSCANStatus = RSCAN_SET_ERROR_MSGFULL;
        }
631
    }
hu's avatar
hu committed
632 633

    return enRSCANStatus;
634
}
hu's avatar
hu committed
635
RSCAN_SetState RSCAN0_CH2_Set_FIFO0_Data(CAN_Frame_st_t *pstCANFrame)
636
{
hu's avatar
hu committed
637 638 639
    uint32_t u32RSCANDataBuf = 0UL;
    uint32_t u32RSCANBufIndexK = (0UL + 3UL * 2UL);
    uint32_t u32RSCANAddress = 0UL;
640

hu's avatar
hu committed
641 642 643
    RSCAN_SetState enRSCANStatus = RSCAN_SET_COMPLETE;

    if ((pstCANFrame->u8CANLEN > 8U) || (pstCANFrame == 0UL))
644
    {
hu's avatar
hu committed
645
        enRSCANStatus = RSCAN_SET_ERROR_PARAMETER;
646
    }
hu's avatar
hu committed
647
    if (enRSCANStatus == RSCAN_SET_COMPLETE)
648
    {
hu's avatar
hu committed
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
        u32RSCANAddress = u32RSCANBufIndexK * 4UL + 0X178UL + RSCAN0_BASE_ADDRESS;

        if (((*((uint32_t *)(u32RSCANAddress))) & 0x00000002UL) == 0x0U)
        //if ((RSCAN0CFSTS3 & 0x00000002UL) == 0x0U)
        {

            u32RSCANDataBuf = pstCANFrame->u8CANFrameIDE;
            u32RSCANDataBuf = u32RSCANDataBuf << 31U;
            u32RSCANDataBuf |= pstCANFrame->u32CANID;

            u32RSCANAddress = u32RSCANBufIndexK * 0x10UL + 0XE80UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = u32RSCANDataBuf;
            //RCFDC0CFDCFID3 = u32RSCANDataBuf;

            u32RSCANDataBuf = pstCANFrame->u8CANLEN;
            u32RSCANAddress = u32RSCANBufIndexK * 0x10UL + 0XE84UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = ((u32RSCANDataBuf) << 28U);
            //RCFDC0CFDCFPTR3 = ((u32RSCANDataBuf) << 28U);

            u32RSCANAddress = u32RSCANBufIndexK * 0x10UL + 0XE88UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = pstCANFrame->unCANData.u32CANData[0U];
            //RCFDC0CFDCFDF0_3 = pstCANFrame->unCANData.u32CANData[0U];
            u32RSCANAddress += 0X04UL;
            (*((uint32_t *)(u32RSCANAddress))) = pstCANFrame->unCANData.u32CANData[1U];
            //RCFDC0CFDCFDF1_3 = pstCANFrame->unCANData.u32CANData[1U];

            u32RSCANAddress = u32RSCANBufIndexK * 0x4UL + 0X1D8UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)(u32RSCANAddress))) = 0XFFUL;
            //RCFDC0CFDCFPCTR3 = 0XFFUL;

            enRSCANStatus = RSCAN_SET_COMPLETE;
        }
        else
        {
            enRSCANStatus = RSCAN_SET_ERROR_MSGFULL;
        }
685
    }
hu's avatar
hu committed
686 687

    return enRSCANStatus;
688 689
}

hu's avatar
hu committed
690 691
/*********************************************************/
RSCAN_SetState RSCAN0_CH0_Set_TXBUF_Data(RSCAN_Channel_Buf_en_t enBufIndex, CAN_Frame_st_t *pstCANFrame)
692
{
hu's avatar
hu committed
693 694 695 696 697 698
    uint8_t i;
    uint32_t u32RSCANDataBuf = 0UL;
    uint32_t u32RSCANBufIndexP = (enBufIndex + 16UL * 0UL);
    uint32_t u32RSCANAddress = 0UL;

    RSCAN_SetState enRSCANStatus = RSCAN_SET_COMPLETE;
699

hu's avatar
hu committed
700
    if ((pstCANFrame->u8CANLEN > 8U) || (pstCANFrame == 0UL) || (pstCANFrame->u8CANFrameIDE > 1U) || (enBufIndex >= RSCAN_CHANNEL_BUF_MAX))
701
    {
hu's avatar
hu committed
702
        enRSCANStatus = RSCAN_SET_ERROR_PARAMETER;
703
    }
hu's avatar
hu committed
704
    if (enRSCANStatus == RSCAN_SET_COMPLETE)
705
    {
hu's avatar
hu committed
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
        u32RSCANAddress = u32RSCANBufIndexP + 0X2D0UL + RSCAN0_BASE_ADDRESS;
        if (((*((uint8_t *)u32RSCANAddress)) & 0x08U) == 0x0U)
        //if ((RSCAN0TMSTS0 & 0x08U) == 0x0U)
        {
            (*((uint8_t *)u32RSCANAddress)) = 0UL;
            //RSCAN0TMSTS0 = 0UL;
            u32RSCANDataBuf = pstCANFrame->u8CANFrameIDE;
            u32RSCANDataBuf = u32RSCANDataBuf << 31U;
            u32RSCANDataBuf |= pstCANFrame->u32CANID;

            u32RSCANAddress = u32RSCANBufIndexP * 0X10UL + 0X1000UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)u32RSCANAddress)) = u32RSCANDataBuf;
            //RCFDC0CFDTMID0 = u32RSCANDataBuf;

            u32RSCANDataBuf = pstCANFrame->u8CANLEN;
            u32RSCANAddress = u32RSCANBufIndexP * 0X10UL + 0X1004UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)u32RSCANAddress)) = (uint32_t)((u32RSCANDataBuf) << 28U);
            //RCFDC0CFDTMPTR0 = (uint32_t)((u32RSCANDataBuf) << 28U);

            u32RSCANAddress = u32RSCANBufIndexP * 0X10UL + 0X1008UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)u32RSCANAddress)) = pstCANFrame->unCANData.u32CANData[0U];
            //RCFDC0CFDTMDF0_0 = pstCANFrame->unCANData.u32CANData[0U];
            u32RSCANAddress += 0X04UL;
            (*((uint32_t *)u32RSCANAddress)) = pstCANFrame->unCANData.u32CANData[1U];
            //RCFDC0CFDTMDF1_0 = pstCANFrame->unCANData.u32CANData[1U];

            u32RSCANAddress = u32RSCANBufIndexP + 0X250UL + RSCAN0_BASE_ADDRESS;
            (*((uint8_t *)u32RSCANAddress)) |= 0X01;
            //RCFDC0CFDTMC0 |= 0X01;

            enRSCANStatus = RSCAN_SET_COMPLETE;
        }
        else
        {
            enRSCANStatus = RSCAN_SET_ERROR_MSGFULL;
        }
742
    }
hu's avatar
hu committed
743
    return enRSCANStatus;
744
}
hu's avatar
hu committed
745 746

RSCAN_SetState RSCAN0_CH1_Set_TXBUF_Data(RSCAN_Channel_Buf_en_t enBufIndex, CAN_Frame_st_t *pstCANFrame)
747 748
{

hu's avatar
hu committed
749 750 751 752 753 754 755 756
    uint8_t i;
    uint32_t u32RSCANDataBuf = 0UL;
    uint32_t u32RSCANBufIndexP = (enBufIndex + 16UL * 1UL);
    uint32_t u32RSCANAddress = 0UL;

    RSCAN_SetState enRSCANStatus = RSCAN_SET_COMPLETE;

    if ((pstCANFrame->u8CANLEN > 8U) || (pstCANFrame == 0UL) || (pstCANFrame->u8CANFrameIDE > 1U) || (enBufIndex >= RSCAN_CHANNEL_BUF_MAX))
757
    {
hu's avatar
hu committed
758
        enRSCANStatus = RSCAN_SET_ERROR_PARAMETER;
759
    }
hu's avatar
hu committed
760
    if (enRSCANStatus == RSCAN_SET_COMPLETE)
761
    {
hu's avatar
hu committed
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
        u32RSCANAddress = u32RSCANBufIndexP + 0X2D0UL + RSCAN0_BASE_ADDRESS;
        if (((*((uint8_t *)u32RSCANAddress)) & 0x08U) == 0x0U)
        //if ((RSCAN0TMSTS0 & 0x08U) == 0x0U)
        {
            (*((uint8_t *)u32RSCANAddress)) = 0UL;
            //RSCAN0TMSTS0 = 0UL;
            u32RSCANDataBuf = pstCANFrame->u8CANFrameIDE;
            u32RSCANDataBuf = u32RSCANDataBuf << 31U;
            u32RSCANDataBuf |= pstCANFrame->u32CANID;

            u32RSCANAddress = u32RSCANBufIndexP * 0X10UL + 0X1000UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)u32RSCANAddress)) = u32RSCANDataBuf;
            //RCFDC0CFDTMID0 = u32RSCANDataBuf;

            u32RSCANDataBuf = pstCANFrame->u8CANLEN;
            u32RSCANAddress = u32RSCANBufIndexP * 0X10UL + 0X1004UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)u32RSCANAddress)) = (uint32_t)((u32RSCANDataBuf) << 28U);
            //RCFDC0CFDTMPTR0 = (uint32_t)((u32RSCANDataBuf) << 28U);

            u32RSCANAddress = u32RSCANBufIndexP * 0X10UL + 0X1008UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)u32RSCANAddress)) = pstCANFrame->unCANData.u32CANData[0U];
            //RCFDC0CFDTMDF0_0 = pstCANFrame->unCANData.u32CANData[0U];
            u32RSCANAddress += 0X04UL;
            (*((uint32_t *)u32RSCANAddress)) = pstCANFrame->unCANData.u32CANData[1U];
            //RCFDC0CFDTMDF1_0 = pstCANFrame->unCANData.u32CANData[1U];

            u32RSCANAddress = u32RSCANBufIndexP + 0X250UL + RSCAN0_BASE_ADDRESS;
            (*((uint8_t *)u32RSCANAddress)) |= 0X01;
            //RCFDC0CFDTMC0 |= 0X01;

            enRSCANStatus = RSCAN_SET_COMPLETE;
        }
        else
        {
            enRSCANStatus = RSCAN_SET_ERROR_MSGFULL;
        }
798
    }
hu's avatar
hu committed
799
    return enRSCANStatus;
800
}
hu's avatar
hu committed
801 802

RSCAN_SetState RSCAN0_CH2_Set_TXBUF_Data(RSCAN_Channel_Buf_en_t enBufIndex, CAN_Frame_st_t *pstCANFrame)
803 804
{

hu's avatar
hu committed
805 806 807 808 809 810 811 812
    uint8_t i;
    uint32_t u32RSCANDataBuf = 0UL;
    uint32_t u32RSCANBufIndexP = (enBufIndex + 16UL * 2UL);
    uint32_t u32RSCANAddress = 0UL;

    RSCAN_SetState enRSCANStatus = RSCAN_SET_COMPLETE;

    if ((pstCANFrame->u8CANLEN > 8U) || (pstCANFrame == 0UL) || (pstCANFrame->u8CANFrameIDE > 1U) || (enBufIndex >= RSCAN_CHANNEL_BUF_MAX))
813
    {
hu's avatar
hu committed
814
        enRSCANStatus = RSCAN_SET_ERROR_PARAMETER;
815
    }
hu's avatar
hu committed
816
    if (enRSCANStatus == RSCAN_SET_COMPLETE)
817
    {
hu's avatar
hu committed
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853
        u32RSCANAddress = u32RSCANBufIndexP + 0X2D0UL + RSCAN0_BASE_ADDRESS;
        if (((*((uint8_t *)u32RSCANAddress)) & 0x08U) == 0x0U)
        //if ((RSCAN0TMSTS0 & 0x08U) == 0x0U)
        {
            (*((uint8_t *)u32RSCANAddress)) = 0UL;
            //RSCAN0TMSTS0 = 0UL;
            u32RSCANDataBuf = pstCANFrame->u8CANFrameIDE;
            u32RSCANDataBuf = u32RSCANDataBuf << 31U;
            u32RSCANDataBuf |= pstCANFrame->u32CANID;

            u32RSCANAddress = u32RSCANBufIndexP * 0X10UL + 0X1000UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)u32RSCANAddress)) = u32RSCANDataBuf;
            //RCFDC0CFDTMID0 = u32RSCANDataBuf;

            u32RSCANDataBuf = pstCANFrame->u8CANLEN;
            u32RSCANAddress = u32RSCANBufIndexP * 0X10UL + 0X1004UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)u32RSCANAddress)) = (uint32_t)((u32RSCANDataBuf) << 28U);
            //RCFDC0CFDTMPTR0 = (uint32_t)((u32RSCANDataBuf) << 28U);

            u32RSCANAddress = u32RSCANBufIndexP * 0X10UL + 0X1008UL + RSCAN0_BASE_ADDRESS;
            (*((uint32_t *)u32RSCANAddress)) = pstCANFrame->unCANData.u32CANData[0U];
            //RCFDC0CFDTMDF0_0 = pstCANFrame->unCANData.u32CANData[0U];
            u32RSCANAddress += 0X04UL;
            (*((uint32_t *)u32RSCANAddress)) = pstCANFrame->unCANData.u32CANData[1U];
            //RCFDC0CFDTMDF1_0 = pstCANFrame->unCANData.u32CANData[1U];

            u32RSCANAddress = u32RSCANBufIndexP + 0X250UL + RSCAN0_BASE_ADDRESS;
            (*((uint8_t *)u32RSCANAddress)) |= 0X01;
            //RCFDC0CFDTMC0 |= 0X01;

            enRSCANStatus = RSCAN_SET_COMPLETE;
        }
        else
        {
            enRSCANStatus = RSCAN_SET_ERROR_MSGFULL;
        }
854
    }
hu's avatar
hu committed
855
    return enRSCANStatus;
856 857
}

hu's avatar
hu committed
858 859 860 861 862 863 864 865
/*
0: Not in Receive state
1: In Receive state
*/
uint8_t RSCAN0_CH0_Get_Rec_Status(void)
{
    uint8_t u8RSCANStatus = 0U;
    if (RSCAN0C0STS & 0x40UL)
866
    {
hu's avatar
hu committed
867
        u8RSCANStatus = 1U;
868
    }
hu's avatar
hu committed
869 870 871 872 873 874 875 876

    return u8RSCANStatus;
}

uint8_t RSCAN0_CH1_Get_Rec_Status(void)
{
    uint8_t u8RSCANStatus = 0U;
    if (RSCAN0C1STS & 0x40UL)
877
    {
hu's avatar
hu committed
878
        u8RSCANStatus = 1U;
879
    }
hu's avatar
hu committed
880 881

    return u8RSCANStatus;
882
}
hu's avatar
hu committed
883
uint8_t RSCAN0_CH2_Get_Rec_Status(void)
884
{
hu's avatar
hu committed
885 886
    uint8_t u8RSCANStatus = 0U;
    if (RSCAN0C2STS & 0x40UL)
887
    {
hu's avatar
hu committed
888
        u8RSCANStatus = 1U;
889
    }
hu's avatar
hu committed
890 891 892 893 894 895 896 897 898 899 900 901

    return u8RSCANStatus;
}

/*
0: Not in bus off state
1: In bus off state
*/
uint8_t RSCAN0_CH0_Get_Busoff_Status(void)
{
    uint8_t u8BusoffStatus = 0U;
    if (RSCAN0C0ERFL & 0x08UL)
902
    {
hu's avatar
hu committed
903
        u8BusoffStatus = 1U;
904
    }
hu's avatar
hu committed
905 906

    return u8BusoffStatus;
907
}
hu's avatar
hu committed
908 909

uint8_t RSCAN0_CH1_Get_Busoff_Status(void)
910
{
hu's avatar
hu committed
911
    uint8_t u8BusoffStatus = 0U;
912

hu's avatar
hu committed
913
    if (RSCAN0C1ERFL & 0x08UL)
914
    {
hu's avatar
hu committed
915
        u8BusoffStatus = 1U;
916
    }
hu's avatar
hu committed
917 918

    return u8BusoffStatus;
919
}
hu's avatar
hu committed
920
uint8_t RSCAN0_CH2_Get_Busoff_Status(void)
921
{
hu's avatar
hu committed
922 923
    uint8_t u8BusoffStatus = 0U;
    if (RSCAN0C2ERFL & 0x08UL)
924
    {
hu's avatar
hu committed
925
        u8BusoffStatus = 1U;
926
    }
hu's avatar
hu committed
927 928 929 930 931 932 933

    return u8BusoffStatus;
}

void RSCAN0_CH0_Busoff_Recover(void)
{
    if (RSCAN0_CH0_Get_Busoff_Status())
934
    {
hu's avatar
hu committed
935 936 937 938 939
        RSCAN0C0ERFL &= 0xFFFFFFF7UL;
        RSCAN0C0CTR &= 0xFFFFFFF8UL; /*  CommunicationMode */
        while ((RSCAN0C0STS & 0x87UL) != 0x80UL)
        {
        }
940 941
    }
}
hu's avatar
hu committed
942
void RSCAN0_CH1_Busoff_Recover(void)
943
{
hu's avatar
hu committed
944
    if (RSCAN0_CH1_Get_Busoff_Status())
945
    {
hu's avatar
hu committed
946 947 948 949 950
        RSCAN0C1ERFL &= 0xFFFFFFF7UL;
        RSCAN0C1CTR &= 0xFFFFFFF8UL; /*  CommunicationMode */
        while ((RSCAN0C1STS & 0x87UL) != 0x80UL)
        {
        }
951
    }
hu's avatar
hu committed
952 953 954 955
}
void RSCAN0_CH2_Busoff_Recover(void)
{
    if (RSCAN0_CH2_Get_Busoff_Status())
956
    {
hu's avatar
hu committed
957 958 959 960 961
        RSCAN0C2ERFL &= 0xFFFFFFF7UL;
        RSCAN0C2CTR &= 0xFFFFFFF8UL; /*  CommunicationMode */
        while ((RSCAN0C2STS & 0x87UL) != 0x80UL)
        {
        }
962 963
    }
}
hu's avatar
hu committed
964 965
/*****************************/
void RSCAN0_CH0_Abort(RSCAN_Channel_Buf_en_t enBufIndex)
966
{
hu's avatar
hu committed
967 968 969 970
    uint32_t u32RSCANBufIndexP = (enBufIndex + 16UL * 0UL);
    uint32_t u32RSCANAddress = 0UL;

    RSCAN_SetState enRSCANStatus = RSCAN_SET_COMPLETE;
971

hu's avatar
hu committed
972
    if ((enBufIndex >= RSCAN_CHANNEL_BUF_MAX))
973
    {
hu's avatar
hu committed
974
        enRSCANStatus = RSCAN_SET_ERROR_PARAMETER;
975
    }
hu's avatar
hu committed
976
    if (enRSCANStatus == RSCAN_SET_COMPLETE)
977
    {
hu's avatar
hu committed
978 979 980
        u32RSCANAddress = u32RSCANBufIndexP + 0X250UL + RSCAN0_BASE_ADDRESS;
        (*((uint8_t *)u32RSCANAddress)) |= 0X02U;
        //RCFDC0CFDTMC0 |= 0X02;
981 982
    }
}
hu's avatar
hu committed
983
void RSCAN0_CH1_Abort(RSCAN_Channel_Buf_en_t enBufIndex)
984
{
hu's avatar
hu committed
985 986
    uint32_t u32RSCANBufIndexP = (enBufIndex + 16UL * 1UL);
    uint32_t u32RSCANAddress = 0UL;
987

hu's avatar
hu committed
988 989 990
    RSCAN_SetState enRSCANStatus = RSCAN_SET_COMPLETE;

    if ((enBufIndex >= RSCAN_CHANNEL_BUF_MAX))
991
    {
hu's avatar
hu committed
992
        enRSCANStatus = RSCAN_SET_ERROR_PARAMETER;
993
    }
hu's avatar
hu committed
994
    if (enRSCANStatus == RSCAN_SET_COMPLETE)
995
    {
hu's avatar
hu committed
996 997 998
        u32RSCANAddress = u32RSCANBufIndexP + 0X250UL + RSCAN0_BASE_ADDRESS;
        (*((uint8_t *)u32RSCANAddress)) |= 0X02U;
        //RCFDC0CFDTMC0 |= 0X02;
999 1000
    }
}
hu's avatar
hu committed
1001
void RSCAN0_CH2_Abort(RSCAN_Channel_Buf_en_t enBufIndex)
1002
{
hu's avatar
hu committed
1003 1004 1005 1006
    uint32_t u32RSCANBufIndexP = (enBufIndex + 16UL * 2UL);
    uint32_t u32RSCANAddress = 0UL;

    RSCAN_SetState enRSCANStatus = RSCAN_SET_COMPLETE;
1007

hu's avatar
hu committed
1008
    if ((enBufIndex >= RSCAN_CHANNEL_BUF_MAX))
1009
    {
hu's avatar
hu committed
1010
        enRSCANStatus = RSCAN_SET_ERROR_PARAMETER;
1011
    }
hu's avatar
hu committed
1012
    if (enRSCANStatus == RSCAN_SET_COMPLETE)
1013
    {
hu's avatar
hu committed
1014 1015 1016
        u32RSCANAddress = u32RSCANBufIndexP + 0X250UL + RSCAN0_BASE_ADDRESS;
        (*((uint8_t *)u32RSCANAddress)) |= 0X02U;
        //RCFDC0CFDTMC0 |= 0X02;
1017 1018
    }
}
hu's avatar
hu committed
1019 1020 1021 1022 1023

/*
如果CAN模块休眠了,但是芯片没休眠,CAN报文无法唤醒CAN模块。
*/
void RSCAN0_CH0_Sleep_Init(void)
1024
{
hu's avatar
hu committed
1025 1026
    RSCAN0C0CTR &= 0xfffffff9UL;
    RSCAN0C0CTR |= 0x01UL;
1027

hu's avatar
hu committed
1028
    while ((RSCAN0C0STS & 0x07UL) != 0X01UL)
1029
    {
hu's avatar
hu committed
1030 1031 1032 1033 1034 1035
        ;
    }
    RSCAN0C0CTR |= 0x04UL;
    while ((RSCAN0C0STS & 0x07UL) != 0X04UL)
    {
        ;
1036 1037
    }
}
hu's avatar
hu committed
1038
void RSCAN0_CH1_Sleep_Init(void)
1039
{
hu's avatar
hu committed
1040 1041
    RSCAN0C1CTR &= 0xfffffff9UL;
    RSCAN0C1CTR |= 0x01UL;
1042

hu's avatar
hu committed
1043
    while ((RSCAN0C1STS & 0x07UL) != 0X01UL)
1044
    {
hu's avatar
hu committed
1045
        ;
1046
    }
hu's avatar
hu committed
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056
    RSCAN0C1CTR |= 0x04UL;
    while ((RSCAN0C1STS & 0x07UL) != 0X04UL)
    {
        ;
    }
}
void RSCAN0_CH2_Sleep_Init(void)
{
    RSCAN0C2CTR &= 0xfffffff9UL;
    RSCAN0C2CTR |= 0x01UL;
1057

hu's avatar
hu committed
1058
    while ((RSCAN0C2STS & 0x07UL) != 0X01UL)
1059
    {
hu's avatar
hu committed
1060 1061 1062 1063 1064 1065 1066 1067
        ;
    }
    RSCAN0C2CTR |= 0x04UL;
    while ((RSCAN0C2STS & 0x07UL) != 0X04UL)
    {
        ;
    }
}
1068

hu's avatar
hu committed
1069 1070 1071 1072
void RSCAN0_Sleep_Init(void)
{
    RSCAN0GCTR &= 0xfffffff9UL;
    RSCAN0GCTR |= 0x01UL;
1073

hu's avatar
hu committed
1074 1075 1076
    while ((RSCAN0GSTS & 0x07UL) != 0X01UL)
    {
        ;
1077
    }
hu's avatar
hu committed
1078 1079 1080 1081

    RSCAN0GCTR |= 0x04UL;
    // while ( (RSCAN0GSTS & 0x07UL) != 0X04UL )
    while ((RSCAN0GSTS & 0x04UL) != 0X04UL)
1082
    {
hu's avatar
hu committed
1083
        ;
1084 1085
    }
}
hu's avatar
hu committed
1086 1087

uint8_t RSCAN0_CH0_TX_Error_Count(void)
1088
{
hu's avatar
hu committed
1089 1090 1091
    uint8_t u8ErrorCount = 0U;
    u8ErrorCount = (uint8_t)(RSCAN0C0STS >> 24U);
    return u8ErrorCount;
1092
}
hu's avatar
hu committed
1093
uint8_t RSCAN0_CH1_TX_Error_Count(void)
1094
{
hu's avatar
hu committed
1095 1096 1097
    uint8_t u8ErrorCount = 0U;
    u8ErrorCount = (uint8_t)(RSCAN0C1STS >> 24U);
    return u8ErrorCount;
1098
}
hu's avatar
hu committed
1099
uint8_t RSCAN0_CH2_TX_Error_Count(void)
1100
{
hu's avatar
hu committed
1101 1102 1103
    uint8_t u8ErrorCount = 0U;
    u8ErrorCount = (uint8_t)(RSCAN0C2STS >> 24U);
    return u8ErrorCount;
1104
}
hu's avatar
hu committed
1105 1106

uint8_t RSCAN0_CH0_RX_Error_Count(void)
1107
{
hu's avatar
hu committed
1108 1109 1110
    uint8_t u8ErrorCount = 0U;
    u8ErrorCount = (uint8_t)(RSCAN0C0STS >> 16U);
    return u8ErrorCount;
1111
}
hu's avatar
hu committed
1112
uint8_t RSCAN0_CH1_RX_Error_Count(void)
1113
{
hu's avatar
hu committed
1114 1115 1116
    uint8_t u8ErrorCount = 0U;
    u8ErrorCount = (uint8_t)(RSCAN0C1STS >> 16U);
    return u8ErrorCount;
1117
}
hu's avatar
hu committed
1118
uint8_t RSCAN0_CH2_RX_Error_Count(void)
1119
{
hu's avatar
hu committed
1120 1121 1122
    uint8_t u8ErrorCount = 0U;
    u8ErrorCount = (uint8_t)(RSCAN0C2STS >> 16U);
    return u8ErrorCount;
1123
}
hu's avatar
hu committed
1124 1125 1126 1127 1128 1129

/****************************************************/

/******************************************************************/

void RSCAN0_CH0_RX_ISR(void)
1130
{
hu's avatar
hu committed
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148
    if (RSCAN0CFSTS2 & 0X08UL)
    {
        CAN_Frame_Receive_st_t stCANFrameReceive;
        RSCAN0CFSTS2 &= 0xFFFFFFF7UL;

        while ((RSCAN0CFSTS2 & 0x01UL) == 0U)
        {
            stCANFrameReceive.stReceiveContent.u32CANID = (uint32_t)(RSCAN0CFID2 & 0x1FFFFFFFUL);
            stCANFrameReceive.stReceiveContent.u8CANLEN = (uint8_t)(RSCAN0CFPTR2 >> 28U);
            stCANFrameReceive.stReceiveContent.u8CANFrameIDE = (uint8_t)((RSCAN0CFID2 >> 31U));
            stCANFrameReceive.stReceiveContent.unCANData.u32CANData[0U] = RSCAN0CFDF02;
            stCANFrameReceive.stReceiveContent.unCANData.u32CANData[1U] = RSCAN0CFDF12;

            RSCAN0CFPCTR2 = 0xFFU;

            RSCAN0_CH0_Receive(&stCANFrameReceive.stReceiveContent);
        }
    }
1149 1150
}

hu's avatar
hu committed
1151
void RSCAN0_CH1_RX_ISR(void)
1152
{
hu's avatar
hu committed
1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170
    if (RSCAN0CFSTS5 & 0X08UL)
    {
        CAN_Frame_Receive_st_t stCANFrameReceive;
        RSCAN0CFSTS5 &= 0xFFFFFFF7UL;

        while ((RSCAN0CFSTS5 & 0x01UL) == 0U)
        {
            stCANFrameReceive.stReceiveContent.u32CANID = (uint32_t)(RSCAN0CFID5 & 0x1FFFFFFFUL);
            stCANFrameReceive.stReceiveContent.u8CANLEN = (uint8_t)(RSCAN0CFPTR5 >> 28U);
            stCANFrameReceive.stReceiveContent.u8CANFrameIDE = (uint8_t)((RSCAN0CFID5 >> 31U));
            stCANFrameReceive.stReceiveContent.unCANData.u32CANData[0U] = RSCAN0CFDF05;
            stCANFrameReceive.stReceiveContent.unCANData.u32CANData[1U] = RSCAN0CFDF15;

            RSCAN0CFPCTR5 = 0xFFU;

            RSCAN0_CH1_Receive(&stCANFrameReceive.stReceiveContent);
        }
    }
1171 1172
}

hu's avatar
hu committed
1173
void RSCAN0_CH2_RX_ISR(void)
1174
{
hu's avatar
hu committed
1175 1176

    if (RSCAN0CFSTS8 & 0X08UL)
1177
    {
hu's avatar
hu committed
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192
        CAN_Frame_Receive_st_t stCANFrameReceive;
        RSCAN0CFSTS8 &= 0xFFFFFFF7UL;

        while ((RSCAN0CFSTS8 & 0x01UL) == 0U)
        {
            stCANFrameReceive.stReceiveContent.u32CANID = (uint32_t)(RSCAN0CFID8 & 0x1FFFFFFFUL);
            stCANFrameReceive.stReceiveContent.u8CANLEN = (uint8_t)(RSCAN0CFPTR8 >> 28U);
            stCANFrameReceive.stReceiveContent.u8CANFrameIDE = (uint8_t)((RSCAN0CFID8 >> 31U));
            stCANFrameReceive.stReceiveContent.unCANData.u32CANData[0U] = RSCAN0CFDF08;
            stCANFrameReceive.stReceiveContent.unCANData.u32CANData[1U] = RSCAN0CFDF18;

            RSCAN0CFPCTR8 = 0xFFU;

            RSCAN0_CH2_Receive(&stCANFrameReceive.stReceiveContent);
        }
1193
    }
hu's avatar
hu committed
1194 1195 1196 1197 1198 1199
}

void RSCAN0_CH0_TX_ISR(void)
{

    if (RSCAN0CFSTS0 & 0X10UL)
1200
    {
hu's avatar
hu committed
1201
        RSCAN0CFSTS0 &= 0XFFFFFFEFUL;
1202
    }
hu's avatar
hu committed
1203
    if (RSCAN0CFSTS1 & 0X10UL)
1204
    {
hu's avatar
hu committed
1205
        RSCAN0CFSTS1 &= 0XFFFFFFEFUL;
1206
    }
hu's avatar
hu committed
1207 1208

    if ((RSCAN0TMSTS0 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1209
    {
hu's avatar
hu committed
1210 1211 1212 1213 1214
        RSCAN0TMSTS0 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(0, 0);
        }
1215
    }
hu's avatar
hu committed
1216
    else if ((RSCAN0TMSTS0 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
1217
    {
hu's avatar
hu committed
1218 1219 1220 1221 1222
        RSCAN0TMSTS0 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(0U);
        }
1223
    }
hu's avatar
hu committed
1224
    if ((RSCAN0TMSTS1 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1225
    {
hu's avatar
hu committed
1226 1227 1228 1229 1230
        RSCAN0TMSTS1 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(1, 0);
        }
1231
    }
hu's avatar
hu committed
1232
    else if ((RSCAN0TMSTS1 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
1233
    {
hu's avatar
hu committed
1234 1235 1236 1237 1238
        RSCAN0TMSTS1 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(1U);
        }
1239
    }
hu's avatar
hu committed
1240
    if ((RSCAN0TMSTS2 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1241
    {
hu's avatar
hu committed
1242 1243 1244 1245 1246
        RSCAN0TMSTS2 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(2, 0);
        }
1247
    }
hu's avatar
hu committed
1248
    else if ((RSCAN0TMSTS2 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
1249
    {
hu's avatar
hu committed
1250 1251 1252 1253 1254
        RSCAN0TMSTS2 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(2U);
        }
1255
    }
hu's avatar
hu committed
1256
    if ((RSCAN0TMSTS3 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1257
    {
hu's avatar
hu committed
1258 1259 1260 1261 1262
        RSCAN0TMSTS3 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(3, 0);
        }
1263
    }
hu's avatar
hu committed
1264
    else if ((RSCAN0TMSTS3 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
1265
    {
hu's avatar
hu committed
1266 1267 1268 1269 1270
        RSCAN0TMSTS3 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(3U);
        }
1271
    }
hu's avatar
hu committed
1272
    if ((RSCAN0TMSTS4 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1273
    {
hu's avatar
hu committed
1274 1275 1276 1277 1278
        RSCAN0TMSTS4 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(4, 0);
        }
1279
    }
hu's avatar
hu committed
1280
    else if ((RSCAN0TMSTS4 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
1281
    {
hu's avatar
hu committed
1282 1283 1284 1285 1286
        RSCAN0TMSTS4 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(4U);
        }
1287
    }
hu's avatar
hu committed
1288
    if ((RSCAN0TMSTS5 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1289
    {
hu's avatar
hu committed
1290 1291 1292 1293 1294
        RSCAN0TMSTS5 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(5, 0);
        }
1295
    }
hu's avatar
hu committed
1296
    else if ((RSCAN0TMSTS5 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
1297
    {
hu's avatar
hu committed
1298 1299 1300 1301 1302
        RSCAN0TMSTS5 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(5U);
        }
1303
    }
hu's avatar
hu committed
1304
    if ((RSCAN0TMSTS6 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1305
    {
hu's avatar
hu committed
1306 1307 1308 1309 1310
        RSCAN0TMSTS6 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(6, 0);
        }
1311
    }
hu's avatar
hu committed
1312
    else if ((RSCAN0TMSTS6 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
1313
    {
hu's avatar
hu committed
1314 1315 1316 1317 1318
        RSCAN0TMSTS6 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(6U);
        }
1319
    }
hu's avatar
hu committed
1320
    if ((RSCAN0TMSTS7 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1321
    {
hu's avatar
hu committed
1322 1323 1324 1325 1326
        RSCAN0TMSTS7 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(7, 0);
        }
1327
    }
hu's avatar
hu committed
1328
    else if ((RSCAN0TMSTS7 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
1329
    {
hu's avatar
hu committed
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462
        RSCAN0TMSTS7 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(7U);
        }
    }
    if ((RSCAN0TMSTS8 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS8 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(8, 0);
        }
    }
    else if ((RSCAN0TMSTS8 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS8 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(8U);
        }
    }
    if ((RSCAN0TMSTS9 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS9 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(9, 0);
        }
    }
    else if ((RSCAN0TMSTS9 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS9 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(9U);
        }
    }
    if ((RSCAN0TMSTS10 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS10 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(10, 0);
        }
    }
    else if ((RSCAN0TMSTS10 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS10 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(10U);
        }
    }
    if ((RSCAN0TMSTS11 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS11 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(11, 0);
        }
    }
    else if ((RSCAN0TMSTS11 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS11 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(11U);
        }
    }
    if ((RSCAN0TMSTS12 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS12 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(12, 0);
        }
    }
    else if ((RSCAN0TMSTS12 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS12 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(12U);
        }
    }
    if ((RSCAN0TMSTS13 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS13 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(13, 0);
        }
    }
    else if ((RSCAN0TMSTS13 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS13 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(13U);
        }
    }
    if ((RSCAN0TMSTS14 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS14 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(14, 0);
        }
    }
    else if ((RSCAN0TMSTS14 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS14 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(14U);
        }
    }
    if ((RSCAN0TMSTS15 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS15 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(15, 0);
        }
    }
    else if ((RSCAN0TMSTS15 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS15 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(15U);
        }
1463 1464 1465
    }
}

hu's avatar
hu committed
1466
void RSCAN0_CH1_TX_ISR(void)
1467 1468
{

hu's avatar
hu committed
1469 1470 1471 1472 1473 1474 1475 1476
    if (RSCAN0CFSTS3 & 0X10UL)
    {
        RSCAN0CFSTS3 &= 0XFFFFFFEFUL;
    }
    if (RSCAN0CFSTS4 & 0X10UL)
    {
        RSCAN0CFSTS4 &= 0XFFFFFFEFUL;
    }
1477

hu's avatar
hu committed
1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733
    if ((RSCAN0TMSTS16 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS16 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(16, 0);
        }
    }
    else if ((RSCAN0TMSTS16 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS16 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(16U);
        }
    }
    if ((RSCAN0TMSTS17 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS17 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(17, 0);
        }
    }
    else if ((RSCAN0TMSTS17 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS17 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(17U);
        }
    }
    if ((RSCAN0TMSTS18 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS18 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(18, 0);
        }
    }
    else if ((RSCAN0TMSTS18 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS18 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(18U);
        }
    }
    if ((RSCAN0TMSTS19 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS19 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(19, 0);
        }
    }
    else if ((RSCAN0TMSTS19 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS19 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(19U);
        }
    }
    if ((RSCAN0TMSTS20 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS20 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(20, 0);
        }
    }
    else if ((RSCAN0TMSTS20 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS20 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(20U);
        }
    }
    if ((RSCAN0TMSTS21 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS21 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(21, 0);
        }
    }
    else if ((RSCAN0TMSTS21 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS21 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(21U);
        }
    }
    if ((RSCAN0TMSTS22 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS22 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(22, 0);
        }
    }
    else if ((RSCAN0TMSTS22 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS22 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(22U);
        }
    }
    if ((RSCAN0TMSTS23 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS23 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(23, 0);
        }
    }
    else if ((RSCAN0TMSTS23 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS23 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(23U);
        }
    }
    if ((RSCAN0TMSTS24 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS24 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(24, 0);
        }
    }
    else if ((RSCAN0TMSTS24 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS24 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(24U);
        }
    }
    if ((RSCAN0TMSTS25 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS25 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(25, 0);
        }
    }
    else if ((RSCAN0TMSTS25 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS25 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(25U);
        }
    }
    if ((RSCAN0TMSTS26 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS26 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(26, 0);
        }
    }
    else if ((RSCAN0TMSTS26 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS26 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(26U);
        }
    }
    if ((RSCAN0TMSTS27 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS27 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(27, 0);
        }
    }
    else if ((RSCAN0TMSTS27 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS27 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(27U);
        }
    }
    if ((RSCAN0TMSTS28 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS28 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(28, 0);
        }
    }
    else if ((RSCAN0TMSTS28 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS28 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(28U);
        }
    }
    if ((RSCAN0TMSTS29 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS29 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(29, 0);
        }
    }
    else if ((RSCAN0TMSTS29 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS29 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(29U);
        }
    }
    if ((RSCAN0TMSTS30 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS30 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(30, 0);
        }
    }
    else if ((RSCAN0TMSTS30 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS30 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(30U);
        }
    }
    if ((RSCAN0TMSTS31 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS31 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANConfirmCallBack(31, 0);
        }
    }
    else if ((RSCAN0TMSTS31 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS31 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh0.pfnRSCANAbortConfirmCallBack(31U);
        }
    }
1734 1735
}

hu's avatar
hu committed
1736
void RSCAN0_CH2_TX_ISR(void)
1737
{
hu's avatar
hu committed
1738 1739 1740 1741 1742 1743 1744 1745
    if (RSCAN0CFSTS6 & 0X10UL)
    {
        RSCAN0CFSTS6 &= 0XFFFFFFEFUL;
    }
    if (RSCAN0CFSTS7 & 0X10UL)
    {
        RSCAN0CFSTS7 &= 0XFFFFFFEFUL;
    }
1746

hu's avatar
hu committed
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762
    if ((RSCAN0TMSTS32 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS32 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(0, 0);
        }
    }
    else if ((RSCAN0TMSTS32 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS32 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(0U);
        }
    }
1763

hu's avatar
hu committed
1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779
    if ((RSCAN0TMSTS33 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS33 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(1U, 0U);
        }
    }
    else if ((RSCAN0TMSTS33 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS33 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(1U);
        }
    }
1780

hu's avatar
hu committed
1781
    if ((RSCAN0TMSTS34 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1782
    {
hu's avatar
hu committed
1783 1784 1785 1786 1787
        RSCAN0TMSTS34 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(2U, 0U);
        }
1788
    }
hu's avatar
hu committed
1789
    else if ((RSCAN0TMSTS34 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
1790
    {
hu's avatar
hu committed
1791 1792 1793 1794 1795
        RSCAN0TMSTS34 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(2U);
        }
1796 1797
    }

hu's avatar
hu committed
1798
    if ((RSCAN0TMSTS35 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1799
    {
hu's avatar
hu committed
1800 1801 1802 1803 1804
        RSCAN0TMSTS35 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(3U, 0U);
        }
1805
    }
hu's avatar
hu committed
1806
    else if ((RSCAN0TMSTS35 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
1807
    {
hu's avatar
hu committed
1808 1809 1810 1811 1812
        RSCAN0TMSTS35 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(3U);
        }
1813 1814
    }

hu's avatar
hu committed
1815
    if ((RSCAN0TMSTS36 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1816
    {
hu's avatar
hu committed
1817 1818 1819 1820 1821
        RSCAN0TMSTS36 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(4U, 0U);
        }
1822
    }
hu's avatar
hu committed
1823
    else if ((RSCAN0TMSTS36 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
1824
    {
hu's avatar
hu committed
1825 1826 1827 1828 1829
        RSCAN0TMSTS36 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(4U);
        }
1830
    }
hu's avatar
hu committed
1831
    if ((RSCAN0TMSTS37 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
1832
    {
hu's avatar
hu committed
1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005
        RSCAN0TMSTS37 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(5U, 0U);
        }
    }
    else if ((RSCAN0TMSTS37 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS37 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(5U);
        }
    }
    if ((RSCAN0TMSTS38 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS38 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(6U, 0U);
        }
    }
    else if ((RSCAN0TMSTS38 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS38 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(6U);
        }
    }
    if ((RSCAN0TMSTS39 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS39 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(7U, 0U);
        }
    }
    else if ((RSCAN0TMSTS39 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS39 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(7U);
        }
    }
    if ((RSCAN0TMSTS40 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS40 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(8U, 0U);
        }
    }
    else if ((RSCAN0TMSTS40 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS40 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(8U);
        }
    }
    if ((RSCAN0TMSTS41 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS41 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(9U, 0U);
        }
    }
    else if ((RSCAN0TMSTS41 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS41 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(9U);
        }
    }
    if ((RSCAN0TMSTS42 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS42 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(10U, 0U);
        }
    }
    else if ((RSCAN0TMSTS42 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS42 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(10U);
        }
    }
    if ((RSCAN0TMSTS43 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS43 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(11U, 0U);
        }
    }
    else if ((RSCAN0TMSTS43 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS43 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(11U);
        }
    }
    if ((RSCAN0TMSTS44 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS44 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(12U, 0U);
        }
    }
    else if ((RSCAN0TMSTS44 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS44 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(12U);
        }
    }
    if ((RSCAN0TMSTS45 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS45 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(13U, 0U);
        }
    }
    else if ((RSCAN0TMSTS45 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS45 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(13U);
        }
    }
    if ((RSCAN0TMSTS46 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS46 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(14U, 0U);
        }
    }
    else if ((RSCAN0TMSTS46 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS46 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(14U);
        }
    }
    if ((RSCAN0TMSTS47 & RSCAN_TX_CPLT_AND) == RSCAN_TX_CPLT)
    {
        RSCAN0TMSTS47 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANConfirmCallBack(15U, 0U);
        }
    }
    else if ((RSCAN0TMSTS47 & RSCAN_ABORT_CPLT_AND) == RSCAN_ABORT_CPLT)
    {
        RSCAN0TMSTS47 = 0X0U;
        if (g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack)
        {
            g_stRSCAN0Config.stRSCANCh1.pfnRSCANAbortConfirmCallBack(15U);
        }
2006 2007
    }
}
hu's avatar
hu committed
2008 2009

/*********************************************************************/