//----------------------------------------------------
/**	
	\file		ctk/hw/can_sja1000.h
	\ingroup	can
	\ingroup	all

	\brief		Ovladac standalone CAN obvodu SJA1000 pripojeneho na XBUS
				<<< ALL >>>
	
	\author		ConTeK s.r.o., Pavel Bazika
	\version	01.01
	\date		6.11.2007
	\todo		Nahradit lattice.c skutecnou knihovnou pro XBUS 

	\note		Prozatim je treba kvuli XBUS pouzivat pomocnou knihovnu lattice.c
*/
//----------------------------------------------------


#ifndef CAN_SJA1000_H_
#define CAN_SJA1000_H_

#include <cancomm.h>


//----------------------------------------------------
//!	Konstanty pro rychlost CANu

typedef enum _CANSPD {
	CANSPD_10,
	CANSPD_20,
	CANSPD_50,	
	CANSPD_125,
	CANSPD_250,
	CANSPD_500,
	CANSPD_800,
	CANSPD_1000 
} CANSPD;


//----------------------------------------------------
//!	Kontext ovladace CAN

typedef struct _CANCTX {
	CANCOMMDESC Parent;		//!< Rodic

	ccmCANTick	Tick;		//!< Rodicovsky tick
	
	bool_t flRunning;		//!< Udava, zda je tento objekt inicializovany
		
	CANMODE Mode;			//!< Rezim ID
	
} CANCTX;


//----------------------------------------------------
/**
	\brief	Inicializace CAN

	\param	ctx				Kontext CAN, ktery bude prirazen teto instanci
	\param	Mode			Rezim ID
	\param	ID				Pocatecni ID vysilace
	\param	Baudrate		Rychlost prenocu na CAN
	
	\return	TRUE			pokud inicializace probehla v poradku
*/
//---------------------------------------------------
bool_t CANInitialize(CANCTX *ctx, CANMODE Mode, uint32_t ID, CANSPD baudRate);


//----------------------------------------------------
/**
	\brief	Finalizace CAN

	\param	ctx		Kontext CAN
*/
//----------------------------------------------------
void CANFinalize(CANCTX * ctx);

#endif /*CAN_SJA1000_H_*/
