hpw421初始版本
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
/*!
|
||||
* \file qdec.c
|
||||
*
|
||||
* \brief Target qdec implementation
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
/*------------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
--------------------------------------------------------------------------------------*/
|
||||
#include "qdec.h"
|
||||
#include "xc6xxx_hal_qdec.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief
|
||||
*
|
||||
* @param[in]
|
||||
* @param[in]
|
||||
****************************************************************************************
|
||||
*/
|
||||
void qdec_demo(void) {
|
||||
DEBUG("__QDEC_DEMO__\n");
|
||||
|
||||
DEBUG("0_XC_QDEC->QDEC_CTL[0x%08x]: %08x\n", &XC_QDEC->QDEC_CTL,
|
||||
XC_QDEC->QDEC_CTL);
|
||||
QDEC_InitCfg qdec_config;
|
||||
qdec_config.Auto_Clr_En = DISABLE;
|
||||
qdec_config.Single_Sample_Rst_En = DISABLE;
|
||||
qdec_config.DB_Filter_En = ENABLE;
|
||||
qdec_config.Acc_Sample_Div = QDEC_DIVIDE_DIV_1024;
|
||||
qdec_config.Pts_Sampled = QDEC_PTS_NUM_80;
|
||||
qdec_config.DB_Sample_Div = QDEC_DB_SAMP_DIV_32;
|
||||
|
||||
QDEC_Init(XC_QDEC, &qdec_config);
|
||||
// XC_QDEC->QDEC_CTL = 0x01;
|
||||
DEBUG("1_XC_QDEC->QDEC_CTL[0x%08x]: %08x\n", &XC_QDEC->QDEC_CTL,
|
||||
XC_QDEC->QDEC_CTL);
|
||||
DEBUG("XC_QDEC->SAMP_CTL[0x%08x]: %08x\n", &XC_QDEC->SAMP_CTL,
|
||||
XC_QDEC->SAMP_CTL);
|
||||
// NVIC_EnableIRQ(QDEC_IRQn);
|
||||
|
||||
__QDEC_Enable();
|
||||
__QDEC_Start_Count();
|
||||
|
||||
DEBUG("2_XC_QDEC->QDEC_CTL[0x%08x]: %08x\n", &XC_QDEC->QDEC_CTL,
|
||||
XC_QDEC->QDEC_CTL);
|
||||
NVIC_EnableIRQ(QDEC_IRQn);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*!
|
||||
* \file qdec.h
|
||||
*
|
||||
* \brief The head file of qdec.c
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __QDEC_H__
|
||||
#define __QDEC_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void qdec_demo(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __QDEC_H__ */
|
||||
Reference in New Issue
Block a user