| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- /*
- * @filename AppBridge.cpp
- *
- * @date Mar 05, 2025
- * @author: juraj
- */
- #include <NbusSlave.h>
- #include "AppBridge.h"
- #include "dataframe.h"
- #include "NbusBridge.h"
- #include "NbusCommunicator.h"
- void app(UART_HandleTypeDef *uartNbus, UART_HandleTypeDef *uartMaster){
- NbusCommunicator *nc = new NbusCommunicator(uartNbus);
- // NbusSlave *slave1 = new NbusSlave(5, nc);
- // NbusSlave *slave2 = new NbusSlave(6, nc);
- // bridge->addSlave(slave1);
- // bridge->addSlave(slave2);
- NbusBridge *bridge = new NbusBridge(nc);
- bridge->scan();
- DataFrame *frameTX;
- while(1){
- for(int i=0; i<bridge->getNumSlaves() ; i++){
- frameTX = bridge->getSlave(i)->nbus_echo();
- if(!frameTX->IsEmpty()) {
- HAL_UART_Transmit_DMA(uartMaster, frameTX->GetFrame(), frameTX->GetLength());
- }
- }
- HAL_Delay(1);
- /*
- for(int i=0;i<256;i++){
- HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_3);
- HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_3);
- }
- */
- }
- }
|