373a8c32b2
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@55 9fe90eed-be63-e94b-8204-d34ff4c2ff93
99 lines
4.0 KiB
C
99 lines
4.0 KiB
C
/* ---------------------------------------------------------------------------
|
|
* IspProtocol.h - v0.1 (c) 2008 Micro-key bv
|
|
* ---------------------------------------------------------------------------
|
|
* Micro-key bv
|
|
* Industrieweg 28, 9804 TG Noordhorn
|
|
* Postbus 92, 9800 AB Zuidhorn
|
|
* The Netherlands
|
|
* Tel: +31 594 503020
|
|
* Fax: +31 594 505825
|
|
* Email: support@microkey.nl
|
|
* Web: www.microkey.nl
|
|
* ---------------------------------------------------------------------------
|
|
* Description: Handles the ISP-protocol (standard In System Programming -protocol)
|
|
* ---------------------------------------------------------------------------
|
|
* Version(s): 0.1, Feb 13, 2008, FSc
|
|
* Creation.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
#ifndef __ISPPROTOCOL_H__
|
|
#define __ISPPROTOCOL_H__
|
|
/** \file IspProtocol.h
|
|
\brief Handles the ISP-protocol (standard In System Programming -protocol)
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* System include files.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Application include files.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Constant and macro definitions.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
#define ISP_MAX_ADMINS (4)
|
|
#define ISP_START_BYTE (0xAA)
|
|
#define ISP_MAX_PAYLOAD_SIZE (80)
|
|
|
|
#define ISP_MSGID_ACKNOWLEDGE (0x01)
|
|
#define ISP_MSGID_UNLOCK (0x02)
|
|
#define ISP_MSGID_ERASEBLOCK (0x03)
|
|
#define ISP_MSGID_PROGRAMFLASH (0x04)
|
|
#define ISP_MSGID_VERIFYFLASH (0x05)
|
|
#define ISP_MSGID_FINISHPROGRAMMING (0x06)
|
|
#define ISP_MSGID_STARTPROGRAM (0x07)
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Type definitions.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
typedef enum
|
|
{
|
|
ISP_CMD_SUCCESS = 0,
|
|
ISP_INVALID_COMMAND = 1,
|
|
ISP_SRC_ADDR_ERROR = 2,
|
|
ISP_DST_ADDR_ERROR = 3,
|
|
ISP_SRC_ADDR_NOT_MAPPED = 4,
|
|
ISP_DST_ADDR_NOT_MAPPED = 5,
|
|
ISP_COUNT_ERROR = 6,
|
|
ISP_INVALID_SECTOR = 7,
|
|
ISP_SECTOR_NOT_BLANK = 8,
|
|
ISP_SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION = 9,
|
|
ISP_COMPARE_ERROR = 10,
|
|
ISP_BUSY = 11,
|
|
ISP_PAYLOAD_TOO_LARGE = 12,
|
|
ISP_RECV_BAD_CRC = 13,
|
|
ISP_INVALID_MESSAGE_ID = 14
|
|
} t_isp_responses;
|
|
|
|
typedef void (*t_isp_ack_callback)(t_isp_responses response);
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Variable declarations.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Function declarations.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
/** \brief Initialises a instance of the ISP-protocol handler */
|
|
int ispInitProtocol(t_isp_ack_callback);
|
|
|
|
/** \brief Does the protocol handling by parsing each byte received on the communication port. */
|
|
void ispHandleRxByte( int handle, UINT8 byte );
|
|
|
|
void ispAdd16bit(UINT8 *payloadlocation, UINT16 data);
|
|
void ispAdd32bit(UINT8 *payloadlocation, UINT32 data);
|
|
UINT8 ispGet8bit(UINT8 *payload, UINT8 *payloadIndex);
|
|
UINT16 ispGet16bit(UINT8 *payload, UINT8 *payloadIndex);
|
|
UINT32 ispGet32bit(UINT8 *payload, UINT8 *payloadIndex);
|
|
|
|
|
|
#endif /* __ISPPROTOCOL_H__ */
|