started on 2014 cape code
diff --git a/bbb_cape/src/cape/Makefile b/bbb_cape/src/cape/Makefile
index 46aeaf9..2971e88 100644
--- a/bbb_cape/src/cape/Makefile
+++ b/bbb_cape/src/cape/Makefile
@@ -47,6 +47,7 @@
analog \
digital \
util \
+ robot \
OBJECTS_bootloader := bootloader \
uart_common \
@@ -56,7 +57,10 @@
OBJECTS_main_test := $(OBJECTS_main_common) \
robot_test \
-OUTPUTS := main_test bootloader
+OBJECTS_main_comp := $(OBJECTS_main_common) \
+ robot_comp \
+
+OUTPUTS := main_test main_comp bootloader
# The sort is to remove duplicates because Make warns about those.
OBJECTS := $(sort $(foreach output,$(OUTPUTS),$(OBJECTS_$(output))))
diff --git a/bbb_cape/src/cape/data_struct.h b/bbb_cape/src/cape/data_struct.h
index 9e5ee6c..b381202 100644
--- a/bbb_cape/src/cape/data_struct.h
+++ b/bbb_cape/src/cape/data_struct.h
@@ -62,41 +62,15 @@
struct {
int32_t left_drive;
int32_t right_drive;
- int32_t shooter_angle;
- int32_t shooter;
- int32_t indexer;
- int32_t wrist;
-
- int32_t capture_top_rise;
- int32_t capture_top_fall;
- int32_t capture_bottom_fall_delay;
- int32_t capture_wrist_rise;
- int32_t capture_shooter_angle_rise;
-
- uint16_t battery_voltage;
uint16_t left_drive_hall;
uint16_t right_drive_hall;
- int8_t top_rise_count;
+ uint16_t battery_voltage;
- int8_t top_fall_count;
-
- int8_t bottom_rise_count;
-
- int8_t bottom_fall_delay_count;
- int8_t bottom_fall_count;
-
- int8_t wrist_rise_count;
-
- int8_t shooter_angle_rise_count;
+ // The length of the pulse from the ultrasonic sensor in 100kHZ ticks.
+ uint32_t ultrasonic_pulse_length;
struct {
- uint8_t wrist_hall_effect : 1;
- uint8_t angle_adjust_bottom_hall_effect : 1;
- uint8_t top_disc : 1;
- uint8_t bottom_disc : 1;
- uint8_t loader_top : 1;
- uint8_t loader_bottom : 1;
};
} main;
};
diff --git a/bbb_cape/src/cape/main_comp.ld b/bbb_cape/src/cape/main_comp.ld
new file mode 120000
index 0000000..af355cc
--- /dev/null
+++ b/bbb_cape/src/cape/main_comp.ld
@@ -0,0 +1 @@
+main.ld
\ No newline at end of file
diff --git a/bbb_cape/src/cape/peripherial_usage.notes b/bbb_cape/src/cape/peripherial_usage.notes
index 22e41ee..757f14a 100644
--- a/bbb_cape/src/cape/peripherial_usage.notes
+++ b/bbb_cape/src/cape/peripherial_usage.notes
@@ -53,3 +53,8 @@
[utilities]
crc
CRC
+
+[robots]
+robot_comp
+ TIM11
+ TIM11_IRQ:3 (aka TIM1_TRG_COM)
diff --git a/bbb_cape/src/cape/robot.c b/bbb_cape/src/cape/robot.c
new file mode 100644
index 0000000..71c0233
--- /dev/null
+++ b/bbb_cape/src/cape/robot.c
@@ -0,0 +1,4 @@
+#include "cape/robot.h"
+
+void robot_init(void) __attribute__((weak));
+void robot_init(void) {}
diff --git a/bbb_cape/src/cape/robot.h b/bbb_cape/src/cape/robot.h
index 02da3e2..cd238a6 100644
--- a/bbb_cape/src/cape/robot.h
+++ b/bbb_cape/src/cape/robot.h
@@ -6,6 +6,9 @@
#include "cape/fill_packet.h"
+// Has a default (weak empty) definition.
+void robot_init(void);
+
void robot_fill_packet(struct DataStruct *packet);
#endif // CAPE_ROBOT_H_
diff --git a/bbb_cape/src/cape/robot_comp.c b/bbb_cape/src/cape/robot_comp.c
new file mode 100644
index 0000000..bf417e9
--- /dev/null
+++ b/bbb_cape/src/cape/robot_comp.c
@@ -0,0 +1,36 @@
+#include "cape/robot.h"
+
+#include <STM32F2XX.h>
+
+#include "cape/encoder.h"
+#include "cape/analog.h"
+#include "cape/digital.h"
+#include "cape/util.h"
+
+// TIM11.1 on PB9
+
+static volatile uint32_t ultrasonic_pulse_length = 0;
+
+void TIM1_TRG_COM_TIM11_IRQHandler(void) {
+ TIM11->SR = ~TIM_SR_CC1IF;
+ ultrasonic_pulse_length = TIM11->CCR1;
+}
+
+void robot_init(void) {
+ gpio_setup_alt(GPIOB, 11, 3);
+ RCC->APB2ENR |= RCC_APB2ENR_TIM11EN;
+ TIM11->CR1 = TIM_CR1_URS;
+ TIM11->SMCR = 5 << 4 /* TI1 */ |
+ 4 << 0 /* reset and start on edge */;
+ TIM11->DIER = TIM_DIER_CC1IE;
+ TIM11->CCMR1 = TIM_CCMR1_CC1S_0 /* input pin 1 -> timer input 1 */;
+ TIM11->CCER = TIM_CCER_CC1P /* go on falling edge */;
+ TIM11->EGR = TIM_EGR_UG;
+ TIM11->PSC = 1200 - 1; // 100kHZ timer
+ TIM11->CR1 |= TIM_CR1_CEN;
+ NVIC_SetPriority(TIM1_TRG_COM_TIM11_IRQn, 3);
+ NVIC_EnableIRQ(TIM1_TRG_COM_TIM11_IRQn);
+}
+
+void robot_fill_packet(struct DataStruct *packet) {
+}
diff --git a/output/.gitignore b/output/.gitignore
index 399a1c9..6ec381b 100644
--- a/output/.gitignore
+++ b/output/.gitignore
@@ -1,4 +1,5 @@
/prime/
/crio/
+/flasher/
/compiled-*/
/ip_base.txt