V1.0
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
/*!
|
||||
* \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_H__
|
||||
#define __PWM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define MAXDUTY 255
|
||||
#define MINDUTY 0
|
||||
#define GAMMA 2.2
|
||||
|
||||
|
||||
#define IO_PWM_W (GPIO_1)
|
||||
#define IO_PWM_C (GPIO_2)
|
||||
#define _deadTime (6)
|
||||
|
||||
|
||||
extern uint16_t timeCnt;
|
||||
extern uint16_t W_PWM;
|
||||
extern uint16_t C_PWM;
|
||||
extern uint16_t W_PWM_duty;//初始化暖光
|
||||
extern uint16_t C_PWM_duty;
|
||||
|
||||
|
||||
extern uint16_t deadTime; //2*deadTime+deadTime_C+deadTime_W=20;这个是修改死区的时间。这三个变量加起来要是20, 规定好了的,当时用的10的死区,后面修改了,不破坏原来的封装
|
||||
extern uint16_t deadTime_C; //
|
||||
extern uint16_t deadTime_W;
|
||||
|
||||
extern uint8_t driveMode;
|
||||
extern uint8_t PWMMAX;
|
||||
extern uint8_t Brightness;
|
||||
|
||||
|
||||
#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
|
||||
-------------------------------------------------------------------------------------*/
|
||||
extern uint8_t pwm_red_idx;
|
||||
extern uint8_t pwm_green_idx;
|
||||
extern uint8_t pwm_blue_idx;
|
||||
extern uint8_t sss;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void _PWM_INIT();
|
||||
void PWM_SetDuty(uint8_t PWMX ,uint8_t duty);
|
||||
void app_pwm_init(void);
|
||||
void UpdateDisplay(void);
|
||||
void UpdateDisplay_1(void);
|
||||
void switch_pwm_pins(uint8_t red_pwm, uint8_t green_pwm, uint8_t blue_pwm);
|
||||
void adc_Init();
|
||||
void My_ADC_Get_Value();
|
||||
void gpio_pullup_input_inter_test();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PWM_TEST_H__ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user