make usb work with weird opencm3 hybrid

This commit is contained in:
jaseg 2020-08-30 15:27:11 +02:00
parent c7cfa7c057
commit cbb4ac1178
4 changed files with 291 additions and 12 deletions

25
main.c
View file

@ -19,6 +19,9 @@
#include "math.h"
#include "color.h"
extern void usb_serial_poll(void);
extern void usb_serial_init(void);
static struct hsvf g_color_s = {0.0f, 0.0f, 0.0f};
struct hsvf *g_color = &g_color_s;
volatile uint64_t g_time_ms = 0;
@ -44,6 +47,9 @@ uint32_t pcg32_random_r() {
}
int main(void){
/* This also sets the clocks */
usb_serial_init();
/* We're starting out from HSI@8MHz */
SystemCoreClockUpdate();
SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */
@ -89,18 +95,19 @@ int main(void){
uint64_t ts = g_time_ms;
uint64_t led_ts = 0;
for (;;) {
g_color->h = fmodf(g_color->h + 0.0005, 1.0f);
//g_color->h = 0.0;
g_color->s = 0.8;
g_color->v = 1.0;
if (check_interval(&ts, 5)) {
g_color->h = fmodf(g_color->h + 0.0005, 1.0f);
//g_color->h = 0.0;
g_color->s = 0.8;
g_color->v = 1.0;
struct rgbf rgb;
hsv_to_rgb(g_color, &rgb);
update_timers(&rgb);
ts = wait_until(ts + 5);
struct rgbf rgb;
hsv_to_rgb(g_color, &rgb);
update_timers(&rgb);
}
blink_led(&led_ts, 100, 200, GPIOC, 13);
usb_serial_poll();
}
}