Explorar el Código

change cs1180 ready to not ready define

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui hace 5 años
padre
commit
0697cf0045
Se han modificado 2 ficheros con 16 adiciones y 20 borrados
  1. 14 18
      Application/bsp/cs1180.c
  2. 2 2
      Application/bsp/gpio.h

+ 14 - 18
Application/bsp/cs1180.c

@@ -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);

+ 2 - 2
Application/bsp/gpio.h

@@ -27,7 +27,7 @@ void gpio_init(void);
 /*power switch for cs110, low active */
 #define CS1180_PWR_ENABLE(x) gpio_bit_write(GPIOB,GPIO_PIN_12, x==1?RESET:SET)
 /*detect for CS1180 is ready */
-#define IS_CS1180_READY() !!gpio_input_bit_get(GPIOA, GPIO_PIN_0)
+#define IS_CS1180_NOT_READY() !!gpio_input_bit_get(GPIOA, GPIO_PIN_0)
 /*spi chip select for cs1180*/
 #define cs1180_cs(x) gpio_bit_write(GPIOA, GPIO_PIN_9, (bit_status)x)
 
@@ -45,7 +45,7 @@ void gpio_init(void);
 /*power switch for cs110, low active */
 #define CS1180_PWR_ENABLE(x) gpio_bit_write(GPIOC,GPIO_PIN_15, x==1?RESET:SET)
 /*detect for CS1180 is ready */
-#define IS_CS1180_READY() !!gpio_input_bit_get(GPIOB, GPIO_PIN_12)
+#define IS_CS1180_NOT_READY() !!gpio_input_bit_get(GPIOB, GPIO_PIN_12)
 /*spi chip select for cs1180*/
 #define cs1180_cs(x) gpio_bit_write(GPIOA, GPIO_PIN_8, (bit_status)x)