mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Use structs for registers
This commit is contained in:
4
Makefile
4
Makefile
@@ -2,9 +2,9 @@ CC=arm-none-eabi-gcc
|
||||
LD=arm-none-eabi-ld.bfd
|
||||
GDB=arm-none-eabi-gdb
|
||||
OBJCOPY=arm-none-eabi-objcopy
|
||||
CFLAGS=-march=armv7e-m -mcpu=cortex-m4 -mthumb -std=c99 -g
|
||||
CFLAGS=-march=armv7e-m -mcpu=cortex-m4 -mthumb -std=c99 -g -Iarch/stm32f429
|
||||
|
||||
objs := boot/crt0.o src/blinky.o
|
||||
objs := boot/crt0.o src/blinky.o arch/stm32f429/registers.o
|
||||
|
||||
run: boot.elf
|
||||
$(GDB) -x gdb_script.gdb boot.elf
|
||||
|
||||
1
arch/stm32f429/registers.c
Normal file
1
arch/stm32f429/registers.c
Normal file
@@ -0,0 +1 @@
|
||||
void * RCC_AHB1ENR = (void *)0x40023830;
|
||||
14
arch/stm32f429/registers.h
Normal file
14
arch/stm32f429/registers.h
Normal file
@@ -0,0 +1,14 @@
|
||||
extern struct {
|
||||
unsigned int GPIOAEN:1;
|
||||
unsigned int GPIOBEN:1;
|
||||
unsigned int GPIOCEN:1;
|
||||
unsigned int GPIODEN:1;
|
||||
unsigned int GPIOEEN:1;
|
||||
unsigned int GPIOFEN:1;
|
||||
unsigned int GPIOGEN:1;
|
||||
unsigned int GPIOHEN:1;
|
||||
unsigned int GPIOIEN:1;
|
||||
unsigned int GPIOJEN:1;
|
||||
unsigned int GPIOKEN:1;
|
||||
unsigned int fill:21;
|
||||
} * RCC_AHB1ENR;
|
||||
BIN
arch/stm32f429/registers.o
Normal file
BIN
arch/stm32f429/registers.o
Normal file
Binary file not shown.
14
src/blinky.c
14
src/blinky.c
@@ -1,10 +1,14 @@
|
||||
long DataSectionTest = 0x1234;
|
||||
#include <registers.h>
|
||||
|
||||
void sleep(long delay);
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
for (int i=0; i< DataSectionTest; i++) {
|
||||
}
|
||||
RCC_AHB1ENR->GPIOGEN = 1;
|
||||
|
||||
//RCC_AHB1ENR_t * RCC_AHB1ENR = (RCC_AHB1ENR_t *)0x40023830;
|
||||
|
||||
|
||||
//RCC_AHB1ENR->GPIOGEN = 1;
|
||||
|
||||
// We want to blink LEDs connected to GPIO pin G13 and G14
|
||||
// (this is documented in our board's PDF)
|
||||
@@ -24,8 +28,8 @@ int main(int argc, char * argv[]) {
|
||||
// (per STM32F429xx datasheet)
|
||||
// In other words, we want to enable bit 6 of (0x40023830)
|
||||
|
||||
long * RCCAHB1ENR = (long *)0x40023830;
|
||||
*RCCAHB1ENR |= (1 << 6); // Set 6th bit of RCCAHB1ENR
|
||||
//long * RCCAHB1ENR = (long *)0x40023830;
|
||||
//*RCCAHB1ENR |= (1 << 6); // Set 6th bit of RCCAHB1ENR
|
||||
|
||||
// Step 2 : Configure the GPIO pin
|
||||
// Set the mode to general purpose output
|
||||
|
||||
Reference in New Issue
Block a user