mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_can.h@76:aeb1df146756, 2014-01-27 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Jan 27 14:30:07 2014 +0000
- Revision:
- 76:aeb1df146756
- Child:
- 106:ced8cbb51063
Synchronized with git revision a31ec9c5f7bcb5c8a1b2eced103f6a1dfa921abd
Full URL: https://github.com/mbedmicro/mbed/commit/a31ec9c5f7bcb5c8a1b2eced103f6a1dfa921abd/
Add NUCLEO_L152RE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 76:aeb1df146756 | 1 | /** |
mbed_official | 76:aeb1df146756 | 2 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 3 | * @file stm32f0xx_can.h |
mbed_official | 76:aeb1df146756 | 4 | * @author MCD Application Team |
mbed_official | 76:aeb1df146756 | 5 | * @version V1.3.0 |
mbed_official | 76:aeb1df146756 | 6 | * @date 16-January-2014 |
mbed_official | 76:aeb1df146756 | 7 | * @brief This file contains all the functions prototypes for the CAN firmware |
mbed_official | 76:aeb1df146756 | 8 | * library, applicable only for STM32F072 devices. |
mbed_official | 76:aeb1df146756 | 9 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 10 | * @attention |
mbed_official | 76:aeb1df146756 | 11 | * |
mbed_official | 76:aeb1df146756 | 12 | * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> |
mbed_official | 76:aeb1df146756 | 13 | * |
mbed_official | 76:aeb1df146756 | 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
mbed_official | 76:aeb1df146756 | 15 | * You may not use this file except in compliance with the License. |
mbed_official | 76:aeb1df146756 | 16 | * You may obtain a copy of the License at: |
mbed_official | 76:aeb1df146756 | 17 | * |
mbed_official | 76:aeb1df146756 | 18 | * http://www.st.com/software_license_agreement_liberty_v2 |
mbed_official | 76:aeb1df146756 | 19 | * |
mbed_official | 76:aeb1df146756 | 20 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 76:aeb1df146756 | 21 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 76:aeb1df146756 | 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 76:aeb1df146756 | 23 | * See the License for the specific language governing permissions and |
mbed_official | 76:aeb1df146756 | 24 | * limitations under the License. |
mbed_official | 76:aeb1df146756 | 25 | * |
mbed_official | 76:aeb1df146756 | 26 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 27 | */ |
mbed_official | 76:aeb1df146756 | 28 | |
mbed_official | 76:aeb1df146756 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 30 | #ifndef __STM32F0xx_CAN_H |
mbed_official | 76:aeb1df146756 | 31 | #define __STM32F0xx_CAN_H |
mbed_official | 76:aeb1df146756 | 32 | |
mbed_official | 76:aeb1df146756 | 33 | #ifdef __cplusplus |
mbed_official | 76:aeb1df146756 | 34 | extern "C" { |
mbed_official | 76:aeb1df146756 | 35 | #endif |
mbed_official | 76:aeb1df146756 | 36 | |
mbed_official | 76:aeb1df146756 | 37 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 38 | #include "stm32f0xx.h" |
mbed_official | 76:aeb1df146756 | 39 | |
mbed_official | 76:aeb1df146756 | 40 | /** @addtogroup STM32F0xx_StdPeriph_Driver |
mbed_official | 76:aeb1df146756 | 41 | * @{ |
mbed_official | 76:aeb1df146756 | 42 | */ |
mbed_official | 76:aeb1df146756 | 43 | |
mbed_official | 76:aeb1df146756 | 44 | /** @addtogroup CAN |
mbed_official | 76:aeb1df146756 | 45 | * @{ |
mbed_official | 76:aeb1df146756 | 46 | */ |
mbed_official | 76:aeb1df146756 | 47 | |
mbed_official | 76:aeb1df146756 | 48 | /* Exported types ------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 49 | |
mbed_official | 76:aeb1df146756 | 50 | #define IS_CAN_ALL_PERIPH(PERIPH) (((PERIPH) == CAN)) |
mbed_official | 76:aeb1df146756 | 51 | |
mbed_official | 76:aeb1df146756 | 52 | /** |
mbed_official | 76:aeb1df146756 | 53 | * @brief CAN init structure definition |
mbed_official | 76:aeb1df146756 | 54 | */ |
mbed_official | 76:aeb1df146756 | 55 | typedef struct |
mbed_official | 76:aeb1df146756 | 56 | { |
mbed_official | 76:aeb1df146756 | 57 | uint16_t CAN_Prescaler; /*!< Specifies the length of a time quantum. |
mbed_official | 76:aeb1df146756 | 58 | It ranges from 1 to 1024. */ |
mbed_official | 76:aeb1df146756 | 59 | |
mbed_official | 76:aeb1df146756 | 60 | uint8_t CAN_Mode; /*!< Specifies the CAN operating mode. |
mbed_official | 76:aeb1df146756 | 61 | This parameter can be a value of @ref CAN_operating_mode */ |
mbed_official | 76:aeb1df146756 | 62 | |
mbed_official | 76:aeb1df146756 | 63 | uint8_t CAN_SJW; /*!< Specifies the maximum number of time quanta |
mbed_official | 76:aeb1df146756 | 64 | the CAN hardware is allowed to lengthen or |
mbed_official | 76:aeb1df146756 | 65 | shorten a bit to perform resynchronization. |
mbed_official | 76:aeb1df146756 | 66 | This parameter can be a value of @ref CAN_synchronisation_jump_width */ |
mbed_official | 76:aeb1df146756 | 67 | |
mbed_official | 76:aeb1df146756 | 68 | uint8_t CAN_BS1; /*!< Specifies the number of time quanta in Bit |
mbed_official | 76:aeb1df146756 | 69 | Segment 1. This parameter can be a value of |
mbed_official | 76:aeb1df146756 | 70 | @ref CAN_time_quantum_in_bit_segment_1 */ |
mbed_official | 76:aeb1df146756 | 71 | |
mbed_official | 76:aeb1df146756 | 72 | uint8_t CAN_BS2; /*!< Specifies the number of time quanta in Bit Segment 2. |
mbed_official | 76:aeb1df146756 | 73 | This parameter can be a value of @ref CAN_time_quantum_in_bit_segment_2 */ |
mbed_official | 76:aeb1df146756 | 74 | |
mbed_official | 76:aeb1df146756 | 75 | FunctionalState CAN_TTCM; /*!< Enable or disable the time triggered communication mode. |
mbed_official | 76:aeb1df146756 | 76 | This parameter can be set either to ENABLE or DISABLE. */ |
mbed_official | 76:aeb1df146756 | 77 | |
mbed_official | 76:aeb1df146756 | 78 | FunctionalState CAN_ABOM; /*!< Enable or disable the automatic bus-off management. |
mbed_official | 76:aeb1df146756 | 79 | This parameter can be set either to ENABLE or DISABLE. */ |
mbed_official | 76:aeb1df146756 | 80 | |
mbed_official | 76:aeb1df146756 | 81 | FunctionalState CAN_AWUM; /*!< Enable or disable the automatic wake-up mode. |
mbed_official | 76:aeb1df146756 | 82 | This parameter can be set either to ENABLE or DISABLE. */ |
mbed_official | 76:aeb1df146756 | 83 | |
mbed_official | 76:aeb1df146756 | 84 | FunctionalState CAN_NART; /*!< Enable or disable the non-automatic retransmission mode. |
mbed_official | 76:aeb1df146756 | 85 | This parameter can be set either to ENABLE or DISABLE. */ |
mbed_official | 76:aeb1df146756 | 86 | |
mbed_official | 76:aeb1df146756 | 87 | FunctionalState CAN_RFLM; /*!< Enable or disable the Receive FIFO Locked mode. |
mbed_official | 76:aeb1df146756 | 88 | This parameter can be set either to ENABLE or DISABLE. */ |
mbed_official | 76:aeb1df146756 | 89 | |
mbed_official | 76:aeb1df146756 | 90 | FunctionalState CAN_TXFP; /*!< Enable or disable the transmit FIFO priority. |
mbed_official | 76:aeb1df146756 | 91 | This parameter can be set either to ENABLE or DISABLE. */ |
mbed_official | 76:aeb1df146756 | 92 | } CAN_InitTypeDef; |
mbed_official | 76:aeb1df146756 | 93 | |
mbed_official | 76:aeb1df146756 | 94 | /** |
mbed_official | 76:aeb1df146756 | 95 | * @brief CAN filter init structure definition |
mbed_official | 76:aeb1df146756 | 96 | */ |
mbed_official | 76:aeb1df146756 | 97 | typedef struct |
mbed_official | 76:aeb1df146756 | 98 | { |
mbed_official | 76:aeb1df146756 | 99 | uint16_t CAN_FilterIdHigh; /*!< Specifies the filter identification number (MSBs for a 32-bit |
mbed_official | 76:aeb1df146756 | 100 | configuration, first one for a 16-bit configuration). |
mbed_official | 76:aeb1df146756 | 101 | This parameter can be a value between 0x0000 and 0xFFFF */ |
mbed_official | 76:aeb1df146756 | 102 | |
mbed_official | 76:aeb1df146756 | 103 | uint16_t CAN_FilterIdLow; /*!< Specifies the filter identification number (LSBs for a 32-bit |
mbed_official | 76:aeb1df146756 | 104 | configuration, second one for a 16-bit configuration). |
mbed_official | 76:aeb1df146756 | 105 | This parameter can be a value between 0x0000 and 0xFFFF */ |
mbed_official | 76:aeb1df146756 | 106 | |
mbed_official | 76:aeb1df146756 | 107 | uint16_t CAN_FilterMaskIdHigh; /*!< Specifies the filter mask number or identification number, |
mbed_official | 76:aeb1df146756 | 108 | according to the mode (MSBs for a 32-bit configuration, |
mbed_official | 76:aeb1df146756 | 109 | first one for a 16-bit configuration). |
mbed_official | 76:aeb1df146756 | 110 | This parameter can be a value between 0x0000 and 0xFFFF */ |
mbed_official | 76:aeb1df146756 | 111 | |
mbed_official | 76:aeb1df146756 | 112 | uint16_t CAN_FilterMaskIdLow; /*!< Specifies the filter mask number or identification number, |
mbed_official | 76:aeb1df146756 | 113 | according to the mode (LSBs for a 32-bit configuration, |
mbed_official | 76:aeb1df146756 | 114 | second one for a 16-bit configuration). |
mbed_official | 76:aeb1df146756 | 115 | This parameter can be a value between 0x0000 and 0xFFFF */ |
mbed_official | 76:aeb1df146756 | 116 | |
mbed_official | 76:aeb1df146756 | 117 | uint16_t CAN_FilterFIFOAssignment; /*!< Specifies the FIFO (0 or 1) which will be assigned to the filter. |
mbed_official | 76:aeb1df146756 | 118 | This parameter can be a value of @ref CAN_filter_FIFO */ |
mbed_official | 76:aeb1df146756 | 119 | |
mbed_official | 76:aeb1df146756 | 120 | uint8_t CAN_FilterNumber; /*!< Specifies the filter which will be initialized. It ranges from 0 to 13. */ |
mbed_official | 76:aeb1df146756 | 121 | |
mbed_official | 76:aeb1df146756 | 122 | uint8_t CAN_FilterMode; /*!< Specifies the filter mode to be initialized. |
mbed_official | 76:aeb1df146756 | 123 | This parameter can be a value of @ref CAN_filter_mode */ |
mbed_official | 76:aeb1df146756 | 124 | |
mbed_official | 76:aeb1df146756 | 125 | uint8_t CAN_FilterScale; /*!< Specifies the filter scale. |
mbed_official | 76:aeb1df146756 | 126 | This parameter can be a value of @ref CAN_filter_scale */ |
mbed_official | 76:aeb1df146756 | 127 | |
mbed_official | 76:aeb1df146756 | 128 | FunctionalState CAN_FilterActivation; /*!< Enable or disable the filter. |
mbed_official | 76:aeb1df146756 | 129 | This parameter can be set either to ENABLE or DISABLE. */ |
mbed_official | 76:aeb1df146756 | 130 | } CAN_FilterInitTypeDef; |
mbed_official | 76:aeb1df146756 | 131 | |
mbed_official | 76:aeb1df146756 | 132 | /** |
mbed_official | 76:aeb1df146756 | 133 | * @brief CAN Tx message structure definition |
mbed_official | 76:aeb1df146756 | 134 | */ |
mbed_official | 76:aeb1df146756 | 135 | typedef struct |
mbed_official | 76:aeb1df146756 | 136 | { |
mbed_official | 76:aeb1df146756 | 137 | uint32_t StdId; /*!< Specifies the standard identifier. |
mbed_official | 76:aeb1df146756 | 138 | This parameter can be a value between 0 to 0x7FF. */ |
mbed_official | 76:aeb1df146756 | 139 | |
mbed_official | 76:aeb1df146756 | 140 | uint32_t ExtId; /*!< Specifies the extended identifier. |
mbed_official | 76:aeb1df146756 | 141 | This parameter can be a value between 0 to 0x1FFFFFFF. */ |
mbed_official | 76:aeb1df146756 | 142 | |
mbed_official | 76:aeb1df146756 | 143 | uint8_t IDE; /*!< Specifies the type of identifier for the message that |
mbed_official | 76:aeb1df146756 | 144 | will be transmitted. This parameter can be a value |
mbed_official | 76:aeb1df146756 | 145 | of @ref CAN_identifier_type */ |
mbed_official | 76:aeb1df146756 | 146 | |
mbed_official | 76:aeb1df146756 | 147 | uint8_t RTR; /*!< Specifies the type of frame for the message that will |
mbed_official | 76:aeb1df146756 | 148 | be transmitted. This parameter can be a value of |
mbed_official | 76:aeb1df146756 | 149 | @ref CAN_remote_transmission_request */ |
mbed_official | 76:aeb1df146756 | 150 | |
mbed_official | 76:aeb1df146756 | 151 | uint8_t DLC; /*!< Specifies the length of the frame that will be |
mbed_official | 76:aeb1df146756 | 152 | transmitted. This parameter can be a value between |
mbed_official | 76:aeb1df146756 | 153 | 0 to 8 */ |
mbed_official | 76:aeb1df146756 | 154 | |
mbed_official | 76:aeb1df146756 | 155 | uint8_t Data[8]; /*!< Contains the data to be transmitted. It ranges from 0 |
mbed_official | 76:aeb1df146756 | 156 | to 0xFF. */ |
mbed_official | 76:aeb1df146756 | 157 | } CanTxMsg; |
mbed_official | 76:aeb1df146756 | 158 | |
mbed_official | 76:aeb1df146756 | 159 | /** |
mbed_official | 76:aeb1df146756 | 160 | * @brief CAN Rx message structure definition |
mbed_official | 76:aeb1df146756 | 161 | */ |
mbed_official | 76:aeb1df146756 | 162 | typedef struct |
mbed_official | 76:aeb1df146756 | 163 | { |
mbed_official | 76:aeb1df146756 | 164 | uint32_t StdId; /*!< Specifies the standard identifier. |
mbed_official | 76:aeb1df146756 | 165 | This parameter can be a value between 0 to 0x7FF. */ |
mbed_official | 76:aeb1df146756 | 166 | |
mbed_official | 76:aeb1df146756 | 167 | uint32_t ExtId; /*!< Specifies the extended identifier. |
mbed_official | 76:aeb1df146756 | 168 | This parameter can be a value between 0 to 0x1FFFFFFF. */ |
mbed_official | 76:aeb1df146756 | 169 | |
mbed_official | 76:aeb1df146756 | 170 | uint8_t IDE; /*!< Specifies the type of identifier for the message that |
mbed_official | 76:aeb1df146756 | 171 | will be received. This parameter can be a value of |
mbed_official | 76:aeb1df146756 | 172 | @ref CAN_identifier_type */ |
mbed_official | 76:aeb1df146756 | 173 | |
mbed_official | 76:aeb1df146756 | 174 | uint8_t RTR; /*!< Specifies the type of frame for the received message. |
mbed_official | 76:aeb1df146756 | 175 | This parameter can be a value of |
mbed_official | 76:aeb1df146756 | 176 | @ref CAN_remote_transmission_request */ |
mbed_official | 76:aeb1df146756 | 177 | |
mbed_official | 76:aeb1df146756 | 178 | uint8_t DLC; /*!< Specifies the length of the frame that will be received. |
mbed_official | 76:aeb1df146756 | 179 | This parameter can be a value between 0 to 8 */ |
mbed_official | 76:aeb1df146756 | 180 | |
mbed_official | 76:aeb1df146756 | 181 | uint8_t Data[8]; /*!< Contains the data to be received. It ranges from 0 to |
mbed_official | 76:aeb1df146756 | 182 | 0xFF. */ |
mbed_official | 76:aeb1df146756 | 183 | |
mbed_official | 76:aeb1df146756 | 184 | uint8_t FMI; /*!< Specifies the index of the filter the message stored in |
mbed_official | 76:aeb1df146756 | 185 | the mailbox passes through. This parameter can be a |
mbed_official | 76:aeb1df146756 | 186 | value between 0 to 0xFF */ |
mbed_official | 76:aeb1df146756 | 187 | } CanRxMsg; |
mbed_official | 76:aeb1df146756 | 188 | |
mbed_official | 76:aeb1df146756 | 189 | /* Exported constants --------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 190 | |
mbed_official | 76:aeb1df146756 | 191 | /** @defgroup CAN_Exported_Constants |
mbed_official | 76:aeb1df146756 | 192 | * @{ |
mbed_official | 76:aeb1df146756 | 193 | */ |
mbed_official | 76:aeb1df146756 | 194 | |
mbed_official | 76:aeb1df146756 | 195 | /** @defgroup CAN_InitStatus |
mbed_official | 76:aeb1df146756 | 196 | * @{ |
mbed_official | 76:aeb1df146756 | 197 | */ |
mbed_official | 76:aeb1df146756 | 198 | |
mbed_official | 76:aeb1df146756 | 199 | #define CAN_InitStatus_Failed ((uint8_t)0x00) /*!< CAN initialization failed */ |
mbed_official | 76:aeb1df146756 | 200 | #define CAN_InitStatus_Success ((uint8_t)0x01) /*!< CAN initialization OK */ |
mbed_official | 76:aeb1df146756 | 201 | |
mbed_official | 76:aeb1df146756 | 202 | |
mbed_official | 76:aeb1df146756 | 203 | /* Legacy defines */ |
mbed_official | 76:aeb1df146756 | 204 | #define CANINITFAILED CAN_InitStatus_Failed |
mbed_official | 76:aeb1df146756 | 205 | #define CANINITOK CAN_InitStatus_Success |
mbed_official | 76:aeb1df146756 | 206 | /** |
mbed_official | 76:aeb1df146756 | 207 | * @} |
mbed_official | 76:aeb1df146756 | 208 | */ |
mbed_official | 76:aeb1df146756 | 209 | |
mbed_official | 76:aeb1df146756 | 210 | /** @defgroup CAN_operating_mode |
mbed_official | 76:aeb1df146756 | 211 | * @{ |
mbed_official | 76:aeb1df146756 | 212 | */ |
mbed_official | 76:aeb1df146756 | 213 | |
mbed_official | 76:aeb1df146756 | 214 | #define CAN_Mode_Normal ((uint8_t)0x00) /*!< normal mode */ |
mbed_official | 76:aeb1df146756 | 215 | #define CAN_Mode_LoopBack ((uint8_t)0x01) /*!< loopback mode */ |
mbed_official | 76:aeb1df146756 | 216 | #define CAN_Mode_Silent ((uint8_t)0x02) /*!< silent mode */ |
mbed_official | 76:aeb1df146756 | 217 | #define CAN_Mode_Silent_LoopBack ((uint8_t)0x03) /*!< loopback combined with silent mode */ |
mbed_official | 76:aeb1df146756 | 218 | |
mbed_official | 76:aeb1df146756 | 219 | #define IS_CAN_MODE(MODE) (((MODE) == CAN_Mode_Normal) || \ |
mbed_official | 76:aeb1df146756 | 220 | ((MODE) == CAN_Mode_LoopBack)|| \ |
mbed_official | 76:aeb1df146756 | 221 | ((MODE) == CAN_Mode_Silent) || \ |
mbed_official | 76:aeb1df146756 | 222 | ((MODE) == CAN_Mode_Silent_LoopBack)) |
mbed_official | 76:aeb1df146756 | 223 | /** |
mbed_official | 76:aeb1df146756 | 224 | * @} |
mbed_official | 76:aeb1df146756 | 225 | */ |
mbed_official | 76:aeb1df146756 | 226 | |
mbed_official | 76:aeb1df146756 | 227 | |
mbed_official | 76:aeb1df146756 | 228 | /** |
mbed_official | 76:aeb1df146756 | 229 | * @defgroup CAN_operating_mode |
mbed_official | 76:aeb1df146756 | 230 | * @{ |
mbed_official | 76:aeb1df146756 | 231 | */ |
mbed_official | 76:aeb1df146756 | 232 | #define CAN_OperatingMode_Initialization ((uint8_t)0x00) /*!< Initialization mode */ |
mbed_official | 76:aeb1df146756 | 233 | #define CAN_OperatingMode_Normal ((uint8_t)0x01) /*!< Normal mode */ |
mbed_official | 76:aeb1df146756 | 234 | #define CAN_OperatingMode_Sleep ((uint8_t)0x02) /*!< sleep mode */ |
mbed_official | 76:aeb1df146756 | 235 | |
mbed_official | 76:aeb1df146756 | 236 | |
mbed_official | 76:aeb1df146756 | 237 | #define IS_CAN_OPERATING_MODE(MODE) (((MODE) == CAN_OperatingMode_Initialization) ||\ |
mbed_official | 76:aeb1df146756 | 238 | ((MODE) == CAN_OperatingMode_Normal)|| \ |
mbed_official | 76:aeb1df146756 | 239 | ((MODE) == CAN_OperatingMode_Sleep)) |
mbed_official | 76:aeb1df146756 | 240 | /** |
mbed_official | 76:aeb1df146756 | 241 | * @} |
mbed_official | 76:aeb1df146756 | 242 | */ |
mbed_official | 76:aeb1df146756 | 243 | |
mbed_official | 76:aeb1df146756 | 244 | /** |
mbed_official | 76:aeb1df146756 | 245 | * @defgroup CAN_operating_mode_status |
mbed_official | 76:aeb1df146756 | 246 | * @{ |
mbed_official | 76:aeb1df146756 | 247 | */ |
mbed_official | 76:aeb1df146756 | 248 | |
mbed_official | 76:aeb1df146756 | 249 | #define CAN_ModeStatus_Failed ((uint8_t)0x00) /*!< CAN entering the specific mode failed */ |
mbed_official | 76:aeb1df146756 | 250 | #define CAN_ModeStatus_Success ((uint8_t)!CAN_ModeStatus_Failed) /*!< CAN entering the specific mode Succeed */ |
mbed_official | 76:aeb1df146756 | 251 | /** |
mbed_official | 76:aeb1df146756 | 252 | * @} |
mbed_official | 76:aeb1df146756 | 253 | */ |
mbed_official | 76:aeb1df146756 | 254 | |
mbed_official | 76:aeb1df146756 | 255 | /** @defgroup CAN_synchronisation_jump_width |
mbed_official | 76:aeb1df146756 | 256 | * @{ |
mbed_official | 76:aeb1df146756 | 257 | */ |
mbed_official | 76:aeb1df146756 | 258 | #define CAN_SJW_1tq ((uint8_t)0x00) /*!< 1 time quantum */ |
mbed_official | 76:aeb1df146756 | 259 | #define CAN_SJW_2tq ((uint8_t)0x01) /*!< 2 time quantum */ |
mbed_official | 76:aeb1df146756 | 260 | #define CAN_SJW_3tq ((uint8_t)0x02) /*!< 3 time quantum */ |
mbed_official | 76:aeb1df146756 | 261 | #define CAN_SJW_4tq ((uint8_t)0x03) /*!< 4 time quantum */ |
mbed_official | 76:aeb1df146756 | 262 | |
mbed_official | 76:aeb1df146756 | 263 | #define IS_CAN_SJW(SJW) (((SJW) == CAN_SJW_1tq) || ((SJW) == CAN_SJW_2tq)|| \ |
mbed_official | 76:aeb1df146756 | 264 | ((SJW) == CAN_SJW_3tq) || ((SJW) == CAN_SJW_4tq)) |
mbed_official | 76:aeb1df146756 | 265 | /** |
mbed_official | 76:aeb1df146756 | 266 | * @} |
mbed_official | 76:aeb1df146756 | 267 | */ |
mbed_official | 76:aeb1df146756 | 268 | |
mbed_official | 76:aeb1df146756 | 269 | /** @defgroup CAN_time_quantum_in_bit_segment_1 |
mbed_official | 76:aeb1df146756 | 270 | * @{ |
mbed_official | 76:aeb1df146756 | 271 | */ |
mbed_official | 76:aeb1df146756 | 272 | #define CAN_BS1_1tq ((uint8_t)0x00) /*!< 1 time quantum */ |
mbed_official | 76:aeb1df146756 | 273 | #define CAN_BS1_2tq ((uint8_t)0x01) /*!< 2 time quantum */ |
mbed_official | 76:aeb1df146756 | 274 | #define CAN_BS1_3tq ((uint8_t)0x02) /*!< 3 time quantum */ |
mbed_official | 76:aeb1df146756 | 275 | #define CAN_BS1_4tq ((uint8_t)0x03) /*!< 4 time quantum */ |
mbed_official | 76:aeb1df146756 | 276 | #define CAN_BS1_5tq ((uint8_t)0x04) /*!< 5 time quantum */ |
mbed_official | 76:aeb1df146756 | 277 | #define CAN_BS1_6tq ((uint8_t)0x05) /*!< 6 time quantum */ |
mbed_official | 76:aeb1df146756 | 278 | #define CAN_BS1_7tq ((uint8_t)0x06) /*!< 7 time quantum */ |
mbed_official | 76:aeb1df146756 | 279 | #define CAN_BS1_8tq ((uint8_t)0x07) /*!< 8 time quantum */ |
mbed_official | 76:aeb1df146756 | 280 | #define CAN_BS1_9tq ((uint8_t)0x08) /*!< 9 time quantum */ |
mbed_official | 76:aeb1df146756 | 281 | #define CAN_BS1_10tq ((uint8_t)0x09) /*!< 10 time quantum */ |
mbed_official | 76:aeb1df146756 | 282 | #define CAN_BS1_11tq ((uint8_t)0x0A) /*!< 11 time quantum */ |
mbed_official | 76:aeb1df146756 | 283 | #define CAN_BS1_12tq ((uint8_t)0x0B) /*!< 12 time quantum */ |
mbed_official | 76:aeb1df146756 | 284 | #define CAN_BS1_13tq ((uint8_t)0x0C) /*!< 13 time quantum */ |
mbed_official | 76:aeb1df146756 | 285 | #define CAN_BS1_14tq ((uint8_t)0x0D) /*!< 14 time quantum */ |
mbed_official | 76:aeb1df146756 | 286 | #define CAN_BS1_15tq ((uint8_t)0x0E) /*!< 15 time quantum */ |
mbed_official | 76:aeb1df146756 | 287 | #define CAN_BS1_16tq ((uint8_t)0x0F) /*!< 16 time quantum */ |
mbed_official | 76:aeb1df146756 | 288 | |
mbed_official | 76:aeb1df146756 | 289 | #define IS_CAN_BS1(BS1) ((BS1) <= CAN_BS1_16tq) |
mbed_official | 76:aeb1df146756 | 290 | /** |
mbed_official | 76:aeb1df146756 | 291 | * @} |
mbed_official | 76:aeb1df146756 | 292 | */ |
mbed_official | 76:aeb1df146756 | 293 | |
mbed_official | 76:aeb1df146756 | 294 | /** @defgroup CAN_time_quantum_in_bit_segment_2 |
mbed_official | 76:aeb1df146756 | 295 | * @{ |
mbed_official | 76:aeb1df146756 | 296 | */ |
mbed_official | 76:aeb1df146756 | 297 | #define CAN_BS2_1tq ((uint8_t)0x00) /*!< 1 time quantum */ |
mbed_official | 76:aeb1df146756 | 298 | #define CAN_BS2_2tq ((uint8_t)0x01) /*!< 2 time quantum */ |
mbed_official | 76:aeb1df146756 | 299 | #define CAN_BS2_3tq ((uint8_t)0x02) /*!< 3 time quantum */ |
mbed_official | 76:aeb1df146756 | 300 | #define CAN_BS2_4tq ((uint8_t)0x03) /*!< 4 time quantum */ |
mbed_official | 76:aeb1df146756 | 301 | #define CAN_BS2_5tq ((uint8_t)0x04) /*!< 5 time quantum */ |
mbed_official | 76:aeb1df146756 | 302 | #define CAN_BS2_6tq ((uint8_t)0x05) /*!< 6 time quantum */ |
mbed_official | 76:aeb1df146756 | 303 | #define CAN_BS2_7tq ((uint8_t)0x06) /*!< 7 time quantum */ |
mbed_official | 76:aeb1df146756 | 304 | #define CAN_BS2_8tq ((uint8_t)0x07) /*!< 8 time quantum */ |
mbed_official | 76:aeb1df146756 | 305 | |
mbed_official | 76:aeb1df146756 | 306 | #define IS_CAN_BS2(BS2) ((BS2) <= CAN_BS2_8tq) |
mbed_official | 76:aeb1df146756 | 307 | /** |
mbed_official | 76:aeb1df146756 | 308 | * @} |
mbed_official | 76:aeb1df146756 | 309 | */ |
mbed_official | 76:aeb1df146756 | 310 | |
mbed_official | 76:aeb1df146756 | 311 | /** @defgroup CAN_clock_prescaler |
mbed_official | 76:aeb1df146756 | 312 | * @{ |
mbed_official | 76:aeb1df146756 | 313 | */ |
mbed_official | 76:aeb1df146756 | 314 | #define IS_CAN_PRESCALER(PRESCALER) (((PRESCALER) >= 1) && ((PRESCALER) <= 1024)) |
mbed_official | 76:aeb1df146756 | 315 | /** |
mbed_official | 76:aeb1df146756 | 316 | * @} |
mbed_official | 76:aeb1df146756 | 317 | */ |
mbed_official | 76:aeb1df146756 | 318 | |
mbed_official | 76:aeb1df146756 | 319 | /** @defgroup CAN_filter_number |
mbed_official | 76:aeb1df146756 | 320 | * @{ |
mbed_official | 76:aeb1df146756 | 321 | */ |
mbed_official | 76:aeb1df146756 | 322 | #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 27) |
mbed_official | 76:aeb1df146756 | 323 | /** |
mbed_official | 76:aeb1df146756 | 324 | * @} |
mbed_official | 76:aeb1df146756 | 325 | */ |
mbed_official | 76:aeb1df146756 | 326 | |
mbed_official | 76:aeb1df146756 | 327 | /** @defgroup CAN_filter_mode |
mbed_official | 76:aeb1df146756 | 328 | * @{ |
mbed_official | 76:aeb1df146756 | 329 | */ |
mbed_official | 76:aeb1df146756 | 330 | #define CAN_FilterMode_IdMask ((uint8_t)0x00) /*!< identifier/mask mode */ |
mbed_official | 76:aeb1df146756 | 331 | #define CAN_FilterMode_IdList ((uint8_t)0x01) /*!< identifier list mode */ |
mbed_official | 76:aeb1df146756 | 332 | |
mbed_official | 76:aeb1df146756 | 333 | #define IS_CAN_FILTER_MODE(MODE) (((MODE) == CAN_FilterMode_IdMask) || \ |
mbed_official | 76:aeb1df146756 | 334 | ((MODE) == CAN_FilterMode_IdList)) |
mbed_official | 76:aeb1df146756 | 335 | /** |
mbed_official | 76:aeb1df146756 | 336 | * @} |
mbed_official | 76:aeb1df146756 | 337 | */ |
mbed_official | 76:aeb1df146756 | 338 | |
mbed_official | 76:aeb1df146756 | 339 | /** @defgroup CAN_filter_scale |
mbed_official | 76:aeb1df146756 | 340 | * @{ |
mbed_official | 76:aeb1df146756 | 341 | */ |
mbed_official | 76:aeb1df146756 | 342 | #define CAN_FilterScale_16bit ((uint8_t)0x00) /*!< Two 16-bit filters */ |
mbed_official | 76:aeb1df146756 | 343 | #define CAN_FilterScale_32bit ((uint8_t)0x01) /*!< One 32-bit filter */ |
mbed_official | 76:aeb1df146756 | 344 | |
mbed_official | 76:aeb1df146756 | 345 | #define IS_CAN_FILTER_SCALE(SCALE) (((SCALE) == CAN_FilterScale_16bit) || \ |
mbed_official | 76:aeb1df146756 | 346 | ((SCALE) == CAN_FilterScale_32bit)) |
mbed_official | 76:aeb1df146756 | 347 | /** |
mbed_official | 76:aeb1df146756 | 348 | * @} |
mbed_official | 76:aeb1df146756 | 349 | */ |
mbed_official | 76:aeb1df146756 | 350 | |
mbed_official | 76:aeb1df146756 | 351 | /** @defgroup CAN_filter_FIFO |
mbed_official | 76:aeb1df146756 | 352 | * @{ |
mbed_official | 76:aeb1df146756 | 353 | */ |
mbed_official | 76:aeb1df146756 | 354 | #define CAN_Filter_FIFO0 ((uint8_t)0x00) /*!< Filter FIFO 0 assignment for filter x */ |
mbed_official | 76:aeb1df146756 | 355 | #define CAN_Filter_FIFO1 ((uint8_t)0x01) /*!< Filter FIFO 1 assignment for filter x */ |
mbed_official | 76:aeb1df146756 | 356 | #define IS_CAN_FILTER_FIFO(FIFO) (((FIFO) == CAN_FilterFIFO0) || \ |
mbed_official | 76:aeb1df146756 | 357 | ((FIFO) == CAN_FilterFIFO1)) |
mbed_official | 76:aeb1df146756 | 358 | |
mbed_official | 76:aeb1df146756 | 359 | /* Legacy defines */ |
mbed_official | 76:aeb1df146756 | 360 | #define CAN_FilterFIFO0 CAN_Filter_FIFO0 |
mbed_official | 76:aeb1df146756 | 361 | #define CAN_FilterFIFO1 CAN_Filter_FIFO1 |
mbed_official | 76:aeb1df146756 | 362 | /** |
mbed_official | 76:aeb1df146756 | 363 | * @} |
mbed_official | 76:aeb1df146756 | 364 | */ |
mbed_official | 76:aeb1df146756 | 365 | |
mbed_official | 76:aeb1df146756 | 366 | /** @defgroup CAN_Start_bank_filter_for_slave_CAN |
mbed_official | 76:aeb1df146756 | 367 | * @{ |
mbed_official | 76:aeb1df146756 | 368 | */ |
mbed_official | 76:aeb1df146756 | 369 | #define IS_CAN_BANKNUMBER(BANKNUMBER) (((BANKNUMBER) >= 1) && ((BANKNUMBER) <= 27)) |
mbed_official | 76:aeb1df146756 | 370 | /** |
mbed_official | 76:aeb1df146756 | 371 | * @} |
mbed_official | 76:aeb1df146756 | 372 | */ |
mbed_official | 76:aeb1df146756 | 373 | |
mbed_official | 76:aeb1df146756 | 374 | /** @defgroup CAN_Tx |
mbed_official | 76:aeb1df146756 | 375 | * @{ |
mbed_official | 76:aeb1df146756 | 376 | */ |
mbed_official | 76:aeb1df146756 | 377 | #define IS_CAN_TRANSMITMAILBOX(TRANSMITMAILBOX) ((TRANSMITMAILBOX) <= ((uint8_t)0x02)) |
mbed_official | 76:aeb1df146756 | 378 | #define IS_CAN_STDID(STDID) ((STDID) <= ((uint32_t)0x7FF)) |
mbed_official | 76:aeb1df146756 | 379 | #define IS_CAN_EXTID(EXTID) ((EXTID) <= ((uint32_t)0x1FFFFFFF)) |
mbed_official | 76:aeb1df146756 | 380 | #define IS_CAN_DLC(DLC) ((DLC) <= ((uint8_t)0x08)) |
mbed_official | 76:aeb1df146756 | 381 | /** |
mbed_official | 76:aeb1df146756 | 382 | * @} |
mbed_official | 76:aeb1df146756 | 383 | */ |
mbed_official | 76:aeb1df146756 | 384 | |
mbed_official | 76:aeb1df146756 | 385 | /** @defgroup CAN_identifier_type |
mbed_official | 76:aeb1df146756 | 386 | * @{ |
mbed_official | 76:aeb1df146756 | 387 | */ |
mbed_official | 76:aeb1df146756 | 388 | #define CAN_Id_Standard ((uint32_t)0x00000000) /*!< Standard Id */ |
mbed_official | 76:aeb1df146756 | 389 | #define CAN_Id_Extended ((uint32_t)0x00000004) /*!< Extended Id */ |
mbed_official | 76:aeb1df146756 | 390 | #define IS_CAN_IDTYPE(IDTYPE) (((IDTYPE) == CAN_Id_Standard) || \ |
mbed_official | 76:aeb1df146756 | 391 | ((IDTYPE) == CAN_Id_Extended)) |
mbed_official | 76:aeb1df146756 | 392 | |
mbed_official | 76:aeb1df146756 | 393 | /* Legacy defines */ |
mbed_official | 76:aeb1df146756 | 394 | #define CAN_ID_STD CAN_Id_Standard |
mbed_official | 76:aeb1df146756 | 395 | #define CAN_ID_EXT CAN_Id_Extended |
mbed_official | 76:aeb1df146756 | 396 | /** |
mbed_official | 76:aeb1df146756 | 397 | * @} |
mbed_official | 76:aeb1df146756 | 398 | */ |
mbed_official | 76:aeb1df146756 | 399 | |
mbed_official | 76:aeb1df146756 | 400 | /** @defgroup CAN_remote_transmission_request |
mbed_official | 76:aeb1df146756 | 401 | * @{ |
mbed_official | 76:aeb1df146756 | 402 | */ |
mbed_official | 76:aeb1df146756 | 403 | #define CAN_RTR_Data ((uint32_t)0x00000000) /*!< Data frame */ |
mbed_official | 76:aeb1df146756 | 404 | #define CAN_RTR_Remote ((uint32_t)0x00000002) /*!< Remote frame */ |
mbed_official | 76:aeb1df146756 | 405 | #define IS_CAN_RTR(RTR) (((RTR) == CAN_RTR_Data) || ((RTR) == CAN_RTR_Remote)) |
mbed_official | 76:aeb1df146756 | 406 | |
mbed_official | 76:aeb1df146756 | 407 | /* Legacy defines */ |
mbed_official | 76:aeb1df146756 | 408 | #define CAN_RTR_DATA CAN_RTR_Data |
mbed_official | 76:aeb1df146756 | 409 | #define CAN_RTR_REMOTE CAN_RTR_Remote |
mbed_official | 76:aeb1df146756 | 410 | /** |
mbed_official | 76:aeb1df146756 | 411 | * @} |
mbed_official | 76:aeb1df146756 | 412 | */ |
mbed_official | 76:aeb1df146756 | 413 | |
mbed_official | 76:aeb1df146756 | 414 | /** @defgroup CAN_transmit_constants |
mbed_official | 76:aeb1df146756 | 415 | * @{ |
mbed_official | 76:aeb1df146756 | 416 | */ |
mbed_official | 76:aeb1df146756 | 417 | #define CAN_TxStatus_Failed ((uint8_t)0x00)/*!< CAN transmission failed */ |
mbed_official | 76:aeb1df146756 | 418 | #define CAN_TxStatus_Ok ((uint8_t)0x01) /*!< CAN transmission succeeded */ |
mbed_official | 76:aeb1df146756 | 419 | #define CAN_TxStatus_Pending ((uint8_t)0x02) /*!< CAN transmission pending */ |
mbed_official | 76:aeb1df146756 | 420 | #define CAN_TxStatus_NoMailBox ((uint8_t)0x04) /*!< CAN cell did not provide |
mbed_official | 76:aeb1df146756 | 421 | an empty mailbox */ |
mbed_official | 76:aeb1df146756 | 422 | /* Legacy defines */ |
mbed_official | 76:aeb1df146756 | 423 | #define CANTXFAILED CAN_TxStatus_Failed |
mbed_official | 76:aeb1df146756 | 424 | #define CANTXOK CAN_TxStatus_Ok |
mbed_official | 76:aeb1df146756 | 425 | #define CANTXPENDING CAN_TxStatus_Pending |
mbed_official | 76:aeb1df146756 | 426 | #define CAN_NO_MB CAN_TxStatus_NoMailBox |
mbed_official | 76:aeb1df146756 | 427 | /** |
mbed_official | 76:aeb1df146756 | 428 | * @} |
mbed_official | 76:aeb1df146756 | 429 | */ |
mbed_official | 76:aeb1df146756 | 430 | |
mbed_official | 76:aeb1df146756 | 431 | /** @defgroup CAN_receive_FIFO_number_constants |
mbed_official | 76:aeb1df146756 | 432 | * @{ |
mbed_official | 76:aeb1df146756 | 433 | */ |
mbed_official | 76:aeb1df146756 | 434 | #define CAN_FIFO0 ((uint8_t)0x00) /*!< CAN FIFO 0 used to receive */ |
mbed_official | 76:aeb1df146756 | 435 | #define CAN_FIFO1 ((uint8_t)0x01) /*!< CAN FIFO 1 used to receive */ |
mbed_official | 76:aeb1df146756 | 436 | |
mbed_official | 76:aeb1df146756 | 437 | #define IS_CAN_FIFO(FIFO) (((FIFO) == CAN_FIFO0) || ((FIFO) == CAN_FIFO1)) |
mbed_official | 76:aeb1df146756 | 438 | /** |
mbed_official | 76:aeb1df146756 | 439 | * @} |
mbed_official | 76:aeb1df146756 | 440 | */ |
mbed_official | 76:aeb1df146756 | 441 | |
mbed_official | 76:aeb1df146756 | 442 | /** @defgroup CAN_sleep_constants |
mbed_official | 76:aeb1df146756 | 443 | * @{ |
mbed_official | 76:aeb1df146756 | 444 | */ |
mbed_official | 76:aeb1df146756 | 445 | #define CAN_Sleep_Failed ((uint8_t)0x00) /*!< CAN did not enter the sleep mode */ |
mbed_official | 76:aeb1df146756 | 446 | #define CAN_Sleep_Ok ((uint8_t)0x01) /*!< CAN entered the sleep mode */ |
mbed_official | 76:aeb1df146756 | 447 | |
mbed_official | 76:aeb1df146756 | 448 | /* Legacy defines */ |
mbed_official | 76:aeb1df146756 | 449 | #define CANSLEEPFAILED CAN_Sleep_Failed |
mbed_official | 76:aeb1df146756 | 450 | #define CANSLEEPOK CAN_Sleep_Ok |
mbed_official | 76:aeb1df146756 | 451 | /** |
mbed_official | 76:aeb1df146756 | 452 | * @} |
mbed_official | 76:aeb1df146756 | 453 | */ |
mbed_official | 76:aeb1df146756 | 454 | |
mbed_official | 76:aeb1df146756 | 455 | /** @defgroup CAN_wake_up_constants |
mbed_official | 76:aeb1df146756 | 456 | * @{ |
mbed_official | 76:aeb1df146756 | 457 | */ |
mbed_official | 76:aeb1df146756 | 458 | #define CAN_WakeUp_Failed ((uint8_t)0x00) /*!< CAN did not leave the sleep mode */ |
mbed_official | 76:aeb1df146756 | 459 | #define CAN_WakeUp_Ok ((uint8_t)0x01) /*!< CAN leaved the sleep mode */ |
mbed_official | 76:aeb1df146756 | 460 | |
mbed_official | 76:aeb1df146756 | 461 | /* Legacy defines */ |
mbed_official | 76:aeb1df146756 | 462 | #define CANWAKEUPFAILED CAN_WakeUp_Failed |
mbed_official | 76:aeb1df146756 | 463 | #define CANWAKEUPOK CAN_WakeUp_Ok |
mbed_official | 76:aeb1df146756 | 464 | /** |
mbed_official | 76:aeb1df146756 | 465 | * @} |
mbed_official | 76:aeb1df146756 | 466 | */ |
mbed_official | 76:aeb1df146756 | 467 | |
mbed_official | 76:aeb1df146756 | 468 | /** |
mbed_official | 76:aeb1df146756 | 469 | * @defgroup CAN_Error_Code_constants |
mbed_official | 76:aeb1df146756 | 470 | * @{ |
mbed_official | 76:aeb1df146756 | 471 | */ |
mbed_official | 76:aeb1df146756 | 472 | #define CAN_ErrorCode_NoErr ((uint8_t)0x00) /*!< No Error */ |
mbed_official | 76:aeb1df146756 | 473 | #define CAN_ErrorCode_StuffErr ((uint8_t)0x10) /*!< Stuff Error */ |
mbed_official | 76:aeb1df146756 | 474 | #define CAN_ErrorCode_FormErr ((uint8_t)0x20) /*!< Form Error */ |
mbed_official | 76:aeb1df146756 | 475 | #define CAN_ErrorCode_ACKErr ((uint8_t)0x30) /*!< Acknowledgment Error */ |
mbed_official | 76:aeb1df146756 | 476 | #define CAN_ErrorCode_BitRecessiveErr ((uint8_t)0x40) /*!< Bit Recessive Error */ |
mbed_official | 76:aeb1df146756 | 477 | #define CAN_ErrorCode_BitDominantErr ((uint8_t)0x50) /*!< Bit Dominant Error */ |
mbed_official | 76:aeb1df146756 | 478 | #define CAN_ErrorCode_CRCErr ((uint8_t)0x60) /*!< CRC Error */ |
mbed_official | 76:aeb1df146756 | 479 | #define CAN_ErrorCode_SoftwareSetErr ((uint8_t)0x70) /*!< Software Set Error */ |
mbed_official | 76:aeb1df146756 | 480 | /** |
mbed_official | 76:aeb1df146756 | 481 | * @} |
mbed_official | 76:aeb1df146756 | 482 | */ |
mbed_official | 76:aeb1df146756 | 483 | |
mbed_official | 76:aeb1df146756 | 484 | /** @defgroup CAN_flags |
mbed_official | 76:aeb1df146756 | 485 | * @{ |
mbed_official | 76:aeb1df146756 | 486 | */ |
mbed_official | 76:aeb1df146756 | 487 | /* If the flag is 0x3XXXXXXX, it means that it can be used with CAN_GetFlagStatus() |
mbed_official | 76:aeb1df146756 | 488 | and CAN_ClearFlag() functions. */ |
mbed_official | 76:aeb1df146756 | 489 | /* If the flag is 0x1XXXXXXX, it means that it can only be used with |
mbed_official | 76:aeb1df146756 | 490 | CAN_GetFlagStatus() function. */ |
mbed_official | 76:aeb1df146756 | 491 | |
mbed_official | 76:aeb1df146756 | 492 | /* Transmit Flags */ |
mbed_official | 76:aeb1df146756 | 493 | #define CAN_FLAG_RQCP0 ((uint32_t)0x38000001) /*!< Request MailBox0 Flag */ |
mbed_official | 76:aeb1df146756 | 494 | #define CAN_FLAG_RQCP1 ((uint32_t)0x38000100) /*!< Request MailBox1 Flag */ |
mbed_official | 76:aeb1df146756 | 495 | #define CAN_FLAG_RQCP2 ((uint32_t)0x38010000) /*!< Request MailBox2 Flag */ |
mbed_official | 76:aeb1df146756 | 496 | |
mbed_official | 76:aeb1df146756 | 497 | /* Receive Flags */ |
mbed_official | 76:aeb1df146756 | 498 | #define CAN_FLAG_FMP0 ((uint32_t)0x12000003) /*!< FIFO 0 Message Pending Flag */ |
mbed_official | 76:aeb1df146756 | 499 | #define CAN_FLAG_FF0 ((uint32_t)0x32000008) /*!< FIFO 0 Full Flag */ |
mbed_official | 76:aeb1df146756 | 500 | #define CAN_FLAG_FOV0 ((uint32_t)0x32000010) /*!< FIFO 0 Overrun Flag */ |
mbed_official | 76:aeb1df146756 | 501 | #define CAN_FLAG_FMP1 ((uint32_t)0x14000003) /*!< FIFO 1 Message Pending Flag */ |
mbed_official | 76:aeb1df146756 | 502 | #define CAN_FLAG_FF1 ((uint32_t)0x34000008) /*!< FIFO 1 Full Flag */ |
mbed_official | 76:aeb1df146756 | 503 | #define CAN_FLAG_FOV1 ((uint32_t)0x34000010) /*!< FIFO 1 Overrun Flag */ |
mbed_official | 76:aeb1df146756 | 504 | |
mbed_official | 76:aeb1df146756 | 505 | /* Operating Mode Flags */ |
mbed_official | 76:aeb1df146756 | 506 | #define CAN_FLAG_WKU ((uint32_t)0x31000008) /*!< Wake up Flag */ |
mbed_official | 76:aeb1df146756 | 507 | #define CAN_FLAG_SLAK ((uint32_t)0x31000012) /*!< Sleep acknowledge Flag */ |
mbed_official | 76:aeb1df146756 | 508 | /* @note When SLAK interrupt is disabled (SLKIE=0), no polling on SLAKI is possible. |
mbed_official | 76:aeb1df146756 | 509 | In this case the SLAK bit can be polled.*/ |
mbed_official | 76:aeb1df146756 | 510 | |
mbed_official | 76:aeb1df146756 | 511 | /* Error Flags */ |
mbed_official | 76:aeb1df146756 | 512 | #define CAN_FLAG_EWG ((uint32_t)0x10F00001) /*!< Error Warning Flag */ |
mbed_official | 76:aeb1df146756 | 513 | #define CAN_FLAG_EPV ((uint32_t)0x10F00002) /*!< Error Passive Flag */ |
mbed_official | 76:aeb1df146756 | 514 | #define CAN_FLAG_BOF ((uint32_t)0x10F00004) /*!< Bus-Off Flag */ |
mbed_official | 76:aeb1df146756 | 515 | #define CAN_FLAG_LEC ((uint32_t)0x30F00070) /*!< Last error code Flag */ |
mbed_official | 76:aeb1df146756 | 516 | |
mbed_official | 76:aeb1df146756 | 517 | #define IS_CAN_GET_FLAG(FLAG) (((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_BOF) || \ |
mbed_official | 76:aeb1df146756 | 518 | ((FLAG) == CAN_FLAG_EPV) || ((FLAG) == CAN_FLAG_EWG) || \ |
mbed_official | 76:aeb1df146756 | 519 | ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_FOV0) || \ |
mbed_official | 76:aeb1df146756 | 520 | ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FMP0) || \ |
mbed_official | 76:aeb1df146756 | 521 | ((FLAG) == CAN_FLAG_FOV1) || ((FLAG) == CAN_FLAG_FF1) || \ |
mbed_official | 76:aeb1df146756 | 522 | ((FLAG) == CAN_FLAG_FMP1) || ((FLAG) == CAN_FLAG_RQCP2) || \ |
mbed_official | 76:aeb1df146756 | 523 | ((FLAG) == CAN_FLAG_RQCP1)|| ((FLAG) == CAN_FLAG_RQCP0) || \ |
mbed_official | 76:aeb1df146756 | 524 | ((FLAG) == CAN_FLAG_SLAK )) |
mbed_official | 76:aeb1df146756 | 525 | |
mbed_official | 76:aeb1df146756 | 526 | #define IS_CAN_CLEAR_FLAG(FLAG)(((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_RQCP2) || \ |
mbed_official | 76:aeb1df146756 | 527 | ((FLAG) == CAN_FLAG_RQCP1) || ((FLAG) == CAN_FLAG_RQCP0) || \ |
mbed_official | 76:aeb1df146756 | 528 | ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FOV0) ||\ |
mbed_official | 76:aeb1df146756 | 529 | ((FLAG) == CAN_FLAG_FF1) || ((FLAG) == CAN_FLAG_FOV1) || \ |
mbed_official | 76:aeb1df146756 | 530 | ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_SLAK)) |
mbed_official | 76:aeb1df146756 | 531 | /** |
mbed_official | 76:aeb1df146756 | 532 | * @} |
mbed_official | 76:aeb1df146756 | 533 | */ |
mbed_official | 76:aeb1df146756 | 534 | |
mbed_official | 76:aeb1df146756 | 535 | |
mbed_official | 76:aeb1df146756 | 536 | /** @defgroup CAN_interrupts |
mbed_official | 76:aeb1df146756 | 537 | * @{ |
mbed_official | 76:aeb1df146756 | 538 | */ |
mbed_official | 76:aeb1df146756 | 539 | #define CAN_IT_TME ((uint32_t)0x00000001) /*!< Transmit mailbox empty Interrupt*/ |
mbed_official | 76:aeb1df146756 | 540 | |
mbed_official | 76:aeb1df146756 | 541 | /* Receive Interrupts */ |
mbed_official | 76:aeb1df146756 | 542 | #define CAN_IT_FMP0 ((uint32_t)0x00000002) /*!< FIFO 0 message pending Interrupt*/ |
mbed_official | 76:aeb1df146756 | 543 | #define CAN_IT_FF0 ((uint32_t)0x00000004) /*!< FIFO 0 full Interrupt*/ |
mbed_official | 76:aeb1df146756 | 544 | #define CAN_IT_FOV0 ((uint32_t)0x00000008) /*!< FIFO 0 overrun Interrupt*/ |
mbed_official | 76:aeb1df146756 | 545 | #define CAN_IT_FMP1 ((uint32_t)0x00000010) /*!< FIFO 1 message pending Interrupt*/ |
mbed_official | 76:aeb1df146756 | 546 | #define CAN_IT_FF1 ((uint32_t)0x00000020) /*!< FIFO 1 full Interrupt*/ |
mbed_official | 76:aeb1df146756 | 547 | #define CAN_IT_FOV1 ((uint32_t)0x00000040) /*!< FIFO 1 overrun Interrupt*/ |
mbed_official | 76:aeb1df146756 | 548 | |
mbed_official | 76:aeb1df146756 | 549 | /* Operating Mode Interrupts */ |
mbed_official | 76:aeb1df146756 | 550 | #define CAN_IT_WKU ((uint32_t)0x00010000) /*!< Wake-up Interrupt*/ |
mbed_official | 76:aeb1df146756 | 551 | #define CAN_IT_SLK ((uint32_t)0x00020000) /*!< Sleep acknowledge Interrupt*/ |
mbed_official | 76:aeb1df146756 | 552 | |
mbed_official | 76:aeb1df146756 | 553 | /* Error Interrupts */ |
mbed_official | 76:aeb1df146756 | 554 | #define CAN_IT_EWG ((uint32_t)0x00000100) /*!< Error warning Interrupt*/ |
mbed_official | 76:aeb1df146756 | 555 | #define CAN_IT_EPV ((uint32_t)0x00000200) /*!< Error passive Interrupt*/ |
mbed_official | 76:aeb1df146756 | 556 | #define CAN_IT_BOF ((uint32_t)0x00000400) /*!< Bus-off Interrupt*/ |
mbed_official | 76:aeb1df146756 | 557 | #define CAN_IT_LEC ((uint32_t)0x00000800) /*!< Last error code Interrupt*/ |
mbed_official | 76:aeb1df146756 | 558 | #define CAN_IT_ERR ((uint32_t)0x00008000) /*!< Error Interrupt*/ |
mbed_official | 76:aeb1df146756 | 559 | |
mbed_official | 76:aeb1df146756 | 560 | /* Flags named as Interrupts : kept only for FW compatibility */ |
mbed_official | 76:aeb1df146756 | 561 | #define CAN_IT_RQCP0 CAN_IT_TME |
mbed_official | 76:aeb1df146756 | 562 | #define CAN_IT_RQCP1 CAN_IT_TME |
mbed_official | 76:aeb1df146756 | 563 | #define CAN_IT_RQCP2 CAN_IT_TME |
mbed_official | 76:aeb1df146756 | 564 | |
mbed_official | 76:aeb1df146756 | 565 | |
mbed_official | 76:aeb1df146756 | 566 | #define IS_CAN_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FMP0) ||\ |
mbed_official | 76:aeb1df146756 | 567 | ((IT) == CAN_IT_FF0) || ((IT) == CAN_IT_FOV0) ||\ |
mbed_official | 76:aeb1df146756 | 568 | ((IT) == CAN_IT_FMP1) || ((IT) == CAN_IT_FF1) ||\ |
mbed_official | 76:aeb1df146756 | 569 | ((IT) == CAN_IT_FOV1) || ((IT) == CAN_IT_EWG) ||\ |
mbed_official | 76:aeb1df146756 | 570 | ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\ |
mbed_official | 76:aeb1df146756 | 571 | ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\ |
mbed_official | 76:aeb1df146756 | 572 | ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK)) |
mbed_official | 76:aeb1df146756 | 573 | |
mbed_official | 76:aeb1df146756 | 574 | #define IS_CAN_CLEAR_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FF0) ||\ |
mbed_official | 76:aeb1df146756 | 575 | ((IT) == CAN_IT_FOV0)|| ((IT) == CAN_IT_FF1) ||\ |
mbed_official | 76:aeb1df146756 | 576 | ((IT) == CAN_IT_FOV1)|| ((IT) == CAN_IT_EWG) ||\ |
mbed_official | 76:aeb1df146756 | 577 | ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\ |
mbed_official | 76:aeb1df146756 | 578 | ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\ |
mbed_official | 76:aeb1df146756 | 579 | ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK)) |
mbed_official | 76:aeb1df146756 | 580 | /** |
mbed_official | 76:aeb1df146756 | 581 | * @} |
mbed_official | 76:aeb1df146756 | 582 | */ |
mbed_official | 76:aeb1df146756 | 583 | |
mbed_official | 76:aeb1df146756 | 584 | /** |
mbed_official | 76:aeb1df146756 | 585 | * @} |
mbed_official | 76:aeb1df146756 | 586 | */ |
mbed_official | 76:aeb1df146756 | 587 | |
mbed_official | 76:aeb1df146756 | 588 | /* Exported macro ------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 589 | /* Exported functions --------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 590 | |
mbed_official | 76:aeb1df146756 | 591 | /* Function used to set the CAN configuration to the default reset state *****/ |
mbed_official | 76:aeb1df146756 | 592 | void CAN_DeInit(CAN_TypeDef* CANx); |
mbed_official | 76:aeb1df146756 | 593 | |
mbed_official | 76:aeb1df146756 | 594 | /* Initialization and Configuration functions *********************************/ |
mbed_official | 76:aeb1df146756 | 595 | uint8_t CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct); |
mbed_official | 76:aeb1df146756 | 596 | void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct); |
mbed_official | 76:aeb1df146756 | 597 | void CAN_StructInit(CAN_InitTypeDef* CAN_InitStruct); |
mbed_official | 76:aeb1df146756 | 598 | void CAN_SlaveStartBank(uint8_t CAN_BankNumber); |
mbed_official | 76:aeb1df146756 | 599 | void CAN_DBGFreeze(CAN_TypeDef* CANx, FunctionalState NewState); |
mbed_official | 76:aeb1df146756 | 600 | void CAN_TTComModeCmd(CAN_TypeDef* CANx, FunctionalState NewState); |
mbed_official | 76:aeb1df146756 | 601 | |
mbed_official | 76:aeb1df146756 | 602 | /* CAN Frames Transmission functions ******************************************/ |
mbed_official | 76:aeb1df146756 | 603 | uint8_t CAN_Transmit(CAN_TypeDef* CANx, CanTxMsg* TxMessage); |
mbed_official | 76:aeb1df146756 | 604 | uint8_t CAN_TransmitStatus(CAN_TypeDef* CANx, uint8_t TransmitMailbox); |
mbed_official | 76:aeb1df146756 | 605 | void CAN_CancelTransmit(CAN_TypeDef* CANx, uint8_t Mailbox); |
mbed_official | 76:aeb1df146756 | 606 | |
mbed_official | 76:aeb1df146756 | 607 | /* CAN Frames Reception functions *********************************************/ |
mbed_official | 76:aeb1df146756 | 608 | void CAN_Receive(CAN_TypeDef* CANx, uint8_t FIFONumber, CanRxMsg* RxMessage); |
mbed_official | 76:aeb1df146756 | 609 | void CAN_FIFORelease(CAN_TypeDef* CANx, uint8_t FIFONumber); |
mbed_official | 76:aeb1df146756 | 610 | uint8_t CAN_MessagePending(CAN_TypeDef* CANx, uint8_t FIFONumber); |
mbed_official | 76:aeb1df146756 | 611 | |
mbed_official | 76:aeb1df146756 | 612 | /* Operation modes functions **************************************************/ |
mbed_official | 76:aeb1df146756 | 613 | uint8_t CAN_OperatingModeRequest(CAN_TypeDef* CANx, uint8_t CAN_OperatingMode); |
mbed_official | 76:aeb1df146756 | 614 | uint8_t CAN_Sleep(CAN_TypeDef* CANx); |
mbed_official | 76:aeb1df146756 | 615 | uint8_t CAN_WakeUp(CAN_TypeDef* CANx); |
mbed_official | 76:aeb1df146756 | 616 | |
mbed_official | 76:aeb1df146756 | 617 | /* CAN Bus Error management functions *****************************************/ |
mbed_official | 76:aeb1df146756 | 618 | uint8_t CAN_GetLastErrorCode(CAN_TypeDef* CANx); |
mbed_official | 76:aeb1df146756 | 619 | uint8_t CAN_GetReceiveErrorCounter(CAN_TypeDef* CANx); |
mbed_official | 76:aeb1df146756 | 620 | uint8_t CAN_GetLSBTransmitErrorCounter(CAN_TypeDef* CANx); |
mbed_official | 76:aeb1df146756 | 621 | |
mbed_official | 76:aeb1df146756 | 622 | /* Interrupts and flags management functions **********************************/ |
mbed_official | 76:aeb1df146756 | 623 | void CAN_ITConfig(CAN_TypeDef* CANx, uint32_t CAN_IT, FunctionalState NewState); |
mbed_official | 76:aeb1df146756 | 624 | FlagStatus CAN_GetFlagStatus(CAN_TypeDef* CANx, uint32_t CAN_FLAG); |
mbed_official | 76:aeb1df146756 | 625 | void CAN_ClearFlag(CAN_TypeDef* CANx, uint32_t CAN_FLAG); |
mbed_official | 76:aeb1df146756 | 626 | ITStatus CAN_GetITStatus(CAN_TypeDef* CANx, uint32_t CAN_IT); |
mbed_official | 76:aeb1df146756 | 627 | void CAN_ClearITPendingBit(CAN_TypeDef* CANx, uint32_t CAN_IT); |
mbed_official | 76:aeb1df146756 | 628 | |
mbed_official | 76:aeb1df146756 | 629 | #ifdef __cplusplus |
mbed_official | 76:aeb1df146756 | 630 | } |
mbed_official | 76:aeb1df146756 | 631 | #endif |
mbed_official | 76:aeb1df146756 | 632 | |
mbed_official | 76:aeb1df146756 | 633 | #endif /* __STM32F0xx_CAN_H */ |
mbed_official | 76:aeb1df146756 | 634 | |
mbed_official | 76:aeb1df146756 | 635 | /** |
mbed_official | 76:aeb1df146756 | 636 | * @} |
mbed_official | 76:aeb1df146756 | 637 | */ |
mbed_official | 76:aeb1df146756 | 638 | |
mbed_official | 76:aeb1df146756 | 639 | /** |
mbed_official | 76:aeb1df146756 | 640 | * @} |
mbed_official | 76:aeb1df146756 | 641 | */ |
mbed_official | 76:aeb1df146756 | 642 | |
mbed_official | 76:aeb1df146756 | 643 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |