2017-08-20 12:41:17 +00:00
|
|
|
/*
|
|
|
|
* it_handlers.c
|
|
|
|
*
|
|
|
|
* Created on: 28.05.2017
|
|
|
|
* Author: mateusz
|
|
|
|
*/
|
|
|
|
|
2019-01-26 22:18:25 +00:00
|
|
|
#include <delay.h>
|
2017-08-20 12:41:17 +00:00
|
|
|
#include <stm32f10x.h>
|
|
|
|
#include "drivers/dallas.h"
|
|
|
|
#include "drivers/tx20.h"
|
|
|
|
#include "drivers/ms5611.h"
|
2018-04-20 21:23:50 +00:00
|
|
|
#include "drivers/_dht22.h"
|
2019-01-13 20:55:09 +00:00
|
|
|
#include "drivers/serial.h"
|
2019-01-23 21:18:05 +00:00
|
|
|
#include "drivers/i2c.h"
|
2017-08-20 12:41:17 +00:00
|
|
|
#include "aprs/wx.h"
|
|
|
|
#include "aprs/telemetry.h"
|
|
|
|
#include "aprs/beacon.h"
|
|
|
|
#include "main.h"
|
2019-01-26 17:02:19 +00:00
|
|
|
//#include "afsk.h"
|
2017-08-20 12:41:17 +00:00
|
|
|
#include "diag/Trace.h"
|
|
|
|
|
2018-01-01 18:57:29 +00:00
|
|
|
#include "station_config.h"
|
|
|
|
|
2017-08-20 12:41:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
// TIM1 w TX20
|
|
|
|
|
|
|
|
/* Zmienne używane do oversamplingu */
|
|
|
|
char adc_sample_count = 0, adc_sample_c2 = 0; // Zmienna odliczająca próbki
|
|
|
|
unsigned short int AdcBuffer[4]; // Bufor przechowujący kolejne wartości rejestru DR
|
|
|
|
short int AdcValue;
|
|
|
|
|
2019-01-26 17:02:19 +00:00
|
|
|
// Systick interrupt used for time measurements, checking timeouts and SysTick_Handler
|
2019-01-13 20:55:09 +00:00
|
|
|
void SysTick_Handler(void) {
|
2019-01-23 21:18:05 +00:00
|
|
|
|
|
|
|
// systick interrupt is generated every 10ms
|
2019-01-27 11:34:43 +00:00
|
|
|
master_time += SYSTICK_TICKS_PERIOD;
|
2019-01-13 20:55:09 +00:00
|
|
|
|
2019-01-26 17:02:19 +00:00
|
|
|
// decrementing a timer to trigger meteo measuremenets
|
|
|
|
main_wx_decremenet_counter();
|
|
|
|
|
2019-01-13 20:55:09 +00:00
|
|
|
srl_keep_timeout();
|
2019-01-23 21:18:05 +00:00
|
|
|
|
|
|
|
i2cKeepTimeout();
|
|
|
|
|
2019-01-26 17:02:19 +00:00
|
|
|
delay_decrement_counter();
|
|
|
|
|
2019-01-13 20:55:09 +00:00
|
|
|
}
|
|
|
|
|
2018-12-29 17:45:28 +00:00
|
|
|
void USART1_IRQHandler(void) {
|
|
|
|
NVIC_ClearPendingIRQ(USART1_IRQn);
|
2019-01-02 07:20:19 +00:00
|
|
|
srl_irq_handler();
|
2017-08-20 12:41:17 +00:00
|
|
|
}
|
|
|
|
|
2018-12-29 17:45:28 +00:00
|
|
|
void I2C1_EV_IRQHandler(void) {
|
|
|
|
NVIC_ClearPendingIRQ(I2C1_EV_IRQn);
|
2017-08-20 12:41:17 +00:00
|
|
|
|
2018-12-29 17:45:28 +00:00
|
|
|
i2cIrqHandler();
|
2017-08-20 12:41:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-12-29 17:45:28 +00:00
|
|
|
void I2C1_ER_IRQHandler(void) {
|
|
|
|
i2cErrIrqHandler();
|
|
|
|
}
|
2017-08-20 12:41:17 +00:00
|
|
|
|
2018-12-29 17:45:28 +00:00
|
|
|
void EXTI4_IRQHandler(void) {
|
|
|
|
EXTI->PR |= EXTI_PR_PR4;
|
2019-01-27 11:34:43 +00:00
|
|
|
dht22_irq_handler();
|
2018-12-29 17:45:28 +00:00
|
|
|
}
|
2017-08-20 12:41:17 +00:00
|
|
|
|
2018-12-29 17:45:28 +00:00
|
|
|
void TIM2_IRQHandler( void ) {
|
|
|
|
TIM2->SR &= ~(1<<0);
|
|
|
|
if (delay_5us > 0)
|
|
|
|
delay_5us--;
|
2017-08-20 12:41:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-27 11:34:43 +00:00
|
|
|
/*
|
2017-08-20 12:41:17 +00:00
|
|
|
void TIM3_IRQHandler(void) {
|
|
|
|
// wysylanie wlasnej pozycji i danych WX
|
|
|
|
TIM3->SR &= ~(1<<0);
|
2019-01-27 11:34:43 +00:00
|
|
|
|
2017-08-20 12:41:17 +00:00
|
|
|
}
|
2019-01-27 11:34:43 +00:00
|
|
|
*/
|
2018-12-29 17:45:28 +00:00
|
|
|
|
|
|
|
void TIM4_IRQHandler( void ) {
|
|
|
|
// obsluga przerwania cyfra-analog
|
|
|
|
TIM4->SR &= ~(1<<0);
|
|
|
|
if (timm == 0) {
|
2019-01-26 22:18:25 +00:00
|
|
|
DAC->DHR8R1 = AFSK_DAC_ISR(&main_afsk);
|
2018-12-29 17:45:28 +00:00
|
|
|
DAC->SWTRIGR |= 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (delay_5us > 0)
|
|
|
|
delay_5us--;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void TIM7_IRQHandler(void) {
|
|
|
|
// obsluga przetwarzania analog-cyfra. Wersja z oversamplingiem
|
|
|
|
TIM7->SR &= ~(1<<0);
|
|
|
|
#define ASC adc_sample_count
|
|
|
|
#define ASC2 adc_sample_c2
|
|
|
|
AdcBuffer[ASC] = ADC1->DR;
|
|
|
|
if(ASC == 3) {
|
|
|
|
AdcValue = (short int)(( AdcBuffer[0] + AdcBuffer[1] + AdcBuffer[2] + AdcBuffer[3]) >> 1);
|
2019-01-26 22:18:25 +00:00
|
|
|
AFSK_ADC_ISR(&main_afsk, (AdcValue - 4095) );
|
|
|
|
if(main_ax25.dcd == true) { // niebieska dioda
|
2018-12-29 17:45:28 +00:00
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BS8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BR8;
|
|
|
|
}
|
|
|
|
ASC = 0;
|
|
|
|
|
|
|
|
if (ASC2++ == 2) {
|
|
|
|
// pooling AX25 musi być tu bo jak z przerwania wyskoczy nadawanie WX, BCN, TELEM przy dcd == true
|
|
|
|
// to bedzie wisialo w nieskonczonosc bo ustawiania dcd jest w srodku ax25_poll
|
2019-01-26 22:18:25 +00:00
|
|
|
ax25_poll(&main_ax25);
|
2018-12-29 17:45:28 +00:00
|
|
|
ASC2 = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ASC++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|