diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/baremetal/stm8s103f3/redblink/redblink.qbs | 9 | ||||
-rw-r--r-- | examples/baremetal/stm8s103f3/redblink/system.h | 22 |
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 |