Berry add gpio.set_freq() (#21375)

This commit is contained in:
Christian Baars 2024-05-07 09:36:39 +02:00 committed by GitHub
parent 21c7f4c81b
commit 08f9b37b99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -27,6 +27,7 @@ extern int gp_get_pin_index(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp
// esp_err_tledc_set_duty_and_update(ledc_mode_tspeed_mode, ledc_channel_tchannel, uint32_t duty, uint32_t hpoint) // esp_err_tledc_set_duty_and_update(ledc_mode_tspeed_mode, ledc_channel_tchannel, uint32_t duty, uint32_t hpoint)
extern void gp_set_duty(int32_t pin, int32_t duty, int32_t hpoint); BE_FUNC_CTYPE_DECLARE(gp_set_duty, "", "ii[i]"); extern void gp_set_duty(int32_t pin, int32_t duty, int32_t hpoint); BE_FUNC_CTYPE_DECLARE(gp_set_duty, "", "ii[i]");
extern void gp_set_frequency(int32_t pin, int32_t frequency); BE_FUNC_CTYPE_DECLARE(gp_set_frequency, "", "ii");
extern int gp_get_duty(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp_get_duty, "i", "i"); extern int gp_get_duty(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp_get_duty, "i", "i");
extern int gp_get_duty_resolution(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp_get_duty_resolution, "i", "i"); extern int gp_get_duty_resolution(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp_get_duty_resolution, "i", "i");
@ -49,6 +50,7 @@ module gpio (scope: global) {
pin, func(gp_pin) pin, func(gp_pin)
set_pwm, ctype_func(gp_set_duty) set_pwm, ctype_func(gp_set_duty)
set_pwm_freq, ctype_func(gp_set_frequency)
read_pwm, ctype_func(gp_get_duty) read_pwm, ctype_func(gp_get_duty)
read_pwm_resolution, ctype_func(gp_get_duty_resolution) read_pwm_resolution, ctype_func(gp_get_duty_resolution)
} }

View File

@ -241,6 +241,10 @@ extern "C" {
analogWritePhase(pin, duty, hpoint); analogWritePhase(pin, duty, hpoint);
} }
void gp_set_frequency(int32_t pin, int32_t frequency) {
analogWriteFreq(frequency, pin);
}
// gpio.counter_read(counter:int) -> int or nil // gpio.counter_read(counter:int) -> int or nil
// //
// Read counter value, or return nil if counter is not used // Read counter value, or return nil if counter is not used