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

📄 dma.h

📁 以TI 公司的OMAP5910为例
💻 H
字号:
//////////////////////////////////////////////////////////////////////////
//            Copyright (C) 2004, Eyoka @ Microunit
//                           All Rights Reserved
//________________________________________________________________________
//
// FILENAME:    dma.h
// PROJECT:     High-Resolution Video System On OMAP
// MODULE:      MPU System
// DESCRIPTION: System DMA Controller Interface
// TARGET CPU:  ARM-925T of OMAP5910
// VERSION:     0.2
//________________________________________________________________________
//
// REVISE HISTORY
// DATE         VERSION AUTHOR  DESCRIPTION
// 2004-11-08   0.2     Eyoka   Checked.
// 2004-11-01   0.1     Eyoka   Created.
//////////////////////////////////////////////////////////////////////////

#ifndef _DMA_H_
#define _DMA_H_

#include "datatypes.h"


/////////////////////////////////////////////////////////////////////
// TYPES
/////////////////////////////////////////////////////////////////////

typedef struct tagDMA_PARAM
{
	BYTE	ch;
	BYTE	data_type;
	BYTE	priority;
	BYTE	auto_init;
	BYTE	repeat;
	BYTE	frame_sync;
	BYTE	sync_req;
	BYTE	reserved1;

	DWORD	src_addr;
	BYTE	src_burst;
	BYTE	src_pack;
	BYTE	src_port;
	BYTE	src_amode;

	DWORD	dst_addr;
	BYTE	dst_burst;
	BYTE	dst_pack;
	BYTE	dst_port;
	BYTE	dst_amode;

	WORD	ele_n;
	WORD	ele_i;
	WORD	frame_n;
	WORD	frame_i;
}
DMA_PARAM;

typedef enum
{
	PORT_EMIFF		= 0,
	PORT_EMIFS		= 1,
	PORT_IMIF		= 2,
	PORT_TIPB		= 3,
	PORT_Local		= 4,
	PORT_TIPB_MPUI	= 5
}
DMA_PORT_t;

typedef enum
{
	DATATYPE_8BIT	= 0,
	DATATYPE_16BIT	= 1,
	DATATYPE_32BIT	= 2
}
DMA_DATATYPE_t;

typedef enum
{
	AMODE_CONST		= 0,
	AMODE_AUTO		= 1,
	AMODE_SINGLE	= 2,
	AMODE_DOUBLE	= 3
}
DMA_AMODE_t;

typedef enum
{
	SYNC_REQ_NONE		= 0,
	SYNC_REQ_MCSI1_TX	= 1,
	SYNC_REQ_MCSI1_RX	= 2,
	SYNC_REQ_I2C_RX		= 3,
	SYNC_REQ_I2C_TX		= 4,
	SYNC_REQ_EX0			= 5,
	SYNC_REQ_EX1			= 6,
	SYNC_REQ_UWire_TX	= 7,
	SYNC_REQ_McBSP1_TX	= 8,
	SYNC_REQ_McBSP1_RX	= 9,
	SYNC_REQ_McBSP3_TX	= 10,
	SYNC_REQ_McBSP3_RX	= 11,
	SYNC_REQ_UART1_TX	= 12,
	SYNC_REQ_UART1_RX	= 13,
	SYNC_REQ_UART2_TX	= 14,
	SYNC_REQ_UART2_RX	= 15,
	SYNC_REQ_McBSP2_TX	= 16,
	SYNC_REQ_McBSP2_RX	= 17,
	SYNC_REQ_UART3_TX	= 18,
	SYNC_REQ_UART3_RX	= 19,
	SYNC_REQ_Camera_RX	= 20,
	SYNC_REQ_MMC_TX		= 21,
	SYNC_REQ_MMC_RX		= 22,
//	Reserved			= 23,
//	Reserved			= 24,
//	Reserved			= 25,
	SYNC_REQ_USB_RX0		= 26,
	SYNC_REQ_USB_RX1		= 27,
	SYNC_REQ_USB_RX2		= 28,
	SYNC_REQ_USB_TX0		= 29,
	SYNC_REQ_USB_TX1		= 30,
	SYNC_REQ_USB_TX2		= 31	
}
DMA_EXTREQ_t;

typedef enum
{
	DMA_INT_BLOCK_DONE	= 5,
	DMA_INT_LAST_FRAME	= 4,
	DMA_INT_FRAME_DONE	= 3,
	DMA_INT_HALF_FRAME	= 2,
	DMA_INT_DROP		= 1,
	DMA_INT_TIMEOUT		= 0
}
DMA_INT_t;


/////////////////////////////////////////////////////////////////////
// DMA REGISTERS
/////////////////////////////////////////////////////////////////////

#define DMA_GCR				REG16(0xFFFEDC00)
#define DMA_CSDP(ch)		REG16(0xFFFED800 + ch * 0x40)
#define DMA_CCR(ch)			REG16(0xFFFED802 + ch * 0x40)
#define DMA_CICR(ch)		REG16(0xFFFED804 + ch * 0x40)
#define DMA_CSR(ch)			REG16(0xFFFED806 + ch * 0x40)
#define DMA_CSSA_L(ch)		REG16(0xFFFED808 + ch * 0x40)
#define DMA_CSSA_U(ch)		REG16(0xFFFED80A + ch * 0x40)
#define DMA_CDSA_L(ch)		REG16(0xFFFED80C + ch * 0x40)
#define DMA_CDSA_U(ch)		REG16(0xFFFED80E + ch * 0x40)
#define DMA_CEN(ch)			REG16(0xFFFED810 + ch * 0x40)
#define DMA_CFN(ch)			REG16(0xFFFED812 + ch * 0x40)
#define DMA_CFI(ch)			REG16(0xFFFED814 + ch * 0x40)
#define DMA_CEI(ch)			REG16(0xFFFED816 + ch * 0x40)
#define DMA_CPC(ch)			REG16(0xFFFED818 + ch * 0x40)


/////////////////////////////////////////////////////////////////////
// DMA FUNCTIONS
/////////////////////////////////////////////////////////////////////

//___________________________________________________________________
// Function: DMA_Setup
// Usage: Config DMA settings.
// Parameters:
//	pConfig			pointer to the configuration struct
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_Setup(DMA_PARAM *pConfig);

//___________________________________________________________________
// Function: DMA_Init
// Usage: Config DMA global settings.
// Parameters:		N/A
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_Init(void);

//___________________________________________________________________
// Function: DMA_EnableDstBurst
// Usage: Enable/Disable destination 4-BYTE burst ability.
// Parameters:
//	ch				channel ID.
//	bEnable			TRUE to Enable, FALSE to Disable.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_EnableDstBurst(BYTE ch, BOOL bEnable);

//___________________________________________________________________
// Function: DMA_EnableSrcBurst
// Usage: Enable/Disable source 4-BYTE burst ability.
// Parameters:
//	ch				channel ID.
//	bEnable			TRUE to Enable, FALSE to Disable.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_EnableSrcBurst(BYTE ch, BOOL bEnable);

//___________________________________________________________________
// Function: DMA_EnableDstPack
// Usage: Enable/Disable destination pack ability.
// Parameters:
//	ch				channel ID.
//	bEnable			TRUE to Enable, FALSE to Disable.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_EnableDstPack(BYTE ch, BOOL bEnable);

//___________________________________________________________________
// Function: DMA_EnableSrcPack
// Usage: Enable/Disable source pack ability.
// Parameters:
//	ch				channel ID.
//	bEnable			TRUE to Enable, FALSE to Disable.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_EnableSrcPack(BYTE ch, BOOL bEnable);

//___________________________________________________________________
// Function: DMA_SetDstPort
// Usage: Set destination port.
// Parameters:
//	ch				channel ID.
//	port			can be: PORT_EMIFF, PORT_EMIFS,
//					PORT_IMIF, PORT_TIPB, PORT_Local, PORT_TIPB_MPUI.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetDstPort(BYTE ch, DMA_PORT_t port);

//___________________________________________________________________
// Function: DMA_SetSrcPort
// Usage: Set source port.
// Parameters:
//	ch				channel ID.
//	port			can be: PORT_EMIFF, PORT_EMIFS,
//					PORT_IMIF, PORT_TIPB, PORT_Local, PORT_TIPB_MPUI.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetSrcPort(BYTE ch, DMA_PORT_t port);

//___________________________________________________________________
// Function: DMA_SetDataType
// Usage: Set transfer data type.
// Parameters:
//	ch				channel ID.
//	type			can be: DATATYPE_8BIT, DATATYPE_16BIT, DATATYPE_32BIT.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetDataType(BYTE ch, DMA_DATATYPE_t type);

//___________________________________________________________________
// Function: DMA_SetDstAdMode
// Usage: Set destination addressing mode.
// Parameters:
//	ch				channel ID.
//	addr_mode		can be: AMODE_CONST, AMODE_AUTO, AMODE_SINGLE
//					or AMODE_DOUBLE.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetDstAdMode(BYTE ch, DMA_AMODE_t addr_mode);

//___________________________________________________________________
// Function: DMA_SetSrcAdMode
// Usage: Set source addressing mode.
// Parameters:
//	ch				channel ID.
//	addr_mode		can be: AMODE_CONST, AMODE_AUTO, AMODE_SINGLE
//					or AMODE_DOUBLE.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetSrcAdMode(BYTE ch, DMA_AMODE_t addressing_mode);

//___________________________________________________________________
// Function: DMA_Programing
// Usage: 
// Parameters:
//	ch				channel ID.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_Programing(BYTE ch, BOOL bPrograming);

//___________________________________________________________________
// Function: DMA_SetRepeat
// Usage: Set repeat mode.
// Parameters:
//	ch				channel ID.
//	bRepeat			TRUE to disregard END_PROG, otherwise FALSE.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetRepeat(BYTE ch, BOOL bRepeat);

//___________________________________________________________________
// Function: DMA_SetAutoInit
// Usage: Set autoinit mode.
// Parameters:
//	ch				channel ID.
//	bAuto			auto restart or not.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetAutoInit(BYTE ch, BOOL bAuto);

//___________________________________________________________________
// Function: DMA_Start
// Usage: Start DMA transfer.
// Parameters:
//	ch				channel ID.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_Start(BYTE ch);

//___________________________________________________________________
// Function: DMA_Stop
// Usage: Stop DMA transfer.
// Parameters:
//	ch				channel ID.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_Stop(BYTE ch);

//___________________________________________________________________
// Function: DMA_IsBusy
// Usage: Query whether the DMA channel is busy.
// Parameters:
//	ch				channel ID.
// Return Values:
//	BOOL			TRUE if busy, FALSE if idle.
//___________________________________________________________________
//
BOOL DMA_IsBusy(BYTE ch);

//___________________________________________________________________
// Function: DMA_SetPriority
// Usage: Set priority of current channel.
// Parameters:
//	ch				channel ID.
//	bHigh			TRUE if is high-priority.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetPriority(BYTE ch, BOOL bHigh);

//___________________________________________________________________
// Function: DMA_FrameSync
// Usage: Set DMA request synchronize mode.
// Parameters:
//	ch				channel ID.
//	bSync			TRUE: a frame is transferred each DMA request,
//				  	FALSE: a element is transferred each DMA request.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_FrameSync(BYTE ch, BOOL bSync);

//___________________________________________________________________
// Function: DMA_SetSyncReq
// Usage: Set the external request to synchronize the DMA transfer.
// Parameters:
//	ch				channel ID.
//	req				external request ID, see defination of DMA_EXTREQ_t.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetSyncReq(BYTE ch, DMA_EXTREQ_t req);

//___________________________________________________________________
// Function: DMA_EnableINT
// Usage: Enable/Disable DMA generated interrupts.
// Parameters:
//	ch				channel ID.
//	intID			interrupt ID, can be:
//						DMA_INT_BLOCK_DONE, DMA_INT_LAST_FRAME,
//						DMA_INT_FRAME_DONE,	DMA_INT_HALF_FRAME,
//						DMA_INT_DROP or DMA_INT_TIMEOUT.
//	bEnable			TRUE to Enable, FALSE to Disable.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_EnableINT(BYTE ch, DMA_INT_t intID, BOOL bEnable);

//___________________________________________________________________
// Function: DMA_SetSrcAddr
// Usage: Set source address.
// Parameters:
//	ch				channel ID.
//	src_addr		source BYTE address.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetSrcAddr(BYTE ch, DWORD src_addr);

//___________________________________________________________________
// Function: DMA_SetDstAddr
// Usage: Set destination address.
// Parameters:
//	ch				channel ID.
//	dst_addr		destination BYTE address.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetDstAddr(BYTE ch, DWORD dst_addr);

//___________________________________________________________________
// Function: DMA_SetElementNumber
// Usage: Set number of elements each frame.
// Parameters:
//	ch				channel ID.
//	element_number	number of elements each frame.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetElementNumber(BYTE ch, WORD element_number);

//___________________________________________________________________
// Function: DMA_SetFrameNumber
// Usage: Set number of frames each block.
// Parameters:
//	ch				channel ID.
//	frame_number	number of frames each block.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetFrameNumber(BYTE ch, WORD frame_number);

//___________________________________________________________________
// Function: DMA_SetElementIndex
// Usage: Set element index.
// Parameters:
//	ch				channel ID.
//	element_index	element index.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetElementIndex(BYTE ch, WORD element_index);

//___________________________________________________________________
// Function: DMA_SetFrameIndex
// Usage: Set frame index.
// Parameters:
//	ch				channel ID.
//	frame_index		frame index.
// Return Values:	N/A
//___________________________________________________________________
//
void DMA_SetFrameIndex(BYTE ch, WORD frame_index);



#endif // ifndef _DMA_H_

⌨️ 快捷键说明

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