v2.h (925B)
1 // Copyright 2022 Jay Greco 2 // SPDX-License-Identifier: GPL-2.0-or-later 3 4 #pragma once 5 6 #include "quantum.h" 7 #include <hal.h> 8 9 enum led_mode { 10 LED_OFF = 0, 11 LED_DIM, 12 LED_ON, 13 NUM_LED_MODE 14 }; 15 16 enum rgb_idx { 17 RED = 0, 18 GREEN, 19 BLUE, 20 NUM_RGB_IDX 21 }; 22 23 typedef struct pwm_led_t { 24 uint32_t pin[3]; 25 PWMDriver* driver[3]; 26 uint8_t channel[3]; 27 uint8_t mode; 28 uint8_t init_complete; 29 } pwm_led_t; 30 31 #define PWM_PAL_MODE (PAL_MODE_ALTERNATE_PWM | PAL_RP_PAD_DRIVE12 | PAL_RP_GPIO_OE) 32 #define PWM_PWM_COUNTER_FREQUENCY 1000000 33 #define PWM_PWM_PERIOD PWM_PWM_COUNTER_FREQUENCY / 1000 34 35 // RP2040 adds HW PWM control! 36 // PWM values are in percent, 0-100 37 void 38 set_scramble_LED(uint8_t mode), 39 set_scramble_LED_rgb_pwm(uint8_t r_pwm, uint8_t g_pwm, uint8_t b_pwm), 40 set_scramble_LED_r_pwm(uint8_t pwm), 41 set_scramble_LED_g_pwm(uint8_t pwm), 42 set_scramble_LED_b_pwm(uint8_t pwm); 43