mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/at86rf2xx: add AT86RF2XX_IS_PERIPH macro
This commit is contained in:
parent
384e3ca534
commit
b6b8dc1958
@ -124,7 +124,7 @@ void at86rf2xx_setup(at86rf2xx_t *dev, const at86rf2xx_params_t *params, uint8_t
|
||||
dev->state = AT86RF2XX_STATE_P_ON;
|
||||
dev->pending_tx = 0;
|
||||
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
(void) params;
|
||||
/* set all interrupts off */
|
||||
at86rf2xx_reg_write(dev, AT86RF2XX_REG__IRQ_MASK, 0x00);
|
||||
@ -140,7 +140,7 @@ void at86rf2xx_setup(at86rf2xx_t *dev, const at86rf2xx_params_t *params, uint8_t
|
||||
|
||||
static void at86rf2xx_disable_clock_output(at86rf2xx_t *dev)
|
||||
{
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
(void) dev;
|
||||
#else
|
||||
uint8_t tmp = at86rf2xx_reg_read(dev, AT86RF2XX_REG__TRX_CTRL_0);
|
||||
@ -210,7 +210,7 @@ void at86rf2xx_reset(at86rf2xx_t *dev)
|
||||
at86rf2xx_set_page(dev, AT86RF2XX_DEFAULT_PAGE);
|
||||
#endif
|
||||
|
||||
#if !defined(MODULE_AT86RFA1) && !defined(MODULE_AT86RFR2)
|
||||
#if !AT86RF2XX_IS_PERIPH
|
||||
/* don't populate masked interrupt flags to IRQ_STATUS register */
|
||||
tmp = at86rf2xx_reg_read(dev, AT86RF2XX_REG__TRX_CTRL_1);
|
||||
tmp &= ~(AT86RF2XX_TRX_CTRL_1_MASK__IRQ_MASK_MODE);
|
||||
|
@ -524,7 +524,7 @@ uint8_t at86rf2xx_set_state(at86rf2xx_t *dev, uint8_t state)
|
||||
/* Discard all IRQ flags, framebuffer is lost anyway */
|
||||
at86rf2xx_reg_read(dev, AT86RF2XX_REG__IRQ_STATUS);
|
||||
/* Go to SLEEP mode from TRX_OFF */
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
/* reset interrupts states in device */
|
||||
dev->irq_status = 0;
|
||||
/* Setting SLPTR bit brings radio transceiver to sleep in in TRX_OFF*/
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "at86rf2xx_internal.h"
|
||||
#include "at86rf2xx_registers.h"
|
||||
|
||||
#if !defined(MODULE_AT86RFA1) && !defined(MODULE_AT86RFR2)
|
||||
#if !AT86RF2XX_IS_PERIPH
|
||||
#include "periph/spi.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
@ -120,7 +120,7 @@ void at86rf2xx_assert_awake(at86rf2xx_t *dev)
|
||||
{
|
||||
if (at86rf2xx_get_status(dev) == AT86RF2XX_STATE_SLEEP) {
|
||||
/* wake up and wait for transition to TRX_OFF */
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
/* Setting SLPTR bit in TRXPR to 0 returns the radio transceiver
|
||||
* to the TRX_OFF state */
|
||||
*AT86RF2XX_REG__TRXPR &= ~(AT86RF2XX_TRXPR_SLPTR);
|
||||
@ -144,7 +144,7 @@ void at86rf2xx_assert_awake(at86rf2xx_t *dev)
|
||||
void at86rf2xx_hardware_reset(at86rf2xx_t *dev)
|
||||
{
|
||||
/* trigger hardware reset */
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
/* set reset Bit */
|
||||
*(AT86RF2XX_REG__TRXPR) |= AT86RF2XX_TRXPR_TRXRST;
|
||||
#else
|
||||
|
@ -62,7 +62,7 @@ const netdev_driver_t at86rf2xx_driver = {
|
||||
.set = _set,
|
||||
};
|
||||
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
/* SOC has radio interrupts, store reference to netdev */
|
||||
static netdev_t *at86rfmega_dev;
|
||||
#else
|
||||
@ -78,7 +78,7 @@ static int _init(netdev_t *netdev)
|
||||
netdev_ieee802154_t, netdev);
|
||||
at86rf2xx_t *dev = container_of(netdev_ieee802154, at86rf2xx_t, netdev);
|
||||
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
at86rfmega_dev = netdev;
|
||||
#else
|
||||
/* initialize GPIOs */
|
||||
@ -161,7 +161,7 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
||||
at86rf2xx_fb_start(dev);
|
||||
|
||||
/* get the size of the received packet */
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
phr = TST_RX_LENGTH;
|
||||
#else
|
||||
at86rf2xx_fb_read(dev, &phr, 1);
|
||||
@ -223,7 +223,7 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
||||
netdev_ieee802154_rx_info_t *radio_info = info;
|
||||
at86rf2xx_fb_read(dev, &(radio_info->lqi), 1);
|
||||
|
||||
#if defined(MODULE_AT86RF231) || defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if defined(MODULE_AT86RF231) || IS_ACTIVE(AT86RF2XX_PERIPH)
|
||||
/* AT86RF231 does not provide ED at the end of the frame buffer, read
|
||||
* from separate register instead */
|
||||
at86rf2xx_fb_stop(dev);
|
||||
@ -752,7 +752,7 @@ static void _isr(netdev_t *netdev)
|
||||
}
|
||||
|
||||
/* read (consume) device status */
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
irq_mask = dev->irq_status;
|
||||
dev->irq_status = 0;
|
||||
#else
|
||||
@ -802,7 +802,7 @@ static void _isr(netdev_t *netdev)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
|
||||
/**
|
||||
* @brief ISR for transceiver's TX_START interrupt
|
||||
@ -1010,4 +1010,4 @@ ISR(TRX24_AWAKE_vect, ISR_BLOCK)
|
||||
avr8_exit_isr();
|
||||
}
|
||||
|
||||
#endif /* MODULE_AT86RFA1 || MODULE_AT86RFR2 */
|
||||
#endif /* AT86RF2XX_IS_PERIPH */
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "at86rf2xx.h"
|
||||
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
#include <string.h>
|
||||
#include "at86rf2xx_registers.h"
|
||||
#endif
|
||||
@ -85,7 +85,7 @@ extern "C" {
|
||||
*
|
||||
* @return the value of the specified register
|
||||
*/
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
static inline uint8_t at86rf2xx_reg_read(const at86rf2xx_t *dev, volatile uint8_t *addr) {
|
||||
(void) dev;
|
||||
return *addr;
|
||||
@ -101,7 +101,7 @@ uint8_t at86rf2xx_reg_read(const at86rf2xx_t *dev, uint8_t addr);
|
||||
* @param[in] addr address of the register to write
|
||||
* @param[in] value value to write to the given register
|
||||
*/
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
static inline void at86rf2xx_reg_write(const at86rf2xx_t *dev, volatile uint8_t *addr,
|
||||
const uint8_t value) {
|
||||
(void) dev;
|
||||
@ -119,7 +119,7 @@ void at86rf2xx_reg_write(const at86rf2xx_t *dev, uint8_t addr, uint8_t value);
|
||||
* @param[out] data buffer to read data into
|
||||
* @param[in] len number of bytes to read from SRAM
|
||||
*/
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
static inline void at86rf2xx_sram_read(const at86rf2xx_t *dev, uint8_t offset,
|
||||
uint8_t *data, size_t len) {
|
||||
(void)dev;
|
||||
@ -137,7 +137,7 @@ void at86rf2xx_sram_read(const at86rf2xx_t *dev, uint8_t offset,
|
||||
* @param[in] data data to copy into SRAM
|
||||
* @param[in] len number of bytes to write to SRAM
|
||||
*/
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
static inline void at86rf2xx_sram_write(const at86rf2xx_t *dev, uint8_t offset,
|
||||
const uint8_t *data, size_t len) {
|
||||
(void)dev;
|
||||
@ -155,7 +155,7 @@ void at86rf2xx_sram_write(const at86rf2xx_t *dev, uint8_t offset,
|
||||
*
|
||||
* @param[in] dev device to start read
|
||||
*/
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
static inline void at86rf2xx_fb_start(const at86rf2xx_t *dev) {
|
||||
(void) dev;
|
||||
}
|
||||
@ -171,7 +171,7 @@ void at86rf2xx_fb_start(const at86rf2xx_t *dev);
|
||||
* @param[out] data buffer to copy the data to
|
||||
* @param[in] len number of bytes to read from the frame buffer
|
||||
*/
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
static inline void at86rf2xx_fb_read(const at86rf2xx_t *dev, uint8_t *data, size_t len) {
|
||||
(void)dev;
|
||||
memcpy(data, (void*)AT86RF2XX_REG__TRXFBST, len);
|
||||
@ -186,7 +186,7 @@ void at86rf2xx_fb_read(const at86rf2xx_t *dev, uint8_t *data, size_t len);
|
||||
*
|
||||
* @param[in] dev device to stop read
|
||||
*/
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
static inline void at86rf2xx_fb_stop(const at86rf2xx_t *dev) {
|
||||
(void) dev;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ extern "C" {
|
||||
/**
|
||||
* @brief AT86RF231 configuration
|
||||
*/
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
static const uint8_t at86rf2xx_params[] =
|
||||
{
|
||||
0 /* dummy value */
|
||||
|
@ -107,6 +107,15 @@ extern "C" {
|
||||
# define MIN_RX_SENSITIVITY (-101)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Whether there is a periph version of the radio
|
||||
*/
|
||||
#if IS_USED(MODULE_AT86RFA1) || IS_USED(MODULE_AT86RFR2)
|
||||
#define AT86RF2XX_IS_PERIPH (1)
|
||||
#else
|
||||
#define AT86RF2XX_IS_PERIPH (0)
|
||||
#endif
|
||||
|
||||
#if defined(DOXYGEN) || defined(MODULE_AT86RF232) || defined(MODULE_AT86RF233) || defined(MODULE_AT86RFR2)
|
||||
/**
|
||||
* @brief Frame retry counter reporting
|
||||
@ -209,7 +218,7 @@ extern "C" {
|
||||
#define AT86RF2XX_PHY_STATE_TX_BUSY AT86RF2XX_STATE_BUSY_TX_ARET
|
||||
#endif /* IS_ACTIVE(AT86RF2XX_BASIC_MODE) */
|
||||
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
/**
|
||||
* @brief memory mapped radio needs no parameters
|
||||
*/
|
||||
@ -235,7 +244,7 @@ typedef struct at86rf2xx_params {
|
||||
*/
|
||||
typedef struct {
|
||||
netdev_ieee802154_t netdev; /**< netdev parent struct */
|
||||
#if defined(MODULE_AT86RFA1) || defined(MODULE_AT86RFR2)
|
||||
#if AT86RF2XX_IS_PERIPH
|
||||
/* ATmega256rfr2 signals transceiver events with different interrupts
|
||||
* they have to be stored to mimic the same flow as external transceiver
|
||||
* Use irq_status to map saved interrupts of SOC transceiver,
|
||||
|
Loading…
Reference in New Issue
Block a user