cleanup read_fuse_lock()

This commit is contained in:
Olaf Rempel 2006-05-26 19:37:18 +02:00
parent d1f7b638d1
commit 93453d0aaa

19
main.c
View File

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