Functions

group group_canfd_functions

Functions

__STATIC_INLINE void Cy_CANFD_Enable (CANFD_Type *base, uint32_t channelMask)

Enables the CAN FD channels.

note

Call Cy_CANFD_Enable before Cy_CANFD_Init.

Function Usage

    /* Scenario:  The CAN FD block and channel must be enabled. */
    uint32_t channelMask = 0x00000001UL; /* Enable the first channel */
    Cy_CANFD_Enable(CANFD0, channelMask);

Parameters
  • *base: The CAN FD registers structure pointer.

  • channelMask: The channel mask (0-0xFF).

__STATIC_INLINE cy_en_canfd_status_t Cy_CANFD_Disable (CANFD_Type *base, uint32_t channelMask)

Disables the CAN FD channels to stop providing clocks to un-used CAN channels for power saving with this functionality.

note

Call Cy_CANFD_Disable only after Cy_CANFD_DeInit. Do not access the CAN FD registers until calling Cy_CANFD_Enable again.

Function Usage

    /* Scenario:  CAN FD no longer in use, a channel or channels must be switched off */
    uint32_t channelMask = 0x00000001UL; /* Disable first channel */
    if(CY_CANFD_SUCCESS != Cy_CANFD_Disable(CANFD0, channelMask))
    {
        /* Insert error handling */
    }

Parameters
  • *base: The CAN FD registers structure pointer.

  • channelMask: The channel mask (0-0xFF).

__STATIC_INLINE void Cy_CANFD_EnableMRAM (CANFD_Type *base, uint32_t channelMask, uint16_t delay)

Switches MRAM on and enables the channels.

Function Usage

    /* Scenario:  Switches MRAM on and enables specified channels. */
    uint32_t channelMask = 0x00000001UL; /* Enables the first channel */
    uint16_t delay = 0x0006U; /* A delay in usec before the MRAM can be used */
    Cy_CANFD_EnableMRAM(CANFD0, channelMask, delay);

Parameters
  • *base: The CAN FD registers structure pointer.

  • channelMask: The channel mask (0-0xFF).

  • delay: The delay in usec to wait power up time before MRAM can be used. Recommended value is 150 CPU cycles or 6 usec for the 25 MHz CPU clock.

__STATIC_INLINE cy_en_canfd_status_t Cy_CANFD_DisableMRAM (CANFD_Type *base)

Disables the channels and switches MRAM off.

Function Usage

    /* Scenario:  Disables all the channels and switches off the MRAM to save power. */
    Cy_CANFD_DisableMRAM(CANFD0);

Parameters
  • *base: The CAN FD registers structure pointer.

__STATIC_INLINE void Cy_CANFD_SetBitrate (CANFD_Type *base, uint32_t chan, const cy_stc_canfd_bitrate_t *bitrate)

Sets Nominal Bit Timing and Prescaler Register parameters: -Nominal Time segment after sample point; -Nominal Time segment before sample point; -Nominal Baud Rate Prescaler; -Nominal Synchronization Jump Width.

note

Before calling the Cy_CANFD_SetBitrate() function, the Cy_CANFD_ConfigChangesEnable() function must be called to set bits CCCR.CCE and CCCR.INIT. It is recommended to call Cy_CANFD_ConfigChangesDisable() after updating Bitrate.

Function Usage

    /* Scenario:  Changes the Nominal Bit Timing or Prescaler Register parameters after the CAN FD block is initialized. */
    cy_stc_canfd_bitrate_t bitrateConfig =
    {
        /* .prescaler     */ 10u - 1u,
        /* .timeSegment1  */ 5u - 1u,
        /* .timeSegment2  */ 2u - 1u,
        /* .syncJumpWidth */ 2u - 1u
    };
    Cy_CANFD_ConfigChangesEnable(CANFD0, 0UL);
    Cy_CANFD_SetBitrate(CANFD0, 0UL, &bitrateConfig);
    Cy_CANFD_ConfigChangesDisable(CANFD0, 0UL);

Parameters

__STATIC_INLINE void Cy_CANFD_SetFastBitrate (CANFD_Type *base, uint32_t chan, const cy_stc_canfd_bitrate_t *fastBitrate)

Sets Data Bit Timing and Prescaler Register parameters for data: -Data Time segment after sample point; -Data Time segment before sample point; -Data Baud Rate Prescaler; -Data Synchronization Jump Width.

note

Before calling the Cy_CANFD_SetFastBitrate() function, the Cy_CANFD_ConfigChangesEnable() function must be called to set bits CCCR.CCE and CCCR.INIT. It is recommended to call Cy_CANFD_ConfigChangesDisable() after updating Bitrate.

Function Usage

    /* Scenario:  Changes the Data Bit Timing or Prescaler Register parameters after the CAN FD block is initialized. */
    cy_stc_canfd_bitrate_t bitrateConfig =
    {
        /* .prescaler     */ 5u - 1u,
        /* .timeSegment1  */ 5u - 1u,
        /* .timeSegment2  */ 2u - 1u,
        /* .syncJumpWidth */ 2u - 1u
    };
    Cy_CANFD_ConfigChangesEnable(CANFD0, 0UL);
    Cy_CANFD_SetFastBitrate(CANFD0, 0UL, &bitrateConfig);
    Cy_CANFD_ConfigChangesDisable(CANFD0, 0UL);

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • *fastBitrate: cy_stc_canfd_bitrate_t

void Cy_CANFD_SidFilterSetup(CANFD_Type const *base, uint32_t chan, const cy_stc_id_filter_t *filter, uint32_t index, cy_stc_canfd_context_t const *context)

Updates the Standard Message ID Filter Element configuration in Message RAM.

Function Usage

    /* Scenario:  Updates the Standard Message ID Filter Element configuration in the Message RAM. */
    static const cy_stc_id_filter_t filter =
    {
        /* .sfid2 */ 0x00000010UL,
        /* .sfid1 */ 0x00000020UL,
        /* .sfec  */ CY_CANFD_SFEC_STORE_RX_FIFO_0,
        /* .sft   */ CY_CANFD_SFT_RANGE_SFID1_SFID2
    };
    cy_stc_canfd_context_t context; /* This is a shared context buffer, unique for each channel */
    Cy_CANFD_SidFilterSetup(CANFD0, 0UL, &filter, 0UL, &context);

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • *filter: The SID Filter register element structure.

  • index: The SID filter index.

  • *context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. The user must not modify anything in this structure.

void Cy_CANFD_SidFiltersSetup(CANFD_Type const *base, uint32_t chan, const cy_stc_canfd_sid_filter_config_t *filterConfig, cy_stc_canfd_context_t const *context)

Updates the Standard Message ID Filters configuration in Message RAM.

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • filterConfig: The Standard ID filter configuration structure.

  • context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. The user must not modify anything in this structure.

void Cy_CANFD_XidFilterSetup(CANFD_Type const *base, uint32_t chan, const cy_stc_extid_filter_t *filter, uint32_t index, cy_stc_canfd_context_t const *context)

Updates the Extended Message ID Filter Element configuration in Message RAM.

Function Usage

    /* Scenario:  Updates the Extended Message ID Filter Element configuration in the Message RAM. */
    cy_stc_canfd_context_t context;
    cy_stc_canfd_f0_t filterF0Config =
    {
        /* .efid1 */ 0x00010010UL,
        /* .efec  */ CY_CANFD_EFEC_STORE_RX_FIFO_1
    };

    cy_stc_canfd_f1_t filterF1Config =
    {
        /* .efid2 */ 0x00010020UL,
        /* .eft   */ CY_CANFD_EFT_DUAL_ID
    };
    
    /* extIdFilter */
    cy_stc_extid_filter_t filter =
    {
        /* .f0_f */ &filterF0Config,
        /* .f1_f */ &filterF1Config
    };
    Cy_CANFD_XidFilterSetup(CANFD0, 0UL, &filter, 0UL, &context);

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • filter: The XID Filter register element structure.

  • index: The XID filter index.

  • context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. The user must not modify anything in this structure.

void Cy_CANFD_XidFiltersSetup(CANFD_Type const *base, uint32_t chan, const cy_stc_canfd_extid_filter_config_t *filterConfig, cy_stc_canfd_context_t const *context)

Updates the Extended Message ID Filters configuration in Message RAM.

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • filterConfig: The Extended ID filter configuration structure.

  • context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. The user must not modify anything in this structure.

cy_en_canfd_status_t Cy_CANFD_TxBufferConfig(CANFD_Type const *base, uint32_t chan, const cy_stc_canfd_tx_buffer_t *txBuffer, uint8_t index, cy_stc_canfd_context_t const *context)

Updates the T0 and T1 Tx buffer element parameters in Message RAM and copies data from cy_stc_canfd_tx_buffer_t structure to Message RAM.

note

Function Cy_CANFD_Init() must be called before setting up an identifier and enabling this message buffer.

Return

cy_en_canfd_status_t

Function Usage

    /* Scenario:  Configure a transmit buffer for the CAN FD transmit operation */
    cy_stc_canfd_context_t context; /* This is a shared context structure, it is unique for each channel.
                                     * It must be global
                                     */
    uint8_t index = 0U;  /* Tx Buffer Element number */
    cy_stc_canfd_t0_t t0fConfig =
    {
        /* .id  */ 0x00000055UL,
        /* .rtr */ CY_CANFD_RTR_DATA_FRAME,
        /* .xtd */ CY_CANFD_XTD_STANDARD_ID,
        /* .esi */ CY_CANFD_ESI_ERROR_PASSIVE
    };
    cy_stc_canfd_t1_t t1fConfig =
    {
        /* .dlc */ 15U,
        /* .brs */ true,
        /* .fdf */ CY_CANFD_FDF_CAN_FD_FRAME,
        /* .efc */ false,
        /* .mm  */ 0UL
    };
    uint32_t data[16] =
    {
            0x00000000, 0x11111111, 0x22222222, 0x33333333,
            0x44444444, 0x55555555, 0x66666666, 0x77777777,
            0x88888888, 0x99999999, 0xAAAAAAAA, 0xBBBBBBBB,
            0xCCCCCCCC, 0xDDDDDDDD, 0xEEEEEEEE, 0xFFFFFFFF
    };
    const cy_stc_canfd_tx_buffer_t txBufferConfig =
    {
        /* .t0_f */ &t0fConfig,
        /* .t1_f */ &t1fConfig,
        /* data_area_f */ data
    };

    if(CY_CANFD_SUCCESS != Cy_CANFD_TxBufferConfig(CANFD0, 0UL, &txBufferConfig, index, &context))
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • *txBuffer: The Tx Buffer configuration structure.

  • index: the message buffer index (0-31).

  • context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. The user must not modify anything in this structure.

uint32_t Cy_CANFD_CalcRxBufAdrs(CANFD_Type const *base, uint32_t chan, uint32_t index, cy_stc_canfd_context_t const *context)

Calculates the address of the RX buffer element.

Return

The message buffer address corresponding to the index. Can be 0 if the index is invalid.

Function Usage

    /* Scenario:  Reads one RX buffer element. */
    uint32_t index = 0UL; /* RX buffer element index */
    bool useFIFO = false; /* true - uses FIFO buffer, false - uses RX buffer */
    uint32_t FIFOnumber = CY_CANFD_RX_FIFO0; /* FIFO number (0 or 1), if used */
    cy_stc_canfd_context_t context; /* This is a shared context structure unique for each channel
                                     * It must be global, initialized with Cy_CANFD_Init()
                                     */
    
    uint32_t address ; /* The address of the RX buffer in Message RAM */
    
    /* The members of the rxBuffer structure */
    cy_stc_canfd_r0_t  r0RxBuffer; /* The R0 register structure of the RX buffer element */
    cy_stc_canfd_r1_t  r1RxBuffer; /* The R1 register structure of the RX buffer element */
    uint32_t           rxData[CY_CANFD_DATA_ELEMENTS_MAX]; /* The array to store RX data */
    
    cy_stc_canfd_rx_buffer_t rxBuffer =
    {
        /* .r0_f         */ &r0RxBuffer,
        /* .r1_f         */ &r1RxBuffer,
        /* .data_area_f  */ rxData
    };
    
    if (useFIFO)
    {
        address = Cy_CANFD_CalcRxFifoAdrs(CANFD0, 0UL, FIFOnumber, index, &context);
    }
    else
    {
        address = Cy_CANFD_CalcRxBufAdrs(CANFD0, 0UL, index, &context);
    }    
    
    if(CY_CANFD_SUCCESS == (Cy_CANFD_GetRxBuffer(CANFD0, 0UL, address, &rxBuffer)))
    {
        if (useFIFO)
        {
            Cy_CANFD_AckRxFifo(CANFD0, 0UL, FIFOnumber);
        }
        else
        {
            Cy_CANFD_AckRxBuf(CANFD0, 0UL, index);
        }
    }
    else
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • index: The message buffer index for reception (0-63).

  • context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. The user must not modify anything in this structure.

uint32_t Cy_CANFD_CalcRxFifoAdrs(CANFD_Type const *base, uint32_t chan, uint32_t fifoNumber, uint32_t index, cy_stc_canfd_context_t const *context)

Calculates the address of the RX FIFO element.

Return

The Message buffer address corresponding to the index. Can be 0 if the index is invalid.

Function Usage

    /* Scenario:  Reads one RX buffer element. */
    uint32_t index = 0UL; /* RX buffer element index */
    bool useFIFO = false; /* true - uses FIFO buffer, false - uses RX buffer */
    uint32_t FIFOnumber = CY_CANFD_RX_FIFO0; /* FIFO number (0 or 1), if used */
    cy_stc_canfd_context_t context; /* This is a shared context structure unique for each channel
                                     * It must be global, initialized with Cy_CANFD_Init()
                                     */
    
    uint32_t address ; /* The address of the RX buffer in Message RAM */
    
    /* The members of the rxBuffer structure */
    cy_stc_canfd_r0_t  r0RxBuffer; /* The R0 register structure of the RX buffer element */
    cy_stc_canfd_r1_t  r1RxBuffer; /* The R1 register structure of the RX buffer element */
    uint32_t           rxData[CY_CANFD_DATA_ELEMENTS_MAX]; /* The array to store RX data */
    
    cy_stc_canfd_rx_buffer_t rxBuffer =
    {
        /* .r0_f         */ &r0RxBuffer,
        /* .r1_f         */ &r1RxBuffer,
        /* .data_area_f  */ rxData
    };
    
    if (useFIFO)
    {
        address = Cy_CANFD_CalcRxFifoAdrs(CANFD0, 0UL, FIFOnumber, index, &context);
    }
    else
    {
        address = Cy_CANFD_CalcRxBufAdrs(CANFD0, 0UL, index, &context);
    }    
    
    if(CY_CANFD_SUCCESS == (Cy_CANFD_GetRxBuffer(CANFD0, 0UL, address, &rxBuffer)))
    {
        if (useFIFO)
        {
            Cy_CANFD_AckRxFifo(CANFD0, 0UL, FIFOnumber);
        }
        else
        {
            Cy_CANFD_AckRxBuf(CANFD0, 0UL, index);
        }
    }
    else
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • fifoNumber: The FIFO number (0 or 1).

  • index: The Message buffer index for the reception (0-63).

  • context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. The user must not modify anything in this structure.

cy_en_canfd_status_t Cy_CANFD_GetRxBuffer(CANFD_Type const *base, uint32_t chan, const uint32_t bufferAddress, cy_stc_canfd_rx_buffer_t const *rxBuffer)

Extracts the RX Buffer from Message RAM.

note

Remember to clear the NDAT register bits after the RX buffer is read.

note

Remember to acknowledge the FIFO buffer after reading one FIFO element.

Return

cy_en_canfd_status_t

Function Usage

    /* Scenario:  Reads one RX buffer element. */
    uint32_t index = 0UL; /* RX buffer element index */
    bool useFIFO = false; /* true - uses FIFO buffer, false - uses RX buffer */
    uint32_t FIFOnumber = CY_CANFD_RX_FIFO0; /* FIFO number (0 or 1), if used */
    cy_stc_canfd_context_t context; /* This is a shared context structure unique for each channel
                                     * It must be global, initialized with Cy_CANFD_Init()
                                     */
    
    uint32_t address ; /* The address of the RX buffer in Message RAM */
    
    /* The members of the rxBuffer structure */
    cy_stc_canfd_r0_t  r0RxBuffer; /* The R0 register structure of the RX buffer element */
    cy_stc_canfd_r1_t  r1RxBuffer; /* The R1 register structure of the RX buffer element */
    uint32_t           rxData[CY_CANFD_DATA_ELEMENTS_MAX]; /* The array to store RX data */
    
    cy_stc_canfd_rx_buffer_t rxBuffer =
    {
        /* .r0_f         */ &r0RxBuffer,
        /* .r1_f         */ &r1RxBuffer,
        /* .data_area_f  */ rxData
    };
    
    if (useFIFO)
    {
        address = Cy_CANFD_CalcRxFifoAdrs(CANFD0, 0UL, FIFOnumber, index, &context);
    }
    else
    {
        address = Cy_CANFD_CalcRxBufAdrs(CANFD0, 0UL, index, &context);
    }    
    
    if(CY_CANFD_SUCCESS == (Cy_CANFD_GetRxBuffer(CANFD0, 0UL, address, &rxBuffer)))
    {
        if (useFIFO)
        {
            Cy_CANFD_AckRxFifo(CANFD0, 0UL, FIFOnumber);
        }
        else
        {
            Cy_CANFD_AckRxBuf(CANFD0, 0UL, index);
        }
    }
    else
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • bufferAddress: The Rx, FIFO 0 or FIFO 1 Buffer element address in CAN Message RAM.

  • *rxBuffer: The Rx Buffer structure in RAM.

cy_en_canfd_status_t Cy_CANFD_GetFIFOTop(CANFD_Type const *base, uint32_t chan, const uint8_t FIFONumber, cy_stc_canfd_rx_buffer_t const *rxBuffer)

Extracts one RX FIFO Buffer element using the FIFO TOP register logic.

Return

cy_en_canfd_status_t

Function Usage

    /* Scenario:  Reads one RX FIFO0 element using the FIFO TOP register logic. */
    uint32_t FIFONumber = 0;  /* 0 - read FIFO0, 1 - read FIFO1 */
    
    /* The members of the rxBuffer structure */
    cy_stc_canfd_r0_t  r0RxBuffer; /* The R0 register structure of the RX buffer element */
    cy_stc_canfd_r1_t  r1RxBuffer; /* The R1 register structure of the RX buffer element */
    uint32_t           rxData[CY_CANFD_DATA_ELEMENTS_MAX]; /* The array to store RX data */
    
    cy_stc_canfd_rx_buffer_t rxBuffer =
    {
        /* .r0_f         */ &r0RxBuffer,
        /* .r1_f         */ &r1RxBuffer,
        /* .data_area_f  */ rxData
    };

    if(CY_CANFD_SUCCESS != (Cy_CANFD_GetFIFOTop(CANFD0, 0UL, FIFONumber, &rxBuffer)))
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • FIFONumber: The CY_CANFD_RX_FIFO0 or CY_CANFD_RX_FIFO1, FIFO Buffer number.

  • *rxBuffer: The Rx Buffer structure in RAM.

cy_en_canfd_status_t Cy_CANFD_ExtractMsgFromRXBuffer(CANFD_Type *base, uint32_t chan, bool rxFIFOMsg, uint8_t msgBufOrRxFIFONum, cy_stc_canfd_rx_buffer_t const *rxBuffer, cy_stc_canfd_context_t const *context)

Extracts one RX buffer or one FIFO buffer element.

Return

cy_en_canfd_status_t

Function Usage

    /* Scenario:  Reads one RX buffer element. */
    cy_stc_canfd_context_t context; /* This is a shared context structure unique for each channel
                                     * It must be global, initialized with Cy_CANFD_Init()
                                     */
    uint8_t msgBufOrRxFIFONum = 0; /* RX buffer element index or FIFO number*/
    bool rxFIFOMsg = false; /* True for FIFO buffers anf False for RX buffers */
    
    /* The members of the rxBuffer structure */
    cy_stc_canfd_r0_t  r0RxBuffer; /* The R0 register structure of the RX buffer element */
    cy_stc_canfd_r1_t  r1RxBuffer; /* The R1 register structure of the RX buffer element */
    uint32_t           rxData[CY_CANFD_DATA_ELEMENTS_MAX]; /* The array to store RX data */
    
    cy_stc_canfd_rx_buffer_t rxBuffer =
    {
        /* .r0_f         */ &r0RxBuffer,
        /* .r1_f         */ &r1RxBuffer,
        /* .data_area_f  */ rxData
    };
    
    if(CY_CANFD_SUCCESS != (Cy_CANFD_ExtractMsgFromRXBuffer(CANFD0, 0UL, 
                                                     rxFIFOMsg, msgBufOrRxFIFONum,
                                                     &rxBuffer, &context)))
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • rxFIFOMsg: The buffer to read: True for FIFO buffers and False for RX buffers.

  • msgBufOrRxFIFONum: The RX buffer element index or FIFO buffer number.

  • *rxBuffer: The Rx buffer structure in RAM.

  • context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. The user must not modify anything in this structure.

void Cy_CANFD_AckRxBuf(CANFD_Type *base, uint32_t chan, uint32_t bufNum)

Acknowledges the data reading and makes the buffer element available for a next message.

Function Usage

    /* Scenario:  Reads one RX buffer element. */
    uint32_t index = 0UL; /* RX buffer element index */
    bool useFIFO = false; /* true - uses FIFO buffer, false - uses RX buffer */
    uint32_t FIFOnumber = CY_CANFD_RX_FIFO0; /* FIFO number (0 or 1), if used */
    cy_stc_canfd_context_t context; /* This is a shared context structure unique for each channel
                                     * It must be global, initialized with Cy_CANFD_Init()
                                     */
    
    uint32_t address ; /* The address of the RX buffer in Message RAM */
    
    /* The members of the rxBuffer structure */
    cy_stc_canfd_r0_t  r0RxBuffer; /* The R0 register structure of the RX buffer element */
    cy_stc_canfd_r1_t  r1RxBuffer; /* The R1 register structure of the RX buffer element */
    uint32_t           rxData[CY_CANFD_DATA_ELEMENTS_MAX]; /* The array to store RX data */
    
    cy_stc_canfd_rx_buffer_t rxBuffer =
    {
        /* .r0_f         */ &r0RxBuffer,
        /* .r1_f         */ &r1RxBuffer,
        /* .data_area_f  */ rxData
    };
    
    if (useFIFO)
    {
        address = Cy_CANFD_CalcRxFifoAdrs(CANFD0, 0UL, FIFOnumber, index, &context);
    }
    else
    {
        address = Cy_CANFD_CalcRxBufAdrs(CANFD0, 0UL, index, &context);
    }    
    
    if(CY_CANFD_SUCCESS == (Cy_CANFD_GetRxBuffer(CANFD0, 0UL, address, &rxBuffer)))
    {
        if (useFIFO)
        {
            Cy_CANFD_AckRxFifo(CANFD0, 0UL, FIFOnumber);
        }
        else
        {
            Cy_CANFD_AckRxBuf(CANFD0, 0UL, index);
        }
    }
    else
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • bufNum: The RX buffer element index.

void Cy_CANFD_AckRxFifo(CANFD_Type *base, uint32_t chan, uint32_t FIFOnumber)

Acknowledges the data reading and makes the buffer element available for a next message.

note

Do not use this function with Cy_CANFD_GetFIFOTop(). FIFO top logic takes care on updating the FIFO read pointer buffer with hardware.

Function Usage

    /* Scenario:  Reads one RX buffer element. */
    uint32_t index = 0UL; /* RX buffer element index */
    bool useFIFO = false; /* true - uses FIFO buffer, false - uses RX buffer */
    uint32_t FIFOnumber = CY_CANFD_RX_FIFO0; /* FIFO number (0 or 1), if used */
    cy_stc_canfd_context_t context; /* This is a shared context structure unique for each channel
                                     * It must be global, initialized with Cy_CANFD_Init()
                                     */
    
    uint32_t address ; /* The address of the RX buffer in Message RAM */
    
    /* The members of the rxBuffer structure */
    cy_stc_canfd_r0_t  r0RxBuffer; /* The R0 register structure of the RX buffer element */
    cy_stc_canfd_r1_t  r1RxBuffer; /* The R1 register structure of the RX buffer element */
    uint32_t           rxData[CY_CANFD_DATA_ELEMENTS_MAX]; /* The array to store RX data */
    
    cy_stc_canfd_rx_buffer_t rxBuffer =
    {
        /* .r0_f         */ &r0RxBuffer,
        /* .r1_f         */ &r1RxBuffer,
        /* .data_area_f  */ rxData
    };
    
    if (useFIFO)
    {
        address = Cy_CANFD_CalcRxFifoAdrs(CANFD0, 0UL, FIFOnumber, index, &context);
    }
    else
    {
        address = Cy_CANFD_CalcRxBufAdrs(CANFD0, 0UL, index, &context);
    }    
    
    if(CY_CANFD_SUCCESS == (Cy_CANFD_GetRxBuffer(CANFD0, 0UL, address, &rxBuffer)))
    {
        if (useFIFO)
        {
            Cy_CANFD_AckRxFifo(CANFD0, 0UL, FIFOnumber);
        }
        else
        {
            Cy_CANFD_AckRxBuf(CANFD0, 0UL, index);
        }
    }
    else
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • FIFOnumber: The RX buffer element index.

__STATIC_INLINE cy_en_canfd_status_t Cy_CANFD_ConfigChangesEnable (CANFD_Type *base, uint32_t chan)

Enables the CPU write access to the protected configuration registers of the CAN FD block and sets the CAN FD block into the initialization state.

Return

cy_en_canfd_status_t

Function Usage

    /* Scenario:  Enable the CPU Write access to the protected configuration registers */

    if(CY_CANFD_SUCCESS != Cy_CANFD_ConfigChangesEnable(CANFD0, 0UL))
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

__STATIC_INLINE cy_en_canfd_status_t Cy_CANFD_ConfigChangesDisable (CANFD_Type *base, uint32_t chan)

Disables the CPU write access to the protected configuration registers of the CAN FD block and sets the CAN FD block into the Normal Operation.

Return

cy_en_canfd_status_t

Function Usage

    /* Scenario:  Disables the CPU Write access to the protected configuration
     * registers of the CAN FD block.
     */

    if(CY_CANFD_SUCCESS != Cy_CANFD_ConfigChangesDisable(CANFD0, 0UL))
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

__STATIC_INLINE void Cy_CANFD_TestModeConfig (CANFD_Type *base, uint32_t chan, cy_stc_canfd_test_mode_t testMode)

Configures test mode.

note

The Cy_CANFD_ConfigChangesEnable must be called before calling this function to enable the configuration changes.

Function Usage

    /* Scenario:  Configures Test mode to use the external loop back to receive
     * the sent data back.
     */

    Cy_CANFD_TestModeConfig(CANFD0, 0UL, CY_CANFD_TEST_MODE_EXTERNAL_LOOP_BACK);

Parameters

__STATIC_INLINE void Cy_CANFD_SetTDC (CANFD_Type *base, uint32_t chan, const cy_stc_canfd_transceiver_delay_compensation_t *tdcConfig)

Sets the CAN FD transceiver delay compensation offset.

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • *tdcConfig: The CAN FD transceiver delay compensation offset configuration.

uint32_t Cy_CANFD_GetLastError(CANFD_Type const *base, uint32_t chan)

Returns the value of Protocol Status Register (PSR).

Use the

Protocol Status Register (PSR) masks to extract necessary fields from the register.

Use the

cy_en_canfd_LEC_t enumeration to interpret LEC and DLEC fields.

Use the

cy_en_canfd_PSR_ACT_t enumeration to interpret the ACT field.

note

Protocol Status Register has reset on read fields. Reading the register will clear the bits PXE, RFDF, RBRS and RESI, and set DLEC[2:0] and LEC[2:0].

Return

Content of the Protocol Status Register (PSR).

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

void Cy_CANFD_IrqHandler(CANFD_Type *base, uint32_t chan, cy_stc_canfd_context_t const *context)

CAN FD (Status/Error/Rx/Tx) interrupt ISR.

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. The user must not modify anything in this structure.

cy_en_canfd_status_t Cy_CANFD_Init(CANFD_Type *base, uint32_t chan, const cy_stc_canfd_config_t *config, cy_stc_canfd_context_t *context)

Initializes the CAN FD module.

note

The function does not enable the Tx Event FIFO but reserves 10 Tx Event FIFO elements in Message RAM.

note

The function enables the "Message stored to Rx Buffer", "Rx FIFO 1 New Message" and "Rx FIFO 0 New Message" interrupt events only. Other interrupts can be configured with the Cy_CANFD_SetInterruptMask() function.

note

If the channel was disabled, call Cy_CANFD_Enable before calling Cy_CANFD_Init.

note

Call this function only after all debug messages reception is completed.

Return

cy_en_canfd_status_t

Function Usage


    /* Scenario:  Initialize the CAN FD block with predefined settings to:
    - Receive the frames with ID = 0x10 into RX buffer element #0 in Massage RAM;
    - Receive the frames with ID = 0x20 into RX buffer element #1 in Massage RAM;
    - Receive the frames with ID = 0x10010 into RX buffer element #2 in Massage RAM;
    - Receive the frames with ID = 0x10020 into RX buffer element #3 in Massage RAM;
    - Receive the frames with non-Matching Standard IDs into RX FIFO#0 in Massage RAM;
    - Receive the frames with non-Matching Extended IDs into RX FIFO#1 in Massage RAM;
    - Transmit two TX buffers.
    */
    
    #define MESSAGE_ID0          (0x00000001UL)
    #define MESSAGE_ID1          (0x00000010UL)
    #define MESSAGE_ID2          (0x00000020UL)
    #define RX_BUFFER_ELEMENT_1  (0x0UL)
    #define RX_BUFFER_ELEMENT_2  (0x1UL)

    #define MESSAGE_ID3          (0x00010010UL)
    #define MESSAGE_ID4          (0x00010020UL)
    #define RX_BUFFER_ELEMENT_3  (0x2UL)
    #define RX_BUFFER_ELEMENT_4  (0x3UL)

    cy_stc_canfd_context_t context; /* This is a shared context structure, it is unique for each channel.
                                     * It must be global
                                     */

    cy_stc_canfd_bitrate_t bitrateConfig =
    {
        /* .prescaler     */ 10u - 1u,
        /* .timeSegment1  */ 5u - 1u,
        /* .timeSegment2  */ 2u - 1u,
        /* .syncJumpWidth */ 2u - 1u
    };

    cy_stc_canfd_bitrate_t fastBitrateConfig =
    {
        /* .prescaler     */ 5u - 1u,
        /* .timeSegment1  */ 5u - 1u,
        /* .timeSegment2  */ 2u - 1u,
        /* .syncJumpWidth */ 2u - 1u
    };

    cy_stc_canfd_transceiver_delay_compensation_t tdcConfig =
    {
        /* .tdcEnabled      */ false,
        /* .tdcOffset       */ 0,
        /* .tdcFilterWindow */ 0
    };

    static const cy_stc_id_filter_t stdIdFilters[] =
    {
        /* stdIdFilter[0] */
        {
            /* .sfid2 */ RX_BUFFER_ELEMENT_1,
            /* .sfid1 */ MESSAGE_ID1,
            /* .sfec  */ CY_CANFD_SFEC_STORE_RX_BUFFER,
            /* .sft   */ CY_CANFD_SFT_CLASSIC_FILTER
        },

        /* stdIdFilter[1] */
        {
            /* .sfid2 */ RX_BUFFER_ELEMENT_2,
            /* .sfid1 */ MESSAGE_ID2,
            /* .sfec  */ CY_CANFD_SFEC_STORE_RX_BUFFER,
            /* .sft   */ CY_CANFD_SFT_CLASSIC_FILTER
        }
    };

    cy_stc_canfd_f0_t filter0F0Config =
    {
        /* .efid1 */ MESSAGE_ID3,
        /* .efec  */ CY_CANFD_EFEC_STORE_RX_BUFFER
    };


    cy_stc_canfd_f1_t filter0F1Config =
    {
        /* .efid2 */ RX_BUFFER_ELEMENT_3,
        /* .eft   */ CY_CANFD_EFT_CLASSIC_FILTER
    };

    cy_stc_canfd_f0_t filter1F0Config =
    {
        /* .efid1 */ MESSAGE_ID4,
        /* .efec  */ CY_CANFD_EFEC_STORE_RX_BUFFER
    };

    cy_stc_canfd_f1_t filter1F1Config =
    {
        /* .efid2 */ RX_BUFFER_ELEMENT_4,
        /* .eft   */ CY_CANFD_EFT_CLASSIC_FILTER
    };

    const cy_stc_extid_filter_t extIdFilters[] =
    {
        /* extIdFilter[0] */
        {
            /* .f0_f */ &filter0F0Config,
            /* .f1_f */ &filter0F1Config
        },

        /* extIdFilter[1] */
        {
            /* .f0_f */ &filter1F0Config,
            /* .f1_f */ &filter1F1Config
        }
    };

    cy_stc_canfd_sid_filter_config_t sidFiltersConfig =
    {
        /* .numberOfSIDFilters */ sizeof(stdIdFilters) / sizeof(stdIdFilters[0]),
        /* .sidFilter          */ stdIdFilters,
    };

    cy_stc_canfd_extid_filter_config_t extidFiltersConfig =
    {
        /* numberOfEXTIDFilters */ sizeof(extIdFilters) / sizeof(extIdFilters[0]),
        /* extidFilter          */ extIdFilters,
        /* extIDANDMask         */ 0x1fffffffUL
    };

    cy_stc_canfd_global_filter_config_t globalFilterConfig =
    {
        /* .nonMatchingFramesStandard  */ CY_CANFD_ACCEPT_IN_RXFIFO_0,
        /* .nonMatchingFramesExtended  */ CY_CANFD_ACCEPT_IN_RXFIFO_1,
        /* .rejectRemoteFramesStandard */ true,
        /* .rejectRemoteFramesExtended */ true
    };

    cy_en_canfd_fifo_config_t rxFifo0Config =
    {
        /* mode                   */ CY_CANFD_FIFO_MODE_BLOCKING,
        /* watermark              */ 1U,
        /* numberOfFifoElements   */ 2U,
        /* topPointerLogicEnabled */ false
    };

    cy_en_canfd_fifo_config_t rxFifo1Config =
    {
        /* mode                   */ CY_CANFD_FIFO_MODE_BLOCKING,
        /* watermark              */ 4U,
        /* numberOfFifoElements   */ 5U,
        /* topPointerLogicEnabled */ false
    };

    const cy_stc_canfd_config_t config =
    {
        /* .txCallback            */ NULL,
        /* .rxCallback            */ NULL,
        /* .errorCallback         */ NULL,
        /* .canFDMode             */ true,
        /* .bitrate               */ &bitrateConfig,
        /* .fastBitrate           */ &fastBitrateConfig,
        /* .tdcConfig             */ &tdcConfig,
        /* .sidFilterConfig       */ &sidFiltersConfig,
        /* .extidFilterConfig     */ &extidFiltersConfig,
        /* .globalFilterConfig    */ &globalFilterConfig,
        /* .rxBufferDataSize      */ CY_CANFD_BUFFER_DATA_SIZE_64,
        /* .rxFIFO1DataSize       */ CY_CANFD_BUFFER_DATA_SIZE_64,
        /* .rxFIFO0DataSize       */ CY_CANFD_BUFFER_DATA_SIZE_64,
        /* .txBufferDataSize      */ CY_CANFD_BUFFER_DATA_SIZE_64,
        /* .rxFIFO0Config         */ &rxFifo0Config,
        /* .rxFIFO1Config         */ &rxFifo1Config,
        /* .noOfRxBuffers         */ 0x4U,
        /* .noOfTxBuffers         */ 0x2U,
        /* .messageRAMaddress     */ CY_CAN0MRAM_BASE,
        /* .messageRAMsize        */ 8192U
    };

    if(CY_CANFD_SUCCESS != Cy_CANFD_Init (CANFD0, 0U, &config, &context))
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • *config: The pointer to the CAN FD configuration structure.

  • *context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. User must not modify anything in this structure.

cy_en_canfd_status_t Cy_CANFD_DeInit(CANFD_Type *base, uint32_t chan, cy_stc_canfd_context_t *context)

De-initializes the CAN FD block, returns registers values to default.

note

Do not call Cy_CANFD_Disable before Cy_CANFD_DeInit.

note

Call this function only after all debug messages reception is completed.

Return

cy_en_canfd_status_t

Function Usage

    /* Scenario: The CAN FD block is initialized/working and then no longer used or needs to be reset. */
    cy_stc_canfd_context_t context; /* This is a shared context structure, it is unique for each channel.
                                     * It must be global
                                     */
    if(CY_CANFD_SUCCESS != Cy_CANFD_DeInit (CANFD0, 0UL, &context))
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • *context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. The user must not modify anything in this structure.

cy_en_canfd_status_t Cy_CANFD_TransmitTxBuffer(CANFD_Type *base, uint32_t chan, uint8_t index)

Starts transmission of the message prepared with Cy_CANFD_TxBufferConfig().

Transmits the message immediately. Function CanFD_Init() must be called before setting up the identifier and enabling this message buffer.

Return

cy_en_canfd_status_t

Function Usage

    /* Scenario:  The TX buffer is configured with Cy_CANFD_TxBufferConfig() 
     * and a message is ready to be sent. 
     */
     
    uint8_t index = 0u; /* TX buffer index (max 31u) */
    
    if(CY_CANFD_SUCCESS != Cy_CANFD_TransmitTxBuffer(CANFD0, 0UL, index))
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • index: Message buffer index (0-31).

cy_en_canfd_status_t Cy_CANFD_UpdateAndTransmitMsgBuffer(CANFD_Type *base, uint32_t chan, const cy_stc_canfd_tx_buffer_t *txBuffer, uint8_t index, cy_stc_canfd_context_t const *context)

Updates the T0 and T1 Tx buffer element parameters in Message RAM and copies data from cy_stc_canfd_tx_buffer_t structure to Message RAM.

Transmits the message immediately. Function CanFD_Init() must be called before setting up the identifier and enabling this message buffer.

Return

cy_en_canfd_status_t

Function Usage

    /* Scenario:  Configure a transmit buffer for the CAN FD transmit operation */
    cy_stc_canfd_context_t context; /* This is a shared context structure, it is unique for each channel.
                                     * It must be global
                                     */
    uint8_t index = 0U;  /* Tx Buffer Element number */
    cy_stc_canfd_t0_t t0fConfig =
    {
        /* .id  */ 0x00000055UL,
        /* .rtr */ CY_CANFD_RTR_DATA_FRAME,
        /* .xtd */ CY_CANFD_XTD_STANDARD_ID,
        /* .esi */ CY_CANFD_ESI_ERROR_PASSIVE
    };

    cy_stc_canfd_t1_t t1fConfig =
    {
        /* .dlc */ 15U,
        /* .brs */ true,
        /* .fdf */ CY_CANFD_FDF_CAN_FD_FRAME,
        /* .efc */ false,
        /* .mm  */ 0UL
    };
    uint32_t data[16] =
    {
            0x00000000UL, 0x11111111UL, 0x22222222UL, 0x33333333UL,
            0x44444444UL, 0x55555555UL, 0x66666666UL, 0x77777777UL,
            0x88888888UL, 0x99999999UL, 0xAAAAAAAAUL, 0xBBBBBBBBUL,
            0xCCCCCCCCUL, 0xDDDDDDDDUL, 0xEEEEEEEEUL, 0xFFFFFFFFUL
    };
    const cy_stc_canfd_tx_buffer_t txBufferConfig =
    {
        /* .t0_f */ &t0fConfig,
        /* .t1_f */ &t1fConfig,
        /* data_area_f */ data
    };

    if(CY_CANFD_SUCCESS != Cy_CANFD_UpdateAndTransmitMsgBuffer(CANFD0, 0UL, &txBufferConfig, index, &context))
    {
        /* Insert error handling */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • *txBuffer: The Tx Buffer configuration structure.

  • index: the message buffer index (0-31).

  • context: The pointer to the context structure cy_stc_canfd_context_t allocated by the user. The structure is used during the CAN FD operation for internal configuration and data retention. The user must not modify anything in this structure.

cy_en_canfd_tx_buffer_status_t Cy_CANFD_GetTxBufferStatus(CANFD_Type const *base, uint32_t chan, uint8_t index)

Gets the status of the CAN FD Tx buffer.

Return

cy_en_canfd_status_t

Function Usage

    /* Scenario:  Checks if the buffer was transmitted. */
    
    uint8_t index = 0u; /* TX buffer index (max 31u) */
    
    if (CY_CANFD_TX_BUFFER_TRANSMIT_OCCURRED == Cy_CANFD_GetTxBufferStatus(CANFD0, 0UL, index))
    {
        /* The buffer with index 0 was transmitted */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • index: Message buffer index (0-31).

__STATIC_INLINE uint32_t Cy_CANFD_GetInterruptStatus (CANFD_Type const *base, uint32_t chan)

Returns a status of CAN FD interrupt requests.

Return

uint32_t The bit mask of the Interrupt Status. Valid masks can be found in RX Interrupt masks, TX Interrupt masks and Error Interrupt masks.

Function Usage

    /* Scenario:  Checks for a new message in the RX buffer. */

    uint32_t status;
    status = Cy_CANFD_GetInterruptStatus(CANFD0, 0UL);
    if (0 != (status & CY_CANFD_RX_BUFFER_NEW_MESSAGE))
        {
            /* Process the received message */
        }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

__STATIC_INLINE void Cy_CANFD_ClearInterrupt (CANFD_Type *base, uint32_t chan, uint32_t status)

Clears CAN FD interrupts by setting each bit.

Function Usage

    /* Scenario:  Clears all RX interrupts by setting corresponding bits to 1. */
    
    uint32_t status =  (CY_CANFD_RX_BUFFER_NEW_MESSAGE |  /* Message stored to Rx Buffer */
                        CY_CANFD_RX_FIFO_1_NEW_MESSAGE | /* Rx FIFO 1 New Message */
                        CY_CANFD_RX_FIFO_0_NEW_MESSAGE); /* Rx FIFO 0 New Message */ 
    
    Cy_CANFD_ClearInterrupt(CANFD0, 0UL, status);

Parameters

__STATIC_INLINE uint32_t Cy_CANFD_GetInterruptMask (CANFD_Type const *base, uint32_t chan)

Returns an interrupt mask.

Return

uint32_t The bit field determines which status changes can cause an interrupt. Valid masks can be found in RX Interrupt masks, TX Interrupt masks and Error Interrupt masks.

Function Usage

    /* Scenario:  Checks if the RX buffer interrupt is enabled. */

    if (0 != (Cy_CANFD_GetInterruptMask(CANFD0, 0UL) & CY_CANFD_RX_BUFFER_NEW_MESSAGE))
    {
        /* The RX buffer interrupt is enabled */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

__STATIC_INLINE void Cy_CANFD_SetInterruptMask (CANFD_Type *base, uint32_t chan, uint32_t interrupt)

Configures which bits of the interrupt request register can trigger an interrupt event.

Function Usage

    /* Scenario:  Enables the interrupts from the RX buffer, RX FIFO 0 and RX FIFO 1. */

    uint32_t status =  (CY_CANFD_RX_BUFFER_NEW_MESSAGE |  /* Message stored to Rx Buffer */
                        CY_CANFD_RX_FIFO_1_NEW_MESSAGE | /* Rx FIFO 1 New Message */
                        CY_CANFD_RX_FIFO_0_NEW_MESSAGE); /* Rx FIFO 0 New Message */ 
    
    Cy_CANFD_SetInterruptMask(CANFD0, 0UL, status);

Parameters

__STATIC_INLINE uint32_t Cy_CANFD_GetInterruptLine (CANFD_Type const *base, uint32_t chan)

Returns the interrupt signals assigned to the line m_ttcan_int0 or m_ttcan_int1.

Return

uint32_t The mask where 1 corresponds to the interrupt signals assigned to the line m_ttcan_int1 and 0 corresponds to m_ttcan_int0. Valid masks can be found in RX Interrupt masks, TX Interrupt masks and Error Interrupt masks.

Function Usage

    /* Scenario:  Checks if Transmission Completed Interrupt uses the line m_ttcan_int1. */
    
    uint32_t interruptLine;
    
    interruptLine = Cy_CANFD_GetInterruptLine(CANFD0, 0UL);
    
    if (0 != (interruptLine & CY_CANFD_TRANSMISSION_COMPLETE))
    {
        /* Transmission Completed Interrupt uses the line m_ttcan_int1 */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

__STATIC_INLINE void Cy_CANFD_SetInterruptLine (CANFD_Type *base, uint32_t chan, uint32_t interruptLineMask)

Configures the bits of the Interrupt Line Select Register to assign the interrupt signal to the line m_ttcan_int0 or m_ttcan_int1.

Bit = 0: The interrupt assigned to the interrupt line m_ttcan_int0, bit = 1: The interrupt assigned to the interrupt line m_ttcan_int1.

Function Usage

    /* Scenario:  Sets Transmission Completed Interrupt to the interrupt 
     * line m_ttcan_int1. 
     */

    Cy_CANFD_SetInterruptLine(CANFD0, 0UL,  Cy_CANFD_GetInterruptLine(CANFD0, 0UL) |
                              CY_CANFD_TRANSMISSION_COMPLETE);

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • interruptLineMask: The mask where 1 corresponds to the interrupt signals assigned to the line m_ttcan_int1 and 0 corresponds to m_ttcan_int0. Valid masks can be found in RX Interrupt masks, TX Interrupt masks and Error Interrupt masks.

__STATIC_INLINE bool Cy_CANFD_IsInterruptLineEnabled (CANFD_Type const *base, uint32_t chan, uint32_t interruptLineMask)

Checks whether Interrupt Line 0, Interrupt Line 1 or both are enabled.

Return

bool The bit mask of the enabled interrupt lines.

Function Usage

    /* Scenario:  Checks if the interrupt line m_ttcan_int0 is enabled. */
    #define INT_LINE_MASK CY_CANFD_INTERRUPT_LINE_0_EN
    if (Cy_CANFD_IsInterruptLineEnabled(CANFD0, 0UL, INT_LINE_MASK))
    {
       /* The interrupt line m_ttcan_int0 is enabled */
    }

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • interruptLineMask: The bit mask to check which interrupt line is enabled. Can be CY_CANFD_INTERRUPT_LINE_0_EN, CY_CANFD_INTERRUPT_LINE_1_EN or (CY_CANFD_INTERRUPT_LINE_0_EN | CY_CANFD_INTERRUPT_LINE_1_EN)

__STATIC_INLINE void Cy_CANFD_EnableInterruptLine (CANFD_Type *base, uint32_t chan, uint32_t interruptLineMask)

Configures which interrupt line is enabled (Interrupt Line 0, Interrupt Line 1 or both).

Function Usage

    /* Scenario:  Enables the interrut line m_ttcan_int0. */

    Cy_CANFD_EnableInterruptLine(CANFD0, 0UL, CY_CANFD_INTERRUPT_LINE_0_EN);

Parameters
  • *base: The pointer to a CAN FD instance.

  • chan: The CAN FD channel number.

  • interruptLineMask: The bit mask whose bits define interrupt lines to enable or disable.