void main(void)
{

// Step 1. Initialize System Control registers, PLL, WatchDog, 
// peripheral Clocks to default state:
// This function is found in the DSP281x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO: 
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example  

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts 
   DINT;

// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.  
// This function is found in the DSP281x_PieCtrl.c file.
   InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt 
// Service Routines (ISR).  
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
   InitPieVectTable();
   
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
// InitPeripherals(); // Not required for this example

// Step 5. User specific code 

   // Tests #1, #2, #3
   Gpio_PortA();
    
   // Test #4
   Gpio_PortB();
    
   // Test #5
   Gpio_PortF();

   program_stop();
    
// Step 6. IDLE loop. Just sit and loop forever (optional):    
//    for(;;);
     
}
Beispiel #2
0
//Chuong trinh Open Semi------------------------------------------------------//
Void program_Open_Semi(){
   int8 vitri;
   boolean exit,temp_close;
   Open_temp = true;
   keyCode = 0;
   exit = 1;
   temp_close = false;
   denbao = 0x08;
   quangbao();
   xoadong(2);
   lcd_putc("OPEN SEMI <--");
   while(program_emergency() && program_stop() && exit){
      if(Close == 0){exit = false; temp_close = true;}
      vitri = kiemtra_vitri();
      if(vitri == 6) {
         D0 = 0;
         D2 = 0;
         D4 = 0;
         xuat_E0();
         xoadong(2);
         lcd_putc("   STOP OPEN DOOR   ");
         exit = false;
      } else if(vitri >=3) {
         D0 = 1;
         D2 = 1;
         D4 = 1;
         xuat_E0();
         xoadong(2);
         lcd_putc("   DANG MO CUA <--  ");
      } else {
         D0 = 0;
         D2 = 0;
         D4 = 0;
         xuat_E0();
         exit = 0;
         xoadong(2);
         lcd_putc("    DA MO CUA...    ");
      }
   }
    if(temp_close == true){
         xoadong(2);
         lcd_putc(" DANG DUNG THAO TAC");
         D0 = 0;
         D2 = 0;
         D3 = 0;
         D4 = 1;
         xuat_E0();
         delay_ms(3000);
         keycode = 3;
    }  
    Open_temp = false;
    bit_clear(denbao,4);
    quangbao();
}
Beispiel #3
0
//Chuong trinh Open Slide-----------------------------------------------------//
void program_Open_Slide()
{
   boolean exit;
   Slide_Open_temp = true;//Bien trung gian bao dang OPen Slide
   exit = 1;
   xoadong(2);
   lcd_putc("  DANG MO SLIDE...");
   denbao = 0x10;
   quangbao();
   if(SW_Close_Slide == 1 && SW_Open_Slide == 1) 
   {
      xoadong(2);
      lcd_putc("     DA MO SLIDE    ");
      exit = 0;
   }
   while(program_emergency() && program_stop() && exit){
      D6 = 1;
      xuat_E0();
      if(SW_Open_Slide==1)
      {
         D6 = 0;
         xuat_E0();
         if(SW_Close_Slide ==1) 
         {
            xoadong(2);
            lcd_putc("    SLIDE DA MO");
         } else {
            xoadong(1);
            lcd_putc("HONG SW CLOSE SLIDE");
            xoadong(2);
            lcd_putc("   DUNG THAO TAC   ");
            speak();//Bao dong bang coi.
            error_open_slide = true;
         }
         exit = 0;
      }
   }
   bit_clear(denbao,4);
   Slide_Open_temp = false; // Khai bao het Open Slide
   quangbao();
}
Beispiel #4
0
//Chuong trinh Close Slide----------------------------------------------------//
void program_Close_Slide()
{
   boolean exit;
   Slide_Close_temp = true; //Khai bao dang Close Slide
   exit = 1;
   denbao =  0x20;
   quangbao();
   xoadong(2);
   lcd_putc(" DANG DONG SLIDE...");
   if(kiemtra_vitri() != 0) 
   {
      xoadong(2);
      lcd_putc("   LOI DONG SLIDE   ");
      exit = 0;
   }
   while(program_emergency() && program_stop() && exit){
      D5 = 1;
      xuat_E0();
      if(SW_Close_Slide==0)
      {
         D5 = 0;
         xuat_E0();
         if(SW_Open_Slide ==0) 
         {
            xoadong(2);
            lcd_putc("   SLIDE DA DONG    ");
         } else {
            xoadong(1);
            lcd_putc("ERROR SW OPEN SLIDE");
            xoadong(2);
            lcd_putc("   DUNG THAO TAC   ");
            speak();//Bao dong bang coi.
            error_close_slide = true;
         }
         exit = 0;
      }
   }
   bit_clear(denbao,5);
   quangbao();
   Slide_Close_temp = false; //Khai bao het Close Slide.
}
Beispiel #5
0
//Chuong trinh dong cua-------------------------------------------------------//
void program_Close()
{
   int8 vitri;
   boolean exit,temp_open;
   Close_temp = true;
   error_open_slide = false;//Khoi phuc lai trang thai de kiem tra  da sua SW chua.
   keyCode = 0;
   exit = 1;
   temp_open = false;
   xoadong(2);
   lcd_putc("    DONG CUA -->");
   program_Open_Slide();
   denbao = 0x02;
   quangbao();
   if(error_open_slide) exit =0;
   delay_ms(10);
   while(program_emergency() && program_stop() && exit){
            vitri = kiemtra_vitri();
            if(Open == 0){exit = false; temp_open = true;}
            if(vitri == 6) {
               D1 = 0;
               D2 = 0;
               D3 = 0;
               D4 = 0;
               xuat_E0();
               exit = 0;  
               speak();//Bao dong bang coi.
               xoadong(2);
               lcd_putc("  STOP CLOSE DOOR");
            } else if(vitri <= 3) {
               D1 = 1;
               D2 = 1;
               D3 = 0;
               D4 = 1;
               xuat_E0();
               xoadong(2);
               lcd_putc(" CLOSE DOOR H SPEED");
            } else if(vitri == 4) {
               D1 = 1;
               D2 = 0;
               D3 = 1;
               D4 = 1;
               xuat_E0();
               xoadong(2);
               lcd_putc(" CLOSE DOOR S SPEED");
            } else {
               D1 = 0;
               D2 = 0;
               D3 = 0;
               D4 = 0;
               xuat_E0();
               exit = 0;
               xoadong(2);
               lcd_putc("  CUA DA DUOC DONG");
            }
    }
    if(temp_open == true){
         xoadong(2);
         lcd_putc(" DANG DUNG THAO TAC");
         D1 = 0;
         D2 = 0;
         D3 = 0;
         D4 = 1;
         xuat_E0();
         delay_ms(3000);
         keyCode = 4;
    }
    Close_temp = false;
    bit_clear(denbao,1);
    quangbao();
}
Beispiel #6
0
//Chuong trinh mo cua---------------------------------------------------------//
void program_Open()
{
   int8 vitri;
   boolean exit,temp_close;
   Open_temp = true;
   denbao = 0x01;
   quangbao();
   error_close_slide = false;//Khoi phuc lai trang thai ban dau de kiem tra xem da sua loi chua.
   keyCode = 0;
   exit = 1;
   temp_close = false;
   xoadong(2);
   lcd_putc("     MO CUA <--     ");
   while(program_emergency() && program_stop() && exit){
         if(Close == 0){exit = false; temp_close = true;}
         vitri = kiemtra_vitri();
         if(vitri == 6) {
            D0 = 0;
            D2 = 0;
            D3 = 0;
            D4 = 0;
            xuat_E0();
            exit = 0;  
            speak();//Bao dong bang coi.
            xoadong(2);
            lcd_putc("   STOP OPEN DOOR   ");
         } else if(vitri >= 2) {
            D0 = 1;
            D2 = 1;
            D3 = 0;
            D4 = 1;
            xuat_E0();
            xoadong(2);
            lcd_putc(" OPEN DOOR H SPEED");
         } else if(vitri == 1) {
            D0 = 1;
            D2 = 0;
            D3 = 1;
            D4 = 1;
            xuat_E0();
            xoadong(2);
            lcd_putc(" OPEN DOOR S SPEED");
         } else {
            D0 = 0;
            D2 = 0;
            D3 = 0;
            D4 = 0;
            xuat_E0();
            exit = 0;
            bit_clear(denbao,0);
            //quangbao();
            delay_ms(10);
            program_Close_Slide();
            if (!error_close_slide){
               xoadong(2);
               lcd_putc("   CUA DA DUOC MO");
            }
         }
    }
     if(temp_close == true){
         xoadong(2);
         lcd_putc(" DANG DUNG THAO TAC");
         D0 = 0;
         D2 = 0;
         D3 = 0;
         D4 = 0;
         xuat_E0();
         delay_ms(3000);
         keycode = 3;
    }
    Open_temp = false;
    bit_clear(denbao,0);
    quangbao();
}