Add SX1262 pins

This commit is contained in:
Lee Lup Yuen 2022-01-01 12:13:16 +08:00
parent e20b2c7dc0
commit 821208d605
3 changed files with 35 additions and 8 deletions

View file

@ -318,7 +318,19 @@ Let's build the NuttX Firmware that contains our __LoRaWAN Library__...
[__"LoRaWAN Frequency"__](https://lupyuen.github.io/articles/lorawan3#lorawan-frequency)
1. TODO: Pins
1. Edit the __Pin Definitions__...
```text
## For BL602 and BL604:
nuttx/boards/risc-v/bl602/bl602evb/include/board.h
## For ESP32: Change "esp32-devkitc" to our ESP32 board
nuttx/boards/xtensa/esp32/esp32-devkitc/src/esp32_gpio.c
```
Check that the __Semtech SX1262 Pins__ are configured correctly in [__board.h__](https://github.com/lupyuen/incubator-nuttx/blob/lorawan/boards/risc-v/bl602/bl602evb/include/board.h#L36-L95) or [__esp32_gpio.c__](https://github.com/lupyuen/incubator-nuttx/blob/lorawan/boards/xtensa/esp32/esp32-devkitc/src/esp32_gpio.c#L43-L67)...
[__"Connect SX1262 Transceiver"__](https://lupyuen.github.io/articles/sx1262#connect-sx1262-transceiver)
1. Configure the build...

View file

@ -886,20 +886,22 @@ printf("\nSX1262 Register 8 is 0x%02x\n", rx_data[4]);
We connect SX1262 to BL602 / ESP32 as follows...
SX1262 | BL602 Pin | ESP32 Pin | Colour
:-------: | :---------: | :--------: | :-----:
:-------: | :---------: | :--------: | :-----
__MOSI__ | GPIO 1 | GPIO 13 | Yellow
__MISO__ | GPIO 0 | GPIO 12 | Light Green
__SCK__ | GPIO 3 | GPIO 14 | Blue
__CS__ | GPIO 11 | GPIO 15 / 16 | Dark Green
__BUSY__ | GPIO 14 | GPIO 18 / 17 |
__DIO1__ | GPIO 17 | GPIO 22 |
__VCC__ | 3V3 | 3V3 | Red
__GND__ | GND | GND | Black
(We don't need to connect the Busy and DIO1 Pins, we're testing simple commands)
Here's SX1262 connected to PineCone BL602...
![SX1262 connected to PineCone BL602](https://lupyuen.github.io/images/spi2-title.jpg)
(Busy and DIO1 Pins are not connected, we'll need them for LoRa in the next artice)
_Why did we connect Chip Select to GPIO 11 / 15 / 16?_
Remember that we're controlling SPI Chip Select ourselves through __GPIO Output__, which is defined as follows...
@ -920,20 +922,33 @@ ESP32-DevKitC defines __GPIO 15__ as the default GPIO Output Pin: [esp32_gpio.c]
```c
/* Output pins. GPIO15 is used as an example, any other outputs could be used. */
#define GPIO_OUT1 15
/* Input pins. GPIO18 is used as an example, any other inputs could be
* used.
*/
#define GPIO_IN1 18
/* Interrupt pins. GPIO22 is used as an example, any other inputs could be
* used.
*/
#define GPIO_IRQPIN1 22
```
ESP32-WROVER-KIT uses __GPIO 16__: [esp32_gpio.c](https://github.com/lupyuen/incubator-nuttx/blob/spi_test/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c#L43-L67)
ESP32-WROVER-KIT uses __GPIO 16__ for GPIO Output: [esp32_gpio.c](https://github.com/lupyuen/incubator-nuttx/blob/spi_test/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c#L43-L67)
```c
#define GPIO_OUT1 16
#define GPIO_IN1 17
#define GPIO_IRQPIN1 22
```
TTGO-LoRa-ESP32 uses __GPIO 15__: [esp32_gpio.c](https://github.com/lupyuen/incubator-nuttx/blob/spi_test/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_gpio.c#L43-L67)
TTGO-LoRa-ESP32 uses __GPIO 15__ for GPIO Output: [esp32_gpio.c](https://github.com/lupyuen/incubator-nuttx/blob/spi_test/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_gpio.c#L43-L67)
```c
#define GPIO_OUT1 15
#define GPIO_IN1 18
#define GPIO_IRQPIN1 22
```
## Test SX1262

View file

@ -189,7 +189,7 @@ __NRESET__ | GPIO 18 | Not assigned yet
GPIO Output __BOARD_GPIO_OUT1__ becomes our __SPI Chip Select__. [(See this)](https://lupyuen.github.io/articles/spi2#control-chip-select-with-gpio)
Right now we won't use __BOARD_GPIO_IN1__ (Busy Pin), __BOARD_GPIO_INT1__ (DIO1) and __NRESET__.
__BOARD_GPIO_IN1__ (Busy Pin) and __BOARD_GPIO_INT1__ (DIO1) will be used for LoRaWAN in the next article.
__For BL602:__ Connect SX1262 to [these pins](https://lupyuen.github.io/articles/spi2#connect-sx1262). Copy the BL602 Pin Definitions from [board.h](https://github.com/lupyuen/incubator-nuttx/blob/spi_test/boards/risc-v/bl602/bl602evb/include/board.h#L36-L92) to...