kopia lustrzana https://github.com/SP8EBC/ParaTNC
rodzic
5ce7f8fcc8
commit
be03b44f7e
|
@ -8,7 +8,8 @@
|
|||
|
||||
extern uint32_t master_time;
|
||||
|
||||
extern uint32_t main_wx_sensors_pool_timer;
|
||||
extern int32_t main_wx_sensors_pool_timer;
|
||||
extern int32_t main_packet_tx_pool_timer;
|
||||
|
||||
extern AX25Ctx main_ax25;
|
||||
extern Afsk main_afsk;
|
||||
|
|
|
@ -33,7 +33,7 @@ void delay_random(void) {
|
|||
}
|
||||
|
||||
void delay_set(uint16_t delay_in_msecs, uint8_t randomize) {
|
||||
preset_delay_msecs = delay_in_msecs;
|
||||
preset_delay_msecs = delay_in_msecs * 50;
|
||||
|
||||
if (randomize == 1) {
|
||||
preset_use_random = 1;
|
||||
|
|
|
@ -71,6 +71,8 @@ void SysTick_Handler(void) {
|
|||
// decrementing a timer to trigger meteo measuremenets
|
||||
main_wx_decremenet_counter();
|
||||
|
||||
main_packets_tx_decremenet_counter();
|
||||
|
||||
srl_keep_timeout();
|
||||
|
||||
i2cKeepTimeout();
|
||||
|
@ -110,13 +112,20 @@ void TIM2_IRQHandler( void ) {
|
|||
void TIM4_IRQHandler( void ) {
|
||||
// obsluga przerwania cyfra-analog
|
||||
TIM4->SR &= ~(1<<0);
|
||||
if (timm == 0) {
|
||||
// if (timm == 0) {
|
||||
DAC->DHR8R1 = AFSK_DAC_ISR(&main_afsk);
|
||||
DAC->SWTRIGR |= 1;
|
||||
// }
|
||||
// else {
|
||||
// if (delay_5us > 0)
|
||||
// delay_5us--;
|
||||
// }
|
||||
|
||||
if (main_afsk.sending) {
|
||||
GPIO_SetBits(GPIOC, GPIO_Pin_9);
|
||||
}
|
||||
else {
|
||||
if (delay_5us > 0)
|
||||
delay_5us--;
|
||||
GPIO_ResetBits(GPIOC, GPIO_Pin_9);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
34
src/main.c
34
src/main.c
|
@ -8,6 +8,7 @@
|
|||
#include <stm32f10x.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "packet_tx_handler.h"
|
||||
#include "station_config.h"
|
||||
|
||||
#include "diag/Trace.h"
|
||||
|
@ -17,6 +18,8 @@
|
|||
#include "TimerConfig.h"
|
||||
#include "PathConfig.h"
|
||||
|
||||
#include "it_handlers.h"
|
||||
|
||||
#include "aprs/digi.h"
|
||||
#include "aprs/telemetry.h"
|
||||
#include "aprs/dac.h"
|
||||
|
@ -62,10 +65,10 @@
|
|||
uint32_t master_time = 0;
|
||||
|
||||
// global variable used as a timer to trigger meteo sensors mesurements
|
||||
uint32_t main_wx_sensors_pool_timer = 65500;
|
||||
int32_t main_wx_sensors_pool_timer = 65500;
|
||||
|
||||
// global variable used as a timer to trigger packet sending
|
||||
uint32_t main_packet_rx_pool_timer = 6000;
|
||||
int32_t main_packet_tx_pool_timer = 60000;
|
||||
|
||||
// global variables represending the AX25/APRS stack
|
||||
AX25Ctx main_ax25;
|
||||
|
@ -97,6 +100,8 @@ main(int argc, char* argv[])
|
|||
|
||||
int32_t ln = 0;
|
||||
|
||||
uint8_t button_inhibit = 0;
|
||||
|
||||
RCC->APB1ENR |= (RCC_APB1ENR_TIM2EN | RCC_APB1ENR_TIM3EN | RCC_APB1ENR_TIM7EN | RCC_APB1ENR_TIM4EN);
|
||||
RCC->APB2ENR |= (RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN | RCC_APB2ENR_IOPCEN | RCC_APB2ENR_IOPDEN | RCC_APB2ENR_AFIOEN | RCC_APB2ENR_TIM1EN);
|
||||
|
||||
|
@ -216,10 +221,19 @@ main(int argc, char* argv[])
|
|||
while (1)
|
||||
{
|
||||
if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0)) {
|
||||
telemetry_send_values(rx10m, tx10m, digi10m, kiss10m, rte_wx_temperature_dallas_valid, rte_wx_dallas_qf, rte_wx_ms5611_qf, rte_wx_dht.qf);
|
||||
|
||||
if (main_afsk.sending == false && button_inhibit == 0) {
|
||||
|
||||
while(main_ax25.dcd == true);
|
||||
|
||||
//telemetry_send_values(rx10m, tx10m, digi10m, kiss10m, rte_wx_temperature_dallas_valid, rte_wx_dallas_qf, rte_wx_ms5611_qf, rte_wx_dht.qf);
|
||||
SendOwnBeacon();
|
||||
}
|
||||
|
||||
button_inhibit = 1;
|
||||
}
|
||||
else {
|
||||
;
|
||||
button_inhibit = 0;
|
||||
}
|
||||
|
||||
// if new packet has been received from radio channel
|
||||
|
@ -262,6 +276,13 @@ main(int argc, char* argv[])
|
|||
main_wx_sensors_pool_timer = 65500;
|
||||
}
|
||||
|
||||
if (main_packet_tx_pool_timer < 10) {
|
||||
|
||||
packet_tx_handler();
|
||||
|
||||
main_packet_tx_pool_timer = 60000;
|
||||
}
|
||||
|
||||
#ifdef _METEO
|
||||
// dht22 sensor communication pooling
|
||||
wx_pool_dht22();
|
||||
|
@ -279,6 +300,11 @@ void main_wx_decremenet_counter(void) {
|
|||
main_wx_sensors_pool_timer -= SYSTICK_TICKS_PERIOD;
|
||||
}
|
||||
|
||||
void main_packets_tx_decremenet_counter(void) {
|
||||
if (main_packet_tx_pool_timer > 0)
|
||||
main_packet_tx_pool_timer -= SYSTICK_TICKS_PERIOD;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -21,10 +21,14 @@ uint8_t packet_tx_meteo_counter = 0;
|
|||
uint8_t packet_tx_telemetry_interval = 10;
|
||||
uint8_t packet_tx_telemetry_counter = 0;
|
||||
|
||||
uint8_t packet_tx_telemetry_descr_interval = 40;
|
||||
uint8_t packet_tx_telemetry_descr_counter = 0;
|
||||
|
||||
// this shall be called in 60 seconds periods
|
||||
void packet_tx_handler(void) {
|
||||
packet_tx_beacon_counter++;
|
||||
packet_tx_telemetry_counter++;
|
||||
packet_tx_telemetry_descr_counter++;
|
||||
#ifdef _METEO
|
||||
packet_tx_meteo_counter++;
|
||||
#endif
|
||||
|
@ -75,4 +79,13 @@ void packet_tx_handler(void) {
|
|||
|
||||
}
|
||||
|
||||
if (packet_tx_telemetry_descr_counter >= packet_tx_telemetry_descr_interval) {
|
||||
|
||||
telemetry_send_chns_description();
|
||||
|
||||
main_wait_for_tx_complete();
|
||||
|
||||
packet_tx_telemetry_descr_interval = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ void DA_Start() {
|
|||
// //Timer2 ENABLE
|
||||
TIM4->CR1 |= TIM_CR1_CEN;
|
||||
|
||||
|
||||
#if (!defined(_METEO))
|
||||
GPIO_SetBits(GPIOC, GPIO_Pin_9);
|
||||
#endif
|
||||
|
|
|
@ -5,15 +5,16 @@
|
|||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "aprs/digi.h"
|
||||
#include "main.h"
|
||||
#include "TimerConfig.h"
|
||||
#include "delay.h"
|
||||
|
||||
#include "station_config.h"
|
||||
#include "config.h"
|
||||
|
||||
extern volatile int delay_5us;
|
||||
|
||||
char digi_q = 0;
|
||||
|
||||
uint8_t digi_msg[CONFIG_AX25_FRAME_BUF_LEN];
|
||||
|
@ -24,7 +25,7 @@ char Digi(struct AX25Msg *msg) {
|
|||
#ifdef _DIGI
|
||||
|
||||
AX25Call digi_path[7];
|
||||
char call_len;
|
||||
uint8_t call_len = 0;
|
||||
memset(digi_path, sizeof(AX25Call) * 7, 0x00);
|
||||
|
||||
// check if the received message is not too long for the transmit buffers
|
||||
|
@ -156,6 +157,7 @@ char Digi(struct AX25Msg *msg) {
|
|||
digi10m++;
|
||||
digi_msg_len = msg->len+1;
|
||||
snprintf(digi_msg, msg->len+1, "%s", msg->info);
|
||||
delay_from_preset();
|
||||
|
||||
while(main_ax25.dcd == true);
|
||||
ax25_sendVia(&main_ax25, digi_path, call_len, digi_msg, digi_msg_len-1);
|
||||
|
|
|
@ -43,7 +43,7 @@ void dallas_init(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, uint16_t GPIO_PinSource
|
|||
|
||||
void dallas_config_timer(void) {
|
||||
// Disabling any time-consuming iterrupts
|
||||
NVIC_DisableIRQ( TIM3_IRQn ); // data transmission initializer
|
||||
//NVIC_DisableIRQ( TIM3_IRQn ); // data transmission initializer
|
||||
NVIC_DisableIRQ( TIM4_IRQn ); // data transmission initializer
|
||||
NVIC_DisableIRQ( TIM7_IRQn ); // data transmission initializer
|
||||
NVIC_DisableIRQ( 25 ); // anemometer
|
||||
|
@ -62,7 +62,7 @@ void dallas_config_timer(void) {
|
|||
void dallas_deconfig_timer(void) {
|
||||
TIM2->CR1 &= (0xFFFFFFFF ^ TIM_CR1_CEN); // disabling timer
|
||||
|
||||
NVIC_EnableIRQ( TIM3_IRQn ); // adc
|
||||
//NVIC_EnableIRQ( TIM3_IRQn ); // adc
|
||||
NVIC_EnableIRQ( TIM4_IRQn ); // data transmission initializer
|
||||
NVIC_EnableIRQ( TIM7_IRQn ); // data transmission initializer
|
||||
NVIC_EnableIRQ( 25 ); // anemometer
|
||||
|
|
Ładowanie…
Reference in New Issue