int main(void) { setup_mcu(); keyboard_setup(); setup_usb(); sei(); /* init modules */ serial_init(); keyboard_init(); host_set_driver(&lufa_driver); #ifdef SLEEP_LED_ENABLE sleep_led_init(); #endif print("Keyboard start.\n"); while (1) { while (USB_DeviceState == DEVICE_STATE_Suspended) { print("[s]"); matrix_power_down(); suspend_power_down(); if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) { USB_Device_SendRemoteWakeup(); } } keyboard_task(); #if !defined(INTERRUPT_CONTROL_ENDPOINT) USB_USBTask(); #endif } }
int main() { gdt_setup(); idt_setup(); isr_setup(); init_video(); irq_setup(); __asm__ __volatile__ ("sti"); timer_setup(); keyboard_setup(); puts(" Welcome to TIK! \n"); for (;;); return 0; }
void boot() { //Initialise display and print message video_text_cls(); video_text_puttext("KAOS version 1\nDeveloped by Karl Hobley.\n\nCopyleft (C) 2011 Karl Hobley.\nKAOS is released under the GPLv3 Licence.\n\nBuild date: "__DATE__" "__TIME__"\n\n\n\n"); //Setup kernel video_text_puttext("Loading GDT "); gdt_setup(); video_text_puttext("[ DONE ]\n"); video_text_puttext("Loading IDT "); idt_setup(); video_text_puttext("[ DONE ]\n"); video_text_puttext("Loading ISR "); isr_setup(); video_text_puttext("[ DONE ]\n"); video_text_puttext("Loading IRQ "); irq_setup(); video_text_puttext("[ DONE ]\n"); video_text_puttext("Enabling Interrupts "); __asm__ __volatile__("sti"); video_text_puttext("[ DONE ]\n"); video_text_puttext("Loading Timer "); timer_setup(); video_text_puttext("[ DONE ]\n"); video_text_puttext("Loading Keyboard "); keyboard_setup(); video_text_puttext("[ DONE ]\n"); //Test panic volatile int a = 1; volatile int b = 0; volatile int c = a / b; }
void kernel_main(void) { terminal_init(); puts("This is BermudOS!"); if(!is_apic_compatible()) puts("Hardware is not APIC compatible"); if(!has_MSR()) puts("CPU has no MSR"); if(!gdt_setup()) puts("Error while setting up GDT"); setup_interrupts(); if(!keyboard_setup()) puts("Error while setting up the keyboard"); wait_sec(4); char bfr[KEYBOARD_BUFFER_SIZE+1]; int i; for(i = 0; i < 4; ++i) { read_keyboard_buffer(bfr); printf("The buffer contained: %s", bfr); } }
/* * ----- Function: main() ----- */ int16_t main(void) { // Call AEDEA initialization function. aedea_init(); // Setup the screen. screen_setup(); // Setup timer for a 10 millisecond tick. timer_setup(TICK_INTERVAL, tick_handler); // Setup the keyboard interrupt handler. keyboard_setup(key_handler); // Add the keyboard process. The keyboard's print area rectangle is passed to the keyboard process // each time it is invoked as the default parameter. aedea_add_process(keyboard_process, &kbd_rect, PID_KEYBOARD_PROCESS, kbd_evt_buff, KEYBOARD_EVENT_BUFF_SZ, sizeof(kbd_evt_t)); // Add the logger process. The log printing area rectangle is passed to the logger process // each time it is invoked as the default parameter. aedea_add_process(logger_process, &log_rect, PID_LOGGER_PROCESS, log_evt_buff, LOGGER_EVENT_BUFF_SZ, sizeof(log_evt_t)); // Add the mouse process. The mouse process contains no default argument and no events, hence, // all related fields are set to NULL. aedea_add_process(mouse_process, NULL, PID_MOUSE_PROCESS, NULL, NULL, NULL); // Install the print timer timeout handler. aedea_install_timeout_handler(print_timer, NULL, TMR_ID_PRINT_TIMER, TMR_INTERVAL_PRINT); // Install the animation timer timeout handler. aedea_install_timeout_handler(animation_timer, &ani_rect, TMR_ID_ANIMATION_TIMER, TMR_INTERVAL_ANIMATION); // Start the AEDEA process manager. aedea_start(); return 0; }
/* Main thread */ int main(void) { /* ChibiOS/RT init */ halInit(); chSysInit(); #ifdef STM32_EEPROM_ENABLE EEPROM_Init(); #endif // TESTING // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); keyboard_setup(); /* Init USB */ init_usb_driver(&USB_DRIVER); /* init printf */ init_printf(NULL,sendchar_pf); #ifdef MIDI_ENABLE setup_midi(); #endif #ifdef SERIAL_LINK_ENABLE init_serial_link(); #endif #ifdef VISUALIZER_ENABLE visualizer_init(); #endif host_driver_t* driver = NULL; /* Wait until the USB or serial link is active */ while (true) { #if defined(WAIT_FOR_USB) || defined(SERIAL_LINK_ENABLE) if(USB_DRIVER.state == USB_ACTIVE) { driver = &chibios_driver; break; } #else driver = &chibios_driver; break; #endif #ifdef SERIAL_LINK_ENABLE if(is_serial_link_connected()) { driver = get_serial_link_driver(); break; } serial_link_update(); #endif wait_ms(50); } /* Do need to wait here! * Otherwise the next print might start a transfer on console EP * before the USB is completely ready, which sometimes causes * HardFaults. */ wait_ms(50); print("USB configured.\n"); /* init TMK modules */ keyboard_init(); host_set_driver(driver); #ifdef SLEEP_LED_ENABLE sleep_led_init(); #endif print("Keyboard start.\n"); /* Main loop */ while(true) { #if !defined(NO_USB_STARTUP_CHECK) if(USB_DRIVER.state == USB_SUSPENDED) { print("[s]"); #ifdef VISUALIZER_ENABLE visualizer_suspend(); #endif while(USB_DRIVER.state == USB_SUSPENDED) { /* Do this in the suspended state */ #ifdef SERIAL_LINK_ENABLE serial_link_update(); #endif suspend_power_down(); // on AVR this deep sleeps for 15ms /* Remote wakeup */ if(suspend_wakeup_condition()) { usbWakeupHost(&USB_DRIVER); } } /* Woken up */ // variables has been already cleared by the wakeup hook send_keyboard_report(); #ifdef MOUSEKEY_ENABLE mousekey_send(); #endif /* MOUSEKEY_ENABLE */ #ifdef VISUALIZER_ENABLE visualizer_resume(); #endif } #endif keyboard_task(); #ifdef CONSOLE_ENABLE console_task(); #endif #ifdef VIRTSER_ENABLE virtser_task(); #endif #ifdef RAW_ENABLE raw_hid_task(); #endif } }
int main(void) { //system config SYSTEMConfig(80000000L, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE); int line = 0; int linewidth = 25; KeysToProcess = 0; //int i = 0; //for(i = 0; i < 15000; i++) // write the whole video frame //{ //VGA_VideoMemory[i] = 0xFF000000; //VGA_VideoMemory[i] = 0x55555555; //} /* writefullhorizontalline(0); writefullhorizontalline(1); writefullhorizontalline(5);//can't see writefullhorizontalline(6);//can see */ //writefullhorizontalline(8); //writefullhorizontalline(10); //writefullhorizontalline(150); //writefullhorizontalline(300); //writefullhorizontalline(450); //writefullhorizontalline(599); /* writefullhorizontalline(75); writefullhorizontalline(150); writefullhorizontalline(225); writefullhorizontalline(300); writefullhorizontalline(375); writefullhorizontalline(450); writefullhorizontalline(525); writefullhorizontalline(599); */ //writehorizontalline(600); // out of frame /* writefullverticalline(0); writefullverticalline(100); writefullverticalline(200); writefullverticalline(300); writefullverticalline(400); writefullverticalline(500); writefullverticalline(600); writefullverticalline(700); writefullverticalline(799); */ //writepixel(700, 500); //writepixel(700, 501); //writepixel(701, 500); //writepixel(701, 501); char testchar[8] = { 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00 }; // should be a "0" character char cursor[8] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; //writechar(testchar, 8, 8); //writechar(testchar, 32, 64); //writechar(keyboard_lookup('0'), 8, 8); //writechar(cursor, 8, 32 ); //writechar(cursor, 32, 8); //loop 800 / 8 = 100 times each line //loop 600 / 8 = 75 lines int i = 0; int j = 0; int CharNum = 0x21; //fill the video memory with characters in a repeating loop for(i = 0; i < 75; i++) //for(i = 0; i < 10; i++) { for(j = 0; j < 100; j++) //for(j = 0; j < 10; j++) { writechar(keyboard_lookup(CharNum), j*8, i*8); //writechar(keyboard_lookup('0'), j*8, i*8); if(CharNum < 0x80) { CharNum++; } else { CharNum = 0x21; } } } keyboard_setup(); VGA_Setup(); INTCONbits.MVEC = 1; // turn on mutli vectored mode //enable interrupts asm("ei"); //---turn things on--- T2CONbits.ON = 1; // turn the timer on //T3CONbits.ON = 1; //T4CONbits.ON = 1; SPI4CONbits.ON = 1;//turn SPI4 on videoON = 0; //initialize global variable to tell if video is on or off videoSEL = 1; global_count = 0;//initalize global variable for counting ISR entries T4STATE = 1;//initalize state machine for timer 4 / h sync T2State = 0; //try to start things by putting something in the shift register //SPI2BUF = TESTDATA; //manually set an SPI flag for testing //IFS1bits.SPI2TXIF = 1; //IFS1bits.SPI2ATXIF = 1; //main loop should contain: //while(1) //interpret TCP/IP or other serial data //interpret keypresses //draw things to memory //do other processing while (1) { if(PORTDbits.RD7 == 0) { int testing = 1; } if(PORTDbits.RD6 == 0) { KEYPRESSED = 1; } if(KeysToProcess == 1) { //process keystrokes interpretKeypress(); } } }
int main(void) { CPU_PRESCALE(0); // DDRD = _BV(PD5); // DDRB = _BV(PB0); // PORTD = _BV(PD5); // PORTB = _BV(PB0); print_set_sendchar(sendchar); // usb_init(); // _delay_ms(2000); // while (!usb_configured()) /* wait */ keyboard_setup(); dprintf("Initializing keyboard...\n"); keyboard_init(); // This implementation is pretty simplistic... if the USB connection // is not configured, choose the Bluefruit, otherwise use USB // Definitely would prefer to have this driven by an input pin and make // it switch dynamically - BCG // if (!usb_configured()) { // // Send power to Bluefruit... Adafruit says it takes 27 mA, I think // // the pins should provide 40 mA, but just in case I switch the // // Bluefruit using a transistor - BCG // DDRB = _BV(PB6); // PORTB |= _BV(PB6); dprintf("Setting host driver to bluefruit...\n"); host_set_driver(bluefruit_driver()); dprintf("Initializing serial...\n"); serial_init(); // char swpa[] = "+++\r\n"; // for (int i = 0; i < 5; i++) { // serial_send(swpa[i]); // } // char ble_enable[] = "AT+BLEKEYBOARDEN=1\r\n"; // for (int i = 0; i < 20; i++) { // serial_send(ble_enable[i]); // } // char reset[] = "ATZ\r\n"; // for (int i = 0; i < 5; i++) { // serial_send(reset[i]); // } // for (int i = 0; i < 5; i++) { // serial_send(swpa[i]); // } // wait an extra second for the PC's operating system // to load drivers and do whatever it does to actually // be ready for input _delay_ms(1000); // PORTD = ~_BV(PD5); dprintf("Starting main loop"); while (1) { keyboard_task(); } // } else { // // I'm not smart enough to get this done with LUFA - BCG // dprintf("Setting host driver to PJRC...\n"); // host_set_driver(pjrc_driver()); // #ifdef SLEEP_LED_ENABLE // sleep_led_init(); // #endif // // wait an extra second for the PC's operating system // // to load drivers and do whatever it does to actually // // be ready for input // _delay_ms(1000); // PORTB = ~_BV(PB0); // dprintf("Starting main loop"); // while (1) { // while (suspend) { // suspend_power_down(); // if (remote_wakeup && suspend_wakeup_condition()) { // usb_remote_wakeup(); // } // } // keyboard_task(); // } // } }
int main(void) { DBG_LED_ENA; DBG_1_ENA; DBG_1_OFF; DBG_2_ENA; DBG_2_OFF; DBG_3_ENA; DBG_3_OFF; debug_code_init(); CLK_init(); ADC0_init(); SR_EXP_Init(); #ifdef RGB_MATRIX_ENABLE i2c1_init(); #endif // RGB_MATRIX_ENABLE matrix_init(); USB2422_init(); DBGC(DC_MAIN_UDC_START_BEGIN); udc_start(); DBGC(DC_MAIN_UDC_START_COMPLETE); DBGC(DC_MAIN_CDC_INIT_BEGIN); CDC_init(); DBGC(DC_MAIN_CDC_INIT_COMPLETE); while (USB2422_Port_Detect_Init() == 0) {} DBG_LED_OFF; #ifdef RGB_MATRIX_ENABLE while (I2C3733_Init_Control() != 1) {} while (I2C3733_Init_Drivers() != 1) {} I2C_DMAC_LED_Init(); i2c_led_q_init(); for (uint8_t drvid = 0; drvid < ISSI3733_DRIVER_COUNT; drvid++) I2C_LED_Q_ONOFF(drvid); //Queue data #endif // RGB_MATRIX_ENABLE keyboard_setup(); keyboard_init(); host_set_driver(&arm_atsam_driver); #ifdef CONSOLE_ENABLE uint64_t next_print = 0; #endif //CONSOLE_ENABLE v_5v_avg = adc_get(ADC_5V); debug_code_disable(); while (1) { main_subtasks(); //Note these tasks will also be run while waiting for USB keyboard polling intervals if (g_usb_state == USB_FSMSTATUS_FSMSTATE_SUSPEND_Val || g_usb_state == USB_FSMSTATUS_FSMSTATE_SLEEP_Val) { if (suspend_wakeup_condition()) { udc_remotewakeup(); //Send remote wakeup signal wait_ms(50); } continue; } keyboard_task(); #ifdef CONSOLE_ENABLE if (timer_read64() > next_print) { next_print = timer_read64() + 250; //Add any debug information here that you want to see very often //dprintf("5v=%u 5vu=%u dlow=%u dhi=%u gca=%u gcd=%u\r\n", v_5v, v_5v_avg, v_5v_avg - V5_LOW, v_5v_avg - V5_HIGH, gcr_actual, gcr_desired); } #endif //CONSOLE_ENABLE } return 1; }