led_matrix/main/ulp/main.c
2024-02-02 10:44:38 +08:00

49 lines
1.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "ulp_riscv.h"
#include "ulp_riscv_utils.h"
#include "ulp_riscv_gpio.h"
#include "soc/rtc_io_reg.h"
#include "ulp_riscv_register_ops.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
#define OE_CAPTRUE_RTC_PIN_NUM_REG_BIT (1 << (HUB75_OE_CAPTRUE__RTC_PIN_NUM + 10))
volatile int set_addr_request = 0;
volatile int oe_disable_val = 1;
volatile int addr_reg_bit_val = 0;
int main (void)
{
if (oe_disable_val) goto OE_HIGH_DISABLE;
else goto OE_LOW_DISABLE;
OE_HIGH_DISABLE:
while(1) {
while (!set_addr_request); /* 等待地址设置请求 */
while (!(REG_READ(RTC_GPIO_IN_REG) & OE_CAPTRUE_RTC_PIN_NUM_REG_BIT)); /* 等待oe高电平disable信号 */
REG_WRITE(RTC_GPIO_OUT_REG, addr_reg_bit_val); /* CPU程序应采用读修改写方式防止影响寄存器其他位 */
set_addr_request = 0;
}
OE_LOW_DISABLE:
while(1) {
while (!set_addr_request);
while ((REG_READ(RTC_GPIO_IN_REG) & OE_CAPTRUE_RTC_PIN_NUM_REG_BIT)); /* 等待oe低电平disable信号 */
REG_WRITE(RTC_GPIO_OUT_REG, addr_reg_bit_val);
set_addr_request = 0;
}
return 0;
}