/*
 * Touch.h
 *
 *  Created on: 27/10/2014
 *      Author: Fabian
 *
 *
 *
 *      Falta manejo de interrupcion y salida del x,y = TouchGetInfo
 *
 *
 */

#ifndef TOUCH_H_
#define TOUCH_H_

/******************************************
 *
 *	Definiciones HW
 *
 *****************************************/

// Puerto a usar
#define		SSI_PORT_SYSCTL		SYSCTL_PERIPH_GPIOD
// Seleccion de funcion del puerto
#define		PIN_RX_MUX			GPIO_PD0_SSI2XDAT1
#define		PIN_TX_MUX			GPIO_PD1_SSI2XDAT0
#define		PIN_FSS_MUX			GPIO_PD2_SSI2FSS
#define		PIN_CLK_MUX			GPIO_PD3_SSI2CLK
// Seleccion de los pines
#define 	PORT_BASE			GPIO_PORTD_BASE
#define		T_PIN_CS			GPIO_PIN_2
#define		T_PIN_CLK			GPIO_PIN_3
#define		T_PIN_TX			GPIO_PIN_1
#define		T_PIN_RX			GPIO_PIN_0
#define		PORT_PINS			T_PIN_CS | T_PIN_CLK | T_PIN_TX | T_PIN_RX

#define 	SSI_ENA				SYSCTL_PERIPH_SSI2
#define		SSI_BASE			SSI2_BASE


// En caso que no se definio por otro modulo lo definimos aca
#ifndef CLKSPEED
#define 	CLKSPEED		120000000
#endif

/******************************************
 *
 *	Definiciones SW
 *
 *****************************************/

#define		TOUCH_READ_X		0x90
#define		TOUCH_READ_Y		0xD0
#define		POWPREC				3		// Modificable
#define		PREC				2^POWPREC

/******************************************
 *
 *	Prototipos de funciones
 *
 *****************************************/

void InitTouch(void);
uint32_t TouchWriteAndRead(uint16_t Data);
void TouchGetInfo();


#endif /* TOUCH_H_ */
