示例#1
0
/*
 * @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');
		}
	}
}
示例#2
0
static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
{
	struct rt_lm3s_serial* serial;
	char *ptr;

	serial = (struct rt_lm3s_serial*) dev;
	if (dev->flag & RT_DEVICE_FLAG_INT_TX)
	{
		/* not support */
		RT_ASSERT(0);
	}
	else if (dev->flag & RT_DEVICE_FLAG_DMA_TX)
	{
		/* not support */
		RT_ASSERT(0);
	}

	/* polling write */
	ptr = (char *)buffer;

	if (dev->flag & RT_DEVICE_FLAG_STREAM)
	{
		/* stream mode */
		while (size)
		{
			if (*ptr == '\n')
				while (MAP_UARTCharPutNonBlocking(serial->hw_base, '\r') == false);

			while (MAP_UARTCharPutNonBlocking(serial->hw_base, *ptr) == false);

			ptr ++;
			size --;
		}
	}
	else
	{
		while (size)
		{
			while (MAP_UARTCharPutNonBlocking(serial->hw_base, *ptr) == false);

			ptr ++;
			size --;
		}
	}

	return (rt_size_t) ptr - (rt_size_t) buffer;
}
示例#3
0
bool uart_tx_char(pyb_uart_obj_t *self, int c) {
    uint32_t timeout = 0;

    while (!MAP_UARTCharPutNonBlocking(self->reg, c)) {
        if (timeout++ > (PYBUART_TX_MAX_TIMEOUT_MS / PYBUART_TX_WAIT_MS)) {
            return false;
        }
        HAL_Delay (PYBUART_TX_WAIT_MS);
    }
    return true;
}
示例#4
0
//--------------------------------
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);
	}
}
示例#5
0
文件: gps.c 项目: tuzhikov/SURD
//------------------------------------------------------------------------------
static BOOL tx_pkt_snd_one()
{
    if (g_tx_buf_len == 0)
    {
        g_tx_buf_ptr = g_tx_buf;
        return FALSE;
    }

    if (MAP_UARTCharPutNonBlocking(UART_BASE, *g_tx_buf_ptr++) == FALSE)
    {
        g_tx_buf_ptr = g_tx_buf;
        g_tx_buf_len = 0;
        return FALSE;
    }

    --g_tx_buf_len;
    return TRUE;
}
示例#6
0
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]);
	}
}
示例#7
0
文件: serial.c 项目: cydvicious/rone
/*
 * @brief Send a byte through serial port FIFO (UART)
 * @param value Data to be sent
 * @returns void
 */
void sendByte(uint8 value) {
	MAP_UARTCharPutNonBlocking(UART0_BASE, value);
}