Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up various code (main, gps) #34

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e88631a
Revert previous commit "1.6.7"
tormodvolden Mar 18, 2022
8c7ed9d
Add AS923 channels
Mar 18, 2022
bcf6e78
Add app and AT feature for turning off GPS
Mar 18, 2022
749a46a
gps: Comment out spurious debug print
Mar 18, 2022
1488564
gps: Whitespace fix in GPS_INPUT()
Mar 18, 2022
b6ee51c
Updated MDK project settings
Mar 18, 2022
bf51c50
Delete autogenerated HTML file from repository
tormodvolden Mar 18, 2022
716040e
gcc: Use openocd 0.11 or newer for dual-bank support
tormodvolden Mar 19, 2022
2c5e757
gcc: Link code in two sections around the flash settings
tormodvolden Jan 27, 2022
f4d0497
gcc: Add printf with float support
tormodvolden Mar 22, 2022
b53999d
gcc: Add README.gcc with build/flash instructions
tormodvolden Mar 19, 2022
6ada1e2
gcc: Add make targets for reading or writing flash settings
tormodvolden Mar 19, 2022
59af65b
Fix hardcoded value for APP_TX_DUTYCYCLE
ubahnverleih Jan 23, 2020
71bfb62
Move flash address definitions to lora.h
tormodvolden Jan 19, 2022
7c3a278
New FLASH_USER_START_ADDR_FDR macro instead of magic address
tormodvolden Oct 8, 2021
42f9911
main: Tidy up gps_Identify()
tormodvolden Jan 18, 2022
bed394e
Tidy up battery voltage processing
tormodvolden Jan 19, 2022
7523be2
lora: Avoid using library atoi()
tormodvolden Oct 8, 2021
238ddbb
main: Eliminate TIMES variable that would never change
tormodvolden Jan 18, 2022
cf5d13c
main: Factor out uplink debug timestamp
tormodvolden Nov 16, 2021
a877c3d
main: Rename printf_uplink() to normalize_gps_coord()
tormodvolden Jan 18, 2022
a942870
Allow overriding debug baud rate
tormodvolden Jan 27, 2022
d0c3e97
gps: Comment out spurious debug print
tormodvolden Jan 21, 2022
9373089
gps: Print GPS debug info when buffers are updated
tormodvolden Nov 16, 2021
ba6b794
gps: Dump GPS buffer if debug level LOGGPS > 1
tormodvolden Nov 16, 2021
942818f
gps: Print date/time/satellites first in debug output
tormodvolden Nov 16, 2021
93ac44b
main: Fit more debug output on one line
tormodvolden Jan 19, 2022
dab7fbf
Tidy up normalize_gps_coord() whitespace and redundant PPRINTF
tormodvolden Mar 21, 2022
f4889ae
gps: Compacter debug output
tormodvolden Mar 22, 2022
20e02a4
gps: Rearrange compact debug output
tormodvolden Apr 20, 2022
3d47cac
gps: Use polling printf for gps buffer debug output
tormodvolden Apr 20, 2022
e0d479c
gps: Do not parse empty fields
tormodvolden Apr 20, 2022
595b2bb
gps: Check result of coordinate parsing
tormodvolden Apr 20, 2022
843ff3a
gps: Correct return whether parsing found a match or not
tormodvolden Apr 20, 2022
41a3f17
gps: Guard against incomplete checksum
tormodvolden Apr 20, 2022
3ff3a3e
gps: Zero-terminate previous sentence when new is started
tormodvolden Apr 20, 2022
5099114
gps: Remove old code destroying sentences
tormodvolden Apr 20, 2022
4f1c338
gps: Zero-terminate incoming sentence on CR or NL
tormodvolden Apr 20, 2022
78f3992
gcc: Display git revision in AT version info
tormodvolden Apr 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ static FLASH_EraseInitTypeDef EraseInitStruct;
/* Exported functions ---------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/
/* Erase the user Flash area
(area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
/* Erase the user Flash area */
void EEPROM_program(uint32_t add, uint32_t *data, uint8_t count)
{
uint32_t Address=0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ Maintainer: Miguel Luis and Gregory Cristian
* @note
* @retval None
*/
#define FLASH_USER_START_ADDR_CONFIG (FLASH_BASE + FLASH_PAGE_SIZE * 800) /* Start @ of user Flash area store config */
#define FLASH_USER_END_ADDR (FLASH_USER_START_ADDR + FLASH_PAGE_SIZE) /* End @ of user Flash area store key*/

#define FLASH_USER_START_ADDR_KEY (FLASH_BASE + FLASH_PAGE_SIZE * 802)
#define EEPROM_USER_Firmware_FLAGS (DATA_EEPROM_BASE+0x04*22)
#define EEPROM_IC_HARDWEAR (DATA_EEPROM_BASE+0x04*21)

Expand Down
150 changes: 88 additions & 62 deletions Drivers/BSP/Components/gps/gps.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "GPS.h"
#include <ctype.h>
#include "gps.h"
#include "at.h"
#include "vcom.h"
#include "delay.h"
Expand All @@ -14,7 +15,6 @@
char lasttime[20];
_Bool isrunning;
uint32_t isFirmwareUpdate = 0;
int count =0;
uint8_t gpspower_flag=0;
float pdop_gps;
char *txdata353;
Expand Down Expand Up @@ -402,7 +402,7 @@ char *split(char *buf,char s,char **left)
}


while(*p != 0 && *p != s && *p != '\r' && *p != '\n')
while(*p != 0 && *p != s)
{
p++;
}
Expand All @@ -417,6 +417,8 @@ char *split(char *buf,char s,char **left)
*left=NULL;
}

if (*ret == '\0')
ret = NULL;
return ret;
}

Expand All @@ -426,9 +428,8 @@ int check(char *sentence,char *cksum)
{

unsigned char *p=(unsigned char *)sentence,sum=0/*,ts*/;
if(sentence == NULL || cksum == NULL)
if (sentence == NULL || cksum == NULL || cksum[0] == '\0' || cksum[1] == '\0')
return 0;


for(; *p != 0; p++)
{
Expand All @@ -448,21 +449,27 @@ int check(char *sentence,char *cksum)
uint8_t GPS_parse(char *buf)
{
//printf("%s\n",buf);
int d,m,mm;
uint8_t i;
char *word,*left=buf+1;
static uint8_t msgcount=0,msgid=0,satcount=0; //����GSV�õ��ı���
//��ͨ�����õ����DZ��
uint8_t usedsatcount=0;
int valid;

if(buf[0] != '$')
return 0;


if (loggps > 1)
PPRINTF("GPS buffer: %s", buf);

word=split(left,ASTERISK,&left);
if(check(word,left) != 1)
return 0;
valid = check(word, left);

if (loggps > 1)
PPRINTF("%s\r\n", valid == 1 ? "" : " (ignored)");

if (valid != 1)
return 0;

left=word;

Expand All @@ -471,6 +478,7 @@ uint8_t GPS_parse(char *buf)
{
gps_setflags=1;
gpspower_flag=0;
return 1;
}

if(!strcmp(word,"GNRRMC"))
Expand Down Expand Up @@ -505,10 +513,13 @@ uint8_t GPS_parse(char *buf)
// AT_PRINTF("GNRMC3:%s\n\r",word);
if(word != NULL)
{

sscanf(word,"%2d%2d.%4d",&d,&m,&mm);
gps.latitude=(float)d+(float)m/60.0+(float)mm/600000.0;
PRINTF("%s: %.6f��\n\r",gps.latitude);
int d,m,mm,ret;
ret = sscanf(word,"%2d%2d.%4d",&d,&m,&mm);
if (ret == 3)
gps.latitude=(float)d+(float)m/60.0+(float)mm/600000.0;
else
return 0;
// AT_PRINTF("%s: %.6f��\n\r",gps.latitude);
}

//�ϱ������־
Expand All @@ -530,10 +541,13 @@ uint8_t GPS_parse(char *buf)
// AT_PRINTF("GNRMC5:%s\n\r",word);
if(word != NULL)
{
int d,m,mm;
sscanf(word,"%3d%2d.%4d",&d,&m,&mm);
gps.longitude = (float)d+(float)m/60.0+(float)mm/600000.0;
// PRINTF("%s: %.6f��\n\r",gps.longitude);
int d,m,mm,ret;
ret = sscanf(word,"%3d%2d.%4d",&d,&m,&mm);
if (ret == 3)
gps.longitude = (float)d+(float)m/60.0+(float)mm/600000.0;
else
return 0;
// AT_PRINTF("%s: %.6f��\n\r",gps.longitude);
}

//���������־
Expand Down Expand Up @@ -605,9 +619,12 @@ uint8_t GPS_parse(char *buf)
// AT_PRINTF("GPRMC2:%s\n\r",word);
if(word != NULL)
{

sscanf(word,"%2d%2d.%4d",&d,&m,&mm);
gps.latitude=(float)d+(float)m/60.0+(float)mm/600000.0;
int d,m,mm,ret;
ret = sscanf(word,"%2d%2d.%4d",&d,&m,&mm);
if (ret == 3)
gps.latitude=(float)d+(float)m/60.0+(float)mm/600000.0;
else
return 0;
}

//�ϱ������־
Expand All @@ -629,9 +646,12 @@ uint8_t GPS_parse(char *buf)
// AT_PRINTF("GPRMC4:%s\n\r",word);
if(word != NULL)
{
int d,m,mm;
sscanf(word,"%3d%2d.%4d",&d,&m,&mm);
gps.longitude = (float)d+(float)m/60.0+(float)mm/600000.0;
int d,m,mm,ret;
ret = sscanf(word,"%3d%2d.%4d",&d,&m,&mm);
if (ret == 3)
gps.longitude = (float)d+(float)m/60.0+(float)mm/600000.0;
else
return 0;
}

//���������־
Expand Down Expand Up @@ -691,9 +711,12 @@ uint8_t GPS_parse(char *buf)
// AT_PRINTF("GPGGA1:%s\n\r",word);
if(word != NULL)
{
int d,m,mm;
sscanf(word,"%2d%2d.%4d",&d,&m,&mm);
gps.latitude=(float)d+(float)m/60.0+(float)mm/600000.0;
int d,m,mm,ret;
ret = sscanf(word,"%2d%2d.%4d",&d,&m,&mm);
if (ret == 3)
gps.latitude=(float)d+(float)m/60.0+(float)mm/600000.0;
else
return 0;
}

//�ϱ������־
Expand All @@ -714,9 +737,12 @@ uint8_t GPS_parse(char *buf)
// AT_PRINTF("GPGGA3:%s\n\r",word);
if(word != NULL)
{
int d,m,mm;
sscanf(word,"%3d%2d.%4d",&d,&m,&mm);
gps.longitude=(float)d+(float)m/60.0+(float)mm/600000.0;
int d,m,mm,ret;
ret = sscanf(word,"%3d%2d.%4d",&d,&m,&mm);
if (ret == 3)
gps.longitude=(float)d+(float)m/60.0+(float)mm/600000.0;
else
return 0;
}

//���������־
Expand Down Expand Up @@ -908,7 +934,9 @@ uint8_t GPS_parse(char *buf)
{
gps.VDOP=(float)my_atof(word);
}
}
} else {
return 0; /* no matches */
}

if(gps.latitude > 90.0)
gps.latitude = 0.0;
Expand Down Expand Up @@ -939,6 +967,7 @@ struct {
return;
if(buffer == '$')
{
GPS_NEMA[NEMA_count].buffer[char_count] = '\0';
GPS_NEMA[NEMA_count].isupdated = 1; //������һ�������ϸ��±�־
NEMA_count++;
if(NEMA_count > (NEMA_NUM_MAX-1))
Expand All @@ -950,18 +979,13 @@ struct {
char_count = 1;

}
else
{
else
{
if (buffer == '\r' || buffer == '\n')
buffer = '\0';
if(char_count < NEMA_CHAR_MAX-1)
GPS_NEMA[NEMA_count].buffer[char_count++] = buffer;
}
count ++;
if(count == 255)
{
GPS_NEMA[NEMA_count].isupdated = 0 ;
GPS_NEMA[NEMA_count].buffer[char_count++] = 0 ;
count = 0;
}
}
uint8_t GPS_INFO_update(void)
{
Expand All @@ -971,7 +995,7 @@ uint8_t GPS_INFO_update(void)
{
if(GPS_NEMA[i].isupdated == 1)
{
temp = GPS_parse(GPS_NEMA[i].buffer);
temp |= GPS_parse(GPS_NEMA[i].buffer);
GPS_NEMA[i].isupdated = 0 ;
}
}
Expand Down Expand Up @@ -1049,29 +1073,31 @@ uint8_t GPS_INFO_update(void)

void GPS_INPUT(void)
{
int dd,mm;
int dd,mm;
FP32 ss;
//
GPS_INFO_update();
if(loggps == 1)
{
GPS_DegreeToDMS(gps.latitude, &dd, &mm,&ss);

AT_PRINTF("%s:%3d %2d'%5.2f ",(gps.latNS == 'N')?"North":"South",dd, mm, ss);
AT_PRINTF("%s: %.6f\n\r",(gps.latNS == 'N')?"North":"South",gps.latitude);

GPS_DegreeToDMS(gps.longitude, &dd, &mm,&ss);
AT_PRINTF("%s:%3d %2d'%05.2f",(gps.lgtEW == 'E')?"East":"West",dd, mm, ss);
AT_PRINTF("%s: %.6f\n\r ",(gps.lgtEW == 'E')?"East":"West",gps.longitude);
AT_PRINTF("Altitude:%.1f%c ",gps.altitude,gps.altitudeunit);
AT_PRINTF("Speed:%.1f km/h ",gps.speed);
AT_PRINTF("Course:%.1f ",gps.direction);
AT_PRINTF("Time:%2d:%02d:%02d ",(gps.hh<16)?gps.hh+8:gps.hh-16,gps.mm,gps.ss);
AT_PRINTF("Date:20%02d-%d-%d ",gps.YY,gps.MM,gps.DD);
AT_PRINTF("Satellite:%2d/%2d",gps.usedsatnum,gps.allsatnum);
AT_PRINTF("Mode:%2d\n\r",gps.GSA_mode2);
AT_PRINTF("PDOP:%.1f\n\r",pdop_gps);
}

if (GPS_INFO_update() && (loggps > 0))
{
AT_PRINTF("20%02d-%02d-%02dT", gps.YY, gps.MM, gps.DD);
AT_PRINTF("%02d:%02d:%02d ",gps.hh, gps.mm, gps.ss);
AT_PRINTF("Sat:%02d/%02d ", gps.usedsatnum, gps.allsatnum);

GPS_DegreeToDMS(gps.latitude, &dd, &mm,&ss);

// AT_PRINTF("%s:%3d %2d'%05.2f ", (gps.latNS == 'N')?"North":"South", dd, mm, ss);
AT_PRINTF("%s: %.6f ",(gps.latNS == 'N')?"North":"South", gps.latitude);

GPS_DegreeToDMS(gps.longitude, &dd, &mm,&ss);

// AT_PRINTF("%s:%3d %2d'%05.2f", (gps.lgtEW == 'E')?"East":"West", dd, mm, ss);
AT_PRINTF("%s: %.6f ",(gps.lgtEW == 'E')?"East":"West", gps.longitude);

AT_PRINTF("PDOP:%.1f\r\n", pdop_gps);
AT_PRINTF("Altitude:%.1f%c ", gps.altitude, gps.altitudeunit);
AT_PRINTF("Speed:%.1f km/h ", gps.speed);
AT_PRINTF("Course:%.1f ", gps.direction);
AT_PRINTF("Mode:%2d\r\n", gps.GSA_mode2);
}

switch(gps.FixMode)
{
Expand Down
2 changes: 1 addition & 1 deletion Drivers/BSP/Components/iwdg/iwdg.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Maintainer: Miguel Luis and Gregory Cristian
* @retval None
*/
void iwdg_init(void);
uint32_t GetLSIFrequency(void);
static uint32_t GetLSIFrequency(void);
void TIMER_IRQHandler(void);
void IWDG_Refresh(void);

Expand Down
2 changes: 1 addition & 1 deletion Middlewares/Third_Party/Lora/Mac/region/RegionAS923.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
#define AS923_LC2 { 917500000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
#else
#else
/*!
* LoRaMac default channel 1
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
Expand Down

This file was deleted.

Loading