diff --git a/Applications/cvc_can.c b/Applications/cvc_can.c index 20c8a34..6c8260a 100644 --- a/Applications/cvc_can.c +++ b/Applications/cvc_can.c @@ -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); } diff --git a/Applications/pm100.c b/Applications/pm100.c index 88dce54..c4e63b1 100644 --- a/Applications/pm100.c +++ b/Applications/pm100.c @@ -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); }