Updated to Rev 04b

This commit is contained in:
adrcs 2025-02-10 13:03:31 -07:00 committed by GitHub
parent d6aad28fb1
commit 3b7d1e5993
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 104 additions and 3 deletions

View file

@ -49,6 +49,7 @@
#define GPS_FIX_LEN 20 // gps fix length
#define GPS_BFR_SIZE 140 // GPS buffer size
#if __ENABLE_GPS
// NMEA GGA Sentence fields
char *nmeaMsgTag = "RMC"; // sentence we are processing
enum {
@ -68,6 +69,35 @@ enum {
NMEA_STATE_MSG, // in the message
};
#define N_NMEA_SEN 14 // number of NMEA sentences
enum {
NMEA_CMD_DISABLED=0, // disabled
NMEA_CMD_ONCE, // once per fix
NMEA_CMD_2FIX, // once every 2 fixes
NMEA_CMD_3FIX, // once every 3 fixes
NMEA_CMD_4FIX, // once every 4 fixes
NMEA_CMD_5FIX, // once every 5 fixes
};
char *nmeaCmd = "$PMTK314"; // command
uint8_t senCmds[N_NMEA_SEN] = {
NMEA_CMD_DISABLED, // 0:GLL disabled
NMEA_CMD_ONCE, // 1: RMC once
NMEA_CMD_DISABLED, // 2: VTG disabled
NMEA_CMD_DISABLED, // 3: GGA disabled
NMEA_CMD_DISABLED, // 4: GSA disabled
NMEA_CMD_DISABLED, // 5: GSV disabled
NMEA_CMD_DISABLED, // 6 not used
NMEA_CMD_DISABLED, // 7
NMEA_CMD_DISABLED, // 13
NMEA_CMD_DISABLED, // 14
NMEA_CMD_DISABLED, // 15
NMEA_CMD_DISABLED, // 16
NMEA_CMD_DISABLED, // 17
NMEA_CMD_DISABLED // 18
};
#endif
// hemispheres
enum {
N_HEMI=0, // North
@ -97,6 +127,7 @@ uint8_t GPSProcBuf[GPS_BFR_SIZE];
uint8_t *GPSBufPtr;
uint8_t GPSMsgSize;
uint8_t NMEAState;
char cmdBuf[MAX_BEACON];
//
BOOL haveGPSFix = FALSE;
BOOL gpsEchoReady=FALSE;
@ -108,6 +139,7 @@ char *gpsFlds[GPS_BFR_SIZE];
// fwd Refs in this module in GPS mode
BOOL processGPSMessage(uint8_t *GPSMsgBuf, uint8_t bufferSize);
void sendGPSCmd(void);
#endif
//fwd refs w/o GPS
@ -158,6 +190,11 @@ void Beacon_Task_exec(void)
}
timerCtrValue = timerInitValue;
#if __ENABLE_GPS
// send a command to the GPS every beacon interval
sendGPSCmd();
#endif
// start with the header
beacon_hdr.setup.flags = setup_memory.params.setup_data.flags;
beacon_hdr.setup.txPower = setup_memory.params.radio_setup.outputPower;
@ -288,6 +325,37 @@ void GPS_Task_exec(void)
}
#if __ENABLE_GPS
/*
* Send a command to the GPS device to limit traffic
*/
void sendGPSCmd(void)
{
uint8_t cksum = 0;
char *buf = cmdBuf;
strcpy(buf, nmeaCmd);
buf += strlen(nmeaCmd);
for(int j=1;j<strlen(nmeaCmd);j++)
cksum ^= nmeaCmd[j];
for(int i=0;i<N_NMEA_SEN;i++) {
*buf = ',';
cksum ^= *buf++;
*buf = senCmds[i] + '0';
cksum ^= *buf++;
}
*buf++ = '*';
hex2ascii(cksum, buf);
buf += 2;
*buf++ = '\r';
*buf++ = '\n';
*buf = '\0';
uint16_t buflen = buf - cmdBuf;
LPUART_Send_String(cmdBuf, buflen);
}
/*
* Process an inbound GPS message
*/

View file

@ -191,6 +191,12 @@ BOOL Chat_Task_exec(void)
// escape key: get a destination call sign
case KEY_ESC:
if(destEnt) {
strcpy(dest_call, BROADCAST);
USART_Print_string("Destination set to broadcast\r\n");
destEnt=FALSE;
break;
}
if(keyPos == 0) {
USART_Print_string("%s->", entCall);
dp = dest_call;

View file

@ -237,8 +237,12 @@ void USART_Print_string(char *format, ...)
// Transmit completed: trigger semaphore
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
#if __ENABLE_GPS
// Not interested in LPUART
if(huart->Instance == LPUART1)
return;
#endif
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xSemaphoreGiveFromISR(txCompleted, &xHigherPriorityTaskWoken);
}
@ -269,6 +273,14 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
}
#if __ENABLE_GPS
// send a string to the LPUART
void LPUART_Send_String(char *str, uint16_t len)
{
// send using interrupt
HAL_UART_Transmit_IT(&hlpuart1, (const uint8_t *)str, len);
}
// receive a byte with DMA, wait for DMA completed interrupt
void LPUART_Receive_char(void)
{

View file

@ -39,13 +39,28 @@ int ascii2Dec(char *dec)
return retval*sgn;
}
// nibble to ascii
char nib2ascii(uint8_t nib)
{
char anib = (char)(nib + '0');
anib = (anib > '9') ? anib+('A'-'9') : anib;
return anib;
}
// hex to ascii
void hex2ascii(uint8_t hex, char *buf)
{
*buf++= nib2ascii(hex>>4);
*buf = nib2ascii(hex & 0xf);
}
// see if an entry is floating point
BOOL isfloat(char *val)
{
while(*val)
if(*val++ == '.')
return TRUE;
return FALSE;
return 1U;
return 0U;
}
// convert an ascii string to a double