main.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdarg.h>
  5. #include <stdint.h>
  6. #include <stdbool.h>
  7. #include <gfambrtuslv.h>
  8. #include "mbslvapp.h"
  9. #include "inc/tm4c1231e6pz.h"
  10. #include "driverlib/sysctl.h"
  11. /////////////////////////////////////////////////////////////////////////////
  12. /////////////////////////////////////////////////////////////////////////////
  13. /////////////////////////////////////////////////////////////////////////////
  14. /////////////////////////////////////////////////////////////////////////////
  15. // fake implementation for demo purposes
  16. // usually the time will be retrieved from a realtime clock
  17. static int32_t _GetRTCTDateTimeTZ(struct tm *ptm)
  18. {
  19. if(!ptm)
  20. return -1;
  21. memset(ptm, 0, sizeof(struct tm));
  22. ptm->tm_year = 119;
  23. ptm->tm_mon = 8;
  24. ptm->tm_mday = 17;
  25. ptm->tm_hour = 17;
  26. ptm->tm_min = 40;
  27. return 2;
  28. }
  29. /////////////////////////////////////////////////////////////////////////////
  30. int main(void)
  31. {
  32. struct tm utc;
  33. int32_t nTzIndex;
  34. SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
  35. GfaUtilsInit();
  36. if((nTzIndex = _GetRTCTDateTimeTZ(&utc)) < 0)
  37. return 1;
  38. if(!GfaTimeSetUTCDateTimeTimezone(&utc, nTzIndex))
  39. return 1;
  40. if(!GfaInitModbusSlaveApp())
  41. return 1;
  42. while(true)
  43. {
  44. GfaDoModbusSlaveApp();
  45. }
  46. }