![]() |
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... | |
Driver for CAN, Controller Area Network.
This module supports the Controller Area Network peripheral. It implements the following interfaces:
| ssp_err_t R_CAN_Close | ( | can_ctrl_t *const | p_ctrl | ) |
Close the CAN channel. Implements can_api_t::close()
| SSP_SUCCESS | Channel closed successfully. |
| SSP_ERR_NOT_OPEN | Control block not open. |
| SSP_ERR_ASSERTION | Null 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
| 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()
| SSP_SUCCESS | Operation succeeded. |
| SSP_ERR_NOT_OPEN | Control block not open. |
| SSP_ERR_INVALID_ARGUMENT | Invalid command. |
| SSP_ERR_ASSERTION | Null pointer presented |
| SSP_ERR_CAN_MODE_SWITCH_FAILED | Switching 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.
| 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()
| SSP_SUCCESS | Operation succeeded. |
| SSP_ERR_NOT_OPEN | Control block not open. |
| SSP_ERR_CAN_DATA_UNAVAILABLE | Channel failed to return info. |
| SSP_ERR_ASSERTION | Null pointer presented |
Get status for channel.
Error encountered when retrieving info.
Save the operation mode
| 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()
| SSP_SUCCESS | Channel opened successfully |
| SSP_ERR_INVALID_ARGUMENT | Invalid channel passed as argument. |
| SSP_ERR_HW_LOCKED | Lock already owned by another user. |
| SSP_ERR_CAN_MODE_SWITCH_FAILED | Channel failed to switch modes. |
| SSP_ERR_CAN_INIT_FAILED | Channel failed to initialize. |
| SSP_ERR_ASSERTION | Null pointer presented. |
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.
| 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()
| SSP_SUCCESS | Data successfully read. |
| SSP_ERR_NOT_OPEN | Control block not open. |
| SSP_ERR_CAN_DATA_UNAVAILABLE | No data available. |
| SSP_ERR_CAN_TRANSMIT_MAILBOX | Mailbox is not setup for receive. |
| SSP_ERR_ASSERTION | Null 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.
| ssp_err_t R_CAN_VersionGet | ( | ssp_version_t *const | p_version | ) |
Get CAN module code and API versions. Implements can_api_t::versionGet()
| SSP_SUCCESS | Operation succeeded. |
| SSP_ERR_ASSERTION | Null pointer presented note This function is reentrant. |
Return module version information.
| 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()
| SSP_SUCCESS | Operation succeeded. |
| SSP_ERR_NOT_OPEN | Control block not open. |
| SSP_ERR_CAN_TRANSMIT_NOT_READY | Transmit in progress, cannot write data at this time. |
| SSP_ERR_CAN_RECEIVE_MAILBOX | Mailbox is setup for receive and cannot send. |
| SSP_ERR_INVALID_ARGUMENT | Data length or frame type invalid. |
| SSP_ERR_ASSERTION | Null 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.