hondartp-1.2.0/src/comm.h

156 lines
5.2 KiB
C

#ifndef _COMM_H
#define _COMM_H
/**************************************************************************
* Written by Marcin O'BenY Benka <obeny@obeny.net>
* Version 1.1.4 (20091212)
*
* NOTE:
*
* Communication with PC using Xtronics ROMulator protocol.
**************************************************************************/
/***************************************************************************
* INCLUDES
***************************************************************************/
#include "global.h"
/***************************************************************************
* DEFINITIONS
***************************************************************************/
/* GLOBAL: tells how to treat byte_count in W write command */
extern BOOL b_bcnt_mode;
/* GLOBAL: indicates device status */
extern BOOL b_status_ready;
/* supported PC commands */
enum e_command
{
/* Xtronics ROMulator commands */
READ_BLOCK = 'R',
READ_BYTE = 'r',
STATUS = 'S',
UNKNOWN = '?',
VERSION = 'V',
WRITE_H = 'w',
WRITE_W = 'W',
WRITE_X = 'X',
/* extended commands for own usage */
BYTECOUNT_MODE = 'B',
FIRMWARE = 'F',
MODIFY = 'M',
VERSION_RESP = 'E', /* dirty workaround for ROMulator 'V' command */
};
/***************************************************************************
* FUNCTIONS
***************************************************************************/
/* counts checksum of given bytes */
/* -----------------------------------------------------------------------
RETURN VAL : added all bytes with no carry
ARGS : buffer_ptr - buffer pointer
length - number of bytes to add
* ----------------------------------------------------------------------- */
BYTE checksum(BYTE* buffer_ptr, const UINT16 length);
/* process command from PC */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommand();
/* modifies current byte_count handling method */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommandBytecountMode();
/* return version of installed firmware */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommandFirmware();
/* modifies current usart settings */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommandModify();
/* upload to PC block of data */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommandReadBlock();
/* upload to PC single byte of data */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommandReadByte();
/* process command from PC */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommandStatus();
/* tells whether device is ready to work */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommandUnknown();
/* illegal command received */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommandVersion();
/* returns device version */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommandVersionResp();
/* discards data sent by program as acknowledge of received version */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommandWriteW();
/* download to uC block of data (used also for hidden-write) */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
void pcCommandWriteX();
/* download to uC block of data */
/* -----------------------------------------------------------------------
RETURN VAL : NONE
ARGS : NONE
* ----------------------------------------------------------------------- */
#endif /* _COMM_H */
/* END */