ftimer_tacho_g.c 2.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
/*
 * Copyright : (C) 2022 Phytium Information Technology, Inc.
 * All Rights Reserved.
 *
 * This program is OPEN SOURCE software: you can redistribute it and/or modify it
 * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
 * either version 1.0 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the Phytium Public License for more details.
 *
 *
 * FilePath: ftimer_tacho_g.c
 * Date: 2022-02-10 14:53:42
 * LastEditTime: 2022-02-18 09:09:07
 * Description:  This files is for
 *
 * Modify History:
 *  Ver   Who        Date         Changes
 * ----- ------     --------    --------------------------------------
 */

/***************************** Include Files *********************************/

#include <string.h>
#include "fparameters.h"
#include "fassert.h"
#include "ftimer_tacho_hw.h"
#include "ftimer_tacho.h"

#define TACHO_PERIOD 1000000 /* 1000000/50000000 = 0.02s*/
/************************** Function Prototypes ******************************/
void FTimerGetDefConfig(u32 timer_id, FTimerTachoConfig *config_p)
{
    FASSERT((timer_id < TIMER_NUM) && (NULL != config_p));

    memset(config_p, 0, sizeof(FTimerTachoConfig));
    config_p->id = timer_id;
    config_p->work_mode  = FTIMER_WORK_MODE_TIMER;
    config_p->timer_mode = FTIMER_RESTART;
    config_p->timer_bits = FTIMER_32_BITS;
    config_p->cmp_type = FTIMER_CYC_CMP;
    config_p->clear_cnt  = FALSE;
    config_p->force_load = TRUE;
}

void FTachoGetDefConfig(u32 tacho_id, FTimerTachoConfig *config_p)
{
    FASSERT((tacho_id < TACHO_NUM) && (NULL != config_p));

    memset(config_p, 0, sizeof(FTimerTachoConfig));
    config_p->id = tacho_id;
    config_p->timer_bits = FTIMER_32_BITS;
    config_p->work_mode = FTIMER_WORK_MODE_TACHO;
    config_p->timer_mode = FTIMER_RESTART;
    config_p->edge_mode = FTACHO_RISING_EDGE;
    config_p->jitter_level = 0;
    config_p->plus_num = TACHO_PERIOD;/*采样周期越长,能够检测到的单位时间脉冲越多,能够检测更小的频率*/
    config_p->clear_cnt = FALSE;
    config_p->force_load = TRUE;
}