Skip to content

Commit

Permalink
Merge to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
bsousi5 committed Oct 4, 2019
2 parents 2598762 + 4639e50 commit 1b725a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions metal/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ struct metal_uart {
const struct metal_uart_vtable *vtable;
};

/*! @brief Get a handle for a UART device
* @param device_num The index of the desired UART device
* @return A handle to the UART device, or NULL if the device does not exist*/
struct metal_uart *metal_uart_get_device(unsigned int device_num);

/*!
* @brief Initialize UART device
Expand Down
11 changes: 11 additions & 0 deletions src/uart.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Copyright 2018 SiFive, Inc */
/* SPDX-License-Identifier: Apache-2.0 */

#include <metal/machine.h>
#include <metal/uart.h>

extern __inline__ void metal_uart_init(struct metal_uart *uart, int baud_rate);
Expand All @@ -21,3 +22,13 @@ extern __inline__ int metal_uart_set_transmit_watermark(struct metal_uart *uart,
extern __inline__ size_t metal_uart_get_transmit_watermark(struct metal_uart *uart);
extern __inline__ int metal_uart_set_receive_watermark(struct metal_uart *uart, size_t level);
extern __inline__ size_t metal_uart_get_receive_watermark(struct metal_uart *uart);

struct metal_uart *metal_uart_get_device(unsigned int device_num) {
#if __METAL_DT_MAX_UARTS > 0
if (device_num < __METAL_DT_MAX_UARTS) {
return (struct metal_uart *)__metal_uart_table[device_num];
}
#endif

return NULL;
}

0 comments on commit 1b725a7

Please sign in to comment.