123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifndef __BSP_SPI_H__
- #define __BSP_SPI_H__
- //SPI 1.0V
- /*********************************************************************
- * INCLUDES
- */
- #include "nrf_drv_spi.h"
- #include "nrf_gpio.h"
- #include "nrf_pwr_mgmt.h"
- #include <string.h>
- #include "app_error.h"
- #include "SEGGER_RTT.h"
- #include "usr_config.h"
- /*********************************************************************
- * DEFINITIONS
- */
- #define BOARD_SPI_CS_ON 0 // SPI片选信号开
- #define BOARD_SPI_CS_OFF 1 // SPI片选信号关
- #define BOARD_SPI0_MISO_IO PIN_BMI_MISO // SPI主输入从输出IO口
- #define BOARD_SPI0_MOSI_IO PIN_BMI_MOSI // SPI主输出从输入IO口
- #define BOARD_SPI0_CLK_IO PIN_BMI_SCLK // SPI时钟控制IO口
- #define SPI_CS_NUMBER 1 // SPI片选引脚数量
- #define BOARD_SPI0_CS0_IO PIN_BMI_nCS // SPI片选0信号IO口
- #define SPI_CS_LIST {BOARD_SPI0_CS0_IO} // SPI片选引脚列表
- #define SPI_INSTANCE 0 // SPI instance index
- #define SPI_FREQUENCY NRF_DRV_SPI_FREQ_8M // SPI 频率
- #define WAIT_TIME_VALUE 3 // 等待超时最大值
- #define SPI_READ 0x00 //读标志位
- #define SPI_WRITE 0x01 //写标志位
- //ERROR CODE
- #define SPI_OP_SUCCESS 0x00 // spi操作成功
- #define SPI_ERROR_TIMEOUT (SPI_OP_SUCCESS+0x01) // 超时错误
- #define SPI_ERROR_CS (SPI_OP_SUCCESS+0x02) // 片选引脚错误
- /*********************************************************************
- * API FUNCTIONS
- */
-
- //SPI初始化
- void SPI_Init(void);
- //SPI只读寄存器数据
- uint32_t SPI_OnlyReadReg(uint32_t CsPin_number, uint8_t reg_addr, uint8_t *pData, uint8_t DataLen);
- //SPI只写寄存器数据
- uint32_t SPI_OnlyWriteReg(uint32_t CsPin_number, uint8_t reg_addr, uint8_t *pData, uint8_t DataLen);
- //开启SPI
- uint32_t SPI_Enable(void);
- //禁用SPI,实现低功耗配合SPI_Enable使用
- uint32_t SPI_Disable(void);
- #endif /* _BOARD_SPI_H_ */
|