use boot.h functions to read own fuses
This commit is contained in:
parent
535dbfc901
commit
997ea730f4
|
|
@ -1,6 +1,7 @@
|
||||||
#include "copier.h"
|
#include "copier.h"
|
||||||
|
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
#include <avr/boot.h>
|
||||||
|
|
||||||
#include "arduino.h"
|
#include "arduino.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
@ -65,18 +66,15 @@ void copy() {
|
||||||
uint8_t f;
|
uint8_t f;
|
||||||
// copy fuses
|
// copy fuses
|
||||||
// first low byte
|
// first low byte
|
||||||
SPMCSR |= MASK(BLBSET) | MASK(SELFPRGEN);
|
f = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
|
||||||
f = pgm_read_byte_near(0);
|
|
||||||
copier_xchange(CMD_WRITE_FUSE_BITS | f);
|
copier_xchange(CMD_WRITE_FUSE_BITS | f);
|
||||||
|
|
||||||
// high byte
|
// high byte
|
||||||
SPMCSR |= MASK(BLBSET) | MASK(SELFPRGEN);
|
f = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
|
||||||
f = pgm_read_byte_near(3);
|
|
||||||
copier_xchange(CMD_WRITE_FUSE_HIGH_BITS | f);
|
copier_xchange(CMD_WRITE_FUSE_HIGH_BITS | f);
|
||||||
|
|
||||||
// extended byte
|
// extended byte
|
||||||
SPMCSR |= MASK(BLBSET) | MASK(SELFPRGEN);
|
f = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);
|
||||||
f = pgm_read_byte_near(2);
|
|
||||||
copier_xchange(CMD_WRITE_FUSE_EXTENDED_BITS | f);
|
copier_xchange(CMD_WRITE_FUSE_EXTENDED_BITS | f);
|
||||||
|
|
||||||
// start copying flash
|
// start copying flash
|
||||||
|
|
@ -93,7 +91,6 @@ void copy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset
|
// reset
|
||||||
WRITE(COPIER_RESET, 0);
|
|
||||||
delay_ms(10);
|
delay_ms(10);
|
||||||
SET_INPUT(MOSI);
|
SET_INPUT(MOSI);
|
||||||
SET_INPUT(SCK);
|
SET_INPUT(SCK);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue