led_matrix/main/ulp/main.c
2024-01-31 17:52:23 +08:00

38 lines
1.1 KiB
C

#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;
volatile int flag = 0;
int main (void)
{
bool gpio_level = false;
while(1) {
gpio_level = (bool)ulp_riscv_gpio_get_level(HUB75_OE_CAPTRUE__RTC_PIN_NUM);
if (gpio_level == true && flag == 1)
{
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);
flag = 0;
}
}
return 0;
}