|
@@ -64,6 +64,11 @@ inline static void send_response(){
|
|
|
HAL_GPIO_WritePin(nBus.periph->led->port, nBus.periph->led->pin, GPIO_PIN_RESET);
|
|
HAL_GPIO_WritePin(nBus.periph->led->port, nBus.periph->led->pin, GPIO_PIN_RESET);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#if MODULE_MASTER == 1
|
|
|
|
|
+inline static void receive_slave_response(){
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
static nBusCommandType_t get_request_type(){
|
|
static nBusCommandType_t get_request_type(){
|
|
|
nBus.addressModule = nBus.rx_buffer[0];
|
|
nBus.addressModule = nBus.rx_buffer[0];
|
|
@@ -103,11 +108,13 @@ static void process_request(){
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#if MODULE_SLAVE == 1
|
|
|
// spracovanie broadcast komunikacie
|
|
// spracovanie broadcast komunikacie
|
|
|
if((request_type == BROADCAST_SPECIFIC_SENSORS || request_type == BROADCAST_GLOBAL)) {
|
|
if((request_type == BROADCAST_SPECIFIC_SENSORS || request_type == BROADCAST_GLOBAL)) {
|
|
|
- nbus_broadcast(&nBus, request_type);
|
|
|
|
|
|
|
+ nbus_slave_broadcast(&nBus, request_type);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
// paket nie je adresovany tomuto modulu
|
|
// paket nie je adresovany tomuto modulu
|
|
|
if(nBus.addressModule != MODULE_ADDRESS) {
|
|
if(nBus.addressModule != MODULE_ADDRESS) {
|
|
@@ -118,29 +125,39 @@ static void process_request(){
|
|
|
nBus.function_code.error = 0;
|
|
nBus.function_code.error = 0;
|
|
|
nBus.tx_length = META_SIZE;
|
|
nBus.tx_length = META_SIZE;
|
|
|
|
|
|
|
|
|
|
+#if MODULE_SLAVE == 1
|
|
|
if(nBus.function_code.notReadWrite == REQUEST_GET) {
|
|
if(nBus.function_code.notReadWrite == REQUEST_GET) {
|
|
|
if(request_type == UNICAST_TO_SENSOR) {
|
|
if(request_type == UNICAST_TO_SENSOR) {
|
|
|
- nbus_unicastToSensorGet(&nBus);
|
|
|
|
|
|
|
+ nbus_slave_unicastToSensorGet(&nBus);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(request_type == UNICAST_TO_MODULE) {
|
|
if(request_type == UNICAST_TO_MODULE) {
|
|
|
- nbus_unicastToModuleGet(&nBus);
|
|
|
|
|
|
|
+ nbus_slave_unicastToModuleGet(&nBus);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
// else request is REQUEST_SET
|
|
// else request is REQUEST_SET
|
|
|
if(request_type == UNICAST_TO_SENSOR) {
|
|
if(request_type == UNICAST_TO_SENSOR) {
|
|
|
- nbus_unicastToSensorSet(&nBus);
|
|
|
|
|
|
|
+ nbus_slave_unicastToSensorSet(&nBus);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(request_type == UNICAST_TO_MODULE) {
|
|
if(request_type == UNICAST_TO_MODULE) {
|
|
|
- nbus_unicastToModuleSet(&nBus);
|
|
|
|
|
|
|
+ nbus_slave_unicastToModuleSet(&nBus);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
nBus.tx_buffer[3] = *(uint8_t*)&nBus.function_code;
|
|
nBus.tx_buffer[3] = *(uint8_t*)&nBus.function_code;
|
|
|
nBus.tx_buffer[nBus.tx_length-1] = crc8x_fast(&nBus.tx_buffer[1], nBus.tx_length-2);
|
|
nBus.tx_buffer[nBus.tx_length-1] = crc8x_fast(&nBus.tx_buffer[1], nBus.tx_length-2);
|
|
|
nBus.tx_buffer[0] = nBus.tx_length;
|
|
nBus.tx_buffer[0] = nBus.tx_length;
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#if MODULE_MASTER == 1
|
|
|
|
|
+ if(nBus.function_code.notReadWrite == REQUEST_GET) {
|
|
|
|
|
+ nbus_master_unicastToModuleGet(&nBus);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ nbus_master_unicastToModuleSet(&nBus);
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -230,6 +247,9 @@ void nbus_stack(void){
|
|
|
receiveOneByte();
|
|
receiveOneByte();
|
|
|
|
|
|
|
|
send_response();
|
|
send_response();
|
|
|
|
|
+#if MODULE_MASTER == 1
|
|
|
|
|
+ receive_slave_response();
|
|
|
|
|
+#endif
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|