Merge pull request #2 from df8oe/master

some refactorings, removed unused functions and files, added license text of GPL v2
pull/4/head
Qyon 2017-06-09 16:29:46 +02:00 zatwierdzone przez GitHub
commit cb6d419afb
12 zmienionych plików z 675 dodań i 653 usunięć

Wyświetl plik

@ -3,28 +3,25 @@ include(CMakeForceCompiler)
SET(CMAKE_SYSTEM_NAME "Generic")
SET(CMAKE_SYSTEM_VERSION 1)
if(UNIX)
set(TOOLCHAIN_DIR /opt/gcc-arm-none-eabi-5_4-2016q3/bin/)
set(TOOLCHAIN_DIR "/opt/gcc-arm-none-eabi-5_4-2016q3/bin/")
CMAKE_FORCE_C_COMPILER(${TOOLCHAIN_DIR}/arm-none-eabi-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(${TOOLCHAIN_DIR}/arm-none-eabi-g++ GNU)
else()
set(TOOLCHAIN_DIR "D:/Programy/GNU Tools ARM Embedded/5.4 2016q3/bin")
CMAKE_FORCE_C_COMPILER(${TOOLCHAIN_DIR}/arm-none-eabi-gcc.exe GNU)
CMAKE_FORCE_CXX_COMPILER(${TOOLCHAIN_DIR}/arm-none-eabi-g++.exe GNU)
endif()
project(STM32_RTTY C ASM CXX)
add_definitions(-DSTM32F100C8)
add_definitions(-DSTM32F10X_MD_VL)
add_definitions(-DUSE_STDPERIPH_DRIVER)
add_definitions(-DSUPPORT_CPLUSPLUS)
add_definitions(-D__ASSEMBLY__)
SET(LINKER_SCRIPT ${PROJECT_SOURCE_DIR}/arm-gcc-link.ld)
SET(COMMON_FLAGS " -mcpu=cortex-m3 -mthumb -Wall -ffunction-sections -g -O3 -g -nostartfiles ")
SET(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")

75
LICENSE.txt 100644
Wyświetl plik

@ -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

Wyświetl plik

@ -1,12 +1,19 @@
# STM32_RTTY
STM32 & SI4032 rtty test
Released under GPL v2
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:
cd into main folder
cmake .
make
Have a nice day ;)
#Changelog

Wyświetl plik

@ -9,30 +9,54 @@
#include "config_external.h"
#else
//**************config**************
#define CALLSIGN "NO1LIC-1" // put your callsign here
#define APRS_CALLSIGN "NO1LIC"
#define APRS_SSID 'B'
//**************config**********************
#define CALLSIGN "DF8OE" // put your RTTY callsign here
#define APRS_CALLSIGN "DF8OE" // put your APRS callsign here
#define APRS_SSID 'B' // put your APRS SSID here
// 0 --> Your primary station usually fixed and message capable
// 1 --> generic additional station, digi, mobile, wx, etc.
// 2 --> generic additional station, digi, mobile, wx, etc.
// 3 --> generic additional station, digi, mobile, wx, etc.
// 4 --> generic additional station, digi, mobile, wx, etc.
// 5 --> Other network sources (Dstar, Iphones, Blackberry's etc)
// 6 --> Special activity, Satellite ops, camping or 6 meters, etc.
// 7 --> walkie talkies, HT's or other human portable
// 8 --> boats, sailboats, RV's or second main mobile
// 9 --> Primary Mobile (usually message capable)
// 10 --> internet, Igates, echolink, winlink, AVRS, APRN, etc.
// 11 --> balloons, aircraft, spacecraft, etc.
// 12 --> APRStt, DTMF, RFID, devices, one-way trackers*, etc.
// 13 --> Weather stations
// 14 --> Truckers or generally full time drivers
// 15 --> generic additional station, digi, mobile, wx, etc.
#define APRS_COMMENT " Hello from the sky!"
#define RTTY_TO_APRS_RATIO 5
#define RTTY_TO_APRS_RATIO 5 //transmit APRS packet with each x RTTY packet
//*************frequency********************
#define RTTY_FREQUENCY 434.500f //Mhz middle frequency
#define APRS_FREQUENCY 432.500f //Mhz middle frequency
//************rtty speed****************** si4032
#define RTTY_SPEED 300
// SHITY -> 450Hz
//************rtty bits****************** si4032
#define RTTY_7BIT 1
//************rtty stop bits****************** si4032
//************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 Smoc 7 // PWR 0...7 0- MIN ... 7 - MAX
// 7 -> 42.95 mW@434.150 MHz na E4406A
//***************************************************
#define TX_POWER 0 // PWR 0...7 0- MIN ... 7 - MAX
// 0 --> -8dBm
// 1 --> -5dBm
// 2 --> -2dBm
// 3 --> 1dBm
// 4 --> 4dBm
// 5 --> 7dBm
// 6 --> 10dBm
// 7 --> 13dBm
//****************************************************
// WARNING: do not use this in flying tracker!
#define ALLOW_DISABLE_BY_BUTTON 1
//********** frame delay in msec**********
//********** frame delay in msec**********************
#define tx_delay 5000
#endif

Wyświetl plik

@ -1,7 +1,7 @@
#include "f_rtty.h"
uint8_t start_bits;
rttyStates send_rtty(char *znak) {
rttyStates send_rtty(char *buffer) {
static uint8_t nr_bit = 0;
nr_bit++;
if (start_bits){
@ -13,7 +13,7 @@ rttyStates send_rtty(char *znak) {
return rttyZero;
}
if (nr_bit > 1 && nr_bit < (RTTY_7BIT ? 9 : 10)) {
if ((*(znak) >> (nr_bit - 2)) & 0x01) {
if ((*(buffer) >> (nr_bit - 2)) & 0x01) {
return rttyOne;
} else {
return rttyZero;

Wyświetl plik

@ -8,5 +8,5 @@ typedef enum {
} rttyStates;
static const uint8_t RTTY_PRE_START_BITS = 10;
rttyStates send_rtty(char *znak);
rttyStates send_rtty(char *);
extern uint8_t start_bits;

73
fun.c
Wyświetl plik

@ -1,73 +0,0 @@
#include <stm32f10x_usart.h>
#include <stm32f10x_spi.h>
#include <stm32f10x_gpio.h>
const char ascii[] = "0123456789ABCDEF";
int srednia_u[5] = {0, 0, 0, 0, 0};
int HexCharToInt(char ch) {
if (ch < 48 || (ch > 57 && ch < 65) || ch > 70) return 0;
return (ch < 58) ? ch - 48 : ch - 55;
}
void print(char *s) {
#ifdef DEBUG
while (*s) {
while (USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET) {
}
USART_SendData(USART3, *(s++));
}
#endif
}
void send_hex(unsigned char data) {
#ifdef DEBUG
while (USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET) {
}
USART_SendData(USART3, ascii[data >> 4]);
while (USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET) {
}
USART_SendData(USART3, ascii[data & 0x0f]);
#endif
}
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;
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;
}

8
fun.h
Wyświetl plik

@ -1,8 +0,0 @@
int HexCharToInt(char ch);
void print( char* s);
void send_hex(unsigned char data);
unsigned char czytaj_GPS(unsigned char pos,unsigned char len, char *source, char * destination);
uint16_t gps_CRC16_checksum (char *string);
int srednia (int dana);

22
init.c
Wyświetl plik

@ -20,7 +20,7 @@ DMA_InitTypeDef DMA_InitStructure;
#define ADC1_DR_Address ((uint32_t)0x4001244C)
#if defined(STM32F10X_CL)
#error "Bedzie problem z kwarcem!"
#error "clock oscillator problem!"
#endif
void init_usart_gps(const uint32_t speed, const uint8_t enable_irq) {
NVIC_DisableIRQ(USART1_IRQn);
@ -30,8 +30,8 @@ void init_usart_gps(const uint32_t speed, const uint8_t enable_irq) {
USART_Cmd(USART1, DISABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);// | RCC_APB2Periph_AFIO, ENABLE);
USART_InitStructure.USART_BaudRate = speed; //0x9c4;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
USART_InitStructure.USART_BaudRate = speed;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
@ -57,7 +57,7 @@ void init_usart_debug() {
NVIC_DisableIRQ(USART3_IRQn);
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_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
@ -87,10 +87,10 @@ void RCC_Conf()
{
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
FLASH_SetLatency(FLASH_Latency_2);
RCC_HCLKConfig(RCC_SYSCLK_Div4); // 24 / 4 -> 6
RCC_PCLK2Config(RCC_HCLK_Div4); // 6 / 4 = 1,5 -> APB2 -> TIMERS x 2
RCC_PCLK1Config(RCC_HCLK_Div2); // 6 / 2 = 3 -> APB1 -> TIMERS x 2
RCC_SYSCLKConfig(RCC_SYSCLKSource_HSE); // 24
RCC_HCLKConfig(RCC_SYSCLK_Div4);
RCC_PCLK2Config(RCC_HCLK_Div4);
RCC_PCLK1Config(RCC_HCLK_Div2);
RCC_SYSCLKConfig(RCC_SYSCLKSource_HSE);
while(RCC_GetSYSCLKSource() != 0x04);
}
}
@ -103,7 +103,7 @@ void init_port()
GPIO_Conf.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_Init(GPIOA, &GPIO_Conf);
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_Speed = GPIO_Speed_10MHz;
GPIO_Init(GPIOB, &GPIO_Conf);
@ -186,7 +186,7 @@ void init_port()
ADC_Cmd (ADC1,ENABLE); //enable ADC
ADC_ResetCalibration(ADC1); // Reset previous calibration
while(ADC_GetResetCalibrationStatus(ADC1));
ADC_StartCalibration(ADC1); // Start new calibration (ADC must be off at that time)
ADC_StartCalibration(ADC1); // start new calibration (ADC must be off at that time)
while(ADC_GetCalibrationStatus(ADC1));
ADC_SoftwareStartConvCmd(ADC1, ENABLE); // start conversion (will be endless as we are in continuous mode)
}
@ -227,7 +227,7 @@ void init_timer(const int rtty_speed) {
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, DISABLE);
TIM2_TimeBaseInitStruct.TIM_Prescaler = 6/*0*/ - 1;// tick every 1/1000000 s
TIM2_TimeBaseInitStruct.TIM_Prescaler = 6 - 1; // tick every 1/1000000 s
TIM2_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
TIM2_TimeBaseInitStruct.TIM_Period = (uint16_t) ((1000000 / rtty_speed) - 1);
TIM2_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1;

Wyświetl plik

@ -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 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);
radio_rw_register(0x72, 10, 1);
@ -48,7 +48,7 @@ void radio_enable_tx() {
int8_t radio_read_temperature() {
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);
radio_rw_register(0x0f, 0x80, 1);
return temperatura;