nbus_master_module.c 961 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * nbus_master_module.c
  3. *
  4. * Created on: Nov 12, 2023
  5. * Author: juraj
  6. */
  7. #include "nbus_master_module.h"
  8. #include "nbus_types.h"
  9. #if MODULE_MASTER == 1
  10. void nbus_master_unicastToModuleSet(nBus_TypeDef *nbus) {}
  11. void nbus_master_unicastToModuleGet(nBus_TypeDef *nbus) {
  12. // case CMD_SYNC:
  13. {
  14. if (nbus->rx_length < 11) {
  15. return;
  16. }
  17. RTC_TimeTypeDef sTime = {0};
  18. RTC_DateTypeDef sDate = {0};
  19. sTime.Hours = nbus->rx_buffer[7];
  20. sTime.Minutes = nbus->rx_buffer[8];
  21. sTime.Seconds = nbus->rx_buffer[9];
  22. sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
  23. sTime.StoreOperation = RTC_STOREOPERATION_RESET;
  24. HAL_RTC_SetTime(nbus->periph->rtc, &sTime, RTC_FORMAT_BCD);
  25. sDate.WeekDay = nbus->rx_buffer[6];
  26. sDate.Date = nbus->rx_buffer[5];
  27. sDate.Month = nbus->rx_buffer[4];
  28. sDate.Year = nbus->rx_buffer[3];
  29. HAL_RTC_SetDate(nbus->periph->rtc, &sDate, RTC_FORMAT_BCD);
  30. }
  31. // break;
  32. }
  33. #endif