led_matrix/main/ulp/main.c

38 lines
1.1 KiB
C
Raw Normal View History

2024-01-31 11:04:31 +08:00
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "ulp_riscv.h"
#include "ulp_riscv_utils.h"
#include "ulp_riscv_gpio.h"
#define HUB75_OE_CAPTRUE__RTC_PIN_NUM GPIO_NUM_18
#define HUB75_LINE_ADDR_A_RTC_PIN_NUM GPIO_NUM_16
#define HUB75_LINE_ADDR_B_RTC_PIN_NUM GPIO_NUM_15
#define HUB75_LINE_ADDR_C_RTC_PIN_NUM GPIO_NUM_14
#define HUB75_LINE_ADDR_D_RTC_PIN_NUM GPIO_NUM_13
volatile int line = 0;
2024-01-31 17:52:23 +08:00
volatile int flag = 0;
2024-01-31 11:04:31 +08:00
int main (void)
{
2024-01-31 13:05:20 +08:00
bool gpio_level = false;
2024-01-31 11:04:31 +08:00
while(1) {
2024-01-31 13:05:20 +08:00
gpio_level = (bool)ulp_riscv_gpio_get_level(HUB75_OE_CAPTRUE__RTC_PIN_NUM);
2024-01-31 17:52:23 +08:00
if (gpio_level == true && flag == 1)
2024-01-31 11:04:31 +08:00
{
ulp_riscv_gpio_output_level(HUB75_LINE_ADDR_A_RTC_PIN_NUM, line & 1);
ulp_riscv_gpio_output_level(HUB75_LINE_ADDR_B_RTC_PIN_NUM, (line >> 1) & 1);
ulp_riscv_gpio_output_level(HUB75_LINE_ADDR_C_RTC_PIN_NUM, (line >> 2) & 1);
ulp_riscv_gpio_output_level(HUB75_LINE_ADDR_D_RTC_PIN_NUM, (line >> 3) & 1);
2024-01-31 17:52:23 +08:00
flag = 0;
2024-01-31 11:04:31 +08:00
}
}
return 0;
}