kopia lustrzana https://github.com/sq2ips/m20-custom-firmware
Code cleanup for includes, making use of static and const
rodzic
56d5649e0f
commit
3a8f04a128
|
@ -1,7 +1,7 @@
|
|||
#ifndef ADF_H_
|
||||
#define ADF_H_
|
||||
|
||||
#include "main.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void adf_reset_config(void);
|
||||
void adf_reset_register_zero(void);
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
#ifndef INC_FSK4_H_
|
||||
#define INC_FSK4_H_
|
||||
|
||||
#include "main.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void FSK4_stop_TX();
|
||||
void FSK_4_send_2bit(uint8_t bits_to_send);
|
||||
uint8_t FSK4_is_active();
|
||||
void FSK_4_write(char* buff, uint16_t adress_2bit);
|
||||
bool FSK4_is_active();
|
||||
void FSK4_timer_handler();
|
||||
void FSK4_start_TX(char* buff, uint8_t len);
|
||||
|
||||
|
||||
#endif /* INC_HORUS_TRANSMIT_H_ */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef INC_HORUS_H_
|
||||
#define INC_HORUS_H_
|
||||
|
||||
#include "main.h"
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct TBinaryPacket{
|
||||
uint16_t PayloadID;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#define __USE_BAROMETER
|
||||
|
||||
/* Includes --------------------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include <stdint.h>
|
||||
//#include "stm32l0xx_hal_conf.h"
|
||||
//#include "algorithms\mathUnit.h"
|
||||
|
||||
|
@ -127,9 +127,6 @@ typedef struct {
|
|||
#define LPS22HB_SENS_DEGC (100.0f)
|
||||
|
||||
/* Exported functions ----------------------------------------------------------------------*/
|
||||
uint8_t SPI_RW( uint8_t sendByte );
|
||||
void LPS22_WriteReg( uint8_t writeAddr, uint8_t writeData );
|
||||
uint8_t LPS22_ReadReg( uint8_t readAddr );
|
||||
|
||||
uint8_t LPS22_Init( void );
|
||||
uint8_t LPS22_DeviceCheck( void );
|
||||
|
|
|
@ -52,12 +52,10 @@ extern "C" {
|
|||
/* USER CODE BEGIN Includes */
|
||||
#include "stm32l0xx_it.h"
|
||||
#include "fsk4.h"
|
||||
#include "config.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
typedef enum { false, true } bool;
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
|
|
@ -20,31 +20,28 @@
|
|||
// set counter to 1000-1
|
||||
|
||||
|
||||
uint16_t current_2_bit = 0;
|
||||
uint8_t FSK_Active = 0;
|
||||
char* buffer;
|
||||
uint8_t buffer_len;
|
||||
|
||||
static uint16_t current_2_bit = 0;
|
||||
static bool FSK_Active = false;
|
||||
static char* buffer;
|
||||
static uint8_t buffer_len;
|
||||
|
||||
void FSK4_stop_TX() {
|
||||
|
||||
TIM2->DIER &= ~(TIM_DIER_UIE); /* Disable the interrupt */
|
||||
adf_RF_off(); //turn TX off
|
||||
FSK_Active = 0;
|
||||
FSK_Active = false;
|
||||
}
|
||||
|
||||
|
||||
void FSK4_send_2bit(uint8_t bits_to_send) { //sends 2 bit value
|
||||
static void FSK4_send_2bit(uint8_t bits_to_send) { //sends 2 bit value
|
||||
bits_to_send = (bits_to_send & 3); //make sure to take only 2 last bites of value - we cannot send more than 2 bits at the same time
|
||||
adf_4fsk_fone(bits_to_send * FSK4_SPACE_MULTIPLIER);
|
||||
}
|
||||
|
||||
uint8_t FSK4_is_active() { //returns 1 if transmitter is active for 4FSK
|
||||
|
||||
return FSK_Active;
|
||||
bool FSK4_is_active() { //returns 1 if transmitter is active for 4FSK
|
||||
return FSK_Active;
|
||||
}
|
||||
|
||||
void FSK4_write(char* buff, uint16_t address_2bit) {
|
||||
static void FSK4_write(char* buff, uint16_t address_2bit) {
|
||||
int full_bytes = address_2bit / 4 ; //number of full bytes of address
|
||||
int fraction_part = address_2bit - (full_bytes * 4); // fraction part of address (number of 2bytes offset)
|
||||
uint8_t byte_to_send = (buff[full_bytes] >> (6-(fraction_part * 2)) & 3); // returns 2 bytes of buffer at address
|
||||
|
@ -84,17 +81,11 @@ void FSK4_start_TX(char* buff, uint8_t len) {
|
|||
//adf_setup();
|
||||
current_2_bit=0; //reset counter of current position of bit address
|
||||
adf_RF_on(QRG_FSK4, PA_FSK4); //turn on radio TX
|
||||
FSK_Active = 1; //change status
|
||||
FSK_Active = true; //change status
|
||||
TIM2->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN)); // Disable the TIM Counter
|
||||
uint16_t timer2StartValue = (100000 / FSK4_BAUD) - 1; //timer value calculated according to baud rate 999 for 100bd
|
||||
TIM2->ARR = timer2StartValue; //set timer counter max value to pre-set value for baudrate (auto-reload register)
|
||||
TIM2->CR1 |= TIM_CR1_CEN; //enable timer again
|
||||
TIM2->DIER |= TIM_DIER_UIE; //Enable the interrupt
|
||||
FSK4_timer_handler(buff); //force execution of procedure responsible for interrupt handling
|
||||
FSK4_timer_handler(); //force execution of procedure responsible for interrupt handling
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
static char uw[] = {'$','$'};
|
||||
const static char uw[] = {'$','$'};
|
||||
|
||||
#define X22 0x00400000 /* vector representation of X^{22} */
|
||||
#define X11 0x00000800 /* vector representation of X^{11} */
|
||||
|
@ -35,7 +35,7 @@ uint16_t crc16(char *string, uint8_t len) {
|
|||
|
||||
#ifdef INTERLEAVER
|
||||
|
||||
uint16_t primes[] = {
|
||||
const static uint16_t primes[] = {
|
||||
2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
|
||||
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
|
||||
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
|
||||
|
@ -309,4 +309,4 @@ void print_hex(char *data, uint8_t length, char *tmp) // prints 8-bit data in he
|
|||
}
|
||||
tmp[length*2] = '\n';
|
||||
tmp[length*2+1] = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,27 +7,27 @@
|
|||
// This file is specifically made for M20 radiosondes. Uses specific hardware connections.
|
||||
// file is basically customized KitSprout library https://github.com/KitSprout/KSDK
|
||||
|
||||
#include <stdint.h>
|
||||
#include "main.h"
|
||||
#include "lps22hb.h"
|
||||
//#include "math.h" //only for calculating altitude
|
||||
|
||||
/**
|
||||
* @brief SPI_RW
|
||||
*/
|
||||
uint8_t SPI_RW(uint8_t sendByte )
|
||||
static uint8_t SPI_RW(uint8_t sendByte )
|
||||
{
|
||||
SET_BIT(SPI1->CR1, SPI_CR1_SPE);
|
||||
SET_BIT(SPI1->CR1, SPI_CR1_SPE);
|
||||
while(((SPI1->SR) & SPI_SR_TXE) != SPI_SR_TXE); // wait while tx-flag not empty
|
||||
*(uint8_t *)&(SPI1->DR) = sendByte; // write data to be transmitted to the SPI data register
|
||||
while ((SPI1->SR & SPI_SR_RXNE) != SPI_SR_RXNE); // wait while rx-buffer not empty
|
||||
/* Wait until the bus is ready before releasing Chip select */
|
||||
while(((SPI1->SR) & SPI_SR_BSY) == SPI_SR_BSY);
|
||||
while(((SPI1->SR) & SPI_SR_BSY) == SPI_SR_BSY);
|
||||
CLEAR_BIT(SPI1->CR1, SPI_CR1_SPE);
|
||||
|
||||
return *(uint8_t *)&(SPI1->DR); // return received data from SPI data register
|
||||
}
|
||||
|
||||
void LPS22_WriteReg( uint8_t writeAddr, uint8_t writeData )
|
||||
static void LPS22_WriteReg( uint8_t writeAddr, uint8_t writeData )
|
||||
{
|
||||
LL_GPIO_ResetOutputPin(LPS_CS_GPIO_Port, LPS_CS_Pin);
|
||||
SPI_RW(writeAddr);
|
||||
|
@ -38,7 +38,7 @@ void LPS22_WriteReg( uint8_t writeAddr, uint8_t writeData )
|
|||
/**
|
||||
* @brief LPS22_ReadReg
|
||||
*/
|
||||
uint8_t LPS22_ReadReg( uint8_t readAddr )
|
||||
static uint8_t LPS22_ReadReg( uint8_t readAddr )
|
||||
{
|
||||
uint8_t readData;
|
||||
|
||||
|
@ -156,4 +156,4 @@ float LPS22_GetAltitude( float pressure )
|
|||
|
||||
return altitude;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -50,7 +50,7 @@ bool GpsBufferReady = false;
|
|||
|
||||
#if GPS_TYPE == 1
|
||||
NMEA NmeaData;
|
||||
static uint8_t GPS_airborne[44] = {0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0xD6};
|
||||
const static uint8_t GPS_airborne[44] = {0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0xD6};
|
||||
#elif GPS_TYPE == 2
|
||||
XMDATA GpsData;
|
||||
#endif
|
||||
|
@ -1037,7 +1037,7 @@ static void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
LL_GPIO_Init(NTC_475K_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
|
||||
/**/
|
||||
GPIO_InitStruct.Pin = NTC_36K_Pin;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
|
@ -1045,7 +1045,7 @@ static void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
LL_GPIO_Init(NTC_36K_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
|
||||
/**/
|
||||
GPIO_InitStruct.Pin = NTC_12K_Pin;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
|
@ -1053,7 +1053,7 @@ static void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
LL_GPIO_Init(NTC_12K_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
|
||||
/**/
|
||||
GPIO_InitStruct.Pin = NTC_330K_Pin;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
|
@ -1061,7 +1061,7 @@ static void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
LL_GPIO_Init(NTC_330K_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
|
||||
/**/
|
||||
GPIO_InitStruct.Pin = NTC_1M5_Pin;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
#endif
|
||||
#include <string.h>
|
||||
|
||||
char data[DATA_SIZE][SENTENCE_SIZE];
|
||||
static char data[DATA_SIZE][SENTENCE_SIZE];
|
||||
|
||||
uint8_t correct = 0;
|
||||
uint16_t olddAlt = 0;
|
||||
uint32_t olddTime = 0;
|
||||
static uint8_t correct = 0;
|
||||
static uint16_t olddAlt = 0;
|
||||
static uint32_t olddTime = 0;
|
||||
|
||||
uint16_t a_strtof(char *buffer){
|
||||
static uint16_t a_strtof(char *buffer){
|
||||
uint8_t d_pos = 0;
|
||||
uint16_t value = 0;
|
||||
|
||||
|
@ -36,7 +36,7 @@ uint16_t a_strtof(char *buffer){
|
|||
return value;
|
||||
}
|
||||
|
||||
uint8_t checksum(char *nmea_frame)
|
||||
static uint8_t checksum(char *nmea_frame)
|
||||
{
|
||||
//if you point a string with less than 5 characters the function will read outside of scope and crash the mcu.
|
||||
if(strlen(nmea_frame) < 5) return 0;
|
||||
|
@ -53,7 +53,7 @@ uint8_t checksum(char *nmea_frame)
|
|||
int receivedHash = 0;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
receivedHash <<= 4; // Shift left by 4 bits (equivalent to multiplying by 16)
|
||||
|
||||
|
||||
if (recv_crc[i] >= '0' && recv_crc[i] <= '9') {
|
||||
receivedHash += recv_crc[i] - '0'; // Convert '0'-'9' to 0-9
|
||||
} else if (recv_crc[i] >= 'A' && recv_crc[i] <= 'F') {
|
||||
|
@ -70,7 +70,7 @@ uint8_t checksum(char *nmea_frame)
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t getValues(char *inputString, char values[MAX_SENTENCE_ELEMENTS][SENTENCE_ELEMENT_LEN]) {
|
||||
static uint8_t getValues(char *inputString, char values[MAX_SENTENCE_ELEMENTS][SENTENCE_ELEMENT_LEN]) {
|
||||
uint8_t pos = 0;
|
||||
uint8_t d_pos = 0;
|
||||
uint8_t cnt = 0;
|
||||
|
@ -100,7 +100,7 @@ uint8_t getValues(char *inputString, char values[MAX_SENTENCE_ELEMENTS][SENTENCE
|
|||
return cnt;
|
||||
}
|
||||
|
||||
int nmea_GGA(NMEA *nmea_data, char *inputString){
|
||||
static bool nmea_GGA(NMEA *nmea_data, char *inputString){
|
||||
char values[MAX_SENTENCE_ELEMENTS][SENTENCE_ELEMENT_LEN];
|
||||
memset(values, 0, sizeof(values));
|
||||
uint8_t len = getValues(inputString, values);
|
||||
|
@ -117,7 +117,7 @@ int nmea_GGA(NMEA *nmea_data, char *inputString){
|
|||
}
|
||||
|
||||
nmea_data->Sats = (values[7][0]-'0')*10 + (values[7][1]-'0');
|
||||
|
||||
|
||||
uint8_t lonSide = values[5][0];
|
||||
uint8_t latSide = values[3][0];
|
||||
if(latSide == 'S' || latSide == 'N'){
|
||||
|
@ -188,7 +188,7 @@ int nmea_GGA(NMEA *nmea_data, char *inputString){
|
|||
}
|
||||
|
||||
|
||||
int nmea_GSA(NMEA *nmea_data, char*inputString){
|
||||
static bool nmea_GSA(NMEA *nmea_data, char*inputString){
|
||||
char values[MAX_SENTENCE_ELEMENTS][SENTENCE_ELEMENT_LEN];
|
||||
memset(values, 0, sizeof(values));
|
||||
uint8_t len = getValues(inputString, values);
|
||||
|
@ -214,7 +214,7 @@ int nmea_GSA(NMEA *nmea_data, char*inputString){
|
|||
|
||||
|
||||
|
||||
int nmea_GLL(NMEA *nmea_data, char*inputString) {
|
||||
static bool nmea_GLL(NMEA *nmea_data, char*inputString) {
|
||||
char values[MAX_SENTENCE_ELEMENTS][SENTENCE_ELEMENT_LEN];
|
||||
memset(values, 0, sizeof(values));
|
||||
uint8_t len = getValues(inputString, values);
|
||||
|
@ -255,13 +255,13 @@ int nmea_GLL(NMEA *nmea_data, char*inputString) {
|
|||
|
||||
}
|
||||
|
||||
int nmea_VTG(NMEA *nmea_data, char*inputString) {
|
||||
static bool nmea_VTG(NMEA *nmea_data, char*inputString) {
|
||||
char values[MAX_SENTENCE_ELEMENTS][SENTENCE_ELEMENT_LEN];
|
||||
memset(values, 0, sizeof(values));
|
||||
uint8_t len = getValues(inputString, values);
|
||||
if(len<7) return 0;
|
||||
|
||||
nmea_data->Speed = a_strtof(values[7]); // 5 for knots, 7 for km/h
|
||||
nmea_data->Speed = a_strtof(values[7]); // 5 for knots, 7 for km/h
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -293,6 +293,6 @@ void ParseNMEA(NMEA *nmea_data, uint8_t *buffer){
|
|||
if (nmea_VTG(nmea_data, data[i])) correct++;
|
||||
}
|
||||
}
|
||||
nmea_data->Corr = correct;
|
||||
nmea_data->Corr = correct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM alpine:3.21
|
||||
FROM alpine:3.22
|
||||
|
||||
RUN apk add --no-cache make gcc-arm-none-eabi newlib-arm-none-eabi
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue