void setup() { ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_FPULazyStackingEnable(); ROM_FPUEnable(); uart_setup(); sd_init(); dac_setup(); keycontrol_setup(); initConfig(); tick_setup(); soundoutcontrol_setup(); setupADC(); setupUSBStore(); initSampleBlocks(); ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); ROM_IntMasterEnable(); DEBUG_PRINT("Setup complete\n", NULL); }
void tick_init(Window* window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); const GPoint center = grect_center_point(&bounds); tick_setup(&tick_path_1, center, 1); tick_setup(&tick_path_3, center, 3); tick_setup(&tick_path_5, center, 5); tick_setup(&tick_path_7, center, 7); tick_setup(&tick_path_9, center, 9); tick_setup(&tick_path_11, center, 11); tick_point_2 = tick_point(center, 2); tick_point_4 = tick_point(center, 4); tick_point_6 = tick_point(center, 6); tick_point_8 = tick_point(center, 8); tick_point_10 = tick_point(center, 10); tick_point_12 = tick_point(center, 12); }
int main(void) { if (DFU_AVAILABLE) { DFU_maybe_jump_to_bootloader(); } clock_setup(); tick_setup(1000); gpio_setup(); led_num(0); if (CDC_AVAILABLE) { console_setup(DEFAULT_BAUDRATE); } if (SEMIHOSTING) { initialise_monitor_handles(); } else if (VCDC_AVAILABLE) { retarget(STDOUT_FILENO, VIRTUAL_USART); retarget(STDERR_FILENO, VIRTUAL_USART); } else if (CDC_AVAILABLE) { retarget(STDOUT_FILENO, CONSOLE_USART); retarget(STDERR_FILENO, CONSOLE_USART); } led_num(1); { char serial[USB_SERIAL_NUM_LENGTH+1]; desig_get_unique_id_as_string(serial, USB_SERIAL_NUM_LENGTH+1); cmp_set_usb_serial_number(serial); } usbd_device* usbd_dev = cmp_usb_setup(); DAP_app_setup(usbd_dev, &on_dfu_request); if (CDC_AVAILABLE) { cdc_uart_app_setup(usbd_dev, &on_usb_activity, &on_usb_activity); } if (VCDC_AVAILABLE) { vcdc_app_setup(usbd_dev, &on_usb_activity, &on_usb_activity); } if (DFU_AVAILABLE) { dfu_setup(usbd_dev, &on_dfu_request); } tick_start(); /* Enable the watchdog to enable DFU recovery from bad firmware images */ iwdg_set_period_ms(1000); iwdg_start(); while (1) { iwdg_reset(); usbd_poll(usbd_dev); if (CDC_AVAILABLE) { cdc_uart_app_update(); } if (VCDC_AVAILABLE) { vcdc_app_update(); } // Handle DAP bool dap_active = DAP_app_update(); if (dap_active) { usb_timer = 1000; } else if (do_reset_to_dfu && DFU_AVAILABLE) { /* Blink 3 times to indicate reset */ int x; for (x=0; x < 3; x++) { iwdg_reset(); led_num(7); wait_ms(150); led_num(0); wait_ms(150); iwdg_reset(); } DFU_reset_and_jump_to_bootloader(); } if (usb_timer > 0) { usb_timer--; LED_ACTIVITY_OUT(1); } else { LED_ACTIVITY_OUT(0); } } return 0; }