c语言 库仑计 您所在的位置:网站首页 ds2784库仑计 c语言 库仑计

c语言 库仑计

2024-07-14 06:14| 来源: 网络整理| 查看: 265

/*

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

*             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);



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有