//----------------------------------------------------
/**
	\file		ctk/hw/stepper_a3980.h
	\ingroup	other
	\ingroup	all

	\brief		Knihovna budice krokoveho motoru A3980
				<<< ALL >>>

	\author		ConTeK s.r.o., Ing. Pavel Bazika
	\version	01.01
	\date		12.01.2007

	\todo	nutna kontrola!!!
			??A390_STATE by melo byt A3980_STATE
*/
//----------------------------------------------------
#ifndef _STEPPER_A3980_H_
#define _STEPPER_A3980_H_

#include "appiodef.h"

#include <stepper.h>
#include <iolib.h>

//----------------------------------------------------
//!	Stavy budice krokoveho motoru A3980

typedef enum _A390_STATE {
	SS_OVER = 0x00,
	SS_SHORT_SUPPLY = 0x01,
	SS_SHORT_GND = 0x02,
	SS_OK = 0x03
} A390_STATE;


//----------------------------------------------------
//!	Kontext krokoveho motoru

typedef struct _STEPPERHW_CTX {
	STEPPER_CTX		Parent;		//!< Rodic

	volatile A390_STATE	Status;		//!< Stav

	uint8_t			FF1Addr;		//!< Adresa pinu pro cteni statusu
	uint8_t			FF2Addr;

	uint8_t			StepAddr;		//!< Adresa pinu krokovani
	uint8_t			DirAddr;		//!< Adresa pinu rizeni smeru

	uint8_t			Pwr0;		//!< Adresa pinu rizeni vykonu
	uint8_t			Pwr1;

	volatile bool_t		flRunning;	//!< Je nainicializovan
} STEPPERHW_CTX;

//----------------------------------------------------
/**
	/brief	HW inicializace krokoveho motoru
*/
//----------------------------------------------------

void StepperHwInitialize(STEPPERHW_CTX * const ctx, const bool_t RampEnabled, const STEPPER_DIR _posDir, const APP_DINP AddrF1,
		const APP_DINP AddrF2, const APP_DOUTP StepAddr, const APP_DOUTP DirAddr,  const APP_DOUTP Pwr0Addr, const APP_DOUTP Pwr1Addr);

//----------------------------------------------------
/**
	/brief	HW ukonceni
*/
//----------------------------------------------------

void StepperHwFinalize(STEPPERHW_CTX * ctx);

#endif /*_STEPPER_A3980_H_*/
