|
hal
Hardware Abstraction Layer
|
Provides serial communication over UART1 and UART2. More...

Functions | |
| int | __io_putchar (int ch) |
| syscall declaration for putchar so that printf may be used. More... | |
| hal_status_t | hal_uart_init (hal_uart_t uart) |
Initialize the UART channel associated with the parameter uart. Must be called prior to using the channel. More... | |
| hal_status_t | hal_uart_deinit (hal_uart_t uart) |
Deinitialize the UART channel associated with the parameter uart. More... | |
| hal_status_t | hal_uart_read (hal_uart_t uart, uint8_t *data, size_t len, size_t *bytes_read) |
| Read an incoming byte stream. More... | |
| hal_status_t | hal_uart_write (hal_uart_t uart, const uint8_t *data, size_t len, size_t *bytes_written) |
| Write an outgoing byte stream. More... | |
Provides serial communication over UART1 and UART2.
Copyright (c) 2025 Cory McKiel. Licensed under the MIT License. See LICENSE file in the project root.
| int __io_putchar | ( | int | ch | ) |
syscall declaration for putchar so that printf may be used.
| ch | The character to print. |
| hal_status_t hal_uart_deinit | ( | hal_uart_t | uart | ) |
Deinitialize the UART channel associated with the parameter uart.
Only a channel that has been initialized can be successfully deinitialized.
| uart | The UART channel to deinitialize. |
| hal_status_t hal_uart_init | ( | hal_uart_t | uart | ) |
Initialize the UART channel associated with the parameter uart. Must be called prior to using the channel.
| uart | The UART channel to initialize. |
| hal_status_t hal_uart_read | ( | hal_uart_t | uart, |
| uint8_t * | data, | ||
| size_t | len, | ||
| size_t * | bytes_read | ||
| ) |
Read an incoming byte stream.
Data is placed into the buffer in the same order it was received on the UART channel. There is no way to partition it using this API. Any processing (i.e. parsing for the start of a command) needs to happen at a higher level.
| uart | The UART channel to read from. |
| data | A buffer to return read data to client. |
| len | The max number of bytes to read into buffer. Should not exceed buffer size. |
| bytes_read | Return the actual number of bytes that were successfully read. |
| hal_status_t hal_uart_write | ( | hal_uart_t | uart, |
| const uint8_t * | data, | ||
| size_t | len, | ||
| size_t * | bytes_written | ||
| ) |
Write an outgoing byte stream.
| uart | The UART channel to write to. |
| data | A buffer filled with data to send. |
| len | The number of bytes to send. Should not exceed buffer size. |
| bytes_written | Return the actual number of bytes that were successfully written. |