test

Committer:
elijahsj
Date:
Mon Nov 09 00:33:19 2020 -0500
Revision:
2:4364577b5ad8
Parent:
1:8a094db1347f
copied mbed library

Who changed what in which revision?

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