annotate tests/ledtest.c @ 1:f7c60e525801

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