interface InternalFlash as IFlash;
interface Crc;
interface Leds;
+#if !defined(PLATFORM_TINYNODE)
interface CC2420Config;
+#endif
async command void setAmAddress(am_addr_t a);
interface ReprogramGuard;
}
command error_t Init.init()
{
BootArgs bootArgs;
- call IFlash.read((uint8_t*)TOSBOOT_ARGS_ADDR, &bootArgs, sizeof(bootArgs));
+ call IFlash.read(TCAST(uint8_t* COUNT(sizeof(bootArgs)),TOSBOOT_ARGS_ADDR), &bootArgs, sizeof(bootArgs));
// Update the local node ID
if (bootArgs.address != 0xFFFF) {
TOS_NODE_ID = bootArgs.address;
call setAmAddress(bootArgs.address);
}
+#if !defined(PLATFORM_TINYNODE)
call CC2420Config.setShortAddr(bootArgs.address);
call CC2420Config.sync();
-
+#endif
return SUCCESS;
}
BootArgs bootArgs;
atomic {
- call IFlash.read((uint8_t*)TOSBOOT_ARGS_ADDR, &bootArgs, sizeof(bootArgs));
+ call IFlash.read(TCAST(uint8_t* COUNT(sizeof(bootArgs)),TOSBOOT_ARGS_ADDR), &bootArgs, sizeof(bootArgs));
if (bootArgs.address != TOS_NODE_ID) {
bootArgs.address = TOS_NODE_ID;
- call IFlash.write((uint8_t*)TOSBOOT_ARGS_ADDR, &bootArgs, sizeof(bootArgs));
+ call IFlash.write(TCAST(uint8_t* COUNT(sizeof(bootArgs)),TOSBOOT_ARGS_ADDR), &bootArgs, sizeof(bootArgs));
}
netprog_reboot();
}
}
atomic {
- call IFlash.read((uint8_t*)TOSBOOT_ARGS_ADDR, &bootArgs, sizeof(bootArgs));
+ call IFlash.read(TCAST(uint8_t* COUNT(sizeof(bootArgs)),TOSBOOT_ARGS_ADDR), &bootArgs, sizeof(bootArgs));
bootArgs.imageAddr = reprogramImgAddr;
bootArgs.gestureCount = 0xff;
bootArgs.noReprogram = FALSE;
bootArgs.address = TOS_NODE_ID;
- call IFlash.write((uint8_t*)TOSBOOT_ARGS_ADDR, &bootArgs, sizeof(bootArgs));
+ call IFlash.write(TCAST(uint8_t* COUNT(sizeof(bootArgs)),TOSBOOT_ARGS_ADDR), &bootArgs, sizeof(bootArgs));
// reboot
netprog_reboot();
}
}
+#if !defined(PLATFORM_TINYNODE)
event void CC2420Config.syncDone(error_t error) {}
+#endif
}