Skip to content

Commit

Permalink
Merge branch 'eeprom_buffer' of github.com:apollo-lhc/cm_mcu into eep…
Browse files Browse the repository at this point in the history
…rom_buffer
  • Loading branch information
gwengardner committed Dec 3, 2019
2 parents 3446c5c + d386303 commit 105eabf
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 8 deletions.
12 changes: 6 additions & 6 deletions boot_loader/bl_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
// Requires: UARTx_BASE
//
//*****************************************************************************
#define UART_CLOCK_ENABLE SYSCTL_RCGCUART_R4
#define UART_CLOCK_ENABLE SYSCTL_RCGCUART_R1

//*****************************************************************************
//
Expand All @@ -370,7 +370,7 @@
// Requires: UART_CLOCK_ENABLE
//
//*****************************************************************************
#define UARTx_BASE UART4_BASE
#define UARTx_BASE UART1_BASE

//*****************************************************************************
//
Expand All @@ -381,7 +381,7 @@
// Requires: UART_RXPIN_BASE, UART_RXPIN_PCTL and UART_RXPIN_POS
//
//*****************************************************************************
#define UART_RXPIN_CLOCK_ENABLE SYSCTL_RCGCGPIO_R4
#define UART_RXPIN_CLOCK_ENABLE SYSCTL_RCGCGPIO_R0

//*****************************************************************************
//
Expand Down Expand Up @@ -414,7 +414,7 @@
// Requires: UART_RXPIN_CLOCK_ENABLE, UART_RXPIN_BASE and UART_RXPIN_PCTL
//
//*****************************************************************************
#define UART_RXPIN_POS 2
#define UART_RXPIN_POS 0

//*****************************************************************************
//
Expand All @@ -425,7 +425,7 @@
// Requires: UART_TXPIN_BASE, UART_TXPIN_PCTL and UART_TXPIN_POS
//
//*****************************************************************************
#define UART_TXPIN_CLOCK_ENABLE SYSCTL_RCGCGPIO_R4
#define UART_TXPIN_CLOCK_ENABLE SYSCTL_RCGCGPIO_R0

//*****************************************************************************
//
Expand Down Expand Up @@ -458,7 +458,7 @@
// Requires: UART_TXPIN_CLOCK_ENABLE, UART_TXPIN_BASE and UART_TXPIN_PCTL
//
//*****************************************************************************
#define UART_TXPIN_POS 3
#define UART_TXPIN_POS 1

//*****************************************************************************
//
Expand Down
26 changes: 25 additions & 1 deletion projects/cm_mcu/CommandLineTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,14 @@ static BaseType_t mon_ctl(char *m, size_t s, const char *mm)
dcdc_args.n_commands-1);
return pdFALSE;
}

// update times, in seconds
TickType_t now = pdTICKS_TO_MS( xTaskGetTickCount())/1000;
TickType_t last = pdTICKS_TO_MS(dcdc_args.updateTick)/1000;
int copied = 0;
if ( (now-last) > 60 ) {
int mins = (now-last)/60;
copied += snprintf(m+copied, s-copied, "%s: stale data, last update %d minutes ago\r\n", __func__, mins);
}
copied += snprintf(m+copied, s-copied, "%s\r\n", dcdc_args.commands[i1].name);
for (int ps = 0; ps < dcdc_args.n_devices; ++ps) {
copied += snprintf(m+copied, s-copied, "SUPPLY %s\r\n",
Expand Down Expand Up @@ -621,6 +627,17 @@ static BaseType_t ff_ctl(char *m, size_t s, const char *mm)
int copied = 0;
static int whichff = 0;

if ( whichff == 0 ) {
// check for stale data
TickType_t now = pdTICKS_TO_MS( xTaskGetTickCount())/1000;
TickType_t last = pdTICKS_TO_MS(getFFupdateTick())/1000;
if ( (now-last) > 60 ) {
int mins = (now-last)/60;
copied += snprintf(m+copied, s-copied, "%s: stale data, last update %d minutes ago\r\n", __func__, mins);
}

}

if ( argc == 0 ) { // default command: temps

if ( whichff == 0 ) {
Expand Down Expand Up @@ -696,6 +713,13 @@ static BaseType_t fpga_ctl(char *m, size_t s, const char *mm)
static int whichfpga = 0;
int howmany = fpga_args.n_devices*fpga_args.n_pages;
if ( whichfpga == 0 ) {
TickType_t now = pdTICKS_TO_MS( xTaskGetTickCount())/1000;
TickType_t last = pdTICKS_TO_MS(getFFupdateTick())/1000;
if ( (now-last) > 60 ) {
int mins = (now-last)/60;
copied += snprintf(m+copied, s-copied, "%s: stale data, last update %d minutes ago\r\n", __func__, mins);
}

copied += snprintf(m+copied, s-copied, "FPGA monitors\r\n");
copied += snprintf(m+copied, s-copied, "%s\r\n", fpga_args.commands[0].name);
}
Expand Down
8 changes: 7 additions & 1 deletion projects/cm_mcu/FireFlyTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ int8_t getFFvalue(const uint8_t i)
return ff_temp[i];
}

static TickType_t ff_updateTick = 0;
TickType_t getFFupdateTick()
{
return ff_updateTick;
}

static
int write_ff_register(const char *name, uint8_t reg, uint16_t value, int size)
{
Expand Down Expand Up @@ -300,7 +306,7 @@ void FireFlyTask(void *parameters)
break;
}
}

ff_updateTick = xTaskGetTickCount();
// select the appropriate output for the mux
data[0] = 0x1U << ff_i2c_addrs[ff].mux_bit;
char tmp[64];
Expand Down
1 change: 1 addition & 0 deletions projects/cm_mcu/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ header file. */
#define CLI_UART UART4_BASE // Front panel
//#define CLI_UART UART1_BASE // Zynq

#define pdTICKS_TO_MS( xTicks ) ( ( ( TickType_t ) ( xTicks ) * 1000u ) / configTICK_RATE_HZ )

#ifdef __cplusplus
}
Expand Down
2 changes: 2 additions & 0 deletions projects/cm_mcu/MonitorTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void MonitorTask(void *parameters)

bool log = true;
int current_error_cnt = 0;
args->updateTick = xLastWakeTime; // initial value

for (;;) {
// check if the 3.3V is there or not. If it disappears then nothing works
Expand All @@ -105,6 +106,7 @@ void MonitorTask(void *parameters)
else {
good = true;
}
args->updateTick = xTaskGetTickCount(); // current time in ticks
// loop over devices
for ( uint8_t ps = 0; ps < args->n_devices; ++ ps ) {
if ( getPSStatus(5) != PWR_ON)
Expand Down
1 change: 1 addition & 0 deletions projects/cm_mcu/MonitorTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct MonitorTaskArgs_t {
const int n_pages;
tSMBus *smbus;
volatile tSMBusStatus *smbus_status;
volatile TickType_t updateTick;
};
// DC-DC converter
#define NSUPPLIES_PS (5) // 5 devices, 2 pages each
Expand Down
2 changes: 2 additions & 0 deletions projects/cm_mcu/Tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ extern QueueHandle_t xFFlyQueue;

const char* getFFname(const uint8_t i);
int8_t getFFvalue(const uint8_t i);
TickType_t getFFupdateTick();


int disable_xcvr_cdr(const char *name);

Expand Down

0 comments on commit 105eabf

Please sign in to comment.