[add] dirty example

pull/1/head
texane 2011-01-14 09:54:01 -06:00
rodzic 18daa64fb4
commit fe76cc4a6b
3 zmienionych plików z 46 dodań i 0 usunięć

19
example/build.sh 100755
Wyświetl plik

@ -0,0 +1,19 @@
#!/usr/bin/env sh
CHAIN=$HOME/sat/bin/arm-none-eabi
PATH=$HOME/sat/arm-none-eabi/bin:$PATH
$CHAIN-gcc \
-O2 \
-mlittle-endian \
-mthumb \
-mcpu=cortex-m3 \
-ffreestanding \
-nostdlib \
-nostdinc \
main.c
$CHAIN-objcopy \
-O binary \
a.out \
/tmp/foobar

27
example/main.c 100644
Wyświetl plik

@ -0,0 +1,27 @@
typedef unsigned int uint32_t;
#define GPIOC 0x40011000 // port C
#define GPIOC_CRH (GPIOC + 0x04) // port configuration register high
#define GPIOC_ODR (GPIOC + 0x0c) // port output data register
#define LED_BLUE (1<<8) // pin 8
#define LED_GREEN (1<<9) // pin 9
#define delay() \
do { \
register unsigned int i; \
for (i = 0; i < 1000000; ++i) \
__asm__ __volatile__ ("nop\n\t":::"memory"); \
} while (0)
static void __attribute__((naked)) __attribute__((used)) main(void)
{
*(volatile uint32_t*)GPIOC_CRH = 0x44444411;
while (1)
{
*(volatile uint32_t*)GPIOC_ODR = LED_BLUE | LED_GREEN;
delay();
*(volatile uint32_t*)GPIOC_ODR = 0;
delay();
}
}

BIN
example/o.bin 100755

Plik binarny nie jest wyświetlany.