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

📄 led_endsimu.c

📁 OMAP1030 处理器的ARM 侧硬件测试代码 OMAP1030 是TI的双核处理器
💻 C
字号:
/*==============================================================================
           TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION

   Property of Texas Instruments. For Unrestricted Internal Use Only
   Unauthorized reproduction and/or distribution is strictly prohibited.
   This product is protected under copyright law and trade secret law 
   as an unpublished work.  
   Created 2002, (C) Copyright 2002 Texas Instruments.  All rights reserved.

   Created        : 31st of May, 2002, 12.00pm

   Filename       : led_endsimu.c

   Description    : Body file for the OMAP1610 End of Simulation
   Description    : Body file for the ARM Interrupt handler level 1

   Project        : HELEN2, OMAP1610, OMAP32

   Author         : Francis Huguenin/Arnaud Balmelle and Dayo Adeyeye
   Adapted by     : Dayo Adeyeye for Helen2 LED only.

   FUNCTIONS PROVIDED

   void EndSimulation_LED(UWORD32 gpio_base_addr)
   void RES_Set_LED(value)
   void RES_Stop_Vhdl_LED()
   void RES_SetLocationLED    => Set location address of the result area
   void RES_GetFinalLED       => Evaluate Final result
   void RES_StopDPLL_VHDL(void)     => Stop DPLL & VHDL sims, wait 4 Dump LED
   void RES_Exception_LED(void)     => combined test exception handler

==============================================================================*/

#include "led_top.h"

UWORD16 ledresult [RESULT_SIZE+2];// To accomodate LED, reserve 2 more values

static UWORD16* led_start_location = NULL;
// static UWORD16* led_start_result = (UWORD16*)&ledresult;
static UWORD16* led_start_result = (UWORD16*)((int)&ledresult);
// static UWORD16* led_global_value = (UWORD16*)((&ledresult) + 1);
static UWORD16* led_global_value = (UWORD16*)((&ledresult) + 1);
/* Pointers to the first elementary led result, allows to reserve a number of
led result items in the range from 1 .. (IndexFirstValue - 1) */
static UWORD16* led_ptcurrent_value = NULL;
// static UWORD16* led_ptresult_current = (UWORD16*)&ledresult;
static UWORD16* led_ptresult_current = (UWORD16*)((int)&ledresult);

/*------------------------------------------------------------------------------
 NAME        : RES_Set_LED
 DESCRIPTION : Set the value of a status to one the values below
               RES_OK or RES_BAD or RES_THE_END or RES_NOT_TRIED
 PARAMETERS  : INPUT => Status to set
 RETURN VALUE: None
 LIMITATIONS : None
------------------------------------------------------------------------------*/
void RES_Set_LED(const UWORD16 status) {
  led_ptcurrent_value++;
  *(led_ptcurrent_value)  = status;
  led_ptresult_current++;
  *(led_ptresult_current) = status;
}

//------------------------------------------------------------------------------
// NAME        : BOOT_EndSimulation_LED(gpio_base_addr)
// DESCRIPTION : 
// PARAMETERS  : Input : UWORD32 gpio_base_addr
//               Output: None
// RETURN VALUE: None
// LIMITATIONS : None
// -----------------------------------------------------------------------------
void EndSimulation_LED(UWORD32 gpio_base_addr) {

  UWORD16 syncpin;
  UWORD8  wakeintsrc, syncintsrc;

  // Address of the array containing the spy_ledresults
  // Address corresponding to the 0x2000_0040 physical address
  REG32(SPY_SRAM_ADDR)=(UWORD32)&ledresult;

  //save the value indicating the end of the spy array
  RES_Set_LED(0xF1F1);

  // Configure & Enable interrupts on GPIO IRQ
  syncintsrc = (CTE_SYNC_INTSRC_TESTCASE & 0xFF);

  // Configure & Enable interrupts on Wakeup  IRQ
  wakeintsrc = (CTE_WAKE_INTSRC_TESTCASE & 0xFF);

  INTLED_InitLevel(syncintsrc,        // Interrupt map 14.
                 INTLED_IRQ,
                 INTLED_HIGHEST_PRIORITY,
                 HIGH_LEVEL_SENSITIVE);
  INTLED_EnableOneIT(syncintsrc, INTLED_IRQ);

  // Configure interrupt of OMAP LED mode
  INTLED_InitLevel(wakeintsrc,        // Interrupt map 78 and map 0.
                 INTLED_IRQ,
                 INTLED_HIGHEST_PRIORITY,
                 RISING_EDGE_SENSITIVE);
  INTLED_EnableOneIT(wakeintsrc, INTLED_IRQ);

  syncpin   = CTE_GPIO_SYNC_PIN;
  gpio_set_itena1(gpio_base_addr, syncpin);
  gpio_set_wkupena(gpio_base_addr, syncpin);

}

/* -----------------------------------------------------------------------------
 NAME        : RES_Stop_Vhdl_LED
 DESCRIPTION : Set THE_END into the last item of ledresult area to stop VHDL
               simulator
 PARAMETERS  : None
 RETURN VALUE: None
 LIMITATIONS : None
----------------------------------------------------------------------------- */
void RES_Stop_Vhdl_LED(void) {
  UWORD32 gpio_base_addr;
  UWORD16 execpin, statuspin;
  execpin   = CTE_GPIO_EXEC_PIN;
  gpio_base_addr = (CTE_GPIO_ADDR_LSB + (65536*CTE_GPIO_ADDR_MSB));

  EndSimulation_LED(gpio_base_addr);    // Function call
  // go to wait for interrupt, put arm to sleep
  // DumpSPY_Results(); // For function debug
  // Clear EXEC_PIN to 0, to indicate the tester the program is finished
  SetARM_WFI_sleep(gpio_base_addr, execpin);
  // Status pin set in Assembler
  statuspin = CTE_GPIO_STAT_PIN;
  DumpSPY_Results(gpio_base_addr, statuspin);
  *(led_start_location + LAST_ITEM_POS) = RES_THE_END;
}

/* -----------------------------------------------------------------------------
 NAME        : RES_GetFinalLED : LED Functions                                -
 DESCRIPTION : Evaluate Final Ledresult, also allow to have some more code as     -
               good ones. This function is especially done for the test of     -
	      reset values or the test register access                        -
               This function allow to have the codes from MIN_ARRAY_OK to      -
               MAX_ARRAY_OK not to be error codes. These 2 constants are       -
               defined above. Scan the ledresult array and set the first word to  -
               RES_NOT_TRIED, RES_BAD or RES_OK. LED signatures function       -
 PARAMETERS  : None                                                            -
 RETURN VALUE: Return the final status value and global status of the test     -
 LIMITATIONS : Must be used at the end of test                                 -
----------------------------------------------------------------------------- */
UWORD16  RES_GetFinalLED(void) {
  UWORD16* value;     // (*led_start_location) = RES_NOT_TRIED;
  UWORD16 ErrorCount = 0;

// We begin to scan at index 3, because index 1 == 0x5555 and index 2 == 0xAAAA
// for tdl led format
  for (value = (led_start_result + 1); value <= led_ptresult_current; value++) {

    // New code for FLED flow PASS or Fails out put from test macros
    if (value == (led_start_result + 1)) {
      if ((*value) != 0x0) {
	ErrorCount = (*value);
      }
      value++;
    }

    // Normal gets final.
    if ((*value) == DATA_STORE) value++;

    else if ((*led_global_value) == DATAEXPECTED_DATAREAD) led_global_value+=2;
    else if ((*value) == START_ARRAY_DATA) {
      while(((*value) != END_ARRAY_DATA) AND (value <= led_ptresult_current)) value++;
    }
    else if ( (*value) != RESULT_SEPARATOR && 
         (*value) != TEST_OK &&
         (*value) != TEST_RESET_VALUE_SEPARATOR  && 
         (*value) != TEST_MODULE_SEPARATOR  && 
         (*value) != GLOBAL_TEST_SEPARATOR  && 
         ((*value)<MIN_ARRAY_OK || 
          (*value)>MAX_ARRAY_OK)) {
         ErrorCount++;
    } //endif
  } // end for

  (*led_start_location) = ErrorCount;
  (*led_start_result) = ErrorCount;
  
  if (ErrorCount == 0) {
    led_ptresult_current++;
    *(led_ptresult_current)= 0xACED;
  } else {
    led_ptresult_current++;
    *(led_ptresult_current)= 0xDEAD;
  }
  return RES_OK;
} // End RES_GetFinalLED

/* -----------------------------------------------------------------------------
 NAME        : RES_SetLocationLED                                              -
 DESCRIPTION : Set the location SPY address of the result area values
 PARAMETERS  : INPUT => Start_address=Start Address of the Result area
 RETURN VALUE: None
 LIMITATIONS : None
------------------------------------------------------------------------------*/
void RES_SetLocationLED(const UWORD32 start_address) { 
  UWORD16* headerPtr;

  led_start_location  = (UWORD16*)(start_address);
  led_ptcurrent_value = (UWORD16*)(start_address);
  // for tdl led format 
  headerPtr=(UWORD16*)(&ledresult);
  *(headerPtr) = 0x5555;
  headerPtr++;
  *(headerPtr) = 0xAAAA;
  // Change address space to avoid smashing first 2 signatures (5555/AAAA)
  led_start_result = (UWORD16*)(((UWORD16*)&ledresult) + 2);
  led_ptresult_current = (((UWORD16*)&ledresult) + 2);
  led_global_value = led_start_result + 1;
}

//------------------------------------------------------------------------------
// NAME	      : RES_INIT_Result_LED
// DESCRIPTION : Initilize all the spy result memory (write 0xBABE).
// PARAMETERS  : None
// RETURN VALUE: None
// LIMITATIONS : Must be used before to start a test
// -----------------------------------------------------------------------------
void RES_INIT_Result_LED(void) {
  UWORD16* value;
   for(value=led_start_result;value<(led_start_result+RESULT_SIZE);value++)
     (*value) = RES_INIT_VAL;
   led_ptresult_current = led_start_result;
} // RES_INIT_Result_LED


//------------------------------------------------------------------------------
// NAME        : RES_StopDPLL_VHDL(void)
// DESCRIPTION : Stop DPLL and VHDL sims and wait for Dump LED routine
// PARAMETERS  : Input :
//               Output:
// RETURN VALUE: None
// LIMITATIONS : None
//------------------------------------------------------------------------------
void RES_StopDPLL_VHDL (void) {
  UWORD16 LED_Result;

  //switch off the dpll
  CLKRST_DPLLCTL1_REG = 0x2000;

  // Test DPLL in Bypass mode before
  while (CLKRST_DPLLCTL1_REG != 0x2002);

  ARM_CKCTL_REG &= 0x3000;

  // Now program to full synchronous mode instead of Bypass mode
  ARM_SYSST_REG &= 0xC7FF;

  // Stop VHDL simulator
  LED_Result = RES_GetFinalLED();

  // GPIO EXEC PIN for execution already set to high. so clear GPIO exec pin
  RES_Stop_Vhdl_LED();
}
 
//------------------------------------------------------------------------------
// NAME        : RES_Exception_LED(void)
// DESCRIPTION : CPU Exception occured,  combined test exception handler
// PARAMETERS  : Input : None
//               Output: None
// RETURN VALUE: None
// LIMITATIONS : None
//------------------------------------------------------------------------------
void RES_Exception_LED(void) {
  RES_Set_LED(0xAB0F);
  RES_StopDPLL_VHDL();
}

⌨️ 快捷键说明

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