⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functions.c

📁 freescale atk source code
💻 C
📖 第 1 页 / 共 2 页
字号:
/*----------------------------------------------------------------------
* FILE:  functions.c
*-----------------------------------------------------------------------
*             (C) Copyright 2001 Metrowerks Corp.
*                 ALL RIGHTS RESERVED .
*
*   THIS IS  CONFIDENTIAL  PROPRIETARY SOURCE CODE OF METROWERKS CORP.
*
*          The copyright notice above does not evidence any
*         actual or intended publication of such source code.
*-----------------------------------------------------------------------
*
* DESCRIPTION: Diagnostic board test on the TORTOLA (i.mx31) board
*              Implementation file for common functions
*
* REFERENCES: 
*      1) TORTOLA spec
*
* HISTORY:
*
* 01 Feb  2005 zeldal	Created
*
*--------------------------------------------------------------------------*/

// #####   HEADER FILE INCLUDES   ################################################### 
#include <stdio.h>
#include "functions.h"
//#include "tortola_memory_map_defines.h"
//#include "verilog_trigger.h"

// #####   FUNCTION DEFINITIONS  -  EXPORTED FUNCTIONS   ############################### 

// #####    COMMON API  ############################ 

//----------------------------------------------------------------------
//  Verilog testbench Interaction Functions
//----------------------------------------------------------------------

//{{{1

// ===  FUNCTION  ======================================================================
// 
//         Name:  info_trigger
// 
//  Description: sends info message composed of 3 32-bit words to verilog-trigger,
//               may be used to send comparison events to verilog trigger
//               output message format is : 
// "Info ARM Event Triggered : INFO1 : <event> , INFO2 : <exp_data> , INFO3 : <act_data>"
// - PARAMETER -------------------------------------------------------------------------
//      Mode   Type             Name            Description
// -------------------------------------------------------------------------------------
//        in:  WORD             event            event number/ID or data word #1
//        in:  WORD             exp_data         expected data / data word #2
//        in:  WORD             act_data         actual data / data word #3
//    in-out:  
//       out:  
//    return: void 
// -------------------------------------------------------------------------------------
//    Author:  
//   Created:  03/01/04 12:05:45 IST
//  Revision:  none
// =====================================================================================
/*
void info_trigger(WORD event,WORD exp_data , WORD act_data)
{ //{{{2
  mem32_write( ARM_PORTHOLE_ADD+0x4 ,event);
  mem32_write( ARM_PORTHOLE_ADD+0x8 ,exp_data);
  mem32_write( ARM_PORTHOLE_ADD+0xc ,act_data);
  mem32_write( ARM_PORTHOLE_ADD , arm_vt_info);

} //2}}}
*/
// ===  FUNCTION  ======================================================================
// 
//         Name:  info_checktest_trigger
// 
//  Description: compares expected and actual data, and sends pass/fail events
//               and information message to verilog trigger
//               output message format is : 
// "CheckTest Info ARM Event Triggered : EVENT : <event>  Expected : <exp_data> Actual : <act_data>"
// 
// - PARAMETER -------------------------------------------------------------------------
//      Mode   Type             Name            Description
// -------------------------------------------------------------------------------------
//        in: WORD              event           event number/ID
//        in: WORD              exp_data        expected data
//        in: WORD              act_data        actual data
//    in-out:  
//       out:  
//    return: void 
// -------------------------------------------------------------------------------------
//    Author:  
//   Created:  03/01/04 12:08:23 IST
//  Revision:  none
// =====================================================================================
//void info_checktest_trigger(WORD event,WORD exp_data , WORD act_data)
//{ //{{{2
//  mem32_write( ARM_PORTHOLE_ADD+0x4 ,event);
//  mem32_write( ARM_PORTHOLE_ADD+0x8 ,exp_data);
//  mem32_write( ARM_PORTHOLE_ADD+0xC ,act_data);
//  mem32_write( ARM_PORTHOLE_ADD , arm_vt_checktest_info);

//} //2}}}

// ===  FUNCTION  ======================================================================
// 
//         Name:  wait_for_gpio_mcu_message 
// 
//  Description:  wait (loop) for certain 4 bit value on 
//                GPIO pads ({GPIO1_3,GPIO1_2,GPIO1_1,GPIO1_0}),
//                by reading PSR register of GPIO1.
//                Those pads are by default in GPIO mode
//                GPIO driver is by default enabled
// 
// - PARAMETER -------------------------------------------------------------------------
//      Mode   Type             Name            Description
// -------------------------------------------------------------------------------------
//        in:  WORD             val             value on GPIO to wait for
//    in-out:  
//       out:  
//    return:  void 
// -------------------------------------------------------------------------------------
//    Author:  
//   Created:  03/01/04 12:00:09 IST
//  Revision:  none
// =====================================================================================

void wait_for_gpio_mcu_message (WORD val)
{ //{{{2
	while (!((reg32_read(GPIO1_PSR0)&0xf) == val) );
    return; 
} //2}}}

//1}}}

//----------------------------------------------------------------------
//  Init Functions
//----------------------------------------------------------------------

//{{{1
// ===  FUNCTION  ======================================================================
// 
//         Name:  InitArray
// 
//  Description:  Initializes 2 arrays (real and expected results) 
// 
// - PARAMETER -------------------------------------------------------------------------
//      Mode   Type             Name            Description
// -------------------------------------------------------------------------------------
//        in:  WORD             *exp_val        expected results array
//        in:  WORD             *res_val        real results array
//        in:  int              num_of_res      number of results (array size)
//    in-out:  
//       out:  
//    return:  
// -------------------------------------------------------------------------------------
//    Author:  
//   Created:  03/01/04 12:01:19 IST
//  Revision:  none
// =====================================================================================
void InitArray(WORD *exp_val, WORD *res_val, int num_of_res)
{ //{{{2
   int i; 
   for (i=0; i<num_of_res; i++){
       exp_val[i] = 1; 
       res_val[i] = 0; 
   }
   return; 
} //2}}}


// ===  FUNCTION  ======================================================================
// 
//         Name:  configure_iomuxc_for_gpio_message_mcu 
// 
//  Description:  configure GPIO pads, so gpio message mechanism will work 
// 
// - PARAMETER -------------------------------------------------------------------------
//      Mode   Type             Name            Description
// -------------------------------------------------------------------------------------
//        in: void 
//    in-out:  
//       out:  
//    return: void
// -------------------------------------------------------------------------------------
//    Author:  
//   Created:  03/02/04 14:19:28 IST
//  Revision:  none
// =====================================================================================
/*
void configure_iomuxc_for_gpio_message_mcu (void) {
    // need to be on GPIO mode
    reg32_write_mask(SW_MUX_CTL_GPIO1_0_GPIO1_1_GPIO1_2_GPIO1_3,0x01010101,0xffffffff);
//  reg32_write_mask(SW_MUX_CTL_UART_CTS2_B_GPIO0_GPIO1_GPIO2,0x00121212,0x00ffffff);
//   reg32_write_mask(SW_MUX_CTL_GPIO3_GPIO4_GPIO5_UART_TXD1,0x24000000,0xff000000);
}
*/
//1}}}

//----------------------------------------------------------------------
//  Check Test Functions
//----------------------------------------------------------------------

//{{{1

// ===  FUNCTION  ======================================================================
// 
//         Name:  CheckTest
// 
//  Description: Main CheckTest routine. compares 2 arrays, gives pass/fail results,
//               sends events to verilog trigger, and finishes test on current processor
// 
// - PARAMETER -------------------------------------------------------------------------
//      Mode   Type             Name            Description
// -------------------------------------------------------------------------------------
//        in:  WORD             *exp_val        expected results array
//        in:  WORD             *res_val        real results array
//        in:  int              num_of_res      number of results (array size)
//    in-out:  
//       out:  
//    return:  
// -------------------------------------------------------------------------------------
//    Author:  
//   Created:  03/01/04 12:11:52 IST
//  Revision:  none
// =====================================================================================
int CheckTest(WORD *exp_val, WORD *res_val, int num_of_res)
{ //{{{2
   WORD var; 
   int rc;
   
//   var = reg32_read(GPIO1_PSR0); 
//   var &= 0x00000080; 
//   if (var==0x00000080) 
//      rc = IntCheckTest(exp_val,res_val,num_of_res);
//   else  
   	rc = ExtCheckTest(exp_val,res_val,num_of_res);
   // After CheckTest - test should end !
//   verilog_trigger(arm_vt_finish); 
	return rc;
} //2}}}

// ===  FUNCTION  ======================================================================
// 
//         Name:  ExtCheckTest
// 
//  Description: Compares 2 arrays (expected Vs. real results) and outputs
//               pass/fail events through verilog_trigger,  
//
// - PARAMETER -------------------------------------------------------------------------
//      Mode   Type             Name            Description
// -------------------------------------------------------------------------------------
//        in: WORD              *exp_val          expected values array
//        in: WORD              *res_val          real results array
//        in: int               num_of_res        number of results (array size) 
//    in-out:  
//       out: 
//    return: void 
// -------------------------------------------------------------------------------------
//    Author:  
//   Created:  03/01/04 11:57:03 IST
//  Revision:  none
// =====================================================================================
int ExtCheckTest(WORD *exp_val, WORD *res_val, int num_of_res) 
{ //{{{2
int rc;

  rc = compare_array(exp_val,res_val,num_of_res);
  return rc;
} //2}}}

// ===  FUNCTION  ======================================================================
// 
//         Name:  IntCheckTest
// 
//  Description: Compares 2 arrays (expected Vs. real results) and outputs
//               pass/fail events through verilog_trigger, and uses GPIO 
//               messaging.
// 
// - PARAMETER -------------------------------------------------------------------------
//      Mode   Type             Name            Description
// -------------------------------------------------------------------------------------
//        in: WORD              *exp_val          expected values array
//        in: WORD              *res_val          real results array
//        in: int               num_of_res        number of results (array size) 
//    in-out:  
//       out: 
//    return: void 
// -------------------------------------------------------------------------------------
//    Author:  
//   Created:  03/01/04 11:57:03 IST
//  Revision:  none
// =====================================================================================
int IntCheckTest(WORD *exp_val, WORD *res_val, int num_of_res) 
{//{{{2
    int i; 
    int error=0; 
    int rc = 0;
    
    for (i=0 ; i < num_of_res ; i++){
//        info_checktest_trigger(i,exp_val[i],res_val[i]);
        if (exp_val[i] == res_val[i]){ 
//            verilog_trigger(arm_vt_pass); 
			;
        }else{ 
            error++; 
//            verilog_trigger(arm_vt_fail); 
			rc = 1;
        }
    }
    if (error != 0) { 
        reg32_write(GPIO1_DR0, 0x00000010);
    }else{
        reg32_write(GPIO1_DR0, 0x00000000);
    }
    for (i=0 ; i < 32 ; i++); 
	
	reg32_write(GPIO1_DR0, 0x00000020);
    
    return rc;
} //2}}}



//1}}}


//----------------------------------------------------------------------
//  Data Compare Functions
//----------------------------------------------------------------------

//{{{1

// ===  FUNCTION  ======================================================================
// 
//         Name:  compare_array
// 
//  Description:  compare 2 arrays (expected values and real results),
//                and trigger pass/fail event for each comparison
//                uses info_checktest_trigger
// 
// - PARAMETER -------------------------------------------------------------------------
//      Mode   Type             Name            Description

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -