summaryrefslogtreecommitdiffstats
path: root/app/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/main.c')
-rw-r--r--app/main.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/app/main.c b/app/main.c
index 495d240..115a1df 100644
--- a/app/main.c
+++ b/app/main.c
@@ -6,7 +6,10 @@ sys_tick_handler (void)
{
uint8_t d;
-while (!ring_read_byte(&rx_ring,&d))
+while (!ring_read_byte(&rx1_ring,&d))
+ kvm_recv(d);
+
+while (!ring_read_byte(&rx2_ring,&d))
kvm_recv(d);
led_tick();
@@ -15,58 +18,62 @@ led_tick();
int
main (void)
{
- int i;
// 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();
+ /*turn on clocks to periferals*/
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);
+ rcc_periph_clock_enable (RCC_USART2);
+ rcc_periph_clock_enable (RCC_USART3);
+ rcc_periph_clock_enable (RCC_AFIO);
-
+ 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);
- //nvic_set_priority(SysTick_IRQn, NVIC_EncodePriority(4,0,0));
- //nvic_set_priority(USART1_IRQn, NVIC_EncodePriority(4,1,0));
-
+ led_clear();
+#if 0
+ /*GPIO C11 was used to determine if we should enter dfu */
+ /*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);
+
- 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();
-
-
+ {
+ int i;
for (i = 0; i < 0x80000; i++)
__asm__ ("nop");
+ }
gpio_clear (GPIOC, GPIO11);
+#endif
- printf ("Hello world main=%p\r\n", main);
+ printf ("stm32_usb_kvm:\r\n");
printf ("dfu_flag=%08lx\r\n", dfu_flag);
usb_run ();