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

📄 embedded_services.h

📁 基于AT91SAM9260的bootloader
💻 H
📖 第 1 页 / 共 2 页
字号:
//*----------------------------------------------------------------------------//*      ATMEL Microcontroller Software Support  -  ROUSSET  -//*----------------------------------------------------------------------------//* The software is delivered "AS IS" without warranty or condition of any//* kind, either express, implied or statutory. This includes without//* limitation any warranty or condition with respect to merchantability or//* fitness for any particular purpose, or against the infringements of//* intellectual property rights of others.//*----------------------------------------------------------------------------//* File Name           : embedded_sevices.h//* Object              : Header File with all the embedded software services definitions//*//* 1.0 24 Jan 2003 FB  : Creation//*----------------------------------------------------------------------------#ifndef embedded_sevices_h#define embedded_sevices_h////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////#include "AT91RM9200.h"#define AT91C_BASE_ROM	(char *)0x00100000//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Buffer Structure//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Return values#define AT91C_BUFFER_SUCCESS		   0#define AT91C_BUFFER_ERROR_SHIFT      16#define AT91C_BUFFER_ERROR            (0x0F << AT91C_BUFFER_ERROR_SHIFT)#define AT91C_BUFFER_OVERFLOW         (0x01 << AT91C_BUFFER_ERROR_SHIFT)#define AT91C_BUFFER_UNDERRUN         (0x02 << AT91C_BUFFER_ERROR_SHIFT)typedef unsigned int AT91S_BufferStatus;struct _AT91S_Pipe;// This structure is a virtual object of a buffertypedef struct _AT91S_Buffer{	struct _AT91S_Pipe *pPipe;	void *pChild;	// Functions invoked by the pipe	AT91S_BufferStatus (*SetRdBuffer)     (struct _AT91S_Buffer *pSBuffer, char *pBuffer, unsigned int Size);	AT91S_BufferStatus (*SetWrBuffer)     (struct _AT91S_Buffer *pSBuffer, char const *pBuffer, unsigned int Size);	AT91S_BufferStatus (*RstRdBuffer)     (struct _AT91S_Buffer *pSBuffer);	AT91S_BufferStatus (*RstWrBuffer)     (struct _AT91S_Buffer *pSBuffer);	char (*MsgWritten)      (struct _AT91S_Buffer *pSBuffer, char const *pBuffer);	char (*MsgRead)         (struct _AT91S_Buffer *pSBuffer, char const *pBuffer);	// Functions invoked by the peripheral	AT91S_BufferStatus (*GetWrBuffer)     (struct _AT91S_Buffer *pSBuffer, char const **pData, unsigned int *pSize);	AT91S_BufferStatus (*GetRdBuffer)     (struct _AT91S_Buffer *pSBuffer, char **pData, unsigned int *pSize);	AT91S_BufferStatus (*EmptyWrBuffer)   (struct _AT91S_Buffer *pSBuffer, unsigned int size);	AT91S_BufferStatus (*FillRdBuffer)    (struct _AT91S_Buffer *pSBuffer, unsigned int size);	char (*IsWrEmpty)      (struct _AT91S_Buffer *pSBuffer);	char (*IsRdFull)       (struct _AT91S_Buffer *pSBuffer);} AT91S_Buffer, *AT91PS_Buffer;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// End of Buffer Structure////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SBuffer Structure//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ===========================================================================================// SimpleBuffer definition//// This structure is pointed by pRealBuffer field in the SBuffer// It contains usefull information for a real implementation of// a SBuffer object.// The application just create an instance of SSBUffer and SBuffer,// call OpenSimpleBuffer, and continue using SBuffer instancetypedef struct _AT91S_SBuffer{	AT91S_Buffer parent;	char         *pRdBuffer;	char const   *pWrBuffer;	unsigned int szRdBuffer;	unsigned int szWrBuffer;	unsigned int stRdBuffer;	unsigned int stWrBuffer;} AT91S_SBuffer, *AT91PS_SBuffer;typedef AT91PS_Buffer (*AT91PF_OpenSBuffer) (AT91PS_SBuffer);// This function is called by the applicationextern AT91PS_Buffer AT91F_OpenSBuffer(AT91PS_SBuffer pBuffer);// Functions invoked by the pipeextern AT91S_BufferStatus AT91F_SbSetRdBuffer  (AT91PS_Buffer pBuffer, char *pData, unsigned int Size);extern AT91S_BufferStatus AT91F_SbSetWrBuffer  (AT91PS_Buffer pBuffer, char const *pData, unsigned int Size);extern AT91S_BufferStatus AT91F_SbRstRdBuffer  (AT91PS_Buffer pBuffer);extern AT91S_BufferStatus AT91F_SbRstWrBuffer  (AT91PS_Buffer pBuffer);extern char AT91F_SbMsgWritten   (AT91PS_Buffer pBuffer, char const *pMsg);extern char AT91F_SbMsgRead      (AT91PS_Buffer pBuffer, char const *pMsg);// Functions invoked by the peripheralextern AT91S_BufferStatus AT91F_SbGetWrBuffer  (AT91PS_Buffer pBuffer, char const **pData, unsigned int *pSize);extern AT91S_BufferStatus AT91F_SbGetRdBuffer  (AT91PS_Buffer pBuffer, char **pData, unsigned int *pSize);extern AT91S_BufferStatus AT91F_SbEmptyWrBuffer(AT91PS_Buffer pBuffer, unsigned int size);extern AT91S_BufferStatus AT91F_SbFillRdBuffer (AT91PS_Buffer pBuffer, unsigned int size);extern char AT91F_SbIsWrEmpty   (AT91PS_Buffer pBuffer);extern char AT91F_SbIsRdFull    (AT91PS_Buffer pBuffer);#ifdef DBG_DRV_BUFFERextern char const *AT91F_SbGetError(AT91S_BufferStatus errorNumber);#endif//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// End of SBuffer Structure////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Tempo service//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////#define AT91C_OPEN_CTRLTEMPO_SUCCESS	0#define AT91C_ERROR_OPEN_CTRLTEMPO		1#define AT91C_START_OK					2#define AT91C_STOP_OK					3#define AT91C_TIMEOUT_REACHED			4/************************************************************************************************************************/typedef enum _AT91E_SvcTempo {	AT91E_SVCTEMPO_DIS,	AT91E_SVCTEMPO_EN} AT91E_SvcTempo;/************************************************************************************************************************/typedef unsigned int AT91S_TempoStatus;/************************************************************************************************************************/// AT91S_SvcTempotypedef struct _AT91S_SvcTempo{	// Methods:	AT91S_TempoStatus (*Start)  (		struct _AT91S_SvcTempo *pSvc,		unsigned int timeout,		unsigned int reload,		void (*callback) (AT91S_TempoStatus, void *),		void *pData);	AT91S_TempoStatus (*Stop)   (struct _AT91S_SvcTempo *pSvc);	struct _AT91S_SvcTempo *pPreviousTempo;	struct _AT91S_SvcTempo *pNextTempo;	// Data	unsigned int TickTempo;	//* timeout value	unsigned int ReloadTempo;//* Reload value for periodic execution	void (*TempoCallback)(AT91S_TempoStatus, void *);	void *pPrivateData;	AT91E_SvcTempo flag;} AT91S_SvcTempo, *AT91PS_SvcTempo;/************************************************************************************************************************/// AT91S_CtrlTempotypedef struct _AT91S_CtlTempo{	// Members:	// Start and stop for Timer	hardware	AT91S_TempoStatus (*CtlTempoStart)  (void *pTimer);	AT91S_TempoStatus (*CtlTempoStop)   (void *pTimer);	// Start and stop for Tempo service	AT91S_TempoStatus (*SvcTempoStart)  (		struct _AT91S_SvcTempo *pSvc,		unsigned int timeout,		unsigned int reload,		void (*callback) (AT91S_TempoStatus, void *),		void *pData);	AT91S_TempoStatus (*SvcTempoStop)   (struct _AT91S_SvcTempo *pSvc);	AT91S_TempoStatus (*CtlTempoSetTime)(struct _AT91S_CtlTempo *pCtrl, unsigned int NewTime);	AT91S_TempoStatus (*CtlTempoGetTime)(struct _AT91S_CtlTempo *pCtrl);	AT91S_TempoStatus (*CtlTempoIsStart)(struct _AT91S_CtlTempo *pCtrl);	AT91S_TempoStatus (*CtlTempoCreate) (								struct _AT91S_CtlTempo *pCtrl,								struct _AT91S_SvcTempo *pTempo);	AT91S_TempoStatus (*CtlTempoRemove) (								struct _AT91S_CtlTempo *pCtrl,								struct _AT91S_SvcTempo *pTempo);	AT91S_TempoStatus (*CtlTempoTick)   (struct _AT91S_CtlTempo *pCtrl);	// Data:	void *pPrivateData;     // Pointer to devived class	void const *pTimer;			// hardware	AT91PS_SvcTempo pFirstTempo;	AT91PS_SvcTempo pNewTempo;} AT91S_CtlTempo, *AT91PS_CtlTempo;/************************************************************************************************************************/typedef AT91S_TempoStatus (*AT91PF_OpenCtlTempo)   ( AT91PS_CtlTempo, void const *);/************************************************************************************************************************/// This function is called by the application.extern AT91S_TempoStatus AT91F_OpenCtlTempo( AT91PS_CtlTempo pCtrlTempo, void const *pTempoTimer );extern AT91S_TempoStatus AT91F_STStart   (void *);extern AT91S_TempoStatus AT91F_STStop    (void *);extern AT91S_TempoStatus AT91F_STSetTime (AT91PS_CtlTempo, unsigned int);extern AT91S_TempoStatus AT91F_STGetTime (AT91PS_CtlTempo);extern AT91S_TempoStatus AT91F_STIsStart (AT91PS_CtlTempo);extern AT91S_TempoStatus AT91F_CtlTempoCreate (AT91PS_CtlTempo, AT91PS_SvcTempo);extern AT91S_TempoStatus AT91F_CtlTempoRemove (AT91PS_CtlTempo, AT91PS_SvcTempo);extern AT91S_TempoStatus AT91F_CtlTempoTick   (AT91PS_CtlTempo);extern AT91S_TempoStatus AT91F_SvcTempoStart (		AT91PS_SvcTempo pSvc,		unsigned int timeout,		unsigned int reload,		void (*callback) (AT91S_TempoStatus, void *),		void *pData);extern AT91S_TempoStatus AT91F_SvcTempoStop (AT91PS_SvcTempo);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// End of Tempo service////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Xmodem service//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Following types are defined in another header filesstruct _AT91S_Buffer;/************************************************************************************************************************/// Constants:#define AT91C_COMMSVC_SUCCESS     0#define AT91C_COMMSVC_ERROR_SHIFT 8#define AT91C_COMMSVC_ERROR       (0x0f << AT91C_COMMSVC_ERROR_SHIFT)/************************************************************************************************************************/typedef unsigned int AT91S_SvcCommStatus;/************************************************************************************************************************/// AT91S_Service definition// This structure is an abstraction of a communication peripheraltypedef struct _AT91S_Service{	// Methods:	AT91S_SvcCommStatus (*Reset)  (struct _AT91S_Service *pService);	AT91S_SvcCommStatus (*StartTx)(struct _AT91S_Service *pService);	AT91S_SvcCommStatus (*StartRx)(struct _AT91S_Service *pService);	AT91S_SvcCommStatus (*StopTx) (struct _AT91S_Service *pService);	AT91S_SvcCommStatus (*StopRx) (struct _AT91S_Service *pService);	char                (*TxReady)(struct _AT91S_Service *pService);	char                (*RxReady)(struct _AT91S_Service *pService);	// Data:	struct _AT91S_Buffer *pBuffer; // Link to a buffer object	void *pChild;} AT91S_SvcComm, *AT91PS_SvcComm;/************************************************************************************************************************/// Constants:#define AT91C_XMODEM_SOH         0x01         /* Start of Heading for 128 bytes */#define AT91C_XMODEM_STX         0x02         /* Start of heading for 1024 bytes */#define AT91C_XMODEM_EOT         0x04         /* End of transmission */#define AT91C_XMODEM_ACK         0x06         /* Acknowledge */#define AT91C_XMODEM_NAK         0x15         /* Negative Acknowledge */#define AT91C_XMODEM_CRCCHR      'C'#define AT91C_XMODEM_PACKET_SIZE 2                 // packet + packetCRC#define AT91C_XMODEM_CRC_SIZE    2                 // crcLSB + crcMSB#define AT91C_XMODEM_DATA_SIZE_SOH    128          // data 128 corresponding to SOH header#define AT91C_XMODEM_DATA_SIZE_STX    1024         // data 1024 corresponding to STX header/************************************************************************************************************************///* Following structure is used by SPipe to refer to the USB device peripheral endpointtypedef struct _AT91PS_SvcXmodem {	// Public Methods:	AT91S_SvcCommStatus (*Handler) (struct _AT91PS_SvcXmodem *, unsigned int);	AT91S_SvcCommStatus (*StartTx) (struct _AT91PS_SvcXmodem *, unsigned int);	AT91S_SvcCommStatus (*StopTx)  (struct _AT91PS_SvcXmodem *, unsigned int);	// Private Methods:	AT91S_SvcCommStatus (*ReadHandler)  (struct _AT91PS_SvcXmodem *, unsigned int csr);	AT91S_SvcCommStatus (*WriteHandler) (struct _AT91PS_SvcXmodem *, unsigned int csr);	unsigned short      (*GetCrc)       (char *ptr, unsigned int count);	char                (*CheckHeader)  (unsigned char currentPacket, char *packet);	char                (*CheckData)    (struct _AT91PS_SvcXmodem *);	AT91S_SvcComm  parent;      // Base class

⌨️ 快捷键说明

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