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_SDT32625B/TOOLCHAIN_IAR/spix.h@172:65be27845400, 2019-02-20 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anna Bridge |
169:a7c7b631e539 | 1 | /******************************************************************************* |
Anna Bridge |
169:a7c7b631e539 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
Anna Bridge |
169:a7c7b631e539 | 3 | * |
Anna Bridge |
169:a7c7b631e539 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
Anna Bridge |
169:a7c7b631e539 | 5 | * copy of this software and associated documentation files (the "Software"), |
Anna Bridge |
169:a7c7b631e539 | 6 | * to deal in the Software without restriction, including without limitation |
Anna Bridge |
169:a7c7b631e539 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
Anna Bridge |
169:a7c7b631e539 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
Anna Bridge |
169:a7c7b631e539 | 9 | * Software is furnished to do so, subject to the following conditions: |
Anna Bridge |
169:a7c7b631e539 | 10 | * |
Anna Bridge |
169:a7c7b631e539 | 11 | * The above copyright notice and this permission notice shall be included |
Anna Bridge |
169:a7c7b631e539 | 12 | * in all copies or substantial portions of the Software. |
Anna Bridge |
169:a7c7b631e539 | 13 | * |
Anna Bridge |
169:a7c7b631e539 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
Anna Bridge |
169:a7c7b631e539 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
Anna Bridge |
169:a7c7b631e539 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
Anna Bridge |
169:a7c7b631e539 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
Anna Bridge |
169:a7c7b631e539 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
Anna Bridge |
169:a7c7b631e539 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
Anna Bridge |
169:a7c7b631e539 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
Anna Bridge |
169:a7c7b631e539 | 21 | * |
Anna Bridge |
169:a7c7b631e539 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
Anna Bridge |
169:a7c7b631e539 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
Anna Bridge |
169:a7c7b631e539 | 24 | * Products, Inc. Branding Policy. |
Anna Bridge |
169:a7c7b631e539 | 25 | * |
Anna Bridge |
169:a7c7b631e539 | 26 | * The mere transfer of this software does not imply any licenses |
Anna Bridge |
169:a7c7b631e539 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
Anna Bridge |
169:a7c7b631e539 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
Anna Bridge |
169:a7c7b631e539 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
Anna Bridge |
169:a7c7b631e539 | 30 | * ownership rights. |
Anna Bridge |
169:a7c7b631e539 | 31 | * |
Anna Bridge |
169:a7c7b631e539 | 32 | * $Date: 2016-05-26 11:38:10 -0500 (Thu, 26 May 2016) $ |
Anna Bridge |
169:a7c7b631e539 | 33 | * $Revision: 23065 $ |
Anna Bridge |
169:a7c7b631e539 | 34 | * |
Anna Bridge |
169:a7c7b631e539 | 35 | ******************************************************************************/ |
Anna Bridge |
169:a7c7b631e539 | 36 | |
Anna Bridge |
169:a7c7b631e539 | 37 | /** |
Anna Bridge |
169:a7c7b631e539 | 38 | * @file spix.h |
Anna Bridge |
169:a7c7b631e539 | 39 | * @brief This is the high level API for the serial peripheral interface execute in place module. |
Anna Bridge |
169:a7c7b631e539 | 40 | * @warning If using this SPIX with IAR Embedded Workbench for Arm, it is required to define |
Anna Bridge |
169:a7c7b631e539 | 41 | * <tt>IAR_SPIX_PRAGMA=1</tt>. This should be done under Project->Options-> |
Anna Bridge |
169:a7c7b631e539 | 42 | * C/C++ Compiler->Preprocessor in the Defined Symbols input box. See the IAR documentation |
Anna Bridge |
169:a7c7b631e539 | 43 | * for additional information on how to set a preprocessor define in a project. |
Anna Bridge |
169:a7c7b631e539 | 44 | */ |
Anna Bridge |
169:a7c7b631e539 | 45 | |
Anna Bridge |
169:a7c7b631e539 | 46 | #include "mxc_sys.h" |
Anna Bridge |
169:a7c7b631e539 | 47 | #include "spix_regs.h" |
Anna Bridge |
169:a7c7b631e539 | 48 | |
Anna Bridge |
169:a7c7b631e539 | 49 | #ifndef _SPIX_H_ |
Anna Bridge |
169:a7c7b631e539 | 50 | #define _SPIX_H_ |
Anna Bridge |
169:a7c7b631e539 | 51 | |
Anna Bridge |
169:a7c7b631e539 | 52 | #ifdef __cplusplus |
Anna Bridge |
169:a7c7b631e539 | 53 | extern "C" { |
Anna Bridge |
169:a7c7b631e539 | 54 | #endif |
Anna Bridge |
169:a7c7b631e539 | 55 | |
Anna Bridge |
169:a7c7b631e539 | 56 | /***** Definitions *****/ |
Anna Bridge |
169:a7c7b631e539 | 57 | |
Anna Bridge |
169:a7c7b631e539 | 58 | /// @brief Options for number of I/O pins to use during for each fetch stage |
Anna Bridge |
169:a7c7b631e539 | 59 | typedef enum { |
Anna Bridge |
169:a7c7b631e539 | 60 | SPIX_SINGLE_IO = MXC_V_SPIX_FETCH_CTRL_CMD_WIDTH_SINGLE, |
Anna Bridge |
169:a7c7b631e539 | 61 | SPIX_DUAL_IO = MXC_V_SPIX_FETCH_CTRL_CMD_WIDTH_DUAL_IO, |
Anna Bridge |
169:a7c7b631e539 | 62 | SPIX_QUAD_IO = MXC_V_SPIX_FETCH_CTRL_CMD_WIDTH_QUAD_IO |
Anna Bridge |
169:a7c7b631e539 | 63 | } spix_width_t; |
Anna Bridge |
169:a7c7b631e539 | 64 | |
Anna Bridge |
169:a7c7b631e539 | 65 | /// @brief Options for number of address bytes to use during fetch |
Anna Bridge |
169:a7c7b631e539 | 66 | typedef enum { |
Anna Bridge |
169:a7c7b631e539 | 67 | SPIX_3BYTE_FETCH_ADDR = 0, |
Anna Bridge |
169:a7c7b631e539 | 68 | SPIX_4BYTE_FETCH_ADDR = 1 |
Anna Bridge |
169:a7c7b631e539 | 69 | } spix_addr_size_t; |
Anna Bridge |
169:a7c7b631e539 | 70 | |
Anna Bridge |
169:a7c7b631e539 | 71 | /// @brief SPIX fetch configuration. |
Anna Bridge |
169:a7c7b631e539 | 72 | typedef struct { |
Anna Bridge |
169:a7c7b631e539 | 73 | spix_width_t cmd_width; ///< Number of I/O lines used for command SPI transaction. |
Anna Bridge |
169:a7c7b631e539 | 74 | spix_width_t addr_width; ///< Number of I/O lines used for address SPI transaction. |
Anna Bridge |
169:a7c7b631e539 | 75 | spix_width_t data_width; ///< Number of I/O lines used for data SPI transaction. |
Anna Bridge |
169:a7c7b631e539 | 76 | spix_addr_size_t addr_size; ///< Use 3 or 4 byte addresses for fetches. |
Anna Bridge |
169:a7c7b631e539 | 77 | uint8_t cmd; ///< Command value to initiate fetch. |
Anna Bridge |
169:a7c7b631e539 | 78 | uint8_t mode_clocks; ///< Number of SPI clocks required during mode phase of fetch. |
Anna Bridge |
169:a7c7b631e539 | 79 | uint8_t no_cmd_mode; ///< Read command sent only once. |
Anna Bridge |
169:a7c7b631e539 | 80 | uint16_t mode_data; ///< Data sent with mode clocks. |
Anna Bridge |
169:a7c7b631e539 | 81 | } spix_fetch_t; |
Anna Bridge |
169:a7c7b631e539 | 82 | |
Anna Bridge |
169:a7c7b631e539 | 83 | /***** Globals *****/ |
Anna Bridge |
169:a7c7b631e539 | 84 | |
Anna Bridge |
169:a7c7b631e539 | 85 | /***** Function Prototypes *****/ |
Anna Bridge |
169:a7c7b631e539 | 86 | |
Anna Bridge |
169:a7c7b631e539 | 87 | /** |
Anna Bridge |
169:a7c7b631e539 | 88 | * @brief Configure SPI execute in place clocking. |
Anna Bridge |
169:a7c7b631e539 | 89 | * @param sys_cfg Pointer to system level configuration structure. |
Anna Bridge |
169:a7c7b631e539 | 90 | * @param mode SPI mode to use for the clocking. |
Anna Bridge |
169:a7c7b631e539 | 91 | * @param baud Frequency in hertz to set the clock to. May not be able to achieve with |
Anna Bridge |
169:a7c7b631e539 | 92 | * the given clock divider. |
Anna Bridge |
169:a7c7b631e539 | 93 | * @param sample Number of SPIX clocks to delay the sampling of the SDIO lines. Will use |
Anna Bridge |
169:a7c7b631e539 | 94 | * feedback mode if set to 0. |
Anna Bridge |
169:a7c7b631e539 | 95 | * @returns #E_NO_ERROR if everything is successful |
Anna Bridge |
169:a7c7b631e539 | 96 | */ |
Anna Bridge |
169:a7c7b631e539 | 97 | int SPIX_ConfigClock(const sys_cfg_spix_t *sys_cfg, uint32_t baud, uint8_t sample); |
Anna Bridge |
169:a7c7b631e539 | 98 | |
Anna Bridge |
169:a7c7b631e539 | 99 | /** |
Anna Bridge |
169:a7c7b631e539 | 100 | * @brief Configure SPI execute in place slave select. |
Anna Bridge |
169:a7c7b631e539 | 101 | * @param ssel Index of which slave select line to use. |
Anna Bridge |
169:a7c7b631e539 | 102 | * @param pol Polarity of slave select (0 for active low, 1 for active high). |
Anna Bridge |
169:a7c7b631e539 | 103 | * @param act_delay SPIX clocks between slave select assert and active SPI clock. |
Anna Bridge |
169:a7c7b631e539 | 104 | * @param inact_delay SPIX clocks between active SPI clock and slave select deassert. |
Anna Bridge |
169:a7c7b631e539 | 105 | */ |
Anna Bridge |
169:a7c7b631e539 | 106 | void SPIX_ConfigSlave(uint8_t ssel, uint8_t pol, uint8_t act_delay, uint8_t inact_delay); |
Anna Bridge |
169:a7c7b631e539 | 107 | |
Anna Bridge |
169:a7c7b631e539 | 108 | /** |
Anna Bridge |
169:a7c7b631e539 | 109 | * @brief Configure how the SPIX fetches data. |
Anna Bridge |
169:a7c7b631e539 | 110 | * @param fetch Pointer to configuration struct that describes how to fetch data. |
Anna Bridge |
169:a7c7b631e539 | 111 | */ |
Anna Bridge |
169:a7c7b631e539 | 112 | void SPIX_ConfigFetch(const spix_fetch_t *fetch); |
Anna Bridge |
169:a7c7b631e539 | 113 | |
Anna Bridge |
169:a7c7b631e539 | 114 | /** |
Anna Bridge |
169:a7c7b631e539 | 115 | * @brief Shutdown SPIX module. |
Anna Bridge |
169:a7c7b631e539 | 116 | * @param spix Pointer to SPIX regs. |
Anna Bridge |
169:a7c7b631e539 | 117 | * @returns #E_NO_ERROR if everything is successful |
Anna Bridge |
169:a7c7b631e539 | 118 | */ |
Anna Bridge |
169:a7c7b631e539 | 119 | int SPIX_Shutdown(mxc_spix_regs_t *spix); |
Anna Bridge |
169:a7c7b631e539 | 120 | |
Anna Bridge |
169:a7c7b631e539 | 121 | |
Anna Bridge |
169:a7c7b631e539 | 122 | #ifdef __cplusplus |
Anna Bridge |
169:a7c7b631e539 | 123 | } |
Anna Bridge |
169:a7c7b631e539 | 124 | #endif |
Anna Bridge |
169:a7c7b631e539 | 125 | |
Anna Bridge |
169:a7c7b631e539 | 126 | #endif /* _SPIX_H */ |