File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ #include "uart.h"
2+ #include "print.h"
3+ #include "obi_timer.h"
4+ #include "util.h"
5+
6+ #define PRINT_TIMER_IRQ
7+
8+ int timer_count = 0 ;
9+
10+ // default interrupt handler override
11+ // count timer interrupts and print irq information
12+ // note: performing slow operations such as
13+ // printing through UART inside interrupt service
14+ // routines is not recommended. Only use for debug
15+ // or testing.
16+ void croc_interrupt_handler (uint32_t cause ) {
17+ if (cause == IRQ_OBI_TIMER ) {
18+ obi_timer_clear_expired ();
19+ timer_count += 1 ;
20+ #ifdef PRINT_TIMER_IRQ
21+ printf ("Timer\n" );
22+ #endif
23+ }
24+ }
25+
26+ int main () {
27+
28+ // setup the uart peripheral
29+ uart_init ();
30+
31+ // set periodic timer
32+ // note: give enough time for printing
33+ obi_timer_set (20000 );
34+
35+ // enable timer interrupt
36+ set_interrupt_enable (1 , IRQ_OBI_TIMER );
37+ set_global_irq_enable (1 );
38+
39+ while (timer_count < 10 ) wfi ();
40+
41+ // disable the timer
42+ obi_timer_set_enable (0 );
43+
44+ // wait until uart has finished sending
45+ uart_write_flush ();
46+
47+ return 0 ;
48+ }
You can’t perform that action at this time.
0 commit comments