-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstdtiva.h
159 lines (151 loc) · 4.42 KB
/
stdtiva.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//***********************************************************//
//
// stdtiva.h - standard functions header for tiva TM4C123GH6PM
//
//***********************************************************//
//
// this software standarizes some functions for TM4C123GH6PM
// tiva ware for the ease of use and learning
//
//***********************************************************//
//
// AUTHOR : Abderlahman Mostafa
// E-mail : [email protected]
// for any questions and inquiries, please send an e-mail or
// make it as a github pull request
//
//***********************************************************//
//
// THIS WAS MADE WHILE LEARNING THE INTRODUCTION TO EMBEDDED
// SYSTEMS COURSE AT FACULTY OF ENGINEERING, AIN SHAMS UNIVERSITY
//
//***********************************************************//
#ifndef STDTIVA_H
#define STDTIVA_H
#include "tm4c123gh6pm.h"
#include <stdint.h>
//***********************************************************//
//
// pins enum as their numbers defined in the datasheet of TM4C123GH6PM
//
//***********************************************************//
typedef enum {
PA0 = 17,
PA1 = 18,
PA2 = 19,
PA3 = 20,
PA4 = 21,
PA5 = 22,
PA6 = 23,
PA7 = 24,
PB0 = 45,
PB1 = 46,
PB2 = 47,
PB3 = 48,
PB4 = 58,
PB5 = 57,
PB6 = 1,
PB7 = 4,
PC0 = 52,
PC1 = 51,
PC2 = 50,
PC3 = 49,
PC4 = 16,
PC5 = 15,
PC6 = 14,
PC7 = 13,
PD0 = 61,
PD1 = 62,
PD2 = 63,
PD3 = 64,
PD4 = 43,
PD5 = 44,
PD6 = 53,
PD7 = 10,
PE0 = 9,
PE1 = 8,
PE2 = 7,
PE3 = 6,
PE4 = 59,
PE5 = 60,
PF0 = 28,
PF1 = 29,
PF2 = 30,
PF3 = 31,
PF4 = 5
} Pin;
typedef enum {
PORTA,
PORTB,
PORTC,
PORTD,
PORTE,
PORTF
} PORT;
typedef enum { LOW = 0, HIGH = 1 } Digital;
typedef enum { INPUT, OUTPUT } Direction;
//***********************************************************//
//
// FUNCTIONS HANDLERS
//
//***********************************************************//
//***********************************************************//
//
// PORT A FUNCTIONS
//
//***********************************************************//
void PORTA_Init(void); // initializes
uint32_t PORTA_Input(void); // reads input from input pins in port A
void PORTA_Output(uint32_t data); // writes output to output pins in port A
//***********************************************************//
//
// PORT B FUNCTIONS
//
//***********************************************************//
void PORTB_Init(void); // initializes
uint32_t PORTB_Input(void); // reads input from input pins in port B
void PORTB_Output(uint32_t data); // writes output to output pins in port B
//***********************************************************//
//
// PORT D FUNCTIONS
//
//***********************************************************//
void PORTD_Init(void); // initializes
uint32_t PORTD_Input(void); // reads input from input pins in port D
void PORTD_Output(uint32_t data); // writes output to output pins in port D
//***********************************************************//
//
// PORT E FUNCTIONS
//
//***********************************************************//
void PORTE_Init(void); // initializes
uint32_t PORTE_Input(void); // reads input from input pins in port E
void PORTE_Output(uint32_t data); // writes output to output pins in port E
//***********************************************************//
//
// PORT F FUNCTIONS
//
//***********************************************************//
void PORTF_Init(void); // initializes
uint32_t PORTF_Input(void); // reads input from input pins in port F
void PORTF_Output(uint32_t data); // writes output to output pins in port F
//***********************************************************//
//
// SYSTICK FUNCTIONS
//
//***********************************************************//
void SysTick_Init(void); // must be called before using SysTick functions
void SysTick_Wait(uint32_t delay); // to wait a certain delay calculated by the system timer
void SysTick_delay(uint32_t delayms); // to wait a certain delay in ms
void SysTick_delayus(uint32_t delayus); // to wait a certain delay in us
//***********************************************************//
//
// STANDARD FUNCTIONS
// these are the main purpose of this file
//
//***********************************************************//
void pinMode(Pin pin, Direction dir);
void digitalEnable(Pin pin, PORT port);
void digitalWrite(Pin pin, Digital I_O);
uint32_t digitalRead(Pin pin);
#endif //STDTIVA_H