Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #29 from Dartmouth-Formula-Racing/pm-100-fix
Browse files Browse the repository at this point in the history
bug fixes
bennewhall authored Feb 25, 2020
2 parents ef39971 + ccc9e6f commit 16aa2b9
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Applications/cvc_can.c
Original file line number Diff line number Diff line change
@@ -302,7 +302,7 @@ void CAN_Send(queue_msg_t Tx_msg)
}

/**
* @brief standard parser for unpacking CAN functions into CAN_inputs table (big endian to big endian)
* @brief standard parser for unpacking CAN functions into CAN_inputs table (big endian messages)
* @param q_msg: incoming CAN message
* @param CAN_msg: reference message from CAN_dict w/ message metadata
*/
@@ -318,7 +318,7 @@ static void CAN_parser_std(queue_msg_t q_msg, uint8_t CAN_idx)
/* iterate over all bytes of input */
for (int j = 0; j < input.size; j++)
{
result = result << 8 | (uint32_t) (q_msg.data._8[input.start_byte + j] << input.start_bit);
result = (result << 8) | (uint32_t) (q_msg.data._8[input.start_byte + j] << input.start_bit);
}


12 changes: 6 additions & 6 deletions Applications/pm100.c
Original file line number Diff line number Diff line change
@@ -122,15 +122,15 @@ void parameter_read_command_2(uint16_t parameter_address)
*/
void command_msg_1(uint16_t torque_command, uint16_t speed_command, uint8_t direction_command, uint8_t inverter_enable, uint8_t inverter_discharge, uint8_t speed_mode_enable, uint16_t commanded_torque_limit){
pm100_command_msg_1.data._8[0] = (torque_command & 0x00FF);
pm100_command_msg_1.data._8[1] = (torque_command & 0xFF00 >> 8);
pm100_command_msg_1.data._8[1] = ((torque_command & 0xFF00) >> 8);
pm100_command_msg_1.data._8[2] = (speed_command & 0x00FF);
pm100_command_msg_1.data._8[3] = (speed_command & 0xFF00 >> 8);
pm100_command_msg_1.data._8[3] = ((speed_command & 0xFF00) >> 8);
pm100_command_msg_1.data._8[4] = direction_command;
pm100_command_msg_1.data._8[5] = inverter_enable;
pm100_command_msg_1.data._8[5] |= inverter_discharge << 1;
pm100_command_msg_1.data._8[5] |= speed_mode_enable << 2;
pm100_command_msg_1.data._8[6] = (commanded_torque_limit & 0x00FF);
pm100_command_msg_1.data._8[7] = (commanded_torque_limit & 0xFF00 >> 8);
pm100_command_msg_1.data._8[7] = ((commanded_torque_limit & 0xFF00) >> 8);

CAN_Send(pm100_command_msg_1);
}
@@ -148,15 +148,15 @@ void command_msg_1(uint16_t torque_command, uint16_t speed_command, uint8_t dire
*/
void command_msg_2(uint16_t torque_command, uint16_t speed_command, uint8_t direction_command, uint8_t inverter_enable, uint8_t inverter_discharge, uint8_t speed_mode_enable, uint16_t commanded_torque_limit){
pm100_command_msg_2.data._8[0] = (torque_command & 0x00FF);
pm100_command_msg_2.data._8[1] = (torque_command & 0xFF00 >> 8);
pm100_command_msg_2.data._8[1] = ((torque_command & 0xFF00) >> 8);
pm100_command_msg_2.data._8[2] = (speed_command & 0x00FF);
pm100_command_msg_2.data._8[3] = (speed_command & 0xFF00 >> 8);
pm100_command_msg_2.data._8[3] = ((speed_command & 0xFF00) >> 8);
pm100_command_msg_2.data._8[4] = direction_command;
pm100_command_msg_2.data._8[5] = inverter_enable;
pm100_command_msg_2.data._8[5] |= inverter_discharge << 1;
pm100_command_msg_2.data._8[5] |= speed_mode_enable << 2;
pm100_command_msg_2.data._8[6] = (commanded_torque_limit & 0x00FF);
pm100_command_msg_2.data._8[7] = (commanded_torque_limit & 0xFF00 >> 8);
pm100_command_msg_2.data._8[7] = ((commanded_torque_limit & 0xFF00) >> 8);

CAN_Send(pm100_command_msg_2);
}

0 comments on commit 16aa2b9

Please sign in to comment.