]> rtime.felk.cvut.cz Git - mirosot.git/blobdiff - bth_tests/bluetooth/bth_inface.h
Added bth_test application. Not finished.
[mirosot.git] / bth_tests / bluetooth / bth_inface.h
diff --git a/bth_tests/bluetooth/bth_inface.h b/bth_tests/bluetooth/bth_inface.h
new file mode 100644 (file)
index 0000000..02d1f58
--- /dev/null
@@ -0,0 +1,79 @@
+
+/*******************************************************************
+  bluetooth library
+
+  bth_inface.h - inline fce for data queue operation + list of fce
+                 bth_inface.c 
+
+  Copyright (C) 2006 by Petr Kovacik petr_kovacik@gmail.com
+
+ *******************************************************************/
+
+#ifndef _ID_BTH_INFACE_H_
+#define _ID_BTH_INFACE_H_
+
+#include <bth_config.h>
+#include <types.h>
+#ifdef CONFIG_BLUETOOTH_LINUX
+#endif
+
+#define BTH_INFACE_CHANAL     (1)
+#define BTH_INFACE_BUF_LEN    (70)
+
+typedef struct{
+    uint8_t *buf_beg; //start of adress structur
+    uint8_t *buf_end; //end of adress structur - beg+sizeof(struct)
+    uint8_t *ip;      //actual position at queue
+    uint8_t *op;      //position first unread char of queue
+} bth_inface_que_t;
+
+typedef struct bth_inface_info {
+  /* Queues */
+  bth_inface_que_t bth_inface_que_in;
+  bth_inface_que_t bth_inface_que_out;
+
+  uint8_t  bth_inface_buff_in[BTH_INFACE_BUF_LEN];
+  uint8_t bth_inface_buff_out[BTH_INFACE_BUF_LEN];
+} bth_inface_info_t;
+
+
+static inline int bth_inface_que_put(bth_inface_que_t *q, int c)
+{
+  __u8 *p;
+  p=q->ip;
+  *(p++)=c;
+  if(p==q->buf_end) p=q->buf_beg;
+  if(p==q->op) return -1;
+  q->ip=p;
+  return c;
+}
+
+/* get character from queue, if empty return -1 */
+static inline int bth_inface_que_get(bth_inface_que_t *q)
+{
+  __u8 *p;
+  int  c;
+  p=q->op;
+  if(p==q->ip) return -1;
+  c=*(p++);
+  if(p==q->buf_end) p=q->buf_beg;
+  q->op=p;
+  return c;
+}
+
+bth_inface_info_t bth_inface_chan_array[BTH_INFACE_CHANAL];
+
+int bth_inface_setup(int chan);
+int bth_inface_sendch(int c, int chan);
+int bth_inface_recch(int chan);
+int bth_inface_sendstr(const char *s, int chan);
+
+//int bth_inface_que_out_free(int chan);
+//int bth_inface_que_in_ready(int chan);
+//int bth_inface_setup(int chan);
+
+int bth_inface_r_isr(int chan, int val);
+int bth_inface_t_isr(int chan);
+
+#endif /* _ID_BTH_INFACE_H_ */
+