37 unsigned short ie1, ie2, wdtctl;
41 mask_intr(
struct ictx *c)
50 c->wdtctl ^= (WDTRPW ^ WDTPW);
51 WDTCTL = WDTPW | WDTHOLD;
58 FCTL2 = FWKEY | FSSEL_SMCLK | (FN2 | FN1);
63 rest_intr(
struct ictx *c)
78 blkwrt(
void *to,
const void *from,
const void *from_end)
83 rom_erase(
long nbytes, off_t offset)
86 char *to = (
char *)(uintptr_t)offset;
89 if(nbytes % ROM_ERASE_UNIT_SIZE != 0) {
93 if(offset % ROM_ERASE_UNIT_SIZE != 0) {
100 FCTL1 = FWKEY | ERASE;
102 nbytes -= ROM_ERASE_UNIT_SIZE;
103 to += ROM_ERASE_UNIT_SIZE;
112 rom_pwrite(
const void *buf,
int nbytes, off_t offset)
114 const char *from = buf;
116 char *to = (
char *)(uintptr_t)offset;
122 int n = (nbytes > 64) ? 64 : nbytes;
123 FCTL1 = FWKEY | BLKWRT | WRT;
124 blkwrt(to, from, from + n);
141 asm(
".type blkwrt,@function");
142 asm(
".section .data");
145 blkwrt(
void *_to,
const void *_from,
const void *_from_end)
147 unsigned short *to = _to;
148 const unsigned short *from = _from;
149 const unsigned short *from_end = _from_end;
152 while(!(FCTL3 & WAIT));
153 }
while(from < from_end);