// // This function initializes the spaceteam program by // setting up all necessary I/O // void init_io(void) { ANSA = 0x0000; // All digital on port A ANSB = 0x4000; // Need analog input for the knob TRISA = TRISAVAL; TRISB = TRISBVAL; // Initialize the keypad too init_keypad(); // Need to set up the A/D for the knob AD1CON2 = 0x0000; // Can leave this as 0 AD1CON3 = 0x0000; AD1CON1 = 0x0000; AD1CHS = 0x0A0A; // Set RB14 = AN10 as the input to the ADC // Now, turn on the ADC module AD1CON1bits.ADON = 1; // Set the chip selects high LATAbits.LATA7 = 1; LATBbits.LATB12 = 1; // And initialize the keypad init_keypad(); init_done = 1; return; }
void init() { //init_display(); init_keypad(); init_timer(); init_delay_1sec(); }
static void plug_devices(void) { /* Port ranges 0x0 -> 0xF */ port_map[0x0] = init_control(); port_map[0x1] = init_flash(); port_map[0x2] = init_sha256(); port_map[0x3] = init_usb(); port_map[0x4] = init_lcd(); port_map[0x5] = init_intrpt(); port_map[0x6] = init_watchdog(); port_map[0x7] = init_gpt(); port_map[0x8] = init_rtc(); port_map[0x9] = init_protected(); port_map[0xA] = init_keypad(); port_map[0xB] = init_backlight(); port_map[0xC] = init_cxxx(); port_map[0xD] = init_dxxx(); port_map[0xE] = init_exxx(); port_map[0xF] = init_fxxx(); reset_proc_count = 0; /* Populate reset callbacks */ add_reset_proc(lcd_reset); add_reset_proc(keypad_reset); add_reset_proc(gpt_reset); add_reset_proc(rtc_reset); add_reset_proc(watchdog_reset); add_reset_proc(cpu_reset); gui_console_printf("[CEmu] Initialized APB...\n"); }
static int kp_init(void) { vbus = l4re_get_env_cap("vbus"); if (l4_is_invalid_cap(vbus)) { printf("[KEYP] Failed to query vbus\n"); return -1; } if (l4vbus_get_device_by_hid(vbus, 0, &i2c_handle, "i2c", 0, 0)) { printf("[KEYP] ##### Cannot find I2C\n"); } return init_keypad(); }
int main(int argc, char **argv) { /* Connect to PicoGUI and tuxphone */ pgInit(argc,argv); phone_fd = phone_open(); if (phone_fd <= 0) { pgMessageDialog("TuxPhone Error","Unable to connect to tuxphone daemon",0); return 1; } /* Build the GUI */ init_call_info(); init_keypad(); /* Set up to recieve phone events */ phone_register_events(phone_fd, ALL_EVENT_MASK); pgCustomizeSelect(&mySelect,&mySelectBH); pgEventLoop(); }
void taskBackground(void* pvParameter) { static unsigned int val1; static unsigned int val2; time_t time_sec; // vTaskSetApplicationTaskTag( NULL, ( void * ) 'b' ); alarm_st = 0; #ifndef SIM_DEBUG //sysinit wdi_ena = 0; Spi_init(); if(get_time_rtc(&rtc_time)== FALSE) { SetError(RTC_ERR, HARWARE_ALRM_SCR); reset_rtc(); while(clear_os_rtc() == FALSE); init_time_rtc(&rtc_time); // rtc_time.tm_sec = 0; // rtc_time.tm_min = 0; // rtc_time.tm_hour = 0; // rtc_time.tm_mday = 1; // rtc_time.tm_wday = 0; // rtc_time.tm_mon = 0; // rtc_time.tm_year = 100; // rtc_time.tm_yday = 0; // rtc_time.tm_isdst = 0; set_time_rtc(&rtc_time)/*set_date()*/; } else if(mktime(&rtc_time)==-1) { SetError(RTC_ERR, HARWARE_ALRM_SCR); // reset_rtc(); init_time_rtc(&rtc_time); set_time_rtc(&rtc_time)/*set_date()*/; } time_sec = mktime(&rtc_time); set_clock(time_sec); // if(get_days(&calib_date) > 365) // if(time_sec - calib_time >= 31536000L /*365*24*60*60*/) // { // Beep(800); // lcd_clear(); // beep(800,4); // RTclock.timer = 2000; //10sec timeout // draw_text( 15, LCD_TXTLINE1, (uchar*)"SEND THE PUMP", LCD_PIXEL_ON,0); // draw_text( 54, LCD_TXTLINE2, (uchar*)"TO", LCD_PIXEL_ON,0); // draw_text( 29, LCD_TXTLINE3, (uchar*)"CALIBRATE", LCD_PIXEL_ON,0); // while(RTclock.timer > 0); // } SST25ProtDisable(); SST25ReadArray(PARAM_E2PIMG_BASE, &E2pImage, sizeof(E2pImage_t)); if(crc16((unsigned char*)&E2pImage, sizeof(E2pImage_t)) != 0) { SetError(EEPROM_ERR, HARWARE_ALRM_SCR); set_defaults(); } SST25ReadArray(CLBR_E2PIMG_BASE, &Clbr_E2pImage, sizeof(Clbr_E2pImage_t)); if(crc16((unsigned char*)&Clbr_E2pImage, sizeof(Clbr_E2pImage_t)) != 0) { SetError(EEPROM_ERR, HARWARE_ALRM_SCR); set_fact_defaults(); } if(GetError() != 0) { err_code = GetError(); ClearError(); ((unsigned int*)&E2pImage)[sizeof(E2pImage_t)/2 - 1] = crc16(&E2pImage, sizeof(E2pImage_t) - 2); SST25SectorErase(PARAM_E2PIMG_BASE); if(!SST25WriteArray(PARAM_E2PIMG_BASE, &E2pImage, sizeof(E2pImage_t))) /*CriticalError("eeprom err")*/; } MCP23S08Init(); MCP4822Write(0, zero_press1 , 0); MCP4822Write(1, zero_press2 , 0); init_motor(); init_airdet(); #endif init_keypad(); init_clock(); CheckParams(); /* drop task priority */ vTaskPrioritySet( hBACKGRNDTask, tskIDLE_PRIORITY + 1 ); while (1) { vTaskDelay( 50 / portTICK_RATE_MS ); // Wait 50ms if(val1 > 0x0fff) val1 = 0; else val1++; if(val2 > 0x0fff) val1 = 0; else val2++; if(!wdi_ena) toggleExpGPO(WDI_EXTIOBIT); // ClrWdt(); // WD_PIN^= 1; /*toggle external watch dog */ } }
int main(void) { LCD_Initalize(); LCD_GoTo(0, 0); // Set cursor to first char in first line LCD_WriteText("-= LCD READY =-"); // Display sample text #ifdef HEART_BEAT SET_BIT(DDRB, PB0); SET_BIT(PORTB, PB0); #endif // g_clock.handle_milisec = milisec_handler; g_clock.handle_second = second_handler; init_clock(); init_keypad(); sei(); msg_t* msg = 0; int screen = DEFAULT_SCREEN; char screen_changed = 1; while(1) { while((msg = get_msg())) { switch(msg->type) { case MSG_INPUT: if (msg->size == BTN_0) { if (screen == SETUP_TIME_SCREEN) { set_clock(g_time_screen.hour, g_time_screen.minute); } ++screen; screen %= SCREEN_COUNT; screen_changed = 1; } break; default: break; } if (screen_changed) { clear_screen(); } switch (screen) { case 0: show_default_screen(msg); break; case 1: show_setup_time_screen(screen_changed, msg); break; case -1: show_setup_diameter_screen(); break; default: break; } screen_changed = 0; free_msg(&msg); } sleep_mode(); } return 0; }