forked from meshack-mbuvi/SPH336_Jan2015
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
86 lines (70 loc) · 2.09 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
79
80
81
82
83
84
85
86
/*
* 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"gpio.h"
#include"uart.h"
#include "led_blinker.h"
void delay(void);
int main(void){
//temporally UART data holder
uint8_t byte=0;
//initialize system
SystemInit();
//initialize UART5 with 8-N-1 settings, 57600 baudrate
init_uart(UART5_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)
{
//toggle_LED1();
//delay();
//if(data_available()){
// byte = uart_read();
//}
//delay();
//puts((uint8_t*)("Ready\r\n"));
//LOOP:
//delay();
byte = uart_read();
//byte2=byte;
switch (byte) {
case '0': led_blinker(0); break;//toggle_LED0(); byte='n'; break;
case '1': led_blinker(1); break;//toggle_LED1(); byte='n'; break;
case '2': led_blinker(2); break;//toggle_LED2(); byte='n'; break;
case '3': led_blinker(3); break;//toggle_LED3(); byte='n'; break;
case '4': led_blinker(4); break;//toggle_LED4(); byte='n'; break;
case '5': led_blinker(5); break;//toggle_LED5(); byte='n'; break;
case '6': led_blinker(6); break;//toggle_LED6(); byte='n'; break;
case '7': led_blinker(7); break;//toggle_LED7(); byte='n'; break;
case '8': led_blinker(8); break;//toggle_LED8(); byte='n'; break;
case '9': led_blinker(9); break;//toggle_LED9(); byte='n'; break;
default: main(); break;//toggle_LED0(); goto LOOP; break;
}
delay();
}
}
/*
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");
}
}