From bc9e93ad20f936c67d6acddb02d426783c32398e Mon Sep 17 00:00:00 2001 From: root Date: Sat, 13 Jun 2015 12:18:52 +0100 Subject: add usb resume support --- app/main.c | 57 +++++++++++++++++++-------------------------------------- 1 file changed, 19 insertions(+), 38 deletions(-) (limited to 'app/main.c') diff --git a/app/main.c b/app/main.c index 115a1df..a4a5394 100644 --- a/app/main.c +++ b/app/main.c @@ -1,20 +1,6 @@ #include "project.h" extern uint32_t dfu_flag; -void -sys_tick_handler (void) -{ -uint8_t d; - -while (!ring_read_byte(&rx1_ring,&d)) - kvm_recv(d); - -while (!ring_read_byte(&rx2_ring,&d)) - kvm_recv(d); - -led_tick(); -} - int main (void) { @@ -23,10 +9,10 @@ main (void) // rcc_clock_setup_in_hsi_out_48mhz (); //nvic_set_priority_grouping(NVIC_PriorityGroup_4); - /*set up pll*/ - rcc_clock_setup_in_hse_8mhz_out_72mhz(); + /*set up pll */ + rcc_clock_setup_in_hse_8mhz_out_72mhz (); - /*turn on clocks to periferals*/ + /*turn on clocks to periferals */ rcc_periph_clock_enable (RCC_GPIOA); rcc_periph_clock_enable (RCC_GPIOB); rcc_periph_clock_enable (RCC_GPIOC); @@ -35,39 +21,32 @@ main (void) rcc_periph_clock_enable (RCC_USART3); rcc_periph_clock_enable (RCC_AFIO); - led_init(); + ticker_init (); + + led_init (); usart_init (); usb_init (); - /*Start periodic timer*/ - - systick_set_clocksource (STK_CSR_CLKSOURCE_AHB_DIV8); - /* 48MHz / 8 = > 6Mhz */ - systick_set_reload (6000); - /* 6MHz / 6000 => 1kHz */ - systick_interrupt_enable (); - systick_counter_enable (); - - /*Adjust interrupt priorities so that uarts trump timer*/ - nvic_set_priority(NVIC_USART1_IRQ, 0x40); - nvic_set_priority(NVIC_USART2_IRQ, 0x40); - nvic_set_priority(NVIC_USART3_IRQ, 0x40); - nvic_set_priority(NVIC_SYSTICK_IRQ, 0xff); + /*Start periodic timer */ + /*Adjust interrupt priorities so that uarts trump timer */ + nvic_set_priority (NVIC_USART1_IRQ, 0x40); + nvic_set_priority (NVIC_USART2_IRQ, 0x40); + nvic_set_priority (NVIC_USART3_IRQ, 0x40); + nvic_set_priority (NVIC_SYSTICK_IRQ, 0xff); - led_clear(); #if 0 /*GPIO C11 was used to determine if we should enter dfu */ - /*now we use a ramdom address in ram*/ + /*now we use a ramdom address in ram */ gpio_set (GPIOC, GPIO11); gpio_set_mode (GPIOC, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO11); - + { - int i; - for (i = 0; i < 0x80000; i++) - __asm__ ("nop"); + int i; + for (i = 0; i < 0x80000; i++) + __asm__ ("nop"); } gpio_clear (GPIOC, GPIO11); @@ -78,5 +57,7 @@ main (void) usb_run (); + + return 0; } -- cgit v1.2.3