Skip to content

Commit

Permalink
Modify sensor initialize function
Browse files Browse the repository at this point in the history
Summary:
- A sensor may have i2c mux in front of the sensor, so check whether has pre_sensor_read_hook to do pre-sensor read.

Test Plan:
- Build code: Pass
  • Loading branch information
Quanta-YangChen committed Jun 6, 2022
1 parent a73a762 commit 9f343b1
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions common/service/sensor/sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ static bool sensor_poll_enable_flag = true;

static bool is_sensor_ready_flag = false;

const int negative_ten_power[16] = { 1, 1, 1, 1, 1, 1,
1, 1000000000, 100000000, 10000000, 1000000, 100000,
10000, 1000, 100, 10 };
const int negative_ten_power[16] = { 1, 1, 1, 1, 1, 1,
1, 1000000000, 100000000, 10000000, 1000000, 100000,
10000, 1000, 100, 10 };

sensor_cfg *sensor_config;
uint8_t sensor_config_num;
Expand Down Expand Up @@ -284,22 +284,22 @@ __weak void pal_fix_sensor_config(void)
return;
}

bool stby_access(uint8_t sensor_number)
bool stby_access(uint8_t sensor_num)
{
return true;
}

bool dc_access(uint8_t sensor_number)
bool dc_access(uint8_t sensor_num)
{
return get_DC_on_delayed_status();
}

bool post_access(uint8_t sensor_number)
bool post_access(uint8_t sensor_num)
{
return get_post_status();
}

bool me_access(uint8_t sensor_number)
bool me_access(uint8_t sensor_num)
{
if (get_me_mode() == ME_NORMAL_MODE) {
return get_post_status();
Expand Down Expand Up @@ -364,6 +364,13 @@ static void drive_init(void)
sensor_cfg *p = sensor_config + i;
for (j = 0; j < drive_num; j++) {
if (p->type == sensor_drive_tbl[j].dev) {
if (p->pre_sensor_read_hook) {
if (p->pre_sensor_read_hook(
p->num, p->pre_sensor_read_args) == false) {
printk("[%s] sensor %d pre sensor read failed!\n",
__func__, p->num);
}
}
ret = sensor_drive_tbl[j].init(p->num);
if (ret != SENSOR_INIT_SUCCESS)
printf("sensor num %d initial fail, ret %d\n", p->num, ret);
Expand Down

0 comments on commit 9f343b1

Please sign in to comment.