Example #1
0
void halBoardInit(void)
{
  char boardName[16];
  int8s i;
  boardDescription = NULL;
#ifdef EMBERZNET_HAL
  halCommonGetToken(boardName, TOKEN_MFG_BOARD_NAME);
#else
  halCommonGetMfgToken(boardName, TOKEN_MFG_BOARD_NAME);
#endif

  i = 15;
  while ((i >= 0) && (boardName[i] == 0xFF)) {
    boardName[i] = 0;
    i--;
  }

  for (i = 0; i < (sizeof(boardList)/4) ; i++) 
    if (strcmp(boardName, (boardList[i])->name) == 0) {
      boardDescription = (BoardResourcesType *) boardList[i];
      break;
    }

  if (boardDescription == NULL) {
    /* Board type not identified default to MB851A also to support legacy boards */
    boardDescription = (BoardResourcesType *) &MB851A;
  }
  return;
}
Example #2
0
void halInternalGetMfgTokenData(void *data,
                                int16u token,
                                int8u index,
                                int8u len)
{
  int8u *ram = (int8u*)data;
  
  //0x7F is a non-indexed token.  Remap to 0 for the address calculation
  index = (index==0x7F) ? 0 : index;
  
  if(token == MFG_EUI_64_LOCATION) {
    //There are two EUI64's stored in the Info Blocks, St and Custom.
    //0x0A00 is the address used by the generic EUI64 token, and it is
    //token.c's responbility to pick the returned EUI64 from either St
    //or Custom.  Return the Custom EUI64 if it is not all FF's, otherwise
    //return the St EUI64.
    tokTypeMfgEui64 eui64;
    halCommonGetMfgToken(&eui64, TOKEN_MFG_CUSTOM_EUI_64);
    if(MEMCOMPARE(eui64,nullEui, 8 /*EUI64_SIZE*/) == 0) {
      halCommonGetMfgToken(&eui64, TOKEN_MFG_ST_EUI_64);
    }
    MEMCOPY(ram, eui64, 8 /*EUI64_SIZE*/);
  } else {
    //read from the Information Blocks.  The token ID is only the
    //bottom 16bits of the token's actual address.  Since the info blocks
    //exist in the range DATA_BIG_INFO_BASE-DATA_BIG_INFO_END, we need
    //to OR the ID with DATA_BIG_INFO_BASE to get the real address.
    int32u realAddress = (DATA_BIG_INFO_BASE|token) + (len*index);
    int8u *flash = (int8u *)realAddress;














    MEMCOPY(ram, flash, len);
  }
}
Example #3
0
void stCalibrateVref(void)
{
    // Calibrate Vref by measuring a known voltage, Vdd/2.
    //
    // FIXME: add support for calibration if done in boost mode.
    tokTypeMfgAnalogueTrimBoth biasTrim;

    halCommonGetMfgToken(&biasTrim, TOKEN_MFG_ANALOG_TRIM_BOTH);

    if(biasTrim.auxadc == 0xFFFF)
    {
        assert(FALSE);
    }
    else
    {
        //The bias trim token is set, so use the trim directly
        int16u temp_value;
        int16u mask = 0xFFFF;

        // halClearLed(BOARDLED3);

        while (SCR_BUSY_REG) ;

        SCR_ADDR_REG = AUXADC_REG ;  // prepare the address to write to

        // initiate read (starts on falling edge of SCR_CTRL_SCR_READ)
        SCR_CTRL_REG = SCR_CTRL_SCR_READ_MASK;
        SCR_CTRL_REG = 0;

        // wait for read to complete
        while (SCR_BUSY_REG) ;

        temp_value = SCR_READ_REG & ~mask;
        temp_value |= biasTrim.auxadc & mask;

        SCR_WRITE_REG = temp_value;

        // initiate write (starts on falling edge of SCR_CTRL_SCR_WRITE_MASK)
        SCR_CTRL_REG = SCR_CTRL_SCR_WRITE_MASK;
        SCR_CTRL_REG = 0;

        while (SCR_BUSY_REG) ;

    }
}