]> rtime.felk.cvut.cz Git - mirosot.git/blob - bluetooth/bth_inface.h
Initial import of Petr's work.
[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 #define BTH_INFACE_CHANAL     (1)
16 #define BTH_INFACE_BUF_LEN    (70)
17
18 typedef struct{
19     uint8_t *buf_beg; //start of adress structur
20     uint8_t *buf_end; //end of adress structur - beg+sizeof(struct)
21     uint8_t *ip;      //actual position at queue
22     uint8_t *op;      //position first unread char of queue
23 } bth_inface_que_t;
24
25 typedef struct bth_inface_info {
26   /* Queues */
27   bth_inface_que_t bth_inface_que_in;
28   bth_inface_que_t bth_inface_que_out;
29
30   uint8_t  bth_inface_buff_in[BTH_INFACE_BUF_LEN];
31   uint8_t bth_inface_buff_out[BTH_INFACE_BUF_LEN];
32 } bth_inface_info_t;
33
34
35 static inline int bth_inface_que_put(bth_inface_que_t *q, int c)
36 {
37   __u8 *p;
38   p=q->ip;
39   *(p++)=c;
40   if(p==q->buf_end) p=q->buf_beg;
41   if(p==q->op) return -1;
42   q->ip=p;
43   return c;
44 }
45
46 /* get character from queue, if empty return -1 */
47 static inline int bth_inface_que_get(bth_inface_que_t *q)
48 {
49   __u8 *p;
50   int  c;
51   p=q->op;
52   if(p==q->ip) return -1;
53   c=*(p++);
54   if(p==q->buf_end) p=q->buf_beg;
55   q->op=p;
56   return c;
57 }
58
59 bth_inface_info_t bth_inface_chan_array[BTH_INFACE_CHANAL];
60
61 int bth_inface_setup(int chan);
62 int bth_inface_sendch(int c, int chan);
63 int bth_inface_recch(int chan);
64 int bth_inface_sendstr(const char *s, int chan);
65
66 //int bth_inface_que_out_free(int chan);
67 //int bth_inface_que_in_ready(int chan);
68 //int bth_inface_setup(int chan);
69
70 int bth_inface_r_isr(int chan, int val);
71 int bth_inface_t_isr(int chan);
72 /* HACK: Include machine specific definitions */
73
74 #endif /* _ID_BTH_INFACE_H_ */
75