dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_com.h
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  */
29 
30 #ifndef PIOS_COM_H
31 #define PIOS_COM_H
32 
33 #include <stdint.h> /* uint*_t */
34 #include <stdbool.h> /* bool */
35 
36 struct pios_com_driver;
37 
39 struct pios_com_dev;
40 
41 typedef uint16_t (*pios_com_callback)(uintptr_t context, uint8_t * buf, uint16_t buf_len, uint16_t * headroom, bool * task_woken);
42 
44  void (*set_baud)(uintptr_t id, uint32_t baud);
45  void (*tx_start)(uintptr_t id, uint16_t tx_bytes_avail);
46  void (*rx_start)(uintptr_t id, uint16_t rx_bytes_avail);
47  void (*bind_rx_cb)(uintptr_t id, pios_com_callback rx_in_cb, uintptr_t context);
48  void (*bind_tx_cb)(uintptr_t id, pios_com_callback tx_out_cb, uintptr_t context);
49  bool (*available)(uintptr_t id);
50 };
51 
52 /* Public Functions */
53 extern uintptr_t PIOS_COM_GetDriverCtx(uintptr_t com_id);
54 extern int32_t PIOS_COM_ChangeBaud(uintptr_t com_id, uint32_t baud);
55 extern int32_t PIOS_COM_SendCharNonBlocking(uintptr_t com_id, char c);
56 extern int32_t PIOS_COM_SendChar(uintptr_t com_id, char c);
57 extern int32_t PIOS_COM_SendBufferNonBlocking(uintptr_t com_id, const uint8_t *buffer, uint16_t len);
58 extern int32_t PIOS_COM_SendBufferStallTimeout(uintptr_t com_id, const uint8_t *buffer, uint16_t len, uint32_t max_ms);
59 extern int32_t PIOS_COM_SendBuffer(uintptr_t com_id, const uint8_t *buffer, uint16_t len);
60 extern int32_t PIOS_COM_SendStringNonBlocking(uintptr_t com_id, const char *str);
61 extern int32_t PIOS_COM_SendString(uintptr_t com_id, const char *str);
62 extern int32_t PIOS_COM_SendFormattedStringNonBlocking(uintptr_t com_id, const char *format, ...);
63 extern int32_t PIOS_COM_SendFormattedString(uintptr_t com_id, const char *format, ...);
64 extern uint16_t PIOS_COM_ReceiveBuffer(uintptr_t com_id, uint8_t * buf, uint16_t buf_len, uint32_t timeout_ms);
65 extern bool PIOS_COM_Available(uintptr_t com_id);
66 uint16_t PIOS_COM_GetNumReceiveBytesPending(uintptr_t com_id);
67 
68 #endif /* PIOS_COM_H */
69 
bool(* available)(uintptr_t id)
Definition: pios_com.h:49
int32_t PIOS_COM_SendString(uintptr_t com_id, const char *str)
int32_t PIOS_COM_SendBufferNonBlocking(uintptr_t com_id, const uint8_t *buffer, uint16_t len)
int32_t PIOS_COM_SendFormattedStringNonBlocking(uintptr_t com_id, const char *format,...)
void(* bind_tx_cb)(uintptr_t id, pios_com_callback tx_out_cb, uintptr_t context)
Definition: pios_com.h:48
uint8_t id
int32_t PIOS_COM_SendStringNonBlocking(uintptr_t com_id, const char *str)
int32_t PIOS_COM_SendChar(uintptr_t com_id, char c)
uint16_t PIOS_COM_ReceiveBuffer(uintptr_t com_id, uint8_t *buf, uint16_t buf_len, uint32_t timeout_ms)
uintptr_t PIOS_COM_GetDriverCtx(uintptr_t com_id)
int32_t PIOS_COM_SendFormattedString(uintptr_t com_id, const char *format,...)
uint16_t PIOS_COM_GetNumReceiveBytesPending(uintptr_t com_id)
int32_t PIOS_COM_SendCharNonBlocking(uintptr_t com_id, char c)
int32_t PIOS_COM_SendBuffer(uintptr_t com_id, const uint8_t *buffer, uint16_t len)
void(* rx_start)(uintptr_t id, uint16_t rx_bytes_avail)
Definition: pios_com.h:46
int32_t PIOS_COM_SendBufferStallTimeout(uintptr_t com_id, const uint8_t *buffer, uint16_t len, uint32_t max_ms)
void(* bind_rx_cb)(uintptr_t id, pios_com_callback rx_in_cb, uintptr_t context)
Definition: pios_com.h:47
void(* tx_start)(uintptr_t id, uint16_t tx_bytes_avail)
Definition: pios_com.h:45
uint16_t(* pios_com_callback)(uintptr_t context, uint8_t *buf, uint16_t buf_len, uint16_t *headroom, bool *task_woken)
Definition: pios_com.h:41
int32_t PIOS_COM_ChangeBaud(uintptr_t com_id, uint32_t baud)
bool PIOS_COM_Available(uintptr_t com_id)
void(* set_baud)(uintptr_t id, uint32_t baud)
Definition: pios_com.h:44