mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/CAN-Demo.git
synced 2025-08-05 21:59:42 +00:00
Working receive and handling of control signals
This commit is contained in:
@@ -46,18 +46,55 @@ namespace demo
|
||||
|
||||
STA_DEBUG_PRINTLN("WAITING");
|
||||
HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &rxHeader, canRX);
|
||||
STA_DEBUG_PRINTLN("RECEIVED");
|
||||
|
||||
uint8_t type_id, sensor_ID, value, include;
|
||||
|
||||
unpackValues(canRX[0], &type_id, &sensor_ID, &value, &include);
|
||||
|
||||
if (type_id == 0 && sensor_ID == 1){
|
||||
if (value == 0){
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_8, GPIO_PIN_RESET);
|
||||
}else{
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_8, GPIO_PIN_SET);
|
||||
if (type_id == 0){
|
||||
if (sensor_ID == 1){
|
||||
|
||||
STA_DEBUG_PRINTLN("Relay 1 triggered");
|
||||
if(value == 1){
|
||||
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_2, GPIO_PIN_SET);
|
||||
} else if(value == 0){
|
||||
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_2, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
}else if (sensor_ID == 2){
|
||||
|
||||
STA_DEBUG_PRINTLN("Relay 2 triggered");
|
||||
if(value == 1){
|
||||
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_1, GPIO_PIN_SET);
|
||||
} else if(value == 0){
|
||||
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_1, GPIO_PIN_RESET);
|
||||
}
|
||||
}else if (sensor_ID == 3){
|
||||
|
||||
STA_DEBUG_PRINTLN("Relay 3 triggered");
|
||||
if(value == 1){
|
||||
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_0, GPIO_PIN_SET);
|
||||
} else if(value == 0){
|
||||
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_0, GPIO_PIN_RESET);
|
||||
}
|
||||
}else if (sensor_ID == 4){
|
||||
|
||||
STA_DEBUG_PRINTLN("Relay 4 triggered");
|
||||
if(value == 1){
|
||||
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_3, GPIO_PIN_SET);
|
||||
} else if(value == 0){
|
||||
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_3, GPIO_PIN_RESET);
|
||||
}
|
||||
}else if (sensor_ID == 5){
|
||||
|
||||
STA_DEBUG_PRINTLN("Relay 5 triggered");
|
||||
if(value == 1){
|
||||
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_6, GPIO_PIN_SET);
|
||||
} else if(value == 0){
|
||||
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_6, GPIO_PIN_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HAL_Delay(1000);
|
||||
|
Reference in New Issue
Block a user