📄 regblock.c
字号:
/*
$Workfile: RegBlock.c $
$Revision: 1.1 $
$Date: Apr 15 2003 16:18:58 $
*/
//******************************************************************
//
// Copyright (C) 2002. GENESIS MICROCHIP INC.
// All rights reserved. No part of this program may be reproduced.
//
// Genesis Microchip Corp., 2150 Gold Street
// Alviso, CA 95002 USA
// Genesis Microchip Inc., 165 Commerce Valley Dr. West
// Thornhill, Ontario, Canada, L3T 7V8
//
//================================================================
//
// MODULE: RegBlock.c
//
// USAGE : This module contains the 52xx Register Block functions
//
//
//******************************************************************
//******************************************************************
// I N C L U D E F I L E S
//******************************************************************
#include "inc\all.h"
//******************************************************************
// L O C A L DEFINITIONS
//******************************************************************
//******************************************************************
// C O D E
//******************************************************************
//******************************************************************
// FUNCTION : gm_WriteRegBlock
// USAGE : Block programming of 52xx registers.
// DESCRIPTION : This function takes the data indicated by the input
// pointer and writes the data to the indicated register.
// The function can perform write operations on byte only.
// It also can wait for a determined period of time
// between write operations.
//
// INPUT : Pointer to the data block
// OUTPUT : None
// GLOBALS : None
// USED_REGS : Registers that are indicated in the data block
//******************************************************************
void gm_WriteRegBlock(const gmt_REG_BLOCK * DataPtr)
{
WORD RegAddress;
BYTE opcode;
BYTE delay;
DWORD dData;
BYTE loop = 1;
while(loop)
{
opcode = *DataPtr++;
if ((opcode & OpCodeBits & 0x7f) != RBDelay) // delay is special, it has no associated address
{
RegAddress = *DataPtr++ + ((WORD) (opcode & RegBlockHiAddrBitsMask) << 8);
}
opcode &= OpCodeBits;
if (opcode & RegBlockEnd) // is it end of block operation ?
{
opcode &= 0x7f;
loop = 0;
}
dData = 0;
switch (opcode)
{
case RBWriteByte:
gm_WriteRegByte(RegAddress,*DataPtr++);
break;
case RBWriteWord:
dData = ((WORD)*DataPtr++ << 8);
dData += *DataPtr++;
gm_WriteRegWord(RegAddress, (WORD)dData);
break;
case RBWriteTriBytes:
dData = ((DWORD)*DataPtr++ << 16);
dData += ((DWORD) *DataPtr++ << 8);
dData += *DataPtr++;
gm_WriteRegTriBytes(RegAddress, dData);
break;
case RBWriteDWord:
dData = ((DWORD)*DataPtr++ << 24);
dData += ((DWORD)*DataPtr++ << 16);
dData += ((DWORD) *DataPtr++ << 8);
dData += *DataPtr++;
gm_WriteRegDWord(RegAddress, dData);
break;
case RBDelay:
delay = *DataPtr++;
gm_Delay1ms(delay);
break;
default: // if none of above, terminate the function.
loop = 0;
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -