kopia lustrzana https://github.com/Qyon/STM32_RTTY
some more refactorings, adding license text as original author's license wish
rodzic
c746fee8ff
commit
6426f48ff3
|
@ -0,0 +1,75 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
|
@ -1,12 +1,19 @@
|
||||||
# STM32_RTTY
|
# STM32_RTTY
|
||||||
STM32 & SI4032 rtty test
|
STM32 & SI4032 rtty test
|
||||||
|
|
||||||
|
Released under GPL v2
|
||||||
|
|
||||||
Use:
|
Use:
|
||||||
https://www.wyzbee.com/download/Utilities/Software/CoIDE-1.7.8.exe
|
https://www.wyzbee.com/download/Utilities/Software/CoIDE-1.7.8.exe
|
||||||
|
|
||||||
And:
|
And:
|
||||||
https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-win32.exe
|
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:
|
||||||
|
cd into main folder
|
||||||
|
cmake .
|
||||||
|
make
|
||||||
|
|
||||||
Have a nice day ;)
|
Have a nice day ;)
|
||||||
|
|
||||||
#Changelog
|
#Changelog
|
||||||
|
|
12
init.c
12
init.c
|
@ -57,7 +57,7 @@ void init_usart_debug() {
|
||||||
NVIC_DisableIRQ(USART3_IRQn);
|
NVIC_DisableIRQ(USART3_IRQn);
|
||||||
USART_Cmd(USART3, DISABLE);
|
USART_Cmd(USART3, DISABLE);
|
||||||
|
|
||||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);// | RCC_APB2Periph_AFIO, ENABLE);
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
|
||||||
USART_InitStructure.USART_BaudRate = 19200; //0x9c4;
|
USART_InitStructure.USART_BaudRate = 19200; //0x9c4;
|
||||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||||
|
@ -87,10 +87,10 @@ void RCC_Conf()
|
||||||
{
|
{
|
||||||
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
|
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
|
||||||
FLASH_SetLatency(FLASH_Latency_2);
|
FLASH_SetLatency(FLASH_Latency_2);
|
||||||
RCC_HCLKConfig(RCC_SYSCLK_Div4); // 24 / 4 -> 6
|
RCC_HCLKConfig(RCC_SYSCLK_Div4);
|
||||||
RCC_PCLK2Config(RCC_HCLK_Div4); // 6 / 4 = 1,5 -> APB2 -> TIMERS x 2
|
RCC_PCLK2Config(RCC_HCLK_Div4);
|
||||||
RCC_PCLK1Config(RCC_HCLK_Div2); // 6 / 2 = 3 -> APB1 -> TIMERS x 2
|
RCC_PCLK1Config(RCC_HCLK_Div2);
|
||||||
RCC_SYSCLKConfig(RCC_SYSCLKSource_HSE); // 24
|
RCC_SYSCLKConfig(RCC_SYSCLKSource_HSE);
|
||||||
while(RCC_GetSYSCLKSource() != 0x04);
|
while(RCC_GetSYSCLKSource() != 0x04);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ void init_port()
|
||||||
GPIO_Conf.GPIO_Speed = GPIO_Speed_10MHz;
|
GPIO_Conf.GPIO_Speed = GPIO_Speed_10MHz;
|
||||||
GPIO_Init(GPIOA, &GPIO_Conf);
|
GPIO_Init(GPIOA, &GPIO_Conf);
|
||||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||||
GPIO_Conf.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 ;//| GPIO_Pin_10;
|
GPIO_Conf.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8;
|
||||||
GPIO_Conf.GPIO_Mode = GPIO_Mode_Out_PP;
|
GPIO_Conf.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
GPIO_Conf.GPIO_Speed = GPIO_Speed_10MHz;
|
GPIO_Conf.GPIO_Speed = GPIO_Speed_10MHz;
|
||||||
GPIO_Init(GPIOB, &GPIO_Conf);
|
GPIO_Init(GPIOB, &GPIO_Conf);
|
||||||
|
|
52
main.c
52
main.c
|
@ -14,7 +14,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <misc.h>
|
#include <misc.h>
|
||||||
#include "f_rtty.h"
|
#include "f_rtty.h"
|
||||||
#include "fun.h"
|
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "radio.h"
|
#include "radio.h"
|
||||||
|
@ -33,7 +32,7 @@ unsigned int send_cun; //frame counter
|
||||||
char status[2] = {'N'};
|
char status[2] = {'N'};
|
||||||
int napiecie;
|
int napiecie;
|
||||||
|
|
||||||
volatile char flaga = 0;//((((tx_delay / 1000) & 0x0f) << 3) | TX_POWER);
|
volatile char flaga = 0;
|
||||||
uint16_t CRC_rtty = 0x12ab; //checksum
|
uint16_t CRC_rtty = 0x12ab; //checksum
|
||||||
char buf_rtty[200];
|
char buf_rtty[200];
|
||||||
|
|
||||||
|
@ -48,6 +47,9 @@ volatile uint16_t button_pressed = 0;
|
||||||
volatile uint8_t disable_armed = 0;
|
volatile uint8_t disable_armed = 0;
|
||||||
|
|
||||||
void send_rtty_packet();
|
void send_rtty_packet();
|
||||||
|
uint16_t gps_CRC16_checksum (char *string);
|
||||||
|
int srednia (int dana);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GPS data processing
|
* GPS data processing
|
||||||
|
@ -69,7 +71,7 @@ void TIM2_IRQHandler(void) {
|
||||||
if (aprs_is_active()){
|
if (aprs_is_active()){
|
||||||
aprs_timer_handler();
|
aprs_timer_handler();
|
||||||
} else {
|
} else {
|
||||||
if (tx_on /*&& ++cun_rtty == 17*/) {
|
if (tx_on) {
|
||||||
send_rtty_status = send_rtty((char *) rtty_buf);
|
send_rtty_status = send_rtty((char *) rtty_buf);
|
||||||
if (!disable_armed){
|
if (!disable_armed){
|
||||||
if (send_rtty_status == rttyEnd) {
|
if (send_rtty_status == rttyEnd) {
|
||||||
|
@ -145,10 +147,10 @@ int main(void) {
|
||||||
radio_rw_register(0x03, 0xff, 0);
|
radio_rw_register(0x03, 0xff, 0);
|
||||||
radio_rw_register(0x04, 0xff, 0);
|
radio_rw_register(0x04, 0xff, 0);
|
||||||
radio_soft_reset();
|
radio_soft_reset();
|
||||||
// programowanie czestotliwosci nadawania
|
// setting TX frequency
|
||||||
radio_set_tx_frequency(RTTY_FREQUENCY);
|
radio_set_tx_frequency(RTTY_FREQUENCY);
|
||||||
|
|
||||||
// Programowanie mocy nadajnika
|
// setting TX power
|
||||||
radio_rw_register(0x6D, 00 | (TX_POWER & 0x0007), 1);
|
radio_rw_register(0x6D, 00 | (TX_POWER & 0x0007), 1);
|
||||||
|
|
||||||
radio_rw_register(0x71, 0x00, 1);
|
radio_rw_register(0x71, 0x00, 1);
|
||||||
|
@ -219,7 +221,7 @@ void send_rtty_packet() {
|
||||||
(gpsData.alt_raw / 1000), temperatura, napiecie, gpsData.sats_raw,
|
(gpsData.alt_raw / 1000), temperatura, napiecie, gpsData.sats_raw,
|
||||||
gpsData.ok_packets, gpsData.bad_packets,
|
gpsData.ok_packets, gpsData.bad_packets,
|
||||||
flaga);
|
flaga);
|
||||||
CRC_rtty = 0xffff; //napiecie flaga
|
CRC_rtty = 0xffff; //napiecie flaga possibly not neccessary??
|
||||||
CRC_rtty = gps_CRC16_checksum(buf_rtty + 4);
|
CRC_rtty = gps_CRC16_checksum(buf_rtty + 4);
|
||||||
sprintf(buf_rtty, "%s*%04X\n", buf_rtty, CRC_rtty & 0xffff);
|
sprintf(buf_rtty, "%s*%04X\n", buf_rtty, CRC_rtty & 0xffff);
|
||||||
rtty_buf = buf_rtty;
|
rtty_buf = buf_rtty;
|
||||||
|
@ -229,6 +231,44 @@ void send_rtty_packet() {
|
||||||
send_cun++;
|
send_cun++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t gps_CRC16_checksum(char *string) {
|
||||||
|
uint16_t crc = 0xffff;
|
||||||
|
char i;
|
||||||
|
while (*(string) != 0) {
|
||||||
|
crc = crc ^ (*(string++) << 8);
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
if (crc & 0x8000)
|
||||||
|
crc = (uint16_t) ((crc << 1) ^ 0x1021);
|
||||||
|
else
|
||||||
|
crc <<= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int srednia(int dana) {
|
||||||
|
static uint8_t nr_pom = 0;
|
||||||
|
static uint8_t first = 1;
|
||||||
|
int srednia_u[5] = {0, 0, 0, 0, 0};
|
||||||
|
uint8_t i;
|
||||||
|
int sr = 0;
|
||||||
|
if (first) {
|
||||||
|
for (i = 0; i < 5; i++) {
|
||||||
|
srednia_u[i] = dana;
|
||||||
|
}
|
||||||
|
first = 0;
|
||||||
|
}
|
||||||
|
srednia_u[nr_pom] = dana;
|
||||||
|
if (++nr_pom > 4) {
|
||||||
|
nr_pom = 0;
|
||||||
|
}
|
||||||
|
for (i = 0; i < 5; i++) {
|
||||||
|
sr += srednia_u[i];
|
||||||
|
}
|
||||||
|
sr = sr / 5;
|
||||||
|
return sr;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void assert_failed(uint8_t* file, uint32_t line)
|
void assert_failed(uint8_t* file, uint32_t line)
|
||||||
{
|
{
|
||||||
|
|
4
radio.c
4
radio.c
|
@ -24,7 +24,7 @@ void radio_set_tx_frequency(const float freq_in_mhz) {
|
||||||
uint8_t hbsel = (uint8_t) ((freq_in_mhz * (30.0f / SI4032_CLOCK)) >= 480.0f ? 1 : 0);
|
uint8_t hbsel = (uint8_t) ((freq_in_mhz * (30.0f / SI4032_CLOCK)) >= 480.0f ? 1 : 0);
|
||||||
|
|
||||||
uint8_t fb = (uint8_t) ((((uint8_t)((freq_in_mhz * (30.0f / SI4032_CLOCK)) / 10) - 24) - (24 * hbsel)) / (1 + hbsel));
|
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; //Stała nie zmieniac
|
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);
|
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(0x72, 10, 1);
|
||||||
|
@ -48,7 +48,7 @@ void radio_enable_tx() {
|
||||||
|
|
||||||
int8_t radio_read_temperature() {
|
int8_t radio_read_temperature() {
|
||||||
uint8_t temp;
|
uint8_t temp;
|
||||||
temp = radio_rw_register(0x11, 0xff, 0); //odczyt ADC
|
temp = radio_rw_register(0x11, 0xff, 0); // read ADC
|
||||||
int8_t temperatura = (int8_t) (-64 + (temp * 5 / 10) - 16);
|
int8_t temperatura = (int8_t) (-64 + (temp * 5 / 10) - 16);
|
||||||
radio_rw_register(0x0f, 0x80, 1);
|
radio_rw_register(0x0f, 0x80, 1);
|
||||||
return temperatura;
|
return temperatura;
|
||||||
|
|
Ładowanie…
Reference in New Issue