PageRenderTime 15ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/stm32/libraries/Keys/src/Keys.h

https://codeberg.org/Gruenstreifen-eV/BSFrance-stm32
C Header | 52 lines | 43 code | 9 blank | 0 comment | 0 complexity | 4674608778fd7dcc78b48261cd038dfd MD5 | raw file
Possible License(s): MIT, GPL-2.0
 1#ifndef __KEYS_H__
 2#define __KEYS_H__
 3
 4#ifdef __cplusplus
 5
 6#define KEY0	bit(0)
 7#define KEY1	bit(1)
 8#define KEY2	bit(2)
 9#define KEY3	bit(3)
10#define KEY4	bit(4)
11#define KEY5	bit(5)
12#define KEY6	bit(6)
13#define KEY7	bit(7)
14
15#define KEY_UNPRESED 0
16#define KEY_PRESED	 1
17
18typedef enum 
19{  
20  BUTTON_MODE_GPIO = 0,
21  BUTTON_MODE_EXTI = 1
22}ButtonMode_TypeDef;     
23
24typedef struct {
25    uint8_t  pins[16];       /**< pin max 16*/
26    uint8_t  nr;             /**< keys num. */
27    uint16_t on;             /**< on state, 1 high or 0 low on. */
28    uint16_t mode;       /*mode bit 1/0 exti/gpio*/
29} BOTTON_TypeDef;
30
31
32class BOTTONClass
33{
34  public:
35    BOTTONClass();
36    BOTTONClass(uint16_t mask, uint8_t k0,
37			    uint8_t k1=0xff, uint8_t k2=0xff, uint8_t k3=0xff,
38			    uint8_t k4=0xff, uint8_t k5=0xff, uint8_t k6=0xff, uint8_t k7=0xff,
39			    uint8_t k8=0xff, uint8_t k9=0xff, uint8_t k10=0xff,uint8_t k11=0xff,
40			    uint8_t k12=0xff,uint8_t k13=0xff,uint8_t k14=0xff,uint8_t k15=0xff);
41	void setKey(uint8_t pin,uint16_t on,ButtonMode_TypeDef mode = BUTTON_MODE_GPIO);
42    void Init();
43    uint8_t  getKey(uint8_t key);
44    uint16_t scan(uint8_t mode = 1);
45	BOTTON_TypeDef *pdata = &bottons;
46  private:
47    BOTTON_TypeDef bottons;
48};
49#endif
50
51#endif
52