123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- #ifndef __MYRADIO_GPIO_H_
- #define __MYRADIO_GPIO_H_
- #include <stdint.h>
- #include <stdbool.h>
- #include "stm32f10x.h"
- #include "stm32f10x_gpio.h"
- #include "stm32f10x_spi.h"
- #include "stm32f10x_it.h"
- #include "board.h"
- #define SPI_HARD
- //已经在keil->Options for Target->C/C++中定义
- // #define MODULE_IS_1W
- typedef void (*RADIO_GPIO_CALLBACK)(uint8_t index);
- //-------------射频模块引脚映射到转接板排针---------------
- #ifdef MODULE_IS_1W
- #define RF_SX128x_RST_PIN BOARD_PIN_SPI_GPIOA //
- #define RF_SX128x_RST_PORT BOARD_PORT_SPI_GPIOA
- #define RF_SX128x_RST RF_SX128x_RST_PORT, RF_SX128x_RST_PIN //
- //
- #define RF_SX128x_BUSY_PIN BOARD_PIN_SPI_GPIOD //
- #define RF_SX128x_BUSY_PORT BOARD_PORT_SPI_GPIOD
- #define RF_SX128x_BUSY RF_SX128x_BUSY_PORT, RF_SX128x_BUSY_PIN //
- //IO1用于射频中断响应
- #define RF_SX128x_IO1_PIN BOARD_PIN_SPI_GPIOB //
- #define RF_SX128x_IO1_PORT BOARD_PORT_SPI_GPIOB
- #define RF_SX128x_IO1 RF_SX128x_IO1_PORT, RF_SX128x_IO1_PIN //
- //
- #define RF_SX128x_IO2_PIN BOARD_PIN_SPI_GPIOE //
- #define RF_SX128x_IO2_PORT BOARD_PORT_SPI_GPIOE
- #define RF_SX128x_IO2 RF_SX128x_IO2_PORT, RF_SX128x_IO2_PIN //
- //
- #define RF_SX128x_IO3_PIN BOARD_PIN_SPI_GPIOC //
- #define RF_SX128x_IO3_PORT BOARD_PORT_SPI_GPIOC
- #define RF_SX128x_IO3 RF_SX128x_IO3_PORT, RF_SX128x_IO3_PIN //
- //外部PA和LNA控制脚
- #define RF_EXTPA_RE_PIN BOARD_PIN_SPI_GPIOE //
- #define RF_EXTPA_RE_PORT BOARD_PORT_SPI_GPIOE
- #define RF_EXTPA_RE RF_EXTPA_RE_PORT, RF_EXTPA_RE_PIN //
- #define RF_EXTPA_TE_PIN BOARD_PIN_SPI_GPIOF //
- #define RF_EXTPA_TE_PORT BOARD_PORT_SPI_GPIOF
- #define RF_EXTPA_TE RF_EXTPA_TE_PORT, RF_EXTPA_TE_PIN //
- #else
- //
- #define RF_SX128x_RST_PIN BOARD_PIN_SPI_GPIOA //
- #define RF_SX128x_RST_PORT BOARD_PORT_SPI_GPIOA
- #define RF_SX128x_RST RF_SX128x_RST_PORT, RF_SX128x_RST_PIN //
- //
- #define RF_SX128x_BUSY_PIN BOARD_PIN_SPI_GPIOB //
- #define RF_SX128x_BUSY_PORT BOARD_PORT_SPI_GPIOB
- #define RF_SX128x_BUSY RF_SX128x_BUSY_PORT, RF_SX128x_BUSY_PIN //
- //IO1用于射频中断响应
- #define RF_SX128x_IO1_PIN BOARD_PIN_SPI_GPIOC //
- #define RF_SX128x_IO1_PORT BOARD_PORT_SPI_GPIOC
- #define RF_SX128x_IO1 RF_SX128x_IO1_PORT, RF_SX128x_IO1_PIN //
- //
- #define RF_SX128x_IO2_PIN BOARD_PIN_SPI_GPIOD //
- #define RF_SX128x_IO2_PORT BOARD_PORT_SPI_GPIOD
- #define RF_SX128x_IO2 RF_SX128x_IO2_PORT, RF_SX128x_IO2_PIN //
- //
- #define RF_SX128x_IO3_PIN BOARD_PIN_SPI_GPIOE //
- #define RF_SX128x_IO3_PORT BOARD_PORT_SPI_GPIOE
- #define RF_SX128x_IO3 RF_SX128x_IO3_PORT, RF_SX128x_IO3_PIN //
- //外部PA和LNA控制脚
- #define RF_EXTPA_RE_PIN BOARD_PIN_SPI_GPIOG //
- #define RF_EXTPA_RE_PORT BOARD_PORT_SPI_GPIOG
- #define RF_EXTPA_RE RF_EXTPA_RE_PORT, RF_EXTPA_RE_PIN //
- #define RF_EXTPA_TE_PIN BOARD_PIN_SPI_GPIOF //
- #define RF_EXTPA_TE_PORT BOARD_PORT_SPI_GPIOF
- #define RF_EXTPA_TE RF_EXTPA_TE_PORT, RF_EXTPA_TE_PIN //
- #endif
- //-------------射频模块引脚映射到转接板排针---------------END
- uint8_t READ_RF_SX128x_BUSY(void);
- uint8_t READ_RF_SX128x_IO1(void);
- void RF_SX128x_RST_H(void);
- void RF_SX128x_RST_L(void);
- void RF_SX128x_BUSY_H(void);
- void RF_SX128x_BUSY_L(void);
- void RF_SX128x_IO1_H(void);
- void RF_SX128x_IO1_L(void);
- void RF_SX128x_IO2_H(void);
- void RF_SX128x_IO2_L(void);
- void RF_SX128x_IO3_H(void);
- void RF_SX128x_IO3_L(void);
- void RF_EXT_PA_RE_H(void);
- void RF_EXT_PA_RE_L(void);
- void RF_EXT_PA_TE_H(void);
- void RF_EXT_PA_TE_L(void);
- #define RF_EXT_PA_TO_TX() RF_EXT_PA_TE_H();RF_EXT_PA_RE_L()
- #define RF_EXT_PA_TO_RX() RF_EXT_PA_TE_L();RF_EXT_PA_RE_H()
- #define RF_EXT_PA_TO_IDLE() RF_EXT_PA_TE_L();RF_EXT_PA_RE_L()
- void BOARD_SPI_NSS_H(void);
- void BOARD_SPI_NSS_L(void);
- //-------------将封装的API映射到射频模块硬件层---------------
- void myRadio_gpio_init(RADIO_GPIO_CALLBACK cb);
- void myRadio_gpio_intoLwPwr(bool sta);
- uint8_t myRadioSpi_rwByte(uint8_t byteToWrite);
- void myRadioSpi_wBuffer(uint8_t* pData, uint16_t len);
- void myRadioSpi_rBuffer(uint8_t* pData, uint16_t len);
- void myRadioSpi_rwBuffer(uint8_t* pDataR, uint8_t* pDataW, uint16_t len);
- #define SpiReadWrite(p) myRadioSpi_rwByte(p)
- #define SpiWriteData(p1, p2) myRadioSpi_wBuffer(p1, p2)
- #define SpiReadData(p1, p2) myRadioSpi_rBuffer(p1, p2)
- #define SpiWriteReadData(p1, p2, p3) myRadioSpi_rwBuffer(p2, p1, p3)
- #define RF_SPI_NSS_H() BOARD_SPI_NSS_H()
- #define RF_SPI_NSS_L() BOARD_SPI_NSS_L()
- //-------------将封装的API映射到射频模块硬件层---------------END
- #endif
|