S32 Design Studio PE工具配置TMR

news2025/1/12 8:02:37

配置步骤

配置内容

生成的配置结构体如下,在Generated_Code路径下的lpTmr.c文件和lpTmr.h文件。

/*! lpTmr1 configuration structure */
const lptmr_config_t lpTmr1_config0 = {
  .workMode = LPTMR_WORKMODE_PULSECOUNTER,
  .dmaRequest = false,
  .interruptEnable = true,
  .freeRun = false,
  .compareValue = 1000U,
  .counterUnits = LPTMR_COUNTER_UNITS_TICKS,
  .clockSelect = LPTMR_CLOCKSOURCE_SIRCDIV2,
  .prescaler = LPTMR_PRESCALE_2,
  .bypassPrescaler = true,
  .pinSelect = LPTMR_PINSELECT_TRGMUX,
  .pinPolarity = LPTMR_PINPOLARITY_RISING,
};

只读也就是这个配置结构体前面加个const

工作模式有Timer计时器和Plus counter脉冲计数器两种

计时器的话就是用作普通计时器,脉冲计数器要选择对应的输入引脚和跟一个叫TRGMUX的模块配合使用。脉冲通过输入引脚给到TRGMUX模块,通过配置SEL寄存器选择输出到TMR模块计算脉冲数量。

DMA请求就是产生对比事件的时候请求DMA帮忙搬运下数据,不然的话就是让CPU来搬运。

中断使能是跟工作模式配合起来的。如果是计时器模式,那就是时间到达产生中断,进入中断函数。如果是脉冲计数器模式,就是脉冲到达一定数量的时候,进入中断函数。

这个中断只是允许定时器产生中断,要调用下INT_SYS_InstallHandler安装中断函数,INT_SYS_EnableIRQ使能。

/* Install IRQ handler for LPTMR interrupt */
INT_SYS_InstallHandler(LPTMR0_IRQn, &lptmrISR, (isr_t *)0);
/* Enable IRQ for LPTMR */
INT_SYS_EnableIRQ(LPTMR0_IRQn);

里面的LPTMR0_IRQn是设备名称,定死的。lptmrISR是中断时进入的函数,自己看着来写就行。

自由运行模式千万不要选,计数器会一直累加,溢出都不管。

对比值就是TMR累加到这个值就产生中断,无论工作模式是计数器模式还是脉冲计数器模式。这个是有最大数值限制的,自己看着来。

对比值单位是根据工作模式来的。如果是计时器模式,就选择微秒。如果是脉冲计数器模式,就选择次数。

输入时钟就是时钟源。

如果工作模式是计数器模式,分频数是自动适配的,不用选择引脚和极性。

如果工作模式是计数器模式,就可以选择分频数和滤波模式,并且选择映射到的引脚和极性。

极性就是在上升沿时刻计数还是下降沿时刻计数。

接口使用

会产生lptmr_driver.c文件和lptmr_driver.h文件,路径在SDK\platform\drivers\src\lptmr和SDK\platform\drivers\inc。

LPTMR_DRV_InitConfigStruct

初始化TMR配置结构体,也就是将配置结构体变成默认配置。

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_InitConfigStruct
 * Description   : Initialize a configuration structure with default values.
 *
 * Implements : LPTMR_DRV_InitConfigStruct_Activity
 *END**************************************************************************/
void LPTMR_DRV_InitConfigStruct(lptmr_config_t * const config)
{
    DEV_ASSERT(config != NULL);

    /* General parameters */
    config->dmaRequest      = false;
    config->interruptEnable = false;
    config->freeRun         = false;
    config->workMode        = LPTMR_WORKMODE_TIMER;

    /* Counter parameters */
    config->clockSelect     = LPTMR_CLOCKSOURCE_SIRCDIV2;
    config->prescaler       = LPTMR_PRESCALE_2;
    config->bypassPrescaler = false;
    config->compareValue    = 0u;
    config->counterUnits    = LPTMR_COUNTER_UNITS_TICKS;

    /* Pulse Counter specific parameters */
    config->pinSelect       = LPTMR_PINSELECT_TRGMUX;
    config->pinPolarity     = LPTMR_PINPOLARITY_RISING;
}

LPTMR_DRV_Init

初始化函数,入参为TMR序号、配置结构体、是否开始计数。

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_Init
 * Description   : Initialize a LPTMR instance based on the input configuration
 * structure.
 *
 * When (counterUnits == LPTMR_COUNTER_UNITS_MICROSECONDS) the function will
 * automatically configure the timer for the input compareValue in microseconds.
 * The input parameters for 'prescaler' and 'bypassPrescaler' will be ignored
 * - their values will be adapted by the function, to best fit the input compareValue
 * (in microseconds) for the operating clock frequency.
 *
 * LPTMR_COUNTER_UNITS_MICROSECONDS may only be used for LPTMR_WORKMODE_TIMER mode.
 * Otherwise the function shall not convert 'compareValue' in ticks
 * and this is likely to cause erroneous behavior.
 *
 * When (counterUnits == LPTMR_COUNTER_UNITS_TICKS) the function will use the
 * 'prescaler' and 'bypassPrescaler' provided in the input configuration structure.
 *
 * When (counterUnits == LPTMR_COUNTER_UNITS_TICKS), 'compareValue' must be lower
 * than 0xFFFFu. Only the least significant 16bits of 'compareValue' will be used.
 * When (counterUnits == LPTMR_COUNTER_UNITS_MICROSECONDS), 'compareValue'
 * may take any 32bits unsigned value.
 *
 * Implements : LPTMR_DRV_Init_Activity
 *END**************************************************************************/
void LPTMR_DRV_Init(const uint32_t instance,
                    const lptmr_config_t * const config,
                    const bool startCounter)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
    DEV_ASSERT(config != NULL);

    LPTMR_Type* const base = g_lptmrBase[instance];

    LPTMR_DRV_SetConfig(instance, config);

    /* Start the counter if requested */
    if (startCounter)
    {
        LPTMR_Enable(base);
    }
}

LPTMR_DRV_SetConfig

将配置结构体的配置信息设置到序号里面的TMR当中。

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_SetConfig
 * Description   : Configure a LPTMR instance based on the input configuration
 * structure.
 *
 * When (counterUnits == LPTMR_COUNTER_UNITS_MICROSECONDS) the function will
 * automatically configure the timer for the input compareValue in microseconds.
 * The input parameters for 'prescaler' and 'bypassPrescaler' will be ignored
 * - their values will be adapted by the function, to best fit the input compareValue
 * (in microseconds) for the operating clock frequency.
 *
 * LPTMR_COUNTER_UNITS_MICROSECONDS may only be used for LPTMR_WORKMODE_TIMER mode.
 * Otherwise the function shall not convert 'compareValue' in ticks
 * and this is likely to cause erroneous behavior.
 *
 * When (counterUnits == LPTMR_COUNTER_UNITS_TICKS) the function will use the
 * 'prescaler' and 'bypassPrescaler' provided in the input configuration structure.
 *
 * When (counterUnits == LPTMR_COUNTER_UNITS_TICKS), 'compareValue' must be lower
 * than 0xFFFFu. Only the least significant 16bits of 'compareValue' will be used.
 * When (counterUnits == LPTMR_COUNTER_UNITS_MICROSECONDS), 'compareValue'
 * may take any 32bits unsigned value.
 *
 * Implements : LPTMR_DRV_SetConfig_Activity
 *END**************************************************************************/
void LPTMR_DRV_SetConfig(const uint32_t instance,
                         const lptmr_config_t * const config)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
    DEV_ASSERT(config != NULL);

    LPTMR_Type* const base          = g_lptmrBase[instance];
    uint32_t configCmpValue         = config->compareValue;
    lptmr_workmode_t configWorkMode = config->workMode;
    uint16_t cmpValueTicks          = 0U;
    lptmr_prescaler_t prescVal      = config->prescaler;
    bool prescBypass                = config->bypassPrescaler;
    lptmr_counter_units_t configCounterUnits = config->counterUnits;

    if(configWorkMode == LPTMR_WORKMODE_TIMER)
    {
        /* A valid clock must be selected when used in Timer Mode. */
        uint32_t clkFreq;
        clkFreq = lptmr_GetClkFreq(config->clockSelect, instance);
        DEV_ASSERT(clkFreq != 0U); /* Clock frequency equal to '0', signals invalid value.  */

        if(configCounterUnits == LPTMR_COUNTER_UNITS_MICROSECONDS)
        {
            bool chooseClkConfigStatus;

            /* When workmode is set to Timer Mode and compare value is provided in microseconds,
             * then the input parameters for prescale value and prescaleBypass are ignored.
             * The prescaleValue, prescaleBypass and cmpValue in ticks, are calculated to best fit
             * the input configCmpValue (in us) for the current operating clk frequency.  */
            chooseClkConfigStatus = lptmr_ChooseClkConfig(clkFreq, configCmpValue, &prescVal, &prescBypass, &cmpValueTicks);
            DEV_ASSERT(chooseClkConfigStatus == true);
            (void) chooseClkConfigStatus;
        }
        else
        {
            DEV_ASSERT(configCounterUnits == LPTMR_COUNTER_UNITS_TICKS);
            DEV_ASSERT(configCmpValue <= LPTMR_CMR_COMPARE_MASK); /* Compare Value in Tick Units must fit in CMR. */

            cmpValueTicks = (uint16_t)(configCmpValue & LPTMR_CMR_COMPARE_MASK);
        }
    }
    else
    {
        /* If configWorkMode is not LPTMR_WORKMODE_TIMER, then it must be LPTMR_WORKMODE_PULSECOUNTER. */
        DEV_ASSERT(configWorkMode == LPTMR_WORKMODE_PULSECOUNTER);

        /* Only LPTMR_COUNTER_UNITS_TICKS can be used when LPTMR is configured as Pulse Counter. */
        DEV_ASSERT(config->counterUnits == LPTMR_COUNTER_UNITS_TICKS);
        /* A valid clock must be selected when glitch filter is enabled (prescaler not bypassed). */
        DEV_ASSERT((lptmr_GetClkFreq(config->clockSelect, instance) != 0u) || prescBypass);
        /* Glitch filter does not support LPTMR_PRESCALE_2. */
        DEV_ASSERT(prescBypass || (prescVal != LPTMR_PRESCALE_2));

        DEV_ASSERT(configCmpValue <= LPTMR_CMR_COMPARE_MASK); /* Compare Value in Tick Units must fit in CMR. */

        cmpValueTicks = (uint16_t)(configCmpValue & LPTMR_CMR_COMPARE_MASK);
    }

    /* Initialize and write configuration parameters. */
    LPTMR_Init(base);

    LPTMR_SetDmaRequest   (base, config->dmaRequest);
    LPTMR_SetInterrupt    (base, config->interruptEnable);
    LPTMR_SetFreeRunning  (base, config->freeRun);
    LPTMR_SetWorkMode     (base, configWorkMode);
    LPTMR_SetPrescaler    (base, prescVal);
    LPTMR_SetBypass       (base, prescBypass);
    LPTMR_SetClockSelect  (base, config->clockSelect);
    LPTMR_SetCompareValue (base, cmpValueTicks);
    LPTMR_SetPinSelect    (base, config->pinSelect);
    LPTMR_SetPinPolarity  (base, config->pinPolarity);
}

LPTMR_DRV_GetConfig

获取配置结构体信息

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_GetConfig
 * Description   : Get the current configuration of the LPTMR instance.
 * Always returns compareValue in LPTMR_COUNTER_UNITS_TICKS.
 *
 * Implements : LPTMR_DRV_GetConfig_Activity
 *END**************************************************************************/
void LPTMR_DRV_GetConfig(const uint32_t instance,
                         lptmr_config_t * const config)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
    DEV_ASSERT(config != NULL);

    const LPTMR_Type* const base = g_lptmrBase[instance];

    /* Read current configuration */
    config->dmaRequest      = LPTMR_GetDmaRequest(base);
    config->interruptEnable = LPTMR_GetInterruptEnable(base);
    config->freeRun         = LPTMR_GetFreeRunning(base);
    config->workMode        = LPTMR_GetWorkMode(base);
    config->prescaler       = LPTMR_GetPrescaler(base);
    config->bypassPrescaler = LPTMR_GetBypass(base);
    config->clockSelect     = LPTMR_GetClockSelect(base);
    config->compareValue    = LPTMR_GetCompareValue(base);
    config->counterUnits    = LPTMR_COUNTER_UNITS_TICKS;
    config->pinSelect       = LPTMR_GetPinSelect(base);
    config->pinPolarity     = LPTMR_GetPinPolarity(base);
}

LPTMR_DRV_Deinit

逆初始化

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_Deinit
 * Description   : De-initialize the LPTMR (stop the counter and reset all registers to default value).
 *
 * Implements : LPTMR_DRV_Deinit_Activity
 *END**************************************************************************/
void LPTMR_DRV_Deinit(const uint32_t instance)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    LPTMR_Type* const base = g_lptmrBase[instance];
    LPTMR_Disable(base);

    LPTMR_Init(base);
}

LPTMR_DRV_SetCompareValueByCount

设置对比值

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_SetCompareValueByCount
 * Description   : Set the compare value in counter tick units, for a LPTMR instance.
 * Possible return values:
 * - STATUS_SUCCESS: completed successfully
 * - STATUS_ERROR: cannot reconfigure compare value (TCF not set)
 * - STATUS_TIMEOUT: compare value is smaller than current counter value
 *
 * Implements : LPTMR_DRV_SetCompareValueByCount_Activity
 *END**************************************************************************/
status_t LPTMR_DRV_SetCompareValueByCount(const uint32_t instance,
                                          const uint16_t compareValueByCount)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    LPTMR_Type* const base  = g_lptmrBase[instance];
    status_t statusCode     = STATUS_SUCCESS;

    bool timerEnabled = LPTMR_GetEnable(base);
    bool compareFlag  = LPTMR_GetCompareFlag(base);

    uint16_t counterVal;

    /* Check if a valid clock is selected for the timer/glitch filter */
#if (defined (DEV_ERROR_DETECT) || defined (CUSTOM_DEVASSERT))
    bool bypass = LPTMR_GetBypass(base);
    lptmr_workmode_t workMode = LPTMR_GetWorkMode(base);
    (void) bypass;
    (void) workMode;
#endif /* (defined (DEV_ERROR_DETECT) || defined (CUSTOM_DEVASSERT)) */
    DEV_ASSERT((lptmr_GetClkFreq(LPTMR_GetClockSelect(base), instance) != 0u) || \
               (bypass && (workMode == LPTMR_WORKMODE_PULSECOUNTER)));


    /* The compare value can only be written if counter is disabled or the compare flag is set. */
    if (timerEnabled && !compareFlag)
    {
        statusCode = STATUS_ERROR;
    }
    else
    {
        /* Check if new value is below the current counter value */
        LPTMR_SetCompareValue(base, compareValueByCount);
        counterVal = LPTMR_GetCounterValue(base);
        if (counterVal >= compareValueByCount)
        {
            statusCode = STATUS_TIMEOUT;
        }
    }

    return statusCode;
}

LPTMR_DRV_GetCompareValueByCount

获取对比值

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_GetCompareValueByCount
 * Description   : Get the compare value of timer in ticks units.
 *
 * Implements : LPTMR_DRV_GetCompareValueByCount_Activity
 *END**************************************************************************/
void LPTMR_DRV_GetCompareValueByCount(const uint32_t instance,
                                      uint16_t * const compareValueByCount)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    const LPTMR_Type* const base = g_lptmrBase[instance];

    *compareValueByCount = LPTMR_GetCompareValue(base);
}

LPTMR_DRV_SetCompareValueByUs

设置对比值,需要工作模式为计时器

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_SetCompareValueUs
 * Description   : Set the compare value for Timer Mode in microseconds,
 * for a LPTMR instance.
 * Can be used only in Timer Mode.
 * Possible return values:
 * - STATUS_SUCCESS: completed successfully
 * - STATUS_ERROR: cannot reconfigure compare value
 * - STATUS_TIMEOUT: compare value greater then current counter value
 *
 * Implements : LPTMR_DRV_SetCompareValueByUs_Activity
 *END**************************************************************************/
status_t LPTMR_DRV_SetCompareValueByUs(const uint32_t instance,
                                       const uint32_t compareValueUs)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    status_t returnCode     = STATUS_SUCCESS;
    LPTMR_Type* const base  = g_lptmrBase[instance];
    bool timerEnabled, compareFlag;

    lptmr_clocksource_t clkSrc;
    uint32_t clkFreq;
    uint16_t cmpValTicks, currentCounterVal;
    lptmr_prescaler_t prescVal;
    bool prescBypass, conversionStatus;

    /* This function can only be used if LPTMR is configured in Timer Mode. */
    DEV_ASSERT(LPTMR_GetWorkMode(base) == LPTMR_WORKMODE_TIMER);

    timerEnabled = LPTMR_GetEnable(base);
    compareFlag  = LPTMR_GetCompareFlag(base);
    /* The compare value can only be written if counter is disabled or the compare flag is set. */
    if (timerEnabled && !compareFlag)
    {
        returnCode = STATUS_ERROR;
    }
    else
    {
        clkSrc  = LPTMR_GetClockSelect(base);
        clkFreq = lptmr_GetClkFreq(clkSrc, instance);
        DEV_ASSERT(clkFreq != 0U); /* Check the calculated clock frequency: '0' - invalid*/

        /* Get prescaler value and prescaler bypass state.*/
        prescVal    = LPTMR_GetPrescaler(base);
        prescBypass = LPTMR_GetBypass(base);
        /* Convert new compare value from microseconds to ticks. */
        conversionStatus = lptmr_Us2Ticks(clkFreq, prescVal, prescBypass, compareValueUs, &cmpValTicks);
        DEV_ASSERT(conversionStatus == true); /* Check the conversion status: compareValueUs doesn't fit for current prescaller. */
        (void) conversionStatus;

        /* Write value and check if written successfully */
        LPTMR_SetCompareValue(base, cmpValTicks);
        currentCounterVal = LPTMR_GetCounterValue(base);

        if (currentCounterVal >= cmpValTicks)
        {
            returnCode = STATUS_TIMEOUT;
        }
    }

    return returnCode;
}

LPTMR_DRV_GetCompareValueByUs

获取对比值,需要工作模式为计时器

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_GetCompareValueByUs
 * Description   : Get the compare value in microseconds representation.
 * Can be used only in Timer Mode.
 *
 * Implements : LPTMR_DRV_GetCompareValueByUs_Activity
 *END**************************************************************************/
void LPTMR_DRV_GetCompareValueByUs(const uint32_t instance,
                                   uint32_t * const compareValueUs)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);
    DEV_ASSERT(compareValueUs != NULL);

    const LPTMR_Type* const base = g_lptmrBase[instance];
    lptmr_clocksource_t clkSrc;
    uint32_t clkFreq;
    uint16_t cmpValTicks;
    lptmr_prescaler_t prescVal;
    bool prescBypass, conversionStatus;

    /* This function can only be used if LPTMR is configured in Timer Mode. */
    DEV_ASSERT(LPTMR_GetWorkMode(base) == LPTMR_WORKMODE_TIMER);

    clkSrc  = LPTMR_GetClockSelect(base);
    clkFreq = lptmr_GetClkFreq(clkSrc, instance);
    /* The clock frequency must be valid. */
    DEV_ASSERT(clkFreq != 0U);

    /* Get prescaler value and prescaler bypass state.*/
    prescVal    = LPTMR_GetPrescaler(base);
    prescBypass = LPTMR_GetBypass(base);
    cmpValTicks = LPTMR_GetCompareValue(base);

    /* Convert current compare value from ticks to microseconds. */
    conversionStatus = lptmr_Ticks2Us(clkFreq, prescVal, prescBypass, cmpValTicks, compareValueUs);
    DEV_ASSERT(conversionStatus == true); /* Check the conversion status. */
    (void) conversionStatus;
}

LPTMR_DRV_GetCompareFlag

它获取的对比标志位的意思是比较事件是否触发

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_GetCompareFlag
 * Description   : Get the current state of the Compare Flag of a LPTMR instance
 *
 * Implements : LPTMR_DRV_GetCompareFlag_Activity
 *END**************************************************************************/
bool LPTMR_DRV_GetCompareFlag(const uint32_t instance)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    const LPTMR_Type* const base = g_lptmrBase[instance];
    bool compareFlag = LPTMR_GetCompareFlag(base);

    return compareFlag;
}

LPTMR_DRV_ClearCompareFlag

清除对比标志位

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_ClearCompareFlag
 * Description   : Clear the Compare Flag.
 *
 * Implements : LPTMR_DRV_ClearCompareFlag_Activity
 *END**************************************************************************/
void LPTMR_DRV_ClearCompareFlag(const uint32_t instance)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    LPTMR_Type* const base = g_lptmrBase[instance];

    LPTMR_ClearCompareFlag(base);
}

LPTMR_DRV_IsRunning

查看TMR是否在运行

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_IsRunning
 * Description   : Get the running state of a LPTMR instance.
 * Possible return values:
 * - true: Timer/Counter started
 * - false: Timer/Counter stopped
 *
 * Implements : LPTMR_DRV_IsRunning_Activity
 *END**************************************************************************/
bool LPTMR_DRV_IsRunning(const uint32_t instance)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    const LPTMR_Type* const base = g_lptmrBase[instance];

    bool runningState = LPTMR_GetEnable(base);

    return runningState;
}

LPTMR_DRV_SetInterrupt

设置是否开启中断

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_SetInterrupt
 * Description   : Enable/disable the LPTMR interrupt.
 *
 * Implements : LPTMR_DRV_SetInterrupt_Activity
 *END**************************************************************************/
void LPTMR_DRV_SetInterrupt(const uint32_t instance,
                            const bool enableInterrupt)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    LPTMR_Type* const base = g_lptmrBase[instance];

    LPTMR_SetInterrupt(base, enableInterrupt);
}

LPTMR_DRV_GetCounterValueByCount

获取计数器值,需要工作模式为脉冲计数器

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_GetCounterValueTicks
 * Description   : Get the current Counter Value in timer ticks representation.
 * Return:
 *  - the counter value.
 *
 * Implements : LPTMR_DRV_GetCounterValueByCount_Activity
 *END**************************************************************************/
uint16_t LPTMR_DRV_GetCounterValueByCount(const uint32_t instance)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    LPTMR_Type* const base = g_lptmrBase[instance];

    uint16_t counterVal = LPTMR_GetCounterValue(base);

    return counterVal;
}

LPTMR_DRV_StartCounter

开始计时

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_StartCounter
 * Description   : Enable (start) the counter.
 *
 * Implements : LPTMR_DRV_StartCounter_Activity
 *END**************************************************************************/
void LPTMR_DRV_StartCounter(const uint32_t instance)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    LPTMR_Type* const base = g_lptmrBase[instance];

    /* Check if a valid clock is selected for the timer/glitch filter */
#if (defined (DEV_ERROR_DETECT) || defined (CUSTOM_DEVASSERT))
    bool bypass = LPTMR_GetBypass(base);
    lptmr_workmode_t workMode = LPTMR_GetWorkMode(base);
    (void) bypass;
    (void) workMode;
#endif /* (defined (DEV_ERROR_DETECT) || defined (CUSTOM_DEVASSERT)) */
    DEV_ASSERT((lptmr_GetClkFreq(LPTMR_GetClockSelect(base), instance) != 0u) || \
               (bypass && (workMode == LPTMR_WORKMODE_PULSECOUNTER)));

    LPTMR_Enable(base);
}

LPTMR_DRV_StopCounter

停止工作

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_StopCounter
 * Description   : Disable (stop) the counter.
 *
 * Implements : LPTMR_DRV_StopCounter_Activity
 *END**************************************************************************/
void LPTMR_DRV_StopCounter(const uint32_t instance)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    LPTMR_Type* const base = g_lptmrBase[instance];

    LPTMR_Disable(base);
}

LPTMR_DRV_SetPinConfiguration

设置脉冲计数的引脚和极性

/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_SetPinConfiguration
 * Description   : Set the Input Pin configuration for Pulse Counter mode.
 *
 * Implements : LPTMR_DRV_SetPinConfiguration_Activity
 *END**************************************************************************/
void LPTMR_DRV_SetPinConfiguration(const uint32_t instance,
                                   const lptmr_pinselect_t pinSelect,
                                   const lptmr_pinpolarity_t pinPolarity)
{
    DEV_ASSERT(instance < LPTMR_INSTANCE_COUNT);

    LPTMR_Type* const base = g_lptmrBase[instance];

    LPTMR_SetPinSelect(base, pinSelect);
    LPTMR_SetPinPolarity(base, pinPolarity);
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1471322.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

《高质量的C/C++编程规范》学习

目录 一、编程规范基础知识 1、头文件 2、程序的板式风格 3、命名规则 二、表达式和基本语句 1、运算符的优先级 2、复合表达式 3、if语句 4、循环语句的效率 5、for循环语句 6、switch语句 三、常量 1、#define和const比较 2、常量定义规则 四、函数设计 1、参…

npm i卡在 idealTree buildDeps没反应的解决方案

通过git clone拉下项目后&#xff0c;进行项目的初始化下包时&#xff0c;发现npm i 并没有反应&#xff08;如图&#xff09;&#xff1a; 关键点&#xff1a;IdealTree 1.网络问题 确保你的网络连接正常&#xff0c;能够正常访问 npm 仓库。有时网络问题可能导致包无法正确…

GitHub下载器,老司机懂的都懂!

有些老司机或者做项目的小伙伴对GitHub应该不陌生吧&#xff0c;然而GitHub的下载速度非常让人不忍直视&#xff01; 而GitHub高速下载器是一款专门用于加速在GitHub上下载资源的软件&#xff0c;解决了许多用户在下载GitHub资源时遭遇的速度慢和下载失败的问题。 本教程将详细…

代码随想录算法训练营第62天 | 739.每日温度 496.下一个更大元素I

每日温度 如果我们单纯的遍历数组&#xff0c;我们不知道当前元素是否比之前的元素大&#xff0c;所以需要维护一个容器来记录遍历过的元素。 什么时候用单调栈&#xff1f;通常是一维数组&#xff0c;要寻找任一个元素的右边或左边第一个比自己大或小的元素的位置。时间复杂度…

Connection管理类实现(模块六)

目录 类功能 类定义 类实现 编译 本文使用了自定的Any类 Any类的简单实现-CSDN博客 类功能 类定义 // DISCONECTED -- 连接关闭状态 CONNECTING -- 连接建立成功-待处理状态 // CONNECTED -- 连接建立完成,各种设置已完成,可以通信状态 DISCONNECTING -- 待关闭状态 t…

每日五道java面试题之spring篇(六)

目录&#xff1a; 第一题 ApplicationContext通常的实现是什么&#xff1f;第二题 什么是Spring的依赖注入&#xff1f;第三题 依赖注入的基本原则第四题 依赖注入有什么优势&#xff1f;第五题 有哪些不同类型的依赖注入实现方式&#xff1f; 第一题 ApplicationContext通常的…

基于频率增强的数据增广的视觉语言导航方法(VLN论文阅读)

基于频率增强的数据增广的视觉语言导航方法&#xff08;VLN论文阅读&#xff09; 摘要 视觉和语言导航&#xff08;VLN&#xff09;是一项具有挑战性的任务&#xff0c;它需要代理基于自然语言指令在复杂的环境中导航。 在视觉语言导航任务中&#xff0c;之前的研究主要是在空间…

pycharm如何设置滚轮缩放代码大小?

左上角的File找到设置&#xff0c;或者快捷键ctrlalts。 弹出对话框&#xff0c;手动输入mouse&#xff0c;点击general&#xff0c;勾选改变字体大小&#xff0c;ok确认

转前端了!!

大家好&#xff0c;我是冰河~~ 没错&#xff0c;为了更好的设计和开发分布式IM即时通讯系统&#xff0c;也为了让大家能够直观的体验到分布式IM即时通讯系统的功能&#xff0c;冰河开始转战前端了。也就是说&#xff0c;整个项目从需求立项到产品设计&#xff0c;从架构设计到…

ubuntu20.04中配置Pyrep和CoppeliaSim

ubuntu20.04中配置Pyrep和CoppeliaSim 在Ubuntu20.04中配置 Pyrep &#xff0c;实现应用Python语言的机器人在 Vrep&#xff08;CoppeliaSim&#xff09;中的虚拟仿真 一、安装CoppeliaSim 4.1 1.1 下载适配Ubuntu20.04的CoppeliaSim 4.1软件 下载链接&#xff1a;https://…

【前端素材】推荐优质后台管理系统Dashy平台模板(附源码)

一、需求分析 后台管理系统&#xff08;或称作管理后台、管理系统、后台管理平台&#xff09;是一种专门用于管理网站、应用程序或系统后台运营的软件系统。它通常由一系列功能模块组成&#xff0c;为管理员提供了管理、监控和控制网站或应用程序的各个方面的工具和界面。以下…

Nginx实现平滑升级

平滑升级 本篇目标&#xff1a;将现有的 nginx 1.22.0 版本升级为 1.24.0 //查看现有版本 [root12 ~]# nginx -v nginx version: nginx/1.22.01、首先在官网下载软件包&#xff0c;地址&#xff1a;nginx: download 2、把要 1.24.0 拖进 /opt 目录后&#xff0c;解压&#xf…

抖店是怎么运营做起来的?一文详解抖店的运营逻辑和流程,可收藏

我是王路飞。 很多人都知道现在的抖音有【商城】&#xff0c;进入之后就是一个个的抖音小店了&#xff0c;也知道抖店的红利。 但是抖店具体是怎么运营并且做起来的&#xff0c;就不太清楚了&#xff0c;因此很多新手明明眼馋抖店的红利&#xff0c;却又无从下手。 今天这篇…

YOLOv9尝鲜测试五分钟极简配置

pip安装python包&#xff1a; pip install yolov9pip在https://github.com/WongKinYiu/yolov9/tree/main中下载好权重文件yolov9-c.pt。 运行下面代码&#xff1a; import yolov9model yolov9.load("yolov9-c.pt", device"cpu") # load pretrained or c…

Spring综合漏洞利用工具

Spring综合漏洞利用工具 工具目前支持Spring Cloud Gateway RCE(CVE-2022-22947)、Spring Cloud Function SpEL RCE (CVE-2022-22963)、Spring Framework RCE (CVE-2022-22965) 的检测以及利用&#xff0c;目前仅为第一个版本&#xff0c;后续会添加更多漏洞POC&#xff0c;以及…

【Flink精讲】Flink性能调优:CPU核数与并行度

常见问题 举个例子 提交任务命令&#xff1a; bin/flink run \ -t yarn-per-job \ -d \ -p 5 \ 指定并行度 -Dyarn.application.queuetest \ 指定 yarn 队列 -Djobmanager.memory.process.size2048mb \ JM2~4G 足够 -Dtaskmanager.memory.process.size4096mb \ 单个 TM2~8G 足…

【机器人学导论笔记】三、操作臂正运动学

3.1 概述 操作臂正运动学研究操作臂的运动特性&#xff0c;主要涉及与运动有关的几何参数和时间参数。本章中&#xff0c;只研究静止状态下操作臂连杆的位置和姿态。 处理这些复杂的几何参数需要一些步骤&#xff1a;首先需要在操作臂的每个连杆上分别固接一个连杆坐标系&…

基于ELFBoard开发板的车牌识别系统

本项目采用的是ElfBoard ELF1开发板作为项目的核心板&#xff0c;主要实现的功能为通过USB 摄像头对车牌进行识别&#xff0c;如果识别成功则会亮绿灯&#xff0c;并将识别的车牌号上传到手机APP上面&#xff0c;车牌识别的实现是通过百度OCR进行实现&#xff0c;手机APP是用Ja…

《低功耗方法学》翻译——第十四章:电源切换网络设计

第十四章&#xff1a;电源切换网络设计 功率门控是在待机或休眠模式下降低漏电功率最有效的方法&#xff0c;但这种方法存在诸如休眠晶体管占用的硅面积、永久和虚拟电源网络的布线资源以及复杂的功率门控设计和实现过程等开销&#xff0c;影响设计风险和进度。 除了开销外&a…

2024年Facebook自动回复优化指南:提升客户满意度的策略(内含自动回复中英文模板)

在这个数字化的时代&#xff0c;快速响应已经成为企业在与客户沟通的必备要素。但是当经常面对大量的相同信息时&#xff0c;如何可以提高效率呢&#xff1f;目前很多社交媒体平台都内设了自动回复功能&#xff0c;像是Facebook。这个功能确保无论何时有人联系你&#xff0c;都…