//----------------------------------------------------
/**
	\file		ctk/inc/uctp.h
	\ingroup	serial
	\ingroup	all

	\brief		Funkce pro seriovou komunikaci protokol CTP
				<<< ALL >>>

	\author		ConTeK s.r.o., Ing. Vladimir Kastner
	\version	01.01
	\date		12.01.2007
*/
//----------------------------------------------------


#ifndef _UCTP_H_
#define _UCTP_H_		//!< Definice pritomnosti knihovny

#include <ctktypes.h>
#include <comm.h>
#include <ucrc16.h>
#include <codepage.h>
#include <ctktime.h>

#ifdef UCTP_SWINFO
//  #include <version.h>  //!< Aplikacne zavisly include!!
#endif // UCTP_SWINFO
#ifdef UCTP_DBGW
  #include <dbgwdef.h>
#endif // UCTP_DBGW

#ifdef UCTP_PARAM
  #include <datadef.h>
#endif // UCTP_PARAM

#if defined(UCTP_CODEPAGE) && (UCTP_CODEPAGE != SYSTEM_CODEPAGE)
	// je treba konvertovat znakove sady odesilanych retezcu
	#define UCTP_CP_CONV
#endif

//----------------------------------------------------
/**
	\brief	Definice verze protokolu,
			pri zasadni zmene zvysit
*/
//----------------------------------------------------

#define VERINFO_PROTOCOL_VERSION	2		//!< Verze protokolu ( pri zasadni zamene zvysit )

//----------------------------------------------------
/**
    \brief Vysvetleni zpusobu komunikace a rozdilu mezi klasickymi a periodickymi parametry

    klasicke parametry: typicky master-slave, master iniciuje kazde cteni

    master                                      slave
    pozadavek na cteni------------------------> zpracovani
    prijmuti <--------------------------------- odpoved

    periodicke parametry: master na pocatku odesle pozadavek na parametr spolu s periodou, s jakou se ma vycitat.
    slave pak uz sam od sebe odpovida vzdy po vyprseni predepsane periody.

    master                                      slave
    pozadavek na cteni+perioda----------------->zpracovani, ulozeni periody
    prijmuti <----------------------------------odpoved
    .......                                     .......
    .......                                     .......
    prijmuti <----------------------------------vyprsela perioda, odpoved
    .......                                     .......
    .......                                     .......
    prijmuti <----------------------------------vyprsela perioda, odpoved
    .......                                     .......

    rozdily v pouziti:
    klasicke parametry: obvykly zpusob komunikace, pro parametry ktere vycitame s dlouhou periodou ("dlouha" zavisi na konkretnim pripade)
    periodicke parametry: pro parametry ktere vycitame velice casto (napr. s periodou 200ms - kresleni grafu apod.). Pouziti periodickych
    parametru vyrazne setri komunikovany objem dat. Seznam periodickych parametru je uchovavan na strane slave a je periodicky prochazen,
    zda nejakemu z parametru nevyprsela perioda a neni tedy potreba ho odvysilat. Z tohoto duvodu je dobre mit nizky pocet periodickych parametru -
    ty slouzi opravdu pouze pro velmi casto komunikovane parametry.

*/
//----------------------------------------------------
/**
	\brief	Definice CTP protokolu
			FLAGS, SEQ, MSGID, *data*
			FLAGS:	typ paketu  odpoved, chybova odpoved, pozadavek,
					pozadavek, na nejz neni ocekavana odpoved
			SEQ:	sekvencni cislo paketu
			MSGID:	identifikator zpravy
*/
//----------------------------------------------------



//!	\name	FLAGS priznak  paketu
//@{

#define CTPF_REQUEST			0x80	//!< Pozadavek s odpovedi
#define CTPF_MESSAGE			0xC0	//!< Pozadavek bez odpovedi
#define	CTPF_RESPONSE			0x00	//!< Odpoved
#define CTPF_RESPONSE_NOREQ     0x20    //!< Automaticka odpoved bez pozadavku
#define CTPF_ERROR				0x40	//!< Chybova odpoved
#define CTPF_MASK				0xF0	//!< Maska pro priznaky CTPF_xxx

//@}


//!	\name	Chybove kody
//@{

#define CTPS_SUCCESS			0x00	//!< OK (tento kod se nikdy neposila)
#define CTPS_INVALID			0x01	//!< Pozadavek je neplatny (nespecifikovano jak)
#define CTPS_INVALID_PROCID		0x02	//!< Neplatne cislo procesu (nevyuziva se)
#define CTPS_INVALID_MSGID		0x03	//!< Neplatne cislo zpravy
#define CTPS_NODATA				0x04	//!< Data nejsou k dispozici

#define CTPS_INVALID_CODE 		0x05	//!< Neplatny kod parametru
#define CTPS_INVALID_INDEX0		0x06	//!< Neplatny index0 parametru
#define CTPS_INVALID_INDEX1		0x07	//!< Neplatny index1 parametru
#define CTPS_INVALID_INDEX2		0x08	//!< Neplatny index2 parametru
#define CTPS_INVALID_DATA		0x09	//!< Neplatna data
#define CTPS_ACCESS_ERROR		0x0A	//!< Nepovoleny pristup
#define CTPS_OUT_OF_RANGE		0x0B	//!< Hodnota mimo rozsah
#define CTPS_BUSY				0x0C	//!< System je zaneprazdnen a proto nelze zpravu zpracovat
//@}

//-----------------------------------------
//! \name	Chybove kody boot loaderu
//@{
#define CTPS_INVALID_ADDRESS	0x20	//!< Neplatna adresa
#define CTPS_BUFFER_OVERFLOW	0x21	//!< Neplatna delka bufferu
#define CTPS_APP_CRC_ERROR		0x22	//!< Neplatne crc aplikace
#define CTPS_WRITE_DENIED		0x23	//!< Zapis zamitnut
#define CTPS_NOT_SUPPORTED		0x24	//!< Operace nad danou pameti neni podporovana

#define CTPS_PLATFORM_DEP		0x40	//!< ??
//@}


//! \name Interni chybove kody
//@{

#define CTPS_MST_TIMEOUT			0xFFFF	//!< Timeout
#define CTPS_MST_INTERNAL_ERROR		0xFFFE	//!< Interni chyba
#define CTPS_MST_INVALID_LENGTH		0XFFFD	//!< Neplatna delka odpovedi
#define CTPS_MST_INVALID_DATA		0xFFFC	//!< Neplatna data odpovedi
#define CTPS_MST_INVALID_DEVICE		0xFFFB	//!< Nevhodne pripojene zarizeni

//@}

//--------------------------------------------------
//! \name Rezervovane identifikatory zprav
//@{

#ifdef UCTP_SWINFO
#define MSGID_GET_SWINFO				0xE0	//!< Cteni verze software a protokolu
#endif // UCTP_SWINFO

#ifdef UCTP_PARAM
#define MSGID_GET_PARAM					0xE2	//!< Cteni parametru
#define MSGID_SET_PARAM					0xE3	//!< Zapis parametru
#endif // UCTP_PARAM

#ifdef UCTP_PERIODICPARAM
#define MSGID_GET_PERIODICPARAM			0xC0    //!< Cteni periodickeho parametru a jeho pridani do seznamu periodicky vycitanych parametru
#define MSGID_REMOVE_PERIODICPARAM		0xC1    //!< Odstraneni parametru ze seznamu periodicky vycitanych parametru

#ifdef UCTP_BLOCK_PARAM
    #define MSGID_GET_BLKPERIODICPARAM		0xC2    //!< Cteni vice parametru naraz a jejich pridani do seznamu periodicky vycitanych parametru
    #define MSGID_REMOVE_BLKPERIODICPARAM	0xC3    //!< Odstraneni vice parametru naraz ze seznamu periodicky vycitanych parametru
#endif

#endif

#ifdef UCTP_BLKPARAM
#define MSGID_GET_BLKPARAM				0xEB	//!< Blokove cteni parametru
#define MSGID_SET_BLKPARAM				0xED	//!< Blokovy zapis parametru
#endif // UCTP_BLKPARAM

#ifdef UCTP_DBG
//#define MSGID_GET_DBGMSG				0xE4	//!< Cteni debugovaciho parametru
#define MSGID_SET_DBGMSG				0xE5	//!< Zapis debugovaciho parametru
#endif // UCTP_DBG

#ifdef UCTP_TSTMSG
#define MSGID_GET_TSTMSG				0xE6	//!< Testovaci zprava
#endif // UCTP_TSTMSG

#ifdef UCTP_DBGW
#define MSGID_GET_DBGW					0xE7	//!< Cteni ladenych promenych
#define MSGID_SET_DBGW					0xE8	//!< Zapis ladenych promenych
#endif // UCTP_DBGW

#ifdef UCTP_LOG
#define MSGID_GET_LOG					0xE9
#define MSGID_SET_LOG					0xEA
#endif

#ifdef UCTP_BLOCK_PARAM
#define MSGID_GET_BLOCK_PARAM			0xEB	//!< Cteni vice parametru naraz
#endif

#ifdef UCTP_TOUCH
//--------------------------------------------------
//! \name	Zpravy touchpadu
//@{
#define MSGID_TOUCH_RD_IDENT			0x20		//!< Pozadavek na identifikaci podrizeneho systemu, odpovedi jsou 3 byty
#define MSGID_TOUCH_RESET				0x21  		//!< Pozadavek na restart podrizeneho systemu

#define MSGID_TOUCH_RD_PORT				0x30		//!< Pozadavek na nacteni portu pro komunikaci s displayem, nevyuziva se
#define MSGID_TOUCH_WR_PORT				0x31		//!< Pozadavek na nastaveni tlacitek, ve formatu pro stary display

// zpravy nahrazujici zapis na port v novych verzich softwaru
#define MSGID_TOUCH_BUTTON_PRESS		0x32		//!< Pozadavek na stisk tlacitka menu
#define MSGID_TOUCH_BUTTON_RELEASE		0x33		//!< Pozadavek na uvolneni vsech tlacitek

//nastavovani parametru
#define MSGID_TOUCH_RD_DEGLITCH			0x40		//!< Pozadavek na vraceni aktualni hodnoty gDispDeglitch z podrizeneho systemu
#define MSGID_TOUCH_WR_DEGLITCH			0x41		//!< Nastaveni gDispDeglitch v podrizenem systemu

#define MSGID_TOUCH_RD_PRESSEDDLY		0x42		//!< Pozadavek na vraceni aktualni hodnoty gDispPressedDly z podrizeneho systemu
#define MSGID_TOUCH_WR_PRESSEDDLY		0x43		//!< Nastaveni gDispDeglitch v podrizenem systemu

#define MSGID_TOUCH_RD_RELEASEDLY		0x44		//!< Pozadavek na vraceni aktualni hodnoty gDispReleasedDly z podrizeneho systemu
#define MSGID_TOUCH_WR_RELEASEDLY		0x45		//!< Nastaveni gDispReleasedDly v podrizenem systemu

#define MSGID_TOUCH_RD_STABILIZATION	0x46		//!< Pozadavek na vraceni aktualni hodnoty gDispStabilization z podrizeneho systemu
#define MSGID_TOUCH_WR_STABILIZATION	0x47		//!< Nastaveni gDispStabilization v podrizenem systemu

#define MSGID_TOUCH_RD_FILTER_WEIGHT	0x48		//!< Pozadavek na vraceni aktualni hodnoty gDispFilterWeight z podrizeneho systemu
#define MSGID_TOUCH_WR_FILTER_WEIGHT	0x49		//!< Nastaveni gDispFilterWeight v podrizenem systemu

#define MSGID_TOUCH_RD_CHARGEWS			0x4a		//!< Pozadavek na vraceni aktualni hodnoty gDispChargeWS z podrizeneho systemu
#define MSGID_TOUCH_WR_CHARGEWS			0x4b		//!< Nastaveni gDispChargeWS v podrizenem systemu

//Zpravy posilane podrizenym systemem nadrazenemu
#define MSGID_TOUCH_PRESSED				0x50		//!< Zprava o stisku displaye
#define MSGID_TOUCH_RELEASED			0x51		//!< Zprava o pusteni displaye
#define MSGID_TOUCH_RESTART				0x52		//!< Pozadavek na restart systemu

#define MSGID_TOUCH_RD_PHASE_ADJUST		0x55		//!< Pozadavek na vraceni aktualni hodnoty gPhaseAdjust z podrizeneho systemu
#define MSGID_TOUCH_WR_PHASE_ADJUST		0x56		//!< Nastaveni gPhaseAdjust v podrizenem systemu

#define MSGID_TOUCH_RD_OFFSET_X			0x57		//!< Pozadavek na vraceni aktualni hodnoty gOffsetX z podrizeneho systemu
#define MSGID_TOUCH_WR_OFFSET_X			0x58		//!< Nastaveni gOffsetX v podrizenem systemu

#define MSGID_TOUCH_RD_OFFSET_Y			0x59		//!< Pozadavek na vraceni aktualni hodnoty gOffsetY z podrizeneho systemu
#define MSGID_TOUCH_WR_OFFSET_Y			0x5A		//!< Nastaveni gOffsetY v podrizenem systemu

#define MSGID_TOUCH_RD_SIZE_X			0x5B		//!< Pozadavek na vraceni aktualni hodnoty gSizeX z podrizeneho systemu
#define MSGID_TOUCH_WR_SIZE_X			0x5C		//!< Nastaveni gSizeY v podrizenem systemu

#define MSGID_TOUCH_RD_SIZE_Y			0x5D		//!< Pozadavek na vraceni aktualni hodnoty gSizeY z podrizeneho systemu
#define MSGID_TOUCH_WR_SIZE_Y			0x5E		//!< Nastaveni gSizeY v podrizenem systemu


//@}
#endif //UCTP_TOUCH


#ifdef UCTP_BLOADER
//-------------------------------------------------
//! \name Zpravy BootLoaderu
//@{
#define MSGID_BLDR_READ_MEM				0xF0	//!< Cteni pameti
#define MSGID_BLDR_WRITE_MEM			0xF1	//!< Zapis do pameti
#define MSGID_BLDR_ERASE_MEM			0xF2	//!< Vymaz sektoru/casti pameti
#define MSGID_BLDR_COMMAND				0xF3	//!< Platforme specificky prikaz

#define MSGID_BLDR_GET_INFO				0xF8	//!< Cteni struktury bootInfo
#define MSGID_BLDR_RUNAPP				0xF9	//!< Vyvolani aplikace
#define MSGID_BLDR_GET_DESC				0xFB	//!< Cteni deskriptoru pameti
#define MSGID_BLDR_EOMSG				0xFC	//!< Zprava posilana po dokonceni transakce bootloaderu (od verze 2.1)
#define MSGID_BLDR_VERIFY_MEM			0xFD	//!< Verifikace pameti
#define MSGID_BLDR_READ_CFG				0xD0	//!< Cteni konfiguracnich dat
#define MSGID_BLDR_WRITE_CFG			0xD1	//!< Zapis konfiguracnich dat
#endif

#if defined(UCTP_BLOADER) || defined(UCTP_RUNBOOT)
 #define MSGID_BLDR_RUNBOOT				0xFA	//!< Vyvolani bootloaderu
#endif // UCTP_BLOADER || UCTP_RUNBOOT
//0xE8-0xFF vyhrazeno ladicimu subsystemu

//@}




#ifdef UCTP_TOUCH
//-----------------------------------------
//! \name	Konstanty tlacitek displaye
//@{

#define	TOUCH_BTN_MENU		0x01	//!< Tlacitko menu
#define TOUCH_BTN_AUTO		0x02	//!< Tlacitko auto
#define	TOUCH_BTN_VOL_M		0x03	//!< Tlacitko volume minus
#define TOUCH_BTN_VOL_P		0x04	//!< Tlacitko volume plus
#define TOUCH_BTN_POWER		0x05	//!< Tlacitko zapnuti

#define TOUCH_BTN_CONTRAST_UP		0x06
#define TOUCH_BTN_CONTRAST_DOWN		0x07
#define TOUCH_BTN_BRIGHTNESS_UP		0x08
#define TOUCH_BTN_BRIGHTNESS_DOWN	0x09

//@}
#endif // UCTP_TOUCH

#ifdef UCTP_LOG
#define LOGID_LOGCOUNT		0x01
#define LOGID_ITEMSIZE		0x02
#define LOGID_ITEMCOUNT		0x03
#define LOGID_HEADERSIZE	0x04
#define LOGID_GETITEM		0x05
#define LOGID_GETHEADER		0x06
#endif // UCTP_LOG

#ifdef UCTP_DBG
//!	\name	Rezervovane identifikatory ladicich zprav
//@{
#define DBGID_SCRWIN		0x01	//!< Zapis stringu do scroll ladiciho okna
#define DBGID_SCRWINU		0x02	//!< Zapis uint do scroll ladiciho okna
#define DBGID_SCRWINI		0x03	//!< Zapis int do scroll ladiciho okna
#define DBGID_SCRWINF		0x04	//!< Zapis float do scroll ladiciho okna
#define DBGID_XYWIN			0x05	//!< Zapis do XY ladiciho okna
#define DBGID_XYWINU		0x06	//!< Zapis uint do XY ladiciho okna
#define DBGID_XYWINI		0x07	//!< Zapis int do XY ladiciho okna
#define DBGID_XYWINF		0x08	//!< Zapis float do XY ladiciho okna
#define DBGID_VIDWIN		0x09	//!< Zapis do video okna
#define DBGID_KEYB			0x0A	//!< Zapis do scroll ladiciho okna
#define DBGID_BUTTON		0x0B	//!< Definice tlacitka
//@}

//-----------------------------------------------------
//! \name Format vypisu cisla, nejnizsi rady vpravo
//@{
#define FRM_TP_DEC			0x00	//!< Dekadicky bez znamenka
#define FRM_TP_HEX			0x20	//!< Hexadecimalni
#define FRM_TP_BIN			0x40	//!< Binarni
#define FRM_TP_BOOL			0x60	//!< Boolean
#define FRM_TP_ASCII		0x80	//!< Ascii
//
#define FRM_TP_MSK			0xE0	//!< Maska typu vypisu D, H, B, Bl, A

#define FRM_SP_L			0x08	//!< Oddeleni mezerou casteji
#define FRM_SP_H			0x10	//!< Oddeleni mezerou mene casto
//
#define FRM_SP_MSK			0x18	//!< Maska oddeleni mezerou D(0,3,6) H(0,2,4) B(0,4,8,16)

#define FRM_LEN_1			0x00	//!< Format 1 znak
#define FRM_LEN_2			0x01	//!< Format 2 znaky
#define FRM_LEN_4			0x02	//!< Format 4 znaky
#define FRM_LEN_8			0x03	//!< Format 8 znaku
#define FRM_LEN_16			0x04	//!< Format 16 znaku
#define FRM_LEN_24			0x05	//!< Format 24 znaku
#define FRM_LEN_32			0x06	//!< Format 32 znaku
#define FRM_LEN_64			0x07	//!< Format 64 znaku
//
#define FRM_LEN_MSK			0x07	//!< Maska poctu znaku D() H(1..8) B(1..64) Bl() A()

#define DBGF_DEC \
	( FRM_TP_DEC | FRM_LEN_64 )				//!< Dekadicky obecny
#define DBGF_DEC_T \
	( FRM_TP_DEC | FRM_SP_L | FRM_LEN_64 )	//!< Dekadicky oddelene mezerami po tisici
#define DBGF_DEC_M \
	( FRM_TP_DEC | FRM_SP_H | FRM_LEN_64 )	//!< Dekadicky oddelene mezerami po milionech

#define DBGF_HEX_1 \
	( FRM_TP_HEX | FRM_LEN_1 )		//!< Hexadecimalni 1 cifra
#define DBGF_HEX_2 \
	( FRM_TP_HEX | FRM_LEN_2 )		//!< Hexadecimalni 2 cifry
#define DBGF_HEX_4 \
	( FRM_TP_HEX | FRM_LEN_4 )		//!< Hexadecimalni 4 cifry
#define DBGF_HEX_6 \
	( FRM_TP_HEX | FRM_LEN_6 )		//!< Hexadecimalni 6 cifer
#define DBGF_HEX_8 \
	( FRM_TP_HEX | FRM_LEN_8 )		//!< Hexadecimalni 8 cifer
#define DBGF_HEX_4_T \
	( FRM_TP_HEX | FRM_LEN_4 | FRM_SP_L )	//!< Hexadecimalni 4 cifry oddelene mezerami po dvou
#define DBGF_HEX_6_T \
	( FRM_TP_HEX | FRM_LEN_6 | FRM_SP_L )	//!< Hexadecimalni 6 cifer oddelene mezerami po dvou
#define DBGF_HEX_8_T \
	( FRM_TP_HEX | FRM_LEN_8 | FRM_SP_L )	//!< Hexadecimalni 8 cifer oddelene mezerami po dvou
#define DBGF_HEX_6_F \
	( FRM_TP_HEX | FRM_LEN_6 | FRM_SP_H )	//!< Hexadecimalni 6 cifer oddelene mezerami po ctyrech
#define DBGF_HEX_8_F \
	( FRM_TP_HEX | FRM_LEN_8 | FRM_SP_H )	//!< Hexadecimalni 8 cifer oddelene mezerami po ctyrech

#define DBGF_BIN_1 \
	( FRM_TP_BIN | FRM_LEN_1 )		//!< Binarni 1 cifra
#define DBGF_BIN_2 \
	( FRM_TP_BIN | FRM_LEN_2 )		//!< Binarni 2 cifry
#define DBGF_BIN_4 \
	( FRM_TP_BIN | FRM_LEN_4 )		//!< Binarni 4 cifry
#define DBGF_BIN_6 \
	( FRM_TP_BIN | FRM_LEN_6 )		//!< Binarni 6 cifer
#define DBGF_BIN_8 \
	( FRM_TP_BIN | FRM_LEN_8 )		//!< Binarni 8 cifer
#define DBGF_BIN_16 \
	( FRM_TP_BIN | FRM_LEN_16 )		//!< Binarni 16 cifer
#define DBGF_BIN_24 \
	( FRM_TP_BIN | FRM_LEN_24 )		//!< Binarni 24 cifer
#define DBGF_BIN_32 \
	( FRM_TP_BIN | FRM_LEN_32 )		//!< Binarni 32 cifer
#define DBGF_BIN_6_F \
	( FRM_TP_BIN | FRM_LEN_6 | FRM_SP_L )	//!< Binarni 6 cifer oddelene mezerami po ctyrech
#define DBGF_BIN_8_F \
	( FRM_TP_BIN | FRM_LEN_8 | FRM_SP_L )	//!< Binarni 8 cifer oddelene mezerami po ctyrech
#define DBGF_BIN_16_F \
	( FRM_TP_BIN | FRM_LEN_16 | FRM_SP_L )	//!< Binarni 16 cifer oddelene mezerami po ctyrech
#define DBGF_BIN_24_F \
	( FRM_TP_BIN | FRM_LEN_24 | FRM_SP_L )	//!< Binarni 24 cifer oddelene mezerami po ctyrech
#define DBGF_BIN_32_F \
	( FRM_TP_BIN | FRM_LEN_32 | FRM_SP_L )	//!< Binarni 32 cifer oddelene mezerami po ctyrech
#define DBGF_BIN_16_E \
	( FRM_TP_BIN | FRM_LEN_16 | FRM_SP_H )	//!< Binarni 16 cifer oddelene mezerami po osmi
#define DBGF_BIN_24_E \
	( FRM_TP_BIN | FRM_LEN_24 | FRM_SP_H )	//!< Binarni 24 cifer oddelene mezerami po osmi
#define DBGF_BIN_32_E \
	( FRM_TP_BIN | FRM_LEN_32 | FRM_SP_H )	//!< Binarni 32 cifer oddelene mezerami po osmi
#define DBGF_BIN_24_S \
	( FRM_TP_BIN | FRM_LEN_24 | FRM_SP_L | FRM_SP_H )	//!< Binarni 24 cifer oddelene mezerami po sestnacti
#define DBGF_BIN_32_S \
	( FRM_TP_BIN | FRM_LEN_32 | FRM_SP_L | FRM_SP_H )	//!< Binarni 32 cifer oddelene mezerami po sestnacti

#define DBGF_BOOL \
	( FRM_TP_BOOL )					//!< Boolean TRUE/FALSE

#define DBGF_ASCII \
	( FRM_TP_ASCII )				//!< ASCII znak jeden
//@}
#endif // UCTP_DBG

#ifdef UCTP_DBGW
//!	\name	Rezervovane identifikatory ladicich zprav
//@{
#define DBGWID_GROUPCNT		0x01	//!< Pocet ladicich skupin
#define DBGWID_GROUP		0x02	//!< Jmeno skupiny a pocet polozek skupiny
#define DBGWID_ITEM			0x03	//!< Jmeno, typ hodnoty a hodnota polozky
//@}

#endif // UCTP_DBGW

#ifdef UCTP_SWINFO
typedef struct
{
	uint16_t	MagicNumber;		//!< Magicke cislo
	uint8_t		ProtocolVersion;	//!< Verze protokolu
	uint16_t	ProjectIdent;		//!< Identifikace projektu
	ctkdate16_t	RevisionDate;		//!< Datum zmeny
	uint8_t		HWVersion;			//!< Verze hardvare, lze-li definovat, jinak 0
	uint8_t		HWRevision;			//!< Revize hardware, lze-li definovat, jinak 0
	uint8_t		SWVersion;			//!< Verze software
	uint8_t		SWRevision;			//!< Revize software
	uint8_t		DataVersion;		//!< Verze datove struktury
	uint8_t		NvDataVersion;		//!< Verze nevolatilnich datove struktury

} SWINFODESC;
#endif // UCTP_SWINFO

#ifdef MSVC
//#pragma pack(show)
#pragma pack(push,1)
//#pragma pack(show)
#endif // MSVC

//! Struktura periodickeho parametru v seznamu parametru na strane slave

#ifdef UCTP_PERIODICPARAM
typedef struct _PERIODICPARAM_ENTRY
{
    uint8_t  Valid;             //!< Priznak ze je dany zaznam platny
    uint32_t Code;              //!< Kod parametru
    uint32_t MsPeriod;          //!< Perioda s jakou je parametr vycitan, v ms
    lticks_t ExpiresAt;         //!< Hodnota tick, kdy dojde k uplynuti periody
} PERIODICPARAM_ENTRY;

#endif

//! Zahlavi paketu CTP protokolu

typedef struct
{
	uint8_t		Flags;				//!< Priznaky CTPS_xxx a cislo procesu
	uint8_t		Seq;				//!< Sekvencni cislo zpravy
	uint8_t		MsgId;				//!< Identifikator zpravy
#ifndef MSVC
} __attribute__((packed)) CTPHDR;
#else
} CTPHDR;
#endif // MSVC

#ifdef UCTP_ERROR
//---------------------------------------------------------------------------
//! Struktura chybove odpovedi

typedef struct
{
	uint16_t	ErrCode;	//!< Chybovy kod

#ifndef MSVC
} __attribute__((packed)) MSG_ERROR_RSP;
#else
} MSG_ERROR_RSP;
#endif // MSVC
#endif // UCTP_ERROR


#ifdef UCTP_SWINFO
//! Struktura pozadavku MSGID_GET_SWINFO

typedef struct
{
#ifndef MSVC
} __attribute__((packed)) MSG_GET_SWINFO_REQ;
#else
} MSG_GET_SWINFO_REQ;
#endif // MSVC

//! Struktura odpovedi na pozadavek MSGID_GET_SWINFO

typedef struct
{
	uint16_t	MagicNumber;		//!< Magicke cislo
	uint8_t		ProtocolVersion;	//!< Verze protokolu
	uint16_t	ProjectIdent;		//!< Identifikace projektu
	ctkdate16_t	RevisionDate;		//!< Datum zmeny
	uint8_t		HWVersion;			//!< Verze hardvare, lze-li definovat, jinak 0
	uint8_t		HWRevision;			//!< Revize hardware, lze-li definovat, jinak 0
	uint8_t		SWVersion;			//!< Verze software
	uint8_t		SWRevision;			//!< Revize software
	uint8_t		DataVersion;		//!< Verze datove struktury
	uint8_t		NvDataVersion;		//!< Verze nevolatilnich datove struktury

#ifndef MSVC
} __attribute__((packed)) MSG_GET_SWINFO_RSP;
#else
} MSG_GET_SWINFO_RSP;
#endif // MSVC

#endif // UCTP_SWINFO

#ifdef UCTP_PARAM
//! Struktura pozadavku MSGID_GET_PARAM

typedef struct
{
	uint32_t	Code;		//!< Kod parametru

#ifndef MSVC
} __attribute__((packed)) MSG_GET_PARAM_REQ;
#else
} MSG_GET_PARAM_REQ;
#endif // MSVC

//! Struktura odpovedi na pozadavek MSGID_GET_PARAM

typedef struct
{
	uint32_t	Code;		//!< Kod parametru
	uint8_t		Data[ UCTP_MAX_PARAM_SIZE ];	//!< Data parametru

#ifndef MSVC
} __attribute__((packed)) MSG_GET_PARAM_RSP;
#else
} MSG_GET_PARAM_RSP;
#endif // MSVC

//! Struktura pozadavku MSGID_SET_PARAM

typedef struct
{
	uint32_t	Code;		//!< Kod parametru
	uint8_t		Data[ UCTP_MAX_PARAM_SIZE ];	//!< Data parametru

#ifndef MSVC
} __attribute__((packed)) MSG_SET_PARAM_REQ;//
#else
} MSG_SET_PARAM_REQ;//
#endif // MSVC

//! Struktura odpovedi na pozadavek MSGID_SET_PARAM

typedef struct
{
	uint32_t	Code;		//!< Kod parametru

#ifndef MSVC
} __attribute__((packed)) MSG_SET_PARAM_RSP;
#else
} MSG_SET_PARAM_RSP;
#endif // MSVC

#ifdef UCTP_PERIODICPARAM

//! Struktura pozadavku MSGID_GET_PERIODICPARAM

typedef struct
{
	uint32_t	Code;		//!< Kod parametru
    uint32_t	MsPeriod;   //!< Perioda parametru v ms

	#ifndef MSVC
		} __attribute__((packed)) MSG_GET_PERIODICPARAM_REQ;
	#else
		} MSG_GET_PERIODICPARAM_REQ;
	#endif // MSVC

//! Struktura odpovedi na pozadavek MSGID_GET_PERIODICPARAM

typedef struct
{
	uint32_t	Code;		//!< Kod parametru
	uint8_t		Data[ UCTP_MAX_PARAM_SIZE ];	//!< Data parametru

	#ifndef MSVC
		} __attribute__((packed)) MSG_GET_PERIODICPARAM_RSP;
	#else
		} MSG_GET_PERIODICPARAM_RSP;
	#endif // MSVC

//! Struktura pozadavku MSGID_REMOVE_PERIODICPARAM

typedef struct
{
	uint32_t	Code;		//!< Kod parametru

	#ifndef MSVC
		} __attribute__((packed)) MSG_REMOVE_PERIODICPARAM_REQ;
	#else
		} MSG_REMOVE_PERIODICPARAM_REQ;
	#endif // MSVC

//! Struktura odpovedi na pozadavek MSGID_REMOVE_PERIODICPARAM

typedef struct
{
	uint32_t	Code;		//!< Kod parametru

	#ifndef MSVC
		} __attribute__((packed)) MSG_REMOVE_PERIODICPARAM_RSP;
	#else
		} MSG_REMOVE_PERIODICPARAM_RSP;
	#endif // MSVC

	#ifdef UCTP_BLOCK_PARAM

//! Struktura pozadavku MSGID_GET_BLKPERIODICPARAM

	typedef struct
	{
		uint8_t		Count;	//!< Pocet vycitanych parametru
        uint32_t	CodesMsPeriods[UCTP_BLOCK_PARAM_BUFSIZE / sizeof(uint32_t)];	//!< Kody pozadovanych parametru a jejich periody v ms

		#ifndef MSVC
			} __attribute__((packed)) MSG_GET_BLKPERIODICPARAM_REQ;
		#else
			} MSG_GET_BLKPERIODICPARAM_REQ;
		#endif // MSVC

//! Struktura odpovedi na pozadavek MSGID_GET_BLKPERIODICPARAM

	typedef struct
	{
		uint8_t		Count;	//!< Pocet vycitanych parametru
		uint8_t		Data[UCTP_BLOCK_PARAM_BUFSIZE];	//!< Data parametru - blok kodu + blok hodnot

		#ifndef MSVC
			} __attribute__((packed)) MSG_GET_BLKPERIODICPARAM_RSP;
		#else
			} MSG_GET_BLKPERIODICPARAM_RSP;
		#endif // MSVC

//! Struktura pozadavku MSGID_REMOVE_BLKPERIODICPARAM

	typedef struct
	{
		uint8_t		Count;	//!< Pocet vycitanych parametru
		uint32_t	Codes[UCTP_BLOCK_PARAM_BUFSIZE / sizeof(uint32_t)];	//!< Kody pozadovanych parametru

		#ifndef MSVC
			} __attribute__((packed)) MSG_REMOVE_BLKPERIODICPARAM_REQ;
		#else
			} MSG_REMOVE_BLKPERIODICPARAM_REQ;
		#endif // MSVC

//! Struktura odpovedi na pozadavek MSGID_REMOVE_BLKPERIODICPARAM

	typedef struct
	{
		uint8_t		Count;	//!< Pocet vycitanych parametru
		uint32_t	Codes[UCTP_BLOCK_PARAM_BUFSIZE / sizeof(uint32_t)];	//!< Kody pozadovanych parametru

		#ifndef MSVC
			} __attribute__((packed)) MSG_REMOVE_BLKPERIODICPARAM_RSP;
		#else
			} MSG_REMOVE_BLKPERIODICPARAM_RSP;
		#endif // MSVC
	
	#endif
#endif

 #ifdef UCTP_BLOCK_PARAM
//! Struktura pozadavku MSGID_GET_PARAM

typedef struct
{
	uint8_t		Count;	//!< Pocet vycitanych parametru
	uint32_t	Codes[UCTP_BLOCK_PARAM_BUFSIZE / sizeof(uint32_t)];	//!< Kody pozadovanych parametru

#ifndef MSVC
} __attribute__((packed)) MSG_GET_BLOCK_PARAM_REQ;
#else
} MSG_GET_BLOCK_PARAM_REQ;
#endif // MSVC

//! Struktura odpovedi na pozadavek MSGID_GET_PARAM

typedef struct
{
	uint8_t		Count;	//!< Pocet vycitanych parametru
	uint8_t		Data[UCTP_BLOCK_PARAM_BUFSIZE];	//!< Data parametru - blok kodu + blok hodnot

#ifndef MSVC
} __attribute__((packed)) MSG_GET_BLOCK_PARAM_RSP;
#else
} MSG_GET_BLOCK_PARAM_RSP;
#endif // MSVC

 #endif // UCTP_BLOCK_PARAM

#endif // UCTP_PARAM

#ifdef UCTP_DBGW
//! Struktura pozadavku MSGID_GET_DBGW

typedef struct
{
	uint8_t	Type;			//!< Typ zpavy
	uint8_t	GroupId;		//!< Cislo skupiny
	uint8_t	ItemId;			//!< Cislo polozky

#ifndef MSVC
} __attribute__((packed)) MSG_GET_DBGW_REQ;
#else
} MSG_GET_DBGW_REQ;
#endif // MSVC

//! Struktura odpovedi na pozadavek MSGID_GET_DBGW

typedef struct
{
	uint8_t	Type;			//!< Typ zpavy
	uint8_t	GroupId;		//!< Cislo skupiny
	uint8_t	ItemId;			//!< Cislo polozky
	uint8_t	Count;			//!< Pocet skupin/polozek
	uint8_t	ItemType;		//!< Typ polozky
	DBGWVAL	ItemVal;		//!< Hodnota polozky

#ifndef MSVC
} __attribute__((packed)) DBGWHDR;
#else
} DBGWHDR;
#endif // MSVC


typedef struct
{
	DBGWHDR	Header;			//!< Hlavicka zpravy
	char_t 	Name[ UCTP_MAX_TEXT_SIZE ];	//!< Jmeno skupiny/polozky

#ifndef MSVC
} __attribute__((packed)) MSG_GET_DBGW_RSP;
#else
} MSG_GET_DBGW_RSP;
#endif // MSVC

//! Struktura pozadavku MSGID_SET_DBGW

typedef struct
{
	uint8_t	GroupId;		//!< Cislo skupiny
	uint8_t	ItemId;			//!< Cislo polozky
	DBGWVAL	ItemVal;		//!< Hodnota polozky

#ifndef MSVC
} __attribute__((packed)) MSG_SET_DBGW_REQ;//
#else
} MSG_SET_DBGW_REQ;//
#endif // MSVC

//! Struktura odpovedi na pozadavek MSGID_DBGW_DBGW

typedef struct
{
	uint8_t	GroupId;		//!< Cislo skupiny
	uint8_t	ItemId;			//!< Cislo polozky

#ifndef MSVC
} __attribute__((packed)) MSG_SET_DBGW_RSP;
#else
} MSG_SET_DBGW_RSP;
#endif // MSVC

#endif // UCTP_DBGW


#ifdef UCTP_DBG
//! Zahlavi DBG paketu

typedef struct
{
	uint8_t		WType;					//!< Typ ladiciho okna
	uint8_t		WNum;					//!< Cislo ladiciho okna

#ifndef MSVC
} __attribute__((packed)) DBGHDR;
#else
} DBGHDR;
#endif // MSVC

#ifdef UCTP_DBG_TXT
//! Struktura pozadavku DBG_SCRWIN

typedef struct
{
	char_t 		WText[ UCTP_MAX_TEXT_SIZE ];	//!< Text k odvysilani

#ifndef MSVC
} __attribute__((packed)) DBG_SCRWIN_REQ;
#else
} DBG_SCRWIN_REQ;
#endif // MSVC

#endif // UCTP_DBG_TXT

//! Struktura pozadavku DBG_SCRWINU

typedef struct
{
	uint32_t 	WNum;					//!< Uint k odvysilani
	uint8_t		WWidth;					//!< Sirka
	uint8_t		WForm;					//!< Format vypisu

#ifndef MSVC
} __attribute__((packed)) DBG_SCRWINU_REQ;
#else
} DBG_SCRWINU_REQ;
#endif // MSVC

//! Struktura pozadavku DBG_SCRWINI

typedef struct
{
	int32_t		WNum;					//!< Int k odvysilani
	uint8_t		WWidth;					//!< Sirka

#ifndef MSVC
} __attribute__((packed)) DBG_SCRWINI_REQ;
#else
} DBG_SCRWINI_REQ;
#endif // MSVC

//! Struktura pozadavku DBG_SCRWINF

typedef struct
{
	float_t		WNum;					//!< Float k odvysilani
	uint8_t		WWidth;					//!< Sirka
	uint8_t		WPrec;					//!< Desetinych mist

#ifndef MSVC
} __attribute__((packed)) DBG_SCRWINF_REQ;
#else
} DBG_SCRWINF_REQ;
#endif // MSVC

#ifdef UCTP_DBG_TXT
//! Struktura pozadavku DBG_XYWIN

typedef struct
{
	uint8_t		WX;						//!< Horizontalni souradnice
	uint8_t 	WY;						//!< Vertikalni souradnice
	char_t 		WText[ UCTP_MAX_TEXT_SIZE ];	//!< Text k odvysilani

#ifndef MSVC
} __attribute__((packed)) DBG_XYWIN_REQ;
#else
} DBG_XYWIN_REQ;
#endif // MSVC

#endif // UCTP_DBG_TXT

//! Struktura pozadavku DBG_XYWINU

typedef struct
{
	uint8_t		WX;						//!< Horizontalni souradnice
	uint8_t 	WY;						//!< Vertikalni souradnice
	uint32_t	WNum;					//!< Uint k odvysilani
	uint8_t		WWidth;					//!< Sirka
	uint8_t		WForm;					//!< Format vypisu

#ifndef MSVC
} __attribute__((packed)) DBG_XYWINU_REQ;
#else
} DBG_XYWINU_REQ;
#endif // MSVC

//! Struktura pozadavku DBG_XYWINI

typedef struct
{
	uint8_t		WX;						//!< Horizontalni souradnice
	uint8_t 	WY;						//!< Vertikalni souradnice
	int32_t 	WNum;					//!< Int k odvysilani
	uint8_t		WWidth;					//!< Sirka

#ifndef MSVC
} __attribute__((packed)) DBG_XYWINI_REQ;
#else
} DBG_XYWINI_REQ;
#endif // MSVC

//! Struktura pozadavku DBG_XYWINF

typedef struct
{
	uint8_t		WX;						//!< Horizontalni souradnice
	uint8_t 	WY;						//!< Vertikalni souradnice
	float_t		WNum;					//!< Float k odvysilani
	uint8_t		WWidth;					//!< Sirka
	uint8_t		WPrec;					//!< Desetinych mist

#ifndef MSVC
} __attribute__((packed)) DBG_XYWINF_REQ;
#else
} DBG_XYWINF_REQ;
#endif // MSVC

#ifdef UCTP_DBG_VID
//! Struktura pozadavku DBG_VIDWIN, prvni zprava

typedef struct
{
	uint8_t 	MNum;					//!< Cislo zpravy = 0
	uint8_t 	WFlg;					//!< Typ displeje
	uint16_t 	WWidth;					//!< Sirka displeje
	uint16_t 	WHeight;				//!< Vyska displeje
	uint16_t 	MLen;					//!< Delka dat nasledujicich zprav

#ifndef MSVC
} __attribute__((packed)) DBG_VIDWINFIRST_REQ;
#else
} DBG_VIDWINFIRST_REQ;
#endif // MSVC

//! Struktura pozadavku DBG_VIDWIN, ostatni zpravy

typedef struct
{
	uint8_t 	MNum;					//!< Cislo zpravy = 1..255
	uint8_t		WData[ UCTP_MAX_BUF_SIZE ];	//!< Data displeje

#ifndef MSVC
} __attribute__((packed)) DBG_VIDWIN_REQ;
#else
} DBG_VIDWIN_REQ;
#endif // MSVC

#endif // UCTP_DBG_VID

#ifdef UCTP_DBG_KEYB
//! Struktura pozadavku DBG_KEYB

typedef struct
{
	char_t 		Text[ UCTP_MAX_TEXT_SIZE ];	//!< Text klavesnice

#ifndef MSVC
} __attribute__((packed)) DBG_KEYB_REQ;
#else
} DBG_KEYB_REQ;
#endif // MSVC

#endif // UCTP_DBG_KEYB

#ifdef UCTP_DBG_BUTTON
//! Struktura pozadavku DBG_BUTTON_REQ

typedef struct
{
	uint8_t		BNum;
	char_t 		ButtonText[ UCTP_MAX_TEXT_SIZE ];	//!< Texty tlacitka
	char_t *	_SendText;							//!< Fiktivni ukazatel na odesilany text, nasleduje za textem tlacitka

#ifndef MSVC
} __attribute__((packed)) DBG_BUTTON_REQ;
#else
} DBG_BUTTON_REQ;
#endif // MSVC

#endif // UCTP_DBG_BUTTON

//! Struktura pozadavku MSG_SET_DBGMSG

typedef struct
{
	DBGHDR		Header;					//!< Hlavicka DBG zpravy
	union
	{
#ifdef UCTP_DBG_TXT
		DBG_SCRWIN_REQ			ScrWin;		//!< Rolovaci okno string
#endif // UCTP_DBG_TXT
		DBG_SCRWINU_REQ			ScrWinU;	//!< Rolovaci okno uint
		DBG_SCRWINI_REQ			ScrWinI;	//!< Rolovaci okno int
		DBG_SCRWINF_REQ			ScrWinF;	//!< Rolovaci okno float
#ifdef UCTP_DBG_TXT
		DBG_XYWIN_REQ			XYWin;		//!< XY okno string
#endif // UCTP_DBG_TXT
		DBG_XYWINU_REQ			XYWinU;		//!< XY okno uint
		DBG_XYWINI_REQ			XYWinI;		//!< XY okno int
		DBG_XYWINF_REQ			XYWinF;		//!< XY okno float
#ifdef UCTP_DBG_VID
		DBG_VIDWINFIRST_REQ		VidWinFirst;	//!< Video okno, prvni zprava
		DBG_VIDWIN_REQ			VidWin;		//!< Video okno
#endif // UCTP_DBG_VID
#ifdef UCTP_DBG_KEYB
		DBG_KEYB_REQ			Keyb;		//!< Klavesnice
#endif // UCTP_DBG_KEYB
#ifdef UCTP_DBG_BUTTON
		DBG_BUTTON_REQ			Button;		//!< Tlacitko
#endif // UCTP_DBG_BUTTON
	} Msg;

#ifndef MSVC
} __attribute__((packed)) MSG_SET_DBGMSG_REQ;
#else
} MSG_SET_DBGMSG_REQ;
#endif // MSVC

#endif // UCTP_DBG

#ifdef UCTP_TSTMSG
// Struktura pozadavku MSG_GET_TSTMSG

typedef struct
{
	uint8_t		TstData;				//!< Testovaci data

#ifndef MSVC
} __attribute__((packed)) MSG_GET_TSTMSG_REQ;
#else
} MSG_GET_TSTMSG_REQ;
#endif // MSVC

// Struktura odpovedi na pozadavek MSG_GET_TST

typedef struct
{
	uint8_t		TstData;				//!< Testovaci data

#ifndef MSVC
} __attribute__((packed)) MSG_GET_TSTMSG_RSP;
#else
} MSG_GET_TSTMSG_RSP;
#endif // MSVC

#endif // UCTP_TSTMSG

#ifdef UCTP_BLOADER
//----------------------------------------------------
//! Zprava MSG_BLDR_READ
//
// data zpravy posilane do zarizeni pri
// cteni dat z jedne z pameti (MSGID_BLDR_READ_xxx)
//

typedef struct
{
	uint32_t	Address;		//!< Adresa
	uint32_t	Size;			//!< delka dat
	uint8_t		DescIndex;

#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_READ_MEM;
#else
} MSG_BLDR_READ_MEM;
#endif // MSVC


//----------------------------------------------------
// !Zprava MSG_BLDR_WRITE
//
// data zpravy posilane do zarizeni pri
// zapisu dat do jedne z pameti (MSGID_BLDR_WRITE_xxx)

typedef struct
{
	uint32_t	Address;			//!< adresa
	uint8_t		DescIndex;
	uint8_t		Data[BLOADER_BLKSIZE];		//!< data

#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_WRITE_MEM;
#else
} MSG_BLDR_WRITE_MEM;
#endif // MSVC


//----------------------------------------------------
//! Zprava MSG_BLDR_ERASE
//

typedef struct
{
	uint32_t	Address;		//!< Adresa
	uint32_t	Size;			//!< delka dat
	uint8_t		DescIndex;

#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_ERASE_MEM;
#else
} MSG_BLDR_ERASE_MEM;
#endif // MSVC


//----------------------------------------------------
// Zprava MSG_BLDR_GET_DESC
//

typedef struct
{
	uint8_t	DescIndex;			//!< Index descriptoru (0..)

#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_GET_DESC;
#else
} MSG_BLDR_GET_DESC;
#endif // MSVC


//----------------------------------------------------
// Zprava MSG_BLDR_DESC
//

typedef struct
{
	uint32_t	Address;			//!< Pocatecni adresa
	uint32_t	SectorSize;			//!< Delka sektoru
	uint16_t	SectorCount;		//!< Pocet sektoru
	uint16_t	Flags;				//!< Priznaky SECF_xxx
	uint8_t		MemType;			//!< Typ pameti MEM_TYPE_xxx
	uint8_t		_reserved1;
	uint16_t	_reserved2;

#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_DESC;
#else
} MSG_BLDR_DESC;
#endif // MSVC


//! Zprava MSG_BLDR_INFO
//
// data zpravy MSGID_BLDR_GET_INFO sposilane do zarizeni pro
// ziskani informaci o zarizeni

typedef struct
{
	uint32_t	Magic;			//
	uint16_t	Size;			//!< velikost struktury = sizeof( MSG_BLDR_INFO )
	uint8_t		BootVer;		//!< verze bootloaderu
	uint8_t		BootRev;		//!< revize bootloaderu
	uint8_t		HwId;			//!< identifikace hardware = hwidXXX
	uint8_t		Flags;			//
	uint16_t	BlkSize;		//!< Maximalni delka prenaseneho bloku dat (B)
	uint16_t	NumOfDesc;		//!< Pocet deskriptoru
	uint16_t	BootSize;		//!< Velikost oblasti boot loaderu (hlavne u AVR)
	uint32_t	AppInfoAddr;	//!< Adresa AppInfo
	uint32_t	_reserved3;		//!< =0
	uint32_t	_reserved4;		//!< =0

#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_INFO;
#else
} MSG_BLDR_INFO;
#endif // MSVC


//----------------------------------------------------
//! Zprava MSG_BLDR_COMMAND
//

typedef struct
{
	char_t 	 	Command[BLOADER_BLKSIZE];

#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_COMMAND;
#else
} MSG_BLDR_COMMAND;
#endif // MSVC

//----------------------------------------------------
//! Data boot zpravy
//

typedef struct
{
	uint8_t		Data[BLOADER_BLKSIZE];	//!< data
#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_DATA;
#else
} MSG_BLDR_DATA;
#endif // MSVC


//----------------------------------------------------
//! Informace posilane pri ukonceni transakce
//

typedef struct
{
	uint8_t			DescIndex;
	uint8_t			Operation;
	uint32_t		Status;
#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_EOMSG;
#else
} MSG_BLDR_EOMSG;
#endif // MSVC

//----------------------------------------------------
//! Zprava MSG_BLDR_READ_CFG
//

typedef struct
{
	uint32_t	Address;		//!< Adresa - offset od zacatku konfigurace
	uint32_t	Size;			//!< delka dat

#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_READ_CFG;
#else
} MSG_BLDR_READ_CFG;
#endif // MSVC


//----------------------------------------------------
// !Zprava MSG_BLDR_WRITE_CFG
//

typedef struct
{
	uint32_t	Address;			//!< adresa
	uint8_t		Data[BLOADER_BLKSIZE];		//!< data

#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_WRITE_CFG;
#else
} MSG_BLDR_WRITE_CFG;
#endif // MSVC

#endif // UCTP_BLOADER

#if defined(UCTP_BLOADER) || defined(UCTP_RUNBOOT)
//----------------------------------------------------
//! Data RunBoot zpravy
//

#define	RUNBOOT_MAGIC_NUMBER	0x1AC0F35E //!< Magicke cislo

typedef struct
{
	uint32_t		MagicNumber;
#ifndef MSVC
} __attribute__((packed)) MSG_BLDR_RUNBOOT;
#else
} MSG_BLDR_RUNBOOT;
#endif // MSVC

#endif // defined(UCTP_BLOADER) || defined(UCTP_RUNBOOT)


//----------------------------------------------------
//! Touch pad zpravy
//

#ifdef UCTP_TOUCH
//	TOUCH PAD

//! Buffer slouzici k odeslani identifikace masteru
typedef struct
{
	uint8_t HwIdent;				//!< Identifikace HW
	uint8_t SoftwareVersion;		//!< Verze softwaru
	uint8_t SoftwareBuild;			//!< Build softwaru

#ifndef MSVC
} __attribute__((packed)) MSG_TOUCH_RDIDENT;
#else
} MSG_TOUCH_RDIDENT;
#endif // MSVC


//! Buffer slouzici k odeslani souradnic stisku ci uvolneni masteru
typedef struct
{
	uint8_t XLower;					//!< Dolnich osm bitu x-souradnice
	uint8_t YLower;					//!< Dolnich osm bitu y-souradnice
	uint8_t Higher;					//!< Horni 4 + 4 bity obou souradnic, vyse jsou bity y-souradnice

#ifndef MSVC
} __attribute__((packed)) MSG_TOUCH_POSITION;
#else
} MSG_TOUCH_POSITION;
#endif // MSVC


//! Buffer slouzici k prijmu a odesilani konfiguracnich  parametru touche
typedef struct
{
	uint8_t Data;					//!< Hodnota parametru touchpadu

#ifndef MSVC
} __attribute__((packed)) MSG_TOUCH_PARAMETER;
#else
} MSG_TOUCH_PARAMETER;
#endif // MSVC

//! Prazdny buffer zpravy touch restart
typedef struct
{
} MSG_TOUCH_RESTART;


//! Buffer na tlacitkove zpravy
typedef struct
{

	uint8_t Button;

#ifndef MSVC
} __attribute__((packed)) MSG_TOUCH_BUTTON;
#else
} MSG_TOUCH_BUTTON;
#endif

#endif // UCTP_TOUCH

#ifdef UCTP_LOG

//! Buffer slouzici k prijmu pozadavku na cteni logu
typedef struct
{
	uint8_t		Command;	//!< Prikaz rozlisujici operaci
	uint8_t		LogIndex;	//!< Index dotazovaneho logu
	union
	{
		struct
		{
			uint32_t	ItemIndex;		//!< Index pozadovane polozky
		} ReadItem;
	} Msg;

#ifndef MSVC
} __attribute__((packed)) MSG_GET_LOG_REQ;
#else
} MSG_GET_LOG_REQ;
#endif // MSVC

//! Buffer slouzici k odpovedi na  pozadavek na cteni logu
typedef struct
{
	uint8_t	Command;		//!< Provadena operace

	union
	{
		struct
		{
			uint8_t		LogCount;		//!< Pocet polozek logu
		} LogCount;

		struct
		{
			uint32_t	ItemSize;		//!< Velikost polozky
		} ItemSize;

		struct
		{
			uint32_t	HeaderSize;		//!< velikost hlavicky
		} HeaderSize;

		struct
		{
			uint32_t	ItemCount;		//!< Pocet poozek v logu
		} ItemCount;

		struct
		{
			uint8_t		ItemData[UCTP_MAX_LOG_BUF_SIZE];		//!< Data polozek
		} ItemData;

		struct
		{
			uint8_t		HeaderData[UCTP_MAX_LOG_BUF_SIZE];		//!< Data hlavicky
		} HeaderData;
	} Msg;
#ifndef MSVC
} __attribute__((packed)) MSG_GET_LOG_RSP;
#else
} MSG_GET_LOG_RSP;
#endif // MSVC

//! Hlavicka zpravy vyuzitelna pro buffer na odesilani logu
typedef struct
{
	BUFDESC		Desc;
	CTPHDR		Header;
	uint8_t		Command;		//!< Provadena operace
#ifndef MSVC
} __attribute__((packed)) LOG_MSG_HEADER;
#else
} LOG_MSG_HEADER;
#endif // MSVC

#endif // UCTP_LOG

//----------------------------------------------------
// \brief Struktura definujici CTP zpravu
//
// \note  neodkazovat se na polozku _crc ve strukture SENDBUF
//        pouze vyhrazuje 1(2) bajty pro crc. Nikdy se na
//        tuto polozku neodkazujte, protoze obsahuje crc
//        pouze u nejdelsi zpravy.

typedef struct
{
	CTPHDR					Header;		//!< zahlavi CTP protokolu
	union
	{
		// obecny buffer

#if defined(MSVC) && !defined(__GNUG__) && !defined(__GNUC__)
 #pragma warning( push )
 #pragma warning( disable: 4200 )
#endif // MSVC

		char_t				_data[UCTP_MIN_BUF_SIZE];	//!< Obecny buffer
#if defined(MSVC) && !defined(__GNUG__) && !defined(__GNUC__)
 #pragma warning( pop )
#endif // MSVC

#ifdef UCTP_ERROR
		// chybova odpoved
		MSG_ERROR_RSP		ErrorRs;	//!< Zprava error, odpoved na jakoukoliv zadost
#endif // UCTP_ERROR

#ifdef UCTP_SWINFO
		// cteni SW verze
		MSG_GET_SWINFO_REQ	GetSwInfoRq;	//!< Zadost MSGID_GET_SWINFO
		MSG_GET_SWINFO_RSP	GetSwInfoRs;	//!< Odpoved MSGID_GET_SWINFO
#endif // UCTP_SWINFO

#ifdef UCTP_PARAM
		// cteni parametru
		MSG_GET_PARAM_REQ	GetParamRq;	//!< Zadost MSGID_GET_PARAM
		MSG_GET_PARAM_RSP	GetParamRs;	//!< Odpoved na MSGID_GET_PARAM

		// zapis parametru
		MSG_SET_PARAM_REQ	SetParamRq;	//!< Zadost MSGID_SET_PARAM
		MSG_SET_PARAM_RSP	SetParamRs;	//!< Odpoved na MSGID_SET_PARAM
#endif // UCTP_PARAM

#ifdef UCTP_PERIODICPARAM
        MSG_GET_PERIODICPARAM_REQ	GetPeriodicParamRq; //!< Zadost MSGID_GET_PERIODICPARAM
        MSG_GET_PERIODICPARAM_RSP	GetPeriodicParamRs; //!< Odpoved na MSGID_GET_PERIODICPARAM
		
        MSG_REMOVE_PERIODICPARAM_REQ	RemovePeriodicParamRq;	//!< Zadost MSGID_REMOVE_PERIODICPARAM
        MSG_REMOVE_PERIODICPARAM_RSP	RemovePeriodicParamRs;  //!< Odpoved na MSGID_REMOVE_PERIODICPARAM
	#ifdef UCTP_BLOCK_PARAM
        MSG_GET_BLKPERIODICPARAM_REQ	GetBlockPeriodicParamRq;	//!< Zadost MSGID_GET_BLKPERIODICPARAM
        MSG_GET_BLKPERIODICPARAM_RSP	GetBlockPeriodicParamRs;    //!< Odpoved na MSGID_GET_BLKPERIODICPARAM
		
        MSG_REMOVE_BLKPERIODICPARAM_REQ	RemoveBlockPeriodicParamRq;	//!< Zadost MSGID_REMOVE_BLKPERIODICPARAM
        MSG_REMOVE_BLKPERIODICPARAM_RSP	RemoveBlockPeriodicParamRs; //!< Odpoved na MSGID_REMOVE_BLKPERIODICPARAM
	#endif
#endif

#ifdef UCTP_BLOCK_PARAM
		// cteni bloku parametru
		MSG_GET_BLOCK_PARAM_REQ		GetBlockParamRq;
		MSG_GET_BLOCK_PARAM_RSP		GetBlockParamRs;
#endif // UCTP_BLOCK_PARAM

#ifdef UCTP_DBGW
		// cteni ladicich promennych
		MSG_GET_DBGW_REQ	GetDbgwRq;	//!< Zadost MSGID_GET_DBGW
		MSG_GET_DBGW_RSP	GetDbgwRs;	//!< Odpoved na MSGID_GET_DBGW

		// zapis ladicich promennych
		MSG_SET_DBGW_REQ	SetDbgwRq;	//!< Zadost MSGID_SET_DBGW
		MSG_SET_DBGW_RSP	SetDbgwRs;	//!< Odpoved na MSGID_SET_DBGW
#endif // UCTP_DBGW

#ifdef UCTP_DBG
		// ladici zpravy
		MSG_SET_DBGMSG_REQ	DbgMsgRq;	//!< Zapis ladicich informaci
#endif // UCTP_DBG

#ifdef UCTP_TSTMSG
		// testovaci zpravy
		MSG_GET_TSTMSG_REQ	TstMsgRq;	//!< Zadost MSG_GET_TSTMSG
		MSG_GET_TSTMSG_RSP	TstMsgRs;	//!< Odpoved na MSG_GET_TSTMSG
#endif // UCTP_TSTMSG

#ifdef UCTP_BLOADER
		// bootloader zpravy
		MSG_BLDR_READ_MEM	BLReadMem;
		MSG_BLDR_WRITE_MEM	BLWriteMem;
		MSG_BLDR_ERASE_MEM	BLEraseMem;
		MSG_BLDR_GET_DESC	BLGetDesc;
		MSG_BLDR_DESC		BLDesc;
		MSG_BLDR_COMMAND	BLCommand;
		MSG_BLDR_DATA		BLData;
		MSG_BLDR_INFO		BLInfo;
		MSG_BLDR_EOMSG		BLEOMsg;
		MSG_BLDR_READ_CFG	BLReadCfg;
		MSG_BLDR_WRITE_CFG	BLWriteCfg;
#endif	// UCTP_BLOADER

#if defined(UCTP_BLOADER) || defined(UCTP_RUNBOOT)
		MSG_BLDR_RUNBOOT	BLRunBoot;
#endif	// defined(UCTP_BLOADER) || defined(UCTP_RUNBOOT)

#ifdef UCTP_TOUCH
		//@{
		//! zpravy touchpadu
		MSG_TOUCH_RDIDENT	TouchRdIdent;
		MSG_TOUCH_POSITION	TouchPosition;
		MSG_TOUCH_PARAMETER	TouchParameter;
		MSG_TOUCH_BUTTON	TouchButton;
		//@}
#endif	// UCTP_TOUCH

#ifdef UCTP_LOG
		//@{
		//! zpravy logu
		MSG_GET_LOG_REQ		LogRq;
		MSG_GET_LOG_RSP		LogRsp;
		//@}
#endif // UCTP_LOG

	} Msg;

	crc16_t					_crc;		//!< vyhrazeno pro crc

#ifndef MSVC
} __attribute__((packed)) CTPMESS;
#else
} CTPMESS;
#endif // MSVC

#ifdef MSVC
#pragma pack(pop)
//#pragma pack(show)
#endif // MSVC

//----------------------------------------------------
//! Struktura definujici obecny prijimaci buffer

typedef struct
{
	BUFDESC		Desc;		//!< popisovac bufferu
	CTPMESS		Msg;		//!< CTP zpravy
} CTPBUFDESC;

//----------------------------------------------------
/**
	\brief	Forward deklarace kontextu
*/
//----------------------------------------------------

struct _CTPDESC;

//----------------------------------------------------
/**
	\brief	Metody objektu
*/
//----------------------------------------------------

typedef void (*cmCtpTick_t) ( struct _CTPDESC * const ctp );

// definice CallBacku
#ifdef UCTP_MST
// master

// metody
typedef bool_t (*cmMReadyToSend_t)( const struct _CTPDESC * const ctp );

// definice CallBacku
 #ifdef UCTP_ERROR
typedef void (*cmErrorRs_t) (const struct _CTPDESC * const _ctp, const uint16_t _errCode, const CTPBUFDESC * const _sndDesc, const CTPBUFDESC * const _rcvDesc);
 #endif // UCTP_ERROR

 #ifdef UCTP_SWINFO
typedef void (*cmGetSWInfoRs_t)( const struct _CTPDESC * const ctp, const SWINFODESC * const SWInfo );
 #endif // UCTP_SWINFO

 #ifdef UCTP_PARAM
typedef void (*cmGetParamRs_t)( const struct _CTPDESC * const ctp, const uint32_t Code, void * const Data);
typedef void (*cmSetParamRs_t)( const struct _CTPDESC * const ctp, const uint32_t Code );
 #endif // UCTP_PARAMS

 #ifdef UCTP_PERIODICPARAM
typedef void (*cmGetPeriodicParamRs_t)( const struct _CTPDESC * const ctp, const uint32_t Code, void * const Data);
typedef void (*cmRemovePeriodicParamRs_t)( const struct _CTPDESC * const ctp, const uint32_t Code );
#ifdef UCTP_BLOCK_PARAM
typedef void (*cmGetBlockPeriodicParamRs_t)(const struct _CTPDESC * const _ctp, const uint8_t _count, const uint32_t * const _codes, const void * const _data, const uint32_t _size);
typedef void (*cmRemoveBlockPeriodicParamRs_t)(const struct _CTPDESC * const _ctp, const uint8_t _count, const uint32_t * const _codes);
#endif // UCTP_BLOCK_PARAM
 #endif // UCTP_PERIODICPARAM

 #ifdef UCTP_BLOCK_PARAM
typedef void (*cmGetBlockParamRs_t)(const struct _CTPDESC * const _ctp, const uint8_t _count, const uint32_t * const _codes, const void * const _data, const uint32_t _size);
 #endif // UCTP_BLOCK_PARAM

 #ifdef UCTP_DBGW
typedef void (*cmGetDbgwGroupCountRs_t)( const struct _CTPDESC * const ctp, const uint8_t GroupCnt );
typedef void (*cmGetDbgwGroupRs_t)( const struct _CTPDESC * const ctp, const uint8_t GroupId, const char_t * const GroupName, const uint8_t ItemCnt );
typedef void (*cmGetDbgwItemRs_t)( const struct _CTPDESC * const ctp, const uint8_t GroupId, const uint8_t ItemId, const char_t * const ItemName, const uint8_t ItemType, const DBGWVAL ItemVal );
typedef void (*cmSetDbgwItemRs_t)( const struct _CTPDESC * const ctp, const uint8_t GroupId, const uint8_t ItemId );
 #endif // UCTP_DBGW

 #ifdef UCTP_TSTMSG
typedef void (*cmGetTstMsgRs_t)( const struct _CTPDESC * const ctp, const uint8_t TstData );
 #endif // UCTP_TSTMSG

 #ifdef UCTP_USERDEFINED
typedef void (*cmUserDefinedRs_t)( const struct _CTPDESC * const ctp, const CTPBUFDESC * const SndDesc, const CTPBUFDESC * const RcvDesc );
 #endif // UCTP_USERDEFINED

typedef void (*cmNoResponse_t)( const struct _CTPDESC * const ctp, const CTPBUFDESC * const SndDesc );

typedef void (*cmConnected_t)( const struct _CTPDESC * const ctp, const CTPBUFDESC * const SndDesc );
typedef void (*cmDisconnected_t)( const struct _CTPDESC * const ctp, const CTPBUFDESC * const SndDesc );

 #ifdef UCTP_BLOADER
typedef void (*cmBLReadMemRs_t)( const struct _CTPDESC * const ctp, const void * const Data, const uint32_t Size );
typedef void (*cmBLWriteMemRs_t)( const struct _CTPDESC * const ctp );
typedef void (*cmBLEraseMemRs_t)( const struct _CTPDESC * const ctp );
typedef void (*cmBLGetDescRs_t)( const struct _CTPDESC * const ctp,
									const uint32_t Address,
									const uint32_t SectorSize,
									const uint16_t SectorCount,
									const uint16_t Flags,
									const uint8_t MemType);
typedef void (*cmBLGetInfoRs_t) ( const struct _CTPDESC * const ctp,
									const uint32_t Magic,
									const uint16_t Size,
									const uint8_t BootVer,
									const uint8_t BootRev,
									const uint8_t HwId,
									const uint8_t Flags,
									const uint16_t BlkSize,
									const uint16_t NumOfDesc,
									const uint16_t BootSize,
									const uint32_t AppInfoAddr);
typedef void (*cmBLCommandRs_t)( const struct _CTPDESC * const ctp );
typedef void (*cmBLRunAppRs_t)( const struct _CTPDESC * const ctp );
typedef void (*cmBLRunBootRs_t)( const struct _CTPDESC * const ctp );
typedef void (*cmBLEOMsgRs_t)( const struct _CTPDESC * const ctp, const uint8_t DescIndex, const uint8_t Operation, const uint32_t Status );
typedef void (*cmBLReadCfgRs_t) (const struct _CTPDESC * const _ctp, const void * const _data, const uint32_t _size);
typedef void (*cmBLWriteCfgRs_t) (const struct _CTPDESC * const _ctp);
 #endif	// UCTP_BLOADER

 #ifdef UCTP_TOUCH
typedef void (*cmTouchRdIdentRs_t) ( const struct _CTPDESC * const ctp, const uint8_t HwIdent, const uint8_t SWVersion, const uint8_t SWBuild );
typedef void (*cmTouchRdPortRs_t) ( const struct _CTPDESC * const ctp, const uint8_t Port );
typedef void (*cmTouchWrPortRs_t) ( const struct _CTPDESC * const ctp );
typedef void (*cmTouchRdDeglitchRs_t) ( const struct _CTPDESC * const ctp, const uint8_t Deglitch );
typedef void (*cmTouchWrDeglitchRs_t) ( const struct _CTPDESC * const ctp );
typedef void (*cmTouchRdPressedDlyRs_t) ( const struct _CTPDESC * const ctp, const uint8_t PressedDly );
typedef void (*cmTouchWrPressedDlyRs_t) ( const struct _CTPDESC * const ctp );
typedef void (*cmTouchRdReleaseDlyRs_t) ( const struct _CTPDESC * const ctp, const uint8_t ReleaseDly );
typedef void (*cmTouchWrReleaseDlyRs_t) ( const struct _CTPDESC * const ctp );
typedef void (*cmTouchRdStabilizationRs_t) ( const struct _CTPDESC * const ctp, const uint8_t Stabilization );
typedef void (*cmTouchWrStabilizationRs_t) ( const struct _CTPDESC * const ctp );
typedef void (*cmTouchRdFilterWeightRs_t) ( const struct _CTPDESC * const ctp, const uint8_t FilterWeight );
typedef void (*cmTouchWrFilterWeightRs_t) ( const struct _CTPDESC * const ctp );
typedef void (*cmTouchRdChargeWSRs_t) ( const struct _CTPDESC * const ctp, const uint8_t ChargeWS );
typedef void (*cmTouchWrChargeWSRs_t) ( const struct _CTPDESC * const ctp );

typedef void (*cmTouchRdPhaseAdjustRs_t) ( const struct _CTPDESC * const ctp, const uint8_t PhaseAdjust );
typedef void (*cmTouchWrPhaseAdjustRs_t) ( const struct _CTPDESC * const ctp );

typedef void (*cmTouchRdOffsetXRs_t) ( const struct _CTPDESC * const ctp, const uint8_t OffsetX );
typedef void (*cmTouchWrOffsetXRs_t) ( const struct _CTPDESC * const ctp );

typedef void (*cmTouchRdOffsetYRs_t) ( const struct _CTPDESC * const ctp, const uint8_t OffsetY );
typedef void (*cmTouchWrOffsetYRs_t) ( const struct _CTPDESC * const ctp );

typedef void (*cmTouchRdSizeXRs_t) ( const struct _CTPDESC * const ctp, const uint8_t SizeX );
typedef void (*cmTouchWrSizeXRs_t) ( const struct _CTPDESC * const ctp );

typedef void (*cmTouchRdSizeYs_t) ( const struct _CTPDESC * const ctp, const uint8_t ChargeWS );
typedef void (*cmTouchWrSizeYRs_t) ( const struct _CTPDESC * const ctp );



typedef void (*cmTouchButtonPressRs_t) ( const struct _CTPDESC * const ctp );
typedef void (*cmTouchButtonReleaseRs_t) ( const struct _CTPDESC * const ctp );

typedef void (*cmTouchPressed_t) ( const struct _CTPDESC * const ctp, const uint16_t X, const uint16_t Y );
typedef void (*cmTouchReleased_t) ( const struct _CTPDESC * const ctp, const uint16_t X, const uint16_t Y );
typedef void (*cmTouchRestart_t) ( const struct _CTPDESC * const ctp );
 #endif	// UCTP_TOUCH

 #ifdef UCTP_LOG
typedef void (*cmLogGetLogCountRs_t)(const struct _CTPDESC * const ctp, const uint8_t LogCount);
typedef void (*cmLogGetItemSizeRs_t)(const struct _CTPDESC * const ctp, const uint32_t ItemSize);
typedef void (*cmLogGetItemCountRs_t)(const struct _CTPDESC * const ctp, const uint32_t ItemCount);
typedef void (*cmLogGetItemRs_t)(const struct _CTPDESC * const ctp, const void * const Data, const uint32_t Size);
typedef void (*cmLogGetHeaderSizeRs_t)(const struct _CTPDESC * const ctp, const uint32_t HeaderSize);
typedef void (*cmLogGetHeaderRs_t)(const struct _CTPDESC * const ctp, const void * const Data, uint32_t Size);
 #endif // UCTP_LOG

#endif // UCTP_MST

#ifdef UCTP_SLV
// slave
// definice CallBacku
 #ifdef UCTP_SWINFO
typedef void (*cmGetSWInfoRq_t)( struct _CTPDESC * const ctp );
 #endif // UCTP_SWINFO

 #ifdef UCTP_PARAM
typedef void (*cmGetParamRq_t)( struct _CTPDESC * const ctp, const uint32_t Code );
typedef void (*cmSetParamRq_t)( struct _CTPDESC * const ctp, const uint32_t Code, void * const Data );
 #endif // UCTP_PARAM
 
 #ifdef UCTP_PERIODICPARAM
 typedef void (*cmGetPeriodicParamRq_t)( struct _CTPDESC * const ctp, const uint32_t Code, const uint32_t MsPeriod );
 typedef void (*cmRemovePeriodicParamRq_t)( struct _CTPDESC * const ctp, const uint32_t Code );
 #ifdef UCTP_BLOCK_PARAM
	typedef void (*cmGetBlockPeriodicParamRq_t) (struct _CTPDESC * const _ctp, const uint8_t _count, const uint32_t * const _codes, const uint32_t * const _msperiods);
	typedef void (*cmRemoveBlockPeriodicParamRq_t) (struct _CTPDESC * const _ctp, const uint8_t _count, const uint32_t * const _codes);
 #endif
 
 #endif

 #ifdef UCTP_BLOCK_PARAM
typedef void (*cmGetBlockParamRq_t) (struct _CTPDESC * const _ctp, const uint8_t _count, const uint32_t * const _codes);
 #endif // UCTP_BLOCK_PARAM

 #ifdef UCTP_DBGW
typedef void (*cmGetDbgwGroupCountRq_t)( struct _CTPDESC * const ctp );
typedef void (*cmGetDbgwGroupRq_t)( struct _CTPDESC * const ctp, const uint8_t GroupId );
typedef void (*cmGetDbgwItemRq_t)( struct _CTPDESC * const ctp, const uint8_t GroupId, const uint8_t ItemId );
typedef void (*cmSetDbgwItemRq_t)( const struct _CTPDESC * const ctp, const uint8_t GroupId, const uint8_t ItemId, const DBGWVAL ItemVal );
 #endif // UCTP_DBGW

 #ifdef UCTP_DBG
  #ifdef UCTP_MST
   #ifdef UCTP_DBG_TXT
typedef void (*cmSetDbgScrWinRq_t)( const struct _CTPDESC * const ctp, const uint8_t WNum, const char_t * const WText );
   #endif // UCTP_DBG_TXT
typedef void (*cmSetDbgScrWinURq_t)( const struct _CTPDESC * const ctp, const uint8_t WNum, const uint32_t WNumber, const uint8_t WWidth, const uint8_t WForm );
typedef void (*cmSetDbgScrWinIRq_t)( const struct _CTPDESC * const ctp, const uint8_t WNum, const int32_t WNumber, const uint8_t WWidth );
typedef void (*cmSetDbgScrWinFRq_t)( const struct _CTPDESC * const ctp, const uint8_t WNum, const float_t WNumber, const uint8_t WWidth, const uint8_t WPrec );
   #ifdef UCTP_DBG_TXT
typedef void (*cmSetDbgXYWinRq_t)( const struct _CTPDESC * const ctp, const uint8_t WNum, const uint8_t WX, const uint8_t WY, const char_t * const WText );
   #endif // UCTP_DBG_TXT
typedef void (*cmSetDbgXYWinURq_t)( const struct _CTPDESC * const ctp, const uint8_t WNum, const uint8_t WX, const uint8_t WY, const uint32_t WNumber, const uint8_t WWidth, const uint8_t WForm );
typedef void (*cmSetDbgXYWinIRq_t)( const struct _CTPDESC * const ctp, const uint8_t WNum, const uint8_t WX, const uint8_t WY, const int32_t WNumber, const uint8_t WWidth );
typedef void (*cmSetDbgXYWinFRq_t)( const struct _CTPDESC * const ctp, const uint8_t WNum, const uint8_t WX, const uint8_t WY, const float_t WNumber, const uint8_t WWidth, const uint8_t WPrec );
   #ifdef UCTP_DBG_VID
typedef void (*cmSetDbgVidWinFirstRq_t)( const struct _CTPDESC * const ctp, const uint8_t WNum, const uint8_t WFlg, const uint16_t WWidth, const uint16_t WHeight, const uint16_t MLen );
typedef void (*cmSetDbgVidWinRq_t)( const struct _CTPDESC * const ctp, const uint8_t WNum, const uint8_t MNum, const uint8_t * const WData );
   #endif // UCTP_DBG_VID
   #ifdef UCTP_DBG_BUTTON
typedef void (*cmSetDbgButton_t)( const struct _CTPDESC * const ctp, const uint8_t BNum, const char_t * const ButtonText, const uint8_t KNum, const char_t * const SendText);
   #endif // UCTP_DBG_BUTTON
  #endif // UCTP_MST
typedef void (*cmSetDbgKeybRq_t)( const struct _CTPDESC * const ctp,  const uint8_t WNum, const char_t * const WText );
 #endif // UCTP_DBG

 #ifdef UCTP_TSTMSG
typedef void (*cmGetTstMsgRq_t)( struct _CTPDESC * const ctp, const uint8_t TstData );
 #endif // UCTP_TSTMSG
 #ifdef UCTP_USERDEFINED
typedef void (*cmUserDefinedRq_t)( struct _CTPDESC * const ctp,  const CTPBUFDESC * const SndDesc, const CTPBUFDESC * const RcvDesc );
 #endif // UCTP_USERDEFINED

 #ifdef UCTP_TOUCH
typedef void (*cmTouchRdIdentRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchRdPortRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrPortRq_t) ( struct _CTPDESC * const ctp, const uint8_t Port );
typedef void (*cmTouchRdDeglitchRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrDeglitchRq_t) ( struct _CTPDESC * const ctp, const uint8_t Deglitch );
typedef void (*cmTouchRdPressedDlyRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrPressedDlyRq_t) ( struct _CTPDESC * const ctp, const uint8_t ReleaseDly );
typedef void (*cmTouchRdReleaseDlyRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrReleaseDlyRq_t) ( struct _CTPDESC * const ctp, const uint8_t ReleaseDly );
typedef void (*cmTouchRdStabilizationRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrStabilizationRq_t) ( struct _CTPDESC * const ctp, const uint8_t Stabilization );
typedef void (*cmTouchRdFilterWeightRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrFilterWeightRq_t) ( struct _CTPDESC * const ctp, const uint8_t FilterWeight );
typedef void (*cmTouchRdChargeWSRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrChargeWSRq_t) ( struct _CTPDESC * const ctp, const uint8_t ChargeWS );
typedef void (*cmTouchResetRq_t) ( const struct _CTPDESC * const ctp );

typedef void (*cmTouchRdPhaseAdjustRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrPhaseAdjustRq_t) ( struct _CTPDESC * const ctp, const uint8_t PhaseAdjust );

typedef void (*cmTouchRdOffsetXRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrOffsetXRq_t) ( struct _CTPDESC * const ctp, const uint8_t OffsetX );

typedef void (*cmTouchRdOffsetYRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrOffsetYRq_t) ( struct _CTPDESC * const ctp, const uint8_t OffsetY );

typedef void (*cmTouchRdSizeXRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrSizeXRq_t) ( struct _CTPDESC * const ctp, const uint8_t SizeX );

typedef void (*cmTouchRdSizeYRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmTouchWrSizeYRq_t) ( struct _CTPDESC * const ctp, const uint8_t SizeY );

typedef void (*cmTouchButtonPressRq_t) ( struct _CTPDESC * const ctp, const uint8_t Button );
typedef void (*cmTouchButtonReleaseRq_t) ( struct _CTPDESC * const ctp, const uint8_t Button );
 #endif	// UCTP_TOUCH

 #ifdef UCTP_BLOADER
typedef void (*cmBLReadMemRq_t)( struct _CTPDESC * const ctp, const uint32_t Address, const uint32_t Size, const uint8_t DescIndex );
typedef void (*cmBLWriteMemRq_t)( struct _CTPDESC * const ctp, const uint32_t Address, const uint32_t Size, void * const Data, const uint8_t DescIndex );
typedef void (*cmBLEraseMemRq_t)( struct _CTPDESC * const ctp, const uint32_t Address, const uint32_t Size, const uint8_t DescIndex );
typedef void (*cmBLGetDescRq_t)( struct _CTPDESC * const ctp, const uint16_t idx );
typedef void (*cmBLGetInfoRq_t) ( struct _CTPDESC * const ctp );
typedef void (*cmBLCommandRq_t)( struct _CTPDESC * const ctp, const void * const data);
typedef void (*cmBLRunAppRq_t)( struct _CTPDESC * const ctp );
typedef void (*cmBLEOMsgRq_t) ( struct _CTPDESC * const ctp, const uint8_t DescIndex, const uint8_t Operation, const uint32_t Status );
typedef void (*cmBLReadCfgRq_t) (struct _CTPDESC * const _ctp, const uint32_t _address, const uint32_t _size);
typedef void (*cmBLWriteCfgRq_t) (struct _CTPDESC * const _ctp, const uint32_t _address, const uint32_t _size, void * const _data);
 #endif // UCTP_BLOADER

 #ifdef UCTP_LOG
typedef void (*cmLogGetLogCountRq_t)(struct _CTPDESC * const ctp);
typedef void (*cmLogGetItemSizeRq_t)(struct _CTPDESC * const ctp, const uint8_t LogIndex);
typedef void (*cmLogGetItemCountRq_t)(struct _CTPDESC * const ctp, const uint8_t LogIndex);
typedef void (*cmLogGetItemRq_t)(struct _CTPDESC * const ctp, const uint8_t LogIndex, const uint32_t IntemIndex);
typedef void (*cmLogGetHeaderSizeRq_t)(struct _CTPDESC * const ctp, const uint8_t LogIndex);
typedef void (*cmLogGetHeaderRq_t)(struct _CTPDESC * const ctp, const uint8_t LogIndex);
 #endif
#endif // UCTP_SLV

#if defined(UCTP_RUNBOOT) || defined(UCTP_SLV_BLOADER)
typedef void (*cmBLRunBootRq_t)( struct _CTPDESC * const ctp, const uint32_t MagicNumber );
#endif // UCTP_RUNBOOT || UCTP_SLV_BLOADER

#ifdef UCTP_ERROR
// chybna zprava
typedef void (*cmErrorMsg_t)( const struct _CTPDESC * const ctp, const CTPBUFDESC * const SndDesc, const CTPBUFDESC * const RcvDesc );
#endif // UCTP_ERROR

 #ifdef UCTP_ANY
typedef void (*cmAnyMsg_t)( const struct _CTPDESC * const ctp, const CTPBUFDESC * const RcvDesc );
 #endif // UCTP_ANY


//----------------------------------------------------
//! Struktura popisujici stav CTP automatu slave
//

typedef struct _CTPDESC
{
	volatile bool_t			flRunning;			//!< Je spusteno

	COMMDESC *				Cmm;				//!< Ovladac seriove linky

	volatile bool_t			flTick;				//!< Tick je vykonavan
	volatile bool_t			flTickCmm;			//!< Tick cmm je vykonavan

	volatile bool_t			connected;

#ifdef UCTP_MST
	// master

	cmConnected_t			cbConnected;
	cmDisconnected_t		cbDisconnected;

	volatile uint8_t		mState;				//!< Stav automatu
	volatile bool_t			mflState;			//!< Automat je vykonavan
	volatile uint8_t		mSeqNumber;			//!< Posledni prirazene sekvencni cislo zpravy
	CTPBUFDESC				mSendBuf;			//!< Buffer odesilaneho paketu
	pktsize_t				mSendSize;			//!< Velikost zpravy pro opakovani
	bool_t					mReqPending;		//!< Priznak probihajiciho pozadavku
	uint8_t					mRetryCount;		//!< Pocet opakaovani
	uint8_t					mRetryCountCnt;		//!< Pocitadlo opakovani vysilani
	ticks_t					mRetryTimer;		//!< Casovac pro opakovani zpravy
	ticks_t					mRetryTimeout;		//!< Timeout pro opakovani zpravy
	void *					pVoid;				//!< Ukazatel

	cmMReadyToSend_t		MReadyToSend;		//!< ready to master send

 #ifdef UCTP_ERROR
	cmErrorRs_t				cbErrorRs;			//!< callback pri chybove odpovedi
 #endif // UCTP_ERROR

#ifdef UCTP_SWINFO
	cmGetSWInfoRs_t			cbGetSWInfoRs;		//!< callback pri odpovedi na cteni verze software a protokolu
 #endif // UCTP_SWINFO

 #ifdef UCTP_PARAM
	cmGetParamRs_t			cbGetParamRs;		//!< callback pri odpovedi na cteni parametru
	cmSetParamRs_t			cbSetParamRs;		//!< callback pri odpovedi na zapis parametru
 #endif // UCTP_PARAM

 #ifdef UCTP_PERIODICPARAM
    cmGetPeriodicParamRs_t  cbGetPeriodicParamRs;   //!< callback pri cteni periodickeho parametru
    cmRemovePeriodicParamRs_t   cbRemovePeriodicParamRs; //!< callback pri odpovedi na odstraneni periodickeho parametru
#ifdef UCTP_BLOCK_PARAM
    cmGetBlockPeriodicParamRs_t cbGetBlockPeriodicParamRs; //!< callback pri cteni periodickych parametru (bud uvodni pozadavek na tyto parametry, nebo soucasne vyprseni periody u vice parametru)
    cmRemoveBlockPeriodicParamRs_t  cbRemoveBlockPeriodicParamRs; //!< callback pri odpovedi na odstraneni vice periodickych parametru
#endif
 #endif

 #ifdef UCTP_BLOCK_PARAM
	cmGetBlockParamRs_t	cbGetBlockParamRs;	//!< callback pri odpovedi na cteni vice parametru
 #endif // UCTP_BLOCK_PARAM

 #ifdef UCTP_DBGW
	cmGetDbgwGroupCountRs_t	cbGetDbgwGroupCountRs;	//!< callback pri odpovedi na cteni ladicich promennych
	cmGetDbgwGroupRs_t		cbGetDbgwGroupRs;		//!< callback pri odpovedi na cteni ladicich promennych
	cmGetDbgwItemRs_t		cbGetDbgwItemRs;		//!< callback pri odpovedi na cteni ladicich promennych
	cmSetDbgwItemRs_t		cbSetDbgwItemRs;		//!< callback pri odpovedi na zapis ladicich promennych
 #endif // UCTP_DBGW

 #ifdef UCTP_TSTMSG
	cmGetTstMsgRs_t			cbGetTstMsgRs;		//!< callback pri odpovedi na testovaci zpravu
 #endif //UCTP_TSTMSG

 #ifdef UCTP_USERDEFINED
	cmUserDefinedRs_t		cbUserDefinedRs;	//!< callback pri odpovedi uzivatelem definovanou zpravu
 #endif //UCTP_USERDEFINED

	cmNoResponse_t			cbNoResponse;		//!< callback pri neprijeti odpovedi

 #ifdef UCTP_BLOADER
	cmBLReadMemRs_t			cbBLReadMemRs;
	cmBLWriteMemRs_t		cbBLWriteMemRs;
	cmBLEraseMemRs_t		cbBLEraseMemRs;
	cmBLGetDescRs_t			cbBLGetDescRs;
	cmBLGetInfoRs_t			cbBLGetInfoRs;
	cmBLCommandRs_t			cbBLCommandRs;
	cmBLRunAppRs_t			cbBLRunAppRs;
	cmBLRunBootRs_t			cbBLRunBootRs;
	cmBLEOMsgRs_t			cbBLEOMsgRs;
	cmBLReadCfgRs_t			cbBLReadCfgRs;
	cmBLWriteCfgRs_t		cbBLWriteCfgRs;
 #endif // UCTP_BLOADER

 #ifdef UCTP_TOUCH
	cmTouchRdIdentRs_t			cbTouchRdIdentRs;
	cmTouchRdPortRs_t			cbTouchRdPortRs;
	cmTouchWrPortRs_t			cbTouchWrPortRs;
	cmTouchRdDeglitchRs_t		cbTouchRdDeglitchRs;
	cmTouchWrDeglitchRs_t		cbTouchWrDeglitchRs;
	cmTouchRdPressedDlyRs_t		cbTouchRdPressedDlyRs;
	cmTouchWrPressedDlyRs_t		cbTouchWrPressedDlyRs;
	cmTouchRdReleaseDlyRs_t		cbTouchRdReleaseDlyRs;
	cmTouchWrReleaseDlyRs_t		cbTouchWrReleaseDlyRs;
	cmTouchRdStabilizationRs_t	cbTouchRdStabilizationRs;
	cmTouchWrStabilizationRs_t	cbTouchWrStabilizationRs;
	cmTouchRdFilterWeightRs_t	cbTouchRdFilterWeightRs;
	cmTouchWrFilterWeightRs_t	cbTouchWrFilterWeightRs;
	cmTouchRdChargeWSRs_t		cbTouchRdChargeWSRs;
	cmTouchWrChargeWSRs_t		cbTouchWrChargeWSRs;
	cmTouchButtonPressRs_t		cbTouchButtonPressRs;
	cmTouchButtonReleaseRs_t	cbTouchButtonReleaseRs;

	cmTouchRdPhaseAdjustRs_t	cbTouchRdPhaseAdjustRs;
	cmTouchWrPhaseAdjustRs_t	cbTouchWrPhaseAdjustRs;

	cmTouchRdOffsetXRs_t		cbTouchRdOffsetXRs;
	cmTouchWrOffsetXRs_t		cbTouchWrOffsetXRs;
	cmTouchRdOffsetYRs_t		cbTouchRdOffsetYRs;
	cmTouchWrOffsetYRs_t		cbTouchWrOffsetYRs;

	cmTouchRdSizeXRs_t		cbTouchRdSizeXRs;
	cmTouchWrSizeXRs_t		cbTouchWrSizeXRs;
	cmTouchRdSizeYRs_t		cbTouchRdSizeYRs;
	cmTouchWrSizeYRs_t		cbTouchWrSizeYRs;


	cmTouchPressed_t			cbTouchPressed;
	cmTouchReleased_t			cbTouchReleased;
	cmTouchRestart_t			cbTouchRestart;
 #endif	//UCTP_TOUCH

 #ifdef UCTP_LOG
	cmLogGetLogCountRs_t		cbLogGetLogCountRs;
	cmLogGetItemSizeRs_t		cbLogGetItemSizeRs;
	cmLogGetItemCountRs_t		cbLogGetItemCountRs;
	cmLogGetItemRs_t			cbLogGetItemRs;
	cmLogGetHeaderSizeRs_t		cbLogGetHeaderSizeRs;
	cmLogGetHeaderRs_t			cbLogGetHeaderRs;
 #endif // UCTP_LOG

#endif // UCTP_MST

#ifdef UCTP_SLV
	// slave
	uint8_t					sSeqNumber;			//!< Posledni prijate sekvencni cislo zpravy
	CTPBUFDESC				sSendBuf;			//!< Slave buffer odesilaneho paketu

 #ifdef UCTP_SWINFO
	cmGetSWInfoRq_t			cbGetSWInfoRq;		//!< callback zadosti o cteni verze software a protokolu
 #endif // UCTP_SWINFO

 #ifdef UCTP_PARAM
	cmGetParamRq_t			cbGetParamRq;		//!< callback zadosti o cteni parametru
	cmSetParamRq_t			cbSetParamRq;		//!< callback zadosti na zapis parametru
 #endif // UCTP_PARAM
 
 #ifdef UCTP_PERIODICPARAM
	cmGetPeriodicParamRq_t		cbGetPeriodicParamRq;
	cmRemovePeriodicParamRq_t	cbRemovePeriodicParamRq;
	#ifdef UCTP_BLOCK_PARAM
		cmGetBlockPeriodicParamRq_t	cbGetBlockPeriodicParamRq;
		cmRemoveBlockPeriodicParamRq_t	cbRemoveBlockPeriodicParamRq;
	#endif
 #endif

 #ifdef UCTP_BLOCK_PARAM
	cmGetBlockParamRq_t	cbGetBlockParamRq;	//!< callback zadosti na cteni vice parametru
 #endif // UCTP_BLOCK_PARAM

 #ifdef UCTP_DBGW
	cmGetDbgwGroupCountRq_t	cbGetDbgwGroupCountRq;	//!< callback zadosti o cteni ladicich promennych
	cmGetDbgwGroupRq_t		cbGetDbgwGroupRq;	//!< callback zadosti o cteni ladicich promennych
	cmGetDbgwItemRq_t		cbGetDbgwItemRq;	//!< callback zadosti o cteni ladicich promennych
	cmSetDbgwItemRq_t		cbSetDbgwItemRq;	//!< callback zadosti na zapis ladicich promennych
 #endif // UCTP_DBGW

 #ifdef UCTP_DBG
  #ifdef UCTP_MST
   #ifdef UCTP_DBG_TXT
	cmSetDbgScrWinRq_t		cbSetDbgScrWinRq;	//!< callback zadosti s ladici zpravou ScrWin
   #endif // UCTP_DBG_TXT
	cmSetDbgScrWinURq_t		cbSetDbgScrWinURq;	//!< callback zadosti s ladici zpravou ScrWinU
	cmSetDbgScrWinIRq_t		cbSetDbgScrWinIRq;	//!< callback zadosti s ladici zpravou ScrWinI
	cmSetDbgScrWinFRq_t		cbSetDbgScrWinFRq;	//!< callback zadosti s ladici zpravou ScrWinF
   #ifdef UCTP_DBG_TXT
	cmSetDbgXYWinRq_t		cbSetDbgXYWinRq;	//!< callback zadosti s ladici zpravou XYWin
   #endif // UCTP_DBG_TXT
	cmSetDbgXYWinURq_t		cbSetDbgXYWinURq;	//!< callback zadosti s ladici zpravou XYWinU
	cmSetDbgXYWinIRq_t		cbSetDbgXYWinIRq;	//!< callback zadosti s ladici zpravou XYWinI
	cmSetDbgXYWinFRq_t		cbSetDbgXYWinFRq;	//!< callback zadosti s ladici zpravou XYWinF
   #ifdef UCTP_DBG_VID
	cmSetDbgVidWinFirstRq_t	cbSetDbgVidWinFirstRq;	//!< callback zadosti s ladici zpravou VidWin
	cmSetDbgVidWinRq_t		cbSetDbgVidWinRq;	//!< callback zadosti s ladici zpravou VidWin
   #endif // UCTP_DBG_VID
   #ifdef UCTP_DBG_BUTTON
	cmSetDbgButton_t		cbSetDbgButtonRq;		//!< callback zadosti o definici tlacitka
   #endif // UCTP_DBG_BUTTON
  #endif // UCTP_MST
  #ifdef UCTP_DBG_KEYB
	cmSetDbgKeybRq_t		cbSetDbgKeybRq;		//!< callback zadosti s ladici zpravou Keyb
  #endif // UCTP_DBG_KEYB
 #endif // UCTP_DBG

 #ifdef UCTP_TSTMSG
	cmGetTstMsgRq_t			cbGetTstMsgRq;		//!< callback zadosti o testovaci zpravu
 #endif // UCTP_TSTMSG

 #ifdef UCTP_USERDEFINED
	cmUserDefinedRq_t		cbUserDefinedRq;	//!< callback zadosti o uzivatelem definovanou zpravu
 #endif // UCTP_USERDEFINED

 #ifdef UCTP_BLOADER

	cmBLWriteMemRq_t		cbBLWriteMemRq;
	cmBLGetDescRq_t			cbBLGetDescRq;
	cmBLGetInfoRq_t			cbBLGetInfoRq;

  #ifndef UCTP_MIN_BLOADER
	cmBLReadMemRq_t			cbBLReadMemRq;
	cmBLEraseMemRq_t		cbBLEraseMemRq;
	cmBLEOMsgRq_t			cbBLEOMsgRq;
	cmBLReadCfgRq_t			cbBLReadCfgRq;
	cmBLWriteCfgRq_t		cbBLWriteCfgRq;
	cmBLRunAppRq_t			cbBLRunAppRq;
	cmBLCommandRq_t			cbBLCommandRq;
  #endif // UCTP_MIN_BLOADER



 #endif // UCTP_BLOADER

 #ifdef UCTP_TOUCH
	uint8_t						seqNumber;

	cmTouchRdIdentRq_t			cbTouchRdIdentRq;
	cmTouchRdPortRq_t			cbTouchRdPortRq;
	cmTouchWrPortRq_t			cbTouchWrPortRq;
	cmTouchRdDeglitchRq_t		cbTouchRdDeglitchRq;
	cmTouchWrDeglitchRq_t		cbTouchWrDeglitchRq;
	cmTouchRdPressedDlyRq_t		cbTouchRdPressedDlyRq;
	cmTouchWrPressedDlyRq_t		cbTouchWrPressedDlyRq;
	cmTouchRdReleaseDlyRq_t		cbTouchRdReleaseDlyRq;
	cmTouchWrReleaseDlyRq_t		cbTouchWrReleaseDlyRq;
	cmTouchRdStabilizationRq_t	cbTouchRdStabilizationRq;
	cmTouchWrStabilizationRq_t	cbTouchWrStabilizationRq;
	cmTouchRdFilterWeightRq_t	cbTouchRdFilterWeightRq;
	cmTouchWrFilterWeightRq_t	cbTouchWrFilterWeightRq;
	cmTouchRdChargeWSRq_t		cbTouchRdChargeWSRq;
	cmTouchWrChargeWSRq_t		cbTouchWrChargeWSRq;
	cmTouchResetRq_t			cbTouchResetRq;

	cmTouchRdPhaseAdjustRq_t	cbTouchRdPhaseAdjustRq;
	cmTouchWrPhaseAdjustRq_t	cbTouchWrPhaseAdjustRq;

	cmTouchRdOffsetXRq_t		cbTouchRdOffsetXRq;
	cmTouchWrOffsetXRq_t		cbTouchWrOffsetXRq;
	cmTouchRdOffsetYRq_t		cbTouchRdOffsetYRq;
	cmTouchWrOffsetYRq_t		cbTouchWrOffsetYRq;

	cmTouchRdSizeXRq_t			cbTouchRdSizeXRq;
	cmTouchWrSizeXRq_t			cbTouchWrSizeXRq;
	cmTouchRdSizeYRq_t			cbTouchRdSizeYRq;
	cmTouchWrSizeYRq_t			cbTouchWrSizeYRq;


	cmTouchButtonPressRq_t		cbTouchButtonPressRq;
	cmTouchButtonReleaseRq_t	cbTouchButtonReleaseRq;
 #endif // UCTP_TOUCH

 #ifdef UCTP_LOG
	cmLogGetLogCountRq_t		cbLogGetLogCountRq;
	cmLogGetItemSizeRq_t		cbLogGetItemSizeRq;
	cmLogGetItemCountRq_t		cbLogGetItemCountRq;
	cmLogGetItemRq_t			cbLogGetItemRq;
	cmLogGetHeaderSizeRq_t		cbLogGetHeaderSizeRq;
	cmLogGetHeaderRq_t			cbLogGetHeaderRq;
 #endif // UCTP_LOG

#endif // UCTP_SLV

#if defined(UCTP_RUNBOOT) || defined(UCTP_SLV_BLOADER)
	cmBLRunBootRq_t			cbBLRunBootRq;
#endif // UCTP_RUNBOOT || UCTP_SLV_BLOADER

#ifdef UCTP_ERROR
 	cmErrorMsg_t			cbErrorMsg;			//!< callback pri chybne zprave
#endif // UCTP_ERROR

#ifdef UCTP_ANY
	cmAnyMsg_t				cbAnyMsg;
#endif // UCTP_ANY

	// metody
	cmCtpTick_t				Tick;				//!< tick knihovny

	//@{
	//! prijimaci buffery
	CTPBUFDESC 				recvbuf1;
	CTPBUFDESC 				recvbuf2;
	//@}

#ifdef UCTP_CP_CONV
	// kontext konverzi znakovych sad
	CODEPAGE_CTX			CpSysComm;
	CODEPAGE_CTX			CpCommSys;
#endif // UCTP_CODEPAGE

#if defined(UCTP_SLV) && defined(UCTP_PERIODICPARAM)
    PERIODICPARAM_ENTRY PeriodicParamArray[UCTP_MAX_PERIODICPARAMARRAY_SIZE];
#endif

}	CTPDESC;

#ifdef UCTP_MST
 #ifdef UCTP_SWINFO
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_GET_SWINFO
//

void CtpMSendGetSWInfoReq( CTPDESC * const ctp );
 #endif // UCTP_SWINFO

#endif // UCTP_MST

#ifdef UCTP_SLV
 #ifdef UCTP_SWINFO
//----------------------------------------------------
//! Funkce pro vyslani odpovedi MSGID_GET_SWINFO
//

void CtpSSendGetSWInfoRsp( CTPDESC * const ctp );

#endif // UCTP_SWINFO
#endif // UCTP_SLV

#ifdef UCTP_MST
 #ifdef UCTP_PARAM
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_GET_PARAM
//

void CtpMSendGetParamReq( CTPDESC * const ctp,
							const uint32_t Code );
 #endif // UCTP_PARAM

#ifdef UCTP_PERIODICPARAM
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_GET_PERIODICPARAM
//

void CtpMSendGetPeriodicParamReq( CTPDESC * const ctp,
                            const uint32_t Code, const uint32_t MsPeriod );

//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_REMOVE_PERIODICPARAM
//

void CtpMSendRemovePeriodicParamReq( CTPDESC * const ctp,
        const uint32_t Code );
#ifdef UCTP_BLOCK_PARAM
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_GET_BLKPERIODICPARAM
//

void CtpMSendGetBlockPeriodicParamArrayReq(CTPDESC * const _ctp, const uint8_t _count, const uint32_t * _codes, const uint32_t * _msperiods);

//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_REMOVE_BLKPERIODICPARAM
//

void CtpMSendRemoveBlockPeriodicParamArrayReq(CTPDESC * const _ctp, const uint8_t _count, const uint32_t * _codes);
#endif
#endif

#endif // UCTP_MST

#ifdef UCTP_SLV
 #ifdef UCTP_PARAM
//----------------------------------------------------
// !Funkce pro vyslani odpovedi MSGID_GET_PARAM
//

void CtpSSendGetParamRsp( CTPDESC * const ctp,
							const uint32_t Code,
							pktsize_t DataSize,
							const void * const Data);
 #endif // UCTP_PARAM
#endif // UCTP_SLV

#ifdef UCTP_MST
 #ifdef UCTP_BLOCK_PARAM
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_GET_PARAM
//

void CtpMSendGetBlockParamVaArgsReq(CTPDESC * const _ctp, ...);

// Pomocne makro, ve kterem neni treba resit zarazku na konci parametru
#define CtpMSendGetBlockParamReq(_ctp, ...) \
	CtpMSendGetBlockParamVaArgsReq((_ctp), __VA_ARGS__, 0xFFFFFFFF)

void CtpMSendGetBlockParamArrayReq(CTPDESC * const _ctp, const uint8_t _count, const uint32_t * _codes);

#endif // UCTP_BLOCK_PARAM
#endif // UCTP_MST

#ifdef UCTP_SLV
 #ifdef UCTP_BLOCK_PARAM
//----------------------------------------------------
// !Funkce pro vyslani odpovedi MSGID_GET_PARAM
//

void CtpSSendGetBlockParamArrayRsp(CTPDESC * const _ctp,
								   const uint8_t _count,
								   const uint32_t * const _codes,
								   const void * const _data,
								   const uint32_t _size);

 #endif // UCTP_BLOCK_PARAM
#endif // UCTP_SLV

#ifdef UCTP_MST
 #ifdef UCTP_PARAM
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_SET_PARAM
//

void CtpMSendSetParamReq( CTPDESC * const ctp,
							const uint32_t Code,
							pktsize_t	DataSize,
							const void * const Data );
 #endif // UCTP_PARAM
#endif // UCTP_MST

#ifdef UCTP_SLV
 #ifdef UCTP_PARAM
//----------------------------------------------------
//! Funkce pro vyslani odpovedi MSGID_SET_PARAM
//

void CtpSSendSetParamRsp( CTPDESC * const ctp,
							const uint32_t Code);
 #endif // UCTP_PARAM
#endif // UCTP_SLV

#ifdef UCTP_MST
 #ifdef UCTP_TSTMSG
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_GET_TSTMSG
//

void CtpMSendGetTstMsgReq( CTPDESC * const ctp,
							const uint8_t TstData );
 #endif // UCTP_TSTMSG
#endif // UCTP_MST

#ifdef UCTP_SLV
 #ifdef UCTP_TSTMSG
//----------------------------------------------------
//! Funkce pro vyslani odpovedi MSGID_GET_TSTMSG
//

void CtpSSendGetTstMsgRsp( CTPDESC * const ctp,
							const uint8_t TstData);
 #endif // UCTP_TSTMSG
#endif // UCTP_SLV

#ifdef UCTP_ERROR
void CtpSSendErrorRsp( CTPDESC * const ctp, const uint8_t msgId, const uint16_t ErrCode);
#endif // UCTP_ERROR

#ifdef UCTP_MST_TOUCH

void CtpMSendTouchRdIdentRq( CTPDESC * const ctp );
void CtpMSendTouchRdPortRq( CTPDESC * const ctp );
void CtpMSendTouchWrPortRq( CTPDESC * const ctp, const uint8_t Port );
void CtpMSendTouchRdDeglitchRq( CTPDESC * const ctp );
void CtpMSendTouchWrDeglitchRq( CTPDESC * const ctp, const uint8_t Deglitch );
void CtpMSendTouchRdPressedDlyRq( CTPDESC * const ctp );
void CtpMSendTouchWrPressedDlyRq( CTPDESC * const ctp, const uint8_t PressedDly );
void CtpMSendTouchRdReleaseDlyRq( CTPDESC * const ctp );
void CtpMSendTouchWrReleaseDlyRq( CTPDESC * const ctp, const uint8_t ReleaseDly );
void CtpMSendTouchRdStabilizationRq( CTPDESC * const ctp );
void CtpMSendTouchWrStabilizationRq( CTPDESC * const ctp, const uint8_t Stabilization );
void CtpMSendTouchRdFilterWeightRq( CTPDESC * const ctp );
void CtpMSendTouchWrFilterWeightRq( CTPDESC * const ctp, const uint8_t FilterWeight );
void CtpMSendTouchRdChargeWSRq( CTPDESC * const ctp );
void CtpMSendTouchWrChargeWSRq( CTPDESC * const ctp, const uint8_t ChargeWS );

void CtpMSendTouchRdPhaseAdjustRq( CTPDESC * const ctp );
void CtpMSendTouchWrPhaseAdjustRq( CTPDESC * const ctp, const uint8_t PhaseAdjust );

void CtpMSendTouchRdOffsetXRq( CTPDESC * const ctp );
void CtpMSendTouchWrOffsetXRq( CTPDESC * const ctp, const uint8_t OffsetX );
void CtpMSendTouchRdOffsetYRq( CTPDESC * const ctp );
void CtpMSendTouchWrOffsetYRq( CTPDESC * const ctp, const uint8_t OffsetY );

void CtpMSendTouchRdSizeXRq( CTPDESC * const ctp );
void CtpMSendTouchWrSizeXRq( CTPDESC * const ctp, const uint8_t SizeX );
void CtpMSendTouchRdSizeYRq( CTPDESC * const ctp );
void CtpMSendTouchWrSizeYRq( CTPDESC * const ctp, const uint8_t SizeY );


void CtpMSendTouchButtonPressRq( CTPDESC * const ctp, const uint8_t Button );
void CtpMSendTouchButtonReleaseRq( CTPDESC * const ctp, const uint8_t Button );

#endif	// UCTP_MST_TOUCH


#ifdef UCTP_SLV_TOUCH

void CtpSSendTouchRdIdentRs ( CTPDESC * const ctp, const uint8_t HWIdent, const uint8_t SWVersion, const uint8_t SWBuild );
void CtpSSendTouchRdPortRs( CTPDESC * const ctp, const uint8_t Port );
void CtpSSendTouchWrPortRs( CTPDESC * const ctp );
void CtpSSendTouchRdDeglitchRs( CTPDESC * const ctp, const uint8_t Deglitch );
void CtpSSendTouchWrDeglitchRs( CTPDESC * const ctp );
void CtpSSendTouchRdPressedDlyRs( CTPDESC * const ctp, const uint8_t PressedDly );
void CtpSSendTouchWrPressedDlyRs( CTPDESC * const ctp );
void CtpSSendTouchRdReleaseDlyRs( CTPDESC * const ctp, const uint8_t ReleaseDly );
void CtpSSendTouchWrReleaseDlyRs( CTPDESC * const ctp );
void CtpSSendTouchRdStabilizationRs( CTPDESC * const ctp, const uint8_t Stabilization );
void CtpSSendTouchWrStabilizationRs( CTPDESC * const ctp );
void CtpSSendTouchRdFilterWeightRs( CTPDESC * const ctp, const uint8_t FilterWeight );
void CtpSSendTouchWrFilterWeightRs( CTPDESC * const ctp );
void CtpSSendTouchRdChargeWSRs( CTPDESC * const ctp, const uint8_t ChargeWS );
void CtpSSendTouchWrChargeWSRs( CTPDESC * const ctp );

void CtpSSendTouchRdPhaseAdjustRs( CTPDESC * const ctp, const uint8_t PhaseAdjust );
void CtpSSendTouchWrPhaseAdjustRs( CTPDESC * const ctp );

void CtpSSendTouchRdOffsetXRs( CTPDESC * const ctp, const uint8_t OffsetX );
void CtpSSendTouchWrOffsetXRs( CTPDESC * const ctp );
void CtpSSendTouchRdOffsetYRs( CTPDESC * const ctp, const uint8_t OffsetY );
void CtpSSendTouchWrOffsetYRs( CTPDESC * const ctp );

void CtpSSendTouchRdSizeXRs( CTPDESC * const ctp, const uint8_t SizeX );
void CtpSSendTouchWrSizeXRs( CTPDESC * const ctp );
void CtpSSendTouchRdSizeYRs( CTPDESC * const ctp, const uint8_t SizeY );
void CtpSSendTouchWrSizeYRs( CTPDESC * const ctp );

void CtpSSendTouchButtonPressRs( CTPDESC * const ctp );
void CtpSSendTouchButtonReleaseRs( CTPDESC * const ctp );

void CtpSSendTouchRestart( CTPDESC * const ctp );
void CtpSSendTouchPressed( CTPDESC * const ctp, CTPBUFDESC * const buf, const uint16_t x, const uint16_t y);
void CtpSSendTouchReleased( CTPDESC * const ctp, CTPBUFDESC * const buf, const uint16_t x, const uint16_t y);
#endif // UCTP_SLV_TOUCH

#ifdef UCTP_MST
 #ifdef UCTP_DBGW
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_GET_DBGW
//

void CtpMSendGetDbgwGroupCountReq( CTPDESC * const ctp );

void CtpMSendGetDbgwGroupReq( CTPDESC * const ctp,
								const uint8_t GroupId );

void CtpMSendGetDbgwItemReq( CTPDESC * const ctp,
								const uint8_t GroupId,
								const uint8_t ItemId );

 #endif //UCTP_DBGW
#endif // UCTP_MST

#ifdef UCTP_SLV_DBG
 #ifdef UCTP_DBG_TXT
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_SET_DBGMSG, DBGID_SCRWIN
//

void CtpSSendSetDbgMsgScrWinReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t WNum,
								const char_t * const WText );
#endif // UCTP_DBG_TXT
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_SET_DBGMSG, DBGID_SCRWINU
//

void CtpSSendSetDbgMsgScrWinUReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t WNum,
								const uint32_t WNumber,
								const uint8_t WWidth,
								const uint8_t WForm );

//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_SET_DBGMSG, DBGID_SCRWINI
//

void CtpSSendSetDbgMsgScrWinIReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t WNum,
								const int32_t WNumber,
								const uint8_t WWidth );

//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_SET_DBGMSG, DBGID_SCRWINF
//

void CtpSSendSetDbgMsgScrWinFReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t WNum,
								const float_t WNumber,
								const uint8_t WWidth,
								const uint8_t WPrec );
 #ifdef UCTP_DBG_TXT
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_SET_DBGMSG, DBGID_XYWIN
//

void CtpSSendSetDbgMsgXYWinReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t WNum,
								const uint8_t WX,
								const uint8_t WY,
								const char_t * const WText );
#endif // UCTP_DBG_TXT
//----------------------------------------------------
// Funkce pro vyslani pozadavku MSGID_SET_DBGMSG, DBGID_XYWINU
//

void CtpSSendSetDbgMsgXYWinUReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t WNum,
								const uint8_t WX,
								const uint8_t WY,
								const uint32_t WNumber,
								const uint8_t WWidth,
								const uint8_t WForm );

//----------------------------------------------------
// Funkce pro vyslani pozadavku MSGID_SET_DBGMSG, DBGID_XYWINI
//

void CtpSSendSetDbgMsgXYWinIReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t WNum,
								const uint8_t WX,
								const uint8_t WY,
								const int32_t WNumber,
								const uint8_t WWidth );

//----------------------------------------------------
// Funkce pro vyslani pozadavku MSGID_SET_DBGMSG, DBGID_XYWINF
//

void CtpSSendSetDbgMsgXYWinFReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t WNum,
								const uint8_t WX,
								const uint8_t WY,
								const float_t WNumber,
								const uint8_t WWidth,
								const uint8_t WPrec );
 #ifdef UCTP_DBG_VID
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_SET_DBGMSG, DBGID_VIDWIN, prvni zprava
//

void CtpSSendSetDbgMsgVidFirstWinReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t WNum,
								const uint8_t WFlg,			//!< Typ displeje
								const uint16_t WWidth,		//!< Sirka displeje
								const uint16_t WHeight,		//!< Vyska displeje
								const uint16_t MLen);			//!< Delka dat nasledujicich zprav

//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_SET_DBGMSG, DBGID_VIDWIN
//

void CtpSSendSetDbgMsgVidWinReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t WNum,
								const uint8_t MNum,
								const pktsize_t MLen,
								const int8_t * const WData);
#endif // UCTP_DBG_VID
 #ifdef UCTP_DBG_BUTTON
void CtpSSendSetDbgMsgButtonReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t BNum,
								const char_t * const ButtonText,
								const uint8_t KNum,
								const char_t * const SendText);
#endif // UCTP_DBG_BUTTON
#endif // UCTP_SLV_DBG

#ifdef UCTP_MST_DBG
//----------------------------------------------------
//! Funkce pro vyslani pozadavku MSGID_SET_DBGMSG, DBGID_KEYB
//

#ifdef UCTP_DBG_KEYB
void CtpMSendSetDbgMsgKeybReq( CTPDESC * const ctp,
								CTPBUFDESC * const SendBuf,
								const uint8_t KNum,
								const char_t * const KText);
#endif

#endif // UCTP_MST_DBG

#ifdef UCTP_MST_BLOADER

void CtpMSendBLReadMemRq( CTPDESC * const ctp, const uint32_t Address, const uint32_t Size, const uint8_t DescIndex );
void CtpMSendBLWriteMemRq( CTPDESC * const ctp, const uint32_t Address, const uint32_t Size, const void * const Data, const uint8_t DescIndex );
void CtpMSendBLEraseMemRq( CTPDESC * const ctp, const uint32_t Address, const uint32_t Size, const uint8_t DescIndex );
void CtpMSendBLGetDescRq( CTPDESC * const ctp, const uint8_t idx );
void CtpMSendBLGetInfoRq( CTPDESC * const ctp );
void CtpMSendBLCommandRq(CTPDESC * const _ctp, const char_t * const _text);
void CtpMSendBLRunAppRq( CTPDESC * const ctp );
void CtpMSendBLRunBootRq( CTPDESC * const ctp );
void CtpMSendBLEOMsgRq( CTPDESC * const ctp, const uint8_t DescIndex, const uint8_t Operation, const uint32_t Status );
void CtpMSendBLReadCfgRq(CTPDESC * const _ctp, const uint32_t _address, const uint32_t _size);
void CtpMSendBLWriteCfgRq(CTPDESC * const _ctp, const uint32_t _address, const void * const _data, const uint32_t _size);

#endif	// UCTP_MST_BLOADER

#if defined(UCTP_SLV_BLOADER) || defined(UCTP_RUNBOOT)

void CtpSSendBLAck( CTPDESC * const ctp, const uint8_t MsgId );

#endif // UCTP_SLV_BLOADER || UCTP_RUNBOOT

#ifdef UCTP_SLV_BLOADER

void CtpSSendBLReadMemRs( CTPDESC * const ctp,
							const MSG_BLDR_DATA * const data,
							const uint32_t size );


void CtpSSendBLGetInfoRs(CTPDESC * const ctp,
							const int32_t Magic,
							const uint8_t Flags,
							const uint8_t BootVer,
							const uint8_t BootRev,
							const uint8_t HwId,
							const uint16_t BlkSize,
							const uint16_t NumOfDesc,
							const uint16_t BootSize,
							const uint32_t AppInfoAddr
						);


void CtpSSendBLGetDescRs( CTPDESC * const ctp,
							const uint32_t Address,
							const uint32_t SectorSize,
							const uint16_t SectorCount,
							const uint16_t Flags,
							const uint8_t MemType
						);

void CtpSSendBLEOMsgRs( CTPDESC * const ctp, const uint8_t DescIndex, const uint8_t Operation, const uint32_t Status );

void CtpSSendBLReadCfgRs(CTPDESC * const _ctp, const void * const _data, const uint32_t _size);

static inline void CtpSSendBLWriteCfgRs(CTPDESC * const _ctp)
{
	CtpSSendBLAck(_ctp, MSGID_BLDR_WRITE_CFG);
}

#endif // UCTP_SLV_BLOADER

#ifdef UCTP_LOG

 #ifdef UCTP_MST
void CtpMSendLogGetLogCountRq(CTPDESC * const ctp);
void CtpMSendLogGetItemSizeRq(CTPDESC * const ctp, const uint8_t LogIndex);
void CtpMSendLogGetItemCountRq(CTPDESC * const ctp, const uint8_t LogIndex);
void CtpMSendLogGetItemRq(CTPDESC * const ctp, const uint8_t LogIndex, const uint32_t ItemIndex);
void CtpMSendLogGetHeaderSizeRq(CTPDESC * const ctp, const uint8_t LogIndex);
void CtpMSendLogGetHeaderRq(CTPDESC * const ctp, const uint8_t LogIndex);
 #endif // UCTP_MST

 #ifdef UCTP_SLV
void CtpSSendLogGetLogCountRs(CTPDESC * const ctp, const uint8_t LogCount);
void CtpSSendLogGetItemSizeRs(CTPDESC * const ctp, const uint32_t ItemSize);
void CtpSSendLogGetItemCountRs(CTPDESC * const ctp, const uint32_t ItemCount);
void CtpSSendLogGetItemRs(CTPDESC * const ctp, BUFDESC * const Data, const uint32_t Size);
void CtpSSendLogGetHeaderSizeRs(CTPDESC * const ctp, const uint32_t HeaderSize);
void CtpSSendLogGetHeaderRs(CTPDESC * const ctp, BUFDESC * const Data, const uint32_t Size);
 #endif // UCTP_SLV

#endif // UCTP_LOG
//----------------------------------------------------
//!
//!	\brief		Funkce prevede cislo chyby na retezec
//!
//!	\param		_id		ID chyby
//!
//!	\return		Retezcova reprezentace cyby
//!

const char_t *CtpGetErrText(const int _id);


#ifdef UCTP_MST

uint8_t CtpGetRetryCount(const CTPDESC * const ctp);
ticks_t CtpGetRetryTimeout(const CTPDESC * const ctp);
void CtpSetRetry(CTPDESC * const ctp, const uint8_t RetryCount, const ticks_t RetryTimeout);

#endif // UCTP_MST

//----------------------------------------------------
/**
	\brief	Funkce pro inicializaci komunikacniho automatu

	\param	ctp			Struktura kontextu automatu

	\return	TRUE		inicializace probehla v poradku
			FALSE		chyba
*/
//----------------------------------------------------

bool_t CtpInitialize( CTPDESC * const ctp, COMMDESC * const cmm
#ifdef UCTP_MST
		, const uint8_t RetryCount, const ticks_t RetryTimeout, void * pVoid
#endif
		);

//----------------------------------------------------
/**
	\brief	Funkce pro ukonceni komunikacniho automatu

*/
//----------------------------------------------------

void CtpFinalize( CTPDESC * const ctp );

#endif // _UCTP_H_
