123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdarg.h>
- #include <stdint.h>
- #include <stdbool.h>
- #include <gfambrtuslv.h>
- #include "mbslvapp.h"
- #include "inc/tm4c1231e6pz.h"
- #include "driverlib/sysctl.h"
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // fake implementation for demo purposes
- // usually the 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;
- }
- /////////////////////////////////////////////////////////////////////////////
- int main(void)
- {
- struct tm utc;
- int32_t nTzIndex;
- SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
- GfaUtilsInit();
- if((nTzIndex = _GetRTCTDateTimeTZ(&utc)) < 0)
- return 1;
- if(!GfaTimeSetUTCDateTimeTimezone(&utc, nTzIndex))
- return 1;
- if(!GfaInitModbusSlaveApp())
- return 1;
- while(true)
- {
- GfaDoModbusSlaveApp();
- }
- }
|