aboutsummaryrefslogtreecommitdiffstats
path: root/examples/baremetal
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-07-27 09:24:10 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-07-29 13:48:35 +0000
commit132b33b6e0d650f9cc63ed352968e4439411713a (patch)
treea1fe3b4c7621c918d08114fecad8aa2355919c5c /examples/baremetal
parent8d8a0bcfeeabc784f9582a9cedfed234336a9654 (diff)
bare-metal: Add support for SDCC to stm8s103f example
Change-Id: I00b62a426e806bbb57526658f7a5d3cb9a210b48 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'examples/baremetal')
-rw-r--r--examples/baremetal/stm8s103f3/redblink/redblink.qbs9
-rw-r--r--examples/baremetal/stm8s103f3/redblink/system.h22
2 files changed, 25 insertions, 6 deletions
diff --git a/examples/baremetal/stm8s103f3/redblink/redblink.qbs b/examples/baremetal/stm8s103f3/redblink/redblink.qbs
index aeba59ee7..197bae8ae 100644
--- a/examples/baremetal/stm8s103f3/redblink/redblink.qbs
+++ b/examples/baremetal/stm8s103f3/redblink/redblink.qbs
@@ -55,6 +55,7 @@ CppApplication {
if (!qbs.architecture.contains("stm8"))
return false;
return qbs.toolchain.contains("iar")
+ || qbs.toolchain.contains("sdcc")
}
name: "stm8s103f3-redblink"
cpp.positionIndependentCode: false
@@ -85,6 +86,14 @@ CppApplication {
}
//
+ // SDCC-specific properties and sources.
+ //
+
+ Properties {
+ condition: qbs.toolchain.contains("sdcc")
+ }
+
+ //
// Common code.
//
diff --git a/examples/baremetal/stm8s103f3/redblink/system.h b/examples/baremetal/stm8s103f3/redblink/system.h
index ff6955ad7..463123ce2 100644
--- a/examples/baremetal/stm8s103f3/redblink/system.h
+++ b/examples/baremetal/stm8s103f3/redblink/system.h
@@ -55,18 +55,28 @@
extern "C" {
#endif
+// Define required registers of Port B (where the LED is connected):
+// * PB_ODR - Output Data Register.
+// * PB_DDR - Data Direction Register.
+// * PB_CR1 - Control Register #1.
+// * PB_CR2 - Control Register #2.
+
#if defined(__ICCSTM8__)
# define system_nop() __asm("nop")
-# define DEFINE_REG(name,addr) __near __no_init volatile unsigned char name @ addr;
+__near __no_init volatile unsigned char PB_ODR @ 0x5005;
+__near __no_init volatile unsigned char PB_DDR @ 0x5007;
+__near __no_init volatile unsigned char PB_CR1 @ 0x5008;
+__near __no_init volatile unsigned char PB_CR2 @ 0x5009;
+#elif defined (__SDCC_stm8)
+# define system_nop() __asm nop __endasm
+#define PB_ODR *(volatile unsigned char *)0x5005
+#define PB_DDR *(volatile unsigned char *)0x5007
+#define PB_CR1 *(volatile unsigned char *)0x5008
+#define PB_CR2 *(volatile unsigned char *)0x5009
#else
#error "Unsupported toolchain"
#endif
-DEFINE_REG(PB_ODR, 0x5005) // Output Data Register of Port B.
-DEFINE_REG(PB_DDR, 0x5007) // Data Direction Register of Port B.
-DEFINE_REG(PB_CR1, 0x5008) // Control Register #1 of Port B.
-DEFINE_REG(PB_CR2, 0x5009) // Control Register #2 of Port B.
-
#ifdef __cplusplus
}
#endif