-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpio.h
69 lines (54 loc) · 2.4 KB
/
gpio.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// GPIO Library
// Jason Losh
//-----------------------------------------------------------------------------
// Hardware Target
//-----------------------------------------------------------------------------
// Target Platform: EK-TM4C123GXL
// Target uC: TM4C123GH6PM
// System Clock: -
// Hardware configuration:
// GPIO APB ports A-F
//-----------------------------------------------------------------------------
// Device includes, defines, and assembler directives
//-----------------------------------------------------------------------------
#ifndef GPIO_H_
#define GPIO_H_
#include <stdint.h>
#include <stdbool.h>
// Enum values set to bitband address of bit 0 of the GPIO_PORTx_DATA_R register
typedef enum _PORT
{
PORTA = 0x42000000 + (0x400043FC-0x40000000)*32,
PORTB = 0x42000000 + (0x400053FC-0x40000000)*32,
PORTC = 0x42000000 + (0x400063FC-0x40000000)*32,
PORTD = 0x42000000 + (0x400073FC-0x40000000)*32,
PORTE = 0x42000000 + (0x400243FC-0x40000000)*32,
PORTF = 0x42000000 + (0x400253FC-0x40000000)*32
} PORT;
//-----------------------------------------------------------------------------
// Subroutines
//-----------------------------------------------------------------------------
void enablePort(PORT port);
void disablePort(PORT port);
void selectPinPushPullOutput(PORT port, uint8_t pin);
void selectPinOpenDrainOutput(PORT port, uint8_t pin);
void selectPinDigitalInput(PORT port, uint8_t pin);
void selectPinAnalogInput(PORT port, uint8_t pin);
void setPinCommitControl(PORT port, uint8_t pin);
void enablePinPullup(PORT port, uint8_t pin);
void disablePinPullup(PORT port, uint8_t pin);
void enablePinPulldown(PORT port, uint8_t pin);
void disablePinPulldown(PORT port, uint8_t pin);
void setPinAuxFunction(PORT port, uint8_t pin, uint32_t fn);
void selectPinInterruptRisingEdge(PORT port, uint8_t pin);
void selectPinInterruptFallingEdge(PORT port, uint8_t pin);
void selectPinInterruptBothEdges(PORT port, uint8_t pin);
void selectPinInterruptHighLevel(PORT port, uint8_t pin);
void selectPinInterruptLowLevel(PORT port, uint8_t pin);
void enablePinInterrupt(PORT port, uint8_t pin);
void disablePinInterrupt(PORT port, uint8_t pin);
void setPinValue(PORT port, uint8_t pin, bool value);
bool getPinValue(PORT port, uint8_t pin);
void setPortValue(PORT port, uint8_t value);
uint8_t getPortValue(PORT port);
#endif