kopia lustrzana https://github.com/SP8EBC/ParaTNC
more work almost everywhere
rodzic
b238588e45
commit
02274ad9a2
|
@ -9,6 +9,7 @@
|
|||
#define DELAY_H_
|
||||
|
||||
#include "stdint.h"
|
||||
#include "main.h"
|
||||
|
||||
extern uint16_t delay_cnt;
|
||||
|
||||
|
@ -19,7 +20,7 @@ void delay_random(void);
|
|||
|
||||
inline void delay_decrement_counter(void) {
|
||||
if (delay_cnt > 0)
|
||||
delay_cnt -= 10;
|
||||
delay_cnt -= SYSTICK_TICKS_PERIOD;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include "aprs/ax25.h"
|
||||
|
||||
#define SYSTICK_TICKS_PER_SECONDS 100
|
||||
#define SYSTICK_TICKS_PERIOD 10
|
||||
|
||||
extern uint32_t master_time;
|
||||
|
||||
extern uint32_t main_wx_sensors_pool_timer;
|
||||
|
@ -10,9 +13,9 @@ extern uint32_t main_wx_sensors_pool_timer;
|
|||
extern AX25Ctx main_ax25;
|
||||
extern Afsk main_afsk;
|
||||
|
||||
extern AX25Call path[3];
|
||||
extern uint8_t path_len;
|
||||
extern uint8_t aprs_msg_len;
|
||||
extern AX25Call main_own_path[3];
|
||||
extern uint8_t main_own_path_ln;
|
||||
extern uint8_t main_own_aprs_msg_len;
|
||||
extern char main_own_aprs_msg[160];
|
||||
|
||||
extern char after_tx_lock;
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
#ifndef PACKET_TX_HANDLER_H_
|
||||
#define PACKET_TX_HANDLER_H_
|
||||
|
||||
|
||||
void packet_tx_handler(void);
|
||||
|
||||
#endif /* PACKET_TX_HANDLER_H_ */
|
||||
|
|
|
@ -84,11 +84,6 @@ short ParseReceivedKISS(uint8_t* SrlRXData, AX25Ctx* ax25, Afsk* a) {
|
|||
while(ax25->dcd == true);
|
||||
while(a->sending == true);
|
||||
|
||||
// delay before transmit
|
||||
TIM2Delay(_DELAY_BASE);
|
||||
while(delay_5us != 0);
|
||||
TIM2DelayDeConfig();
|
||||
// .. end delay
|
||||
|
||||
ax25_sendRaw(ax25,FrameBuff,j);
|
||||
afsk_txStart(a);
|
||||
|
|
|
@ -11,33 +11,10 @@
|
|||
#include "station_config.h"
|
||||
|
||||
|
||||
extern volatile int delay_5us;
|
||||
|
||||
#if (_DELAY_BASE > 20)
|
||||
#error "Transmit delay shouldn't be longer that 1000msec. Decrease _DELAY_BASE in config below 20"
|
||||
#endif
|
||||
|
||||
void TIM2Delay(char delay) {
|
||||
#ifdef _RANDOM_DELAY
|
||||
delay_5us = delay + ((uint16_t)ADC1->DR % 10) * 2;
|
||||
#else
|
||||
delay_5us = delay;
|
||||
#endif
|
||||
|
||||
NVIC_SetPriority(TIM2_IRQn, 1);
|
||||
TIM2->PSC = 9999;
|
||||
TIM2->ARR = 119; // frekwencja 20Hz - 1 tick = 50ms
|
||||
TIM2->CR1 |= TIM_CR1_DIR;
|
||||
TIM2->CR1 &= (0xFFFFFFFF ^ TIM_CR1_DIR);
|
||||
TIM2->CR1 |= TIM_CR1_CEN;
|
||||
TIM2->DIER |= 1;
|
||||
NVIC_EnableIRQ( TIM2_IRQn );
|
||||
}
|
||||
|
||||
void TIM2DelayDeConfig(void) {
|
||||
TIM2->CR1 &= (0xFFFFFF ^ TIM_CR1_CEN);
|
||||
}
|
||||
|
||||
void TimerConfig(void) {
|
||||
///////////////////////////////////////////
|
||||
/// konfiguracja TIM2 -- dallas delay ///
|
||||
|
@ -54,7 +31,7 @@ void TimerConfig(void) {
|
|||
// //////////////////////////////
|
||||
// //// konfiguracja TIM4 -- dac ///
|
||||
// //////////////////////////////
|
||||
NVIC_SetPriority(TIM4_IRQn, 1);
|
||||
NVIC_SetPriority(TIM4_IRQn, 2);
|
||||
TIM4->PSC = 0;
|
||||
TIM4->ARR = 2499;
|
||||
TIM4->CR1 |= TIM_CR1_DIR;
|
||||
|
@ -65,7 +42,7 @@ void TimerConfig(void) {
|
|||
///////////////////////////////////////////
|
||||
/// konfiguracja TIM7 --adc ///
|
||||
///////////////////////////////////////////
|
||||
NVIC_SetPriority(TIM7_IRQn, 2);
|
||||
NVIC_SetPriority(TIM7_IRQn, 3);
|
||||
TIM7->PSC = 0;
|
||||
TIM7->ARR = 624; /// 2499
|
||||
TIM7->CR1 |= TIM_CR1_DIR;
|
||||
|
@ -73,16 +50,18 @@ void TimerConfig(void) {
|
|||
TIM7->CR1 |= TIM_CR1_CEN;
|
||||
TIM7->DIER |= 1;
|
||||
NVIC_EnableIRQ( TIM7_IRQn );
|
||||
/*
|
||||
///////////////////////////////////////////
|
||||
/// konfiguracja TIM3 -- wysylanie wlasnej pozycji i danych WX ///
|
||||
/// konfiguracja TIM3 -- wysylanie wlasnej pozycji i danych WX ///
|
||||
///////////////////////////////////////////
|
||||
NVIC_SetPriority(TIM3_IRQn, 4);
|
||||
TIM3->PSC = 65534; /* Czêstotliwoæ za dzielnikiem: 366Hz */
|
||||
TIM3->ARR = 21960; /* Wyzwalanie przerwania co jednṗ minutê */
|
||||
TIM3->PSC = 65534;
|
||||
TIM3->ARR = 21960;
|
||||
TIM3->CR1 |= TIM_CR1_DIR;
|
||||
TIM3->CR1 &= (0xFFFFFFFF ^ TIM_CR1_DIR);
|
||||
TIM3->CR1 |= TIM_CR1_CEN;
|
||||
TIM3->DIER |= 1;
|
||||
NVIC_EnableIRQ( TIM3_IRQn );
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ short int AdcValue;
|
|||
void SysTick_Handler(void) {
|
||||
|
||||
// systick interrupt is generated every 10ms
|
||||
master_time += 10;
|
||||
master_time += SYSTICK_TICKS_PERIOD;
|
||||
|
||||
// decrementing a timer to trigger meteo measuremenets
|
||||
main_wx_decremenet_counter();
|
||||
|
@ -66,7 +66,7 @@ void I2C1_ER_IRQHandler(void) {
|
|||
|
||||
void EXTI4_IRQHandler(void) {
|
||||
EXTI->PR |= EXTI_PR_PR4;
|
||||
dht22_timeout_keeper();
|
||||
dht22_irq_handler();
|
||||
}
|
||||
|
||||
void TIM2_IRQHandler( void ) {
|
||||
|
@ -76,71 +76,13 @@ void TIM2_IRQHandler( void ) {
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
void TIM3_IRQHandler(void) {
|
||||
// wysylanie wlasnej pozycji i danych WX
|
||||
TIM3->SR &= ~(1<<0);
|
||||
/*
|
||||
#ifdef _METEO
|
||||
temperature = SensorBringTemperature();
|
||||
td = DallasQuery();
|
||||
#ifdef _DBG_TRACE
|
||||
trace_printf("temperatura DS: %d\r\n", (int)td);
|
||||
#endif
|
||||
pressure = (float)SensorBringPressure();
|
||||
#ifdef _DBG_TRACE
|
||||
trace_printf("cisnienie MS: %d\r\n", (int)pressure);
|
||||
#endif
|
||||
if (dht22State == DHT22_STATE_DONE || dht22State == DHT22_STATE_TIMEOUT)
|
||||
dht22State = DHT22_STATE_IDLE;
|
||||
*/
|
||||
/*
|
||||
#ifndef _MUTE_OWN
|
||||
if (WXInterval != 0 && WXI >= WXInterval) {
|
||||
trace_printf("Pogoda\r\n");
|
||||
|
||||
temperature = SensorBringTemperature();
|
||||
// td = DallasQuery();
|
||||
trace_printf("temperatura DS: %d\r\n", (int)td);
|
||||
pressure = (float)SensorBringPressure();
|
||||
trace_printf("cisnienie MS: %d\r\n", (int)pressure);
|
||||
// while(ax25.afsk->hdlc.raw_dcd == TRUE);
|
||||
SendWXFrame(&VNAME, td, pressure);
|
||||
while (a.sending == 1);
|
||||
WXI = 1;
|
||||
}
|
||||
else
|
||||
WXI++;
|
||||
#endif
|
||||
*/
|
||||
// if (BcnInterval != 0 && BcnI >= BcnInterval) {
|
||||
#ifndef _MUTE_OWN
|
||||
// while(ax25.afsk->hdlc.raw_dcd == TRUE);
|
||||
// trace_printf("Wlasny beacon\r\n");
|
||||
// SendOwnBeacon();
|
||||
// while (a.sending == 1);
|
||||
#endif
|
||||
// BcnI = 1;
|
||||
// }
|
||||
// else
|
||||
// BcnI++;
|
||||
// if (TelemInterval != 0 && TelemI >= TelemInterval) {
|
||||
#ifndef _MUTE_OWN
|
||||
// trace_printf("Telemetria\r\n");
|
||||
// ch14 = ADCReturnChannel(14);
|
||||
// ch15 = ADCReturnChannel(15);
|
||||
// ADCStartConfig();
|
||||
// while(ax25.afsk->hdlc.raw_dcd == TRUE);
|
||||
// if (t % 12 == 0 || t == 0)
|
||||
// SendSimpleTelemetry(1);
|
||||
// else
|
||||
// SendSimpleTelemetry(0);
|
||||
// while (a.sending == 1);
|
||||
#endif
|
||||
// TelemI = 1;
|
||||
// }
|
||||
// else
|
||||
// TelemI++;
|
||||
}
|
||||
*/
|
||||
|
||||
void TIM4_IRQHandler( void ) {
|
||||
// obsluga przerwania cyfra-analog
|
||||
|
|
20
src/main.c
20
src/main.c
|
@ -72,9 +72,9 @@ AX25Ctx main_ax25;
|
|||
Afsk main_afsk;
|
||||
|
||||
|
||||
AX25Call path[3];
|
||||
uint8_t path_len = 0;
|
||||
uint8_t aprs_msg_len;
|
||||
AX25Call main_own_path[3];
|
||||
uint8_t main_own_path_ln = 0;
|
||||
uint8_t main_own_aprs_msg_len;
|
||||
char main_own_aprs_msg[160];
|
||||
|
||||
// global variable used to store return value from various functions
|
||||
|
@ -102,11 +102,13 @@ main(int argc, char* argv[])
|
|||
|
||||
memset(main_own_aprs_msg, 0x00, 128);
|
||||
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
|
||||
|
||||
// choosing the signal source for the SysTick timer.
|
||||
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
|
||||
|
||||
// Configuring the SysTick timer to generate interrupt 100x per second (one interrupt = 10ms)
|
||||
SysTick_Config(SystemCoreClock / 100);
|
||||
SysTick_Config(SystemCoreClock / SYSTICK_TICKS_PER_SECONDS);
|
||||
|
||||
#if defined _RANDOM_DELAY
|
||||
// configuring a default delay value
|
||||
|
@ -117,7 +119,7 @@ main(int argc, char* argv[])
|
|||
#endif
|
||||
|
||||
// configuring an APRS path used to transmit own packets (telemetry, wx, beacons)
|
||||
path_len = ConfigPath(path);
|
||||
main_own_path_ln = ConfigPath(main_own_path);
|
||||
|
||||
#ifdef _METEO
|
||||
i2cConfigure();
|
||||
|
@ -146,13 +148,13 @@ main(int argc, char* argv[])
|
|||
#endif
|
||||
|
||||
// preparing initial beacon which will be sent to host PC using KISS protocol via UART
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, "=%07.2f%c%c%08.2f%c%c %s", (float)_LAT, _LATNS, _SYMBOL_F, (float)_LON, _LONWE, _SYMBOL_S, _COMMENT);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, "=%07.2f%c%c%08.2f%c%c %s", (float)_LAT, _LATNS, _SYMBOL_F, (float)_LON, _LONWE, _SYMBOL_S, _COMMENT);
|
||||
|
||||
// terminating the aprs message
|
||||
main_own_aprs_msg[aprs_msg_len] = 0;
|
||||
main_own_aprs_msg[main_own_aprs_msg_len] = 0;
|
||||
|
||||
// 'sending' the message which will only encapsulate it inside AX25 protocol (ax25_starttx is not called here)
|
||||
ax25_sendVia(&main_ax25, path, (sizeof(path) / sizeof(*(path))), main_own_aprs_msg, aprs_msg_len);
|
||||
ax25_sendVia(&main_ax25, main_own_path, (sizeof(main_own_path) / sizeof(*(main_own_path))), main_own_aprs_msg, main_own_aprs_msg_len);
|
||||
|
||||
// SendKISSToHost function cleares the output buffer hence routine need to wait till the UART will be ready for next transmission.
|
||||
// Here this could be omitted because UART isn't used before but general idea
|
||||
|
@ -268,7 +270,7 @@ uint16_t main_get_adc_sample(void) {
|
|||
|
||||
void main_wx_decremenet_counter(void) {
|
||||
if (main_wx_sensors_pool_timer > 0)
|
||||
main_wx_sensors_pool_timer -= 10;
|
||||
main_wx_sensors_pool_timer -= SYSTICK_TICKS_PERIOD;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -13,8 +13,10 @@
|
|||
uint8_t packet_tx_beacon_interval = _BCN_INTERVAL;
|
||||
uint8_t packet_tx_beacon_counter = 0;
|
||||
|
||||
#ifdef _METEO
|
||||
uint8_t packet_tx_meteo_interval = _WX_INTERVAL;
|
||||
uint8_t packet_tx_meteo_counter = 0;
|
||||
#endif
|
||||
|
||||
uint8_t packet_tx_telemetry_interval = 10;
|
||||
uint8_t packet_tx_telemetry_counter = 0;
|
||||
|
@ -22,8 +24,10 @@ uint8_t packet_tx_telemetry_counter = 0;
|
|||
// this shall be called in 60 seconds periods
|
||||
void packet_tx_handler(void) {
|
||||
packet_tx_beacon_counter++;
|
||||
packet_tx_meteo_counter++;
|
||||
packet_tx_telemetry_counter++;
|
||||
#ifdef _METEO
|
||||
packet_tx_meteo_counter++;
|
||||
#endif
|
||||
|
||||
if (packet_tx_beacon_counter >= packet_tx_beacon_interval) {
|
||||
|
||||
|
@ -34,23 +38,41 @@ void packet_tx_handler(void) {
|
|||
packet_tx_beacon_counter = 0;
|
||||
}
|
||||
|
||||
#ifdef _METEO
|
||||
if (packet_tx_meteo_counter >= packet_tx_meteo_interval) {
|
||||
|
||||
#if defined _DALLAS_AS_TELEM
|
||||
// _DALLAS_AS_TELEM wil be set during compilation wx packets will be filled by temperature from MS5611 sensor
|
||||
SendWXFrame(&VNAME, rte_wx_temperature_valid, rte_wx_pressure_valid);
|
||||
#else
|
||||
SendWXFrame(&VNAME, rte_wx_temperature_dallas_valid, rte_wx_pressure_valid);
|
||||
|
||||
#endif
|
||||
main_wait_for_tx_complete();
|
||||
|
||||
packet_tx_meteo_counter = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (packet_tx_telemetry_counter >= packet_tx_telemetry_interval) {
|
||||
|
||||
|
||||
#if defined _DALLAS_AS_TELEM
|
||||
// if _DALLAS_AS_TELEM will be enabled the fifth channel will be set to temperature measured by DS12B20
|
||||
telemetry_send_values(rx10m, tx10m, digi10m, kiss10m, rte_wx_temperature_dallas_valid, rte_wx_dallas_qf, rte_wx_ms5611_qf, rte_wx_dht_valid.qf);
|
||||
#elif defined _METEO
|
||||
// if _METEO will be enabled, but without _DALLAS_AS_TELEM the fifth channel will be used to transmit temperature from MS5611
|
||||
// which may be treated then as 'rack/cabinet internal temperature'. Dallas DS12B10 will be used for ragular WX frames
|
||||
telemetry_send_values(rx10m, tx10m, digi10m, kiss10m, rte_wx_temperature_valid, rte_wx_dallas_qf, rte_wx_ms5611_qf, rte_wx_dht.qf);
|
||||
#else
|
||||
// if user will disable both _METEO and _DALLAS_AS_TELEM value will be zeroed internally anyway
|
||||
telemetry_send_values(rx10m, tx10m, digi10m, kiss10m, 0.0f, rte_wx_dallas_qf, rte_wx_ms5611_qf, rte_wx_dht.qf);
|
||||
#endif
|
||||
|
||||
main_wait_for_tx_complete();
|
||||
|
||||
packet_tx_telemetry_counter = 0;
|
||||
|
||||
rx10m = 0, tx10m = 0, digi10m = 0, kiss10m = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,12 +61,16 @@ void wx_pool_dht22(void) {
|
|||
break;
|
||||
case DHT22_STATE_DATA_DECD:
|
||||
rte_wx_dht_valid = rte_wx_dht; // powrot do stanu DHT22_STATE_IDLE jest w TIM3_IRQHandler
|
||||
//rte_wx_dht_valid.qf = DHT22_QF_FULL;
|
||||
dht22State = DHT22_STATE_DONE;
|
||||
|
||||
#ifdef _DBG_TRACE
|
||||
trace_printf("DHT22: temperature=%d,humi=%d\r\n", dht_valid.scaledTemperature, dht_valid.humidity);
|
||||
#endif
|
||||
break;
|
||||
case DHT22_STATE_TIMEOUT:
|
||||
rte_wx_dht_valid.qf = DHT22_QF_UNAVALIABLE;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
#define DHT22_STATE_IDLE 10
|
||||
#define DHT22_STATE_COMMS 11
|
||||
#define DHT22_STATE_DATA_RDY 12
|
||||
#define DHT22_STATE_DATA_DECD 13
|
||||
#define DHT22_STATE_DATA_RDY 12 // data has been rxed from a sensor and it is ready for decoding
|
||||
#define DHT22_STATE_DATA_DECD 13 // data has been decoded
|
||||
#define DHT22_STATE_TIMEOUT 14
|
||||
#define DHT22_STATE_DONE 15
|
||||
#define DHT22_STATE_COMMS_IRQ 16
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
|
||||
void SendOwnBeacon(void) {
|
||||
// BcnLng = sprintf(BcnInfoField, "=%07.2f%c%c%08.2f%c%c %s", this->Settings.Lat, this->Settings.LatNS, this->Settings.BcnSymbolF, this->Settings.Lon, this->Settings.LonWE, this->Settings.BcnSymbolS, this->Settings.Comment);
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, "=%07.2f%c%c%08.2f%c%c %s\0", (float)_LAT, _LATNS, _SYMBOL_F, (float)_LON, _LONWE, _SYMBOL_S, _COMMENT);
|
||||
main_own_aprs_msg[aprs_msg_len] = 0;
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, "=%07.2f%c%c%08.2f%c%c %s\0", (float)_LAT, _LATNS, _SYMBOL_F, (float)_LON, _LONWE, _SYMBOL_S, _COMMENT);
|
||||
main_own_aprs_msg[main_own_aprs_msg_len] = 0;
|
||||
// fifo_flush(&a.tx_fifo);
|
||||
ax25_sendVia(&main_ax25, path, path_len, main_own_aprs_msg, aprs_msg_len);
|
||||
ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len);
|
||||
after_tx_lock = 1;
|
||||
// for(jj = 0; jj <= 0xFBFFF; jj++);
|
||||
// while(ax25.dcd == true);
|
||||
|
|
|
@ -16,16 +16,16 @@ void telemetry_send_chns_description(void) {
|
|||
while (main_afsk.sending == 1);
|
||||
|
||||
#if (_SSID == 0)
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, ":%s :PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,MS_QF_FULL,DHT_QF_FULL,N", _CALL);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s :PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,MS_QF_FULL,DHT_QF_FULL,N", _CALL);
|
||||
#endif
|
||||
#if (_SSID > 0 && _SSID <= 9)
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d :PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,MS_QF_FULL,DHT_QF_FULL,N", _CALL, _SSID);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d :PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,MS_QF_FULL,DHT_QF_FULL,N", _CALL, _SSID);
|
||||
#endif
|
||||
#if (_SSID > 9 && _SSID <= 15)
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRADA,DS_QF_NAVBLE,MS_QF_FULL,DHT_QF_FULL,N", _CALL, _SSID);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRADA,DS_QF_NAVBLE,MS_QF_FULL,DHT_QF_FULL,N", _CALL, _SSID);
|
||||
#endif
|
||||
main_own_aprs_msg[aprs_msg_len] = 0;
|
||||
ax25_sendVia(&main_ax25, path, path_len, main_own_aprs_msg, aprs_msg_len);
|
||||
main_own_aprs_msg[main_own_aprs_msg_len] = 0;
|
||||
ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len);
|
||||
after_tx_lock = 1;
|
||||
afsk_txStart(&main_afsk);
|
||||
|
||||
|
@ -34,16 +34,16 @@ aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:PARM.Rx10min,Tx10min,Digi10min
|
|||
delay_fixed(1200);
|
||||
|
||||
#if (_SSID == 0)
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, ":%s :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.25,-25", _CALL);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.25,-25", _CALL);
|
||||
#endif
|
||||
#if (_SSID > 0 && _SSID <= 9)
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.25,-25", _CALL, _SSID);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.25,-25", _CALL, _SSID);
|
||||
#endif
|
||||
#if (_SSID > 9 && _SSID <= 15)
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.25,-25", _CALL, _SSID);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.25,-25", _CALL, _SSID);
|
||||
#endif
|
||||
main_own_aprs_msg[aprs_msg_len] = 0;
|
||||
ax25_sendVia(&main_ax25, path, path_len, main_own_aprs_msg, aprs_msg_len);
|
||||
main_own_aprs_msg[main_own_aprs_msg_len] = 0;
|
||||
ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len);
|
||||
after_tx_lock = 1;
|
||||
afsk_txStart(&main_afsk);
|
||||
|
||||
|
@ -52,16 +52,16 @@ aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:PARM.Rx10min,Tx10min,Digi10min
|
|||
delay_fixed(1200);
|
||||
|
||||
#if (_SSID == 0)
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, ":%s :UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,N", _CALL);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s :UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,N", _CALL);
|
||||
#endif
|
||||
#if (_SSID > 0 && _SSID <= 9)
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d :UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,N", _CALL, _SSID);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d :UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,N", _CALL, _SSID);
|
||||
#endif
|
||||
#if (_SSID > 9 && _SSID <= 15)
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,N", _CALL, _SSID);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,N", _CALL, _SSID);
|
||||
#endif
|
||||
main_own_aprs_msg[aprs_msg_len] = 0;
|
||||
ax25_sendVia(&main_ax25, path, path_len, main_own_aprs_msg, aprs_msg_len);
|
||||
main_own_aprs_msg[main_own_aprs_msg_len] = 0;
|
||||
ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len);
|
||||
after_tx_lock = 1;
|
||||
afsk_txStart(&main_afsk);
|
||||
|
||||
|
@ -131,15 +131,15 @@ void telemetry_send_values( uint8_t rx_pkts,
|
|||
}
|
||||
|
||||
#ifdef _DALLAS_AS_TELEM
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, "T#%03d,%03d,%03d,%03d,%03d,%03d,%c%c%c%c%c000", telemetry_counter++, rx_pkts, tx_pkts, digi_pkts, kiss_pkts, scaled_temperature, qf, degr, nav, ms_qf_full, dht_qf_full);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, "T#%03d,%03d,%03d,%03d,%03d,%03d,%c%c%c%c%c000", telemetry_counter++, rx_pkts, tx_pkts, digi_pkts, kiss_pkts, scaled_temperature, qf, degr, nav, ms_qf_full, dht_qf_full);
|
||||
#else
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, "T#%03d,%03d,%03d,%03d,%03d,%03d,%c%c%c%c%c000", telemetry_counter++, rx_pkts, tx_pkts, digi_pkts, kiss_pkts, 0, qf, degr, nav, ms_qf_full, dht_qf_full);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, "T#%03d,%03d,%03d,%03d,%03d,%03d,%c%c%c%c%c000", telemetry_counter++, rx_pkts, tx_pkts, digi_pkts, kiss_pkts, 0, qf, degr, nav, ms_qf_full, dht_qf_full);
|
||||
#endif
|
||||
|
||||
if (telemetry_counter > 999)
|
||||
telemetry_counter = 0;
|
||||
main_own_aprs_msg[aprs_msg_len] = 0;
|
||||
ax25_sendVia(&main_ax25, path, path_len, main_own_aprs_msg, aprs_msg_len);
|
||||
main_own_aprs_msg[main_own_aprs_msg_len] = 0;
|
||||
ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len);
|
||||
after_tx_lock = 1;
|
||||
// while(ax25.dcd == true);
|
||||
|
||||
|
|
|
@ -34,10 +34,10 @@ void SendWXFrame(Anemometer* input, float temperatura, unsigned cisnienie) {
|
|||
wind_gusts_mph = (short)max_wind_speed + 1;
|
||||
else
|
||||
wind_gusts_mph = (short)max_wind_speed;
|
||||
aprs_msg_len = sprintf(main_own_aprs_msg, "!%07.2f%c%c%08.2f%c%c%03d/%03dg%03dt%03dr...p...P...b%05d", _LAT, _LATNS, '/', _LON, _LONWE, '_', /* kierunek */(short)(input->HistoryAVG[0].WindDirX), /* predkosc*/(int)wind_speed_mph, /* porywy */(short)(wind_gusts_mph), /*temperatura */(short)(temperatura*1.8+32), cisnienie *10);
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, "!%07.2f%c%c%08.2f%c%c%03d/%03dg%03dt%03dr...p...P...b%05d", _LAT, _LATNS, '/', _LON, _LONWE, '_', /* kierunek */(short)(input->HistoryAVG[0].WindDirX), /* predkosc*/(int)wind_speed_mph, /* porywy */(short)(wind_gusts_mph), /*temperatura */(short)(temperatura*1.8+32), cisnienie *10);
|
||||
// aprs_msg_len = sprintf(aprs_msg, "%s%03d/%03dg%03dt%03dr%03dp%03dP%03db%04d ~", "!5001.45N/02159.66E_", /* kierunek */90, /* predkosc*/(int)(2.1 * 2.23698), /* porywy */(short)(5.7 * 2.23698), /*temperatura */(short)(23 * 1.8 + 32), 0, 0, 0, 10130);
|
||||
main_own_aprs_msg[aprs_msg_len] = 0;
|
||||
ax25_sendVia(&main_ax25, path, path_len, main_own_aprs_msg, aprs_msg_len);
|
||||
main_own_aprs_msg[main_own_aprs_msg_len] = 0;
|
||||
ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len);
|
||||
after_tx_lock = 1;
|
||||
// for(jj = 0; jj <= 0x19FFFF; jj++);
|
||||
while(main_ax25.dcd == true);
|
||||
|
|
|
@ -143,18 +143,17 @@ void dht22_decode(dht22Values *data) {
|
|||
}
|
||||
else {
|
||||
data->qf = DHT22_QF_DEGRADATED;
|
||||
dht22State = DHT22_STATE_IDLE;
|
||||
dht22State = DHT22_STATE_DATA_DECD;
|
||||
}
|
||||
}
|
||||
|
||||
void dht22_timeout_keeper(void) {
|
||||
if (dht22State == DHT22_STATE_COMMS) {
|
||||
if (dht22State == DHT22_STATE_COMMS || dht22State == DHT22_STATE_COMMS_IRQ) {
|
||||
if (delay_5us == 0) {
|
||||
dht22State = DHT22_STATE_TIMEOUT;
|
||||
dht22_init();
|
||||
EXTI_Init(&exti_disable);
|
||||
DallasDeConfigTimer();
|
||||
|
||||
dht22State = DHT22_STATE_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ void DallasConfigTimer(void) {
|
|||
TIM2->CR1 |= TIM_CR1_CEN;
|
||||
TIM2->DIER |= 1;
|
||||
NVIC_EnableIRQ( TIM2_IRQn ); // enabling in case that it weren't been enabled earlier
|
||||
timm = 1;
|
||||
//timm = 1;
|
||||
}
|
||||
|
||||
void DallasDeConfigTimer(void) {
|
||||
|
@ -68,14 +68,14 @@ void DallasDeConfigTimer(void) {
|
|||
NVIC_EnableIRQ( 25 ); // anemometer
|
||||
|
||||
// reverting back to APRS timings
|
||||
NVIC_SetPriority(TIM4_IRQn, 1);
|
||||
TIM4->PSC = 0;
|
||||
TIM4->ARR = 2499;
|
||||
TIM4->CR1 |= TIM_CR1_DIR;
|
||||
TIM4->CR1 &= (0xFFFFFFFF ^ TIM_CR1_DIR);
|
||||
TIM4->DIER |= 1;
|
||||
//NVIC_SetPriority(TIM4_IRQn, 1);
|
||||
//TIM4->PSC = 0;
|
||||
//TIM4->ARR = 2499;
|
||||
//TIM4->CR1 |= TIM_CR1_DIR;
|
||||
//TIM4->CR1 &= (0xFFFFFFFF ^ TIM_CR1_DIR);
|
||||
//TIM4->DIER |= 1;
|
||||
// NVIC_EnableIRQ( TIM4_IRQn );
|
||||
timm = 0;
|
||||
//timm = 0;
|
||||
}
|
||||
|
||||
char DallasReset(void) {
|
||||
|
@ -181,6 +181,14 @@ float __attribute__((optimize("O0"))) DallasQuery(DallasQF *qf) {
|
|||
DallasDeConfigTimer();
|
||||
|
||||
crc = CalculateCRC8(data, 8);
|
||||
|
||||
if ((data[0] == 0x00 && data[1] == 0x00 && data[2] == 0x00 && data[3] == 0x00 && data[4] == 0x00 && data[5] == 0x00 && data[6] == 0x00) ||
|
||||
(data[0] == 0xFF && data[1] == 0xFF && data[2] == 0xFF && data[3] == 0xFF && data[4] == 0xFF && data[5] == 0xFF && data[6] == 0xFF))
|
||||
{
|
||||
*qf = DALLAS_QF_NOT_AVALIABLE;
|
||||
return -128.0f;
|
||||
}
|
||||
|
||||
if (crc == data[8]) {
|
||||
|
||||
temp3 = data[0] | (data[1] << 8); // combined LSB and MSB
|
||||
|
|
Ładowanie…
Reference in New Issue