aboutsummaryrefslogtreecommitdiff
path: root/examples/test-session.cpp
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-03-22 16:59:29 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-03-24 07:25:14 -0400
commit296b1188bfb8cf28466b95f1dd0fde309b1f9399 (patch)
treeb0ed2b9fecb2da85266e6b2b88c6fe31bb0ca2c8 /examples/test-session.cpp
parent68b57d90007a234e6a2fc82f6b9402fb6b77ef34 (diff)
Initial timer refactor.
Basic PWM works. Had some problems in testing that might be due to USART bugs. HardwareTimer has been removed from the build for now; I will re-implement it in terms of the new libmaple API, but consider it deprecated. Let's come up with something better. Servo is implemented in terms of HardwareTimer, so it also has been temporarily removed from the build. pwmWrite() likely got a little bit less inefficient due to indirection, but the PIN_MAPs shrank by a pointer per PinMapping.
Diffstat (limited to 'examples/test-session.cpp')
-rw-r--r--examples/test-session.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/examples/test-session.cpp b/examples/test-session.cpp
index a147e06..9b4bce4 100644
--- a/examples/test-session.cpp
+++ b/examples/test-session.cpp
@@ -15,7 +15,6 @@
//#define COMM Serial2
//#define COMM Serial3
-
#define ESC ((uint8)27)
int rate = 0;
@@ -610,17 +609,15 @@ void cmd_servo_sweep(void) {
COMM.println("(reset serial port)");
}
+static uint16 init_all_timers_prescale = 0;
+
+static void set_prescale(timer_dev *dev) {
+ timer_set_prescaler(dev, init_all_timers_prescale);
+}
+
void init_all_timers(uint16 prescale) {
- timer_init(TIMER1, prescale);
- timer_init(TIMER2, prescale);
- timer_init(TIMER3, prescale);
- timer_init(TIMER4, prescale);
-#ifdef STM32_HIGH_DENSITY
- timer_init(TIMER5, prescale);
- // timer_init(TIMER6, prescale);
- // timer_init(TIMER7, prescale);
- timer_init(TIMER8, prescale);
-#endif
+ init_all_timers_prescale = prescale;
+ timer_foreach(set_prescale);
}
// Force init to be called *first*, i.e. before static object allocation.