I am reading the RF12demo code, and I think the code below might be imperfect. dfcommand issues a CLI code on the end. this means dfWriteCmd switches off interrupts and never switches them on again. perhaps the dfdeselect and last dfcommand should switch places in dfWriteCmd?
if this code is correct in it's current form, why does it not cause interrupt issues ?
void dfcommand (byte cmd) {
for (;;) {
cli();
dfenable();
dfxfer(0x05); // Read Status Register
byte status = dfxfer(0);
dfdisable();
sei();
// don't wait for ready bit if there is clearly no dataflash connected
if (status == 0xFF || (status & 1) == 0)
break;
}
cli();
dfenable();
dfxfer(cmd);
}
static void dfwriteCmd (byte cmd) {
dfcommand(0x06); // Write Enable
dfdeselect();
dfcommand(cmd);
}
static void dfdeselect () {
dfdisable();
sei();
}
