Browse Source

update

master
zhaohe 3 years ago
parent
commit
497996b2e6
  1. 23
      APP/board.h
  2. 38
      APP/irqhandler.c
  3. 30
      APP/irqhandler.h
  4. 31
      APP/light.h
  5. 30
      APP/main.c
  6. 47
      APP/main.h
  7. 26
      APP/ozone_pwm_control.h
  8. 1
      APP/port.c
  9. 167
      APP/pwm.c
  10. 19
      APP/pwm.h
  11. 327
      APP/service/light_control_service.c
  12. 0
      APP/service/light_control_service.h
  13. 162
      APP/service/ozone_control_service.c
  14. 0
      APP/service/ozone_control_service.h
  15. 218
      MDK_StartUp/startup_ES8P5066.s
  16. 1068
      project_ozone/Listings/project_o.map
  17. 46
      project_ozone/project_o.uvgui.zel
  18. 100
      project_ozone/project_o.uvopt
  19. 42
      project_ozone/project_o.uvproj

23
APP/board.h

@ -5,25 +5,4 @@
#define EXCEPTION_CHECK_PERIOD 50
//
#define AUTO_SHUTDOWN_ONE_LIGHT_EQ_TIME_S 20
//
// #define INTERVAL_WORK_PERIOD_MS (60 * 1000)
#define INTERVAL_WORK_PERIOD_MS (20 * 1000)
//
#define INTERVAL_WORK_DUTY ((uint8_t)50)
#define HIGH_LEVEL_PWM_FREQ 25000
#define LOW_LEVEL_PWM_FREQ 10000
// #define HIGH_LEVEL_PWM_FREQ 99000
// #define LOW_LEVEL_PWM_FREQ 50000
#define MIN_PWM_FREQ 5000
#define PWM_CHANGE_INTERVAL_TIME_MS 1000
//PWM变化的频率
#define PWM_CHANGE_STEP_FREQ 1000
//PWM小于这个数值时20k
#define PWM_CHANGE_BEGIN_STEP_FREQ 20000
//PWM改变一次的周期
#define PWM_CHANGE_PERIOD 1000
#define PWM_PULSE_WIDTH_US 8
#define AUTO_SHUTDOWN_ONE_LIGHT_EQ_TIME_S 20

38
PlatForm/irqhandler.c → APP/irqhandler.c

@ -1,19 +1,19 @@
#include "irqhandler.h"
void NMI_IRQHandler(void) {}
void HardFault_IRQHandler(void) {
while (1) {
}
}
void SVC_IRQHandler(void) {}
void PendSV_IRQHandler(void) {}
// uint32_t g_sys_sick = 0;
// void SysTick_IRQHandler(void) {
// g_sys_sick++;
// }
#include "irqhandler.h"
void NMI_IRQHandler(void) {}
void HardFault_IRQHandler(void) {
while (1) {
}
}
void SVC_IRQHandler(void) {}
void PendSV_IRQHandler(void) {}
// uint32_t g_sys_sick = 0;
// void SysTick_IRQHandler(void) {
// g_sys_sick++;
// }

30
PlatForm/irqhandler.h → APP/irqhandler.h

@ -1,15 +1,15 @@
#ifndef __IRQHANDLER_H__
#define __IRQHANDLER_H__
#include "ES8P5066.h"
//#include "light.h"
//#include "gpio.h"
/************中断函数声明***********/
void NMI_IRQHandler(void);
void HardFault_IRQHandler(void);
void SVC_IRQHandler(void);
void PendSV_IRQHandler(void);
void SysTick_IRQHandler(void);
#endif
#ifndef __IRQHANDLER_H__
#define __IRQHANDLER_H__
#include "ES8P5066.h"
//#include "light.h"
//#include "gpio.h"
/************中断函数声明***********/
void NMI_IRQHandler(void);
void HardFault_IRQHandler(void);
void SVC_IRQHandler(void);
void PendSV_IRQHandler(void);
void SysTick_IRQHandler(void);
#endif

31
APP/light.h

@ -1,31 +0,0 @@
#ifndef _LIGHT_H_
#define _LIGHT_H_
// #include "board.h"
// #include "lib_config.h"
// #include "port.h"
// #include "system_ES8P5066.h"
// #include "systick.h"
// typedef enum {
// krgb_close = 0, /*关闭灯*/
// krgb_color_green = 1, /*打开绿灯*/
// krgb_color_blue = 2, /*打开蓝灯*/
// krgb_color_red = 3, /*打开红灯*/
// } rgb_light_mode_t;
// void light_module_set_rgb_mode(rgb_light_mode_t mode);
// void light_module_set_error_light_mode(bool open, uint8_t error_mode);
// void light_module_set_autoshutdown_indicator_light(bool light);
// void light_module_set_rgb_in_interval_working_mode(bool state);
// void light_module_close_all_light(void);
// void light_module_schedule(void);
// //
// int hook_get_autoshutdown_timecount();
// //
// bool hook_get_ozone_generator_working_flag();
#endif

30
APP/main.c

@ -1,4 +1,3 @@
#include "main.h"
#include <stdbool.h> //定义布尔
#include <string.h>
@ -209,6 +208,18 @@ void systicket_do_debug_light_state(void) {
}
}
void init_all_subdevice_state() {
port_debug_set(false);
port_fan_set(false);
port_led0_set(false);
port_led1_set(false);
port_led2_set(false);
port_led3_set(false);
port_led_r_set(false);
port_led_g_set(false);
port_led_b_set(false);
}
int main(void) {
SystemInit(); //
DeviceClockAllEnable(); //
@ -231,35 +242,26 @@ int main(void) {
/**
* @brief
*/
init_all_subdevice_state();
port_debug_set(false);
port_fan_set(false);
port_led0_set(false);
port_led1_set(false);
port_led2_set(false);
port_led3_set(false);
port_led_r_set(false);
port_led_g_set(false);
port_led_b_set(false);
//
port_fan_set(true);
port_ozone_pwm_set_duty(30000, 10 * 1000);
port_ozone_pwm_start();
// port_ozone_pwm_stop
while (true) {
//
systicket_do_debug_light_state();
//
DO_IT_EACH_MS(KEY_PERIOD) { zkey_do_loop_in_each_period(NULL); }
END();
#if 1 //打印功
#if 1
//
DO_IT_EACH_MS(300) { //
// printf("v :fan:%f,ozone:%f\n", port_adc_get_fan_voltage(), port_adc_get_ozone_generator_voltage());
printf("power:fan:%f,ozone:%f\n", port_adc_get_fan_power(), port_adc_get_ozone_generator_power());
}
END();
test_all_light();
#endif

47
APP/main.h

@ -1,47 +0,0 @@
#ifndef __MAIN_H__
#define __MAIN_H__
#if 0
#include "irqhandler.h"
#include "lib_config.h"
#include "light.h"
#include "ozone_pwm_control.h"
#include "port.h"
#include "pwm.h"
#include "system_ES8P5066.h"
#include "systick.h"
#include "uart0.h"
typedef enum {
kwork_level_close = 0, /*关闭PWM输出,关闭RGB*/
kwork_level_low = 1, /*低档*/
kwork_level_hight = 2, /*高档*/
} work_level_t;
typedef struct {
bool fan_error_status; /*风扇电压异常*/
bool way_circuit_error_status; /*总电压异常*/
} error_state_t;
// void Uart0Init(void);
// void Uart0SendBuff(uint8_t *buff);
// void port_do_debug_light_state(void);
// void LedInit(void);
void process_intervalkey_press_even(void);
void update_interval_period_duty(uint8_t interval_duty);
void restore_the_mode_before_intermittent_work(void);
void process_rgb_flicker(void);
void power_on_ozone_working_status(void);
void update_ozone_work_level(work_level_t level);
void process_levelkey_press_even(void);
void shutdown(void);
void starting_up(void);
void process_powerkey(void);
void updae_timing_light_state(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
#endif

26
APP/ozone_pwm_control.h

@ -1,26 +0,0 @@
#if 0
#ifndef _OZONE_PWM_CONTROL_H_
#define _OZONE_PWM_CONTROL_H_
#include <stdbool.h>
#include <stdint.h>
#include "lib_config.h"
#include "light.h"
#include "port.h"
#include "system_ES8P5066.h"
void ozone_pwm_control_module_set_pwm_output_1(uint32_t hardware_period, uint8_t hardware_duty);
void ozone_pwm_control_module_set_pwm_output_2(uint32_t hardware_period, uint8_t hardware_duty, uint32_t large_period, uint8_t large_duty);
void ozone_pwm_control_module_stop_pwm(void);
void ozone_pwm_control_module_loop(void);
void ozone_pwm_control_enable(void);
void ozone_pwm_control_disable(void);
bool ozone_pwm_control_is_enable(void);
bool ozone_pwm_control_hardware_is_enable(void);
#endif
#endif

1
APP/port.c

@ -5,7 +5,6 @@
#include "../zes8p5066lib/pwm.h"
#include "../zes8p5066lib/systicket.h"
#include "../zes8p5066lib/uart0.h"
#include "pwm.h"
zpwm_t g_ozonepwm;

167
APP/pwm.c

@ -1,167 +0,0 @@
#if 1
#include "pwm.h"
#include "board.h"
#define CLCK 48.0
#define PRE_CLK 1.0
uint32_t target_frequencyhz;
uint32_t target_duty;
static uint32_t s_mat2;
static uint32_t s_top;
static double calculate_top(double target_frequency_hz) {
int clck = 0;
int top = 0;
clck = CLCK * 1000 * 1000 / PRE_CLK;
top = clck / target_frequency_hz;
return top;
}
void t16_pa4_init(void) {
T16Nx_Disable(T16N0);
// PA4 T16N0_1
T16Nx_BaseInitStruType x;
T16Nx_PWMInitStruType y;
/* 初始化T16Nx定时器*/
x.T16Nx_ClkS = T16Nx_ClkS_PCLK; //48M
x.T16Nx_SYNC = Disable; //
x.T16Nx_EDGE = T16Nx_EDGE_Rise; //沿
x.T16Nx_Mode = T16Nx_Mode_PWM; // PWM模式
x.T16Nx_PREMAT = PRE_CLK; /* 预分频比1:1 */
T16Nx_BaseInit(T16N0, &x);
/* 配置T16N0通道1输出 */
y.T16Nx_MOE0 = Disable;
y.T16Nx_MOE1 = Enable;
y.T16Nx_POL0 = POSITIVE; //
y.T16Nx_POL1 = POSITIVE;
y.T16Nx_PWMMODE = T16Nx_PWMMode_INDEP; //
y.PWMDZE = Disable; // PWM互补模式死区使能
y.REGBUFEN = Enable; //使 (REGBUFEN目前不知道干什么用的)
T16Nx_PMWOutInit(T16N0, &y);
/* 配置T16N0 通道1输出 */
/*MAT2 MAT3 通道的中断配置*/
//
T16Nx_MAT2ITConfig(T16N0, T16Nx_Go_No);
//,
T16Nx_MAT3ITConfig(T16N0, T16Nx_Clr_Int);
/*MAT2 MAT3 匹配后的输出电平高低*/
T16Nx_MAT2Out1Config(T16N0,
T16Nx_Out_Low); //
T16Nx_MAT3Out1Config(T16N0,
T16Nx_Out_High); //
//
T16Nx_SetCNT1(T16N0, 0); //
T16Nx_SetMAT2(T16N0, 0); //
T16Nx_SetMAT3(T16N0, 0); //
////48M/48000=1khZ(PWM的周期由TOP1决定为TOP+11ms)
T16Nx_SetTOP1(T16N0, 0);
//
/* 配置输出管脚 */
GPIO_InitSettingType initset;
initset.Signal = GPIO_Pin_Signal_Digital; //
initset.Dir = GPIO_Direction_Output; //
initset.Func = GPIO_Reuse_Func2; //T16N0_1功能
initset.ODE = GPIO_ODE_Output_Disable; //使
initset.DS = GPIO_DS_Output_Normal; //
initset.PUE = GPIO_PUE_Input_Enable; //使
initset.PDE = GPIO_PDE_Input_Disable; //
/* 配置PA4为T16N0输出通道1 */
GPIO_Init(GPIO_Pin_A4, &initset);
T16Nx_Enable(T16N0);
return;
}
void set_pwm_t16_pa4_2(uint16_t mat2, uint16_t top) {
uint16_t Mat2 = mat2;
uint16_t Mat3 = top;
s_mat2 = mat2;
s_top = top;
// printf("set_pwm_t16_pa4 mat2:%d mat3:%d top:%d\n", mat2, Mat3, top);
T16Nx_SetCNT1(T16N0, 0); //
T16Nx_SetMAT2(T16N0, Mat2); //
T16Nx_SetMAT3(T16N0, Mat3); //
////48M/48000=1khZ(PWM的周期由TOP1决定为TOP+11ms)
T16Nx_SetTOP1(T16N0, top);
//
}
uint32_t getCNT() { return T16Nx_GetCNT1(T16N0); }
uint32_t getTOP() { return T16Nx_GetTOP1(T16N0); }
void set_pwm_mat2(uint16_t mat2) { set_pwm_t16_pa4_2(mat2, s_top); }
void set_pwm_t16_pa4(uint32_t freqhz, double duty) {
// printf("set_pwm_t16_pa4 %d %f\n", freqhz, duty);
double top_double = calculate_top(freqhz); //TOP
uint16_t top = (uint16_t)top_double;
uint16_t Mat2 = (uint16_t)top_double * (duty / 100.0);
if (Mat2 >= top) Mat2 = top - 1;
set_pwm_t16_pa4_2(Mat2, top);
}
//######################################################
/**
* @brief pwm的周期占空比
*
* @param frequency
* @param duty
*/
/**
*
* :
*
*
*
* :
* 20->0
* 0->20
* 0->10
*
* ,
*
*
*
*
*
*
* 1. ,
* 2.
*
*/
uint32_t s_target_frequencyhz;
uint32_t s_now_frequencyhz;
uint32_t s_target_duty;
uint32_t s_now_duty;
void set_pwm_modbul_freq_duty(uint32_t frequencyhz, uint32_t duty) {
// s_target_frequencyhz = frequencyhz;
// if (s_target_frequencyhz <= MIN_PWM_FREQ) {
// s_target_frequencyhz = MIN_PWM_FREQ;
// }
// s_target_duty = duty;
if (frequencyhz < 50) frequencyhz = 50;
set_pwm_t16_pa4(frequencyhz, duty);
}
void set_pwm_modbul_freq_duty2(uint32_t frequencyhz, double duty) {
// s_target_frequencyhz = frequencyhz;
// if (s_target_frequencyhz <= MIN_PWM_FREQ) {
// s_target_frequencyhz = MIN_PWM_FREQ;
// }
// s_target_duty = duty;
if (frequencyhz < 50) frequencyhz = 50;
set_pwm_t16_pa4(frequencyhz, duty);
}
void stop_pwm_output() { T16Nx_Disable(T16N0); }
#endif

19
APP/pwm.h

@ -1,19 +0,0 @@
#ifndef _PWM_MODULE_H_
#define _PWM_MODULE_H_
#include "lib_config.h"
#include "light.h"
#include "port.h"
#include "system_ES8P5066.h"
void set_pwm_modbul_freq_duty(uint32_t frequencyhz, uint32_t duty);
void set_pwm_mat2(uint16_t mat2);
void set_pwm_modbul_freq_duty2(uint32_t frequencyhz, double duty);
void stop_pwm_output();
void t16_pa4_init(void);
#endif

327
APP/light.c → APP/service/light_control_service.c

@ -1,164 +1,165 @@
#include "light.h"
#if 0
static bool s_interval_working_mode;
static rgb_light_mode_t s_rgb_now_state;
static rgb_light_mode_t s_rgb_light_mode_config;
static int s_errornum = 0;
static bool s_errorlight_display_state;
static bool s_autoshutdown_light_state;
/**
* @brief ,
* 绿
*/
static void prv_light_module_set_rgb_mode(rgb_light_mode_t mode) {
if (mode == krgb_color_red) {
port_led_r_set(true);
port_led_g_set(false);
port_led_b_set(false);
} else if (mode == krgb_color_blue) {
port_led_r_set(false);
port_led_g_set(false);
port_led_b_set(true);
} else if (mode == krgb_color_green) {
port_led_r_set(false);
port_led_b_set(false);
port_led_g_set(true);
} else if (mode == krgb_close) {
port_led_r_set(false);
port_led_g_set(false);
port_led_b_set(false);
}
s_rgb_now_state = mode;
}
static void prv_set_timing_light_mode(int mode) {
if (mode == 1) {
port_led0_set(true);
port_led1_set(false);
port_led2_set(false);
port_led3_set(false);
} else if (mode == 2) {
port_led0_set(true);
port_led1_set(true);
port_led2_set(false);
port_led3_set(false);
} else if (mode == 3) {
port_led0_set(true);
port_led1_set(true);
port_led2_set(true);
port_led3_set(false);
} else if (mode == 4) {
port_led0_set(true);
port_led1_set(true);
port_led2_set(true);
port_led3_set(true);
} else if (mode == 0) {
port_led0_set(false);
port_led1_set(false);
port_led2_set(false);
port_led3_set(false);
}
}
void prv_light_module_rgb_light_control_schedule() {
if (s_rgb_light_mode_config == krgb_close) {
prv_light_module_set_rgb_mode(krgb_close);
return;
}
if (!s_interval_working_mode) {
prv_light_module_set_rgb_mode(s_rgb_light_mode_config);
return;
}
/**
* @brief
*/
if (s_interval_working_mode) {
if (hook_get_ozone_generator_working_flag()) {
static uint32_t rgb_flicker_ticket = 0;
static uint8_t rgb_ticket_count = 0;
if (port_haspassedms(rgb_flicker_ticket) > 1000) {
rgb_flicker_ticket = get_sys_ticket();
if (s_rgb_now_state == krgb_close) {
prv_light_module_set_rgb_mode(s_rgb_light_mode_config);
} else {
prv_light_module_set_rgb_mode(krgb_close);
}
}
} else {
prv_light_module_set_rgb_mode(krgb_color_green);
}
}
}
/**
* @brief
*/
static void prv_time_light_control_schedule() {
if (s_autoshutdown_light_state) {
/**
* @brief
*/
int lightnum = hook_get_autoshutdown_timecount() / AUTO_SHUTDOWN_ONE_LIGHT_EQ_TIME_S;
int lightnum_remainder = hook_get_autoshutdown_timecount() % AUTO_SHUTDOWN_ONE_LIGHT_EQ_TIME_S;
if (lightnum_remainder != 0) {
lightnum += 1;
}
prv_set_timing_light_mode(lightnum);
} else if (s_errorlight_display_state) {
/**
* @brief
*/
static uint32_t ticket = 0;
static bool state;
if (port_haspassedms(ticket) > 300) {
ticket = get_sys_ticket();
state = !state;
if (state) {
prv_set_timing_light_mode(s_errornum);
} else {
prv_set_timing_light_mode(0);
}
}
} else {
prv_set_timing_light_mode(0);
}
}
/***********************************************************************************************************************
* ======================================================Extern======================================================= *
***********************************************************************************************************************/
void light_module_set_rgb_mode(rgb_light_mode_t mode) {
printf("light_module_set_rgb_mode %d\n", mode);
s_rgb_light_mode_config = mode;
prv_light_module_set_rgb_mode(mode);
}
void light_module_set_rgb_in_interval_working_mode(bool state) {
printf("light_module_set_rgb_in_interval_working_mode %d\n", state);
s_interval_working_mode = state;
}
void light_module_set_autoshutdown_indicator_light(bool open) { s_autoshutdown_light_state = open; }
void light_module_set_error_light_mode(bool open, uint8_t error_mode) {
printf("light_module_set_error_light_mode %d\n", error_mode);
s_errorlight_display_state = open;
s_errornum = error_mode;
}
void light_module_close_all_light(void) {
printf("light_module_close_all_light\n");
light_module_set_rgb_mode(krgb_close);
light_module_set_autoshutdown_indicator_light(false);
light_module_set_rgb_in_interval_working_mode(false);
prv_set_timing_light_mode(0);
s_errornum = 0;
s_interval_working_mode = false;
s_autoshutdown_light_state = false;
s_errorlight_display_state = false;
}
void light_module_schedule(void) {
prv_light_module_rgb_light_control_schedule();
prv_time_light_control_schedule();
}
#if 0
#include "light.h"
static bool s_interval_working_mode;
static rgb_light_mode_t s_rgb_now_state;
static rgb_light_mode_t s_rgb_light_mode_config;
static int s_errornum = 0;
static bool s_errorlight_display_state;
static bool s_autoshutdown_light_state;
/**
* @brief ,
* 绿
*/
static void prv_light_module_set_rgb_mode(rgb_light_mode_t mode) {
if (mode == krgb_color_red) {
port_led_r_set(true);
port_led_g_set(false);
port_led_b_set(false);
} else if (mode == krgb_color_blue) {
port_led_r_set(false);
port_led_g_set(false);
port_led_b_set(true);
} else if (mode == krgb_color_green) {
port_led_r_set(false);
port_led_b_set(false);
port_led_g_set(true);
} else if (mode == krgb_close) {
port_led_r_set(false);
port_led_g_set(false);
port_led_b_set(false);
}
s_rgb_now_state = mode;
}
static void prv_set_timing_light_mode(int mode) {
if (mode == 1) {
port_led0_set(true);
port_led1_set(false);
port_led2_set(false);
port_led3_set(false);
} else if (mode == 2) {
port_led0_set(true);
port_led1_set(true);
port_led2_set(false);
port_led3_set(false);
} else if (mode == 3) {
port_led0_set(true);
port_led1_set(true);
port_led2_set(true);
port_led3_set(false);
} else if (mode == 4) {
port_led0_set(true);
port_led1_set(true);
port_led2_set(true);
port_led3_set(true);
} else if (mode == 0) {
port_led0_set(false);
port_led1_set(false);
port_led2_set(false);
port_led3_set(false);
}
}
void prv_light_module_rgb_light_control_schedule() {
if (s_rgb_light_mode_config == krgb_close) {
prv_light_module_set_rgb_mode(krgb_close);
return;
}
if (!s_interval_working_mode) {
prv_light_module_set_rgb_mode(s_rgb_light_mode_config);
return;
}
/**
* @brief
*/
if (s_interval_working_mode) {
if (hook_get_ozone_generator_working_flag()) {
static uint32_t rgb_flicker_ticket = 0;
static uint8_t rgb_ticket_count = 0;
if (port_haspassedms(rgb_flicker_ticket) > 1000) {
rgb_flicker_ticket = get_sys_ticket();
if (s_rgb_now_state == krgb_close) {
prv_light_module_set_rgb_mode(s_rgb_light_mode_config);
} else {
prv_light_module_set_rgb_mode(krgb_close);
}
}
} else {
prv_light_module_set_rgb_mode(krgb_color_green);
}
}
}
/**
* @brief
*/
static void prv_time_light_control_schedule() {
if (s_autoshutdown_light_state) {
/**
* @brief
*/
int lightnum = hook_get_autoshutdown_timecount() / AUTO_SHUTDOWN_ONE_LIGHT_EQ_TIME_S;
int lightnum_remainder = hook_get_autoshutdown_timecount() % AUTO_SHUTDOWN_ONE_LIGHT_EQ_TIME_S;
if (lightnum_remainder != 0) {
lightnum += 1;
}
prv_set_timing_light_mode(lightnum);
} else if (s_errorlight_display_state) {
/**
* @brief
*/
static uint32_t ticket = 0;
static bool state;
if (port_haspassedms(ticket) > 300) {
ticket = get_sys_ticket();
state = !state;
if (state) {
prv_set_timing_light_mode(s_errornum);
} else {
prv_set_timing_light_mode(0);
}
}
} else {
prv_set_timing_light_mode(0);
}
}
/***********************************************************************************************************************
* ======================================================Extern======================================================= *
***********************************************************************************************************************/
void light_module_set_rgb_mode(rgb_light_mode_t mode) {
printf("light_module_set_rgb_mode %d\n", mode);
s_rgb_light_mode_config = mode;
prv_light_module_set_rgb_mode(mode);
}
void light_module_set_rgb_in_interval_working_mode(bool state) {
printf("light_module_set_rgb_in_interval_working_mode %d\n", state);
s_interval_working_mode = state;
}
void light_module_set_autoshutdown_indicator_light(bool open) { s_autoshutdown_light_state = open; }
void light_module_set_error_light_mode(bool open, uint8_t error_mode) {
printf("light_module_set_error_light_mode %d\n", error_mode);
s_errorlight_display_state = open;
s_errornum = error_mode;
}
void light_module_close_all_light(void) {
printf("light_module_close_all_light\n");
light_module_set_rgb_mode(krgb_close);
light_module_set_autoshutdown_indicator_light(false);
light_module_set_rgb_in_interval_working_mode(false);
prv_set_timing_light_mode(0);
s_errornum = 0;
s_interval_working_mode = false;
s_autoshutdown_light_state = false;
s_errorlight_display_state = false;
}
void light_module_schedule(void) {
prv_light_module_rgb_light_control_schedule();
prv_time_light_control_schedule();
}
#endif

0
APP/service/light_control_service.h

162
APP/ozone_pwm_control.c → APP/service/ozone_control_service.c

@ -1,82 +1,82 @@
#if 0
#include "ozone_pwm_control.h"
#include "pwm.h"
static bool s_ozone_pwm_control_enable_falg = false;
static bool s_pwm_modble_hardware_control_flag; //pwm使能标志位
static uint32_t s_hardware_frequency; // hz
static uint32_t s_hardware_duty; //msPWM占空比
static uint32_t s_large_period; //ms
static uint32_t s_large_duty = 100; //ms
static uint32_t begin_ticket;
static void prv_pwm_module_set_pwm_duty(uint32_t frequencyhz, uint32_t duty) {
set_pwm_modbul_freq_duty(frequencyhz, duty);
s_pwm_modble_hardware_control_flag = true;
}
static void prv_pwm_stop(void) {
set_pwm_modbul_freq_duty(s_hardware_frequency, 0); //PWM输出
s_pwm_modble_hardware_control_flag = false;
}
static bool prv_pwm_is_enable(void) { return s_pwm_modble_hardware_control_flag; }
static void prv_update_begin_ticket(void) {
begin_ticket = get_sys_ticket(); //
}
bool ozone_pwm_control_is_enable(void) { return s_ozone_pwm_control_enable_falg; }
bool ozone_pwm_control_hardware_is_enable(void) { return s_pwm_modble_hardware_control_flag; }
/**
* @brief 100
* 300000
* @param freq
* @param duty
*/
void ozone_pwm_control_module_set_pwm_output_1(uint32_t freqhz, uint8_t hardware_duty) {
ozone_pwm_control_module_set_pwm_output_2(freqhz, hardware_duty, 100 * 1000, 100);
}
/**
* @brief PWM
*
* @param hardware_period pwm频率
* @param hardware_duty pwm占空比
* @param large_period
* @param large_duty
*/
void ozone_pwm_control_module_set_pwm_output_2(uint32_t freqhz, uint8_t hardware_duty, uint32_t large_period, uint8_t large_duty) {
s_hardware_frequency = freqhz;
s_hardware_duty = hardware_duty;
s_large_period = large_period;
s_large_duty = large_duty;
prv_update_begin_ticket();
s_ozone_pwm_control_enable_falg = true;
prv_pwm_module_set_pwm_duty(freqhz, hardware_duty);
}
void ozone_pwm_control_module_stop_pwm(void) { s_ozone_pwm_control_enable_falg = false; }
void ozone_pwm_control_module_loop(void) {
static uint32_t hardware_frequency;
static uint32_t hardware_duty;
if (ozone_pwm_control_is_enable() == false) { //使退
if (prv_pwm_is_enable()) {
prv_pwm_stop();
}
return;
}
if (port_haspassedms(begin_ticket) % s_large_period <= s_large_period * s_large_duty / 100) {
if (!prv_pwm_is_enable()) {
printf("set work\r\n");
prv_pwm_module_set_pwm_duty(hardware_frequency, hardware_duty);
}
} else {
if (prv_pwm_is_enable()) {
printf("set rest\r\n");
hardware_frequency = s_hardware_frequency; //
hardware_duty = s_hardware_duty; //
prv_pwm_stop();
}
}
}
#if 0
#include "ozone_pwm_control.h"
#include "pwm.h"
static bool s_ozone_pwm_control_enable_falg = false;
static bool s_pwm_modble_hardware_control_flag; //pwm使能标志位
static uint32_t s_hardware_frequency; // hz
static uint32_t s_hardware_duty; //msPWM占空比
static uint32_t s_large_period; //ms
static uint32_t s_large_duty = 100; //ms
static uint32_t begin_ticket;
static void prv_pwm_module_set_pwm_duty(uint32_t frequencyhz, uint32_t duty) {
set_pwm_modbul_freq_duty(frequencyhz, duty);
s_pwm_modble_hardware_control_flag = true;
}
static void prv_pwm_stop(void) {
set_pwm_modbul_freq_duty(s_hardware_frequency, 0); //PWM输出
s_pwm_modble_hardware_control_flag = false;
}
static bool prv_pwm_is_enable(void) { return s_pwm_modble_hardware_control_flag; }
static void prv_update_begin_ticket(void) {
begin_ticket = get_sys_ticket(); //
}
bool ozone_pwm_control_is_enable(void) { return s_ozone_pwm_control_enable_falg; }
bool ozone_pwm_control_hardware_is_enable(void) { return s_pwm_modble_hardware_control_flag; }
/**
* @brief 100
* 300000
* @param freq
* @param duty
*/
void ozone_pwm_control_module_set_pwm_output_1(uint32_t freqhz, uint8_t hardware_duty) {
ozone_pwm_control_module_set_pwm_output_2(freqhz, hardware_duty, 100 * 1000, 100);
}
/**
* @brief PWM
*
* @param hardware_period pwm频率
* @param hardware_duty pwm占空比
* @param large_period
* @param large_duty
*/
void ozone_pwm_control_module_set_pwm_output_2(uint32_t freqhz, uint8_t hardware_duty, uint32_t large_period, uint8_t large_duty) {
s_hardware_frequency = freqhz;
s_hardware_duty = hardware_duty;
s_large_period = large_period;
s_large_duty = large_duty;
prv_update_begin_ticket();
s_ozone_pwm_control_enable_falg = true;
prv_pwm_module_set_pwm_duty(freqhz, hardware_duty);
}
void ozone_pwm_control_module_stop_pwm(void) { s_ozone_pwm_control_enable_falg = false; }
void ozone_pwm_control_module_loop(void) {
static uint32_t hardware_frequency;
static uint32_t hardware_duty;
if (ozone_pwm_control_is_enable() == false) { //使退
if (prv_pwm_is_enable()) {
prv_pwm_stop();
}
return;
}
if (port_haspassedms(begin_ticket) % s_large_period <= s_large_period * s_large_duty / 100) {
if (!prv_pwm_is_enable()) {
printf("set work\r\n");
prv_pwm_module_set_pwm_duty(hardware_frequency, hardware_duty);
}
} else {
if (prv_pwm_is_enable()) {
printf("set rest\r\n");
hardware_frequency = s_hardware_frequency; //
hardware_duty = s_hardware_duty; //
prv_pwm_stop();
}
}
}
#endif

0
APP/service/ozone_control_service.h

218
MDK_StartUp/startup_ES8P5066.s

@ -1,218 +0,0 @@
;*******************************************************************************
; *author : Eastsoft MCU Software Team
; *version : V0.01
; *data : 5/28/2021
;
; *Copyright (C) 2021 Shanghai Eastsoft Microelectronics Co., Ltd.
; *
; * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
; * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
; * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
; * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
; * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
;*******************************************************************************
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000000
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
__Vectors DCD __initial_sp ;0, Top of Stack
DCD Reset_IRQHandler ;1, Reset Handler
DCD NMI_IRQHandler ;2, NMI Handler
DCD HardFault_IRQHandler ;3, HardFault Handler
DCD 0 ;4, Reserved
DCD 0 ;5, Reserved
DCD 0 ;6, Reserved
DCD 0 ;7, Reserved
DCD 0 ;8, Reserved
DCD 0 ;9, Reserved
DCD 0 ;10, Reserved
DCD SVC_IRQHandler ;11, SVCall Handler
DCD 0 ;12, Reserved
DCD 0 ;13, Reserved
DCD PendSV_IRQHandler ;14, PendSV Handler
DCD SysTick_IRQHandler ;15, SysTick Handler
; External Interrupts
DCD PINT0_IRQHandler ;16, PINT0 IRQHandler
DCD PINT1_IRQHandler ;17, PINT1 IRQHandler
DCD PINT2_IRQHandler ;18, PINT2 IRQHandler
DCD PINT3_IRQHandler ;19, PINT3 IRQHandler
DCD PINT4_IRQHandler ;20, PINT4 IRQHandler
DCD PINT5_IRQHandler ;21, PINT5 IRQHandler
DCD PINT6_IRQHandler ;22, PINT6 IRQHandler
DCD PINT7_IRQHandler ;23, PINT7 IRQHandler
DCD T16N0_IRQHandler ;24, T16N0 IRQHandler
DCD T16N1_IRQHandler ;25, T16N1 IRQHandler
DCD T16N2_IRQHandler ;26, T16N2 IRQHandler
DCD T16N3_IRQHandler ;27, T16N3 IRQHandler
DCD T32N0_IRQHandler ;28, T32N0 IRQHandler
DCD 0 ;29, Reserved
DCD 0 ;30, Reserved
DCD WWDT_IRQHandler ;31, WWDT IRQHandler
DCD IWDT_IRQHandler ;32, IWDT IRQHandler
DCD 0 ;33, Reserved
DCD KINT_IRQHandler ;34, KINT IRQHandler
DCD ADC_IRQHandler ;35, ADC IRQHandler
DCD 0 ;36, Reserved
DCD LVD_IRQHandler ;37, LVD IRQHandler
DCD 0 ;38, Reserved
DCD UART0_IRQHandler ;39, UART0 IRQHandler
DCD UART1_IRQHandler ;40, UART1 IRQHandler
DCD UART2_IRQHandler ;41, UART2 IRQHandler
DCD 0 ;42, Reserved
DCD 0 ;43, Reserved
DCD SPI1_IRQHandler ;44, SPI1 IRQHandler
DCD I2C0_IRQHandler ;45, I2C0 IRQHandler
DCD 0 ;46, Reserved
DCD CCM_IRQHandler ;47, CCM IRQHandler
AREA |.text|, CODE, READONLY
; Reset Handler
Reset_IRQHandler PROC
EXPORT Reset_IRQHandler [WEAK]
IMPORT __main
IMPORT SystemInit
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception IRQHandlers (infinite loops which can be modified)
NMI_IRQHandler PROC
EXPORT NMI_IRQHandler [WEAK]
B .
ENDP
HardFault_IRQHandler PROC
EXPORT HardFault_IRQHandler [WEAK]
B .
ENDP
SVC_IRQHandler PROC
EXPORT SVC_IRQHandler [WEAK]
B .
ENDP
PendSV_IRQHandler PROC
EXPORT PendSV_IRQHandler [WEAK]
B .
ENDP
SysTick_IRQHandler PROC
EXPORT SysTick_IRQHandler [WEAK]
B .
ENDP
Default_IRQHandler PROC
EXPORT PINT0_IRQHandler [WEAK]
EXPORT PINT1_IRQHandler [WEAK]
EXPORT PINT2_IRQHandler [WEAK]
EXPORT PINT3_IRQHandler [WEAK]
EXPORT PINT4_IRQHandler [WEAK]
EXPORT PINT5_IRQHandler [WEAK]
EXPORT PINT6_IRQHandler [WEAK]
EXPORT PINT7_IRQHandler [WEAK]
EXPORT T16N0_IRQHandler [WEAK]
EXPORT T16N1_IRQHandler [WEAK]
EXPORT T16N2_IRQHandler [WEAK]
EXPORT T16N3_IRQHandler [WEAK]
EXPORT T32N0_IRQHandler [WEAK]
EXPORT WWDT_IRQHandler [WEAK]
EXPORT IWDT_IRQHandler [WEAK]
EXPORT RTC_IRQHandler [WEAK]
EXPORT KINT_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT LVD_IRQHandler [WEAK]
EXPORT UART0_IRQHandler [WEAK]
EXPORT UART1_IRQHandler [WEAK]
EXPORT UART2_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT I2C0_IRQHandler [WEAK]
EXPORT CCM_IRQHandler [WEAK]
PINT0_IRQHandler
PINT1_IRQHandler
PINT2_IRQHandler
PINT3_IRQHandler
PINT4_IRQHandler
PINT5_IRQHandler
PINT6_IRQHandler
PINT7_IRQHandler
T16N0_IRQHandler
T16N1_IRQHandler
T16N2_IRQHandler
T16N3_IRQHandler
T32N0_IRQHandler
WWDT_IRQHandler
IWDT_IRQHandler
RTC_IRQHandler
KINT_IRQHandler
ADC_IRQHandler
LVD_IRQHandler
UART0_IRQHandler
UART1_IRQHandler
UART2_IRQHandler
SPI1_IRQHandler
I2C0_IRQHandler
CCM_IRQHandler
B .
ENDP
ALIGN
; User Initial Stack & Heap
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END

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

46
project_ozone/project_o.uvgui.zel
File diff suppressed because it is too large
View File

100
project_ozone/project_o.uvopt

@ -253,8 +253,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\APP\light.c</PathWithFileName>
<FilenameWithoutPath>light.c</FilenameWithoutPath>
<PathWithFileName>..\APP\test.c</PathWithFileName>
<FilenameWithoutPath>test.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@ -265,8 +265,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\APP\ozone_pwm_control.c</PathWithFileName>
<FilenameWithoutPath>ozone_pwm_control.c</FilenameWithoutPath>
<PathWithFileName>..\APP\service\light_control_service.c</PathWithFileName>
<FilenameWithoutPath>light_control_service.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@ -277,20 +277,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\APP\test.c</PathWithFileName>
<FilenameWithoutPath>test.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>6</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\APP\pwm.c</PathWithFileName>
<FilenameWithoutPath>pwm.c</FilenameWithoutPath>
<PathWithFileName>..\APP\service\ozone_control_service.c</PathWithFileName>
<FilenameWithoutPath>ozone_control_service.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@ -304,7 +292,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>7</FileNumber>
<FileNumber>6</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -314,6 +302,18 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>7</FileNumber>
<FileType>2</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\CMSIS\startup_ES8P5066.s</PathWithFileName>
<FilenameWithoutPath>startup_ES8P5066.s</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@ -457,7 +457,7 @@
</Group>
<Group>
<GroupName>MDK_StartUp</GroupName>
<GroupName>zes8p5066lib</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
@ -465,46 +465,6 @@
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>19</FileNumber>
<FileType>2</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\MDK_StartUp\startup_ES8P5066.s</PathWithFileName>
<FilenameWithoutPath>startup_ES8P5066.s</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>PlatForm</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>20</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\PlatForm\irqhandler.c</PathWithFileName>
<FilenameWithoutPath>irqhandler.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>zes8p5066lib</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>21</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -515,8 +475,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>22</FileNumber>
<GroupNumber>4</GroupNumber>
<FileNumber>20</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -527,8 +487,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>23</FileNumber>
<GroupNumber>4</GroupNumber>
<FileNumber>21</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -539,8 +499,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>24</FileNumber>
<GroupNumber>4</GroupNumber>
<FileNumber>22</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -551,8 +511,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>25</FileNumber>
<GroupNumber>4</GroupNumber>
<FileNumber>23</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -563,8 +523,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>26</FileNumber>
<GroupNumber>4</GroupNumber>
<FileNumber>24</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>

42
project_ozone/project_o.uvproj

@ -433,24 +433,19 @@
<FilePath>..\APP\port.c</FilePath>
</File>
<File>
<FileName>light.c</FileName>
<FileType>1</FileType>
<FilePath>..\APP\light.c</FilePath>
</File>
<File>
<FileName>ozone_pwm_control.c</FileName>
<FileName>test.c</FileName>
<FileType>1</FileType>
<FilePath>..\APP\ozone_pwm_control.c</FilePath>
<FilePath>..\APP\test.c</FilePath>
</File>
<File>
<FileName>test.c</FileName>
<FileName>light_control_service.c</FileName>
<FileType>1</FileType>
<FilePath>..\APP\test.c</FilePath>
<FilePath>..\APP\service\light_control_service.c</FilePath>
</File>
<File>
<FileName>pwm.c</FileName>
<FileName>ozone_control_service.c</FileName>
<FileType>1</FileType>
<FilePath>..\APP\pwm.c</FilePath>
<FilePath>..\APP\service\ozone_control_service.c</FilePath>
</File>
</Files>
</Group>
@ -462,6 +457,11 @@
<FileType>1</FileType>
<FilePath>..\CMSIS\system_es8p5066.c</FilePath>
</File>
<File>
<FileName>startup_ES8P5066.s</FileName>
<FileType>2</FileType>
<FilePath>..\CMSIS\startup_ES8P5066.s</FilePath>
</File>
</Files>
</Group>
<Group>
@ -525,26 +525,6 @@
</Files>
</Group>
<Group>
<GroupName>MDK_StartUp</GroupName>
<Files>
<File>
<FileName>startup_ES8P5066.s</FileName>
<FileType>2</FileType>
<FilePath>..\MDK_StartUp\startup_ES8P5066.s</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>PlatForm</GroupName>
<Files>
<File>
<FileName>irqhandler.c</FileName>
<FileType>1</FileType>
<FilePath>..\PlatForm\irqhandler.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>zes8p5066lib</GroupName>
<Files>
<File>

Loading…
Cancel
Save