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

📄 define.h

📁 ARM嵌入式应用开发典型实例配书光盘,希望对你有用!
💻 H
字号:
/// define.h

#ifndef __DEFINE_H__
#define __DEFINE_H__

#include "streambuffer.h"

#define PrintMsg(_x_) dbg _x_;
#define PrintMsg1(_x_) dbg _x_;

//typedef unsigned char BYTE;
//typedef unsigned short WORD;

typedef unsigned char UCHAR;
typedef unsigned short USHORT;
typedef unsigned long ULONG;

#define ADDR_INT_PARAMETER		0xfffa
#define ADDR_INT_INDEX			0xfffb

/* Bulk transfer */
#define	BULK_IN_BUFSIZE			8192
#define	BULK_OUT_BUFSIZE		4096

typedef enum 
{
	DS_NOTSTARTED,		
	DS_IDLE,			// after StartDevice
	DS_OPENED,			// after CreateProc
	DS_BOOTUPED,		// after Bootup
	DS_RUNNING,			// after initialize
}DEVICE_STATE;

typedef enum
{
	IT_FATALERROR = 0,	// chip meets a fatal error
	IT_TIMEOUT    = 1,	// no video signal
}INTERRUPT_TYPE; 

/*
typedef struct _INTERRUPT_INFO
{
	PKEVENT			NotifyEvent;			
	HANDLE			NotifyHandle;
	unsigned short  RetValue;
	unsigned short  RetData;
}INTERRUPT_INFO;
*/
typedef enum
{
	UM_EZUSB,
	UM_ONCHIP,
}USB_MODE;
 
/*
//
// A structure representing the instance information associated with
// this particular device.
//
typedef struct _DEVICE_EXTENSION
{
	UNICODE_STRING	ifSymLinkName;

	// physical device object
	PDEVICE_OBJECT PhysicalDeviceObject;        

	// Device object we call when submitting Urbs/Irps to the USB stack
	PDEVICE_OBJECT StackDeviceObject;		

	DEVICE_STATE DeviceState;

	// Indicates the device needs to be cleaned up (ie., some configuration
	// has occurred and needs to be torn down).
	BOOLEAN NeedCleanup;

	// configuration handle for the configuration the device is currently in
	USBD_CONFIGURATION_HANDLE ConfigurationHandle;

	// ptr to the USB device descriptor for this device
	PUSB_DEVICE_DESCRIPTOR DeviceDescriptor;

	// we support up to one interface
	PUSBD_INTERFACE_INFORMATION Interface;

	// the number of device handles currently open to the device object.
	// Gets incremented by Create and decremented by Close
	ULONG OpenHandles;

	// use counter for the device.  Gets incremented when the driver receives
	// a request and gets decremented when a request s completed.
	LONG usage;

	// this ev gets set when it is ok to remove the device
	KEVENT evRemove;

	// TRUE if we're trying to remove this device
	BOOLEAN removing;

	int				InterruptThreadState;
	int				StreamThreadState;
	STREAM_BUFFER	StreamBuffer;
    KSEMAPHORE		CallUSBSemaphore;
    KSEMAPHORE		CallUSBNoTimeOutSemaphore;

	USB_MODE		UsbMode;	

	int				FrameCount;
	int				TotalBytes;

	int				InterruptNum;
	INTERRUPT_INFO	InterruptInfo[128];

	int				BlockSize;	// block size set by application

	int				IFrameNum;	// for drop all data before first I frame
	int				PFrameNum;	// for dropping B frame before first P frame or first 2 I frames

	KEVENT			evPacketReturn;	// return for send packet			
	USHORT			PacketReturnData;

	int				TotalDelay;		// current encoded - next frame to be fetched from stream buffer
	int				ChipDelay;		// current encoded - current added to stream buffer
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
*/

typedef struct
{
	/* Basic device information */
	struct usb_device	*usbdev;
	int					minor;
	int					open_count;

	/* Wait queue */
	wait_queue_head_t	wq_control_pipe;
	wait_queue_head_t	wq_download_pipe;
	wait_queue_head_t	wq_stream_pipe;
	wait_queue_head_t	wq_interrupt_pipe;
	wait_queue_head_t	wq_stop_stream_thread;

	/* Interrupt pipe */
	struct
	{
		short			allow_irq;
		short			ready;
		unsigned short	retval;
		unsigned short	retdata;
	} rd_irq_data;

	struct semaphore	mutex;
	wait_queue_head_t	wait;
	wait_queue_head_t	remove_ok;
	spinlock_t			lock;
	atomic_t			pending_io;
	int					remove_pending;
	int					got_mem;
	int					total_buffer_size;
	unsigned int		overruns;
	int					readptr;
	int					opened;
	struct list_head	free_buff_list;
	struct list_head	rec_buff_list;
	
	struct semaphore	mutex_streambuffer;
	STREAM_BUFFER		StreamBuffer;
	DEVICE_STATE		DeviceState;
	int					InterruptThreadState;
	int					StreamThreadState;

	/* Tasklet */
	struct tasklet_struct	bh;

	/* URB */
	purb_t				irq_urb;
	char				*irq_buf;

	purb_t				bulkin_urb;

	/* bulk transfer */
	int				bulk_out_size;

	int				stream_in_ready;

	unsigned char*	bulk_in_buffer;
	unsigned char*	bulk_out_buffer;
} usb_t,*pusb_t;


typedef struct _INT_PACKET
{
	unsigned short Buffer[32]; 	
} INT_PACKET, *PINT_PACKET;

typedef struct _CMD_PACKET
{
	int Type;
	int Param;
	unsigned char pBuf[64];
} CMD_PACKET;

typedef struct _READ_VIDEO_HEAD
{
	int FrameSize;
	int FrameCount;
	int TotalDelay;
	int ChipDelay;
	int FrameInBuf;
} READ_VIDEO_HEAD;

#endif

⌨️ 快捷键说明

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