comparison tests/ledtest.c @ 0:a0ce8ebf2f18

LED on PINB0 & PINB1 and UART testing. - LED flasing on PINB0 & PINB1. - print 'hello' messages to UART for every flashing round.
author Thinker K.F. Li <thinker@branda.to>
date Sat, 21 Feb 2009 15:49:59 +0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a0ce8ebf2f18
1 #include <stdio.h>
2 #include "avriotools.h"
3 #include <util/delay.h>
4 #include <avr/io.h>
5
6 int main(int argc, char *const argv[]) {
7 int i, cnt = 0;
8 const char *msg = "hello%d\n";
9 char buf[64];
10
11 uart_init(400000);
12
13 pin_mode(&PORTB, PINB0, PM_OUTPUT);
14 pin_mode(&PORTB, PINB1, PM_OUTPUT);
15 pin_lo(PORTB, PINB1);
16 for(i = 0; i < 30; i++) {
17 pin_hi(PORTB, PINB0);
18 _delay_ms(100);
19 pin_lo(PORTB, PINB0);
20 _delay_ms(100);
21 }
22
23 while(1) {
24 pin_hi(PORTB, PINB0);
25 _delay_ms(100);
26 pin_lo(PORTB, PINB0);
27 _delay_ms(100);
28 pin_hi(PORTB, PINB0);
29 _delay_ms(100);
30 pin_lo(PORTB, PINB0);
31 _delay_ms(100);
32 pin_hi(PORTB, PINB0);
33 _delay_ms(500);
34 pin_lo(PORTB, PINB0);
35 _delay_ms(100);
36
37 sprintf(buf, msg, cnt++);
38 for(i = 0; buf[i] != 0; i++)
39 uart_putc(buf[i]);
40 }
41 }