#include "stm32l0xx_hal_conf.h"
#include "stm32l0xx_hal.h"
#include "init.h"
#include "gyroskop.h"

/*uint8_t Read(uint8_t ADDR)
{
    return ADDR | 0b10000000;
};

uint8_t Write(uint8_t ADDR)
{
    return ADDR & 0b01111111;
};

void gyr_Init(void)
{
        HAL_GPIO_WritePin(CS_AKC, LOW);
        SPI_TransmitReceive(Write(CMD));
        SPI_TransmitReceive(GYRO_NORMAL_MODE);
        HAL_GPIO_WritePin(CS_AKC, HIGH);

        HAL_GPIO_WritePin(CS_AKC, LOW);    //set to 25Hz          
        SPI_TransmitReceive(Write(GYR_CONF));
        SPI_TransmitReceive(0b00100110); 
        HAL_GPIO_WritePin(CS_AKC, HIGH);          
    
    
        HAL_GPIO_WritePin(CS_AKC, LOW);    //set range +- 125 °/s          
        SPI_TransmitReceive(Write(GYR_RANGE));
        SPI_TransmitReceive(0b00000100); 
        HAL_GPIO_WritePin(CS_AKC, HIGH);  
};

uint8_t gyr_ID(void)
{
        uint8_t tmp = 0;
        HAL_GPIO_WritePin(CS_AKC, LOW);
        SPI_TransmitReceive(Read(CHIP_ID));
        tmp = SPI_TransmitReceive(0xFF);
        HAL_GPIO_WritePin(CS_AKC, HIGH);
        return tmp;
};

uint8_t gyr_ERR_Reg(void)
{
        uint8_t tmp = 0;
        HAL_GPIO_WritePin(CS_AKC, LOW);
        SPI_TransmitReceive(Read(ERR_REG));
        tmp = SPI_TransmitReceive(0xFF);
        HAL_GPIO_WritePin(CS_AKC, HIGH);
        return tmp; 
};

uint8_t gyr_ReadSTATUS(void)
{
    uint8_t tmp = 0;
    HAL_GPIO_WritePin(CS_AKC, LOW);    //Status register    
    SPI_TransmitReceive(Read(STATUS_REG));
    tmp = SPI_TransmitReceive(0xFF); 
    HAL_GPIO_WritePin(CS_AKC, HIGH); 
    return tmp;
};

*/





