}
+/****************************************************************************** */
+/* Serial send byte - quick function with almost no tests.
+ * If the uart is not sending, the byte is placed directly in the data buffer and
+ * the call returns 0.
+ * Else, the call returns -EBUSY and nothing is sent.
+ */
+int serial_send_quickbyte(uint32_t uart_num, uint8_t data)
+{
+ struct uart_device* uart = &uarts[uart_num];
+ if (!uart->sending) {
+ uart->regs->func.buffer = data;
+ return 0;
+ } else {
+ return -EBUSY;
+ }
+}
/***************************************************************************** */
/* Serial Write
uint8_t mul_val;
};
static struct uart_clk_cfg uart_clk_table[] = {
- { 1152000, 2, 4, 13},
+ { 250000, 12, 0, 1},
+ { 1152000, 2, 3, 10},
{ 0, 0, 0, 0, },
};
pclk = get_main_clock(); /* See above note */
div = (pclk / (baudrate * 16));
sys_ctrl->uart_clk_div[uart_num] = 0x01;
- /* The easy one : divider is an integer, or baudrate is low enought for the aproximation */
+ /* The easy one : divider is an integer, or baudrate is low enough for the aproximation */
if ((baudrate <= 115200) || ((div * baudrate * 16) == pclk)) {
uart->line_ctrl |= LPC_UART_ENABLE_DLAB;
uart->ctrl.divisor_latch_lsb = (div & 0xff);
struct lpc_uart* uart = uarts[uart_num].regs; /* Get the right registers */
uint32_t status = 0;
/* Set up UART mode */
- uart->line_ctrl = uarts[uart_num].config;;
+ uart->line_ctrl = uarts[uart_num].config;
/* Clear all fifo, reset and enable them */
/* Note : fifo trigger level is one bit */
uart->ctrl.fifo_ctrl = (LPC_UART_FIFO_EN | LPC_UART_TX_CLR | LPC_UART_RX_CLR);
return status;
}
+/* Change UART configuration (number of data, parity and stop bits).
+ * config is a mask of LPC_UART_xBIT (x = 5..8), LPC_UART_xSTOP (x = 1..2)
+ * and one of LPC_UART_NO_PAR, LPC_UART_ODD_PAR or LPC_UART_EVEN_PAR.
+ */
+int uart_set_config(uint8_t uart_num, uint8_t config)
+{
+ struct uart_device* uart = NULL;
+
+ if (uart_num >= NUM_UARTS)
+ return -EINVAL;
+ uart = &uarts[uart_num];
+ uart->config = config;
+ return 0;
+}
+
struct uart_def
{
uint32_t irq;
int serial_flush(uint32_t uart_num);
+/****************************************************************************** */
+/* Serial send byte - quick function with almost no tests.
+ * If the uart is not sending, the byte is placed directly in the data buffer and
+ * the call returns 0.
+ * Else, the call returns -EBUSY and nothing is sent.
+ */
+int serial_send_quickbyte(uint32_t uart_num, uint8_t data);
/***************************************************************************** */
/* Public access to UART setup */
+
+/* Change UART configuration (number of data, parity and stop bits).
+ * config is a mask of LPC_UART_xBIT (x = 5..8), LPC_UART_xSTOP (x = 1..2)
+ * and one of LPC_UART_NO_PAR, LPC_UART_ODD_PAR or LPC_UART_EVEN_PAR.
+ */
+int uart_set_config(uint8_t uart_num, uint8_t config);
+
/* Change uart mode to RS485
* return -ENODEV when the device does not support RS485 mode.
*/