main.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. /////////////////////////////////////////////////////////////////////////
  37. // set Date, Time, Timezone
  38. if((nTzIndex = _GetRTCTDateTimeTZ(&utc)) < 0)
  39. return 1;
  40. if(!GfaTimeSetUTCDateTimeTimezone(&utc, nTzIndex))
  41. return 1;
  42. /////////////////////////////////////////////////////////////////////////
  43. if(!GfaInitModbusSlaveApp())
  44. return 1;
  45. while(true)
  46. {
  47. GfaDoModbusSlaveApp();
  48. }
  49. }