prod_test.c File Reference

#include "config.h"
#include "conf_usb.h"
#include "modules/file_system/navigation.h"
#include "modules/control_access/ctrl_access.h"
#include "lib_mcu/flash/flash_lib.h"
#include "lib_system\memory\memory.h"

Include dependency graph for prod_test.c:

Go to the source code of this file.

Defines

#define PROD_TEST   DISABLE
#define TEST_FLAG_ADDR   0x500

Functions

code char g_prd_test At (0x500)
static void launch_test (void)
void prod_test (void)
 This function runs the production test is necessary.


Detailed Description

This file contains the feature to test USBKEY on prod - Compiler: IAR EWAVR and GNU GCC for AVR

Definition in file prod_test.c.


Define Documentation

#define PROD_TEST   DISABLE

Definition at line 50 of file prod_test.c.

#define TEST_FLAG_ADDR   0x500

Definition at line 72 of file prod_test.c.

Referenced by launch_test().


Function Documentation

code char g_prd_test At ( 0x500   ) 

static void launch_test ( void   )  [static]

Definition at line 94 of file prod_test.c.

References CTRL_GOOD, flash_lib_check(), flash_wr_block(), FS_CACHE_SIZE, FS_FORMAT_DEFAULT, fs_g_sector, Hwb_button_init, Is_btn_middle, Is_joy_down, Is_joy_left, Is_joy_right, Is_joy_up, Joy_init, Led1_toggle, Led2_toggle, Leds_init, memory_2_ram(), nav_drive_format(), nav_drive_set(), nav_file_create(), nav_reset(), ram_2_memory(), TEST_FLAG_ADDR, and TRUE.

Referenced by prod_test().

00095 {
00096    volatile U16 u16_tmp;
00097    U8 flag, save_int;
00098    char name_first_file[] = "USBKEY.tmp";
00099    
00100    // Init interface board
00101    Joy_init();
00102    Leds_init();
00103    Hwb_button_init();
00104    
00105    // Check joystick
00106    while( !Is_btn_middle() );
00107    while( !Is_joy_right() );
00108    while( !Is_joy_left() );
00109    while( !Is_joy_up() );
00110    while( !Is_joy_down() );
00111    
00112    // Format DataFlash
00113    nav_reset();
00114    if( !nav_drive_set( 0 ) )
00115       return;  // Test Error
00116    
00117    // Write in four sectors
00118    memset( fs_g_sector , 0x55 , FS_CACHE_SIZE );
00119    if (CTRL_GOOD != ram_2_memory( 0 , 16+0 , fs_g_sector ))
00120       return;  // Test Error
00121    if (CTRL_GOOD != ram_2_memory( 0 , 16+2 , fs_g_sector ))
00122       return;  // Test Error
00123    memset( fs_g_sector , 0xAA , FS_CACHE_SIZE );
00124    if (CTRL_GOOD != ram_2_memory( 0 , 16+1 , fs_g_sector ))
00125       return;  // Test Error
00126    if (CTRL_GOOD != ram_2_memory( 0 , 16+3 , fs_g_sector ))
00127       return;  // Test Error
00128 
00129    // Check value in sectors
00130    if (CTRL_GOOD != memory_2_ram( 0 , 16+0 , fs_g_sector ))
00131       return;  // Test Error
00132    for( u16_tmp=0; u16_tmp<FS_CACHE_SIZE; u16_tmp++) {
00133       if( fs_g_sector[u16_tmp] != 0x55 ) 
00134          return;  // Test Error
00135    }
00136    if (CTRL_GOOD != memory_2_ram( 0 , 16+2 , fs_g_sector ))
00137       return;  // Test Error
00138    for( u16_tmp=0; u16_tmp<FS_CACHE_SIZE; u16_tmp++) {
00139       if( fs_g_sector[u16_tmp] != 0x55 ) 
00140          return;  // Test Error
00141    }
00142    if (CTRL_GOOD != memory_2_ram( 0 , 16+1 , fs_g_sector ))
00143       return;  // Test Error
00144    for( u16_tmp=0; u16_tmp<FS_CACHE_SIZE; u16_tmp++) {
00145       if( fs_g_sector[u16_tmp] != 0xAA ) 
00146          return;  // Test Error
00147    }
00148    if (CTRL_GOOD != memory_2_ram( 0 , 16+3 , fs_g_sector ))
00149       return;  // Test Error
00150    for( u16_tmp=0; u16_tmp<FS_CACHE_SIZE; u16_tmp++) {
00151       if( fs_g_sector[u16_tmp] != 0xAA ) 
00152          return;  // Test Error
00153    }
00154    
00155    if( !nav_drive_format( FS_FORMAT_DEFAULT ) )
00156       return;  // Test Error
00157    
00158    // Create a temporary file on DataFlash
00159    if( !nav_file_create(name_first_file ))
00160       return;  // Test Error
00161 
00162    // Update status test flag
00163    if( !flash_lib_check() )
00164       return;  // Test Error
00165    save_int=Get_interrupt_state();
00166    Disable_interrupt();
00167    flag = TRUE;
00168    flash_wr_block( &flag, TEST_FLAG_ADDR, 1 );
00169    // Restore interrupt state
00170    if(save_int) { Enable_interrupt(); }
00171 
00172    // Display Led OK
00173    while( 1 )
00174    {
00175       // Blink led green
00176       Led1_toggle();
00177       Led2_toggle();
00178       for( u16_tmp=0; u16_tmp<0xFFFF; u16_tmp++ );
00179    }
00180 }

Here is the call graph for this function:

Here is the caller graph for this function:

void prod_test ( void   ) 

This function runs the production test is necessary.

Definition at line 85 of file prod_test.c.

References launch_test().

00086 {
00087    if( 0x00 != g_prd_test )
00088       return; // Test already done
00089    
00090    launch_test();
00091    while(1);
00092 }

Here is the call graph for this function:


Generated on Wed Sep 23 09:49:42 2009 for ATMEL by  doxygen 1.5.3