Esempio n. 1
0
uint8_t readBit() {
	uint8_t result;
	setdirection(TDATA, 1);
	setpin(TDATA,0);
	_delay_us(6);
	setpin(TDATA,1);
	_delay_us(9);
	setdirection(TDATA, 0);
	result = TPIN & (1 << TDATA);
	_delay_us(55);
	return result;
}
Esempio n. 2
0
void writeBit(uint8_t bit) {
	setdirection(TDATA, 1);
	if (bit) {
		setpin(TDATA, 0);
		_delay_us(6);
		setpin(TDATA, 1);
		_delay_us(64);
	} else {
		setpin(TDATA, 0);
		_delay_us(60);
		setpin(TDATA, 1);
		_delay_us(10);
	}
}
Esempio n. 3
0
uint8_t resetSensor() {
	uint8_t result;
	//_delay_ms(2000);
	setdirection(TDATA, 1); //PB1 output
	setpin(TDATA, 1); //PB1 high VDD init
	_delay_ms(100);
	setpin(TDATA, 0);
	_delay_us(490);
	setdirection(TDATA, 0);
	_delay_us(70);
	result = (TPIN & (1 << TDATA));
	_delay_us(410);
	return result;
}
Esempio n. 4
0
/*******************************************************************************
*  ??????                                                                *
*******************************************************************************/
void main()
{

    char individual=255;
     setpin();
     init_comms();
     individual=E2promRead(0x00);
     OPTION_REG = 0b0000010 ; // ??????(Fosc/4)?TIMER0???????????????? 1:128
     TMR0   = T0COUT ;         // ????0????
     TMR0IF = 0 ;              // ????0?????(T0IF)?0???
     time   = 0 ;              // ??????????????0???
     TMR0IE = 1 ;              // ????0???(T0IE)?????
     WPUB = 0xC0;
     nWPUEN = 0;
     GIE    = 0 ;              // ???????????
//     while(individual==getch()){
//         putch(individual);
//         __delay_ms(100);
//     }
     uartget();
     while(1)
     {
         while(RD4==0);
         change();
         while(RD4==1);
         change();
     }

    PORTA=0xFF;
    PORTB=0xFF;
    PORTC=0xFF;
    PORTD=0xFF; 
    PORTE=0xFF;
        RA7=0;
        RA6=0;
        RC0=0;
        RC1=0;
        RC2=0;
        RC3=0;
        RD0=0;
        RD1=0;
        i=1;0;
        RD6=1;
     while(1){
         while(RD4==0);
         if(RD5==1)
             i=8;
         //__delay_ms(500);
         switch(i){
            case 1:RA7=1;break;
            case 2:RA6=1;break;
            case 3:RC0=1;break;
            case 4:RC1=1;break;
            case 5:RC2=1;break;
            case 6:RC3=1;break;
            case 7:RD0=1;break;
            case 8:RD1=1;i=0;break;
         }
         //__delay_ms(500);
         while(RD4==1);

        RA7=0;
        RA6=0;
        RC0=0;
        RC1=0;
        RC2=0;
        RC3=0;
        RD0=0;
        RD1=0;
        PORTC=0b11110000;
        PORTA=0b00111111;
        PORTD=0b11111100;

         i++;
    }
}
Esempio n. 5
0
void main()
{
     char i,j,n,test[8][4],individual=255;
     char getdata[70]={0},getKeeping[16][2],getNum=0,onetime=0,resetFlug=0,gettingSuccess=0;
     setpin();
     while(1){
         RD6=1;
         getch();
         RD6=0;
         __delay_ms(100);
     }
     init_comms();
     individual=E2promRead(0x00);
     for(i=0;i<16;i++)
      putdata[i][1]=x2(i);
     OPTION_REG = 0b0000100 ; // ??????(Fosc/4)?TIMER0???????????????? 1:128
     TMR0   = T0COUT ;         // ????0????
     TMR0IF = 0 ;              // ????0?????(T0IF)?0???
     time   = 0 ;              // ??????????????0???
     TMR0IE = 1 ;              // ????0???(T0IE)?????
     WPUB = 0xC0;
     nWPUEN = 0;
     
     
     
     
     GIE    = 1 ;
     while(1) {
         // 0x 47 65 74 ="Get"
         if(getNum>69)
             getNum=0;
         else if(reservingNow){
             onetime=getch();
             getdata[getNum]=onetime;
             getNum++;
             reservingNow=0;
         }
         if(onetime==0x47)
             resetFlug=1;
         else if(resetFlug){
             if(resetFlug==1){
                 if(onetime==0x65)
                     resetFlug==2;
                 else
                     resetFlug=0;
             }
             else if(resetFlug==2){
                 if(onetime=0x74)
                     getNum=0;
                 else
                     resetFlug=0;
             }
         }
         if(getNum==64){
             if(onetime==0x0A)
                 gettingSuccess=1;
         }
         else if(gettingSuccess==1){
             if(onetime==0x0B)
                 gettingSuccess=2;
             else
                 gettingSuccess=0;
         }
         if(gettingSuccess==2){
             gettingSuccess=0;
             for(i=1;i<17;i++){
                 for(j=0;j<2;j++){
                     n=(i-1)*4+j;
                     getKeeping[i][j]=getdata[n];
                 }
             }
             for(i=1;i<17;i++){
                 //A
                 putdata[i][0]=getKeeping[i][0]&0b11111110;
                 //C
                 putdata[i][2]=getKeeping[i][1]&0b00001111;
                 //D
                 putdata[i][3]=(getKeeping[i][0]&0b00000001)|((getKeeping[i][1]&0b10000000)>>6);
                 if(i==16)
                     putdata[i][3]=putdata[i][3]|0b10110000;
                 else if(i%2==0)
                     putdata[i][3]=putdata[i][3]|0b10010000;
                 //E
                 putdata[i][4]=(getKeeping[i][1]&0b01110000)>>4;
             }
         }
     }