Revision 89f527ad
Added makefile magic to program bootloader in correct place
scout_avr/bom/bootloader.c | ||
---|---|---|
1 | 1 |
#include <inttypes.h> |
2 |
#include <avr/boot.h> |
|
2 | 3 |
#include <avr/interrupt.h> |
3 | 4 |
#include <avr/pgmspace.h> |
4 | 5 |
#include "tiny-twi-sync.h" |
6 |
#include "bootloader.h" |
|
5 | 7 |
|
6 | 8 |
uint32_t current_page; |
7 | 9 |
|
... | ... | |
32 | 34 |
boot_page_write (page); // Store buffer in flash page. |
33 | 35 |
boot_spm_busy_wait(); // Wait until the memory is written. |
34 | 36 |
|
35 |
// Reenable RWW-section again. We need this if we want to jump back |
|
36 |
// to the application after bootloading. |
|
37 |
|
|
38 |
boot_rww_enable (); |
|
39 |
|
|
40 | 37 |
// Re-enable interrupts (if they were ever enabled). |
41 | 38 |
|
42 | 39 |
SREG = sreg; |
... | ... | |
47 | 44 |
if (current_page == 0) { |
48 | 45 |
uint16_t w = 0xC000 | ((START_ADDR >> 1) - 1); |
49 | 46 |
buf[0] = w & 0xFF; |
50 |
buf[1] = (w >> 16) & 0xFF;
|
|
47 |
buf[1] = (w >> 8) & 0xFF;
|
|
51 | 48 |
} |
52 | 49 |
boot_program_page(current_page, buf); |
53 | 50 |
current_page++; |
... | ... | |
67 | 64 |
} |
68 | 65 |
} |
69 | 66 |
|
70 |
|
|
71 |
|
|
72 |
|
|
73 | 67 |
int main() { |
68 |
smb_init(slave_rx); |
|
69 |
smb_set_address(3); // TODO parameterize address |
|
70 |
twi_run(); |
|
71 |
// TODO timeout |
|
74 | 72 |
return 0; |
75 |
} |
|
73 |
} |
Also available in: Unified diff