/* Radio control interface */ int menuTask(task* t) { if(USART_HasReceived(0)) { char uInput = USART_Receive(0); switch(uInput) { // Fan case 'f': tempProcess(0x3F); // emulate "?" function button tempProcess(0x32); // emulate "2" function button break; // Enable case 'e': tempProcess(0x3F); // emulate "?" function button tempProcess(0x31); // emulate "2" function button break; default: if(uInput >= '0' && uInput <= '9') { tempProcess(0x30 | (uInput - '0')); } break; } } return 0; }
void main() { SCB->VTOR = 0x08000000; // set clock source as HSI / 2 * (PLL) 4 RCC->CFGR |= RCC_CFGR_PLLMULL8 | RCC_CFGR_PLLXTPRE_HSE_Div2 /*| RCC_CFGR_PLLSRC*/; RCC->CR |= RCC_CR_PLLON; while (!(RCC->CR & RCC_CR_PLLRDY)); RCC->CFGR |= RCC_CFGR_SW_PLL; while (!(RCC->CFGR & RCC_CFGR_SWS_PLL)); // enable peripherals RCC->APB1ENR = RCC_APB1ENR_TIM2EN; RCC->APB2ENR = RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN | RCC_APB2ENR_IOPCEN | RCC_APB2ENR_ADC1EN | RCC_APB2ENR_USART1EN | RCC_APB2ENR_AFIOEN; AFIO->MAPR = AFIO_MAPR_SWJ_CFG_JTAGDISABLE; // configure USART IO_ALT_PUSH_PULL(UART_TX); USART1->BRR = USART_BRR(230400); USART1->CR1 = USART_CR1_UE | USART_CR1_TE | USART_CR1_RE | USART_CR1_RXNEIE; ENABLE_INTERRUPT(USART1_IRQn); // enable systick SysTick->LOAD = SysTick->VAL = (F_CPU / 1000) / 8; SysTick->CTRL = /*SysTick_CTRL_CLKSOURCE |*/ SysTick_CTRL_ENABLE | SysTick_CTRL_TICKINT; _delay_init(); IO_PUSH_PULL(LED); IO_HIGH(LED); #ifndef ETHERNET_MODULE OW_UART_init(); tempInit(); ioInit(); irInit(); #endif #ifdef ETHERNET ethInit(); #endif uint8_t b; uint32_t lastCheck = 0; for (;;) { // if (IO_IS_LOW(IN1)) dodump = 1; // else dodump = 0; // dodump=1; #ifndef ETHERNET_MODULE ioProcess(); tempProcess(); irProcess(); #endif provTmr(); #ifdef ETHERNET ethProcess(); #endif } }