IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Git Source Tree
Root/
Source at commit 2978afe92b395305a002c6615676e9cb992989eb created 13 years 16 days ago. By Werner Almesberger, atusb/fw/flash.c: simplified logic of flash_write and corrected several small bugs | |
---|---|
1 | /* |
2 | * fw/boot.c - DFU boot loader for ATUSB |
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 | |
18 | #define F_CPU 8000000UL |
19 | #include <util/delay.h> |
20 | |
21 | #include "usb.h" |
22 | #include "dfu.h" |
23 | |
24 | #include "board.h" |
25 | #include "spi.h" |
26 | #include "atusb/ep0.h" |
27 | |
28 | |
29 | #define MS_TO_LOOPS(ms) ((uint32_t) (ms)*81) |
30 | |
31 | |
32 | static void (*run_payload)(void) = 0; |
33 | |
34 | |
35 | int main(void) |
36 | { |
37 | uint32_t loop = 0; |
38 | |
39 | board_init(); |
40 | spi_init(); |
41 | reset_rf(); |
42 | |
43 | /* now we should be at 8 MHz */ |
44 | |
45 | usb_init(); |
46 | dfu_init(); |
47 | |
48 | led(1); |
49 | |
50 | while (loop != MS_TO_LOOPS(2000)) { |
51 | usb_poll(); |
52 | if (dfu.state == dfuIDLE) |
53 | loop++; |
54 | else |
55 | loop = 0; |
56 | } |
57 | |
58 | led(0); |
59 | |
60 | run_payload(); |
61 | |
62 | while (1); /* not reached */ |
63 | } |
64 |