initial
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
//
|
||||
// Created by MightyPork on 2017/02/10.
|
||||
//
|
||||
|
||||
#include <stm8s.h>
|
||||
#include "bootstrap.h"
|
||||
|
||||
/** Global time base */
|
||||
volatile uint16_t time_ms;
|
||||
|
||||
/**
|
||||
* Putchar for printf
|
||||
* @param c - char to print
|
||||
*/
|
||||
int putchar(int c)
|
||||
{
|
||||
while ((UART1->SR & UART1_SR_TXE) == 0);
|
||||
UART1->DR = (u8)c;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init for the chinese STM8 board
|
||||
* - enable LED
|
||||
* - enable UART @ 115200
|
||||
* - set up UART rx irq
|
||||
*/
|
||||
void SimpleInit(void)
|
||||
{
|
||||
// Disable default div/8 HSI prescaller
|
||||
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
|
||||
|
||||
// LED
|
||||
GPIO_Init(GPIOB, GPIO_PIN_5, GPIO_MODE_OUT_PP_HIGH_FAST);
|
||||
|
||||
// UART init & enable IRQ
|
||||
UART_SimpleInit(UART_BAUD_115200);
|
||||
// UART1_ITConfig(UART1_IT_RXNE_OR, ENABLE);
|
||||
|
||||
// Timebase generation counter
|
||||
TIM4_UpdateRequestConfig(TIM4_UPDATESOURCE_REGULAR);
|
||||
TIM4_PrescalerConfig(TIM4_PRESCALER_128, TIM4_PSCRELOADMODE_IMMEDIATE);
|
||||
TIM4_SetAutoreload(0xFF);
|
||||
TIM4_ARRPreloadConfig(ENABLE);
|
||||
TIM4_ITConfig(TIM4_IT_UPDATE, ENABLE);
|
||||
TIM4_Cmd(ENABLE);
|
||||
|
||||
enableInterrupts();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Timer4 Update/Overflow Interrupt routine.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23)
|
||||
{
|
||||
time_ms++;
|
||||
TIM4_ClearITPendingBit(TIM4_IT_UPDATE);
|
||||
|
||||
}
|
||||
|
||||
/** Delay ms */
|
||||
void Delay(uint16_t ms)
|
||||
{
|
||||
uint16_t start = time_ms;
|
||||
uint16_t t2;
|
||||
while (1) {
|
||||
t2 = time_ms;
|
||||
if ((t2 - start) >= ms) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Delay N seconds */
|
||||
void Delay_s(uint16_t s)
|
||||
{
|
||||
while (s != 0) {
|
||||
Delay(1000);
|
||||
s--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UART1 RX Interrupt routine.
|
||||
*/
|
||||
INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18)
|
||||
{
|
||||
if (UART1->SR & UART1_SR_RXNE) {
|
||||
UART_HandleRx(UART1->DR);
|
||||
}
|
||||
}
|
||||
|
||||
// Comment out if custom rx handler is added
|
||||
#if 1
|
||||
void UART_HandleRx(char c)
|
||||
{
|
||||
// echo
|
||||
putchar(c);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// Created by MightyPork on 2017/02/10.
|
||||
//
|
||||
|
||||
#ifndef STM8S_STDINIT_H
|
||||
#define STM8S_STDINIT_H
|
||||
|
||||
/** Global timebase */
|
||||
extern volatile uint16_t time_ms;
|
||||
|
||||
/** Uart IRQ handler */
|
||||
void UART1_RX_IRQHandler(void) INTERRUPT(18);
|
||||
|
||||
/** SysTick handler */
|
||||
void TIM4_UPD_OVF_IRQHandler(void) INTERRUPT(23);
|
||||
|
||||
/** putchar, used by the SDCC stdlib */
|
||||
int putchar(int c);
|
||||
|
||||
/**
|
||||
* Simple init (UART, LED, timebase)
|
||||
*/
|
||||
void SimpleInit(void);
|
||||
|
||||
/**
|
||||
* Millisecond delay
|
||||
*
|
||||
* @param ms - nr of milliseconds
|
||||
*/
|
||||
void Delay(uint16_t ms);
|
||||
|
||||
/**
|
||||
* User UART rx handler
|
||||
*
|
||||
* If adding custom handler, comment out the defualt echo impl in bootstrap.c
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
extern void UART_HandleRx(char c);
|
||||
|
||||
/** Toggle indicator LED */
|
||||
inline void LED_Toggle(void)
|
||||
{
|
||||
GPIOB->ODR ^= GPIO_PIN_5;
|
||||
}
|
||||
|
||||
/** Set indicator LED */
|
||||
inline void LED_Set(bool state)
|
||||
{
|
||||
if (state) {
|
||||
GPIOB->ODR &= ~GPIO_PIN_5;
|
||||
} else {
|
||||
GPIOB->ODR |= GPIO_PIN_5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif //STM8S_DEBUG_H
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
#include "stm8s.h"
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include "bootstrap.h"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
SimpleInit();
|
||||
|
||||
|
||||
//GPIOC->DDR |= GPIO_PIN_4; // out
|
||||
//GPIOC->CR1 &= ~GPIO_PIN_4; // open drain
|
||||
//GPIOC->CR2 |= GPIO_PIN_4; // fast
|
||||
|
||||
// Rows
|
||||
GPIO_Init(GPIOC, GPIO_PIN_3, GPIO_MODE_OUT_OD_HIZ_FAST);
|
||||
GPIO_Init(GPIOC, GPIO_PIN_4, GPIO_MODE_OUT_OD_HIZ_FAST);
|
||||
GPIO_Init(GPIOC, GPIO_PIN_5, GPIO_MODE_OUT_OD_HIZ_FAST);
|
||||
GPIO_Init(GPIOC, GPIO_PIN_6, GPIO_MODE_OUT_OD_HIZ_FAST);
|
||||
|
||||
// Columns (feedback)
|
||||
GPIO_Init(GPIOD, GPIO_PIN_1, GPIO_MODE_IN_PU_NO_IT);
|
||||
GPIO_Init(GPIOD, GPIO_PIN_2, GPIO_MODE_IN_PU_NO_IT);
|
||||
GPIO_Init(GPIOD, GPIO_PIN_3, GPIO_MODE_IN_PU_NO_IT);
|
||||
GPIO_Init(GPIOD, GPIO_PIN_4, GPIO_MODE_IN_PU_NO_IT);
|
||||
|
||||
bool matrix[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
uint16_t counter[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
const char *digits = "123A456B789C*0#D";
|
||||
|
||||
#define DEBO 8
|
||||
|
||||
while (1) {
|
||||
int b = 0;
|
||||
|
||||
GPIO_WriteLow(GPIOC, GPIO_PIN_3);
|
||||
Delay(1);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_1);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_2);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_3);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_4);
|
||||
GPIO_WriteHigh(GPIOC, GPIO_PIN_3);
|
||||
|
||||
GPIO_WriteLow(GPIOC, GPIO_PIN_4);
|
||||
Delay(1);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_1);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_2);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_3);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_4);
|
||||
GPIO_WriteHigh(GPIOC, GPIO_PIN_4);
|
||||
|
||||
GPIO_WriteLow(GPIOC, GPIO_PIN_5);
|
||||
Delay(1);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_1);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_2);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_3);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_4);
|
||||
GPIO_WriteHigh(GPIOC, GPIO_PIN_5);
|
||||
|
||||
GPIO_WriteLow(GPIOC, GPIO_PIN_6);
|
||||
Delay(1);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_1);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_2);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_3);
|
||||
matrix[b++] = GPIO_ReadInputPin(GPIOD, GPIO_PIN_4);
|
||||
GPIO_WriteHigh(GPIOC, GPIO_PIN_6);
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (matrix[i] == 0) {
|
||||
// pushed
|
||||
if (counter[i] < DEBO) {
|
||||
counter[i]++;
|
||||
if (counter[i] == DEBO) {
|
||||
GPIO_WriteLow(GPIOB, GPIO_PIN_5); // LED on
|
||||
putchar(digits[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
counter[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Delay(5);
|
||||
GPIO_WriteHigh(GPIOB, GPIO_PIN_5); // LED off
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm8s_conf.h
|
||||
* @author MCD Application Team
|
||||
* @version V2.2.0
|
||||
* @date 30-September-2014
|
||||
* @brief This file is used to configure the Library.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM8S_CONF_H
|
||||
#define __STM8S_CONF_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm8s.h"
|
||||
|
||||
/* Uncomment the line below to enable peripheral header file inclusion */
|
||||
#if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) ||\
|
||||
defined(STM8S903) || defined (STM8AF626x) || defined (STM8AF622x)
|
||||
#include "stm8s_adc1.h"
|
||||
#endif /* (STM8S105) ||(STM8S103) || (STM8S903) || (STM8AF626x) || (STM8AF622x) */
|
||||
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\
|
||||
defined (STM8AF62Ax)
|
||||
#include "stm8s_adc2.h"
|
||||
#endif /* (STM8S208) || (STM8S207) || (STM8AF62Ax) || (STM8AF52Ax) */
|
||||
//#include "stm8s_awu.h"
|
||||
#include "stm8s_beep.h"
|
||||
#if defined (STM8S208) || defined (STM8AF52Ax)
|
||||
#include "stm8s_can.h"
|
||||
#endif /* (STM8S208) || (STM8AF52Ax) */
|
||||
#include "stm8s_clk.h"
|
||||
#include "stm8s_exti.h"
|
||||
//#include "stm8s_flash.h"
|
||||
#include "stm8s_gpio.h"
|
||||
#include "stm8s_i2c.h"
|
||||
//#include "stm8s_itc.h"
|
||||
#include "stm8s_iwdg.h"
|
||||
#include "stm8s_rst.h"
|
||||
#include "stm8s_spi.h"
|
||||
#include "stm8s_tim1.h"
|
||||
#if !defined(STM8S903) || !defined(STM8AF622x)
|
||||
#include "stm8s_tim2.h"
|
||||
#endif /* (STM8S903) || (STM8AF622x) */
|
||||
#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) ||\
|
||||
defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x)
|
||||
#include "stm8s_tim3.h"
|
||||
#endif /* (STM8S208) ||defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) */
|
||||
#if !defined(STM8S903) || !defined(STM8AF622x)
|
||||
#include "stm8s_tim4.h"
|
||||
#endif /* (STM8S903) || (STM8AF622x) */
|
||||
#if defined(STM8S903) || defined(STM8AF622x)
|
||||
#include "stm8s_tim5.h"
|
||||
#include "stm8s_tim6.h"
|
||||
#endif /* (STM8S903) || (STM8AF622x) */
|
||||
#if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) ||defined(STM8S103) ||\
|
||||
defined(STM8S003) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
|
||||
#include "stm8s_uart1.h"
|
||||
#endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S903) || (STM8AF52Ax) || (STM8AF62Ax) */
|
||||
#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
|
||||
#include "stm8s_uart2.h"
|
||||
#endif /* (STM8S105) || (STM8AF626x) */
|
||||
#if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\
|
||||
defined (STM8AF62Ax)
|
||||
#include "stm8s_uart3.h"
|
||||
#endif /* STM8S208 || STM8S207 || STM8AF52Ax || STM8AF62Ax */
|
||||
#if defined(STM8AF622x)
|
||||
#include "stm8s_uart4.h"
|
||||
#endif /* (STM8AF622x) */
|
||||
#include "stm8s_wwdg.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Uncomment the line below to expanse the "assert_param" macro in the
|
||||
Standard Peripheral Library drivers code */
|
||||
//#define USE_FULL_ASSERT (1)
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr: If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* @retval : None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t* file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#endif /* __STM8S_CONF_H */
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,553 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm8s_it.c
|
||||
* @author MCD Application Team
|
||||
* @version V2.2.0
|
||||
* @date 30-September-2014
|
||||
* @brief Main Interrupt Service Routines.
|
||||
* This file provides template for all peripherals interrupt service
|
||||
* routine.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© 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.nope"
|
||||
|
||||
/** @addtogroup Template_Project
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/* Public functions ----------------------------------------------------------*/
|
||||
|
||||
#ifdef _COSMIC_
|
||||
/**
|
||||
* @brief Dummy Interrupt routine
|
||||
* @par Parameters:
|
||||
* 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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#endif /*_COSMIC_*/
|
||||
|
||||
/**
|
||||
* @brief TRAP Interrupt routine
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
#if !defined(_SDCC_) || (SKIP_TRAPS != 1) // SDCC patch: trap handling requires SDCC >=v3.4.3
|
||||
INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler)
|
||||
{
|
||||
/* In order to detect unexpected events during development,
|
||||
it is recommended to set a breakpoint on the following instruction.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined (STM8S903) || defined (STM8AF622x)
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#endif /* (STM8S903) || (STM8AF622x) */
|
||||
|
||||
#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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined (STM8S903) || defined (STM8AF622x)
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#endif /* (STM8S903) || (STM8AF622x) */
|
||||
|
||||
#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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */
|
||||
|
||||
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
|
||||
defined(STM8S003) || 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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S903) || (STM8AF62Ax) || (STM8AF52Ax) */
|
||||
|
||||
#if defined(STM8AF622x)
|
||||
/**
|
||||
* @brief UART4 TX Interrupt routine.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
INTERRUPT_HANDLER(UART4_TX_IRQHandler, 17)
|
||||
{
|
||||
/* In order to detect unexpected events during development,
|
||||
it is recommended to set a breakpoint on the following instruction.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UART4 RX Interrupt routine.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
INTERRUPT_HANDLER(UART4_RX_IRQHandler, 18)
|
||||
{
|
||||
/* In order to detect unexpected events during development,
|
||||
it is recommended to set a breakpoint on the following instruction.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#endif /* (STM8AF622x) */
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
#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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#endif /* (STM8S105) || (STM8AF626x) */
|
||||
|
||||
#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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#endif /* (STM8S208) || (STM8S207) || (STM8AF52Ax) || (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 or STM8S103 or STM8S903 or STM8AF626x or STM8AF622x */
|
||||
/**
|
||||
* @brief ADC1 interrupt routine.
|
||||
* @par Parameters:
|
||||
* 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) || (STM8S207) || (STM8AF52Ax) || (STM8AF62Ax) */
|
||||
|
||||
#if defined (STM8S903) || defined (STM8AF622x)
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#else /* STM8S208 or STM8S207 or STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax 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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#endif /* (STM8S903) || (STM8AF622x)*/
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
#endif
|
||||
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm8s_it.h
|
||||
* @author MCD Application Team
|
||||
* @version V2.2.0
|
||||
* @date 30-September-2014
|
||||
* @brief This file contains the headers of the interrupt handlers
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM8S_IT_H
|
||||
#define __STM8S_IT_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm8s.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
#ifdef _COSMIC_
|
||||
void _stext(void); /* RESET startup routine */
|
||||
INTERRUPT(void )NonHandledInterrupt(void);
|
||||
#endif /* _COSMIC_ */
|
||||
|
||||
#if !defined(_RAISONANCE_) // SDCC patch: interrupt keyword required after function
|
||||
|
||||
// INTERRUPT(void )TRAP_IRQHandler(void); /* TRAP */
|
||||
void TLI_IRQHandler(void) INTERRUPT(0); /* TLI */
|
||||
void AWU_IRQHandler(void) INTERRUPT(1); /* AWU */
|
||||
void CLK_IRQHandler(void) INTERRUPT(2); /* CLOCK */
|
||||
void EXTI_PORTA_IRQHandler(void) INTERRUPT(3); /* EXTI PORTA */
|
||||
void EXTI_PORTB_IRQHandler(void) INTERRUPT(4); /* EXTI PORTB */
|
||||
void EXTI_PORTC_IRQHandler(void) INTERRUPT(5); /* EXTI PORTC */
|
||||
void EXTI_PORTD_IRQHandler(void) INTERRUPT(6); /* EXTI PORTD */
|
||||
void EXTI_PORTE_IRQHandler(void) INTERRUPT(7); /* EXTI PORTE */
|
||||
|
||||
#if defined(STM8S903) || defined(STM8AF622x)
|
||||
void EXTI_PORTF_IRQHandler(void) INTERRUPT(8); /* EXTI PORTF */
|
||||
#endif /* (STM8S903) || (STM8AF622x) */
|
||||
|
||||
#if defined (STM8S208) || defined (STM8AF52Ax)
|
||||
void CAN_RX_IRQHandler(void) INTERRUPT(8); /* CAN RX */
|
||||
void CAN_TX_IRQHandler(void) INTERRUPT(9); /* CAN TX/ER/SC */
|
||||
#endif /* (STM8S208) || (STM8AF52Ax) */
|
||||
|
||||
void SPI_IRQHandler(void) INTERRUPT(10); /* SPI */
|
||||
void TIM1_CAP_COM_IRQHandler(void) INTERRUPT(12); /* TIM1 CAP/COM */
|
||||
void TIM1_UPD_OVF_TRG_BRK_IRQHandler(void) INTERRUPT(11); /* TIM1 UPD/OVF/TRG/BRK */
|
||||
|
||||
#if defined(STM8S903) || defined(STM8AF622x)
|
||||
void TIM5_UPD_OVF_BRK_TRG_IRQHandler(void) INTERRUPT(13); /* TIM5 UPD/OVF/BRK/TRG */
|
||||
void TIM5_CAP_COM_IRQHandler(void) INTERRUPT(14); /* TIM5 CAP/COM */
|
||||
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
|
||||
|
||||
void TIM2_UPD_OVF_BRK_IRQHandler(void) INTERRUPT(13); /* TIM2 UPD/OVF/BRK */
|
||||
void TIM2_CAP_COM_IRQHandler(void) INTERRUPT(14); /* TIM2 CAP/COM */
|
||||
#endif /* (STM8S903) || (STM8AF622x) */
|
||||
|
||||
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
|
||||
defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x)
|
||||
void TIM3_UPD_OVF_BRK_IRQHandler(void) INTERRUPT(15); /* TIM3 UPD/OVF/BRK */
|
||||
void TIM3_CAP_COM_IRQHandler(void) INTERRUPT(16); /* TIM3 CAP/COM */
|
||||
#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */
|
||||
|
||||
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
|
||||
defined(STM8S003) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903)
|
||||
|
||||
void UART1_TX_IRQHandler(void) INTERRUPT(17); /* UART1 TX */
|
||||
void UART1_RX_IRQHandler(void) INTERRUPT(18); /* UART1 RX */
|
||||
#endif /* (STM8S208) || (STM8S207) || (STM8S903) || (STM8S103) || (STM8AF52Ax) || (STM8AF62Ax) */
|
||||
|
||||
#if defined (STM8AF622x)
|
||||
void UART4_TX_IRQHandler(void) INTERRUPT(17); /* UART4 TX */
|
||||
void UART4_RX_IRQHandler(void) INTERRUPT(18); /* UART4 RX */
|
||||
#endif /* (STM8AF622x) */
|
||||
|
||||
void I2C_IRQHandler(void) INTERRUPT(19); /* I2C */
|
||||
|
||||
#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
|
||||
void UART2_RX_IRQHandler(void) INTERRUPT(20); /* UART2 RX */
|
||||
void UART2_TX_IRQHandler(void) INTERRUPT(21); /* UART2 TX */
|
||||
#endif /* (STM8S105) || (STM8AF626x) */
|
||||
|
||||
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
|
||||
void UART3_RX_IRQHandler(void) INTERRUPT(20); /* UART3 RX */
|
||||
void UART3_TX_IRQHandler(void) INTERRUPT(21); /* UART3 TX */
|
||||
#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
|
||||
|
||||
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
|
||||
void ADC2_IRQHandler(void) INTERRUPT(22); /* ADC2 */
|
||||
#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */
|
||||
|
||||
void ADC1_IRQHandler(void) INTERRUPT(22); /* ADC1 */
|
||||
#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */
|
||||
|
||||
#if defined(STM8S903) || defined(STM8AF622x)
|
||||
void TIM6_UPD_OVF_TRG_IRQHandler(void) INTERRUPT(23); /* TIM6 UPD/OVF/TRG */
|
||||
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */
|
||||
|
||||
void TIM4_UPD_OVF_IRQHandler(void) INTERRUPT(23); /* TIM4 UPD/OVF */
|
||||
#endif /* (STM8S903) || (STM8AF622x) */
|
||||
|
||||
void EEPROM_EEC_IRQHandler(void) INTERRUPT(24); /* EEPROM ECC CORRECTION */
|
||||
#endif /* _RAISONANCE_ */
|
||||
|
||||
#endif /* __STM8S_IT_H */
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
Reference in New Issue
Block a user