Directory | Description |
---|---|
doc | Reference documentation |
img | Images |
script | Maixpy script example |
src | C program example based on the standalone sdk |
The SP_LoRa module uses M-XL8 module with LoRaTM modem and LoRa module with adjustable power amplifier. It has high performance and reliability and is connected by SP_MOD.
See Specification for more information
MCU:FUN(IO) | SP_LCD |
---|---|
GPIOHS7(IO_7) | RST |
SPI:MISO(IO_15) | SO |
SPI:SS0(IO_20) | CS |
SPI:SCK(IO_21) | SCK |
SPI:MOSI(IO_8) | SI |
GPIOH(IO_6) | IRQ |
1.8-6.3V | 3.3V |
GND | GND |
Configure IO port corresponding to MCU as SPI function pin.
-
C
fpioa_set_function(SPI_LORA_SX127X_CS_PIN_NUM, FUNC_SPI1_SS0); // CS: 20 fpioa_set_function(SPI_LORA_SX127X_SCK_PIN_NUM, FUNC_SPI1_SCLK); // SCLK: 21 fpioa_set_function(SPI_LORA_SX127X_MOSI_PIN_NUM, FUNC_SPI1_D0); // MOSI: 8 fpioa_set_function(SPI_LORA_SX127X_MISO_PIN_NUM, FUNC_SPI1_D1); // MISO: 15 fpioa_set_function(SPI_LORA_SX127X_IRQ_PIN_NUM, FUNC_GPIOHS0 + SPI_LORA_SX127X_IQR_GPIO_NUM); // IQR: 6 fpioa_set_function(SPI_LORA_SX127X_RST_PIN_NUM, FUNC_GPIOHS0 + SPI_LORA_SX127X_RST_GPIO_NUM); // RST: 7
-
MaixPy
fm.register(20, fm.fpioa.GPIOHS20, force=True) # RST fm.register(7, fm.fpioa.GPIOHS7, force=True) # CS # set gpiohs work mode to output mode cs = GPIO(GPIO.GPIOHS20, GPIO.OUT) rst = GPIO(GPIO.GPIOHS7, GPIO.IN) # The other pins are configured at SPI initialization time
-
C
spi_init(SPI_DEVICE_1, SPI_WORK_MODE_0, SPI_FF_STANDARD, DATALENGTH, 0);
-
MaixPy
spi1 = SPI(SPI.SPI1, mode=SPI.MODE_MASTER, baudrate=100 * 1000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB, sck=21, mosi=8, miso = 15)
-
Process
- Create the LoRa object and initialize it
- Send or receive data
-
C
sx1278_begin(&SX1278, SX1278_433MHZ, SX1278_POWER_17DBM, SX1278_LORA_SF_8, SX1278_LORA_BW_20_8KHZ, 10); if (master == 1) { printf("====MASTER====\r\n"); ret = sx1278_LoRaEntryTx(&SX1278, 16, 2000); } else { printf("====SALAVE====\r\n"); ret = sx1278_LoRaEntryRx(&SX1278, 16, 2000); }
-
MaixPy
lora = SX127x(spi=spi1, pin_ss=cs) lora.init() #######receiver########### receive(lora) ########sender########### # send(lora)
See SX1276_77_78_79.pdf for more information.
Language | Boards | SDK/Firmware version |
---|---|---|
C | MaixCube | kendryte-standalone-sdk v0.5.6 |
MaixPy | MaixCube | maixpy v0.5.1 |
The following parameters need to be modified.
-
C
// board_config.h #define SPI_INDEX 1 #define SPI_SCLK_RATE 600*1000 #define SPI_CHIP_SELECT_NSS 0//SPI_CHIP_SELECT_0 #define SPI_LORA_SX127X_CS_PIN_NUM 20 #define SPI_LORA_SX127X_SCK_PIN_NUM 21 #define SPI_LORA_SX127X_MOSI_PIN_NUM 8 #define SPI_LORA_SX127X_MISO_PIN_NUM 15 #define SPI_LORA_SX127X_IRQ_PIN_NUM 6 #define SPI_LORA_SX127X_RST_PIN_NUM 7 #define SPI_LORA_SX127X_IQR_GPIO_NUM 6 #define SPI_LORA_SX127X_RST_GPIO_NUM 7
-
MaixPy
################### config ################### LORA_RST = const(20) LORA_CS = const(7) LORA_SPI_SCK = const(21) LORA_SPI_MOSI = const(8) LORA_SPI_MISO = const(15) LORA_SPI_NUM = SPI.SPI1 LORA_SPI_FREQ_KHZ = const(100) ##############################################
See LICENSE file.
Version | Editor | Date |
---|---|---|
v1.0 | vamoosebbf | 2020.12.2 |