selftest.c File Reference

#include "power_clocks_lib.h"
#include "gpio.h"
#include "intc.h"
#include "print_funcs.h"
#include "flashc.h"
#include <string.h>
#include "nlao_cpu.h"
#include "nlao_usart.h"
#include "polarssl/config.h"
#include "polarssl/md2.h"
#include "polarssl/md4.h"
#include "polarssl/md5.h"
#include "polarssl/sha1.h"
#include "polarssl/sha2.h"
#include "polarssl/sha4.h"
#include "polarssl/arc4.h"
#include "polarssl/des.h"
#include "polarssl/aes.h"
#include "polarssl/camellia.h"
#include "polarssl/base64.h"
#include "polarssl/bignum.h"
#include "polarssl/rsa.h"
#include "polarssl/x509.h"
#include "polarssl/xtea.h"

Go to the source code of this file.

Defines

#define _CRT_SECURE_NO_DEPRECATE   1

Functions

int _init_startup (void)
 Low-level initialization routine called during startup, before the main function.
static void init_sys_clocks (void)
 Initializes the MCU system clocks.
int main (int argc, char *argv[])

Variables

System Clock Frequencies
static pcl_freq_param_t pcl_freq_param


Define Documentation

#define _CRT_SECURE_NO_DEPRECATE   1

Definition at line 25 of file selftest.c.


Function Documentation

int _init_startup ( void   ) 

Low-level initialization routine called during startup, before the main function.

This version comes in replacement to the default one provided by the Newlib add-ons library. Newlib add-ons' _init_startup only calls init_exceptions, but Newlib add-ons' exception and interrupt vectors are defined in the same section and Newlib add-ons' interrupt vectors are not compatible with the interrupt management of the INTC module. More low-level initializations are besides added here.

Definition at line 98 of file selftest.c.

References pcl_freq_param.

00099 {
00100   // Import the Exception Vector Base Address.
00101   extern void _evba;
00102 
00103   // Load the Exception Vector Base Address in the corresponding system register.
00104   Set_system_register(AVR32_EVBA, (int)&_evba);
00105 
00106   // Enable exceptions.
00107   Enable_global_exception();
00108 
00109   // Initialize interrupt handling.
00110   INTC_init_interrupts();
00111 
00112   // Give the used CPU clock frequency to Newlib, so it can work properly.
00113   set_cpu_hz(pcl_freq_param.pba_f);
00114 
00115   // Initialize the USART used for the debug trace with the configured parameters.
00116   set_usart_base( ( void * ) DBG_USART );
00117 
00118   // Don't-care value for GCC.
00119   return 1;
00120 }

static void init_sys_clocks ( void   )  [static]

Initializes the MCU system clocks.

Definition at line 73 of file selftest.c.

References pcl_freq_param.

Referenced by main().

00074 {
00075    
00076   // Configure system clocks.
00077   if (pcl_configure_clocks(&pcl_freq_param) != PASS) {
00078     while(1);
00079   }
00080      
00081   // Initialize usart comm
00082   init_dbg_rs232(pcl_freq_param.pba_f);
00083 }

int main ( int  argc,
char *  argv[] 
)

Definition at line 146 of file selftest.c.

References aes_self_test(), arc4_self_test(), base64_self_test(), camellia_self_test(), des_self_test(), init_sys_clocks(), md2_self_test(), md4_self_test(), md5_self_test(), mpi_self_test(), rsa_self_test(), sha1_self_test(), sha2_self_test(), sha4_self_test(), x509_self_test(), and xtea_self_test().

00147 {
00148     int ret, v=1; // v=1 is verbos mode 
00149     
00150     init_sys_clocks();
00151        
00152     printf( "Start Self Test\n" );
00153     
00154 #if defined(POLARSSL_MD2_C)
00155     if( ( ret = md2_self_test( v ) ) != 0 )
00156         return( ret );
00157 #endif
00158 
00159 #if defined(POLARSSL_MD4_C)
00160     if( ( ret = md4_self_test( v ) ) != 0 )
00161         return( ret );
00162 #endif
00163 
00164 #if defined(POLARSSL_MD5_C)
00165     if( ( ret = md5_self_test( v ) ) != 0 )
00166         return( ret );
00167 #endif
00168 
00169 #if defined(POLARSSL_SHA1_C)
00170     if( ( ret = sha1_self_test( v ) ) != 0 )
00171         return( ret );
00172 #endif
00173 
00174 #if defined(POLARSSL_SHA2_C)
00175     if( ( ret = sha2_self_test( v ) ) != 0 )
00176         return( ret );
00177 #endif
00178 
00179 #if defined(POLARSSL_SHA4_C)
00180     if( ( ret = sha4_self_test( v ) ) != 0 )
00181         return( ret );
00182 #endif
00183 
00184 #if defined(POLARSSL_ARC4_C)
00185     if( ( ret = arc4_self_test( v ) ) != 0 )
00186         return( ret );
00187 #endif
00188 
00189 #if defined(POLARSSL_DES_C)
00190     if( ( ret = des_self_test( v ) ) != 0 )
00191         return( ret );
00192 #endif
00193 
00194 #if defined(POLARSSL_AES_C)
00195     if( ( ret = aes_self_test( v ) ) != 0 )
00196         return( ret );
00197 #endif
00198 
00199 #if defined(POLARSSL_BASE64_C)
00200     if( ( ret = base64_self_test( v ) ) != 0 )
00201         return( ret );
00202 #endif
00203 
00204 #if defined(POLARSSL_BIGNUM_C)
00205     if( ( ret = mpi_self_test( v ) ) != 0 )
00206         return( ret );
00207 #endif
00208 
00209 #if defined(POLARSSL_RSA_C)
00210     if( ( ret = rsa_self_test( v ) ) != 0 )
00211         return( ret );
00212 #endif
00213 
00214 #if defined(POLARSSL_X509_PARSE_C)
00215     if( ( ret = x509_self_test( v ) ) != 0 );
00216         //return( ret );
00217 #endif
00218 
00219 #if defined(POLARSSL_XTEA_C)
00220     if( ( ret = xtea_self_test( v ) ) != 0 )
00221         return( ret );
00222 #endif
00223 
00224 #if defined(POLARSSL_CAMELLIA_C)
00225     if( ( ret = camellia_self_test( v ) ) != 0 )
00226         return( ret );
00227 #endif
00228 
00229     if( v != 0 )
00230     {
00231         printf( "  [ All tests passed ]\n\n" );
00232 #ifdef WIN32
00233         printf( "  Press Enter to exit this program.\n" );
00234         fflush( stdout ); getchar();
00235 #endif
00236     }
00237 
00238     return( ret );
00239 }


Variable Documentation

pcl_freq_param_t pcl_freq_param [static]

Initial value:

{
  .cpu_f        = AVR32_PM_CPU_MAX_FREQ,
  .pba_f        = AVR32_PM_PBA_MAX_FREQ,
  .osc0_f       = FOSC0,
  .osc0_startup = OSC0_STARTUP
}

Definition at line 62 of file selftest.c.

Referenced by _init_startup(), and init_sys_clocks().


Generated on Fri Feb 19 02:31:59 2010 for AVR32 - POLARSSL - Self Test Example by  doxygen 1.5.5