k_uart.h
Go to the documentation of this file.
1 /*
2  * KubOS Core Flight Services
3  * Copyright (C) 2016 Kubos Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
35 #ifndef K_UART_H
36 #define K_UART_H
37 
38 #include <stdint.h>
39 
43 struct uart_conf {
44  const char *device;
45  uint32_t baudrate;
46  uint8_t databits;
47  uint8_t stopbits;
48  uint8_t paritysetting;
49  uint8_t checkparity;
50 };
51 
56 void uart_init(struct uart_conf *conf);
57 
64 typedef void (*uart_callback_t) (void * extra_data, uint8_t *buf, int len, void *pxTaskWoken);
65 void uart_set_callback(void * arg, uart_callback_t callback);
66 
72 void uart_insert(char c, void *pxTaskWoken);
73 
80 void uart_putc(char c);
81 
89 void uart_putstr(char *buf, int len);
90 
97 char uart_getc(void);
98 
99 int uart_messages_waiting(int handle);
100 
101 static inline int uart_stdio_msgwaiting(void) {
102  return uart_messages_waiting(0);
103 }
104 
105 #endif /* K_UART_H_ */
106 
107 /* @} */
void uart_set_callback(void *arg, uart_callback_t callback)
uint8_t stopbits
Definition: k_uart.h:47
void uart_init(struct uart_conf *conf)
Initialise UART with the uart_conf data structure.
Usart configuration, to be used with the uart_init call.
Definition: k_uart.h:43
void(* uart_callback_t)(void *extra_data, uint8_t *buf, int len, void *pxTaskWoken)
In order to catch incoming chars use the callback.
Definition: k_uart.h:64
const char * device
Definition: k_uart.h:44
uint8_t paritysetting
Definition: k_uart.h:48
int uart_messages_waiting(int handle)
uint8_t checkparity
Definition: k_uart.h:49
void uart_putstr(char *buf, int len)
Send char buffer on UART.
void uart_putc(char c)
Polling putchar.
uint8_t databits
Definition: k_uart.h:46
void uart_insert(char c, void *pxTaskWoken)
Insert a character to the RX buffer of a uart.
char uart_getc(void)
Buffered getchar.
uint32_t baudrate
Definition: k_uart.h:45