⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.lst

📁 lcd interface code for lpc214x series micro controllers
💻 LST
📖 第 1 页 / 共 2 页
字号:
  206          extern int  putchar_0 (int ch);              /* Write character to Serial Port  */
  207          extern int  getchar_0 (void);                /* Read character from Serial Port */
  208          
  209          
  210          void puthex_1 (int hex) {                    /* Write Hex Digit to Serial Port  */
  211   1        if (hex > 9) putchar_1('A' + (hex - 10));
  212   1        else         putchar_1('0' +  hex);
  213   1      }
  214          
  215          void putstr_1 (char *p) {                    /* Write string */
  216   1        while (*p) {
  217   2          putchar_1 (*p++);
  218   2        }
  219   1      }
  220          
  221          
  222          
  223          void puthex_0 (int hex) {                    /* Write Hex Digit to Serial Port  */
  224   1        if (hex > 9) putchar_0('A' + (hex - 10));
  225   1        else         putchar_0('0' +  hex);
  226   1      }
  227          
  228          void putstr_0 (char *p) {                    /* Write string */
  229   1        while (*p) {
  230   2          putchar_0 (*p++);
  231   2        }
  232   1      }
  233          
  234          
  235          
  236          
  237          
  238          
  239          void udelay(int val){
  240   1            int d = val*69;
  241   1            while(d--);
  242   1      }
  243          
  244          void init_buttons(){
  245   1           PINSEL1 &= (0x007FFFFF); //enable GPIO
  246   1           IODIR &= (0x07FFFFFF); //INPUT - 0
  247   1      }
  248          
  249          int button_pressed(){
  250   1            unsigned long val;
  251   1            val = IOPIN;
  252   1            
ARM COMPILER V0.07,  test                                                                  26/11/04  11:06:08  PAGE 5   

  253   1            if (!(val&BUTTON1)){
  254   2                  return 1;
  255   2            }
  256   1             
  257   1            if (!(val&BUTTON2)){
  258   2                  return 2;
  259   2            }
  260   1             
  261   1            if (!(val&BUTTON3)){
  262   2                  return 3;
  263   2            }
  264   1             
  265   1            if (!(val&BUTTON4)){
  266   2                  return 4;
  267   2            }
  268   1            
  269   1            if (!(val&BUTTON5)){
  270   2                  return 5;
  271   2            }
  272   1            return 0;
  273   1      }
  274          
  275          
  276           
  277          int
  278          main(void)
  279          {
  280   1        int i,a, j;
  281   1       // unsigned char  rtc_data[6];
  282   1        //int counter;
  283   1        //power led
  284   1        MAMCR = 2;
  285   1        PINSEL0  &= ~((LEDMASK<<2)|(LEDMASK<<1));
  286   1      
  287   1        IODIR |= LEDMASK;
  288   1        IOCLR |= LEDMASK; //ON LED
  289   1      
  290   1        IODIR |= RELAYMASK;
  291   1        IOSET |= RELAYMASK; //ON RELAY
  292   1      
  293   1        lcd_init();
  294   1      
  295   1        lcd_cursor_off();
  296   1        init_serial_1();
  297   1          init_serial_0();                  
  298   1                                   /* Initialize Serial Interface   */
  299   1        putstr_1("Hello");
  300   1        putstr_0("Hello");
  301   1        InitI2C();   // this function Initialises I2C 
  302   1      
  303   1         if (!store_time(&current_time))              // store the current time in the Real Time Clock held in 
             -the current_time
  304   1                                                     // structure. If there is an error display an error messag
             -e
  305   1        {
  306   2          lcd_gotoxy(0,0);
  307   2          lcd_print("Err writing to RTC");
  308   2        }
  309   1      
  310   1       a=i;
  311   1       
  312   1        while(1){
  313   2          
  314   2          if (read_time(&current_time))              // read the current time
  315   2            {
  316   3              display_time(&current_time);             // display the current time if no error
ARM COMPILER V0.07,  test                                                                  26/11/04  11:06:08  PAGE 6   

  317   3              display_date(&current_time);             // display the current time if no error
  318   3            }
  319   2          else
  320   2          {
  321   3              lcd_gotoxy(0,0);
  322   3              lcd_print("Err writing to RTC");
  323   3          }
  324   2      
  325   2             if (i=button_pressed()){
  326   3      
  327   3                 if(a!=i){
  328   4                 a=i;
  329   4                 lcd_clear();  udelay(300);
  330   4                 switch(i){
  331   5                      case 1:
  332   5                      //   lcd_gotoxy(0,0);
  333   5                      //   lcd_print("SW1 Pressed");
  334   5                           lcd_gotoxy(1,1);
  335   5                           lcd_print("SW1 Pressed");
  336   5                           lcd_gotoxy(2,2);
  337   5                           lcd_print("SW1 Pressed");
  338   5                           lcd_gotoxy(3,3);
  339   5                           lcd_print("SW1 Pressed");
  340   5                           IOSET |= LEDMASK; //OFF LED
  341   5                           putstr_1("Hello");
  342   5                           putstr_0("Hello");
  343   5                            break;
  344   5                      case 2:
  345   5                      //   lcd_gotoxy(0,0);
  346   5                      //   lcd_print("SW2 Pressed");
  347   5                           lcd_gotoxy(1,1);
  348   5                           lcd_print("SW2 Pressed");
  349   5                           lcd_gotoxy(2,2);
  350   5                           lcd_print("SW2 Pressed");
  351   5                           lcd_gotoxy(3,3);
  352   5                           lcd_print("SW2 Pressed");
  353   5                            IOCLR |= LEDMASK; //ON LED
  354   5                           break;
  355   5      
  356   5                      case 3:
  357   5                      //   lcd_gotoxy(0,0);
  358   5                      //   lcd_print("SW3 Pressed");
  359   5                           lcd_gotoxy(1,1);
  360   5                           lcd_print("SW3 Pressed");
  361   5                           lcd_gotoxy(2,2);
  362   5                           lcd_print("SW3 Pressed");
  363   5                           lcd_gotoxy(3,3);
  364   5                           lcd_print("SW3 Pressed");
  365   5                           IOCLR |= RELAYMASK; //OFF RELAY
  366   5                           break;
  367   5      
  368   5                      case 4:
  369   5                      //   lcd_gotoxy(0,0);
  370   5                      //   lcd_print("SW4 Pressed");
  371   5                           lcd_gotoxy(1,1);
  372   5                           lcd_print("SW4 Pressed");
  373   5                           lcd_gotoxy(2,2);
  374   5                           lcd_print("SW4 Pressed");
  375   5                           lcd_gotoxy(3,3);
  376   5                           lcd_print("SW4 Pressed");
  377   5                           IOSET |= RELAYMASK; //ON RELAY
  378   5                           break;
  379   5      
  380   5                      case 5:
  381   5                      //   lcd_gotoxy(0,0);
  382   5                      //   lcd_print("SW5 Pressed");
ARM COMPILER V0.07,  test                                                                  26/11/04  11:06:08  PAGE 7   

  383   5                           lcd_gotoxy(1,1);
  384   5                           lcd_print("SW5 Pressed");
  385   5                           lcd_gotoxy(2,2);
  386   5                           lcd_print("SW5 Pressed");
  387   5                           lcd_gotoxy(3,3);
  388   5                           lcd_print("SW5 Pressed");
  389   5                           IOSET |= LEDMASK; //OFF LED
  390   5                           IOCLR |= RELAYMASK; //OFF RELAY
  391   5                           break;
  392   5                      default:
  393   5                              break;
  394   5      
  395   5                 }
  396   4                 }
  397   3             }else {
  398   3                if(a!=i+6)
  399   3                {
  400   4               lcd_clear();    udelay(300);
  401   4               a=i+6;   // dummy
  402   4             //  lcd_gotoxy(0,0);
  403   4          //   lcd_print("ARO Equipments");
  404   4               lcd_gotoxy(1,1);
  405   4               lcd_print("805 Ph-V ");
  406   4               lcd_gotoxy(2,2);
  407   4               lcd_print("Udyog Vihar");
  408   4               lcd_gotoxy(3,3);
  409   4               lcd_print("Gurgaon ");
  410   4               }
  411   3             }
  412   2      
  413   2             udelay(1000);
  414   2      
  415   2        }
  416   1      
  417   1      }
  418          // EOF

ARM COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -