12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdint.h>
- #include <stdbool.h>
- #include <gfambrtumst.h>
- #include "mbmstapp.h"
- #include "driverlib/sysctl.h"
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // fake implementation for demo purposes
- // usually the date and time will be retrieved from a realtime clock
- static int32_t _GetRTCTDateTimeTZ(struct tm *ptm)
- {
- if(!ptm)
- return -1;
- memset(ptm, 0, sizeof(struct tm));
- ptm->tm_year = 119;
- ptm->tm_mon = 8;
- ptm->tm_mday = 17;
- ptm->tm_hour = 17;
- ptm->tm_min = 40;
- return 2; // return timezone
- }
- /////////////////////////////////////////////////////////////////////////////
- int main(void)
- {
- struct tm utc;
- int32_t nTzIndex;
- /////////////////////////////////////////////////////////////////////////
- // System initialization
- SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
- GfaUtilsInit();
- /////////////////////////////////////////////////////////////////////////
- // set date, time and timezone
- if((nTzIndex = _GetRTCTDateTimeTZ(&utc)) < 0)
- return 1;
- if(!GfaTimeSetUTCDateTimeTimezone(&utc, nTzIndex))
- return 1;
- /////////////////////////////////////////////////////////////////////////
- // start the modbus slave
- if(!GfaInitModbusMasterApp())
- return 1;
- while(true)
- {
- GfaDoModbusMasterApp();
- }
- }
|