Version of easy-connect with the u-blox cellular platforms C027 and C030 added.
stm-spirit1-rf-driver/stm-spirit1-rf-driver/radio_spi.h@5:9da11cf868d9, 2017-09-14 (annotated)
- Committer:
- rob.meades@u-blox.com
- Date:
- Thu Sep 14 09:42:14 2017 +0100
- Revision:
- 5:9da11cf868d9
- Parent:
- 0:19aa55d66228
Add N2xx as an option.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
group-ublox | 0:19aa55d66228 | 1 | /** |
group-ublox | 0:19aa55d66228 | 2 | ****************************************************************************** |
group-ublox | 0:19aa55d66228 | 3 | * @file radio_spi.h |
group-ublox | 0:19aa55d66228 | 4 | * @author System Lab - NOIDA |
group-ublox | 0:19aa55d66228 | 5 | * @version V1.0.0 |
group-ublox | 0:19aa55d66228 | 6 | * @date 15-May-2014 |
group-ublox | 0:19aa55d66228 | 7 | * @brief This file contains all the functions prototypes for SPI . |
group-ublox | 0:19aa55d66228 | 8 | ****************************************************************************** |
group-ublox | 0:19aa55d66228 | 9 | * @attention |
group-ublox | 0:19aa55d66228 | 10 | * |
group-ublox | 0:19aa55d66228 | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
group-ublox | 0:19aa55d66228 | 12 | * |
group-ublox | 0:19aa55d66228 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
group-ublox | 0:19aa55d66228 | 14 | * are permitted provided that the following conditions are met: |
group-ublox | 0:19aa55d66228 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
group-ublox | 0:19aa55d66228 | 16 | * this list of conditions and the following disclaimer. |
group-ublox | 0:19aa55d66228 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
group-ublox | 0:19aa55d66228 | 18 | * this list of conditions and the following disclaimer in the documentation |
group-ublox | 0:19aa55d66228 | 19 | * and/or other materials provided with the distribution. |
group-ublox | 0:19aa55d66228 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
group-ublox | 0:19aa55d66228 | 21 | * may be used to endorse or promote products derived from this software |
group-ublox | 0:19aa55d66228 | 22 | * without specific prior written permission. |
group-ublox | 0:19aa55d66228 | 23 | * |
group-ublox | 0:19aa55d66228 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
group-ublox | 0:19aa55d66228 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
group-ublox | 0:19aa55d66228 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
group-ublox | 0:19aa55d66228 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
group-ublox | 0:19aa55d66228 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
group-ublox | 0:19aa55d66228 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
group-ublox | 0:19aa55d66228 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
group-ublox | 0:19aa55d66228 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
group-ublox | 0:19aa55d66228 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
group-ublox | 0:19aa55d66228 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
group-ublox | 0:19aa55d66228 | 34 | * |
group-ublox | 0:19aa55d66228 | 35 | ****************************************************************************** |
group-ublox | 0:19aa55d66228 | 36 | */ |
group-ublox | 0:19aa55d66228 | 37 | |
group-ublox | 0:19aa55d66228 | 38 | |
group-ublox | 0:19aa55d66228 | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ |
group-ublox | 0:19aa55d66228 | 40 | #ifndef __RADIO_SPI_H |
group-ublox | 0:19aa55d66228 | 41 | #define __RADIO_SPI_H |
group-ublox | 0:19aa55d66228 | 42 | #ifdef __cplusplus |
group-ublox | 0:19aa55d66228 | 43 | extern "C" { |
group-ublox | 0:19aa55d66228 | 44 | #endif |
group-ublox | 0:19aa55d66228 | 45 | |
group-ublox | 0:19aa55d66228 | 46 | /* Includes ------------------------------------------------------------------*/ |
group-ublox | 0:19aa55d66228 | 47 | #ifdef USE_STM32L1XX_NUCLEO |
group-ublox | 0:19aa55d66228 | 48 | // #include "stm32l1xx_hal.h" |
group-ublox | 0:19aa55d66228 | 49 | #endif |
group-ublox | 0:19aa55d66228 | 50 | |
group-ublox | 0:19aa55d66228 | 51 | #ifdef USE_STM32F4XX_NUCLEO |
group-ublox | 0:19aa55d66228 | 52 | // #include "stm32f4xx_hal.h" |
group-ublox | 0:19aa55d66228 | 53 | #endif |
group-ublox | 0:19aa55d66228 | 54 | #include "SPIRIT_Config.h" |
group-ublox | 0:19aa55d66228 | 55 | #include "radio_spi.h" |
group-ublox | 0:19aa55d66228 | 56 | // #include "spirit1-arch.h" |
group-ublox | 0:19aa55d66228 | 57 | |
group-ublox | 0:19aa55d66228 | 58 | /** |
group-ublox | 0:19aa55d66228 | 59 | * @addtogroup BSP |
group-ublox | 0:19aa55d66228 | 60 | * @{ |
group-ublox | 0:19aa55d66228 | 61 | */ |
group-ublox | 0:19aa55d66228 | 62 | |
group-ublox | 0:19aa55d66228 | 63 | /* Exported types ------------------------------------------------------------*/ |
group-ublox | 0:19aa55d66228 | 64 | |
group-ublox | 0:19aa55d66228 | 65 | |
group-ublox | 0:19aa55d66228 | 66 | /* Exported constants --------------------------------------------------------*/ |
group-ublox | 0:19aa55d66228 | 67 | |
group-ublox | 0:19aa55d66228 | 68 | |
group-ublox | 0:19aa55d66228 | 69 | /* Exported macro ------------------------------------------------------------*/ |
group-ublox | 0:19aa55d66228 | 70 | /* Define for SPIRIT1 board */ |
group-ublox | 0:19aa55d66228 | 71 | #if !defined (USE_SPIRIT1_DEFAULT) |
group-ublox | 0:19aa55d66228 | 72 | #define USE_SPIRIT1_DEFAULT |
group-ublox | 0:19aa55d66228 | 73 | #endif |
group-ublox | 0:19aa55d66228 | 74 | |
group-ublox | 0:19aa55d66228 | 75 | /* SPIRIT1_Spi_config */ |
group-ublox | 0:19aa55d66228 | 76 | /* SPI1 */ |
group-ublox | 0:19aa55d66228 | 77 | #define RADIO_SPI SPI1 |
group-ublox | 0:19aa55d66228 | 78 | #define RADIO_SPI_CLK_ENABLE() __SPI1_CLK_ENABLE() |
group-ublox | 0:19aa55d66228 | 79 | #define RADIO_SPI_CLK_DISABLE() __SPI1_CLK_DISABLE() |
group-ublox | 0:19aa55d66228 | 80 | |
group-ublox | 0:19aa55d66228 | 81 | #define RADIO_SPI_MISO_PORT GPIOA |
group-ublox | 0:19aa55d66228 | 82 | #define RADIO_SPI_MISO_PIN GPIO_PIN_6 |
group-ublox | 0:19aa55d66228 | 83 | #define RADIO_SPI_MISO_CLOCK_ENABLE() __GPIOA_CLK_ENABLE() |
group-ublox | 0:19aa55d66228 | 84 | #define RADIO_SPI_MISO_CLOCK_DISABLE() __GPIOA_CLK_DISABLE() |
group-ublox | 0:19aa55d66228 | 85 | |
group-ublox | 0:19aa55d66228 | 86 | #define RADIO_SPI_MOSI_PORT GPIOA |
group-ublox | 0:19aa55d66228 | 87 | #define RADIO_SPI_MOSI_PIN GPIO_PIN_7 |
group-ublox | 0:19aa55d66228 | 88 | #define RADIO_SPI_MOSI_CLOCK_ENABLE() __GPIOA_CLK_ENABLE() |
group-ublox | 0:19aa55d66228 | 89 | #define RADIO_SPI_MOSI_CLOCK_DISABLE() __GPIOA_CLK_DISABLE() |
group-ublox | 0:19aa55d66228 | 90 | |
group-ublox | 0:19aa55d66228 | 91 | |
group-ublox | 0:19aa55d66228 | 92 | |
group-ublox | 0:19aa55d66228 | 93 | #ifdef USE_SPIRIT1_DEFAULT |
group-ublox | 0:19aa55d66228 | 94 | |
group-ublox | 0:19aa55d66228 | 95 | #define RADIO_SPI_SCK_PORT GPIOB |
group-ublox | 0:19aa55d66228 | 96 | #define RADIO_SPI_SCK_PIN GPIO_PIN_3 |
group-ublox | 0:19aa55d66228 | 97 | #define RADIO_SPI_SCK_CLOCK_ENABLE() __GPIOB_CLK_ENABLE() |
group-ublox | 0:19aa55d66228 | 98 | #define RADIO_SPI_SCK_CLOCK_DISABLE() __GPIOB_CLK_DISABLE() |
group-ublox | 0:19aa55d66228 | 99 | |
group-ublox | 0:19aa55d66228 | 100 | |
group-ublox | 0:19aa55d66228 | 101 | #define RADIO_SPI_CS_PORT GPIOB |
group-ublox | 0:19aa55d66228 | 102 | #define RADIO_SPI_CS_PIN GPIO_PIN_6 |
group-ublox | 0:19aa55d66228 | 103 | #define RADIO_SPI_CS_CLOCK_ENABLE() __GPIOB_CLK_ENABLE() |
group-ublox | 0:19aa55d66228 | 104 | #define RADIO_SPI_CS_CLOCK_DISABLE() __GPIOB_CLK_DISABLE() |
group-ublox | 0:19aa55d66228 | 105 | |
group-ublox | 0:19aa55d66228 | 106 | #else |
group-ublox | 0:19aa55d66228 | 107 | |
group-ublox | 0:19aa55d66228 | 108 | #define RADIO_SPI_SCK_PORT GPIOB |
group-ublox | 0:19aa55d66228 | 109 | #define RADIO_SPI_SCK_PIN GPIO_PIN_3 |
group-ublox | 0:19aa55d66228 | 110 | #define RADIO_SPI_SCK_CLOCK_ENABLE() __GPIOB_CLK_ENABLE() |
group-ublox | 0:19aa55d66228 | 111 | #define RADIO_SPI_SCK_CLOCK_DISABLE() __GPIOB_CLK_DISABLE() |
group-ublox | 0:19aa55d66228 | 112 | |
group-ublox | 0:19aa55d66228 | 113 | |
group-ublox | 0:19aa55d66228 | 114 | #define RADIO_SPI_CS_PORT GPIOB |
group-ublox | 0:19aa55d66228 | 115 | #define RADIO_SPI_CS_PIN GPIO_PIN_6 |
group-ublox | 0:19aa55d66228 | 116 | #define RADIO_SPI_CS_CLOCK_ENABLE() __GPIOB_CLK_ENABLE() |
group-ublox | 0:19aa55d66228 | 117 | #define RADIO_SPI_CS_CLOCK_DISABLE() __GPIOB_CLK_DISABLE() |
group-ublox | 0:19aa55d66228 | 118 | |
group-ublox | 0:19aa55d66228 | 119 | #endif |
group-ublox | 0:19aa55d66228 | 120 | |
group-ublox | 0:19aa55d66228 | 121 | /* Maximum Timeout values for flags waiting loops. These timeouts are not based |
group-ublox | 0:19aa55d66228 | 122 | on accurate values, they just guarantee that the application will not remain |
group-ublox | 0:19aa55d66228 | 123 | stuck if the SPI communication is corrupted. |
group-ublox | 0:19aa55d66228 | 124 | You may modify these timeout values depending on CPU frequency and application |
group-ublox | 0:19aa55d66228 | 125 | conditions (interrupts routines ...) */ |
group-ublox | 0:19aa55d66228 | 126 | #define RADIO_SPI_TIMEOUT_MAX ((uint32_t)1000) |
group-ublox | 0:19aa55d66228 | 127 | |
group-ublox | 0:19aa55d66228 | 128 | /* SPIRIT1_Spi_config_Private_Defines */ |
group-ublox | 0:19aa55d66228 | 129 | #define CS_TO_SCLK_DELAY 0x0200//FIXME what is this doing? |
group-ublox | 0:19aa55d66228 | 130 | #define CLK_TO_CS_DELAY 0x0001 |
group-ublox | 0:19aa55d66228 | 131 | |
group-ublox | 0:19aa55d66228 | 132 | /* SPIRIT1_Spi_config_Headers */ |
group-ublox | 0:19aa55d66228 | 133 | #define HEADER_WRITE_MASK 0x00 /*!< Write mask for header byte*/ |
group-ublox | 0:19aa55d66228 | 134 | #define HEADER_READ_MASK 0x01 /*!< Read mask for header byte*/ |
group-ublox | 0:19aa55d66228 | 135 | #define HEADER_ADDRESS_MASK 0x00 /*!< Address mask for header byte*/ |
group-ublox | 0:19aa55d66228 | 136 | #define HEADER_COMMAND_MASK 0x80 /*!< Command mask for header byte*/ |
group-ublox | 0:19aa55d66228 | 137 | |
group-ublox | 0:19aa55d66228 | 138 | #define LINEAR_FIFO_ADDRESS 0xFF /*!< Linear FIFO address*/ |
group-ublox | 0:19aa55d66228 | 139 | |
group-ublox | 0:19aa55d66228 | 140 | /* SPIRIT1_Spi_config_Private_FunctionPrototypes */ |
group-ublox | 0:19aa55d66228 | 141 | #define SPI_ENTER_CRITICAL() IRQ_DISABLE() |
group-ublox | 0:19aa55d66228 | 142 | #define SPI_EXIT_CRITICAL() IRQ_ENABLE() |
group-ublox | 0:19aa55d66228 | 143 | |
group-ublox | 0:19aa55d66228 | 144 | /* SPIRIT1_Spi_config_Private_Functions */ |
group-ublox | 0:19aa55d66228 | 145 | #define RadioSpiCSLow() HAL_GPIO_WritePin(RADIO_SPI_CS_PORT, RADIO_SPI_CS_PIN, GPIO_PIN_RESET) |
group-ublox | 0:19aa55d66228 | 146 | #define RadioSpiCSHigh() HAL_GPIO_WritePin(RADIO_SPI_CS_PORT, RADIO_SPI_CS_PIN, GPIO_PIN_SET) |
group-ublox | 0:19aa55d66228 | 147 | |
group-ublox | 0:19aa55d66228 | 148 | /* SPIRIT1_Spi_config_Private_Macros */ |
group-ublox | 0:19aa55d66228 | 149 | #define BUILT_HEADER(add_comm, w_r) (add_comm | w_r) /*!< macro to build the header byte*/ |
group-ublox | 0:19aa55d66228 | 150 | #define WRITE_HEADER BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_WRITE_MASK) /*!< macro to build the write |
group-ublox | 0:19aa55d66228 | 151 | header byte*/ |
group-ublox | 0:19aa55d66228 | 152 | #define READ_HEADER BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_READ_MASK) /*!< macro to build the read |
group-ublox | 0:19aa55d66228 | 153 | header byte*/ |
group-ublox | 0:19aa55d66228 | 154 | #define COMMAND_HEADER BUILT_HEADER(HEADER_COMMAND_MASK, HEADER_WRITE_MASK) /*!< macro to build the command |
group-ublox | 0:19aa55d66228 | 155 | header byte*/ |
group-ublox | 0:19aa55d66228 | 156 | |
group-ublox | 0:19aa55d66228 | 157 | |
group-ublox | 0:19aa55d66228 | 158 | |
group-ublox | 0:19aa55d66228 | 159 | /* Exported Variables --------------------------------------------------------*/ |
group-ublox | 0:19aa55d66228 | 160 | |
group-ublox | 0:19aa55d66228 | 161 | |
group-ublox | 0:19aa55d66228 | 162 | /* Exported functions ------------------------------------------------------- */ |
group-ublox | 0:19aa55d66228 | 163 | void SdkEvalSpiInit(void); |
group-ublox | 0:19aa55d66228 | 164 | // void SpiCSGpioSetLevel(GPIO_PinState xState); |
group-ublox | 0:19aa55d66228 | 165 | StatusBytes SdkEvalSpiWriteRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t* pcBuffer); |
group-ublox | 0:19aa55d66228 | 166 | StatusBytes SdkEvalSpiReadRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t* pcBuffer); |
group-ublox | 0:19aa55d66228 | 167 | StatusBytes SdkEvalSpiCommandStrobes(uint8_t cCommandCode); |
group-ublox | 0:19aa55d66228 | 168 | StatusBytes SdkEvalSpiWriteFifo(uint8_t cNbBytes, uint8_t* pcBuffer); |
group-ublox | 0:19aa55d66228 | 169 | StatusBytes SdkEvalSpiReadFifo(uint8_t cNbBytes, uint8_t* pcBuffer); |
group-ublox | 0:19aa55d66228 | 170 | |
group-ublox | 0:19aa55d66228 | 171 | |
group-ublox | 0:19aa55d66228 | 172 | #ifdef __cplusplus |
group-ublox | 0:19aa55d66228 | 173 | } |
group-ublox | 0:19aa55d66228 | 174 | #endif |
group-ublox | 0:19aa55d66228 | 175 | #endif /*__RADIO_SPI_H */ |
group-ublox | 0:19aa55d66228 | 176 | |
group-ublox | 0:19aa55d66228 | 177 | /** |
group-ublox | 0:19aa55d66228 | 178 | * @} |
group-ublox | 0:19aa55d66228 | 179 | */ |
group-ublox | 0:19aa55d66228 | 180 | |
group-ublox | 0:19aa55d66228 | 181 | /** |
group-ublox | 0:19aa55d66228 | 182 | * @} |
group-ublox | 0:19aa55d66228 | 183 | */ |
group-ublox | 0:19aa55d66228 | 184 | |
group-ublox | 0:19aa55d66228 | 185 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |