Skip to content

Commit

Permalink
Sn 6067 add rtk dgb to rmc bits (#799)
Browse files Browse the repository at this point in the history
* SN-6073_GRMCSerialPortRefactor initial work

* fix magic numbers

* pr updates

* make things work again

* renmae

* code readabilty

* Add RTK_dbg ToRMC bits

* remove GPX specific defines in SDK

* fix bug

* Update protocol_nmea.cpp

fix debug code bug

* Remove g_GpxRtkDebugReq

* remove wanning

* add to gitnore

* does this fix dev build

* white space
  • Loading branch information
tmcd249 authored Jan 7, 2025
1 parent a5152dd commit e7c232e
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 97 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ CMakeFiles/
/ros/ros2/log
/scripts/.venv
/src/version
ExampleProjects/InertialSense_log_reader_RegCmp/Log/
ExampleProjects/InertialSense_log_reader_RegCmp/CMakeSettings.json
124 changes: 62 additions & 62 deletions ExampleProjects/InertialSense_log_reader_RegCmp/LogReader_RegCmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,33 +205,33 @@ typedef void(*dma_callback_function)(void*);

typedef struct
{
uint32_t parent; // Pointer to parent peripheral management struct
uint8_t mode; // DMA_MODE_...
uint32_t tc_handler; // If non-null, this function pointer is called from within transfer complete interrupt handler when all data including queued data has been transferred.
uint8_t interrupt;
uint8_t interrupt_priority;
uint8_t priority; // DMA priority (DMA_PRIO_...)
uint8_t request_num; // DMA request ID, links channel to peripheral (DMA_IDX_... for index)
uint32_t periph_reg; // target 8-bit peripheral register (DMA_IDX_... for index)
uint32_t parent; // Pointer to parent peripheral management struct
uint8_t mode; // DMA_MODE_...
uint32_t tc_handler; // If non-null, this function pointer is called from within transfer complete interrupt handler when all data including queued data has been transferred.
uint8_t interrupt;
uint8_t interrupt_priority;
uint8_t priority; // DMA priority (DMA_PRIO_...)
uint8_t request_num; // DMA request ID, links channel to peripheral (DMA_IDX_... for index)
uint32_t periph_reg; // target 8-bit peripheral register (DMA_IDX_... for index)
uint32_t buf;
uint16_t buf_len; // Actual usable buffer length is one less (buf_len - 1)
uint16_t buf_len; // Actual usable buffer length is one less (buf_len - 1)
} dma_config_t_GPX;

typedef struct
{
bool dir; // DMA_RX or DMA_TX
bool circular; // DMA_CIRC_ON or DMA_CIRC_OFF
uint8_t priority; // DMA_PRIO_LOW, DMA_PRIO_MEDIUM, DMA_PRIO_HIGH, DMA_PRIO_VERY_HIGH
uint8_t interrupt;
uint8_t interrupt_priority; // 0 to 15, 15 is low
uint8_t dma_channel_select; // 0 to 7. See RM0394 11.6.7
uint8_t parent_type; // DMA_PARENT_USART, ...
uint32_t parent; // Pointer to parent init base
uint32_t periph_reg; // Pointer to peripheral register
uint32_t buf;
uint16_t buf_len; // This doesn't correspond to the length register, it is just however big the buffer is
bool linear_buf; // If true, the buffer is user-specified and we treat it like a non-circular buffer.
uint32_t tcie_handler; // If non-null on init, transfer complete irq will be enabled, and this fn called by the IRQ
bool dir; // DMA_RX or DMA_TX
bool circular; // DMA_CIRC_ON or DMA_CIRC_OFF
uint8_t priority; // DMA_PRIO_LOW, DMA_PRIO_MEDIUM, DMA_PRIO_HIGH, DMA_PRIO_VERY_HIGH
uint8_t interrupt;
uint8_t interrupt_priority; // 0 to 15, 15 is low
uint8_t dma_channel_select; // 0 to 7. See RM0394 11.6.7
uint8_t parent_type; // DMA_PARENT_USART, ...
uint32_t parent; // Pointer to parent init base
uint32_t periph_reg; // Pointer to peripheral register
uint32_t buf;
uint16_t buf_len; // This doesn't correspond to the length register, it is just however big the buffer is
bool linear_buf; // If true, the buffer is user-specified and we treat it like a non-circular buffer.
uint32_t tcie_handler; // If non-null on init, transfer complete irq will be enabled, and this fn called by the IRQ
} dma_config_t_IMX;

typedef struct
Expand All @@ -256,22 +256,22 @@ typedef union

typedef struct
{
volatile uint16_t active_tx_len;
uint32_t lli_head; // Linked list output to dma
uint32_t lli_tail; // Linked list input from dma_buffer_write()
volatile bool dma_running;
volatile uint16_t active_tx_len;
uint32_t lli_head; // Linked list output to dma
uint32_t lli_tail; // Linked list input from dma_buffer_write()
volatile bool dma_running;
} dma_tx_state_t;

typedef struct dma_channel_
{
uint32_t instance;
volatile uint32_t ptr_start;
volatile uint32_t ptr_end;
dma_config_t_GPX cfg;
dma_lli_u lli; // Linked list memory. DMA_MODE_TX_LLI uses 6, DMA_MODE_RX_CIRC uses 1.
dma_tx_state_t txState;
int lastDmaUsed;
uint8_t overflow; // Buffer overflow
dma_config_t_GPX cfg;
dma_lli_u lli; // Linked list memory. DMA_MODE_TX_LLI uses 6, DMA_MODE_RX_CIRC uses 1.
dma_tx_state_t txState;
int lastDmaUsed;
uint8_t overflow; // Buffer overflow
} dma_ch_t_GPX;

typedef struct
Expand Down Expand Up @@ -318,11 +318,11 @@ typedef struct
uint32_t instance;
uint32_t ptr_start;
uint32_t ptr_end;
uint16_t active_tx_len;
bool done; // Currently only used in TX
dma_config_t_IMX cfg;
int lastDmaUsed; // Number of bytes in the buffer minus bytes last read. This is used to identify buffer overflow.
uint8_t overflow; // Buffer overflow
uint16_t active_tx_len;
bool done; // Currently only used in TX
dma_config_t_IMX cfg;
int lastDmaUsed; // Number of bytes in the buffer minus bytes last read. This is used to identify buffer overflow.
uint8_t overflow; // Buffer overflow
} dma_ch_t_IMX;

typedef struct
Expand All @@ -347,32 +347,32 @@ typedef struct
PUSH_PACK_1

typedef struct{
uint32_t inst_CCR; /*!< DMA channel x configuration register */
uint32_t inst_CNDTR; /*!< DMA channel x number of data register */
uint32_t inst_CPAR; /*!< DMA channel x peripheral address register */
uint32_t inst_CMAR; /*!< DMA channel x memory address register */

uint32_t ptr_start;
uint32_t ptr_end;
uint16_t active_tx_len;
uint8_t done; // Currently only used in TX

uint8_t cfg_dir; // DMA_RX or DMA_TX
uint8_t cfg_circular; // DMA_CIRC_ON or DMA_CIRC_OFF
uint8_t cfg_priority; // DMA_PRIO_LOW, DMA_PRIO_MEDIUM, DMA_PRIO_HIGH, DMA_PRIO_VERY_HIGH
uint8_t cfg_interrupt;
uint8_t cfg_interrupt_priority; // 0 to 15, 15 is low
uint8_t cfg_dma_channel_select; // 0 to 7. See RM0394 11.6.7
uint8_t cfg_parent_type; // DMA_PARENT_USART, ...
uint32_t cfg_parent; // Pointer to parent init base
uint32_t cfg_periph_reg; // Pointer to peripheral register
uint32_t cfg_buf;
uint16_t cfg_buf_len; // This doesn't correspond to the length register, it is just however big the buffer is
uint8_t cfg_linear_buf; // If true, the buffer is user-specified and we treat it like a non-circular buffer.
uint32_t cfg_tcie_handler; // If n
int lastDmaUsed; // Number of bytes in the buffer minus bytes last read. This is used to identify buffer overflow.
uint8_t overflow; // Buffer overflow
uint32_t inst_CCR; /*!< DMA channel x configuration register */
uint32_t inst_CNDTR; /*!< DMA channel x number of data register */
uint32_t inst_CPAR; /*!< DMA channel x peripheral address register */
uint32_t inst_CMAR; /*!< DMA channel x memory address register */

uint32_t ptr_start;
uint32_t ptr_end;
uint16_t active_tx_len;
uint8_t done; // Currently only used in TX

uint8_t cfg_dir; // DMA_RX or DMA_TX
uint8_t cfg_circular; // DMA_CIRC_ON or DMA_CIRC_OFF
uint8_t cfg_priority; // DMA_PRIO_LOW, DMA_PRIO_MEDIUM, DMA_PRIO_HIGH, DMA_PRIO_VERY_HIGH
uint8_t cfg_interrupt;
uint8_t cfg_interrupt_priority; // 0 to 15, 15 is low
uint8_t cfg_dma_channel_select; // 0 to 7. See RM0394 11.6.7
uint8_t cfg_parent_type; // DMA_PARENT_USART, ...
uint32_t cfg_parent; // Pointer to parent init base
uint32_t cfg_periph_reg; // Pointer to peripheral register
uint32_t cfg_buf;
uint16_t cfg_buf_len; // This doesn't correspond to the length register, it is just however big the buffer is
uint8_t cfg_linear_buf; // If true, the buffer is user-specified and we treat it like a non-circular buffer.
uint32_t cfg_tcie_handler; // If n
int lastDmaUsed; // Number of bytes in the buffer minus bytes last read. This is used to identify buffer overflow.
uint8_t overflow; // Buffer overflow
} eventImxDmaTxInst_local_t;

POP_PACK
Expand Down
18 changes: 0 additions & 18 deletions src/com_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,13 +591,6 @@ int ISComManager::processBinaryRxPacket(protocol_type_t ptype, packet_t *pkt, po
(((gdata->id >= DID_GPX_FIRST) && (gdata->id <= DID_GPX_LAST)) || (gdata->id == DID_RTK_DEBUG)))
{
comManagerGetData(COM0_PORT, gdata->id, gdata->size, gdata->offset, gdata->period);

if (gdata->id == DID_RTK_DEBUG) {
if (gdata->period != 0)
g_GpxRtkDebugReq |= 0x01 << portId(port);
else
g_GpxRtkDebugReq |= 0x01 << (portId(port) + 4);
}
}
}
#endif
Expand All @@ -615,9 +608,6 @@ int ISComManager::processBinaryRxPacket(protocol_type_t ptype, packet_t *pkt, po
disableBcastFnc(NULL); // all ports

sendAck(port, pkt, PKT_TYPE_ACK);
#ifdef IMX_5
g_GpxRtkDebugReq = 0;
#endif
break;

case PKT_TYPE_STOP_BROADCASTS_CURRENT_PORT:
Expand All @@ -628,18 +618,10 @@ int ISComManager::processBinaryRxPacket(protocol_type_t ptype, packet_t *pkt, po
disableBcastFnc(port);

sendAck(port, pkt, PKT_TYPE_ACK);

#ifdef IMX_5
g_GpxRtkDebugReq &= ~(0x01 << portId(port));
#endif
break;

case PKT_TYPE_STOP_DID_BROADCAST:
disableDidBroadcast(port, pkt->hdr.id);
#ifdef IMX_5
if (DID_RTK_DEBUG)
g_GpxRtkDebugReq &= ~(0x01 << portId(port));
#endif
break;

case PKT_TYPE_NACK:
Expand Down
2 changes: 1 addition & 1 deletion src/com_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ int comManagerSendData(port_handle_t port, const void* data, uint16_t did, uint1
* @param pFlags Additional packet flags if needed.
* @return 0 if success, anything else if failure
*/
int comManagerSendDataNoAck(port_handle_t port, const void *data, uint16_t did, uint16_t size, uint16_t offset = 0);
extern "C" int comManagerSendDataNoAck(port_handle_t port, const void *data, uint16_t did, uint16_t size, uint16_t offset = 0);

/**
* Write bare data directly to the serial port.
Expand Down
1 change: 1 addition & 0 deletions src/data_sets.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ const uint64_t g_didToRmcBit[DID_COUNT] =
[DID_GPX_RMC] = RMC_BITS_GPX_RMC,
[DID_GPX_BIT] = RMC_BITS_GPX_BIT,
[DID_GPX_PORT_MONITOR] = RMC_BITS_GPX_PORT_MON,
[DID_RTK_DEBUG] = RMC_BITS_GPX_RTK_DBG,
};

uint64_t didToRmcBit(uint32_t dataId, uint64_t defaultRmcBits, uint64_t devInfoRmcBits)
Expand Down
10 changes: 7 additions & 3 deletions src/data_sets.h
Original file line number Diff line number Diff line change
Expand Up @@ -1775,12 +1775,14 @@ typedef struct PACKED
#define RMC_BITS_PIMU_MAG 0x0000000800000000
#define RMC_BITS_GPS1_RTK_HDG_REL 0x0000001000000000 // DID_FLASH_CONFIG.startupGPSDtMs (200ms default)
#define RMC_BITS_GPS1_RTK_HDG_MISC 0x0000002000000000 // "
#define RMC_BITS_REFERENCE_IMU 0x0000004000000000 // DID_FLASH_CONFIG.startupNavDtMs
#define RMC_BITS_REFERENCE_PIMU 0x0000008000000000 // "
#define RMC_BITS_REFERENCE_IMU 0x0000004000000000 // DID_FLASH_CONFIG.startupNavDtMs
#define RMC_BITS_REFERENCE_PIMU 0x0000008000000000 // "
#define RMC_BITS_IMU3_RAW 0x0000010000000000
#define RMC_BITS_IMU_RAW 0x0000020000000000
#define RMC_BITS_GPS1_SIG 0x0000040000000000 // 1s
#define RMC_BITS_GPS2_SIG 0x0000080000000000

// GPX messages could go into a local grmc if imx memory we expanded. (TM)
#define RMC_BITS_GPX_RTOS_INFO 0x0000100000000000
#define RMC_BITS_GPX_DEBUG 0x0000200000000000
#define RMC_BITS_GPX_STATUS 0x0000400000000000
Expand All @@ -1789,6 +1791,7 @@ typedef struct PACKED
#define RMC_BITS_GPX_FLASH_CFG 0x0002000000000000
#define RMC_BITS_GPX_BIT 0x0004000000000000
#define RMC_BITS_GPX_PORT_MON 0x0008000000000000
#define RMC_BITS_GPX_RTK_DBG 0x0010000000000000

#define RMC_BITS_EVENT 0x0800000000000000

Expand Down Expand Up @@ -1832,7 +1835,8 @@ typedef struct PACKED
| RMC_BITS_GPS1_SAT \
| RMC_BITS_GPS2_SAT \
| RMC_BITS_EVENT \
| RMC_BITS_GPX_STATUS)
| RMC_BITS_GPX_STATUS \
| RMC_BITS_GPX_RTK_DBG)
#define RMC_PRESET_IMX_PPD_GROUND_VEHICLE (RMC_PRESET_IMX_PPD \
| RMC_BITS_WHEEL_ENCODER \
| RMC_BITS_GROUND_VEHICLE)
Expand Down
10 changes: 5 additions & 5 deletions src/protocol_nmea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,9 +1099,9 @@ int nmea_zda(char a[], const int aSize, gps_pos_t &pos)

int n = nmea_talker(a, aSize);
nmea_sprint(a, aSize, n, "ZDA");
nmea_GPSTimeToUTCTimeMsPrecision_ZDA_debug(a, aSize, n, pos); // 1
nmea_GPSDateOfLastFixCSV(a, aSize, n, pos); // 2,3,4
nmea_sprint(a, aSize, n, ",00,00"); // 5,6
nmea_GPSTimeToUTCTimeMsPrecision_ZDA_debug(a, aSize, n, pos); // 1
nmea_GPSDateOfLastFixCSV(a, aSize, n, pos); // 2,3,4
nmea_sprint(a, aSize, n, ",00,00"); // 5,6

return nmea_sprint_footer(a, aSize, n);
}
Expand Down Expand Up @@ -2876,8 +2876,8 @@ int nmea_parse_zda(const char a[], int aSize, uint32_t &gpsTowMs, uint32_t &gpsW
ptr = ASCII_to_i32((int32_t*)&(date.month), ptr);
ptr = ASCII_to_i32((int32_t*)&(date.year), ptr);

// Convert UTC date and time to GPS time of week and number of weeks
int datetime[7] = { date.year, date.month, date.day, time.hour, time.minute, time.second, time.millisecond }; // year,month,day,hour,min,sec,msec
// Convert UTC date and time to GPS time of week and number of weeks
int datetime[7] = { date.year, date.month, date.day, time.hour, time.minute, time.second, time.millisecond }; // year,month,day,hour,min,sec,msec
UtcDateTimeToGpsTime(datetime, leapS, gpsTowMs, gpsWeek);
date.weekday = gpsTowMsToUtcWeekday(gpsTowMs, leapS);

Expand Down
10 changes: 5 additions & 5 deletions src/time_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ static const gtime_t gpsRefT0 = { 315964800, 0 }; // (gtime) gps reference ti
*-----------------------------------------------------------------------------*/
double timeToGpst(gtime_t t, int *week)
{
time_t sec = t.time - gpsRefT0.time;
time_t w = (time_t)(sec / C_SECONDS_PER_WEEK);
if (week){ *week = (int)w; }
return (double)(sec - (double)w * C_SECONDS_PER_WEEK) + t.sec;
time_t sec = t.time - gpsRefT0.time;
time_t w = (time_t)(sec / C_SECONDS_PER_WEEK);
if (week){ *week = (int)w; }
return (double)(sec - (double)w * C_SECONDS_PER_WEEK) + t.sec;
}

void UtcDateTimeToGpsTime(const int dateTime[6], int leapSeconds, uint32_t &gpsTowMs, uint32_t &gpsWeek, double *debugGtm)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_time_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ TEST(time_conversion, UTC_to_GPS_to_UTC_time)
ASSERT_EQ(gpsTowMs, gpsTowMs2);
ASSERT_EQ(gpsWeek, gpsWeek2);

int datetime[7] = {
int datetime[7] = {
utcTime.tm_year + 1900,
utcTime.tm_mon + 1,
utcTime.tm_mday,
Expand Down Expand Up @@ -81,8 +81,8 @@ TEST(time_conversion, GPS_to_UTC_to_GPS_time)
gpsWeekTowMsToUtcDateTime(gpsWeek, gpsTowMs, leapS, &d, &t, &milliseconds);
gpsTowMsToUtcTime(gpsTowMs, leapS, &t);

// Convert UTC date and time to GPS time and week
int datetime[7] = { d.year, d.month, d.day, t.hour, t.minute, t.second, (int)milliseconds }; // year,month,day,hour,min,sec,msec
// Convert UTC date and time to GPS time and week
int datetime[7] = { d.year, d.month, d.day, t.hour, t.minute, t.second, (int)milliseconds }; // year,month,day,hour,min,sec,msec
uint32_t gpsTowMs2, gpsWeek2;
UtcDateTimeToGpsTime(datetime, leapS, gpsTowMs2, gpsWeek2);

Expand Down

0 comments on commit e7c232e

Please sign in to comment.