static uint8_t ost_init = 0;
+static uint8_t ost_start_flag = 0;
+
static uint16_t timer_cnt = 0;
static float g_sum_y = 0;
void hx3508_set_factory_test_mode(uint8_t cmd)
{
factory_flag = cmd;
+ if(factory_flag == 1)
+ ots_write_reg(RA_DSP_EN,0x03); //进入校准模式前将这个寄存器写成0x03
+ else
+ ots_write_reg(RA_DSP_EN,0x01); //退出校准模式后将这个寄存器写成0x01
}
void hx3508_set_coffy(float data)
void hx3508_get_sum_y(float *data)
{
- if(sum_deltay && coffy!= 0 && data != 0 && sum_deltay != 0)
+ if(coffy!= 0 && data != 0 && sum_deltay != 0)
{
printf("sum_deltay : %d coffy : %.3f\n",sum_deltay,coffy);
// g_sum_y = 360/(float)sum_deltay * 1200 * coffy;
stand_still = 0;
//X Y的数据必须全部被读出,但是我们只需要X的结果来判断方向和速度
deltax = ots_read_reg(RA_ACC_DELTA_X_LOW) |(ots_read_reg(RA_ACC_DELTA_X_HIG)<<8);
- deltay = ots_read_reg(RA_ACC_DELTA_Y_LOW) |(ots_read_reg(RA_ACC_DELTA_Y_HIG)<<8);
- TYHX_LOG("Deltay = %d \r\n",deltay);//djd0305
+ deltay = ots_read_reg(RA_ACC_DELTA_Y_LOW) |(ots_read_reg(RA_ACC_DELTA_Y_HIG)<<8);
+ //下面这一行日志加时间戳打印
+ TYHX_LOG("Deltay = %d, pic qulity =%d, agc num=%d, dsp en=%d\r\n",deltay, ots_read_reg(RA_DATA_2AGC), ots_read_reg(RA_EXP_NUM_SEL)&0x7F, ots_read_reg(RA_DSP_EN));//djd0305
// printf("deltay:%d,coffy:%.3f\n",deltay,coffy);
// if(deltay && coffy)
// deltay = (float)deltay * coffy;
}
void hx3508l_calibration(void)
{
- uint8_t cali75,cali74;
- LOS_Mdelay(2);//必须有这个delay
+ uint8_t cali75;
+ LOS_Mdelay(10);//必须有这个delay
ots_write_reg(RA_DEBUG_CAS0,0x41);
cali75 = ots_read_reg(0x75);
- cali74 = ots_read_reg(0x74);
- if((cali75!=0x84) || (cali74 < 0x42))
+ if((cali75&0x80)!=0x80)
{
ots_write_reg(RA_DEBUG_CAS0,0x41);
LOS_Mdelay(2);
*/
void ots_start(void)
{
+ if(ost_start_flag == 1)
+ return;
+
+ ost_start_flag = 1;
//bool ret = true;
ots_write_reg(RA_DEBUG_CAS0,0x43);
LOS_Mdelay(2); //delay about 1ms
*/
void ots_stop(void)
{
+ if(ost_start_flag == 0)
+ return;
+
+ ost_start_flag = 0;
+
#ifdef MOT_NO_USE_MODE
ots_timer_stop();
// uapi_pin_set_ie(INT_PIN,HAL_PIO_IE_DISABLE);