7 #define DEBUG DEBUG_FULL
10 mc1322xConfig mc1322x_config;
12 void dump_bytes(uint32_t addr, uint16_t num);
15 void mc1322x_config_set_default(mc1322xConfig *c) {
17 c->magic = MC1322X_CONFIG_MAGIC;
18 c->version = MC1322X_CONFIG_VERSION;
20 c->channel = RF_CHANNEL - 11;
22 c->flags.demod = DEMOD_DCD;
23 c->flags.autoack = AUTOACK;
24 nvm_detect(gNvmInternalInterface_c, &type);
25 c->flags.nvmtype = type;
29 void mc1322x_config_save(mc1322xConfig *c) {
31 err = nvm_erase(gNvmInternalInterface_c, c->flags.nvmtype, 1 << MC1322X_CONFIG_PAGE/4096);
32 err = nvm_write(gNvmInternalInterface_c, c->flags.nvmtype, (uint8_t *)c, MC1322X_CONFIG_PAGE,
sizeof(mc1322xConfig));
36 void mc1322x_config_restore(mc1322xConfig *c) {
39 if (c->flags.nvmtype == 0) { nvm_detect(gNvmInternalInterface_c, &type); }
40 c->flags.nvmtype = type;
41 err = nvm_read(gNvmInternalInterface_c, c->flags.nvmtype, c, MC1322X_CONFIG_PAGE,
sizeof(mc1322xConfig));
45 int mc1322x_config_valid(mc1322xConfig *c) {
46 if (c->magic == MC1322X_CONFIG_MAGIC &&
47 c->version == MC1322X_CONFIG_VERSION) {
51 if (c->magic != MC1322X_CONFIG_MAGIC) { PRINTF(
"config bad magic %04x\n\r", c->magic); }
52 if (c->version != MC1322X_CONFIG_MAGIC) { PRINTF(
"config bad version %04x\n\r", c->version); }
58 void mc1322x_config_print(
void) {
60 PRINTF(
"mc1322x config:\n\r");
61 PRINTF(
" magic: %04x\n\r", mc1322x_config.magic);
62 PRINTF(
" version: %d\n\r", mc1322x_config.version);
63 PRINTF(
" eui: %08x%08x\n\r", (uint32_t)(mc1322x_config.eui>>32), (uint32_t)(mc1322x_config.eui & 0xffffffff));
64 PRINTF(
" channel: %d\n\r", mc1322x_config.channel);
65 PRINTF(
" power: %d\n\r", mc1322x_config.power);
66 PRINTF(
" flags: %08x\n\r", mc1322x_config.flags);
67 PRINTF(
" demod: %d\n\r", mc1322x_config.flags.demod);
68 PRINTF(
" autoack: %d\n\r", mc1322x_config.flags.autoack);
69 PRINTF(
" nvm type: %d\n\r", mc1322x_config.flags.nvmtype);
72 void dump_bytes(uint32_t addr, uint16_t num) {
77 err = nvm_read(gNvmInternalInterface_c, mc1322x_config.flags.nvmtype, (uint8_t *)buf, addr, num);
78 PRINTF(
"nvm_read returned: 0x%02x\r\n", err);
80 for(i=0; i < num/4; i++) {
81 printf(
"0x%08x\r\n", (
unsigned int)buf[i]);
A set of debugging macros.