Parameter \em bit_segments |
Bit |
for \em select = \ref ARM_CAN_BITRATE_NOMINAL \n (CAN specification) |
for \em select = \ref ARM_CAN_BITRATE_NOMINAL \n (CAN FD specification) |
for \em select = \ref ARM_CAN_BITRATE_FD_DATA \n (CAN FD specification) |
\ref ARM_CAN_BIT_PROP_SEG(x) \n
Propagation Time Segment \n (PROP_SEG)
|
0..7 |
\em x = \token{[1..8]} |
\em x = \token{[1..32] or more} |
\em x = \token{[0..8]} |
\ref ARM_CAN_BIT_PHASE_SEG1(x) \n
Phase Buffer Segment 1 \n (PHASE_SEG1)
|
8..15 |
\em x = \token{[1..8]} |
\em x = \token{[1..32] or more} |
\em x = \token{[1..8]} |
\ref ARM_CAN_BIT_PHASE_SEG2(x) \n
Phase Buffer Segment 2 \n (PHASE_SEG2)
|
16..23 |
\em x = \token{[1..8]} |
\em x = \token{[1..32] or more} |
\em x = \token{[1..8]} |
The maximum allowed value is \token{x = MAX (PHASE_SEG1, IPT)}.
IPT = Information Processing Time. Usually, IPT = \token{2}.
Exceptions apply. Read the specifications of your CAN controller. |
\ref ARM_CAN_BIT_SJW(x) \n
(Re-)Synchronization Jump Width \n (SJW).
|
24..31 |
\em x = \token{[1..4]} |
\em x = \token{[1..4]} |
\em x = \token{[1..4]} |
The maximum allowed value is \token{x = MIN (MIN (PHASE_SEG1, PHASE_SEG2), 4)}.
SJW is not allowed to be greater than either PHASE segment.
|
The picture shows a Nominal Bit Time with 10 time quanta.
\image html CAN_Bit_Timing.png "CAN Bit Timing"
The time quanta (N) per bit is:
\code
N = 1 + PROP_SEG + PHASE_SEG1 + PHASE_SEG2; // note SYNC_SEG is always 1
\endcode
The driver uses this value and the CAN clock to calculate a suitable prescaler value (P).
If the driver cannot achieve the requested \em bitrate it returns with \ref ARM_CAN_INVALID_BITRATE.
The formula for the \em bitrate is:
\code
bitrate = (CAN_Clock / P) / N;
\endcode
Parameter \em mode |
Bus Communication Mode |
supported when \ref ARM_CAN_OBJ_CAPABILITIES data field |
\ref ARM_CAN_MODE_INITIALIZATION |
Initialization mode; Used to setup communication parameters for the reception
objects and global filtering, while peripheral is not active on the bus.
Refer to \ref can_filtering for details. |
always supported |
\ref ARM_CAN_MODE_NORMAL |
Normal operation mode. Used when peripheral is in active mode to
receive, transmit, and acknowledge messages on the bus. Depending on the current unit state,
it can generate error or overload messages. Verify the unit state with \ref ARM_CAN_GetStatus.
| always supported |
\ref ARM_CAN_MODE_RESTRICTED |
Restricted operation mode. Used for monitoring the bus communication non-intrusively
without transmitting. |
\em restricted_mode = \token{1} |
\ref ARM_CAN_MODE_MONITOR |
Bus monitoring mode. |
\em monitor_mode = \token{1} |
\ref ARM_CAN_MODE_LOOPBACK_INTERNAL |
Test mode; loopback of CAN transmission to its receiver. No transmission visible on CAN bus. |
\em internal_loopback = \token{1} |
\ref ARM_CAN_MODE_LOOPBACK_EXTERNAL |
Test mode; loopback of CAN transmission to its receiver. Transmission is visible on CAN bus. |
\em external_loopback = \token{1} |
**************************************************************************************************************************/
ARM_CAN_OBJ_CAPABILITIES ARM_CAN_ObjectGetCapabilities (uint32_t obj_idx) {
// your code
// return type ARM_CAN_OBJ_CAPABILITIES;
}
/**
\fn ARM_CAN_OBJ_CAPABILITIES ARM_CAN_ObjectGetCapabilities (uint32_t obj_idx)
\details
The function \b ARM_CAN_ObjectGetCapabilities retrieves the capabilities of a CAN object.
The structure \ref ARM_CAN_OBJ_CAPABILITIES stores the values.
The parameter \em obj_idx is the message object index.
\sa ARM_CAN_ObjectConfigure
\sa ARM_CAN_ObjectSetFilter
**************************************************************************************************************************/
int32_t ARM_CAN_ObjectSetFilter (uint32_t obj_idx, ARM_CAN_FILTER_OPERATION operation, uint32_t id, uint32_t arg) {
return ARM_DRIVER_OK;
}
/**
\fn int32_t ARM_CAN_ObjectSetFilter (uint32_t obj_idx, ARM_CAN_FILTER_OPERATION operation, uint32_t id, uint32_t arg)
\details
The function \b ARM_CAN_ObjectSetFilter sets or removes the filter for message reception. Refer to \ref can_filtering for details on filtering.
The parameter \em obj_idx is the message object index. \n
The parameter \em operation is the operation on the filter as listed in the table below and
which are defined in the structure \ref ARM_CAN_FILTER_OPERATION.
Parameter \em operation | Operation on Filter | supported when \ref ARM_CAN_OBJ_CAPABILITIES data field
:---------------------------------------|:------------------------------|:------------------------------------------
\ref ARM_CAN_FILTER_ID_EXACT_ADD | Add exact ID filter | \em exact_filtering = \token{1}
\ref ARM_CAN_FILTER_ID_EXACT_REMOVE | Remove exact ID filter | \em exact_filtering = \token{1}
\ref ARM_CAN_FILTER_ID_RANGE_ADD | Add range ID filter | \em range_filtering = \token{1}
\ref ARM_CAN_FILTER_ID_RANGE_REMOVE | Remove range ID filter | \em range_filtering = \token{1}
\ref ARM_CAN_FILTER_ID_MASKABLE_ADD | Add maskable ID filter | \em mask_filtering = \token{1}
\ref ARM_CAN_FILTER_ID_MASKABLE_REMOVE | Remove maskable ID filter | \em mask_filtering = \token{1}
The parameter \em id is the identifier of the filter or defines the start of the filter range (depends on the filter operation). \n
The parameter \em arg is the mask of the filter or defines the end of the filter range (depends on the filter operation).
\sa ARM_CAN_ObjectConfigure
**************************************************************************************************************************/
int32_t ARM_CAN_ObjectConfigure (uint32_t obj_idx, ARM_CAN_OBJ_CONFIG obj_cfg) {
return ARM_DRIVER_OK;
}
/**
\fn int32_t ARM_CAN_ObjectConfigure (uint32_t obj_idx, ARM_CAN_OBJ_CONFIG obj_cfg)
\details
The function \b ARM_CAN_ObjectConfigure configures the message object, which can be a mailbox or FIFO.
Refer to \ref can_filtering for details.
The parameter \em obj_idx specifies the message object index. \n
The parameter \em obj_cfg configures the \b object with values as shown in the following table.
Parameter \em obj_cfg |
Object Configuration |
supported when \ref ARM_CAN_OBJ_CAPABILITIES data field |
\ref ARM_CAN_OBJ_INACTIVE |
Deactivate object (default after \ref ARM_CAN_Initialize)
|
always supported |
\ref ARM_CAN_OBJ_RX |
Receive object; read received message with \ref ARM_CAN_MessageRead.
|
\em rx = \token{1} |
\ref ARM_CAN_OBJ_TX |
Transmit object; send message with \ref ARM_CAN_MessageSend.
|
\em tx = \token{1} |
\ref ARM_CAN_OBJ_RX_RTR_TX_DATA |
\ref Remote_Frame Receive; when \b RTR is received data message is transmitted; set data message with \ref ARM_CAN_MessageSend.
|
\em rx_rtr_tx_data = \token{1} |
\ref ARM_CAN_OBJ_TX_RTR_RX_DATA |
\ref Remote_Frame Transmit; a \b RTR is sent with \ref ARM_CAN_MessageSend to trigger object reception; read received data message with \ref ARM_CAN_MessageRead.
|
\em tx_rtr_rx_data = \token{1} |
When the \b object is deactivated, it is not used for data communication.
\sa ARM_CAN_ObjectSetFilter
**************************************************************************************************************************/
int32_t ARM_CAN_MessageSend (uint32_t obj_idx, ARM_CAN_MSG_INFO *msg_info, const uint8_t *data, uint8_t size) {
return ARM_DRIVER_OK;
}
/**
\fn int32_t ARM_CAN_MessageSend (uint32_t obj_idx, ARM_CAN_MSG_INFO *msg_info, const uint8_t *data, uint8_t size)
\details
The function \b ARM_CAN_MessageSend sends a CAN message on the CAN bus, or sets data message that will be automatically returned upon RTR reception with matching CAN ID.
Only one message can be sent with a call to this function (for CAN up to \token{8} bytes; for CAN FD up to \token{64} bytes of data).
A message transmission can be terminated with a call to the function \ref ARM_CAN_Control with \em control = \ref ARM_CAN_ABORT_MESSAGE_SEND.
The parameter \em obj_idx specifies the message object index.
The parameter \em msg_info is a pointer to the structure \ref ARM_CAN_MSG_INFO, which contains the following relevant data fields for sending message:
- \em id: Identifier of the message; bit \token{31} specifies if this is an \token{11-bit} or \token{29-bit} identifier.
- \em rtr: Specifies if Remote Transmission Request should be sent (\em dlc is used for number of requested bytes), otherwise the data message will be sent. Refer to \ref Remote_Frame for details.
- \em edl: Specifies if Extended Data Length is used; for CAN FD, message can contain up to \token{64} data bytes.
- \em brs: Specifies if Bit Rate Switching is to be used; for CAN FD, the bit rate can be increased during data phase.
- \em dlc: Data Length Code of requested data bytes when sending Remote Transmission Request.
The parameter \em data is a pointer to the data buffer.\n
The parameter \em size is the number of data bytes to send.\n
The function returns the number of bytes accepted to be sent or \ref ARM_DRIVER_ERROR_BUSY if the hardware is not
ready to accept a new message for transmission.
When the message is sent, the callback function \ref ARM_CAN_SignalObjectEvent is called signalling \ref ARM_CAN_EVENT_SEND_COMPLETE
on specified object.
\sa \ref can_filtering