Update .clang-format and apply
Update .clang-format for LLVM 14.0, available on Ubuntu 22.04. There is still plenty that clang-format sucks at or does wrong, so either add some more blocks to disable it, or just put up with it. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Jeremy Soller
parent
c3267fc4ad
commit
e032c5f0f2
@ -43,10 +43,10 @@
|
||||
// clang-format on
|
||||
|
||||
int16_t uart_count() {
|
||||
return sizeof(UARTS)/sizeof(struct Uart);
|
||||
return sizeof(UARTS) / sizeof(struct Uart);
|
||||
}
|
||||
|
||||
struct Uart * uart_new(int16_t num) {
|
||||
struct Uart *uart_new(int16_t num) {
|
||||
if (num < uart_count()) {
|
||||
return &UARTS[num];
|
||||
} else {
|
||||
@ -54,40 +54,40 @@ struct Uart * uart_new(int16_t num) {
|
||||
}
|
||||
}
|
||||
|
||||
void uart_init(struct Uart * uart, uint32_t baud) {
|
||||
void uart_init(struct Uart *uart, uint32_t baud) {
|
||||
uint32_t baud_prescale = (F_CPU / (baud * 16UL)) - 1;
|
||||
*(uart->baud_h) = (uint8_t)(baud_prescale>>8);
|
||||
*(uart->baud_h) = (uint8_t)(baud_prescale >> 8);
|
||||
*(uart->baud_l) = (uint8_t)(baud_prescale);
|
||||
*(uart->a) = uart->a_init;
|
||||
*(uart->b) = uart->b_init;
|
||||
*(uart->c) = uart->c_init;
|
||||
}
|
||||
|
||||
uint8_t uart_can_read(struct Uart * uart) {
|
||||
uint8_t uart_can_read(struct Uart *uart) {
|
||||
return (*(uart->a)) & uart->a_read;
|
||||
}
|
||||
|
||||
uint8_t uart_read(struct Uart * uart) {
|
||||
while (!uart_can_read(uart)) ;
|
||||
uint8_t uart_read(struct Uart *uart) {
|
||||
while (!uart_can_read(uart)) {}
|
||||
return *(uart->data);
|
||||
}
|
||||
|
||||
uint8_t uart_can_write(struct Uart * uart) {
|
||||
uint8_t uart_can_write(struct Uart *uart) {
|
||||
return (*(uart->a)) & uart->a_write;
|
||||
}
|
||||
|
||||
void uart_write(struct Uart * uart, uint8_t data) {
|
||||
while (!uart_can_write(uart)) ;
|
||||
void uart_write(struct Uart *uart, uint8_t data) {
|
||||
while (!uart_can_write(uart)) {}
|
||||
*(uart->data) = data;
|
||||
}
|
||||
|
||||
struct Uart * uart_stdio = NULL;
|
||||
struct Uart *uart_stdio = NULL;
|
||||
|
||||
int16_t uart_stdio_get(FILE * stream) {
|
||||
int16_t uart_stdio_get(FILE *stream) {
|
||||
return (int16_t)uart_read(uart_stdio);
|
||||
}
|
||||
|
||||
int16_t uart_stdio_put(char data, FILE * stream) {
|
||||
int16_t uart_stdio_put(char data, FILE *stream) {
|
||||
uart_write(uart_stdio, (uint8_t)data);
|
||||
return 0;
|
||||
}
|
||||
@ -95,8 +95,8 @@ int16_t uart_stdio_put(char data, FILE * stream) {
|
||||
FILE uart_stdio_file = FDEV_SETUP_STREAM(uart_stdio_put, uart_stdio_get, _FDEV_SETUP_RW);
|
||||
|
||||
void uart_stdio_init(int16_t num, uint32_t baud) {
|
||||
struct Uart * uart = uart_new(num);
|
||||
if(uart != NULL) {
|
||||
struct Uart *uart = uart_new(num);
|
||||
if (uart != NULL) {
|
||||
uart_init(uart, baud);
|
||||
uart_stdio = uart;
|
||||
stdin = stdout = stderr = &uart_stdio_file;
|
||||
|
Reference in New Issue
Block a user