From ff1234c4b01ed46dda7ea96e3f2afd986a28967d Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 17 Feb 2013 18:45:41 +0100 Subject: Enable PWM outputs. --- main.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/main.cpp b/main.cpp index a227a39..91b3dd6 100644 --- a/main.cpp +++ b/main.cpp @@ -10,6 +10,8 @@ #include +#include + #include "lsm303dlm.h" #include "l3gd20.h" @@ -33,6 +35,9 @@ static Pin& i2c_sda = PB11; static Pin& cs_pressure = PB4; static Pin& cs_gyro = PB5; +static Pin& esc_power = PA1; +static Pin pwm_outputs[] = {PC6, PC7, PC8, PC9}; + auto dev_desc = device_desc(0x200, 0, 0, 0, 64, 0x1234, 0x5678, 0, 0, 0, 0, 1); auto conf_desc = configuration_desc(3, 1, 0, 0xc0, 0, interface_desc(0, 0, 1, 0xff, 0x00, 0x00, 0, @@ -214,6 +219,24 @@ int main() { PA0.set_af(1); ppmsum.enable(); + for(Pin& p : pwm_outputs) { + p.set_af(3); + p.set_mode(Pin::AF); + } + + RCC.enable(RCC.TIM8); + TIM8.PSC = 168 - 1; + TIM8.ARR = 2500; + TIM8.CCER = 0x1111; + TIM8.CCMR1 = 0x6868; + TIM8.CCMR2 = 0x6868; + TIM8.BDTR = (1 << 15); + TIM8.CCR1 = 1000; + TIM8.CCR2 = 1000; + TIM8.CCR3 = 1000; + TIM8.CCR4 = 1000; + TIM8.CR1 = 0x05; + while(1) { led_error.toggle(); Time::sleep(10); -- cgit v1.2.3