Files
kunlun/driver/src/hw3/inc/ledc_hw.h

276 lines
8.5 KiB
C
Raw Normal View History

2024-09-28 14:24:04 +08:00
/****************************************************************************
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.
****************************************************************************/
#ifndef _LEDC_HW_H_
#define _LEDC_HW_H_
#define SIG_OUT_LED0 GPIO_MTX_LED0_OUT
#define LEDC_ENA_ENABLE 1
#define LEDC_ENA_DISABLE 0
#define TIMER_CTRL_START 1
#define TIMER_CTRL_PAUSE 0
#define OUT_POL_INVERT 1
#define OUT_POL_ORIGINAL 0
#define IDLE_LEVEL_HIGH 1
#define IDLE_LEVEL_LOW 0
#define DUTY_CNT_COMMON 1
#define DUTY_CNT_OWN 0
#define DUTY_OPT_MODE_NEW 1
#define DUTY_OPT_MODE_OLD 0
#define PHASE_NUM_TWO 1
#define PHASE_NUM_ONE 0
#define PHASE_MODE_FIXED_DUTY 0
#define PHASE_MODE_KEEP_DARK 1
#define PHASE_MODE_INCREASE 2
#define PHASE_MODE_DECREASE 3
typedef enum {
LEDC_PORT_0 = 0,
LEDC_PORT_1,
LEDC_PORT_2,
LEDC_PORT_3,
LEDC_PORT_4,
LEDC_PORT_5,
LEDC_PORT_6,
LEDC_PORT_7,
LEDC_PORT_MAX
} LEDC_PORT;
typedef enum {
COMMON_TIMER_SEL_0 = 0,
COMMON_TIMER_SEL_1,
COMMON_TIMER_SEL_2,
COMMON_TIMER_SEL_3,
COMMON_TIMER_SEL_4,
COMMON_TIMER_SEL_5,
COMMON_TIMER_SEL_6,
COMMON_TIMER_SEL_7,
COMMON_TIMER_SEL_MAX
} COMMON_TIMER_SEL;
typedef void (*ledc_interrrupt_cb_typedef)(uint8_t port);
/**
* @brief ledc_ena_rst() - 使ledc
*/
void ledc_ena_rst(void);
/**
* @brief ledc_gpio_config() - function used to set ledc gpio
* @param port: led port number
* @param gpio: gpio编号.
*/
void ledc_gpio_config(LEDC_PORT port, uint8_t gpio);
/**
* @brief ledc_timer_rst() - ledc的定时器
* @param port: ledc
*/
void ledc_timer_rst(LEDC_PORT port);
/**
* @brief ledc_timer_init() - ledc的定时器
* @param port: ledc
* @param div 0-0xffff24M
*/
void ledc_timer_init(LEDC_PORT port, uint16_t div);
/**
* @brief ledc_timer_ctrl() - ledc的定时器
* @param port: ledc
* @param status: TIMER_CTRL_START
* TIMER_CTRL_PAUSE
*/
void ledc_timer_ctrl(LEDC_PORT port, uint8_t status);
/**
* @brief ledc_cnt_ena() - ledc启停控制
* @param port: ledc
* @param status: LEDC_ENA_ENABLE 使
* LEDC_ENA_DISABLE
*/
void ledc_cnt_ena(LEDC_PORT port, uint8_t status);
/**
* @brief ledc_polarity_sel() - ledc输出极性选择
* @param port: ledc
* @param polarity: OUT_POL_ORIGINAL
* OUT_POL_INVERT
*/
void ledc_polarity_sel(LEDC_PORT port, uint8_t polarity);
/**
* @brief ledc_idle_level_sel() - ledc空闲时电平状态选择
* @param port: ledc
* @param level: IDLE_LEVEL_HIGH
* IDLE_LEVEL_LOW
*/
void ledc_idle_level_sel(LEDC_PORT port, uint8_t level);
/**
* @brief ledc_phase1_blink_times_set() - ledc phase1
* @param port: ledc
* @param times: 0-0xffff0
*/
void ledc_phase1_blink_times_set(LEDC_PORT port, uint16_t times);
/**
* @brief ledc_phase2_blink_times_set() - ledc phase2
* @param port: ledc
* @param times: 0-0xffff0
*/
void ledc_phase2_blink_times_set(LEDC_PORT port, uint16_t times);
/**
* @brief ledc_h2l_point_set() -
* @param port: ledc
* @param point: 0-0xffff
*/
void ledc_h2l_point_set(LEDC_PORT port, uint16_t point);
/**
* @brief ledc_l2h_point_set() -
* @param port: ledc
* @param point: 0-0xffff
*/
void ledc_l2h_point_set(LEDC_PORT port, uint16_t point);
/**
* @brief ledc_duty_cnt_sel() -
* @param port: ledc
* @param point: DUTY_CNT_COMMON 使
* DUTY_CNT_OWN 使ledc自己私有的计数器
*/
void ledc_duty_cnt_sel(LEDC_PORT port, uint8_t duty_cnt);
/**
* @brief ledc_thrs_set() -
* @param port: ledc
* @param thrs: 0-0xffff
*/
void ledc_thrs_set(LEDC_PORT port, uint16_t thrs);
/**
* @brief ledc_phase_opt_sel() -
* @param port: ledc
* @param opt: DUTY_OPT_MODE_NEW 使 使
* DUTY_OPT_MODE_OLD 使
*/
void ledc_phase_opt_sel(LEDC_PORT port, uint8_t opt);
/**
* @brief ledc_phase_num_sel() - phase个数选择
* @param port: ledc
* @param num: PHASE_NUM_TWO phase1 phase2两个phase都使用
* PHASE_NUM_ONE 使phase1一个phase
*/
void ledc_phase_num_sel(LEDC_PORT port, uint8_t num);
/**
* @brief ledc_phase_num_sel() - phase1工作模式选择
* @param port: ledc
* @param mode: PHASE_MODE_FIXED_DUTY
* PHASE_MODE_KEEP_DARK
* PHASE_MODE_INCREASE
* PHASE_MODE_DECREASE
*/
void ledc_phase1_mode_sel(LEDC_PORT port, uint8_t mode);
/**
* @brief ledc_phase2_mode_sel() - phase1工作模式选择
* @param port: ledc
* @param mode: PHASE_MODE_FIXED_DUTY
* PHASE_MODE_KEEP_DARK
* PHASE_MODE_INCREASE
* PHASE_MODE_DECREASE
*/
void ledc_phase2_mode_sel(LEDC_PORT port, uint8_t mode);
/**
* @brief ledc_phase1_scale_set() - phase1的渐变幅度设置
* @param port: ledc
* @param scale: 0-0xff
*/
void ledc_phase1_scale_set(LEDC_PORT port, uint8_t scale);
/**
* @brief ledc_phase2_scale_set() - phase2的渐变幅度设置
* @param port: ledc
* @param scale: 0-0xff
*/
void ledc_phase2_scale_set(LEDC_PORT port, uint8_t scale);
/**
* @brief ledc_cycle_times_set() - loop里有多少个cycle
* @param port: ledc
* @param times: 0-0xff
*/
void ledc_cycle_times_set(LEDC_PORT port, uint8_t times);
/**
* @brief ledc_cycle_times_set() - loop
* @param port: ledc
* @param times: 0-0xff
*/
void ledc_loop_times_set(LEDC_PORT port, uint8_t times);
/**
* @brief ledc_nop_num_set() - loop
* @param port: ledc
* @param times: 0-0xff
*/
void ledc_nop_num_set(LEDC_PORT port, uint16_t num);
/**
* @brief ledc_common_cnt_ena() -
* @param en: LEDC_ENA_ENABLE 使
* LEDC_ENA_DISABLE
*/
void ledc_common_cnt_ena(uint8_t en);
/**
* @brief ledc_common_thrs_set() -
* @param thrs: 0-0xffff
*/
void ledc_common_thrs_set(uint16_t thrs);
/**
* @brief ledc_common_thrs_set() -
* @param timer_num:
*/
void ledc_common_timer_sel(COMMON_TIMER_SEL timer_num);
/**
* @brief ledc_interrupt_init() - 使
* void ledc_interrrupt_cb(uint8_t port)
* @param port:
*/
void ledc_interrupt_init(uint8_t port, ledc_interrrupt_cb_typedef cb);
#endif