From 7e03729526d4f0005eddd49e347f9384d6fc905f Mon Sep 17 00:00:00 2001 From: Philipp Klaus Krause Date: Thu, 16 Jun 2016 20:59:11 +0200 Subject: [PATCH] Make atomthreads assemble with SDCC --- ports/stm8/atomport-asm-sdcc.s | 36 ++++++++++++++++++++++++++++++++++ ports/stm8/atomport.c | 4 ++++ ports/stm8/sdcc.mak | 2 +- ports/stm8/uart.c | 16 +++++++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/ports/stm8/atomport-asm-sdcc.s b/ports/stm8/atomport-asm-sdcc.s index e69de29..0fb199e 100644 --- a/ports/stm8/atomport-asm-sdcc.s +++ b/ports/stm8/atomport-asm-sdcc.s @@ -0,0 +1,36 @@ +; uint8_t get_cc(void); +_get_cc:: + push cc + pop a + ret + +; void set_cc(uint8_t); +_set_cc:: + ld a, (3, sp) + push a + pop cc + ret + +; void archContextSwitch (ATOM_TCB *old_tcb_ptr, ATOM_TCB *new_tcb_ptr) +_archContextSwitch:: + + ; save context + ldw x, (3, sp) + ldw y, sp + ldw (x), y + + ; restore context + ldw x, (5, sp) + jra restore + +; void archFirstThreadRestore (ATOM_TCB *new_tcb_ptr) +_archFirstThreadRestore:: + + ; restore context + ldw x, (3, sp) + restore: + ldw x, (x) + ldw sp, x + + ret + diff --git a/ports/stm8/atomport.c b/ports/stm8/atomport.c index 6f9c79f..7dc27bf 100644 --- a/ports/stm8/atomport.c +++ b/ports/stm8/atomport.c @@ -95,6 +95,8 @@ static NO_REG_SAVE void thread_shell (void) rim(); #elif defined(__RCSTM8__) _rim_(); +#elif defined(__SDCC_stm8) + __asm__("rim"); #endif /* Call the thread entry point */ @@ -293,6 +295,7 @@ void archInitSystemTickTimer ( void ) INTERRUPT void TIM1_SystemTickISR (void) #if defined(__RCSTM8__) interrupt 11 + #elif defined(__SDCC_stm8) __interrupt(11) #endif @@ -309,3 +312,4 @@ __interrupt(11) /* Call the interrupt exit routine */ atomIntExit(TRUE); } + diff --git a/ports/stm8/sdcc.mak b/ports/stm8/sdcc.mak index 972e879..390c6d3 100644 --- a/ports/stm8/sdcc.mak +++ b/ports/stm8/sdcc.mak @@ -42,7 +42,7 @@ vpath %.elf .\$(BUILD_DIR) vpath %.hex .\$(BUILD_DIR) # Compiler/Assembler flags -CFLAGS= -mstm8 -c -D $(PART) --opt-code-size --max-allocs-per-node 300 +CFLAGS= -mstm8 -c -D $(PART) --opt-code-size --max-allocs-per-node 3000 DBG_CFLAGS= -mstm8 -c -D $(PART) --opt-code-size --max-allocs-per-node 3000 ASMFLAGS= -off DBG_ASMFLAGS= -off diff --git a/ports/stm8/uart.c b/ports/stm8/uart.c index 90515ac..e34881e 100644 --- a/ports/stm8/uart.c +++ b/ports/stm8/uart.c @@ -154,3 +154,19 @@ size_t __write(int handle, const unsigned char *buf, size_t bufSize) return (chars_written); } #endif /* __IAR_SYSTEMS_ICC__ */ + +#if defined(__SDCC_stm8) +#if __SDCC_REVISION >= 9624 +int putchar (int c) +{ + return(uart_putchar(c)); +} +#else +void putchar (char c) +{ + uart_putchar(c); +} +#endif + +#endif +