aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--gyro.c (renamed from gyroscope.c)10
-rw-r--r--gyro.h13
-rw-r--r--gyroscope.h13
-rw-r--r--main.c10
5 files changed, 24 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index b273b86..9f3ae5c 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ MCU = atmega88
all: sanduhr.hex
-sanduhr.elf: main.c i2c.c i2c.h uart.c uart.h timer.c timer.h gyroscope.c gyroscope.h
+sanduhr.elf: main.c i2c.c i2c.h uart.c uart.h timer.c timer.h gyro.c gyro.h
avr-gcc -std=gnu99 -mmcu=$(MCU) -Os -o $@ $^
sanduhr.hex: sanduhr.elf
diff --git a/gyroscope.c b/gyro.c
index 23fa197..f4d7529 100644
--- a/gyroscope.c
+++ b/gyro.c
@@ -4,7 +4,7 @@
#include <avr/sleep.h>
#include "i2c.h"
-#include "gyroscope.h"
+#include "gyro.h"
/* device address */
#define L3GD20 0b11010100
@@ -29,7 +29,7 @@ ISR(PCINT0_vect) {
drdy = true;
}
-void gyroscopeInit () {
+void gyroInit () {
/* set PB1 to input, with pull-up */
DDRB = (DDRB & ~((1 << PB1)));
PORTB = (PORTB | (1 << PB1));
@@ -40,7 +40,7 @@ void gyroscopeInit () {
}
/* XXX: make nonblocking */
-void gyroscopeStart () {
+void gyroStart () {
/* configuration:
* disable power-down-mode
* defaults
@@ -57,7 +57,7 @@ void gyroscopeStart () {
printf ("final twi status was %i\n", twr.status);
}
-bool gyroscopeRead () {
+bool gyroRead () {
if (drdy) {
drdy = false;
@@ -71,7 +71,7 @@ bool gyroscopeRead () {
}
}
-volatile const int16_t *gyroscopeGet () {
+volatile const int16_t *gyroGet () {
return val;
}
diff --git a/gyro.h b/gyro.h
new file mode 100644
index 0000000..ac3550e
--- /dev/null
+++ b/gyro.h
@@ -0,0 +1,13 @@
+#ifndef GYROSCOPE_H
+#define GYROSCOPE_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+void gyroInit ();
+void gyroStart ();
+bool gyroRead ();
+volatile const int16_t *gyroGet ();
+
+#endif /* GYROSCOPE_H */
+
diff --git a/gyroscope.h b/gyroscope.h
deleted file mode 100644
index 20ef373..0000000
--- a/gyroscope.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef GYROSCOPE_H
-#define GYROSCOPE_H
-
-#include <stdbool.h>
-#include <stdint.h>
-
-void gyroscopeInit ();
-void gyroscopeStart ();
-bool gyroscopeRead ();
-volatile const int16_t *gyroscopeGet ();
-
-#endif /* GYROSCOPE_H */
-
diff --git a/main.c b/main.c
index f017109..f04c725 100644
--- a/main.c
+++ b/main.c
@@ -11,7 +11,7 @@
#include "i2c.h"
#include "uart.h"
#include "timer.h"
-#include "gyroscope.h"
+#include "gyro.h"
static void ledInit () {
/* set led1,led2 to output */
@@ -43,25 +43,25 @@ int main () {
ledInit ();
twInit ();
uartInit ();
- gyroscopeInit ();
+ gyroInit ();
set_sleep_mode (SLEEP_MODE_IDLE);
printf ("initialization done\n");
/* global interrupt enable */
sei ();
- gyroscopeStart ();
+ gyroStart ();
//timerStart ();
while (1) {
//sleepwhile (!timerHit ());
//printf ("running for %u seconds\n", seconds);
- sleepwhile (!gyroscopeRead ());
+ sleepwhile (!gyroRead ());
sleepwhile (twr.status == TWST_WAIT);
switch (twr.status) {
case TWST_OK: {
- volatile const int16_t *val = gyroscopeGet ();
+ volatile const int16_t *val = gyroGet ();
printf ("%i/%i/%i\n", val[0], val[1], val[2]);
break;
}