Skip to content
Snippets Groups Projects
Select Git revision
  • 1cc81ed449fe51c787d002e786cd5afe5c632f97
  • wip-bootstrap default
  • dualcore
  • ch3/leds
  • ch3/time
  • master
6 results

esppwm.h

Blame
  • user avatar
    Damien George authored and Paul Sokolovsky committed
    PWM implementation uses a timer and interrupts (FRC1), taken from
    Espressif's/NodeMCU's implementation and adapted for our use.
    
    8 channels are supported, on pins 0, 2, 4, 5, 12, 13, 14, 15.
    
    Usage:
    
        import machine
        pwm0 = machine.PWM(machine.Pin(0))
        pwm0.freq(1000)
        pwm0.duty(500)
    
    Frequency is shared (ie the same) for all channels.  Frequency is
    between 1 and 1000.  Duty is between 0 and 1023.
    632d8efa
    History
    esppwm.h 419 B
    #ifndef __ESPPWM_H__
    #define __ESPPWM_H__
    
    #include <stdbool.h>
    #include <stdint.h>
    
    void pwm_init(void);
    void pwm_start(void);
    
    void pwm_set_duty(uint16_t duty, uint8_t channel);
    uint16_t pwm_get_duty(uint8_t channel);
    void pwm_set_freq(uint16_t freq, uint8_t channel);
    uint16_t pwm_get_freq(uint8_t channel);
    int pwm_add(uint8_t pin_id, uint32_t pin_mux, uint32_t pin_func);
    bool pwm_delete(uint8_t channel);
    
    #endif