-
Notifications
You must be signed in to change notification settings - Fork 0
/
Initialization 2_Abdullah
66 lines (56 loc) · 1.79 KB
/
Initialization 2_Abdullah
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
# include "stdint.h"
# include "math.h"
# include "stdio.h"
# include "string.h"
# include "stdlib.h"
# include "TM4C123GH6PM.h"
void SystemInit(){}
volatile long double lat2 = 0;
volatile long double long2 = 0;
volatile long double dist = 0;
volatile long double long1 = 0;
volatile long double lat1 = 0;
volatile long double long1temp = 0;
volatile long double lat1temp = 0;
volatile long double theta = 0;
volatile long double lastdist = 0;
volatile long double dist1 = 0;
volatile long double dist2 = 0;
volatile long double PI = 3.14159265358979323846264338327950288;
char Start0[] = "Press SW2 to";
char Start1[] = "start";
char Stop0[] = "Press SW1 at";
char Stop1[] = "any time to stop";
char Stop2[] = "Press SW1 again";
char Distance[] = "Distance=";
void init_uart(void)
{
GPIO_PORTE_LOCK_R = 0x4C4F434B;
GPIO_PORTE_CR_R |= 0x30;
GPIO_PORTE_AFSEL_R |= 0x30 ;
GPIO_PORTE_AMSEL_R &= ~ 0x30 ;
GPIO_PORTE_PCTL_R |= 0x00110000 ;
GPIO_PORTE_DEN_R |= 0x30 ;
UART5_CTL_R &= ~0x301; // disable UART5
UART5_IBRD_R = 104; // baudrate(integer part) = 16000000/(16*9600)= 104.1666667 , integer = 104
UART5_FBRD_R = 11; // baudrate(fraction part) = round(0.1667*64)= 11
UART5_LCRH_R = 0x00000070; // enable FIFO ,no parity, one stop, 8-bit data
UART5_CTL_R |= 0x301; // enable UART5
}
char read_uart(void)
{
while((UART5_FR_R&0x0010)!=0){}
return((char)UART5_DR_R&0xFF);
}
/*
1-delay function
2-function prints and perform orders to lcd
3-LCD Commands to initalize LCD
*/
//delay function takes an integer as a parameter and produce a time delay equal to this integer multipled by 10 nanoseconds
void delay10Ns(int time)
{
int i;
for(i = 0; i < time; i++)
{}
}