STM8S/A Standard Peripherals Drivers
|
This file contains all the functions for the CAN peripheral. More...
#include "stm8s.h"
Go to the source code of this file.
Defines | |
#define | CAN_DLC_MAX ((uint8_t)0x08) |
#define | CAN_EXTID_SIZE ((uint32_t)0x1FFFFFFF) |
#define | CAN_IT_CONFIG_MASK ~(uint16_t)(CAN_IT_TME|CAN_IT_FMP|CAN_IT_FF|CAN_IT_FOV|CAN_IT_WKU|CAN_IT_EWG|CAN_IT_EPV|CAN_IT_BOF|CAN_IT_LEC|CAN_IT_ERR) |
Macro used by the assert function in order to check the CAN Configuration interrupts. | |
#define | CAN_STDID_SIZE ((uint16_t)0x07FF) |
#define | IS_CAN_BITSEG1_OK(BS1) ((BS1) <= CAN_BitSeg1_16TimeQuantum) |
Macro used by the assert function in order to check time quantum in bit segment 1 . | |
#define | IS_CAN_BITSEG2_OK(BS2) ((((BS2) >= CAN_BitSeg2_2TimeQuantum) && ((BS2) <= CAN_BitSeg2_8TimeQuantum))|| ((BS2) == CAN_BitSeg2_1TimeQuantum)) |
Macro used by the assert function in order to check time quantum in bit segment 2. | |
#define | IS_CAN_DLC_OK(DLC) ((DLC) <= CAN_DLC_MAX) |
Macro used by the assert function in order to check the DLC to be sent. | |
#define | IS_CAN_EXTID_OK(EXTID) ((EXTID) <= ((uint32_t)CAN_EXTID_SIZE)) |
Macro used by the assert function in order to check the Extended ID to be sent. | |
#define | IS_CAN_FILTER_MODE_OK(MODE) |
Macro used by the assert function in order to check CAN filter mode. | |
#define | IS_CAN_FILTER_NUMBER_OK(NUMBER) |
Macro used by the assert function in order to check CAN filter number. | |
#define | IS_CAN_FILTER_SCALE_OK(SCALE) |
Macro used by the assert function in order to check CAN filter scale. | |
#define | IS_CAN_FLAG_CLEAR_OK(FLAG) |
Macro used by the assert function in order to check CAN flags which can be cleared by CAN_ClearFlag. | |
#define | IS_CAN_FLAG_STATUS_OK(FLAG) |
Macro used by the assert function in order to check CAN flags which can be got by CAN_GetFlagStatus. | |
#define | IS_CAN_IDTYPE_OK(IDTYPE) (((IDTYPE) == CAN_Id_Standard) || ((IDTYPE) == CAN_Id_Extended)) |
Macro used by the assert function in order to check the type of the ID to be sent. | |
#define | IS_CAN_IT_CONFIG_OK(IT) (((IT) != 0x0000) && ((uint16_t)((uint16_t)(IT) & (uint16_t)CAN_IT_CONFIG_MASK) == 0x0000)) |
#define | IS_CAN_IT_PENDING_BIT_OK(IT) |
Macro used by the assert function in order to check the CAN Pending bit interrupts. | |
#define | IS_CAN_IT_STATUS_OK(IT) |
Macro used by the assert function in order to check the CAN status interrupts. | |
#define | IS_CAN_LAST_ERROR_CODE_OK(CODE) (((CODE) & 0x8F) == 0x00) |
Macro used by the assert function in order to check the Last Error Code. | |
#define | IS_CAN_MASTERCTRL_OK(MODE) |
Macro used by the assert function in order to check CAN Time Triggered Communication mode. | |
#define | IS_CAN_MODE_OK(MODE) |
Macro used by the assert function in order to check CAN mode options . | |
#define | IS_CAN_OPERATINGMODE_OK(MODE) |
Macro used by the assert function in order to check CAN operating mode. | |
#define | IS_CAN_PRESCALER_OK(PRESCALER) (((PRESCALER) >= 1) && ((PRESCALER) <= 64)) |
Macro used by the assert function in order to check CAN clock prescaler. | |
#define | IS_CAN_RTR_OK(RTR) (((RTR) == CAN_RTR_Data) || ((RTR) == CAN_RTR_Remote)) |
Macro used by the assert function in order to check CAN transmission Frame Type. | |
#define | IS_CAN_ST7_COMPATIBILITY_OK(STATE) (((STATE) == CAN_ST7Compatibility_Enable) || ((STATE) == CAN_ST7Compatibility_Disable)) |
Macro used by the assert function in order to check the CAN ST7 Compatibility parameters. | |
#define | IS_CAN_STDID_OK(STDID) ((STDID) <= ((uint16_t)CAN_STDID_SIZE)) |
Macro used by the assert function in order to check the Standard ID to be sent. | |
#define | IS_CAN_SYNJUMPWIDTH_OK(SJW) |
Macro used by the assert function in order to check the CAN synchronisation jump width (SJW). | |
#define | IS_CAN_TRANSMITMAILBOX_OK(TRANSMITMAILBOX) |
Macro used by the assert function in order to check CAN Tx mailboxes. | |
Enumerations | |
enum | CAN_BitSeg1_TypeDef { CAN_BitSeg1_1TimeQuantum = ((uint8_t)0x00), CAN_BitSeg1_2TimeQuantum = ((uint8_t)0x01), CAN_BitSeg1_3TimeQuantum = ((uint8_t)0x02), CAN_BitSeg1_4TimeQuantum = ((uint8_t)0x03), CAN_BitSeg1_5TimeQuantum = ((uint8_t)0x04), CAN_BitSeg1_6TimeQuantum = ((uint8_t)0x05), CAN_BitSeg1_7TimeQuantum = ((uint8_t)0x06), CAN_BitSeg1_8TimeQuantum = ((uint8_t)0x07), CAN_BitSeg1_9TimeQuantum = ((uint8_t)0x08), CAN_BitSeg1_10TimeQuantum = ((uint8_t)0x09), CAN_BitSeg1_11TimeQuantum = ((uint8_t)0x0A), CAN_BitSeg1_12TimeQuantum = ((uint8_t)0x0B), CAN_BitSeg1_13TimeQuantum = ((uint8_t)0x0C), CAN_BitSeg1_14TimeQuantum = ((uint8_t)0x0D), CAN_BitSeg1_15TimeQuantum = ((uint8_t)0x0E), CAN_BitSeg1_16TimeQuantum = ((uint8_t)0x0F) } |
time quantum in bit segment 1 More... | |
enum | CAN_BitSeg2_TypeDef { CAN_BitSeg2_1TimeQuantum = ((uint8_t)0x00), CAN_BitSeg2_2TimeQuantum = ((uint8_t)0x10), CAN_BitSeg2_3TimeQuantum = ((uint8_t)0x20), CAN_BitSeg2_4TimeQuantum = ((uint8_t)0x30), CAN_BitSeg2_5TimeQuantum = ((uint8_t)0x40), CAN_BitSeg2_6TimeQuantum = ((uint8_t)0x50), CAN_BitSeg2_7TimeQuantum = ((uint8_t)0x60), CAN_BitSeg2_8TimeQuantum = ((uint8_t)0x70) } |
time quantum in bit segment 2 More... | |
enum | CAN_ErrorCode_TypeDef { CAN_ErrorCode_NoErr = ((uint8_t)0x00), CAN_ErrorCode_StuffErr = ((uint8_t)0x10), CAN_ErrorCode_FormErr = ((uint8_t)0x20), CAN_ErrorCode_ACKErr = ((uint8_t)0x30), CAN_ErrorCode_BitRecessiveErr = ((uint8_t)0x40), CAN_ErrorCode_BitDominantErr = ((uint8_t)0x50), CAN_ErrorCode_CRCErr = ((uint8_t)0x60), CAN_ErrorCode_SoftwareSetErr = ((uint8_t)0x70) } |
CAN Error Code description. More... | |
enum | CAN_FilterMode_TypeDef { CAN_FilterMode_IdMask = ((uint8_t)0x00), CAN_FilterMode_IdMask_IdList = ((uint8_t)0x10), CAN_FilterMode_IdList_IdMask = ((uint8_t)0x11), CAN_FilterMode_IdList = ((uint8_t)0x01) } |
CAN filter mode. More... | |
enum | CAN_FilterNumber_TypeDef { CAN_FilterNumber_0 = ((uint8_t)0x00), CAN_FilterNumber_1 = ((uint8_t)0x01), CAN_FilterNumber_2 = ((uint8_t)0x02), CAN_FilterNumber_3 = ((uint8_t)0x03), CAN_FilterNumber_4 = ((uint8_t)0x04), CAN_FilterNumber_5 = ((uint8_t)0x05) } |
CAN filter number. More... | |
enum | CAN_FilterScale_TypeDef { CAN_FilterScale_8Bit = ((uint8_t)0x00), CAN_FilterScale_16_8Bit = ((uint8_t)0x02), CAN_FilterScale_16Bit = ((uint8_t)0x04), CAN_FilterScale_32Bit = ((uint8_t)0x06) } |
CAN filter scale. More... | |
enum | CAN_FLAG_TypeDef { CAN_FLAG_RQCP0 = ((uint16_t)0x3401), CAN_FLAG_RQCP1 = ((uint16_t)0x3402), CAN_FLAG_RQCP2 = ((uint16_t)0x3404), CAN_FLAG_FMP = ((uint16_t)0x1203), CAN_FLAG_FF = ((uint16_t)0x3208), CAN_FLAG_FOV = ((uint16_t)0x3210), CAN_FLAG_WKU = ((uint16_t)0x3108), CAN_FLAG_EWG = ((uint16_t)0x1001), CAN_FLAG_EPV = ((uint16_t)0x1002), CAN_FLAG_BOF = ((uint16_t)0x1004), CAN_FLAG_LEC = ((uint16_t)0x3070) } |
CAN flags. More... | |
enum | CAN_Id_TypeDef { CAN_Id_Standard = ((uint8_t)0x00), CAN_Id_Extended = ((uint8_t)0x40) } |
CAN identifier type. More... | |
enum | CAN_InitStatus_TypeDef { CAN_InitStatus_Failed = 0, CAN_InitStatus_Success = ! CAN_InitStatus_Failed } |
CAN sleep constants. More... | |
enum | CAN_IT_TypeDef { CAN_IT_TME = ((uint16_t)0x0001), CAN_IT_FMP = ((uint16_t)0x0002), CAN_IT_FF = ((uint16_t)0x0004), CAN_IT_FOV = ((uint16_t)0x0008), CAN_IT_WKU = ((uint16_t)0x0080), CAN_IT_ERR = ((uint16_t)0x4000), CAN_IT_EWG = ((uint16_t)0x0100), CAN_IT_EPV = ((uint16_t)0x0200), CAN_IT_BOF = ((uint16_t)0x0400), CAN_IT_LEC = ((uint16_t)0x0800) } |
CAN interrupts. More... | |
enum | CAN_MasterCtrl_TypeDef { CAN_MasterCtrl_AllDisabled = ((uint8_t)0x00), CAN_MasterCtrl_AllEnabled = ((uint8_t)0xFC), CAN_MasterCtrl_TimeTriggerCOMMode = ((uint8_t)0x80), CAN_MasterCtrl_AutoBusOffManagement = ((uint8_t)0x40), CAN_MasterCtrl_AutoWakeUpMode = ((uint8_t)0x20), CAN_MasterCtrl_NoAutoReTx = ((uint8_t)0x10), CAN_MasterCtrl_RxFifoLockedMode = ((uint8_t)0x08), CAN_MasterCtrl_TxFifoPriority = ((uint8_t)0x04) } |
CAN Time Triggered Communication mode. More... | |
enum | CAN_Mode_TypeDef { CAN_Mode_Normal = ((uint8_t)0x00), CAN_Mode_LoopBack = ((uint8_t)0x01), CAN_Mode_Silent = ((uint8_t)0x02), CAN_Mode_Silent_LoopBack = ((uint8_t)0x03) } |
CAN mode options. More... | |
enum | CAN_ModeStatus_TypeDef { CAN_ModeStatus_Failed = ((uint8_t)0x00), CAN_ModeStatus_Success = ! CAN_ModeStatus_Failed } |
CAN operating mode status. More... | |
enum | CAN_NbrPendingMessage_TypeDef { CAN_NbrPendingMessage_0 = ((uint8_t)0x00), CAN_NbrPendingMessage_1 = ((uint8_t)0x01), CAN_NbrPendingMessage_2 = ((uint8_t)0x02), CAN_NbrPendingMessage_3 = ((uint8_t)0x03) } |
CAN Pending Messages number. More... | |
enum | CAN_OperatingMode_TypeDef { CAN_OperatingMode_Initialization = ((uint8_t)0x00), CAN_OperatingMode_Normal = ((uint8_t)0x01), CAN_OperatingMode_Sleep = ((uint8_t)0x02) } |
CAN operating mode. More... | |
enum | CAN_Page_TypeDef { CAN_Page_TxMailBox0 = ((uint8_t) 0), CAN_Page_TxMailBox1 = ((uint8_t) 1), CAN_Page_TxMailBox2 = ((uint8_t) 5), CAN_Page_Filter01 = ((uint8_t) 2), CAN_Page_Filter23 = ((uint8_t) 3), CAN_Page_Filter45 = ((uint8_t) 4), CAN_Page_Config = ((uint8_t) 6), CAN_Page_RxFifo = ((uint8_t) 7) } |
CAN Page Mapping. More... | |
enum | CAN_RTR_TypeDef { CAN_RTR_Data = ((uint8_t)0x00), CAN_RTR_Remote = ((uint8_t)0x20) } |
CAN remote transmission request. More... | |
enum | CAN_Sleep_TypeDef { CAN_Sleep_Failed = ((uint8_t)0x00), CAN_Sleep_Ok = ((uint8_t)0x01) } |
CAN sleep Status. More... | |
enum | CAN_ST7Compatibility_TypeDef { CAN_ST7Compatibility_Enable = ((uint8_t)0x00), CAN_ST7Compatibility_Disable = ((uint8_t)0x10) } |
CAN ST7 Compatibility. More... | |
enum | CAN_SynJumpWidth_TypeDef { CAN_SynJumpWidth_1TimeQuantum = ((uint8_t)0x00), CAN_SynJumpWidth_2TimeQuantum = ((uint8_t)0x40), CAN_SynJumpWidth_3TimeQuantum = ((uint8_t)0x80), CAN_SynJumpWidth_4TimeQuantum = ((uint8_t)0xC0) } |
CAN synchronisation jump width (SJW) More... | |
enum | CAN_TransmitMailBox_TypeDef { CAN_TransmitMailBox_0 = ((uint8_t) 0x00), CAN_TransmitMailBox_1 = ((uint8_t) 0x01), CAN_TransmitMailBox_2 = ((uint8_t) 0x05) } |
CAN Tx mailboxes. More... | |
enum | CAN_TxStatus_TypeDef { CAN_TxStatus_Failed = ((uint8_t)0xF0), CAN_TxStatus_Ok = ((uint8_t)0xF1), CAN_TxStatus_Pending = ((uint8_t)0xF2), CAN_TxStatus_NoMailBox = ((uint8_t)0xF4), CAN_TxStatus_MailBoxEmpty = ((uint8_t)0xF5), CAN_TxStatus_MailBox0Ok = ((uint8_t)0x00), CAN_TxStatus_MailBox1Ok = ((uint8_t)0x01), CAN_TxStatus_MailBox2Ok = ((uint8_t)0x05) } |
CAN transmit Status. More... | |
enum | CAN_WakeUp_TypeDef { CAN_WakeUp_Failed = ((uint8_t)0x00), CAN_WakeUp_Ok = ((uint8_t)0x01) } |
CAN wake up status. More... | |
Functions | |
void | CAN_CancelTransmit (CAN_TransmitMailBox_TypeDef CAN_TransmitMailbox) |
Cancels a transmit request. | |
void | CAN_ClearFlag (CAN_FLAG_TypeDef CAN_Flag) |
Clears the CAN's pending flags. | |
void | CAN_ClearITPendingBit (CAN_IT_TypeDef CAN_IT) |
Clears the CAN�s interrupt pending bits. | |
void | CAN_DeInit (void) |
Deinitializes the CAN peripheral registers to their default reset values. | |
void | CAN_FIFORelease (void) |
Releases the CAN FIFO. | |
void | CAN_FilterInit (CAN_FilterNumber_TypeDef CAN_FilterNumber, FunctionalState CAN_FilterActivation, CAN_FilterMode_TypeDef CAN_FilterMode, CAN_FilterScale_TypeDef CAN_FilterScale, uint8_t CAN_FilterID1, uint8_t CAN_FilterID2, uint8_t CAN_FilterID3, uint8_t CAN_FilterID4, uint8_t CAN_FilterIDMask1, uint8_t CAN_FilterIDMask2, uint8_t CAN_FilterIDMask3, uint8_t CAN_FilterIDMask4) |
Initializes the CAN peripheral Filter according to the specified parameters. | |
FlagStatus | CAN_GetFlagStatus (CAN_FLAG_TypeDef CAN_Flag) |
Checks whether the specified CAN flag is set or not. | |
ITStatus | CAN_GetITStatus (CAN_IT_TypeDef CAN_IT) |
Checks whether the specified CAN interrupt has occurred or not. | |
CAN_ErrorCode_TypeDef | CAN_GetLastErrorCode (void) |
Gets the Last Error Code. | |
uint16_t | CAN_GetMessageTimeStamp (void) |
Returns the Received time stamp. | |
uint8_t | CAN_GetReceivedData (uint8_t CAN_DataIndex) |
Gets the CAN Data of the received message. | |
uint8_t | CAN_GetReceivedDLC (void) |
Gets the CAN DLC of the received message. | |
uint8_t | CAN_GetReceivedFMI (void) |
Gets the CAN FMI of the received message. | |
uint32_t | CAN_GetReceivedId (void) |
Gets the CAN Id of the received message. | |
CAN_Id_TypeDef | CAN_GetReceivedIDE (void) |
Gets the CAN IDE of the received message. | |
CAN_RTR_TypeDef | CAN_GetReceivedRTR (void) |
Gets the CAN RTR of the received message. | |
CAN_Page_TypeDef | CAN_GetSelectedPage (void) |
Gets the selected registers page. | |
CAN_InitStatus_TypeDef | CAN_Init (CAN_MasterCtrl_TypeDef CAN_MasterCtrl, CAN_Mode_TypeDef CAN_Mode, CAN_SynJumpWidth_TypeDef CAN_SynJumpWidth, CAN_BitSeg1_TypeDef CAN_BitSeg1, CAN_BitSeg2_TypeDef CAN_BitSeg2, uint8_t CAN_Prescaler) |
Initializes the CAN peripheral according to the specified parameters. | |
void | CAN_ITConfig (CAN_IT_TypeDef CAN_IT, FunctionalState NewState) |
Enables or disables the specified CAN interrupts. | |
CAN_NbrPendingMessage_TypeDef | CAN_MessagePending (void) |
Returns the number of pending messages. | |
CAN_ModeStatus_TypeDef | CAN_OperatingModeRequest (CAN_OperatingMode_TypeDef CAN_OperatingMode) |
Select the CAN Operation mode. | |
void | CAN_Receive (void) |
Receives a message which contains CAN Id, IDE, RTR DLC, data and FMI number. | |
void | CAN_SelectPage (CAN_Page_TypeDef CAN_Page) |
Sets the registers page to be selected. | |
CAN_Sleep_TypeDef | CAN_Sleep (void) |
Enters the Sleep low power mode. | |
void | CAN_ST7CompatibilityCmd (CAN_ST7Compatibility_TypeDef CAN_ST7Compatibility) |
Enables or Disables the ST7 CAN Compatibility. | |
CAN_TxStatus_TypeDef | CAN_Transmit (uint32_t CAN_Id, CAN_Id_TypeDef CAN_IDE, CAN_RTR_TypeDef CAN_RTR, uint8_t CAN_DLC, uint8_t *CAN_Data) |
Initiates the transmission of a message. | |
CAN_TxStatus_TypeDef | CAN_TransmitStatus (CAN_TransmitMailBox_TypeDef CAN_TransmitMailbox) |
Checks the transmission of a message. | |
void | CAN_TTComModeCmd (FunctionalState NewState) |
Enables or disables the CAN Time TriggerOperation communication mode. | |
CAN_WakeUp_TypeDef | CAN_WakeUp (void) |
Wakes the CAN up. |
Detailed Description
This file contains all the functions for the CAN peripheral.
- Attention:
© COPYRIGHT 2014 STMicroelectronics
Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:
http://www.st.com/software_license_agreement_liberty_v2
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file stm8s_can.h.
Define Documentation
#define CAN_DLC_MAX ((uint8_t)0x08) |
Definition at line 38 of file stm8s_can.h.
#define CAN_EXTID_SIZE ((uint32_t)0x1FFFFFFF) |
Definition at line 37 of file stm8s_can.h.
Referenced by CAN_Receive(), and CAN_Transmit().
#define CAN_STDID_SIZE ((uint16_t)0x07FF) |
Definition at line 36 of file stm8s_can.h.
Referenced by CAN_Receive(), and CAN_Transmit().