From 59ee3ee23fc05cc54b0916397e9d33042c40c1e2 Mon Sep 17 00:00:00 2001 From: zhji Date: Mon, 2 Jun 2025 20:53:18 +0800 Subject: [PATCH] [update] update timer_interrupt demo --- .../peripherals/timer/timer_interrupt/main.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/example/peripherals/timer/timer_interrupt/main.c b/example/peripherals/timer/timer_interrupt/main.c index a44a32c..7628bcc 100644 --- a/example/peripherals/timer/timer_interrupt/main.c +++ b/example/peripherals/timer/timer_interrupt/main.c @@ -1,9 +1,10 @@ -#include "system.h" -#include "irq.h" +#include "resets.h" +#include "gpio.h" +#include "uart.h" #include "timer.h" +#include "irq.h" #include "stdio.h" - #define TIMER_ALARM_ID TIMER_ALARM_0 #define TIMER_PERIOD_US (1000 * 1000) @@ -16,16 +17,17 @@ void timer_alarm_0_isr(void) int main(void) { - system_init(); + reset_unreset_blocks_wait(RESETS_BLOCK_IO_BANK0 | RESETS_BLOCK_UART0 | RESETS_BLOCK_TIMER); + gpio_init(0, GPIO_FUNC_UART | GPIO_PULL_UP | GPIO_DRIVE_4MA); /* UART_TX pin */ + gpio_init(1, GPIO_FUNC_UART | GPIO_PULL_UP | GPIO_SCHMITT | GPIO_PAD_IE | GPIO_PAD_OD); /* UART_RX pin */ + uart_init(uart0_hw, 6 * 1000 * 1000, UART_DATABITS_8 | UART_PARITY_NONE | UART_STOPBITS_1); + printf("timer_interrupt example\r\n"); + timer_count_write(0); timer_alarm_set(TIMER_ALARM_ID, TIMER_PERIOD_US); timer_int_enable(TIMER_ALARM_ID); irq_attach(TIMER_IRQ_0, timer_alarm_0_isr); irq_enable(TIMER_IRQ_0); - while (1) { - - } - return 0; }