cleanup read_fuse_lock()

This commit is contained in:
Olaf Rempel 2006-05-26 19:37:18 +02:00
parent d1f7b638d1
commit 93453d0aaa
1 changed files with 10 additions and 9 deletions

19
main.c
View File

@ -226,16 +226,17 @@ static inline uint16_t readEEpromPage(uint16_t address, pagebuf_t size)
return address;
}
static uint8_t read_fuse_lock(uint16_t addr, uint8_t mode)
static uint8_t read_fuse_lock(uint16_t addr)
{
uint8_t mode = (1<<BLBSET) | (1<<SPMEN);
uint8_t retval;
asm volatile
(
"movw r30, %3\n\t" /* Z to addr */ \
"sts %0, %2\n\t" /* set mode in SPM_REG */ \
"lpm\n\t" /* load fuse/lock value into r0 */ \
"mov %1,r0\n\t" /* save return value */ \
"movw r30, %3\n\t" /* Z to addr */ \
"sts %0, %2\n\t" /* set mode in SPM_REG */ \
"lpm\n\t" /* load fuse/lock value into r0 */ \
"mov %1,r0\n\t" /* save return value */ \
: "=m" (SPM_REG),
"=r" (retval)
: "r" (mode),
@ -462,19 +463,19 @@ int main(void)
#warning "Extension 'ReadFuseLock' enabled"
// read "low" fuse bits
} else if (val == 'F') {
sendchar(read_fuse_lock(0x0000, (1<<BLBSET) | (1<<SPMEN)));
sendchar(read_fuse_lock(GET_LOW_FUSE_BITS));
// read lock bits
} else if (val == 'r') {
sendchar(read_fuse_lock(0x0001, (1<<BLBSET) | (1<<SPMEN)));
sendchar(read_fuse_lock(GET_LOCK_BITS));
// read high fuse bits
} else if (val == 'N') {
sendchar(read_fuse_lock(0x0003, (1<<BLBSET) | (1<<SPMEN)));
sendchar(read_fuse_lock(GET_HIGH_FUSE_BITS));
// read extended fuse bits
} else if (val == 'Q') {
sendchar(read_fuse_lock(0x0002, (1<<BLBSET) | (1<<SPMEN)));
sendchar(read_fuse_lock(GET_EXTENDED_FUSE_BITS));
#endif
// Return device type