Ejemplo n.º 1
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);

}
    	    }

}
Ejemplo n.º 2
0
int main(void) {
	__asm__("SEI");
	MCUCR |= (1<<0);//make it on change
	GICR |= (1<<6); // PIE for INT0

	DIO_u8WritePinDir(26,DIO_u8INPUT);
	DIO_u8WritePinDir(8,DIO_u8OUTPUT);
	DIO_u8WritePinDir(9,DIO_u8OUTPUT);

	while (1) {
		DIO_u8WritePinVal(8,LEDFlag);
		DIO_u8WritePinVal(9,DIO_u8HIGH);
		voidDELAY_MS(1000);
		DIO_u8WritePinVal(9,DIO_u8LOW);
		voidDELAY_MS(1000);
	}
	return 0;
}
Ejemplo n.º 3
0
extern void Init_interrupt (void)
{

	/************************Enable global interrupt******************************/
			__asm__("SEI");

		//	ClrBit(GICR,6); // disable int0
		//	ClrBit(GICR,7); // disable int1
		//	ClrBit(GICR,5); // disable int2
	/************************Set Int0,int1 on change *****************************/

			INT0_REQUEST   // int0 on change
			INT1_REQUEST	//int 1 on change
			INT2_REQUEST	// int2 on rising
	/*************************Set interrupt pins as input ************************/

			DIO_u8WritePinDir(INT0_pin,DIO_u8INPUT);
			DIO_u8WritePinDir(INT1_pin,DIO_u8INPUT);
			DIO_u8WritePinDir(INT2_pin,DIO_u8INPUT); // need to know pin int2


}
Ejemplo n.º 4
0
extern void SSD_voidInit(void) {

	/*Comment!:if there is at least one display initialize it*/
#if (SSD_u8DISPCOUNT>=1) && (SSD_u8DISPCOUNT<=6)
	/*Comment!:set segment bins as output*/
	DIO_u8WritePinDir(SSD_u8DISP1_SEGA, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP1_SEGB, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP1_SEGC, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP1_SEGD, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP1_SEGE, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP1_SEGF, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP1_SEGG, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP1_INITCOM, DIO_u8OUTPUT);

	/*Comment!:set 7 segments initial value */
	DIO_u8WritePinVal(SSD_u8DISP1_SEGA,
			SSD_u8Numbers_Array[SSD_u8DISP1TYPE][SSD_u8DISP1_INITVAL][SSD_u8SEGA]);
	DIO_u8WritePinVal(SSD_u8DISP1_SEGB,
			SSD_u8Numbers_Array[SSD_u8DISP1TYPE][SSD_u8DISP1_INITVAL][SSD_u8SEGB]);
	DIO_u8WritePinVal(SSD_u8DISP1_SEGC,
			SSD_u8Numbers_Array[SSD_u8DISP1TYPE][SSD_u8DISP1_INITVAL][SSD_u8SEGC]);
	DIO_u8WritePinVal(SSD_u8DISP1_SEGD,
			SSD_u8Numbers_Array[SSD_u8DISP1TYPE][SSD_u8DISP1_INITVAL][SSD_u8SEGD]);
	DIO_u8WritePinVal(SSD_u8DISP1_SEGE,
			SSD_u8Numbers_Array[SSD_u8DISP1TYPE][SSD_u8DISP1_INITVAL][SSD_u8SEGE]);
	DIO_u8WritePinVal(SSD_u8DISP1_SEGF,
			SSD_u8Numbers_Array[SSD_u8DISP1TYPE][SSD_u8DISP1_INITVAL][SSD_u8SEGF]);
	DIO_u8WritePinVal(SSD_u8DISP1_SEGG,
			SSD_u8Numbers_Array[SSD_u8DISP1TYPE][SSD_u8DISP1_INITVAL][SSD_u8SEGG]);
	DIO_u8WritePinVal(SSD_u8DISP1_INITCOM,
			SSD_u8Control_Signals_Array[SSD_u8DISP1]);
#endif

	/*Comment!:if there is at least two displays initialize them*/
#if (SSD_u8DISPCOUNT>=2) && (SSD_u8DISPCOUNT<=6)
	/*Comment!:set segment bins as output*/
	DIO_u8WritePinDir(SSD_u8DISP2_SEGA, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP2_SEGB, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP2_SEGC, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP2_SEGD, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP2_SEGE, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP2_SEGF, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP2_SEGG, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP2_INITCOM, DIO_u8OUTPUT);
	/*Comment!:set 7 segments initial value */
	DIO_u8WritePinVal(SSD_u8DISP2_SEGA,
			SSD_u8Numbers_Array[SSD_u8DISP2TYPE][SSD_u8DISP2_INITVAL][SSD_u8SEGA]);
	DIO_u8WritePinVal(SSD_u8DISP2_SEGB,
			SSD_u8Numbers_Array[SSD_u8DISP2TYPE][SSD_u8DISP2_INITVAL][SSD_u8SEGB]);
	DIO_u8WritePinVal(SSD_u8DISP2_SEGC,
			SSD_u8Numbers_Array[SSD_u8DISP2TYPE][SSD_u8DISP2_INITVAL][SSD_u8SEGC]);
	DIO_u8WritePinVal(SSD_u8DISP2_SEGD,
			SSD_u8Numbers_Array[SSD_u8DISP2TYPE][SSD_u8DISP2_INITVAL][SSD_u8SEGD]);
	DIO_u8WritePinVal(SSD_u8DISP2_SEGE,
			SSD_u8Numbers_Array[SSD_u8DISP2TYPE][SSD_u8DISP2_INITVAL][SSD_u8SEGE]);
	DIO_u8WritePinVal(SSD_u8DISP2_SEGF,
			SSD_u8Numbers_Array[SSD_u8DISP2TYPE][SSD_u8DISP2_INITVAL][SSD_u8SEGF]);
	DIO_u8WritePinVal(SSD_u8DISP2_SEGG,
			SSD_u8Numbers_Array[SSD_u8DISP2TYPE][SSD_u8DISP2_INITVAL][SSD_u8SEGG]);
	DIO_u8WritePinVal(SSD_u8DISP2_INITCOM,
			SSD_u8Control_Signals_Array[SSD_u8DISP2]);
#endif

	/*Comment!:if there is at least three displays initialize them*/
#if (SSD_u8DISPCOUNT>=3) && (SSD_u8DISPCOUNT<=6)
	/*Comment!:set segment bins as output*/
	DIO_u8WritePinDir(SSD_u8DISP3_SEGA, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP3_SEGB, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP3_SEGC, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP3_SEGD, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP3_SEGE, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP3_SEGF, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP3_SEGG, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP3_INITCOM, DIO_u8OUTPUT);
	/*Comment!:set 7 segments initial value */
	DIO_u8WritePinVal(SSD_u8DISP3_SEGA,
			SSD_u8Numbers_Array[SSD_u8DISP3TYPE][SSD_u8DISP3_INITVAL][SSD_u8SEGA]);
	DIO_u8WritePinVal(SSD_u8DISP3_SEGB,
			SSD_u8Numbers_Array[SSD_u8DISP3TYPE][SSD_u8DISP3_INITVAL][SSD_u8SEGB]);
	DIO_u8WritePinVal(SSD_u8DISP3_SEGC,
			SSD_u8Numbers_Array[SSD_u8DISP3TYPE][SSD_u8DISP3_INITVAL][SSD_u8SEGC]);
	DIO_u8WritePinVal(SSD_u8DISP3_SEGD,
			SSD_u8Numbers_Array[SSD_u8DISP3TYPE][SSD_u8DISP3_INITVAL][SSD_u8SEGD]);
	DIO_u8WritePinVal(SSD_u8DISP3_SEGE,
			SSD_u8Numbers_Array[SSD_u8DISP3TYPE][SSD_u8DISP3_INITVAL][SSD_u8SEGE]);
	DIO_u8WritePinVal(SSD_u8DISP3_SEGF,
			SSD_u8Numbers_Array[SSD_u8DISP3TYPE][SSD_u8DISP3_INITVAL][SSD_u8SEGF]);
	DIO_u8WritePinVal(SSD_u8DISP3_SEGG,
			SSD_u8Numbers_Array[SSD_u8DISP3TYPE][SSD_u8DISP3_INITVAL][SSD_u8SEGG]);
	DIO_u8WritePinVal(SSD_u8DISP3_INITCOM,
			SSD_u8Control_Signals_Array[SSD_u8DISP3]);
#endif

	/*Comment!:if there is at least one display initialize it*/
#if (SSD_u8DISPCOUNT>=4) && (SSD_u8DISPCOUNT<=6)
	/*Comment!:set segment bins as output*/
	DIO_u8WritePinDir(SSD_u8DISP4_SEGA, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP4_SEGB, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP4_SEGC, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP4_SEGD, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP4_SEGE, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP4_SEGF, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP4_SEGG, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP4_INITCOM, DIO_u8OUTPUT);
	/*Comment!:set 7 segments initial value */
	DIO_u8WritePinVal(SSD_u8DISP4_SEGA,
			SSD_u8Numbers_Array[SSD_u8DISP4TYPE][SSD_u8DISP4_INITVAL][SSD_u8SEGA]);
	DIO_u8WritePinVal(SSD_u8DISP4_SEGB,
			SSD_u8Numbers_Array[SSD_u8DISP4TYPE][SSD_u8DISP4_INITVAL][SSD_u8SEGB]);
	DIO_u8WritePinVal(SSD_u8DISP4_SEGC,
			SSD_u8Numbers_Array[SSD_u8DISP4TYPE][SSD_u8DISP4_INITVAL][SSD_u8SEGC]);
	DIO_u8WritePinVal(SSD_u8DISP4_SEGD,
			SSD_u8Numbers_Array[SSD_u8DISP4TYPE][SSD_u8DISP4_INITVAL][SSD_u8SEGD]);
	DIO_u8WritePinVal(SSD_u8DISP4_SEGE,
			SSD_u8Numbers_Array[SSD_u8DISP4TYPE][SSD_u8DISP4_INITVAL][SSD_u8SEGE]);
	DIO_u8WritePinVal(SSD_u8DISP4_SEGF,
			SSD_u8Numbers_Array[SSD_u8DISP4TYPE][SSD_u8DISP4_INITVAL][SSD_u8SEGF]);
	DIO_u8WritePinVal(SSD_u8DISP4_SEGG,
			SSD_u8Numbers_Array[SSD_u8DISP4TYPE][SSD_u8DISP4_INITVAL][SSD_u8SEGG]);
	DIO_u8WritePinVal(SSD_u8DISP4_INITCOM,
			SSD_u8Control_Signals_Array[SSD_u8DISP4]);
#endif

	/*Comment!:if there is at least one display initialize it*/
#if (SSD_u8DISPCOUNT>=5) && (SSD_u8DISPCOUNT<=6)
	/*Comment!:set segment bins as output*/
	DIO_u8WritePinDir(SSD_u8DISP5_SEGA, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP5_SEGB, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP5_SEGC, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP5_SEGD, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP5_SEGE, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP5_SEGF, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP5_SEGG, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP5_INITCOM, DIO_u8OUTPUT);
	/*Comment!:set 7 segments initial value */
	DIO_u8WritePinVal(SSD_u8DISP5_SEGA,
			SSD_u8Numbers_Array[SSD_u8DISP5TYPE][SSD_u8DISP5_INITVAL][SSD_u8SEGA]);
	DIO_u8WritePinVal(SSD_u8DISP5_SEGB,
			SSD_u8Numbers_Array[SSD_u8DISP5TYPE][SSD_u8DISP5_INITVAL][SSD_u8SEGB]);
	DIO_u8WritePinVal(SSD_u8DISP5_SEGC,
			SSD_u8Numbers_Array[SSD_u8DISP5TYPE][SSD_u8DISP5_INITVAL][SSD_u8SEGC]);
	DIO_u8WritePinVal(SSD_u8DISP5_SEGD,
			SSD_u8Numbers_Array[SSD_u8DISP5TYPE][SSD_u8DISP5_INITVAL][SSD_u8SEGD]);
	DIO_u8WritePinVal(SSD_u8DISP5_SEGE,
			SSD_u8Numbers_Array[SSD_u8DISP5TYPE][SSD_u8DISP5_INITVAL][SSD_u8SEGE]);
	DIO_u8WritePinVal(SSD_u8DISP5_SEGF,
			SSD_u8Numbers_Array[SSD_u8DISP5TYPE][SSD_u8DISP5_INITVAL][SSD_u8SEGF]);
	DIO_u8WritePinVal(SSD_u8DISP5_SEGG,
			SSD_u8Numbers_Array[SSD_u8DISP5TYPE][SSD_u8DISP5_INITVAL][SSD_u8SEGG]);
	DIO_u8WritePinVal(SSD_u8DISP5_INITCOM,
			SSD_u8Control_Signals_Array[SSD_u8DISP5]);
#endif

	/*Comment!:if there is at least one display initialize it*/
#if SSD_u8DISPCOUNT==6
	/*Comment!:set segment bins as output*/
	DIO_u8WritePinDir(SSD_u8DISP6_SEGA, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP6_SEGB, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP6_SEGC, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP6_SEGD, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP6_SEGE, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP6_SEGF, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP6_SEGG, DIO_u8OUTPUT);
	DIO_u8WritePinDir(SSD_u8DISP6_INITCOM, DIO_u8OUTPUT);
	/*Comment!:set 7 segments initial value */
	DIO_u8WritePinVal(SSD_u8DISP6_SEGA,
			SSD_u8Numbers_Array[SSD_u8DISP6TYPE][SSD_u8DISP6_INITVAL][SSD_u8SEGA]);
	DIO_u8WritePinVal(SSD_u8DISP6_SEGB,
			SSD_u8Numbers_Array[SSD_u8DISP6TYPE][SSD_u8DISP6_INITVAL][SSD_u8SEGB]);
	DIO_u8WritePinVal(SSD_u8DISP6_SEGC,
			SSD_u8Numbers_Array[SSD_u8DISP6TYPE][SSD_u8DISP6_INITVAL][SSD_u8SEGC]);
	DIO_u8WritePinVal(SSD_u8DISP6_SEGD,
			SSD_u8Numbers_Array[SSD_u8DISP6TYPE][SSD_u8DISP6_INITVAL][SSD_u8SEGD]);
	DIO_u8WritePinVal(SSD_u8DISP6_SEGE,
			SSD_u8Numbers_Array[SSD_u8DISP6TYPE][SSD_u8DISP6_INITVAL][SSD_u8SEGE]);
	DIO_u8WritePinVal(SSD_u8DISP6_SEGF,
			SSD_u8Numbers_Array[SSD_u8DISP6TYPE][SSD_u8DISP6_INITVAL][SSD_u8SEGF]);
	DIO_u8WritePinVal(SSD_u8DISP6_SEGG,
			SSD_u8Numbers_Array[SSD_u8DISP6TYPE][SSD_u8DISP6_INITVAL][SSD_u8SEGG]);
	DIO_u8WritePinVal(SSD_u8DISP6_INITCOM,
			SSD_u8Control_Signals_Array[SSD_u8DISP6]);
#endif

}
Ejemplo n.º 5
0
void LCD_WaitLcd(void)
{
	u8 Local_u8ValBusyFlag;
	#if (LCD_u8LcdMode == LCD_u8Bit4)

	DIO_u8WritePinDir(LCD_u8D0,DIO_u8INPUT);//lcdd7=i/p .
	DIO_u8WritePinDir(LCD_u8D1,DIO_u8INPUT);//lazm el 4 yb2o i/p 3shan ama b2lb enable mn high l low bib3t lcd btb3t high
	DIO_u8WritePinDir(LCD_u8D2,DIO_u8INPUT);//lazm el 4 yb2o i/p 3shan ama b2lb enable mn high l low bib3t lcd btb3t high
	DIO_u8WritePinDir(LCD_u8D3,DIO_u8INPUT);//lazm el 4 yb2o i/p 3shan ama b2lb enable mn high l low bib3t lcd btb3t high
	DIO_u8WritePinVal(LCD_u8ReadWrite,DIO_u8HIGH);//rw=1.
	#elif (LCD_u8LcdMode == LCD_u8Bit8)
	DIO_u8WritePinDir(LCD_u8D0,DIO_u8INPUT);
	DIO_u8WritePinDir(LCD_u8D1,DIO_u8INPUT);
	DIO_u8WritePinDir(LCD_u8D2,DIO_u8INPUT);
	DIO_u8WritePinDir(LCD_u8D3,DIO_u8INPUT);
	DIO_u8WritePinDir(LCD_u8D4,DIO_u8INPUT);
	DIO_u8WritePinDir(LCD_u8D5,DIO_u8INPUT);
	DIO_u8WritePinDir(LCD_u8D6,DIO_u8INPUT);
	DIO_u8WritePinDir(LCD_u8D7,DIO_u8INPUT);
	DIO_u8WritePinVal(LCD_u8ReadWrite,DIO_u8HIGH);//rw=1.
	#endif
	DIO_u8WritePinVal(LCD_u8Reset,DIO_u8LOW);//rs=0.
	do
	{
		Local_u8ValBusyFlag=0;
		DIO_u8WritePinVal(LCD_u8Enable,DIO_u8HIGH);//Enable=1.
		Delay_ms_Max1s(1);
		#if (LCD_u8LcdMode == LCD_u8Bit4)
		DIO_u8ReadPinVal(LCD_u8D3,&Local_u8ValBusyFlag );
		#elif (LCD_u8LcdMode == LCD_u8Bit8)
		DIO_u8ReadPinVal(LCD_u8D7,&Local_u8ValBusyFlag );
		#endif
		Delay_ms_Max1s(1);
		DIO_u8WritePinVal(LCD_u8Enable,DIO_u8LOW);//e=0.
		Delay_ms_Max1s(1);

		DIO_u8WritePinVal(LCD_u8Enable,DIO_u8HIGH);//e=1
		Delay_ms_Max1s(1);
	}while(Local_u8ValBusyFlag == LCD_u8Busy);
	DIO_u8WritePinVal(LCD_u8ReadWrite,DIO_u8LOW);//rw=0.

	#if (LCD_u8LcdMode == LCD_u8Bit4)
	DIO_u8WritePinDir(LCD_u8D0,DIO_u8OUTPUT);
	DIO_u8WritePinDir(LCD_u8D1,DIO_u8OUTPUT);
	DIO_u8WritePinDir(LCD_u8D2,DIO_u8OUTPUT);
	DIO_u8WritePinDir(LCD_u8D3,DIO_u8OUTPUT);
	Delay_ms_Max1s(1);
	#elif (LCD_u8LcdMode == LCD_u8Bit8)
	DIO_u8WritePinDir(LCD_u8D0,DIO_u8OUTPUT);
	DIO_u8WritePinDir(LCD_u8D1,DIO_u8OUTPUT);
	DIO_u8WritePinDir(LCD_u8D2,DIO_u8OUTPUT);
	DIO_u8WritePinDir(LCD_u8D3,DIO_u8OUTPUT);
	DIO_u8WritePinDir(LCD_u8D4,DIO_u8OUTPUT);
	DIO_u8WritePinDir(LCD_u8D5,DIO_u8OUTPUT);
	DIO_u8WritePinDir(LCD_u8D6,DIO_u8OUTPUT);
	DIO_u8WritePinDir(LCD_u8D7,DIO_u8OUTPUT);
	#endif
}