AppBridge.cpp 940 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * @filename AppBridge.cpp
  3. *
  4. * @date Mar 05, 2025
  5. * @author: juraj
  6. */
  7. #include <NbusSlave.h>
  8. #include "AppBridge.h"
  9. #include "dataframe.h"
  10. #include "NbusBridge.h"
  11. #include "NbusCommunicator.h"
  12. void app(UART_HandleTypeDef *uartNbus, UART_HandleTypeDef *uartMaster){
  13. NbusCommunicator *nc = new NbusCommunicator(uartNbus);
  14. // NbusSlave *slave1 = new NbusSlave(5, nc);
  15. // NbusSlave *slave2 = new NbusSlave(6, nc);
  16. // bridge->addSlave(slave1);
  17. // bridge->addSlave(slave2);
  18. NbusBridge *bridge = new NbusBridge(nc);
  19. bridge->scan();
  20. DataFrame *frameTX;
  21. while(1){
  22. for(int i=0; i<bridge->getNumSlaves() ; i++){
  23. frameTX = bridge->getSlave(i)->nbus_echo();
  24. if(!frameTX->IsEmpty()) {
  25. HAL_UART_Transmit_DMA(uartMaster, frameTX->GetFrame(), frameTX->GetLength());
  26. }
  27. }
  28. HAL_Delay(1);
  29. /*
  30. for(int i=0;i<256;i++){
  31. HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_3);
  32. HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_3);
  33. }
  34. */
  35. }
  36. }