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