/*
 * max6675.h
 *
 *  Created on: 16 янв. 2022 г.
 *      Author: mcfly
 */

#ifndef INC_MAX6675_H_
#define INC_MAX6675_H_

#include "stm32g0xx_hal.h"
#include "spi.h"
#include "main.h"

//Interface
#define MAX6675_SPI			&hspi2				//SPI interface
#define MAX6675_CS_pn		MAX_CS_Pin			//CS pin
#define MAX6675_CS_pt		MAX_CS_GPIO_Port	//CS pin port

//CS Macros
#define MAX6675_CS_ON()		(HAL_GPIO_WritePin(MAX6675_CS_pt, MAX6675_CS_pn, GPIO_PIN_RESET))
#define MAX6675_CS_OFF()	(HAL_GPIO_WritePin(MAX6675_CS_pt, MAX6675_CS_pn, GPIO_PIN_SET))

//Return codes
#define MAX6675_OK		1
#define MAX6675_ERROR	0



//Read the temperature. -1.0: SPI error; -2.0: Sensor is not connected
float MAX6675_GetTemp();

#endif /* INC_MAX6675_H_ */
