/*---------------------------------------------------------------------------*/ static void set_rime_addr(void) { int i; union { uint8_t u8[8]; } eui64; uint8_t *stm32w_eui64 = ST_RadioGetEui64(); { uint8_t c; /* Copy the EUI-64 to lladdr converting from Little-Endian to Big-Endian. */ for(c = 0; c < 8; c++) { eui64.u8[c] = stm32w_eui64[7 - c]; } } #if UIP_CONF_IPV6 memcpy(&uip_lladdr.addr, &eui64, sizeof(uip_lladdr.addr)); #endif #if UIP_CONF_IPV6 linkaddr_set_node_addr((linkaddr_t *)&eui64); #else linkaddr_set_node_addr((linkaddr_t *)&eui64.u8[8 - LINKADDR_SIZE]); #endif printf("Rime started with address "); for(i = 0; i < sizeof(linkaddr_t) - 1; i++) { printf("%d.", linkaddr_node_addr.u8[i]); } printf("%d\n", linkaddr_node_addr.u8[i]); }
static void txBufferInit(u8 broadcast) { if (broadcast) { txBufferControl.broadcast = TRUE; txBufferControl.retries = 0; txBroadcastBuffer.length = 0; txBroadcastBuffer.fc = 0xc801; txBroadcastBuffer.dstPanID = 0xFFFF; txBroadcastBuffer.dstShortAddr = 0xFFFF; txBroadcastBuffer.srcPanID = IAP_BOOTLOADER_PAN_ID; } else { txBufferControl.broadcast = FALSE; txBufferControl.retries = MAC_ACK_RETRIES; txBuffer.length = 0; txBuffer.fc = 0xcc61; txBuffer.dstPanID = IAP_BOOTLOADER_PAN_ID; } halCommonMemCopy ((void *) TX_BUFFER(srcEui64), ST_RadioGetEui64(), 8); txBufferControl.retryNumber = 0; txBufferControl.status = TX_SUCCESS; txBufferControl.pointer = 0; }
void radio_init() { #ifdef EUI64_TRUNK_ID { uint8_t *eui = ST_RadioGetEui64(); my_addr8_ = eui[0]; my_addr16_ = my_addr8_; } #else { my_addr8_ = MY_ADDR; my_addr16_ = MY_ADDR; } #endif result_1 = ST_RadioSetPowerMode(0x00); #ifdef _STM32W_HIGH_POWER_ // For High Power Module use this uint16_t txPowerMode = 0x0001; //USER_TX_POWER_MODE; // Boost and alternate Tx/RX result_1 = ST_RadioSetPowerMode(txPowerMode); GPIO_PCCFGH = GPIO_PCCFGH & 0xFFFFFF0F; // PC5 GPIO_PCCFGH = GPIO_PCCFGH | 0x00000090; // PC5 = 0x9 - Special function (TX select) // Prepare PB5, PB6, PB7 for controlling the external amplifier GPIO_PBCFGH = GPIO_PBCFGH & 0xFFFF000F; GPIO_PBCFGH = GPIO_PBCFGH | 0x00001110; GPIO_PBCLR = 0x000000E0; GPIO_PBSET = 0x000000C0; // 0xC - enable LNA and activate chip, 0x4 - enable chip (exit sleep) #endif //_STM32W_HIGH_POWER_ my_rf_channel_ = DEFAULT_RF_CHANNEL; my_tx_power_ = DEFAULT_TX_POWER; // configured power level (default for orodinary communication stradio_retransmit_req_ = 0; ST_RadioSetNodeId(MY_ADDR); ST_RadioSetPanId(MY_PAN_ID); result_1 = ST_RadioSetChannel(my_rf_channel_); phy_set_power_level ( my_tx_power_ ); stradio_pending_len_ = 0; stradio_pending_data_ = NULL; stradio_pending_dst_ = 0; sch_add_loop((sch_loop_func_t)radio_loop); // GPIO_PBOUT = }
/*---------------------------------------------------------------------------*/ static void set_rime_addr(void) { int i; union { u8_t u8[8]; }eui64; //rimeaddr_t lladdr; int8u *stm32w_eui64 = ST_RadioGetEui64(); { int8u c; for(c = 0; c < 8; c++) { // Copy the EUI-64 to lladdr converting from Little-Endian to Big-Endian. eui64.u8[c] = stm32w_eui64[7 - c]; } } PRINTF("\n\rRadio EUI-64:"); PRINTLLADDR(eui64); PRINTF("\n\r"); #if UIP_CONF_IPV6 memcpy(&uip_lladdr.addr, &eui64, sizeof(uip_lladdr.addr)); #endif #if UIP_CONF_IPV6 rimeaddr_set_node_addr((rimeaddr_t *)&eui64); #else rimeaddr_set_node_addr((rimeaddr_t *)&eui64.u8[8-RIMEADDR_SIZE]); #endif printf("Rime started with address "); for(i = 0; i < sizeof(rimeaddr_t) - 1; i++) { printf("%d.", rimeaddr_node_addr.u8[i]); } printf("%d\n", rimeaddr_node_addr.u8[i]); }
/*--------------------------------------------------------------------------*/ static radio_result_t get_object(radio_param_t param, void *dest, size_t size) { const uint8_t *eui64; uint8_t *target; int i; if(param == RADIO_PARAM_64BIT_ADDR) { if(size < 8 || !dest) { return RADIO_RESULT_INVALID_VALUE; } eui64 = ST_RadioGetEui64(); if(!eui64) { return RADIO_RESULT_ERROR; } target = dest; for(i = 0; i < 8; i++) { target[i] = eui64[7 - i]; } return RADIO_RESULT_OK; } return RADIO_RESULT_NOT_SUPPORTED; }