-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflx5pilot.c
109 lines (91 loc) · 2.4 KB
/
flx5pilot.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
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
/**
* Entry point for the flyx5 firmware.
*
* @author Juan I. Carrano
*
* @copyright Copyright 2014 Juan I Carrano, Andrés Calcabrini, Juan I Ubeira,
* Nicolás venturo.
*/
#include "common.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "flyx5_hw.h"
#include "hw_init.h"
#include "peripheral/buzzer.h"
/**
* This error routine that is called if the driver library encounters an error.
*/
#ifdef DEBUG
void __error__(char *filename, uint32_t line)
{
// FIXME: unimplemented
}
#endif
/**
* Send a string to the UART, blocks execution until done.
*
* String must be null terminated.
*/
void UARTStringPut(uint32_t ui32Base, const char *s)
{
char c;
while((c = *s) != '\0') {
R_(UARTCharPut)(ui32Base, c);
s++;
}
}
/**
* Send a string to the UART, blocks execution until done.
*
* String must be null terminated.
*/
void UARTIntPut(uint32_t ui32Base, int x)
{
#define INT_MAX_S_LEN 32
char s[INT_MAX_S_LEN];
int i = INT_MAX_S_LEN-2;
s[INT_MAX_S_LEN-1] = 0;
while (x) {
s[i--] = x%10 + '0';
x = x/10;
}
UARTStringPut(ui32Base, s + i + 1);
}
int main(void)
{
init_failsafe();
init_clock();
//init_pins();
/* Initialise all ports */
init_all_gpio();
if (!running_under_debugger()) {
SysCtlDelay(10000000);
init_jtag_muxed_pins();
}
/* Initialize port */
ENABLE_AND_RESET(UART_DEBUG);
CFG_PIN(DEBUG_RX);
CFG_PIN(DEBUG_TX);
R_(UARTConfigSetExpClk)(BASE_PERIPH(UART_DEBUG) , R_(SysCtlClockGet)(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
#define HELLO_TXT "Hello, nigga!\r\n"
UARTStringPut(BASE_PERIPH(UART_DEBUG), HELLO_TXT);
#define CLK_TXT "Clock speed is: "
#define ENDL "\r\n"
UARTStringPut(BASE_PERIPH(UART_DEBUG), CLK_TXT);
UARTIntPut(BASE_PERIPH(UART_DEBUG), R_(SysCtlClockGet)());
UARTStringPut(BASE_PERIPH(UART_DEBUG), ENDL);
buzzer_init();
buzzer_play_note();
//
// Loop forever.
//
while(1)
{
int c = R_(UARTCharGet)(BASE_PERIPH(UART_DEBUG));
c = (c <= 'z' && c >= 'a')? c - 'a' + 'A' : c;
R_(UARTCharPut)(BASE_PERIPH(UART_DEBUG), c);
}
}