uint8 bmm150_init(void) { uint8 init_ret = BMM150_ERROR; uint8 self_test_fault_cnt = 0; init_ret = bmm150_read_pwr_control(); if(BMM150_OK != init_ret) { init_ret = bmm150_set_pwr_control(BMM150_PWR_OTHER_MODE); if(BMM150_OK != init_ret) { return init_ret; } } //bmm150_soft_reset(); init_ret = bmm150_read_id(); if(BMM150_OK != init_ret) { return init_ret; } #if (!NORMAL_WORK_MODE) init_ret = bmm150_set_pwr_mode(BMM150_PWR_SLEEP_MODE); if(BMM150_OK != init_ret) { return init_ret; } init_ret = bmm150_set_ready_en(BMM150_READY_EN); if(BMM150_OK != init_ret) { return init_ret; } init_ret = bmm150_set_repxy(BMM150_REPXY_LOWPWR); if(BMM150_OK != init_ret) { return init_ret; } init_ret = bmm150_set_repz(BMM150_REPZ_LOWPWR); if(BMM150_OK != init_ret) { return init_ret; } #else init_ret = bmm150_set_ready_en(BMM150_READY_EN); if(BMM150_OK != init_ret) { return init_ret; } init_ret = bmm150_set_rate(BMM150_DATA_RATE_10HZ); if(BMM150_OK != init_ret) { return init_ret; } init_ret = bmm150_set_repxy(BMM150_REPXY_REGULAR); if(BMM150_OK != init_ret) { return init_ret; } init_ret = bmm150_set_repz(BMM150_REPZ_REGULAR); if(BMM150_OK != init_ret) { return init_ret; } init_ret = bmm150_set_pwr_mode(BMM150_PWR_NORMAL_MODE); if(BMM150_OK != init_ret) { return init_ret; } #endif return BMM150_OK; } Thanks.
... View more