Skip to content

Commit cf52184

Browse files
committed
parent bfa4f12
author Charles <[email protected]> 1637881721 +0100 committer Charles <[email protected]> 1638183821 +0100 parent bfa4f12 author Charles <[email protected]> 1637881721 +0100 committer Charles <[email protected]> 1638183722 +0100 Fixe Low Power high consumption Check TCXO available added TCXO startup delay STM32L1: add support of MCU_STM32L151xB for custom boards like RAK811 Allow STM32F7 targets without Ethernet Support different STM32F7 flash configurations Support missing SPI6 on STM32F7 Add STM32F722ZE target DTLSSocket handshake timeout calls object functions even if object is destructed. Fixed by removing timeout event from event queue on close/destruction. B_U585I_IOT02A supports OSPI M2354: Fix potential issues in TF-M Fix the following issues in TF-M to avoid emergence in the future: 1. Enable initial stack not located in SRAM bank0 On reset, only SRAM bank0 is enabled. And SRAM bank1/2 will be enabled in immediately following SystemInit(). When initial stack is located in SRAM bank1/2, we will meet trouble because SystemInit() itself needs to use initial stack. To conquer the dilemma, we add preceding code in front of original Systeminit(), which is responsible for enabling SRAM bank1/2 and guarantees no using initial stack. 2. Fix sector maps of internal/external (SDH) Flash are incompatible, caused by TF-M's MCUboot port. This is done by adapting external (SDH) Flash sector size to internal Flash's. 3. Enlarge firmware upgrade scratch size. There are two advantages: (1) Get around MCUboot limit which requires scratch size not smaller than image trailer size (2) Improve wear leveling for the scratch area Update Mbed version block Fixe Low Power high consumption Fix CI added TCXO startup delay
1 parent bfa4f12 commit cf52184

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

connectivity/drivers/lora/COMPONENT_SX1276/SX1276_LoRaRadio.cpp

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ SPDX-License-Identifier: BSD-3-Clause
3535
#include "sx1276Regs-LoRa.h"
3636

3737
#include <math.h> //rint
38-
38+
#include <chrono>
39+
using namespace std::chrono_literals;
3940
using namespace rtos;
4041
using namespace mbed;
4142

@@ -210,6 +211,8 @@ SX1276_LoRaRadio::SX1276_LoRaRadio(PinName spi_mosi,
210211

211212
if (tcxo != NC) {
212213
_tcxo = 1;
214+
// TCXO startup time
215+
ThisThread::sleep_for(60ms);
213216
}
214217

215218
#ifdef MBED_CONF_RTOS_PRESENT
@@ -288,9 +291,9 @@ void SX1276_LoRaRadio::radio_reset()
288291
{
289292
_reset_ctl.output();
290293
_reset_ctl = 0;
291-
ThisThread::sleep_for(2);
294+
ThisThread::sleep_for(2ms);
292295
_reset_ctl.input();
293-
ThisThread::sleep_for(6);
296+
ThisThread::sleep_for(6ms);
294297
}
295298

296299
/**
@@ -357,7 +360,7 @@ uint32_t SX1276_LoRaRadio::random(void)
357360
set_operation_mode(RF_OPMODE_RECEIVER);
358361

359362
for (i = 0; i < 32; i++) {
360-
ThisThread::sleep_for(1);
363+
ThisThread::sleep_for(1ms);
361364
// Unfiltered RSSI value reading. Only takes the LSB value
362365
rnd |= ((uint32_t) read_register(REG_LR_RSSIWIDEBAND) & 0x01) << i;
363366
}
@@ -805,7 +808,7 @@ void SX1276_LoRaRadio::send(uint8_t *buffer, uint8_t size)
805808
// FIFO operations can not take place in Sleep mode
806809
if ((read_register(REG_OPMODE) & ~RF_OPMODE_MASK) == RF_OPMODE_SLEEP) {
807810
standby();
808-
ThisThread::sleep_for(1);
811+
ThisThread::sleep_for(1ms);
809812
}
810813
// write_to_register payload buffer
811814
write_fifo(buffer, size);
@@ -1025,7 +1028,7 @@ bool SX1276_LoRaRadio::perform_carrier_sense(radio_modems_t modem,
10251028
set_operation_mode(RF_OPMODE_RECEIVER);
10261029

10271030
// hold on a bit, radio turn-around time
1028-
ThisThread::sleep_for(1);
1031+
ThisThread::sleep_for(1ms);
10291032

10301033
Timer elapsed_time;
10311034
elapsed_time.start();
@@ -1263,13 +1266,27 @@ void SX1276_LoRaRadio::read_fifo(uint8_t *buffer, uint8_t size)
12631266
void SX1276_LoRaRadio::set_operation_mode(uint8_t mode)
12641267
{
12651268
if (mode == RF_OPMODE_SLEEP) {
1269+
write_to_register(REG_OPMODE, (read_register(REG_OPMODE) & RF_OPMODE_MASK) | mode);
12661270
set_low_power_mode();
1271+
/* FIXME taken from set_modem, it reduces the power consumption
1272+
*from 300µA to 1.5µA */
1273+
write_to_register(REG_DIOMAPPING1, 0x00); // sets DIO0-DI03 in default mode
1274+
write_to_register(REG_DIOMAPPING2, 0x30); // bits 4-5 are turned on i.e.,
1275+
if (_rf_ctrls.tcxo != NC) {
1276+
ThisThread::sleep_for(10ms);
1277+
_tcxo = 0;
1278+
}
12671279
} else {
1280+
if (_rf_ctrls.tcxo != NC) {
1281+
_tcxo = 1;
1282+
// TCXO startup time
1283+
ThisThread::sleep_for(60ms);
1284+
}
12681285
set_low_power_mode();
1286+
write_to_register(REG_OPMODE, (read_register(REG_OPMODE) & RF_OPMODE_MASK) | mode);
12691287
set_antenna_switch(mode);
12701288
}
12711289

1272-
write_to_register(REG_OPMODE, (read_register(REG_OPMODE) & RF_OPMODE_MASK) | mode);
12731290
}
12741291

12751292
/**
@@ -1327,14 +1344,14 @@ void SX1276_LoRaRadio::set_sx1276_variant_type()
13271344
{
13281345
if (_rf_ctrls.ant_switch != NC) {
13291346
_ant_switch.input();
1330-
ThisThread::sleep_for(1);
1347+
ThisThread::sleep_for(1ms);
13311348
if (_ant_switch == 1) {
13321349
radio_variant = SX1276MB1LAS;
13331350
} else {
13341351
radio_variant = SX1276MB1MAS;
13351352
}
13361353
_ant_switch.output();
1337-
ThisThread::sleep_for(1);
1354+
ThisThread::sleep_for(1ms);
13381355
} else {
13391356
radio_variant = MBED_CONF_SX1276_LORA_DRIVER_RADIO_VARIANT;
13401357
}

0 commit comments

Comments
 (0)