Merged in merlin17/nuttx/ieee802154 (pull request #330)
wireless/ieee802154: Work on packet reception at radio layer (MRF24J40) Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
commit
93e5c6905b
@ -1618,6 +1618,8 @@ static int mrf24j40_rxenable(FAR struct ieee802154_radio_s *radio, bool state,
|
||||
|
||||
static void mrf24j40_irqwork_rx(FAR struct mrf24j40_radio_s *dev)
|
||||
{
|
||||
FAR struct iob_s *iob;
|
||||
struct ieee802154_txdesc_s rxdesc;
|
||||
uint32_t addr;
|
||||
uint32_t index;
|
||||
uint8_t reg;
|
||||
@ -1634,25 +1636,46 @@ static void mrf24j40_irqwork_rx(FAR struct mrf24j40_radio_s *dev)
|
||||
|
||||
mrf24j40_setreg(dev->spi, MRF24J40_BBREG1, MRF24J40_BBREG1_RXDECINV);
|
||||
|
||||
|
||||
/* Allocate an IOB to put the packet in */
|
||||
|
||||
iob = iob_alloc(true);
|
||||
DEBUGASSERT(iob != NULL);
|
||||
|
||||
iob->io_flink = NULL;
|
||||
iob->io_len = 0;
|
||||
iob->io_offset = 0;
|
||||
iob->io_pktlen = 0;
|
||||
|
||||
/* Read packet */
|
||||
|
||||
addr = MRF24J40_RXBUF_BASE;
|
||||
dev->radio.rxbuf->len = mrf24j40_getreg(dev->spi, addr++);
|
||||
|
||||
iob->io_len= mrf24j40_getreg(dev->spi, addr++);
|
||||
/* wlinfo("len %3d\n", dev->radio.rxbuf->len); */
|
||||
|
||||
for (index = 0; index < dev->radio.rxbuf->len; index++)
|
||||
/* TODO: This needs to be changed. It is inefficient to do the SPI read byte
|
||||
* by byte */
|
||||
|
||||
for (index = 0; index < iob->io_len; index++)
|
||||
{
|
||||
dev->radio.rxbuf->data[index] = mrf24j40_getreg(dev->spi, addr++);
|
||||
iob->io_data[index] = mrf24j40_getreg(dev->spi, addr++);
|
||||
}
|
||||
|
||||
dev->radio.rxbuf->lqi = mrf24j40_getreg(dev->spi, addr++);
|
||||
dev->radio.rxbuf->rssi = mrf24j40_getreg(dev->spi, addr++);
|
||||
/* Copy meta-data into RX descriptor */
|
||||
|
||||
rxdesc.lqi = mrf24j40_getreg(dev->spi, addr++);
|
||||
rxdesc.rssi = mrf24j40_getreg(dev->spi, addr++);
|
||||
|
||||
/* Reduce len by 2, we only receive frames with correct crc, no check
|
||||
* required.
|
||||
*/
|
||||
|
||||
dev->radio.rxbuf->len -= 2;
|
||||
iob->io_len -= 2;
|
||||
|
||||
/* Callback the receiver in the next highest layer */
|
||||
|
||||
dev->radiocb->rx_frame(dev->radiocb, &rxdesc, iob);
|
||||
|
||||
/* Enable reception of next packet by flushing the fifo.
|
||||
* This is an MRF24J40 errata (no. 1).
|
||||
@ -1664,7 +1687,6 @@ static void mrf24j40_irqwork_rx(FAR struct mrf24j40_radio_s *dev)
|
||||
|
||||
mrf24j40_setreg(dev->spi, MRF24J40_BBREG1, 0);
|
||||
|
||||
sem_post(&dev->radio.rxsem);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -168,6 +168,12 @@ struct ieee802154_txdesc_s
|
||||
/* TODO: Add slotting information for GTS transactions */
|
||||
};
|
||||
|
||||
struct ieee802154_rxdesc_s
|
||||
{
|
||||
uint8_t lqi;
|
||||
uint8_t rssi;
|
||||
};
|
||||
|
||||
struct ieee802154_radiocb_s
|
||||
{
|
||||
CODE int (*poll_csma) (FAR struct ieee802154_radiocb_s *radiocb,
|
||||
@ -178,6 +184,9 @@ struct ieee802154_radiocb_s
|
||||
FAR const struct ieee802154_txdesc_s *tx_desc);
|
||||
CODE int (*txdone_gts) (FAR struct ieee802154_radiocb_s *radiocb,
|
||||
FAR const struct ieee802154_txdesc_s *tx_desc);
|
||||
CODE int (*rx_frame) (FAR struct ieee802154_radiocb_s *radiocb,
|
||||
FAR const struct ieee8021254_rxdesc_s *rx_desc,
|
||||
FAR struct iob_s *frame);
|
||||
};
|
||||
|
||||
struct ieee802154_radio_s; /* Forward reference */
|
||||
@ -197,13 +206,6 @@ struct ieee802154_radioops_s
|
||||
struct ieee802154_radio_s
|
||||
{
|
||||
FAR const struct ieee802154_radioops_s *ops;
|
||||
|
||||
/* Packet reception management */
|
||||
|
||||
struct ieee802154_packet_s *rxbuf; /* packet reception buffer, filled by
|
||||
* rx interrupt, NULL if rx not enabled */
|
||||
sem_t rxsem; /* Semaphore posted after reception of
|
||||
* a packet */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -77,7 +77,7 @@
|
||||
*/
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_MTU > (CONFIG_IOB_BUFSIZE * CONFIG_IOB_NBUFFERS)
|
||||
# error Not enough IOBs to hold one full IEEE802.14.5 packet
|
||||
# error Not enough IOBs to hold one full 6LoWPAN packet
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user