/*
 * spi.h
 *
 *  Created on: Mar 27, 2020
 *      Author: Hadamek
 */

#ifndef _SPI_H_
#define _SPI_H_

#include "xspi.h"		/* SPI device driver */

#define SPI_READ(x)		{x |= 0x80;}
#define SPI_WRITE(x)	{x &= 0x7f;}

struct reg_t {
	uint16_t reg;
	uint8_t	val;
};

int spi_init(XSpi *SpiInstancePtr, u16 SpiDeviceId);
int spi_rw_reg(XSpi *spi, uint16_t reg_addr, uint8_t *reg_val, int write);
int spi_write_conf(XSpi *spi, struct reg_t *conf, int size);
int spi_compare_conf(XSpi *spi, struct reg_t *conf, int size);
int spi_write_reg(XSpi *spi, uint16_t reg_addr, uint8_t reg_val);

#endif /* SRC_SPI_H_ */
