diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2024-09-10 08:42:16 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2024-09-10 08:42:16 +0800 |
| commit | 582b7eeb62154b95207d39ea612ceaf81d45f6f6 (patch) | |
| tree | 8261d6e8a537d2eaebf738f0a765366c56037172 /main.c | |
| parent | 2d4eee24f42d33eca5e2b5a78a868b18049ee9ff (diff) | |
| download | bare-metal-arduino-due-582b7eeb62154b95207d39ea612ceaf81d45f6f6.tar.gz | |
wip
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 119 |
1 files changed, 63 insertions, 56 deletions
@@ -1,69 +1,76 @@ -#define PIOA 0x400E0E00 -#define PIOB 0x400E1000 -#define PIOC 0x400E1200 -#define PIOD 0x400E1400 +#define PIOA 0x400E0E00u +#define PIOB 0x400E1000u +#define PIOC 0x400E1200u +#define PIOD 0x400E1400u -#define PORT PIOC; +#define PORT PIOC -#define PIO_PER *((volatile unsigned int *)(PORT + 0x0000)) -#define PIO_PDR *((volatile unsigned int *)(PORT + 0x0004)) -#define PIO_PSR *((volatile unsigned int *)(PORT + 0x0008)) -#define PIO_OER *((volatile unsigned int *)(PORT + 0x0010)) -#define PIO_ODR *((volatile unsigned int *)(PORT + 0x0014)) -#define PIO_OSR *((volatile unsigned int *)(PORT + 0x0018)) -#define PIO_IFER *((volatile unsigned int *)(PORT + 0x0020)) -#define PIO_IFDR *((volatile unsigned int *)(PORT + 0x0024)) -#define PIO_IFSR *((volatile unsigned int *)(PORT + 0x0028)) -#define PIO_SODR *((volatile unsigned int *)(PORT + 0x0030)) -#define PIO_CODR *((volatile unsigned int *)(PORT + 0x0034)) -#define PIO_ODSR *((volatile unsigned int *)(PORT + 0x0038)) -#define PIO_PDSR *((volatile unsigned int *)(PORT + 0x003C)) -#define PIO_IER *((volatile unsigned int *)(PORT + 0x0040)) -#define PIO_IDR *((volatile unsigned int *)(PORT + 0x0044)) -#define PIO_IMR *((volatile unsigned int *)(PORT + 0x0048)) -#define PIO_ISR *((volatile unsigned int *)(PORT + 0x004C)) -#define PIO_MDER *((volatile unsigned int *)(PORT + 0x0050)) -#define PIO_MDDR *((volatile unsigned int *)(PORT + 0x0054)) -#define PIO_MDSR *((volatile unsigned int *)(PORT + 0x0058)) -#define PIO_PUDR *((volatile unsigned int *)(PORT + 0x0060)) -#define PIO_PUER *((volatile unsigned int *)(PORT + 0x0064)) -#define PIO_PUSR *((volatile unsigned int *)(PORT + 0x0068)) -#define PIO_ABSR *((volatile unsigned int *)(PORT + 0x0070)) -#define PIO_SCIFSR *((volatile unsigned int *)(PORT + 0x0080)) -#define PIO_DIFSR *((volatile unsigned int *)(PORT + 0x0084)) -#define PIO_IFDGSR *((volatile unsigned int *)(PORT + 0x0088)) -#define PIO_SCDR *((volatile unsigned int *)(PORT + 0x008C)) -#define PIO_OWER *((volatile unsigned int *)(PORT + 0x00A0)) -#define PIO_OWDR *((volatile unsigned int *)(PORT + 0x00A4)) -#define PIO_OWSR *((volatile unsigned int *)(PORT + 0x00A8)) -#define PIO_AIMER *((volatile unsigned int *)(PORT + 0x00B0)) -#define PIO_AIMDR *((volatile unsigned int *)(PORT + 0x00B4)) -#define PIO_AIMMR *((volatile unsigned int *)(PORT + 0x00B8)) +#define PIO_PER *((volatile unsigned int *)(PORT + 0x0000u)) +#define PIO_PDR *((volatile unsigned int *)(PORT + 0x0004u)) +#define PIO_PSR *((volatile unsigned int *)(PORT + 0x0008u)) +#define PIO_OER *((volatile unsigned int *)(PORT + 0x0010u)) +#define PIO_ODR *((volatile unsigned int *)(PORT + 0x0014u)) +#define PIO_OSR *((volatile unsigned int *)(PORT + 0x0018u)) +#define PIO_IFER *((volatile unsigned int *)(PORT + 0x0020u)) +#define PIO_IFDR *((volatile unsigned int *)(PORT + 0x0024u)) +#define PIO_IFSR *((volatile unsigned int *)(PORT + 0x0028u)) +#define PIO_SODR *((volatile unsigned int *)(PORT + 0x0030u)) +#define PIO_CODR *((volatile unsigned int *)(PORT + 0x0034u)) +#define PIO_ODSR *((volatile unsigned int *)(PORT + 0x0038u)) +#define PIO_PDSR *((volatile unsigned int *)(PORT + 0x003Cu)) +#define PIO_IER *((volatile unsigned int *)(PORT + 0x0040u)) +#define PIO_IDR *((volatile unsigned int *)(PORT + 0x0044u)) +#define PIO_IMR *((volatile unsigned int *)(PORT + 0x0048u)) +#define PIO_ISR *((volatile unsigned int *)(PORT + 0x004Cu)) +#define PIO_MDER *((volatile unsigned int *)(PORT + 0x0050u)) +#define PIO_MDDR *((volatile unsigned int *)(PORT + 0x0054u)) +#define PIO_MDSR *((volatile unsigned int *)(PORT + 0x0058u)) +#define PIO_PUDR *((volatile unsigned int *)(PORT + 0x0060u)) +#define PIO_PUER *((volatile unsigned int *)(PORT + 0x0064u)) +#define PIO_PUSR *((volatile unsigned int *)(PORT + 0x0068u)) +#define PIO_ABSR *((volatile unsigned int *)(PORT + 0x0070u)) +#define PIO_SCIFSR *((volatile unsigned int *)(PORT + 0x0080u)) +#define PIO_DIFSR *((volatile unsigned int *)(PORT + 0x0084u)) +#define PIO_IFDGSR *((volatile unsigned int *)(PORT + 0x0088u)) +#define PIO_SCDR *((volatile unsigned int *)(PORT + 0x008Cu)) +#define PIO_OWER *((volatile unsigned int *)(PORT + 0x00A0u)) +#define PIO_OWDR *((volatile unsigned int *)(PORT + 0x00A4u)) +#define PIO_OWSR *((volatile unsigned int *)(PORT + 0x00A8u)) +#define PIO_AIMER *((volatile unsigned int *)(PORT + 0x00B0u)) +#define PIO_AIMDR *((volatile unsigned int *)(PORT + 0x00B4u)) +#define PIO_AIMMR *((volatile unsigned int *)(PORT + 0x00B8u)) -#define PIO_WPMR *((volatile unsigned int *)(PORT + 0x00E4)) -#define PIO_WPSR *((volatile unsigned int *)(PORT + 0x00E8)) +#define PIO_WPMR *((volatile unsigned int *)(PORT + 0x00E4u)) +#define PIO_WPSR *((volatile unsigned int *)(PORT + 0x00E8u)) -#define PIN_NUM_MASK (1U << 0) -#define PIO_WPEN_MASK 0x50494F00 +#define PIN_NUM_MASK (1U << 1) +#define PIO_WPEN_MASK 0x50494F00 int main(void) { PIO_WPMR = PIO_WPEN_MASK & 0xFFFFFFFE; - PIO_PER |= PIN_NUM_MASK; - PIO_PDR |= ~PIN_NUM_MASK; - - PIO_OER |= PIN_NUM_MASK; - PIO_ODR |= ~PIN_NUM_MASK; - - PIO_IER |= ~PIN_NUM_MASK; - PIO_IDR |= PIN_NUM_MASK; - - PIO_PUDR |= PIN_NUM_MASK; - PIO_PUER |= ~PIN_NUM_MASK; + PIO_PER = 0x0000FFFF; + PIO_OER = 0x000000FF; + PIO_ODR = 0xFFFFFF00; + PIO_IFER = 0x00000F00; + PIO_IFDR = 0xFFFFF0FF; + PIO_SODR = 0x00000000; + PIO_CODR = 0x0FFFFFFF; + PIO_IER = 0x0F000F00; + PIO_IDR = 0xF0FFF0FF; + PIO_MDER = 0x0000000F; + PIO_MDDR = 0xFFFFFFF0; + PIO_PUDR = 0xF0F000F0; + PIO_PUER = 0x0F0FFF0F; + PIO_ABSR = 0x00F00000; + PIO_OWER = 0x0000000F; + PIO_OWDR = 0x0FFFFFF0; - PIO_SODR = 1; - PIO_CODR = 0; + PIO_SODR = 0x000000F0; + + for (;;) + ; return 0; } |
