summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2017-09-02 16:44:43 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2017-09-02 16:44:43 (GMT)
commit6265e46a54402744f9e8d66ddfd325a30ffef8f0 (patch)
tree0da9e9e419f234190d1c9504a98c002a6960ebc9
parent5530b7eb6b7bcdb27be726356db7ab786858bf49 (diff)
fix programmer and led pin for stm8blue
-rw-r--r--defines.mk8
-rw-r--r--include.mk19
-rw-r--r--lib/led.c16
3 files changed, 29 insertions, 14 deletions
diff --git a/defines.mk b/defines.mk
index 9d26b19..6d8669a 100644
--- a/defines.mk
+++ b/defines.mk
@@ -27,15 +27,15 @@ ifeq ($(BOARD_TYPE),discovery)
LED_CNT := 1
LED_GPIO := GPIOD
LED_PINNUM := 0
- PROG := stm8flash
+ PROG := stlink
endif
ifeq ($(BOARD_TYPE),stm8blue)
MCU := stm8s103f3
SPL_MCU := STM8S103
LED_CNT := 1
- LED_GPIO := GPIOD
- LED_PINNUM := 3
- PROG := stm8flash
+ LED_GPIO := GPIOB
+ LED_PINNUM := 5
+ PROG := stlinkv2
endif
CC = sdcc
diff --git a/include.mk b/include.mk
index 8272dff..3139a59 100644
--- a/include.mk
+++ b/include.mk
@@ -130,15 +130,26 @@ clean:
distclean: clean-external clean
-### stm8flash
-define stm8flash/erase
+### stlink
+define stlink/erase
endef
-define stm8flash/flash
+define stlink/flash
$(stm8flash) -c stlink -p $(MCU) -w $1
endef
-define stm8flash/run
+define stlink/run
+endef
+
+### stlinkv2
+define stlinkv2/erase
+endef
+
+define stlinkv2/flash
+ $(stm8flash) -c stlinkv2 -p $(MCU) -w $1
+endef
+
+define stlinkv2/run
endef
### stm8gal
diff --git a/lib/led.c b/lib/led.c
index 9da4197..338226b 100644
--- a/lib/led.c
+++ b/lib/led.c
@@ -33,11 +33,15 @@
#define LED_DIR 0
#endif
+#ifdef LED_PINNUM
+#define LED_MASK (1<<LED_PINNUM)
+#endif
+
void led_init(void)
{
#if LED_CNT >= 1
led_off();
- LED_GPIO->DDR |= 1<<LED_PINNUM;
+ LED_GPIO->DDR |= LED_MASK;
#endif
}
@@ -45,9 +49,9 @@ void led_on(void)
{
#if LED_CNT >= 1
#if LED_DIR == 1
- LED_GPIO->ODR |= 1<<LED_PINNUM;
+ LED_GPIO->ODR |= LED_MASK;
#else
- LED_GPIO->ODR &= ~(1<<LED_PINNUM);
+ LED_GPIO->ODR &= ~LED_MASK;
#endif
#endif
}
@@ -56,9 +60,9 @@ void led_off(void)
{
#if LED_CNT >= 1
#if LED_DIR == 1
- LED_GPIO->ODR &= ~(1<<LED_PINNUM);
+ LED_GPIO->ODR &= ~(LED_MASK);
#else
- LED_GPIO->ODR |= 1<<LED_PINNUM;
+ LED_GPIO->ODR |= LED_MASK;
#endif
#endif
}
@@ -66,6 +70,6 @@ void led_off(void)
void led_toggle(void)
{
#if LED_CNT >= 1
- LED_GPIO->ODR ^= 1<<LED_PINNUM;
+ LED_GPIO->ODR ^= LED_MASK;
#endif
}