📄 periph.h
字号:
/*******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2002 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
* $Element: /project/dsp568_sdk/sdk/src/dsp56838evm/nos/include/periph.h $ * $Author: saa $ * $Revision: /main/2 $ * $VOB: /project/dsp568_sdk $ * $OS: solaris $ *
* Description: direct access to pheripheral
*
* Notes: trick with ArchIO zero address and far V2 pheripheral address
*
******************************************************************************/
/* File: periph.h */
#ifndef __PERIPH_H
#define __PERIPH_H
#include "port.h"
#include "bsp.h"
#include "arch.h"
#include "arch_off.h"
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************
* Routines for Peripheral Memory Access
********************************************************
* Parameter usage:
* Addr - architecture structure field
* Mask - bit to manipulate
* Data - 16 bit word to assign or access
********************************************************/
#if defined( BSP_MACRO_ACCESS )
#define periphBitSet(Mask, Addr) *(Addr + BSP_PERIPH_OFF) |= Mask
#else /* defined( BSP_MACRO_ACCESS ) */
inline void periphBitSet(register UWord16 Mask, register volatile UWord16 * Addr)
{
#if defined( BSP_FARPTR_PATCH )
register unsigned int Value;
asm(move.w x:(Addr + BSP_PERIPH_BASE),Value);
asm(or.w Mask,Value);
asm(move.w Value,x:(Addr + BSP_PERIPH_BASE));
#else /* defined( BSP_FARPTR_PATCH ) */
*(Addr + BSP_PERIPH_OFF) |= Mask;
#endif /* defined( BSP_FARPTR_PATCH ) */
}
#endif /* defined( BSP_MACRO_ACCESS ) */
#if defined( BSP_MACRO_ACCESS )
#define periphBitClear(Mask, Addr) *(Addr + BSP_PERIPH_OFF) &= ~(Mask)
#else /* defined( BSP_MACRO_ACCESS ) */
inline void periphBitClear(register UWord16 Mask, register volatile UWord16 * Addr)
{
#if defined( BSP_FARPTR_PATCH )
register unsigned int Value;
asm(move.w x:(Addr + BSP_PERIPH_BASE),Value);
asm(not.w Mask);
asm(and.w Mask,Value);
asm(move.w Value,x:(Addr + BSP_PERIPH_BASE));
#else /* defined( BSP_FARPTR_PATCH ) */
*(Addr + BSP_PERIPH_OFF) &= ~(Mask);
#endif /* defined( BSP_FARPTR_PATCH ) */
}
#endif /* defined( BSP_MACRO_ACCESS ) */
#if defined( BSP_MACRO_ACCESS )
#define periphBitChange(Mask, Addr) *(Addr + BSP_PERIPH_OFF) ^= Mask
#else /* defined( BSP_MACRO_ACCESS ) */
inline void periphBitChange(register UWord16 Mask, register volatile UWord16 * Addr)
{
#if defined( BSP_FARPTR_PATCH )
register unsigned int Value;
asm(move.w x:(Addr + BSP_PERIPH_BASE),Value);
asm(eor.w Mask,Value);
asm(move.w Value,x:(Addr + BSP_PERIPH_BASE));
#else /* defined( BSP_FARPTR_PATCH ) */
*(Addr + BSP_PERIPH_OFF) ^= Mask;
#endif /* defined( BSP_FARPTR_PATCH ) */
}
#endif /* defined( BSP_MACRO_ACCESS ) */
#if defined( BSP_MACRO_ACCESS )
#define periphBitTest(Mask, Addr) ( *(Addr + BSP_PERIPH_OFF) & (Mask) )
#else /* defined( BSP_MACRO_ACCESS ) */
inline bool periphBitTest(register UWord16 Mask, register volatile UWord16 * Addr)
{
#if defined( BSP_FARPTR_PATCH )
register unsigned int Value;
asm(move.w x:(Addr + BSP_PERIPH_BASE), Value);
if ((Value & Mask) == 0)
{
return false;
}
return true;
#else /* defined( BSP_FARPTR_PATCH ) */
return( *(Addr + BSP_PERIPH_OFF) & (Mask) );
#endif /* defined( BSP_FARPTR_PATCH ) */
}
#endif /* defined( BSP_MACRO_ACCESS ) */
#if defined( BSP_MACRO_ACCESS )
#define periphMemWrite(Data, Addr) ( (*(Addr + BSP_PERIPH_OFF)) = Data )
#else /* defined( BSP_MACRO_ACCESS ) */
inline void periphMemWrite(register UWord16 Data, register volatile UWord16 * Addr)
{
#if defined( BSP_FARPTR_PATCH )
asm(move.w Data,X:(Addr + BSP_PERIPH_BASE));
#else /* defined( BSP_FARPTR_PATCH ) */
( (*(Addr + BSP_PERIPH_OFF)) = Data );
#endif /* defined( BSP_FARPTR_PATCH ) */
}
#endif /* defined( BSP_MACRO_ACCESS ) */
#if defined( BSP_MACRO_ACCESS )
#define periphMemRead(Addr) ((UWord16)*(Addr + BSP_PERIPH_OFF))
#else /* defined( BSP_MACRO_ACCESS ) */
inline UWord16 periphMemRead(register volatile UWord16 * Addr)
{
#if defined( BSP_FARPTR_PATCH )
register unsigned int Value;
asm(move.w X:(Addr + BSP_PERIPH_BASE),Value);
return Value;
#else /* defined( BSP_FARPTR_PATCH ) */
return *(Addr + BSP_PERIPH_OFF);
#endif /* defined( BSP_FARPTR_PATCH ) */
}
#endif /* defined( BSP_MACRO_ACCESS ) */
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -