diff options
-rw-r--r-- | lib/cm4.h | 10 | ||||
-rw-r--r-- | usb/usb.c | 15 |
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/cm4.h b/lib/cm4.h new file mode 100644 index 0000000..7c1c774 --- /dev/null +++ b/lib/cm4.h @@ -0,0 +1,10 @@ +#ifndef LIB_CM4_H +#define LIB_CM4_H + +#define CLRPEND(n) REG_32(0xE000E280 + 4 * (n)) +#define ISR_CLRPEND(i) CLRPEND((i) / 32) = BV((i) % 32); + +#define SETENA(n) REG_32(0xE000E100 + 4 * (n)) +#define ISR_SETENA(i) SETENA((i) / 32) = BV((i) % 32); + +#endif /* LIB_CM4_H */ @@ -1,6 +1,7 @@ +#include <cm4.h> +#include <reg/gpio.h> #include <reg/sim.h> #include <reg/usbotg.h> -#include <reg/gpio.h> #include <stddef.h> #include "usb.h" @@ -11,16 +12,10 @@ #define USBFRAC_VAL 1 /* 72 MHz * 2 = 144 MHz (Top of Fraction) */ #define USBDIV_VAL 2 /* 144 MHz / 3 = 48 MHz (Bottom of Fraction) */ -/* TODO: Move this to lib somewhere */ -#define CLRPEND(n) REG_32(0xE000E280 + 4 * (n)) -#define ISR_CLRPEND(i) CLRPEND((i) / 32) = BV((i) % 32); - -#define SETENA(n) REG_32(0xE000E100 + 4 * (n)) -#define ISR_SETENA(i) SETENA((i) / 32) = BV((i) % 32); - - +/* TODO: Only use the number of endpoints that are needed */ +/* TODO: Try using static */ __attribute__ ((aligned(512))) -struct usb0_bd usb_bdt[16 * 4]; /* TODO: Only use the number of endpoints that are needed */ +struct usb0_bd usb_bdt[16 * 4]; /* usb_setup: Setup function for USB subsystem */ void usb_setup(void) |