/* * @brief print out the string in parameter over serial. Serial COM must first be initialized. */ void faultPrintSerial(const char *string) { int i, j, len; len = strlen(string); for (i = 0; i < len; i++) { // Block until UART buffer has more room while (!MAP_UARTSpaceAvail(UART0_BASE)); MAP_UARTCharPutNonBlocking(UART0_BASE, string[i]); if (string[i] == '\n') { while (!MAP_UARTSpaceAvail(UART0_BASE)); MAP_UARTCharPutNonBlocking(UART0_BASE, '\r'); } } }
void mgos_uart_hal_dispatch_tx_top(struct mgos_uart_state *us) { struct cc32xx_uart_state *ds = (struct cc32xx_uart_state *) us->dev_data; struct mbuf *txb = &us->tx_buf; size_t len = 0; while (len < txb->len && MAP_UARTSpaceAvail(ds->base)) { HWREG(ds->base + UART_O_DR) = *(txb->buf + len); len++; } mbuf_remove(txb, len); us->stats.tx_bytes += len; MAP_UARTIntClear(ds->base, UART_TX_INTS); }
//-------------------------------- void esp8266::OnTransmit() { if (m_nTxHead != m_nTxFill) { MAP_IntDisable(UART_INT); while (MAP_UARTSpaceAvail(UART_BASE) && (m_nTxHead != m_nTxFill)) { m_nTxHead = ((m_nTxHead + 1) % OutputBufferSize); MAP_UARTCharPutNonBlocking(UART_BASE, m_cOutput[m_nTxHead]); } MAP_IntEnable(UART_INT); } if (m_nTxHead == m_nTxFill) { MAP_UARTIntDisable(UART_BASE, UART_INT_TX); } }
STATIC mp_uint_t pyb_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) { pyb_uart_obj_t *self = self_in; mp_uint_t ret; if (request == MP_IOCTL_POLL) { mp_uint_t flags = arg; ret = 0; if ((flags & MP_IOCTL_POLL_RD) && uart_rx_any(self)) { ret |= MP_IOCTL_POLL_RD; } if ((flags & MP_IOCTL_POLL_WR) && MAP_UARTSpaceAvail(self->reg)) { ret |= MP_IOCTL_POLL_WR; } } else { *errcode = EINVAL; ret = MP_STREAM_ERROR; } return ret; }
void HardwareSerial::primeTransmit(unsigned long ulBase) { /* Do we have any data to transmit? */ if(!TX_BUFFER_EMPTY) { /* Disable the UART interrupt. If we don't do this there is a race * condition which can cause the read index to be corrupted. */ MAP_IntDisable(g_ulUARTInt[uartModule]); /* Yes - take some characters out of the transmit buffer and feed * them to the UART transmit FIFO. */ while(!TX_BUFFER_EMPTY){ while(MAP_UARTSpaceAvail(ulBase) && !TX_BUFFER_EMPTY){ MAP_UARTCharPutNonBlocking(ulBase, txBuffer[txReadIndex]); txReadIndex = (txReadIndex + 1) % txBufferSize; } } /* Reenable the UART interrupt */ MAP_IntEnable(g_ulUARTInt[uartModule]); } }