Added details on RTC oscillator startup delay and implemented a delay_us function. Added information about NO_INLINE and USE_SLOW_SHOW to example user_settings.h. Moved the USE_SLOW_SHA2 into the SHA512 area.

pull/409/head
David Garske 2016-05-05 09:43:11 -07:00
parent 5ee0659e1b
commit 726703e903
3 changed files with 35 additions and 6 deletions

View File

@ -15,6 +15,9 @@ void hw_uart_printchar(int c);
void hw_watchdog_disable(void);
uint32_t hw_rand(void);
// Delay functions
void delay_us(uint32_t microseconds);
#endif /* WOLFSSL_ROWLEY_HW_H */

View File

@ -58,6 +58,16 @@
/***********************************************/
// Private functions
static uint32_t mDelayCyclesPerUs = 0;
#define NOP_FOR_LOOP_INSTRUCTION_COUNT 6
static void delay_nop(uint32_t count)
{
int i;
for(i=0; i<count; i++) {
__asm volatile("nop");
}
}
static void hw_mcg_init(void)
{
/* Adjust clock dividers (core/system=div/1, bus=div/2, flex bus=div/2, flash=div/4) */
@ -119,6 +129,9 @@ static void hw_uart_init(void)
static void hw_rtc_init(void)
{
/* Init nop delay */
mDelayCyclesPerUs = (SYS_CLK_KHZ / 1000 / NOP_FOR_LOOP_INSTRUCTION_COUNT);
/* Enable RTC clock and oscillator */
SIM->SCGC6 |= SIM_SCGC6_RTC_MASK;
@ -141,10 +154,8 @@ static void hw_rtc_init(void)
/* Turn on */
RTC->CR |= RTC_CR_OSCE_MASK;
/* Wait RTC startup delay */
for (i=0; i<10000; i++) {
asm("nop");
}
/* Wait RTC startup delay 1000 us */
delay_us(1000);
}
/* Enable counter */
@ -203,6 +214,12 @@ uint32_t hw_rand(void)
return RNG->OR; /* Return next value in FIFO output register */
}
void delay_us(uint32_t microseconds)
{
delay_nop(mDelayCyclesPerUs * microseconds);
}
// Watchdog
void hw_watchdog_disable(void)
{

View File

@ -156,6 +156,8 @@ extern "C" {
/* Sha */
#undef NO_SHA
#if 1
/* 1k smaller, but 25% slower */
//#define USE_SLOW_SHA
#else
#define NO_SHA
#endif
@ -163,8 +165,6 @@ extern "C" {
/* Sha256 */
#undef NO_SHA256
#if 1
/* over twice as small, but 50% slower */
//#define USE_SLOW_SHA2
#else
#define NO_SHA256
#endif
@ -179,6 +179,9 @@ extern "C" {
#if 1
#define WOLFSSL_SHA384
#endif
/* over twice as small, but 50% slower */
//#define USE_SLOW_SHA2
#endif
/* MD5 */
@ -306,6 +309,12 @@ extern "C" {
#undef NO_CRYPT_BENCHMARK
//#define NO_CRYPT_BENCHMARK
/* In-lining of misc.c functions */
/* If defined, must include wolfcrypt/src/misc.c in build */
/* Slower, but about 1k smaller */
#undef NO_INLINE
//#define NO_INLINE
#undef NO_FILESYSTEM
#define NO_FILESYSTEM