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

📄 hwaccess.c

📁 这个是单片机4200的ui程序
💻 C
字号:
/*
 *  Start of Zoran Standard Header
 *  Copyright (c) 2005 Zoran Corporation
 *  
 *  
 *  All rights reserved.  Proprietary and confidential.
 *  
 *  DESCRIPTION for hwaccess.c
 *     Routines which control access to the chip-select-3 (CS3) region.
 *     Access must be controlled because we must change the CS3
 *     characteristics in order to talk to the text LCD on the
 *     combo UI board.
 *  
 *  NEW HISTORY COMMENT (description must be followed by a blank line)
 *  <Enter change description here>

 *  ===== HISTORY of changes in //depot/imgeng/sw/se_gw/ui/fs/comboui/hwaccess.c
 *  
 *  19/Aug/05 #1  dstrauss  Created.
 *  
 *  
 *  End of Zoran Standard Header
 */

#include "sys.h"
#include "ts.h"
#include "hwaccess.h"

/************************************************************
 * To access the text LCD we need to change the characteristics
 * of the chip select 3 accesses (SBSEL3 @ 0xE030002C) as follows:
 *
 * "SP"  bit[5]      = [1]         -- makes R/W strobes active high
 * "SUP" bits[25:22] = [0100]      -- setup time is 4 clocks 
 * "WH"  bits[21:19] = [100]       -- write hold is 4 clocks
 * "RH"  bits[18:16] = [100]       -- read hold is 4 clocks
 * "AD"  bits[15:8]  = [00011010]  -- cycle time is 26 clocks
 *
 * This code controls access to the CS3 region so the various
 * pieces of code don't step on each other.  For the 4050 we
 * need a separate semaphore to do this, but for the 4100 and 4200
 * we use the memory file system semaphore which controls *all* 
 * system bus accesses.
 *
 ************************************************************/
#define SBSELMASK (~((1<<5) | (0xf<<22) | (0x7<<19) | (0x7<<16) | (0xff<<8)))

#if defined(ZR4100) || defined(ZR4200)
/* Because of the necessity of reconfiguring the Quatro's pins
 * to access the memory card interface, we need to control
 * access to the system bus for 4100 and 4200 boards.
 */
#include "memfs.h"
#define LOCK_SYSTEM_BUS   memfsFIFOProtect(MEMFS_FIRE_REF_UI_FIFO_ACCESS);
#define UNLOCK_SYSTEM_BUS memfsFIFOUnprotect(MEMFS_FIRE_REF_UI_FIFO_ACCESS);

#elif defined(ZR4050)

static tsSemaphore hwAccessSem = INVALIDSEM;
#define LOCK_SYSTEM_BUS   TASKSEMWAIT(hwAccessSem)
#define UNLOCK_SYSTEM_BUS TASKSEMSIGNAL(hwAccessSem)

#endif /* not 4100 and not 4200 */

static Uint32 SBSEL3Save;

void hwAccessInit()
{
#if !defined(ZR4100) && !defined(ZR4200)
  hwAccessSem = TaskSemCreate(1);
  ASSERT(hwAccessSem != INVALIDSEM);
#endif /* not 4100 and not 4200 */
}

/************************************************************
 * hwAccessLock -- Get exclusive access to the chip-select 3 (CS3)
 *                  region.  All modules which talk to the
 *                  combo-UI board *must* call this routine
 *                  before reading from or writing to
 *                  registers on the board.
 *
 *                  This routine may block while waiting for access.
 *
 * Parameters:      Bool accessLCD -- TRUE if the calling routine
 *                  wants to access the color LCD (in which case
 *                  the CS3 access parameters are changed).
 *                 
 ************************************************************/
void hwAccessLock(Bool accessLCD)
{
  LOCK_SYSTEM_BUS;
  if (accessLCD) {
    Uint32 newsetting;

    /* change CS3 attributes so we can talk to the text LCD module */
    newsetting = SBSEL3Save = *(volatile Uint32 *)0xE030002C;
    newsetting &= SBSELMASK;
    newsetting |= ((1<<5)|(4<<22)|(4<<19)|(4<<16)|(26<<8));
    *(volatile Uint32 *)0xE030002C = newsetting;
  }
}

/************************************************************
 * hwAccessUnlock -- Relinquish exclusive access to the chip-select 3
 *                    (CS3) region.  All modules which talk to the
 *                    combo-UI board *must* call this routine
 *                    after reading from or writing to
 *                    registers on the board.
 *
 * Parameters:        Bool accessLCD -- TRUE if the calling routine
 *                    accessed the color LCD (in which case
 *                    the CS3 access parameters are restored).
 *                 
 ************************************************************/
void hwAccessUnlock(Bool accessLCD)
{
  if (accessLCD) {
    /* restore CS3 attributes */
    *(volatile Uint32 *)0xE030002C = SBSEL3Save;
  }
  UNLOCK_SYSTEM_BUS;
}

⌨️ 快捷键说明

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