-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathports.h
51 lines (46 loc) · 846 Bytes
/
ports.h
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
#ifndef PORTS_H
#define PORTS_H
typedef enum CMD_SWITCH
{
USB, GPS
} CMD_SWITCH;
/**
* Initialisation des ports:
* - direction
* - mode usart (sélection)
*/
void initPorts(void)
{
/* Ports P1.0 à P1.4 en sortie
* Respectivement, LED_0 à LED_4
*/
P1DIR |= 0x1F;
/* Ports P2.0 à P2.4 en entré
* Respectivement, PUSH, TOP, BOTTOM, LEFT, RIGHT
* Activation des interruptions
*/
P2DIR &= 0xE0;
P2IES |= 0x1F;
P2IE |= 0x1F;
/* Ports P4.0, P4.1, P4.2 en sortie
* Respectivement, ENABLE_GPS, RESET_LCD, CMD_SWITCH
*/
P4DIR |= 0x07;
/* Initialisation de l'USART 1 et 2
*/
P3SEL |= 0xF0;
P3DIR |= 0x50; // ATTENTION PEUT ETER 0x30 (WUT?)
P3DIR &= 0x5F;
}
void setCmdSwitch(CMD_SWITCH device)
{
if (device == USB)
{
P4OUT |= 0x04;
}
else if (device == GPS)
{
P4OUT &= 0xFB;
}
}
#endif