summaryrefslogtreecommitdiff
path: root/Project/src/stm32f0xx_it.c
blob: b628455b73f8375bb20fc5f1b883b37784099f9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/**
  ******************************************************************************
  * @file    Projects\Demonstration\stm32f0xx_it.c 
  * @author  MCD Application Team
  * @version V1.0.0
  * @date    17-January-2014
  * @brief   Main Interrupt Service Routines.
  *          This file provides template for all exceptions handler and 
  *          peripherals interrupt service routine.
  ******************************************************************************
  * @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 "stm32f0xx_it.h"
#include "stm32f0xx_conf.h"

#include "ltimers.h"
#include "ltimers_config.h"

#include "nixie_driver_config.h"
#include "nixie_driver_process.h"
#include "led_driver_process.h"
#include "led_driver_config.h"

#include "tsl_types.h"
#include "tsl_user.h"
#include "tsl_time_stm32f0xx.h"


/** @addtogroup STM32F072B_DISCOVERY
  * @{
  */

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/

/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/******************************************************************************/
/*            Cortex-M0 Processor Exceptions Handlers                         */
/******************************************************************************/

/**
  * @brief  This function handles NMI exception.
  * @param  None
  * @retval None
  */
void NMI_Handler(void)
{
}

/**
  * @brief  This function handles Hard Fault exception.
  * @param  None
  * @retval None
  */
void HardFault_Handler(void)
{
  /* Go to infinite loop when Hard Fault exception occurs */
  while (1)
  {
  }
}

/**
  * @brief  This function handles SVCall exception.
  * @param  None
  * @retval None
  * @ Используется в файле portasm.s
  */
//void SVC_Handler(void)
//{
//}

/**
  * @brief  This function handles PendSVC exception.
  * @param  None
  * @retval None
  * @ Используется в файле portasm.s
  */
//void PendSV_Handler(void)
//{
//}

/**
  * @brief  This function handles SysTick Handler.
  * @param  None
  * @retval None
  */
//void SysTick_Handler(void)
//{
//  TimingDelay_Decrement();
//  TSL_tim_ProcessIT();
//}

/******************************************************************************/
/*                 STM32F0xx Peripherals Interrupt Handlers                   */
/*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
/*  available peripheral interrupt handler's name please refer to the startup */
/*  file (startup_stm32f0xx.s).                                            */
/******************************************************************************/

// ----------------------------------------------------------------------------
// Обработчик прерывания таймера общего назначения для тиков в 1 мс
// ----------------------------------------------------------------------------
void LTIMER_IRQHandler ( void )
{
  if ( TIM_GetITStatus ( LTIMER_TIMx, TIM_IT_Update ) != RESET )
  {    
     TIM_ClearITPendingBit ( LTIMER_TIMx, TIM_IT_Update );
     
     ProcessLTimers ();
     //NIX_TEST_PIN_PB11_TOGGLE;
  }
}

void TIM17_handler(void) { LTIMER_IRQHandler(); }


// ----------------------------------------------------------------------------
// Обработчик прерывания таймера для работы NixieDriver
// Это прерывание имеет самый высокий приоритет, чтобы обеспечить стабильную
// частоту динамической индикации ламп Nixie
// ----------------------------------------------------------------------------
void NIX_DRIVER_TIM_IRQHandler ( void )
{
  if ( TIM_GetITStatus ( NIX_DRIVER_TIMx, TIM_IT_Update ) != RESET )
  {    
     TIM_ClearITPendingBit ( NIX_DRIVER_TIMx, TIM_IT_Update );
     
     ProcessNixieDriverFromISR ();
  }
}

void TIM16_handler(void) { NIX_DRIVER_TIM_IRQHandler(); }


// ----------------------------------------------------------------------------
// Обработчик прерывания таймера для работы LED_Driver
// ----------------------------------------------------------------------------
void LED_TIM_IRQHandler ( void )
{
  if ( TIM_GetITStatus ( LED_TIMx, TIM_IT_Update ) != RESET )
  {    
     TIM_ClearITPendingBit ( LED_TIMx, TIM_IT_Update );
     
     LEDDriverProcessFromISR ();
  }
}

void TIM3_handler(void) { LED_TIM_IRQHandler(); }


// ----------------------------------------------------------------------------
// - поставить этому прерыванию наивысший приоритет, чтобы передавать 2 байта
// подряд гарантированно без промежутка времени (или не так важно? может ли
// между двумя байтами задержка повлиять на вывод данных на лампы?)
// ----------------------------------------------------------------------------
//static uint16_t empty_data;

void NIX_SPIx_IRQHandler ( void )
{ 
  /* SPI in Master Receiver mode--------------------------------------- */
  if ( SPI_I2S_GetITStatus ( NIX_SPIx, SPI_I2S_IT_TXE ) == SET )
  {
      // Обязательно надо считать, чтобы сбросить флаг 
      SPI_I2S_ReceiveData16 ( NIX_SPIx );
      SPI_I2S_ITConfig ( NIX_SPIx, SPI_I2S_IT_TXE, DISABLE );
      //NixieDriverCheckDPPins(); 
      NIX_DRIVER_SET_ST_PIN;
  }
}

void SPI1_handler(void) { NIX_SPIx_IRQHandler(); }


// ----------------------------------------------------------------------------
//
// ----------------------------------------------------------------------------
#ifdef LED_DRIVER
void LED_SPIx_IRQHandler ( void )
{ 
  /* SPI in Master Receiver mode--------------------------------------- */
  if ( SPI_I2S_GetITStatus ( LED_SPIx, SPI_I2S_IT_RXNE ) == SET )
  {
      //empty_data = SPI_I2S_ReceiveData16 ( LED_SPIx ); 
      // Обязательно надо считать, чтобы сбросить флаг 
      SPI_I2S_ReceiveData16 ( LED_SPIx ); 
      LED_ST_PIN_SET;
  }
}

void SPI2_handler(void) { LED_SPIx_IRQHandler(); }
#endif


// ----------------------------------------------------------------------------
/**
  * @brief  This function handles Touch Sensing Controller Handler.
  * @param  None
  * @retval None
  */
// ----------------------------------------------------------------------------
extern __IO uint32_t Gv_EOA;

void TSC_IRQHandler ( void )
{
#if TSLPRM_TSC_IODEF > 0 // Default = Input Floating
  /* Set IO default in Output PP Low to discharge all capacitors */
  TSC->CR &= (uint32_t)(~(1 << 4));
#endif
  TSC->ICR |= 0x03; /* Clear EOAF and MCEF flags */
  Gv_EOA = 1; /* To inform the main loop routine of the End Of Acquisition */
}

void TSC_handler(void) { TSC_IRQHandler(); }


// ----------------------------------------------------------------------------
//
// ----------------------------------------------------------------------------
void TS_TIM_IRQHandler ( void )
{
  TIM_ClearITPendingBit ( TS_TIMx, TIM_IT_Update );
  TSL_tim_ProcessIT();
}

void TIM15_handler(void) { TS_TIM_IRQHandler(); }


/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/