Coder Social home page Coder Social logo

sx126x_driver's Introduction

SX126X driver

This package proposes an implementation in C of the driver for SX126X radio component. Please see the changelog for more information.

Structure

The driver is defined as follows:

  • sx126x.c: implementation of the driver functions
  • sx126x.h: declarations of the driver functions
  • sx126x_regs.h: definitions of all useful registers (address and fields)
  • sx126x_hal.h: declarations of the HAL functions (to be implemented by the user - see below)
  • lr_fhss_mac.c: Transceiver-independent LR-FHSS implementation
  • sx126x_lr_fhss.c: Transceiver-dependent LR-FHSS implementation
  • lr_fhss_mac.h: Transceiver-independent LR-FHSS declarations
  • sx126x_lr_fhss.h: Transceiver-dependent LR-FHSS declarations
  • lr_fhss_v1_base_types.h: LR-FHSS type interface

HAL

The HAL (Hardware Abstraction Layer) is a collection of functions the user shall implement to write platform-dependant calls to the host. The list of functions is the following:

  • sx126x_hal_reset
  • sx126x_hal_wakeup
  • sx126x_hal_write
  • sx126x_hal_read

sx126x_driver's People

Contributors

smtc-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sx126x_driver's Issues

Error in library sx126x.c

In the library (sx126x.c), the command length is 3. In the documentation ( page 84) , the command length is 2 (highlighted in red). Response (data) 1 byte long (highlighted in blue)

SX126X_SIZE_GET_PKT_TYPE               = 3,

image

Output power not valid with SX126xWaitOnBusy

The sx1261 seems to be timing sensitive during configuration. I have multiple strange behaviors like low power output or bad frequency.

I'm using a custom bord with stm32l152 and I measure output power with an R&S Spectrum Rider FPH (spectrometer 5kHz->3Ghz).

Config 1 :

  • SX126xWaitOnBusy not implemented
  • Delay of 1s before and after Radio.SetChannel

==> Works correctly, the power is 14dB and frequency is 868Mhz

Config 2:

  • SX126xWaitOnBusy implemented
  • No delay

==> Frequency is OK, but power is reduce to -15dB

Config 3:

  • SX126xWaitOnBusy not implemented
  • No delay

==> Power output is Ok but frequency is set to 915Mhz

Here most important part of my code:

Main.c

Radio.Init( &RadioEvents );

      // Delays are mandatory without SX126xWaitOnBusy
//HAL_Delay(1000);
Radio.SetChannel( RF_FREQUENCY );
//HAL_Delay(1000);

Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
LORA_SPREADING_FACTOR, LORA_CODINGRATE,
LORA_PREAMBLE_LENGTH,LORA_FIX_LENGTH_PAYLOAD,
LORA_CRC, 0, 0, LORA_IQ_INVERSION, TX_TIMEOUT_VALUE );

Radio.SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD,
LORA_RX_LENGTH_PAYLOAD, LORA_CRC, 0, 0, LORA_IQ_INVERSION, RX_CONTINUOUS );

while (1){
  SetTrame(BufferTx, LORA_TX_LENGTH_PAYLOAD);
  Radio.Send(BufferTx, LORA_TX_LENGTH_PAYLOAD);
  RadioStatus_t status = SX126xGetStatus();
}

sx126X-board.c

void SX126xReset( void ){
	GPIO_InitTypeDef GPIO_InitStruct;

	GPIO_InitStruct.Pin = SX_NRESET_Pin;
	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
	HAL_GPIO_Init(SX_NRESET_GPIO_Port, &GPIO_InitStruct);
	HAL_Delay(10);

	HAL_GPIO_WritePin(SX_NRESET_GPIO_Port, SX_NRESET_Pin, GPIO_PIN_RESET);
	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
	HAL_GPIO_Init(SX_NRESET_GPIO_Port, &GPIO_InitStruct);
	HAL_Delay(10);

	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
	HAL_GPIO_Init(SX_NRESET_GPIO_Port, &GPIO_InitStruct);
}

void SX126xWaitOnBusy( void ){
	/*
	HAL_Delay(3);
	while( HAL_GPIO_ReadPin(SX_BUSY_GPIO_Port, SX_BUSY_Pin) == 1 );
	*/
}

Anyone have this issue ?

unable to enter rx mode

From the documentation an error 2A means the chip is still in standby and unable to enter the rx mode

The command was successfully processed, however the chip could not execute the command; for instance it was unable to enter the specified
device mode or send the requested data,

What would be the reason for the chip to be unable to enter rx mode ? or what are the condition to successfully enter rx mode from standby state using lora on sx1262 (ebyte E22 900M22S)?

sx1262

hello please provided main.c for sx126x_driver any one help me how to send data to gatway

FHSS only used in GMSK ?

this enum only has one . So maybe this code only used in GMSK?
typedef enum lr_fhss_v1_modulation_type_e
{
LR_FHSS_V1_MODULATION_TYPE_GMSK_488 = 0,
} lr_fhss_v1_modulation_type_t;

Range check of sx126x_set_rx_duty_cycle

May I suggest a range check in the function

sx126x_status_t sx126x_set_rx_duty_cycle( const void* context, const uint32_t rx_time_in_ms, const uint32_t sleep_time_in_ms )

The sx126x only provides 24 bits for setting the on and off times for rx duty cycle.

Either check for over maximum and set maximum or return an error.

`sx126x_status_t sx126x_set_rx_duty_cycle( const void* context, const uint32_t rx_time_in_ms,
const uint32_t sleep_time_in_ms )
{
const uint32_t rx_time_in_rtc_step = sx126x_convert_timeout_in_ms_to_rtc_step( rx_time_in_ms );
const uint32_t sleep_time_in_rtc_step = sx126x_convert_timeout_in_ms_to_rtc_step( sleep_time_in_ms );

if (rx_time_in_rtc_step >= (1 << 24))
{
    rx_time_in_rtc_step = (1 << 24) - 1;
}

if (sleep_time_in_rtc_step >= (1 << 24))
{
    sleep_time_in_rtc_step = (1 << 24) - 1;
}


return sx126x_set_rx_duty_cycle_with_timings_in_rtc_step( context, rx_time_in_rtc_step, sleep_time_in_rtc_step );

}`

local return variables size at sx126x.c not matching datasheet

There seems to be a mismatch between the size of the local arrays that hold the return value at functions in sx1262.c and the actual return value as it is states in the datasheet https://semtech.my.salesforce.com/sfc/p/#E0000000JelG/a/2R000000Un70/ZHJLT5MqbYVJJZCeCYgXjCek0iAq88aBOmZOU6Vgskk
some functions that I can point to are:
sx126x_get_irq_status- the irq_local is 2 byte size although the spi transction return 4 bytes (RFU, status, IrqStatus(15:0))
sx126x_get_gfsk_pkt_status - pkt_status_local is 3 bytes, although the spi transction return 5 bytes
sx126x_get_rssi_inst - rssi_local is 1 although the spi transction return 3 bytes

strange behavior in the RX buffer

when reading the buffer RX ( sx126x_read_buffer ) , if I read as many bytes as the sx126x_get_rx_buffer_status function says, there is random data. In order to retrieve my frame is to read 255 B and my received frame is there, with 4 bytes offset. If I read a different amount of bytes from the RX buffer, I get random data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.