Move delay to an independent file.
authorWalter Fetter Lages <w.fetter@ieee.org>
Thu, 31 Jan 2019 05:44:34 +0000 (03:44 -0200)
committerWalter Fetter Lages <w.fetter@ieee.org>
Thu, 31 Jan 2019 05:44:34 +0000 (03:44 -0200)
include/bno055_delay.h [new file with mode: 0644]
lib/Makefile
lib/bno055_delay.c [new file with mode: 0644]
lib/bno055_tty.c

diff --git a/include/bno055_delay.h b/include/bno055_delay.h
new file mode 100644 (file)
index 0000000..26631e0
--- /dev/null
@@ -0,0 +1,41 @@
+/******************************************************************************
+                             BNO055 Library
+                                 Delay
+          Copyright (C) 2019 Walter Fetter Lages <w.fetter@ieee.org>
+
+        This program is free software: you can redistribute it and/or modify
+        it under the terms of the GNU General Public License as published by
+        the Free Software Foundation, either version 3 of the License, or
+        (at your option) any later version.
+
+        This program is distributed in the hope that it will be useful, but
+        WITHOUT ANY WARRANTY; without even the implied warranty of
+        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+        General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this program.  If not, see
+        <http://www.gnu.org/licenses/>.
+        
+*******************************************************************************/
+
+#ifndef __BNO055_DELAY_H__
+#define __BNO055_DELAY_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <bno055.h>
+
+/*     Brief : Delay routine
+ *     \param : delay in ms
+*/
+extern void BNO055_delay(u32 ms);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 1771b88..558bc76 100644 (file)
@@ -1,5 +1,5 @@
 TARGET=libbno055ifc.a
-SRCS=bno055_tty.c
+SRCS=bno055_tty.c bno055_delay.c
 
 FLAGS=-O2 -Wall -MMD
 INCLUDE=-I. -I../include -I../../BNO055_driver
diff --git a/lib/bno055_delay.c b/lib/bno055_delay.c
new file mode 100644 (file)
index 0000000..593e1e4
--- /dev/null
@@ -0,0 +1,29 @@
+/******************************************************************************
+                             BNO055 Library
+                                 Delay
+          Copyright (C) 2019 Walter Fetter Lages <w.fetter@ieee.org>
+
+        This program is free software: you can redistribute it and/or modify
+        it under the terms of the GNU General Public License as published by
+        the Free Software Foundation, either version 3 of the License, or
+        (at your option) any later version.
+
+        This program is distributed in the hope that it will be useful, but
+        WITHOUT ANY WARRANTY; without even the implied warranty of
+        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+        General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this program.  If not, see
+        <http://www.gnu.org/licenses/>.
+        
+*******************************************************************************/
+
+#include <unistd.h>
+
+#include <bno055_delay.h>
+
+void BNO055_delay(u32 ms)
+{
+       usleep(ms*1000);
+}
index 2e23cc9..2e4847b 100644 (file)
@@ -24,6 +24,7 @@
 #include <unistd.h>
 #include <sys/ioctl.h>
 
+#include <bno055_delay.h>
 #include <bno055_tty.h>
 
 s8 BNO055_tty_init(int fd,struct bno055_t *bno055)
@@ -42,7 +43,7 @@ s8 BNO055_tty_init(int fd,struct bno055_t *bno055)
 
        bno055->bus_write=BNO055_tty_write;
        bno055->bus_read=BNO055_tty_read;
-       bno055->delay_msec=BNO055_tty_delay_ms;
+       bno055->delay_msec=BNO055_delay;
        bno055->dev_addr=fd;
        
        return BNO055_SUCCESS;
@@ -118,8 +119,3 @@ s8 BNO055_tty_read(u8 dev_addr,u8 reg_addr,u8 *reg_data,u8 cnt)
        }
        return BNO055_SUCCESS;  
 }
-
-void BNO055_tty_delay_ms(u32 ms)
-{
-       usleep(ms*1000);
-}