Microchip® Advanced Software Framework

can.h File Reference

Controller Area Network (CAN) driver module for SAM.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"

Data Structures

struct  can_mb_conf_t
 Define the struct for CAN message mailbox. More...
 

Macros

#define CAN_BPS_1000K   1000
 Define the typical baudrate for CAN communication in KHz. More...
 
#define CAN_BPS_10K   10
 
#define CAN_BPS_125K   125
 
#define CAN_BPS_250K   250
 
#define CAN_BPS_25K   25
 
#define CAN_BPS_500K   500
 
#define CAN_BPS_50K   50
 
#define CAN_BPS_5K   5
 
#define CAN_BPS_800K   800
 
#define CAN_DISABLE_ALL_INTERRUPT_MASK   0xffffffff
 Disable all interrupt mask. More...
 
#define CAN_MAILBOX_NOT_READY   0x01
 Receiver is empty or transmitter is busy. More...
 
#define CAN_MAILBOX_RX_NEED_RD_AGAIN   0x04
 Application needs to re-read the data register in Receive with Overwrite mode. More...
 
#define CAN_MAILBOX_RX_OVER   0x02
 Message overwriting happens or there're messages lost in different receive modes. More...
 
#define CAN_MAILBOX_TRANSFER_OK   0
 Define CAN mailbox transfer status code. More...
 
#define CAN_MB_CONSUMER_MODE   4
 
#define CAN_MB_DISABLE_MODE   0
 Define the mailbox mode. More...
 
#define CAN_MB_PRODUCER_MODE   5
 
#define CAN_MB_RX_MODE   1
 
#define CAN_MB_RX_OVER_WR_MODE   2
 
#define CAN_MB_TX_MODE   3
 
#define GLOBAL_MAILBOX_MASK   0x000000ff
 Define the Mailbox mask for eight mailboxes. More...
 

Functions

void can_disable (Can *p_can)
 Disable CAN Controller. More...
 
void can_disable_autobaud_listen_mode (Can *p_can)
 Disable CAN Controller autobaud/listen mode. More...
 
void can_disable_interrupt (Can *p_can, uint32_t dw_mask)
 Disable CAN interrupt. More...
 
void can_disable_low_power_mode (Can *p_can)
 Disable CAN Controller low power mode. More...
 
void can_disable_overload_frame (Can *p_can)
 CAN Controller won't generate overload frame. More...
 
void can_disable_time_triggered_mode (Can *p_can)
 Disable CAN Controller time triggered mode. More...
 
void can_disable_timer_freeze (Can *p_can)
 Disable CAN Controller timer freeze. More...
 
void can_disable_tx_repeat (Can *p_can)
 Disable CAN Controller transmit repeat function. More...
 
void can_enable (Can *p_can)
 Enable CAN Controller. More...
 
void can_enable_autobaud_listen_mode (Can *p_can)
 Enable CAN Controller autobaud/listen mode. More...
 
void can_enable_interrupt (Can *p_can, uint32_t dw_mask)
 Enable CAN interrupt. More...
 
void can_enable_low_power_mode (Can *p_can)
 Enable CAN Controller low power mode. More...
 
void can_enable_overload_frame (Can *p_can)
 CAN Controller will generate an overload frame after each successful reception for mailboxes configured in Receive mode, Producer and Consumer. More...
 
void can_enable_time_triggered_mode (Can *p_can)
 Enable CAN Controller time triggered mode. More...
 
void can_enable_timer_freeze (Can *p_can)
 Enable CAN Controller timer freeze. More...
 
void can_enable_tx_repeat (Can *p_can)
 Enable CAN Controller transmit repeat function. More...
 
uint32_t can_get_internal_timer_value (Can *p_can)
 Get the 16-bit free-running internal timer count. More...
 
uint32_t can_get_interrupt_mask (Can *p_can)
 Get CAN Interrupt Mask. More...
 
uint8_t can_get_rx_error_cnt (Can *p_can)
 Get CAN receive error counter. More...
 
uint32_t can_get_status (Can *p_can)
 Get CAN status. More...
 
uint32_t can_get_timestamp_value (Can *p_can)
 Get CAN timestamp register value. More...
 
uint8_t can_get_tx_error_cnt (Can *p_can)
 Get CAN transmit error counter. More...
 
void can_global_send_abort_cmd (Can *p_can, uint8_t uc_mask)
 Send global abort request. More...
 
void can_global_send_transfer_cmd (Can *p_can, uint8_t uc_mask)
 Send global transfer request. More...
 
uint32_t can_init (Can *p_can, uint32_t ul_mck, uint32_t ul_baudrate)
 Initialize CAN controller. More...
 
uint32_t can_mailbox_get_status (Can *p_can, uint8_t uc_index)
 Get status of the mailbox. More...
 
void can_mailbox_init (Can *p_can, can_mb_conf_t *p_mailbox)
 Initialize the mailbox in different mode and set up related configuration. More...
 
uint32_t can_mailbox_read (Can *p_can, can_mb_conf_t *p_mailbox)
 Read receive information for the mailbox. More...
 
void can_mailbox_send_abort_cmd (Can *p_can, can_mb_conf_t *p_mailbox)
 Send single mailbox abort request. More...
 
void can_mailbox_send_transfer_cmd (Can *p_can, can_mb_conf_t *p_mailbox)
 Send single mailbox transfer request. More...
 
void can_mailbox_set_timemark (Can *p_can, uint8_t uc_index, uint16_t us_cnt)
 Configure the timemark for the mailbox. More...
 
uint32_t can_mailbox_tx_remote_frame (Can *p_can, can_mb_conf_t *p_mailbox)
 Require to send out a remote frame. More...
 
uint32_t can_mailbox_write (Can *p_can, can_mb_conf_t *p_mailbox)
 Prepare transmit information and write them into the mailbox. More...
 
void can_reset_all_mailbox (Can *p_can)
 Reset the eight mailboxes. More...
 
void can_reset_internal_timer (Can *p_can)
 Reset the internal free-running 16-bit timer. More...
 
void can_set_rx_sync_stage (Can *p_can, uint32_t ul_stage)
 Configure CAN Controller reception synchronization stage. More...
 
void can_set_timestamp_capture_point (Can *p_can, uint32_t ul_flag)
 Configure the timestamp capture point, at the start or the end of frame. More...
 

#define CAN_BPS_1000K   1000

Define the typical baudrate for CAN communication in KHz.

Referenced by main(), and run_can_test().

#define CAN_BPS_10K   10
#define CAN_BPS_125K   125
#define CAN_BPS_250K   250
#define CAN_BPS_25K   25
#define CAN_BPS_500K   500
#define CAN_BPS_50K   50
#define CAN_BPS_5K   5
#define CAN_BPS_800K   800
#define CAN_DISABLE_ALL_INTERRUPT_MASK   0xffffffff

Disable all interrupt mask.

Referenced by main(), and run_can_test().

#define CAN_MAILBOX_NOT_READY   0x01

Receiver is empty or transmitter is busy.

Referenced by can_mailbox_tx_remote_frame(), and can_mailbox_write().

#define CAN_MAILBOX_RX_NEED_RD_AGAIN   0x04

Application needs to re-read the data register in Receive with Overwrite mode.

Referenced by can_mailbox_read().

#define CAN_MAILBOX_RX_OVER   0x02

Message overwriting happens or there're messages lost in different receive modes.

Referenced by can_mailbox_read().

#define CAN_MAILBOX_TRANSFER_OK   0

Define CAN mailbox transfer status code.

Read from or write into mailbox successfully.

Referenced by can_mailbox_read(), can_mailbox_tx_remote_frame(), and can_mailbox_write().

#define CAN_MB_CONSUMER_MODE   4

Referenced by test_4().

#define CAN_MB_DISABLE_MODE   0

Define the mailbox mode.

Referenced by can_reset_all_mailbox().

#define CAN_MB_PRODUCER_MODE   5

Referenced by run_can_test(), and test_4().

#define CAN_MB_RX_MODE   1

Referenced by run_can_test(), test_1(), and test_2().

#define CAN_MB_RX_OVER_WR_MODE   2

Referenced by test_3().

#define CAN_MB_TX_MODE   3

Referenced by run_can_test(), test_1(), test_2(), and test_3().

#define GLOBAL_MAILBOX_MASK   0x000000ff

Define the Mailbox mask for eight mailboxes.

Referenced by CAN0_Handler(), CAN1_Handler(), can_global_send_abort_cmd(), and can_global_send_transfer_cmd().