802.15.4 Atmel RF driver update

Sync with master version v3.3.2
pull/13550/head
Arto Kinnunen 2020-09-04 13:19:52 +03:00
parent 14a802b2b9
commit 7f1aa67611
4 changed files with 30 additions and 13 deletions

View File

@ -20,7 +20,7 @@
#include "at24mac.h"
#include "PinNames.h"
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_I2C && defined(MBED_CONF_RTOS_PRESENT)
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_I2C && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)
#include "NanostackRfPhy.h"

View File

@ -16,7 +16,7 @@
#include <string.h>
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_I2C && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)
#include "ns_types.h"
#include "platform/arm_hal_interrupt.h"

View File

@ -34,6 +34,21 @@
#include "inttypes.h"
#include "Timeout.h"
#include "platform/mbed_error.h"
#include "platform/mbed_version.h"
#if (MBED_VERSION > MBED_ENCODE_VERSION(6, 0, 0))
/* Mbed OS 6.0 introduces support for chrono time management */
using namespace std::chrono;
#define ATMEL_RF_TIME_50US 50us
#define ATMEL_RF_TIME_2MS 2ms
#define ATMEL_RF_TIME_10MS 10ms
#define ATMEL_RF_ATTACH(timer_ref, signal_ref, timeout_ref) timer_ref.attach(signal_ref, timeout_ref)
#else
#define ATMEL_RF_TIME_50US 50
#define ATMEL_RF_TIME_2MS 2
#define ATMEL_RF_TIME_10MS 10
#define ATMEL_RF_ATTACH(timer_ref, signal_ref, timeout_ref) timer_ref.attach_us(signal_ref, timeout_ref)
#endif
#define TRACE_GROUP "AtRF"
@ -345,7 +360,6 @@ static rf_trx_part_e rf_radio_type_read(void)
return ret_val;
}
/*
* \brief Function starts the ACK wait timeout.
*
@ -356,9 +370,9 @@ static rf_trx_part_e rf_radio_type_read(void)
static void rf_if_ack_wait_timer_start(uint16_t slots)
{
#ifdef MBED_CONF_RTOS_PRESENT
rf->ack_timer.attach_us(rf_if_ack_timer_signal, slots * 50);
ATMEL_RF_ATTACH(rf->ack_timer, rf_if_ack_timer_signal, slots * ATMEL_RF_TIME_50US);
#else
rf->ack_timer.attach_us(rf_ack_wait_timer_interrupt, slots * 50);
ATMEL_RF_ATTACH(rf->ack_timer, rf_ack_wait_timer_interrupt, slots * ATMEL_RF_TIME_50US);
#endif
}
@ -372,9 +386,9 @@ static void rf_if_ack_wait_timer_start(uint16_t slots)
static void rf_if_calibration_timer_start(uint32_t slots)
{
#ifdef MBED_CONF_RTOS_PRESENT
rf->cal_timer.attach_us(rf_if_cal_timer_signal, slots * 50);
ATMEL_RF_ATTACH(rf->cal_timer, rf_if_cal_timer_signal, slots * ATMEL_RF_TIME_50US);
#else
rf->cal_timer.attach_us(rf_calibration_timer_interrupt, slots * 50);
ATMEL_RF_ATTACH(rf->cal_timer, rf_calibration_timer_interrupt, slots * ATMEL_RF_TIME_50US);
#endif
}
@ -388,9 +402,9 @@ static void rf_if_calibration_timer_start(uint32_t slots)
static void rf_if_cca_timer_start(uint32_t slots)
{
#ifdef MBED_CONF_RTOS_PRESENT
rf->cca_timer.attach_us(rf_if_cca_timer_signal, slots * 50);
ATMEL_RF_ATTACH(rf->cca_timer, rf_if_cca_timer_signal, slots * ATMEL_RF_TIME_50US);
#else
rf->cca_timer.attach_us(rf_cca_timer_interrupt, slots * 50);
ATMEL_RF_ATTACH(rf->cca_timer, rf_cca_timer_interrupt, slots * ATMEL_RF_TIME_50US);
#endif
}
@ -519,14 +533,14 @@ static void rf_if_reset_radio(void)
#endif
rf->IRQ.rise(nullptr);
rf->RST = 1;
ThisThread::sleep_for(2);
ThisThread::sleep_for(ATMEL_RF_TIME_2MS);
rf->RST = 0;
ThisThread::sleep_for(10);
ThisThread::sleep_for(ATMEL_RF_TIME_10MS);
CS_RELEASE();
rf->SLP_TR = 0;
ThisThread::sleep_for(10);
ThisThread::sleep_for(ATMEL_RF_TIME_10MS);
rf->RST = 1;
ThisThread::sleep_for(10);
ThisThread::sleep_for(ATMEL_RF_TIME_10MS);
rf->IRQ.rise(&rf_if_interrupt_handler);
}

View File

@ -17,6 +17,8 @@
#ifndef RFBITS_H_
#define RFBITS_H_
#if DEVICE_SPI
#include "DigitalIn.h"
#include "DigitalOut.h"
#include "InterruptIn.h"
@ -78,4 +80,5 @@ public:
DigitalOut ANT_SEL;
};
#endif /* DEVICE_SPI */
#endif /* RFBITS_H_ */