75 #define bitMaskSetChk(value, bitMask) (((value) & (bitMask)) == (bitMask)) 76 #define bitMaskClrChk(value, bitMask) (((value) & (bitMask)) == 0) 78 #define bitMaskSet(value, bitMask) (value |= (bitMask)) 79 #define bitMaskClr(value, bitMask) (value &= ~(bitMask)) 81 #define bitMaskSetClr(value, bitMask, setNotClr) ((setNotClr) ? bitMaskSet(value,bitMask) : bitMaskClr(value,bitMask)) 83 #define LOG_1(n) (((n) >= 2) ? 1 : 0) 84 #define LOG_2(n) (((n) >= 1<<2) ? (2 + LOG_1((n)>>2)) : LOG_1(n)) 85 #define LOG_4(n) (((n) >= 1<<4) ? (4 + LOG_2((n)>>4)) : LOG_2(n)) 86 #define LOG_8(n) (((n) >= 1<<8) ? (8 + LOG_4((n)>>8)) : LOG_4(n)) 87 #define LOG(n) (((n) >= 1<<16) ? (16 + LOG_8((n)>>16)) : LOG_8(n)) 93 #define BM2BITPOS(bm) ((bm)&1<<7 ? 7 : \ 102 #define LTC2947_I2C_ADDR_LL 0x5C // AD0=L, AD1=L (default) 103 #define LTC2947_I2C_ADDR_LH 0x5D // AD0=L, AD1=H 104 #define LTC2947_I2C_ADDR_LR 0x5E // AD0=L, AD1=R 105 #define LTC2947_I2C_ADDR_RL 0x64 // AD0=R, AD1=L 106 #define LTC2947_I2C_ADDR_RH 0x65 // AD0=R, AD1=H 107 #define LTC2947_I2C_ADDR_RR 0x66 // AD0=R, AD1=R 110 #define LTC2947_SPI_READ_CMD 0x01 111 #define LTC2947_SPI_WRITE_CMD 0x00 113 #define LTC2947_LSB_FACTOR_MILLI_HOURS (1.0 / 60.0 / 60.0 / 1.0e-3) 114 #define LTC2947_LSB_FACTOR_HOURS (1.0 / 60.0 / 60.0) 117 #define LTC2947_CS QUIKEVAL_CS 147 #define LTC2947_EXTCLK 4e6 // external frequency on CLKI pin (must be 4MHz in case of crystal) 148 #undef LTC2947_PRE // will be calculated and defined by LTC2947.h 149 #undef LTC2947_DIV // will be calculated and defined by LTC2947.h 168 #define LTC2947_REG_GPIOSTATCL 0x067 171 #define LTC2947_REG_STATUS 0x080 174 #define LTC2947_REG_STATVT 0x081 177 #define LTC2947_REG_STATIP 0x082 180 #define LTC2947_REG_STATC 0x083 183 #define LTC2947_REG_STATE 0x084 186 #define LTC2947_REG_STATCEOF 0x085 189 #define LTC2947_REG_STATTB 0x086 192 #define LTC2947_REG_STATVDVCC 0x087 195 #define LTC2947_REG_STATUSM 0x088 198 #define LTC2947_REG_STATVTM 0x089 201 #define LTC2947_REG_STATIPM 0x08A 204 #define LTC2947_REG_STATCM 0x08B 207 #define LTC2947_REG_STATEM 0x08C 210 #define LTC2947_REG_STATCEOFM 0x08D 213 #define LTC2947_REG_STATTBM 0x08E 216 #define LTC2947_REG_STATVDVCCM 0x08F 223 #define LTC2947_REG_ACCICTL 0x0E1 230 #define LTC2947_REG_ACCGPCTL 0x0E3 234 #define LTC2947_REG_ACCIDB 0x0E4 237 #define LTC2947_REG_ALERTBCTL 0x0E8 240 #define LTC2947_REG_TBCTL 0x0E9 243 #define LTC2947_REG_OPCTL 0x0F0 246 #define LTC2947_REG_PGCTL 0x0FF 258 #define LTC2947_REG_C1_47_40 0x000 261 #define LTC2947_REG_C1_39_32 0x001 264 #define LTC2947_REG_C1_31_24 0x002 267 #define LTC2947_REG_C1_23_16 0x003 270 #define LTC2947_REG_C1_15_8 0x004 273 #define LTC2947_REG_C1_7_0 0x005 276 #define LTC2947_REG_E1_47_40 0x006 279 #define LTC2947_REG_E1_39_32 0x007 282 #define LTC2947_REG_E1_31_24 0x008 285 #define LTC2947_REG_E1_23_16 0x009 288 #define LTC2947_REG_E1_15_8 0x00A 291 #define LTC2947_REG_E1_7_0 0x00B 294 #define LTC2947_REG_TB1_31_24 0x00C 297 #define LTC2947_REG_TB1_23_16 0x00D 300 #define LTC2947_REG_TB1_15_8 0x00E 303 #define LTC2947_REG_TB1_7_0 0x00F 306 #define LTC2947_REG_C2_47_40 0x010 309 #define LTC2947_REG_C2_39_32 0x011 312 #define LTC2947_REG_C2_31_24 0x012 315 #define LTC2947_REG_C2_23_16 0x013 318 #define LTC2947_REG_C2_15_8 0x014 321 #define LTC2947_REG_C2_7_0 0x015 324 #define LTC2947_REG_E2_47_40 0x016 327 #define LTC2947_REG_E2_39_32 0x017 330 #define LTC2947_REG_E2_31_24 0x018 333 #define LTC2947_REG_E2_23_16 0x019 336 #define LTC2947_REG_E2_15_8 0x01A 339 #define LTC2947_REG_E2_7_0 0x01B 342 #define LTC2947_REG_TB2_31_24 0x01C 345 #define LTC2947_REG_TB2_23_16 0x01D 348 #define LTC2947_REG_TB2_15_8 0x01E 351 #define LTC2947_REG_TB2_7_0 0x01F 354 #define LTC2947_REG_IMAX_15_8 0x040 357 #define LTC2947_REG_IMAX_7_0 0x041 360 #define LTC2947_REG_IMIN_15_8 0x042 363 #define LTC2947_REG_IMIN_7_0 0x043 366 #define LTC2947_REG_PMAX_15_8 0x044 369 #define LTC2947_REG_PMAX_7_0 0x045 372 #define LTC2947_REG_PMIN_15_8 0x046 375 #define LTC2947_REG_PMIN_7_0 0x047 378 #define LTC2947_REG_VMAX_15_8 0x050 381 #define LTC2947_REG_VMAX_7_0 0x051 384 #define LTC2947_REG_VMIN_15_8 0x052 387 #define LTC2947_REG_VMIN_7_0 0x053 390 #define LTC2947_REG_TEMPMAX_15_8 0x054 393 #define LTC2947_REG_TEMPMAX_7_0 0x055 396 #define LTC2947_REG_TEMPMIN_15_8 0x056 399 #define LTC2947_REG_TEMPMIN_7_0 0x057 402 #define LTC2947_REG_VDVCCMAX_15_8 0x058 405 #define LTC2947_REG_VDVCCMAX_7_0 0x059 408 #define LTC2947_REG_VDVCCMIN_15_8 0x05A 411 #define LTC2947_REG_VDVCCMIN_7_0 0x05B 414 #define LTC2947_REG_I_23_16 0x090 417 #define LTC2947_REG_I_15_8 0x091 420 #define LTC2947_REG_I_7_0 0x092 423 #define LTC2947_REG_P_23_16 0x093 426 #define LTC2947_REG_P_15_8 0x094 429 #define LTC2947_REG_P_7_0 0x095 432 #define LTC2947_REG_V_15_8 0x0A0 435 #define LTC2947_REG_V_7_0 0x0A1 438 #define LTC2947_REG_TEMP_15_8 0x0A2 441 #define LTC2947_REG_TEMP_7_0 0x0A3 444 #define LTC2947_REG_VDVCC_15_8 0x0A4 447 #define LTC2947_REG_VDVCC_7_0 0x0A5 450 #define LTC2947_REG_IH1_23_16 0x0B0 453 #define LTC2947_REG_IH1_15_8 0x0B1 456 #define LTC2947_REG_IH1_7_0 0x0B2 459 #define LTC2947_REG_IH2_23_16 0x0B3 462 #define LTC2947_REG_IH2_15_8 0x0B4 465 #define LTC2947_REG_IH2_7_0 0x0B5 468 #define LTC2947_REG_IH3_23_16 0x0B6 471 #define LTC2947_REG_IH3_15_8 0x0B7 474 #define LTC2947_REG_IH3_7_0 0x0B8 477 #define LTC2947_REG_IH4_23_16 0x0B9 480 #define LTC2947_REG_IH4_15_8 0x0BA 483 #define LTC2947_REG_IH4_7_0 0x0BB 486 #define LTC2947_REG_IH5_23_16 0x0BC 489 #define LTC2947_REG_IH5_15_8 0x0BD 492 #define LTC2947_REG_IH5_7_0 0x0BE 495 #define LTC2947_REG_C1TH_47_40 0x100 498 #define LTC2947_REG_C1TH_39_32 0x101 501 #define LTC2947_REG_C1TH_31_24 0x102 504 #define LTC2947_REG_C1TH_23_16 0x103 507 #define LTC2947_REG_C1TH_15_8 0x104 510 #define LTC2947_REG_C1TH_7_0 0x105 513 #define LTC2947_REG_C1TL_47_40 0x106 516 #define LTC2947_REG_C1TL_39_32 0x107 519 #define LTC2947_REG_C1TL_31_24 0x108 522 #define LTC2947_REG_C1TL_23_16 0x109 525 #define LTC2947_REG_C1TL_15_8 0x10A 528 #define LTC2947_REG_C1TL_7_0 0x10B 531 #define LTC2947_REG_TB1TH_31_24 0x10C 534 #define LTC2947_REG_TB1TH_23_16 0x10D 537 #define LTC2947_REG_TB1TH_15_8 0x10E 540 #define LTC2947_REG_TB1TH_7_0 0x10F 543 #define LTC2947_REG_E1TH_47_40 0x110 546 #define LTC2947_REG_E1TH_39_32 0x111 549 #define LTC2947_REG_E1TH_31_24 0x112 552 #define LTC2947_REG_E1TH_23_16 0x113 555 #define LTC2947_REG_E1TH_15_8 0x114 558 #define LTC2947_REG_E1TH_7_0 0x115 561 #define LTC2947_REG_E1TL_47_40 0x116 564 #define LTC2947_REG_E1TL_39_32 0x117 567 #define LTC2947_REG_E1TL_31_24 0x118 570 #define LTC2947_REG_E1TL_23_16 0x119 573 #define LTC2947_REG_E1TL_15_8 0x11A 576 #define LTC2947_REG_E1TL_7_0 0x11B 579 #define LTC2947_REG_C2TH_47_40 0x120 582 #define LTC2947_REG_C2TH_39_32 0x121 585 #define LTC2947_REG_C2TH_31_24 0x122 588 #define LTC2947_REG_C2TH_23_16 0x123 591 #define LTC2947_REG_C2TH_15_8 0x124 594 #define LTC2947_REG_C2TH_7_0 0x125 597 #define LTC2947_REG_C2TL_47_40 0x126 600 #define LTC2947_REG_C2TL_39_32 0x127 603 #define LTC2947_REG_C2TL_31_24 0x128 606 #define LTC2947_REG_C2TL_23_16 0x129 609 #define LTC2947_REG_C2TL_15_8 0x12A 612 #define LTC2947_REG_C2TL_7_0 0x12B 615 #define LTC2947_REG_TB2TH_31_24 0x12C 618 #define LTC2947_REG_TB2TH_23_16 0x12D 621 #define LTC2947_REG_TB2TH_15_8 0x12E 624 #define LTC2947_REG_TB2TH_7_0 0x12F 627 #define LTC2947_REG_E2TH_47_40 0x130 630 #define LTC2947_REG_E2TH_39_32 0x131 633 #define LTC2947_REG_E2TH_31_24 0x132 636 #define LTC2947_REG_E2TH_23_16 0x133 639 #define LTC2947_REG_E2TH_15_8 0x134 642 #define LTC2947_REG_E2TH_7_0 0x135 645 #define LTC2947_REG_E2TL_47_40 0x136 648 #define LTC2947_REG_E2TL_39_32 0x137 651 #define LTC2947_REG_E2TL_31_24 0x138 654 #define LTC2947_REG_E2TL_23_16 0x139 657 #define LTC2947_REG_E2TL_15_8 0x13A 660 #define LTC2947_REG_E2TL_7_0 0x13B 663 #define LTC2947_REG_ITH_15_8 0x180 666 #define LTC2947_REG_ITH_7_0 0x181 669 #define LTC2947_REG_ITL_15_8 0x182 672 #define LTC2947_REG_ITL_7_0 0x183 675 #define LTC2947_REG_PTH_15_8 0x184 678 #define LTC2947_REG_PTH_7_0 0x185 681 #define LTC2947_REG_PTL_15_8 0x186 684 #define LTC2947_REG_PTL_7_0 0x187 687 #define LTC2947_REG_VTH_15_8 0x190 690 #define LTC2947_REG_VTH_7_0 0x191 693 #define LTC2947_REG_VTL_15_8 0x192 696 #define LTC2947_REG_VTL_7_0 0x193 699 #define LTC2947_REG_TEMPTH_15_8 0x194 702 #define LTC2947_REG_TEMPTH_7_0 0x195 705 #define LTC2947_REG_TEMPTL_15_8 0x196 708 #define LTC2947_REG_TEMPTL_7_0 0x197 711 #define LTC2947_REG_VDVCCTH_15_8 0x198 714 #define LTC2947_REG_VDVCCTH_7_0 0x199 717 #define LTC2947_REG_VDVCCTL_15_8 0x19A 720 #define LTC2947_REG_VDVCCTL_7_0 0x19B 723 #define LTC2947_REG_TEMPTFANH_15_8 0x19C 726 #define LTC2947_REG_TEMPTFANH_7_0 0x19D 729 #define LTC2947_REG_TEMPTFANL_15_8 0x19E 732 #define LTC2947_REG_TEMPTFANL_7_0 0x19F 744 #define LTC2947_VAL_C1 0x000 747 #define LTC2947_VAL_E1 0x006 750 #define LTC2947_VAL_TB1 0x00C 753 #define LTC2947_VAL_C2 0x010 756 #define LTC2947_VAL_E2 0x016 759 #define LTC2947_VAL_TB2 0x01C 762 #define LTC2947_VAL_IMAX 0x040 765 #define LTC2947_VAL_IMIN 0x042 768 #define LTC2947_VAL_PMAX 0x044 771 #define LTC2947_VAL_PMIN 0x046 774 #define LTC2947_VAL_VMAX 0x050 777 #define LTC2947_VAL_VMIN 0x052 780 #define LTC2947_VAL_TEMPMAX 0x054 783 #define LTC2947_VAL_TEMPMIN 0x056 786 #define LTC2947_VAL_VDVCCMAX 0x058 789 #define LTC2947_VAL_VDVCCMIN 0x05A 792 #define LTC2947_VAL_I 0x090 795 #define LTC2947_VAL_P 0x093 798 #define LTC2947_VAL_V 0x0A0 801 #define LTC2947_VAL_TEMP 0x0A2 804 #define LTC2947_VAL_VDVCC 0x0A4 807 #define LTC2947_VAL_IH1 0x0B0 810 #define LTC2947_VAL_IH2 0x0B3 813 #define LTC2947_VAL_IH3 0x0B6 816 #define LTC2947_VAL_IH4 0x0B9 819 #define LTC2947_VAL_IH5 0x0BC 822 #define LTC2947_VAL_C1TH 0x100 825 #define LTC2947_VAL_C1TL 0x106 828 #define LTC2947_VAL_TB1TH 0x10C 831 #define LTC2947_VAL_E1TH 0x110 834 #define LTC2947_VAL_E1TL 0x116 837 #define LTC2947_VAL_C2TH 0x120 840 #define LTC2947_VAL_C2TL 0x126 843 #define LTC2947_VAL_TB2TH 0x12C 846 #define LTC2947_VAL_E2TH 0x130 849 #define LTC2947_VAL_E2TL 0x136 852 #define LTC2947_VAL_ITH 0x180 855 #define LTC2947_VAL_ITL 0x182 858 #define LTC2947_VAL_PTH 0x184 861 #define LTC2947_VAL_PTL 0x186 864 #define LTC2947_VAL_VTH 0x190 867 #define LTC2947_VAL_VTL 0x192 870 #define LTC2947_VAL_TEMPTH 0x194 873 #define LTC2947_VAL_TEMPTL 0x196 876 #define LTC2947_VAL_VDVCCTH 0x198 879 #define LTC2947_VAL_VDVCCTL 0x19A 882 #define LTC2947_VAL_TEMPTFANH 0x19C 885 #define LTC2947_VAL_TEMPTFANL 0x19E 892 #ifndef LTC2947_EXTCLK 894 #define LTC2947_PRE 7 895 #define LTC2947_DIV 0 896 #define LTC2947_EXTCLK 4e6 898 #define LTC2947_EXTCLK_UNSUPPORTED 5 900 #define LTC2947_PRE ( \ 901 LTC2947_EXTCLK <= 1e6 ? 0 : \ 902 LTC2947_EXTCLK <= 2e6 ? 1 : \ 903 LTC2947_EXTCLK <= 4e6 ? 2 : \ 904 LTC2947_EXTCLK <= 8e6 ? 3 : \ 905 LTC2947_EXTCLK <= 16e6 ? 4 : \ 906 LTC2947_EXTCLK <= 25e6 ? 5 : LTC2947_EXTCLK_UNSUPPORTED) 907 #define LTC2947_DIV ((uint8_t)(LTC2947_EXTCLK/32768.0/(1 << LTC2947_PRE))) 911 #define LTC2947_EXTPER (1.0/LTC2947_EXTCLK) 913 #define LTC2947_INTC 31e-6 916 #define LTC2947_LSB_C1 (0.0384946 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 918 #define LTC2947_LSB_E1 (0.641576 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 920 #define LTC2947_LSB_TB1 (12.8315 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 922 #define LTC2947_LSB_C2 (0.0384946 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 924 #define LTC2947_LSB_E2 (0.641576 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 926 #define LTC2947_LSB_TB2 (12.8315 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 928 #define LTC2947_LSB_IMAX 12.0 930 #define LTC2947_LSB_IMIN 12.0 932 #define LTC2947_LSB_PMAX 200.0 934 #define LTC2947_LSB_PMIN 200.0 936 #define LTC2947_LSB_VMAX 2.0 938 #define LTC2947_LSB_VMIN 2.0 940 #define LTC2947_LSB_TEMPMAX 0.204 942 #define LTC2947_OFFS_TEMPMAX 5.5 944 #define LTC2947_LSB_TEMPMIN 0.204 946 #define LTC2947_OFFS_TEMPMIN 5.5 948 #define LTC2947_LSB_VDVCCMAX 145.0 950 #define LTC2947_LSB_VDVCCMIN 145.0 952 #define LTC2947_LSB_I 3.0 954 #define LTC2947_LSB_P 50.0 956 #define LTC2947_LSB_V 2.0 958 #define LTC2947_LSB_TEMP 0.204 960 #define LTC2947_OFFS_TEMP 5.5 962 #define LTC2947_LSB_VDVCC 145.0 964 #define LTC2947_LSB_IH1 3.0 966 #define LTC2947_LSB_IH2 3.0 968 #define LTC2947_LSB_IH3 3.0 970 #define LTC2947_LSB_IH4 3.0 972 #define LTC2947_LSB_IH5 3.0 974 #define LTC2947_LSB_C1TH (0.0384946 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 976 #define LTC2947_LSB_C1TL (0.0384946 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 978 #define LTC2947_LSB_TB1TH (12.8315 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 980 #define LTC2947_LSB_E1TH (0.641576 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 982 #define LTC2947_LSB_E1TL (0.641576 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 984 #define LTC2947_LSB_C2TH (0.0384946 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 986 #define LTC2947_LSB_C2TL (0.0384946 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 988 #define LTC2947_LSB_TB2TH (12.8315 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 990 #define LTC2947_LSB_E2TH (0.641576 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 992 #define LTC2947_LSB_E2TL (0.641576 * (LTC2947_PRE == 7 ? LTC2947_INTC : LTC2947_EXTPER * (1 << LTC2947_PRE) * (LTC2947_DIV + 1))) 994 #define LTC2947_LSB_ITH 12.0 996 #define LTC2947_LSB_ITL 12.0 998 #define LTC2947_LSB_PTH 200.0 1000 #define LTC2947_LSB_PTL 200.0 1002 #define LTC2947_LSB_VTH 2.0 1004 #define LTC2947_LSB_VTL 2.0 1006 #define LTC2947_LSB_TEMPTH 0.204 1008 #define LTC2947_OFFS_TEMPTH 5.5 1010 #define LTC2947_LSB_TEMPTL 0.204 1012 #define LTC2947_OFFS_TEMPTL 5.5 1014 #define LTC2947_LSB_VDVCCTH 145.0 1016 #define LTC2947_LSB_VDVCCTL 145.0 1018 #define LTC2947_LSB_TEMPTFANH 0.204 1020 #define LTC2947_OFFS_TEMPTFANH 5.5 1022 #define LTC2947_LSB_TEMPTFANL 0.204 1024 #define LTC2947_OFFS_TEMPTFANL 5.5 1032 #define LTC2947_BM_GPIOSTATCL_GPOEN 0x1 1036 #define LTC2947_BM_GPIOSTATCL_GPI 0x10 1040 #define LTC2947_BM_GPIOSTATCL_GPO 0x20 1044 #define LTC2947_BM_GPIOSTATCL_FANEN 0x40 1048 #define LTC2947_BM_GPIOSTATCL_FANPOL 0x80 1052 #define LTC2947_BM_STATUS_UVLOA 0x1 1054 #define LTC2947_BM_STATUS_PORA 0x2 1056 #define LTC2947_BM_STATUS_UVLOSTBY 0x4 1058 #define LTC2947_BM_STATUS_UVLOD 0x8 1060 #define LTC2947_BM_STATUS_UPDATE 0x10 1062 #define LTC2947_BM_STATUS_ADCERR 0x20 1064 #define LTC2947_BM_STATUS_TBERR 0x40 1068 #define LTC2947_BM_STATVT_VH 0x1 1070 #define LTC2947_BM_STATVT_VL 0x2 1072 #define LTC2947_BM_STATVT_TEMPH 0x4 1074 #define LTC2947_BM_STATVT_TEMPL 0x8 1076 #define LTC2947_BM_STATVT_FANH 0x10 1078 #define LTC2947_BM_STATVT_FANL 0x20 1082 #define LTC2947_BM_STATIP_IH 0x1 1084 #define LTC2947_BM_STATIP_IL 0x2 1086 #define LTC2947_BM_STATIP_PH 0x4 1088 #define LTC2947_BM_STATIP_PL 0x8 1092 #define LTC2947_BM_STATC_C1H 0x1 1094 #define LTC2947_BM_STATC_C1L 0x2 1096 #define LTC2947_BM_STATC_C2H 0x4 1098 #define LTC2947_BM_STATC_C2L 0x8 1102 #define LTC2947_BM_STATE_E1H 0x1 1104 #define LTC2947_BM_STATE_E1L 0x2 1106 #define LTC2947_BM_STATE_E2H 0x4 1108 #define LTC2947_BM_STATE_E2L 0x8 1112 #define LTC2947_BM_STATCEOF_C1OF 0x1 1114 #define LTC2947_BM_STATCEOF_C2OF 0x2 1116 #define LTC2947_BM_STATCEOF_E1OF 0x10 1118 #define LTC2947_BM_STATCEOF_E2OF 0x20 1122 #define LTC2947_BM_STATTB_TB1TH 0x1 1124 #define LTC2947_BM_STATTB_TB2TH 0x2 1126 #define LTC2947_BM_STATTB_TB1OF 0x10 1128 #define LTC2947_BM_STATTB_TB2OF 0x20 1132 #define LTC2947_BM_STATVDVCC_VDVCCH 0x1 1134 #define LTC2947_BM_STATVDVCC_VDVCCL 0x2 1138 #define LTC2947_BM_STATUSM_UVLOAM 0x1 1140 #define LTC2947_BM_STATUSM_UVLODM 0x8 1142 #define LTC2947_BM_STATUSM_UPDATEM 0x10 1144 #define LTC2947_BM_STATUSM_ADCERRM 0x20 1146 #define LTC2947_BM_STATUSM_TBERRM 0x40 1150 #define LTC2947_BM_STATVTM_VHM 0x1 1152 #define LTC2947_BM_STATVTM_VLM 0x2 1154 #define LTC2947_BM_STATVTM_TEMPHM 0x4 1156 #define LTC2947_BM_STATVTM_TEMPLM 0x8 1158 #define LTC2947_BM_STATVTM_FANHM 0x10 1160 #define LTC2947_BM_STATVTM_FANLM 0x20 1164 #define LTC2947_BM_STATIPM_IHM 0x1 1166 #define LTC2947_BM_STATIPM_ILM 0x2 1168 #define LTC2947_BM_STATIPM_PHM 0x4 1170 #define LTC2947_BM_STATIPM_PLM 0x8 1174 #define LTC2947_BM_STATCM_C1HM 0x1 1176 #define LTC2947_BM_STATCM_C1LM 0x2 1178 #define LTC2947_BM_STATCM_C2HM 0x4 1180 #define LTC2947_BM_STATCM_C2LM 0x8 1184 #define LTC2947_BM_STATEM_E1HM 0x1 1186 #define LTC2947_BM_STATEM_E1LM 0x2 1188 #define LTC2947_BM_STATEM_E2HM 0x4 1190 #define LTC2947_BM_STATEM_E2LM 0x8 1194 #define LTC2947_BM_STATCEOFM_C1OFM 0x1 1196 #define LTC2947_BM_STATCEOFM_C2OFM 0x2 1198 #define LTC2947_BM_STATCEOFM_E1OFM 0x10 1200 #define LTC2947_BM_STATCEOFM_E2OFM 0x20 1204 #define LTC2947_BM_STATTBM_TB1THM 0x1 1206 #define LTC2947_BM_STATTBM_TB2THM 0x2 1208 #define LTC2947_BM_STATTBM_TB1OFM 0x10 1210 #define LTC2947_BM_STATTBM_TB2OFM 0x20 1214 #define LTC2947_BM_STATVDVCCM_VDVCCHM 0x1 1216 #define LTC2947_BM_STATVDVCCM_VDVCCLM 0x2 1220 #define LTC2947_BM_ACCICTL_ACC1I0 0x1 1222 #define LTC2947_BM_ACCICTL_ACC1I1 0x2 1224 #define LTC2947_BM_ACCICTL_ACC2I0 0x4 1226 #define LTC2947_BM_ACCICTL_ACC2I1 0x8 1230 #define LTC2947_BM_ACCGPCTL_ACC1GP0 0x1 1232 #define LTC2947_BM_ACCGPCTL_ACC1GP1 0x2 1234 #define LTC2947_BM_ACCGPCTL_ACC2GP0 0x4 1236 #define LTC2947_BM_ACCGPCTL_ACC2GP1 0x8 1241 #define LTC2947_BM_ALERTBCTL_ALERTBEN 0x1 1245 #define LTC2947_BM_TBCTL_PRE_0 0x1 1247 #define LTC2947_BM_TBCTL_PRE_1 0x2 1249 #define LTC2947_BM_TBCTL_PRE_2 0x4 1251 #define LTC2947_BM_TBCTL_DIV_0 0x8 1253 #define LTC2947_BM_TBCTL_DIV_1 0x10 1255 #define LTC2947_BM_TBCTL_DIV_2 0x20 1257 #define LTC2947_BM_TBCTL_DIV_3 0x40 1259 #define LTC2947_BM_TBCTL_DIV_4 0x80 1264 #define LTC2947_BM_OPCTL_SHDN 0x1 1266 #define LTC2947_BM_OPCTL_CLR 0x2 1268 #define LTC2947_BM_OPCTL_SSHOT 0x4 1271 #define LTC2947_BM_OPCTL_CONT 0x8 1273 #define LTC2947_BM_OPCTL_RST 0x80 1279 #define LTC2947_BM_PGCTL_PAGE 0x1 1339 uint8_t *unsignedBytes,
1350 uint8_t *signedBytes,
1393 #ifdef LTC2947_DEBUG 1395 void LTC2947_DoubleToBytes_Test();
1508 #define LTC2947_ARA_ERROR 0xFF 1510 #define LTC2947_ARA_LTC2947_RESPONSE 1 1512 #define LTC2947_ARA_OTHER_RESPONSE 2 1514 #define LTC2947_ARA_NO_RESPONSE 3 1516 #define LTC2947_ARA_RESPONSE_WO_WR 4 1518 #define LTC2947_ALERT_RESP_ADDR 0x0C int32_t LTC2947_3BytesToInt32(byte *bytes)
converts an array of 3 bytes to 32-bit signed integer
double LTC2947_UnsignedBytesToDouble(uint8_t *unsignedBytes, uint8_t length, double lsb)
Converts an unsigned value of arbitrary number of bytes to a floating point value with the scaling fa...
void LTC2947_GPIO_PinMode(uint8_t mode)
Enables/disables the output driver on the GPIO pin Make sure LTC2947's page 0 is selected before call...
static int8_t LTC2947_RD_BYTES(uint8_t REG_ADDR, uint8_t LENGTH, uint8_t *BYTES)
read multiple bytes via I2C/SPI
uint8_t LTC2947_Ara(uint8_t *svlAddr)
Sends the Alert Response address to the I2C bus and reads the response If two or more devices on the ...
void LTC2947_InitI2C(uint8_t slvAddr)
Initializes the LTC2947 library for I2C mode operation and configures the slave address see defines L...
uint32_t LTC2947_3BytesToUInt32(byte *bytes)
converts an array of 3 bytes to 32-bit unsigned integer
uint16_t LTC2947_2BytesToUInt16(byte *bytes)
Converts an array of 2 bytes to 16-bit unsigned integer.
void LTC2947_DoubleToBytes(double value, double lsb, uint8_t *bytes, uint8_t length)
Converts a floating point number that was scaled with a given LSB to an integer representation that w...
void LTC2947_SerialPrint64hex(uint64_t uint64Val)
Prints a 64-bit value in 16-character hexadecimal format with left padded zeros.
int8_t LTC2947_I2CWrBlock(uint8_t slvAddr, uint8_t regAddr, uint8_t length, uint8_t *values)
write byte array via I2C interface
uint8_t LTC2947_I2C_Slave_Addr
set by LTC2947_InitI2C to set slave address for I2C operation
void LTC2947_SetPageSelect(boolean page)
write LTC2947's page control register to selected one of two memory pages
uint32_t LTC2947_4BytesToUInt32(byte *bytes)
Converts an array of 4 bytes to 32-bit unsigned integer.
double LTC2947_BytesToDouble(uint8_t *bytes, uint8_t length, boolean sig, double lsb)
Converts a signed or unsigned value of arbitrary number of bytes to a floating point number...
void LTC2947_Read_Abs_C_E_TB(boolean accuSet1, double *C, boolean *signC, double *E, boolean *signE, double *TB)
Reads charge (C), energy (E) and time (TB) from the device.
boolean LTC2947_GPIO_Read()
reads the current GPIO pin state Make sure LTC2947's page 0 is selected before calling this function...
int8_t LTC2947_I2CWrByte(uint8_t slvAddr, uint8_t regAddr, uint8_t value)
write single byte via I2C
int8_t LTC2947_SpiWrBlock(uint8_t address, uint8_t length, uint8_t *values)
writes block (array) of bytes to the SPI interface
void LTC2947_SerialPrint32hex(uint32_t val)
Prints a 32-bit value in 8-character hexadecimal format with left padded zeros.
int8_t LTC2947_I2CRdByte(uint8_t slvAddr, uint8_t regAddr, uint8_t *value)
read single byte via I2C
void LTC2947_GPIO_SetPinState(uint8_t val)
Sets the level of the output driver on the GPIO pin This has only an effect if the output driver is e...
int16_t LTC2947_2BytesToInt16(byte *bytes)
converts an array of 2 bytes to 16-bit signed integer
int8_t LTC2947_I2CRdBlock(uint8_t slvAddr, uint8_t regAddr, uint8_t length, uint8_t *values)
read multiple bytes via I2C
double LTC2947_SignedBytesToDouble(uint8_t *signedBytes, uint8_t length, double lsb)
Converts a signed value of arbitrary number of bytes to a floating point value with the scaling facto...
int8_t LTC2947_SpiRdBlock(uint8_t address, uint8_t length, uint8_t *values)
read array of bytes from the SPI interface
int32_t LTC2947_4BytesToInt32(byte *bytes)
Converts an array of 4 bytes to 32-bit signed integer.
boolean LTC2947_GetCurrentPageSelect()
reads LTC2947's page control register to determine the currently selected memory page ...
int8_t LTC2947_SpiRdByte(uint8_t address, uint8_t *value)
read single byte from SPI interface
boolean LTC2947_SPI_Mode_Enabled
controlled by LTC2947_InitI2C / LTC2947_InitSPI to switch between I2C / SPI mode
boolean LTC2947_Abs(uint8_t *bytes, uint8_t length)
Calculates the absolute value of a signed value with arbitrary number of bytes.
static int8_t LTC2947_WR_BYTES(uint8_t REG_ADDR, uint8_t LENGTH, uint8_t *BYTES)
write byte array via I2C/SPI interface
static int8_t LTC2947_WR_BYTE(uint8_t REG_ADDR, uint8_t VALUE)
write single byte via I2C
void LTC2947_SerialPrint8hex(uint8_t val)
Prints a 8-bit value in 2-character hexadecimal format with left padded zeros.
void LTC2947_InitSPI()
Initializes the LTC2947 library for SPI mode operation.
int16_t LTC2947_wake_up()
Wake up LTC2947 from shutdown mode and measure the wakeup time.
void LTC2947_Read_C_E_TB(boolean accuSet1, double *C, double *E, double *TB)
Reads charge (C), energy (E) and time (TB) from the device.
void LTC2947_SerialPrint16hex(uint16_t val)
Prints a 16-bit value in 4-character hexadecimal format with left padded zeros.
static int8_t LTC2947_RD_BYTE(uint8_t REG_ADDR, uint8_t *RESULT)
read single byte via I2C/SPI
void LTC2947_Read_I_P_V_TEMP_VCC(float *I, float *P, float *V, float *TEMP, float *VCC)
Reads current (I), power (P), voltage (V), temperature (TEMP) and supply voltage (VCC) from the devic...
int8_t LTC2947_SpiWrByte(uint8_t address, uint8_t value)
write single byte to SPI interface