forked from stlink-org/stlink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,626 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
libstlink.a | ||
test_usb | ||
test_sg | ||
gdbserver/st-utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ [email protected] | |
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
. flash writing is not working from GDB | ||
add a standalone application, flash/ | ||
. flash tool | ||
. test support for reading | ||
. writing is not working. refer to the specs, may have changed for stm32l | ||
. then test with blink_flash example | ||
. then update the documentation | ||
|
||
. add a startup.S based example | ||
. documentation | ||
. make README points to doc/tutorial | ||
|
||
. remove libsg dependency using: | ||
https://github.com/afaerber/stlink/tree/master/libstlink | ||
|
||
. compile and test a realtime kernel, for instance: | ||
http://www.chibios.org/dokuwiki/doku.php?id=start | ||
http://www.chibios.org/dokuwiki/doku.php?id=chibios:articles:stm32l_discovery | ||
svn checkout https://chibios.svn.sourceforge.net/svnroot/chibios/trunk ; | ||
cd chibios/trunk/demos/ARMCM3-STM32L152-DISCOVERY ; | ||
make ; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
EXECUTABLE=blink.elf | ||
BIN_IMAGE=blink.bin | ||
|
||
CC=arm-none-eabi-gcc | ||
OBJCOPY=arm-none-eabi-objcopy | ||
|
||
CFLAGS=-O2 -mlittle-endian -mthumb | ||
|
||
CFLAGS=-g -O2 -mlittle-endian -mthumb | ||
ifeq ($(CONFIG_STM32L_DISCOVERY), 1) | ||
CFLAGS+=-mcpu=cortex-m3 -DCONFIG_STM32L_DISCOVERY | ||
else ifeq ($(CONFIG_STM32VL_DISCOVERY), 1) | ||
CFLAGS+=-mcpu=cortex-m3 -DCONFIG_STM32VL_DISCOVERY=1 | ||
else ifeq ($(CONFIG_STM32F4_DISCOVERY), 1) | ||
CFLAGS+=-mcpu=cortex-m4 -DCONFIG_STM32F4_DISCOVERY=1 | ||
else | ||
$(error "must specify CONFIG_ for board!") | ||
endif | ||
CFLAGS+=-ffreestanding -nostdlib -nostdinc | ||
|
||
# to run from FLASH | ||
CFLAGS+=-Wl,-T,stm32_flash.ld | ||
|
||
all: $(BIN_IMAGE) | ||
|
||
$(BIN_IMAGE): $(EXECUTABLE) | ||
$(OBJCOPY) -O binary $^ $@ | ||
|
||
$(EXECUTABLE): main.c startup_stm32l1xx_md.s | ||
$(CC) $(CFLAGS) $^ -o $@ | ||
|
||
clean: | ||
rm -rf $(EXECUTABLE) | ||
rm -rf $(BIN_IMAGE) | ||
|
||
.PHONY: all clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* missing type */ | ||
|
||
typedef unsigned int uint32_t; | ||
|
||
|
||
/* hardware configuration */ | ||
|
||
#define CONFIG_STM32L_DISCOVERY 1 | ||
#define CONFIG_STM32VL_DISCOVERY 0 | ||
|
||
|
||
#if CONFIG_STM32VL_DISCOVERY | ||
|
||
# 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) /* port C, pin 8 */ | ||
# define LED_GREEN (1 << 9) /* port C, pin 9 */ | ||
|
||
static inline void setup_leds(void) | ||
{ | ||
*(volatile uint32_t*)GPIOC_CRH = 0x44444411; | ||
} | ||
|
||
static inline void switch_leds_on(void) | ||
{ | ||
*(volatile uint32_t*)GPIOC_ODR = LED_BLUE | LED_GREEN; | ||
} | ||
|
||
static inline void switch_leds_off(void) | ||
{ | ||
*(volatile uint32_t*)GPIOC_ODR = 0; | ||
} | ||
|
||
#elif CONFIG_STM32L_DISCOVERY | ||
|
||
# define GPIOB 0x40020400 /* port B */ | ||
# define GPIOB_MODER (GPIOB + 0x00) /* port mode register */ | ||
# define GPIOB_ODR (GPIOB + 0x14) /* port output data register */ | ||
|
||
# define LED_BLUE (1 << 6) /* port B, pin 6 */ | ||
# define LED_GREEN (1 << 7) /* port B, pin 7 */ | ||
|
||
static inline void setup_leds(void) | ||
{ | ||
/* configure port 6 and 7 as output */ | ||
*(volatile uint32_t*)GPIOB_MODER |= (1 << (7 * 2)) | (1 << (6 * 2)); | ||
} | ||
|
||
static inline void switch_leds_on(void) | ||
{ | ||
*(volatile uint32_t*)GPIOB_ODR = LED_BLUE | LED_GREEN; | ||
} | ||
|
||
static inline void switch_leds_off(void) | ||
{ | ||
*(volatile uint32_t*)GPIOB_ODR = 0; | ||
} | ||
|
||
#endif /* otherwise, error */ | ||
|
||
|
||
#define delay() \ | ||
do { \ | ||
register unsigned int i; \ | ||
for (i = 0; i < 1000000; ++i) \ | ||
__asm__ __volatile__ ("nop\n\t":::"memory"); \ | ||
} while (0) | ||
|
||
void main(void) | ||
{ | ||
setup_leds(); | ||
|
||
while (1) | ||
{ | ||
switch_leds_on(); | ||
delay(); | ||
switch_leds_off(); | ||
delay(); | ||
} | ||
} |
Oops, something went wrong.