drivers: ieee802154: Let's timeout on cc2520 tx
Looks like getting an SFD interruption is not 100% reliable, so let's just use a semaphore with a timeout on it instead of using device_sync* routines. Change-Id: I4e4115c7b939c95d7e75fbb33664d411e0a6e8cc Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
d33c883eaf
commit
9313172f84
3 changed files with 7 additions and 9 deletions
|
@ -338,7 +338,7 @@ static inline void sfd_int_handler(struct device *port,
|
|||
|
||||
if (atomic_get(&cc2520->tx) == 1) {
|
||||
atomic_set(&cc2520->tx, 0);
|
||||
device_sync_call_complete(&cc2520->tx_sync);
|
||||
nano_isr_sem_give(&cc2520->tx_sync);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -831,6 +831,7 @@ static int cc2520_tx(struct device *dev, struct net_buf *buf)
|
|||
/* 1 retry is allowed here */
|
||||
do {
|
||||
atomic_set(&cc2520->tx, 1);
|
||||
nano_sem_init(&cc2520->tx_sync);
|
||||
|
||||
if (!instruct_stxoncca(&cc2520->spi)) {
|
||||
SYS_LOG_ERR(" Cannot start transmission\n");
|
||||
|
@ -838,8 +839,7 @@ static int cc2520_tx(struct device *dev, struct net_buf *buf)
|
|||
}
|
||||
|
||||
/* _cc2520_print_exceptions(cc2520); */
|
||||
|
||||
device_sync_call_wait(&cc2520->tx_sync);
|
||||
nano_sem_take(&cc2520->tx_sync, MSEC(10));
|
||||
|
||||
retry--;
|
||||
status = verify_tx_done(cc2520);
|
||||
|
@ -994,7 +994,6 @@ static int cc2520_init(struct device *dev)
|
|||
{
|
||||
struct cc2520_context *cc2520 = dev->driver_data;
|
||||
|
||||
device_sync_call_init(&cc2520->tx_sync);
|
||||
atomic_set(&cc2520->tx, 0);
|
||||
nano_sem_init(&cc2520->rx_lock);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ struct cc2520_context {
|
|||
struct cc2520_spi spi;
|
||||
uint8_t mac_addr[8];
|
||||
/************TX************/
|
||||
device_sync_call_t tx_sync;
|
||||
struct nano_sem tx_sync;
|
||||
atomic_t tx;
|
||||
/************RX************/
|
||||
char __stack cc2520_rx_stack[CONFIG_CC2520_RX_STACK_SIZE];
|
||||
|
|
|
@ -346,7 +346,7 @@ static inline void sfd_int_handler(struct device *port,
|
|||
|
||||
if (atomic_get(&cc2520->tx) == 1) {
|
||||
atomic_set(&cc2520->tx, 0);
|
||||
device_sync_call_complete(&cc2520->tx_sync);
|
||||
nano_isr_sem_give(&cc2520->tx_sync);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -794,6 +794,7 @@ static inline int cc2520_tx(struct device *dev, struct net_buf *buf)
|
|||
/* 1 retry is allowed here */
|
||||
do {
|
||||
atomic_set(&cc2520->tx, 1);
|
||||
nano_sem_init(&cc2520->tx_sync);
|
||||
|
||||
if (!instruct_stxoncca(&cc2520->spi)) {
|
||||
SYS_LOG_DBG("%s: Cannot start transmission\n", __func__);
|
||||
|
@ -801,8 +802,7 @@ static inline int cc2520_tx(struct device *dev, struct net_buf *buf)
|
|||
}
|
||||
|
||||
/* _cc2520_print_exceptions(cc2520); */
|
||||
|
||||
device_sync_call_wait(&cc2520->tx_sync);
|
||||
nano_sem_take(&cc2520->tx_sync, MSEC(10));
|
||||
|
||||
retry--;
|
||||
status = verify_tx_done(cc2520);
|
||||
|
@ -1135,7 +1135,6 @@ int cc2520_init(struct device *dev)
|
|||
|
||||
dev->driver_api = NULL;
|
||||
|
||||
device_sync_call_init(&cc2520->tx_sync);
|
||||
atomic_set(&cc2520->tx, 0);
|
||||
nano_sem_init(&cc2520->rx_lock);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue