Last active
April 18, 2018 15:28
-
-
Save boochow/82f32296422ecae06f80bcef68caf85e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define IOREG(X) (*(volatile uint32_t *) (X)) | |
#define IRQ_PEND1 IOREG(0x2000B204) | |
#define SYST_CS IOREG(0x20003000) | |
#define SYST_C0 IOREG(0x2000300C) | |
#define SYST_C1 IOREG(0x20003010) | |
#define SYST_C2 IOREG(0x20003014) | |
#define SYST_C3 IOREG(0x20003018) | |
#define IRQ_TIMER_C1 (1 << 1) | |
#define IRQ_TIMER_C3 (1 << 3) | |
static volatile int counter1; | |
static volatile int counter3; | |
static volatile int changed1; | |
static volatile int changed3; | |
static void __attribute__((interrupt("IRQ"))) irq_handler(void) { | |
if (IRQ_PEND1 & IRQ_TIMER_C1) { | |
counter1++; | |
changed1 = 1; | |
SYST_C1 = SYST_C1 + 960000; | |
SYST_CS |= (1 << 1); | |
} | |
if (IRQ_PEND1 & IRQ_TIMER_C3) { | |
counter3++; | |
changed3 = 1; | |
SYST_C3 = SYST_C3 + 720000; | |
SYST_CS |= (1 << 3); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment