• DSP28335矩阵键盘的检测


    #include "DSP2833x_Device.h"
    #include "DSP2833x_Examples.h"
    char temp;
    void gpio_init(void)
    {
     EALLOW;
     GpioCtrlRegs.GPBMUX2.all=0x0000;
     GpioCtrlRegs.GPBDIR.bit.GPIO50=1;
     GpioCtrlRegs.GPBDIR.bit.GPIO49=1;
     GpioCtrlRegs.GPBDIR.bit.GPIO48=1;
     GpioCtrlRegs.GPBPUD.bit.GPIO53=1;
     GpioCtrlRegs.GPBPUD.bit.GPIO52=1;
     GpioCtrlRegs.GPBPUD.bit.GPIO51=1;
     GpioCtrlRegs.GPBDIR.bit.GPIO53=0;
     GpioCtrlRegs.GPBDIR.bit.GPIO52=0;
     GpioCtrlRegs.GPBDIR.bit.GPIO51=0;
     GpioCtrlRegs.GPAMUX1.all=0x0000;
     GpioCtrlRegs.GPADIR.all=0xffff;
     EDIS;
    }
    void delay(void)
    {
     long int i,j;
     for(i=0;i<20;i++)
      for(j=0;j<10;j++);
    }

    void delay1(void)
    {
     long int i,j;
     for(i=0;i<200;i++)
      for(j=0;j<100;j++);
    }
    void all_on(void)
    {
     GpioDataRegs.GPBCLEAR.bit.GPIO50=1;
     GpioDataRegs.GPBCLEAR.bit.GPIO49=1;
     GpioDataRegs.GPBCLEAR.bit.GPIO48=1; 
    }
    char matrix_key(void)
    {
     all_on();
     if(GpioDataRegs.GPBDAT.bit.GPIO53==0)
     {
      delay1();
      if(GpioDataRegs.GPBDAT.bit.GPIO53==0){
      GpioDataRegs.GPBSET.bit.GPIO50=1;
      delay();
      if(GpioDataRegs.GPBDAT.bit.GPIO53==1)   
       temp=1;
      else temp=temp;
      all_on();
      GpioDataRegs.GPBSET.bit.GPIO48=1;
      delay();
      if(GpioDataRegs.GPBDAT.bit.GPIO53==1)   
       temp=2;
      else temp=temp;
      all_on();
      GpioDataRegs.GPBSET.bit.GPIO49=1;
      delay();
      if(GpioDataRegs.GPBDAT.bit.GPIO53==1)   
       temp=3;
      else temp=temp;
      }
     }
     all_on();
     if(GpioDataRegs.GPBDAT.bit.GPIO52==0)
     {
      delay1();
      if(GpioDataRegs.GPBDAT.bit.GPIO52==0){
      GpioDataRegs.GPBSET.bit.GPIO50=1;
      delay();
      if(GpioDataRegs.GPBDAT.bit.GPIO52==1)   
       temp=4;
      else temp=temp;
      all_on();
      GpioDataRegs.GPBSET.bit.GPIO48=1;
      delay();
      if(GpioDataRegs.GPBDAT.bit.GPIO52==1)   
       temp=5;
      else temp=temp;
      all_on();
      GpioDataRegs.GPBSET.bit.GPIO49=1;
      delay();
      if(GpioDataRegs.GPBDAT.bit.GPIO52==1)   
       temp=6;
      else temp=temp;
      }
     }
     all_on();
     if(GpioDataRegs.GPBDAT.bit.GPIO51==0)
     {
      delay1();
      if(GpioDataRegs.GPBDAT.bit.GPIO51==0){
      GpioDataRegs.GPBSET.bit.GPIO50=1;
      delay();
      if(GpioDataRegs.GPBDAT.bit.GPIO51==1)   
       temp=7;
      else temp=temp;
      all_on();
      GpioDataRegs.GPBSET.bit.GPIO48=1;
      delay();
      if(GpioDataRegs.GPBDAT.bit.GPIO51==1)   
       temp=8;
      else temp=temp;
      all_on();
      GpioDataRegs.GPBSET.bit.GPIO49=1;
      delay();
      if(GpioDataRegs.GPBDAT.bit.GPIO51==1)   
       temp=9;
      else temp=temp;
      }
     }
     return temp;
    }
    void main(void)
    {
     gpio_init();
     temp=0;
     for(;;)
     {
     // matrix_key();
     // GpioDataRegs.GPADAT.all=temp;
     // delay();
      GpioDataRegs.GPADAT.all=~matrix_key();
     }
    }

  • 相关阅读:
    解决mac启动springboot项目很慢的问题
    Oracle如何创建索引、删除索引、查询索引
    查看Oracle索引是否被使用或者有效
    Mysql创建、使用循环函数
    处理idea加载不到Spring的xml或者properties配置文件
    UML常用图、常见关系、设计模式
    设置文本框能够滚动
    MFC中的ID命名规则
    MFC应用中如何触发ON_MESSAGE
    使用MFC创建一个可视化程序
  • 原文地址:https://www.cnblogs.com/luxiaolai/p/3283724.html
Copyright © 2020-2023  润新知