Browse Source

update

master
Yuenold 3 years ago
parent
commit
4e71ebf891
  1. 156
      APP/adc.c
  2. 2
      APP/adc.h
  3. 77
      APP/main.c
  4. 2
      README.md
  5. 1025
      project_ozone/Listings/project_o.map
  6. 170
      project_ozone/project_o.uvgui.admin

156
APP/adc.c

@ -40,8 +40,8 @@ void ADCInit(uint8_t *port, uint8_t pin) {
//*3.3/4096= //*3.3/4096=
x.VREF_SEL = ADC_VREF_SEL_0; /* 内部参考电压2.048v,仅设置内部参考电压为多少 */ x.VREF_SEL = ADC_VREF_SEL_0; /* 内部参考电压2.048v,仅设置内部参考电压为多少 */
x.VREFP = ADC_VREFP_VDD; /* 选择芯片的工作电压VDD,这个是设置adc具体是要哪个电压来做参考adc的参考电压为多少 */
x.VREFN = ADC_VREFN_VSS; /* 负向参考电压选择 */
x.VREFP = ADC_VREFP_VDD; /* 选择芯片的工作电压VDD,这个是设置adc具体是要哪个电压来做参考adc的参考电压为多少 */
x.VREFN = ADC_VREFN_VSS; /* 负向参考电压选择 */
// x.CHS = ADC_CHS_AIN4; // x.CHS = ADC_CHS_AIN4;
// x.CHS = ADC_CHS_AIN8; // x.CHS = ADC_CHS_AIN8;
x.SMPS = ADC_SMPS_SOFT; /* AD采样模式为软件控制 */ x.SMPS = ADC_SMPS_SOFT; /* AD采样模式为软件控制 */
@ -51,6 +51,148 @@ void ADCInit(uint8_t *port, uint8_t pin) {
ADC_Init(&x); ADC_Init(&x);
} }
//adc采集的电压值
void ADCPA2Init() {
ADC_InitStruType x;
GPIO_InitSettingType y;
y.Signal = GPIO_Pin_Signal_Analog; //
y.Dir = GPIO_Direction_Input; //
y.Func = GPIO_Reuse_Func0;
// x.CHS设置adc采集的通道每个引脚对应一个通道
GPIO_Init(GPIO_Pin_A2, &y);
//Tadclk=1/(PCLK/4)0.083us
x.CLKS = ADC_CLKS_PCLK;
x.CLKDIV = ADC_CLKDIV_1_32; /* ADC时钟源预分频 */
//*3.3/4096=
x.VREF_SEL = ADC_VREF_SEL_0; /* 内部参考电压2.048v,仅设置内部参考电压为多少 */
x.VREFP = ADC_VREFP_VDD; /* 选择芯片的工作电压VDD,这个是设置adc具体是要哪个电压来做参考adc的参考电压为多少 */
x.VREFN = ADC_VREFN_VSS; /* 负向参考电压选择 */
x.CHS = ADC_CHS_AIN8;
x.SMPS = ADC_SMPS_SOFT; /* AD采样模式为软件控制 */
//st*2+1(Tadclk)=1.743us
x.ST = 10; /* AD硬件采样时间选择 */
x.BITSEL = ADC_BITSEL_12; /* AD分辨率12位 */
ADC_Init(&x);
}
void get_pa2_adc_value(void) {
volatile uint32_t pa2_adc_val = 0;
ADCPA2Init();
ADC_SoftStart();
//
while (ADC_GetConvStatus() != RESET)
;
pa2_adc_val = ADC_GetConvValue();
ADC_SoftStop();
printf("%d\r\n", pa2_adc_val);
printf("pa2_val:%lf\r\n", pa2_adc_val * 3.3 / 4096);
}
void ADCPB8Init() {
ADC_InitStruType x;
GPIO_InitSettingType y;
y.Signal = GPIO_Pin_Signal_Analog; //
y.Dir = GPIO_Direction_Input; //
y.Func = GPIO_Reuse_Func0;
// x.CHS设置adc采集的通道每个引脚对应一个通道
GPIO_Init(GPIO_Pin_B8, &y);
//Tadclk=1/(PCLK/4)0.083us
x.CLKS = ADC_CLKS_PCLK;
x.CLKDIV = ADC_CLKDIV_1_32; /* ADC时钟源预分频 */
//*3.3/4096=
x.VREF_SEL = ADC_VREF_SEL_0; /* 内部参考电压2.048v,仅设置内部参考电压为多少 */
x.VREFP = ADC_VREFP_VDD; /* 选择芯片的工作电压VDD,这个是设置adc具体是要哪个电压来做参考adc的参考电压为多少 */
x.VREFN = ADC_VREFN_VSS; /* 负向参考电压选择 */
x.CHS = ADC_CHS_AIN3;
x.SMPS = ADC_SMPS_SOFT; /* AD采样模式为软件控制 */
//st*2+1(Tadclk)=1.743us
x.ST = 10; /* AD硬件采样时间选择 */
x.BITSEL = ADC_BITSEL_12; /* AD分辨率12位 */
ADC_Init(&x);
}
void get_pb8_adc_value(void) {
volatile uint32_t pb8_adc_val = 0;
ADCPB8Init();
ADC_SoftStart();
//
while (ADC_GetConvStatus() != RESET)
;
pb8_adc_val = ADC_GetConvValue();
ADC_SoftStop();
printf("%d\r\n", pb8_adc_val);
printf("pb8_val:%lf\r\n", pb8_adc_val * 3.3 / 4096);
}
void ADCPB9Init() {
ADC_InitStruType x;
GPIO_InitSettingType y;
y.Signal = GPIO_Pin_Signal_Analog; //
y.Dir = GPIO_Direction_Input; //
y.Func = GPIO_Reuse_Func0;
// x.CHS设置adc采集的通道每个引脚对应一个通道
GPIO_Init(GPIO_Pin_B9, &y);
//Tadclk=1/(PCLK/32)
x.CLKS = ADC_CLKS_PCLK;
x.CLKDIV = ADC_CLKDIV_1_32; /* ADC时钟源预分频 */
//*3.3/4096=
x.VREF_SEL = ADC_VREF_SEL_0; /* 内部参考电压2.048v,仅设置内部参考电压为多少 */
x.VREFP = ADC_VREFP_VDD; /* 选择芯片的工作电压VDD,这个是设置adc具体是要哪个电压来做参考adc的参考电压为多少 */
x.VREFN = ADC_VREFN_VSS; /* 负向参考电压选择 */
x.CHS = ADC_CHS_AIN4;
// x.CHS = ADC_CHS_AIN8;
x.SMPS = ADC_SMPS_SOFT; /* AD采样模式为软件控制 */
//st*2+1(Tadclk)=1.743us
x.ST = 10; /* AD硬件采样时间选择 */
x.BITSEL = ADC_BITSEL_12; /* AD分辨率12位 */
ADC_Init(&x);
}
void get_pb9_adc_value(void) {
volatile uint32_t pb9_adc_val = 0;
ADCPB9Init();
ADC_SoftStart();
//
while (ADC_GetConvStatus() != RESET)
;
pb9_adc_val = ADC_GetConvValue();
ADC_SoftStop();
printf("%d\r\n", pb9_adc_val);
printf("pb9_val:%lf\r\n", pb9_adc_val * 3.3 / 4096);
}
void try_adc_gather(void) {
static uint32_t adc_ticket = 0;
// static uint32_t adc_ticket_count = 0;
if (port_haspassedms(adc_ticket) > 1000) {
// adc_ticket_count++;
adc_ticket = get_sys_ticket();
// if (adc_ticket_count < 5) {
get_pb8_adc_value();
get_pa2_adc_value();
get_pb9_adc_value();
// }
// get_adc_value();
// if (adc_ticket_count >= 5) {
// if (adc_ticket_count == 10) {
// adc_ticket_count = 0;
// }
// ADC_Disable();
// get_pa2_adc_value();
// }
}
}
void get_adc_value(void) { void get_adc_value(void) {
// uint16_t adc_value = 0; // uint16_t adc_value = 0;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@ -62,15 +204,7 @@ void get_adc_value(void) {
ADC_SoftStop(); ADC_SoftStop();
// record_adc_gather_value(s_adc[i].adc_just_now_gather_val); // record_adc_gather_value(s_adc[i].adc_just_now_gather_val);
printf("%d\r\n", s_adc[i].adc_just_now_gather_val); printf("%d\r\n", s_adc[i].adc_just_now_gather_val);
}
}
void try_adc_gather(void) {
static uint32_t adc_ticket = 0;
if (port_haspassedms(adc_ticket) > 500) {
adc_ticket = get_sys_ticket();
get_adc_value();
printf("voltage:%lf\r\n", (s_adc[i].adc_just_now_gather_val) * 3.3 / 4096);
} }
} }

2
APP/adc.h

@ -6,7 +6,9 @@
#include "systick.h" #include "systick.h"
void ADCInit(uint8_t *port, uint8_t pin); void ADCInit(uint8_t *port, uint8_t pin);
void ADCPA2Init();
void get_adc_value(void); void get_adc_value(void);
void get_pa2_adc_value(void);
void try_adc_gather(void); void try_adc_gather(void);
void beg_average_value(uint16_t *adc_buff); void beg_average_value(uint16_t *adc_buff);

77
APP/main.c

@ -15,6 +15,7 @@ static uint32_t s_timing_time; //
static uint32_t s_interval_period = 0; // static uint32_t s_interval_period = 0; //
static uint8_t s_now_interval_duty = 0; // static uint8_t s_now_interval_duty = 0; //
static uint8_t s_intervalkey_press_count = 0; // static uint8_t s_intervalkey_press_count = 0; //
uint8_t rgb_ticket_count = 3;
WORK_LEVEL_T now_level; // WORK_LEVEL_T now_level; //
WORK_LEVEL_T shutdown_before_level; // WORK_LEVEL_T shutdown_before_level; //
@ -42,6 +43,8 @@ bool HOOK_pwm_is_enable(void) { return pwm_modble_enable_falg; }
void process_intervalkey_press_even(void) { void process_intervalkey_press_even(void) {
s_intervalkey_press_count++; s_intervalkey_press_count++;
if (s_intervalkey_press_count == 1) { if (s_intervalkey_press_count == 1) {
//rgb亮三秒灭一秒,rgb_ticket_count设置3rgb灭1s
rgb_ticket_count = 3;
update_interval_period_duty(50); update_interval_period_duty(50);
} else { } else {
update_interval_period_duty(100); // update_interval_period_duty100s_intervalkey_press_count=0 update_interval_period_duty(100); // update_interval_period_duty100s_intervalkey_press_count=0
@ -94,7 +97,6 @@ void restore_the_mode_before_intermittent_work(void) {
*/ */
void process_rgb_flicker(void) { void process_rgb_flicker(void) {
static uint32_t rgb_ticket = 0; static uint32_t rgb_ticket = 0;
static uint8_t rgb_ticket_count = 0;
if (port_haspassedms(rgb_ticket) > 1000) { if (port_haspassedms(rgb_ticket) > 1000) {
rgb_ticket = get_sys_ticket(); rgb_ticket = get_sys_ticket();
if (rgb_ticket_count < 3) { if (rgb_ticket_count < 3) {
@ -405,6 +407,74 @@ void process_error_even(void) {
* =============================================================================================================== * ===============================================================================================================
** **
***********************************************************************************************************************/ ***********************************************************************************************************************/
void test_adc(void) {
while (1) {
ADC_InitStruType x;
GPIO_InitSettingType y;
y.Signal = GPIO_Pin_Signal_Analog; //
y.Dir = GPIO_Direction_Input; //
y.Func = GPIO_Reuse_Func0;
// x.CHS设置adc采集的通道每个引脚对应一个通道
GPIO_Init(GPIO_Pin_A2, &y);
//Tadclk=1/(PCLK/4)0.083us
x.CLKS = ADC_CLKS_PCLK;
x.CLKDIV = ADC_CLKDIV_1_32; /* ADC时钟源预分频 */
//*3.3/4096=
x.VREF_SEL = ADC_VREF_SEL_0; /* 内部参考电压2.048v,仅设置内部参考电压为多少 */
x.VREFP = ADC_VREFP_VDD; /* 选择芯片的工作电压VDD,这个是设置adc具体是要哪个电压来做参考adc的参考电压为多少 */
x.VREFN = ADC_VREFN_VSS; /* 负向参考电压选择 */
x.CHS = ADC_CHS_AIN8;
x.SMPS = ADC_SMPS_SOFT; /* AD采样模式为软件控制 */
//st*2+1(Tadclk)=1.743us
x.ST = 10; /* AD硬件采样时间选择 */
x.BITSEL = ADC_BITSEL_12; /* AD分辨率12位 */
ADC_Init(&x);
uint32_t pa2_adc_val = 0;
ADC_SoftStart();
ADC_SoftStop();
//
while (ADC_GetConvStatus() != RESET)
;
pa2_adc_val = ADC_GetConvValue();
printf("%d\r\n", pa2_adc_val);
printf("pa2_adc_valpa2_val:%lf\r\n", pa2_adc_val * 3.3 / 4096);
y.Signal = GPIO_Pin_Signal_Analog; //
y.Dir = GPIO_Direction_Input; //
y.Func = GPIO_Reuse_Func0;
// x.CHS设置adc采集的通道每个引脚对应一个通道
GPIO_Init(GPIO_Pin_B8, &y);
//Tadclk=1/(PCLK/4)0.083us
x.CLKS = ADC_CLKS_PCLK;
x.CLKDIV = ADC_CLKDIV_1_32; /* ADC时钟源预分频 */
//*3.3/4096=
x.VREF_SEL = ADC_VREF_SEL_0; /* 内部参考电压2.048v,仅设置内部参考电压为多少 */
x.VREFP = ADC_VREFP_VDD; /* 选择芯片的工作电压VDD,这个是设置adc具体是要哪个电压来做参考adc的参考电压为多少 */
x.VREFN = ADC_VREFN_VSS; /* 负向参考电压选择 */
x.CHS = ADC_CHS_AIN3;
x.SMPS = ADC_SMPS_SOFT; /* AD采样模式为软件控制 */
//st*2+1(Tadclk)=1.743us
x.ST = 10; /* AD硬件采样时间选择 */
x.BITSEL = ADC_BITSEL_12; /* AD分辨率12位 */
ADC_Init(&x);
uint32_t pb8_adc_val = 0;
ADC_SoftStart();
ADC_SoftStop();
//
while (ADC_GetConvStatus() != RESET)
;
pb8_adc_val = ADC_GetConvValue();
printf("pb8_adc_val%d\r\n", pb8_adc_val);
printf("pb8_val:%lf\r\n", pb8_adc_val * 3.3 / 4096);
Delayms(1000);
}
}
void test(void) { void test(void) {
port_fan_set(false); port_fan_set(false);
Delayms(10000); Delayms(10000);
@ -464,12 +534,13 @@ int main(void) {
// iwdt_init(); // iwdt_init();
power_on_ozone_working_status(); power_on_ozone_working_status();
printf("Initialization completed\r\n"); printf("Initialization completed\r\n");
//test();
// test();
// test_adc();
while (true) { while (true) {
port_do_debug_light_state(); port_do_debug_light_state();
// feed_iwdt(); // feed_iwdt();
static uint32_t keylastprocess = 0; static uint32_t keylastprocess = 0;
if (port_haspassedms(keylastprocess) > 20) {
if (port_haspassedms(keylastprocess) > 40) {
keylastprocess = get_sys_ticket(); keylastprocess = get_sys_ticket();
zkey_do_loop_in_each_period(NULL); zkey_do_loop_in_each_period(NULL);
} }

2
README.md

@ -10,7 +10,7 @@
[ESBurner编程器软件](http://192.168.1.3:3000/weizhuangzhuang/ES8P5066_Doc/raw/branch/master/doc/ESBurner%e7%bc%96%e7%a8%8b%e5%99%a8%e8%bd%af%e4%bb%b6.zip) [ESBurner编程器软件](http://192.168.1.3:3000/weizhuangzhuang/ES8P5066_Doc/raw/branch/master/doc/ESBurner%e7%bc%96%e7%a8%8b%e5%99%a8%e8%bd%af%e4%bb%b6.zip)
[资源列表](http://192.168.1.3:3000/manufacturer_eastsoft/ES8P5066_doc)
[ES8P5066开发手册](http://192.168.1.3:3000/manufacturer_eastsoft/ES8P5066_doc)
## 环境搭建 ## 环境搭建

1025
project_ozone/Listings/project_o.map
File diff suppressed because it is too large
View File

170
project_ozone/project_o.uvgui.admin
File diff suppressed because it is too large
View File

Loading…
Cancel
Save