Commit 1d417fc 1 parent 62e4a45 commit 1d417fc Copy full SHA for 1d417fc
File tree 3 files changed +54
-0
lines changed
src/platform/efm32gg/driver
3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ source = [
37
37
' usb.c' ,
38
38
' usb_descriptors.c' ,
39
39
' hal/hid.c' ,
40
+ ' driver/key_direct.c' ,
40
41
]
41
42
42
43
[dependencies ]
Original file line number Diff line number Diff line change
1
+ /*
2
+ * SPDX-License-Identifier: MIT
3
+ * SPDX-FileCopyrightText: 2021 Rafael Silva <perigoso@riseup.net>
4
+ */
5
+
6
+ #include "platform/efm32gg/driver/key_direct.h"
7
+ #include "platform/efm32gg/systick.h"
8
+
9
+ struct key_direct_t key_direct_init (struct gpio_pin_t pin , u8 active_low )
10
+ {
11
+ struct key_direct_t key ;
12
+
13
+ key .pin = pin ;
14
+ key .active_low = active_low ;
15
+ key .key .key_status = key_released ;
16
+ key .change_timestamp = systick_get_ticks ();
17
+
18
+ return key ;
19
+ }
20
+
21
+ void key_direct_update (struct key_direct_t * key )
22
+ {
23
+ enum key_status_t last_status = key -> key .key_status ;
24
+
25
+ key -> key .key_status = (gpio_get (key -> pin ) ^ key -> active_low ) ? key_pressed : key_released ;
26
+
27
+ if (key -> key .key_status != last_status )
28
+ key -> change_timestamp = systick_get_ticks ();
29
+
30
+ key -> key .key_t_delta = systick_get_ticks () - key -> change_timestamp ;
31
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * SPDX-License-Identifier: MIT
3
+ * SPDX-FileCopyrightText: 2021 Rafael Silva <perigoso@riseup.net>
4
+ */
5
+
6
+ #pragma once
7
+
8
+ #include "util/types.h"
9
+
10
+ #include "platform/efm32gg/gpio.h"
11
+
12
+ #include "key_actions/key_actions.h"
13
+
14
+ struct key_direct_t {
15
+ struct gpio_pin_t pin ;
16
+ u32 change_timestamp ;
17
+ u8 active_low : 1 ;
18
+ struct key_t key ;
19
+ };
20
+
21
+ struct key_direct_t key_direct_init (struct gpio_pin_t pin , u8 active_low );
22
+ void key_direct_update (struct key_direct_t * key );
You can’t perform that action at this time.
0 commit comments