![]() |
M480 BSP V3.05.006
The Board Support Package for M480 Series
|
Macros | |
#define | CAN_STD_ID_MASK(mask_bit) |
Specifies the standard identifier mask used for acceptance filtering. More... | |
#define | CAN_EXT_ID_MASK(mask_bit) |
Specifies the extended identifier mask used for acceptance filtering. More... | |
#define | CAN_GET_INT_STATUS(can) |
Get interrupt status. More... | |
#define | CAN_GET_INT_PENDING_STATUS(can) |
Get specified interrupt pending status. More... | |
#define | CAN_DISABLE_WAKEUP(can) |
Disable wake-up function. More... | |
#define | CAN_ENABLE_WAKEUP(can) |
Enable wake-up function. More... | |
#define | CAN_GET_NEW_DATA_IN_BIT(can, u32MsgNum) |
Get specified Message Object new data into bit value. More... | |
Functions | |
uint32_t | CAN_SetBaudRate (CAN_T *tCAN, uint32_t u32BaudRate) |
Set bus baud-rate. More... | |
uint32_t | CAN_Open (CAN_T *tCAN, uint32_t u32BaudRate, uint32_t u32Mode) |
Set CAN operation mode and target baud-rate. More... | |
void | CAN_Close (CAN_T *tCAN) |
The function is used to disable all CAN interrupt. More... | |
void | CAN_CLR_INT_PENDING_BIT (CAN_T *tCAN, uint8_t u32MsgNum) |
Clear interrupt pending bit. More... | |
void | CAN_EnableInt (CAN_T *tCAN, uint32_t u32Mask) |
Enable CAN interrupt. More... | |
void | CAN_DisableInt (CAN_T *tCAN, uint32_t u32Mask) |
Disable CAN interrupt. More... | |
int32_t | CAN_Transmit (CAN_T *tCAN, uint32_t u32MsgNum, STR_CANMSG_T *pCanMsg) |
Send CAN message. More... | |
int32_t | CAN_Receive (CAN_T *tCAN, uint32_t u32MsgNum, STR_CANMSG_T *pCanMsg) |
Gets the message, if received. More... | |
int32_t | CAN_SetMultiRxMsg (CAN_T *tCAN, uint32_t u32MsgNum, uint32_t u32MsgCount, uint32_t u32IDType, uint32_t u32ID) |
The function is used to configure several receive message objects. More... | |
int32_t | CAN_SetRxMsg (CAN_T *tCAN, uint32_t u32MsgNum, uint32_t u32IDType, uint32_t u32ID) |
The function is used to configure a receive message object. More... | |
int32_t | CAN_SetRxMsgAndMsk (CAN_T *tCAN, uint32_t u32MsgNum, uint32_t u32IDType, uint32_t u32ID, uint32_t u32IDMask) |
The function is used to configure a receive message object. More... | |
int32_t | CAN_SetTxMsg (CAN_T *tCAN, uint32_t u32MsgNum, STR_CANMSG_T *pCanMsg) |
The function is used to configure a transmit object. More... | |
int32_t | CAN_TriggerTxMsg (CAN_T *tCAN, uint32_t u32MsgNum) |
Set transmit request bit. More... | |
int32_t | CAN_BasicSendMsg (CAN_T *tCAN, STR_CANMSG_T *pCanMsg) |
Send CAN message in BASIC mode of test mode. More... | |
int32_t | CAN_BasicReceiveMsg (CAN_T *tCAN, STR_CANMSG_T *pCanMsg) |
Get a message information in BASIC mode. More... | |
void | CAN_EnterInitMode (CAN_T *tCAN, uint8_t u8Mask) |
Enter initialization mode. More... | |
void | CAN_EnterTestMode (CAN_T *tCAN, uint8_t u8TestMask) |
Switch the CAN into test mode. More... | |
void | CAN_LeaveTestMode (CAN_T *tCAN) |
Leave the test mode. More... | |
uint32_t | CAN_GetCANBitRate (CAN_T *tCAN) |
Get current bit rate. More... | |
uint32_t | CAN_IsNewDataReceived (CAN_T *tCAN, uint8_t u8MsgObj) |
Get the waiting status of a received message. More... | |
void | CAN_LeaveInitMode (CAN_T *tCAN) |
Leave initialization mode. More... | |
int32_t | CAN_SetRxMsgObjAndMsk (CAN_T *tCAN, uint8_t u8MsgObj, uint8_t u8idType, uint32_t u32id, uint32_t u32idmask, uint8_t u8singleOrFifoLast) |
Set Rx message object, include ID mask. More... | |
int32_t | CAN_SetRxMsgObj (CAN_T *tCAN, uint8_t u8MsgObj, uint8_t u8idType, uint32_t u32id, uint8_t u8singleOrFifoLast) |
Set Rx message object. More... | |
void | CAN_WaitMsg (CAN_T *tCAN) |
Wait message into message buffer in basic mode. More... | |
int32_t | CAN_ReadMsgObj (CAN_T *tCAN, uint8_t u8MsgObj, uint8_t u8Release, STR_CANMSG_T *pCanMsg) |
Gets the message. More... | |
Variables | |
uint32_t | STR_CANMSG_T::IdType |
uint32_t | STR_CANMSG_T::FrameType |
uint32_t | STR_CANMSG_T::Id |
uint8_t | STR_CANMSG_T::DLC |
uint8_t | STR_CANMSG_T::Data [8] |
uint8_t | STR_CANMASK_T::u8Xtd |
uint8_t | STR_CANMASK_T::u8Dir |
uint32_t | STR_CANMASK_T::u32Id |
uint8_t | STR_CANMASK_T::u8IdType |
HIDDEN_SYMBOLS
#define CAN_DISABLE_WAKEUP | ( | can | ) |
#define CAN_ENABLE_WAKEUP | ( | can | ) |
#define CAN_EXT_ID_MASK | ( | mask_bit | ) |
#define CAN_GET_INT_PENDING_STATUS | ( | can | ) |
Get specified interrupt pending status.
[in] | can | The base address of can module. |
If several interrupts are pending, the CAN Interrupt Register will point to the pending interrupt with the highest priority, disregarding their chronological order.
#define CAN_GET_INT_STATUS | ( | can | ) |
Get interrupt status.
[in] | can | The base address of can module. |
Status Interrupt is generated by bits BOff (CAN_STATUS[7]), EWarn (CAN_STATUS[6]), EPass (CAN_STATUS[5]), RxOk (CAN_STATUS[4]), TxOk (CAN_STATUS[3]), and LEC (CAN_STATUS[2:0]).
#define CAN_GET_NEW_DATA_IN_BIT | ( | can, | |
u32MsgNum | |||
) |
Get specified Message Object new data into bit value.
[in] | can | The base address of can module. |
[in] | u32MsgNum | Specified Message Object number, valid value are from 0 to 31. |
The NewDat bit (CAN_IFn_MCON[15]) of a specific Message Object can be set/reset by the software through the IFn Message Interface Registers or by the Message Handler after reception of a Data Frame or after a successful transmission.
#define CAN_STD_ID_MASK | ( | mask_bit | ) |
int32_t CAN_BasicReceiveMsg | ( | CAN_T * | tCAN, |
STR_CANMSG_T * | pCanMsg | ||
) |
int32_t CAN_BasicSendMsg | ( | CAN_T * | tCAN, |
STR_CANMSG_T * | pCanMsg | ||
) |
Send CAN message in BASIC mode of test mode.
[in] | tCAN | The pointer to CAN module base address. |
[in] | pCanMsg | Pointer to the message structure containing data to transmit. |
The function is used to send CAN message in BASIC mode of test mode. Before call the API, the user should be call CAN_EnterTestMode(CAN_TEST_BASIC) and let CAN controller enter basic mode of test mode. Please notice IF1 Registers used as Tx Buffer in basic mode.
void CAN_Close | ( | CAN_T * | tCAN | ) |
void CAN_CLR_INT_PENDING_BIT | ( | CAN_T * | tCAN, |
uint8_t | u32MsgNum | ||
) |
void CAN_DisableInt | ( | CAN_T * | tCAN, |
uint32_t | u32Mask | ||
) |
Disable CAN interrupt.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u32Mask | Interrupt Mask. (CAN_CON_IE_Msk / CAN_CON_SIE_Msk / CAN_CON_EIE_Msk). |
The interrupt remains active until the Interrupt Register is back to value zero (the cause of the interrupt is reset) or until IE is reset.
void CAN_EnableInt | ( | CAN_T * | tCAN, |
uint32_t | u32Mask | ||
) |
Enable CAN interrupt.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u32Mask | Interrupt Mask. Valid values are:
|
The application software has two possibilities to follow the source of a message interrupt. First, it can follow the IntId in the Interrupt Register and second it can poll the Interrupt Pending Register.
void CAN_EnterInitMode | ( | CAN_T * | tCAN, |
uint8_t | u8Mask | ||
) |
Enter initialization mode.
HIDDEN_SYMBOLS
[in] | tCAN | The pointer to CAN module base address. |
[in] | u8Mask | Following values can be used. CAN_CON_DAR_Msk Disable automatic retransmission. CAN_CON_EIE_Msk Enable error interrupt. CAN_CON_SIE_Msk Enable status interrupt. CAN_CON_IE_Msk CAN interrupt. |
This function is used to set CAN to enter initialization mode and enable access bit timing register. After bit timing configuration ready, user must call CAN_LeaveInitMode() to leave initialization mode and lock bit timing register to let new configuration take effect.
void CAN_EnterTestMode | ( | CAN_T * | tCAN, |
uint8_t | u8TestMask | ||
) |
Switch the CAN into test mode.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u8TestMask | Specifies the configuration in test modes CAN_TEST_BASIC_Msk Enable basic mode of test mode CAN_TEST_SILENT_Msk Enable silent mode of test mode CAN_TEST_LBACK_Msk Enable Loop Back Mode of test mode CAN_TEST_Tx_Msk Control CAN_TX pin bit field |
Switch the CAN into test mode. There are four test mode (BASIC/SILENT/LOOPBACK/ LOOPBACK combined SILENT/CONTROL_TX_PIN)could be selected. After setting test mode,user must call CAN_LeaveInitMode() to let the setting take effect.
uint32_t CAN_GetCANBitRate | ( | CAN_T * | tCAN | ) |
uint32_t CAN_IsNewDataReceived | ( | CAN_T * | tCAN, |
uint8_t | u8MsgObj | ||
) |
Get the waiting status of a received message.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u8MsgObj | Specifies the Message object number, from 0 to 31. |
non-zero | The corresponding message object has a new data bit is set. |
0 | No message object has new data. |
This function is used to get the waiting status of a received message.
void CAN_LeaveInitMode | ( | CAN_T * | tCAN | ) |
void CAN_LeaveTestMode | ( | CAN_T * | tCAN | ) |
uint32_t CAN_Open | ( | CAN_T * | tCAN, |
uint32_t | u32BaudRate, | ||
uint32_t | u32Mode | ||
) |
Set CAN operation mode and target baud-rate.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u32BaudRate | The target CAN baud-rate. The range of u32BaudRate is 1~1000KHz. |
[in] | u32Mode | The CAN operation mode. Valid values are:
|
Set bus timing parameter according current clock and target baud-rate. In Basic mode, IF1 Registers used as Tx Buffer, IF2 Registers used as Rx Buffer.
int32_t CAN_ReadMsgObj | ( | CAN_T * | tCAN, |
uint8_t | u8MsgObj, | ||
uint8_t | u8Release, | ||
STR_CANMSG_T * | pCanMsg | ||
) |
Gets the message.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u8MsgObj | Specifies the Message object number, from 0 to 31. |
[in] | u8Release | Specifies the message release indicator. This parameter can be one of the following values: TRUE: the message object is released when getting the data. FALSE:the message object is not released. |
[in] | pCanMsg | Pointer to the message structure where received data is copied. |
TRUE | Success |
FALSE | No any message received |
-1 | Read Message Fail |
Gets the message, if received.
int32_t CAN_Receive | ( | CAN_T * | tCAN, |
uint32_t | u32MsgNum, | ||
STR_CANMSG_T * | pCanMsg | ||
) |
Gets the message, if received.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u32MsgNum | Specifies the Message object number, from 0 to 31. |
[in] | pCanMsg | Pointer to the message structure where received data is copied. |
FALSE | No any message received. |
TRUE | Receive Message success. |
The Interface Registers avoid conflict between the CPU accesses to the Message RAM and CAN message reception and transmission by buffering the data to be transferred.
uint32_t CAN_SetBaudRate | ( | CAN_T * | tCAN, |
uint32_t | u32BaudRate | ||
) |
Set bus baud-rate.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u32BaudRate | The target CAN baud-rate. The range of u32BaudRate is 1~1000KHz. |
The function is used to set bus timing parameter according current clock and target baud-rate.
int32_t CAN_SetMultiRxMsg | ( | CAN_T * | tCAN, |
uint32_t | u32MsgNum, | ||
uint32_t | u32MsgCount, | ||
uint32_t | u32IDType, | ||
uint32_t | u32ID | ||
) |
The function is used to configure several receive message objects.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u32MsgNum | The starting MSG RAM number(0 ~ 31). |
[in] | u32MsgCount | the number of MSG RAM of the FIFO. |
[in] | u32IDType | Specifies the identifier type of the frames that will be transmitted. Valid values are:
|
[in] | u32ID | Specifies the identifier used for acceptance filtering. |
FALSE | No useful interface. |
TRUE | Configure receive message objects success. |
The Interface Registers avoid conflict between the CPU accesses to the Message RAM and CAN message reception and transmission by buffering the data to be transferred.
int32_t CAN_SetRxMsg | ( | CAN_T * | tCAN, |
uint32_t | u32MsgNum, | ||
uint32_t | u32IDType, | ||
uint32_t | u32ID | ||
) |
The function is used to configure a receive message object.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u32MsgNum | Specifies the Message object number, from 0 to 31. |
[in] | u32IDType | Specifies the identifier type of the frames that will be transmitted. Valid values are:
|
[in] | u32ID | Specifies the identifier used for acceptance filtering. |
FALSE | No useful interface. |
TRUE | Configure a receive message object success. |
If the RxIE bit (CAN_IFn_MCON[10]) is set, the IntPnd bit (CAN_IFn_MCON[13]) will be set when a received Data Frame is accepted and stored in the Message Object.
int32_t CAN_SetRxMsgAndMsk | ( | CAN_T * | tCAN, |
uint32_t | u32MsgNum, | ||
uint32_t | u32IDType, | ||
uint32_t | u32ID, | ||
uint32_t | u32IDMask | ||
) |
The function is used to configure a receive message object.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u32MsgNum | Specifies the Message object number, from 0 to 31. |
[in] | u32IDType | Specifies the identifier type of the frames that will be transmitted. Valid values are:
|
[in] | u32ID | Specifies the identifier used for acceptance filtering. |
[in] | u32IDMask | Specifies the identifier mask used for acceptance filtering. |
FALSE | No useful interface. |
TRUE | Configure a receive message object success. |
If the RxIE bit (CAN_IFn_MCON[10]) is set, the IntPnd bit (CAN_IFn_MCON[13]) will be set when a received Data Frame is accepted and stored in the Message Object.
int32_t CAN_SetRxMsgObj | ( | CAN_T * | tCAN, |
uint8_t | u8MsgObj, | ||
uint8_t | u8idType, | ||
uint32_t | u32id, | ||
uint8_t | u8singleOrFifoLast | ||
) |
Set Rx message object.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u8MsgObj | Specifies the Message object number, from 0 to 31. |
[in] | u8idType | Specifies the identifier type of the frames that will be transmitted This parameter can be one of the following values: CAN_STD_ID (standard ID, 11-bit) CAN_EXT_ID (extended ID, 29-bit) |
[in] | u32id | Specifies the identifier used for acceptance filtering. |
[in] | u8singleOrFifoLast | Specifies the end-of-buffer indicator. This parameter can be one of the following values: TRUE: for a single receive object or a FIFO receive object that is the last one of the FIFO. FALSE: for a FIFO receive object that is not the last one. |
TRUE | SUCCESS |
FALSE | No useful interface |
The function is used to configure a receive message object.
int32_t CAN_SetRxMsgObjAndMsk | ( | CAN_T * | tCAN, |
uint8_t | u8MsgObj, | ||
uint8_t | u8idType, | ||
uint32_t | u32id, | ||
uint32_t | u32idmask, | ||
uint8_t | u8singleOrFifoLast | ||
) |
Set Rx message object, include ID mask.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u8MsgObj | Specifies the Message object number, from 0 to 31. |
[in] | u8idType | Specifies the identifier type of the frames that will be transmitted This parameter can be one of the following values: CAN_STD_ID (standard ID, 11-bit) CAN_EXT_ID (extended ID, 29-bit) |
[in] | u32id | Specifies the identifier used for acceptance filtering. |
[in] | u32idmask | Specifies the identifier mask used for acceptance filtering. CAN_STD_ID_MASK CAN_EXT_ID_MASK CAN_MASK_MSG_DIR CAN_MASK_EXT_ID_BIT |
[in] | u8singleOrFifoLast | Specifies the end-of-buffer indicator. This parameter can be one of the following values: TRUE: for a single receive object or a FIFO receive object that is the last one of the FIFO. FALSE: for a FIFO receive object that is not the last one. |
TRUE | SUCCESS |
FALSE | No useful interface |
The function is used to configure a receive message object.
int32_t CAN_SetTxMsg | ( | CAN_T * | tCAN, |
uint32_t | u32MsgNum, | ||
STR_CANMSG_T * | pCanMsg | ||
) |
The function is used to configure a transmit object.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u32MsgNum | Specifies the Message object number, from 0 to 31. |
[in] | pCanMsg | Pointer to the message structure where received data is copied. |
FALSE | No useful interface. |
TRUE | Config message object success. |
The two sets of interface registers (IF1 and IF2) control the software access to the Message RAM. They buffer the data to be transferred to and from the RAM, avoiding conflicts between software accesses and message reception/transmission.
int32_t CAN_Transmit | ( | CAN_T * | tCAN, |
uint32_t | u32MsgNum, | ||
STR_CANMSG_T * | pCanMsg | ||
) |
Send CAN message.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u32MsgNum | Specifies the Message object number, from 0 to 31. |
[in] | pCanMsg | Pointer to the message structure where received data is copied. |
FALSE | 1. When operation in basic mode: Transmit message time out.
|
TRUE | Transmit Message success. |
The receive/transmit priority for the Message Objects is attached to the message number. Message Object 1 has the highest priority, while Message Object 32 has the lowest priority.
int32_t CAN_TriggerTxMsg | ( | CAN_T * | tCAN, |
uint32_t | u32MsgNum | ||
) |
Set transmit request bit.
[in] | tCAN | The pointer to CAN module base address. |
[in] | u32MsgNum | Specifies the Message object number, from 0 to 31. |
TRUE | Start transmit message. |
FALSE | No any message received |
-1 | CAN IF Busy. |
If a transmission is requested by programming bit TxRqst/NewDat (IFn_CMASK[2]), the TxRqst (IFn_MCON[8]) will be ignored.
void CAN_WaitMsg | ( | CAN_T * | tCAN | ) |
Wait message into message buffer in basic mode.
[in] | tCAN | The pointer to CAN module base address. |
This function is used to wait message into message buffer in basic mode. Please notice the function is polling NEWDAT bit of MCON register by while loop and it is used in basic mode.