Use structs for registers

This commit is contained in:
Romain Goyet
2015-05-02 15:38:12 +02:00
parent ba17acb208
commit f4ac66bf0b
5 changed files with 26 additions and 7 deletions

View File

@@ -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

View File

@@ -0,0 +1 @@
void * RCC_AHB1ENR = (void *)0x40023830;

View 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

Binary file not shown.

View File

@@ -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