-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpio.c
60 lines (22 loc) · 799 Bytes
/
gpio.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdint.h>
#include <stdbool.h>
#include "efm32gg.h"
/* function to set up GPIO mode and interrupts*/
void setupGPIO()
{
/* TODO set input and output pins for the joystick */
/* Example of HW access from C code: turn on joystick LEDs D4-D8
check efm32gg.h for other useful register definitions
*/
*CMU_HFPERCLKEN0 |= CMU2_HFPERCLKEN0_GPIO; /* enable GPIO clock*/
*GPIO_PA_CTRL = 2; /* set high drive strength */
*GPIO_PA_MODEH = 0x55555555; /* set pins A8-15 as output */
*GPIO_PC_MODEL = 0x33333333;
*GPIO_PC_DOUT = 0xff;
*GPIO_EXTIPSELL = 0x22222222;
*GPIO_EXTIFALL = 0xff;
*GPIO_EXTIRISE = 0xff;
*GPIO_IEN = 0xff;
//*ISER0 = 0x802;
*GPIO_PA_DOUT = 0xf1f1f1f1; /* turn on LEDs D4-D8 (LEDs are active low) */
}