static rstatus_t gossip_process_msgs(void) { //TODOs: fix this to process an array of nodes while (!CBUF_IsEmpty(C2G_InQ)) { struct ring_msg *msg = (struct ring_msg *) CBUF_Pop(C2G_InQ); msg->cb(msg); ring_msg_deinit(msg); } return DN_OK; }
static rstatus_t core_process_messages(void) { //loga("Leng of C2G_OutQ ::: %d", CBUF_Len( C2G_OutQ )); while (!CBUF_IsEmpty(C2G_OutQ)) { struct ring_msg *msg = (struct ring_msg *) CBUF_Pop(C2G_OutQ); if (msg != NULL && msg->cb != NULL) { msg->cb(msg); core_debug(msg->sp->ctx); ring_msg_deinit(msg); } } return DN_OK; }
void UART5_IRQHandler(void) { char c; //figure out which flag triggered the interrupt uint32_t status = UART5->SR; if (status & _BV(RXNE5)) //received a byte { c = UART5->DR; CBUF_Push(uart5_getbuf, c); } else if (status & _BV(ORE5)) //this is a weird condition when another byte came in c = UART5->DR; //at exact moment of reading DR, causing ORE, but not RXNE if (status & _BV(TXE5)) //transmit buffer is empty { if (!CBUF_IsEmpty(uart5_putbuf)) UART5->DR = CBUF_Pop(uart5_putbuf); //push next character else UART5->CR1 &= ~(_BV(TXEIE5)); // Disable interrupt } }
int32_t uart5_getchar() { return ( CBUF_IsEmpty(uart5_getbuf) ? EOF : CBUF_Pop(uart5_getbuf) ); }