bll_imu.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. /*Includes ----------------------------------------------*/
  2. #include "tool.h"
  3. #include "nrf_delay.h"
  4. #include "bsp_time.h"
  5. #include "exception.h"
  6. #include "system.h"
  7. #include "bll_imu.h"
  8. /*Private macro ------------------------------------------------------------------------------------------------------------------------------------*/
  9. #define BLL_IMU_DATA_GROUP_NUM_MAX 12 //IMU能存储的最大数据组数
  10. #define BLL_IMU_REGISTER_CONFIG_PARAM_MAX 12 //IMU能存储的最大数据组数
  11. #define BLL_IMU_REGISTER_DATA_NOTIFY_MAX 5 //IMU能数据通知回调的最大数量
  12. #define BLL_IMU_GET_MAX(a,b) (((a) > (b)) ? (a) : (b)) //对比大小宏
  13. /*STRUCTION ------------------------------------------------------------------------------------------------------------------------------------*/
  14. typedef struct bll_imu_data_notify
  15. {
  16. uint8_t priority; //优先级
  17. bll_imu_data_notify_cb cb; //回调函数
  18. }Bll_Imu_Data_Notify_t;
  19. typedef struct bll_imu
  20. {
  21. /*private member*/
  22. const bll_imu_param_t *register_config_param[BLL_IMU_REGISTER_CONFIG_PARAM_MAX]; //已注册的IMU配置参数地址
  23. Bll_Imu_Data_Notify_t register_data_notify[BLL_IMU_REGISTER_DATA_NOTIFY_MAX]; //已注册的IMU数据通知回调
  24. bll_imu_one_way_param_t highest_priority_config_param[BLL_IMU_DIR_NUM]; //最高优先级配置IMU参数
  25. BLL_IMU_CONFIG_RESULT config_result; //配置结果
  26. } Bll_Imu_t;
  27. /*Local Variable ------------------------------------------------------------------------------------------------------------------------------------*/
  28. static Bll_Imu_t ob_bll_imu;
  29. /*Local Functions ------------------------------------------------------------------------------------------------------------------------------------*/
  30. static void bll_imu_register_config_cb(uint32_t conf_result)
  31. {
  32. if(conf_result == FML_IMU_CONFIG_FLOW_DONE) //配置成功
  33. {
  34. ob_bll_imu.config_result = (BLL_IMU_CONFIG_FINISH);
  35. }
  36. else //配置失败
  37. {
  38. if(conf_result == 4)
  39. {
  40. ob_bll_imu.config_result = (BLL_IMU_CONFIG_FAIL_BACK_MAG_GET_ID); //后脚获取ID失败
  41. }
  42. else if(conf_result == 5)
  43. {
  44. ob_bll_imu.config_result = (BLL_IMU_CONFIG_FAIL_FRONT_SIX_AXIS_GET_ID); //前脚六轴获取ID失败
  45. }
  46. else if(conf_result == 6)
  47. {
  48. ob_bll_imu.config_result = (BLL_IMU_CONFIG_FAIL_FRONT_MAG_GET_ID); //前脚地磁获取ID失败
  49. }
  50. else if(conf_result == 16)
  51. {
  52. ob_bll_imu.config_result = (BLL_IMU_CONFIG_FAIL_FRONT_MAG); //前脚mag配置失败
  53. }
  54. else if(conf_result >= 26 && conf_result < FML_IMU_CONFIG_FLOW_DONE)
  55. {
  56. ob_bll_imu.config_result = (BLL_IMU_CONFIG_FAIL_BACK_MAG); //后脚mag配置失败
  57. }
  58. else
  59. {
  60. ob_bll_imu.config_result = (BLL_IMU_CONFIG_FAIL_FRONT_SIX_AXIS); //前脚lsm配置失败
  61. }
  62. }
  63. }
  64. static void bll_imu_register_data_notify_cb(uint32_t dir_bit)
  65. {
  66. //从最高优先级开始筛选
  67. for(int i=BLL_IMU_DATA_NOTIFY_CB_PRIORITY_NUM - 1; i >= 0; i--)
  68. {
  69. for(int j=0; j<BLL_IMU_REGISTER_DATA_NOTIFY_MAX;j++)
  70. {
  71. if(ob_bll_imu.register_data_notify[j].priority == i && ob_bll_imu.register_data_notify[j].cb != NULL)
  72. {
  73. ob_bll_imu.register_data_notify[j].cb(dir_bit);
  74. }
  75. }
  76. }
  77. }
  78. static int bll_imu_get_highest_priority_config_param(bll_imu_one_way_param_t out_param[], const bll_imu_one_way_param_t int_param[])
  79. {
  80. if(out_param == NULL || int_param == NULL)return -1;
  81. for(uint8_t i=0; i<BLL_IMU_DIR_NUM; i++){
  82. out_param[i].acc_fs = BLL_IMU_GET_MAX(out_param[i].acc_fs, int_param[i].acc_fs);
  83. out_param[i].acc_odr = BLL_IMU_GET_MAX(out_param[i].acc_odr, int_param[i].acc_odr);
  84. out_param[i].acc_power_mode = BLL_IMU_GET_MAX(out_param[i].acc_power_mode,int_param[i].acc_power_mode);
  85. out_param[i].fifo_odr = BLL_IMU_GET_MAX(out_param[i].fifo_odr,int_param[i].fifo_odr);
  86. out_param[i].gry_fs = BLL_IMU_GET_MAX(out_param[i].gry_fs,int_param[i].gry_fs);
  87. out_param[i].gry_odr = BLL_IMU_GET_MAX(out_param[i].gry_odr,int_param[i].gry_odr);
  88. out_param[i].gry_power_mode = BLL_IMU_GET_MAX(out_param[i].gry_power_mode,int_param[i].gry_power_mode);
  89. out_param[i].mag_fs = BLL_IMU_GET_MAX(out_param[i].mag_fs,int_param[i].mag_fs);
  90. out_param[i].mag_odr = BLL_IMU_GET_MAX(out_param[i].mag_odr,int_param[i].mag_odr);
  91. out_param[i].timestamp_resolution = BLL_IMU_GET_MAX(out_param[i].timestamp_resolution,int_param[i].timestamp_resolution);
  92. out_param[i].timestamp_switch = BLL_IMU_GET_MAX(out_param[i].timestamp_switch,int_param[i].timestamp_switch);
  93. }
  94. return 0;
  95. }
  96. static int bll_imu_is_equal(bll_imu_one_way_param_t *param_1, bll_imu_one_way_param_t *param_2)
  97. {
  98. int diff = 0;
  99. if(param_1->acc_fs != param_2->acc_fs)diff++;
  100. if(param_1->acc_odr != param_2->acc_odr)diff++;
  101. if(param_1->acc_power_mode != param_2->acc_power_mode)diff++;
  102. if(param_1->fifo_odr != param_2->fifo_odr)diff++;
  103. if(param_1->gry_fs != param_2->gry_fs)diff++;
  104. if(param_1->gry_odr != param_2->gry_odr)diff++;
  105. if(param_1->gry_power_mode != param_2->gry_power_mode)diff++;
  106. if(param_1->mag_fs != param_2->mag_fs)diff++;
  107. if(param_1->mag_odr != param_2->mag_odr)diff++;
  108. if(param_1->timestamp_resolution != param_2->timestamp_resolution)diff++;
  109. if(param_1->timestamp_switch != param_2->timestamp_switch)diff++;
  110. return diff;
  111. }
  112. /*API ------------------------------------------------------------------------------------------------------------------------------------*/
  113. /**
  114. @brief 初始化IMU业务逻辑层
  115. @param 无
  116. @return 错误代码 - [out] -1失败,0成功
  117. */
  118. int bll_imu_Init(void)
  119. {
  120. int ret = 0;
  121. //初始化imu服务
  122. if(fml_imu_Init() == -1)ret = -1;
  123. //重置模式管理服务结构体
  124. memset(&ob_bll_imu, 0, sizeof(ob_bll_imu));
  125. //默认配置完成
  126. ob_bll_imu.config_result = (BLL_IMU_CONFIG_FINISH);
  127. if(ret == -1)return -1;
  128. return 0;
  129. }
  130. /**
  131. @brief 注册IMU要进行配置的参数
  132. @param param - [in] IMU要进行配置的参数地址
  133. @return 错误代码 - [out] 0失败,成功返回参数地址
  134. */
  135. const bll_imu_param_t* bll_imu_register_config_param(const bll_imu_param_t *param)
  136. {
  137. if(param == NULL)return 0;
  138. //若已存在,则返回该指针的地址作为句柄返回
  139. for(int i=0; i<BLL_IMU_REGISTER_CONFIG_PARAM_MAX; i++)
  140. {
  141. if(ob_bll_imu.register_config_param[i] == param)return param;
  142. }
  143. //若不存在,则存储起来,且将该指针的地址作为句柄返回
  144. for(int i=0; i<BLL_IMU_REGISTER_CONFIG_PARAM_MAX; i++)
  145. {
  146. if(ob_bll_imu.register_config_param[i] == 0)
  147. {
  148. ob_bll_imu.register_config_param[i] = param;
  149. return param;
  150. }
  151. }
  152. return 0;
  153. }
  154. /**
  155. @brief 注册IMU要进行配置的参数,并重新设置IMU
  156. @param param - [in] IMU要进行配置的参数地址
  157. @return 错误代码 - [out] 0失败,成功返回参数地址
  158. */
  159. const bll_imu_param_t* bll_imu_Resume_config_param(const bll_imu_param_t *param)
  160. {
  161. if(param == NULL)return 0;
  162. //若已存在,则返回该指针的地址作为句柄返回
  163. for(int i=0; i<BLL_IMU_REGISTER_CONFIG_PARAM_MAX; i++)
  164. {
  165. if(ob_bll_imu.register_config_param[i] == param){
  166. bll_imu_start_config();
  167. return param;
  168. }
  169. }
  170. //若不存在,则存储起来,且将该指针的地址作为句柄返回
  171. for(int i=0; i<BLL_IMU_REGISTER_CONFIG_PARAM_MAX; i++)
  172. {
  173. if(ob_bll_imu.register_config_param[i] == 0)
  174. {
  175. ob_bll_imu.register_config_param[i] = param;
  176. {
  177. bll_imu_start_config();
  178. return param;
  179. }
  180. }
  181. }
  182. return 0;
  183. }
  184. /**
  185. @brief 注销已注册的IMU配置参数
  186. @param param - [in] IMU配置参数的地址
  187. @return 错误代码 - [out] 0成功,-1地址异常,-2没有该注册的IMU配置参数
  188. */
  189. int bll_imu_unregister_config_param(const bll_imu_param_t* param)
  190. {
  191. if(param == NULL)return -1;
  192. for(int i=0; i<BLL_IMU_REGISTER_CONFIG_PARAM_MAX; i++)
  193. {
  194. if(ob_bll_imu.register_config_param[i] == param)
  195. {
  196. ob_bll_imu.register_config_param[i] = 0;
  197. return 0;
  198. }
  199. }
  200. return -2;
  201. }
  202. /**
  203. @brief 注销已注册的IMU配置参数并重新配置IMU
  204. @param param - [in] IMU配置参数的地址
  205. @return 错误代码 - [out] 0成功,-1地址异常,-2没有该注册的IMU配置参数
  206. */
  207. int bll_imu_Resume_unregister_config_param(const bll_imu_param_t* param)
  208. {
  209. if(param == NULL)return -1;
  210. for(int i=0; i<BLL_IMU_REGISTER_CONFIG_PARAM_MAX; i++)
  211. {
  212. if(ob_bll_imu.register_config_param[i] == param)
  213. {
  214. ob_bll_imu.register_config_param[i] = 0;
  215. bll_imu_start_config();
  216. return 0;
  217. }
  218. }
  219. return -2;
  220. }
  221. /**
  222. @brief 注册IMU数据通知回调函数
  223. @param priority - [in] 回调优先级
  224. @param cb - [in] 回调函数
  225. @return 错误代码 - [out] -1失败,0成功
  226. */
  227. int bll_imu_register_data_notify_callback(BLL_IMU_DATA_NOTIFY_CB_PRIORITY_e priority, bll_imu_data_notify_cb cb)
  228. {
  229. if(cb == NULL || priority>=BLL_IMU_DATA_NOTIFY_CB_PRIORITY_NUM)return -1;
  230. //若是已存在,更新优先级
  231. for(int i=0; i<BLL_IMU_REGISTER_DATA_NOTIFY_MAX; i++)
  232. {
  233. //已存在回调函数
  234. if(ob_bll_imu.register_data_notify[i].cb == cb)
  235. {
  236. //更新优先级
  237. ob_bll_imu.register_data_notify[i].priority = priority;
  238. return 0;
  239. }
  240. }
  241. //若是不存在
  242. for(int i=0; i<BLL_IMU_REGISTER_DATA_NOTIFY_MAX; i++)
  243. {
  244. //找到空位,进行赋值
  245. if(ob_bll_imu.register_data_notify[i].cb == 0)
  246. {
  247. ob_bll_imu.register_data_notify[i].cb = cb;
  248. ob_bll_imu.register_data_notify[i].priority = priority;
  249. return 0;
  250. }
  251. }
  252. //满了
  253. return -1;
  254. }
  255. /**
  256. @brief 开始配置。根据已注册IMU参数筛选出最高优先级进行配置,且只配置一次。
  257. @param 无
  258. @return 错误代码 - [out] -1失败,0成功
  259. */
  260. int bll_imu_start_config(void)
  261. {
  262. int ret= 0xff;
  263. uint8_t i=0;
  264. bll_imu_one_way_param_t cur_imu_param;
  265. int f_diff,b_diff;
  266. //清除当前最高优先级配置参数
  267. for(i=0; i<BLL_IMU_DIR_NUM; i++)
  268. memset(&ob_bll_imu.highest_priority_config_param[i],0,sizeof(bll_imu_one_way_param_t));
  269. //获取前脚和后脚最高优先级配置
  270. for(i=0; i<BLL_IMU_REGISTER_CONFIG_PARAM_MAX; i++){
  271. if(ob_bll_imu.register_config_param[i] != 0)
  272. {
  273. ret = bll_imu_get_highest_priority_config_param(ob_bll_imu.highest_priority_config_param, *ob_bll_imu.register_config_param[i]->config_param);
  274. if(ret == -1)return -1;
  275. }
  276. }
  277. fml_imu_get_config_param((FML_IMU_DIR_e)BLL_IMU_DIR_FRONT,&cur_imu_param);
  278. f_diff = bll_imu_is_equal(&cur_imu_param, &ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_FRONT]);
  279. fml_imu_get_config_param((FML_IMU_DIR_e)BLL_IMU_DIR_BACK,&cur_imu_param);
  280. b_diff = bll_imu_is_equal(&cur_imu_param, &ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_BACK]);
  281. if(f_diff == 0 && b_diff == 0)
  282. {
  283. return -1;
  284. }
  285. // DEBUG_LOG("FRONT :fifo_odr :%d,acc_odr :%d,gry_odr :%d,mag_odr :%d,acc_fs :%d,gry_fs :%d,mag_fs :%d\n",
  286. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_FRONT].fifo_odr,
  287. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_FRONT].acc_odr,
  288. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_FRONT].gry_odr,
  289. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_FRONT].mag_odr,
  290. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_FRONT].acc_fs,
  291. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_FRONT].gry_fs,
  292. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_FRONT].mag_fs
  293. // );
  294. //
  295. //
  296. // DEBUG_LOG("BACK :fifo_odr :%d,acc_odr :%d,gry_odr :%d,mag_odr :%d,acc_fs :%d,gry_fs :%d,mag_fs :%d\n",
  297. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_BACK].fifo_odr,
  298. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_BACK].acc_odr,
  299. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_BACK].gry_odr,
  300. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_BACK].mag_odr,
  301. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_BACK].acc_fs,
  302. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_BACK].gry_fs,
  303. // ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_BACK].mag_fs
  304. // );
  305. //设置前脚要配置的参数
  306. ret = fml_imu_config_param((FML_IMU_DIR_e)BLL_IMU_DIR_FRONT, &ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_FRONT]);
  307. if(ret == -1)return -1;
  308. //设置后脚要配置的参数
  309. ret = fml_imu_config_param((FML_IMU_DIR_e)BLL_IMU_DIR_BACK, &ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_BACK]);
  310. if(ret == -1)return -1;
  311. //注册配置回调函数
  312. ret = fml_imu_register_config_callback(bll_imu_register_config_cb);
  313. if(ret == -1)return -1;
  314. //注册数据通知回调函数
  315. ret = fml_imu_register_data_notify_callback(bll_imu_register_data_notify_cb);
  316. if(ret == -1)return -1;
  317. //开始配置IMU
  318. ret = fml_imu_start_config();
  319. if(ret == 0)
  320. {
  321. //设置为配置中...
  322. ob_bll_imu.config_result = (BLL_IMU_CONFIG_DOING);
  323. }
  324. return 0;
  325. }
  326. /**
  327. @brief 查询IMU配置参数是否准备好
  328. @param dir - [in] 方向
  329. @param param - [in] 需要查询的IMU配置参数
  330. @return 查询结果 - [out] BLL_IMU_CONFIG_RESULT
  331. */
  332. BLL_IMU_CONFIG_RESULT bll_imu_query_config_param_is_ready(BLL_IMU_DIR_e dir, const bll_imu_param_t *param)
  333. {
  334. BLL_IMU_CONFIG_RESULT result;
  335. if(param == NULL || dir >= BLL_IMU_DIR_NUM)
  336. {
  337. result = (BLL_IMU_CONFIG_VAILERROR);
  338. return result;
  339. }
  340. const bll_imu_one_way_param_t *front_bll = param->config_param[BLL_IMU_DIR_FRONT];
  341. const bll_imu_one_way_param_t *back_bll = param->config_param[BLL_IMU_DIR_BACK];
  342. const bll_imu_one_way_param_t *highest_front_bll = &ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_FRONT];
  343. const bll_imu_one_way_param_t *highest_back_bll = &ob_bll_imu.highest_priority_config_param[BLL_IMU_DIR_BACK];
  344. //当前最高配置参数小于输入的配置参数
  345. switch(dir)
  346. {
  347. case BLL_IMU_DIR_FRONT:
  348. //前脚
  349. if(front_bll->acc_fs > highest_front_bll->acc_fs)return result = (BLL_IMU_CONFIG_VAILERROR);
  350. if(front_bll->acc_odr > highest_front_bll->acc_odr)return result = (BLL_IMU_CONFIG_VAILERROR);
  351. if(front_bll->acc_power_mode > highest_front_bll->acc_power_mode)return result = (BLL_IMU_CONFIG_VAILERROR);
  352. if(front_bll->fifo_odr > highest_front_bll->fifo_odr)return result = (BLL_IMU_CONFIG_VAILERROR);
  353. if(front_bll->gry_fs > highest_front_bll->gry_fs)return result = (BLL_IMU_CONFIG_VAILERROR);
  354. if(front_bll->gry_odr > highest_front_bll->gry_odr)return result = (BLL_IMU_CONFIG_VAILERROR);
  355. if(front_bll->gry_power_mode > highest_front_bll->gry_power_mode)return result = (BLL_IMU_CONFIG_VAILERROR);
  356. if(front_bll->mag_fs > highest_front_bll->mag_fs)return result = ( BLL_IMU_CONFIG_VAILERROR);
  357. if(front_bll->mag_odr > highest_front_bll->mag_odr)return result = ( BLL_IMU_CONFIG_VAILERROR);
  358. if(front_bll->timestamp_resolution > highest_front_bll->timestamp_resolution)return result = ( BLL_IMU_CONFIG_VAILERROR);
  359. if(front_bll->timestamp_switch > highest_front_bll->timestamp_switch)return result = ( BLL_IMU_CONFIG_VAILERROR);
  360. break;
  361. case BLL_IMU_DIR_BACK:
  362. //后脚
  363. if(back_bll->acc_fs > highest_back_bll->acc_fs)return result = ( BLL_IMU_CONFIG_VAILERROR);
  364. if(back_bll->acc_odr > highest_back_bll->acc_odr)return result = ( BLL_IMU_CONFIG_VAILERROR);
  365. if(back_bll->acc_power_mode > highest_back_bll->acc_power_mode)return result = ( BLL_IMU_CONFIG_VAILERROR);
  366. if(back_bll->fifo_odr > highest_back_bll->fifo_odr)return result = ( BLL_IMU_CONFIG_VAILERROR);
  367. if(back_bll->gry_fs > highest_back_bll->gry_fs)return result = ( BLL_IMU_CONFIG_VAILERROR);
  368. if(back_bll->gry_odr > highest_back_bll->gry_odr)return result = ( BLL_IMU_CONFIG_VAILERROR);
  369. if(back_bll->gry_power_mode > highest_back_bll->gry_power_mode)return result = ( BLL_IMU_CONFIG_VAILERROR);
  370. if(back_bll->mag_fs > highest_back_bll->mag_fs)return result = ( BLL_IMU_CONFIG_VAILERROR);
  371. if(back_bll->mag_odr > highest_back_bll->mag_odr)return result = ( BLL_IMU_CONFIG_VAILERROR);
  372. if(back_bll->timestamp_resolution > highest_back_bll->timestamp_resolution)return result = ( BLL_IMU_CONFIG_VAILERROR);
  373. if(back_bll->timestamp_switch > highest_back_bll->timestamp_switch)return result = ( BLL_IMU_CONFIG_VAILERROR);
  374. break;
  375. default:
  376. break;
  377. }
  378. result = ob_bll_imu.config_result;
  379. return result;
  380. }
  381. /**
  382. @brief 读取当前IMU数据的数量
  383. @param dir - [in] 方向
  384. @return 返回当前IMU数据的数量
  385. */
  386. int bll_imu_get_data_num(BLL_IMU_DIR_e dir)
  387. {
  388. return fml_imu_get_data_num((FML_IMU_DIR_e)dir);
  389. }
  390. /**
  391. @brief 获取当前IMU数据
  392. @param dir - [in] 方向
  393. @param index - [in] 数据索引
  394. @param pdata - [out] 返回的IMU数据指针
  395. @return 错误代码 - [out] -1失败,0成功
  396. */
  397. int bll_imu_get_data(BLL_IMU_DIR_e dir, int index, bll_imu_data_t *pdata)
  398. {
  399. return fml_imu_get_data((FML_IMU_DIR_e)dir, index, pdata);
  400. }
  401. /**
  402. @brief 关闭IMU
  403. @return 错误代码 - [out] -1失败,0成功
  404. */
  405. int bll_imu_close(void)
  406. {
  407. int ret;
  408. //断电前后脚
  409. ret = fml_imu_close(FML_IMU_DIR_FRONT);
  410. if(ret == -1)return -1;
  411. ret = fml_imu_close(FML_IMU_DIR_BACK);
  412. if(ret == -1)return -1;
  413. //重置模式管理服务结构体
  414. memset(&ob_bll_imu, 0, sizeof(ob_bll_imu));
  415. //默认配置完成
  416. ob_bll_imu.config_result = (BLL_IMU_CONFIG_FINISH);
  417. return 0;
  418. }