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.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 145:64910690c574 1 /*
AnnaBridge 145:64910690c574 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
AnnaBridge 145:64910690c574 3 * All rights reserved.
AnnaBridge 145:64910690c574 4 *
AnnaBridge 145:64910690c574 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 145:64910690c574 6 * are permitted provided that the following conditions are met:
AnnaBridge 145:64910690c574 7 *
AnnaBridge 145:64910690c574 8 * o Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 145:64910690c574 9 * of conditions and the following disclaimer.
AnnaBridge 145:64910690c574 10 *
AnnaBridge 145:64910690c574 11 * o Redistributions in binary form must reproduce the above copyright notice, this
AnnaBridge 145:64910690c574 12 * list of conditions and the following disclaimer in the documentation and/or
AnnaBridge 145:64910690c574 13 * other materials provided with the distribution.
AnnaBridge 145:64910690c574 14 *
AnnaBridge 145:64910690c574 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
AnnaBridge 145:64910690c574 16 * contributors may be used to endorse or promote products derived from this
AnnaBridge 145:64910690c574 17 * software without specific prior written permission.
AnnaBridge 145:64910690c574 18 *
AnnaBridge 145:64910690c574 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 145:64910690c574 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 145:64910690c574 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 145:64910690c574 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 145:64910690c574 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 145:64910690c574 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 145:64910690c574 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 145:64910690c574 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 145:64910690c574 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 145:64910690c574 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 145:64910690c574 29 */
AnnaBridge 145:64910690c574 30
AnnaBridge 145:64910690c574 31 #ifndef _FSL_FLEXBUS_H_
AnnaBridge 145:64910690c574 32 #define _FSL_FLEXBUS_H_
AnnaBridge 145:64910690c574 33
AnnaBridge 145:64910690c574 34 #include "fsl_common.h"
AnnaBridge 145:64910690c574 35
AnnaBridge 145:64910690c574 36 /*!
AnnaBridge 145:64910690c574 37 * @addtogroup flexbus
AnnaBridge 145:64910690c574 38 * @{
AnnaBridge 145:64910690c574 39 */
AnnaBridge 145:64910690c574 40
AnnaBridge 145:64910690c574 41
AnnaBridge 145:64910690c574 42 /*******************************************************************************
AnnaBridge 145:64910690c574 43 * Definitions
AnnaBridge 145:64910690c574 44 ******************************************************************************/
AnnaBridge 145:64910690c574 45
AnnaBridge 145:64910690c574 46 /*! @name Driver version */
AnnaBridge 145:64910690c574 47 /*@{*/
AnnaBridge 145:64910690c574 48 #define FSL_FLEXBUS_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) /*!< Version 2.0.1. */
AnnaBridge 145:64910690c574 49 /*@}*/
AnnaBridge 145:64910690c574 50
AnnaBridge 145:64910690c574 51 /*!
AnnaBridge 145:64910690c574 52 * @brief Defines port size for FlexBus peripheral.
AnnaBridge 145:64910690c574 53 */
AnnaBridge 145:64910690c574 54 typedef enum _flexbus_port_size
AnnaBridge 145:64910690c574 55 {
AnnaBridge 145:64910690c574 56 kFLEXBUS_4Bytes = 0x00U, /*!< 32-bit port size */
AnnaBridge 145:64910690c574 57 kFLEXBUS_1Byte = 0x01U, /*!< 8-bit port size */
AnnaBridge 145:64910690c574 58 kFLEXBUS_2Bytes = 0x02U /*!< 16-bit port size */
AnnaBridge 145:64910690c574 59 } flexbus_port_size_t;
AnnaBridge 145:64910690c574 60
AnnaBridge 145:64910690c574 61 /*!
AnnaBridge 145:64910690c574 62 * @brief Defines number of cycles to hold address and attributes for FlexBus peripheral.
AnnaBridge 145:64910690c574 63 */
AnnaBridge 145:64910690c574 64 typedef enum _flexbus_write_address_hold
AnnaBridge 145:64910690c574 65 {
AnnaBridge 145:64910690c574 66 kFLEXBUS_Hold1Cycle = 0x00U, /*!< Hold address and attributes one cycles after FB_CSn negates on writes */
AnnaBridge 145:64910690c574 67 kFLEXBUS_Hold2Cycles = 0x01U, /*!< Hold address and attributes two cycles after FB_CSn negates on writes */
AnnaBridge 145:64910690c574 68 kFLEXBUS_Hold3Cycles = 0x02U, /*!< Hold address and attributes three cycles after FB_CSn negates on writes */
AnnaBridge 145:64910690c574 69 kFLEXBUS_Hold4Cycles = 0x03U /*!< Hold address and attributes four cycles after FB_CSn negates on writes */
AnnaBridge 145:64910690c574 70 } flexbus_write_address_hold_t;
AnnaBridge 145:64910690c574 71
AnnaBridge 145:64910690c574 72 /*!
AnnaBridge 145:64910690c574 73 * @brief Defines number of cycles to hold address and attributes for FlexBus peripheral.
AnnaBridge 145:64910690c574 74 */
AnnaBridge 145:64910690c574 75 typedef enum _flexbus_read_address_hold
AnnaBridge 145:64910690c574 76 {
AnnaBridge 145:64910690c574 77 kFLEXBUS_Hold1Or0Cycles = 0x00U, /*!< Hold address and attributes 1 or 0 cycles on reads */
AnnaBridge 145:64910690c574 78 kFLEXBUS_Hold2Or1Cycles = 0x01U, /*!< Hold address and attributes 2 or 1 cycles on reads */
AnnaBridge 145:64910690c574 79 kFLEXBUS_Hold3Or2Cycle = 0x02U, /*!< Hold address and attributes 3 or 2 cycles on reads */
AnnaBridge 145:64910690c574 80 kFLEXBUS_Hold4Or3Cycle = 0x03U /*!< Hold address and attributes 4 or 3 cycles on reads */
AnnaBridge 145:64910690c574 81 } flexbus_read_address_hold_t;
AnnaBridge 145:64910690c574 82
AnnaBridge 145:64910690c574 83 /*!
AnnaBridge 145:64910690c574 84 * @brief Address setup for FlexBus peripheral.
AnnaBridge 145:64910690c574 85 */
AnnaBridge 145:64910690c574 86 typedef enum _flexbus_address_setup
AnnaBridge 145:64910690c574 87 {
AnnaBridge 145:64910690c574 88 kFLEXBUS_FirstRisingEdge = 0x00U, /*!< Assert FB_CSn on first rising clock edge after address is asserted */
AnnaBridge 145:64910690c574 89 kFLEXBUS_SecondRisingEdge = 0x01U, /*!< Assert FB_CSn on second rising clock edge after address is asserted */
AnnaBridge 145:64910690c574 90 kFLEXBUS_ThirdRisingEdge = 0x02U, /*!< Assert FB_CSn on third rising clock edge after address is asserted */
AnnaBridge 145:64910690c574 91 kFLEXBUS_FourthRisingEdge = 0x03U, /*!< Assert FB_CSn on fourth rising clock edge after address is asserted */
AnnaBridge 145:64910690c574 92 } flexbus_address_setup_t;
AnnaBridge 145:64910690c574 93
AnnaBridge 145:64910690c574 94 /*!
AnnaBridge 145:64910690c574 95 * @brief Defines byte-lane shift for FlexBus peripheral.
AnnaBridge 145:64910690c574 96 */
AnnaBridge 145:64910690c574 97 typedef enum _flexbus_bytelane_shift
AnnaBridge 145:64910690c574 98 {
AnnaBridge 145:64910690c574 99 kFLEXBUS_NotShifted = 0x00U, /*!< Not shifted. Data is left-justified on FB_AD */
AnnaBridge 145:64910690c574 100 kFLEXBUS_Shifted = 0x01U, /*!< Shifted. Data is right justified on FB_AD */
AnnaBridge 145:64910690c574 101 } flexbus_bytelane_shift_t;
AnnaBridge 145:64910690c574 102
AnnaBridge 145:64910690c574 103 /*!
AnnaBridge 145:64910690c574 104 * @brief Defines multiplex group1 valid signals.
AnnaBridge 145:64910690c574 105 */
AnnaBridge 145:64910690c574 106 typedef enum _flexbus_multiplex_group1_signal
AnnaBridge 145:64910690c574 107 {
AnnaBridge 145:64910690c574 108 kFLEXBUS_MultiplexGroup1_FB_ALE = 0x00U, /*!< FB_ALE */
AnnaBridge 145:64910690c574 109 kFLEXBUS_MultiplexGroup1_FB_CS1 = 0x01U, /*!< FB_CS1 */
AnnaBridge 145:64910690c574 110 kFLEXBUS_MultiplexGroup1_FB_TS = 0x02U, /*!< FB_TS */
AnnaBridge 145:64910690c574 111 } flexbus_multiplex_group1_t;
AnnaBridge 145:64910690c574 112
AnnaBridge 145:64910690c574 113 /*!
AnnaBridge 145:64910690c574 114 * @brief Defines multiplex group2 valid signals.
AnnaBridge 145:64910690c574 115 */
AnnaBridge 145:64910690c574 116 typedef enum _flexbus_multiplex_group2_signal
AnnaBridge 145:64910690c574 117 {
AnnaBridge 145:64910690c574 118 kFLEXBUS_MultiplexGroup2_FB_CS4 = 0x00U, /*!< FB_CS4 */
AnnaBridge 145:64910690c574 119 kFLEXBUS_MultiplexGroup2_FB_TSIZ0 = 0x01U, /*!< FB_TSIZ0 */
AnnaBridge 145:64910690c574 120 kFLEXBUS_MultiplexGroup2_FB_BE_31_24 = 0x02U, /*!< FB_BE_31_24 */
AnnaBridge 145:64910690c574 121 } flexbus_multiplex_group2_t;
AnnaBridge 145:64910690c574 122
AnnaBridge 145:64910690c574 123 /*!
AnnaBridge 145:64910690c574 124 * @brief Defines multiplex group3 valid signals.
AnnaBridge 145:64910690c574 125 */
AnnaBridge 145:64910690c574 126 typedef enum _flexbus_multiplex_group3_signal
AnnaBridge 145:64910690c574 127 {
AnnaBridge 145:64910690c574 128 kFLEXBUS_MultiplexGroup3_FB_CS5 = 0x00U, /*!< FB_CS5 */
AnnaBridge 145:64910690c574 129 kFLEXBUS_MultiplexGroup3_FB_TSIZ1 = 0x01U, /*!< FB_TSIZ1 */
AnnaBridge 145:64910690c574 130 kFLEXBUS_MultiplexGroup3_FB_BE_23_16 = 0x02U, /*!< FB_BE_23_16 */
AnnaBridge 145:64910690c574 131 } flexbus_multiplex_group3_t;
AnnaBridge 145:64910690c574 132
AnnaBridge 145:64910690c574 133 /*!
AnnaBridge 145:64910690c574 134 * @brief Defines multiplex group4 valid signals.
AnnaBridge 145:64910690c574 135 */
AnnaBridge 145:64910690c574 136 typedef enum _flexbus_multiplex_group4_signal
AnnaBridge 145:64910690c574 137 {
AnnaBridge 145:64910690c574 138 kFLEXBUS_MultiplexGroup4_FB_TBST = 0x00U, /*!< FB_TBST */
AnnaBridge 145:64910690c574 139 kFLEXBUS_MultiplexGroup4_FB_CS2 = 0x01U, /*!< FB_CS2 */
AnnaBridge 145:64910690c574 140 kFLEXBUS_MultiplexGroup4_FB_BE_15_8 = 0x02U, /*!< FB_BE_15_8 */
AnnaBridge 145:64910690c574 141 } flexbus_multiplex_group4_t;
AnnaBridge 145:64910690c574 142
AnnaBridge 145:64910690c574 143 /*!
AnnaBridge 145:64910690c574 144 * @brief Defines multiplex group5 valid signals.
AnnaBridge 145:64910690c574 145 */
AnnaBridge 145:64910690c574 146 typedef enum _flexbus_multiplex_group5_signal
AnnaBridge 145:64910690c574 147 {
AnnaBridge 145:64910690c574 148 kFLEXBUS_MultiplexGroup5_FB_TA = 0x00U, /*!< FB_TA */
AnnaBridge 145:64910690c574 149 kFLEXBUS_MultiplexGroup5_FB_CS3 = 0x01U, /*!< FB_CS3 */
AnnaBridge 145:64910690c574 150 kFLEXBUS_MultiplexGroup5_FB_BE_7_0 = 0x02U, /*!< FB_BE_7_0 */
AnnaBridge 145:64910690c574 151 } flexbus_multiplex_group5_t;
AnnaBridge 145:64910690c574 152
AnnaBridge 145:64910690c574 153 /*!
AnnaBridge 145:64910690c574 154 * @brief Configuration structure that the user needs to set.
AnnaBridge 145:64910690c574 155 */
AnnaBridge 145:64910690c574 156 typedef struct _flexbus_config
AnnaBridge 145:64910690c574 157 {
AnnaBridge 145:64910690c574 158 uint8_t chip; /*!< Chip FlexBus for validation */
AnnaBridge 145:64910690c574 159 uint8_t waitStates; /*!< Value of wait states */
AnnaBridge 145:64910690c574 160 uint32_t chipBaseAddress; /*!< Chip base address for using FlexBus */
AnnaBridge 145:64910690c574 161 uint32_t chipBaseAddressMask; /*!< Chip base address mask */
AnnaBridge 145:64910690c574 162 bool writeProtect; /*!< Write protected */
AnnaBridge 145:64910690c574 163 bool burstWrite; /*!< Burst-Write enable */
AnnaBridge 145:64910690c574 164 bool burstRead; /*!< Burst-Read enable */
AnnaBridge 145:64910690c574 165 bool byteEnableMode; /*!< Byte-enable mode support */
AnnaBridge 145:64910690c574 166 bool autoAcknowledge; /*!< Auto acknowledge setting */
AnnaBridge 145:64910690c574 167 bool extendTransferAddress; /*!< Extend transfer start/extend address latch enable */
AnnaBridge 145:64910690c574 168 bool secondaryWaitStates; /*!< Secondary wait states number */
AnnaBridge 145:64910690c574 169 flexbus_port_size_t portSize; /*!< Port size of transfer */
AnnaBridge 145:64910690c574 170 flexbus_bytelane_shift_t byteLaneShift; /*!< Byte-lane shift enable */
AnnaBridge 145:64910690c574 171 flexbus_write_address_hold_t writeAddressHold; /*!< Write address hold or deselect option */
AnnaBridge 145:64910690c574 172 flexbus_read_address_hold_t readAddressHold; /*!< Read address hold or deselect option */
AnnaBridge 145:64910690c574 173 flexbus_address_setup_t addressSetup; /*!< Address setup setting */
AnnaBridge 145:64910690c574 174 flexbus_multiplex_group1_t group1MultiplexControl; /*!< FlexBus Signal Group 1 Multiplex control */
AnnaBridge 145:64910690c574 175 flexbus_multiplex_group2_t group2MultiplexControl; /*!< FlexBus Signal Group 2 Multiplex control */
AnnaBridge 145:64910690c574 176 flexbus_multiplex_group3_t group3MultiplexControl; /*!< FlexBus Signal Group 3 Multiplex control */
AnnaBridge 145:64910690c574 177 flexbus_multiplex_group4_t group4MultiplexControl; /*!< FlexBus Signal Group 4 Multiplex control */
AnnaBridge 145:64910690c574 178 flexbus_multiplex_group5_t group5MultiplexControl; /*!< FlexBus Signal Group 5 Multiplex control */
AnnaBridge 145:64910690c574 179 } flexbus_config_t;
AnnaBridge 145:64910690c574 180
AnnaBridge 145:64910690c574 181 /*******************************************************************************
AnnaBridge 145:64910690c574 182 * API
AnnaBridge 145:64910690c574 183 ******************************************************************************/
AnnaBridge 145:64910690c574 184
AnnaBridge 145:64910690c574 185 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 186 extern "C" {
AnnaBridge 145:64910690c574 187 #endif /* __cplusplus */
AnnaBridge 145:64910690c574 188
AnnaBridge 145:64910690c574 189 /*!
AnnaBridge 145:64910690c574 190 * @name FlexBus functional operation
AnnaBridge 145:64910690c574 191 * @{
AnnaBridge 145:64910690c574 192 */
AnnaBridge 145:64910690c574 193
AnnaBridge 145:64910690c574 194 /*!
AnnaBridge 145:64910690c574 195 * @brief Initializes and configures the FlexBus module.
AnnaBridge 145:64910690c574 196 *
AnnaBridge 145:64910690c574 197 * This function enables the clock gate for FlexBus module.
AnnaBridge 145:64910690c574 198 * Only chip 0 is validated and set to known values. Other chips are disabled.
AnnaBridge 145:64910690c574 199 * Note that in this function, certain parameters, depending on external memories, must
AnnaBridge 145:64910690c574 200 * be set before using the FLEXBUS_Init() function.
AnnaBridge 145:64910690c574 201 * This example shows how to set up the uart_state_t and the
AnnaBridge 145:64910690c574 202 * flexbus_config_t parameters and how to call the FLEXBUS_Init function by passing
AnnaBridge 145:64910690c574 203 * in these parameters.
AnnaBridge 145:64910690c574 204 @code
AnnaBridge 145:64910690c574 205 flexbus_config_t flexbusConfig;
AnnaBridge 145:64910690c574 206 FLEXBUS_GetDefaultConfig(&flexbusConfig);
AnnaBridge 145:64910690c574 207 flexbusConfig.waitStates = 2U;
AnnaBridge 145:64910690c574 208 flexbusConfig.chipBaseAddress = 0x60000000U;
AnnaBridge 145:64910690c574 209 flexbusConfig.chipBaseAddressMask = 7U;
AnnaBridge 145:64910690c574 210 FLEXBUS_Init(FB, &flexbusConfig);
AnnaBridge 145:64910690c574 211 @endcode
AnnaBridge 145:64910690c574 212 *
AnnaBridge 145:64910690c574 213 * @param base FlexBus peripheral address.
AnnaBridge 145:64910690c574 214 * @param config Pointer to the configuration structure
AnnaBridge 145:64910690c574 215 */
AnnaBridge 145:64910690c574 216 void FLEXBUS_Init(FB_Type *base, const flexbus_config_t *config);
AnnaBridge 145:64910690c574 217
AnnaBridge 145:64910690c574 218 /*!
AnnaBridge 145:64910690c574 219 * @brief De-initializes a FlexBus instance.
AnnaBridge 145:64910690c574 220 *
AnnaBridge 145:64910690c574 221 * This function disables the clock gate of the FlexBus module clock.
AnnaBridge 145:64910690c574 222 *
AnnaBridge 145:64910690c574 223 * @param base FlexBus peripheral address.
AnnaBridge 145:64910690c574 224 */
AnnaBridge 145:64910690c574 225 void FLEXBUS_Deinit(FB_Type *base);
AnnaBridge 145:64910690c574 226
AnnaBridge 145:64910690c574 227 /*!
AnnaBridge 145:64910690c574 228 * @brief Initializes the FlexBus configuration structure.
AnnaBridge 145:64910690c574 229 *
AnnaBridge 145:64910690c574 230 * This function initializes the FlexBus configuration structure to default value. The default
AnnaBridge 145:64910690c574 231 * values are.
AnnaBridge 145:64910690c574 232 @code
AnnaBridge 145:64910690c574 233 fbConfig->chip = 0;
AnnaBridge 145:64910690c574 234 fbConfig->writeProtect = 0;
AnnaBridge 145:64910690c574 235 fbConfig->burstWrite = 0;
AnnaBridge 145:64910690c574 236 fbConfig->burstRead = 0;
AnnaBridge 145:64910690c574 237 fbConfig->byteEnableMode = 0;
AnnaBridge 145:64910690c574 238 fbConfig->autoAcknowledge = true;
AnnaBridge 145:64910690c574 239 fbConfig->extendTransferAddress = 0;
AnnaBridge 145:64910690c574 240 fbConfig->secondaryWaitStates = 0;
AnnaBridge 145:64910690c574 241 fbConfig->byteLaneShift = kFLEXBUS_NotShifted;
AnnaBridge 145:64910690c574 242 fbConfig->writeAddressHold = kFLEXBUS_Hold1Cycle;
AnnaBridge 145:64910690c574 243 fbConfig->readAddressHold = kFLEXBUS_Hold1Or0Cycles;
AnnaBridge 145:64910690c574 244 fbConfig->addressSetup = kFLEXBUS_FirstRisingEdge;
AnnaBridge 145:64910690c574 245 fbConfig->portSize = kFLEXBUS_1Byte;
AnnaBridge 145:64910690c574 246 fbConfig->group1MultiplexControl = kFLEXBUS_MultiplexGroup1_FB_ALE;
AnnaBridge 145:64910690c574 247 fbConfig->group2MultiplexControl = kFLEXBUS_MultiplexGroup2_FB_CS4 ;
AnnaBridge 145:64910690c574 248 fbConfig->group3MultiplexControl = kFLEXBUS_MultiplexGroup3_FB_CS5;
AnnaBridge 145:64910690c574 249 fbConfig->group4MultiplexControl = kFLEXBUS_MultiplexGroup4_FB_TBST;
AnnaBridge 145:64910690c574 250 fbConfig->group5MultiplexControl = kFLEXBUS_MultiplexGroup5_FB_TA;
AnnaBridge 145:64910690c574 251 @endcode
AnnaBridge 145:64910690c574 252 * @param config Pointer to the initialization structure.
AnnaBridge 145:64910690c574 253 * @see FLEXBUS_Init
AnnaBridge 145:64910690c574 254 */
AnnaBridge 145:64910690c574 255 void FLEXBUS_GetDefaultConfig(flexbus_config_t *config);
AnnaBridge 145:64910690c574 256
AnnaBridge 145:64910690c574 257 /*! @}*/
AnnaBridge 145:64910690c574 258
AnnaBridge 145:64910690c574 259 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 260 }
AnnaBridge 145:64910690c574 261 #endif /* __cplusplus */
AnnaBridge 145:64910690c574 262
AnnaBridge 145:64910690c574 263 /*! @}*/
AnnaBridge 145:64910690c574 264
AnnaBridge 145:64910690c574 265 #endif /* _FSL_FLEXBUS_H_ */