[update] update timer_interrupt demo
This commit is contained in:
parent
8bc6f6d5db
commit
59ee3ee23f
@ -1,9 +1,10 @@
|
|||||||
#include "system.h"
|
#include "resets.h"
|
||||||
#include "irq.h"
|
#include "gpio.h"
|
||||||
|
#include "uart.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
#include "irq.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
|
|
||||||
#define TIMER_ALARM_ID TIMER_ALARM_0
|
#define TIMER_ALARM_ID TIMER_ALARM_0
|
||||||
#define TIMER_PERIOD_US (1000 * 1000)
|
#define TIMER_PERIOD_US (1000 * 1000)
|
||||||
|
|
||||||
@ -16,16 +17,17 @@ void timer_alarm_0_isr(void)
|
|||||||
|
|
||||||
int main(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_count_write(0);
|
||||||
timer_alarm_set(TIMER_ALARM_ID, TIMER_PERIOD_US);
|
timer_alarm_set(TIMER_ALARM_ID, TIMER_PERIOD_US);
|
||||||
timer_int_enable(TIMER_ALARM_ID);
|
timer_int_enable(TIMER_ALARM_ID);
|
||||||
irq_attach(TIMER_IRQ_0, timer_alarm_0_isr);
|
irq_attach(TIMER_IRQ_0, timer_alarm_0_isr);
|
||||||
irq_enable(TIMER_IRQ_0);
|
irq_enable(TIMER_IRQ_0);
|
||||||
|
|
||||||
while (1) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user