Files
stair56e_uart/project/example/driver/pwm/app/api/pwm.h
T
2026-08-05 19:07:52 +08:00

110 lines
3.1 KiB
C

/*!
* \file pwm_test.h
*
* \brief The head file of pwm_test.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 __PWM_TEST_H__
#define __PWM_TEST_H__
#ifdef __cplusplus
extern "C" {
#endif
/*-----------------------------------------------------------------------------------
INCLUDE HEADE FILES
------------------------------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>
#include <stdint.h>
/*------------------------------------------------------------------------------------
Macros
-------------------------------------------------------------------------------------*/
#define DEVIATION_FREQ 10
#define DEVIATION_DUTYCYCLE 10
#define CAPTURE_DATA_MAX 101
#define CAPTURE_VALID_POS 4
/*------------------------------------------------------------------------------------
TypeDef
-------------------------------------------------------------------------------------*/
typedef enum
{
PWM_CAP_IDLE = 0,
PWM_CAP_FREQ,
PWM_CAP_DUTYCYCLE,
PWM_CAP_RIGHT,
PWM_CAP_ERROR,
} PWM_CAP_STA_TypeDef;
typedef enum
{
PWM_BRK_IDLE = 0,
PWM_BRK_START,
PWM_BRK_STOP,
} PWM_BRK_STA_TypeDef;
typedef enum
{
PWM_BRK_CAP_VALID,
PWM_BRK_CAP_RECOVERY,
PWM_BRK_CAP_ERROR,
} PWM_BRK_CAP_STA_TypeDef;
typedef struct pwm_ch_cap_freq
{
uint16_t ch0_cap_freq;
uint16_t ch1_cap_freq;
uint16_t ch2_cap_freq;
} pwm_ch_cap_freq_t;
typedef struct pwm_ch_cap_dutycycle
{
uint16_t ch0_cap_dutycycle;
uint16_t ch1_cap_dutycycle;
uint16_t ch2_cap_dutycycle;
} pwm_ch_cap_dutycycle_t;
typedef struct pwm_ch_cap_type
{
uint8_t ch0_cap_type;
uint8_t ch1_cap_type;
uint8_t ch2_cap_type;
} pwm_ch_cap_type_t;
typedef enum
{
PWM_CAP_TYPE_FREQ,
PWM_CAP_TYPE_DUTYCYCLE,
} PWM_CAP_TYPE_TypeDef;
/*------------------------------------------------------------------------------------
Global Variables
-------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------
Exported Functions
-------------------------------------------------------------------------------------*/
void pwm_demo(void);
uint32_t find_duplicate_data(uint16_t *buff, uint16_t size);
#ifdef __cplusplus
}
#endif
#endif /* __PWM_TEST_H__ */