add current feedback receive
This commit is contained in:
parent
901c46af34
commit
1affd1220d
|
@ -127,6 +127,8 @@ typedef struct{
|
||||||
int16_t speedL_meas;
|
int16_t speedL_meas;
|
||||||
int16_t batVoltage;
|
int16_t batVoltage;
|
||||||
int16_t boardTemp;
|
int16_t boardTemp;
|
||||||
|
int16_t curL_DC;
|
||||||
|
int16_t curR_DC;
|
||||||
int16_t checksum;
|
int16_t checksum;
|
||||||
} SerialFeedback;
|
} SerialFeedback;
|
||||||
SerialFeedback Feedback1;
|
SerialFeedback Feedback1;
|
||||||
|
|
|
@ -51,8 +51,9 @@ void ReceiveSerial1()
|
||||||
// Check if we reached the end of the package
|
// Check if we reached the end of the package
|
||||||
if (idx1 == sizeof(SerialFeedback)) {
|
if (idx1 == sizeof(SerialFeedback)) {
|
||||||
uint16_t checksum;
|
uint16_t checksum;
|
||||||
|
|
||||||
checksum = (uint16_t)(NewFeedback1.start ^ NewFeedback1.cmd1 ^ NewFeedback1.cmd2 ^ NewFeedback1.speedR ^ NewFeedback1.speedL
|
checksum = (uint16_t)(NewFeedback1.start ^ NewFeedback1.cmd1 ^ NewFeedback1.cmd2 ^ NewFeedback1.speedR ^ NewFeedback1.speedL
|
||||||
^ NewFeedback1.speedR_meas ^ NewFeedback1.speedL_meas ^ NewFeedback1.batVoltage ^ NewFeedback1.boardTemp);
|
^ NewFeedback1.speedR_meas ^ NewFeedback1.speedL_meas ^ NewFeedback1.batVoltage ^ NewFeedback1.boardTemp ^ NewFeedback1.curL_DC ^ NewFeedback1.curR_DC);
|
||||||
|
|
||||||
// Check validity of the new data
|
// Check validity of the new data
|
||||||
if (NewFeedback1.start == START_FRAME && checksum == NewFeedback1.checksum) {
|
if (NewFeedback1.start == START_FRAME && checksum == NewFeedback1.checksum) {
|
||||||
|
@ -112,7 +113,7 @@ void ReceiveSerial2()
|
||||||
if (idx2 == sizeof(SerialFeedback)) {
|
if (idx2 == sizeof(SerialFeedback)) {
|
||||||
uint16_t checksum;
|
uint16_t checksum;
|
||||||
checksum = (uint16_t)(NewFeedback2.start ^ NewFeedback2.cmd1 ^ NewFeedback2.cmd2 ^ NewFeedback2.speedR ^ NewFeedback2.speedL
|
checksum = (uint16_t)(NewFeedback2.start ^ NewFeedback2.cmd1 ^ NewFeedback2.cmd2 ^ NewFeedback2.speedR ^ NewFeedback2.speedL
|
||||||
^ NewFeedback2.speedR_meas ^ NewFeedback2.speedL_meas ^ NewFeedback2.batVoltage ^ NewFeedback2.boardTemp);
|
^ NewFeedback2.speedR_meas ^ NewFeedback2.speedL_meas ^ NewFeedback2.batVoltage ^ NewFeedback2.boardTemp ^ NewFeedback2.curL_DC ^ NewFeedback2.curR_DC);
|
||||||
|
|
||||||
// Check validity of the new data
|
// Check validity of the new data
|
||||||
if (NewFeedback2.start == START_FRAME && checksum == NewFeedback2.checksum) {
|
if (NewFeedback2.start == START_FRAME && checksum == NewFeedback2.checksum) {
|
||||||
|
|
Loading…
Reference in New Issue