Synergy Software Package User's Manual

Driver for CAN, Controller Area Network. More...

Data Structures

struct  can_instance_ctrl_t
 
struct  can_extended_cfg_t
 

Functions

ssp_err_t R_CAN_Open (can_ctrl_t *const p_ctrl, can_cfg_t const *const p_cfg)
 Open and configure the CAN channel for operation. Implements can_api_t::open() More...
 
ssp_err_t R_CAN_Close (can_ctrl_t *const p_ctrl)
 Close the CAN channel. Implements can_api_t::close() More...
 
ssp_err_t R_CAN_Read (can_ctrl_t *const p_ctrl, uint32_t mailbox, can_frame_t *const p_frame)
 Read data from the CAN channel. Return up to eight bytes read from the channel mailbox. Implements can_api_t::read() More...
 
ssp_err_t R_CAN_Write (can_ctrl_t *const p_ctrl, uint32_t mailbox, can_frame_t *const p_frame)
 Write data to the CAN channel. Write up to eight bytes to the channel mailbox. Implements can_api_t::write() More...
 
ssp_err_t R_CAN_Control (can_ctrl_t *const p_ctrl, can_command_t const command, void *p_data)
 CAN Control is used to control extended features. Implements can_api_t::control() More...
 
ssp_err_t R_CAN_InfoGet (can_ctrl_t *const p_ctrl, can_info_t *const p_info)
 Get CAN state and status information for the channel. Implements can_api_t::infoGet() More...
 
ssp_err_t R_CAN_VersionGet (ssp_version_t *const p_version)
 Get CAN module code and API versions. Implements can_api_t::versionGet() More...
 

Detailed Description

Driver for CAN, Controller Area Network.

This module supports the Controller Area Network peripheral. It implements the following interfaces:

Function Documentation

◆ R_CAN_Close()

ssp_err_t R_CAN_Close ( can_ctrl_t *const  p_ctrl)

Close the CAN channel. Implements can_api_t::close()

Return values
SSP_SUCCESSChannel closed successfully.
SSP_ERR_NOT_OPENControl block not open.
SSP_ERR_ASSERTIONNull pointer presented.

Mark the channel not open so other APIs cannot use it.

Disable transmit, receive and error interrupts

Enable module stop for the CAN channel

Unlock the CAN channel

◆ R_CAN_Control()

ssp_err_t R_CAN_Control ( can_ctrl_t *const  p_ctrl,
can_command_t const  command,
void *  p_data 
)

CAN Control is used to control extended features. Implements can_api_t::control()

Return values
SSP_SUCCESSOperation succeeded.
SSP_ERR_NOT_OPENControl block not open.
SSP_ERR_INVALID_ARGUMENTInvalid command.
SSP_ERR_ASSERTIONNull pointer presented
SSP_ERR_CAN_MODE_SWITCH_FAILEDSwitching modes failed.

Verify command is CAN_COMMAND_MODE_SWITCH

Change operating mode. Returns false if invalid mode or mode switch failed.

Save mode for diagnostic purposes.

◆ R_CAN_InfoGet()

ssp_err_t R_CAN_InfoGet ( can_ctrl_t *const  p_ctrl,
can_info_t *const  p_info 
)

Get CAN state and status information for the channel. Implements can_api_t::infoGet()

Return values
SSP_SUCCESSOperation succeeded.
SSP_ERR_NOT_OPENControl block not open.
SSP_ERR_CAN_DATA_UNAVAILABLEChannel failed to return info.
SSP_ERR_ASSERTIONNull pointer presented

Get status for channel.

Error encountered when retrieving info.

Save the operation mode

◆ R_CAN_Open()

ssp_err_t R_CAN_Open ( can_ctrl_t *const  p_ctrl,
can_cfg_t const *const  p_cfg 
)

Open and configure the CAN channel for operation. Implements can_api_t::open()

Return values
SSP_SUCCESSChannel opened successfully
SSP_ERR_INVALID_ARGUMENTInvalid channel passed as argument.
SSP_ERR_HW_LOCKEDLock already owned by another user.
SSP_ERR_CAN_MODE_SWITCH_FAILEDChannel failed to switch modes.
SSP_ERR_CAN_INIT_FAILEDChannel failed to initialize.
SSP_ERR_ASSERTIONNull pointer presented.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

Check for valid parameters.

Make sure the feature exists on this MCU.

Return if failed to get feature information.

Try to get channel lock.

Return if channel is already open so return error

Enter module start state.

Disable interrupts while initializing

Initialize and configure CAN module to run.

Set channel, callback function, context, id mode, mailbox count, message mode, op mode and opened status.

If successful, Lookup and store IRQ numbers. Enable interrupts.

If successful, Mark the control block as open

If the device failed to initialize, disable interrupts, stop and unlock the hardware and mark the control block as closed.

Process errors before returning.

Log error or assertion.

◆ R_CAN_Read()

ssp_err_t R_CAN_Read ( can_ctrl_t *const  p_ctrl,
uint32_t  mailbox,
can_frame_t *const  p_frame 
)

Read data from the CAN channel. Return up to eight bytes read from the channel mailbox. Implements can_api_t::read()

Return values
SSP_SUCCESSData successfully read.
SSP_ERR_NOT_OPENControl block not open.
SSP_ERR_CAN_DATA_UNAVAILABLENo data available.
SSP_ERR_CAN_TRANSMIT_MAILBOXMailbox is not setup for receive.
SSP_ERR_ASSERTIONNull pointer presented.

Check for receive data

Get frame data.

Check for other mailboxes in an overrun state.

Check for other mailboxes with received messages pending.

◆ R_CAN_VersionGet()

ssp_err_t R_CAN_VersionGet ( ssp_version_t *const  p_version)

Get CAN module code and API versions. Implements can_api_t::versionGet()

Return values
SSP_SUCCESSOperation succeeded.
SSP_ERR_ASSERTIONNull pointer presented note This function is reentrant.

Return module version information.

◆ R_CAN_Write()

ssp_err_t R_CAN_Write ( can_ctrl_t *const  p_ctrl,
uint32_t  mailbox,
can_frame_t *const  p_frame 
)

Write data to the CAN channel. Write up to eight bytes to the channel mailbox. Implements can_api_t::write()

Return values
SSP_SUCCESSOperation succeeded.
SSP_ERR_NOT_OPENControl block not open.
SSP_ERR_CAN_TRANSMIT_NOT_READYTransmit in progress, cannot write data at this time.
SSP_ERR_CAN_RECEIVE_MAILBOXMailbox is setup for receive and cannot send.
SSP_ERR_INVALID_ARGUMENTData length or frame type invalid.
SSP_ERR_ASSERTIONNull pointer presented

Check transmit ready flag.

Transmit ready flag is not set, return error/status.

Transmit ready flag set, so clear it.

Send transmit frame.