static void serial_hw_init(unsigned int baudrate, bool parity_enabled, bool parity) { qsm->QIVR = SERIAL_INTERRUPT_HANDLER_INDEX; /* Set the interrupt level */ qsm->QILR &= ~ILSCI_MASK; qsm->QILR |= SERIAL_INTERRUPT_LEVEL << ILSCI; /* Clear the SQPI interrupt level */ qsm->QILR &= ~ILQSPI_MASK; /* Calculate and set the baudrate */ qsm->SCCR0 = (SYSTEM_CLOCK * 10 / (32 * baudrate) + 5) / 10; /* Enable the reception interrupt, the transmission and the reception */ qsm->SCCR1 = RIE | TE | RE | (parity ? PT : 0) | (parity_enabled ? PE|M : 0); /* Install the interrupt handler for the serial interface */ install_interrupt(serial_hw_interrupt_handler, SERIAL_INTERRUPT_HANDLER_INDEX); }
FILE * pcterm_init(struct Device_Conf *dev){ finit( & term.file ); term.file.fs = &term_fs; term.file.d = (void*)&term; term.file.codepage = CODEPAGE_PC437; term.scr.x = term.scr.y = 0; if( dev->addr ) term.scr.d = (u_short*)(dev->addr - k_paddr); else term.scr.d = (u_short*)(0xB8000 - k_paddr); if( dev->flags ) term.scr.attr = dev->flags; else term.scr.attr = 7; if( dev->port ) term.kbd.port = dev->port; else term.kbd.port = KBD_PORT; term.kbd.head = term.kbd.tail = term.kbd.len = 0; term.kbd.state = 0; if( install_interrupt(dev->irq, IPL_TTY, kbdirq, dev->name) ){ PANIC("could not install kbd irq"); } #ifndef PLATFORM_EMUL /* config h/w */ clear_screen( &term.file ); move_cursor( &term.file, 0, 0 ); #endif pcterm_port = &term.file; kprintf("%s scrn at mem 0x%x (0x%x) kbd at io 0x%x irq %d\n", dev->name, term.scr.d, (int)term.scr.d + (int)k_paddr, term.kbd.port, dev->irq); return pcterm_port; }
void main_task ( uint_32 initial_data ) { DATE_STRUCT time_rtc; TIME_STRUCT time_mqx; if (_lwevent_create(&lwevent,0) != MQX_OK) { printf("\nMake event failed"); _task_block(); } printf ("\fStart time (MQX synchronized to RTC time during bsp init):\n\n"); /* initialize time */ time_rtc.YEAR = 2010; time_rtc.MONTH = 10; time_rtc.DAY = 15; time_rtc.HOUR = 10; time_rtc.MINUTE = 8; time_rtc.SECOND = 0; time_rtc.MILLISEC = 0; _time_from_date (&time_rtc, &time_mqx); _time_set( &time_mqx); if( _rtc_sync_with_mqx(FALSE) != MQX_OK ) { printf("\nError synchronize time!\n"); _task_block(); } _time_get (&time_mqx); _time_to_date (&time_mqx, &time_rtc); print_mqx_time(&time_rtc, &time_mqx); print_current_time(); /* except MPC5125 */ #ifndef BSP_TWRMPC5125 install_interrupt(); /* enable stopwatch */ install_stopwatch(); /* enable alarm */ install_alarm(); _lwevent_wait_ticks(&lwevent,LWE_ALARM,FALSE,0); _lwevent_clear(&lwevent,LWE_ALARM); printf ("\nALARM!\n"); print_current_time(); /* end of alarm */ printf ("Continue wasting time (2 minutes max) ...\n"); _lwevent_wait_ticks(&lwevent,LWE_STOPWATCH,FALSE,0); _lwevent_clear(&lwevent,LWE_STOPWATCH); printf ("\nSTOPWATCH!\n"); print_current_time(); printf ("\nClearing RTC:\n"); _rtc_init (RTC_INIT_FLAG_CLEAR | RTC_INIT_FLAG_ENABLE); print_current_time(); install_alarm(); _lwevent_wait_ticks(&lwevent,LWE_ALARM,FALSE,0); _lwevent_clear(&lwevent,LWE_ALARM); printf ("ALARM!\n"); print_current_time(); #else /* BSP_TWRMPC5125 */ printf ("Waste 10 seconds here\n"); _time_delay(10000); _rtc_get_time_mqxd (&time_rtc); print_rtc_time(&time_rtc, &time_mqx); #endif printf ("Synchronize RTC to MQX time again:\n"); _rtc_sync_with_mqx (FALSE); _rtc_get_time_mqxd (&time_rtc); _time_from_date (&time_rtc, &time_mqx); print_rtc_time(&time_rtc, &time_mqx); #if PSP_HAS_IRTC == 1 irtc_test(); #endif /* PSP_HAS_IRTC == 1 */ /* Test tamper event functionality on MCF51EMxx device */ #if PSP_MQX_CPU_IS_MCF51EM test_tamper(); #else printf ("Finish, press/hold reset to repeat.\n"); _task_block() ; #endif }