38 unsigned short ie1, ie2, wdtctl;
42 mask_intr(
struct ictx *c)
51 c->wdtctl ^= (WDTRPW ^ WDTPW);
52 WDTCTL = WDTPW | WDTHOLD;
59 FCTL2 = FWKEY | FSSEL_SMCLK | (FN2 | FN1);
64 rest_intr(
struct ictx *c)
79 blkwrt(
void *to,
const void *from,
const void *from_end)
84 rom_erase(
long nbytes, off_t offset)
87 char *to = (
char *)(uintptr_t)offset;
90 if(nbytes % ROM_ERASE_UNIT_SIZE != 0) {
94 if(offset % ROM_ERASE_UNIT_SIZE != 0) {
101 FCTL1 = FWKEY | ERASE;
103 nbytes -= ROM_ERASE_UNIT_SIZE;
104 to += ROM_ERASE_UNIT_SIZE;
113 rom_pwrite(
const void *buf,
int nbytes, off_t offset)
115 const char *from = buf;
117 char *to = (
char *)(uintptr_t)offset;
123 int n = (nbytes > 64) ? 64 : nbytes;
124 FCTL1 = FWKEY | BLKWRT | WRT;
125 blkwrt(to, from, from + n);
142 asm(
".type blkwrt,@function");
143 asm(
".section .data");
146 blkwrt(
void *_to,
const void *_from,
const void *_from_end)
148 unsigned short *to = _to;
149 const unsigned short *from = _from;
150 const unsigned short *from_end = _from_end;
153 while(!(FCTL3 & WAIT));
154 }
while(from < from_end);