Skip to content

Commit

Permalink
fixup! drivers/at86rf2xx: add AT86RF2XX_PERIPH macro
Browse files Browse the repository at this point in the history
  • Loading branch information
jia200x committed Nov 25, 2022
1 parent 1b93554 commit 99ac9fc
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 26 deletions.
6 changes: 3 additions & 3 deletions drivers/at86rf2xx/at86rf2xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
(void) params;
/* set all interrupts off */
at86rf2xx_reg_write(dev, AT86RF2XX_REG__IRQ_MASK, 0x00);
Expand All @@ -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 IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
(void) dev;
#else
uint8_t tmp = at86rf2xx_reg_read(dev, AT86RF2XX_REG__TRX_CTRL_0);
Expand Down Expand Up @@ -210,7 +210,7 @@ void at86rf2xx_reset(at86rf2xx_t *dev)
at86rf2xx_set_page(dev, AT86RF2XX_DEFAULT_PAGE);
#endif

#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if !AT86RF2XX_HAVE_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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/at86rf2xx/at86rf2xx_getset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
/* reset interrupts states in device */
dev->irq_status = 0;
/* Setting SLPTR bit brings radio transceiver to sleep in in TRX_OFF*/
Expand Down
6 changes: 3 additions & 3 deletions drivers/at86rf2xx/at86rf2xx_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "at86rf2xx_internal.h"
#include "at86rf2xx_registers.h"

#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if !AT86RF2XX_HAVE_PERIPH
#include "periph/spi.h"
#include "periph/gpio.h"

Expand Down Expand Up @@ -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 IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
/* Setting SLPTR bit in TRXPR to 0 returns the radio transceiver
* to the TRX_OFF state */
*AT86RF2XX_REG__TRXPR &= ~(AT86RF2XX_TRXPR_SLPTR);
Expand All @@ -144,7 +144,7 @@ void at86rf2xx_assert_awake(at86rf2xx_t *dev)
void at86rf2xx_hardware_reset(at86rf2xx_t *dev)
{
/* trigger hardware reset */
#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
/* set reset Bit */
*(AT86RF2XX_REG__TRXPR) |= AT86RF2XX_TRXPR_TRXRST;
#else
Expand Down
12 changes: 6 additions & 6 deletions drivers/at86rf2xx/at86rf2xx_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const netdev_driver_t at86rf2xx_driver = {
.set = _set,
};

#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
/* SOC has radio interrupts, store reference to netdev */
static netdev_t *at86rfmega_dev;
#else
Expand All @@ -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 IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
at86rfmega_dev = netdev;
#else
/* initialize GPIOs */
Expand Down Expand Up @@ -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 IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
phr = TST_RX_LENGTH;
#else
at86rf2xx_fb_read(dev, &phr, 1);
Expand Down Expand Up @@ -752,7 +752,7 @@ static void _isr(netdev_t *netdev)
}

/* read (consume) device status */
#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
irq_mask = dev->irq_status;
dev->irq_status = 0;
#else
Expand Down Expand Up @@ -802,7 +802,7 @@ static void _isr(netdev_t *netdev)
}
}

#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH

/**
* @brief ISR for transceiver's TX_START interrupt
Expand Down Expand Up @@ -1010,4 +1010,4 @@ ISR(TRX24_AWAKE_vect, ISR_BLOCK)
avr8_exit_isr();
}

#endif /* AT86RF2XX_PERIPH */
#endif /* AT86RF2XX_HAVE_PERIPH */
16 changes: 8 additions & 8 deletions drivers/at86rf2xx/include/at86rf2xx_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "at86rf2xx.h"

#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
#include <string.h>
#include "at86rf2xx_registers.h"
#endif
Expand Down Expand Up @@ -85,7 +85,7 @@ extern "C" {
*
* @return the value of the specified register
*/
#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
static inline uint8_t at86rf2xx_reg_read(const at86rf2xx_t *dev, volatile uint8_t *addr) {
(void) dev;
return *addr;
Expand All @@ -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 IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
static inline void at86rf2xx_reg_write(const at86rf2xx_t *dev, volatile uint8_t *addr,
const uint8_t value) {
(void) dev;
Expand All @@ -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 IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
static inline void at86rf2xx_sram_read(const at86rf2xx_t *dev, uint8_t offset,
uint8_t *data, size_t len) {
(void)dev;
Expand All @@ -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 IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
static inline void at86rf2xx_sram_write(const at86rf2xx_t *dev, uint8_t offset,
const uint8_t *data, size_t len) {
(void)dev;
Expand All @@ -155,7 +155,7 @@ void at86rf2xx_sram_write(const at86rf2xx_t *dev, uint8_t offset,
*
* @param[in] dev device to start read
*/
#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
static inline void at86rf2xx_fb_start(const at86rf2xx_t *dev) {
(void) dev;
}
Expand All @@ -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 IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_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);
Expand All @@ -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 IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
static inline void at86rf2xx_fb_stop(const at86rf2xx_t *dev) {
(void) dev;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/at86rf2xx/include/at86rf2xx_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extern "C" {
/**
* @brief AT86RF231 configuration
*/
#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
static const uint8_t at86rf2xx_params[] =
{
0 /* dummy value */
Expand Down
10 changes: 6 additions & 4 deletions drivers/include/at86rf2xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ extern "C" {
* @brief Whether there is a periph version of the radio
*/
#if IS_USED(MODULE_AT86RFA1) || IS_USED(MODULE_AT86RFR2)
#define AT86RF2XX_PERIPH 1
#define AT86RF2XX_HAVE_PERIPH (1)
#else
#define AT86RF2XX_HAVE_PERIPH (0)
#endif

/**
* @brief ED Register
*/
#if defined(MODULE_AT86RF231) || IS_ACTIVE(AT86RF2XX_PERIPH)
#if defined(MODULE_AT86RF231) || AT86RF2XX_HAVE_PERIPH
#define AT86RF2XX_HAVE_ED_REGISTER (1)
#else
#define AT86RF2XX_HAVE_ED_REGISTER (0)
Expand Down Expand Up @@ -253,7 +255,7 @@ extern "C" {
#define AT86RF2XX_PHY_STATE_TX_BUSY AT86RF2XX_STATE_BUSY_TX_ARET
#endif /* IS_ACTIVE(AT86RF2XX_BASIC_MODE) */

#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_PERIPH
/**
* @brief memory mapped radio needs no parameters
*/
Expand All @@ -279,7 +281,7 @@ typedef struct at86rf2xx_params {
*/
typedef struct {
netdev_ieee802154_t netdev; /**< netdev parent struct */
#if IS_ACTIVE(AT86RF2XX_PERIPH)
#if AT86RF2XX_HAVE_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,
Expand Down

0 comments on commit 99ac9fc

Please sign in to comment.