4 /* SERCOMM layer on UART1 (modem UART) */
7 #include <osmocom/msgb.h>
10 #define SERCOMM_UART_NR 1
13 #define HDLC_FLAG 0x7E
14 #define HDLC_ESCAPE 0x7D
16 #define HDLC_C_UI 0x03
17 #define HDLC_C_P_BIT (1 << 4)
18 #define HDLC_C_F_BIT (1 << 4)
20 /* a low sercomm_dlci means high priority. A high DLCI means low priority */
28 void sercomm_init(void);
29 int sercomm_initialized(void);
31 /* User Interface: Tx */
33 /* user interface for transmitting messages for a given DLCI */
34 void sercomm_sendmsg(uint8_t dlci, struct msgb *msg);
35 /* how deep is the Tx queue for a given DLCI */
36 unsigned int sercomm_tx_queue_depth(uint8_t dlci);
38 /* User Interface: Rx */
40 /* receiving messages for a given DLCI */
41 typedef void (*dlci_cb_t)(uint8_t dlci, struct msgb *msg);
42 int sercomm_register_rx_cb(uint8_t dlci, dlci_cb_t cb);
44 /* Driver Interface */
46 /* fetch one octet of to-be-transmitted serial data. returns 0 if no more data */
47 int sercomm_drv_pull(uint8_t *ch);
48 /* the driver has received one byte, pass it into sercomm layer.
49 returns 1 in case of success, 0 in case of unrecognized char */
50 int sercomm_drv_rx_char(uint8_t ch);
52 static inline struct msgb *sercomm_alloc_msgb(unsigned int len)
54 return msgb_alloc_headroom(len, 4, "sercomm_tx");
57 #endif /* _SERCOMM_H */