/* *------------------------------------------------------------------------------ * void APP_init(void) * * Summary : Initialize application * * Input : None * * Output : None *------------------------------------------------------------------------------ */ void APP_init( void ) { UINT8 i; //Set Date and Time //WriteRtcTimeAndDate(writeTimeDateBuffer); //Read the value of PRESET TIME from EPROM for(i = 0 ; i < NO_OF_DIGITS;i++) { app.mildstone1[i] = Read_b_eep (EEPROM_MILDSTONE1_ADDRESS + i); Busy_eep(); } app.mildstone1Value = (UINT16)(((app.mildstone1[3]- '0' )* 10 )+ ( app.mildstone1[2] - '0') )* 60 +(((app.mildstone1[1]- '0' )* 10 )+ (app.mildstone1[0] - '0')); for(i = 0 ; i < NO_OF_DIGITS;i++) { app.mildstone2[i] = Read_b_eep (EEPROM_MILDSTONE2_ADDRESS + i); Busy_eep(); } app.mildstone2Value = (UINT16)(((app.mildstone2[3]- '0' )* 10 )+ ( app.mildstone2[2] - '0') )* 60 +(((app.mildstone2[1]- '0' )* 10 )+ (app.mildstone2[0] - '0')); APP_resetDisplayBuffer(); DigitDisplay_updateBufferPartial(app.displayBuffer , 0, 4); GREEN_LAMP = RESET; RED_LAMP = RESET; CLOCK_LED = TRUE; }
void UI_updateDepartment(UINT8 *buffer) { UINT8 i ,j ; UINT8 department_data; UINT8 department_index = (buffer[0] - '0') - 1 ; i = j =0; while(buffer[i+1] != '\0') { Write_b_eep((DEPARTMENT_START_ADD +( (department_index * 16))+ i) ,buffer[i+1] ); Busy_eep(); i++; } Write_b_eep((DEPARTMENT_START_ADD +(department_index * 16))+ i , '\0'); Busy_eep(); department_data = Read_b_eep(DEPARTMENT_START_ADD +(department_index * 16)); Busy_eep(); while(department_data != '\0') { ui_department[department_index +1][j] = department_data ; j++; department_data = Read_b_eep((DEPARTMENT_START_ADD +(department_index * 16))+ j); Busy_eep(); } ui_department[department_index +1][j] = '\0'; }
void APP_init(void) { UINT8 i = 0, j = 0; UINT8 receivedMsg = '1'; UINT16 index = 0; UINT8 data = 0; UINT8 messageIndex = 0; //Read the receivedMsg from EEPROM and store it into for( i = 0; i < MAX_PROCESS; i++ ) { j = 0; //store the message offset index = ( UINT16 ) i * INDEX_OFFSET; //read the data from eeprom check for null data = Read_b_eep( index + j ); Busy_eep( ); if( data == '\0' ) continue; while( data != '\0' ) { data = app.msg[i][j++] = Read_b_eep( index + j ); Busy_eep( ); } } //restore the current message index = ( UINT16 )MAX_PROCESS * INDEX_OFFSET; messageIndex = Read_b_eep( index ); Busy_eep( ); app.previousInput = app.currentInput = messageIndex; app.currentIndex = messageIndex; if( messageIndex <= MAX_PROCESS ) { MMD_clearSegment(0); mmdConfig.startAddress = 0; mmdConfig.length = MMD_MAX_CHARS; mmdConfig.symbolCount = strlen( app.msg[messageIndex] ); mmdConfig.symbolBuffer = app.msg[messageIndex]; mmdConfig.scrollSpeed = SCROLL_SPEED_LOW; MMD_configSegment( 0 , &mmdConfig); } }
void UI_init(void) { UINT8 i, j; UINT8 department_index; UINT8 department_data; ui.departmentNo = '0'; setbckspc('\x08'); //Indicates LCD driver "\x08" is the symbol for backspace clearUIBuffer(); clearUIInput(); //read department data from EPROM and store no of department for(i = 0 ; i <= MAX_DEPARTMENTS ;i++) { department_index = Read_b_eep(DEPARTMENT_START_ADD +(i * 16)); Busy_eep(); if(department_index != '\0') { j = 0; department_data = department_index; while(department_data != '\0') { ui_department[i+1][j] = department_data ; j++; department_data = Read_b_eep((DEPARTMENT_START_ADD +(i * 16))+ j); Busy_eep(); } ui_department[i+1][j] = '\0'; ui.departmentNo ++; } } if (loginStatus() == TRUE) { setUImsg(UI_MSG_STATION); ui.state = UI_STATION; rawWriteCommandToLcd(DISPLAY_ON_CUR_BLINK_BIG); } else { ui.state = UI_IDLE; setUImsg(UI_MSG_IDLE); rawWriteCommandToLcd(DISPLAY_ON_CUR_OFF); } }
// Initialise the PIC static void initialisePic(void) { // PIC port set up -------------------------------------------------------- // Default all pins to digital ADCON1 = 0x0F; // Configure ports as inputs (1) or outputs(0) TRISA = 0b00000000; TRISB = 0b00000000; TRISC = 0b00000000; TRISD = 0b00000000; TRISE = 0b00000000; // Clear all ports PORTA = 0b00000000; PORTB = 0b00000000; PORTC = 0b00000000; PORTD = 0b00000000; PORTE = 0b00000000; // initialise the atmega IC atmegaFeederRunningTRIS = 1; atmegaResetPin = 1; // initialise i2c communication OpenI2C( MASTER, SLEW_OFF); SSPADD = 0x70; // Application specific initialisation applicationInit(); // Initialise the USB device USBDeviceInit(); // Initialise the output pins setVac1off; setVac2off; setVibrationoff; OpenTimer2( TIMER_INT_OFF & T2_PS_1_1); // load pwm values from eeprom led1_duty_cycle = Read_b_eep(baseLED_EEPROM_address); led2_duty_cycle = Read_b_eep(headLED_EEPROM_address); // initialise the stepper driver and start timer 0 at 1 microsecond intervals }
/* *------------------------------------------------------------------------------ * void APP_init(void) * * Summary : Initialize application * * Input : None * * Output : None *------------------------------------------------------------------------------ */ void APP_init( void ) { UINT8 i; // writeTimeDateBuffer[2] = SetHourMode(0X09,1,1); //Set Date and Time //WriteRtcTimeAndDate(writeTimeDateBuffer); //Read the value of PRESET TIME from EPROM for(i = 0 ; i < NO_OF_DIGITS;i++) { app.presetBuffer[i] = Read_b_eep (EEPROM_PRESET_ADDRESS + i); Busy_eep(); } app.presetValue = (UINT16)(((app.presetBuffer[3]- '0' )* 10 )+ ( app.presetBuffer[2] - '0') )* 60 +(((app.presetBuffer[1]- '0' )* 10 )+ (app.presetBuffer[0] - '0')); //Maintain the state from EPROM app.state = Read_b_eep (EEPROM_STATE_ADDRESS); Busy_eep(); //Read the STORED RTC value from EPROM for(i = 0 ; i < 6 ;i++) { app.displayBuffer[i] = Read_b_eep (EEPROM_RTC_ADDRESS + i); Busy_eep(); } //update that value on RTC APP_updateRTC(); //Maintain the HOOTER state from EPROM HOOTER = Read_b_eep (EEPROM_HOOTER_ADDRESS); Busy_eep(); //Maintain the hooter_reset value from EPROM app.hooter_reset = Read_b_eep (EEPROM_HOOTER_ADDRESS + 1); Busy_eep(); if(HOOTER == TRUE) { DigitDisplay_updateBuffer(app.presetBuffer); CLOCK_LED = 1; } //ON DOT_CONTROL leds CLOCK_LED = 0; }
/*---------------------------------------------- Store department riase vlaue from EEPROM ------------------------------------------------*/ void readDeptRaise(void) { UINT8 i; for( i = 0; i < MAX_DEPARTMENTS ;i++) { ias.department_raised[i+1] = Read_b_eep( DEPARTMENT_RAISE_ADD + i ); Busy_eep(); ClrWdt(); } }
void APP_task(void) { UINT8 i = 0, j = 0; UINT8 writeIndex = 0; UINT16 eepromIndex = 0; //update the new string in eeprom and buffer if(app.eepUpdate == TRUE) { //update EEPROM with new receivedMsg string while( app.receivedMsg[i] != '\0' ) { Write_b_eep( (app.receivedIndex+i), app.receivedMsg[i] ); Busy_eep(); i++; } //Store null eeprom Write_b_eep( (app.receivedIndex+i), '\0' ); Busy_eep(); //Get the write index of buffer by dividing message length writeIndex = ( UINT8 ) app.receivedIndex / INDEX_OFFSET; for( j = 0; j < i; j++ ) { app.msg[writeIndex][j] = Read_b_eep( app.receivedIndex + j ); Busy_eep( ); } app.msg[writeIndex][j] = '\0'; if( writeIndex == app.currentIndex ) { MMD_clearSegment(0); mmdConfig.startAddress = 0; mmdConfig.length = MMD_MAX_CHARS; mmdConfig.symbolCount = strlen( app.msg[writeIndex] ); mmdConfig.symbolBuffer = app.msg[writeIndex]; mmdConfig.scrollSpeed = SCROLL_SPEED_LOW; MMD_configSegment( 0 , &mmdConfig); } app.eepUpdate = FALSE; } //scan the input for change and update mmd based on the input app.currentInput = 0; if ( (LinearKeyPad_getKeyState(BIT_0) == 1) ) app.currentInput |= 0X01; //0b00000001; if ( (LinearKeyPad_getKeyState(BIT_1) == 1) ) app.currentInput |= 0X02; //0b00000010; if ( (LinearKeyPad_getKeyState(BIT_2) == 1) ) app.currentInput |= 0X04; //0b00000100; if ( (LinearKeyPad_getKeyState(BIT_3) == 1) ) app.currentInput |= 0X08; //0b00001000; if( app.previousInput != app.currentInput && app.currentInput != 0x00 ) { if( app.currentInput <= MAX_PROCESS ) { MMD_clearSegment(0); mmdConfig.startAddress = 0; mmdConfig.length = MMD_MAX_CHARS; mmdConfig.symbolCount = strlen( app.msg[app.currentInput-1] ); mmdConfig.symbolBuffer = app.msg[app.currentInput-1]; mmdConfig.scrollSpeed = SCROLL_SPEED_LOW; MMD_configSegment( 0 , &mmdConfig); app.previousInput = app.currentInput; app.currentIndex = app.currentInput-1; //store current message index into eeprom Write_b_eep( (UINT16)MAX_PROCESS * INDEX_OFFSET, app.currentInput-1 ); Busy_eep(); } } }
void IAS_init(void) { UINT16 i; UINT8 j,*ptr; UINT8 ackStatus = 0; UINT8 grn =0 ,org = 0,red = 0,buz = 0; #ifdef __FACTORY_CONFIGURATION__ ias.state = ISSUE_RESOLVED; ias.issues_raised = 0; //No. of raised issues should be 0 initially ias.issues_critical = 0; //No. of critical issues should be 0 initially ias.preAppTime = 0; ias.curAppTime = 0; log.index = 0; ias.logonStatus = 0; updateIndication(1,0,0,0); for(i = 0; i < 256; i++) { Write_b_eep(i,0); Busy_eep(); ClrWdt(); } #else ias.preAppTime = 0; ias.curAppTime = 0; log.index = 0; for( i = 0; i < MAX_ISSUES; i++) { ptr = (UINT8*) &ias.issues[i]; for( j = 0 ; j < ISSUE_ENTRY_SIZE; j++) { Busy_eep(); ClrWdt(); *(ptr+j) = Read_b_eep((i*ISSUE_ENTRY_SIZE)+j ); Busy_eep(); ClrWdt(); } if( ias.issues[i].state == ISSUE_RAISED) ias.issues_raised++; if(ias.issues[i].state == ISSUE_CRITICAL) ias.issues_critical++; if(ias.issues[i].ackStatus == 1) ackStatus = 1; } if( ias.issues_critical > 0 ) red = 1; else if( ias.issues_raised > 0 ) org = 1; else grn = 1; if( ackStatus == 1 ) buz = 1; ias.buzzerTimeout = 6; Busy_eep(); ClrWdt(); updateIndication(0,0,0,0); login(); ias.logonStatus = 1; updateIndication(grn,org,red,buz); #endif COM_init(CMD_SOP , CMD_EOP ,RESP_SOP , RESP_EOP , APP_comCallBack); }