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