Project

General

Profile

Revision 6b1a3a0d

ID6b1a3a0db1418685bf7a66a3684a4b126ab33074
Parent f414f222
Child fa11365c

Added by Aaron Perley about 10 years ago

Add bootloader files

View differences:

scout_avr/bom/bootloader.c
1
#include <inttypes.h>
2
#include <avr/interrupt.h>
3
#include <avr/pgmspace.h>
4
#include "tiny-twi-sync.h"
5

  
6
void boot_program_page (uint32_t page, uint8_t *buf)
7
{
8
  uint16_t i;
9
  uint8_t sreg;
10

  
11
  // Disable interrupts.
12

  
13
  sreg = SREG;
14
  cli();
15

  
16
  eeprom_busy_wait ();
17

  
18
  boot_page_erase (page);
19
  boot_spm_busy_wait ();      // Wait until the memory is erased.
20

  
21
  for (i=0; i<SPM_PAGESIZE; i+=2)
22
  {
23
    // Set up little-endian word.
24

  
25
    uint16_t w = *buf++;
26
    w += (*buf++) << 8;
27

  
28
    boot_page_fill (page + i, w);
29
  }
30

  
31
  boot_page_write (page);     // Store buffer in flash page.
32
  boot_spm_busy_wait();       // Wait until the memory is written.
33

  
34
  // Reenable RWW-section again. We need this if we want to jump back
35
  // to the application after bootloading.
36

  
37
  boot_rww_enable ();
38

  
39
  // Re-enable interrupts (if they were ever enabled).
40

  
41
  SREG = sreg;
42
}
43

  
44
int main() {
45
  return 0;
46
}
scout_avr/bom/bootloader.h
1
#ifndef BOOTLOADER_H
2
#define BOOTLOADER_H
3

  
4
void boot_program_page (uint32_t page, uint8_t *buf)
5

  
6
#endif

Also available in: Unified diff