Kinetis Bootloader  2.0.0
Common bootloader for Kinetis devices
FLEXCAN Peripheral

FLEXCAN peripheral interface. More...

+ Collaboration diagram for FLEXCAN Peripheral:

Data Structures

struct  flexcan_state_t
 Internal driver state information. More...
 
struct  flexcan_data_info_t
 FlexCAN data info from user. More...
 
struct  flexcan_transfer_info_t
 flexCAN global information structure. More...
 

Enumerations

enum  flexcan_operation_modes_t {
  kFlexCanNormalMode,
  kFlexCanListenOnlyMode,
  kFlexCanLoopBackMode,
  kFlexCanFreezeMode,
  kFlexCanDisableMode,
  kFlexCanNormalMode,
  kFlexCanListenOnlyMode,
  kFlexCanLoopBackMode,
  kFlexCanFreezeMode,
  kFlexCanDisableMode,
  kFlexCanNormalMode,
  kFlexCanListenOnlyMode,
  kFlexCanLoopBackMode,
  kFlexCanFreezeMode,
  kFlexCanDisableMode,
  kFlexCanNormalMode,
  kFlexCanListenOnlyMode,
  kFlexCanLoopBackMode,
  kFlexCanFreezeMode,
  kFlexCanDisableMode
}
 FlexCAN operation modes. More...
 

Functions

static bool flexcan_poll_for_activity (const peripheral_descriptor_t *self)
 flexCAN poll for activity function
 
static status_t flexcan_full_init (const peripheral_descriptor_t *self, serial_byte_receive_func_t function)
 flexCAN init function
 
static void flexcan_full_shutdown (const peripheral_descriptor_t *self)
 flexCAN shutdown function
 
static void flexcan_initial_data_sink (uint8_t sink_byte, uint32_t instance)
 flexCAN receiving first byte data sink function
 
static void flexcan_data_sink (uint8_t sink_byte, uint32_t instance)
 flexCAN receiving data sink function
 
static void flexcan_peripheral_init (uint32_t instance)
 flexCAN internal init function
 
static status_t flexcan_write (const peripheral_descriptor_t *self, const uint8_t *buffer, uint32_t byteCount)
 flexCAN sending data function
 
static status_t FLEXCAN_Send (uint8_t instance, uint32_t mb_idx, flexcan_data_info_t *tx_info, uint32_t msg_id, uint8_t *mb_data, uint32_t timeout_ms)
 
void FLEXCAN_SoftReset (CAN_Type *baseAddr)
 
void FLEXCAN_ExitFreezeMode (CAN_Type *baseAddr)
 
void FLEXCAN_EnterFreezeMode (CAN_Type *baseAddr)
 
void FLEXCAN_EnableOperationMode (CAN_Type *baseAddr, flexcan_operation_modes_t mode)
 
void FLEXCAN_DisableOperationMode (CAN_Type *baseAddr, flexcan_operation_modes_t mode)
 
void FLEXCAN_IRQBusoffHandler (uint8_t instance)
 
void FLEXCAN_IRQErrorHandler (uint8_t instance)
 
void FLEXCAN_IRQHandler (uint8_t instance)
 
void FLEXCAN_CANIRQHandler (uint8_t instance)
 
void CAN0_Oredbuf_IRQHandler (void)
 
void CAN0_Bus_Off_IRQHandler (void)
 
void CAN0_Error_IRQHandler (void)
 
void CAN0_Wakeup_IRQHandler (void)
 
void CAN0_IRQHandler (void)
 
void CAN1_ORed_Message_buffer_IRQHandler (void)
 
void CAN1_Bus_Off_IRQHandler (void)
 
void CAN1_Error_IRQHandler (void)
 
void CAN1_Wake_Up_IRQHandler (void)
 

Variables

const flexcan_timing_config_t bit_rate_table_8Mhz [FLEXCAN_MAX_SPEED]
 FlexCAN bit timing parameters calculated by using the method outlined in AN1798, section 4.1. More...
 
const flexcan_timing_config_t bit_rate_table []
 flexCAN timing table (20.9715Mhz)contains propseg, pseg1, pseg2, pre_divider, rjw More...
 
const flexcan_timing_config_t bit_rate_table_12Mhz [FLEXCAN_MAX_SPEED]
 
const flexcan_timing_config_t bit_rate_table_6Mhz [FLEXCAN_MAX_SPEED]
 
const flexcan_timing_config_t bit_rate_table_10Mhz [FLEXCAN_MAX_SPEED]
 
const peripheral_control_interface_t g_flexcanControlInterface
 flexCAN control interface information More...
 
const peripheral_byte_inteface_t g_flexcanByteInterface
 flexCAN byte interface information More...
 
flexcan_transfer_info_t s_flexcanInfo
 Global state for the FLEXCAN peripheral interface.
 
static bool s_flexcanIntialized [FSL_FEATURE_SOC_FLEXCAN_COUNT] = { false }
 Flag for flexcan intialization state.
 
static bool s_flexcanActivity [FSL_FEATURE_SOC_FLEXCAN_COUNT] = { false }
 
static serial_byte_receive_func_t s_flexcan_app_data_sink_callback
 flexCAN receiving data call back function
 
static const uint32_t g_flexcanBaseAddr [] = CAN_BASE_ADDRS
 
const IRQn_Type g_flexcanRxWarningIrqId [] = CAN_Rx_Warning_IRQS
 
const IRQn_Type g_flexcanTxWarningIrqId [] = CAN_Tx_Warning_IRQS
 
const IRQn_Type g_flexcanWakeUpIrqId [] = CAN_Wake_Up_IRQS
 
const IRQn_Type g_flexcanErrorIrqId [] = CAN_Error_IRQS
 
const IRQn_Type g_flexcanBusOffIrqId [] = CAN_Bus_Off_IRQS
 
const IRQn_Type g_flexcanOredMessageBufferIrqId [] = CAN_ORed_Message_buffer_IRQS
 

Usage Information

FLEXCAN peripheral interface.


Data Structure Documentation

struct flexcan_state_t

Internal driver state information.

Note
The contents of this structure are internal to the driver and should not be modified by users. Also, contents of the structure are subject to change in future releases.
+ Collaboration diagram for flexcan_state_t:
Data Fields
volatile uint32_t rx_mb_idx

Index of the message buffer for receiving

semaphore_t rxIrqSync

Used to wait for ISR to complete its RX business.

volatile uint32_t tx_mb_idx

Index of the message buffer for transmitting

semaphore_t txIrqSync

Used to wait for ISR to complete its TX business.

struct flexcan_data_info_t

FlexCAN data info from user.

Data Fields
uint32_t data_length

Length of Data in Bytes

flexcan_frame_format_t msg_id_type

Type of message ID (standard or extended)

struct flexcan_transfer_info_t

flexCAN global information structure.

flexCAN common information structure

+ Collaboration diagram for flexcan_transfer_info_t:

Data Fields

flexcan_state_t state
 state
 
flexcan_data_info_t rx_info
 tx info
 
flexcan_data_info_t tx_info
 tx info
 
int8_t baudrate
 baudrate (index)
 
flexcan_operation_modes_t mode
 
bool baudrateDetect
 auto baudrate detection
 
uint16_t txId
 tx id
 
uint16_t rxId
 rx id
 
void(* data_source )(uint8_t *source_byte)
 
void(* data_sink )(uint8_t sink_byte, uint32_t instance)
 
uint32_t rxId
 rx id
 
uint32_t txId
 tx id
 
uint32_t rx_mailbox_num
 rx mb number
 
uint32_t tx_mailbox_num
 tx mb number
 
uint8_t rx_buf [64]
 rx buffer
 
uint8_t rx_buf_write_index
 rx buffer write index
 
uint8_t rx_buf_read_index
 rx buffer read index
 

Enumeration Type Documentation

FlexCAN operation modes.

Enumerator
kFlexCanNormalMode 

Normal mode or user mode

kFlexCanListenOnlyMode 

Listen-only mode

kFlexCanLoopBackMode 

Loop-back mode

kFlexCanFreezeMode 

Freeze mode

kFlexCanDisableMode 

Module disable mode

kFlexCanNormalMode 

Normal mode or user mode

kFlexCanListenOnlyMode 

Listen-only mode

kFlexCanLoopBackMode 

Loop-back mode

kFlexCanFreezeMode 

Freeze mode

kFlexCanDisableMode 

Module disable mode

kFlexCanNormalMode 

Normal mode or user mode

kFlexCanListenOnlyMode 

Listen-only mode

kFlexCanLoopBackMode 

Loop-back mode

kFlexCanFreezeMode 

Freeze mode

kFlexCanDisableMode 

Module disable mode

kFlexCanNormalMode 

Normal mode or user mode

kFlexCanListenOnlyMode 

Listen-only mode

kFlexCanLoopBackMode 

Loop-back mode

kFlexCanFreezeMode 

Freeze mode

kFlexCanDisableMode 

Module disable mode

Variable Documentation

flexcan_timing_config_t bit_rate_table
Initial value:
= {
{ 7, 3, 7, 7, 3 },
{ 3, 3, 7, 7, 3 },
{ 1, 3, 7, 7, 3 },
{ 1, 3, 3, 3, 5 },
{ 0, 3, 5, 5, 7 }
}

flexCAN timing table (20.9715Mhz)contains propseg, pseg1, pseg2, pre_divider, rjw

const flexcan_timing_config_t bit_rate_table_10Mhz[FLEXCAN_MAX_SPEED]
Initial value:
= {
{ 7, 3, 3, 3, 0 },
{ 3, 3, 3, 3, 0 },
{ 1, 2, 2, 2, 2 },
{ 0, 3, 3, 3, 3 },
{ 0, 1, 1, 1, 4 }
}
const flexcan_timing_config_t bit_rate_table_12Mhz[FLEXCAN_MAX_SPEED]
Initial value:
= {
{ 7, 3, 4, 4, 0 },
{ 3, 3, 4, 4, 0 },
{ 1, 3, 3, 3, 2 },
{ 1, 1, 1, 1, 2 },
{ 0, 2, 2, 2, 4 }
}
const flexcan_timing_config_t bit_rate_table_6Mhz[FLEXCAN_MAX_SPEED]
Initial value:
= {
{ 3, 3, 4, 4, 0 },
{ 1, 3, 4, 4, 0 },
{ 0, 3, 3, 3, 2 },
{ 0, 1, 1, 1, 2 },
{ 0, 0, 0, 1, 1 }
}
const flexcan_timing_config_t bit_rate_table_8Mhz
Initial value:
= {
{ 7, 2, 2, 2, 0 },
{ 3, 2, 2, 2, 0 },
{ 1, 1, 1, 1, 2 },
{ 0, 2, 2, 2, 2 },
{ 0, 1, 1, 1, 2 }
}

FlexCAN bit timing parameters calculated by using the method outlined in AN1798, section 4.1.

The table contains propseg, pseg1, pseg2, pre_divider, and rjw.

const peripheral_byte_inteface_t g_flexcanByteInterface
Initial value:
= {
.init = NULL, .write = flexcan_write,
}
static status_t flexcan_write(const peripheral_descriptor_t *self, const uint8_t *buffer, uint32_t byteCount)
flexCAN sending data function
Definition: flexcan_peripheral_interface.c:681

flexCAN byte interface information

Byte I/O interface for the FLEXCAN peripheral driver.

const peripheral_control_interface_t g_flexcanControlInterface
Initial value:
= {.pollForActivity = flexcan_poll_for_activity,
.shutdown = flexcan_full_shutdown,
.pump = 0 }
static bool flexcan_poll_for_activity(const peripheral_descriptor_t *self)
flexCAN poll for activity function
Definition: flexcan_peripheral_interface.c:440
static void flexcan_full_shutdown(const peripheral_descriptor_t *self)
flexCAN shutdown function
Definition: flexcan_peripheral_interface.c:661
static status_t flexcan_full_init(const peripheral_descriptor_t *self, serial_byte_receive_func_t function)
flexCAN init function
Definition: flexcan_peripheral_interface.c:642

flexCAN control interface information

Control interface for the FLEXCAN peripheral driver.