Skip to content

Commit 3baa549

Browse files
committed
adopted the arduino serial module for use with the STM8S
1 parent 1ba53a8 commit 3baa549

6 files changed

Lines changed: 517 additions & 0 deletions

File tree

examples/uart-ringbuffer/Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
SDCC=sdcc
2+
SDLD=sdld
3+
OBJECT=uart
4+
OBJECTS=uart-ringbuffer.rel
5+
6+
LIBDIR=../../STM8S_StdPeriph_Driver/src
7+
#LIBFILES=$(LIBDIR)/stm8s_gpio.rel
8+
LIBFILES=$(LIBDIR)/stm8s.lib
9+
10+
CFLAGS=-DSTM8S103 -I. -I../../STM8S_StdPeriph_Driver/inc
11+
12+
13+
.PHONY: all clean flash
14+
15+
all: $(OBJECT).ihx
16+
17+
clean:
18+
rm -f *.asm *.ihx *.rel *.sym *.map *.cdb *.lk *.lst *.rst *~
19+
20+
flash: $(OBJECT).ihx
21+
stm8flash -cstlinkv2 -pstm8s103?3 -w $(OBJECT).ihx
22+
23+
$(OBJECT).ihx: $(OBJECTS) $(LIBFILES)
24+
$(SDCC) -lstm8 -mstm8 --out-fmt-ihx $(LDFLAGS) $^ -o $@
25+
26+
%.rel: %.c
27+
$(SDCC) -lstm8 -mstm8 --out-fmt-ihx $(CFLAGS) $(LDFLAGS) -c $<

examples/uart-ringbuffer/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# uart-ringbuffer.c
2+
3+
Adopted HardwareSerial.cpp from arduino-1.0 for use with the STM8S and SDCC
4+
using SPL functions.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/**
2+
******************************************************************************
3+
* @file stm8s_conf.h
4+
* @author MCD Application Team
5+
* @version V2.2.0
6+
* @date 30-September-2014
7+
* @brief This file is used to configure the Library.
8+
******************************************************************************
9+
* @attention
10+
*
11+
* <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
12+
*
13+
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14+
* You may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at:
16+
*
17+
* http://www.st.com/software_license_agreement_liberty_v2
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*
25+
******************************************************************************
26+
*/
27+
28+
/* Define to prevent recursive inclusion -------------------------------------*/
29+
#ifndef __STM8S_CONF_H
30+
#define __STM8S_CONF_H
31+
32+
/* Includes ------------------------------------------------------------------*/
33+
#include "stm8s.h"
34+
35+
/* Uncomment the line below to enable peripheral header file inclusion */
36+
#if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) ||\
37+
defined(STM8S903) || defined (STM8AF626x) || defined (STM8AF622x)
38+
#include "stm8s_adc1.h"
39+
#endif /* (STM8S105) ||(STM8S103) || (STM8S903) || (STM8AF626x) || (STM8AF622x) */
40+
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\
41+
defined (STM8AF62Ax)
42+
#include "stm8s_adc2.h"
43+
#endif /* (STM8S208) || (STM8S207) || (STM8AF62Ax) || (STM8AF52Ax) */
44+
#include "stm8s_awu.h"
45+
#include "stm8s_beep.h"
46+
#if defined (STM8S208) || defined (STM8AF52Ax)
47+
#include "stm8s_can.h"
48+
#endif /* (STM8S208) || (STM8AF52Ax) */
49+
#include "stm8s_clk.h"
50+
#include "stm8s_exti.h"
51+
#include "stm8s_flash.h"
52+
#include "stm8s_gpio.h"
53+
#include "stm8s_i2c.h"
54+
#include "stm8s_itc.h"
55+
#include "stm8s_iwdg.h"
56+
#include "stm8s_rst.h"
57+
#include "stm8s_spi.h"
58+
#include "stm8s_tim1.h"
59+
#if !defined(STM8S903) || !defined(STM8AF622x)
60+
#include "stm8s_tim2.h"
61+
#endif /* (STM8S903) || (STM8AF622x) */
62+
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) ||\
63+
defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x)
64+
#include "stm8s_tim3.h"
65+
#endif /* (STM8S208) ||defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) */
66+
#if !defined(STM8S903) || !defined(STM8AF622x)
67+
#include "stm8s_tim4.h"
68+
#endif /* (STM8S903) || (STM8AF622x) */
69+
#if defined(STM8S903) || defined(STM8AF622x)
70+
#include "stm8s_tim5.h"
71+
#include "stm8s_tim6.h"
72+
#endif /* (STM8S903) || (STM8AF622x) */
73+
#if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) ||defined(STM8S103) ||\
74+
defined(STM8S003) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
75+
#include "stm8s_uart1.h"
76+
#endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S903) || (STM8AF52Ax) || (STM8AF62Ax) */
77+
#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
78+
#include "stm8s_uart2.h"
79+
#endif /* (STM8S105) || (STM8AF626x) */
80+
#if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\
81+
defined (STM8AF62Ax)
82+
#include "stm8s_uart3.h"
83+
#endif /* STM8S208 || STM8S207 || STM8AF52Ax || STM8AF62Ax */
84+
#if defined(STM8AF622x)
85+
#include "stm8s_uart4.h"
86+
#endif /* (STM8AF622x) */
87+
#include "stm8s_wwdg.h"
88+
89+
/* Exported types ------------------------------------------------------------*/
90+
/* Exported constants --------------------------------------------------------*/
91+
/* Uncomment the line below to expanse the "assert_param" macro in the
92+
Standard Peripheral Library drivers code */
93+
//#define USE_FULL_ASSERT (1)
94+
95+
/* Exported macro ------------------------------------------------------------*/
96+
#ifdef USE_FULL_ASSERT
97+
98+
/**
99+
* @brief The assert_param macro is used for function's parameters check.
100+
* @param expr: If expr is false, it calls assert_failed function
101+
* which reports the name of the source file and the source
102+
* line number of the call that failed.
103+
* If expr is true, it returns no value.
104+
* @retval : None
105+
*/
106+
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
107+
/* Exported functions ------------------------------------------------------- */
108+
void assert_failed(uint8_t* file, uint32_t line);
109+
#else
110+
#define assert_param(expr) ((void)0)
111+
#endif /* USE_FULL_ASSERT */
112+
113+
#endif /* __STM8S_CONF_H */
114+
115+
116+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/**
2+
******************************************************************************
3+
* @file stm8s_it.h
4+
* @author MCD Application Team
5+
* @version V2.2.0
6+
* @date 30-September-2014
7+
* @brief This file contains the headers of the interrupt handlers
8+
******************************************************************************
9+
* @attention
10+
*
11+
* <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
12+
*
13+
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14+
* You may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at:
16+
*
17+
* http://www.st.com/software_license_agreement_liberty_v2
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*
25+
******************************************************************************
26+
*/
27+
28+
/* Define to prevent recursive inclusion -------------------------------------*/
29+
#ifndef __STM8S_IT_H
30+
#define __STM8S_IT_H
31+
32+
/* Includes ------------------------------------------------------------------*/
33+
#include "stm8s.h"
34+
35+
/* Exported types ------------------------------------------------------------*/
36+
/* Exported constants --------------------------------------------------------*/
37+
/* Exported macro ------------------------------------------------------------*/
38+
/* Exported functions ------------------------------------------------------- */
39+
#ifdef _COSMIC_
40+
void _stext(void); /* RESET startup routine */
41+
INTERRUPT void NonHandledInterrupt(void);
42+
#endif /* _COSMIC_ */
43+
44+
#if !defined(_RAISONANCE_) && !defined(_SDCC_) // SDCC patch: interrupt keyword required after function
45+
INTERRUPT void TRAP_IRQHandler(void); /* TRAP */
46+
INTERRUPT void TLI_IRQHandler(void); /* TLI */
47+
INTERRUPT void AWU_IRQHandler(void); /* AWU */
48+
INTERRUPT void CLK_IRQHandler(void); /* CLOCK */
49+
INTERRUPT void EXTI_PORTA_IRQHandler(void); /* EXTI PORTA */
50+
INTERRUPT void EXTI_PORTB_IRQHandler(void); /* EXTI PORTB */
51+
INTERRUPT void EXTI_PORTC_IRQHandler(void); /* EXTI PORTC */
52+
INTERRUPT void EXTI_PORTD_IRQHandler(void); /* EXTI PORTD */
53+
INTERRUPT void EXTI_PORTE_IRQHandler(void); /* EXTI PORTE */
54+
55+
#if defined(STM8S903) || defined(STM8AF622x)
56+
INTERRUPT void EXTI_PORTF_IRQHandler(void); /* EXTI PORTF */
57+
#endif /* (STM8S903) || (STM8AF622x) */
58+
59+
#if defined (STM8S208) || defined (STM8AF52Ax)
60+
INTERRUPT void CAN_RX_IRQHandler(void); /* CAN RX */
61+
INTERRUPT void CAN_TX_IRQHandler(void); /* CAN TX/ER/SC */
62+
#endif /* (STM8S208) || (STM8AF52Ax) */
63+
64+
INTERRUPT void SPI_IRQHandler(void); /* SPI */
65+
INTERRUPT void TIM1_CAP_COM_IRQHandler(void); /* TIM1 CAP/COM */
66+
INTERRUPT void TIM1_UPD_OVF_TRG_BRK_IRQHandler(void); /* TIM1 UPD/OVF/TRG/BRK */
67+
68+
#if defined(STM8S903) || defined(STM8AF622x)
69+
INTERRUPT void TIM5_UPD_OVF_BRK_TRG_IRQHandler(void); /* TIM5 UPD/OVF/BRK/TRG */
70+
INTERRUPT void TIM5_CAP_COM_IRQHandler(void); /* TIM5 CAP/COM */
71+
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
72+
INTERRUPT void TIM2_UPD_OVF_BRK_IRQHandler(void); /* TIM2 UPD/OVF/BRK */
73+
INTERRUPT void TIM2_CAP_COM_IRQHandler(void); /* TIM2 CAP/COM */
74+
#endif /* (STM8S903) || (STM8AF622x) */
75+
76+
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
77+
defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x)
78+
INTERRUPT void TIM3_UPD_OVF_BRK_IRQHandler(void); /* TIM3 UPD/OVF/BRK */
79+
INTERRUPT void TIM3_CAP_COM_IRQHandler(void); /* TIM3 CAP/COM */
80+
#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
81+
82+
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
83+
defined(STM8S003) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903)
84+
INTERRUPT void UART1_TX_IRQHandler(void); /* UART1 TX */
85+
INTERRUPT void UART1_RX_IRQHandler(void); /* UART1 RX */
86+
#endif /* (STM8S208) || (STM8S207) || (STM8S903) || (STM8S103) || (STM8AF52Ax) || (STM8AF62Ax) */
87+
88+
#if defined (STM8AF622x)
89+
INTERRUPT void UART4_TX_IRQHandler(void); /* UART4 TX */
90+
INTERRUPT void UART4_RX_IRQHandler(void); /* UART4 RX */
91+
#endif /* (STM8AF622x) */
92+
93+
INTERRUPT void I2C_IRQHandler(void); /* I2C */
94+
95+
#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
96+
INTERRUPT void UART2_RX_IRQHandler(void); /* UART2 RX */
97+
INTERRUPT void UART2_TX_IRQHandler(void); /* UART2 TX */
98+
#endif /* (STM8S105) || (STM8AF626x) */
99+
100+
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
101+
INTERRUPT void UART3_RX_IRQHandler(void); /* UART3 RX */
102+
INTERRUPT void UART3_TX_IRQHandler(void); /* UART3 TX */
103+
#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
104+
105+
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
106+
INTERRUPT void ADC2_IRQHandler(void); /* ADC2 */
107+
#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */
108+
INTERRUPT void ADC1_IRQHandler(void); /* ADC1 */
109+
#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
110+
111+
#if defined(STM8S903) || defined(STM8AF622x)
112+
INTERRUPT void TIM6_UPD_OVF_TRG_IRQHandler(void); /* TIM6 UPD/OVF/TRG */
113+
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */
114+
INTERRUPT void TIM4_UPD_OVF_IRQHandler(void); /* TIM4 UPD/OVF */
115+
#endif /* (STM8S903) || (STM8AF622x) */
116+
INTERRUPT void EEPROM_EEC_IRQHandler(void); /* EEPROM ECC CORRECTION */
117+
#endif /* _RAISONANCE_ */
118+
119+
#endif /* __STM8S_IT_H */
120+
121+
122+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

0 commit comments

Comments
 (0)