summaryrefslogtreecommitdiff
path: root/code/esp32/components/eos/bq25895.c
blob: fc32fbdd24d8832614ce01e2e9468f287031f4ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <stdio.h>
#include <esp_log.h>

#include "eos.h"
#include "i2c.h"

static const char *TAG = "BQ25895";

#define BQ25895_ADDR                0x6A

/**
 * @brief test function to show buffer
 */
static void disp_buf(uint8_t *buf, int len)
{
    int i;
    for (i = 0; i < len; i++) {
        printf("%02x ", buf[i]);
        if ((i + 1) % 16 == 0) {
            printf("\n");
        }
    }
    printf("\n");
}

void eos_bq25895_set_ilim(void) {
    uint8_t data = 0;
    // eos_i2c_write8(BQ25895_ADDR, 2, 0xfd);
    eos_i2c_write8(BQ25895_ADDR, 2, 0xec);
    eos_i2c_write8(BQ25895_ADDR, 0, 0x26);
    data = eos_i2c_read8(BQ25895_ADDR, 0x00);
    ESP_LOGI(TAG, "REG00: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x01);
    ESP_LOGI(TAG, "REG01: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x02);
    ESP_LOGI(TAG, "REG02: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x03);
    ESP_LOGI(TAG, "REG03: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x04);
    ESP_LOGI(TAG, "REG04: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x05);
    ESP_LOGI(TAG, "REG05: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x06);
    ESP_LOGI(TAG, "REG06: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x07);
    ESP_LOGI(TAG, "REG07: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x08);
    ESP_LOGI(TAG, "REG08: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x09);
    ESP_LOGI(TAG, "REG09: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x0a);
    ESP_LOGI(TAG, "REG0A: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x0b);
    ESP_LOGI(TAG, "REG0B: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x0c);
    ESP_LOGI(TAG, "REG0C: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x0d);
    ESP_LOGI(TAG, "REG0D: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x0e);
    ESP_LOGI(TAG, "REG0E: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x0f);
    ESP_LOGI(TAG, "REG0F: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x10);
    ESP_LOGI(TAG, "REG10: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x11);
    ESP_LOGI(TAG, "REG11: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x12);
    ESP_LOGI(TAG, "REG12: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x13);
    ESP_LOGI(TAG, "REG13: %02x", data);
    data = eos_i2c_read8(BQ25895_ADDR, 0x14);
    ESP_LOGI(TAG, "REG14: %02x", data);
}