AT86RF23x: Clean-up, standardize lower half interface. Take advantage of new OS features for interrupt parameter passing.
This commit is contained in:
parent
16c3ea1f53
commit
b315f0d851
@ -146,7 +146,7 @@ static int at86rf23x_regdump(FAR struct at86rf23x_dev_s *dev);
|
||||
static void at86rf23x_irqwork_rx(FAR struct at86rf23x_dev_s *dev);
|
||||
static void at86rf23x_irqwork_tx(FAR struct at86rf23x_dev_s *dev);
|
||||
static void at86rf23x_irqworker(FAR void *arg);
|
||||
static int at86rf23x_interrupt(int irq, FAR void *context);
|
||||
static int at86rf23x_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||
|
||||
/* Driver operations */
|
||||
|
||||
@ -1221,11 +1221,11 @@ static int at86rf23x_resetrf(FAR struct at86rf23x_dev_s *dev)
|
||||
|
||||
/* Reset the radio */
|
||||
|
||||
lower->reset(lower, 0);
|
||||
lower->slptr(lower, 0);
|
||||
lower->reset(lower, false);
|
||||
lower->slptr(lower, false);
|
||||
|
||||
up_udelay(RF23X_TIME_RESET);
|
||||
lower->reset(lower, 1);
|
||||
lower->reset(lower, true);
|
||||
|
||||
/* Dummy read of IRQ register */
|
||||
|
||||
@ -1287,13 +1287,11 @@ static int at86rf23x_rxenable(FAR struct ieee802154_radio_s *ieee, bool state,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int at86rf23x_interrupt(int irq, FAR void *context)
|
||||
static int at86rf23x_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||
{
|
||||
/* To support multiple devices, retrieve the priv structure using the irq
|
||||
* number.
|
||||
*/
|
||||
FAR struct at86rf23x_dev_s *dev = (FAR struct at86rf23x_dev_s *)arg;
|
||||
|
||||
register FAR struct at86rf23x_dev_s *dev = &g_at86rf23x_devices[0];
|
||||
DEBUGASSERT(dev != NULL);
|
||||
|
||||
/* In complex environments, we cannot do SPI transfers from the interrupt
|
||||
* handler because semaphores are probably used to lock the SPI bus. In
|
||||
@ -1309,8 +1307,7 @@ static int at86rf23x_interrupt(int irq, FAR void *context)
|
||||
* Interrupts are re-enabled in enc_irqworker() when the work is completed.
|
||||
*/
|
||||
|
||||
dev->lower->irq(dev->lower, NULL, FALSE);
|
||||
//dev->lower->enable(dev->lower, FALSE);
|
||||
dev->lower->enable(dev->lower, false);
|
||||
|
||||
return work_queue(HPWORK, &dev->irqwork, at86rf23x_irqworker,
|
||||
(FAR void *)dev, 0);
|
||||
@ -1393,11 +1390,11 @@ static void at86rf23x_irqworker(FAR void *arg)
|
||||
{
|
||||
wlerr("ERROR: Unknown IRQ Status: %d\n", irq_status);
|
||||
|
||||
/* Re enable the IRQ even if we don't know how to handle previous
|
||||
/* Re-enable the IRQ even if we don't know how to handle previous
|
||||
* status.
|
||||
*/
|
||||
|
||||
dev->lower->irq(dev->lower, NULL, true);
|
||||
dev->lower->enable(dev->lower, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1428,9 +1425,9 @@ static void at86rf23x_irqwork_rx(FAR struct at86rf23x_dev_s *dev)
|
||||
* soon.
|
||||
*/
|
||||
|
||||
/* Re enable the IRQ */
|
||||
/* Re-enable the IRQ */
|
||||
|
||||
dev->lower->irq(dev->lower, NULL, true);
|
||||
dev->lower->enable(dev->lower, true);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -1452,7 +1449,7 @@ static void at86rf23x_irqwork_tx(FAR struct at86rf23x_dev_s *dev)
|
||||
|
||||
/* Re enable the IRQ */
|
||||
|
||||
dev->lower->irq(dev->lower, NULL, true);
|
||||
dev->lower->enable(dev->lower, true);
|
||||
|
||||
sem_post(&dev->ieee.txsem);
|
||||
}
|
||||
@ -1528,7 +1525,7 @@ FAR struct ieee802154_radio_s *at86rf23x_init(FAR struct spi_dev_s *spi,
|
||||
|
||||
/* Attach irq */
|
||||
|
||||
if (lower->irq(lower, at86rf23x_interrupt, false) != OK)
|
||||
if (lower->attach(lower, at86rf23x_interrupt, dev) != OK)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -1598,6 +1595,6 @@ FAR struct ieee802154_radio_s *at86rf23x_init(FAR struct spi_dev_s *spi,
|
||||
|
||||
/* Enable Radio IRQ */
|
||||
|
||||
lower->irq(lower, at86rf23x_interrupt, true);
|
||||
lower->enable(lower, true);
|
||||
return &dev->ieee;
|
||||
}
|
||||
|
@ -37,25 +37,36 @@
|
||||
#ifndef __INCLUDE_NUTTX_IEEE802154_AT86RF23X_H
|
||||
#define __INCLUDE_NUTTX_IEEE802154_AT86RF23X_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* The at86rf23x provides interrupts to the MCU via a GPIO pin. The
|
||||
* following structure provides an MCU-independent mechanixm for controlling
|
||||
* the at86rf23x GPIO interrupt.
|
||||
*
|
||||
* The at86rf23x interrupt is an active low, *level* interrupt. From Datasheet:
|
||||
* "Note 1: The INTEDGE polarity defaults to:
|
||||
* 0 = Falling Edge. Ensure that the inter-
|
||||
* rupt polarity matches the interrupt pin
|
||||
* polarity of the host microcontroller.
|
||||
* Note 2: The INT pin will remain high or low,
|
||||
* depending on INTEDGE polarity setting,
|
||||
* until INTSTAT register is read."
|
||||
* "Note 1: The INTEDGE polarity defaults to: 0 = Falling Edge. Ensure that
|
||||
* the interrupt polarity matches the interrupt pin polarity of the host
|
||||
* microcontroller.
|
||||
* "Note 2: The INT pin will remain high or low, depending on INTEDGE polarity
|
||||
* setting, until INTSTAT register is read."
|
||||
*/
|
||||
|
||||
struct at86rf23x_lower_s
|
||||
{
|
||||
int (*irq)(FAR const struct at86rf23x_lower_s *lower, xcpt_t handler, int state);
|
||||
void (*slptr)(FAR const struct at86rf23x_lower_s *lower, int state);
|
||||
void (*reset)(FAR const struct at86rf23x_lower_s *lower, int state);
|
||||
int (*attach)(FAR const struct at86rf23x_lower_s *lower, xcpt_t handler,
|
||||
FAR void *arg);
|
||||
void (*enable)(FAR const struct at86rf23x_lower_s *lower, bool state);
|
||||
void (*slptr)(FAR const struct at86rf23x_lower_s *lower, bool state);
|
||||
void (*reset)(FAR const struct at86rf23x_lower_s *lower, bool state);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
Reference in New Issue
Block a user