Interrupt counters added (use -DDEBUG_INTERRUPTS=YES to enable and CLI command "print int" to see them)

This commit is contained in:
Damjan Adamic
2016-04-03 17:51:20 +02:00
parent a0b4053e82
commit 9673df83a7
21 changed files with 188 additions and 52 deletions
+6 -12
View File
@@ -58,8 +58,8 @@ void init2MhzTimer()
TIMER_2MHz_TIMER->CR1 = TIM_CR1_CEN;
}
// Starts TIMER at 200Hz, 5mS period
void init5msTimer()
// Starts TIMER at 1000Hz
void init1msTimer()
{
INTERRUPT_5MS_TIMER->ARR = 999 ; // 1mS
INTERRUPT_5MS_TIMER->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1 ; // 1uS from 30MHz
@@ -72,15 +72,8 @@ void init5msTimer()
NVIC_SetPriority(TIM8_TRG_COM_TIM14_IRQn, 7);
}
void stop5msTimer( void )
{
TIM14->CR1 = 0 ; // stop timer
NVIC_DisableIRQ(TIM8_TRG_COM_TIM14_IRQn) ;
RCC->APB1ENR &= ~RCC_APB1ENR_TIM14EN ; // Disable clock
}
// TODO use the same than board_sky9x.cpp
void interrupt5ms()
void interrupt1ms()
{
static uint32_t pre_scale ; // Used to get 10 Hz counter
@@ -106,7 +99,8 @@ void interrupt5ms()
extern "C" void TIM8_TRG_COM_TIM14_IRQHandler()
{
TIM14->SR &= ~TIM_SR_UIF ;
interrupt5ms() ;
interrupt1ms() ;
DEBUG_INTERRUPT(INT_1MS);
}
void boardInit()
@@ -155,7 +149,7 @@ void boardInit()
lcdInit();
audioInit();
init2MhzTimer();
init5msTimer();
init1msTimer();
usbInit();
hapticInit();
@@ -165,6 +165,7 @@ static void intmoduleNoneStop()
#if !defined(SIMU)
extern "C" void DMA2_Stream7_IRQHandler(void)
{
DEBUG_INTERRUPT(INT_DMA2S7);
if(DMA_GetITStatus(INTMODULE_DMA_STREAM, DMA_IT_TCIF7)) {
// TODO we could send the 8 next channels here (when needed)
DMA_ClearITPendingBit(INTMODULE_DMA_STREAM, DMA_IT_TCIF7);
@@ -173,6 +174,7 @@ extern "C" void DMA2_Stream7_IRQHandler(void)
extern "C" void TIM1_CC_IRQHandler()
{
DEBUG_INTERRUPT(INT_TIM1CC);
INTMODULE_TIMER->DIER &= ~TIM_DIER_CC2IE; // stop this interrupt
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF; // clear flag
@@ -551,6 +553,7 @@ static void extmodulePpmStop()
extern "C" void TIM2_IRQHandler()
{
DEBUG_INTERRUPT(INT_TIM2);
//determine if its CC or UP interrupt
uint16_t sr = EXTMODULE_TIMER->SR;
uint16_t dier = EXTMODULE_TIMER->DIER;
+22 -20
View File
@@ -1,23 +1,23 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/* Includes ------------------------------------------------------------------*/
#include "../horus/sdio_sd.h"
@@ -2776,11 +2776,13 @@ OPTIMIZE("O0") uint8_t convert_from_bytes_to_power_of_two(uint16_t NumberOfBytes
void SDIO_IRQHandler(void)
{
DEBUG_INTERRUPT(INT_SDIO);
SD_ProcessIRQ();
}
void SD_SDIO_DMA_IRQHANDLER(void)
{
DEBUG_INTERRUPT(INT_SDIO_DMA);
SD_ProcessDMAIRQ();
}
@@ -134,6 +134,7 @@ uint8_t serial2TracesEnabled()
#if !defined(SIMU)
extern "C" void SERIAL_USART_IRQHandler(void)
{
DEBUG_INTERRUPT(INT_SER2);
// Send
if (USART_GetITStatus(SERIAL_USART, USART_IT_TXE) != RESET) {
uint8_t txchar;
@@ -136,6 +136,7 @@ void sportSendBuffer(uint8_t * buffer, uint32_t count)
extern "C" void TELEMETRY_DMA_TX_IRQHandler(void)
{
DEBUG_INTERRUPT(INT_TELEM_DMA);
if (DMA_GetITStatus(TELEMETRY_DMA_Stream_TX, TELEMETRY_DMA_TX_FLAG_TC)) {
DMA_ClearITPendingBit(TELEMETRY_DMA_Stream_TX, TELEMETRY_DMA_TX_FLAG_TC);
telemetryPortSetDirectionInput();
@@ -103,6 +103,7 @@ void stop_trainer_capture()
#if !defined(SIMU)
extern "C" void TIM3_IRQHandler()
{
DEBUG_INTERRUPT(INT_TIM3);
uint16_t capture = 0;
bool doCapture = false;
+2
View File
@@ -20,6 +20,7 @@
#include "board_horus.h"
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h"
#include "debug.h"
int usbPlugged(void)
{
@@ -46,6 +47,7 @@ USB_OTG_CORE_HANDLE USB_OTG_dev;
void OTG_FS_IRQHandler(void)
{
DEBUG_INTERRUPT(INT_OTG_FS);
USBD_OTG_ISR_Handler(&USB_OTG_dev);
}
@@ -120,6 +120,7 @@ void audioEnd()
extern "C" void AUDIO_TIM_IRQHandler()
{
DEBUG_INTERRUPT(INT_AUDIO);
DAC->CR &= ~DAC_CR_DMAEN1 ; // Stop DMA requests
#if !defined(REV9E)
DAC->CR &= ~DAC_CR_DMAUDRIE1 ; // Stop underrun interrupt
@@ -104,6 +104,7 @@ void bluetoothDone()
extern "C" void USART6_IRQHandler(void)
{
DEBUG_INTERRUPT(INT_BLUETOOTH);
if (USART_GetITStatus(BT_USART, USART_IT_RXNE) != RESET) {
USART_ClearITPendingBit(BT_USART, USART_IT_RXNE);
uint8_t byte = USART_ReceiveData(BT_USART);
@@ -108,6 +108,7 @@ extern "C" void INTERRUPT_5MS_IRQHandler()
{
INTERRUPT_5MS_TIMER->SR &= ~TIM_SR_UIF ;
interrupt5ms() ;
DEBUG_INTERRUPT(INT_5MS);
}
#if defined(REV9E)
+21 -20
View File
@@ -1,23 +1,23 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "../../opentx.h"
#define WriteData(x) AspiData(x)
@@ -199,6 +199,7 @@ void lcdRefresh(bool wait)
extern "C" void DMA1_Stream7_IRQHandler()
{
DEBUG_INTERRUPT(INT_LCD);
//clear interrupt flag
DMA1_Stream7->CR &= ~DMA_SxCR_TCIE ; // Stop interrupt
DMA1->HIFCR |= DMA_HIFCR_CTCIF7; // Clear interrupt flag
@@ -375,6 +375,7 @@ static void intmodulePpmStop()
#if !defined(SIMU)
extern "C" void TIM1_CC_IRQHandler()
{
DEBUG_INTERRUPT(INT_TIM1CC);
INTMODULE_TIMER->DIER &= ~TIM_DIER_CC2IE; // stop this interrupt
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF; // clear flag
DMA2_Stream6->CR &= ~DMA_SxCR_EN; // disable DMA, it will have the whole of the execution time of setupPulses() to actually stop
@@ -402,6 +403,7 @@ extern "C" void TIM1_CC_IRQHandler()
extern "C" void TIM1_UP_TIM10_IRQHandler()
{
DEBUG_INTERRUPT(INT_TIM1);
INTMODULE_TIMER->SR &= ~TIM_SR_UIF ; // Clear flag
INTMODULE_TIMER->ARR = *modulePulsesData[INTERNAL_MODULE].ppm.ptr++ ;
@@ -612,6 +614,7 @@ extern "C" void TIM8_CC_IRQHandler()
extern "C" void TIM8_UP_TIM13_IRQHandler()
{
DEBUG_INTERRUPT(INT_TIM8);
EXTMODULE_TIMER->SR &= ~TIM_SR_UIF ; // Clear flag
EXTMODULE_TIMER->ARR = *modulePulsesData[EXTERNAL_MODULE].ppm.ptr++ ;
@@ -138,6 +138,7 @@ uint8_t serial2TracesEnabled()
#if !defined(SIMU)
extern "C" void SERIAL_USART_IRQHandler(void)
{
DEBUG_INTERRUPT(INT_SER2);
// Send
if (USART_GetITStatus(SERIAL_USART, USART_IT_TXE) != RESET) {
uint8_t txchar;
@@ -114,6 +114,7 @@ void sportSendBuffer(uint8_t * buffer, uint32_t count)
extern "C" void TELEMETRY_DMA_TX_IRQHandler(void)
{
DEBUG_INTERRUPT(INT_TELEM_DMA);
if (DMA_GetITStatus(TELEMETRY_DMA_Stream_TX, TELEMETRY_DMA_TX_FLAG_TC)) {
DMA_ClearITPendingBit(TELEMETRY_DMA_Stream_TX, TELEMETRY_DMA_TX_FLAG_TC);
telemetryPortSetDirectionInput();
@@ -123,6 +124,7 @@ extern "C" void TELEMETRY_DMA_TX_IRQHandler(void)
#define USART_FLAG_ERRORS (USART_FLAG_ORE | USART_FLAG_NE | USART_FLAG_FE | USART_FLAG_PE)
extern "C" void TELEMETRY_USART_IRQHandler(void)
{
DEBUG_INTERRUPT(INT_TELEM_USART);
uint32_t status = TELEMETRY_USART->SR;
while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
uint8_t data = TELEMETRY_USART->DR;
@@ -103,6 +103,7 @@ void stop_trainer_capture()
#if !defined(SIMU)
extern "C" void TIM3_IRQHandler()
{
DEBUG_INTERRUPT(INT_TRAINER);
uint16_t capture = 0;
bool doCapture = false;
+2
View File
@@ -20,6 +20,7 @@
#include "board_taranis.h"
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h"
#include "debug.h"
int usbPlugged(void)
{
@@ -46,6 +47,7 @@ USB_OTG_CORE_HANDLE USB_OTG_dev;
void OTG_FS_IRQHandler(void)
{
DEBUG_INTERRUPT(INT_OTG_FS);
USBD_OTG_ISR_Handler(&USB_OTG_dev);
}