|
|
@@ -56,7 +56,7 @@ static void spi_read_reg(uint8_t reg, uint8_t *data, uint8_t len){
|
|
|
|
|
|
static uint8_t cs1180_dumy_read(void){
|
|
|
uint8_t data[16] = {0x5A, 0x5A, 0x5A};
|
|
|
- while (IS_CS1180_READY());
|
|
|
+ while (IS_CS1180_NOT_READY());
|
|
|
cs1180_cs(0);
|
|
|
cs_delay();
|
|
|
spi_read_reg(0x0, data, 16);
|
|
|
@@ -75,10 +75,10 @@ static void cs1180_self_calibrate(void)
|
|
|
cs1180_cs(1);
|
|
|
delay_us(50);
|
|
|
/* wait calibrate finished */
|
|
|
- while (IS_CS1180_READY());
|
|
|
- while (!IS_CS1180_READY());
|
|
|
+ while (IS_CS1180_NOT_READY());
|
|
|
+ while (!IS_CS1180_NOT_READY());
|
|
|
delay_us(50 * 1000);
|
|
|
- while (IS_CS1180_READY()); //drop first data
|
|
|
+ while (IS_CS1180_NOT_READY()); //drop first data
|
|
|
}
|
|
|
|
|
|
/* 对芯片的偏移误差进行纠正 */
|
|
|
@@ -89,8 +89,8 @@ __attribute__((unused)) static void cs1180_self_offset_calibrate(void)
|
|
|
cs1180_cs(1);
|
|
|
delay_us(50);
|
|
|
/* wait calibrate finished */
|
|
|
- while (IS_CS1180_READY());
|
|
|
- while (!IS_CS1180_READY());
|
|
|
+ while (IS_CS1180_NOT_READY());
|
|
|
+ while (!IS_CS1180_NOT_READY());
|
|
|
}
|
|
|
|
|
|
/* 对芯片的增益误差进行纠正 */
|
|
|
@@ -101,8 +101,8 @@ __attribute__((unused)) static void cs1180_self_gain_calibrate(void)
|
|
|
cs1180_cs(1);
|
|
|
delay_us(50);
|
|
|
/* wait calibrate finished */
|
|
|
- while (IS_CS1180_READY());
|
|
|
- while (!IS_CS1180_READY());
|
|
|
+ while (IS_CS1180_NOT_READY());
|
|
|
+ while (!IS_CS1180_NOT_READY());
|
|
|
}
|
|
|
|
|
|
/* 对系统的失调误差(偏移误差)进行纠正, 必须要求输入为差分电压为0,
|
|
|
@@ -116,10 +116,10 @@ void cs1180_sys_offset_calibrate(void)
|
|
|
cs1180_cs(1);
|
|
|
delay_us(50);
|
|
|
/* wait calibrate finished */
|
|
|
- while (IS_CS1180_READY());
|
|
|
- while (!IS_CS1180_READY());
|
|
|
+ while (IS_CS1180_NOT_READY());
|
|
|
+ while (!IS_CS1180_NOT_READY());
|
|
|
delay_us(10 * 1000);
|
|
|
- while (IS_CS1180_READY()); //drop first data
|
|
|
+ while (IS_CS1180_NOT_READY()); //drop first data
|
|
|
}
|
|
|
|
|
|
/* 对系统的增益误差进行纠正,必须输入正满幅度的电压, SP700,SP600未提供满辐电压,故这一项不做 */
|
|
|
@@ -130,8 +130,8 @@ __attribute__((unused)) static void cs1180_sys_gain_calibrate(void)
|
|
|
cs1180_cs(1);
|
|
|
delay_us(50);
|
|
|
/* wait calibrate finished */
|
|
|
- while (IS_CS1180_READY());
|
|
|
- while (!IS_CS1180_READY());
|
|
|
+ while (IS_CS1180_NOT_READY());
|
|
|
+ while (!IS_CS1180_NOT_READY());
|
|
|
}
|
|
|
|
|
|
static void _cs1180_adc_set_gain(int gain){
|
|
|
@@ -206,12 +206,8 @@ float cs1180_adc_sample(void)
|
|
|
{
|
|
|
uint8_t data[3] = {0,0,0};
|
|
|
int a = 0;
|
|
|
- while (!IS_CS1180_READY());
|
|
|
- if (cs1180_dumy_read() != 0x7){
|
|
|
- return 0;
|
|
|
- }
|
|
|
|
|
|
- while (IS_CS1180_READY()); //当drdy 为高时,不读取数据
|
|
|
+ while (IS_CS1180_NOT_READY()); //当drdy 为高时,不读取数据
|
|
|
|
|
|
cs1180_cs(0);
|
|
|
//spi_read_reg(0xD, data, 3);
|