Skip to content

Commit

Permalink
Merge pull request #16 from apollo-lhc/cleanup
Browse files Browse the repository at this point in the history
CLI comments, i2c reg write fix
  • Loading branch information
pwittich authored Sep 9, 2019
2 parents 4c4ee49 + cd3eccf commit b30d55a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
41 changes: 22 additions & 19 deletions projects/project2/CommandLineTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,17 @@ static BaseType_t i2c_ctl_reg_w(char *m, size_t s, const char *mm)
const int MAX_BYTES=4;
uint8_t data[MAX_BYTES+1];
data[0] = reg_address;
// pack the bytes into the data array, offset by
// one due to the address
for (int i = 1; i < MAX_BYTES+1; ++i ) {
data[i] = (packed_data >> i*8) & 0xFFUL;
data[i] = (packed_data >> (i-1)*8) & 0xFFUL;
}
nbytes++; // to account for the register address
if ( nbytes > MAX_BYTES )
nbytes = MAX_BYTES;
snprintf(m, s, "%s: write 0x%08x to address 0x%02x, register 0x%02x (%d bytes)\r\n", __func__,
snprintf(m, s, "%s: write 0x%08x to address 0x%02x, register 0x%02x (%d bytes including reg addr byte)\r\n", __func__,
packed_data, address, reg_address, nbytes);
DPRINT(m);

tSMBusStatus r = SMBusMasterI2CWrite(p_sMaster, address, data, nbytes);
if (r != SMBUS_OK) {
snprintf(m,s, "%s: operation failed (1)\r\n", __func__);
Expand All @@ -248,7 +250,7 @@ static BaseType_t i2c_ctl_reg_w(char *m, size_t s, const char *mm)
}

snprintf(m, s, "%s: Wrote to address 0x%x, register 0x%x, value 0x%08x (%d bytes)\r\n", __func__,
address, reg_address, packed_data, nbytes);
address, reg_address, packed_data, nbytes-1);
return pdFALSE;
}

Expand Down Expand Up @@ -992,27 +994,28 @@ void vCommandLineTask( void *pvParameters )
pcInputString);

DPRINT(pcOutputString);
/* The command interpreter is called repeatedly until it returns
if ( pcInputString[0] != '#' ) { // process unless comment char
/* The command interpreter is called repeatedly until it returns
pdFALSE. See the "Implementing a command" documentation for an
explanation of why this is. */
do {
/* Send the command string to the command interpreter. Any
do {
/* Send the command string to the command interpreter. Any
output generated by the command interpreter will be placed in the
pcOutputString buffer. */
xMoreDataToFollow = FreeRTOS_CLIProcessCommand
(
(const char*)pcInputString, /* The command string.*/
(char*)pcOutputString, /* The output buffer. */
MAX_OUTPUT_LENGTH/* The size of the output buffer. */
);

/* Write the output generated by the command interpreter to the
xMoreDataToFollow = FreeRTOS_CLIProcessCommand
(
(const char*)pcInputString, /* The command string.*/
(char*)pcOutputString, /* The output buffer. */
MAX_OUTPUT_LENGTH/* The size of the output buffer. */
);

/* Write the output generated by the command interpreter to the
console. */
if ( pcOutputString[0] != '\0')
UARTPrint(uart_base,pcOutputString);

} while( xMoreDataToFollow != pdFALSE );
if ( pcOutputString[0] != '\0')
UARTPrint(uart_base,pcOutputString);

} while( xMoreDataToFollow != pdFALSE );
}
/* All the strings generated by the input command have been sent.
Processing of the command is complete. Clear the input string ready
to receive the next command. */
Expand Down
1 change: 1 addition & 0 deletions projects/project2/FireFlyTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ void FireFlyTask(void *parameters)
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);
DPRINT(tmp);
ff_temp[ff] =-55;
break;
}
#ifdef DEBUG_FIF
Expand Down

0 comments on commit b30d55a

Please sign in to comment.