From 9438d0d41b376a47d8267af6148e4c6cd5eb22b0 Mon Sep 17 00:00:00 2001 From: toddouska Date: Mon, 28 Oct 2013 11:03:50 -0700 Subject: [PATCH] add Microchip MPLAB Harmony support --- ctaocrypt/src/asn.c | 4 ++++ ctaocrypt/src/random.c | 11 ++++++++--- cyassl/ctaocrypt/settings.h | 6 +++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ctaocrypt/src/asn.c b/ctaocrypt/src/asn.c index 4b99b6760..7a1d0f363 100644 --- a/ctaocrypt/src/asn.c +++ b/ctaocrypt/src/asn.c @@ -285,7 +285,11 @@ time_t pic32_time(time_t* timer) if (timer == NULL) timer = &localTime; +#ifdef MICROCHIP_MPLAB_HARMONY + sec = TCPIP_SNTP_UTCSecondsGet(); +#else sec = SNTPGetUTCSeconds(); +#endif *timer = (time_t) sec; return *timer; diff --git a/ctaocrypt/src/random.c b/ctaocrypt/src/random.c index 88871951d..e73767561 100644 --- a/ctaocrypt/src/random.c +++ b/ctaocrypt/src/random.c @@ -458,18 +458,23 @@ int GenerateSeed(OS_Seed* os, byte* output, word32 sz) #elif defined(MICROCHIP_PIC32) -#include +#ifndef MICROCHIP_MPLAB_HARMONY + #include + #define PIC32_SEED_COUNT _CP0_GET_COUNT +#else + #define PIC32_SEED_COUNT ReadCoreTimer +#endif /* uses the core timer, in nanoseconds to seed srand */ int GenerateSeed(OS_Seed* os, byte* output, word32 sz) { int i; - srand(ReadCoreTimer() * 25); + srand(PIC32_SEED_COUNT() * 25); for (i = 0; i < sz; i++ ) { output[i] = rand() % 256; if ( (i % 8) == 7) - srand(ReadCoreTimer() * 25); + srand(PIC32_SEED_COUNT() * 25); } return 0; diff --git a/cyassl/ctaocrypt/settings.h b/cyassl/ctaocrypt/settings.h index 1adab17c6..d61c5484a 100644 --- a/cyassl/ctaocrypt/settings.h +++ b/cyassl/ctaocrypt/settings.h @@ -130,7 +130,11 @@ #ifdef MICROCHIP_TCPIP /* include timer, NTP functions */ #include "system/system_services.h" - #include "tcpip/sntp.h" + #ifdef MICROCHIP_MPLAB_HARMONY + #include "tcpip/tcpip.h" + #else + #include "tcpip/sntp.h" + #endif #endif #ifdef MBED