#include "bma253.h"

void i2c_chekc(uint8_t result){
    switch(result){
        case HAL_OK:
        printf("HAL_OK : %d \r\n",result);
        break;
        case HAL_ERROR:
        printf("HAL_ERROR : %d\r\n",result);
        break;
        case HAL_BUSY:
        printf("HAL_BUSY : %d\r\n",result);
        break;
        case HAL_TIMEOUT:
        printf("HAL_TIMEOUT : %d\r\n",result);
        break;
    }

}
int bma253_get_chip_id(void){
    uint8_t data,res[1]={0,};
    data = HAL_I2C_Mem_Read(&hi2c2, (REG_VALUE_CHIP_ID << 1), BMA253_SPI_READ_CMD_BIT|0, 1, &res[0], 1, 10);
    i2c_chekc(data);
    HAL_Delay(1000);
    data = HAL_I2C_Mem_Read(&hi2c2, REG_VALUE_CHIP_ID , BMA253_SPI_READ_CMD_BIT|0, 1, &res[0], 1, 10);
    i2c_chekc(data);
    HAL_Delay(1000);
    data = HAL_I2C_Mem_Read(&hi2c2, 0, 0xfa, 1, &res[0], 1, 10);
    i2c_chekc(data);
    HAL_Delay(1000);
    data = HAL_I2C_Mem_Read(&hi2c2, 0, 0xfa<<1, 1, &res[0], 1, 10);
    i2c_chekc(data);
    HAL_Delay(1000);

}
