Пример #1
0
void ScriptCtrl_Init(void)
{
	gScriptBuf.inLoop = Eeprom_Read(EEPROM_SCRIPTBUF_INLOOP);
	gScriptBuf.read = Eeprom_Read(EEPROM_SCRIPTBUF_READ);
	gScriptBuf.write = Eeprom_Read(EEPROM_SCRIPTBUF_WRITE);
	gScriptBuf.execute = gScriptBuf.read;
	gScriptBuf.isRunning = TRUE;
}
Пример #2
0
void AnalogIn_AutoSendInit( )
{
    int autosend;
    Eeprom_Read( EEPROM_ANALOGIN_AUTOSEND, (uchar*)&autosend, 4 );
    if( !((autosend >> 16) & 0xFF) == AUTOSENDSAVE )
        AnalogIn->autosend = AUTOSENDSAVE << 16;
    else
Пример #3
0
/**
	Read the board's name.
	@return The board's name as a string.
	
	\b Example
	\code
	char* board_name = System_GetName();
	\endcode
*/
char* System_GetName( )
{
  System_SetActive( 1 );
  if( System->name[0] == 0 )
  {
    char* ptr;
    ptr = System->name;
    int i;
    bool legal = false;
    for( i = 0; i <= SYSTEM_MAX_NAME; i++ )
    {
      Eeprom_Read( EEPROM_SYSTEM_NAME + i, (uchar*)ptr, 1 );
      if( *ptr == 0 )
        break;
      if( !isalnum( *ptr ) && *ptr != ' ' )
      {
        legal = false;
        break;
      }
      legal = true;
      
      if( i == SYSTEM_MAX_NAME && *ptr != 0 )
        *ptr = 0;
      ptr++;
    }

    if( !legal )
    {
      strcpy( System->name, "Make Controller Kit" );
      System_SetName( System->name );
    }
  }

  return System->name;
}
Пример #4
0
/**
	Gets the board's Serial Number.
	Each board has a serial number, although it's not necessarily unique
	as you can reset it as you please.
	
	The serial number is used to determine the Ethernet MAC address, so boards
	on the same network need to have unique serial numbers.
	@return CONTROLLER_OK ( = 0 ).
	
	\b Example
	\code
	// get this board's serial number
	int sernum = System_GetSerialNumber();
	\endcode
*/
int System_GetSerialNumber( void )
{
  int serial;
  if ( Eeprom_Read( EEPROM_SYSTEM_SERIAL_NUMBER, (uchar*)&serial, 4 ) == CONTROLLER_OK )
    return serial & 0xFFFF;
  return 0;
}
Пример #5
0
int System_GetAutoSendInterval( )
{
  System_SetActive( 1 );
  if( System->autoInterval == ASYNC_INIT )
  {
    int interval;
    Eeprom_Read( EEPROM_OSC_ASYNC_INTERVAL, (uchar*)&interval, 4 );
    if( interval >= 0 && interval <= 5000 )
      System->autoInterval = interval;
    else
      System->autoInterval = 10;
  }
  return System->autoInterval;
}
Пример #6
0
int System_GetAsyncDestination( )
{
  System_SetActive( 1 );
  if( System->asyncDestination == ASYNC_INIT )
  {
    int async;
    Eeprom_Read( EEPROM_OSC_ASYNC_DEST, (uchar*)&async, 4 );
    if( async >= 0 && async <= (OSC_CHANNEL_COUNT-1) )
      System->asyncDestination = async;
    else
      System->asyncDestination = ASYNC_INACTIVE;
  }
  return System->asyncDestination;
}
Пример #7
0
void main()
{
     b=1;
     trisb = 0b00001111;
     trisc = 0b10000000;
     portc = 0;
     ///////////// Store The Password(12345) //////////
     Eeprom_Write(0x00,1);
     Eeprom_Write(0x01,2);
     Eeprom_Write(0x02,3);
     Eeprom_Write(0x03,4);
     Eeprom_Write(0x04,5);
     //////////////////////////////////////////
     Lcd_Init(&portd);
S:   Lcd_Cmd(Lcd_Clear);
     Lcd_Out_Cp("Ent Pass:"******"*");
                            delay_ms(700);

                do{
                                    K = Key_Read();
                            }
                while(k==20);
               // Lcd_Out_Cp("*");
                if(k==10)

                {
    ////////////// Detection Process /////////////////////
                
                for(i = 0;i <= 4;i++)
                {
                  if(sum==0) sum = sum + (Eeprom_Read(i) - Eeprom_Read(i + 5));
                }

                if(sum == 0){ b=1;
                              Lcd_Out(2,1,"OPEN");

                              portc=1;

                              //do
                              //{
                              for(x=1000 ; x>2; x--)
                              {
                              delay_ms(10);
                              PORTC=PORTC<<1;
                              if (PORTc.F4) PORTC=1;
                              

                              }
                              delay_ms(5000);
                              for(x=1000; x>2; x--)
                              {
                              delay_ms(10);
                              PORTC=PORTC>>1;
                              if (PORTC==0) PORTc=8;
                               }
                               for(a=0;a<5;a++)
                               { Eeprom_Write(a+5,19);
                                }
                               goto S;

                            }
                else {
                        Lcd_Out(2,1,"ERORR");
                        b++;
                         delay_ms(500);
                       if(b==4){
                              while(1){delay_ms(500); Lcd_Out(2,1,"LOCKED"); }}
                        
                      } }   }