mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/CAN-Demo.git
synced 2025-08-02 05:01:54 +00:00
Formtatting of messages added
This commit is contained in:
parent
60c7f59e46
commit
98ecffac48
@ -52,14 +52,14 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unpackValues(uint8_t packedByte, uint8_t* type_id, uint8_t* sensor_ID, uint8_t* value, uint8_t* include) {
|
extern "C" void unpackValues(uint8_t packedByte, uint8_t* type_id, uint8_t* sensor_ID, uint8_t* value, uint8_t* include) {
|
||||||
*type_id = (packedByte >> 6) & 0x03; // Extracting two bits for type_id
|
*type_id = (packedByte >> 6) & 0x03; // Extracting two bits for type_id
|
||||||
*sensor_ID = (packedByte >> 3) & 0x07; // Extracting three bits for sensorID
|
*sensor_ID = (packedByte >> 3) & 0x07; // Extracting three bits for sensorID
|
||||||
*include = (packedByte >> 2) & 0x01; // Extracting the flag for included value
|
*include = (packedByte >> 2) & 0x01; // Extracting the flag for included value
|
||||||
*value = (packedByte >> 1) & 0x01; // Extracting one bit for value
|
*value = (packedByte >> 1) & 0x01; // Extracting one bit for value
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t packValues(uint8_t type_id, uint8_t sensor_ID, uint8_t value, uint8_t include) {
|
extern "C" uint8_t packValues(uint8_t type_id, uint8_t sensor_ID, uint8_t value, uint8_t include) {
|
||||||
uint8_t packedByte = 0;
|
uint8_t packedByte = 0;
|
||||||
|
|
||||||
// Shifting and ORing the values
|
// Shifting and ORing the values
|
||||||
|
@ -327,9 +327,9 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan1)
|
|||||||
|
|
||||||
HAL_CAN_GetRxMessage(hcan1, CAN_RX_FIFO0, &rxHeader, canRX);
|
HAL_CAN_GetRxMessage(hcan1, CAN_RX_FIFO0, &rxHeader, canRX);
|
||||||
|
|
||||||
/*uint8_t type_id, sensor_ID, value, include;
|
uint8_t type_id, sensor_ID, value, include;
|
||||||
|
|
||||||
unpackValues(canRX, *type_id, *sensor_ID, *value, *include);
|
unpackValues(canRX[0], &type_id, &sensor_ID, &value, &include);
|
||||||
|
|
||||||
if (type_id == 0 && sensor_ID == 1){
|
if (type_id == 0 && sensor_ID == 1){
|
||||||
if (value == 0){
|
if (value == 0){
|
||||||
@ -337,7 +337,7 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan1)
|
|||||||
}else{
|
}else{
|
||||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_8, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_8, GPIO_PIN_SET);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user