센서보드 RF IRQ 테스트 중

Fork of stm-spirit1-rf-driver by ST

Committer:
Wolfgang Betz
Date:
Thu Feb 01 16:15:57 2018 +0100
Revision:
78:65de72417cd3
Parent:
67:93bec0baf1de
Cleanup unnecessary header files

Who changed what in which revision?

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