From 5950acfb05fb3e172fa5710f1cda6ab347f51f2f Mon Sep 17 00:00:00 2001 From: root Date: Thu, 13 Nov 2014 17:39:18 +0000 Subject: leds --- app/main.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'app/main.c') diff --git a/app/main.c b/app/main.c index 508580d..495d240 100644 --- a/app/main.c +++ b/app/main.c @@ -4,12 +4,12 @@ extern uint32_t dfu_flag; void sys_tick_handler (void) { -#if 0 - printf ("fish\r\n"); - keyboard_test (); - mouse_test (); - tablet_test (); -#endif +uint8_t d; + +while (!ring_read_byte(&rx_ring,&d)) + kvm_recv(d); + +led_tick(); } int @@ -18,9 +18,14 @@ main (void) int i; - rcc_clock_setup_in_hsi_out_48mhz (); - rcc_periph_clock_enable (RCC_GPIOC); +// rcc_clock_setup_in_hsi_out_48mhz (); + //nvic_set_priority_grouping(NVIC_PriorityGroup_4); + + rcc_clock_setup_in_hse_8mhz_out_72mhz(); + rcc_periph_clock_enable (RCC_GPIOA); + rcc_periph_clock_enable (RCC_GPIOB); + rcc_periph_clock_enable (RCC_GPIOC); rcc_periph_clock_enable (RCC_AFIO); rcc_periph_clock_enable (RCC_USART1); @@ -31,16 +36,29 @@ main (void) systick_set_clocksource (STK_CSR_CLKSOURCE_AHB_DIV8); /* 48MHz / 8 = > 6Mhz */ - systick_set_reload (3000000); - /* 6MHz / 3000000 => 2Hz */ + systick_set_reload (6000); + /* 6MHz / 6000 => 1kHz */ systick_interrupt_enable (); systick_counter_enable (); + nvic_set_priority(NVIC_USART1_IRQ, 0x40); + nvic_set_priority(NVIC_SYSTICK_IRQ, 0xff); + + //nvic_set_priority(SysTick_IRQn, NVIC_EncodePriority(4,0,0)); + //nvic_set_priority(USART1_IRQn, NVIC_EncodePriority(4,1,0)); + + gpio_set (GPIOC, GPIO11); gpio_set_mode (GPIOC, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO11); + gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ, + GPIO_CNF_OUTPUT_PUSHPULL, GPIO8); + gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ, + GPIO_CNF_OUTPUT_PUSHPULL, GPIO9); + + led_clear(); for (i = 0; i < 0x80000; i++) -- cgit v1.2.3