So I want to use the existing parts I have to make a meshcore node.
I have:
- Xiao nrf52 (not plus)
- RFM95 (aka SX1276 according to [Radiolib](https://jgromes.github.io/RadioLib/class_s_x1276.html))
MeshCore has support for the [Xiao nrf52](https://github.com/meshcore-dev/MeshCore/blob/5377d7cc1780a80d70196ea2e85773033d96d5e3/variants/xiao_nrf52/platformio.ini#L32) combined with the [Wio-SX1262](https://wiki.seeedstudio.com/xiao_nrf52840&_wio_SX1262_kit_for_meshtastic/) , so I'm pretty close. I just need to swap out the pins and classes for the SX1276
```
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=22
-D P_LORA_DIO_1=D1
-D P_LORA_RESET=D2
-D P_LORA_BUSY=D3
-D P_LORA_NSS=D4
-D SX126X_RXEN=D5
-D SX126X_TXEN=RADIOLIB_NC
-D SX126X_DIO2_AS_RF_SWITCH=1
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D PIN_WIRE_SCL=6
-D PIN_WIRE_SDA=7
```
These are the defines that we'll have to override.
```
-D SX127X_CURRENT_LIMIT=120
-D RADIO_CLASS=CustomSX1276
-D WRAPPER_CLASS=CustomSX1276Wrapper
-D LORA_TX_POWER=20
-D PIN_BOARD_SDA=6
-D PIN_BOARD_SCL=7
```
We need to figure out what pins are used for what.
We have ([RadioLibHal](https://jgromes.github.io/RadioLib/class_radio_lib_hal.html) *[hal](https://jgromes.github.io/RadioLib/class_module.html#a4483f0a39a523dd1b37b467d81418f7d), uint32_t cs, uint32_t irq, uint32_t rst, uint32_t gpio=RADIOLIB_NC)
So the RadioLib module constructor is:
- CS
- IRQ
- RST
- ?? "Pin to be used as additional interrupt/GPIO."
The T-Beam SX1276 (which we want to emulate) does this:
`RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1);`
So, DIO_0 is used for IRQ and DIO_1 is used for... IDK
The nrf with SX1262 does this:
`RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);`
So DIO_1 is used for IRQ and LORA_BUSY is what it says, a dedicated pin on the chip that the SX1276 doesn't seem to have.
I don't think I need SX1276X_RXEN or SX1276X_TXEN
# Final Pins
| Name | Xiao Pin | SX1276 Pin | Desc |
| ------------ | -------- | ---------- | --------------------------------------- |
| P_LORA_DIO_1 | D1 | DIO0 | We'll use DIO_0 or write some code |
| P_LORA_RESET | D2 | RESET | This is pulled to 3V3 on the WIO SX126X |
| P_LORA_BUSY | D3 | DIO1 | DIO_1 on the SX127X |
| P_LORA_NSS | D4 | NSS | |
| MOSI | D10 | MOSI | |
| MISO | D9 | MISO | |
| SCK | D8 | SCK | |
| 3.3V | 3.3V | 3.3V | |
| SDA | D6 | | For i2c if used |
| SCL | D7 | | |
| SX126X_RXEN | D5? | | Not a pin on SX127x? |
# References
- [WIO-SX1262 schematic](https://files.seeedstudio.com/products/SenseCAP/Wio_SX1262/Wio-SX1262%20for%20XIAO%20V1.0_SCH.pdf)
- [WIO-SX1262 product page](https://www.seeedstudio.com/Wio-SX1262-for-XIAO-p-6379.html)
- [RFM9X datasheet](https://cdn.sparkfun.com/assets/learn_tutorials/8/0/4/RFM95_96_97_98W.pdf)
- [SX1262 datasheet](https://www.mouser.com/datasheet/2/761/DS_SX1261-2_V1.1-1307803.pdf)
- [SX127X datasheet](https://cdn-shop.adafruit.com/product-files/3179/sx1276_77_78_79.pdf)
- [XAIO nRF72840 pinout](https://files.seeedstudio.com/wiki/XIAO-BLE/pinout2.png)
- [Radiolib SX1276 class reference](https://jgromes.github.io/RadioLib/class_s_x1276.html)