Merge pull request #5 from df8oe/master

removed more functions without any effect
stable
Qyon 2017-06-14 14:45:14 +02:00 zatwierdzone przez GitHub
commit 09f79f95d1
9 zmienionych plików z 111 dodań i 79 usunięć

Wyświetl plik

@ -16,7 +16,7 @@ else()
CMAKE_FORCE_CXX_COMPILER(${TOOLCHAIN_DIR}/arm-none-eabi-g++.exe GNU)
endif()
project(STM32_RTTY C CXX)
project(RS41HUP C CXX)
add_definitions(-DSTM32F100C8)
add_definitions(-DSTM32F10X_MD_VL)
@ -60,5 +60,10 @@ set(CMAKE_CXX_STANDARD 11)
add_custom_target(program
DEPENDS ${PROJECT_NAME}.elf
COMMAND D:/Programy/stlink-1.3.0-win64/bin/st-flash --reset write ${BIN_FILE} 0x08000000
if(UNIX)
#TODO
else()
COMMAND D:/Programy/stlink-1.3.0-win64/bin/st-flash --reset write ${BIN_FILE} 0x08000000
endif()
COMMENT "flashing ${BIN_FILE}")

Wyświetl plik

@ -1,19 +1,46 @@
# STM32_RTTY
STM32 & SI4032 rtty test
# RS41HUP (Ham Use Project)
Firmware for Vaisala RS41 for HAM use
It is posible to recycle Vaisala's RS41-SGP sondes for amateur radio use without any electrical changes. You just have to build a new firmware (this one) and apply it via a cheap adaptor "ST-Linkv2". Modified sonde now transmits on defineable frequenca in 70cm band GPS and telemetry data in FSK RTTY format which is used by HAB projects and additionally it transmits APRS packets on a seperately defineable TX frequency.
Released under GPL v2
# Windows:
Use:
https://www.wyzbee.com/download/Utilities/Software/CoIDE-1.7.8.exe
And:
https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-win32.exe
Using Linux:
# Linux:
cd into main folder
cmake .
make
# Configuration
All configs in ```config.h```
Shift 450Hz
* ```CALLSIGN``` RTTY callsign
* ```APRS_CALLSIGN``` APRS callsign, 6 characters. If your callsign is shorter add spaces
* ```APRS_SSID``` APRS SSID
* ```APRS_COMMENT``` APRS comment
* ```RTTY_TO_APRS_RATIO``` number of RTTY frames between each APRS frame
* ```RTTY_FREQUENCY``` RTTY frequency in MHz
* ```APRS_FREQUENCY``` APRS frequency in MHz
* ```RTTY_DEVIATION``` RTTY shift configurable in 270Hz steps
* ```RTTY_SPEED``` RTTY speed in bauds
* ```RTTY_7BIT``` Use 7 bit RTTY
* ```RTTY_USE_2_STOP_BITS``` use 2 stop bits
* ```TX_POWER``` Power 0-7, (7 means 42.95 mW@434.150 MHz measured on E4406A)
* ```TX_DELAY``` Delay between frames in milliseconds
* ```ALLOW_DISABLE_BY_BUTTON``` Allow disabling device using button
Have a nice day ;)
#Changelog
@ -21,26 +48,15 @@ Have a nice day ;)
* 07.01.2017 - GPS now using proprietiary UBLOX protocol, more elastic code to set working frequency by SQ5RWU
* 23.01.2017 - Test APRS code, small fixes in GPS code by SQ5RWU
* 06.06.2017 - APRS code fix, some code cleanup
* June 2017 - starting with Linux support, making configuration more flexible by DF8OE
#TODO
* Adding support for EmbiTZ IDE
* Adding support for platform independent IDE Eclipse
* More APRS config options
* Temperature and moisture sensor?
# Configuration
All configs in ```config.h```
Shift 450Hz
* ```CALLSIGN``` RTTY callsign
* ```APRS_CALLSIGN``` APRS callsign, 6 characters. If your callsign is shorter add spaces
* ```APRS_COMMENT``` APRS comment
* ```APRS_SSID``` APRS SSID - '1' -> 1, 'A' -> 10 etc.
* ```RTTY_TO_APRS_RATIO``` number of RTTY frames between each APRS frame
* ```RTTY_FREQUENCY``` RTTY frequency in MHz
* ```APRS_FREQUENCY``` APRS frequency in MHz
* ```RTTY_SPEED``` RTTY speed in bauds
* ```RTTY_7BIT``` Use 7 bit RTTY
* ```RTTY_USE_2_STOP_BITS``` use 2 stop bits
* ```TX_POWER``` Power 0-7, where 7 means 42.95 mW@434.150 MHz measured on E4406A
* ```tx_delay``` Delay between frames in milliseconds
* ```ALLOW_DISABLE_BY_BUTTON``` Allow disabling device using button
* Temperature and moisture sensor
* Pressure sensor
* implementing protocol for using external devices on extension header
* Configuration via extension header (serial connection) without need for reflashing firmware
* Possibly add configuration "wireless" using RFID loop present in sonde

6
aprs.h
Wyświetl plik

@ -2,8 +2,8 @@
// Created by Admin on 2017-01-09.
//
#ifndef STM32_RTTY_APRS_H
#define STM32_RTTY_APRS_H
#ifndef RS41HUP_APRS_H
#define RS41HUP_APRS_H
#ifdef __cplusplus
#include <stdint.h>
@ -21,4 +21,4 @@ extern "C" {
#ifdef __cplusplus
};
#endif
#endif //STM32_RTTY_APRS_H
#endif //RS41HUP_APRS_H

Wyświetl plik

@ -2,13 +2,18 @@
// Created by SQ5RWU on 2016-12-24.
//
#ifndef STM32_RTTY_CONFIG_H
#define STM32_RTTY_CONFIG_H
#ifndef RS41HUP_CONFIG_H
#define RS41HUP_CONFIG_H
#ifdef USE_EXTERNAL_CONFIG
#include "config_external.h"
#else
//**************RTTY Data Format**********************
// $$<callsign>,<frame>,<hhmmss>,<latitude>,<longitude>,<height>,<radio chip temperature (°C)>,<battery voltage>,<used gps satellites>,<good gps datasets>,<bad gps datasets>,<gps fix>,<CRC>
//**************config**********************
#define CALLSIGN "NOCALL" // put your RTTY callsign here
#define APRS_CALLSIGN "NOCALL" // put your APRS callsign here, 6 characters. If your callsign is shorter add spaces
@ -33,16 +38,22 @@
#define APRS_COMMENT " Hello from the sky!"
#define RTTY_TO_APRS_RATIO 5 //transmit APRS packet with each x RTTY packet
//*************frequency********************
//*************TX Frequencies********************
#define RTTY_FREQUENCY 434.500f //Mhz middle frequency
#define APRS_FREQUENCY 432.500f //Mhz middle frequency
//************rtty speed*********************** si4032
//************RTTY Shift*********************** si4032
#define RTTY_DEVIATION 0x2 // RTTY shift = RTTY_DEVIATION x 270Hz
//************RTTY Speed*********************** si4032
#define RTTY_SPEED 75 // RTTY baudrate
// SHIFT is always 450Hz
//************rtty bits************************ si4032
#define RTTY_7BIT 1 // if 0 --> 5 bits
//************rtty stop bits******************* si4032
#define RTTY_USE_2_STOP_BITS 0
//********* power definition**************************
#define TX_POWER 0 // PWR 0...7 0- MIN ... 7 - MAX
// 0 --> -1dBm
@ -54,10 +65,13 @@
// 6 --> 17dBm
// 7 --> 20dBm
//****************************************************
// WARNING: do not use this in flying tracker!
// Switch sonde ON/OFF via Button
// If this is a flight you might prevent sonde from powered off by button
#define ALLOW_DISABLE_BY_BUTTON 1
//********** frame delay in msec**********************
#define tx_delay 5000
//********** Frame Delay in msec**********************
#define TX_DELAY 5000
#endif
#endif //STM32_RTTY_CONFIG_H
#endif //RS41HUP_CONFIG_H

Plik binarny nie jest wyświetlany.

68
main.c
Wyświetl plik

@ -31,6 +31,7 @@ char callsign[15] = {CALLSIGN};
unsigned int send_cun; //frame counter
char status[2] = {'N'};
int voltage;
volatile int adc_bottom = 2000;
volatile char flaga = 0;
uint16_t CRC_rtty = 0x12ab; //checksum
@ -48,7 +49,6 @@ volatile uint8_t disable_armed = 0;
void send_rtty_packet();
uint16_t gps_CRC16_checksum (char *string);
// int srednia (int dana);
/**
@ -67,6 +67,24 @@ void USART1_IRQHandler(void) {
void TIM2_IRQHandler(void) {
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) {
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
if (ALLOW_DISABLE_BY_BUTTON){
if (ADCVal[1] > adc_bottom * 1.1){
button_pressed++;
if (button_pressed > (5 * RTTY_SPEED)){
disable_armed = 1;
GPIO_SetBits(GPIOB, RED);
GPIO_SetBits(GPIOB, GREEN);
}
} else {
if (disable_armed){
GPIO_SetBits(GPIOA, GPIO_Pin_12);
}
button_pressed = 0;
}
if (button_pressed == 0) {
adc_bottom = ADCVal[1]; // dynamical reference for power down level
}
}
if (aprs_is_active()){
aprs_timer_handler();
@ -78,12 +96,12 @@ void TIM2_IRQHandler(void) {
GPIO_SetBits(GPIOB, RED);
if (*(++rtty_buf) == 0) {
tx_on = 0;
tx_on_delay = tx_delay / (1000/RTTY_SPEED);
tx_on_delay = TX_DELAY / (1000/RTTY_SPEED);
tx_enable = 0;
radio_disable_tx();
}
} else if (send_rtty_status == rttyOne) {
radio_rw_register(0x73, 0x02, 1);
radio_rw_register(0x73, RTTY_DEVIATION, 1);
GPIO_SetBits(GPIOB, RED);
} else if (send_rtty_status == rttyZero) {
radio_rw_register(0x73, 0x00, 1);
@ -107,21 +125,6 @@ void TIM2_IRQHandler(void) {
}
cun = 200;
}
if (ALLOW_DISABLE_BY_BUTTON){
if (ADCVal[1] > 1900){
button_pressed++;
if (button_pressed > (5 * RTTY_SPEED)){
disable_armed = 1;
GPIO_SetBits(GPIOB, RED);
GPIO_SetBits(GPIOB, GREEN);
}
} else {
if (disable_armed){
GPIO_SetBits(GPIOA, GPIO_Pin_12);
}
button_pressed = 0;
}
}
}
}
@ -143,25 +146,23 @@ int main(void) {
GPIO_SetBits(GPIOB, RED);
USART_SendData(USART3, 0xc);
// radio_rw_register(0x02, 0xff, 0);
// radio_rw_register(0x03, 0xff, 0);
// radio_rw_register(0x04, 0xff, 0);
radio_soft_reset();
// setting TX frequency
// setting RTTY TX frequency
radio_set_tx_frequency(RTTY_FREQUENCY);
// setting TX power
radio_rw_register(0x6D, 00 | (TX_POWER & 0x0007), 1);
// initial RTTY modulation
radio_rw_register(0x71, 0x00, 1);
// radio_rw_register(0x87, 0x08, 0);
// radio_rw_register(0x02, 0xff, 0);
// radio_rw_register(0x75, 0xff, 0);
// radio_rw_register(0x76, 0xff, 0);
// radio_rw_register(0x77, 0xff, 0);
radio_rw_register(0x12, 0x20, 1);
radio_rw_register(0x13, 0x00, 1);
// Temperature Value Offset
radio_rw_register(0x13, 0xF0, 1);
// Temperature Sensor Calibration
radio_rw_register(0x12, 0x00, 1);
// ADC configuration
radio_rw_register(0x0f, 0x80, 1);
rtty_buf = buf_rtty;
tx_on = 0;
@ -172,6 +173,7 @@ int main(void) {
uint8_t rtty_before_aprs_left = RTTY_TO_APRS_RATIO;
while (1) {
if (tx_on == 0 && tx_enable) {
if (rtty_before_aprs_left){
@ -184,7 +186,6 @@ int main(void) {
ublox_get_last_data(&gpsData);
USART_Cmd(USART1, DISABLE);
int8_t temperature = radio_read_temperature();
// uint16_t voltage = (uint16_t) srednia(ADCVal[0] * 600 / 4096);
uint16_t voltage = (uint16_t) ADCVal[0] * 600 / 4096;
aprs_send_position(gpsData, temperature, voltage);
USART_Cmd(USART1, ENABLE);
@ -202,7 +203,6 @@ void send_rtty_packet() {
start_bits = RTTY_PRE_START_BITS;
int8_t si4032_temperature = radio_read_temperature();
// voltage = srednia(ADCVal[0] * 600 / 4096);
voltage = ADCVal[0] * 600 / 4096;
GPSEntry gpsData;
ublox_get_last_data(&gpsData);
@ -216,14 +216,14 @@ void send_rtty_packet() {
uint8_t lon_d = (uint8_t) abs(gpsData.lon_raw / 10000000);
uint32_t lon_fl = (uint32_t) abs(abs(gpsData.lon_raw) - lon_d * 10000000) / 100;
sprintf(buf_rtty, "$$$$%s,%d,%02u%02u%02u,%s%d.%05ld,%s%d.%05ld,%ld,%d,%d,%d,%d,%d,%02x", callsign, send_cun,
sprintf(buf_rtty, "$$$$%s,%d,%02u%02u%02u,%s%d.%05ld,%s%d.%05ld,%ld,%d,%d.%d,%d,%d,%d,%02x", callsign, send_cun,
gpsData.hours, gpsData.minutes, gpsData.seconds,
gpsData.lat_raw < 0 ? "-" : "", lat_d, lat_fl,
gpsData.lon_raw < 0 ? "-" : "", lon_d, lon_fl,
(gpsData.alt_raw / 1000), si4032_temperature, voltage, gpsData.sats_raw,
(gpsData.alt_raw / 1000), si4032_temperature, voltage/100, voltage-voltage/100*100, gpsData.sats_raw,
gpsData.ok_packets, gpsData.bad_packets,
flaga);
CRC_rtty = 0xffff; //possibly not neccessary??
// CRC_rtty = 0xffff; //possibly not neccessary??
CRC_rtty = gps_CRC16_checksum(buf_rtty + 4);
sprintf(buf_rtty, "%s*%04X\n", buf_rtty, CRC_rtty & 0xffff);
rtty_buf = buf_rtty;

Wyświetl plik

@ -26,9 +26,6 @@ void radio_set_tx_frequency(const float freq_in_mhz) {
uint8_t fb = (uint8_t) ((((uint8_t)((freq_in_mhz * (30.0f / SI4032_CLOCK)) / 10) - 24) - (24 * hbsel)) / (1 + hbsel));
uint8_t gen_div = 3; // constant - not possible to change!
uint16_t fc = (uint16_t) (((freq_in_mhz / ((SI4032_CLOCK / gen_div) * (hbsel + 1))) - fb - 24) * 64000);
radio_rw_register(0x72, 10, 1);
radio_rw_register(0x75, (uint8_t) (0b01000000 | (fb & 0b11111) | ((hbsel & 0b1) << 5)), 1);
radio_rw_register(0x76, (uint8_t) (((uint16_t)fc >> 8) & 0xff), 1);
radio_rw_register(0x77, (uint8_t) ((uint16_t)fc & 0xff), 1);

Wyświetl plik

@ -2,8 +2,8 @@
// Created by SQ5RWU on 2016-12-24.
//
#ifndef STM32_RTTY_RADIO_H
#define STM32_RTTY_RADIO_H
#ifndef RS41HUP_RADIO_H
#define RS41HUP_RADIO_H
#include "config.h"
#include <stdint.h>
@ -37,4 +37,4 @@ int8_t radio_read_temperature();
}
#endif
#endif //STM32_RTTY_RADIO_H
#endif //RS41HUP_RADIO_H

Wyświetl plik

@ -2,8 +2,8 @@
// Created by SQ5RWU on 2016-12-27.
//
#ifndef STM32_RTTY_UBLOX_H
#define STM32_RTTY_UBLOX_H
#ifndef RS41HUP_UBLOX_H
#define RS41HUP_UBLOX_H
#include <stdint.h>
typedef struct {
@ -207,4 +207,4 @@ void ublox_handle_incoming_byte(uint8_t data);
void ublox_handle_packet(uBloxPacket *pkt);
uint8_t ublox_wait_for_ack();
#endif //STM32_RTTY_UBLOX_H
#endif //RS41HUP_UBLOX_H