//***************************************************************************** // //! @brief Set up the stimer. //! //! @param ui32STimerConfig is the value to load into the configuration reg. //! //! This function should be used to perform the initial set-up of the //! stimer. //! //! @return The 32-bit current config of the STimer Config register // //***************************************************************************** uint32_t am_hal_stimer_config(uint32_t ui32STimerConfig) { uint32_t ui32CurrVal; // // Read the current config // ui32CurrVal = AM_REG(CTIMER, STCFG); // // Write our configuration value. // AM_REG(CTIMER, STCFG) = ui32STimerConfig; // // If all of the clock sources are not HFRC, disable LDO when sleeping if timers are enabled. // if ( (AM_BFR(CTIMER, STCFG, CLKSEL) == AM_REG_CTIMER_STCFG_CLKSEL_HFRC_DIV16) || (AM_BFR(CTIMER, STCFG, CLKSEL) == AM_REG_CTIMER_STCFG_CLKSEL_HFRC_DIV256) ) { AM_BFW(PWRCTRL, MISCOPT, DIS_LDOLPMODE_TIMERS, 0); } else { AM_BFW(PWRCTRL, MISCOPT, DIS_LDOLPMODE_TIMERS, 1); } return ui32CurrVal; }
//***************************************************************************** // //! @brief Gets all relevant device information. //! //! @param psDevice is a pointer to a structure that will be used to store all //! device info. //! //! This function gets the device part number, chip IDs, and revision and //! stores them in the passed structure. //! //! @return None // //***************************************************************************** void am_hal_mcuctrl_device_info_get(am_hal_mcuctrl_device_t *psDevice) { // // Read the Part Number. // psDevice->ui32ChipPN = AM_REG(MCUCTRL, CHIP_INFO); // // Read the Chip ID0. // psDevice->ui32ChipID0 = AM_REG(MCUCTRL, CHIPID0); // // Read the Chip ID1. // psDevice->ui32ChipID1 = AM_REG(MCUCTRL, CHIPID1); // // Read the Chip Revision. // psDevice->ui32ChipRev = AM_REG(MCUCTRL, CHIPREV); // // Read the Part Number. // psDevice->ui32ChipPN = AM_REG(MCUCTRL, CHIP_INFO); // // Read the Chip ID0. // psDevice->ui32ChipID0 = AM_REG(MCUCTRL, CHIPID0); // // Read the Chip ID1. // psDevice->ui32ChipID1 = AM_REG(MCUCTRL, CHIPID1); // // Read the Chip Revision. // psDevice->ui32ChipRev = AM_REG(MCUCTRL, CHIPREV); // // Read the Chip VENDOR ID. // psDevice->ui32VendorID = AM_REG(MCUCTRL, VENDORID); // // Qualified from Part Number. // psDevice->ui32Qualified = (psDevice->ui32ChipPN & AM_HAL_MCUCTRL_CHIP_INFO_QUAL_M) >> AM_HAL_MCUCTRL_CHIP_INFO_QUAL_S; // // Flash size from Part Number. // psDevice->ui32FlashSize = g_am_hal_mcuctrl_flash_size[ (psDevice->ui32ChipPN & AM_HAL_MCUCTRL_CHIP_INFO_FLASH_SIZE_M) >> AM_HAL_MCUCTRL_CHIP_INFO_FLASH_SIZE_S]; // // SRAM size from Part Number. // psDevice->ui32SRAMSize = g_am_hal_mcuctrl_flash_size[ (psDevice->ui32ChipPN & AM_HAL_MCUCTRL_CHIP_INFO_SRAM_SIZE_M) >> AM_HAL_MCUCTRL_CHIP_INFO_SRAM_SIZE_S]; // // Now, let's look at the JEDEC info. // The full partnumber is 12 bits total, but is scattered across 2 registers. // Bits [11:8] are 0xE. // Bits [7:4] are 0xE for Apollo, 0xD for Apollo2. // Bits [3:0] are defined differently for Apollo and Apollo2. // For Apollo, the low nibble is 0x0. // For Apollo2, the low nibble indicates flash and SRAM size. // psDevice->ui32JedecPN = (AM_BFR(JEDEC, PID0, PNL8) << 0); psDevice->ui32JedecPN |= (AM_BFR(JEDEC, PID1, PNH4) << 8); // // JEPID is the JEP-106 Manufacturer ID Code, which is assigned to Ambiq as // 0x1B, with parity bit is 0x9B. It is 8 bits located across 2 registers. // psDevice->ui32JedecJEPID = (AM_BFR(JEDEC, PID1, JEPIDL) << 0); psDevice->ui32JedecJEPID |= (AM_BFR(JEDEC, PID2, JEPIDH) << 4); // // CHIPREV is 8 bits located across 2 registers. // psDevice->ui32JedecCHIPREV = (AM_BFR(JEDEC, PID2, CHIPREVH4) << 4); psDevice->ui32JedecCHIPREV |= (AM_BFR(JEDEC, PID3, CHIPREVL4) << 0); // // Let's get the Coresight ID (32-bits across 4 registers) // For Apollo and Apollo2, it's expected to be 0xB105100D. // psDevice->ui32JedecCID = (AM_BFR(JEDEC, CID3, CID) << 24); psDevice->ui32JedecCID |= (AM_BFR(JEDEC, CID2, CID) << 16); psDevice->ui32JedecCID |= (AM_BFR(JEDEC, CID1, CID) << 8); psDevice->ui32JedecCID |= (AM_BFR(JEDEC, CID0, CID) << 0); }