Fixed improper _

This commit is contained in:
Kevin Thomas
2026-04-11 10:52:10 -04:00
parent f6683beff5
commit 0df58712e1
70 changed files with 603 additions and 603 deletions
+3 -3
View File
@@ -58,7 +58,7 @@
* @param end Ending duty percentage
* @param step Increment per iteration (negative for descending)
*/
static void _sweep_duty(int start, int end, int step) {
static void sweep_duty(int start, int end, int step) {
for (int duty = start; (step > 0) ? duty <= end : duty >= end; duty += step) {
pwm_driver_set_duty_percent((uint8_t)duty);
printf("Duty: %3d%%\r\n", duty);
@@ -71,7 +71,7 @@ int main(void) {
pwm_driver_init(PWM_PIN, PWM_FREQ_HZ);
printf("PWM initialized: GPIO%d @ %d Hz\r\n", PWM_PIN, PWM_FREQ_HZ);
while (true) {
_sweep_duty(0, 100, 5);
_sweep_duty(100, 0, -5);
sweep_duty(0, 100, 5);
sweep_duty(100, 0, -5);
}
}
+4 -4
View File
@@ -50,7 +50,7 @@ static uint32_t pwm_wrap;
* @param wrap_val Chosen PWM counter wrap value (period - 1)
* @return float Clock divider to program into the PWM slice
*/
static float _calc_clk_div(uint32_t freq_hz, uint32_t wrap_val) {
static float calc_clk_div(uint32_t freq_hz, uint32_t wrap_val) {
uint32_t sys_hz = clock_get_hz(clk_sys);
return (float)sys_hz / ((float)freq_hz * (float)(wrap_val + 1));
}
@@ -63,9 +63,9 @@ static float _calc_clk_div(uint32_t freq_hz, uint32_t wrap_val) {
*
* @param freq_hz Desired PWM output frequency in Hz
*/
static void _apply_pwm_config(uint32_t freq_hz) {
static void apply_pwm_config(uint32_t freq_hz) {
pwm_config cfg = pwm_get_default_config();
pwm_config_set_clkdiv(&cfg, _calc_clk_div(freq_hz, pwm_wrap));
pwm_config_set_clkdiv(&cfg, calc_clk_div(freq_hz, pwm_wrap));
pwm_config_set_wrap(&cfg, pwm_wrap);
pwm_init(pwm_slice, &cfg, true);
pwm_set_chan_level(pwm_slice, pwm_chan, 0);
@@ -76,7 +76,7 @@ void pwm_driver_init(uint32_t pin, uint32_t freq_hz) {
pwm_slice = pwm_gpio_to_slice_num(pin);
pwm_chan = pwm_gpio_to_channel(pin);
pwm_wrap = 10000 - 1;
_apply_pwm_config(freq_hz);
apply_pwm_config(freq_hz);
}
void pwm_driver_set_duty_percent(uint8_t percent) {