992 lines
		
	
	
		
			24 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			992 lines
		
	
	
		
			24 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#include "iot_bitops.h"
							 | 
						|||
| 
								 | 
							
								#include "dtest_printf.h"
							 | 
						|||
| 
								 | 
							
								#include "cpu.h"
							 | 
						|||
| 
								 | 
							
								#include "ahb.h"
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#if HW_PLATFORM > HW_PLATFORM_SIMU
							 | 
						|||
| 
								 | 
							
								#include "dbg_io.h"
							 | 
						|||
| 
								 | 
							
								#endif
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#include "chip_reg_base.h"
							 | 
						|||
| 
								 | 
							
								#include "ahb_rf_s.h"
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#include "uart.h"
							 | 
						|||
| 
								 | 
							
								#include "strformat.h"
							 | 
						|||
| 
								 | 
							
								#include "uart_e.h"
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#include "iot_irq.h"
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#include "dev_spinlock.h"
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#include "apb.h"
							 | 
						|||
| 
								 | 
							
								#include "gpio_mtx.h"
							 | 
						|||
| 
								 | 
							
								#include "ledc_hw.h"
							 | 
						|||
| 
								 | 
							
								#include "watchdog.h"
							 | 
						|||
| 
								 | 
							
								#include "gp_timer.h"
							 | 
						|||
| 
								 | 
							
								#include "iot_clock.h"
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#include "iot_led.h"
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void register_print_by_addr(uint32_t addr, int num);
							 | 
						|||
| 
								 | 
							
								void delay_sometime(void);
							 | 
						|||
| 
								 | 
							
								void wdt_cpu_reset_test(LEDC_PORT ch);
							 | 
						|||
| 
								 | 
							
								void wdt_full_reset_test(LEDC_PORT ch);
							 | 
						|||
| 
								 | 
							
								void software_rst_test(LEDC_PORT ch);
							 | 
						|||
| 
								 | 
							
								void led_hal_test(void);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void ledc_interrrupt_cb(uint8_t port)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    iot_printf("port%d done\r\n", port);
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								typedef struct ledc_para_t {
							 | 
						|||
| 
								 | 
							
								    uint16_t div;//uint32_t clk_period;
							 | 
						|||
| 
								 | 
							
								    uint16_t l2h_point;
							 | 
						|||
| 
								 | 
							
								    uint16_t h2l_point;
							 | 
						|||
| 
								 | 
							
								    uint16_t phase1_blink_times;
							 | 
						|||
| 
								 | 
							
								    uint16_t phase2_blink_times;
							 | 
						|||
| 
								 | 
							
								    uint16_t thrs;
							 | 
						|||
| 
								 | 
							
								    uint8_t phase_num;
							 | 
						|||
| 
								 | 
							
								    uint8_t phase1_mode;
							 | 
						|||
| 
								 | 
							
								    uint8_t phase2_mode;
							 | 
						|||
| 
								 | 
							
								    uint8_t phase1_scale;
							 | 
						|||
| 
								 | 
							
								    uint8_t phase2_scale;
							 | 
						|||
| 
								 | 
							
								    uint8_t cycle_times;
							 | 
						|||
| 
								 | 
							
								    uint8_t loop_times;
							 | 
						|||
| 
								 | 
							
								    uint16_t nop_num;
							 | 
						|||
| 
								 | 
							
								}ledc_para_s;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void start_ledc(uint8_t ch)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    ledc_cnt_ena(ch, LEDC_ENA_ENABLE);
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void stop_ledc(uint8_t ch)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    ledc_cnt_ena(ch, LEDC_ENA_DISABLE);
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void config_ledc(uint8_t ch, ledc_para_s * para)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    //中断初始化
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_interrupt_init(ch, ledc_interrrupt_cb);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //2
							 | 
						|||
| 
								 | 
							
								    ledc_timer_rst(ch);
							 | 
						|||
| 
								 | 
							
								    ledc_timer_init(ch, para->div); // 24 --> 1M
							 | 
						|||
| 
								 | 
							
								    ledc_timer_ctrl(ch, TIMER_CTRL_START);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //3
							 | 
						|||
| 
								 | 
							
								    ledc_polarity_sel(ch, OUT_POL_ORIGINAL);//OUT_POL_INVERT);
							 | 
						|||
| 
								 | 
							
								    ledc_idle_level_sel(ch, IDLE_LEVEL_LOW);//IDLE_LEVEL_HIGH);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //4
							 | 
						|||
| 
								 | 
							
								    ledc_h2l_point_set(ch, para->h2l_point);
							 | 
						|||
| 
								 | 
							
								    ledc_l2h_point_set(ch, para->l2h_point);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //5
							 | 
						|||
| 
								 | 
							
								    ledc_phase1_blink_times_set(ch, para->phase1_blink_times); // thrs/scale
							 | 
						|||
| 
								 | 
							
								    ledc_phase2_blink_times_set(ch, para->phase2_blink_times);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //6
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_duty_cnt_sel(ch, DUTY_CNT_OWN);
							 | 
						|||
| 
								 | 
							
								    ledc_thrs_set(ch, para->thrs); // 1000 -> 1k
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //7
							 | 
						|||
| 
								 | 
							
								    ledc_phase_opt_sel(ch, DUTY_OPT_MODE_NEW);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_phase_num_sel(ch, para->phase_num);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_phase1_mode_sel(ch,  para->phase1_mode);
							 | 
						|||
| 
								 | 
							
								    ledc_phase2_mode_sel(ch,  para->phase2_mode);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_phase1_scale_set(ch, para->phase1_scale);
							 | 
						|||
| 
								 | 
							
								    ledc_phase2_scale_set(ch, para->phase2_scale);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_cycle_times_set(ch, para->cycle_times);
							 | 
						|||
| 
								 | 
							
								    ledc_loop_times_set(ch, para->loop_times);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_nop_num_set(ch, para->nop_num);
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void delay(int times)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    for(int i = 0; i < times; i++)
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        delay_sometime();
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								ledc_para_s para_table[] = {
							 | 
						|||
| 
								 | 
							
								{//0
							 | 
						|||
| 
								 | 
							
								    .div = 24,
							 | 
						|||
| 
								 | 
							
								    .h2l_point = 999,
							 | 
						|||
| 
								 | 
							
								    .l2h_point = 500,
							 | 
						|||
| 
								 | 
							
								    .phase1_blink_times = 50,
							 | 
						|||
| 
								 | 
							
								    .phase2_blink_times = 50,
							 | 
						|||
| 
								 | 
							
								    .thrs = 999,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase_num = PHASE_NUM_ONE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								    .phase2_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_scale = 15,
							 | 
						|||
| 
								 | 
							
								    .phase2_scale = 20,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .cycle_times = 3,
							 | 
						|||
| 
								 | 
							
								    .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								},
							 | 
						|||
| 
								 | 
							
								{//1
							 | 
						|||
| 
								 | 
							
								    .div = 24,
							 | 
						|||
| 
								 | 
							
								    .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								    .l2h_point = 500,
							 | 
						|||
| 
								 | 
							
								    .phase1_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .phase2_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .thrs = 1000,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase_num = PHASE_NUM_TWO,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								    .phase2_mode = PHASE_MODE_DECREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_scale = 50,
							 | 
						|||
| 
								 | 
							
								    .phase2_scale = 50,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .cycle_times = 3,
							 | 
						|||
| 
								 | 
							
								    .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								},
							 | 
						|||
| 
								 | 
							
								{//2
							 | 
						|||
| 
								 | 
							
								    .div = 24,
							 | 
						|||
| 
								 | 
							
								    .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								    .l2h_point = 500,
							 | 
						|||
| 
								 | 
							
								    .phase1_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .phase2_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .thrs = 1000,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase_num = PHASE_NUM_TWO,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								    .phase2_mode = PHASE_MODE_DECREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_scale = 50,
							 | 
						|||
| 
								 | 
							
								    .phase2_scale = 100,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .cycle_times = 3,
							 | 
						|||
| 
								 | 
							
								    .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								},
							 | 
						|||
| 
								 | 
							
								{//3
							 | 
						|||
| 
								 | 
							
								    .div = 24,
							 | 
						|||
| 
								 | 
							
								    .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								    .l2h_point = 500,
							 | 
						|||
| 
								 | 
							
								    .phase1_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .phase2_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .thrs = 1000,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase_num = PHASE_NUM_TWO,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								    .phase2_mode = PHASE_MODE_DECREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_scale = 50,
							 | 
						|||
| 
								 | 
							
								    .phase2_scale = 25,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .cycle_times = 3,
							 | 
						|||
| 
								 | 
							
								    .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								},
							 | 
						|||
| 
								 | 
							
								{//4
							 | 
						|||
| 
								 | 
							
								    .div = 24,
							 | 
						|||
| 
								 | 
							
								    .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								    .l2h_point = 500,
							 | 
						|||
| 
								 | 
							
								    .phase1_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .phase2_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .thrs = 1000,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase_num = PHASE_NUM_TWO,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								    .phase2_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_scale = 50,
							 | 
						|||
| 
								 | 
							
								    .phase2_scale = 25,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .cycle_times = 3,
							 | 
						|||
| 
								 | 
							
								    .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								},
							 | 
						|||
| 
								 | 
							
								{//5
							 | 
						|||
| 
								 | 
							
								    .div = 24,
							 | 
						|||
| 
								 | 
							
								    .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								    .l2h_point = 250,
							 | 
						|||
| 
								 | 
							
								    .phase1_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .phase2_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .thrs = 1000,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase_num = PHASE_NUM_TWO,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_mode = PHASE_MODE_FIXED_DUTY,
							 | 
						|||
| 
								 | 
							
								    .phase2_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_scale = 50,
							 | 
						|||
| 
								 | 
							
								    .phase2_scale = 25,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .cycle_times = 3,
							 | 
						|||
| 
								 | 
							
								    .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								},
							 | 
						|||
| 
								 | 
							
								{//6
							 | 
						|||
| 
								 | 
							
								    .div = 24,
							 | 
						|||
| 
								 | 
							
								    .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								    .l2h_point = 250,
							 | 
						|||
| 
								 | 
							
								    .phase1_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .phase2_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .thrs = 1000,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase_num = PHASE_NUM_TWO,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_mode = PHASE_MODE_FIXED_DUTY,
							 | 
						|||
| 
								 | 
							
								    .phase2_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_scale = 50,
							 | 
						|||
| 
								 | 
							
								    .phase2_scale = 150,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .cycle_times = 5,
							 | 
						|||
| 
								 | 
							
								    .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								},
							 | 
						|||
| 
								 | 
							
								{//7
							 | 
						|||
| 
								 | 
							
								    .div = 24,
							 | 
						|||
| 
								 | 
							
								    .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								    .l2h_point = 250,
							 | 
						|||
| 
								 | 
							
								    .phase1_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .phase2_blink_times = 10,
							 | 
						|||
| 
								 | 
							
								    .thrs = 1000,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase_num = PHASE_NUM_TWO,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_mode = PHASE_MODE_FIXED_DUTY,
							 | 
						|||
| 
								 | 
							
								    .phase2_mode = PHASE_MODE_DECREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_scale = 50,
							 | 
						|||
| 
								 | 
							
								    .phase2_scale = 150,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .cycle_times = 5,
							 | 
						|||
| 
								 | 
							
								    .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								},
							 | 
						|||
| 
								 | 
							
								{//8
							 | 
						|||
| 
								 | 
							
								    .div = 24,
							 | 
						|||
| 
								 | 
							
								    .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								    .l2h_point = 250,
							 | 
						|||
| 
								 | 
							
								    .phase1_blink_times = 20,
							 | 
						|||
| 
								 | 
							
								    .phase2_blink_times = 15,
							 | 
						|||
| 
								 | 
							
								    .thrs = 1000,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase_num = PHASE_NUM_TWO,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								    .phase2_mode = PHASE_MODE_DECREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_scale = 100,
							 | 
						|||
| 
								 | 
							
								    .phase2_scale = 100,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .cycle_times = 5,
							 | 
						|||
| 
								 | 
							
								    .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								},
							 | 
						|||
| 
								 | 
							
								{//9
							 | 
						|||
| 
								 | 
							
								    .div = 24,
							 | 
						|||
| 
								 | 
							
								    .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								    .l2h_point = 250,
							 | 
						|||
| 
								 | 
							
								    .phase1_blink_times = 20,
							 | 
						|||
| 
								 | 
							
								    .phase2_blink_times = 15,
							 | 
						|||
| 
								 | 
							
								    .thrs = 1000,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase_num = PHASE_NUM_TWO,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								    .phase2_mode = PHASE_MODE_FIXED_DUTY,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .phase1_scale = 100,
							 | 
						|||
| 
								 | 
							
								    .phase2_scale = 100,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .cycle_times = 5,
							 | 
						|||
| 
								 | 
							
								    .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								},
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								};
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								extern struct uart_ctrl uart_e_ctrl;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void mode_switch_test(int ch)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    ledc_para_s para_flash;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_para_s para_dark2light_breath;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_para_s para_light2dark_breath;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_para_s light2dark_flash;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_para_s dark2light_flash;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //-----------------------------
							 | 
						|||
| 
								 | 
							
								        para_flash.div = 249; // 100k
							 | 
						|||
| 
								 | 
							
								        para_flash.l2h_point = 20000;
							 | 
						|||
| 
								 | 
							
								        para_flash.h2l_point = 40000;
							 | 
						|||
| 
								 | 
							
								        para_flash.phase1_blink_times = 10;
							 | 
						|||
| 
								 | 
							
								        para_flash.phase2_blink_times = 10;
							 | 
						|||
| 
								 | 
							
								        para_flash.thrs = 40000; // 5hz
							 | 
						|||
| 
								 | 
							
								        para_flash.phase_num = PHASE_NUM_TWO;
							 | 
						|||
| 
								 | 
							
								        para_flash.phase1_mode = PHASE_MODE_FIXED_DUTY;
							 | 
						|||
| 
								 | 
							
								        para_flash.phase2_mode = PHASE_MODE_FIXED_DUTY;
							 | 
						|||
| 
								 | 
							
								        para_flash.phase1_scale = 200;
							 | 
						|||
| 
								 | 
							
								        para_flash.phase2_scale = 200;
							 | 
						|||
| 
								 | 
							
								        para_flash.cycle_times = 70;
							 | 
						|||
| 
								 | 
							
								        para_flash.loop_times = 10;
							 | 
						|||
| 
								 | 
							
								        para_flash.nop_num = 10;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //----------------------------------------------
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.div = 24; // 100k
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.l2h_point = 10000;
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.h2l_point = 20000;
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.phase1_blink_times = 100;
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.phase2_blink_times = 100;
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.thrs = 20000; // 5hz
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.phase_num = PHASE_NUM_TWO;
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.phase1_mode = PHASE_MODE_INCREASE;
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.phase2_mode = PHASE_MODE_DECREASE;
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.phase1_scale = 200;
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.phase2_scale = 200;
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.cycle_times = 70;
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.loop_times = 10;
							 | 
						|||
| 
								 | 
							
								        para_light2dark_breath.nop_num = 10;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //----------------------------------------------
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.div = 24; // 100k
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.l2h_point = 10000;
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.h2l_point = 20000;
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.phase1_blink_times = 100;
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.phase2_blink_times = 100;
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.thrs = 20000; // 5hz
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.phase_num = PHASE_NUM_TWO;
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.phase1_mode = PHASE_MODE_DECREASE;
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.phase2_mode = PHASE_MODE_INCREASE;
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.phase1_scale = 200;
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.phase2_scale = 200;
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.cycle_times = 70;
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.loop_times = 10;
							 | 
						|||
| 
								 | 
							
								        para_dark2light_breath.nop_num = 10;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //----------------------------------------------
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.div = 24; // 100k
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.l2h_point = 10000;
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.h2l_point = 20000;
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.phase1_blink_times = 100;
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.phase2_blink_times = 100;
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.thrs = 20000; // 5hz
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.phase_num = PHASE_NUM_ONE;
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.phase1_mode = PHASE_MODE_INCREASE;
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.phase2_mode = PHASE_MODE_FIXED_DUTY;
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.phase1_scale = 200;
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.phase2_scale = 200;
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.cycle_times = 70;
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.loop_times = 10;
							 | 
						|||
| 
								 | 
							
								        light2dark_flash.nop_num = 10;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //----------------------------------------------
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.div = 24; // 100k
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.l2h_point = 10000;
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.h2l_point = 20000;
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.phase1_blink_times = 100;
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.phase2_blink_times = 100;
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.thrs = 20000; // 5hz
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.phase_num = PHASE_NUM_ONE;
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.phase1_mode = PHASE_MODE_DECREASE;
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.phase2_mode = PHASE_MODE_FIXED_DUTY;
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.phase1_scale = 200;
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.phase2_scale = 200;
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.cycle_times = 70;
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.loop_times = 10;
							 | 
						|||
| 
								 | 
							
								        dark2light_flash.nop_num = 10;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        for(;;) {
							 | 
						|||
| 
								 | 
							
								            stop_ledc(ch);
							 | 
						|||
| 
								 | 
							
								            config_ledc(ch, ¶_flash);
							 | 
						|||
| 
								 | 
							
								            start_ledc(ch);
							 | 
						|||
| 
								 | 
							
								            delay(100);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            stop_ledc(ch);
							 | 
						|||
| 
								 | 
							
								            config_ledc(ch, ¶_dark2light_breath);
							 | 
						|||
| 
								 | 
							
								            start_ledc(ch);
							 | 
						|||
| 
								 | 
							
								            delay(100);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            stop_ledc(ch);
							 | 
						|||
| 
								 | 
							
								            config_ledc(ch, ¶_light2dark_breath);
							 | 
						|||
| 
								 | 
							
								            start_ledc(ch);
							 | 
						|||
| 
								 | 
							
								            delay(100);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            stop_ledc(ch);
							 | 
						|||
| 
								 | 
							
								            config_ledc(ch, &light2dark_flash);
							 | 
						|||
| 
								 | 
							
								            start_ledc(ch);
							 | 
						|||
| 
								 | 
							
								            delay(100);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            stop_ledc(ch);
							 | 
						|||
| 
								 | 
							
								            config_ledc(ch, &dark2light_flash);
							 | 
						|||
| 
								 | 
							
								            start_ledc(ch);
							 | 
						|||
| 
								 | 
							
								            delay(100);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#define foreach(times, statement) \
							 | 
						|||
| 
								 | 
							
								for(int __i__ = 0; __i__ < times; __i__ ++) { \
							 | 
						|||
| 
								 | 
							
								    statement \
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void wdt_reset_test()
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								uint8_t g_pin_table[] = {
							 | 
						|||
| 
								 | 
							
								26, // j208  8
							 | 
						|||
| 
								 | 
							
								27, // j208  7
							 | 
						|||
| 
								 | 
							
								28, // j208  10
							 | 
						|||
| 
								 | 
							
								9,  // j204  19
							 | 
						|||
| 
								 | 
							
								12, //       38
							 | 
						|||
| 
								 | 
							
								11, //       36
							 | 
						|||
| 
								 | 
							
								39, //       10
							 | 
						|||
| 
								 | 
							
								8,  // j213  T1 只能作为输出
							 | 
						|||
| 
								 | 
							
								7   //       R1 只能作为输入
							 | 
						|||
| 
								 | 
							
								};
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								/*
							 | 
						|||
| 
								 | 
							
								cmd ch gpio
							 | 
						|||
| 
								 | 
							
								00 00 08 以para_table[0]为参数进行测试对LEDC0进行测试,波形从GPIO8输出
							 | 
						|||
| 
								 | 
							
								00 01 08 以para_table[1]为参数进行测试对LEDC1进行测试,波形从GPIO8输出
							 | 
						|||
| 
								 | 
							
								02 02 08 以para_table[2]为参数进行测试对LEDC2进行测试,波形从GPIO8输出
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								55 00 08 LEDC0 动态模式切换测试,波形从GPIO8输出
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								56 01 08 LEDC1 看门狗cputrst测试,波形从GPIO8输出
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								57       full rst 其他同上
							 | 
						|||
| 
								 | 
							
								58       software rst
							 | 
						|||
| 
								 | 
							
								*/
							 | 
						|||
| 
								 | 
							
								extern void _start(void);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								int main(void)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    iot_interrupt_init(0);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    dbg_uart_init();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    iot_printf("total paras = %d\r\n", sizeof(para_table)/sizeof(para_table[0]) );
							 | 
						|||
| 
								 | 
							
								    ahb_core0_set_start((uint32_t) _start);
							 | 
						|||
| 
								 | 
							
								    volatile int i = 0;
							 | 
						|||
| 
								 | 
							
								    while(1) {
							 | 
						|||
| 
								 | 
							
								        if (uart_e_ctrl.rx_fifo_cnt(UART_PT0) > 2) {
							 | 
						|||
| 
								 | 
							
								            int c = uart_e_ctrl.getc(UART_PT0);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            int ch = uart_e_ctrl.getc(UART_PT0);
							 | 
						|||
| 
								 | 
							
								            int gpio = 8;
							 | 
						|||
| 
								 | 
							
								            gpio = uart_e_ctrl.getc(UART_PT0);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            iot_printf("cmd=%d,ch=%d;gpio=%d\r\n", c, ch, gpio);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (c == 0x59) {
							 | 
						|||
| 
								 | 
							
								                iot_printf("entry mode led hal test \r\n");
							 | 
						|||
| 
								 | 
							
								                led_hal_test();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            ledc_ena_rst();
							 | 
						|||
| 
								 | 
							
								            ledc_gpio_config(ch, gpio);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            //中断初始化
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            ledc_interrupt_init(ch, ledc_interrrupt_cb);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (c >=0 && c <= sizeof(para_table)/sizeof(para_table[0])) {
							 | 
						|||
| 
								 | 
							
								                iot_printf("use para %d testig\r\n", c);
							 | 
						|||
| 
								 | 
							
								                stop_ledc(ch);
							 | 
						|||
| 
								 | 
							
								                config_ledc(ch, ¶_table[c]);
							 | 
						|||
| 
								 | 
							
								                start_ledc(ch);
							 | 
						|||
| 
								 | 
							
								            } else if(c == 0x55) {
							 | 
						|||
| 
								 | 
							
								                iot_printf("entry mode switch test dead loop\r\n");
							 | 
						|||
| 
								 | 
							
								                mode_switch_test(ch);
							 | 
						|||
| 
								 | 
							
								            } else if( c == 0x56) {
							 | 
						|||
| 
								 | 
							
								                iot_printf("entry mode wdt cpu rst test \r\n");
							 | 
						|||
| 
								 | 
							
								                wdt_cpu_reset_test(ch);
							 | 
						|||
| 
								 | 
							
								            } else if (c == 0x57) {
							 | 
						|||
| 
								 | 
							
								                iot_printf("entry mode wdt full rst test \r\n");
							 | 
						|||
| 
								 | 
							
								                wdt_full_reset_test(ch);
							 | 
						|||
| 
								 | 
							
								            } else if (c == 0x58) {
							 | 
						|||
| 
								 | 
							
								                iot_printf("entry mode software rst test \r\n");
							 | 
						|||
| 
								 | 
							
								                software_rst_test(ch);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }else {
							 | 
						|||
| 
								 | 
							
								            i ++;
							 | 
						|||
| 
								 | 
							
								            if (i >= 100000) {
							 | 
						|||
| 
								 | 
							
								                //iot_printf("wait cmd\r\n");
							 | 
						|||
| 
								 | 
							
								                i = 0;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								//中断测试
							 | 
						|||
| 
								 | 
							
								//25M
							 | 
						|||
| 
								 | 
							
								int main3(void)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    uint8_t ch = 0;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint8_t div = 24; // 1M
							 | 
						|||
| 
								 | 
							
								    uint16_t h2l = 20000;  // h2l must large than l2h
							 | 
						|||
| 
								 | 
							
								    uint16_t l2h = 5000;
							 | 
						|||
| 
								 | 
							
								    uint16_t phase1_blink_times = 100;
							 | 
						|||
| 
								 | 
							
								    uint16_t phase2_blink_times = 100;
							 | 
						|||
| 
								 | 
							
								    uint16_t thrs = 20000;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint8_t phase_num = PHASE_NUM_TWO;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint8_t phase1_mode = PHASE_MODE_INCREASE;//PHASE_MODE_FIXED_DUTY;//PHASE_MODE_DECREASE
							 | 
						|||
| 
								 | 
							
								    uint8_t phase2_mode = PHASE_MODE_DECREASE;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint8_t phase1_scale = 200;
							 | 
						|||
| 
								 | 
							
								    uint8_t phase2_scale = 200;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint8_t cycle_times = 70;
							 | 
						|||
| 
								 | 
							
								    uint8_t loop_times = 1;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint16_t nop_num = 200;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    dbg_uart_init();
							 | 
						|||
| 
								 | 
							
								    iot_interrupt_init();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_ena_rst();
							 | 
						|||
| 
								 | 
							
								    ledc_gpio_config(ch, 26);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //1
							 | 
						|||
| 
								 | 
							
								    ledc_cnt_ena(ch, LEDC_ENA_DISABLE);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //中断初始化
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_interrupt_init(ch, ledc_interrrupt_cb);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //2
							 | 
						|||
| 
								 | 
							
								    ledc_timer_rst(ch);
							 | 
						|||
| 
								 | 
							
								    ledc_timer_init(ch, div); // 24 --> 1M
							 | 
						|||
| 
								 | 
							
								    ledc_timer_ctrl(ch, TIMER_CTRL_START);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //3
							 | 
						|||
| 
								 | 
							
								    ledc_polarity_sel(ch, OUT_POL_INVERT);
							 | 
						|||
| 
								 | 
							
								    ledc_idle_level_sel(ch, IDLE_LEVEL_HIGH);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //4
							 | 
						|||
| 
								 | 
							
								    ledc_h2l_point_set(ch, h2l);
							 | 
						|||
| 
								 | 
							
								    ledc_l2h_point_set(ch, l2h);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //5
							 | 
						|||
| 
								 | 
							
								    ledc_phase1_blink_times_set(ch, phase1_blink_times); // thrs/scale
							 | 
						|||
| 
								 | 
							
								    ledc_phase2_blink_times_set(ch, phase2_blink_times);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //6
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_duty_cnt_sel(ch, DUTY_CNT_OWN);
							 | 
						|||
| 
								 | 
							
								    ledc_thrs_set(ch, thrs); // 1000 -> 1k
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //7
							 | 
						|||
| 
								 | 
							
								    ledc_phase_opt_sel(ch, DUTY_OPT_MODE_NEW);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_phase_num_sel(ch, phase_num);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_phase1_mode_sel(ch,  phase1_mode);
							 | 
						|||
| 
								 | 
							
								    ledc_phase2_mode_sel(ch,  phase2_mode);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_phase1_scale_set(ch, phase1_scale);
							 | 
						|||
| 
								 | 
							
								    ledc_phase2_scale_set(ch, phase2_scale);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_cycle_times_set(ch, cycle_times);
							 | 
						|||
| 
								 | 
							
								    ledc_loop_times_set(ch, loop_times);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_nop_num_set(ch, nop_num);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //
							 | 
						|||
| 
								 | 
							
								    ledc_cnt_ena(ch, LEDC_ENA_ENABLE);
							 | 
						|||
| 
								 | 
							
								    //1.5.3
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								////////////////////////////////////////////////////////////////////////
							 | 
						|||
| 
								 | 
							
								    ch = 2;
							 | 
						|||
| 
								 | 
							
								    ledc_gpio_config(ch, 27);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //1
							 | 
						|||
| 
								 | 
							
								    ledc_cnt_ena(ch, LEDC_ENA_DISABLE);
							 | 
						|||
| 
								 | 
							
								    //中断初始化
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_interrupt_init(ch, ledc_interrrupt_cb);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //2
							 | 
						|||
| 
								 | 
							
								    ledc_timer_rst(ch);
							 | 
						|||
| 
								 | 
							
								    ledc_timer_init(ch, 4); // 24 --> 1M
							 | 
						|||
| 
								 | 
							
								    ledc_timer_ctrl(ch, TIMER_CTRL_START);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //3
							 | 
						|||
| 
								 | 
							
								    ledc_polarity_sel(ch, OUT_POL_ORIGINAL);
							 | 
						|||
| 
								 | 
							
								    ledc_idle_level_sel(ch, IDLE_LEVEL_LOW);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //4
							 | 
						|||
| 
								 | 
							
								    ledc_h2l_point_set(ch, 500);
							 | 
						|||
| 
								 | 
							
								    ledc_l2h_point_set(ch, 250);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //5
							 | 
						|||
| 
								 | 
							
								    ledc_phase1_blink_times_set(ch, 50); // thrs/scale
							 | 
						|||
| 
								 | 
							
								    ledc_phase2_blink_times_set(ch, 50);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //6
							 | 
						|||
| 
								 | 
							
								    ledc_duty_cnt_sel(ch, DUTY_CNT_OWN);
							 | 
						|||
| 
								 | 
							
								    ledc_thrs_set(ch, 1000); // 1000 -> 500hz
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //7
							 | 
						|||
| 
								 | 
							
								    ledc_phase_opt_sel(ch, DUTY_OPT_MODE_NEW);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_phase_num_sel(ch, PHASE_NUM_TWO);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_phase1_mode_sel(ch, PHASE_MODE_INCREASE);
							 | 
						|||
| 
								 | 
							
								    ledc_phase2_mode_sel(ch,  PHASE_MODE_FIXED_DUTY);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_phase1_scale_set(ch, 10);
							 | 
						|||
| 
								 | 
							
								    ledc_phase2_scale_set(ch, 20);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_cycle_times_set(ch, 10);
							 | 
						|||
| 
								 | 
							
								    ledc_loop_times_set(ch, 10);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_nop_num_set(ch, 200);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //
							 | 
						|||
| 
								 | 
							
								    ledc_cnt_ena(ch, LEDC_ENA_ENABLE);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    while(1)
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        delay_sometime();
							 | 
						|||
| 
								 | 
							
								        delay_sometime();
							 | 
						|||
| 
								 | 
							
								        //LEDC0->ledc0_conf._b.ledc0_idle_lv = 1;
							 | 
						|||
| 
								 | 
							
								        delay_sometime();
							 | 
						|||
| 
								 | 
							
								        delay_sometime();
							 | 
						|||
| 
								 | 
							
								        //LEDC0->ledc0_conf._b.ledc0_idle_lv = 0;
							 | 
						|||
| 
								 | 
							
								        register_print_by_addr(LEDC_REG_BASEADDR | (0x200 << 0), 8);
							 | 
						|||
| 
								 | 
							
								        register_print_by_addr(LEDC_REG_BASEADDR | (0x600 << 0), 4);
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								    return 0;
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								int main2(void)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    uint8_t ch = 0;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint8_t div = 24;
							 | 
						|||
| 
								 | 
							
								    uint16_t h2l[4] = {997, 998, 999, 1000};
							 | 
						|||
| 
								 | 
							
								    uint16_t l2h[4] = {497, 498, 499, 500};
							 | 
						|||
| 
								 | 
							
								    uint16_t phase1_blink_times[4] = {10, 10, 10, 10};
							 | 
						|||
| 
								 | 
							
								    uint16_t phase2_blink_times[4] = {5, 5, 5, 5};
							 | 
						|||
| 
								 | 
							
								    uint16_t thrs = 1000;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint8_t phase_num[4] = {PHASE_NUM_ONE,
							 | 
						|||
| 
								 | 
							
								                            PHASE_NUM_ONE,
							 | 
						|||
| 
								 | 
							
								                            PHASE_NUM_ONE,
							 | 
						|||
| 
								 | 
							
								                            PHASE_NUM_ONE};
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint8_t phase1_mode[4] = {PHASE_MODE_FIXED_DUTY,
							 | 
						|||
| 
								 | 
							
								                              PHASE_MODE_FIXED_DUTY,
							 | 
						|||
| 
								 | 
							
								                              PHASE_MODE_FIXED_DUTY,
							 | 
						|||
| 
								 | 
							
								                              PHASE_MODE_FIXED_DUTY};
							 | 
						|||
| 
								 | 
							
								    uint8_t phase2_mode[4] = {PHASE_MODE_DECREASE,
							 | 
						|||
| 
								 | 
							
								                              PHASE_MODE_DECREASE,
							 | 
						|||
| 
								 | 
							
								                              PHASE_MODE_DECREASE,
							 | 
						|||
| 
								 | 
							
								                              PHASE_MODE_DECREASE};
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint8_t phase1_scale[4] = {100, 100, 100, 100};
							 | 
						|||
| 
								 | 
							
								    uint8_t phase2_scale[4] = {100, 100, 100, 100};
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint8_t cycle_times[4] = {1, 1, 1, 1};
							 | 
						|||
| 
								 | 
							
								    uint8_t loop_times[4] = {7, 7, 7, 7};
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    uint16_t nop_num[4]= {200, 200, 200, 200};
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    dbg_uart_init();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_ena_rst();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //2
							 | 
						|||
| 
								 | 
							
								    int common_timer = 0;
							 | 
						|||
| 
								 | 
							
								    ledc_timer_rst(common_timer);
							 | 
						|||
| 
								 | 
							
								    ledc_timer_init(common_timer, div); // 24 --> 1M
							 | 
						|||
| 
								 | 
							
								    ledc_timer_ctrl(common_timer, TIMER_CTRL_START);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    common_timer = 1;
							 | 
						|||
| 
								 | 
							
								    ledc_timer_rst(common_timer);
							 | 
						|||
| 
								 | 
							
								    ledc_timer_init(common_timer, div * 2); // 24 --> 1M
							 | 
						|||
| 
								 | 
							
								    ledc_timer_ctrl(common_timer, TIMER_CTRL_START);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    ledc_common_cnt_ena(LEDC_ENA_DISABLE);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    for (ch = 0; ch <=3; ch++) {
							 | 
						|||
| 
								 | 
							
								        ledc_gpio_config(ch, 26 + ch);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        //1
							 | 
						|||
| 
								 | 
							
								        ledc_cnt_ena(ch, LEDC_ENA_DISABLE);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        //3
							 | 
						|||
| 
								 | 
							
								        ledc_polarity_sel(ch, OUT_POL_ORIGINAL);
							 | 
						|||
| 
								 | 
							
								        ledc_idle_level_sel(ch, IDLE_LEVEL_LOW);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        //4
							 | 
						|||
| 
								 | 
							
								        ledc_h2l_point_set(ch, h2l[ch]);
							 | 
						|||
| 
								 | 
							
								        ledc_l2h_point_set(ch, l2h[ch]);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        //5
							 | 
						|||
| 
								 | 
							
								        ledc_phase1_blink_times_set(ch, phase1_blink_times[ch]); // thrs/scale
							 | 
						|||
| 
								 | 
							
								        ledc_phase2_blink_times_set(ch, phase2_blink_times[ch]);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        //6
							 | 
						|||
| 
								 | 
							
								        ledc_duty_cnt_sel(ch, DUTY_CNT_COMMON);
							 | 
						|||
| 
								 | 
							
								        ledc_thrs_set(ch, thrs); // 1000 -> 1k
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        //7
							 | 
						|||
| 
								 | 
							
								        ledc_phase_opt_sel(ch, DUTY_OPT_MODE_NEW);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        ledc_phase_num_sel(ch, phase_num[ch]);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        ledc_phase1_mode_sel(ch,  phase1_mode[ch]);
							 | 
						|||
| 
								 | 
							
								        ledc_phase2_mode_sel(ch,  phase2_mode[ch]);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        ledc_phase1_scale_set(ch, phase1_scale[ch]);
							 | 
						|||
| 
								 | 
							
								        ledc_phase2_scale_set(ch, phase2_scale[ch]);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        ledc_cycle_times_set(ch, cycle_times[ch]);
							 | 
						|||
| 
								 | 
							
								        ledc_loop_times_set(ch, loop_times[ch]);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        ledc_nop_num_set(ch, nop_num[ch]);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        //
							 | 
						|||
| 
								 | 
							
								        ledc_cnt_ena(ch, LEDC_ENA_ENABLE);
							 | 
						|||
| 
								 | 
							
								        delay_sometime();
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								    ledc_common_thrs_set(thrs);
							 | 
						|||
| 
								 | 
							
								    ledc_common_timer_sel(COMMON_TIMER_SEL_0);
							 | 
						|||
| 
								 | 
							
								    ledc_common_cnt_ena(LEDC_ENA_ENABLE);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    while(1) {
							 | 
						|||
| 
								 | 
							
								        delay_sometime();
							 | 
						|||
| 
								 | 
							
								        delay_sometime();
							 | 
						|||
| 
								 | 
							
								        delay_sometime();
							 | 
						|||
| 
								 | 
							
								        delay_sometime();
							 | 
						|||
| 
								 | 
							
								        register_print_by_addr(LEDC_REG_BASEADDR               , 3);
							 | 
						|||
| 
								 | 
							
								        register_print_by_addr(LEDC_REG_BASEADDR | (0x200 << 0), 8);
							 | 
						|||
| 
								 | 
							
								        register_print_by_addr(LEDC_REG_BASEADDR | (0x600 << 0), 4);
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								uint32_t *p_data = (uint32_t *)0x10038004;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void wdt_cpu_reset_test(LEDC_PORT ch)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    /*这配置一个比较长的波形输出,然后复位,看是否有影响*/
							 | 
						|||
| 
								 | 
							
								    ledc_para_s para = {
							 | 
						|||
| 
								 | 
							
								        .div = 240, // 240 对应时钟频率 100k
							 | 
						|||
| 
								 | 
							
								        .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								        .l2h_point = 500,
							 | 
						|||
| 
								 | 
							
								        .phase1_blink_times = 50,
							 | 
						|||
| 
								 | 
							
								        .phase2_blink_times = 50,
							 | 
						|||
| 
								 | 
							
								        .thrs = 1000, // 结合上面分频是240,则输出的波形的频率为100hz
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .phase_num = PHASE_NUM_ONE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .phase1_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								        .phase2_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .phase1_scale = 15,
							 | 
						|||
| 
								 | 
							
								        .phase2_scale = 20,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .cycle_times = 3,
							 | 
						|||
| 
								 | 
							
								        .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								    };
							 | 
						|||
| 
								 | 
							
								    uint32_t cur_cpu = cpu_get_mhartid();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    wdg_deinit(cur_cpu);
							 | 
						|||
| 
								 | 
							
								    wdg_init(cur_cpu);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    wdg_set_cmp(cur_cpu, 32768);//SET_WDG_INTC_CMP);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    wdg_set_timeout_cmp(cur_cpu, 255);//SET_WDG_TIMEOUT_CMP);
							 | 
						|||
| 
								 | 
							
								    wdg_set_cpurst_cmp(cur_cpu, 3);//SET_WDG_CPURST_CMP );
							 | 
						|||
| 
								 | 
							
								    wdg_set_fullrst_cmp(cur_cpu, 250);//SET_WDG_FULLRST_CMP);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    if (0xabcdaabb == (*p_data)) {
							 | 
						|||
| 
								 | 
							
								        iot_printf("wdg cpu rst\r\n");
							 | 
						|||
| 
								 | 
							
								    } else {
							 | 
						|||
| 
								 | 
							
								        iot_printf("pow on rst\r\n");
							 | 
						|||
| 
								 | 
							
								        (*p_data) = 0xabcdaabb;
							 | 
						|||
| 
								 | 
							
								        stop_ledc(ch);
							 | 
						|||
| 
								 | 
							
								        config_ledc(ch, ¶);
							 | 
						|||
| 
								 | 
							
								        start_ledc(ch);
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void wdt_full_reset_test(LEDC_PORT ch)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    /*这配置一个比较长的波形输出,然后复位,看是否有影响*/
							 | 
						|||
| 
								 | 
							
								    ledc_para_s para = {
							 | 
						|||
| 
								 | 
							
								        .div = 240, // 240 对应时钟频率 100k
							 | 
						|||
| 
								 | 
							
								        .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								        .l2h_point = 500,
							 | 
						|||
| 
								 | 
							
								        .phase1_blink_times = 50,
							 | 
						|||
| 
								 | 
							
								        .phase2_blink_times = 50,
							 | 
						|||
| 
								 | 
							
								        .thrs = 1000, // 结合上面分频是240,则输出的波形的频率为100hz
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .phase_num = PHASE_NUM_ONE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .phase1_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								        .phase2_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .phase1_scale = 15,
							 | 
						|||
| 
								 | 
							
								        .phase2_scale = 20,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .cycle_times = 3,
							 | 
						|||
| 
								 | 
							
								        .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								    };
							 | 
						|||
| 
								 | 
							
								    uint32_t cur_cpu = cpu_get_mhartid();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    wdg_deinit(cur_cpu);
							 | 
						|||
| 
								 | 
							
								    wdg_init(cur_cpu);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    wdg_set_cmp(cur_cpu, 32768);//SET_WDG_INTC_CMP);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    wdg_set_timeout_cmp(cur_cpu, 255);//SET_WDG_TIMEOUT_CMP);
							 | 
						|||
| 
								 | 
							
								    wdg_set_cpurst_cmp(cur_cpu, 250);//SET_WDG_CPURST_CMP );
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    wdg_set_fullrst_cmp(cur_cpu, 3);//SET_WDG_FULLRST_CMP);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    if (0xabcdaabb == (*p_data)) {
							 | 
						|||
| 
								 | 
							
								        iot_printf("wdg full rst\r\n");
							 | 
						|||
| 
								 | 
							
								    } else {
							 | 
						|||
| 
								 | 
							
								        iot_printf("pow on rst\r\n");
							 | 
						|||
| 
								 | 
							
								        (*p_data) = 0xabcdaabb;
							 | 
						|||
| 
								 | 
							
								        stop_ledc(ch);
							 | 
						|||
| 
								 | 
							
								        config_ledc(ch, ¶);
							 | 
						|||
| 
								 | 
							
								        start_ledc(ch);
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void software_rst_test(LEDC_PORT ch)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /*这配置一个比较长的波形输出,然后复位,看是否有影响*/
							 | 
						|||
| 
								 | 
							
								    ledc_para_s para = {
							 | 
						|||
| 
								 | 
							
								        .div = 240, // 240 对应时钟频率 100k
							 | 
						|||
| 
								 | 
							
								        .h2l_point = 1000,
							 | 
						|||
| 
								 | 
							
								        .l2h_point = 500,
							 | 
						|||
| 
								 | 
							
								        .phase1_blink_times = 50,
							 | 
						|||
| 
								 | 
							
								        .phase2_blink_times = 50,
							 | 
						|||
| 
								 | 
							
								        .thrs = 1000, // 结合上面分频是240,则输出的波形的频率为100hz
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .phase_num = PHASE_NUM_ONE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .phase1_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								        .phase2_mode = PHASE_MODE_INCREASE,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .phase1_scale = 15,
							 | 
						|||
| 
								 | 
							
								        .phase2_scale = 20,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .cycle_times = 3,
							 | 
						|||
| 
								 | 
							
								        .loop_times = 7,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        .nop_num = 200,
							 | 
						|||
| 
								 | 
							
								    };
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    gp_timer_init();
							 | 
						|||
| 
								 | 
							
								    gp_timer_set(0, 0xffffffff, 0);
							 | 
						|||
| 
								 | 
							
								    gp_timer_start(0);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    stop_ledc(ch);
							 | 
						|||
| 
								 | 
							
								    config_ledc(ch, ¶);
							 | 
						|||
| 
								 | 
							
								    start_ledc(ch);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    iot_delay_us(500000);
							 | 
						|||
| 
								 | 
							
								    apb_glb_chip_rst();
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#include "iot_led.h"
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void led_hal_test(void)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    iot_led_init();
							 | 
						|||
| 
								 | 
							
								    iot_led_blink(0, 15);
							 | 
						|||
| 
								 | 
							
								    iot_led_set_blink_interval(1000);
							 | 
						|||
| 
								 | 
							
								    iot_led_enable_blink(1);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    while(1) {
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void register_print_by_addr(uint32_t addr, int num)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    volatile uint32_t *p_addr = (volatile uint32_t *)addr;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    iot_printf("base=%08x:", addr);
							 | 
						|||
| 
								 | 
							
								    for(int i = 0; i < num; i++)
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        iot_printf("%02x=%08x,", (uint32_t)p_addr & 0xff, *p_addr);
							 | 
						|||
| 
								 | 
							
								        p_addr ++;
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								    iot_printf("\r\n");
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								void delay_sometime(void) {
							 | 
						|||
| 
								 | 
							
								    uint32_t loop;
							 | 
						|||
| 
								 | 
							
								    loop = 0;
							 | 
						|||
| 
								 | 
							
								    while(loop++ < 1000000) __asm volatile ("nop\n");
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 |