The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_K64F/TOOLCHAIN_IAR/fsl_flexcan.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 171:3a7713b1edbc | 1 | /* |
AnnaBridge | 171:3a7713b1edbc | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
AnnaBridge | 171:3a7713b1edbc | 3 | * All rights reserved. |
AnnaBridge | 171:3a7713b1edbc | 4 | * |
AnnaBridge | 171:3a7713b1edbc | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 171:3a7713b1edbc | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 171:3a7713b1edbc | 7 | * |
AnnaBridge | 171:3a7713b1edbc | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 171:3a7713b1edbc | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 171:3a7713b1edbc | 10 | * |
AnnaBridge | 171:3a7713b1edbc | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 171:3a7713b1edbc | 12 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 171:3a7713b1edbc | 13 | * other materials provided with the distribution. |
AnnaBridge | 171:3a7713b1edbc | 14 | * |
AnnaBridge | 171:3a7713b1edbc | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
AnnaBridge | 171:3a7713b1edbc | 16 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 171:3a7713b1edbc | 17 | * software without specific prior written permission. |
AnnaBridge | 171:3a7713b1edbc | 18 | * |
AnnaBridge | 171:3a7713b1edbc | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 171:3a7713b1edbc | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 171:3a7713b1edbc | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 171:3a7713b1edbc | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 171:3a7713b1edbc | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 171:3a7713b1edbc | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 171:3a7713b1edbc | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 171:3a7713b1edbc | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 171:3a7713b1edbc | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 171:3a7713b1edbc | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 171:3a7713b1edbc | 29 | */ |
AnnaBridge | 171:3a7713b1edbc | 30 | #ifndef _FSL_FLEXCAN_H_ |
AnnaBridge | 171:3a7713b1edbc | 31 | #define _FSL_FLEXCAN_H_ |
AnnaBridge | 171:3a7713b1edbc | 32 | |
AnnaBridge | 171:3a7713b1edbc | 33 | #include "fsl_common.h" |
AnnaBridge | 171:3a7713b1edbc | 34 | |
AnnaBridge | 171:3a7713b1edbc | 35 | /*! |
AnnaBridge | 171:3a7713b1edbc | 36 | * @addtogroup flexcan_driver |
AnnaBridge | 171:3a7713b1edbc | 37 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 38 | */ |
AnnaBridge | 171:3a7713b1edbc | 39 | |
AnnaBridge | 171:3a7713b1edbc | 40 | |
AnnaBridge | 171:3a7713b1edbc | 41 | /****************************************************************************** |
AnnaBridge | 171:3a7713b1edbc | 42 | * Definitions |
AnnaBridge | 171:3a7713b1edbc | 43 | *****************************************************************************/ |
AnnaBridge | 171:3a7713b1edbc | 44 | |
AnnaBridge | 171:3a7713b1edbc | 45 | /*! @name Driver version */ |
AnnaBridge | 171:3a7713b1edbc | 46 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 47 | /*! @brief FlexCAN driver version 2.1.0. */ |
AnnaBridge | 171:3a7713b1edbc | 48 | #define FLEXCAN_DRIVER_VERSION (MAKE_VERSION(2, 1, 0)) |
AnnaBridge | 171:3a7713b1edbc | 49 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 50 | |
AnnaBridge | 171:3a7713b1edbc | 51 | /*! @brief FlexCAN Frame ID helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 52 | #define FLEXCAN_ID_STD(id) \ |
AnnaBridge | 171:3a7713b1edbc | 53 | (((uint32_t)(((uint32_t)(id)) << CAN_ID_STD_SHIFT)) & CAN_ID_STD_MASK) /*!< Standard Frame ID helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 54 | #define FLEXCAN_ID_EXT(id) \ |
AnnaBridge | 171:3a7713b1edbc | 55 | (((uint32_t)(((uint32_t)(id)) << CAN_ID_EXT_SHIFT)) & \ |
AnnaBridge | 171:3a7713b1edbc | 56 | (CAN_ID_EXT_MASK | CAN_ID_STD_MASK)) /*!< Extend Frame ID helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 57 | |
AnnaBridge | 171:3a7713b1edbc | 58 | /*! @brief FlexCAN Rx Message Buffer Mask helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 59 | #define FLEXCAN_RX_MB_STD_MASK(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 60 | (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \ |
AnnaBridge | 171:3a7713b1edbc | 61 | FLEXCAN_ID_STD(id)) /*!< Standard Rx Message Buffer Mask helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 62 | #define FLEXCAN_RX_MB_EXT_MASK(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 63 | (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \ |
AnnaBridge | 171:3a7713b1edbc | 64 | FLEXCAN_ID_EXT(id)) /*!< Extend Rx Message Buffer Mask helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 65 | |
AnnaBridge | 171:3a7713b1edbc | 66 | /*! @brief FlexCAN Rx FIFO Mask helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 67 | #define FLEXCAN_RX_FIFO_STD_MASK_TYPE_A(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 68 | (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \ |
AnnaBridge | 171:3a7713b1edbc | 69 | (FLEXCAN_ID_STD(id) << 1)) /*!< Standard Rx FIFO Mask helper macro Type A helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 70 | #define FLEXCAN_RX_FIFO_STD_MASK_TYPE_B_HIGH(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 71 | (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \ |
AnnaBridge | 171:3a7713b1edbc | 72 | (FLEXCAN_ID_STD(id) << 16)) /*!< Standard Rx FIFO Mask helper macro Type B upper part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 73 | #define FLEXCAN_RX_FIFO_STD_MASK_TYPE_B_LOW(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 74 | (((uint32_t)((uint32_t)(rtr) << 15) | (uint32_t)((uint32_t)(ide) << 14)) | \ |
AnnaBridge | 171:3a7713b1edbc | 75 | FLEXCAN_ID_STD(id)) /*!< Standard Rx FIFO Mask helper macro Type B lower part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 76 | #define FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_HIGH(id) \ |
AnnaBridge | 171:3a7713b1edbc | 77 | ((FLEXCAN_ID_STD(id) & 0x7F8) << 21) /*!< Standard Rx FIFO Mask helper macro Type C upper part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 78 | #define FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_MID_HIGH(id) \ |
AnnaBridge | 171:3a7713b1edbc | 79 | ((FLEXCAN_ID_STD(id) & 0x7F8) << 13) /*!< Standard Rx FIFO Mask helper macro Type C mid-upper part helper macro. \ |
AnnaBridge | 171:3a7713b1edbc | 80 | */ |
AnnaBridge | 171:3a7713b1edbc | 81 | #define FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_MID_LOW(id) \ |
AnnaBridge | 171:3a7713b1edbc | 82 | ((FLEXCAN_ID_STD(id) & 0x7F8) << 5) /*!< Standard Rx FIFO Mask helper macro Type C mid-lower part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 83 | #define FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_LOW(id) \ |
AnnaBridge | 171:3a7713b1edbc | 84 | ((FLEXCAN_ID_STD(id) & 0x7F8) >> 3) /*!< Standard Rx FIFO Mask helper macro Type C lower part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 85 | #define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_A(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 86 | (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \ |
AnnaBridge | 171:3a7713b1edbc | 87 | (FLEXCAN_ID_EXT(id) << 1)) /*!< Extend Rx FIFO Mask helper macro Type A helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 88 | #define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_B_HIGH(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 89 | (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \ |
AnnaBridge | 171:3a7713b1edbc | 90 | ((FLEXCAN_ID_EXT(id) & 0x1FFF8000) << 1)) /*!< Extend Rx FIFO Mask helper macro Type B upper part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 91 | #define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_B_LOW(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 92 | (((uint32_t)((uint32_t)(rtr) << 15) | (uint32_t)((uint32_t)(ide) << 14)) | \ |
AnnaBridge | 171:3a7713b1edbc | 93 | ((FLEXCAN_ID_EXT(id) & 0x1FFF8000) >> \ |
AnnaBridge | 171:3a7713b1edbc | 94 | 15)) /*!< Extend Rx FIFO Mask helper macro Type B lower part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 95 | #define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_HIGH(id) \ |
AnnaBridge | 171:3a7713b1edbc | 96 | ((FLEXCAN_ID_EXT(id) & 0x1FE00000) << 3) /*!< Extend Rx FIFO Mask helper macro Type C upper part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 97 | #define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_MID_HIGH(id) \ |
AnnaBridge | 171:3a7713b1edbc | 98 | ((FLEXCAN_ID_EXT(id) & 0x1FE00000) >> \ |
AnnaBridge | 171:3a7713b1edbc | 99 | 5) /*!< Extend Rx FIFO Mask helper macro Type C mid-upper part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 100 | #define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_MID_LOW(id) \ |
AnnaBridge | 171:3a7713b1edbc | 101 | ((FLEXCAN_ID_EXT(id) & 0x1FE00000) >> \ |
AnnaBridge | 171:3a7713b1edbc | 102 | 13) /*!< Extend Rx FIFO Mask helper macro Type C mid-lower part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 103 | #define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_LOW(id) \ |
AnnaBridge | 171:3a7713b1edbc | 104 | ((FLEXCAN_ID_EXT(id) & 0x1FE00000) >> 21) /*!< Extend Rx FIFO Mask helper macro Type C lower part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 105 | |
AnnaBridge | 171:3a7713b1edbc | 106 | /*! @brief FlexCAN Rx FIFO Filter helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 107 | #define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_A(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 108 | FLEXCAN_RX_FIFO_STD_MASK_TYPE_A(id, rtr, ide) /*!< Standard Rx FIFO Filter helper macro Type A helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 109 | #define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_B_HIGH(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 110 | FLEXCAN_RX_FIFO_STD_MASK_TYPE_B_HIGH( \ |
AnnaBridge | 171:3a7713b1edbc | 111 | id, rtr, ide) /*!< Standard Rx FIFO Filter helper macro Type B upper part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 112 | #define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_B_LOW(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 113 | FLEXCAN_RX_FIFO_STD_MASK_TYPE_B_LOW( \ |
AnnaBridge | 171:3a7713b1edbc | 114 | id, rtr, ide) /*!< Standard Rx FIFO Filter helper macro Type B lower part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 115 | #define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_C_HIGH(id) \ |
AnnaBridge | 171:3a7713b1edbc | 116 | FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_HIGH( \ |
AnnaBridge | 171:3a7713b1edbc | 117 | id) /*!< Standard Rx FIFO Filter helper macro Type C upper part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 118 | #define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_C_MID_HIGH(id) \ |
AnnaBridge | 171:3a7713b1edbc | 119 | FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_MID_HIGH( \ |
AnnaBridge | 171:3a7713b1edbc | 120 | id) /*!< Standard Rx FIFO Filter helper macro Type C mid-upper part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 121 | #define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_C_MID_LOW(id) \ |
AnnaBridge | 171:3a7713b1edbc | 122 | FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_MID_LOW( \ |
AnnaBridge | 171:3a7713b1edbc | 123 | id) /*!< Standard Rx FIFO Filter helper macro Type C mid-lower part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 124 | #define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_C_LOW(id) \ |
AnnaBridge | 171:3a7713b1edbc | 125 | FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_LOW(id) /*!< Standard Rx FIFO Filter helper macro Type C lower part helper macro. \ |
AnnaBridge | 171:3a7713b1edbc | 126 | */ |
AnnaBridge | 171:3a7713b1edbc | 127 | #define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_A(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 128 | FLEXCAN_RX_FIFO_EXT_MASK_TYPE_A(id, rtr, ide) /*!< Extend Rx FIFO Filter helper macro Type A helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 129 | #define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_B_HIGH(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 130 | FLEXCAN_RX_FIFO_EXT_MASK_TYPE_B_HIGH( \ |
AnnaBridge | 171:3a7713b1edbc | 131 | id, rtr, ide) /*!< Extend Rx FIFO Filter helper macro Type B upper part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 132 | #define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_B_LOW(id, rtr, ide) \ |
AnnaBridge | 171:3a7713b1edbc | 133 | FLEXCAN_RX_FIFO_EXT_MASK_TYPE_B_LOW( \ |
AnnaBridge | 171:3a7713b1edbc | 134 | id, rtr, ide) /*!< Extend Rx FIFO Filter helper macro Type B lower part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 135 | #define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_C_HIGH(id) \ |
AnnaBridge | 171:3a7713b1edbc | 136 | FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_HIGH(id) /*!< Extend Rx FIFO Filter helper macro Type C upper part helper macro. \ |
AnnaBridge | 171:3a7713b1edbc | 137 | */ |
AnnaBridge | 171:3a7713b1edbc | 138 | #define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_C_MID_HIGH(id) \ |
AnnaBridge | 171:3a7713b1edbc | 139 | FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_MID_HIGH( \ |
AnnaBridge | 171:3a7713b1edbc | 140 | id) /*!< Extend Rx FIFO Filter helper macro Type C mid-upper part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 141 | #define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_C_MID_LOW(id) \ |
AnnaBridge | 171:3a7713b1edbc | 142 | FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_MID_LOW( \ |
AnnaBridge | 171:3a7713b1edbc | 143 | id) /*!< Extend Rx FIFO Filter helper macro Type C mid-lower part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 144 | #define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_C_LOW(id) \ |
AnnaBridge | 171:3a7713b1edbc | 145 | FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_LOW(id) /*!< Extend Rx FIFO Filter helper macro Type C lower part helper macro. */ |
AnnaBridge | 171:3a7713b1edbc | 146 | |
AnnaBridge | 171:3a7713b1edbc | 147 | /*! @brief FlexCAN transfer status. */ |
AnnaBridge | 171:3a7713b1edbc | 148 | enum _flexcan_status |
AnnaBridge | 171:3a7713b1edbc | 149 | { |
AnnaBridge | 171:3a7713b1edbc | 150 | kStatus_FLEXCAN_TxBusy = MAKE_STATUS(kStatusGroup_FLEXCAN, 0), /*!< Tx Message Buffer is Busy. */ |
AnnaBridge | 171:3a7713b1edbc | 151 | kStatus_FLEXCAN_TxIdle = MAKE_STATUS(kStatusGroup_FLEXCAN, 1), /*!< Tx Message Buffer is Idle. */ |
AnnaBridge | 171:3a7713b1edbc | 152 | kStatus_FLEXCAN_TxSwitchToRx = MAKE_STATUS( |
AnnaBridge | 171:3a7713b1edbc | 153 | kStatusGroup_FLEXCAN, 2), /*!< Remote Message is send out and Message buffer changed to Receive one. */ |
AnnaBridge | 171:3a7713b1edbc | 154 | kStatus_FLEXCAN_RxBusy = MAKE_STATUS(kStatusGroup_FLEXCAN, 3), /*!< Rx Message Buffer is Busy. */ |
AnnaBridge | 171:3a7713b1edbc | 155 | kStatus_FLEXCAN_RxIdle = MAKE_STATUS(kStatusGroup_FLEXCAN, 4), /*!< Rx Message Buffer is Idle. */ |
AnnaBridge | 171:3a7713b1edbc | 156 | kStatus_FLEXCAN_RxOverflow = MAKE_STATUS(kStatusGroup_FLEXCAN, 5), /*!< Rx Message Buffer is Overflowed. */ |
AnnaBridge | 171:3a7713b1edbc | 157 | kStatus_FLEXCAN_RxFifoBusy = MAKE_STATUS(kStatusGroup_FLEXCAN, 6), /*!< Rx Message FIFO is Busy. */ |
AnnaBridge | 171:3a7713b1edbc | 158 | kStatus_FLEXCAN_RxFifoIdle = MAKE_STATUS(kStatusGroup_FLEXCAN, 7), /*!< Rx Message FIFO is Idle. */ |
AnnaBridge | 171:3a7713b1edbc | 159 | kStatus_FLEXCAN_RxFifoOverflow = MAKE_STATUS(kStatusGroup_FLEXCAN, 8), /*!< Rx Message FIFO is overflowed. */ |
AnnaBridge | 171:3a7713b1edbc | 160 | kStatus_FLEXCAN_RxFifoWarning = MAKE_STATUS(kStatusGroup_FLEXCAN, 0), /*!< Rx Message FIFO is almost overflowed. */ |
AnnaBridge | 171:3a7713b1edbc | 161 | kStatus_FLEXCAN_ErrorStatus = MAKE_STATUS(kStatusGroup_FLEXCAN, 10), /*!< FlexCAN Module Error and Status. */ |
AnnaBridge | 171:3a7713b1edbc | 162 | kStatus_FLEXCAN_UnHandled = MAKE_STATUS(kStatusGroup_FLEXCAN, 11), /*!< UnHadled Interrupt asserted. */ |
AnnaBridge | 171:3a7713b1edbc | 163 | }; |
AnnaBridge | 171:3a7713b1edbc | 164 | |
AnnaBridge | 171:3a7713b1edbc | 165 | /*! @brief FlexCAN frame format. */ |
AnnaBridge | 171:3a7713b1edbc | 166 | typedef enum _flexcan_frame_format |
AnnaBridge | 171:3a7713b1edbc | 167 | { |
AnnaBridge | 171:3a7713b1edbc | 168 | kFLEXCAN_FrameFormatStandard = 0x0U, /*!< Standard frame format attribute. */ |
AnnaBridge | 171:3a7713b1edbc | 169 | kFLEXCAN_FrameFormatExtend = 0x1U, /*!< Extend frame format attribute. */ |
AnnaBridge | 171:3a7713b1edbc | 170 | } flexcan_frame_format_t; |
AnnaBridge | 171:3a7713b1edbc | 171 | |
AnnaBridge | 171:3a7713b1edbc | 172 | /*! @brief FlexCAN frame type. */ |
AnnaBridge | 171:3a7713b1edbc | 173 | typedef enum _flexcan_frame_type |
AnnaBridge | 171:3a7713b1edbc | 174 | { |
AnnaBridge | 171:3a7713b1edbc | 175 | kFLEXCAN_FrameTypeData = 0x0U, /*!< Data frame type attribute. */ |
AnnaBridge | 171:3a7713b1edbc | 176 | kFLEXCAN_FrameTypeRemote = 0x1U, /*!< Remote frame type attribute. */ |
AnnaBridge | 171:3a7713b1edbc | 177 | } flexcan_frame_type_t; |
AnnaBridge | 171:3a7713b1edbc | 178 | |
AnnaBridge | 171:3a7713b1edbc | 179 | /*! @brief FlexCAN clock source. */ |
AnnaBridge | 171:3a7713b1edbc | 180 | typedef enum _flexcan_clock_source |
AnnaBridge | 171:3a7713b1edbc | 181 | { |
AnnaBridge | 171:3a7713b1edbc | 182 | kFLEXCAN_ClkSrcOsc = 0x0U, /*!< FlexCAN Protocol Engine clock from Oscillator. */ |
AnnaBridge | 171:3a7713b1edbc | 183 | kFLEXCAN_ClkSrcPeri = 0x1U, /*!< FlexCAN Protocol Engine clock from Peripheral Clock. */ |
AnnaBridge | 171:3a7713b1edbc | 184 | } flexcan_clock_source_t; |
AnnaBridge | 171:3a7713b1edbc | 185 | |
AnnaBridge | 171:3a7713b1edbc | 186 | /*! @brief FlexCAN Rx Fifo Filter type. */ |
AnnaBridge | 171:3a7713b1edbc | 187 | typedef enum _flexcan_rx_fifo_filter_type |
AnnaBridge | 171:3a7713b1edbc | 188 | { |
AnnaBridge | 171:3a7713b1edbc | 189 | kFLEXCAN_RxFifoFilterTypeA = 0x0U, /*!< One full ID (standard and extended) per ID Filter element. */ |
AnnaBridge | 171:3a7713b1edbc | 190 | kFLEXCAN_RxFifoFilterTypeB = |
AnnaBridge | 171:3a7713b1edbc | 191 | 0x1U, /*!< Two full standard IDs or two partial 14-bit ID slices per ID Filter Table element. */ |
AnnaBridge | 171:3a7713b1edbc | 192 | kFLEXCAN_RxFifoFilterTypeC = |
AnnaBridge | 171:3a7713b1edbc | 193 | 0x2U, /*!< Four partial 8-bit Standard or extended ID slices per ID Filter Table element. */ |
AnnaBridge | 171:3a7713b1edbc | 194 | kFLEXCAN_RxFifoFilterTypeD = 0x3U, /*!< All frames rejected. */ |
AnnaBridge | 171:3a7713b1edbc | 195 | } flexcan_rx_fifo_filter_type_t; |
AnnaBridge | 171:3a7713b1edbc | 196 | |
AnnaBridge | 171:3a7713b1edbc | 197 | /*! |
AnnaBridge | 171:3a7713b1edbc | 198 | * @brief FlexCAN Rx FIFO priority. |
AnnaBridge | 171:3a7713b1edbc | 199 | * |
AnnaBridge | 171:3a7713b1edbc | 200 | * The matching process starts from the Rx MB(or Rx FIFO) with higher priority. |
AnnaBridge | 171:3a7713b1edbc | 201 | * If no MB(or Rx FIFO filter) is satisfied, the matching process goes on with |
AnnaBridge | 171:3a7713b1edbc | 202 | * the Rx FIFO(or Rx MB) with lower priority. |
AnnaBridge | 171:3a7713b1edbc | 203 | */ |
AnnaBridge | 171:3a7713b1edbc | 204 | typedef enum _flexcan_rx_fifo_priority |
AnnaBridge | 171:3a7713b1edbc | 205 | { |
AnnaBridge | 171:3a7713b1edbc | 206 | kFLEXCAN_RxFifoPrioLow = 0x0U, /*!< Matching process start from Rx Message Buffer first*/ |
AnnaBridge | 171:3a7713b1edbc | 207 | kFLEXCAN_RxFifoPrioHigh = 0x1U, /*!< Matching process start from Rx FIFO first*/ |
AnnaBridge | 171:3a7713b1edbc | 208 | } flexcan_rx_fifo_priority_t; |
AnnaBridge | 171:3a7713b1edbc | 209 | |
AnnaBridge | 171:3a7713b1edbc | 210 | /*! |
AnnaBridge | 171:3a7713b1edbc | 211 | * @brief FlexCAN interrupt configuration structure, default settings all disabled. |
AnnaBridge | 171:3a7713b1edbc | 212 | * |
AnnaBridge | 171:3a7713b1edbc | 213 | * This structure contains the settings for all of the FlexCAN Module interrupt configurations. |
AnnaBridge | 171:3a7713b1edbc | 214 | * Note: FlexCAN Message Buffers and Rx FIFO have their own interrupts. |
AnnaBridge | 171:3a7713b1edbc | 215 | */ |
AnnaBridge | 171:3a7713b1edbc | 216 | enum _flexcan_interrupt_enable |
AnnaBridge | 171:3a7713b1edbc | 217 | { |
AnnaBridge | 171:3a7713b1edbc | 218 | kFLEXCAN_BusOffInterruptEnable = CAN_CTRL1_BOFFMSK_MASK, /*!< Bus Off interrupt. */ |
AnnaBridge | 171:3a7713b1edbc | 219 | kFLEXCAN_ErrorInterruptEnable = CAN_CTRL1_ERRMSK_MASK, /*!< Error interrupt. */ |
AnnaBridge | 171:3a7713b1edbc | 220 | kFLEXCAN_RxWarningInterruptEnable = CAN_CTRL1_RWRNMSK_MASK, /*!< Rx Warning interrupt. */ |
AnnaBridge | 171:3a7713b1edbc | 221 | kFLEXCAN_TxWarningInterruptEnable = CAN_CTRL1_TWRNMSK_MASK, /*!< Tx Warning interrupt. */ |
AnnaBridge | 171:3a7713b1edbc | 222 | kFLEXCAN_WakeUpInterruptEnable = CAN_MCR_WAKMSK_MASK, /*!< Wake Up interrupt. */ |
AnnaBridge | 171:3a7713b1edbc | 223 | }; |
AnnaBridge | 171:3a7713b1edbc | 224 | |
AnnaBridge | 171:3a7713b1edbc | 225 | /*! |
AnnaBridge | 171:3a7713b1edbc | 226 | * @brief FlexCAN status flags. |
AnnaBridge | 171:3a7713b1edbc | 227 | * |
AnnaBridge | 171:3a7713b1edbc | 228 | * This provides constants for the FlexCAN status flags for use in the FlexCAN functions. |
AnnaBridge | 171:3a7713b1edbc | 229 | * Note: The CPU read action clears FlEXCAN_ErrorFlag, therefore user need to |
AnnaBridge | 171:3a7713b1edbc | 230 | * read FlEXCAN_ErrorFlag and distinguish which error is occur using |
AnnaBridge | 171:3a7713b1edbc | 231 | * @ref _flexcan_error_flags enumerations. |
AnnaBridge | 171:3a7713b1edbc | 232 | */ |
AnnaBridge | 171:3a7713b1edbc | 233 | enum _flexcan_flags |
AnnaBridge | 171:3a7713b1edbc | 234 | { |
AnnaBridge | 171:3a7713b1edbc | 235 | kFLEXCAN_SynchFlag = CAN_ESR1_SYNCH_MASK, /*!< CAN Synchronization Status. */ |
AnnaBridge | 171:3a7713b1edbc | 236 | kFLEXCAN_TxWarningIntFlag = CAN_ESR1_TWRNINT_MASK, /*!< Tx Warning Interrupt Flag. */ |
AnnaBridge | 171:3a7713b1edbc | 237 | kFLEXCAN_RxWarningIntFlag = CAN_ESR1_RWRNINT_MASK, /*!< Rx Warning Interrupt Flag. */ |
AnnaBridge | 171:3a7713b1edbc | 238 | kFLEXCAN_TxErrorWarningFlag = CAN_ESR1_TXWRN_MASK, /*!< Tx Error Warning Status. */ |
AnnaBridge | 171:3a7713b1edbc | 239 | kFLEXCAN_RxErrorWarningFlag = CAN_ESR1_RXWRN_MASK, /*!< Rx Error Warning Status. */ |
AnnaBridge | 171:3a7713b1edbc | 240 | kFLEXCAN_IdleFlag = CAN_ESR1_IDLE_MASK, /*!< CAN IDLE Status Flag. */ |
AnnaBridge | 171:3a7713b1edbc | 241 | kFLEXCAN_FaultConfinementFlag = CAN_ESR1_FLTCONF_MASK, /*!< Fault Confinement State Flag. */ |
AnnaBridge | 171:3a7713b1edbc | 242 | kFLEXCAN_TransmittingFlag = CAN_ESR1_TX_MASK, /*!< FlexCAN In Transmission Status. */ |
AnnaBridge | 171:3a7713b1edbc | 243 | kFLEXCAN_ReceivingFlag = CAN_ESR1_RX_MASK, /*!< FlexCAN In Reception Status. */ |
AnnaBridge | 171:3a7713b1edbc | 244 | kFLEXCAN_BusOffIntFlag = CAN_ESR1_BOFFINT_MASK, /*!< Bus Off Interrupt Flag. */ |
AnnaBridge | 171:3a7713b1edbc | 245 | kFLEXCAN_ErrorIntFlag = CAN_ESR1_ERRINT_MASK, /*!< Error Interrupt Flag. */ |
AnnaBridge | 171:3a7713b1edbc | 246 | kFLEXCAN_WakeUpIntFlag = CAN_ESR1_WAKINT_MASK, /*!< Wake-Up Interrupt Flag. */ |
AnnaBridge | 171:3a7713b1edbc | 247 | kFLEXCAN_ErrorFlag = CAN_ESR1_BIT1ERR_MASK | /*!< All FlexCAN Error Status. */ |
AnnaBridge | 171:3a7713b1edbc | 248 | CAN_ESR1_BIT0ERR_MASK | |
AnnaBridge | 171:3a7713b1edbc | 249 | CAN_ESR1_ACKERR_MASK | CAN_ESR1_CRCERR_MASK | CAN_ESR1_FRMERR_MASK | CAN_ESR1_STFERR_MASK, |
AnnaBridge | 171:3a7713b1edbc | 250 | }; |
AnnaBridge | 171:3a7713b1edbc | 251 | |
AnnaBridge | 171:3a7713b1edbc | 252 | /*! |
AnnaBridge | 171:3a7713b1edbc | 253 | * @brief FlexCAN error status flags. |
AnnaBridge | 171:3a7713b1edbc | 254 | * |
AnnaBridge | 171:3a7713b1edbc | 255 | * The FlexCAN Error Status enumerations is used to report current error of the FlexCAN bus. |
AnnaBridge | 171:3a7713b1edbc | 256 | * This enumerations should be used with KFLEXCAN_ErrorFlag in @ref _flexcan_flags enumerations |
AnnaBridge | 171:3a7713b1edbc | 257 | * to ditermine which error is generated. |
AnnaBridge | 171:3a7713b1edbc | 258 | */ |
AnnaBridge | 171:3a7713b1edbc | 259 | enum _flexcan_error_flags |
AnnaBridge | 171:3a7713b1edbc | 260 | { |
AnnaBridge | 171:3a7713b1edbc | 261 | kFLEXCAN_StuffingError = CAN_ESR1_STFERR_MASK, /*!< Stuffing Error. */ |
AnnaBridge | 171:3a7713b1edbc | 262 | kFLEXCAN_FormError = CAN_ESR1_FRMERR_MASK, /*!< Form Error. */ |
AnnaBridge | 171:3a7713b1edbc | 263 | kFLEXCAN_CrcError = CAN_ESR1_CRCERR_MASK, /*!< Cyclic Redundancy Check Error. */ |
AnnaBridge | 171:3a7713b1edbc | 264 | kFLEXCAN_AckError = CAN_ESR1_ACKERR_MASK, /*!< Received no ACK on transmission. */ |
AnnaBridge | 171:3a7713b1edbc | 265 | kFLEXCAN_Bit0Error = CAN_ESR1_BIT0ERR_MASK, /*!< Unable to send dominant bit. */ |
AnnaBridge | 171:3a7713b1edbc | 266 | kFLEXCAN_Bit1Error = CAN_ESR1_BIT1ERR_MASK, /*!< Unable to send recessive bit. */ |
AnnaBridge | 171:3a7713b1edbc | 267 | }; |
AnnaBridge | 171:3a7713b1edbc | 268 | |
AnnaBridge | 171:3a7713b1edbc | 269 | /*! |
AnnaBridge | 171:3a7713b1edbc | 270 | * @brief FlexCAN Rx FIFO status flags. |
AnnaBridge | 171:3a7713b1edbc | 271 | * |
AnnaBridge | 171:3a7713b1edbc | 272 | * The FlexCAN Rx FIFO Status enumerations are used to determine the status of the |
AnnaBridge | 171:3a7713b1edbc | 273 | * Rx FIFO. Because Rx FIFO occupy the MB0 ~ MB7 (Rx Fifo filter also occupies |
AnnaBridge | 171:3a7713b1edbc | 274 | * more Message Buffer space), Rx FIFO status flags are mapped to the corresponding |
AnnaBridge | 171:3a7713b1edbc | 275 | * Message Buffer status flags. |
AnnaBridge | 171:3a7713b1edbc | 276 | */ |
AnnaBridge | 171:3a7713b1edbc | 277 | enum _flexcan_rx_fifo_flags |
AnnaBridge | 171:3a7713b1edbc | 278 | { |
AnnaBridge | 171:3a7713b1edbc | 279 | kFLEXCAN_RxFifoOverflowFlag = CAN_IFLAG1_BUF7I_MASK, /*!< Rx FIFO overflow flag. */ |
AnnaBridge | 171:3a7713b1edbc | 280 | kFLEXCAN_RxFifoWarningFlag = CAN_IFLAG1_BUF6I_MASK, /*!< Rx FIFO almost full flag. */ |
AnnaBridge | 171:3a7713b1edbc | 281 | kFLEXCAN_RxFifoFrameAvlFlag = CAN_IFLAG1_BUF5I_MASK, /*!< Frames available in Rx FIFO flag. */ |
AnnaBridge | 171:3a7713b1edbc | 282 | }; |
AnnaBridge | 171:3a7713b1edbc | 283 | |
AnnaBridge | 171:3a7713b1edbc | 284 | #if defined(__CC_ARM) |
AnnaBridge | 171:3a7713b1edbc | 285 | #pragma anon_unions |
AnnaBridge | 171:3a7713b1edbc | 286 | #endif |
AnnaBridge | 171:3a7713b1edbc | 287 | /*! @brief FlexCAN message frame structure. */ |
AnnaBridge | 171:3a7713b1edbc | 288 | typedef struct _flexcan_frame |
AnnaBridge | 171:3a7713b1edbc | 289 | { |
AnnaBridge | 171:3a7713b1edbc | 290 | struct |
AnnaBridge | 171:3a7713b1edbc | 291 | { |
AnnaBridge | 171:3a7713b1edbc | 292 | uint32_t timestamp : 16; /*!< FlexCAN internal Free-Running Counter Time Stamp. */ |
AnnaBridge | 171:3a7713b1edbc | 293 | uint32_t length : 4; /*!< CAN frame payload length in bytes(Range: 0~8). */ |
AnnaBridge | 171:3a7713b1edbc | 294 | uint32_t type : 1; /*!< CAN Frame Type(DATA or REMOTE). */ |
AnnaBridge | 171:3a7713b1edbc | 295 | uint32_t format : 1; /*!< CAN Frame Identifier(STD or EXT format). */ |
AnnaBridge | 171:3a7713b1edbc | 296 | uint32_t : 1; /*!< Reserved. */ |
AnnaBridge | 171:3a7713b1edbc | 297 | uint32_t idhit : 9; /*!< CAN Rx FIFO filter hit id(This value is only used in Rx FIFO receive mode). */ |
AnnaBridge | 171:3a7713b1edbc | 298 | }; |
AnnaBridge | 171:3a7713b1edbc | 299 | struct |
AnnaBridge | 171:3a7713b1edbc | 300 | { |
AnnaBridge | 171:3a7713b1edbc | 301 | uint32_t id : 29; /*!< CAN Frame Identifier, should be set using FLEXCAN_ID_EXT() or FLEXCAN_ID_STD() macro. */ |
AnnaBridge | 171:3a7713b1edbc | 302 | uint32_t : 3; /*!< Reserved. */ |
AnnaBridge | 171:3a7713b1edbc | 303 | }; |
AnnaBridge | 171:3a7713b1edbc | 304 | union |
AnnaBridge | 171:3a7713b1edbc | 305 | { |
AnnaBridge | 171:3a7713b1edbc | 306 | struct |
AnnaBridge | 171:3a7713b1edbc | 307 | { |
AnnaBridge | 171:3a7713b1edbc | 308 | uint32_t dataWord0; /*!< CAN Frame payload word0. */ |
AnnaBridge | 171:3a7713b1edbc | 309 | uint32_t dataWord1; /*!< CAN Frame payload word1. */ |
AnnaBridge | 171:3a7713b1edbc | 310 | }; |
AnnaBridge | 171:3a7713b1edbc | 311 | struct |
AnnaBridge | 171:3a7713b1edbc | 312 | { |
AnnaBridge | 171:3a7713b1edbc | 313 | uint8_t dataByte3; /*!< CAN Frame payload byte3. */ |
AnnaBridge | 171:3a7713b1edbc | 314 | uint8_t dataByte2; /*!< CAN Frame payload byte2. */ |
AnnaBridge | 171:3a7713b1edbc | 315 | uint8_t dataByte1; /*!< CAN Frame payload byte1. */ |
AnnaBridge | 171:3a7713b1edbc | 316 | uint8_t dataByte0; /*!< CAN Frame payload byte0. */ |
AnnaBridge | 171:3a7713b1edbc | 317 | uint8_t dataByte7; /*!< CAN Frame payload byte7. */ |
AnnaBridge | 171:3a7713b1edbc | 318 | uint8_t dataByte6; /*!< CAN Frame payload byte6. */ |
AnnaBridge | 171:3a7713b1edbc | 319 | uint8_t dataByte5; /*!< CAN Frame payload byte5. */ |
AnnaBridge | 171:3a7713b1edbc | 320 | uint8_t dataByte4; /*!< CAN Frame payload byte4. */ |
AnnaBridge | 171:3a7713b1edbc | 321 | }; |
AnnaBridge | 171:3a7713b1edbc | 322 | }; |
AnnaBridge | 171:3a7713b1edbc | 323 | } flexcan_frame_t; |
AnnaBridge | 171:3a7713b1edbc | 324 | |
AnnaBridge | 171:3a7713b1edbc | 325 | /*! @brief FlexCAN module configuration structure. */ |
AnnaBridge | 171:3a7713b1edbc | 326 | typedef struct _flexcan_config |
AnnaBridge | 171:3a7713b1edbc | 327 | { |
AnnaBridge | 171:3a7713b1edbc | 328 | uint32_t baudRate; /*!< FlexCAN baud rate in bps. */ |
AnnaBridge | 171:3a7713b1edbc | 329 | flexcan_clock_source_t clkSrc; /*!< Clock source for FlexCAN Protocol Engine. */ |
AnnaBridge | 171:3a7713b1edbc | 330 | uint8_t maxMbNum; /*!< The maximum number of Message Buffers used by user. */ |
AnnaBridge | 171:3a7713b1edbc | 331 | bool enableLoopBack; /*!< Enable or Disable Loop Back Self Test Mode. */ |
AnnaBridge | 171:3a7713b1edbc | 332 | bool enableSelfWakeup; /*!< Enable or Disable Self Wakeup Mode. */ |
AnnaBridge | 171:3a7713b1edbc | 333 | bool enableIndividMask; /*!< Enable or Disable Rx Individual Mask. */ |
AnnaBridge | 171:3a7713b1edbc | 334 | #if (defined(FSL_FEATURE_FLEXCAN_HAS_DOZE_MODE_SUPPORT) && FSL_FEATURE_FLEXCAN_HAS_DOZE_MODE_SUPPORT) |
AnnaBridge | 171:3a7713b1edbc | 335 | bool enableDoze; /*!< Enable or Disable Doze Mode. */ |
AnnaBridge | 171:3a7713b1edbc | 336 | #endif |
AnnaBridge | 171:3a7713b1edbc | 337 | } flexcan_config_t; |
AnnaBridge | 171:3a7713b1edbc | 338 | |
AnnaBridge | 171:3a7713b1edbc | 339 | /*! @brief FlexCAN protocol timing characteristic configuration structure. */ |
AnnaBridge | 171:3a7713b1edbc | 340 | typedef struct _flexcan_timing_config |
AnnaBridge | 171:3a7713b1edbc | 341 | { |
AnnaBridge | 171:3a7713b1edbc | 342 | uint8_t preDivider; /*!< Clock Pre-scaler Division Factor. */ |
AnnaBridge | 171:3a7713b1edbc | 343 | uint8_t rJumpwidth; /*!< Re-sync Jump Width. */ |
AnnaBridge | 171:3a7713b1edbc | 344 | uint8_t phaseSeg1; /*!< Phase Segment 1. */ |
AnnaBridge | 171:3a7713b1edbc | 345 | uint8_t phaseSeg2; /*!< Phase Segment 2. */ |
AnnaBridge | 171:3a7713b1edbc | 346 | uint8_t propSeg; /*!< Propagation Segment. */ |
AnnaBridge | 171:3a7713b1edbc | 347 | } flexcan_timing_config_t; |
AnnaBridge | 171:3a7713b1edbc | 348 | |
AnnaBridge | 171:3a7713b1edbc | 349 | /*! |
AnnaBridge | 171:3a7713b1edbc | 350 | * @brief FlexCAN Receive Message Buffer configuration structure |
AnnaBridge | 171:3a7713b1edbc | 351 | * |
AnnaBridge | 171:3a7713b1edbc | 352 | * This structure is used as the parameter of FLEXCAN_SetRxMbConfig() function. |
AnnaBridge | 171:3a7713b1edbc | 353 | * The FLEXCAN_SetRxMbConfig() function is used to configure FlexCAN Receive |
AnnaBridge | 171:3a7713b1edbc | 354 | * Message Buffer. The function abort previous receiving process, clean the |
AnnaBridge | 171:3a7713b1edbc | 355 | * Message Buffer and activate the Rx Message Buffer using given Message Buffer |
AnnaBridge | 171:3a7713b1edbc | 356 | * setting. |
AnnaBridge | 171:3a7713b1edbc | 357 | */ |
AnnaBridge | 171:3a7713b1edbc | 358 | typedef struct _flexcan_rx_mb_config |
AnnaBridge | 171:3a7713b1edbc | 359 | { |
AnnaBridge | 171:3a7713b1edbc | 360 | uint32_t id; /*!< CAN Message Buffer Frame Identifier, should be set using |
AnnaBridge | 171:3a7713b1edbc | 361 | FLEXCAN_ID_EXT() or FLEXCAN_ID_STD() macro. */ |
AnnaBridge | 171:3a7713b1edbc | 362 | flexcan_frame_format_t format; /*!< CAN Frame Identifier format(Standard of Extend). */ |
AnnaBridge | 171:3a7713b1edbc | 363 | flexcan_frame_type_t type; /*!< CAN Frame Type(Data or Remote). */ |
AnnaBridge | 171:3a7713b1edbc | 364 | } flexcan_rx_mb_config_t; |
AnnaBridge | 171:3a7713b1edbc | 365 | |
AnnaBridge | 171:3a7713b1edbc | 366 | /*! @brief FlexCAN Rx FIFO configuration structure. */ |
AnnaBridge | 171:3a7713b1edbc | 367 | typedef struct _flexcan_rx_fifo_config |
AnnaBridge | 171:3a7713b1edbc | 368 | { |
AnnaBridge | 171:3a7713b1edbc | 369 | uint32_t *idFilterTable; /*!< Pointer to the FlexCAN Rx FIFO identifier filter table. */ |
AnnaBridge | 171:3a7713b1edbc | 370 | uint8_t idFilterNum; /*!< The quantity of filter elements. */ |
AnnaBridge | 171:3a7713b1edbc | 371 | flexcan_rx_fifo_filter_type_t idFilterType; /*!< The FlexCAN Rx FIFO Filter type. */ |
AnnaBridge | 171:3a7713b1edbc | 372 | flexcan_rx_fifo_priority_t priority; /*!< The FlexCAN Rx FIFO receive priority. */ |
AnnaBridge | 171:3a7713b1edbc | 373 | } flexcan_rx_fifo_config_t; |
AnnaBridge | 171:3a7713b1edbc | 374 | |
AnnaBridge | 171:3a7713b1edbc | 375 | /*! @brief FlexCAN Message Buffer transfer. */ |
AnnaBridge | 171:3a7713b1edbc | 376 | typedef struct _flexcan_mb_transfer |
AnnaBridge | 171:3a7713b1edbc | 377 | { |
AnnaBridge | 171:3a7713b1edbc | 378 | flexcan_frame_t *frame; /*!< The buffer of CAN Message to be transfer. */ |
AnnaBridge | 171:3a7713b1edbc | 379 | uint8_t mbIdx; /*!< The index of Message buffer used to transfer Message. */ |
AnnaBridge | 171:3a7713b1edbc | 380 | } flexcan_mb_transfer_t; |
AnnaBridge | 171:3a7713b1edbc | 381 | |
AnnaBridge | 171:3a7713b1edbc | 382 | /*! @brief FlexCAN Rx FIFO transfer. */ |
AnnaBridge | 171:3a7713b1edbc | 383 | typedef struct _flexcan_fifo_transfer |
AnnaBridge | 171:3a7713b1edbc | 384 | { |
AnnaBridge | 171:3a7713b1edbc | 385 | flexcan_frame_t *frame; /*!< The buffer of CAN Message to be received from Rx FIFO. */ |
AnnaBridge | 171:3a7713b1edbc | 386 | } flexcan_fifo_transfer_t; |
AnnaBridge | 171:3a7713b1edbc | 387 | |
AnnaBridge | 171:3a7713b1edbc | 388 | /*! @brief FlexCAN handle structure definition. */ |
AnnaBridge | 171:3a7713b1edbc | 389 | typedef struct _flexcan_handle flexcan_handle_t; |
AnnaBridge | 171:3a7713b1edbc | 390 | |
AnnaBridge | 171:3a7713b1edbc | 391 | /*! @brief FlexCAN transfer callback function. |
AnnaBridge | 171:3a7713b1edbc | 392 | * |
AnnaBridge | 171:3a7713b1edbc | 393 | * The FlexCAN transfer callback returns a value from the underlying layer. |
AnnaBridge | 171:3a7713b1edbc | 394 | * If the status equals to kStatus_FLEXCAN_ErrorStatus, the result parameter is the Content of |
AnnaBridge | 171:3a7713b1edbc | 395 | * FlexCAN status register which can be used to get the working status(or error status) of FlexCAN module. |
AnnaBridge | 171:3a7713b1edbc | 396 | * If the status equals to other FlexCAN Message Buffer transfer status, the result is the index of |
AnnaBridge | 171:3a7713b1edbc | 397 | * Message Buffer that generate transfer event. |
AnnaBridge | 171:3a7713b1edbc | 398 | * If the status equals to other FlexCAN Message Buffer transfer status, the result is meaningless and should be |
AnnaBridge | 171:3a7713b1edbc | 399 | * Ignored. |
AnnaBridge | 171:3a7713b1edbc | 400 | */ |
AnnaBridge | 171:3a7713b1edbc | 401 | typedef void (*flexcan_transfer_callback_t)( |
AnnaBridge | 171:3a7713b1edbc | 402 | CAN_Type *base, flexcan_handle_t *handle, status_t status, uint32_t result, void *userData); |
AnnaBridge | 171:3a7713b1edbc | 403 | |
AnnaBridge | 171:3a7713b1edbc | 404 | /*! @brief FlexCAN handle structure. */ |
AnnaBridge | 171:3a7713b1edbc | 405 | struct _flexcan_handle |
AnnaBridge | 171:3a7713b1edbc | 406 | { |
AnnaBridge | 171:3a7713b1edbc | 407 | flexcan_transfer_callback_t callback; /*!< Callback function. */ |
AnnaBridge | 171:3a7713b1edbc | 408 | void *userData; /*!< FlexCAN callback function parameter.*/ |
AnnaBridge | 171:3a7713b1edbc | 409 | flexcan_frame_t *volatile mbFrameBuf[CAN_WORD1_COUNT]; |
AnnaBridge | 171:3a7713b1edbc | 410 | /*!< The buffer for received data from Message Buffers. */ |
AnnaBridge | 171:3a7713b1edbc | 411 | flexcan_frame_t *volatile rxFifoFrameBuf; /*!< The buffer for received data from Rx FIFO. */ |
AnnaBridge | 171:3a7713b1edbc | 412 | volatile uint8_t mbState[CAN_WORD1_COUNT]; /*!< Message Buffer transfer state. */ |
AnnaBridge | 171:3a7713b1edbc | 413 | volatile uint8_t rxFifoState; /*!< Rx FIFO transfer state. */ |
AnnaBridge | 171:3a7713b1edbc | 414 | }; |
AnnaBridge | 171:3a7713b1edbc | 415 | |
AnnaBridge | 171:3a7713b1edbc | 416 | /****************************************************************************** |
AnnaBridge | 171:3a7713b1edbc | 417 | * API |
AnnaBridge | 171:3a7713b1edbc | 418 | *****************************************************************************/ |
AnnaBridge | 171:3a7713b1edbc | 419 | |
AnnaBridge | 171:3a7713b1edbc | 420 | #if defined(__cplusplus) |
AnnaBridge | 171:3a7713b1edbc | 421 | extern "C" { |
AnnaBridge | 171:3a7713b1edbc | 422 | #endif |
AnnaBridge | 171:3a7713b1edbc | 423 | |
AnnaBridge | 171:3a7713b1edbc | 424 | /*! |
AnnaBridge | 171:3a7713b1edbc | 425 | * @name Initialization and deinitialization |
AnnaBridge | 171:3a7713b1edbc | 426 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 427 | */ |
AnnaBridge | 171:3a7713b1edbc | 428 | |
AnnaBridge | 171:3a7713b1edbc | 429 | /*! |
AnnaBridge | 171:3a7713b1edbc | 430 | * @brief Initializes a FlexCAN instance. |
AnnaBridge | 171:3a7713b1edbc | 431 | * |
AnnaBridge | 171:3a7713b1edbc | 432 | * This function initializes the FlexCAN module with user-defined settings. |
AnnaBridge | 171:3a7713b1edbc | 433 | * This example shows how to set up the flexcan_config_t parameters and how |
AnnaBridge | 171:3a7713b1edbc | 434 | * to call the FLEXCAN_Init function by passing in these parameters. |
AnnaBridge | 171:3a7713b1edbc | 435 | * @code |
AnnaBridge | 171:3a7713b1edbc | 436 | * flexcan_config_t flexcanConfig; |
AnnaBridge | 171:3a7713b1edbc | 437 | * flexcanConfig.clkSrc = kFLEXCAN_ClkSrcOsc; |
AnnaBridge | 171:3a7713b1edbc | 438 | * flexcanConfig.baudRate = 125000U; |
AnnaBridge | 171:3a7713b1edbc | 439 | * flexcanConfig.maxMbNum = 16; |
AnnaBridge | 171:3a7713b1edbc | 440 | * flexcanConfig.enableLoopBack = false; |
AnnaBridge | 171:3a7713b1edbc | 441 | * flexcanConfig.enableSelfWakeup = false; |
AnnaBridge | 171:3a7713b1edbc | 442 | * flexcanConfig.enableIndividMask = false; |
AnnaBridge | 171:3a7713b1edbc | 443 | * flexcanConfig.enableDoze = false; |
AnnaBridge | 171:3a7713b1edbc | 444 | * FLEXCAN_Init(CAN0, &flexcanConfig, 8000000UL); |
AnnaBridge | 171:3a7713b1edbc | 445 | * @endcode |
AnnaBridge | 171:3a7713b1edbc | 446 | * |
AnnaBridge | 171:3a7713b1edbc | 447 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 448 | * @param config Pointer to the user-defined configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 449 | * @param sourceClock_Hz FlexCAN Protocol Engine clock source frequency in Hz. |
AnnaBridge | 171:3a7713b1edbc | 450 | */ |
AnnaBridge | 171:3a7713b1edbc | 451 | void FLEXCAN_Init(CAN_Type *base, const flexcan_config_t *config, uint32_t sourceClock_Hz); |
AnnaBridge | 171:3a7713b1edbc | 452 | |
AnnaBridge | 171:3a7713b1edbc | 453 | /*! |
AnnaBridge | 171:3a7713b1edbc | 454 | * @brief De-initializes a FlexCAN instance. |
AnnaBridge | 171:3a7713b1edbc | 455 | * |
AnnaBridge | 171:3a7713b1edbc | 456 | * This function disables the FlexCAN module clock and sets all register values |
AnnaBridge | 171:3a7713b1edbc | 457 | * to the reset value. |
AnnaBridge | 171:3a7713b1edbc | 458 | * |
AnnaBridge | 171:3a7713b1edbc | 459 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 460 | */ |
AnnaBridge | 171:3a7713b1edbc | 461 | void FLEXCAN_Deinit(CAN_Type *base); |
AnnaBridge | 171:3a7713b1edbc | 462 | |
AnnaBridge | 171:3a7713b1edbc | 463 | /*! |
AnnaBridge | 171:3a7713b1edbc | 464 | * @brief Gets the default configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 465 | * |
AnnaBridge | 171:3a7713b1edbc | 466 | * This function initializes the FlexCAN configuration structure to default values. The default |
AnnaBridge | 171:3a7713b1edbc | 467 | * values are as follows. |
AnnaBridge | 171:3a7713b1edbc | 468 | * flexcanConfig->clkSrc = KFLEXCAN_ClkSrcOsc; |
AnnaBridge | 171:3a7713b1edbc | 469 | * flexcanConfig->baudRate = 125000U; |
AnnaBridge | 171:3a7713b1edbc | 470 | * flexcanConfig->maxMbNum = 16; |
AnnaBridge | 171:3a7713b1edbc | 471 | * flexcanConfig->enableLoopBack = false; |
AnnaBridge | 171:3a7713b1edbc | 472 | * flexcanConfig->enableSelfWakeup = false; |
AnnaBridge | 171:3a7713b1edbc | 473 | * flexcanConfig->enableIndividMask = false; |
AnnaBridge | 171:3a7713b1edbc | 474 | * flexcanConfig->enableDoze = false; |
AnnaBridge | 171:3a7713b1edbc | 475 | * |
AnnaBridge | 171:3a7713b1edbc | 476 | * @param config Pointer to the FlexCAN configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 477 | */ |
AnnaBridge | 171:3a7713b1edbc | 478 | void FLEXCAN_GetDefaultConfig(flexcan_config_t *config); |
AnnaBridge | 171:3a7713b1edbc | 479 | |
AnnaBridge | 171:3a7713b1edbc | 480 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 481 | |
AnnaBridge | 171:3a7713b1edbc | 482 | /*! |
AnnaBridge | 171:3a7713b1edbc | 483 | * @name Configuration. |
AnnaBridge | 171:3a7713b1edbc | 484 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 485 | */ |
AnnaBridge | 171:3a7713b1edbc | 486 | |
AnnaBridge | 171:3a7713b1edbc | 487 | /*! |
AnnaBridge | 171:3a7713b1edbc | 488 | * @brief Sets the FlexCAN protocol timing characteristic. |
AnnaBridge | 171:3a7713b1edbc | 489 | * |
AnnaBridge | 171:3a7713b1edbc | 490 | * This function gives user settings to CAN bus timing characteristic. |
AnnaBridge | 171:3a7713b1edbc | 491 | * The function is for an experienced user. For less experienced users, call |
AnnaBridge | 171:3a7713b1edbc | 492 | * the FLEXCAN_Init() and fill the baud rate field with a desired value. |
AnnaBridge | 171:3a7713b1edbc | 493 | * This provides the default timing characteristics to the module. |
AnnaBridge | 171:3a7713b1edbc | 494 | * |
AnnaBridge | 171:3a7713b1edbc | 495 | * Note that calling FLEXCAN_SetTimingConfig() overrides the baud rate set |
AnnaBridge | 171:3a7713b1edbc | 496 | * in FLEXCAN_Init(). |
AnnaBridge | 171:3a7713b1edbc | 497 | * |
AnnaBridge | 171:3a7713b1edbc | 498 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 499 | * @param config Pointer to the timing configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 500 | */ |
AnnaBridge | 171:3a7713b1edbc | 501 | void FLEXCAN_SetTimingConfig(CAN_Type *base, const flexcan_timing_config_t *config); |
AnnaBridge | 171:3a7713b1edbc | 502 | |
AnnaBridge | 171:3a7713b1edbc | 503 | /*! |
AnnaBridge | 171:3a7713b1edbc | 504 | * @brief Sets the FlexCAN receive message buffer global mask. |
AnnaBridge | 171:3a7713b1edbc | 505 | * |
AnnaBridge | 171:3a7713b1edbc | 506 | * This function sets the global mask for the FlexCAN message buffer in a matching process. |
AnnaBridge | 171:3a7713b1edbc | 507 | * The configuration is only effective when the Rx individual mask is disabled in the FLEXCAN_Init(). |
AnnaBridge | 171:3a7713b1edbc | 508 | * |
AnnaBridge | 171:3a7713b1edbc | 509 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 510 | * @param mask Rx Message Buffer Global Mask value. |
AnnaBridge | 171:3a7713b1edbc | 511 | */ |
AnnaBridge | 171:3a7713b1edbc | 512 | void FLEXCAN_SetRxMbGlobalMask(CAN_Type *base, uint32_t mask); |
AnnaBridge | 171:3a7713b1edbc | 513 | |
AnnaBridge | 171:3a7713b1edbc | 514 | /*! |
AnnaBridge | 171:3a7713b1edbc | 515 | * @brief Sets the FlexCAN receive FIFO global mask. |
AnnaBridge | 171:3a7713b1edbc | 516 | * |
AnnaBridge | 171:3a7713b1edbc | 517 | * This function sets the global mask for FlexCAN FIFO in a matching process. |
AnnaBridge | 171:3a7713b1edbc | 518 | * |
AnnaBridge | 171:3a7713b1edbc | 519 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 520 | * @param mask Rx Fifo Global Mask value. |
AnnaBridge | 171:3a7713b1edbc | 521 | */ |
AnnaBridge | 171:3a7713b1edbc | 522 | void FLEXCAN_SetRxFifoGlobalMask(CAN_Type *base, uint32_t mask); |
AnnaBridge | 171:3a7713b1edbc | 523 | |
AnnaBridge | 171:3a7713b1edbc | 524 | /*! |
AnnaBridge | 171:3a7713b1edbc | 525 | * @brief Sets the FlexCAN receive individual mask. |
AnnaBridge | 171:3a7713b1edbc | 526 | * |
AnnaBridge | 171:3a7713b1edbc | 527 | * This function sets the individual mask for the FlexCAN matching process. |
AnnaBridge | 171:3a7713b1edbc | 528 | * The configuration is only effective when the Rx individual mask is enabled in the FLEXCAN_Init(). |
AnnaBridge | 171:3a7713b1edbc | 529 | * If the Rx FIFO is disabled, the individual mask is applied to the corresponding Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 530 | * If the Rx FIFO is enabled, the individual mask for Rx FIFO occupied Message Buffer is applied to |
AnnaBridge | 171:3a7713b1edbc | 531 | * the Rx Filter with the same index. Note that only the first 32 |
AnnaBridge | 171:3a7713b1edbc | 532 | * individual masks can be used as the Rx FIFO filter mask. |
AnnaBridge | 171:3a7713b1edbc | 533 | * |
AnnaBridge | 171:3a7713b1edbc | 534 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 535 | * @param maskIdx The Index of individual Mask. |
AnnaBridge | 171:3a7713b1edbc | 536 | * @param mask Rx Individual Mask value. |
AnnaBridge | 171:3a7713b1edbc | 537 | */ |
AnnaBridge | 171:3a7713b1edbc | 538 | void FLEXCAN_SetRxIndividualMask(CAN_Type *base, uint8_t maskIdx, uint32_t mask); |
AnnaBridge | 171:3a7713b1edbc | 539 | |
AnnaBridge | 171:3a7713b1edbc | 540 | /*! |
AnnaBridge | 171:3a7713b1edbc | 541 | * @brief Configures a FlexCAN transmit message buffer. |
AnnaBridge | 171:3a7713b1edbc | 542 | * |
AnnaBridge | 171:3a7713b1edbc | 543 | * This function aborts the previous transmission, cleans the Message Buffer, and |
AnnaBridge | 171:3a7713b1edbc | 544 | * configures it as a Transmit Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 545 | * |
AnnaBridge | 171:3a7713b1edbc | 546 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 547 | * @param mbIdx The Message Buffer index. |
AnnaBridge | 171:3a7713b1edbc | 548 | * @param enable Enable/disable Tx Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 549 | * - true: Enable Tx Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 550 | * - false: Disable Tx Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 551 | */ |
AnnaBridge | 171:3a7713b1edbc | 552 | void FLEXCAN_SetTxMbConfig(CAN_Type *base, uint8_t mbIdx, bool enable); |
AnnaBridge | 171:3a7713b1edbc | 553 | |
AnnaBridge | 171:3a7713b1edbc | 554 | /*! |
AnnaBridge | 171:3a7713b1edbc | 555 | * @brief Configures a FlexCAN Receive Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 556 | * |
AnnaBridge | 171:3a7713b1edbc | 557 | * This function cleans a FlexCAN build-in Message Buffer and configures it |
AnnaBridge | 171:3a7713b1edbc | 558 | * as a Receive Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 559 | * |
AnnaBridge | 171:3a7713b1edbc | 560 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 561 | * @param mbIdx The Message Buffer index. |
AnnaBridge | 171:3a7713b1edbc | 562 | * @param config Pointer to the FlexCAN Message Buffer configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 563 | * @param enable Enable/disable Rx Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 564 | * - true: Enable Rx Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 565 | * - false: Disable Rx Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 566 | */ |
AnnaBridge | 171:3a7713b1edbc | 567 | void FLEXCAN_SetRxMbConfig(CAN_Type *base, uint8_t mbIdx, const flexcan_rx_mb_config_t *config, bool enable); |
AnnaBridge | 171:3a7713b1edbc | 568 | |
AnnaBridge | 171:3a7713b1edbc | 569 | /*! |
AnnaBridge | 171:3a7713b1edbc | 570 | * @brief Configures the FlexCAN Rx FIFO. |
AnnaBridge | 171:3a7713b1edbc | 571 | * |
AnnaBridge | 171:3a7713b1edbc | 572 | * This function configures the Rx FIFO with given Rx FIFO configuration. |
AnnaBridge | 171:3a7713b1edbc | 573 | * |
AnnaBridge | 171:3a7713b1edbc | 574 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 575 | * @param config Pointer to the FlexCAN Rx FIFO configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 576 | * @param enable Enable/disable Rx FIFO. |
AnnaBridge | 171:3a7713b1edbc | 577 | * - true: Enable Rx FIFO. |
AnnaBridge | 171:3a7713b1edbc | 578 | * - false: Disable Rx FIFO. |
AnnaBridge | 171:3a7713b1edbc | 579 | */ |
AnnaBridge | 171:3a7713b1edbc | 580 | void FLEXCAN_SetRxFifoConfig(CAN_Type *base, const flexcan_rx_fifo_config_t *config, bool enable); |
AnnaBridge | 171:3a7713b1edbc | 581 | |
AnnaBridge | 171:3a7713b1edbc | 582 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 583 | |
AnnaBridge | 171:3a7713b1edbc | 584 | /*! |
AnnaBridge | 171:3a7713b1edbc | 585 | * @name Status |
AnnaBridge | 171:3a7713b1edbc | 586 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 587 | */ |
AnnaBridge | 171:3a7713b1edbc | 588 | |
AnnaBridge | 171:3a7713b1edbc | 589 | /*! |
AnnaBridge | 171:3a7713b1edbc | 590 | * @brief Gets the FlexCAN module interrupt flags. |
AnnaBridge | 171:3a7713b1edbc | 591 | * |
AnnaBridge | 171:3a7713b1edbc | 592 | * This function gets all FlexCAN status flags. The flags are returned as the logical |
AnnaBridge | 171:3a7713b1edbc | 593 | * OR value of the enumerators @ref _flexcan_flags. To check the specific status, |
AnnaBridge | 171:3a7713b1edbc | 594 | * compare the return value with enumerators in @ref _flexcan_flags. |
AnnaBridge | 171:3a7713b1edbc | 595 | * |
AnnaBridge | 171:3a7713b1edbc | 596 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 597 | * @return FlexCAN status flags which are ORed by the enumerators in the _flexcan_flags. |
AnnaBridge | 171:3a7713b1edbc | 598 | */ |
AnnaBridge | 171:3a7713b1edbc | 599 | static inline uint32_t FLEXCAN_GetStatusFlags(CAN_Type *base) |
AnnaBridge | 171:3a7713b1edbc | 600 | { |
AnnaBridge | 171:3a7713b1edbc | 601 | return base->ESR1; |
AnnaBridge | 171:3a7713b1edbc | 602 | } |
AnnaBridge | 171:3a7713b1edbc | 603 | |
AnnaBridge | 171:3a7713b1edbc | 604 | /*! |
AnnaBridge | 171:3a7713b1edbc | 605 | * @brief Clears status flags with the provided mask. |
AnnaBridge | 171:3a7713b1edbc | 606 | * |
AnnaBridge | 171:3a7713b1edbc | 607 | * This function clears the FlexCAN status flags with a provided mask. An automatically cleared flag |
AnnaBridge | 171:3a7713b1edbc | 608 | * can't be cleared by this function. |
AnnaBridge | 171:3a7713b1edbc | 609 | * |
AnnaBridge | 171:3a7713b1edbc | 610 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 611 | * @param mask The status flags to be cleared, it is logical OR value of @ref _flexcan_flags. |
AnnaBridge | 171:3a7713b1edbc | 612 | */ |
AnnaBridge | 171:3a7713b1edbc | 613 | static inline void FLEXCAN_ClearStatusFlags(CAN_Type *base, uint32_t mask) |
AnnaBridge | 171:3a7713b1edbc | 614 | { |
AnnaBridge | 171:3a7713b1edbc | 615 | /* Write 1 to clear status flag. */ |
AnnaBridge | 171:3a7713b1edbc | 616 | base->ESR1 = mask; |
AnnaBridge | 171:3a7713b1edbc | 617 | } |
AnnaBridge | 171:3a7713b1edbc | 618 | |
AnnaBridge | 171:3a7713b1edbc | 619 | /*! |
AnnaBridge | 171:3a7713b1edbc | 620 | * @brief Gets the FlexCAN Bus Error Counter value. |
AnnaBridge | 171:3a7713b1edbc | 621 | * |
AnnaBridge | 171:3a7713b1edbc | 622 | * This function gets the FlexCAN Bus Error Counter value for both Tx and |
AnnaBridge | 171:3a7713b1edbc | 623 | * Rx direction. These values may be needed in the upper layer error handling. |
AnnaBridge | 171:3a7713b1edbc | 624 | * |
AnnaBridge | 171:3a7713b1edbc | 625 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 626 | * @param txErrBuf Buffer to store Tx Error Counter value. |
AnnaBridge | 171:3a7713b1edbc | 627 | * @param rxErrBuf Buffer to store Rx Error Counter value. |
AnnaBridge | 171:3a7713b1edbc | 628 | */ |
AnnaBridge | 171:3a7713b1edbc | 629 | static inline void FLEXCAN_GetBusErrCount(CAN_Type *base, uint8_t *txErrBuf, uint8_t *rxErrBuf) |
AnnaBridge | 171:3a7713b1edbc | 630 | { |
AnnaBridge | 171:3a7713b1edbc | 631 | if (txErrBuf) |
AnnaBridge | 171:3a7713b1edbc | 632 | { |
AnnaBridge | 171:3a7713b1edbc | 633 | *txErrBuf = (uint8_t)((base->ECR & CAN_ECR_TXERRCNT_MASK) >> CAN_ECR_TXERRCNT_SHIFT); |
AnnaBridge | 171:3a7713b1edbc | 634 | } |
AnnaBridge | 171:3a7713b1edbc | 635 | |
AnnaBridge | 171:3a7713b1edbc | 636 | if (rxErrBuf) |
AnnaBridge | 171:3a7713b1edbc | 637 | { |
AnnaBridge | 171:3a7713b1edbc | 638 | *rxErrBuf = (uint8_t)((base->ECR & CAN_ECR_RXERRCNT_MASK) >> CAN_ECR_RXERRCNT_SHIFT); |
AnnaBridge | 171:3a7713b1edbc | 639 | } |
AnnaBridge | 171:3a7713b1edbc | 640 | } |
AnnaBridge | 171:3a7713b1edbc | 641 | |
AnnaBridge | 171:3a7713b1edbc | 642 | /*! |
AnnaBridge | 171:3a7713b1edbc | 643 | * @brief Gets the FlexCAN Message Buffer interrupt flags. |
AnnaBridge | 171:3a7713b1edbc | 644 | * |
AnnaBridge | 171:3a7713b1edbc | 645 | * This function gets the interrupt flags of a given Message Buffers. |
AnnaBridge | 171:3a7713b1edbc | 646 | * |
AnnaBridge | 171:3a7713b1edbc | 647 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 648 | * @param mask The ORed FlexCAN Message Buffer mask. |
AnnaBridge | 171:3a7713b1edbc | 649 | * @return The status of given Message Buffers. |
AnnaBridge | 171:3a7713b1edbc | 650 | */ |
AnnaBridge | 171:3a7713b1edbc | 651 | #if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0) |
AnnaBridge | 171:3a7713b1edbc | 652 | static inline uint64_t FLEXCAN_GetMbStatusFlags(CAN_Type *base, uint64_t mask) |
AnnaBridge | 171:3a7713b1edbc | 653 | #else |
AnnaBridge | 171:3a7713b1edbc | 654 | static inline uint32_t FLEXCAN_GetMbStatusFlags(CAN_Type *base, uint32_t mask) |
AnnaBridge | 171:3a7713b1edbc | 655 | #endif |
AnnaBridge | 171:3a7713b1edbc | 656 | { |
AnnaBridge | 171:3a7713b1edbc | 657 | #if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0) |
AnnaBridge | 171:3a7713b1edbc | 658 | return ((((uint64_t)base->IFLAG1) & mask) | ((((uint64_t)base->IFLAG2) << 32) & mask)); |
AnnaBridge | 171:3a7713b1edbc | 659 | #else |
AnnaBridge | 171:3a7713b1edbc | 660 | return (base->IFLAG1 & mask); |
AnnaBridge | 171:3a7713b1edbc | 661 | #endif |
AnnaBridge | 171:3a7713b1edbc | 662 | } |
AnnaBridge | 171:3a7713b1edbc | 663 | |
AnnaBridge | 171:3a7713b1edbc | 664 | /*! |
AnnaBridge | 171:3a7713b1edbc | 665 | * @brief Clears the FlexCAN Message Buffer interrupt flags. |
AnnaBridge | 171:3a7713b1edbc | 666 | * |
AnnaBridge | 171:3a7713b1edbc | 667 | * This function clears the interrupt flags of a given Message Buffers. |
AnnaBridge | 171:3a7713b1edbc | 668 | * |
AnnaBridge | 171:3a7713b1edbc | 669 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 670 | * @param mask The ORed FlexCAN Message Buffer mask. |
AnnaBridge | 171:3a7713b1edbc | 671 | */ |
AnnaBridge | 171:3a7713b1edbc | 672 | #if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0) |
AnnaBridge | 171:3a7713b1edbc | 673 | static inline void FLEXCAN_ClearMbStatusFlags(CAN_Type *base, uint64_t mask) |
AnnaBridge | 171:3a7713b1edbc | 674 | #else |
AnnaBridge | 171:3a7713b1edbc | 675 | static inline void FLEXCAN_ClearMbStatusFlags(CAN_Type *base, uint32_t mask) |
AnnaBridge | 171:3a7713b1edbc | 676 | #endif |
AnnaBridge | 171:3a7713b1edbc | 677 | { |
AnnaBridge | 171:3a7713b1edbc | 678 | #if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0) |
AnnaBridge | 171:3a7713b1edbc | 679 | base->IFLAG1 = (uint32_t)(mask & 0xFFFFFFFF); |
AnnaBridge | 171:3a7713b1edbc | 680 | base->IFLAG2 = (uint32_t)(mask >> 32); |
AnnaBridge | 171:3a7713b1edbc | 681 | #else |
AnnaBridge | 171:3a7713b1edbc | 682 | base->IFLAG1 = mask; |
AnnaBridge | 171:3a7713b1edbc | 683 | #endif |
AnnaBridge | 171:3a7713b1edbc | 684 | } |
AnnaBridge | 171:3a7713b1edbc | 685 | |
AnnaBridge | 171:3a7713b1edbc | 686 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 687 | |
AnnaBridge | 171:3a7713b1edbc | 688 | /*! |
AnnaBridge | 171:3a7713b1edbc | 689 | * @name Interrupts |
AnnaBridge | 171:3a7713b1edbc | 690 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 691 | */ |
AnnaBridge | 171:3a7713b1edbc | 692 | |
AnnaBridge | 171:3a7713b1edbc | 693 | /*! |
AnnaBridge | 171:3a7713b1edbc | 694 | * @brief Enables FlexCAN interrupts according to the provided mask. |
AnnaBridge | 171:3a7713b1edbc | 695 | * |
AnnaBridge | 171:3a7713b1edbc | 696 | * This function enables the FlexCAN interrupts according to the provided mask. The mask |
AnnaBridge | 171:3a7713b1edbc | 697 | * is a logical OR of enumeration members, see @ref _flexcan_interrupt_enable. |
AnnaBridge | 171:3a7713b1edbc | 698 | * |
AnnaBridge | 171:3a7713b1edbc | 699 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 700 | * @param mask The interrupts to enable. Logical OR of @ref _flexcan_interrupt_enable. |
AnnaBridge | 171:3a7713b1edbc | 701 | */ |
AnnaBridge | 171:3a7713b1edbc | 702 | static inline void FLEXCAN_EnableInterrupts(CAN_Type *base, uint32_t mask) |
AnnaBridge | 171:3a7713b1edbc | 703 | { |
AnnaBridge | 171:3a7713b1edbc | 704 | /* Solve Wake Up Interrupt. */ |
AnnaBridge | 171:3a7713b1edbc | 705 | if (mask & kFLEXCAN_WakeUpInterruptEnable) |
AnnaBridge | 171:3a7713b1edbc | 706 | { |
AnnaBridge | 171:3a7713b1edbc | 707 | base->MCR |= CAN_MCR_WAKMSK_MASK; |
AnnaBridge | 171:3a7713b1edbc | 708 | } |
AnnaBridge | 171:3a7713b1edbc | 709 | |
AnnaBridge | 171:3a7713b1edbc | 710 | /* Solve others. */ |
AnnaBridge | 171:3a7713b1edbc | 711 | base->CTRL1 |= (mask & (~((uint32_t)kFLEXCAN_WakeUpInterruptEnable))); |
AnnaBridge | 171:3a7713b1edbc | 712 | } |
AnnaBridge | 171:3a7713b1edbc | 713 | |
AnnaBridge | 171:3a7713b1edbc | 714 | /*! |
AnnaBridge | 171:3a7713b1edbc | 715 | * @brief Disables FlexCAN interrupts according to the provided mask. |
AnnaBridge | 171:3a7713b1edbc | 716 | * |
AnnaBridge | 171:3a7713b1edbc | 717 | * This function disables the FlexCAN interrupts according to the provided mask. The mask |
AnnaBridge | 171:3a7713b1edbc | 718 | * is a logical OR of enumeration members, see @ref _flexcan_interrupt_enable. |
AnnaBridge | 171:3a7713b1edbc | 719 | * |
AnnaBridge | 171:3a7713b1edbc | 720 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 721 | * @param mask The interrupts to disable. Logical OR of @ref _flexcan_interrupt_enable. |
AnnaBridge | 171:3a7713b1edbc | 722 | */ |
AnnaBridge | 171:3a7713b1edbc | 723 | static inline void FLEXCAN_DisableInterrupts(CAN_Type *base, uint32_t mask) |
AnnaBridge | 171:3a7713b1edbc | 724 | { |
AnnaBridge | 171:3a7713b1edbc | 725 | /* Solve Wake Up Interrupt. */ |
AnnaBridge | 171:3a7713b1edbc | 726 | if (mask & kFLEXCAN_WakeUpInterruptEnable) |
AnnaBridge | 171:3a7713b1edbc | 727 | { |
AnnaBridge | 171:3a7713b1edbc | 728 | base->MCR &= ~CAN_MCR_WAKMSK_MASK; |
AnnaBridge | 171:3a7713b1edbc | 729 | } |
AnnaBridge | 171:3a7713b1edbc | 730 | |
AnnaBridge | 171:3a7713b1edbc | 731 | /* Solve others. */ |
AnnaBridge | 171:3a7713b1edbc | 732 | base->CTRL1 &= ~(mask & (~((uint32_t)kFLEXCAN_WakeUpInterruptEnable))); |
AnnaBridge | 171:3a7713b1edbc | 733 | } |
AnnaBridge | 171:3a7713b1edbc | 734 | |
AnnaBridge | 171:3a7713b1edbc | 735 | /*! |
AnnaBridge | 171:3a7713b1edbc | 736 | * @brief Enables FlexCAN Message Buffer interrupts. |
AnnaBridge | 171:3a7713b1edbc | 737 | * |
AnnaBridge | 171:3a7713b1edbc | 738 | * This function enables the interrupts of given Message Buffers. |
AnnaBridge | 171:3a7713b1edbc | 739 | * |
AnnaBridge | 171:3a7713b1edbc | 740 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 741 | * @param mask The ORed FlexCAN Message Buffer mask. |
AnnaBridge | 171:3a7713b1edbc | 742 | */ |
AnnaBridge | 171:3a7713b1edbc | 743 | #if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0) |
AnnaBridge | 171:3a7713b1edbc | 744 | static inline void FLEXCAN_EnableMbInterrupts(CAN_Type *base, uint64_t mask) |
AnnaBridge | 171:3a7713b1edbc | 745 | #else |
AnnaBridge | 171:3a7713b1edbc | 746 | static inline void FLEXCAN_EnableMbInterrupts(CAN_Type *base, uint32_t mask) |
AnnaBridge | 171:3a7713b1edbc | 747 | #endif |
AnnaBridge | 171:3a7713b1edbc | 748 | { |
AnnaBridge | 171:3a7713b1edbc | 749 | #if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0) |
AnnaBridge | 171:3a7713b1edbc | 750 | base->IMASK1 |= (uint32_t)(mask & 0xFFFFFFFF); |
AnnaBridge | 171:3a7713b1edbc | 751 | base->IMASK2 |= (uint32_t)(mask >> 32); |
AnnaBridge | 171:3a7713b1edbc | 752 | #else |
AnnaBridge | 171:3a7713b1edbc | 753 | base->IMASK1 |= mask; |
AnnaBridge | 171:3a7713b1edbc | 754 | #endif |
AnnaBridge | 171:3a7713b1edbc | 755 | } |
AnnaBridge | 171:3a7713b1edbc | 756 | |
AnnaBridge | 171:3a7713b1edbc | 757 | /*! |
AnnaBridge | 171:3a7713b1edbc | 758 | * @brief Disables FlexCAN Message Buffer interrupts. |
AnnaBridge | 171:3a7713b1edbc | 759 | * |
AnnaBridge | 171:3a7713b1edbc | 760 | * This function disables the interrupts of given Message Buffers. |
AnnaBridge | 171:3a7713b1edbc | 761 | * |
AnnaBridge | 171:3a7713b1edbc | 762 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 763 | * @param mask The ORed FlexCAN Message Buffer mask. |
AnnaBridge | 171:3a7713b1edbc | 764 | */ |
AnnaBridge | 171:3a7713b1edbc | 765 | #if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0) |
AnnaBridge | 171:3a7713b1edbc | 766 | static inline void FLEXCAN_DisableMbInterrupts(CAN_Type *base, uint64_t mask) |
AnnaBridge | 171:3a7713b1edbc | 767 | #else |
AnnaBridge | 171:3a7713b1edbc | 768 | static inline void FLEXCAN_DisableMbInterrupts(CAN_Type *base, uint32_t mask) |
AnnaBridge | 171:3a7713b1edbc | 769 | #endif |
AnnaBridge | 171:3a7713b1edbc | 770 | { |
AnnaBridge | 171:3a7713b1edbc | 771 | #if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0) |
AnnaBridge | 171:3a7713b1edbc | 772 | base->IMASK1 &= ~((uint32_t)(mask & 0xFFFFFFFF)); |
AnnaBridge | 171:3a7713b1edbc | 773 | base->IMASK2 &= ~((uint32_t)(mask >> 32)); |
AnnaBridge | 171:3a7713b1edbc | 774 | #else |
AnnaBridge | 171:3a7713b1edbc | 775 | base->IMASK1 &= ~mask; |
AnnaBridge | 171:3a7713b1edbc | 776 | #endif |
AnnaBridge | 171:3a7713b1edbc | 777 | } |
AnnaBridge | 171:3a7713b1edbc | 778 | |
AnnaBridge | 171:3a7713b1edbc | 779 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 780 | |
AnnaBridge | 171:3a7713b1edbc | 781 | #if (defined(FSL_FEATURE_FLEXCAN_HAS_RX_FIFO_DMA) && FSL_FEATURE_FLEXCAN_HAS_RX_FIFO_DMA) |
AnnaBridge | 171:3a7713b1edbc | 782 | /*! |
AnnaBridge | 171:3a7713b1edbc | 783 | * @name DMA Control |
AnnaBridge | 171:3a7713b1edbc | 784 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 785 | */ |
AnnaBridge | 171:3a7713b1edbc | 786 | |
AnnaBridge | 171:3a7713b1edbc | 787 | /*! |
AnnaBridge | 171:3a7713b1edbc | 788 | * @brief Enables or disables the FlexCAN Rx FIFO DMA request. |
AnnaBridge | 171:3a7713b1edbc | 789 | * |
AnnaBridge | 171:3a7713b1edbc | 790 | * This function enables or disables the DMA feature of FlexCAN build-in Rx FIFO. |
AnnaBridge | 171:3a7713b1edbc | 791 | * |
AnnaBridge | 171:3a7713b1edbc | 792 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 793 | * @param enable true to enable, false to disable. |
AnnaBridge | 171:3a7713b1edbc | 794 | */ |
AnnaBridge | 171:3a7713b1edbc | 795 | void FLEXCAN_EnableRxFifoDMA(CAN_Type *base, bool enable); |
AnnaBridge | 171:3a7713b1edbc | 796 | |
AnnaBridge | 171:3a7713b1edbc | 797 | /*! |
AnnaBridge | 171:3a7713b1edbc | 798 | * @brief Gets the Rx FIFO Head address. |
AnnaBridge | 171:3a7713b1edbc | 799 | * |
AnnaBridge | 171:3a7713b1edbc | 800 | * This function returns the FlexCAN Rx FIFO Head address, which is mainly used for the DMA/eDMA use case. |
AnnaBridge | 171:3a7713b1edbc | 801 | * |
AnnaBridge | 171:3a7713b1edbc | 802 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 803 | * @return FlexCAN Rx FIFO Head address. |
AnnaBridge | 171:3a7713b1edbc | 804 | */ |
AnnaBridge | 171:3a7713b1edbc | 805 | static inline uint32_t FLEXCAN_GetRxFifoHeadAddr(CAN_Type *base) |
AnnaBridge | 171:3a7713b1edbc | 806 | { |
AnnaBridge | 171:3a7713b1edbc | 807 | return (uint32_t) & (base->MB[0].CS); |
AnnaBridge | 171:3a7713b1edbc | 808 | } |
AnnaBridge | 171:3a7713b1edbc | 809 | |
AnnaBridge | 171:3a7713b1edbc | 810 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 811 | #endif /* FSL_FEATURE_FLEXCAN_HAS_RX_FIFO_DMA */ |
AnnaBridge | 171:3a7713b1edbc | 812 | |
AnnaBridge | 171:3a7713b1edbc | 813 | /*! |
AnnaBridge | 171:3a7713b1edbc | 814 | * @name Bus Operations |
AnnaBridge | 171:3a7713b1edbc | 815 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 816 | */ |
AnnaBridge | 171:3a7713b1edbc | 817 | |
AnnaBridge | 171:3a7713b1edbc | 818 | /*! |
AnnaBridge | 171:3a7713b1edbc | 819 | * @brief Enables or disables the FlexCAN module operation. |
AnnaBridge | 171:3a7713b1edbc | 820 | * |
AnnaBridge | 171:3a7713b1edbc | 821 | * This function enables or disables the FlexCAN module. |
AnnaBridge | 171:3a7713b1edbc | 822 | * |
AnnaBridge | 171:3a7713b1edbc | 823 | * @param base FlexCAN base pointer. |
AnnaBridge | 171:3a7713b1edbc | 824 | * @param enable true to enable, false to disable. |
AnnaBridge | 171:3a7713b1edbc | 825 | */ |
AnnaBridge | 171:3a7713b1edbc | 826 | static inline void FLEXCAN_Enable(CAN_Type *base, bool enable) |
AnnaBridge | 171:3a7713b1edbc | 827 | { |
AnnaBridge | 171:3a7713b1edbc | 828 | if (enable) |
AnnaBridge | 171:3a7713b1edbc | 829 | { |
AnnaBridge | 171:3a7713b1edbc | 830 | base->MCR &= ~CAN_MCR_MDIS_MASK; |
AnnaBridge | 171:3a7713b1edbc | 831 | |
AnnaBridge | 171:3a7713b1edbc | 832 | /* Wait FlexCAN exit from low-power mode. */ |
AnnaBridge | 171:3a7713b1edbc | 833 | while (base->MCR & CAN_MCR_LPMACK_MASK) |
AnnaBridge | 171:3a7713b1edbc | 834 | { |
AnnaBridge | 171:3a7713b1edbc | 835 | } |
AnnaBridge | 171:3a7713b1edbc | 836 | } |
AnnaBridge | 171:3a7713b1edbc | 837 | else |
AnnaBridge | 171:3a7713b1edbc | 838 | { |
AnnaBridge | 171:3a7713b1edbc | 839 | base->MCR |= CAN_MCR_MDIS_MASK; |
AnnaBridge | 171:3a7713b1edbc | 840 | |
AnnaBridge | 171:3a7713b1edbc | 841 | /* Wait FlexCAN enter low-power mode. */ |
AnnaBridge | 171:3a7713b1edbc | 842 | while (!(base->MCR & CAN_MCR_LPMACK_MASK)) |
AnnaBridge | 171:3a7713b1edbc | 843 | { |
AnnaBridge | 171:3a7713b1edbc | 844 | } |
AnnaBridge | 171:3a7713b1edbc | 845 | } |
AnnaBridge | 171:3a7713b1edbc | 846 | } |
AnnaBridge | 171:3a7713b1edbc | 847 | |
AnnaBridge | 171:3a7713b1edbc | 848 | /*! |
AnnaBridge | 171:3a7713b1edbc | 849 | * @brief Writes a FlexCAN Message to the Transmit Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 850 | * |
AnnaBridge | 171:3a7713b1edbc | 851 | * This function writes a CAN Message to the specified Transmit Message Buffer |
AnnaBridge | 171:3a7713b1edbc | 852 | * and changes the Message Buffer state to start CAN Message transmit. After |
AnnaBridge | 171:3a7713b1edbc | 853 | * that the function returns immediately. |
AnnaBridge | 171:3a7713b1edbc | 854 | * |
AnnaBridge | 171:3a7713b1edbc | 855 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 856 | * @param mbIdx The FlexCAN Message Buffer index. |
AnnaBridge | 171:3a7713b1edbc | 857 | * @param txFrame Pointer to CAN message frame to be sent. |
AnnaBridge | 171:3a7713b1edbc | 858 | * @retval kStatus_Success - Write Tx Message Buffer Successfully. |
AnnaBridge | 171:3a7713b1edbc | 859 | * @retval kStatus_Fail - Tx Message Buffer is currently in use. |
AnnaBridge | 171:3a7713b1edbc | 860 | */ |
AnnaBridge | 171:3a7713b1edbc | 861 | status_t FLEXCAN_WriteTxMb(CAN_Type *base, uint8_t mbIdx, const flexcan_frame_t *txFrame); |
AnnaBridge | 171:3a7713b1edbc | 862 | |
AnnaBridge | 171:3a7713b1edbc | 863 | /*! |
AnnaBridge | 171:3a7713b1edbc | 864 | * @brief Reads a FlexCAN Message from Receive Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 865 | * |
AnnaBridge | 171:3a7713b1edbc | 866 | * This function reads a CAN message from a specified Receive Message Buffer. |
AnnaBridge | 171:3a7713b1edbc | 867 | * The function fills a receive CAN message frame structure with |
AnnaBridge | 171:3a7713b1edbc | 868 | * just received data and activates the Message Buffer again. |
AnnaBridge | 171:3a7713b1edbc | 869 | * The function returns immediately. |
AnnaBridge | 171:3a7713b1edbc | 870 | * |
AnnaBridge | 171:3a7713b1edbc | 871 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 872 | * @param mbIdx The FlexCAN Message Buffer index. |
AnnaBridge | 171:3a7713b1edbc | 873 | * @param rxFrame Pointer to CAN message frame structure for reception. |
AnnaBridge | 171:3a7713b1edbc | 874 | * @retval kStatus_Success - Rx Message Buffer is full and has been read successfully. |
AnnaBridge | 171:3a7713b1edbc | 875 | * @retval kStatus_FLEXCAN_RxOverflow - Rx Message Buffer is already overflowed and has been read successfully. |
AnnaBridge | 171:3a7713b1edbc | 876 | * @retval kStatus_Fail - Rx Message Buffer is empty. |
AnnaBridge | 171:3a7713b1edbc | 877 | */ |
AnnaBridge | 171:3a7713b1edbc | 878 | status_t FLEXCAN_ReadRxMb(CAN_Type *base, uint8_t mbIdx, flexcan_frame_t *rxFrame); |
AnnaBridge | 171:3a7713b1edbc | 879 | |
AnnaBridge | 171:3a7713b1edbc | 880 | /*! |
AnnaBridge | 171:3a7713b1edbc | 881 | * @brief Reads a FlexCAN Message from Rx FIFO. |
AnnaBridge | 171:3a7713b1edbc | 882 | * |
AnnaBridge | 171:3a7713b1edbc | 883 | * This function reads a CAN message from the FlexCAN build-in Rx FIFO. |
AnnaBridge | 171:3a7713b1edbc | 884 | * |
AnnaBridge | 171:3a7713b1edbc | 885 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 886 | * @param rxFrame Pointer to CAN message frame structure for reception. |
AnnaBridge | 171:3a7713b1edbc | 887 | * @retval kStatus_Success - Read Message from Rx FIFO successfully. |
AnnaBridge | 171:3a7713b1edbc | 888 | * @retval kStatus_Fail - Rx FIFO is not enabled. |
AnnaBridge | 171:3a7713b1edbc | 889 | */ |
AnnaBridge | 171:3a7713b1edbc | 890 | status_t FLEXCAN_ReadRxFifo(CAN_Type *base, flexcan_frame_t *rxFrame); |
AnnaBridge | 171:3a7713b1edbc | 891 | |
AnnaBridge | 171:3a7713b1edbc | 892 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 893 | |
AnnaBridge | 171:3a7713b1edbc | 894 | /*! |
AnnaBridge | 171:3a7713b1edbc | 895 | * @name Transactional |
AnnaBridge | 171:3a7713b1edbc | 896 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 897 | */ |
AnnaBridge | 171:3a7713b1edbc | 898 | |
AnnaBridge | 171:3a7713b1edbc | 899 | /*! |
AnnaBridge | 171:3a7713b1edbc | 900 | * @brief Performs a polling send transaction on the CAN bus. |
AnnaBridge | 171:3a7713b1edbc | 901 | * |
AnnaBridge | 171:3a7713b1edbc | 902 | * Note that a transfer handle does not need to be created before calling this API. |
AnnaBridge | 171:3a7713b1edbc | 903 | * |
AnnaBridge | 171:3a7713b1edbc | 904 | * @param base FlexCAN peripheral base pointer. |
AnnaBridge | 171:3a7713b1edbc | 905 | * @param mbIdx The FlexCAN Message Buffer index. |
AnnaBridge | 171:3a7713b1edbc | 906 | * @param txFrame Pointer to CAN message frame to be sent. |
AnnaBridge | 171:3a7713b1edbc | 907 | * @retval kStatus_Success - Write Tx Message Buffer Successfully. |
AnnaBridge | 171:3a7713b1edbc | 908 | * @retval kStatus_Fail - Tx Message Buffer is currently in use. |
AnnaBridge | 171:3a7713b1edbc | 909 | */ |
AnnaBridge | 171:3a7713b1edbc | 910 | status_t FLEXCAN_TransferSendBlocking(CAN_Type *base, uint8_t mbIdx, flexcan_frame_t *txFrame); |
AnnaBridge | 171:3a7713b1edbc | 911 | |
AnnaBridge | 171:3a7713b1edbc | 912 | /*! |
AnnaBridge | 171:3a7713b1edbc | 913 | * @brief Performs a polling receive transaction on the CAN bus. |
AnnaBridge | 171:3a7713b1edbc | 914 | * |
AnnaBridge | 171:3a7713b1edbc | 915 | * Note that a transfer handle does not need to be created before calling this API. |
AnnaBridge | 171:3a7713b1edbc | 916 | * |
AnnaBridge | 171:3a7713b1edbc | 917 | * @param base FlexCAN peripheral base pointer. |
AnnaBridge | 171:3a7713b1edbc | 918 | * @param mbIdx The FlexCAN Message Buffer index. |
AnnaBridge | 171:3a7713b1edbc | 919 | * @param rxFrame Pointer to CAN message frame structure for reception. |
AnnaBridge | 171:3a7713b1edbc | 920 | * @retval kStatus_Success - Rx Message Buffer is full and has been read successfully. |
AnnaBridge | 171:3a7713b1edbc | 921 | * @retval kStatus_FLEXCAN_RxOverflow - Rx Message Buffer is already overflowed and has been read successfully. |
AnnaBridge | 171:3a7713b1edbc | 922 | * @retval kStatus_Fail - Rx Message Buffer is empty. |
AnnaBridge | 171:3a7713b1edbc | 923 | */ |
AnnaBridge | 171:3a7713b1edbc | 924 | status_t FLEXCAN_TransferReceiveBlocking(CAN_Type *base, uint8_t mbIdx, flexcan_frame_t *rxFrame); |
AnnaBridge | 171:3a7713b1edbc | 925 | |
AnnaBridge | 171:3a7713b1edbc | 926 | /*! |
AnnaBridge | 171:3a7713b1edbc | 927 | * @brief Performs a polling receive transaction from Rx FIFO on the CAN bus. |
AnnaBridge | 171:3a7713b1edbc | 928 | * |
AnnaBridge | 171:3a7713b1edbc | 929 | * Note that a transfer handle does not need to be created before calling this API. |
AnnaBridge | 171:3a7713b1edbc | 930 | * |
AnnaBridge | 171:3a7713b1edbc | 931 | * @param base FlexCAN peripheral base pointer. |
AnnaBridge | 171:3a7713b1edbc | 932 | * @param rxFrame Pointer to CAN message frame structure for reception. |
AnnaBridge | 171:3a7713b1edbc | 933 | * @retval kStatus_Success - Read Message from Rx FIFO successfully. |
AnnaBridge | 171:3a7713b1edbc | 934 | * @retval kStatus_Fail - Rx FIFO is not enabled. |
AnnaBridge | 171:3a7713b1edbc | 935 | */ |
AnnaBridge | 171:3a7713b1edbc | 936 | status_t FLEXCAN_TransferReceiveFifoBlocking(CAN_Type *base, flexcan_frame_t *rxFrame); |
AnnaBridge | 171:3a7713b1edbc | 937 | |
AnnaBridge | 171:3a7713b1edbc | 938 | /*! |
AnnaBridge | 171:3a7713b1edbc | 939 | * @brief Initializes the FlexCAN handle. |
AnnaBridge | 171:3a7713b1edbc | 940 | * |
AnnaBridge | 171:3a7713b1edbc | 941 | * This function initializes the FlexCAN handle, which can be used for other FlexCAN |
AnnaBridge | 171:3a7713b1edbc | 942 | * transactional APIs. Usually, for a specified FlexCAN instance, |
AnnaBridge | 171:3a7713b1edbc | 943 | * call this API once to get the initialized handle. |
AnnaBridge | 171:3a7713b1edbc | 944 | * |
AnnaBridge | 171:3a7713b1edbc | 945 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 946 | * @param handle FlexCAN handle pointer. |
AnnaBridge | 171:3a7713b1edbc | 947 | * @param callback The callback function. |
AnnaBridge | 171:3a7713b1edbc | 948 | * @param userData The parameter of the callback function. |
AnnaBridge | 171:3a7713b1edbc | 949 | */ |
AnnaBridge | 171:3a7713b1edbc | 950 | void FLEXCAN_TransferCreateHandle(CAN_Type *base, |
AnnaBridge | 171:3a7713b1edbc | 951 | flexcan_handle_t *handle, |
AnnaBridge | 171:3a7713b1edbc | 952 | flexcan_transfer_callback_t callback, |
AnnaBridge | 171:3a7713b1edbc | 953 | void *userData); |
AnnaBridge | 171:3a7713b1edbc | 954 | |
AnnaBridge | 171:3a7713b1edbc | 955 | /*! |
AnnaBridge | 171:3a7713b1edbc | 956 | * @brief Sends a message using IRQ. |
AnnaBridge | 171:3a7713b1edbc | 957 | * |
AnnaBridge | 171:3a7713b1edbc | 958 | * This function sends a message using IRQ. This is a non-blocking function, which returns |
AnnaBridge | 171:3a7713b1edbc | 959 | * right away. When messages have been sent out, the send callback function is called. |
AnnaBridge | 171:3a7713b1edbc | 960 | * |
AnnaBridge | 171:3a7713b1edbc | 961 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 962 | * @param handle FlexCAN handle pointer. |
AnnaBridge | 171:3a7713b1edbc | 963 | * @param xfer FlexCAN Message Buffer transfer structure. See the #flexcan_mb_transfer_t. |
AnnaBridge | 171:3a7713b1edbc | 964 | * @retval kStatus_Success Start Tx Message Buffer sending process successfully. |
AnnaBridge | 171:3a7713b1edbc | 965 | * @retval kStatus_Fail Write Tx Message Buffer failed. |
AnnaBridge | 171:3a7713b1edbc | 966 | * @retval kStatus_FLEXCAN_TxBusy Tx Message Buffer is in use. |
AnnaBridge | 171:3a7713b1edbc | 967 | */ |
AnnaBridge | 171:3a7713b1edbc | 968 | status_t FLEXCAN_TransferSendNonBlocking(CAN_Type *base, flexcan_handle_t *handle, flexcan_mb_transfer_t *xfer); |
AnnaBridge | 171:3a7713b1edbc | 969 | |
AnnaBridge | 171:3a7713b1edbc | 970 | /*! |
AnnaBridge | 171:3a7713b1edbc | 971 | * @brief Receives a message using IRQ. |
AnnaBridge | 171:3a7713b1edbc | 972 | * |
AnnaBridge | 171:3a7713b1edbc | 973 | * This function receives a message using IRQ. This is non-blocking function, which returns |
AnnaBridge | 171:3a7713b1edbc | 974 | * right away. When the message has been received, the receive callback function is called. |
AnnaBridge | 171:3a7713b1edbc | 975 | * |
AnnaBridge | 171:3a7713b1edbc | 976 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 977 | * @param handle FlexCAN handle pointer. |
AnnaBridge | 171:3a7713b1edbc | 978 | * @param xfer FlexCAN Message Buffer transfer structure. See the #flexcan_mb_transfer_t. |
AnnaBridge | 171:3a7713b1edbc | 979 | * @retval kStatus_Success - Start Rx Message Buffer receiving process successfully. |
AnnaBridge | 171:3a7713b1edbc | 980 | * @retval kStatus_FLEXCAN_RxBusy - Rx Message Buffer is in use. |
AnnaBridge | 171:3a7713b1edbc | 981 | */ |
AnnaBridge | 171:3a7713b1edbc | 982 | status_t FLEXCAN_TransferReceiveNonBlocking(CAN_Type *base, flexcan_handle_t *handle, flexcan_mb_transfer_t *xfer); |
AnnaBridge | 171:3a7713b1edbc | 983 | |
AnnaBridge | 171:3a7713b1edbc | 984 | /*! |
AnnaBridge | 171:3a7713b1edbc | 985 | * @brief Receives a message from Rx FIFO using IRQ. |
AnnaBridge | 171:3a7713b1edbc | 986 | * |
AnnaBridge | 171:3a7713b1edbc | 987 | * This function receives a message using IRQ. This is a non-blocking function, which returns |
AnnaBridge | 171:3a7713b1edbc | 988 | * right away. When all messages have been received, the receive callback function is called. |
AnnaBridge | 171:3a7713b1edbc | 989 | * |
AnnaBridge | 171:3a7713b1edbc | 990 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 991 | * @param handle FlexCAN handle pointer. |
AnnaBridge | 171:3a7713b1edbc | 992 | * @param xfer FlexCAN Rx FIFO transfer structure. See the @ref flexcan_fifo_transfer_t. |
AnnaBridge | 171:3a7713b1edbc | 993 | * @retval kStatus_Success - Start Rx FIFO receiving process successfully. |
AnnaBridge | 171:3a7713b1edbc | 994 | * @retval kStatus_FLEXCAN_RxFifoBusy - Rx FIFO is currently in use. |
AnnaBridge | 171:3a7713b1edbc | 995 | */ |
AnnaBridge | 171:3a7713b1edbc | 996 | status_t FLEXCAN_TransferReceiveFifoNonBlocking(CAN_Type *base, |
AnnaBridge | 171:3a7713b1edbc | 997 | flexcan_handle_t *handle, |
AnnaBridge | 171:3a7713b1edbc | 998 | flexcan_fifo_transfer_t *xfer); |
AnnaBridge | 171:3a7713b1edbc | 999 | |
AnnaBridge | 171:3a7713b1edbc | 1000 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1001 | * @brief Aborts the interrupt driven message send process. |
AnnaBridge | 171:3a7713b1edbc | 1002 | * |
AnnaBridge | 171:3a7713b1edbc | 1003 | * This function aborts the interrupt driven message send process. |
AnnaBridge | 171:3a7713b1edbc | 1004 | * |
AnnaBridge | 171:3a7713b1edbc | 1005 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1006 | * @param handle FlexCAN handle pointer. |
AnnaBridge | 171:3a7713b1edbc | 1007 | * @param mbIdx The FlexCAN Message Buffer index. |
AnnaBridge | 171:3a7713b1edbc | 1008 | */ |
AnnaBridge | 171:3a7713b1edbc | 1009 | void FLEXCAN_TransferAbortSend(CAN_Type *base, flexcan_handle_t *handle, uint8_t mbIdx); |
AnnaBridge | 171:3a7713b1edbc | 1010 | |
AnnaBridge | 171:3a7713b1edbc | 1011 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1012 | * @brief Aborts the interrupt driven message receive process. |
AnnaBridge | 171:3a7713b1edbc | 1013 | * |
AnnaBridge | 171:3a7713b1edbc | 1014 | * This function aborts the interrupt driven message receive process. |
AnnaBridge | 171:3a7713b1edbc | 1015 | * |
AnnaBridge | 171:3a7713b1edbc | 1016 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1017 | * @param handle FlexCAN handle pointer. |
AnnaBridge | 171:3a7713b1edbc | 1018 | * @param mbIdx The FlexCAN Message Buffer index. |
AnnaBridge | 171:3a7713b1edbc | 1019 | */ |
AnnaBridge | 171:3a7713b1edbc | 1020 | void FLEXCAN_TransferAbortReceive(CAN_Type *base, flexcan_handle_t *handle, uint8_t mbIdx); |
AnnaBridge | 171:3a7713b1edbc | 1021 | |
AnnaBridge | 171:3a7713b1edbc | 1022 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1023 | * @brief Aborts the interrupt driven message receive from Rx FIFO process. |
AnnaBridge | 171:3a7713b1edbc | 1024 | * |
AnnaBridge | 171:3a7713b1edbc | 1025 | * This function aborts the interrupt driven message receive from Rx FIFO process. |
AnnaBridge | 171:3a7713b1edbc | 1026 | * |
AnnaBridge | 171:3a7713b1edbc | 1027 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1028 | * @param handle FlexCAN handle pointer. |
AnnaBridge | 171:3a7713b1edbc | 1029 | */ |
AnnaBridge | 171:3a7713b1edbc | 1030 | void FLEXCAN_TransferAbortReceiveFifo(CAN_Type *base, flexcan_handle_t *handle); |
AnnaBridge | 171:3a7713b1edbc | 1031 | |
AnnaBridge | 171:3a7713b1edbc | 1032 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1033 | * @brief FlexCAN IRQ handle function. |
AnnaBridge | 171:3a7713b1edbc | 1034 | * |
AnnaBridge | 171:3a7713b1edbc | 1035 | * This function handles the FlexCAN Error, the Message Buffer, and the Rx FIFO IRQ request. |
AnnaBridge | 171:3a7713b1edbc | 1036 | * |
AnnaBridge | 171:3a7713b1edbc | 1037 | * @param base FlexCAN peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1038 | * @param handle FlexCAN handle pointer. |
AnnaBridge | 171:3a7713b1edbc | 1039 | */ |
AnnaBridge | 171:3a7713b1edbc | 1040 | void FLEXCAN_TransferHandleIRQ(CAN_Type *base, flexcan_handle_t *handle); |
AnnaBridge | 171:3a7713b1edbc | 1041 | |
AnnaBridge | 171:3a7713b1edbc | 1042 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 1043 | |
AnnaBridge | 171:3a7713b1edbc | 1044 | #if defined(__cplusplus) |
AnnaBridge | 171:3a7713b1edbc | 1045 | } |
AnnaBridge | 171:3a7713b1edbc | 1046 | #endif |
AnnaBridge | 171:3a7713b1edbc | 1047 | |
AnnaBridge | 171:3a7713b1edbc | 1048 | /*! @}*/ |
AnnaBridge | 171:3a7713b1edbc | 1049 | |
AnnaBridge | 171:3a7713b1edbc | 1050 | #endif /* _FSL_FLEXCAN_H_ */ |