]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_FreedomStudio/freedom-metal/metal/uart.h
Update RISCC-V-RV32-SiFive_HiFive1_FreedomStudio project to latest tools and metal...
[freertos] / FreeRTOS / Demo / RISC-V_RV32_SiFive_HiFive1_FreedomStudio / freedom-metal / metal / uart.h
index 611792a6cc71c4a320e78ec498f570f9d1b1e3af..e9e4d04363670607c8fd37d4e6c59edfd5d12465 100644 (file)
 #include <metal/interrupt.h>
 
 struct metal_uart;
-
+#undef getc
+#undef putc
 struct metal_uart_vtable {
     void (*init)(struct metal_uart *uart, int baud_rate);
-    int (*putc)(struct metal_uart *uart, unsigned char c);
-    int (*getc)(struct metal_uart *uart, unsigned char *c);
+    int (*putc)(struct metal_uart *uart, int c);
+    int (*txready)(struct metal_uart *uart);
+    int (*getc)(struct metal_uart *uart, int *c);
     int (*get_baud_rate)(struct metal_uart *uart);
     int (*set_baud_rate)(struct metal_uart *uart, int baud_rate);
     struct metal_interrupt* (*controller_interrupt)(struct metal_uart *uart);
@@ -39,7 +41,7 @@ struct metal_uart {
  * @param uart The UART device handle
  * @param baud_rate the baud rate to set the UART to
  */
-inline void metal_uart_init(struct metal_uart *uart, int baud_rate) { return uart->vtable->init(uart, baud_rate); }
+__inline__ void metal_uart_init(struct metal_uart *uart, int baud_rate) { uart->vtable->init(uart, baud_rate); }
 
 /*!
  * @brief Output a character over the UART
@@ -47,22 +49,32 @@ inline void metal_uart_init(struct metal_uart *uart, int baud_rate) { return uar
  * @param c The character to send over the UART
  * @return 0 upon success
  */
-inline int metal_uart_putc(struct metal_uart *uart, unsigned char c) { return uart->vtable->putc(uart, c); }
+__inline__ int metal_uart_putc(struct metal_uart *uart, int c) { return uart->vtable->putc(uart, c); }
+
+/*!
+ * @brief Test, determine if tx output is blocked(full/busy)
+ * @param uart The UART device handle
+ * @return 0 not blocked
+ */
+__inline__ int metal_uart_txready(struct metal_uart *uart) { return uart->vtable->txready(uart); }
 
 /*!
  * @brief Read a character sent over the UART
  * @param uart The UART device handle
  * @param c The varible to hold the read character
  * @return 0 upon success
+ *
+ * If "c == -1" no char was ready.
+ * If "c != -1" then C == byte value (0x00 to 0xff)
  */
-inline int metal_uart_getc(struct metal_uart *uart, unsigned char *c) { return uart->vtable->getc(uart, c); }
+__inline__ int metal_uart_getc(struct metal_uart *uart, int *c) { return uart->vtable->getc(uart, c); }
 
 /*!
  * @brief Get the baud rate of the UART peripheral
  * @param uart The UART device handle
  * @return The current baud rate of the UART
  */
-inline int metal_uart_get_baud_rate(struct metal_uart *uart) { return uart->vtable->get_baud_rate(uart); }
+__inline__ int metal_uart_get_baud_rate(struct metal_uart *uart) { return uart->vtable->get_baud_rate(uart); }
 
 /*!
  * @brief Set the baud rate of the UART peripheral
@@ -70,7 +82,7 @@ inline int metal_uart_get_baud_rate(struct metal_uart *uart) { return uart->vtab
  * @param baud_rate The baud rate to configure
  * @return the new baud rate of the UART
  */
-inline int metal_uart_set_baud_rate(struct metal_uart *uart, int baud_rate) { return uart->vtable->set_baud_rate(uart, baud_rate); }
+__inline__ int metal_uart_set_baud_rate(struct metal_uart *uart, int baud_rate) { return uart->vtable->set_baud_rate(uart, baud_rate); }
 
 /*!
  * @brief Get the interrupt controller of the UART peripheral
@@ -82,13 +94,13 @@ inline int metal_uart_set_baud_rate(struct metal_uart *uart, int baud_rate) { re
  * @param uart The UART device handle
  * @return The handle for the UART interrupt controller
  */
-inline struct metal_interrupt* metal_uart_interrupt_controller(struct metal_uart *uart) { return uart->vtable->controller_interrupt(uart); }
+__inline__ struct metal_interrupt* metal_uart_interrupt_controller(struct metal_uart *uart) { return uart->vtable->controller_interrupt(uart); }
 
 /*!
  * @brief Get the interrupt ID of the UART controller
  * @param uart The UART device handle
  * @return The UART interrupt id
  */
-inline int metal_uart_get_interrupt_id(struct metal_uart *uart) { return uart->vtable->get_interrupt_id(uart); }
+__inline__ int metal_uart_get_interrupt_id(struct metal_uart *uart) { return uart->vtable->get_interrupt_id(uart); }
 
 #endif