-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmain.c~
63 lines (53 loc) · 1.37 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
/*
* File: main.c
*
* Copyright (c) 2015, [email protected]
*
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details.
*
*/
#include "main.h"
#include"gpio.h"
#include"uart.h"
int main(void){
//temporally UART data holder
uint8_t byte=0, blink=1;
//initialize system
SystemInit();
//initialize UART5 with 8-N-1 settings, 57600 baudrate
init_uart(UART3_BASE_PTR,periph_clk_khz,57600);
//clear all interrupts and enable interrupts
nvic->ICPR[2] |= 1 << (87 & 0x1F); //Clear Pending Interrupts
nvic->ISER[2] |= 1 << (87 & 0x1F); //Enable Interrupts
//initialize GPIO ports
gpio_init();
//Loop forever
while(1)
{
if(data_available()){
byte = uart_read();
if ((byte>47&&byte<58)){//check that data received is an digit
displayBinary(byte);//call function to blink leds with byte
//as the argument
}
// TODO: check character being given as input to be part of boundary
else{;}
}
}
}
/*
brief Silly delay
*/
void delay(void)
{
volatile unsigned int i,j;
for(i=0; i<25000; i++)
{
for(j=0; j<300; j++)
__asm__("nop");
}
}