//***************************************************************************** // //! @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 Disables the fault capture registers. //! //! This function disables the DCODEFAULTADDR and ICODEFAULTADDR registers. //! //! @return None // //***************************************************************************** void am_hal_mcuctrl_fault_capture_disable(void) { // // Disable the Fault Capture registers. // AM_BFW(MCUCTRL, FAULTCAPTUREEN, ENABLE, 0); }
//***************************************************************************** // //! @brief Start capturing data with the specified capture register. //! //! @param ui32CaptureNum is the Capture Register Number to read (0-3). //! ui32GPIONumber is the pin number. //! bPolarity: false (0) = Capture on low to high transition. //! true (1) = Capture on high to low transition. //! //! Use this function to start capturing. //! //! @return None. // //***************************************************************************** void am_hal_stimer_capture_start(uint32_t ui32CaptureNum, uint32_t ui32GPIONumber, bool bPolarity) { uint32_t ui32CapCtrl; if ( ui32GPIONumber > (AM_HAL_GPIO_MAX_PADS-1) ) { return; } // // Set the polarity and pin selection in the GPIO block. // switch (ui32CaptureNum) { case 0: AM_BFW(GPIO, STMRCAP, STPOL0, bPolarity); AM_BFW(GPIO, STMRCAP, STSEL0, ui32GPIONumber); ui32CapCtrl = AM_REG_CTIMER_CAPTURE_CONTROL_CAPTURE_A_M; break; case 1: AM_BFW(GPIO, STMRCAP, STPOL1, bPolarity); AM_BFW(GPIO, STMRCAP, STSEL1, ui32GPIONumber); ui32CapCtrl = AM_REG_CTIMER_CAPTURE_CONTROL_CAPTURE_B_M; break; case 2: AM_BFW(GPIO, STMRCAP, STPOL2, bPolarity); AM_BFW(GPIO, STMRCAP, STSEL2, ui32GPIONumber); ui32CapCtrl = AM_REG_CTIMER_CAPTURE_CONTROL_CAPTURE_C_M; break; case 3: AM_BFW(GPIO, STMRCAP, STPOL3, bPolarity); AM_BFW(GPIO, STMRCAP, STSEL3, ui32GPIONumber); ui32CapCtrl = AM_REG_CTIMER_CAPTURE_CONTROL_CAPTURE_D_M; break; default: return; // error concealment. } // // Enable it in the CTIMER Block // AM_REG(CTIMER, CAPTURE_CONTROL) |= ui32CapCtrl; }