Beispiel #1
0
void cmd_chibi_addr(uint8_t argc, char **argv)
{
  if (argc > 0)
  {
    // Try to convert supplied value to an integer
    int32_t addr;
    getNumber (argv[0], &addr);
    
    // Check for invalid values (getNumber may complain about this as well)
    if (addr <= 0 || addr > 0xFFFF)
    {
      printf("Invalid Address: 1-65534 or 0x0001-0xFFFE required.%s", CFG_PRINTF_NEWLINE);
      return;
    }
    if (addr == 0xFFFF)
    {
      printf("Invalid Address: 0xFFFF  reserved for broadcast.%s", CFG_PRINTF_NEWLINE);
      return;
    }

    // Write address to EEPROM and update peripheral control block
    chb_set_short_addr((uint16_t)addr);
    chb_pcb_t *pcb = chb_get_pcb();
    printf("Address set to: 0x%04X%s", pcb->src_addr, CFG_PRINTF_NEWLINE);
  }
  else
  {
    // Display the current address
    chb_pcb_t *pcb = chb_get_pcb();
    printf("0x%04X%s", pcb->src_addr, CFG_PRINTF_NEWLINE);
  }
}
Beispiel #2
0
void chibiSetShortAddr(uint16_t addr)
{
    chb_set_short_addr(addr);
}