got it so the gyro should work
I basically split the linear code from the gyro board up into a state
machine that runs in ISRs.
diff --git a/bbb_cape/src/cape/fill_packet.c b/bbb_cape/src/cape/fill_packet.c
index 537c527..5779ae3 100644
--- a/bbb_cape/src/cape/fill_packet.c
+++ b/bbb_cape/src/cape/fill_packet.c
@@ -10,6 +10,8 @@
#include "cape/encoder.h"
#include "cape/crc.h"
#include "cape/bootloader_handoff.h"
+#include "cape/gyro.h"
+#include "cape/led.h"
#define TIMESTAMP_TIM TIM6
#define RCC_APB1ENR_TIMESTAMP_TIMEN RCC_APB1ENR_TIM6EN
@@ -29,6 +31,14 @@
packet->flash_checksum = flash_checksum;
+ struct GyroOutput gyro_output;
+ gyro_get_output(&gyro_output);
+ packet->gyro_angle = gyro_output.angle;
+ packet->old_gyro_reading = gyro_output.last_reading_bad;
+ packet->uninitialized_gyro = !gyro_output.initialized;
+ packet->zeroing_gyro = !gyro_output.zeroed;
+ packet->bad_gyro = gyro_output.gyro_bad;
+
packet->main.encoders[0] = encoder_read(0);
packet->main.encoders[1] = encoder_read(1);
packet->main.encoders[2] = encoder_read(2);
@@ -67,7 +77,9 @@
TIMESTAMP_TIM->CR1 |= TIM_CR1_CEN;
crc_init();
+ led_init();
encoder_init();
+ gyro_init();
uint8_t *flash_end = &__etext + (&__data_start__ - &__data_end__) + 8;
flash_checksum = crc_calculate((void *)MAIN_FLASH_START,