-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from TG9541/C0135
#12 board support for C0135
- Loading branch information
Showing
9 changed files
with
284 additions
and
47 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 |
---|---|---|
@@ -0,0 +1,127 @@ | ||
; STM8S103F3P6 "Minimal System Board" STM8S device dependent routines | ||
|
||
|
||
; BOARDINIT ( -- ) | ||
; Init board GPIO (except COM ports) | ||
|
||
BOARDINIT: | ||
; "Nano PLC Relay board" GPIO for relay & LED | ||
MOV PB_DDR,#0b00110000 ; --R1---- R:DE/RE 1:R1 | ||
MOV PB_CR1,#0b00000000 | ||
MOV PC_DDR,#0b00111000 ; --432--- 4:R4 3:R3 2:R2 | ||
MOV PC_CR1,#0b00000000 | ||
MOV PD_DDR,#0b00010000 ; ---L---- L:LED | ||
MOV PD_CR1,#0b00010000 | ||
|
||
.ifne HAS_OUTPUTS | ||
CLR A | ||
JRA AOUTSTOR | ||
.else | ||
RET | ||
.endif | ||
|
||
;=============================================================== | ||
|
||
.ifne HAS_OUTPUTS | ||
RamWord OUTPUTS ; "OUT", e.g. relays, LEDs, etc. (16 bit) | ||
|
||
; OUT! ( c -- ) | ||
; Put c to board outputs, storing a copy in OUTPUTS | ||
|
||
.dw LINK | ||
|
||
LINK = . | ||
.db (4) | ||
.ascii "OUT!" | ||
OUTSTOR: | ||
INCW X | ||
LD A,(X) | ||
INCW X | ||
AOUTSTOR: | ||
LD OUTPUTS+1,A | ||
XOR A,#0x0F ; C0135 Relay-4 Board | ||
RRC A | ||
BCCM PB_ODR,#4 ; Relay1 | ||
RRC A | ||
BCCM PC_ODR,#3 ; Relay2 | ||
RRC A | ||
BCCM PC_ODR,#4 ; Relay3 | ||
RRC A | ||
BCCM PC_ODR,#5 ; Relay4 | ||
RRC A | ||
BCCM PD_ODR,#4 ; LED | ||
RET | ||
.endif | ||
|
||
;=============================================================== | ||
|
||
; Dummy labels for PSIM interrupts declared in main.c | ||
|
||
.ifne PSIM-PORTA | ||
; Dummy label for _EXTIA_IRQHandler | ||
_EXTI0_IRQHandler: | ||
.endif | ||
|
||
.ifne PSIM-PORTB | ||
; Dummy label for _EXTIB_IRQHandler | ||
_EXTI1_IRQHandler: | ||
.endif | ||
|
||
.ifne PSIM-PORTC | ||
; Dummy label for _EXTIC_IRQHandler | ||
_EXTI2_IRQHandler: | ||
.endif | ||
|
||
.ifne PSIM-PORTD | ||
; Dummy label for _EXTID_IRQHandler | ||
_EXTI3_IRQHandler: | ||
.endif | ||
|
||
.ifne PSIM-PORTE | ||
; Dummy label for _EXTIE_IRQHandler | ||
_EXTI4_IRQHandler: | ||
.endif | ||
|
||
;=============================================================== | ||
|
||
.ifne HAS_LED7SEG | ||
; LED_MPX driver ( -- ) | ||
; Code called from ISR for LED MPX | ||
|
||
LED_MPX: | ||
RET | ||
.endif | ||
|
||
;=============================================================== | ||
|
||
.ifne HAS_KEYS | ||
|
||
; BKEY ( -- c ) ( TOS STM8: -- A,Z,N ) | ||
; Read board key state as a bitfield | ||
|
||
.dw LINK | ||
|
||
LINK = . | ||
.db (4) | ||
.ascii "BKEY" | ||
BKEY: | ||
; Key "S2" port PA3 (inverted) | ||
LD A,PA_IDR | ||
SLA A | ||
SWAP A | ||
CPL A | ||
AND A,#0x01 | ||
JP ASTOR | ||
|
||
|
||
; BKEYC ( -- c ) ( TOS STM8: -- A,Z,N ) | ||
; Read and translate board dependent key bitmap into char | ||
|
||
BKEYCHAR: | ||
CALLR BKEY | ||
JREQ 1$ | ||
ADD A,#'@' | ||
LD (1,X),A | ||
1$: RET | ||
.endif | ||
|
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,40 @@ | ||
; STM8EF Global Configuration File | ||
; Config for C0135 "Relay Board-4 STM8S" | ||
|
||
HALF_DUPLEX = 0 ; Use UART in half duplex mode | ||
HAS_RXUART = 0 ; No UART RXD, word ?RX | ||
HAS_TXUART = 0 ; No UART TXD, word TX! | ||
HAS_RXSIM = 1 ; Enable RxD via GPIO/TIM4, word ?RXGP | ||
HAS_TXSIM = 1 ; Like HAS_RXSIM, word TXGP!, use for console if > HAS_TXUART | ||
PSIM = PORTD ; Port for UART simulation | ||
PNRX = 1 ; Port GPIO# for HAS_RXDSIM | ||
PNTX = 1 ; Port GPIO# for HAS_TXDSIM | ||
|
||
EMIT_BG = DROP ; 7S-LED background EMIT vector | ||
QKEY_BG = QKEYB ; ?KEYB for background ?KEY | ||
|
||
HAS_LED7SEG = 0 ; no 7S-Display | ||
HAS_KEYS = 1 ; yes, 1 key | ||
HAS_OUTPUTS = 5 ; yes, 4 relays, 1 LED | ||
HAS_ADC = 1 ; Analog input words | ||
|
||
HAS_BACKGROUND = 1 ; Background Forth task (TIM2 ticker) | ||
HAS_CPNVM = 1 ; Can compile to Flash, always interpret to RAM | ||
HAS_DOES = 1 ; CREATE-DOES> extension | ||
HAS_DOLOOP = 1 ; DO .. LOOP extension: DO LEAVE LOOP +LOOP | ||
|
||
CASEINSENSITIVE = 1 ; Case insensitive dictionary search | ||
SPEEDOVERSIZE = 0 ; Speed-over-size in core words: ROT - = < | ||
BAREBONES = 0 ; Remove or unlink some more: hi HERE .R U.R SPACES @EXECUTE AHEAD CALL, EXIT COMPILE [COMPILE] | ||
|
||
WORDS_LINKINTER = 0 ; Link interpreter words: ACCEPT QUERY TAP kTAP hi 'BOOT tmp >IN 'TIB #TIB eval CONTEXT pars PARSE NUMBER? DIGIT? WORD TOKEN NAME> SAME? find ABORT aborq $INTERPRET INTER? .OK ?STACK EVAL PRESET QUIT $COMPILE | ||
WORDS_LINKCOMP = 0 ; Link compiler words: cp last OVERT $"| ."| $,n | ||
WORDS_LINKRUNTI = 0 ; Link runtime words: doLit do$ doVAR donxt dodoes ?branch branch | ||
WORDS_LINKCHAR = 1 ; Link char out words: DIGIT <# # #S SIGN #> str hld HOLD | ||
WORDS_LINKMISC = 0 ; Link composing words of SEE DUMP WORDS: >CHAR _TYPE dm+ .ID >NAME | ||
|
||
WORDS_EXTRASTACK = 0 ; Link/include stack core words: rp@ rp! sp! sp@ DEPTH | ||
WORDS_EXTRADEBUG = 0 ; Extra debug words: SEE | ||
WORDS_EXTRACORE = 1 ; Extra core words: =0 I | ||
WORDS_EXTRAMEM = 1 ; Extra memory words: B! 2C@ 2C! | ||
WORDS_EXTRAEEPR = 1 ; Extra EEPROM lock/unlock words: LOCK ULOCK ULOCKF LOCKF |
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,14 @@ | ||
; STM8S103F3 device and memory layout configuration | ||
|
||
TARGET = STM8S103F3 | ||
|
||
RAMEND = 0x03FF ; system (return) stack, growing down | ||
EEPROMEND = 0x427F ; STM8S103F3: 640 bytes EEPROM | ||
FLASHEND = 0x9FFF ; 8K devices | ||
|
||
FORTHRAM = 0x0040 ; Start of RAM controlled by Forth | ||
UPPLOC = 0x0060 ; UPP (user/system area) location for 1K RAM | ||
CTOPLOC = 0x0080 ; CTOP (user dictionary) location for 1K RAM | ||
SPPLOC = 0x0350 ; SPP (data stack top), TIB start | ||
RPPLOC = RAMEND ; RPP (return stack top) | ||
|
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
Oops, something went wrong.