Browse Source

update

master
Yuenold 3 years ago
parent
commit
a6d1ef07e3
  1. 20
      APP/adc.c
  2. 10
      APP/adc.h
  3. 74
      APP/main.c
  4. 44
      APP/main.h
  5. 2
      APP/main_2.c
  6. 1039
      project_ozone/Listings/project_o.map
  7. 103
      project_ozone/project_o.uvgui.admin

20
APP/adc.c

@ -14,10 +14,10 @@ void ADCInit(uint8_t *port, uint8_t pin) {
// GPIO_PIN(A, 28);
ADC_InitStruType x;
GPIO_InitSettingType y;
y.Signal = GPIO_Pin_Signal_Analog; //
y.Dir = GPIO_Direction_Input; //
y.Signal = GPIO_Pin_Signal_Analog; //
y.Dir = GPIO_Direction_Input; //
y.Func = GPIO_Reuse_Func0;
//x.CHS设置adc采集的通道每个引脚对应一个通道
// x.CHS设置adc采集的通道每个引脚对应一个通道
// GPIO_Init(GPIO_Pin_B9, &y);
if (pin == 2) {
GPIO_Init(GPIO_Pin_A2, &y);
@ -40,8 +40,8 @@ void ADCInit(uint8_t *port, uint8_t pin) {
//*3.3/4096=
x.VREF_SEL = ADC_VREF_SEL_0; /* 内部参考电压2.048v,设置内部参考电压为多少 */
x.VREFP = ADC_VREFP_VDD; /* 选择芯片的工作电压VDD,adc的参考电压为多少 */
x.VREFN = ADC_VREFN_VSS; /* 负向参考电压选择 */
x.VREFP = ADC_VREFP_VDD; /* 选择芯片的工作电压VDD,adc的参考电压为多少 */
x.VREFN = ADC_VREFN_VSS; /* 负向参考电压选择 */
// x.CHS = ADC_CHS_AIN4;
// x.CHS = ADC_CHS_AIN8;
x.SMPS = ADC_SMPS_SOFT; /* AD采样模式为软件控制 */
@ -52,20 +52,20 @@ void ADCInit(uint8_t *port, uint8_t pin) {
}
void get_adc_value(void) {
uint16_t adc_value = 0;
// uint16_t adc_value = 0;
for (int i = 0; i < 3; i++) {
ADCInit(s_adc[i].port, s_adc[i].pin);
ADC_SoftStart();
while (ADC_GetConvStatus() == SET)
; //
; //
s_adc[i].adc_just_now_gather_val = ADC_GetConvValue();
ADC_SoftStop();
record_adc_gather_value(s_adc[i].adc_just_now_gather_val);
//printf("%d\r\n",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);
}
}
void adc_loop_gather(void) {
void try_adc_gather(void) {
static uint32_t adc_ticket = 0;
if (port_haspassedms(adc_ticket) > 500) {

10
APP/adc.h

@ -1,15 +1,15 @@
#ifndef _ADC_H_
#define _ADC_H_
#include "ozone_work.h"
#include "port.h"
#include "systick.h"
#include "ozone_work.h"
void ADCInit(uint8_t *port,uint8_t pin);
void ADCInit(uint8_t *port, uint8_t pin);
void get_adc_value(void);
void adc_loop_gather(void);
void try_adc_gather(void);
void beg_average_value(uint16_t *adc_buff);
typedef struct {
bool abnormal_state;
bool past_count_reached_five;
@ -19,7 +19,7 @@ typedef struct {
uint16_t adc_just_now_gather_val;
uint8_t *port;
uint8_t pin;
}adc_t;
} adc_t;
void record_adc_gather_value(uint16_t adc_value);
// typedef struct {
// uint16_t adc_value_buff[5];

74
APP/main.c

@ -16,7 +16,8 @@ uint8_t s_now_interval_duty = 0;
WORK_GEARS_T now_gears;
WORK_GEARS_T shutdown_before_gears; //
uint8_t s_intervalkey_press_count = 0;
ERROR_EVEN_T error_even;
static bool error_even_trigger_after_stop_ozone_work_state;
// /***********************************************************************************************************************
// * =====================================================HOOK实现====================================================== *
// ***********************************************************************************************************************/
@ -87,7 +88,7 @@ void before_resuming_flicker_rgb_mode(void) {
}
}
/**
* @brief rgb亮3s闪烁1s
* @brief rgb亮3s1s
*
*/
void process_rgb_flicker(void) {
@ -230,7 +231,9 @@ void shutdown(void) {
starting_up_state = false;
update_ozone_work_gears(WORK_GEARS_CLOSE);
light_module_set_timing_light_mode(CLOSE_ALL_LED);
port_fan_set(false); //
port_fan_set(false); //
error_even = NO_ERROR_EVENT;
error_even_trigger_after_stop_ozone_work_state = false;
}
/**
@ -325,6 +328,64 @@ void try_shutdown(void) {
}
bool timing_function_is_enable(void) { return timing_function_enable_falg; }
void iwdt_init(void) {
/**
* @brief 0+1
* 2
* 4
*
*/
IWDT_InitStruType x;
x.WDT_Tms = 4000;
x.WDT_IE = Enable; /* IWDT中断使能 */
x.WDT_Rst = Enable; /* IWDT复位使能 */
x.WDT_Clock = IWDT_CLOCK_WDT; /* LRC */
IWDT_Init(&x);
/* 使能IWDT */
IWDT_Enable();
}
void feed_iwdt(void) {
//
if (0x01 == IWDT_GetFlagStatus()) //
{
IWDT_Clear();
// printf("喂狗\r\n");
}
}
void process_error_even(void) {
if (error_even == NO_ERROR_EVENT) {
return;
}
if (!error_even_trigger_after_stop_ozone_work_state) {
error_even_trigger_after_stop_ozone_work_state = true;
set_pwm_modbul_freq_duty(1, 0);
light_module_set_rgb_mode(RGB_CLOSE);
light_module_set_timing_light_mode(CLOSE_ALL_LED);
port_fan_set(false); //
} else if (error_even == ERROR_EVEN_FAN) {
static uint32_t error_even_fan_ticket = 0;
static uint8_t one_led_flicker_state = 1;
if (port_haspassedms(error_even_fan_ticket) > 500) {
error_even_fan_ticket = get_sys_ticket();
one_led_flicker_state = !one_led_flicker_state;
port_led0_set(one_led_flicker_state);
}
} else if (error_even == ERROR_EVEN_WAY_CIRCUIT) {
static uint32_t error_even_way_circuit = 0;
static uint8_t two_led_flicker_state = 1;
if (port_haspassedms(error_even_way_circuit) > 500) {
error_even_way_circuit = get_sys_ticket();
two_led_flicker_state = !two_led_flicker_state;
port_led0_set(two_led_flicker_state);
port_led1_set(two_led_flicker_state);
}
}
}
/**
* @brief 使rgb闪烁
*
@ -342,7 +403,9 @@ int main(void) {
gpio_init();
zkey_init(&key_module);
t16_pa4_init();
iwdt_init();
power_on_ozone_working_status();
error_even = ERROR_EVEN_WAY_CIRCUIT;
while (true) {
static uint32_t keylastprocess = 0;
if (port_haspassedms(keylastprocess) > 20) {
@ -351,6 +414,8 @@ int main(void) {
}
if (starting_up_state) { //
port_do_debug_light_state();
process_error_even();
try_adc_gather();
if (timing_function_is_enable()) { //
try_shutdown();
}
@ -360,6 +425,7 @@ int main(void) {
}
} else { //
}
feed_iwdt();
}
}
@ -369,5 +435,7 @@ int main(void) {
*
*
*
* led0闪烁测试通过
* led0led1闪烁测试通过
*
*/

44
APP/main.h

@ -32,28 +32,34 @@ typedef enum {
WORK_GEARS_LOW_END = 3, /*低档*/
} WORK_GEARS_T;
typedef enum {
NO_ERROR_EVENT = 0, /*没有异常*/
ERROR_EVEN_FAN = 1, /*风扇电压异常*/
ERROR_EVEN_WAY_CIRCUIT = 2, /*总电压异常*/
} ERROR_EVEN_T;
// void Uart0Init(void);
// void Uart0SendBuff(uint8_t *buff);
// void port_do_debug_light_state(void);
// void LedInit(void);
void Uart0Init(void);
void Uart0SendBuff(uint8_t *buff);
void port_do_debug_light_state(void);
void LedInit(void);
uint32_t port_haspassedms(uint32_t ticket);
void port_do_debug_light_state(void);
uint32_t get_sys_ticket(void);
void beg_average_value(uint16_t *adc_buff);
void updae_led_light_mode(void);
void update_timing_time(void);
void update_pwm_output_duty(uint8_t pwm_duty);
void update_rgb_color(uint8_t color);
void shutdown(void);
void starting_up(void);
void update_ozone_work_gears(WORK_GEARS_T gears);
void process_gearskey_press_even(void);
bool interval_function_is_enable(void);
void process_rgb_flicker(void);
void process_intervalkey_press_even(void);
void update_interval_period_duty(uint8_t interval_duty);
void before_resuming_flicker_rgb_mode(void);
void before_resuming_flicker_rgb_mode(void);
void process_rgb_flicker(void);
void power_on_ozone_working_status(void);
void update_ozone_work_gears(WORK_GEARS_T gears);
void process_gearskey_press_even(void);
void shutdown(void);
void starting_up(void);
void process_switchkey(void);
void updae_led_light_mode(void);
void update_timing_time(void);
void try_shutdown(void);
bool timing_function_is_enable(void);
void iwdt_init(void);
void feed_iwdt(void);
void process_error_even(void);
#endif

2
APP/main_2.c

@ -101,7 +101,7 @@
// // light_module_set_rgb_mode(rgb_message.turn_off_the_mode_before_rgb);
// // rgb_message.already_set_rgb_mode = true;
// // }
// // // adc_loop_gather();
// adc_loop_gather();
// // } else if (get_ozone_starting_up_state() == false) { //
// // }
// // test_iwdt();

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

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

Loading…
Cancel
Save