//----------------------------------------------------
/**
	\file		AensAmteo/inc/ioboard.h
	\ingroup	platform
	\ingroup	cortex-m4

	\brief		Knihovna obsluhy zarizeni danneho modulu
				<<< CTBRD03C >>>

	\author		ConTeK s.r.o., Bc. Jan Prasil
	\version	01.01
	\date		20.03.2014
*/
//----------------------------------------------------
#ifndef _IOBOARD_H_
#define _IOBOARD_H_

#include <libsets.h>
#include <iolib.h>

//----------------------------------------------------
//!	\name	Digitalni vstupy desky
//@{
#define _HW_DI_0		0	// DI0
#define _HW_DI_1		1	// DI1
#define _HW_DI_2		2	// DI2
#define _HW_DI_3		3	// DI3
#define _HW_DI_4		4	// DI4
#define _HW_DI_5		5	// DI5
#define _HW_DI_6		6	// DI6
#define _HW_DI_7		7	// DI7

#define _HW_DI_STS		8	// STS
//@}


//----------------------------------------------------
//!	\name	Digitalni vystupy desky
//@{
#define _HW_DO_0			0	// DO0
#define _HW_DO_1			1	// DO1
#define _HW_DO_2			2	// DO2
#define _HW_DO_3			3	// DO3
#define _HW_DO_4			4	// DO4
#define _HW_DO_5			5	// DO5
#define _HW_DO_6			6	// DO6
#define _HW_DO_7			7	// DO7

#define _HW_OUT_EN			8	// nOUT_EN
#define _HW_LAMBDA_POWER	9	// LAMBDA POWER
//@}


//----------------------------------------------------
//!	\name	Analogove vstupy desky
//@{
#define _HW_AI_0	0	// thermocouple
#define _HW_AI_1	1	// temp on conector
#define _HW_AI_2	2	// Lambda power current
#define _HW_AI_3	3	// reserved
#define _HW_AI_4	4	// Lambda
#define _HW_AI_5	5	// Photoresistor
#define _HW_AI_6	6	// Phototransistor
//@}


//----------------------------------------------------
//!	\name	Analogove vystupy desky
//@{
#define _HW_AO_0	0	// none
//@}


//----------------------------------------------------
//!	\name	Pocty vstupu a vystupu
//@{
#define IOBOARD_DINP_COUNT			9		//!< Pocet digitalnich vstupu
#define IOBOARD_DOUTP_COUNT			10		//!< Pocet digitalnich vystupu
#define IOBOARD_AINP_COUNT			7		//!< Pocet analogovych vstupu
#define IOBOARD_AOUTP_COUNT			1		//!< Pocet analogovych vystupu

#define IOBOARD_DINP_B_COUNT		(sGetByteIndex( IOBOARD_DINP_COUNT ) + 1)		//!< Pocet digitalnich vstupu v byte
#define IOBOARD_DOUTP_B_COUNT		(sGetByteIndex( IOBOARD_DOUTP_COUNT ) + 1)		//!< Pocet digitalnich vystupu v byte
//@}

#define VOLT_ON_DIV	(3.3 / 65535)

//----------------------------------------------------
//!	Kontext IO desky

typedef struct _IOBOARD_CTX
{
	IODEVICE		Device;			//!< Rodic

	volatile bool_t	flRunning;		//!< Priznak inicializace
} IOBOARD_CTX;


//----------------------------------------------------
/**
	\brief	Inicializace IO desky

	\param	ctx		Kontext
*/
//----------------------------------------------------

void IOBoardInitialize(IOBOARD_CTX * ctx);


//----------------------------------------------------
/**
	\brief	Finalizace IO desky

	\param	ctx		Kontext
*/
//----------------------------------------------------

void IOBoardFinalize(IOBOARD_CTX * ctx);

#endif /* _IOBOARD_H_ */
