at86rf231: introduce variable to keep internal driver state
The at86rf231 radio transceiver provides one IRQ (TRX_END) signaling end of transmission or reception but no way to distinguish between these.
This commit is contained in:
parent
aaa2c2e8ba
commit
d50f43e9f5
@ -18,6 +18,7 @@
|
|||||||
* @brief Driver implementation for at86rf231 chip
|
* @brief Driver implementation for at86rf231 chip
|
||||||
*
|
*
|
||||||
* @author Alaeddine Weslati <alaeddine.weslati@inria.fr>
|
* @author Alaeddine Weslati <alaeddine.weslati@inria.fr>
|
||||||
|
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
|
||||||
*
|
*
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
@ -34,6 +35,8 @@ static uint8_t radio_channel;
|
|||||||
static uint16_t radio_address;
|
static uint16_t radio_address;
|
||||||
static uint64_t radio_address_long;
|
static uint64_t radio_address_long;
|
||||||
|
|
||||||
|
uint8_t driver_state;
|
||||||
|
|
||||||
void at86rf231_init(kernel_pid_t tpid)
|
void at86rf231_init(kernel_pid_t tpid)
|
||||||
{
|
{
|
||||||
transceiver_pid = tpid;
|
transceiver_pid = tpid;
|
||||||
@ -103,7 +106,18 @@ void at86rf231_switch_to_rx(void)
|
|||||||
|
|
||||||
void at86rf231_rx_irq(void)
|
void at86rf231_rx_irq(void)
|
||||||
{
|
{
|
||||||
at86rf231_rx_handler();
|
/* check if we are in sending state */
|
||||||
|
if (driver_state == AT_DRIVER_STATE_SENDING) {
|
||||||
|
/* Read IRQ to clear it */
|
||||||
|
at86rf231_reg_read(AT86RF231_REG__IRQ_STATUS);
|
||||||
|
/* clear internal state */
|
||||||
|
driver_state = AT_DRIVER_STATE_DEFAULT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* handle receive */
|
||||||
|
at86rf231_rx_handler();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
radio_address_t at86rf231_set_address(radio_address_t address)
|
radio_address_t at86rf231_set_address(radio_address_t address)
|
||||||
|
|||||||
@ -10,7 +10,11 @@
|
|||||||
#include "at86rf231_arch.h"
|
#include "at86rf231_arch.h"
|
||||||
#include "at86rf231_spi.h"
|
#include "at86rf231_spi.h"
|
||||||
|
|
||||||
|
#define ENABLE_DEBUG (0)
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
static void at86rf231_xmit(uint8_t *data, radio_packet_length_t length);
|
static void at86rf231_xmit(uint8_t *data, radio_packet_length_t length);
|
||||||
|
|
||||||
static void at86rf231_gen_pkt(uint8_t *buf, at86rf231_packet_t *packet);
|
static void at86rf231_gen_pkt(uint8_t *buf, at86rf231_packet_t *packet);
|
||||||
|
|
||||||
static uint8_t sequenz_nr;
|
static uint8_t sequenz_nr;
|
||||||
@ -87,11 +91,17 @@ static void at86rf231_xmit(uint8_t *data, radio_packet_length_t length)
|
|||||||
}
|
}
|
||||||
while ((status & AT86RF231_TRX_STATUS_MASK__TRX_STATUS) != AT86RF231_TRX_STATUS__PLL_ON);
|
while ((status & AT86RF231_TRX_STATUS_MASK__TRX_STATUS) != AT86RF231_TRX_STATUS__PLL_ON);
|
||||||
|
|
||||||
|
/* radio driver state: sending */
|
||||||
|
/* will be freed in at86rf231_rx_irq when TRX_END interrupt occurs */
|
||||||
|
driver_state = AT_DRIVER_STATE_SENDING;
|
||||||
|
|
||||||
// copy the packet to the radio FIFO
|
// copy the packet to the radio FIFO
|
||||||
at86rf231_write_fifo(data, length);
|
at86rf231_write_fifo(data, length);
|
||||||
|
DEBUG("Wrote to FIFO\n");
|
||||||
|
|
||||||
// Start TX
|
// Start TX
|
||||||
at86rf231_reg_write(AT86RF231_REG__TRX_STATE, AT86RF231_TRX_STATE__TX_START);
|
at86rf231_reg_write(AT86RF231_REG__TRX_STATE, AT86RF231_TRX_STATE__TX_START);
|
||||||
|
DEBUG("Started TX\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -31,6 +31,19 @@ typedef struct __attribute__((packed))
|
|||||||
}
|
}
|
||||||
at86rf231_packet_t;
|
at86rf231_packet_t;
|
||||||
|
|
||||||
|
extern int transceiver_pid;
|
||||||
|
|
||||||
|
#define AT_DRIVER_STATE_DEFAULT (0)
|
||||||
|
#define AT_DRIVER_STATE_SENDING (1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief To keep state inside of at86rf231 driver
|
||||||
|
* @details This variable is used to determine if a TRX_END IRQ from
|
||||||
|
* the radio transceiver has to be interpreted as end of
|
||||||
|
* sending or reception.
|
||||||
|
*/
|
||||||
|
extern uint8_t driver_state;
|
||||||
|
|
||||||
void at86rf231_init(kernel_pid_t tpid);
|
void at86rf231_init(kernel_pid_t tpid);
|
||||||
//void at86rf231_reset(void);
|
//void at86rf231_reset(void);
|
||||||
void at86rf231_rx(void);
|
void at86rf231_rx(void);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user