IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Git Source Tree
Root/
| 1 | /* |
| 2 | * fw/atusb.c - ATUSB initialization and main loop |
| 3 | * |
| 4 | * Written 2008-2011 by Werner Almesberger |
| 5 | * Copyright 2008-2011 Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | |
| 16 | #include <avr/io.h> |
| 17 | #include <avr/sleep.h> |
| 18 | #include <avr/interrupt.h> |
| 19 | |
| 20 | #include "usb.h" |
| 21 | |
| 22 | #include "board.h" |
| 23 | #include "sernum.h" |
| 24 | #include "spi.h" |
| 25 | #include "atusb/ep0.h" |
| 26 | |
| 27 | #ifdef DEBUG |
| 28 | #include "uart.h" |
| 29 | #endif |
| 30 | |
| 31 | |
| 32 | int main(void) |
| 33 | { |
| 34 | board_init(); |
| 35 | board_app_init(); |
| 36 | reset_rf(); |
| 37 | |
| 38 | user_get_descriptor = sernum_get_descr; |
| 39 | |
| 40 | /* now we should be at 8 MHz */ |
| 41 | |
| 42 | #ifdef DEBUG |
| 43 | uart_init(); |
| 44 | static FILE atben_stdout = FDEV_SETUP_STREAM(uart_write_char, NULL, |
| 45 | _FDEV_SETUP_WRITE); |
| 46 | stdout = &atben_stdout; |
| 47 | #endif |
| 48 | |
| 49 | usb_init(); |
| 50 | ep0_init(); |
| 51 | #ifdef ATUSB |
| 52 | timer_init(); |
| 53 | |
| 54 | /* move interrupt vectors to 0 */ |
| 55 | MCUCR = 1 << IVCE; |
| 56 | MCUCR = 0; |
| 57 | #endif |
| 58 | |
| 59 | sei(); |
| 60 | |
| 61 | while (1) |
| 62 | sleep_mode(); |
| 63 | } |
| 64 |
