Cleanup timers

This commit is contained in:
Manuel Bl 2019-10-07 23:24:51 +02:00
parent a601c2b2bf
commit c2a5bd8374
4 changed files with 1 additions and 48 deletions

20
Kconfig
View File

@ -46,26 +46,6 @@ config TTN_RADIO_SX1276_77_78_79
endchoice
choice TTN_TIMER
prompt "Timer"
default TTN_TIMER_1_GROUP_0
help
A timer is used to implement the LoRaWAN protocol. This selects the ESP32's timer.
config TTN_TIMER_0_GROUP_0
bool "Timer 0 of group 0"
config TTN_TIMER_1_GROUP_0
bool "Timer 1 of group 0"
config TTN_TIMER_0_GROUP_1
bool "Timer 0 of group 1"
config TTN_TIMER_1_GROUP_1
bool "Timer 1 of group 1"
endchoice
config TTN_SPI_FREQ
int "SPI frequency (in Hz)"
default 10000000

View File

@ -38,26 +38,6 @@
#error TTN LoRa radio chip must be configured using 'make menuconfig'
#endif
#if defined(CONFIG_TTN_TIMER_0_GROUP_0)
#define TTN_TIMER TIMER_0
#define TTN_TIMER_GROUP TIMER_GROUP_0
#define TTN_CLEAR_TIMER_ALARM TIMERG0.int_clr_timers.t0 = 1
#elif defined(CONFIG_TTN_TIMER_1_GROUP_0)
#define TTN_TIMER TIMER_1
#define TTN_TIMER_GROUP TIMER_GROUP_0
#define TTN_CLEAR_TIMER_ALARM TIMERG0.int_clr_timers.t1 = 1
#elif defined(CONFIG_TTN_TIMER_0_GROUP_1)
#define TTN_TIMER TIMER_0
#define TTN_TIMER_GROUP TIMER_GROUP_1
#define TTN_CLEAR_TIMER_ALARM TIMERG1.int_clr_timers.t0 = 1
#elif defined(CONFIG_TTN_TIMER_1_GROUP_1)
#define TTN_TIMER TIMER_1
#define TTN_TIMER_GROUP TIMER_GROUP_1
#define TTN_CLEAR_TIMER_ALARM TIMERG1.int_clr_timers.t1 = 1
#else
#error TTN timer must be configured using 'make menuconfig'
#endif
#if !defined(CONFIG_TTN_PROVISION_UART_NONE)
#define TTN_HAS_AT_COMMANDS 1
#if defined(CONFIG_TTN_PROVISION_UART_CONFIG_YES)

View File

@ -40,7 +40,7 @@ struct HALQueueItem
// Constructor
HAL_ESP32::HAL_ESP32()
: rssiCal(10), nextAlarm(0), isTimerArmed(false)
: rssiCal(10), nextAlarm(0)
{
}
@ -274,23 +274,17 @@ void HAL_ESP32::setNextAlarm(int64_t time)
void HAL_ESP32::armTimer(int64_t espNow)
{
if (isTimerArmed)
esp_timer_stop(timer);
if (nextAlarm == 0)
return;
int64_t timeout = nextAlarm - esp_timer_get_time();
if (timeout < 0)
timeout = 10;
esp_timer_start_once(timer, timeout);
isTimerArmed = true;
}
void HAL_ESP32::disarmTimer()
{
if (!isTimerArmed)
return;
esp_timer_stop(timer);
isTimerArmed = false;
}
void HAL_ESP32::timerCallback(void *arg)

View File

@ -87,7 +87,6 @@ private:
SemaphoreHandle_t mutex;
esp_timer_handle_t timer;
int64_t nextAlarm;
bool isTimerArmed;
};
extern HAL_ESP32 ttn_hal;