diff --git a/ctaocrypt/src/asn.c b/ctaocrypt/src/asn.c index 00235fe4c..99e28e539 100644 --- a/ctaocrypt/src/asn.c +++ b/ctaocrypt/src/asn.c @@ -95,7 +95,7 @@ #endif #define NO_TIME_H /* since Micrium not defining XTIME or XGMTIME, CERT_GEN not available */ -#elif defined(MICROCHIP_TCPIP) +#elif defined(MICROCHIP_TCPIP_V5) || defined(MICROCHIP_TCPIP) #include #define XTIME(t1) pic32_time((t1)) #define XGMTIME(c) gmtime((c)) @@ -255,7 +255,7 @@ struct tm* my_gmtime(const time_t* timer) /* has a gmtime() but hangs */ #endif /* THREADX */ -#ifdef MICROCHIP_TCPIP +#if defined(MICROCHIP_TCPIP_V5) || defined(MICROCHIP_TCPIP) /* * time() is just a stub in Microchip libraries. We need our own @@ -263,7 +263,11 @@ struct tm* my_gmtime(const time_t* timer) /* has a gmtime() but hangs */ */ time_t pic32_time(time_t* timer) { +#ifdef MICROCHIP_TCPIP_V5 DWORD sec = 0; +#else + uint32_t sec = 0; +#endif time_t localTime; if (timer == NULL) diff --git a/cyassl/ctaocrypt/settings.h b/cyassl/ctaocrypt/settings.h index c8ff60577..a3693d86e 100644 --- a/cyassl/ctaocrypt/settings.h +++ b/cyassl/ctaocrypt/settings.h @@ -45,7 +45,10 @@ /* Uncomment next line if using Microchip PIC32 ethernet starter kit */ /* #define MICROCHIP_PIC32 */ -/* Uncomment next line if using Microchip TCP/IP stack, for time features */ +/* Uncomment next line if using Microchip TCP/IP stack, version 5 */ +/* #define MICROCHIP_TCPIP_V5 */ + +/* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */ /* #define MICROCHIP_TCPIP */ /* Uncomment next line if using FreeRTOS */ @@ -94,11 +97,17 @@ #define TFM_TIMING_RESISTANT #endif -#ifdef MICROCHIP_TCPIP - /* includes timer functions */ +#ifdef MICROCHIP_TCPIP_V5 + /* include timer functions */ #include "TCPIP Stack/TCPIP.h" #endif +#ifdef MICROCHIP_TCPIP + /* include timer, NTP functions */ + #include "system/system_services.h" + #include "tcpip/sntp.h" +#endif + #ifdef MBED #define SINGLE_THREADED #define CYASSL_USER_IO diff --git a/src/internal.c b/src/internal.c index c26723cb9..24997aae9 100644 --- a/src/internal.c +++ b/src/internal.c @@ -2088,7 +2088,7 @@ ProtocolVersion MakeDTLSv1_2(void) } -#elif defined(MICROCHIP_TCPIP) +#elif defined(MICROCHIP_TCPIP_V5) word32 LowResTimer(void) { @@ -2096,6 +2096,14 @@ ProtocolVersion MakeDTLSv1_2(void) } +#elif defined(MICROCHIP_TCPIP) + + word32 LowResTimer(void) + { + return (word32) SYS_TICK_Get(); + } + + #elif defined(USER_TICKS) #if 0 word32 LowResTimer(void)