c语言 库仑计_BQ27510 电量计的校准 的 C语言实现

/*

================================================================================

*             Texas Instruments OMAP(TM) Platform Software

* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.

*

* Use of this software is controlled by the terms and conditions found

* in the license agreement under which this software has been supplied.

*

================================================================================

*/

//

//  File:  bqtool.c

//

#include 

#include 

#include 

#include 

#include 

#include "bq27500.h"

#define CMD_MAX_DATA_SIZE   512

#define MAX_LINE_LEN        ((CMD_MAX_DATA_SIZE + 4) * 3)

#define CMD_RETRY_DELAY     100 /* in ms */

#define RETRY_LIMIT     3

typedefenum{

CMD_INVALID = 0,

CMD_R,  /* Read */

CMD_W,  /* Write */

CMD_C,  /* Compare */

CMD_X,  /* Delay */

} cmd_type_t;

/*

* DO NOT change the order of fields - particularly reg

* should be immediately followed by data

*/

typedefstruct{

cmd_type_t cmd_type;

unsigned charaddr;

unsigned charreg;

union{

unsigned charbytes[CMD_MAX_DATA_SIZE + 1];

UINTdelay;

} data;

unsigned chardata_len;

UINT32line_num;

CHAR*line;

}cmd_t;

staticUINT32line_num;

/* Parse S into tokens separated by characters in DELIM.

If S is NULL, the saved pointer in SAVE_PTR is used as

the next starting point.  For example:

char s[] = "-abc-=-def";

char *sp;

x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"

x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL

x = strtok_r(NULL, "=", &sp);   // x = NULL

// s = "abc/0-def/0"

*/

staticchar*strtok_r(char*s,constchar*delim,char**save_ptr) {

char*token;

if(s == NULL) s = *save_ptr;

/* Scan leading delimiters.  */

s += strspn(s, delim);<

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值