mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Thu Sep 18 14:00:17 2014 +0100
Revision:
324:406fd2029f23
Parent:
149:1fb5f62b92bd
Synchronized with git revision a73f28e6fbca9559fbed2726410eeb4c0534a4a5

Full URL: https://github.com/mbedmicro/mbed/commit/a73f28e6fbca9559fbed2726410eeb4c0534a4a5/

Extended #476, which does not break ethernet for K64F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 146:f64d43ff0c18 1 /*
mbed_official 146:f64d43ff0c18 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 146:f64d43ff0c18 3 * All rights reserved.
mbed_official 146:f64d43ff0c18 4 *
mbed_official 146:f64d43ff0c18 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 146:f64d43ff0c18 6 * are permitted provided that the following conditions are met:
mbed_official 146:f64d43ff0c18 7 *
mbed_official 146:f64d43ff0c18 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 146:f64d43ff0c18 9 * of conditions and the following disclaimer.
mbed_official 146:f64d43ff0c18 10 *
mbed_official 146:f64d43ff0c18 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 146:f64d43ff0c18 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 146:f64d43ff0c18 13 * other materials provided with the distribution.
mbed_official 146:f64d43ff0c18 14 *
mbed_official 146:f64d43ff0c18 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 146:f64d43ff0c18 16 * contributors may be used to endorse or promote products derived from this
mbed_official 146:f64d43ff0c18 17 * software without specific prior written permission.
mbed_official 146:f64d43ff0c18 18 *
mbed_official 146:f64d43ff0c18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 146:f64d43ff0c18 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 146:f64d43ff0c18 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 146:f64d43ff0c18 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 146:f64d43ff0c18 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 146:f64d43ff0c18 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 146:f64d43ff0c18 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 146:f64d43ff0c18 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 146:f64d43ff0c18 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 146:f64d43ff0c18 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 146:f64d43ff0c18 29 */
mbed_official 146:f64d43ff0c18 30 #ifndef __FSL_FLEXCAN_HAL_H__
mbed_official 146:f64d43ff0c18 31 #define __FSL_FLEXCAN_HAL_H__
mbed_official 146:f64d43ff0c18 32
mbed_official 146:f64d43ff0c18 33 #include <assert.h>
mbed_official 146:f64d43ff0c18 34 #include <stdint.h>
mbed_official 146:f64d43ff0c18 35 #include <stdbool.h>
mbed_official 146:f64d43ff0c18 36 #include "fsl_flexcan_features.h"
mbed_official 146:f64d43ff0c18 37 #include "fsl_device_registers.h"
mbed_official 146:f64d43ff0c18 38
mbed_official 324:406fd2029f23 39 #ifndef MBED_NO_FLEXCAN
mbed_official 324:406fd2029f23 40
mbed_official 146:f64d43ff0c18 41 /*!
mbed_official 146:f64d43ff0c18 42 * @addtogroup flexcan_hal
mbed_official 146:f64d43ff0c18 43 * @{
mbed_official 146:f64d43ff0c18 44 */
mbed_official 146:f64d43ff0c18 45
mbed_official 146:f64d43ff0c18 46 /*******************************************************************************
mbed_official 146:f64d43ff0c18 47 * Definitions
mbed_official 146:f64d43ff0c18 48 ******************************************************************************/
mbed_official 146:f64d43ff0c18 49
mbed_official 146:f64d43ff0c18 50 /*! @brief FlexCAN constants*/
mbed_official 146:f64d43ff0c18 51 enum _flexcan_constants
mbed_official 146:f64d43ff0c18 52 {
mbed_official 146:f64d43ff0c18 53 kFlexCanMessageSize = 8, /*!< FlexCAN message buffer data size in bytes*/
mbed_official 146:f64d43ff0c18 54 };
mbed_official 146:f64d43ff0c18 55
mbed_official 146:f64d43ff0c18 56 /*! @brief The Status enum is used to report current status of the FlexCAN interface.*/
mbed_official 146:f64d43ff0c18 57 enum _flexcan_err_status
mbed_official 146:f64d43ff0c18 58 {
mbed_official 146:f64d43ff0c18 59 kFlexCan_RxWrn = 0x0080, /*!< Reached warning level for RX errors*/
mbed_official 146:f64d43ff0c18 60 kFlexCan_TxWrn = 0x0100, /*!< Reached warning level for TX errors*/
mbed_official 146:f64d43ff0c18 61 kFlexCan_StfErr = 0x0200, /*!< Stuffing Error*/
mbed_official 146:f64d43ff0c18 62 kFlexCan_FrmErr = 0x0400, /*!< Form Error*/
mbed_official 146:f64d43ff0c18 63 kFlexCan_CrcErr = 0x0800, /*!< Cyclic Redundancy Check Error*/
mbed_official 146:f64d43ff0c18 64 kFlexCan_AckErr = 0x1000, /*!< Received no ACK on transmission*/
mbed_official 146:f64d43ff0c18 65 kFlexCan_Bit0Err = 0x2000, /*!< Unable to send dominant bit*/
mbed_official 146:f64d43ff0c18 66 kFlexCan_Bit1Err = 0x4000, /*!< Unable to send recessive bit*/
mbed_official 146:f64d43ff0c18 67 };
mbed_official 146:f64d43ff0c18 68
mbed_official 146:f64d43ff0c18 69 /*! @brief FlexCAN status return codes*/
mbed_official 146:f64d43ff0c18 70 typedef enum _flexcan_status
mbed_official 146:f64d43ff0c18 71 {
mbed_official 146:f64d43ff0c18 72 kStatus_FLEXCAN_Success = 0,
mbed_official 146:f64d43ff0c18 73 kStatus_FLEXCAN_OutOfRange,
mbed_official 146:f64d43ff0c18 74 kStatus_FLEXCAN_UnknownProperty,
mbed_official 146:f64d43ff0c18 75 kStatus_FLEXCAN_InvalidArgument,
mbed_official 146:f64d43ff0c18 76 kStatus_FLEXCAN_Fail,
mbed_official 146:f64d43ff0c18 77 kStatus_FLEXCAN_TimeOut,
mbed_official 146:f64d43ff0c18 78 } flexcan_status_t;
mbed_official 146:f64d43ff0c18 79
mbed_official 146:f64d43ff0c18 80
mbed_official 146:f64d43ff0c18 81 /*! @brief FlexCAN operation modes*/
mbed_official 146:f64d43ff0c18 82 typedef enum _flexcan_operation_modes {
mbed_official 146:f64d43ff0c18 83 kFlexCanNormalMode, /*!< Normal mode or user mode*/
mbed_official 146:f64d43ff0c18 84 kFlexCanListenOnlyMode, /*!< Listen-only mode*/
mbed_official 146:f64d43ff0c18 85 kFlexCanLoopBackMode, /*!< Loop-back mode*/
mbed_official 146:f64d43ff0c18 86 kFlexCanFreezeMode, /*!< Freeze mode*/
mbed_official 146:f64d43ff0c18 87 kFlexCanDisableMode, /*!< Module disable mode*/
mbed_official 146:f64d43ff0c18 88 } flexcan_operation_modes_t;
mbed_official 146:f64d43ff0c18 89
mbed_official 146:f64d43ff0c18 90 /*! @brief FlexCAN message buffer CODE for Rx buffers*/
mbed_official 146:f64d43ff0c18 91 typedef enum _flexcan_mb_code_rx {
mbed_official 146:f64d43ff0c18 92 kFlexCanRX_Inactive = 0x0, /*!< MB is not active.*/
mbed_official 146:f64d43ff0c18 93 kFlexCanRX_Full = 0x2, /*!< MB is full.*/
mbed_official 146:f64d43ff0c18 94 kFlexCanRX_Empty = 0x4, /*!< MB is active and empty.*/
mbed_official 146:f64d43ff0c18 95 kFlexCanRX_Overrun = 0x6, /*!< MB is overwritten into a full buffer.*/
mbed_official 146:f64d43ff0c18 96 kFlexCanRX_Busy = 0x8, /*!< FlexCAN is updating the contents of the MB.*/
mbed_official 146:f64d43ff0c18 97 /*! The CPU must not access the MB.*/
mbed_official 146:f64d43ff0c18 98 kFlexCanRX_Ranswer = 0xA, /*!< A frame was configured to recognize a Remote Request Frame*/
mbed_official 146:f64d43ff0c18 99 /*! and transmit a Response Frame in return.*/
mbed_official 146:f64d43ff0c18 100 kFlexCanRX_NotUsed = 0xF, /*!< Not used*/
mbed_official 146:f64d43ff0c18 101 } flexcan_mb_code_rx_t;
mbed_official 146:f64d43ff0c18 102
mbed_official 146:f64d43ff0c18 103 /*! @brief FlexCAN message buffer CODE FOR Tx buffers*/
mbed_official 146:f64d43ff0c18 104 typedef enum _flexcan_mb_code_tx {
mbed_official 146:f64d43ff0c18 105 kFlexCanTX_Inactive = 0x08, /*!< MB is not active.*/
mbed_official 146:f64d43ff0c18 106 kFlexCanTX_Abort = 0x09, /*!< MB is aborted.*/
mbed_official 146:f64d43ff0c18 107 kFlexCanTX_Data = 0x0C, /*!< MB is a TX Data Frame(MB RTR must be 0).*/
mbed_official 146:f64d43ff0c18 108 kFlexCanTX_Remote = 0x1C, /*!< MB is a TX Remote Request Frame (MB RTR must be 1).*/
mbed_official 146:f64d43ff0c18 109 kFlexCanTX_Tanswer = 0x0E, /*!< MB is a TX Response Request Frame from.*/
mbed_official 146:f64d43ff0c18 110 /*! an incoming Remote Request Frame.*/
mbed_official 146:f64d43ff0c18 111 kFlexCanTX_NotUsed = 0xF, /*!< Not used*/
mbed_official 146:f64d43ff0c18 112 } flexcan_mb_code_tx_t;
mbed_official 146:f64d43ff0c18 113
mbed_official 146:f64d43ff0c18 114 /*! @brief FlexCAN message buffer transmission types*/
mbed_official 146:f64d43ff0c18 115 typedef enum _flexcan_mb_transmission_type {
mbed_official 146:f64d43ff0c18 116 kFlexCanMBStatusType_TX, /*!< Transmit MB*/
mbed_official 146:f64d43ff0c18 117 kFlexCanMBStatusType_TXRemote, /*!< Transmit remote request MB*/
mbed_official 146:f64d43ff0c18 118 kFlexCanMBStatusType_RX, /*!< Receive MB*/
mbed_official 146:f64d43ff0c18 119 kFlexCanMBStatusType_RXRemote, /*!< Receive remote request MB*/
mbed_official 146:f64d43ff0c18 120 kFlexCanMBStatusType_RXTXRemote, /*!< FlexCAN remote frame receives remote request and*/
mbed_official 146:f64d43ff0c18 121 /*! transmits MB.*/
mbed_official 146:f64d43ff0c18 122 } flexcan_mb_transmission_type_t;
mbed_official 146:f64d43ff0c18 123
mbed_official 146:f64d43ff0c18 124 typedef enum _flexcan_rx_fifo_id_element_format {
mbed_official 146:f64d43ff0c18 125 kFlexCanRxFifoIdElementFormat_A, /*!< One full ID (standard and extended) per ID Filter Table*/
mbed_official 146:f64d43ff0c18 126 /*! element.*/
mbed_official 146:f64d43ff0c18 127 kFlexCanRxFifoIdElementFormat_B, /*!< Two full standard IDs or two partial 14-bit (standard and*/
mbed_official 146:f64d43ff0c18 128 /*! extended) IDs per ID Filter Table element.*/
mbed_official 146:f64d43ff0c18 129 kFlexCanRxFifoIdElementFormat_C, /*!< Four partial 8-bit Standard IDs per ID Filter Table*/
mbed_official 146:f64d43ff0c18 130 /*! element.*/
mbed_official 146:f64d43ff0c18 131 kFlexCanRxFifoIdElementFormat_D, /*!< All frames rejected.*/
mbed_official 146:f64d43ff0c18 132 } flexcan_rx_fifo_id_element_format_t;
mbed_official 146:f64d43ff0c18 133
mbed_official 146:f64d43ff0c18 134 /*! @brief FlexCAN Rx FIFO filters number*/
mbed_official 146:f64d43ff0c18 135 typedef enum _flexcan_rx_fifo_id_filter_number {
mbed_official 146:f64d43ff0c18 136 kFlexCanRxFifoIDFilters_8 = 0x0, /*!< 8 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 137 kFlexCanRxFifoIDFilters_16 = 0x1, /*!< 16 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 138 kFlexCanRxFifoIDFilters_24 = 0x2, /*!< 24 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 139 kFlexCanRxFifoIDFilters_32 = 0x3, /*!< 32 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 140 kFlexCanRxFifoIDFilters_40 = 0x4, /*!< 40 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 141 kFlexCanRxFifoIDFilters_48 = 0x5, /*!< 48 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 142 kFlexCanRxFifoIDFilters_56 = 0x6, /*!< 56 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 143 kFlexCanRxFifoIDFilters_64 = 0x7, /*!< 64 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 144 kFlexCanRxFifoIDFilters_72 = 0x8, /*!< 72 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 145 kFlexCanRxFifoIDFilters_80 = 0x9, /*!< 80 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 146 kFlexCanRxFifoIDFilters_88 = 0xA, /*!< 88 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 147 kFlexCanRxFifoIDFilters_96 = 0xB, /*!< 96 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 148 kFlexCanRxFifoIDFilters_104 = 0xC, /*!< 104 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 149 kFlexCanRxFifoIDFilters_112 = 0xD, /*!< 112 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 150 kFlexCanRxFifoIDFilters_120 = 0xE, /*!< 120 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 151 kFlexCanRxFifoIDFilters_128 = 0xF /*!< 128 Rx FIFO Filters*/
mbed_official 146:f64d43ff0c18 152 } flexcan_rx_fifo_id_filter_num_t;
mbed_official 146:f64d43ff0c18 153
mbed_official 146:f64d43ff0c18 154 /*! @brief FlexCAN RX FIFO ID filter table structure*/
mbed_official 146:f64d43ff0c18 155 typedef struct FLEXCANIdTable {
mbed_official 146:f64d43ff0c18 156 bool is_remote_mb; /*!< Remote frame*/
mbed_official 146:f64d43ff0c18 157 bool is_extended_mb; /*!< Extended frame*/
mbed_official 146:f64d43ff0c18 158 uint32_t *id_filter; /*!< Rx FIFO ID filter elements*/
mbed_official 146:f64d43ff0c18 159 } flexcan_id_table_t;
mbed_official 146:f64d43ff0c18 160
mbed_official 146:f64d43ff0c18 161 /*! @brief FlexCAN RX mask type.*/
mbed_official 146:f64d43ff0c18 162 typedef enum _flexcan_rx_mask_type {
mbed_official 146:f64d43ff0c18 163 kFlexCanRxMask_Global, /*!< Rx global mask*/
mbed_official 146:f64d43ff0c18 164 kFlexCanRxMask_Individual, /*!< Rx individual mask*/
mbed_official 146:f64d43ff0c18 165 } flexcan_rx_mask_type_t;
mbed_official 146:f64d43ff0c18 166
mbed_official 146:f64d43ff0c18 167 /*! @brief FlexCAN MB ID type*/
mbed_official 146:f64d43ff0c18 168 typedef enum _flexcan_mb_id_type {
mbed_official 146:f64d43ff0c18 169 kFlexCanMbId_Std, /*!< Standard ID*/
mbed_official 146:f64d43ff0c18 170 kFlexCanMbId_Ext, /*!< Extended ID*/
mbed_official 146:f64d43ff0c18 171 } flexcan_mb_id_type_t;
mbed_official 146:f64d43ff0c18 172
mbed_official 146:f64d43ff0c18 173 /*! @brief FlexCAN clock source*/
mbed_official 146:f64d43ff0c18 174 typedef enum _flexcan_clk_source {
mbed_official 146:f64d43ff0c18 175 kFlexCanClkSource_Osc, /*!< Oscillator clock*/
mbed_official 146:f64d43ff0c18 176 kFlexCanClkSource_Ipbus, /*!< Peripheral clock*/
mbed_official 146:f64d43ff0c18 177 } flexcan_clk_source_t;
mbed_official 146:f64d43ff0c18 178
mbed_official 146:f64d43ff0c18 179 /*! @brief FlexCAN error interrupt types*/
mbed_official 146:f64d43ff0c18 180 typedef enum _flexcan_int_type {
mbed_official 146:f64d43ff0c18 181 kFlexCanInt_Buf, /*!< OR'd message buffers interrupt*/
mbed_official 146:f64d43ff0c18 182 kFlexCanInt_Err, /*!< Error interrupt*/
mbed_official 146:f64d43ff0c18 183 kFlexCanInt_Boff, /*!< Bus off interrupt*/
mbed_official 146:f64d43ff0c18 184 kFlexCanInt_Wakeup, /*!< Wakeup interrupt*/
mbed_official 146:f64d43ff0c18 185 kFlexCanInt_Txwarning, /*!< TX warning interrupt*/
mbed_official 146:f64d43ff0c18 186 kFlexCanInt_Rxwarning, /*!< RX warning interrupt*/
mbed_official 146:f64d43ff0c18 187 } flexcan_int_type_t;
mbed_official 146:f64d43ff0c18 188
mbed_official 146:f64d43ff0c18 189 /*! @brief FlexCAN bus error counters*/
mbed_official 146:f64d43ff0c18 190 typedef struct FLEXCANBerrCounter {
mbed_official 146:f64d43ff0c18 191 uint16_t txerr; /*!< Transmit error counter*/
mbed_official 146:f64d43ff0c18 192 uint16_t rxerr; /*!< Receive error counter*/
mbed_official 146:f64d43ff0c18 193 } flexcan_berr_counter_t;
mbed_official 146:f64d43ff0c18 194
mbed_official 324:406fd2029f23 195 /*! @brief FlexCAN MB code and status for transmit and receive */
mbed_official 324:406fd2029f23 196 typedef struct FLEXCANMbCodeStatus {
mbed_official 324:406fd2029f23 197 uint32_t code; /*!< MB code for TX or RX buffers.
mbed_official 324:406fd2029f23 198 Defined by flexcan_mb_code_rx_t and flexcan_mb_code_tx_t */
mbed_official 324:406fd2029f23 199 flexcan_mb_id_type_t msg_id_type; /*!< Type of message ID (standard or extended)*/
mbed_official 324:406fd2029f23 200 uint32_t data_length; /*!< Length of Data in Bytes*/
mbed_official 324:406fd2029f23 201 } flexcan_mb_code_status_t;
mbed_official 146:f64d43ff0c18 202
mbed_official 146:f64d43ff0c18 203 /*! @brief FlexCAN message buffer structure*/
mbed_official 146:f64d43ff0c18 204 typedef struct FLEXCANMb {
mbed_official 146:f64d43ff0c18 205 uint32_t cs; /*!< Code and Status*/
mbed_official 146:f64d43ff0c18 206 uint32_t msg_id; /*!< Message Buffer ID*/
mbed_official 146:f64d43ff0c18 207 uint8_t data[kFlexCanMessageSize]; /*!< Bytes of the FlexCAN message*/
mbed_official 146:f64d43ff0c18 208 } flexcan_mb_t;
mbed_official 146:f64d43ff0c18 209
mbed_official 146:f64d43ff0c18 210 /*! @brief FlexCAN configuration*/
mbed_official 146:f64d43ff0c18 211 typedef struct FLEXCANUserConfig {
mbed_official 146:f64d43ff0c18 212 uint32_t max_num_mb; /*!< The maximum number of Message Buffers*/
mbed_official 146:f64d43ff0c18 213 flexcan_rx_fifo_id_filter_num_t num_id_filters; /*!< The number of Rx FIFO ID filters needed*/
mbed_official 146:f64d43ff0c18 214 bool is_rx_fifo_needed; /*!< 1 if needed; 0 if not*/
mbed_official 146:f64d43ff0c18 215 } flexcan_user_config_t;
mbed_official 146:f64d43ff0c18 216
mbed_official 146:f64d43ff0c18 217 /*! @brief FlexCAN timing related structures*/
mbed_official 146:f64d43ff0c18 218 typedef struct FLEXCANTimeSegment {
mbed_official 146:f64d43ff0c18 219 uint32_t propseg; /*!< Propagation segment*/
mbed_official 146:f64d43ff0c18 220 uint32_t pseg1; /*!< Phase segment 1*/
mbed_official 146:f64d43ff0c18 221 uint32_t pseg2; /*!< Phase segment 2*/
mbed_official 146:f64d43ff0c18 222 uint32_t pre_divider; /*!< Clock pre divider*/
mbed_official 146:f64d43ff0c18 223 uint32_t rjw; /*!< Resync jump width*/
mbed_official 146:f64d43ff0c18 224 } flexcan_time_segment_t;
mbed_official 146:f64d43ff0c18 225
mbed_official 146:f64d43ff0c18 226
mbed_official 146:f64d43ff0c18 227 /*******************************************************************************
mbed_official 146:f64d43ff0c18 228 * API
mbed_official 146:f64d43ff0c18 229 ******************************************************************************/
mbed_official 146:f64d43ff0c18 230
mbed_official 146:f64d43ff0c18 231 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 232 extern "C" {
mbed_official 146:f64d43ff0c18 233 #endif
mbed_official 146:f64d43ff0c18 234
mbed_official 146:f64d43ff0c18 235 /*!
mbed_official 146:f64d43ff0c18 236 * @name Configuration
mbed_official 146:f64d43ff0c18 237 * @{
mbed_official 146:f64d43ff0c18 238 */
mbed_official 146:f64d43ff0c18 239
mbed_official 146:f64d43ff0c18 240 /*!
mbed_official 146:f64d43ff0c18 241 * @brief Enables FlexCAN controller.
mbed_official 146:f64d43ff0c18 242 *
mbed_official 324:406fd2029f23 243 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 244 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 245 */
mbed_official 324:406fd2029f23 246 flexcan_status_t FLEXCAN_HAL_Enable(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 247
mbed_official 146:f64d43ff0c18 248 /*!
mbed_official 146:f64d43ff0c18 249 * @brief Disables FlexCAN controller.
mbed_official 146:f64d43ff0c18 250 *
mbed_official 324:406fd2029f23 251 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 252 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 253 */
mbed_official 324:406fd2029f23 254 flexcan_status_t FLEXCAN_HAL_Disable(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 255
mbed_official 146:f64d43ff0c18 256 /*!
mbed_official 146:f64d43ff0c18 257 * @brief Checks whether the FlexCAN is enabled or disabled.
mbed_official 146:f64d43ff0c18 258 *
mbed_official 324:406fd2029f23 259 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 260 * @return State of FlexCAN enable(0)/disable(1)
mbed_official 146:f64d43ff0c18 261 */
mbed_official 324:406fd2029f23 262 static inline bool FLEXCAN_HAL_IsEnabled(uint32_t canBaseAddr)
mbed_official 146:f64d43ff0c18 263 {
mbed_official 324:406fd2029f23 264 return BR_CAN_MCR_MDIS(canBaseAddr);
mbed_official 146:f64d43ff0c18 265 }
mbed_official 146:f64d43ff0c18 266
mbed_official 146:f64d43ff0c18 267 /*!
mbed_official 146:f64d43ff0c18 268 * @brief Selects the clock source for FlexCAN.
mbed_official 146:f64d43ff0c18 269 *
mbed_official 324:406fd2029f23 270 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 271 * @param clk The FlexCAN clock source
mbed_official 146:f64d43ff0c18 272 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 273 */
mbed_official 324:406fd2029f23 274 flexcan_status_t FLEXCAN_HAL_SelectClock(uint32_t canBaseAddr, flexcan_clk_source_t clk);
mbed_official 146:f64d43ff0c18 275
mbed_official 146:f64d43ff0c18 276 /*!
mbed_official 146:f64d43ff0c18 277 * @brief Initializes the FlexCAN controller.
mbed_official 146:f64d43ff0c18 278 *
mbed_official 324:406fd2029f23 279 * @param canBaseAddr The FlexCAN base address
mbed_official 324:406fd2029f23 280 * @param data The FlexCAN platform data.
mbed_official 146:f64d43ff0c18 281 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 282 */
mbed_official 324:406fd2029f23 283 flexcan_status_t FLEXCAN_HAL_Init(uint32_t canBaseAddr, const flexcan_user_config_t *data);
mbed_official 146:f64d43ff0c18 284
mbed_official 146:f64d43ff0c18 285 /*!
mbed_official 146:f64d43ff0c18 286 * @brief Sets the FlexCAN time segments for setting up bit rate.
mbed_official 146:f64d43ff0c18 287 *
mbed_official 324:406fd2029f23 288 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 289 * @param time_seg FlexCAN time segments, which need to be set for the bit rate.
mbed_official 146:f64d43ff0c18 290 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 291 */
mbed_official 324:406fd2029f23 292 void FLEXCAN_HAL_SetTimeSegments(uint32_t canBaseAddr, flexcan_time_segment_t *time_seg);
mbed_official 146:f64d43ff0c18 293
mbed_official 146:f64d43ff0c18 294 /*!
mbed_official 146:f64d43ff0c18 295 * @brief Gets the FlexCAN time segments to calculate the bit rate.
mbed_official 146:f64d43ff0c18 296 *
mbed_official 324:406fd2029f23 297 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 298 * @param time_seg FlexCAN time segments read for bit rate
mbed_official 146:f64d43ff0c18 299 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 300 */
mbed_official 324:406fd2029f23 301 void FLEXCAN_HAL_GetTimeSegments(uint32_t canBaseAddr, flexcan_time_segment_t *time_seg);
mbed_official 146:f64d43ff0c18 302
mbed_official 146:f64d43ff0c18 303 /*!
mbed_official 146:f64d43ff0c18 304 * @brief Un freezes the FlexCAN module.
mbed_official 146:f64d43ff0c18 305 *
mbed_official 324:406fd2029f23 306 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 307 * @return 0 if successful; non-zero failed.
mbed_official 146:f64d43ff0c18 308 */
mbed_official 324:406fd2029f23 309 void FLEXCAN_HAL_ExitFreezeMode(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 310
mbed_official 146:f64d43ff0c18 311 /*!
mbed_official 146:f64d43ff0c18 312 * @brief Freezes the FlexCAN module.
mbed_official 146:f64d43ff0c18 313 *
mbed_official 324:406fd2029f23 314 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 315 */
mbed_official 324:406fd2029f23 316 void FLEXCAN_HAL_EnterFreezeMode(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 317
mbed_official 146:f64d43ff0c18 318 /*!
mbed_official 146:f64d43ff0c18 319 * @brief Enables operation mode.
mbed_official 146:f64d43ff0c18 320 *
mbed_official 324:406fd2029f23 321 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 322 * @param mode An operation mode to be enabled
mbed_official 146:f64d43ff0c18 323 * @return 0 if successful; non-zero failed.
mbed_official 146:f64d43ff0c18 324 */
mbed_official 324:406fd2029f23 325 flexcan_status_t FLEXCAN_HAL_EnableOperationMode(
mbed_official 324:406fd2029f23 326 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 327 flexcan_operation_modes_t mode);
mbed_official 146:f64d43ff0c18 328
mbed_official 146:f64d43ff0c18 329 /*!
mbed_official 146:f64d43ff0c18 330 * @brief Disables operation mode.
mbed_official 146:f64d43ff0c18 331 *
mbed_official 324:406fd2029f23 332 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 333 * @param mode An operation mode to be disabled
mbed_official 146:f64d43ff0c18 334 * @return 0 if successful; non-zero failed.
mbed_official 146:f64d43ff0c18 335 */
mbed_official 324:406fd2029f23 336 flexcan_status_t FLEXCAN_HAL_DisableOperationMode(
mbed_official 324:406fd2029f23 337 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 338 flexcan_operation_modes_t mode);
mbed_official 146:f64d43ff0c18 339
mbed_official 146:f64d43ff0c18 340 /*@}*/
mbed_official 146:f64d43ff0c18 341
mbed_official 146:f64d43ff0c18 342 /*!
mbed_official 146:f64d43ff0c18 343 * @name Data transfer
mbed_official 146:f64d43ff0c18 344 * @{
mbed_official 146:f64d43ff0c18 345 */
mbed_official 146:f64d43ff0c18 346
mbed_official 146:f64d43ff0c18 347 /*!
mbed_official 146:f64d43ff0c18 348 * @brief Sets the FlexCAN message buffer fields for transmitting.
mbed_official 146:f64d43ff0c18 349 *
mbed_official 324:406fd2029f23 350 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 351 * @param data The FlexCAN platform data
mbed_official 146:f64d43ff0c18 352 * @param mb_idx Index of the message buffer
mbed_official 146:f64d43ff0c18 353 * @param cs CODE/status values (TX)
mbed_official 146:f64d43ff0c18 354 * @param msg_id ID of the message to transmit
mbed_official 146:f64d43ff0c18 355 * @param mb_data Bytes of the FlexCAN message
mbed_official 146:f64d43ff0c18 356 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 357 */
mbed_official 324:406fd2029f23 358 flexcan_status_t FLEXCAN_HAL_SetMbTx(
mbed_official 324:406fd2029f23 359 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 360 const flexcan_user_config_t *data,
mbed_official 146:f64d43ff0c18 361 uint32_t mb_idx,
mbed_official 324:406fd2029f23 362 flexcan_mb_code_status_t *cs,
mbed_official 146:f64d43ff0c18 363 uint32_t msg_id,
mbed_official 146:f64d43ff0c18 364 uint8_t *mb_data);
mbed_official 146:f64d43ff0c18 365
mbed_official 146:f64d43ff0c18 366 /*!
mbed_official 324:406fd2029f23 367 * @brief Sets the FlexCAN message buffer fields for receiving.
mbed_official 146:f64d43ff0c18 368 *
mbed_official 324:406fd2029f23 369 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 370 * @param data The FlexCAN platform data
mbed_official 146:f64d43ff0c18 371 * @param mb_idx Index of the message buffer
mbed_official 146:f64d43ff0c18 372 * @param cs CODE/status values (RX)
mbed_official 146:f64d43ff0c18 373 * @param msg_id ID of the message to receive
mbed_official 146:f64d43ff0c18 374 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 375 */
mbed_official 324:406fd2029f23 376 flexcan_status_t FLEXCAN_HAL_SetMbRx(
mbed_official 324:406fd2029f23 377 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 378 const flexcan_user_config_t *data,
mbed_official 146:f64d43ff0c18 379 uint32_t mb_idx,
mbed_official 324:406fd2029f23 380 flexcan_mb_code_status_t *cs,
mbed_official 146:f64d43ff0c18 381 uint32_t msg_id);
mbed_official 146:f64d43ff0c18 382
mbed_official 146:f64d43ff0c18 383 /*!
mbed_official 146:f64d43ff0c18 384 * @brief Gets the FlexCAN message buffer fields.
mbed_official 146:f64d43ff0c18 385 *
mbed_official 324:406fd2029f23 386 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 387 * @param data The FlexCAN platform data
mbed_official 146:f64d43ff0c18 388 * @param mb_idx Index of the message buffer
mbed_official 146:f64d43ff0c18 389 * @param mb The fields of the message buffer
mbed_official 146:f64d43ff0c18 390 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 391 */
mbed_official 324:406fd2029f23 392 flexcan_status_t FLEXCAN_HAL_GetMb(
mbed_official 324:406fd2029f23 393 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 394 const flexcan_user_config_t *data,
mbed_official 146:f64d43ff0c18 395 uint32_t mb_idx,
mbed_official 146:f64d43ff0c18 396 flexcan_mb_t *mb);
mbed_official 146:f64d43ff0c18 397
mbed_official 146:f64d43ff0c18 398 /*!
mbed_official 146:f64d43ff0c18 399 * @brief Locks the FlexCAN Rx message buffer.
mbed_official 146:f64d43ff0c18 400 *
mbed_official 324:406fd2029f23 401 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 402 * @param data The FlexCAN platform data
mbed_official 146:f64d43ff0c18 403 * @param mb_idx Index of the message buffer
mbed_official 146:f64d43ff0c18 404 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 405 */
mbed_official 324:406fd2029f23 406 flexcan_status_t FLEXCAN_HAL_LockRxMb(
mbed_official 324:406fd2029f23 407 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 408 const flexcan_user_config_t *data,
mbed_official 146:f64d43ff0c18 409 uint32_t mb_idx);
mbed_official 146:f64d43ff0c18 410
mbed_official 146:f64d43ff0c18 411 /*!
mbed_official 146:f64d43ff0c18 412 * @brief Unlocks the FlexCAN Rx message buffer.
mbed_official 146:f64d43ff0c18 413 *
mbed_official 324:406fd2029f23 414 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 415 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 416 */
mbed_official 324:406fd2029f23 417 static inline void FLEXCAN_HAL_UnlockRxMb(uint32_t canBaseAddr)
mbed_official 146:f64d43ff0c18 418 {
mbed_official 146:f64d43ff0c18 419 /* Unlock the mailbox */
mbed_official 324:406fd2029f23 420 HW_CAN_TIMER_RD(canBaseAddr);
mbed_official 146:f64d43ff0c18 421 }
mbed_official 146:f64d43ff0c18 422
mbed_official 146:f64d43ff0c18 423 /*!
mbed_official 146:f64d43ff0c18 424 * @brief Enables the Rx FIFO.
mbed_official 146:f64d43ff0c18 425 *
mbed_official 324:406fd2029f23 426 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 427 */
mbed_official 324:406fd2029f23 428 void FLEXCAN_HAL_EnableRxFifo(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 429
mbed_official 146:f64d43ff0c18 430 /*!
mbed_official 146:f64d43ff0c18 431 * @brief Disables the Rx FIFO.
mbed_official 146:f64d43ff0c18 432 *
mbed_official 324:406fd2029f23 433 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 434 */
mbed_official 324:406fd2029f23 435 void FLEXCAN_HAL_DisableRxFifo(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 436
mbed_official 146:f64d43ff0c18 437 /*!
mbed_official 146:f64d43ff0c18 438 * @brief Sets the number of the Rx FIFO filters.
mbed_official 146:f64d43ff0c18 439 *
mbed_official 324:406fd2029f23 440 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 441 * @param number The number of Rx FIFO filters
mbed_official 146:f64d43ff0c18 442 */
mbed_official 324:406fd2029f23 443 void FLEXCAN_HAL_SetRxFifoFiltersNumber(uint32_t canBaseAddr, uint32_t number);
mbed_official 146:f64d43ff0c18 444
mbed_official 146:f64d43ff0c18 445 /*!
mbed_official 146:f64d43ff0c18 446 * @brief Sets the maximum number of Message Buffers.
mbed_official 146:f64d43ff0c18 447 *
mbed_official 324:406fd2029f23 448 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 449 * @param data The FlexCAN platform data
mbed_official 146:f64d43ff0c18 450 */
mbed_official 324:406fd2029f23 451 void FLEXCAN_HAL_SetMaxMbNumber(
mbed_official 324:406fd2029f23 452 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 453 const flexcan_user_config_t *data);
mbed_official 146:f64d43ff0c18 454
mbed_official 146:f64d43ff0c18 455 /*!
mbed_official 146:f64d43ff0c18 456 * @brief Sets the Rx FIFO ID filter table elements.
mbed_official 146:f64d43ff0c18 457 *
mbed_official 324:406fd2029f23 458 * @param canBaseAddr The FlexCAN base address
mbed_official 324:406fd2029f23 459 * @param data The FlexCAN platform data
mbed_official 324:406fd2029f23 460 * @param id_format The format of the Rx FIFO ID Filter Table Elements
mbed_official 324:406fd2029f23 461 * @param id_filter_table The ID filter table elements which contain if RTR bit,
mbed_official 324:406fd2029f23 462 * IDE bit and RX message ID need to be set.
mbed_official 146:f64d43ff0c18 463 * @return 0 if successful; non-zero failed.
mbed_official 146:f64d43ff0c18 464 */
mbed_official 324:406fd2029f23 465 flexcan_status_t FLEXCAN_HAL_SetIdFilterTableElements(
mbed_official 324:406fd2029f23 466 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 467 const flexcan_user_config_t *data,
mbed_official 146:f64d43ff0c18 468 flexcan_rx_fifo_id_element_format_t id_format,
mbed_official 146:f64d43ff0c18 469 flexcan_id_table_t *id_filter_table);
mbed_official 146:f64d43ff0c18 470
mbed_official 146:f64d43ff0c18 471 /*!
mbed_official 146:f64d43ff0c18 472 * @brief Sets the FlexCAN Rx FIFO fields.
mbed_official 146:f64d43ff0c18 473 *
mbed_official 324:406fd2029f23 474 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 475 * @param data The FlexCAN platform data
mbed_official 146:f64d43ff0c18 476 * @param id_format The format of the Rx FIFO ID Filter Table Elements
mbed_official 146:f64d43ff0c18 477 * @param id_filter_table The ID filter table elements which contain RTR bit, IDE bit,
mbed_official 146:f64d43ff0c18 478 * and RX message ID.
mbed_official 146:f64d43ff0c18 479 * @return 0 if successful; non-zero failed.
mbed_official 146:f64d43ff0c18 480 */
mbed_official 324:406fd2029f23 481 flexcan_status_t FLEXCAN_HAL_SetRxFifo(
mbed_official 324:406fd2029f23 482 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 483 const flexcan_user_config_t *data,
mbed_official 146:f64d43ff0c18 484 flexcan_rx_fifo_id_element_format_t id_format,
mbed_official 146:f64d43ff0c18 485 flexcan_id_table_t *id_filter_table);
mbed_official 146:f64d43ff0c18 486
mbed_official 146:f64d43ff0c18 487 /*!
mbed_official 146:f64d43ff0c18 488 * @brief Gets the FlexCAN Rx FIFO data.
mbed_official 146:f64d43ff0c18 489 *
mbed_official 324:406fd2029f23 490 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 491 * @param rx_fifo The FlexCAN receive FIFO data
mbed_official 146:f64d43ff0c18 492 * @return 0 if successful; non-zero failed.
mbed_official 146:f64d43ff0c18 493 */
mbed_official 324:406fd2029f23 494 flexcan_status_t FLEXCAN_HAL_ReadFifo(
mbed_official 324:406fd2029f23 495 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 496 flexcan_mb_t *rx_fifo);
mbed_official 146:f64d43ff0c18 497
mbed_official 146:f64d43ff0c18 498 /*@}*/
mbed_official 146:f64d43ff0c18 499
mbed_official 146:f64d43ff0c18 500 /*!
mbed_official 146:f64d43ff0c18 501 * @name Interrupts
mbed_official 146:f64d43ff0c18 502 * @{
mbed_official 146:f64d43ff0c18 503 */
mbed_official 146:f64d43ff0c18 504
mbed_official 146:f64d43ff0c18 505 /*!
mbed_official 146:f64d43ff0c18 506 * @brief Enables the FlexCAN Message Buffer interrupt.
mbed_official 146:f64d43ff0c18 507 *
mbed_official 324:406fd2029f23 508 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 509 * @param data The FlexCAN platform data
mbed_official 146:f64d43ff0c18 510 * @param mb_idx Index of the message buffer
mbed_official 146:f64d43ff0c18 511 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 512 */
mbed_official 324:406fd2029f23 513 flexcan_status_t FLEXCAN_HAL_EnableMbInt(
mbed_official 324:406fd2029f23 514 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 515 const flexcan_user_config_t *data,
mbed_official 146:f64d43ff0c18 516 uint32_t mb_idx);
mbed_official 146:f64d43ff0c18 517
mbed_official 146:f64d43ff0c18 518 /*!
mbed_official 146:f64d43ff0c18 519 * @brief Disables the FlexCAN Message Buffer interrupt.
mbed_official 146:f64d43ff0c18 520 *
mbed_official 324:406fd2029f23 521 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 522 * @param data The FlexCAN platform data
mbed_official 146:f64d43ff0c18 523 * @param mb_idx Index of the message buffer
mbed_official 146:f64d43ff0c18 524 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 525 */
mbed_official 324:406fd2029f23 526 flexcan_status_t FLEXCAN_HAL_DisableMbInt(
mbed_official 324:406fd2029f23 527 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 528 const flexcan_user_config_t *data,
mbed_official 146:f64d43ff0c18 529 uint32_t mb_idx);
mbed_official 146:f64d43ff0c18 530
mbed_official 146:f64d43ff0c18 531 /*!
mbed_official 146:f64d43ff0c18 532 * @brief Enables error interrupt of the FlexCAN module.
mbed_official 324:406fd2029f23 533 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 534 */
mbed_official 324:406fd2029f23 535 void FLEXCAN_HAL_EnableErrInt(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 536
mbed_official 146:f64d43ff0c18 537 /*!
mbed_official 146:f64d43ff0c18 538 * @brief Disables error interrupt of the FlexCAN module.
mbed_official 146:f64d43ff0c18 539 *
mbed_official 324:406fd2029f23 540 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 541 */
mbed_official 324:406fd2029f23 542 void FLEXCAN_HAL_DisableErrInt(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 543
mbed_official 146:f64d43ff0c18 544 /*!
mbed_official 146:f64d43ff0c18 545 * @brief Enables Bus off interrupt of the FlexCAN module.
mbed_official 146:f64d43ff0c18 546 *
mbed_official 324:406fd2029f23 547 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 548 */
mbed_official 324:406fd2029f23 549 void FLEXCAN_HAL_EnableBusOffInt(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 550
mbed_official 146:f64d43ff0c18 551 /*!
mbed_official 146:f64d43ff0c18 552 * @brief Disables Bus off interrupt of the FlexCAN module.
mbed_official 146:f64d43ff0c18 553 *
mbed_official 324:406fd2029f23 554 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 555 */
mbed_official 324:406fd2029f23 556 void FLEXCAN_HAL_DisableBusOffInt(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 557
mbed_official 146:f64d43ff0c18 558 /*!
mbed_official 146:f64d43ff0c18 559 * @brief Enables Wakeup interrupt of the FlexCAN module.
mbed_official 146:f64d43ff0c18 560 *
mbed_official 324:406fd2029f23 561 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 562 */
mbed_official 324:406fd2029f23 563 void FLEXCAN_HAL_EnableWakeupInt(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 564
mbed_official 146:f64d43ff0c18 565 /*!
mbed_official 146:f64d43ff0c18 566 * @brief Disables Wakeup interrupt of the FlexCAN module.
mbed_official 146:f64d43ff0c18 567 *
mbed_official 324:406fd2029f23 568 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 569 */
mbed_official 324:406fd2029f23 570 void FLEXCAN_HAL_DisableWakeupInt(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 571
mbed_official 146:f64d43ff0c18 572 /*!
mbed_official 146:f64d43ff0c18 573 * @brief Enables TX warning interrupt of the FlexCAN module
mbed_official 146:f64d43ff0c18 574 *
mbed_official 324:406fd2029f23 575 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 576 */
mbed_official 324:406fd2029f23 577 void FLEXCAN_HAL_EnableTxWarningInt(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 578
mbed_official 146:f64d43ff0c18 579 /*!
mbed_official 146:f64d43ff0c18 580 * @brief Disables TX warning interrupt of the FlexCAN module.
mbed_official 146:f64d43ff0c18 581 *
mbed_official 324:406fd2029f23 582 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 583 */
mbed_official 324:406fd2029f23 584 void FLEXCAN_HAL_DisableTxWarningInt(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 585
mbed_official 146:f64d43ff0c18 586 /*!
mbed_official 146:f64d43ff0c18 587 * @brief Enables RX warning interrupt of the FlexCAN module.
mbed_official 146:f64d43ff0c18 588 *
mbed_official 324:406fd2029f23 589 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 590 */
mbed_official 324:406fd2029f23 591 void FLEXCAN_HAL_EnableRxWarningInt(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 592
mbed_official 146:f64d43ff0c18 593 /*!
mbed_official 146:f64d43ff0c18 594 * @brief Disables RX warning interrupt of the FlexCAN module.
mbed_official 146:f64d43ff0c18 595 *
mbed_official 324:406fd2029f23 596 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 597 */
mbed_official 324:406fd2029f23 598 void FLEXCAN_HAL_DisableRxWarningInt(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 599
mbed_official 146:f64d43ff0c18 600 /*@}*/
mbed_official 146:f64d43ff0c18 601
mbed_official 146:f64d43ff0c18 602 /*!
mbed_official 146:f64d43ff0c18 603 * @name Status
mbed_official 146:f64d43ff0c18 604 * @{
mbed_official 146:f64d43ff0c18 605 */
mbed_official 146:f64d43ff0c18 606
mbed_official 146:f64d43ff0c18 607 /*!
mbed_official 146:f64d43ff0c18 608 * @brief Gets the value of FlexCAN freeze ACK.
mbed_official 146:f64d43ff0c18 609 *
mbed_official 324:406fd2029f23 610 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 611 * @return freeze ACK state (1-freeze mode, 0-not in freeze mode).
mbed_official 146:f64d43ff0c18 612 */
mbed_official 324:406fd2029f23 613 static inline uint32_t FLEXCAN_HAL_GetFreezeAck(uint32_t canBaseAddr)
mbed_official 146:f64d43ff0c18 614 {
mbed_official 324:406fd2029f23 615 return HW_CAN_MCR(canBaseAddr).B.FRZACK;
mbed_official 146:f64d43ff0c18 616 }
mbed_official 146:f64d43ff0c18 617
mbed_official 146:f64d43ff0c18 618 /*!
mbed_official 146:f64d43ff0c18 619 * @brief Gets the individual FlexCAN MB interrupt flag.
mbed_official 146:f64d43ff0c18 620 *
mbed_official 324:406fd2029f23 621 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 622 * @param data The FlexCAN platform data
mbed_official 146:f64d43ff0c18 623 * @param mb_idx Index of the message buffer
mbed_official 146:f64d43ff0c18 624 * @return the individual MB interrupt flag (0 and 1 are the flag value)
mbed_official 146:f64d43ff0c18 625 */
mbed_official 324:406fd2029f23 626 uint8_t FLEXCAN_HAL_GetMbIntFlag(
mbed_official 324:406fd2029f23 627 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 628 const flexcan_user_config_t *data,
mbed_official 146:f64d43ff0c18 629 uint32_t mb_idx);
mbed_official 146:f64d43ff0c18 630
mbed_official 146:f64d43ff0c18 631 /*!
mbed_official 146:f64d43ff0c18 632 * @brief Gets all FlexCAN MB interrupt flags.
mbed_official 146:f64d43ff0c18 633 *
mbed_official 324:406fd2029f23 634 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 635 * @return all MB interrupt flags
mbed_official 146:f64d43ff0c18 636 */
mbed_official 324:406fd2029f23 637 static inline uint32_t FLEXCAN_HAL_GetAllMbIntFlags(uint32_t canBaseAddr)
mbed_official 146:f64d43ff0c18 638 {
mbed_official 324:406fd2029f23 639 return HW_CAN_IFLAG1_RD(canBaseAddr);
mbed_official 146:f64d43ff0c18 640 }
mbed_official 146:f64d43ff0c18 641
mbed_official 146:f64d43ff0c18 642 /*!
mbed_official 146:f64d43ff0c18 643 * @brief Clears the interrupt flag of the message buffers.
mbed_official 146:f64d43ff0c18 644 *
mbed_official 324:406fd2029f23 645 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 646 * @param reg_val The value to be written to the interrupt flag1 register.
mbed_official 146:f64d43ff0c18 647 */
mbed_official 146:f64d43ff0c18 648 /* See fsl_flexcan_hal.h for documentation of this function.*/
mbed_official 324:406fd2029f23 649 static inline void FLEXCAN_HAL_ClearMbIntFlag(
mbed_official 324:406fd2029f23 650 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 651 uint32_t reg_val)
mbed_official 146:f64d43ff0c18 652 {
mbed_official 146:f64d43ff0c18 653 /* Clear the corresponding message buffer interrupt flag*/
mbed_official 324:406fd2029f23 654 HW_CAN_IFLAG1_SET(canBaseAddr, reg_val);
mbed_official 146:f64d43ff0c18 655 }
mbed_official 146:f64d43ff0c18 656
mbed_official 146:f64d43ff0c18 657 /*!
mbed_official 146:f64d43ff0c18 658 * @brief Gets the transmit error counter and receives the error counter.
mbed_official 146:f64d43ff0c18 659 *
mbed_official 324:406fd2029f23 660 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 661 * @param err_cnt Transmit error counter and receive error counter
mbed_official 146:f64d43ff0c18 662 */
mbed_official 324:406fd2029f23 663 void FLEXCAN_HAL_GetErrCounter(
mbed_official 324:406fd2029f23 664 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 665 flexcan_berr_counter_t *err_cnt);
mbed_official 146:f64d43ff0c18 666
mbed_official 146:f64d43ff0c18 667 /*!
mbed_official 146:f64d43ff0c18 668 * @brief Gets error and status.
mbed_official 146:f64d43ff0c18 669 *
mbed_official 324:406fd2029f23 670 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 671 * @return The current error and status
mbed_official 146:f64d43ff0c18 672 */
mbed_official 324:406fd2029f23 673 static inline uint32_t FLEXCAN_HAL_GetErrStatus(uint32_t canBaseAddr)
mbed_official 146:f64d43ff0c18 674 {
mbed_official 324:406fd2029f23 675 return HW_CAN_ESR1_RD(canBaseAddr);
mbed_official 146:f64d43ff0c18 676 }
mbed_official 146:f64d43ff0c18 677
mbed_official 146:f64d43ff0c18 678 /*!
mbed_official 146:f64d43ff0c18 679 * @brief Clears all other interrupts in ERRSTAT register (Error, Busoff, Wakeup).
mbed_official 146:f64d43ff0c18 680 *
mbed_official 324:406fd2029f23 681 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 682 */
mbed_official 324:406fd2029f23 683 void FLEXCAN_HAL_ClearErrIntStatus(uint32_t canBaseAddr);
mbed_official 146:f64d43ff0c18 684
mbed_official 146:f64d43ff0c18 685 /*@}*/
mbed_official 146:f64d43ff0c18 686
mbed_official 146:f64d43ff0c18 687 /*!
mbed_official 146:f64d43ff0c18 688 * @name Mask
mbed_official 146:f64d43ff0c18 689 * @{
mbed_official 146:f64d43ff0c18 690 */
mbed_official 146:f64d43ff0c18 691
mbed_official 146:f64d43ff0c18 692 /*!
mbed_official 146:f64d43ff0c18 693 * @brief Sets the Rx masking type.
mbed_official 146:f64d43ff0c18 694 *
mbed_official 324:406fd2029f23 695 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 696 * @param type The FlexCAN Rx mask type
mbed_official 146:f64d43ff0c18 697 */
mbed_official 324:406fd2029f23 698 void FLEXCAN_HAL_SetMaskType(uint32_t canBaseAddr, flexcan_rx_mask_type_t type);
mbed_official 146:f64d43ff0c18 699
mbed_official 146:f64d43ff0c18 700 /*!
mbed_official 146:f64d43ff0c18 701 * @brief Sets the FlexCAN RX FIFO global standard mask.
mbed_official 146:f64d43ff0c18 702 *
mbed_official 324:406fd2029f23 703 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 704 * @param std_mask Standard mask
mbed_official 146:f64d43ff0c18 705 */
mbed_official 324:406fd2029f23 706 void FLEXCAN_HAL_SetRxFifoGlobalStdMask(
mbed_official 324:406fd2029f23 707 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 708 uint32_t std_mask);
mbed_official 146:f64d43ff0c18 709
mbed_official 146:f64d43ff0c18 710 /*!
mbed_official 146:f64d43ff0c18 711 * @brief Sets the FlexCAN Rx FIFO global extended mask.
mbed_official 146:f64d43ff0c18 712 *
mbed_official 324:406fd2029f23 713 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 714 * @param ext_mask Extended mask
mbed_official 146:f64d43ff0c18 715 */
mbed_official 324:406fd2029f23 716 void FLEXCAN_HAL_SetRxFifoGlobalExtMask(
mbed_official 324:406fd2029f23 717 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 718 uint32_t ext_mask);
mbed_official 146:f64d43ff0c18 719
mbed_official 146:f64d43ff0c18 720 /*!
mbed_official 146:f64d43ff0c18 721 * @brief Sets the FlexCAN Rx individual standard mask for ID filtering in the Rx MBs and the Rx FIFO.
mbed_official 146:f64d43ff0c18 722 *
mbed_official 324:406fd2029f23 723 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 724 * @param data The FlexCAN platform data
mbed_official 146:f64d43ff0c18 725 * @param mb_idx Index of the message buffer
mbed_official 146:f64d43ff0c18 726 * @param std_mask Individual standard mask
mbed_official 146:f64d43ff0c18 727 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 728 */
mbed_official 324:406fd2029f23 729 flexcan_status_t FLEXCAN_HAL_SetRxIndividualStdMask(
mbed_official 324:406fd2029f23 730 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 731 const flexcan_user_config_t * data,
mbed_official 146:f64d43ff0c18 732 uint32_t mb_idx,
mbed_official 146:f64d43ff0c18 733 uint32_t std_mask);
mbed_official 146:f64d43ff0c18 734
mbed_official 146:f64d43ff0c18 735 /*!
mbed_official 146:f64d43ff0c18 736 * @brief Sets the FlexCAN Rx individual extended mask for ID filtering in the Rx MBs and the Rx FIFO.
mbed_official 146:f64d43ff0c18 737 *
mbed_official 324:406fd2029f23 738 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 739 * @param data The FlexCAN platform data
mbed_official 146:f64d43ff0c18 740 * @param mb_idx Index of the message buffer
mbed_official 146:f64d43ff0c18 741 * @param ext_mask Individual extended mask
mbed_official 146:f64d43ff0c18 742 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 743 */
mbed_official 324:406fd2029f23 744 flexcan_status_t FLEXCAN_HAL_SetRxIndividualExtMask(
mbed_official 324:406fd2029f23 745 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 746 const flexcan_user_config_t * data,
mbed_official 146:f64d43ff0c18 747 uint32_t mb_idx,
mbed_official 146:f64d43ff0c18 748 uint32_t ext_mask);
mbed_official 146:f64d43ff0c18 749
mbed_official 146:f64d43ff0c18 750 /*!
mbed_official 146:f64d43ff0c18 751 * @brief Sets the FlexCAN Rx MB global standard mask.
mbed_official 146:f64d43ff0c18 752 *
mbed_official 324:406fd2029f23 753 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 754 * @param std_mask Standard mask
mbed_official 146:f64d43ff0c18 755 */
mbed_official 324:406fd2029f23 756 void FLEXCAN_HAL_SetRxMbGlobalStdMask(
mbed_official 324:406fd2029f23 757 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 758 uint32_t std_mask);
mbed_official 146:f64d43ff0c18 759
mbed_official 146:f64d43ff0c18 760 /*!
mbed_official 146:f64d43ff0c18 761 * @brief Sets the FlexCAN RX MB BUF14 standard mask.
mbed_official 146:f64d43ff0c18 762 *
mbed_official 324:406fd2029f23 763 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 764 * @param std_mask Standard mask
mbed_official 146:f64d43ff0c18 765 */
mbed_official 324:406fd2029f23 766 void FLEXCAN_HAL_SetRxMbBuf14StdMask(
mbed_official 324:406fd2029f23 767 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 768 uint32_t std_mask);
mbed_official 146:f64d43ff0c18 769
mbed_official 146:f64d43ff0c18 770 /*!
mbed_official 146:f64d43ff0c18 771 * @brief Sets the FlexCAN Rx MB BUF15 standard mask.
mbed_official 146:f64d43ff0c18 772 *
mbed_official 324:406fd2029f23 773 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 774 * @param std_mask Standard mask
mbed_official 146:f64d43ff0c18 775 * @return 0 if successful; non-zero failed
mbed_official 146:f64d43ff0c18 776 */
mbed_official 324:406fd2029f23 777 void FLEXCAN_HAL_SetRxMbBuf15StdMask(
mbed_official 324:406fd2029f23 778 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 779 uint32_t std_mask);
mbed_official 146:f64d43ff0c18 780
mbed_official 146:f64d43ff0c18 781 /*!
mbed_official 146:f64d43ff0c18 782 * @brief Sets the FlexCAN RX MB global extended mask.
mbed_official 146:f64d43ff0c18 783 *
mbed_official 324:406fd2029f23 784 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 785 * @param ext_mask Extended mask
mbed_official 146:f64d43ff0c18 786 */
mbed_official 324:406fd2029f23 787 void FLEXCAN_HAL_SetRxMbGlobalExtMask(
mbed_official 324:406fd2029f23 788 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 789 uint32_t ext_mask);
mbed_official 146:f64d43ff0c18 790
mbed_official 146:f64d43ff0c18 791 /*!
mbed_official 146:f64d43ff0c18 792 * @brief Sets the FlexCAN RX MB BUF14 extended mask.
mbed_official 146:f64d43ff0c18 793 *
mbed_official 324:406fd2029f23 794 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 795 * @param ext_mask Extended mask
mbed_official 146:f64d43ff0c18 796 */
mbed_official 324:406fd2029f23 797 void FLEXCAN_HAL_SetRxMbBuf14ExtMask(
mbed_official 324:406fd2029f23 798 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 799 uint32_t ext_mask);
mbed_official 146:f64d43ff0c18 800
mbed_official 146:f64d43ff0c18 801 /*!
mbed_official 146:f64d43ff0c18 802 * @brief Sets the FlexCAN RX MB BUF15 extended mask.
mbed_official 146:f64d43ff0c18 803 *
mbed_official 324:406fd2029f23 804 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 805 * @param ext_mask Extended mask
mbed_official 146:f64d43ff0c18 806 */
mbed_official 324:406fd2029f23 807 void FLEXCAN_HAL_SetRxMbBuf15ExtMask(
mbed_official 324:406fd2029f23 808 uint32_t canBaseAddr,
mbed_official 146:f64d43ff0c18 809 uint32_t ext_mask);
mbed_official 146:f64d43ff0c18 810
mbed_official 146:f64d43ff0c18 811 /*!
mbed_official 146:f64d43ff0c18 812 * @brief Gets the FlexCAN ID acceptance filter hit indicator on Rx FIFO.
mbed_official 146:f64d43ff0c18 813 *
mbed_official 324:406fd2029f23 814 * @param canBaseAddr The FlexCAN base address
mbed_official 146:f64d43ff0c18 815 * @return RX FIFO information
mbed_official 146:f64d43ff0c18 816 */
mbed_official 324:406fd2029f23 817 static inline uint32_t FLEXCAN_HAL_GetIdAcceptanceFilterRxFifo(uint32_t canBaseAddr)
mbed_official 146:f64d43ff0c18 818 {
mbed_official 324:406fd2029f23 819 return BR_CAN_RXFIR_IDHIT(canBaseAddr);
mbed_official 146:f64d43ff0c18 820 }
mbed_official 146:f64d43ff0c18 821
mbed_official 146:f64d43ff0c18 822 /*@}*/
mbed_official 146:f64d43ff0c18 823
mbed_official 146:f64d43ff0c18 824 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 825 }
mbed_official 146:f64d43ff0c18 826 #endif
mbed_official 146:f64d43ff0c18 827
mbed_official 146:f64d43ff0c18 828 /*! @}*/
mbed_official 146:f64d43ff0c18 829
mbed_official 324:406fd2029f23 830 #endif /* MBED_NO_FLEXCAN */
mbed_official 324:406fd2029f23 831
mbed_official 146:f64d43ff0c18 832 #endif /* __FSL_FLEXCAN_HAL_H__*/
mbed_official 146:f64d43ff0c18 833
mbed_official 146:f64d43ff0c18 834 /*******************************************************************************
mbed_official 146:f64d43ff0c18 835 * EOF
mbed_official 146:f64d43ff0c18 836 ******************************************************************************/
mbed_official 146:f64d43ff0c18 837