Skip to content

Commit

Permalink
clean up for bug hunting
Browse files Browse the repository at this point in the history
  • Loading branch information
pwittich committed Oct 7, 2019
1 parent 9a26b68 commit efc2bcd
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 30 deletions.
5 changes: 3 additions & 2 deletions makedefs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ CFLAGS=-mthumb \
-Wall \
-pedantic \
-DPART_${PART} \
-c
-DTARGET_IS_TM4C129_RA2 \
-c

#
#
# The size command
#
SIZE=${PREFIX}-size
Expand Down
26 changes: 14 additions & 12 deletions projects/cm_mcu/CommandLineTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ void Print(const char* str);
int snprintf( char *buf, unsigned int count, const char *format, ... );


#define MAX_INPUT_LENGTH 50
#define MAX_OUTPUT_LENGTH 512
#define MAX_INPUT_LENGTH 64
#define MAX_OUTPUT_LENGTH 1024


extern tSMBus g_sMaster1;
Expand Down Expand Up @@ -334,26 +334,28 @@ static BaseType_t power_ctl(char *m, size_t s, const char *mm)
}
else if ( strcmp(p1, "status") == 0 ) { // report status to UART
int copied = 0;
copied += snprintf(m+copied, s-copied, "power_ctl:\r\nLowest ena: %d\r\n",
getLowestEnabledPSPriority());
// copied += snprintf(m+copied, s-copied, "power_ctl:\r\nLowest ena: %d\r\n",
// getLowestEnabledPSPriority());
bool ku_enable = (read_gpio_pin(TM4C_DIP_SW_1) == 1);
bool vu_enable = (read_gpio_pin(TM4C_DIP_SW_2) == 1);
copied += snprintf(m+copied, s-copied, "VU_ENABLE:\t%d\r\nKU_ENABLE:\t%d\r\n",
vu_enable, ku_enable);
copied += snprintf(m+copied, s-copied, "pwr_ctl:\r\nVU_ENABLE:\t%d\r\n"
"KU_ENABLE:\t%d\r\n", vu_enable, ku_enable);
for ( int i = 0; i < N_PS_OKS; ++i ) {
int j = getPSStatus(i);
enum ps_state j = getPSStatus(i);
char *c;
switch (j) {
case 0:
c = "UNKNOWN";
case PWR_UNKNOWN:
c = "PWR_UNKNOWN";
break;
case 1:
case PWR_ON:
c = "PWR_ON";
break;
case 2:
case PWR_OFF:
c = "PWR_OFF";
break;
case 3:
case PWR_DISABLED:
c = "PWR_DISABLED";
break;
default:
c = "UNKNOWN";
break;
Expand Down
2 changes: 1 addition & 1 deletion projects/cm_mcu/FireFlyTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ void FireFlyTask(void *parameters)
vTaskDelayUntil( &xLastWakeTime, pdMS_TO_TICKS( 10 )); // wait
}
if ( *p_status != SMBUS_OK ) {
snprintf(tmp, 64, "FIF: %s: Error %d, break out of loop (ps=%d,c=%d) ...\r\n", __func__, *p_status, ff,c);
snprintf(tmp, 64, "FIF: %s: Error %d, break loop (ps=%d,c=%d) ...\r\n", __func__, *p_status, ff,c);
DPRINT(tmp);
ff_temp[ff] =-55;
break;
Expand Down
4 changes: 0 additions & 4 deletions projects/cm_mcu/MonitorTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ void MonitorTask(void *parameters)
bool log = true;
int current_error_cnt = 0;

Print(args->name);
char tmp[64];
snprintf(tmp, 64, "\tnumber of devices is %d %s\r\n", args->n_devices, args->devices->name);
Print(tmp);

for (;;) {
// check if the 3.3V is there or not. If it disappears then nothing works
Expand Down
3 changes: 2 additions & 1 deletion projects/cm_mcu/PowerSupplyTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ void PowerSupplyTask(void *parameters)
newstate = PWR_OFF;
}
else if ( ! alarm ) { // blade_power_enable and not alarm
set_ps();
if ( oldState != PWR_ON )
set_ps();
newstate = PWR_ON;
}
// now check the actual state
Expand Down
24 changes: 14 additions & 10 deletions projects/cm_mcu/cm_mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,18 @@ int main( void )
for (int i =0; i < fpga_args.n_values; ++i)
fpga_args.pm_values[i] = -999.;


#define SMALL_STACK 256

// start the tasks here
xTaskCreate(PowerSupplyTask, "POW", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+5, &TaskNamePairs[0].value);
xTaskCreate(LedTask, "LED", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+2, &TaskNamePairs[1].value);
xTaskCreate(vCommandLineTask,"CLIZY", 512, &cli_uart1, tskIDLE_PRIORITY+1, &TaskNamePairs[2].value);
xTaskCreate(vCommandLineTask,"CLIFP", 512, &cli_uart4, tskIDLE_PRIORITY+1, &TaskNamePairs[3].value);
xTaskCreate(ADCMonitorTask, "ADC", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+4, &TaskNamePairs[4].value);
xTaskCreate(FireFlyTask, "FFLY", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+4, &TaskNamePairs[6].value);
xTaskCreate(MonitorTask, "PSMON", configMINIMAL_STACK_SIZE, &dcdc_args, tskIDLE_PRIORITY+4, &TaskNamePairs[5].value);
xTaskCreate(MonitorTask, "XIMON", configMINIMAL_STACK_SIZE, &fpga_args, tskIDLE_PRIORITY+4, &TaskNamePairs[7].value);
xTaskCreate(AlarmTask, "ALARM", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+5, &TaskNamePairs[8].value);
xTaskCreate(PowerSupplyTask, "POW", 2*SMALL_STACK, NULL, tskIDLE_PRIORITY+5, &TaskNamePairs[0].value);
xTaskCreate(LedTask, "LED", SMALL_STACK, NULL, tskIDLE_PRIORITY+2, &TaskNamePairs[1].value);
xTaskCreate(vCommandLineTask,"CLIZY", 2*SMALL_STACK, &cli_uart1, tskIDLE_PRIORITY+1, &TaskNamePairs[2].value);
xTaskCreate(vCommandLineTask,"CLIFP", 2*SMALL_STACK, &cli_uart4, tskIDLE_PRIORITY+1, &TaskNamePairs[3].value);
xTaskCreate(ADCMonitorTask, "ADC", SMALL_STACK, NULL, tskIDLE_PRIORITY+4, &TaskNamePairs[4].value);
xTaskCreate(FireFlyTask, "FFLY", SMALL_STACK, NULL, tskIDLE_PRIORITY+4, &TaskNamePairs[6].value);
xTaskCreate(MonitorTask, "PSMON", SMALL_STACK, &dcdc_args, tskIDLE_PRIORITY+4, &TaskNamePairs[5].value);
xTaskCreate(MonitorTask, "XIMON", SMALL_STACK, &fpga_args, tskIDLE_PRIORITY+4, &TaskNamePairs[7].value);
xTaskCreate(AlarmTask, "ALARM", SMALL_STACK, NULL, tskIDLE_PRIORITY+5, &TaskNamePairs[8].value);

snprintf(TaskNamePairs[0].key,configMAX_TASK_NAME_LEN,"POW");
snprintf(TaskNamePairs[1].key,configMAX_TASK_NAME_LEN,"LED");
Expand Down Expand Up @@ -457,6 +457,10 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
function will automatically get called if a task overflows its stack. */
( void ) pxTask;
( void ) pcTaskName;
char tmp[256];
snprintf(tmp, 256, "Stack overflow: task %s\r\n", pcTaskName);
Print(tmp);

for( ;; );
}
#endif
Expand Down

0 comments on commit efc2bcd

Please sign in to comment.