summaryrefslogtreecommitdiff
path: root/serial-led
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2017-08-26 21:00:05 +0200
committerChristian Pointner <equinox@spreadspace.org>2017-08-26 21:00:05 +0200
commit6f93f6b1adefa0f541b6e81d37b7677a4cb34460 (patch)
tree1afcb738ea103a473543f6acc34678e2e74ddedc /serial-led
parentbuild spl doxygen if available (diff)
fix linking to external libs
Diffstat (limited to 'serial-led')
-rw-r--r--serial-led/Makefile33
-rw-r--r--serial-led/serial-led.c58
-rw-r--r--serial-led/stm8s_conf.h116
-rw-r--r--serial-led/stm8s_it.h122
4 files changed, 329 insertions, 0 deletions
diff --git a/serial-led/Makefile b/serial-led/Makefile
new file mode 100644
index 0000000..a039111
--- /dev/null
+++ b/serial-led/Makefile
@@ -0,0 +1,33 @@
+##
+## spreadspace stm8 utils
+##
+##
+## Copyright (C) 2017 Christian Pointner <equinox@spreadspace.org>
+##
+## This file is part of spreadspace stm8 utils.
+##
+## spreadspace stm8 utils 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, either version 3 of the License, or
+## any later version.
+##
+## spreadspace stm8 utils 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 spreadspace stm8 utils. If not, see <http://www.gnu.org/licenses/>.
+##
+
+NAME := serial-led
+BOARD_TYPE := discovery
+OBJ := $(NAME).rel
+LIBS := util led serialio
+EXTERNAL_LIBS := spl
+SPREADSTM8_PATH := ..
+
+SPL_PATH := $(SPREADSTM8_PATH)/contrib/STM8S_StdPeriph_Lib
+#SPL_COMPONENTS := clk uart2
+
+include $(SPREADSTM8_PATH)/include.mk
diff --git a/serial-led/serial-led.c b/serial-led/serial-led.c
new file mode 100644
index 0000000..0516de3
--- /dev/null
+++ b/serial-led/serial-led.c
@@ -0,0 +1,58 @@
+/*
+ * spreadspace stm8 utils
+ *
+ *
+ * Copyright (C) 2017 Christian Pointner <equinox@spreadspace.org>
+ *
+ * This file is part of spreadspace stm8 utils.
+ *
+ * spreadspace stm8 utils 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, either version 3 of the License, or
+ * any later version.
+ *
+ * spreadspace stm8 utils 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 spreadspace stm8 utils. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stm8s.h>
+#include <stdio.h>
+
+#include "util.h"
+#include "led.h"
+#include "serialio.h"
+
+void handle_cmd(uint8_t cmd)
+{
+ switch(cmd) {
+ case '0': led_off(); break;
+ case '1': led_on(); break;
+ case 't': led_toggle(); break;
+ default: printf("error\r\n"); return;
+ }
+ printf("ok\r\n");
+}
+
+int main(void)
+{
+ cpu_init();
+ swim_disable();
+ led_init();
+ serialio_init(115200);
+
+ led_off();
+ for(;;) {
+ uint8_t BytesReceived = serialio_bytes_received();
+ while(BytesReceived > 0) {
+ char ReceivedByte = getchar();
+ handle_cmd(ReceivedByte);
+ BytesReceived--;
+ }
+ serialio_task();
+ }
+}
diff --git a/serial-led/stm8s_conf.h b/serial-led/stm8s_conf.h
new file mode 100644
index 0000000..590fe45
--- /dev/null
+++ b/serial-led/stm8s_conf.h
@@ -0,0 +1,116 @@
+/**
+ ******************************************************************************
+ * @file stm8s_conf.h
+ * @author MCD Application Team
+ * @version V2.2.0
+ * @date 30-September-2014
+ * @brief This file is used to configure the Library.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM8S_CONF_H
+#define __STM8S_CONF_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm8s.h"
+
+/* Uncomment the line below to enable peripheral header file inclusion */
+#if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) ||\
+ defined(STM8S903) || defined (STM8AF626x) || defined (STM8AF622x)
+#include "stm8s_adc1.h"
+#endif /* (STM8S105) ||(STM8S103) || (STM8S903) || (STM8AF626x) || (STM8AF622x) */
+#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\
+ defined (STM8AF62Ax)
+ #include "stm8s_adc2.h"
+#endif /* (STM8S208) || (STM8S207) || (STM8AF62Ax) || (STM8AF52Ax) */
+#include "stm8s_awu.h"
+#include "stm8s_beep.h"
+#if defined (STM8S208) || defined (STM8AF52Ax)
+ #include "stm8s_can.h"
+#endif /* (STM8S208) || (STM8AF52Ax) */
+#include "stm8s_clk.h"
+#include "stm8s_exti.h"
+#include "stm8s_flash.h"
+#include "stm8s_gpio.h"
+#include "stm8s_i2c.h"
+#include "stm8s_itc.h"
+#include "stm8s_iwdg.h"
+#include "stm8s_rst.h"
+#include "stm8s_spi.h"
+#include "stm8s_tim1.h"
+#if !defined(STM8S903) || !defined(STM8AF622x)
+ #include "stm8s_tim2.h"
+#endif /* (STM8S903) || (STM8AF622x) */
+#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) ||\
+ defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x)
+ #include "stm8s_tim3.h"
+#endif /* (STM8S208) ||defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) */
+#if !defined(STM8S903) || !defined(STM8AF622x)
+ #include "stm8s_tim4.h"
+#endif /* (STM8S903) || (STM8AF622x) */
+#if defined(STM8S903) || defined(STM8AF622x)
+ #include "stm8s_tim5.h"
+ #include "stm8s_tim6.h"
+#endif /* (STM8S903) || (STM8AF622x) */
+#if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) ||defined(STM8S103) ||\
+ defined(STM8S003) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
+ #include "stm8s_uart1.h"
+#endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S903) || (STM8AF52Ax) || (STM8AF62Ax) */
+#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
+ #include "stm8s_uart2.h"
+#endif /* (STM8S105) || (STM8AF626x) */
+#if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\
+ defined (STM8AF62Ax)
+ #include "stm8s_uart3.h"
+#endif /* STM8S208 || STM8S207 || STM8AF52Ax || STM8AF62Ax */
+#if defined(STM8AF622x)
+ #include "stm8s_uart4.h"
+#endif /* (STM8AF622x) */
+#include "stm8s_wwdg.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Uncomment the line below to expanse the "assert_param" macro in the
+ Standard Peripheral Library drivers code */
+/* #define USE_FULL_ASSERT (1) */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval : None
+ */
+#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+void assert_failed(uint8_t* file, uint32_t line);
+#else
+#define assert_param(expr) ((void)0)
+#endif /* USE_FULL_ASSERT */
+
+#endif /* __STM8S_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/serial-led/stm8s_it.h b/serial-led/stm8s_it.h
new file mode 100644
index 0000000..c5779ec
--- /dev/null
+++ b/serial-led/stm8s_it.h
@@ -0,0 +1,122 @@
+/**
+ ******************************************************************************
+ * @file stm8s_it.h
+ * @author MCD Application Team
+ * @version V2.2.0
+ * @date 30-September-2014
+ * @brief This file contains the headers of the interrupt handlers
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM8S_IT_H
+#define __STM8S_IT_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm8s.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+#ifdef _COSMIC_
+ void _stext(void); /* RESET startup routine */
+ INTERRUPT void NonHandledInterrupt(void);
+#endif /* _COSMIC_ */
+
+#if !defined(_RAISONANCE_) && !defined(_SDCC_) // SDCC patch: interrupt keyword required after function
+ INTERRUPT void TRAP_IRQHandler(void); /* TRAP */
+ INTERRUPT void TLI_IRQHandler(void); /* TLI */
+ INTERRUPT void AWU_IRQHandler(void); /* AWU */
+ INTERRUPT void CLK_IRQHandler(void); /* CLOCK */
+ INTERRUPT void EXTI_PORTA_IRQHandler(void); /* EXTI PORTA */
+ INTERRUPT void EXTI_PORTB_IRQHandler(void); /* EXTI PORTB */
+ INTERRUPT void EXTI_PORTC_IRQHandler(void); /* EXTI PORTC */
+ INTERRUPT void EXTI_PORTD_IRQHandler(void); /* EXTI PORTD */
+ INTERRUPT void EXTI_PORTE_IRQHandler(void); /* EXTI PORTE */
+
+#if defined(STM8S903) || defined(STM8AF622x)
+ INTERRUPT void EXTI_PORTF_IRQHandler(void); /* EXTI PORTF */
+#endif /* (STM8S903) || (STM8AF622x) */
+
+#if defined (STM8S208) || defined (STM8AF52Ax)
+ INTERRUPT void CAN_RX_IRQHandler(void); /* CAN RX */
+ INTERRUPT void CAN_TX_IRQHandler(void); /* CAN TX/ER/SC */
+#endif /* (STM8S208) || (STM8AF52Ax) */
+
+ INTERRUPT void SPI_IRQHandler(void); /* SPI */
+ INTERRUPT void TIM1_CAP_COM_IRQHandler(void); /* TIM1 CAP/COM */
+ INTERRUPT void TIM1_UPD_OVF_TRG_BRK_IRQHandler(void); /* TIM1 UPD/OVF/TRG/BRK */
+
+#if defined(STM8S903) || defined(STM8AF622x)
+ INTERRUPT void TIM5_UPD_OVF_BRK_TRG_IRQHandler(void); /* TIM5 UPD/OVF/BRK/TRG */
+ INTERRUPT void TIM5_CAP_COM_IRQHandler(void); /* TIM5 CAP/COM */
+#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
+ INTERRUPT void TIM2_UPD_OVF_BRK_IRQHandler(void); /* TIM2 UPD/OVF/BRK */
+ INTERRUPT void TIM2_CAP_COM_IRQHandler(void); /* TIM2 CAP/COM */
+#endif /* (STM8S903) || (STM8AF622x) */
+
+#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
+ defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x)
+ INTERRUPT void TIM3_UPD_OVF_BRK_IRQHandler(void); /* TIM3 UPD/OVF/BRK */
+ INTERRUPT void TIM3_CAP_COM_IRQHandler(void); /* TIM3 CAP/COM */
+#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
+
+#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
+ defined(STM8S003) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903)
+ INTERRUPT void UART1_TX_IRQHandler(void); /* UART1 TX */
+ INTERRUPT void UART1_RX_IRQHandler(void); /* UART1 RX */
+#endif /* (STM8S208) || (STM8S207) || (STM8S903) || (STM8S103) || (STM8AF52Ax) || (STM8AF62Ax) */
+
+#if defined (STM8AF622x)
+ INTERRUPT void UART4_TX_IRQHandler(void); /* UART4 TX */
+ INTERRUPT void UART4_RX_IRQHandler(void); /* UART4 RX */
+#endif /* (STM8AF622x) */
+
+ INTERRUPT void I2C_IRQHandler(void); /* I2C */
+
+#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
+ INTERRUPT void UART2_RX_IRQHandler(void); /* UART2 RX */
+ INTERRUPT void UART2_TX_IRQHandler(void); /* UART2 TX */
+#endif /* (STM8S105) || (STM8AF626x) */
+
+#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
+ INTERRUPT void UART3_RX_IRQHandler(void); /* UART3 RX */
+ INTERRUPT void UART3_TX_IRQHandler(void); /* UART3 TX */
+#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
+
+#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
+ INTERRUPT void ADC2_IRQHandler(void); /* ADC2 */
+#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */
+ INTERRUPT void ADC1_IRQHandler(void); /* ADC1 */
+#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
+
+#if defined(STM8S903) || defined(STM8AF622x)
+ INTERRUPT void TIM6_UPD_OVF_TRG_IRQHandler(void); /* TIM6 UPD/OVF/TRG */
+#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */
+ INTERRUPT void TIM4_UPD_OVF_IRQHandler(void); /* TIM4 UPD/OVF */
+#endif /* (STM8S903) || (STM8AF622x) */
+ INTERRUPT void EEPROM_EEC_IRQHandler(void); /* EEPROM ECC CORRECTION */
+#endif /* _RAISONANCE_ */
+
+#endif /* __STM8S_IT_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/