1987 views|0 replies

3836

Posts

19

Resources
The OP
 

DSP TMS320 F28035 key driver [Copy link]

/************************************ Title: key.h Software platform: DSP.com/forum.php?mod=forumdisplay&fid=58" target="_blank" class="relatedlink">CCS v5.2 Hardware platform: Bishe control board Main frequency: 60M author: Xiaochuandata: 2013-02-23 *****************************************/ #ifndef KEY_H_ #define KEY_H_ #include "PeripheralHeaderIncludes.h" #include

#define delay_cheak 15000

#define KEY1     1
#define KEY2     2
#define KEY3     3
#define KEY4     4
#define noKEY    0

#define KEY1_on        GpioDataRegs.GPADAT.bit.GPIO19 == 0
#define KEY2_on        GpioDataRegs.GPADAT.bit.GPIO6 == 0
#define KEY3_on     GpioDataRegs.GPADAT.bit.GPIO12 == 0
#define KEY4_on        GpioDataRegs.GPADAT.bit.GPIO16 == 0
#define KEYs_on     (GpioDataRegs.GPADAT.all & 0x00091040) != 0x00091040

extern void (*key1_handle)();
extern void (*key2_handle)();
extern void (*key3_handle)();
extern void (*key4_handle)();

void KEY_init(void (*key1_dle)(), void (*key2_dle)(), void (*key3_handle)(), void (*key4_dle)());
char KEY_scanf_handle();

#endif /* KEY_H_ */

/************************************
    标题:key.c
    软件平台:CCS v5.2
    硬件平台:毕设控制板
    主频:60M

    author:小船
    data:2013-02-23
*************************************/
#include "key.h"

void (*key1_handle) () = NULL;
void (*key2_handle) () = NULL;
void (*key3_handle) () = NULL;
void (*key4_handle) () = NULL;

void KEY_init(void (*key1_dle)(), void (*key2_dle)(), void (*key3_dle)(), void (*key4_dle)())
{
    EALLOW;

    GpioCtrlRegs.GPAPUD.all &= (~0x00091040); //除能上拉电阻
    GpioCtrlRegs.GPADIR.all &= (~0x00091040);   //输入
    GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 0;  //GPIO19
    GpioCtrlRegs.GPAQSEL2.bit.GPIO19 = 2; // 6 samples

    GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0;  //GPIO6
    GpioCtrlRegs.GPAQSEL1.bit.GPIO6 = 2; // 6 samples

    GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0;  //GPIO12
    GpioCtrlRegs.GPAQSEL1.bit.GPIO12 = 2; // 6 samples

    GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 0;  //GPIO16
    GpioCtrlRegs.GPAQSEL2.bit.GPIO16 = 2; // 6 samples

    EDIS;

    GpioDataRegs.GPASET.all |= 0x00091040;

    key1_handle = key1_dle;
    key2_handle = key2_dle;
    key3_handle = key3_dle;
    key4_handle = key4_dle;
}

char KEY_scanf_handle()
{
char KEY_mun = 0;
if(KEYs_on)
  {
   DELAY_US(delay_cheak);
   if(KEYs_on)
   {
       if(KEY1_on)
       {
        (*key1_handle)();
        KEY_mun = KEY1;
       }
       if(KEY2_on)
       {
        (*key2_handle)();
        KEY_mun = KEY2;
       }
       if(KEY3_on)
       {
        (*key3_handle)();
        KEY_mun = KEY3;
       }
       if(KEY4_on)
       {
        (*key4_handle)();
        KEY_mun = KEY4;
       }
   }
  }
return KEY_mun;
}

This post is from DSP and ARM Processors
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list