int main(void) { DIO_voidInit(); SSD_voidInit(); p[0] = letterA; p[1] = letterN; p[2] = letterW; p[3] = letterA; p[4] = letterR; DIO_u8WritePinVal(otpt_pin,0); // output enable DIO_u8WritePinVal(sh_clk,0); // output enable while(1) { Segments(); //for(u8 ii=0;ii<5;ii++) // { // DIO_u8WritePinVal(16,1); //for(u8 i=0;i<50;i++) //{ // (*p[0])(); //} // DIO_u8WritePinVal(16,0); //} } return 0; }
int main() { DIO_voidInit(); CHARACTER_LCD_voidInit(); //goto cgram CHARACTER_LCD_voidWriteCommand(0b01000000); CHARACTER_LCD_voidWriteData(0xff); CHARACTER_LCD_voidWriteData(0x00); CHARACTER_LCD_voidWriteData(0xff); CHARACTER_LCD_voidWriteData(0x00); CHARACTER_LCD_voidWriteData(0xff); CHARACTER_LCD_voidWriteData(0x00); CHARACTER_LCD_voidWriteData(0xff); CHARACTER_LCD_voidWriteData(0x00); //goto ddram //CHARACTER_LCD_voidWriteCommand(0x80); // CHARACTER_LCD_voidWriteCommand(0b11000000); start of line 2 CHARACTER_LCD_voidWriteCommand(0b11000000); CHARACTER_LCD_voidWriteData(0x00); return 0; }
void main (void) { u8 x ; DIO_voidInit(); u8 cola_H[]={1,1,1,1,1,1,1,1}; u8 rowa_H[]={1,1,1,1,1,1,1,1}; DIO_u8WritePinDir(17,1); DIO_u8WritePinDir(16,0); while(1) { // Write_M() ; // Write_A() ; // Write_M() ; // Write_D() ; // Write_O() ; // Write_H() ; TSW_u8ReadState(0,&x); if(x==1) { DIO_u8WritePinVal(17,1); } else { DIO_u8WritePinVal(17,0); } } }
int main(void) { u8 Local_u8SwitchValue; // to store the Switch Value u8 Local_u8SwitchFlag = FALSE; // to run the switch in the single mode u16 Local_u16ADCValue; // to store the ADC Value u16 Local_u16PrevADCValue = 2000; // to store the Previous ADC Value f32 Local_f32VoltageValue; u8 Local_u8Buffer[5]; // to store the Volt value as characters DIO_voidInit(); ADC_voidInit(); ADC_voidEnable(); LCD_voidInit(); LCD_u8Write_String("Voltage:"); //LCD_u8Write_Command(0x80); //go to First line and --0 is for 0th position while (1) { TSW_u8CheckSwitch(TSW_u8NUM1, &Local_u8SwitchValue); if (Local_u8SwitchValue == TSW_u8PRESSED) { if (!Local_u8SwitchFlag) { Local_u8SwitchFlag = TRUE; DIO_u8WritePinVal(RELAYCONTROL, DIO_u8HIGH); } } else { //Local_u8SwitchValue == TSW_u8RELEASED if (Local_u8SwitchFlag) { Local_u8SwitchFlag = FALSE; DIO_u8WritePinVal(RELAYCONTROL, DIO_u8LOW); } } //ADC_u8ReadChannel(ADC_u8CH7, &Local_u16ADCValue); ADC_u8ReadChannelFiltered(ADC_u8CH7, &Local_u16ADCValue); if (Local_u16ADCValue == Local_u16PrevADCValue) { } else { //Local_u16ADCValue != Local_u16PrevADCValue Local_u16PrevADCValue = Local_u16ADCValue; CalculateVlotage(Local_u8SwitchFlag, Local_u16ADCValue, &Local_f32VoltageValue); ftoa(Local_u8Buffer, Local_f32VoltageValue, 2); //Local_f32VoltageValue = Local_u16ADCValue * ADC_STEP; // Local_u8IntVoltageValue = Local_f32VoltageValue; // itoa(Local_u8IntVoltageValue, Local_u8PotienoValue, 10); // LCD_u8Write_Command(0xC0); //go to Second line and --0 is for 0th position //dtostrf(value, width, precision, char array) LCD_u8Write_Command(0xC0); //go to Second line and --0 is for 0th position LCD_u8Write_String(Local_u8Buffer); LCD_u8Write_String(" "); // LCD_u8Write_String("."); // Local_f32VoltageValue = Local_f32VoltageValue - Local_u8IntVoltageValue; // Local_u8IntVoltageValue = 100 * Local_f32VoltageValue; // itoa(Local_u8IntVoltageValue, Local_u8PotienoValue, 10); // LCD_u8Write_String(Local_u8PotienoValue); } } return 0; }
int main (void) { u16 local_u8AdcRead=0 ,local_u8OldAdcRead=1 ; u8 local_u8AdcStr[2],local_u8CountStr[2]; u8 THR_COUNT= 0 , Old_THR_COUNT= 1 , THR_FLAG=0; DIO_voidInit(); ADC_voidInit(); CLC_voidInit(); ADC_voidEnable(); while(1) { TSEN_u8ReadTSensr(0,&local_u8AdcRead); if( local_u8AdcRead > (TSEN_u8THRSHOLD - TSEN_u8TOLERANCE) && THR_FLAG==0 ) { BUZ_voidBuzOn(); THR_COUNT++; THR_FLAG=1 ; if(THR_COUNT>100) THR_COUNT=0 ; } else if( local_u8AdcRead < (TSEN_u8THRSHOLD - TSEN_u8TOLERANCE) ) { BUZ_voidBuzOff(); THR_FLAG=0; } if(THR_COUNT != Old_THR_COUNT || local_u8AdcRead != local_u8OldAdcRead) { CLCD_u8WriteComand( CLC_u8CLRDISP); CLCD_u8WriteComand(CLC_u8STL); itoa(local_u8AdcRead,local_u8AdcStr,10); CLCD_u8WriteDataStr(local_u8AdcStr) ; CLCD_u8WriteComand(CLC_u8NEWL ); itoa(THR_COUNT,local_u8CountStr,10); CLCD_u8WriteDataStr(local_u8CountStr); local_u8OldAdcRead = local_u8AdcRead ; Old_THR_COUNT=THR_COUNT ; } } return 0; }
void main (void) { u8 x ; DIO_voidInit(); while(1) { DIO_u8WritePinVal(24,1); DIO_u8ReadPinVal(23,&x); if(x==1) DIO_u8WritePinVal(28,1); else if(x==0) DIO_u8WritePinVal(28,0); } }
int main (void){ DIO_voidInit(); SPI_voidInit(); SPI_voidEnable(); SPI_voidInterruptEnable(); SPI_voidSetISR(SPI_IRQHandelr); SPI_SlaveInit(); UART_voidInit(); UART_voidTxEnable(); while(1); return 0 ; }
void main () { DIO_voidInit(); CLC_voidInit(); TSW_voidinit() ; ADC_voidInit(); ADC_voidEnable(); while(1) { Read_sw(); } }
int main(void) { u8 Local_u8OutputCompareValue; u16 Local_u16ADCValue; u16 Local_u16ADCValueP; DIO_voidInit(); ADC_voidInit(); TIMER0_voidSetOCR(255); TIMER0_voidInit(); //TIMER0_CTC, TIMER0_COM1 //Enable_Global_INT(); // enable global interrupt while (1) { ADC_u8ReadChannel(ADC_u8CH0, &Local_u16ADCValue); if (Local_u16ADCValue != Local_u16ADCValueP) { Local_u8OutputCompareValue = (u8)(Local_u16ADCValue >> 2); TIMER0_voidSetOCR(Local_u8OutputCompareValue); Local_u16ADCValueP = Local_u16ADCValue; } }
int main (void){ DIO_voidInit(); TACTILE_voidInit(); LCD_VoidInit(); EEPROM_voidInit(); u8 Local_FirstCheck; EEPROM_u8ReadByte(FLAG_ADDRESS,&Local_FirstCheck); if(Local_FirstCheck==0xFF) { EEPROM_voidWriteByte(20,TEMP_ADDRESS); EEPROM_voidWriteByte(2,SPEED_ADDRESS); EEPROM_voidWriteByte(0,FLAG_ADDRESS); } //LCD_VoidString("sfs"); while (1){ app(); } return 0 ; }
int main(void) { u8 Local_u8KeypadReading = 0; u8 Local_u8MaxCounter = 0; u8 Local_u8Counter = 0; u8 Local_u8MotorDir = u8FORWARD; DIO_voidInit(); while (1) { // //Stepper_Stop(); Local_u8KeypadReading = Keypad_u8Read(); Local_u8MaxCounter = (320 / Local_u8KeypadReading); Local_u8Counter++; if (Local_u8Counter >= Local_u8MaxCounter) { // if (Local_u8KeypadReading == 13) { // Stepper_Stop(); // Local_u8Counter = 0; } // else if (Local_u8KeypadReading == 10) { // if (Local_u8MotorDir == u8FORWARD) { // Local_u8MotorDir = u8REVERSE; // Stepper_Speed(Local_u8MotorDir); // Local_u8Counter = 0; // } else if (Local_u8MotorDir == u8REVERSE) { // Local_u8MotorDir = u8FORWARD; // Stepper_Speed(Local_u8MotorDir); // Local_u8Counter = 0; // } // // } // else { // Stepper_Speed(Local_u8MotorDir); // Local_u8Counter = 0; // } // } // Stepper_Speed(Local_u8KeypadReading); //DELAY_voidDELAY(300); //Stepper_Reverse(); DIO_u8WritePortVal(2, Local_u8KeypadReading);} } return 0; }
void main(void) { DIO_voidInit(); App_voidInit(); while (1) { App_voidStepperSpeed(); //App_voidDotMotor(); //App_voidDisplayLetter(App_u8Stop); } return; }
void main(void) { u16 Local_u8ADCReading; u16 Local_u8LCDresult[5]; u8 Local_u8SW; u8 Local_u8ADCanalog; DIO_voidInit(); TACTILE_voidInit(); ADC_voidConfig(); ADC_voidEnable(); LCD_voidInit(); while (1) { ADC_voidReadSingleShot(&Local_u8ADCReading); DIO_u8ReadPinVal(DIO_u8PIN31, &Local_u8SW); Local_u8ADCanalog=((Local_u8ADCReading>>6)*(u16)5)/(u16)1024; switch (Local_u8SW) { case TACTILE_u8Pressed: DIO_u8WritePinVal(DIO_u8PIN27, 1); itoa(Local_u8ADCanalog+5, Local_u8LCDresult, 10); LCD_voidWriteString(Local_u8LCDresult); delay_ms(5); break; case TACTILE_u8Released: DIO_u8WritePinVal(DIO_u8PIN27, 0); itoa(Local_u8ADCanalog, Local_u8LCDresult, 10); LCD_voidWriteString(Local_u8LCDresult); delay_ms(5); break; } LCD_voidClearSceen(); } return; }
int main() { DIO_voidInit(); DIO_u8WritePortDir(LEDS,255); DIO_u8WritePortDir(DIO_u8PORT3,255); DIO_u8WritePortVal(DIO_u8PORT3,0); while(1) { DIO_voidBlink1(); DIO_voidBlink2(); DIO_voidBlink3(); DIO_voidBlink4(); DIO_voidBlink5(); DIO_voidBlink6(); DIO_voidBlink7(); DIO_voidBlink8(); DIO_voidBlink9(); } return 0; }
int main(void) { u8 Local_u8Row; u16 Local_u8Counter = 0; DIO_voidInit(); // For Testing, Turn on all Leds HC595_u8WriteByte(RAWS, DIO_u8PORTHIGH);/*All ROWS are ON*/ HC595_u8WriteByte(COLUMNS, DIO_u8PORTLOW); /*All Columns are Off*/ voidDELAY_MS(1000); // Delay 1 Sec // Turn off all Leds HC595_u8WriteByte(RAWS, DIO_u8PORTLOW); /*All ROWS are Off*/ HC595_u8WriteByte(COLUMNS, DIO_u8PORTLOW); /*All Columns are Off*/ voidDELAY_MS(1000); //Delay 1 Sec while (1) { for (Local_u8Row = 0; Local_u8Row < 8; Local_u8Row++) { HC595_u8WriteByte(RAWS, DIO_u8PORTLOW); //turn off all Rows HC595_u8WriteByte(COLUMNS, ~MyName[(Local_u8Counter/800)%6][Local_u8Row]); // assign the specific row's data to the corresponded columns HC595_u8WriteByte(RAWS, (1<<Local_u8Row)); //Turn on the specific Row } Local_u8Counter++; // increment the counter } return 0; }
int main(void) { DIO_voidInit(); TIMER0_VoidINIT(); TIMER0_CallbackSetup(led); Enable_Global_INT(); // *DIO_u8PORTA=0xff; TIMER0_Void_Delay_MS(90); while (1) { // *DIO_u8PORTA=0xff; if (flag1 == 1) { // DIO_u8WritePortVal(DIO_u8PORT0, flag); flag1 = 0; TIMER0_Void_Delay_MS(500); } } return 0; }
int main(void) { //u8 Local_u8SwitchValue; //To store the switch value u8 Local_u8KeypadValue = 0; //Counter to adjust the delay u8 Previous_Value = 0; DIO_voidInit(); KEYPAD_voidInit(); while (1) { KEYPAD_u8Read(&Local_u8KeypadValue); switch (Local_u8KeypadValue) { case 0: if(Previous_Value == 0) StepperOFF(); else StepperRunning(Previous_Value); break; //0 // case 1: // StepperRunning(Local_u8KeypadValue); // break; //1 // case 2: // StepperRunning(Local_u8KeypadValue); // break; //2 // case 3: // StepperRunning(Local_u8KeypadValue); // break; //3 // case 4: // StepperRunning(Local_u8KeypadValue); // break; //4 // case 5: // StepperRunning(Local_u8KeypadValue); // break; //5 // case 6: // StepperRunning(Local_u8KeypadValue); // break; //6 // case 7: // StepperRunning(Local_u8KeypadValue); // break; //7 // case 8: // StepperRunning(Local_u8KeypadValue); // break; //8 // case 9: // StepperRunning(Local_u8KeypadValue); // break; //9 // case 10: // StepperRunning(Local_u8KeypadValue); // break; //10 // case 11: // StepperRunning(Local_u8KeypadValue); // break; //11 // case 12: // StepperRunning(Local_u8KeypadValue); // break; //12 // case 13: // StepperRunning(Local_u8KeypadValue); // break; //13 // case 14: // StepperRunning(Local_u8KeypadValue); // break; //14 // case 15: // StepperRunning(Local_u8KeypadValue); // break; //15 case 16: StepperOFF(); Previous_Value = 0; break; //16 default: Previous_Value = Local_u8KeypadValue; StepperRunning(Local_u8KeypadValue); break; } } return 0; }
int main() { u8 local_u8state = STARTING_POINT; u8 local_u8SwitchRead; u16 local_u16Counter; u8 local_Direction_Flag = RIGHT; u16 local_stepper_counter = 0; u8 local_Display_Flag = DISPLAY_OFF; Keypad_u16Switches keypad; u8 local_u8Switch_Pressed_num = STOP_SWITCH_INDEX; u8 local_u8MotorPin1Val[2] = { DIO_u8HIGH, DIO_u8LOW }; u8 LOCAL_U8DirectionMATRIX[3][8] = { { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7C }, { 0x78, 0x44, 0x48, 0x70, 0x70, 0x48, 0x44, 0x42 }, { 0, 0, 0, 0, 0, 0, 0, 0 } }; /*Comment!:calling initialization functions */ DIO_voidInit(); TACTILE_SWITCH_voidInit(); KEYPAD_voidInit(); /*Comment!: use pull up resistors on portc*/ /*Comment!: this is against design rules but i had to use this way because there weren't pull up resistors on hardware*/ *DIO_u8PORTC = 0x0f; /*Comment!:shift register work at rising edge so sh,st must be low before writing to shift register */ DIO_u8WritePinVal(SH_CP, DIO_u8LOW); DIO_u8WritePinVal(ST_CP, DIO_u8LOW); while (1) { /*Comment!:Display at Dot Matrix */ for (u8 local_u8RowsLoopCounter = 0; local_u8RowsLoopCounter < 8; local_u8RowsLoopCounter++) { /*Comment!:active one row each time */ for (u8 local_u8RowIndex = 0; local_u8RowIndex < 8; local_u8RowIndex++) { /*Comment!:write bit to shift register */ if (local_u8RowIndex != local_u8RowsLoopCounter) { DIO_u8WritePinVal(DS, DIO_u8HIGH); } else { DIO_u8WritePinVal(DS, DIO_u8LOW); } DIO_u8WritePinVal(SH_CP, DIO_u8HIGH); DIO_u8WritePinVal(SH_CP, DIO_u8LOW); } /*Comment!:Write column */ for (u8 local_u8ColumnsLoopCounter = 0; local_u8ColumnsLoopCounter < 8; local_u8ColumnsLoopCounter++) { /*Comment!:write bit to shift register */ DIO_u8WritePinVal(DS, GET_BIT(LOCAL_U8DirectionMATRIX[local_Display_Flag][local_u8RowsLoopCounter], local_u8ColumnsLoopCounter)); DIO_u8WritePinVal(SH_CP, DIO_u8HIGH); DIO_u8WritePinVal(SH_CP, DIO_u8LOW); } /*Comment!:latch Rows and Columns to dot matrix */ DIO_u8WritePinVal(ST_CP, DIO_u8HIGH); DIO_u8WritePinVal(ST_CP, DIO_u8LOW); } /*comment!: end of displaying one column*/ /*Comment!:read Keypad*/ keypad = KEYPAD_Keypad_u16SwitchesRead(); /*Comment!:Check if switch pressed */ if (keypad.KEYPAD_u16Switches) { /*Comment!:get number of pressed switch */ local_u8Switch_Pressed_num = Stepper_16_Switch_Number(keypad.KEYPAD_u16Switches); } else { } if ((local_u8Switch_Pressed_num < local_stepper_counter) && local_u8Switch_Pressed_num != STOP_SWITCH_INDEX) { Stepper_voidRotate(); local_stepper_counter = 0; } else if (local_u8Switch_Pressed_num != STOP_SWITCH_INDEX) { local_stepper_counter++; } else { } /*Comment!:read switch */ TACTILE_SWITCH_u8Read(TACTILE_SWITCH_u8SWITCH1ID, &local_u8SwitchRead); switch (local_u8state) { case STARTING_POINT: if (local_u8SwitchRead == TACTILE_SWITCH_u8PRESSED) { /*Comment!:Rotate Motor */ DIO_u8WritePinVal(DIO_u8PIN8, local_u8MotorPin1Val[local_Direction_Flag]); DIO_u8WritePinVal(DIO_u8PIN9, !local_u8MotorPin1Val[local_Direction_Flag]); /*Comment!:Change State */ local_u8state = SWITCH_PRESSED; /*Comment!:Change direction at display */ local_Display_Flag = local_Direction_Flag; /*Comment!:Reset Time Counter */ local_u16Counter = 0; } else if (local_u8SwitchRead != TACTILE_SWITCH_u8PRESSED) { /*Comment!:Stop motor */ DIO_u8WritePinVal(DIO_u8PIN8, DIO_u8HIGH); DIO_u8WritePinVal(DIO_u8PIN9, DIO_u8HIGH); /*Comment!:Turn off dot matrix*/ local_Display_Flag = DISPLAY_OFF; } else { } break; case SWITCH_PRESSED: /*Comment!:increment counter that represents time */ local_u16Counter++; if (local_u8SwitchRead != TACTILE_SWITCH_u8PRESSED) { /*Comment!:Checking time */ if (local_u16Counter <= TIME_LIMIT) { /*Comment!:change state*/ local_u8state = CONTINOUS_MODE; } else { /*Comment!:Change direction*/ local_Direction_Flag = !local_Direction_Flag; /*Comment!:change state*/ local_u8state = STARTING_POINT; } } else { } break; case CONTINOUS_MODE: /*Comment!:Rotate Motor*/ DIO_u8WritePinVal(DIO_u8PIN8, local_u8MotorPin1Val[local_Direction_Flag]); DIO_u8WritePinVal(DIO_u8PIN9, !local_u8MotorPin1Val[local_Direction_Flag]); if (local_u8SwitchRead == TACTILE_SWITCH_u8PRESSED) { /*Comment!:stop motor*/ DIO_u8WritePinVal(DIO_u8PIN8, DIO_u8HIGH); DIO_u8WritePinVal(DIO_u8PIN9, DIO_u8HIGH); /*Comment!:change state*/ local_u8state = WAITING_FOR_SWITCH_RELEASE; } else { } break; case WAITING_FOR_SWITCH_RELEASE: /*Comment!:waiting for switch release*/ if (local_u8SwitchRead != TACTILE_SWITCH_u8PRESSED) { local_u8state = STARTING_POINT; } else { } break; default: break; } } return 0; }