void initHardware(void) { /* disable watchdog */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* clock full speed */ clock_prescale_set(clock_div_1); /* Hardware Initialization */ vrefInit(); srInit(); srClear(); srEnable(); USB_Init(); }
void Serial::interruptCallback(InterruptController::Index /*index*/) { __SR sr; sr.value = srValue(); bool any = false; if (sr.bits.ORE) { error(System::Event::Result::OverrunError); // we have to read the data even though the STM tells us that there is nothing to read (RXNE = 0) (void)read(); any = true; } if (sr.bits.FE) { error(System::Event::Result::FramingError); // we have to read the data even though the STM tells us that there is nothing to read (RXNE = 0) (void)read(); any = true; } if (sr.bits.PE) { error(System::Event::Result::ParityError); // we have to wait for the RXNE flag any = true; } if (sr.bits.LBD) { error(System::Event::Result::LineBreak); // we have to manually clear the bit __SR clear; clear.bits.LBD = 1; srClear(clear.value); any = true; } if (sr.bits.NF) { error(System::Event::Result::NoiseDetected); // we have to read the data even though the STM tells us that there is nothing to read (RXNE = 0) (void)read(); any = true; } if (sr.bits.RXNE && mBase->CR1.RXNEIE) { interrupt(Interrupt::DataRead); any = true; } if (sr.bits.TXE && mBase->CR1.TXEIE) { interrupt(Interrupt::TransmitDataEmpty); any = true; } if (sr.bits.TC && mBase->CR1.TCIE) { interrupt(Interrupt::TransmitComplete); any = true; } if (sr.bits.IDLE && mBase->CR1.IDLEIE) { // we have to read the data to clear the idle bit (void)read(); interrupt(Interrupt::Idle); any = true; } if (!any) interrupt(Interrupt::DataReadByDma); #ifdef STM32F7 srClear(sr.value); #endif }