]> rtime.felk.cvut.cz Git - mirosot.git/blob - bluetooth/bth_inface.h
An unsucesfull attempt to clean bluetooth library and make it working.
[mirosot.git] / bluetooth / bth_inface.h
1
2 /*******************************************************************
3   bluetooth library
4
5   bth_inface.h - inline fce for data queue operation + list of fce
6                  bth_inface.c 
7
8   Copyright (C) 2006 by Petr Kovacik petr_kovacik@gmail.com
9
10  *******************************************************************/
11
12 #ifndef _ID_BTH_INFACE_H_
13 #define _ID_BTH_INFACE_H_
14
15 #include <bth_config.h>
16 #include <types.h>
17 #ifdef CONFIG_BLUETOOTH_LINUX
18 #endif
19
20 #define BTH_INFACE_CHANAL     (1)
21 #define BTH_INFACE_BUF_LEN    (70)
22
23 typedef struct{
24     uint8_t *buf_beg; //start of adress structur
25     uint8_t *buf_end; //end of adress structur - beg+sizeof(struct)
26     uint8_t *ip;      //actual position at queue
27     uint8_t *op;      //position first unread char of queue
28 } bth_inface_que_t;
29
30 typedef struct bth_inface_info {
31   /* Queues */
32   bth_inface_que_t bth_inface_que_in;
33   bth_inface_que_t bth_inface_que_out;
34
35   uint8_t  bth_inface_buff_in[BTH_INFACE_BUF_LEN];
36   uint8_t bth_inface_buff_out[BTH_INFACE_BUF_LEN];
37 } bth_inface_info_t;
38
39
40 static inline int bth_inface_que_put(bth_inface_que_t *q, int c)
41 {
42   __u8 *p;
43   p=q->ip;
44   *(p++)=c;
45   if(p==q->buf_end) p=q->buf_beg;
46   if(p==q->op) return -1;
47   q->ip=p;
48   return c;
49 }
50
51 /* get character from queue, if empty return -1 */
52 static inline int bth_inface_que_get(bth_inface_que_t *q)
53 {
54   __u8 *p;
55   int  c;
56   p=q->op;
57   if(p==q->ip) return -1;
58   c=*(p++);
59   if(p==q->buf_end) p=q->buf_beg;
60   q->op=p;
61   return c;
62 }
63
64 bth_inface_info_t bth_inface_chan_array[BTH_INFACE_CHANAL];
65
66 int bth_inface_setup(int chan);
67 int bth_inface_sendch(int c, int chan);
68 int bth_inface_recch(int chan);
69 int bth_inface_sendstr(const char *s, int chan);
70
71 //int bth_inface_que_out_free(int chan);
72 //int bth_inface_que_in_ready(int chan);
73 //int bth_inface_setup(int chan);
74
75 int bth_inface_r_isr(int chan, int val);
76 int bth_inface_t_isr(int chan);
77
78 #endif /* _ID_BTH_INFACE_H_ */
79