diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 40 |
1 files changed, 8 insertions, 32 deletions
@@ -78,8 +78,8 @@ int main() { RCC.enable(RCC.USB); usb.init(); - //RCC.enable(RCC.SPI2); - /* + RCC.enable(RCC.SPI2); + spi2_sck.set_mode(Pin::AF); spi2_sck.set_af(5); spi2_mosi.set_mode(Pin::AF); @@ -97,42 +97,18 @@ int main() { magn.init(); float buf[3] = {0,0,0}; - */ - s1.set_mode(Pin::AF); - s1.set_af(1); - s2.set_mode(Pin::AF); - s2.set_af(1); - - RCC.enable(RCC.TIM8); - TIM8.PSC = 168 - 1; - TIM8.ARR = 2500; - TIM8.CCER = (1 << 12) | (1 << 8) | (1 << 4) | (1 << 0); - TIM8.CCMR1 = (6 << 12) | (1 << 11) | (6 << 4) | (1 << 3); - TIM8.CCMR2 = (6 << 12) | (1 << 11) | (6 << 4) | (1 << 3); - TIM8.BDTR = (1 << 15); - TIM8.CCR1 = 1000; - TIM8.CCR2 = 1000; - TIM8.CCR3 = 1000; - TIM8.CCR4 = 1000; - TIM8.CR1 = (1 << 2) | (1 << 0); while(1) { usb.process(); - //uint8_t magn_status = magn.update(); - - //buf[0] = magn.x; - //buf[1] = magn.y; - //buf[2] = magn.z; - TIM8.CCR1 = 1000 + 100; - TIM8.CCR2 = 1000 + 100; - TIM8.CCR3 = 1000 + 100; - TIM8.CCR4 = 1000 + 100; - + uint8_t magn_status = magn.update(); + buf[0] = magn.x; + buf[1] = magn.y; + buf[2] = magn.z; + if(usb.ep_ready(1)) { - //usb.write(1, (uint32_t*)&magn.ident, sizeof(magn.ident)); - //usb.write(1, (uint32_t*)buf, sizeof(buf)); + usb.write(1, (uint32_t*)buf, sizeof(buf)); //usb.write(1, (uint32_t*)&magn_status, sizeof(magn_status)); } } |