avrboot/lowlevel.c

28 lines
584 B
C
Raw Normal View History

2006-05-01 19:10:39 +02:00
//
2006-05-01 19:15:27 +02:00
// Low-level routines to read lock and fuse-bytes
2006-05-01 19:10:39 +02:00
//
2006-05-01 19:15:27 +02:00
// Copyright (C) 2/2005 Martin Thomas, Kaiserslautern, Germany
2006-05-01 19:10:39 +02:00
//
2006-05-01 19:12:13 +02:00
#include "lowlevel.h"
2006-05-01 19:10:39 +02:00
2006-05-01 19:15:27 +02:00
unsigned char read_fuse_lock(unsigned short addr, unsigned char mode)
2006-05-01 19:10:39 +02:00
{
2006-05-01 19:15:27 +02:00
unsigned char retval;
2006-05-01 19:10:39 +02:00
asm volatile
(
2006-05-01 19:15:27 +02:00
"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 */ \
2006-05-01 19:10:39 +02:00
: "=m" (SPM_REG),
"=r" (retval)
2006-05-01 19:15:27 +02:00
: "r" (mode),
"r" (addr)
2006-05-01 19:10:39 +02:00
: "r30", "r31", "r0"
);
return retval;
}