Skip to content

Commit

Permalink
bug fix to address updated address table/missing data (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwittich authored Jul 23, 2020
1 parent 4f53d42 commit c0079b0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion projects/cm_mcu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ ${COMPILER}/cm_mcu.axf: ${COMPILER}/I2CSlaveTask.o
${COMPILER}/cm_mcu.axf: ${COMPILER}/AlarmTask.o
${COMPILER}/cm_mcu.axf: ${COMPILER}/LedTask.o
${COMPILER}/cm_mcu.axf: ${COMPILER}/microrl.o
${COMPILER}/cm_mcu.axf: ${COMPILER}/SoftUartTask.o
${COMPILER}/cm_mcu.axf: ${COMPILER}/ZynqMonTask.o
${COMPILER}/cm_mcu.axf: ${COMPILER}/InterruptHandlers.o
${COMPILER}/cm_mcu.axf: ${COMPILER}/InitTask.o
${COMPILER}/cm_mcu.axf: ${COMPILER}/LocalTasks.o
Expand Down
2 changes: 1 addition & 1 deletion projects/cm_mcu/Tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void EEPROMTask(void *parameters);
#define SOFTUART_TEST_RAW 0x7

extern QueueHandle_t xSoftUartQueue;
void SoftUartTask(void *parameters);
void ZynqMonTask(void *parameters);

#ifdef SUART_TEST_MODE
void setSUARTTestData(uint8_t sensor, uint16_t value);
Expand Down
27 changes: 13 additions & 14 deletions projects/cm_mcu/SoftUartTask.c → projects/cm_mcu/ZynqMonTask.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SoftUartTask.c
* ZynqMonTask.c
*
* Created on: Jan 3, 2020
* Author: wittich
Expand Down Expand Up @@ -27,6 +27,9 @@

// Data Format
// https://github.com/apollo-lhc/SM_ZYNQ_FW/blob/develop/src/CM_interface/CM_Monitoring_data_format.txt
//
// Register List
// See Google Docs, 'CM uC Sensor register map'

#define SENSOR_MESSAGE_START_OF_FRAME_NIB 2
#define SENSOR_MESSAGE_DATA_FRAME_NIB 0
Expand Down Expand Up @@ -101,7 +104,7 @@ extern uint32_t g_ui32SysClock;

QueueHandle_t xSoftUartQueue;

void SoftUartTask(void *parameters)
void ZynqMonTask(void *parameters)
{
// Setup
// initialize to the current tick time
Expand Down Expand Up @@ -273,28 +276,23 @@ void SoftUartTask(void *parameters)
__fp16 f;
} convert_16_t;
// MonitorTask values -- power supply
const int offsetMonitor = 32;
const int num_uart_psmon_registers = 8; // ugh
int offset = offsetMonitor;
// this indirection list is required because of a mistake
// made when initially putting together the register list.
const size_t offsets[] = {32, 40, 48, 56, 160, 168, 64, 72, 80, 88};
for (int j = 0; j < dcdc_args.n_devices; ++j) { // loop over supplies
for (int l = 0; l < dcdc_args.n_pages;
++l) { // loop over register pages
for (int k = 0; k < dcdc_args.n_commands;
++k) { // loop over commands
// HACK -- skip status command
if (k == 5)
continue;
for (int l = 0; l < dcdc_args.n_pages; ++l) { // loop over register pages
for (int k = 0; k < 5; ++k) { // loop over FIRST FIVE commands
int index = j * (dcdc_args.n_commands * dcdc_args.n_pages) +
l * dcdc_args.n_commands + k;
convert_16_t u;
u.f = dcdc_args.pm_values[index];
int reg = offset + k;
if ( u.f < -900.f ) u.f = __builtin_nanf("");
int reg = offsets[j*2+l] + k;
format_data(reg, u.us, message);
for (int i = 0; i < 4; ++i) {
SoftUARTCharPut(&g_sUART, message[i]);
}
}
offset += num_uart_psmon_registers;
}
}
// ADC values
Expand All @@ -314,6 +312,7 @@ void SoftUartTask(void *parameters)
for (int j = 0; j < fpga_args.n_commands * fpga_args.n_devices; ++j) {
convert_16_t u;
u.f = fpga_args.pm_values[j];
if ( u.f < -900.f ) u.f = __builtin_nanf("");
format_data(j + offsetFPGA, u.us, message);
for (int i = 0; i < 4; ++i) {
SoftUARTCharPut(&g_sUART, message[i]);
Expand Down
2 changes: 1 addition & 1 deletion projects/cm_mcu/cm_mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ int main( void )
xTaskCreate(I2CSlaveTask, "I2CS0", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+5, NULL);
xTaskCreate(EEPROMTask, "EPRM", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+4, NULL);
xTaskCreate(InitTask, "INIT", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+5, NULL);
xTaskCreate(SoftUartTask, "SUART", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+5, NULL);
xTaskCreate(ZynqMonTask, "SUART", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+5, NULL);


// -------------------------------------------------
Expand Down

0 comments on commit c0079b0

Please sign in to comment.