cy_canfd_8h

This file provides constants and parameter values for the CAN FD driver.

Version

1.20

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
Copyright

Copyright 2019-2020 Cypress Semiconductor Corporation SPDX-License-Identifier: Apache-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defines

CY_CANFD_DRV_VERSION_MAJOR

Driver major version.

CY_CANFD_DRV_VERSION_MINOR

Driver minor version.

CY_CANFD_ID

CAN FD driver ID.

CY_CANFD_MESSAGE_DATA_BUFFER_SIZE

Size of word data bytes in a receive or transmit operation (16word = 64byte)

CY_CANFD_RX_FIFO0

FIFO number 0.

CY_CANFD_RX_FIFO1

FIFO number 1.

CY_CANFD_RX_FIFO_0_NEW_MESSAGE

Rx FIFO 0 New Message.

CY_CANFD_RX_FIFO_1_NEW_MESSAGE

Rx FIFO 1 New Message.

CY_CANFD_RX_BUFFER_NEW_MESSAGE

Message stored to Dedicated Rx Buffer.

CY_CANFD_HIGH_PRIORITY_MESSAGE

High Priority Message.

CY_CANFD_TRANSMISSION_COMPLETE

Transmission Completed.

CY_CANFD_TRANSMISSION_CANCEL_FINISHED

Transmission Cancellation Finished.

CY_CANFD_TX_FIFO_EMPTY

Tx FIFO Empty.

CY_CANFD_TX_EVENT_FIFO_NEW_ENTRY

Tx Event FIFO New Entry.

CY_CANFD_RX_FIFO_0_WATERMARK_REACHED

Rx FIFO 0 Watermark Reached.

CY_CANFD_RX_FIFO_0_FULL

Rx FIFO 0 Full.

CY_CANFD_RX_FIFO_0_MSG_LOST

Rx FIFO 0 Message Lost.

CY_CANFD_RX_FIFO_1_WATERMARK_REACHED

Rx FIFO 1 Watermark Reached.

CY_CANFD_RX_FIFO_1_FULL

Rx FIFO 1 Full.

CY_CANFD_RX_FIFO_1_MSG_LOST

Rx FIFO 1 Message Lost.

CY_CANFD_TX_FIFO_1_WATERMARK_REACHED

Tx Event FIFO Watermark Reached.

CY_CANFD_TX_FIFO_1_FULL

Tx Event FIFO Full.

CY_CANFD_TX_FIFO_1_MSG_LOST

Tx Event FIFO Element Lost.

CY_CANFD_TIMESTAMP_WRAPAROUND

Timestamp Wraparound.

CY_CANFD_MRAM_ACCESS_FAILURE

Message RAM Access Failure.

CY_CANFD_TIMEOUT_OCCURRED

Timeout Occurred.

CY_CANFD_BIT_ERROR_CORRECTED

Bit Error Corrected.

CY_CANFD_BIT_ERROR_UNCORRECTED

Bit Error Uncorrected.

CY_CANFD_ERROR_LOG_OVERFLOW

Error Logging Overflow.

CY_CANFD_ERROR_PASSIVE

Error Passive.

CY_CANFD_WARNING_STATUS

Warning Status.

CY_CANFD_BUS_OFF_STATUS

Bus_Off Status.

CY_CANFD_WATCHDOG_INTERRUPT

Watchdog Interrupt.

CY_CANFD_PROTOCOL_ERROR_ARB_PHASE

Protocol Error in Arbitration Phase.

CY_CANFD_PROTOCOL_ERROR_DATA_PHASE

Protocol Error in Data Phase.

CY_CANFD_ACCESS_RESERVED_ADDR

Access to Reserved Address.

CY_CANFD_INTERRUPT_LINE_0_EN

Enable Interrupt Line 0.

CY_CANFD_INTERRUPT_LINE_1_EN

Enable Interrupt Line 1.

CY_CANFD_PSR_LEC_POS

Last Error Code position.

CY_CANFD_PSR_LEC_MASK

Last Error Code bit mask.

CY_CANFD_PSR_ACT_POS

Activity position.

CY_CANFD_PSR_ACT_MASK

Activity bit mask.

CY_CANFD_PSR_EP

Error Passive.

CY_CANFD_PSR_EW

Warning Status.

CY_CANFD_PSR_BO

Bus_Off Status.

CY_CANFD_PSR_DLEC_POS

Data Phase Last Error Code position.

CY_CANFD_PSR_DLEC_MASK

Data Phase Last Error Code bit mask.

CY_CANFD_PSR_RESI

ESI flag of last received CAN FD Message.

CY_CANFD_PSR_RBRS

BRS flag of last received CAN FD Message.

CY_CANFD_PSR_RFDF

Received a CAN FD Message.

CY_CANFD_PSR_PXE

Protocol Exception Event.

CY_CANFD_PSR_TDCV_POS

Transmitter Delay Compensation Value position.

CY_CANFD_PSR_TDCV_MASK

Transmitter Delay Compensation Value bit mask.

Typedefs

typedef void (*cy_canfd_tx_msg_func_ptr_t)(void)

Message transmission complete callback function (cy_canfd_tx_msg_func_ptr_t).

Signals a successful completed transmission. Triggered with CY_CANFD_TRANSMISSION_COMPLETE interrupt event

typedef void (*cy_canfd_rx_msg_func_ptr_t)(bool rxFIFOMsg, uint8_t msgBufOrRxFIFONum, cy_stc_canfd_rx_buffer_t *basemsg)

The message reception callback function for message received in the dedicated Rx Buffer or in Rx FIFO (cy_canfd_rx_msg_func_ptr_t)

Signals that CAN FD has received a new message.

  • If message was received in the dedicated Rx Buffer (0 - 63), rxFIFOMsg is False and u8MsgBufOrFIFONum indicates the Rx Buffer number.

  • If message was received in Rx FIFO (0/1), rxFIFOMsg is True and u8MsgBufOrFIFONum indicates the FIFO number.

Triggered with corresponding CY_CANFD_RX_BUFFER_NEW_MESSAGE CY_CANFD_RX_FIFO_0_NEW_MESSAGE CY_CANFD_RX_FIFO_1_NEW_MESSAGE

interrupt events.

typedef void (*cy_canfd_error_func_ptr_t)(uint32_t errorMask)

The error callback function (cy_canfd_error_func_ptr_t).

Signals that the CAN bus status changed or an error occurred.

Triggered with

CY_CANFD_RX_FIFO_0_WATERMARK_REACHED CY_CANFD_RX_FIFO_0_FULL CY_CANFD_RX_FIFO_0_MSG_LOST CY_CANFD_RX_FIFO_1_WATERMARK_REACHED CY_CANFD_RX_FIFO_1_FULL CY_CANFD_RX_FIFO_1_MSG_LOST CY_CANFD_TX_FIFO_1_WATERMARK_REACHED CY_CANFD_TX_FIFO_1_FULL CY_CANFD_TX_FIFO_1_MSG_LOST CY_CANFD_TIMESTAMP_WRAPAROUND CY_CANFD_MRAM_ACCESS_FAILURE CY_CANFD_TIMEOUT_OCCURRED CY_CANFD_BIT_ERROR_CORRECTED CY_CANFD_BIT_ERROR_UNCORRECTED CY_CANFD_ERROR_LOG_OVERFLOW CY_CANFD_ERROR_PASSIVE CY_CANFD_WARNING_STATUS CY_CANFD_BUS_OFF_STATUS CY_CANFD_WATCHDOG_INTERRUPT CY_CANFD_PROTOCOL_ERROR_ARB_PHASE CY_CANFD_PROTOCOL_ERROR_DATA_PHASE CY_CANFD_ACCESS_RESERVED_ADDR

interrupt events.

Enums

enum cy_en_canfd_status_t

cy_en_canfd_status_t: CAN FD status enumeration.

Values:

enumerator CY_CANFD_SUCCESS

Returned successful.

enumerator CY_CANFD_BAD_PARAM

Bad parameter was passed.

enumerator CY_CANFD_ERROR_TIMEOUT

A Time out error occurred.

enum cy_en_canfd_tx_buffer_status_t

cy_en_canfd_tx_buffer_status_t: CAN FD Tx Buffer status enumeration.

Values:

enumerator CY_CANFD_TX_BUFFER_IDLE
enumerator CY_CANFD_TX_BUFFER_PENDING

Pending transmission.

enumerator CY_CANFD_TX_BUFFER_TRANSMIT_OCCURRED

Transmission occurred.

enumerator CY_CANFD_TX_BUFFER_CANCEL_REQUESTED

Cancellation requested.

enumerator CY_CANFD_TX_BUFFER_CANCEL_FINISHED

Cancellation finished.

enum cy_en_canfd_buffer_data_size_t

cy_en_canfd_buffer_data_size_t: CAN FD Tx/Rx buffer element size.

Values:

enumerator CY_CANFD_BUFFER_DATA_SIZE_8

8 byte data field

enumerator CY_CANFD_BUFFER_DATA_SIZE_12

12 byte data field

enumerator CY_CANFD_BUFFER_DATA_SIZE_16

16 byte data field

enumerator CY_CANFD_BUFFER_DATA_SIZE_20

20 byte data field

enumerator CY_CANFD_BUFFER_DATA_SIZE_24

24 byte data field

enumerator CY_CANFD_BUFFER_DATA_SIZE_32

32 byte data field

enumerator CY_CANFD_BUFFER_DATA_SIZE_48

48 byte data field

enumerator CY_CANFD_BUFFER_DATA_SIZE_64

64 byte data field

enum cy_en_canfd_fifo_mode_t

cy_en_canfd_fifo_mode_t: CAN FD Rx FIFO operating mode.

Values:

enumerator CY_CANFD_FIFO_MODE_BLOCKING

FIFO blocking mode.

enumerator CY_CANFD_FIFO_MODE_OVERWRITE

FIFO overwrite mode.

enum cy_en_accept_non_matching_frames_t

cy_en_accept_non_matching_frames_t: CAN FD accept non matching frames.

Values:

enumerator CY_CANFD_ACCEPT_IN_RXFIFO_0

Accept in Rx FIFO 0.

enumerator CY_CANFD_ACCEPT_IN_RXFIFO_1

Accept in Rx FIFO 1.

enumerator CY_CANFD_REJECT_NON_MATCHING

Reject the frames.

enum cy_en_canfd_id_filter_element_config_t

cy_en_canfd_id_filter_element_config_t: ID Filter element configuration type.

Values:

enumerator CY_CANFD_ID_FILTER_ELEMNT_CONFIG_DISABLE_FILETER_ELEMENT

Disable filter element.

enumerator CY_CANFD_ID_FILTER_ELEMNT_CONFIG_STORE_RXFIFO0

Store in Rx FIFO 0, if filter matches.

enumerator CY_CANFD_ID_FILTER_ELEMNT_CONFIG_STORE_RXFIFO1

Store in Rx FIFO 1, if filter matches.

enumerator CY_CANFD_ID_FILTER_ELEMNT_CONFIG_REJECT_ID

Reject ID if filter matches.

enumerator CY_CANFD_ID_FILTER_ELEMNT_CONFIG_SET_PRIORIY

Set priority if filter matches.

enumerator CY_CANFD_ID_FILTER_ELEMNT_CONFIG_SET_PIORITY_STORE_RXFIFO0

Set priority and store in FIFO 0, if filter matches.

enumerator CY_CANFD_ID_FILTER_ELEMNT_CONFIG_SET_PIORITY_STORE_RXFIFO1

Set priority and store in FIFO 1, if filter matches.

enumerator CY_CANFD_ID_FILTER_ELEMNT_CONFIG_STORE_RXBUFF_OR_DEBUGMSG

Store into Rx Buffer or as debug message, configuration of SFT[1:0] ignored.

enum cy_en_canfd_std_id_filter_type_t

cy_en_canfd_std_id_filter_type_t: Standard ID filter type.

Values:

enumerator CY_CANFD_STD_ID_FILTER_TYPE_RANGE

The Range filter from SFID1 to SFID2 (SFID2 = SFID1)

enumerator CY_CANFD_STD_ID_FILTER_TYPE_DUAL

The Dual ID filter for SFID1 or SFID2.

enumerator CY_CANFD_STD_ID_FILTER_TYPE_CLASSIC

The Classic filter: SFID1 = filter, SFID2 = mask.

enum cy_en_canfd_ext_id_filter_type_t

cy_en_canfd_ext_id_filter_type_t: Extended ID filter type.

Values:

enumerator CY_CANFD_EXT_ID_FILTER_TYPE_RANGE_AND_MASK

The range filter from EFID1 to EFID2 (EFID2 = EFID1)

enumerator CY_CANFD_EXT_ID_FILTER_TYPE_DUAL

The dual ID filter for EFID1 or EFID2.

enumerator CY_CANFD_EXT_ID_FILTER_TYPE_CLASSIC

The classic filter: EFID1 = filter, EFID2 = mask.

enumerator CY_CANFD_EXT_ID_FILTER_TYPE_RANGE

The range filter from EFID1 to EFID2 (EFID2 = EFID1), XIDAM mask not applied.

enum cy_en_canfd_rtr_t

cy_en_canfd_rtr_t: Type for indication of the received frame (Remote Transmission Request)

Values:

enumerator CY_CANFD_RTR_DATA_FRAME

The received frame is a data frame.

enumerator CY_CANFD_RTR_REMOTE_FRAME

The received frame is a remote frame.

enum cy_en_canfd_xtd_t

cy_en_canfd_xtd_t: Extended Identifier type (whether the received frame has a standard or extended identifier)

Values:

enumerator CY_CANFD_XTD_STANDARD_ID

The 11-bit standard identifier.

enumerator CY_CANFD_XTD_EXTENDED_ID

The 29-bit extended identifier.

enum cy_en_canfd_esi_t

cy_en_canfd_esi_t: Error State Indicator type.

Values:

enumerator CY_CANFD_ESI_ERROR_ACTIVE

The transmitting node is error active.

enumerator CY_CANFD_ESI_ERROR_PASSIVE

The transmitting node is error passive.

enum cy_en_canfd_fdf_t

cy_en_canfd_fdf_t: FD Format type.

Values:

enumerator CY_CANFD_FDF_STANDARD_FRAME

The standard frame format.

enumerator CY_CANFD_FDF_CAN_FD_FRAME

The CAN FD frame format (new DLC-coding and CRC)

enum cy_en_canfd_anmf_t

cy_en_canfd_anmf_t: Accepted Non-matching Frame type.

Values:

enumerator CY_CANFD_ANMF_MATCH_FILTER

The received frame matching filter index FIDX.

enumerator CY_CANFD_ANMF_NOT_MATCH_FILTER

The received frame did not match any Rx filter element.

enum cy_en_canfd_sfec_t

cy_en_canfd_sfec_t: Standard Filter Element Configuration type.

Values:

enumerator CY_CANFD_SFEC_DISABLE

Disable the filter element.

enumerator CY_CANFD_SFEC_STORE_RX_FIFO_0

Store in Rx FIFO 0 if the filter matches.

enumerator CY_CANFD_SFEC_STORE_RX_FIFO_1

Store in Rx FIFO 1 if the filter matches.

enumerator CY_CANFD_SFEC_REJECT_ID

Reject ID if the filter matches.

enumerator CY_CANFD_SFEC_SET_PRIORITY

Set priority if the filter matches.

enumerator CY_CANFD_SFEC_SET_PRIORITY_STORE_FIFO_0

Set priority and store in FIFO 0 if the filter matches.

enumerator CY_CANFD_SFEC_SET_PRIORITY_STORE_FIFO_1

Set priority and store in FIFO 1 if filter matches.

enumerator CY_CANFD_SFEC_STORE_RX_BUFFER

Store into Rx Buffer or as debug message, configuration of SFT[1:0] ignored.

enum cy_en_canfd_sft_t

cy_en_canfd_sft_t: Standard Filter Type.

Values:

enumerator CY_CANFD_SFT_RANGE_SFID1_SFID2

The range filter from SFID1 to SFID2 (SFID2 >= SFID1)

enumerator CY_CANFD_SFT_DUAL_ID

The Dual ID filter for SFID1 or SFID2.

enumerator CY_CANFD_SFT_CLASSIC_FILTER

The Classic filter: SFID1 = filter, SFID2 = mask.

enumerator CY_CANFD_SFT_DISABLED

The Filter element disabled.

enum cy_en_canfd_efec_t

cy_en_canfd_efec_t: Extended Filter Element Configuration type.

Values:

enumerator CY_CANFD_EFEC_DISABLE

Disable the filter element.

enumerator CY_CANFD_EFEC_STORE_RX_FIFO_0

Store in Rx FIFO 0 if the filter matches.

enumerator CY_CANFD_EFEC_STORE_RX_FIFO_1

Store in Rx FIFO 1 if the filter matches.

enumerator CY_CANFD_EFEC_REJECT_ID

Reject ID if the filter matches.

enumerator CY_CANFD_EFEC_SET_PRIORITY

Set priority if the filter matches.

enumerator CY_CANFD_EFEC_SET_PRIORITY_STORE_FIFO_0

Set priority and store in FIFO 0 if the filter matches.

enumerator CY_CANFD_EFEC_SET_PRIORITY_STORE_FIFO_1

Set priority and store in FIFO 1 if filter matches.

enumerator CY_CANFD_EFEC_STORE_RX_BUFFER

Store into Rx Buffer or as debug message, configuration of EFT[1:0] ignored.

enum cy_en_canfd_eft_t

cy_en_canfd_eft_t: Extended Filter Type.

Values:

enumerator CY_CANFD_EFT_RANGE_EFID1_EFID2

The range filter from EFID1 to EFID2 (EFID2 >= EFID1)

enumerator CY_CANFD_EFT_DUAL_ID

The Dual ID filter for EFID1 or EFID2.

enumerator CY_CANFD_EFT_CLASSIC_FILTER

The Classic filter: EFID1 = filter, EFID2 = mask.

enumerator CY_CANFD_EFT_RANGE_EFID1_EFID2_NO_MSK

The range filter from EFID1 to EFID2 (EFID2 >= EFID1), XIDAM mask not applied.

enum cy_stc_canfd_test_mode_t

cy_stc_canfd_test_mode_t: Test Mode Type.

Values:

enumerator CY_CANFD_TEST_MODE_DISABLE

The normal operation.

Test Mode is disabled

enumerator CY_CANFD_TEST_MODE_BUS_MONITORING

The Bus Monitoring Mode.

enumerator CY_CANFD_TEST_MODE_EXTERNAL_LOOP_BACK

The External Loop Back Mode.

enumerator CY_CANFD_TEST_MODE_INTERNAL_LOOP_BACK

The Internal Loop Back Mode.

enum cy_en_canfd_LEC_t

cy_en_canfd_LEC_t: Last Error Code and Data Phase Last Error Code Type.

Used with

Cy_CANFD_GetLastError() for LEC and DLEC fields of the Protocol Status Register.

Values:

enumerator CY_CANFD_LEC_NO_ERROR

No error occurred since LEC was reset by successful reception or transmission.

enumerator CY_CANFD_LEC_STUFF_ERROR

More than 5 equal bits in a sequence occurred in a part of a received message.

enumerator CY_CANFD_LEC_FORM_ERROR

A fixed format part of a received frame has the wrong format.

enumerator CY_CANFD_LEC_ACK_ERROR

The message this CAN FD Core transmitted was not acknowledged by another node.

enumerator CY_CANFD_LEC_BIT1_ERROR

While trying to send a recessive bit (1) a dominant level (0) was sampled.

enumerator CY_CANFD_LEC_BIT0_ERROR

While trying to send a dominant bit (0) a recessive level (1) was sampled.

enumerator CY_CANFD_LEC_CRC_ERROR

The CRC checksum was incorrect.

enumerator CY_CANFD_LEC_NO_CHANGE

No CAN bus event was detected since the last CPU read access to the Protocol Status Register.

enum cy_en_canfd_PSR_ACT_t

cy_en_canfd_PSR_ACT_t: Bus Activity State field of the PSR Used with Cy_CANFD_GetLastError() for ACT field of the Protocol Status Register.

Values:

enumerator CY_CANFD_PSR_ACT_SYNC

The node is synchronizing on CAN communication.

enumerator CY_CANFD_PSR_ACT_IDLE

The node is neither receiver nor transmitter.

enumerator CY_CANFD_PSR_ACT_RX

The node is operating as receiver.

enumerator CY_CANFD_PSR_ACT_TX

The node is operating as transmitter.

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.

struct cy_stc_canfd_r0_t
#include <cy_canfd.h>

R0 register.

Public Members

uint32_t id

Identifier.

cy_en_canfd_rtr_t rtr

Remote transmission request.

cy_en_canfd_xtd_t xtd

Extended identifier.

cy_en_canfd_esi_t esi

Error state indicator.

struct cy_stc_canfd_r1_t
#include <cy_canfd.h>

R1 register.

Public Members

uint32_t rxts

Rx timestamp.

uint32_t dlc

Data length code.

bool brs

Bit rate switch.

cy_en_canfd_fdf_t fdf

Extended data length.

uint32_t fidx

Filter index.

cy_en_canfd_anmf_t anmf

Accepted non-matching frame.

struct cy_stc_canfd_rx_buffer_t
#include <cy_canfd.h>

Rx buffer.

Public Members

cy_stc_canfd_r0_t *r0_f

Rx buffer element for R0.

See cy_stc_canfd_r0_t

cy_stc_canfd_r1_t *r1_f

Rx buffer element for R1.

See cy_stc_canfd_r1_t

uint32_t *data_area_f

Rx buffer element for Rn.

struct cy_stc_canfd_t0_t
#include <cy_canfd.h>

T0 register.

Public Members

uint32_t id

Identifier.

cy_en_canfd_rtr_t rtr

Remote transmission request.

0:data frame, 1:remote frame

cy_en_canfd_xtd_t xtd

Extended identifier.

0:11-bit standard identifier, 1:29-bit extended identifier

cy_en_canfd_esi_t esi

Error state indicator.

struct cy_stc_canfd_t1_t
#include <cy_canfd.h>

T1 register.

Public Members

uint32_t dlc

Data length code.

bool brs

Bit rate switching.

cy_en_canfd_fdf_t fdf

FD Format.

bool efc

Event FIFO control.

false: Do not store Tx events, true: Store Tx events

uint32_t mm

Message marker.

struct cy_stc_canfd_tx_buffer_t
#include <cy_canfd.h>

Tx buffer register.

Public Members

cy_stc_canfd_t0_t *t0_f

Tx buffer element for T0.

See cy_stc_canfd_t0_t

cy_stc_canfd_t1_t *t1_f

Tx buffer element for T1.

See cy_stc_canfd_t1_t

uint32_t *data_area_f

Tx buffer element for Tn.

struct cy_stc_id_filter_t
#include <cy_canfd.h>

Message ID filter register.

Public Members

uint32_t sfid2

Standard filter ID 2.

uint32_t sfid1

Standard filter ID 1.

cy_en_canfd_sfec_t sfec

Standard filter element configuration.

cy_en_canfd_sft_t sft

Standard filter Type.

struct cy_stc_canfd_f0_t
#include <cy_canfd.h>

F0 register.

Public Members

uint32_t efid1

Extended filter ID 1.

cy_en_canfd_efec_t efec

Extended filter element configuration.

struct cy_stc_canfd_f1_t
#include <cy_canfd.h>

F1 register.

Public Members

uint32_t efid2

Extended filter ID 2.

cy_en_canfd_eft_t eft

Extended filter type.

struct cy_stc_extid_filter_t
#include <cy_canfd.h>

Extended message ID filter register.

Public Members

const cy_stc_canfd_f0_t *f0_f

Extended message ID filter element for F0.

See cy_stc_canfd_f0_t

const cy_stc_canfd_f1_t *f1_f

Extended message ID filter element for F1.

See cy_stc_canfd_f1_t

struct cy_stc_canfd_bitrate_t
#include <cy_canfd.h>

CAN FD bitrate.

Public Members

uint16_t prescaler

Baud rate prescaler.

uint8_t timeSegment1

Time segment before sample point.

uint8_t timeSegment2

Time segment after sample point.

uint8_t syncJumpWidth

Synchronization jump width.

struct cy_stc_canfd_transceiver_delay_compensation_t
#include <cy_canfd.h>

CAN FD transceiver delay compensation offset configuration.

Public Members

bool tdcEnabled

Transceiver delay compensation enabled.

uint8_t tdcOffset

Transmitter delay compensation offset.

uint8_t tdcFilterWindow

Transmitter delay compensation filter window length.

struct cy_stc_canfd_sid_filter_config_t
#include <cy_canfd.h>

Standard ID filter configuration.

Public Members

uint8_t numberOfSIDFilters

Number Of standard ID filters.

const cy_stc_id_filter_t *sidFilter

Message ID Filter register.

struct cy_stc_canfd_extid_filter_config_t
#include <cy_canfd.h>

Extended ID filter configuration.

Public Members

uint8_t numberOfEXTIDFilters

Number Of extended ID filters.

const cy_stc_extid_filter_t *extidFilter

Extended message ID filter register.

uint32_t extIDANDMask

Extended ID AND Mask.

struct cy_stc_canfd_global_filter_config_t
#include <cy_canfd.h>

Global filter configuration.

Public Members

cy_en_accept_non_matching_frames_t nonMatchingFramesStandard

Non matching frames standard.

cy_en_accept_non_matching_frames_t nonMatchingFramesExtended

Non matching frames extended.

bool rejectRemoteFramesStandard

Reject remote frames standard.

bool rejectRemoteFramesExtended

Reject remote frames extended.

struct cy_en_canfd_fifo_config_t
#include <cy_canfd.h>

Rx FIFO configuration.

Public Members

cy_en_canfd_fifo_mode_t mode

CAN FD Rx FIFO operating mode.

uint8_t watermark

Watermark.

uint8_t numberOfFIFOElements

Number Of FIFO elements.

Note: The Rx FIFO size must be greater than 1 when FIFO Top Pointer Logic is enabled.

bool topPointerLogicEnabled

Top pointer logic enabled.

struct cy_stc_canfd_config_t
#include <cy_canfd.h>

CAN FD configuration.

Public Members

cy_canfd_tx_msg_func_ptr_t txCallback

Callback function for transmit completed.

Can be NULL

cy_canfd_rx_msg_func_ptr_t rxCallback

Callback function for receive completed.

Can be NULL

cy_canfd_error_func_ptr_t errorCallback

Callback function for CAN related errors.

Can be NULL

bool canFDMode

TRUE:CAN FD mode, FALSE:Classic CAN mode.

const cy_stc_canfd_bitrate_t *bitrate

CAN bitrate setting.

const cy_stc_canfd_bitrate_t *fastBitrate

CAN Fast bitrate setting.

const cy_stc_canfd_transceiver_delay_compensation_t *tdcConfig

CAN transceiver delay compensation setting.

const cy_stc_canfd_sid_filter_config_t *sidFilterConfig

CAN Standard ID filter setting.

const cy_stc_canfd_extid_filter_config_t *extidFilterConfig

CAN Extended ID filter setting.

const cy_stc_canfd_global_filter_config_t *globalFilterConfig

CAN global filter setting.

cy_en_canfd_buffer_data_size_t rxBufferDataSize

Rx Buffer Data Size.

cy_en_canfd_buffer_data_size_t rxFIFO1DataSize

Rx FIFO 1 Data Size.

cy_en_canfd_buffer_data_size_t rxFIFO0DataSize

Rx FIFO 0 Data Size.

cy_en_canfd_buffer_data_size_t txBufferDataSize

Tx Buffer Data Size.

const cy_en_canfd_fifo_config_t *rxFIFO0Config

Rx FIFO 0 configuration.

const cy_en_canfd_fifo_config_t *rxFIFO1Config

Rx FIFO 1 configuration.

uint8_t noOfRxBuffers

Number of Rx Buffers (Max 64)

uint8_t noOfTxBuffers

Number of Rx Buffers (Max 32)

uint32_t messageRAMaddress

The start address of Message RAM for the channel.

uint32_t messageRAMsize

The size in bytes of Message RAM for the channel.

struct cy_stc_canfd_interrupt_handling_t
#include <cy_canfd.h>

CAN FD interrupt pointer structure.

Holds some pointers to callback functions and buffer

Public Members

cy_canfd_tx_msg_func_ptr_t canFDTxInterruptFunction

The pointer to transmit interrupt callback.

cy_canfd_rx_msg_func_ptr_t canFDRxInterruptFunction

The pointer to receive interrupt callback (dedicated Rx Buffer or RxFIFO without Top pointer logic)

cy_canfd_error_func_ptr_t canFDErrorInterruptFunction

The pointer to error interrupt callback.

struct cy_stc_canfd_context_t
#include <cy_canfd.h>

Context structure.

Public Members

cy_stc_canfd_interrupt_handling_t canFDInterruptHandling

Interrupt callback.

uint32_t messageRAMaddress

The start address of Message RAM for the channel.

uint32_t messageRAMsize

The size in bytes of Message RAM for the channel.