9c2a25f8b7e1b0df4a446a6bfcee529da517b7f1
[beacon-tx-433.git] / main.c
1 /*
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  Revision : $Id: main.c,v 1.4.6.3 2007-05-28 12:55:48 zer0 Exp $
19  *
20  */
21
22 #include <aversive.h>
23 #include <aversive/wait.h>
24
25 #include <stdio.h>
26 #include <string.h>
27
28 #define TX_ENABLE_PORT 2
29 #define DATA_PORT 1
30 #define BUZZER_PORT 0
31
32 #define TX_ON()       sbi(PORTB, TX_ENABLE_PORT)
33 #define TX_OFF()      cbi(PORTB, TX_ENABLE_PORT)
34
35 #define DATA_ON()       sbi(PORTB, DATA_PORT)
36 #define DATA_OFF()      cbi(PORTB, DATA_PORT)
37
38 int main(void)
39 {
40         int i;
41
42         /* PORTB TX/DATA out*/
43         DDRB |= (1 << TX_ENABLE_PORT) |
44                 (1 << DATA_PORT) |
45                 (1 << BUZZER_PORT);
46
47
48         while (1) {
49                 PORTB &= ~(1 << TX_ENABLE_PORT);
50                 wait_ms(500);
51                 PORTB |= (1 << TX_ENABLE_PORT);
52                 for (i=0;i<100; i++) {
53                         PORTB |= (1 << DATA_PORT);
54                         PORTB |= (1 << BUZZER_PORT);
55                         _delay_us(1000);
56                         PORTB &= ~(1 << DATA_PORT);
57                         PORTB &= ~(1 << BUZZER_PORT);
58                         _delay_us(1000);
59                 }
60         }
61
62         return 0;
63 }