Initial Commit

This commit is contained in:
2024-06-12 23:21:05 +02:00
commit e00cc65941
22 changed files with 5772 additions and 0 deletions

2382
.gdbinit Normal file

File diff suppressed because it is too large Load Diff

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.cache/
.clangd
.pio/
compile_commands.json

84
README.md Normal file
View File

@@ -0,0 +1,84 @@
Commands to initialize:
To run every time you create a new file to update the compile\_commands.json:
pio run -t compiledb
Command to generate/override a .clangd and write the symlink in the toolchain folder
pio run -t clangd
Command to build the firmware without uploading
pio run -t buildprog
Command to build the firmware and upload it
pio run -t upload
If in the buildprog/upload you use the verbose like:
pio run -t upload -v
The system will tell you the exact size of the ELF sections.
Commadn to open the serial monitor
pio device monitor
Command extremely powerful to obtain the size of every symbol inside a firmware.elf:
```bash
objdump -t .pio/build/stm8sblue/firmware.elf | sort | uniq | awk '
/^[0-9a-f]+ / {
if (prev_addr != "") {
sizes[prev_symbol] = strtonum("0x"$1) - prev_addr;
}
prev_addr = strtonum("0x"$1);
prev_symbol = $NF;
addresses[NR] = prev_addr;
symbols[NR] = prev_symbol;
count++;
}
END {
for (i = 1; i <= count; i++) {
if (i == count) {
sizes[symbols[i]] = 0; # Size of the last symbol is unknown, set to 0
}
printf "Address: 0x%08x Symbol: %s Size: %d\n", addresses[i], symbols[i], sizes[symbols[i]];
}
}'
```
Acconsenti al caricamento del .gdbinit in GDB mettendo nel tuo ~/.gdbinit:
```
add-auto-load-safe-path /PROJECT_DIR_ABSOLUTE_PATH/.gdbinit
```
Librerie richieste da stm8-gdb
paru -S python2-bin
sudo ln -s /usr/lib/libmpfr.so /usr/lib/libmpfr.so.4
Per lanciare il debugger:
Assicurati di avere un firmware compilato con i debug symbols. Per crearlo fai:
pio debug
Apri poi un terminale e fai
pio pkg exec openocd -- -f interface/stlink-dap.cfg -f target/stm8s103.cfg -c "init" -c "reset halt"
Poi in un altro
pio pkg exec stm8-gdb -- .pio/build/stm8sblue/firmware.elf
Note:
Nel caso serva flashare a mano:
~/git/stm8flash/stm8flash -c stlinkv3 -p stm8s103f3 -s flash -w .pio/build/stm8sblue/firmware.hex
Risulta che nonostante la parte di sviluppo sia compensabile easy con Platformio, esistono dei problemi che sono difficili da sistemare.
I problemi sono:
- Su Windows stm8flash e' troppo vecchio e non funziona correttamente
- Durante il Debug, OpenOCD non si apre propriamente in background, non ho idea di come deubggare la cosa...
- L'OpenOCD shippato potrebbe essere troppo vecchio per STLink-V3
- stm8gdb shippato e' buildato senza il supporto alla TUI rendendo il debugging estremamente macchinoso senza VSCode
- VSCode e' impossibile da configurare propriamente per ignorare le peculiarita di SDCC toolchain, dato che non ho trovato modo di aggiungere build flag al solo c/cpp json config senza che esse venissero usate effettivamente per il build. L'approccio su VSCode richiede env separati per sviluppo e compilazione nel platformio.ini, cosa estremamente scomoda e prona a errori
Attualmente l'assetto con Clangd e vim sembra ottimo, quindi VSCode non e' un opzione.
L'unica alternativa che ho in mente e' utilizzare una versione aggiornata di:
- stm8flash (su Windows)
- openocd (per STLink-V3)
- stm8binutils (per avere TUI GDB!)
Gli altri possiamo lasciarli cosi come sono... per ora.
Qual e' il modo migliore? Generalmente openocd (e sdcc) sono comuni sulle repo dei sistemi operativi, gli unici magagni sono stm8flash e stm8binutils che van sicuramente compilati.
Su Linux per un environment base l'unica necessita e' avere stm8binutils compilato con le flag giuste.
stm8binutils sembra INCOMPILABILE...

61
extra_script.py Normal file
View File

@@ -0,0 +1,61 @@
Import("env")
def gen_clangd(target, source, env):
_ = target
_ = source
from subprocess import run
import shlex
from pathlib import Path
SDCC = run(shlex.split("which sdcc"), capture_output=True).stdout.decode().strip()
# SDCC = '/home/fpasqua/.platformio/packages/toolchain-sdcc/bin/sdcc'
p = Path(SDCC).parent.parent # toolchain root
SDCC_INCLUDE = p / 'share' / 'sdcc' / 'include'
# SDCC_INCLUDE = '/home/fpasqua/.platformio/packages/toolchain-sdcc/share/sdcc/include/'
GETDEFINEFLAGS = '-E -dM -mstm8 -x c /dev/null'
res = run([SDCC] + shlex.split(GETDEFINEFLAGS), capture_output=True)
res.check_returncode()
defines_raw = res.stdout.decode().strip().split('\n')
defines = [d.replace('#define ', '-D').replace(' ', '=') for d in defines_raw]
sdcc_defines = ", ".join(defines)
sdccext_defines = ", ".join(['-D__trap=', '-D__interrupt(x)='])
SUPPRESSED = [
"clang-diagnostic-main-return-type",
"clang-diagnostic-empty-body",
"pp_including_mainfile_in_preamble",
]
with open('.clangd', 'w') as f:
f.writelines([
'CompileFlags:\n',
f' Add: [-I{SDCC_INCLUDE}, {sdcc_defines}, {sdccext_defines}]\n'
' Remove: [--opt-code-size, -mstm8]\n',
'Index:\n',
' StandardLibrary: No\n',
'Diagnostics:\n',
' Suppress:\n',
*[f' - "{s}"\n' for s in SUPPRESSED],
' UnusedIncludes: None\n',
])
print("Project .clangd created")
o = run(shlex.split(f'ln -s -f {env["PROJECT_DIR"]}/.clangd .clangd'), cwd=p)
o.check_returncode()
print(f"Symlink to toolchain {p / '.clangd'} done.")
# include toolchain paths
env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True)
# custom .clangd initialization
env.AddCustomTarget(
name='clangd',
dependencies=None,
actions=gen_clangd,
title='Gen .clangd',
description='Generate required files for clangd to work properly.',
always_build=True,
)
# TODO: add target to load the .clangd in the sdcc toolchain too

39
include/README Normal file
View File

@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

46
lib/README Normal file
View File

@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

123
oldblink/main.c Normal file
View File

@@ -0,0 +1,123 @@
/**
******************************************************************************
* @file GPIO_Toggle\main.c
* @author MCD Application Team
* @version V2.0.4
* @date 26-April-2018
* @brief This file contains the main function for GPIO Toggle example.
******************************************************************************
* @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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8s.h"
#include "stm8s_it.h" /* SDCC patch: required by SDCC for interrupts */
/**
* @addtogroup GPIO_Toggle
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Evalboard I/Os configuration */
/* automatically use built-in LED for known nucleo boards */
#if defined(STM8S_NUCLEO_208RB) || defined(STM8S_NUCLEO_207K8)
#define LED_GPIO_PORT (GPIOC)
#define LED_GPIO_PINS (GPIO_PIN_5)
#elif defined(STM8S103)
/* for STM8S103F3 breakout board. building with GPIOG would result in failure (chip
* does not have that GPIO peripheral) */
#define LED_GPIO_PORT (GPIOB)
#define LED_GPIO_PINS (GPIO_PIN_5)
#else
#define LED_GPIO_PORT (GPIOG)
#define LED_GPIO_PINS (GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0)
#endif
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
void Delay (uint16_t nCount);
/* Private functions ---------------------------------------------------------*/
/* Public functions ----------------------------------------------------------*/
/**
* @brief Main program.
* @param None
* @retval None
*/
void main(void)
{
/* Initialize I/Os in Output Mode */
GPIO_Init(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS, GPIO_MODE_OUT_PP_LOW_FAST);
while (1)
{
/* Toggles LEDs */
GPIO_WriteReverse(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS);
Delay(0xFFFF);
}
}
/**
* @brief Delay
* @param nCount
* @retval None
*/
void Delay(uint16_t nCount)
{
/* Decrement nCount value */
while (nCount != 0)
{
nCount--;
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

118
oldblink/stm8s_conf.h Normal file
View File

@@ -0,0 +1,118 @@
/**
******************************************************************************
* @file stm8s_conf.h
* @author MCD Application Team
* @version V2.0.4
* @date 26-April-2018
* @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.
*
******************************************************************************
*/
/* SDCC patch: include "STM8AF622x" defined in "STM8S_StdPeriph_Tempate" */
/* 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(STM8S001) || defined(STM8S903) || defined (STM8AF626x) || defined (STM8AF622x)
//#include "stm8s_adc1.h"
#endif /* (STM8S105) ||(STM8S103) || (STM8S001) || (STM8S903) || (STM8AF626x) */
#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) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #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) || (STM8S207) || (STM8S007) || (STM8S105) */
#if !defined(STM8S903) && !defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #include "stm8s_tim4.h"
#endif /* (STM8S903) || (STM8AF622x) */
#if defined(STM8S903) || defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #include "stm8s_tim5.h"
// #include "stm8s_tim6.h"
#endif /* (STM8S903) || (STM8AF622x) */
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) ||\
defined(STM8S003) || defined(STM8S001) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
// #include "stm8s_uart1.h"
#endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S001) || (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) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #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****/

482
oldblink/stm8s_it.c Normal file
View File

@@ -0,0 +1,482 @@
/**
******************************************************************************
* @file stm8s_it.c
* @author MCD Application Team
* @version V2.0.4
* @date 26-April-2018
* @brief Main Interrupt Service Routines.
******************************************************************************
* @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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8s_it.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* Public functions ----------------------------------------------------------*/
/** @addtogroup GPIO_Toggle
* @{
*/
#ifdef _COSMIC_
/**
* @brief Dummy interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(NonHandledInterrupt, 25)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*_COSMIC_*/
/**
* @brief TRAP interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Top Level Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TLI_IRQHandler, 0)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Auto Wake Up Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(AWU_IRQHandler, 1)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Clock Controller Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CLK_IRQHandler, 2)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTA Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTB Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTC Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTD Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTE Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#ifdef STM8S903
/**
* @brief External Interrupt PORTF Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S903*/
#if defined (STM8S208) || defined (STM8AF52Ax)
/**
* @brief CAN RX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief CAN TX Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S208 || STM8AF52Ax */
/**
* @brief SPI Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(SPI_IRQHandler, 10)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer1 Update/Overflow/Trigger/Break Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer1 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#ifdef STM8S903
/**
* @brief Timer5 Update/Overflow/Break/Trigger Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer5 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
/**
* @brief Timer2 Update/Overflow/Break Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer2 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S903*/
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
defined(STM8S005) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8AF626x)
/**
* @brief Timer3 Update/Overflow/Break Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer3 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
defined(STM8S003) || defined(STM8S001) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8S903)
/**
* @brief UART1 TX Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART1 RX Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S105 || STM8S001 */
/**
* @brief I2C Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(I2C_IRQHandler, 19)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
/**
* @brief UART2 TX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART2 RX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* STM8S105*/
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
/**
* @brief UART3 TX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART3 RX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
/**
* @brief ADC2 interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(ADC2_IRQHandler, 22)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
return;
}
#else /*STM8S105, STM8S103 or STM8S903 or STM8AF626x */
/**
* @brief ADC1 interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(ADC1_IRQHandler, 22)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
return;
}
#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */
#ifdef STM8S903
/**
* @brief Timer6 Update/Overflow/Trigger Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
/**
* @brief Timer4 Update/Overflow Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S903*/
/**
* @brief Eeprom EEC Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

201
oldblink/stm8s_it.h Normal file
View File

@@ -0,0 +1,201 @@
/**
******************************************************************************
* @file stm8s_it.h
* @author MCD Application Team
* @version V2.0.4
* @date 26-April-2018
* @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_ */
// SDCC patch: requires separate handling for SDCC (see below)
#if !defined(_RAISONANCE_) && !defined(_SDCC_)
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) // SDCC patch: add 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) // SDCC patch: add 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) || (STM8S001) || (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(STM8S001) || 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) || (STM8S007) || (STM8S103) || (STM8S003) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8S903) */
#if defined (STM8AF622x) // SDCC patch: add 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) || (STM8S005) || (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) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */
#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) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */
#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x
INTERRUPT void TIM6_UPD_OVF_TRG_IRQHandler(void); /* TIM6 UPD/OVF/TRG */
#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
INTERRUPT void TIM4_UPD_OVF_IRQHandler(void); /* TIM4 UPD/OVF */
#endif /* (STM8S903) || (STM8AF622x) */
INTERRUPT void EEPROM_EEC_IRQHandler(void); /* EEPROM ECC CORRECTION */
// SDCC patch: __interrupt keyword required after function name --> requires new block
#elif defined (_SDCC_)
INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler); /* TRAP */
INTERRUPT_HANDLER(TLI_IRQHandler, 0); /* TLI */
INTERRUPT_HANDLER(AWU_IRQHandler, 1); /* AWU */
INTERRUPT_HANDLER(CLK_IRQHandler, 2); /* CLOCK */
INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3); /* EXTI PORTA */
INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4); /* EXTI PORTB */
INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5); /* EXTI PORTC */
INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6); /* EXTI PORTD */
INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7); /* EXTI PORTE */
#if defined(STM8S903) || defined(STM8AF622x)
INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8); /* EXTI PORTF */
#endif /* (STM8S903) || (STM8AF622x) */
#if defined (STM8S208) || defined (STM8AF52Ax)
INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8); /* CAN RX */
INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9); /* CAN TX/ER/SC */
#endif /* (STM8S208) || (STM8AF52Ax) */
INTERRUPT_HANDLER(SPI_IRQHandler, 10); /* SPI */
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); /* TIM1 UPD/OVF/TRG/BRK */
INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12); /* TIM1 CAP/COM */
#if defined(STM8S903) || defined(STM8AF622x)
INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); /* TIM5 UPD/OVF/BRK/TRG */
INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14); /* TIM5 CAP/COM */
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13); /* TIM2 UPD/OVF/BRK */
INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14); /* TIM2 CAP/COM */
#endif /* (STM8S903) || (STM8AF622x) */
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x)
INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15); /* TIM3 UPD/OVF/BRK */
INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16); /* TIM3 CAP/COM */
#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
defined(STM8S003) || defined(STM8S001) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903)
INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17); /* UART1 TX */
INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18); /* UART1 RX */
#endif /* (STM8S208) || (STM8S207) || (STM8S903) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) */
#if defined (STM8AF622x)
INTERRUPT_HANDLER(UART4_TX_IRQHandler, 17); /* UART4 TX */
INTERRUPT_HANDLER(UART4_RX_IRQHandler, 18); /* UART4 RX */
#endif /* (STM8AF622x) */
INTERRUPT_HANDLER(I2C_IRQHandler, 19); /* I2C */
#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20); /* UART2 TX */
INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21); /* UART2 RX */
#endif /* (STM8S105) || (STM8AF626x) */
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
INTERRUPT_HANDLER(UART3_RX_IRQHandler, 20); /* UART3 RX */
INTERRUPT_HANDLER(UART3_TX_IRQHandler, 21); /* UART3 TX */
#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
INTERRUPT_HANDLER(ADC2_IRQHandler, 22); /* ADC2 */
#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */
INTERRUPT_HANDLER(ADC1_IRQHandler, 22); /* ADC1 */
#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
#if defined(STM8S903) || defined(STM8AF622x)
INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23); /* TIM6 UPD/OVF/TRG */
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */
INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23); /* TIM4 UPD/OVF */
#endif /* (STM8S903) || (STM8AF622x) */
INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24); /* EEPROM ECC CORRECTION */
#endif /* !(_RAISONANCE_) && !(_SDCC_) */
#endif /* __STM8S_IT_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

129
oldtest/main.c Normal file
View File

@@ -0,0 +1,129 @@
#include "main.h"
//#include "stdio.h"
uint32_t ms_passed = 0;
PUTCHAR_PROTOTYPE;
void puts(const char *s) {
const char* p = s;
while (*p != '\0') putchar(*p++);
}
void main(void)
{
/*High speed internal clock prescaler: 1*/
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
UART1_DeInit();
/* UART1 configuration ------------------------------------------------------*/
/* UART1 configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Receive and transmit enabled
- UART1 Clock disabled
*/
UART1_Init((uint32_t)115200, UART1_WORDLENGTH_8D, UART1_STOPBITS_1, UART1_PARITY_NO,
UART1_SYNCMODE_CLOCK_DISABLE, UART1_MODE_TXRX_ENABLE);
puts("Demotest\n\r");
// uint8_t *uniqueid = (uint8_t*)0x4865;
// puts("\n\rUnique ID: ");
// for (int i = 0; i < 12; i++) {
// if(i > 0) printf(":");
// printf("%02X", uniqueid[i]);
// }
// puts("\n\r");
/* Initialize Interrupt*/
GPIO_Init(GPIOB, GPIO_PIN_4, GPIO_MODE_IN_PU_IT);
EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOB, EXTI_SENSITIVITY_FALL_ONLY);
EXTI_SetTLISensitivity(EXTI_TLISENSITIVITY_FALL_ONLY);
enableInterrupts();
/* Initialize I/Os in Output Mode */
GPIO_Init(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS, GPIO_MODE_OUT_PP_LOW_FAST);
/* Show the system is working properly */
GPIO_WriteHigh(LED_GPIO_PORT, LED_GPIO_PINS);
delay_ms(200);
GPIO_WriteLow(LED_GPIO_PORT, LED_GPIO_PINS);
delay_ms(100);
GPIO_WriteHigh(LED_GPIO_PORT, LED_GPIO_PINS);
delay_ms(200);
GPIO_WriteLow(LED_GPIO_PORT, LED_GPIO_PINS);
delay_ms(100);
GPIO_WriteHigh(LED_GPIO_PORT, LED_GPIO_PINS);
delay_ms(200);
GPIO_WriteLow(LED_GPIO_PORT, LED_GPIO_PINS);
while (1) {
/* Toggles LEDs */
delay_ms(10);
ms_passed += 10;
if(ms_passed % 1000 == 0) {
GPIO_WriteReverse(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS);
uint32_t ntick = ms_passed / 1000;
char x = ntick % 58 + 65;
putchar(8); //backspace
putchar(x);
}
}
}
/**
* @brief Retargets the C library printf function to the UART.
* @param c Character to send
* @retval char Character sent
*/
PUTCHAR_PROTOTYPE
{
/* Write a character to the UART1 */
UART1_SendData8(c);
/* Loop until the end of transmission */
while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET);
return (c);
}
/**
* @brief Retargets the C library scanf function to the USART.
* @param None
* @retval char Character to Read
*/
GETCHAR_PROTOTYPE
{
#ifdef _COSMIC_
char c = 0;
#else
int c = 0;
#endif
/* Loop until the Read data register flag is SET */
while (UART1_GetFlagStatus(UART1_FLAG_RXNE) == RESET);
c = UART1_ReceiveData8();
return (c);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif

50
oldtest/main.h Normal file
View File

@@ -0,0 +1,50 @@
#ifndef __MAIN_H
#define __MAIN_H
#include "stm8s.h"
#include "stm8s_it.h" /* SDCC patch: required by SDCC for interrupts */
/* automatically use built-in LED for known nucleo boards */
#if defined(STM8S_NUCLEO_208RB) || defined(STM8S_NUCLEO_207K8)
#define LED_GPIO_PORT (GPIOC)
#define LED_GPIO_PINS (GPIO_PIN_5)
#elif defined(STM8S103)
/* for STM8S103F3 breakout board. building with GPIOG would result in failure (chip
* does not have that GPIO peripheral) */
#define LED_GPIO_PORT (GPIOB)
#define LED_GPIO_PINS (GPIO_PIN_5)
#else
#define LED_GPIO_PORT (GPIOG)
#define LED_GPIO_PINS (GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0)
#endif
#ifdef _RAISONANCE_
#define PUTCHAR_PROTOTYPE int putchar (char c)
#define GETCHAR_PROTOTYPE int getchar (void)
#elif defined (_COSMIC_)
#define PUTCHAR_PROTOTYPE char putchar (char c)
#define GETCHAR_PROTOTYPE char getchar (void)
#else /* _IAR_ */
#define PUTCHAR_PROTOTYPE int putchar (int c)
#define GETCHAR_PROTOTYPE int getchar (void)
#endif /* _RAISONANCE_ */
#define US(us) ( F_CPU / 6000000.0 * us )
inline void delay_count (uint16_t nCount) {
/* Decrement nCount value */
while (nCount != 0)
{
nCount--;
}
}
inline void delay_ms(uint32_t ms) {
while (ms != 0) {
ms--;
delay_count(US(1000));
}
}
extern uint32_t ms_passed;
#endif

118
oldtest/stm8s_conf.h Normal file
View File

@@ -0,0 +1,118 @@
/**
******************************************************************************
* @file stm8s_conf.h
* @author MCD Application Team
* @version V2.0.4
* @date 26-April-2018
* @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.
*
******************************************************************************
*/
/* SDCC patch: include "STM8AF622x" defined in "STM8S_StdPeriph_Tempate" */
/* 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(STM8S001) || defined(STM8S903) || defined (STM8AF626x) || defined (STM8AF622x)
//#include "stm8s_adc1.h"
#endif /* (STM8S105) ||(STM8S103) || (STM8S001) || (STM8S903) || (STM8AF626x) */
#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) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #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) || (STM8S207) || (STM8S007) || (STM8S105) */
#if !defined(STM8S903) && !defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #include "stm8s_tim4.h"
#endif /* (STM8S903) || (STM8AF622x) */
#if defined(STM8S903) || defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #include "stm8s_tim5.h"
// #include "stm8s_tim6.h"
#endif /* (STM8S903) || (STM8AF622x) */
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) ||\
defined(STM8S003) || defined(STM8S001) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
#include "stm8s_uart1.h"
#endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S001) || (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) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #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****/

488
oldtest/stm8s_it.c Normal file
View File

@@ -0,0 +1,488 @@
/**
******************************************************************************
* @file stm8s_it.c
* @author MCD Application Team
* @version V2.0.4
* @date 26-April-2018
* @brief Main Interrupt Service Routines.
******************************************************************************
* @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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8s_it.h"
#include "main.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* Public functions ----------------------------------------------------------*/
/** @addtogroup GPIO_Toggle
* @{
*/
#ifdef _COSMIC_
/**
* @brief Dummy interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(NonHandledInterrupt, 25)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*_COSMIC_*/
/**
* @brief TRAP interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Top Level Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TLI_IRQHandler, 0)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Auto Wake Up Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(AWU_IRQHandler, 1)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Clock Controller Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CLK_IRQHandler, 2)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTA Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTB Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
ms_passed = 0;
// GPIO_WriteHigh(LED_GPIO_PORT, LED_GPIO_PINS);
// delay_ms(100);
// GPIO_WriteLow(LED_GPIO_PORT, LED_GPIO_PINS);
}
/**
* @brief External Interrupt PORTC Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTD Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTE Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#ifdef STM8S903
/**
* @brief External Interrupt PORTF Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S903*/
#if defined (STM8S208) || defined (STM8AF52Ax)
/**
* @brief CAN RX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief CAN TX Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S208 || STM8AF52Ax */
/**
* @brief SPI Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(SPI_IRQHandler, 10)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer1 Update/Overflow/Trigger/Break Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer1 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#ifdef STM8S903
/**
* @brief Timer5 Update/Overflow/Break/Trigger Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer5 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
/**
* @brief Timer2 Update/Overflow/Break Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer2 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S903*/
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
defined(STM8S005) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8AF626x)
/**
* @brief Timer3 Update/Overflow/Break Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer3 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
defined(STM8S003) || defined(STM8S001) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8S903)
/**
* @brief UART1 TX Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART1 RX Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S105 || STM8S001 */
/**
* @brief I2C Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(I2C_IRQHandler, 19)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
/**
* @brief UART2 TX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART2 RX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* STM8S105*/
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
/**
* @brief UART3 TX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART3 RX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
/**
* @brief ADC2 interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(ADC2_IRQHandler, 22)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
return;
}
#else /*STM8S105, STM8S103 or STM8S903 or STM8AF626x */
/**
* @brief ADC1 interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(ADC1_IRQHandler, 22)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
return;
}
#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */
#ifdef STM8S903
/**
* @brief Timer6 Update/Overflow/Trigger Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
/**
* @brief Timer4 Update/Overflow Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S903*/
/**
* @brief Eeprom EEC Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

201
oldtest/stm8s_it.h Normal file
View File

@@ -0,0 +1,201 @@
/**
******************************************************************************
* @file stm8s_it.h
* @author MCD Application Team
* @version V2.0.4
* @date 26-April-2018
* @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_ */
// SDCC patch: requires separate handling for SDCC (see below)
#if !defined(_RAISONANCE_) && !defined(_SDCC_)
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) // SDCC patch: add 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) // SDCC patch: add 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) || (STM8S001) || (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(STM8S001) || 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) || (STM8S007) || (STM8S103) || (STM8S003) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8S903) */
#if defined (STM8AF622x) // SDCC patch: add 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) || (STM8S005) || (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) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */
#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) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */
#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x
INTERRUPT void TIM6_UPD_OVF_TRG_IRQHandler(void); /* TIM6 UPD/OVF/TRG */
#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
INTERRUPT void TIM4_UPD_OVF_IRQHandler(void); /* TIM4 UPD/OVF */
#endif /* (STM8S903) || (STM8AF622x) */
INTERRUPT void EEPROM_EEC_IRQHandler(void); /* EEPROM ECC CORRECTION */
// SDCC patch: __interrupt keyword required after function name --> requires new block
#elif defined (_SDCC_)
INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler); /* TRAP */
INTERRUPT_HANDLER(TLI_IRQHandler, 0); /* TLI */
INTERRUPT_HANDLER(AWU_IRQHandler, 1); /* AWU */
INTERRUPT_HANDLER(CLK_IRQHandler, 2); /* CLOCK */
INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3); /* EXTI PORTA */
INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4); /* EXTI PORTB */
INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5); /* EXTI PORTC */
INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6); /* EXTI PORTD */
INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7); /* EXTI PORTE */
#if defined(STM8S903) || defined(STM8AF622x)
INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8); /* EXTI PORTF */
#endif /* (STM8S903) || (STM8AF622x) */
#if defined (STM8S208) || defined (STM8AF52Ax)
INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8); /* CAN RX */
INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9); /* CAN TX/ER/SC */
#endif /* (STM8S208) || (STM8AF52Ax) */
INTERRUPT_HANDLER(SPI_IRQHandler, 10); /* SPI */
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); /* TIM1 UPD/OVF/TRG/BRK */
INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12); /* TIM1 CAP/COM */
#if defined(STM8S903) || defined(STM8AF622x)
INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); /* TIM5 UPD/OVF/BRK/TRG */
INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14); /* TIM5 CAP/COM */
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13); /* TIM2 UPD/OVF/BRK */
INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14); /* TIM2 CAP/COM */
#endif /* (STM8S903) || (STM8AF622x) */
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x)
INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15); /* TIM3 UPD/OVF/BRK */
INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16); /* TIM3 CAP/COM */
#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
defined(STM8S003) || defined(STM8S001) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903)
INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17); /* UART1 TX */
INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18); /* UART1 RX */
#endif /* (STM8S208) || (STM8S207) || (STM8S903) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) */
#if defined (STM8AF622x)
INTERRUPT_HANDLER(UART4_TX_IRQHandler, 17); /* UART4 TX */
INTERRUPT_HANDLER(UART4_RX_IRQHandler, 18); /* UART4 RX */
#endif /* (STM8AF622x) */
INTERRUPT_HANDLER(I2C_IRQHandler, 19); /* I2C */
#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20); /* UART2 TX */
INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21); /* UART2 RX */
#endif /* (STM8S105) || (STM8AF626x) */
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
INTERRUPT_HANDLER(UART3_RX_IRQHandler, 20); /* UART3 RX */
INTERRUPT_HANDLER(UART3_TX_IRQHandler, 21); /* UART3 TX */
#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
INTERRUPT_HANDLER(ADC2_IRQHandler, 22); /* ADC2 */
#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */
INTERRUPT_HANDLER(ADC1_IRQHandler, 22); /* ADC1 */
#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
#if defined(STM8S903) || defined(STM8AF622x)
INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23); /* TIM6 UPD/OVF/TRG */
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */
INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23); /* TIM4 UPD/OVF */
#endif /* (STM8S903) || (STM8AF622x) */
INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24); /* EEPROM ECC CORRECTION */
#endif /* !(_RAISONANCE_) && !(_SDCC_) */
#endif /* __STM8S_IT_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

24
platformio.ini Normal file
View File

@@ -0,0 +1,24 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:stm8sblue]
platform = ststm8
board = stm8sblue
framework = spl
extra_scripts = pre:extra_script.py
upload_protocol = stlinkv2
board_build.mcu = stm8s103f3p6
board_build.f_cpu = 16000000L
; serial monitor options
monitor_speed = 115200
;build_unflags = --nostdlib
;build_flags =
; -I$PROJECT_PACKAGES_DIR/toolchain-sdcc/include/

284
src/main.c Normal file
View File

@@ -0,0 +1,284 @@
#include "main.h"
#include "stm8s_i2c.h"
// #include "stm8s_i2c.h"
// #include "stm8s_uart1.h"
/* Private macro -------------------------------------------------------------*/
// extern uint8_t HEADER_ADDRESS_Read = (((SLAVE_ADDRESS & 0xFF00) >> 7) | 0xF1);
// extern uint8_t HEADER_ADDRESS_Write;
/* Private variables ---------------------------------------------------------*/
uint8_t i = 0;
TestStatus TransferStatus1 = FAILED;
extern __IO uint8_t SlaveAddress;
extern __IO uint8_t TxByte;
extern __IO uint8_t RxByte;
extern __IO uint8_t State;
/* Private function prototypes -----------------------------------------------*/
TestStatus Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength);
PUTCHAR_PROTOTYPE;
void main(void)
{
UART1_DeInit();
I2C_DeInit();
#ifdef FAST_I2C_MODE
/* system_clock / 1 */
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
#else
/* system_clock / 2 */
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV2);
#endif
UART1_Init((uint32_t)115200, UART1_WORDLENGTH_8D, UART1_STOPBITS_1, UART1_PARITY_NO,
UART1_SYNCMODE_CLOCK_DISABLE, UART1_MODE_TXRX_ENABLE);
puts("Demotest\n\r");
delay_ms(1000);
/* I2C Initialize */
I2C_Init(I2C_SPEED, 0xA0, I2C_DUTYCYCLE_2, I2C_ACK_CURR, I2C_ADDMODE_7BIT, 16);
/* Enable Buffer and Event Interrupt*/
I2C_ITConfig((I2C_IT_TypeDef)(I2C_IT_EVT | I2C_IT_BUF | I2C_IT_ERR) , ENABLE);
enableInterrupts();
// /* Initialize LED in Output Mode */
// GPIO_Init(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS, GPIO_MODE_OUT_PP_LOW_FAST);
// /* Show the system is working properly */
// GPIO_WriteHigh(LED_GPIO_PORT, LED_GPIO_PINS);
// delay_ms(200);
// GPIO_WriteLow(LED_GPIO_PORT, LED_GPIO_PINS);
// delay_ms(100);
// GPIO_WriteHigh(LED_GPIO_PORT, LED_GPIO_PINS);
// delay_ms(200);
// GPIO_WriteLow(LED_GPIO_PORT, LED_GPIO_PINS);
// delay_ms(100);
// GPIO_WriteHigh(LED_GPIO_PORT, LED_GPIO_PINS);
// delay_ms(200);
// GPIO_WriteLow(LED_GPIO_PORT, LED_GPIO_PINS);
SlaveAddress = SLAVE_ACCGYR_ADDR;
State = 0;
TxByte = 0x0F;
puts("START I2C\n");
/* Send START condition */
I2C_GenerateSTART(ENABLE);
// I2C_SendData(0x0F);
// I2C_GenerateSTART(ENABLE);
// I2C_Send7bitAddress(SLAVE_MAG_ADDR, I2C_DIRECTION_RX);
// uint8_t r = I2C_ReceiveData();
// // I2C_GenerateSTOP(ENABLE);
// putchar(r);
// puts("\nSOTNKS\n");
while (I2C_GetFlagStatus(I2C_FLAG_BUSBUSY));
puts("NOBUSY\n");
RxByte = I2C_ReceiveData();
putchar(RxByte);
while(1){}
/* Add a delay to be sure that communication is finished */
delay_count(0xFFFF);
/***** reception phase ***/
puts("RECEPTION PHASE\n");
/* Wait while the bus is busy */
while (I2C_GetFlagStatus(I2C_FLAG_BUSBUSY));
/* Send START condition */
I2C_GenerateSTART(ENABLE);
/* Test on EV5 and clear it */
while (!I2C_CheckEvent(I2C_EVENT_MASTER_MODE_SELECT));
/* Send slave Address for write */
I2C_Send7bitAddress(SlaveAddress, I2C_DIRECTION_RX);
/* Test on EV6 and clear it */
while (!I2C_CheckEvent(I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED));
// /* While there is data to be read */
// while (NumByteToRead)
// {
// #ifdef SAFE_PROCEDURE
// if (NumByteToRead != 3) /* Receive bytes from first byte until byte N-3 */
// {
// while ((I2C_GetFlagStatus(I2C_FLAG_TRANSFERFINISHED) == RESET)); /* Poll on BTF */
//
// /* Read a byte from the Slave */
// RxBuffer[Rx_Idx] = I2C_ReceiveData();
//
// /* Point to the next location where the byte read will be saved */
// Rx_Idx++;
//
// /* Decrement the read bytes counter */
// NumByteToRead--;
// }
//
// if (NumByteToRead == 3) /* it remains to read three data: data N-2, data N-1, Data N */
// {
// /* Data N-2 in DR and data N -1 in shift register */
// while ((I2C_GetFlagStatus(I2C_FLAG_TRANSFERFINISHED) == RESET)); /* Poll on BTF */
//
// /* Clear ACK */
// I2C_AcknowledgeConfig(I2C_ACK_NONE);
//
// /* Disable general interrupts */
// disableInterrupts();
//
// /* Read Data N-2 */
// RxBuffer[Rx_Idx] = I2C_ReceiveData();
//
// /* Point to the next location where the byte read will be saved */
// Rx_Idx++;
//
// /* Program the STOP */
// I2C_GenerateSTOP(ENABLE);
//
// /* Read DataN-1 */
// RxBuffer[Rx_Idx] = I2C_ReceiveData();
//
// /* Enable General interrupts */
// enableInterrupts();
//
// /* Point to the next location where the byte read will be saved */
// Rx_Idx++;
//
// while ((I2C_GetFlagStatus(I2C_FLAG_RXNOTEMPTY) == RESET)); /* Poll on RxNE */
//
// /* Read DataN */
// RxBuffer[Rx_Idx] = I2C_ReceiveData();
//
// /* Reset the number of bytes to be read by master */
// NumByteToRead = 0;
//
// }
// #else
// if (NumByteToRead == 1)
// {
// /* Disable Acknowledgement */
// I2C_AcknowledgeConfig(I2C_ACK_NONE);
//
// /* Send STOP Condition */
// I2C_GenerateSTOP(ENABLE);
//
// /* Poll on RxNE Flag */
// while ((I2C_GetFlagStatus(I2C_FLAG_RXNOTEMPTY) == RESET));
// /* Read a byte from the Slave */
// RxBuffer[Rx_Idx] = I2C_ReceiveData();
//
// /* Point to the next location where the byte read will be saved */
// Rx_Idx++;
//
// /* Decrement the read bytes counter */
// NumByteToRead--;
// }
//
// /* Test on EV7 and clear it */
// if (I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED) )
// {
// /* Read a byte from the EEPROM */
// RxBuffer[Rx_Idx] = I2C_ReceiveData();
//
// /* Point to the next location where the byte read will be saved */
// Rx_Idx++;
//
// /* Decrement the read bytes counter */
// NumByteToRead--;
// }
// #endif /* SAFE_PROCEDURE */
// }
//
// /* check if sent and received data are not corrupted */
// TransferStatus1 = Buffercmp((uint8_t*)TxBuffer, (uint8_t*) RxBuffer, BUFFERSIZE);
if (TransferStatus1 != FAILED)
{
puts("FAILED\n");
while (1)
{
/* Toggle LED*/
GPIO_WriteReverse(LED_GPIO_PORT, LED_GPIO_PINS);
/* Insert delay */
delay_count(0x7FFF);
}
}
else
{
puts("OK!\n");
while (1)
{
/* Toggle LED*/
GPIO_WriteReverse(LED_GPIO_PORT, LED_GPIO_PINS);
/* Insert delay */
delay_count(0xFFFF);
}
}
}
/**
* @brief Compares two buffers.
* @param pBuffer1, pBuffer2: buffers to be compared.
* @param BufferLength: buffer's length
* @retval PASSED: pBuffer1 identical to pBuffer2
* FAILED: pBuffer1 differs from pBuffer2
*/
TestStatus Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength)
{
while (BufferLength--)
{
if (*pBuffer1 != *pBuffer2)
{
return FAILED;
}
pBuffer1++;
pBuffer2++;
}
return PASSED;
}
void puts(const char *s) {
const char* p = s;
while (*p != '\0') putchar(*p++);
}
/**
* @brief Retargets the C library printf function to the UART.
* @param c Character to send
* @retval char Character sent
*/
PUTCHAR_PROTOTYPE {
/* Write a character to the UART1 */
UART1_SendData8(c);
/* Loop until the end of transmission */
while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET);
return (c);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif

67
src/main.h Normal file
View File

@@ -0,0 +1,67 @@
#ifndef __MAIN_H
#define __MAIN_H
#include "stm8s.h"
#include "stm8s_it.h" /* SDCC patch: required by SDCC for interrupts */
/* automatically use built-in LED for known nucleo boards */
#if defined(STM8S_NUCLEO_208RB) || defined(STM8S_NUCLEO_207K8)
#define LED_GPIO_PORT (GPIOC)
#define LED_GPIO_PINS (GPIO_PIN_5)
#elif defined(STM8S103)
/* for STM8S103F3 breakout board. building with GPIOG would result in failure (chip
* does not have that GPIO peripheral) */
#define LED_GPIO_PORT (GPIOB)
#define LED_GPIO_PINS (GPIO_PIN_5)
#else
#define LED_GPIO_PORT (GPIOG)
#define LED_GPIO_PINS (GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0)
#endif
/* stdio Prototypes */
#define PUTCHAR_PROTOTYPE int putchar (int c)
#define GETCHAR_PROTOTYPE int getchar (void)
void puts(const char* s);
/* Delay functions */
#define US(us) ( F_CPU / 6000000.0 * us )
inline void delay_count (uint16_t nCount) {
/* Decrement nCount value */
while (nCount != 0)
{
nCount--;
}
}
inline void delay_ms(uint32_t ms) {
while (ms != 0) {
ms--;
delay_count(US(1000));
}
}
/* definition of fast or default standard mode (bus speed up to 400 or 100 kHz) */
// #define FAST_I2C_MODE
#ifdef FAST_I2C_MODE
#define I2C_SPEED 300000
#else
#define I2C_SPEED 100000
#endif
/* 7-bit slave addresses */
#define SLAVE_ACCGYR_ADDR 0b11010100
#define SLAVE_MAG_ADDR 0b00111000
/* This define is used in master receiver */
/* Uncomment the line below if you want to use the safe procedure */
#define SAFE_PROCEDURE
#define BUFFERSIZE 10
typedef enum {FAILED = 0, PASSED = !FAILED} TestStatus;
#endif

118
src/stm8s_conf.h Normal file
View File

@@ -0,0 +1,118 @@
/**
******************************************************************************
* @file stm8s_conf.h
* @author MCD Application Team
* @version V2.0.4
* @date 26-April-2018
* @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.
*
******************************************************************************
*/
/* SDCC patch: include "STM8AF622x" defined in "STM8S_StdPeriph_Tempate" */
/* 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(STM8S001) || defined(STM8S903) || defined (STM8AF626x) || defined (STM8AF622x)
//#include "stm8s_adc1.h"
#endif /* (STM8S105) ||(STM8S103) || (STM8S001) || (STM8S903) || (STM8AF626x) */
#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) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #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) || (STM8S207) || (STM8S007) || (STM8S105) */
#if !defined(STM8S903) && !defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #include "stm8s_tim4.h"
#endif /* (STM8S903) || (STM8AF622x) */
#if defined(STM8S903) || defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #include "stm8s_tim5.h"
// #include "stm8s_tim6.h"
#endif /* (STM8S903) || (STM8AF622x) */
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) ||\
defined(STM8S003) || defined(STM8S001) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
#include "stm8s_uart1.h"
#endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S001) || (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) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */
// #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****/

541
src/stm8s_it.c Normal file
View File

@@ -0,0 +1,541 @@
/**
******************************************************************************
* @file stm8s_it.c
* @author MCD Application Team
* @version V2.0.4
* @date 26-April-2018
* @brief Main Interrupt Service Routines.
******************************************************************************
* @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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8s_it.h"
#include "main.h"
#include "stm8s.h"
#include "stm8s_i2c.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
// extern uint8_t HEADER_ADDRESS_Write = (((SLAVE_ADDRESS & 0xFF00) >> 7) | 0xF0);
// extern uint8_t HEADER_ADDRESS_Read;
/* Private variables ---------------------------------------------------------*/
__IO uint8_t SlaveAddress;
__IO uint8_t TxByte;
__IO uint8_t RxByte;
__IO uint8_t State;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* Public functions ----------------------------------------------------------*/
/** @addtogroup GPIO_Toggle
* @{
*/
#ifdef _COSMIC_
/**
* @brief Dummy interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(NonHandledInterrupt, 25)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*_COSMIC_*/
/**
* @brief TRAP interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Top Level Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TLI_IRQHandler, 0)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Auto Wake Up Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(AWU_IRQHandler, 1)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Clock Controller Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CLK_IRQHandler, 2)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTA Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTB Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTC Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTD Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTE Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#ifdef STM8S903
/**
* @brief External Interrupt PORTF Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S903*/
#if defined (STM8S208) || defined (STM8AF52Ax)
/**
* @brief CAN RX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief CAN TX Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S208 || STM8AF52Ax */
/**
* @brief SPI Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(SPI_IRQHandler, 10)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer1 Update/Overflow/Trigger/Break Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer1 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#ifdef STM8S903
/**
* @brief Timer5 Update/Overflow/Break/Trigger Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer5 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
/**
* @brief Timer2 Update/Overflow/Break Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer2 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S903*/
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
defined(STM8S005) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8AF626x)
/**
* @brief Timer3 Update/Overflow/Break Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer3 Capture/Compare Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
defined(STM8S003) || defined(STM8S001) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8S903)
/**
* @brief UART1 TX Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART1 RX Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S105 || STM8S001 */
/**
* @brief I2C Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(I2C_IRQHandler, 19)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
// puts("I2C ");
switch (I2C_GetLastEvent()) {
/* EV5 */
case I2C_EVENT_MASTER_MODE_SELECT :
if (State == 0) {
/* Send slave Address for write */
I2C_Send7bitAddress(SlaveAddress, I2C_DIRECTION_TX);
puts("EV5_TX\n");
} else {
I2C_Send7bitAddress(SlaveAddress, I2C_DIRECTION_RX);
puts("EV5_RX\n");
}
break;
/* EV6 */
case I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED:
I2C_SendData(TxByte);
// I2C_ITConfig(I2C_IT_BUF, DISABLE);
State = 1;
puts("EV6_TX\n");
break;
case I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED:
I2C_AcknowledgeConfig(I2C_ACK_NONE);
puts("EV6_RX\n");
break;
/* EV7 */
case I2C_EVENT_MASTER_BYTE_RECEIVED:
I2C_GenerateSTOP(ENABLE);
puts("EV7\n");
break;
/* EV8 */
case I2C_EVENT_MASTER_BYTE_TRANSMITTING:
/* Transmit Data */
I2C_GenerateSTART(ENABLE);
puts("EV8\n");
break;
default:
if(I2C_GetFlagStatus(I2C_FLAG_ACKNOWLEDGEFAILURE) == SET) {
puts("ACK FAILURE\n");
I2C_ClearFlag(I2C_FLAG_ACKNOWLEDGEFAILURE);
} else {
puts("BOH FAILURE\n");
}
break;
}
}
#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
/**
* @brief UART2 TX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART2 RX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* STM8S105*/
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
/**
* @brief UART3 TX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART3 RX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
/**
* @brief ADC2 interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(ADC2_IRQHandler, 22)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
return;
}
#else /*STM8S105, STM8S103 or STM8S903 or STM8AF626x */
/**
* @brief ADC1 interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(ADC1_IRQHandler, 22)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
return;
}
#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */
#ifdef STM8S903
/**
* @brief Timer6 Update/Overflow/Trigger Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
/**
* @brief Timer4 Update/Overflow Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*STM8S903*/
/**
* @brief Eeprom EEC Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

201
src/stm8s_it.h Normal file
View File

@@ -0,0 +1,201 @@
/**
******************************************************************************
* @file stm8s_it.h
* @author MCD Application Team
* @version V2.0.4
* @date 26-April-2018
* @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_ */
// SDCC patch: requires separate handling for SDCC (see below)
#if !defined(_RAISONANCE_) && !defined(_SDCC_)
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) // SDCC patch: add 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) // SDCC patch: add 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) || (STM8S001) || (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(STM8S001) || 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) || (STM8S007) || (STM8S103) || (STM8S003) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8S903) */
#if defined (STM8AF622x) // SDCC patch: add 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) || (STM8S005) || (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) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */
#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) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */
#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x
INTERRUPT void TIM6_UPD_OVF_TRG_IRQHandler(void); /* TIM6 UPD/OVF/TRG */
#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
INTERRUPT void TIM4_UPD_OVF_IRQHandler(void); /* TIM4 UPD/OVF */
#endif /* (STM8S903) || (STM8AF622x) */
INTERRUPT void EEPROM_EEC_IRQHandler(void); /* EEPROM ECC CORRECTION */
// SDCC patch: __interrupt keyword required after function name --> requires new block
#elif defined (_SDCC_)
INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler); /* TRAP */
INTERRUPT_HANDLER(TLI_IRQHandler, 0); /* TLI */
INTERRUPT_HANDLER(AWU_IRQHandler, 1); /* AWU */
INTERRUPT_HANDLER(CLK_IRQHandler, 2); /* CLOCK */
INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3); /* EXTI PORTA */
INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4); /* EXTI PORTB */
INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5); /* EXTI PORTC */
INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6); /* EXTI PORTD */
INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7); /* EXTI PORTE */
#if defined(STM8S903) || defined(STM8AF622x)
INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8); /* EXTI PORTF */
#endif /* (STM8S903) || (STM8AF622x) */
#if defined (STM8S208) || defined (STM8AF52Ax)
INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8); /* CAN RX */
INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9); /* CAN TX/ER/SC */
#endif /* (STM8S208) || (STM8AF52Ax) */
INTERRUPT_HANDLER(SPI_IRQHandler, 10); /* SPI */
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); /* TIM1 UPD/OVF/TRG/BRK */
INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12); /* TIM1 CAP/COM */
#if defined(STM8S903) || defined(STM8AF622x)
INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); /* TIM5 UPD/OVF/BRK/TRG */
INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14); /* TIM5 CAP/COM */
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13); /* TIM2 UPD/OVF/BRK */
INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14); /* TIM2 CAP/COM */
#endif /* (STM8S903) || (STM8AF622x) */
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x)
INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15); /* TIM3 UPD/OVF/BRK */
INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16); /* TIM3 CAP/COM */
#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
defined(STM8S003) || defined(STM8S001) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903)
INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17); /* UART1 TX */
INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18); /* UART1 RX */
#endif /* (STM8S208) || (STM8S207) || (STM8S903) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) */
#if defined (STM8AF622x)
INTERRUPT_HANDLER(UART4_TX_IRQHandler, 17); /* UART4 TX */
INTERRUPT_HANDLER(UART4_RX_IRQHandler, 18); /* UART4 RX */
#endif /* (STM8AF622x) */
INTERRUPT_HANDLER(I2C_IRQHandler, 19); /* I2C */
#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20); /* UART2 TX */
INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21); /* UART2 RX */
#endif /* (STM8S105) || (STM8AF626x) */
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
INTERRUPT_HANDLER(UART3_RX_IRQHandler, 20); /* UART3 RX */
INTERRUPT_HANDLER(UART3_TX_IRQHandler, 21); /* UART3 TX */
#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
INTERRUPT_HANDLER(ADC2_IRQHandler, 22); /* ADC2 */
#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */
INTERRUPT_HANDLER(ADC1_IRQHandler, 22); /* ADC1 */
#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
#if defined(STM8S903) || defined(STM8AF622x)
INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23); /* TIM6 UPD/OVF/TRG */
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */
INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23); /* TIM4 UPD/OVF */
#endif /* (STM8S903) || (STM8AF622x) */
INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24); /* EEPROM ECC CORRECTION */
#endif /* !(_RAISONANCE_) && !(_SDCC_) */
#endif /* __STM8S_IT_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

11
test/README Normal file
View File

@@ -0,0 +1,11 @@
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html