/**************************************************************************** Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT be copied by any method or incorporated into another program without the express written consent of Aerospace C.Power. This Information or any portion thereof remains the property of Aerospace C.Power. The Information contained herein is believed to be accurate and Aerospace C.Power assumes no responsibility or liability for its use in any way and conveys no license or title under any patent or copyright and makes no representation or warranty that this Information is free from patent or copyright infringement. ****************************************************************************/ #include "os_utils.h" #include "chip_reg_base.h" #include "hw_reg_api.h" #include "ahb.h" #include "gpio_mtx.h" #include "iot_led.h" #include "ledc.h" #include "sec_glb.h" #include "iot_io.h" #include "dbg_io.h" #define REG32(a) (*((volatile uint32_t *)(a))) void gpio_sel() { gpio_mtx_enable(); gpio_sig_info_t sfc = { 2, { {IO_TYPE_OUT, 0, 0, 0xff, 52}, {IO_TYPE_OUT, 0, 1, 0xff, 53}, } }; gpio_module_pin_select(&sfc); gpio_module_sig_select(&sfc, GPIO_MTX_MODE_MATRIX); // gpio output inv gpio_pin_oinv(1, 1); gpio_pin_oinv(0, 0); } void led_ctrl_test() { ledc_ena_rst(); // config timer, timer0 for led0, timer1 for led1, timer2 for reference led ledc_timer_cfg(0, 0, 0, 0, 0x10000, 5); ledc_timer_cfg(1, 0, 0, 0, 0x10000, 5); ledc_timer_cfg(2, 0, 0, 0, 0x10001, 5); #if 1 // enable reference led clock ledc_set_l2h_val(8, 0); ledc_target_value(8, 0xa0); ledc_target_cfg(8, LED_TARGET_SHADOW_ENA, LED_TARGET_DEC, 8, 1, 2); // led config ledc_cfg(8, 1, 1, 2); #endif #if 1 // enable test led0 ledc_set_l2h_val(0, 0); ledc_target_value(0, 0x100); ledc_target_cfg(0, LED_TARGET_SHADOW_ENA, LED_TARGET_DEC, 0, 1, 1); ledc_cfg(0, 0, 1, 0); // use reference led // ledc_out_ref(0, 1); #endif #if 1 // enable test led1 ledc_set_l2h_val(1, 0); ledc_target_value(1, 0xa0); ledc_target_cfg(1, LED_TARGET_SHADOW_ENA, LED_TARGET_DEC, 0, 1, 1); ledc_cfg(1, 0, 1, 1); // use reference led // ledc_out_ref(1, 1); #endif return; } int main(void) { dbg_uart_init(); gpio_sel(); iot_printf("test led\n"); led_ctrl_test(); iot_printf("end.......\n"); return 0; }