/*---------------------------------------------------------------------------*/ static void set_rime_addr(void) { uint8_t *addr_long = NULL; uint16_t addr_short = 0; char i; __xdata unsigned char * macp = &X_IEEE_ADDR; PUTSTRING("Rime is 0x"); PUTHEX(sizeof(rimeaddr_t)); PUTSTRING(" bytes long\n"); PUTSTRING("Reading MAC from Info Page\n"); for(i = (RIMEADDR_SIZE - 1); i >= 0; --i) { rimeaddr_node_addr.u8[i] = *macp; macp++; } /* Now the address is stored MSB first */ #if STARTUP_VERBOSE PUTSTRING("Rime configured with address "); for(i = 0; i < RIMEADDR_SIZE - 1; i++) { PUTHEX(rimeaddr_node_addr.u8[i]); PUTCHAR(':'); } PUTHEX(rimeaddr_node_addr.u8[i]); PUTCHAR('\n'); #endif cc2530_rf_set_addr(IEEE802154_PANID); }
//added by dongbo huang, this is to set the short address of this node static void set_rime_addr(void) { signed char i; #if CC2530_CONF_MAC_FROM_PRIMARY unsigned char __xdata *macp = &X_IEEE_ADDR; #else unsigned char __code *macp = (__code unsigned char *)0xFFE8; #endif //#if CC2530_CONF_MAC_FROM_PRIMARY // putstring("Reading MAC from Info Page\r\n"); //#else // putstring("Reading MAC from flash\r\n"); /* * The MAC is always stored in 0xFFE8 of the highest BANK of our flash. This * maps to address 0xFFF8 of our CODE segment, when this BANK is selected. * Load the bank, read 8 bytes starting at 0xFFE8 and restore last BANK. * Since we are called from main(), this MUST be BANK1 or something is very * wrong. This code can be used even without a bankable firmware. */ /* Don't interrupt us to make sure no BANK switching happens while working */ // DISABLE_INTERRUPTS(); /* Switch to the BANKn, * map CODE: 0x8000 - 0xFFFF to FLASH: 0xn8000 - 0xnFFFF */ // FMAP = CC2530_LAST_FLASH_BANK; //#endif for(i = (RIMEADDR_SIZE - 1); i >= 0; --i) { rimeaddr_node_addr.u8[i] = *macp; macp++; } #if !CC2530_CONF_MAC_FROM_PRIMARY /* Remap 0x8000 - 0xFFFF to BANK1 */ FMAP = 1; ENABLE_INTERRUPTS(); #endif /* Now the address is stored MSB first */ #if STARTUP_CONF_VERBOSE putstring("Rime configured with address "); for(i = 0; i < RIMEADDR_SIZE - 1; i++) { puthex(rimeaddr_node_addr.u8[i]); putchar(':'); } puthex(rimeaddr_node_addr.u8[i]); putstring("\r\n"); #endif cc2530_rf_set_addr(IEEE802154_PANID); return; }
/*---------------------------------------------------------------------------*/ static void set_rime_addr(void) { uint8_t *addr_long = NULL; uint16_t addr_short = 0; int8_t i; #ifdef SDCC __xdata unsigned char * macp = &X_IEEE_ADDR; #else volatile unsigned char * macp = &X_IEEE_ADDR; // IEEE地址 位于XDATA 780C #endif PUTSTRING("Rime is 0x"); PUTHEX(sizeof(rimeaddr_t)); PUTSTRING(" bytes long\r\n"); PUTSTRING("Reading MAC from Info Page\r\n"); // 从INFO中取MAC地址, for(i = (RIMEADDR_SIZE - 1); i >= 0; --i) { rimeaddr_node_addr.u8[i] = *macp; macp++; } /* Now the address is stored MSB first */ #if STARTUP_VERBOSE // 显示MAC地址 PUTSTRING("Rime configured with address "); for(i = 0; i < RIMEADDR_SIZE - 1; i++) { PUTHEX(rimeaddr_node_addr.u8[i]); PUTCHAR(':'); } PUTHEX(rimeaddr_node_addr.u8[i]); PUTCHAR('\r');PUTCHAR('\n'); PUTSTRING("**************************************\r\n"); #endif cc2530_rf_set_addr(IEEE802154_PANID); // 设置PANID }