2015-08-28 20:24:14 +00:00
|
|
|
/* Implementation of PWM support for the Espressif SDK.
|
|
|
|
*
|
|
|
|
* Part of esp-open-rtos
|
|
|
|
* Copyright (C) 2015 Guillem Pascual Ginovart (https://github.com/gpascualg)
|
|
|
|
* Copyright (C) 2015 Javier Cardona (https://github.com/jcard0na)
|
|
|
|
* BSD Licensed as described in the file LICENSE
|
|
|
|
*/
|
2016-10-24 13:09:17 +00:00
|
|
|
#ifndef EXTRAS_PWM_H_
|
|
|
|
#define EXTRAS_PWM_H_
|
|
|
|
|
2015-08-28 20:24:14 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#define MAX_PWM_PINS 8
|
|
|
|
|
2016-10-24 13:09:17 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-12-02 06:54:04 +00:00
|
|
|
//Warning: Printf disturb pwm. You can use "uart_putc" instead.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize pwm
|
|
|
|
* @param npins Number of pwm pin used
|
|
|
|
* @param pins Array pointer to the pins
|
|
|
|
* @param reverse If true, the pwm work in reverse mode
|
|
|
|
*/
|
|
|
|
void pwm_init(uint8_t npins, const uint8_t* pins, uint8_t reverse);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set PWM frequency. If error, frequency not set
|
|
|
|
* @param freq PWM frequency value in Hertz
|
|
|
|
*/
|
2015-08-28 20:24:14 +00:00
|
|
|
void pwm_set_freq(uint16_t freq);
|
2017-12-02 06:54:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set Duty between 0 and UINT16_MAX
|
|
|
|
* @param duty Duty value
|
|
|
|
*/
|
2015-08-28 20:24:14 +00:00
|
|
|
void pwm_set_duty(uint16_t duty);
|
|
|
|
|
2017-12-02 06:54:04 +00:00
|
|
|
/**
|
|
|
|
* Restart the pwm signal
|
|
|
|
*/
|
2015-08-28 20:24:14 +00:00
|
|
|
void pwm_restart();
|
2017-12-02 06:54:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Start the pwm signal
|
|
|
|
*/
|
2015-08-28 20:24:14 +00:00
|
|
|
void pwm_start();
|
2017-12-02 06:54:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop the pwm signal
|
|
|
|
*/
|
2015-08-28 20:24:14 +00:00
|
|
|
void pwm_stop();
|
2016-10-24 13:09:17 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* EXTRAS_PWM_H_ */
|