Use sleep/wakeup for serial driver top-half

This commit is contained in:
Fabio Utzig 2015-05-14 23:07:10 -03:00
parent 3a0eb96f70
commit aa43fd6554
2 changed files with 6 additions and 14 deletions

View File

@ -98,7 +98,9 @@ static void notify1(io_queue_t *qp)
chnAddFlagsI(&SD1, CHN_OUTPUT_EMPTY);
return;
}
SD1.thread = chThdGetSelfX();
NRF_UART0->TXD = b;
chEvtWaitAny((eventmask_t) 1);
}
#endif
@ -123,25 +125,14 @@ OSAL_IRQ_HANDLER(Vector48) {
}
if (NRF_UART0->EVENTS_TXDRDY) {
msg_t b;
NRF_UART0->EVENTS_TXDRDY = 0;
osalSysLockFromISR();
b = oqGetI(&SD1.oqueue);
chEvtSignalI(SD1.thread, (eventmask_t) 1);
osalSysUnlockFromISR();
if (b < Q_OK) {
osalSysLockFromISR();
chnAddFlagsI(&SD1, CHN_OUTPUT_EMPTY);
osalSysUnlockFromISR();
} else {
NRF_UART0->TXD = b;
}
}
//TODO
NRF_UART0->EVENTS_ERROR = 0;
//NRF_UART0->EVENTS_ERROR = 0;
OSAL_IRQ_EPILOGUE();
}

View File

@ -88,7 +88,8 @@ typedef struct {
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
uint8_t ob[SERIAL_BUFFERS_SIZE]; \
/* End of the mandatory fields.*/
/* End of the mandatory fields.*/ \
thread_t *thread;
/*===========================================================================*/
/* Driver macros. */