a blinker for stm8. not quite sure how the .rel files work but this
authorDarron Broad <darron@kewl.org>
Mon, 09 Feb 2015 23:09:19 +0000
changeset 0 667c91da5a34
child 1 834a8047a3a1
a blinker for stm8. not quite sure how the .rel files work but this
builds at least
Makefile
miniblink.c
stm8.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Mon Feb 09 23:09:19 2015 +0000
@@ -0,0 +1,61 @@
+#
+# Copyright (C) 2015 Darron Broad
+# All rights reserved.
+#
+# This file is part of miniblink.
+#
+# miniblink is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation.
+#
+# miniblink is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along
+# with miniblink. If not, see http://www.gnu.org/licenses/
+#
+
+CC=sdcc
+AS=sdasstm8
+LD=sdldstm8
+
+CFLAGS=--std-sdcc99 -mstm8
+CLIB=
+
+TARGET = miniblink.hex
+
+CSOURCE = miniblink.c
+ASOURCE = $(CSOURCE:.c=.asm)
+CHEADER =
+COBJECT = $(CSOURCE:.c=.rel)
+LSCRIPT =
+
+build:$(TARGET)
+
+$(TARGET):$(ASOURCE) $(COBJECT)
+	@echo -n "[LINK] "
+	$(CC) $(CFLAGS) $(COBJECT) -o $(TARGET) $(CLIB)
+
+#$(LD) -im $(TARGET) $(COBJECT) $(CLIB)
+
+$(ASOURCE):$(CHEADER) $(LSCRIPT) Makefile
+
+install:build
+
+uninstall:clean
+
+clean:
+	rm -f $(COBJECT) $(TARGET) *~ *.asm *.cdb *.lk *.lst *.map *.rel *.rst *.sym
+
+flash:build
+	stm8flash -cstlink -pstm8s105 -w $(TARGET)
+
+%.asm:%.c
+	@echo -n "[CC] "
+	$(CC) -S $(CFLAGS) -c $< -o $@
+
+%.rel:%.asm
+	@echo -n "[AS] "
+	$(AS) -plosgffw $< 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/miniblink.c	Mon Feb 09 23:09:19 2015 +0000
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2015 Darron Broad
+ * All rights reserved.
+ * 
+ * This file is part of miniblink.
+ * 
+ * miniblink is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation. 
+ * 
+ * miniblink is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details. 
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with miniblink. If not, see http://www.gnu.org/licenses/
+ */
+
+#include "stm8.h"
+
+void
+main(void)
+{
+	uint32_t i;
+
+	PD_DDR = 0x01;
+	PD_CR1 = 0x01;
+
+	while (1) {
+		for (i = 0; i < 100000; ++i)
+			;
+		PD_ODR ^= 0x01;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stm8.h	Mon Feb 09 23:09:19 2015 +0000
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2015 Darron Broad
+ * All rights reserved.
+ * 
+ * This file is part of miniblink.
+ * 
+ * miniblink is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation. 
+ * 
+ * miniblink is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details. 
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with miniblink. If not, see http://www.gnu.org/licenses/
+ */
+
+/*
+ * RM0016
+ * Reference manual
+ *
+ * STM8S and STM8AF microcontroller families 
+ *
+ * CD00190271.pdf
+ */
+
+#ifndef _STM8_H
+#define _STM8_H
+
+#include <stdint.h>
+
+/*
+ * 11.9 GPIO registers
+ *
+ * Page: 112
+ */
+#define PA_ODR *(volatile uint8_t *)(0x5000)
+#define PA_IDR *(volatile uint8_t *)(0x5001)
+#define PA_DDR *(volatile uint8_t *)(0x5002)
+#define PA_CR1 *(volatile uint8_t *)(0x5003)
+#define PA_CR2 *(volatile uint8_t *)(0x5004)
+
+#define PB_ODR *(volatile uint8_t *)(0x5005)
+#define PB_IDR *(volatile uint8_t *)(0x5006)
+#define PB_DDR *(volatile uint8_t *)(0x5007)
+#define PB_CR1 *(volatile uint8_t *)(0x5008)
+#define PB_CR2 *(volatile uint8_t *)(0x5009)
+
+#define PC_ODR *(volatile uint8_t *)(0x500A)
+#define PC_IDR *(volatile uint8_t *)(0x500B)
+#define PC_DDR *(volatile uint8_t *)(0x500C)
+#define PC_CR1 *(volatile uint8_t *)(0x500D)
+#define PC_CR2 *(volatile uint8_t *)(0x500E)
+
+#define PD_ODR *(volatile uint8_t *)(0x500F)
+#define PD_IDR *(volatile uint8_t *)(0x5010)
+#define PD_DDR *(volatile uint8_t *)(0x5011)
+#define PD_CR1 *(volatile uint8_t *)(0x5012)
+#define PD_CR2 *(volatile uint8_t *)(0x5013)
+
+#define PE_ODR *(volatile uint8_t *)(0x5014)
+#define PE_IDR *(volatile uint8_t *)(0x5015)
+#define PE_DDR *(volatile uint8_t *)(0x5016)
+#define PE_CR1 *(volatile uint8_t *)(0x5017)
+#define PE_CR2 *(volatile uint8_t *)(0x5018)
+
+#define PF_ODR *(volatile uint8_t *)(0x5019)
+#define PF_IDR *(volatile uint8_t *)(0x501A)
+#define PF_DDR *(volatile uint8_t *)(0x501B)
+#define PF_CR1 *(volatile uint8_t *)(0x501C)
+#define PF_CR2 *(volatile uint8_t *)(0x501D)
+
+#endif