-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
78 lines (67 loc) · 1.56 KB
/
main.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
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
////////////////////////////////////////////////
//
// x
// 2020-04-02 pds initial cut
//
#include <stdint.h> // for uint32_t
#include <stddef.h> // for size_t
#include "clock.h"
#include "uart0.h"
#include "gpio.h"
///////////////////////////////////////////////
//
// entry point
//
int main()
{
unsigned int x;
uint32_t clk_hz;
clk_hz = clock_init( PRCI_EXT_DIR ); // first things, first
gpio_init();
uart0_init( clk_hz, 115200 );
uart0_write_string( "welcome to uart test\r\n" );
gpio_dir( 9, GPIO_OUT );
gpio_dir( 10, GPIO_OUT );
gpio_dir( 11, GPIO_OUT );
while(1)
{
x = uart0_read();
switch (x)
{
case 'F':
uart0_write_string( "Flash " );
gpio_high( 9 );
break;
case 'f':
uart0_write_string( "flash " );
gpio_low( 9 );
break;
case 'M':
uart0_write_string( "Memory " );
gpio_high( 10 );
break;
case 'm':
uart0_write_string( "memory " );
gpio_low( 10 );
break;
case 'S':
uart0_write_string( "Summit " );
gpio_high( 11 );
break;
case 's':
uart0_write_string( "summit " );
gpio_low( 11 );
break;
case '?':
uart0_write_string( "welcome to uart test\r\n" );
break;
case '\r':
uart0_write_string( "\r\n" );
break;
default:
uart0_write( (uint8_t *) &x, 1 );
break;
}
}
return 0xDEADBEEF;
}