mirror of
https://github.com/whowechina/aic_pico.git
synced 2024-11-14 17:47:35 +01:00
Enable IO lock to avoid deadlock
This commit is contained in:
parent
12d710ebe2
commit
d293db87fd
Binary file not shown.
@ -25,6 +25,8 @@ static uint32_t rgb_buf[16];
|
|||||||
static uint8_t led_gpio[] = LED_DEF;
|
static uint8_t led_gpio[] = LED_DEF;
|
||||||
#define RGB_NUM (sizeof(rgb_buf) / sizeof(rgb_buf[0]))
|
#define RGB_NUM (sizeof(rgb_buf) / sizeof(rgb_buf[0]))
|
||||||
#define LED_NUM (sizeof(led_gpio))
|
#define LED_NUM (sizeof(led_gpio))
|
||||||
|
static uint8_t led_buf[LED_NUM];
|
||||||
|
|
||||||
|
|
||||||
#define _MAP_LED(x) _MAKE_MAPPER(x)
|
#define _MAP_LED(x) _MAKE_MAPPER(x)
|
||||||
#define _MAKE_MAPPER(x) MAP_LED_##x
|
#define _MAKE_MAPPER(x) MAP_LED_##x
|
||||||
@ -134,10 +136,9 @@ static void rainbow_update()
|
|||||||
rgb_buf[i] = apply_level(color_wheel[index]);
|
rgb_buf[i] = apply_level(color_wheel[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; (i < LED_NUM) && (i < RGB_NUM); i++) {
|
for (int i = 0; i < LED_NUM; i++) {
|
||||||
uint32_t index = (rotator + RAINBOW_PITCH * 2 * i) % COLOR_WHEEL_SIZE;
|
uint32_t index = (rotator + RAINBOW_PITCH * 2 * i) % COLOR_WHEEL_SIZE;
|
||||||
int level = apply_level(color_wheel[index]) & 0xff;
|
led_buf[i] = apply_level(color_wheel[index]) & 0xff;
|
||||||
pwm_set_gpio_level(led_gpio[i], aic_cfg->light.led ? level * level : 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,6 +180,11 @@ static void drive_led()
|
|||||||
uint32_t color = aic_cfg->light.rgb ? rgb_buf[i] << 8u : 0;
|
uint32_t color = aic_cfg->light.rgb ? rgb_buf[i] << 8u : 0;
|
||||||
pio_sm_put_blocking(pio0, 0, color);
|
pio_sm_put_blocking(pio0, 0, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < LED_NUM; i++) {
|
||||||
|
uint8_t level = aic_cfg->light.led ? led_buf[i] : 0;
|
||||||
|
pwm_set_gpio_level(led_gpio[i], level);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void light_set_color(unsigned index, uint32_t color)
|
void light_set_color(unsigned index, uint32_t color)
|
||||||
|
@ -106,9 +106,9 @@ static void core1_loop()
|
|||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
if (mutex_try_enter(&core1_io_lock, NULL)) {
|
if (mutex_try_enter(&core1_io_lock, NULL)) {
|
||||||
|
light_update();
|
||||||
mutex_exit(&core1_io_lock);
|
mutex_exit(&core1_io_lock);
|
||||||
}
|
}
|
||||||
light_update();
|
|
||||||
cli_fps_count(1);
|
cli_fps_count(1);
|
||||||
sleep_ms(1);
|
sleep_ms(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user