diff options
-rw-r--r-- | main.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -10,6 +10,8 @@ #include <i2c/i2c.h> +#include <timer/timer.h> + #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); |