chore: ld
This commit is contained in:
31
src/main.c
Normal file
31
src/main.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <stdint.h>
|
||||
|
||||
extern uint32_t DiagPrintf(const char *fmt, ...)
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
#define printf DiagPrintf
|
||||
|
||||
// GPIO direction register @ 0x1004 (from GPIO_Direction: 12 * port + 0x40000000
|
||||
// + 0x1000 + 4) For interrupt control: 0x1030: Interrupt enable register
|
||||
// 0x1038: Interrupt trigger type
|
||||
// 0x103C: Interrupt polarity
|
||||
// 0x1048: Interrupt debounce
|
||||
|
||||
#define PERIPH_BASE 0x40000000
|
||||
// 12 * port_number(0) + PERIPH_BASE + 0x1000
|
||||
#define PORT_A_BASE (PERIPH_BASE + 0x1000)
|
||||
|
||||
#define GPIOA_DIR (*(volatile uint32_t *)(PORT_A_BASE + 0x4))
|
||||
#define GPIOA (*(volatile uint32_t *)(PORT_A_BASE + 0x0))
|
||||
|
||||
int main(void) {
|
||||
printf("hello from main\n");
|
||||
// while (1) {
|
||||
// __asm("nop");
|
||||
// }
|
||||
|
||||
GPIOA_DIR |= (1 << 0);
|
||||
while (1) {
|
||||
GPIOA ^= (1 << 0);
|
||||
for (volatile int i = 0; i < 100000; i++);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user