/*
 * AS5048.h
 *
 * Created: 27/07/2021 16:12:53
 *  Author: Nick-XMG
 */ 

#ifndef AS5048_H_
#define AS5048_H_
#include <atmel_start.h>


struct SPI_AS5048 {
	struct spi_m_sync_descriptor *SPI_descr;
	struct io_descriptor *io_descr;
	uint8_t state;
	uint8_t flags;
	uint32_t SS_pin;
	uint8_t *tx_buffer;
	uint8_t *rx_buffer;
};

struct SPI_AS5048 AS_1;

void as5048a_init(struct spi_m_sync_descriptor *spi, struct SPI_AS5048 *Sn);
void as5048a_State_Machine(struct SPI_AS5048 *Sn);
//
///* Sensor Specific Read Functions */
uint16_t as5048a_read(struct SPI_AS5048 *Sn, uint16_t address);
uint16_t as5048a_getRawRotation(struct SPI_AS5048 *Sn);
int16_t as5048a_getRotation(struct SPI_AS5048 *Sn);
float as5048a_getRotationInDegrees(struct SPI_AS5048 *Sn);
//
///* Support Functions */
uint16_t as5048a_transfer16(struct SPI_AS5048 *Sn, uint16_t value);
uint8_t as5048a_CalcEvenParity(uint16_t value);

#endif /* AS5048_H_ */