|
4 | 4 | #include "power/i2c.inc" |
5 | 5 |
|
6 | 6 | #define AXP2101_ADDR 0x34 |
| 7 | +static i2c_master_dev_handle_t axp2101 = NULL; |
7 | 8 |
|
8 | 9 | static void axp2101_init(void) |
9 | 10 | { |
10 | 11 | // initial stuff |
11 | 12 | // Set vbus voltage limit to 4.36v |
12 | | - _power_write_command(AXP2101_ADDR, 0x15, 6); |
| 13 | + _power_write_command(axp2101, 0x15, 6); |
13 | 14 | vTaskDelay(100 / portTICK_PERIOD_MS); |
14 | 15 | // Set input current limit to 100ma. |
15 | | - _power_write_command(AXP2101_ADDR, 0x16, 0); |
| 16 | + _power_write_command(axp2101, 0x16, 0); |
16 | 17 | vTaskDelay(100 / portTICK_PERIOD_MS); |
17 | 18 | // Set input current limit to 100ma. |
18 | | - _power_write_command(AXP2101_ADDR, 0x24, 0); |
| 19 | + _power_write_command(axp2101, 0x24, 0); |
19 | 20 | vTaskDelay(100 / portTICK_PERIOD_MS); |
20 | 21 |
|
21 | 22 | // FIXME: disable things we do not need |
22 | 23 | // TFT backlight |
23 | | - _power_write_command(AXP2101_ADDR, 0x92, 28); |
| 24 | + _power_write_command(axp2101, 0x92, 28); |
24 | 25 | vTaskDelay(100 / portTICK_PERIOD_MS); |
25 | | - _power_write_command(AXP2101_ADDR, 0x93, 28); |
| 26 | + _power_write_command(axp2101, 0x93, 28); |
26 | 27 | vTaskDelay(100 / portTICK_PERIOD_MS); |
27 | 28 | // touch screen driver ALDO3 |
28 | | - _power_write_command(AXP2101_ADDR, 0x94, 28); |
| 29 | + _power_write_command(axp2101, 0x94, 28); |
29 | 30 | vTaskDelay(100 / portTICK_PERIOD_MS); |
30 | | - _power_write_command(AXP2101_ADDR, 0x95, 28); |
| 31 | + _power_write_command(axp2101, 0x95, 28); |
31 | 32 | vTaskDelay(100 / portTICK_PERIOD_MS); |
32 | | - _power_write_command(AXP2101_ADDR, 0x97, 28); |
| 33 | + _power_write_command(axp2101, 0x97, 28); |
33 | 34 | vTaskDelay(100 / portTICK_PERIOD_MS); |
34 | | - _power_write_command(AXP2101_ADDR, 0x80, 1); |
| 35 | + _power_write_command(axp2101, 0x80, 1); |
35 | 36 | vTaskDelay(100 / portTICK_PERIOD_MS); |
36 | | - _power_write_command(AXP2101_ADDR, 0x90, 1 + 2 + 4 + 8 + 32); |
| 37 | + _power_write_command(axp2101, 0x90, 1 + 2 + 4 + 8 + 32); |
37 | 38 | vTaskDelay(100 / portTICK_PERIOD_MS); |
38 | | - _power_write_command(AXP2101_ADDR, 0x91, 0); |
| 39 | + _power_write_command(axp2101, 0x91, 0); |
39 | 40 | vTaskDelay(100 / portTICK_PERIOD_MS); |
40 | 41 |
|
41 | 42 | // FIXME: implement setbit and clearbit |
42 | | - _power_write_command(AXP2101_ADDR, 0x40, 0); |
| 43 | + _power_write_command(axp2101, 0x40, 0); |
43 | 44 | vTaskDelay(100 / portTICK_PERIOD_MS); |
44 | | - _power_write_command(AXP2101_ADDR, 0x41, 0); |
| 45 | + _power_write_command(axp2101, 0x41, 0); |
45 | 46 | vTaskDelay(100 / portTICK_PERIOD_MS); |
46 | | - _power_write_command(AXP2101_ADDR, 0x42, 0); |
| 47 | + _power_write_command(axp2101, 0x42, 0); |
47 | 48 | vTaskDelay(100 / portTICK_PERIOD_MS); |
48 | | - _power_write_command(AXP2101_ADDR, 0x48, 0); |
| 49 | + _power_write_command(axp2101, 0x48, 0); |
49 | 50 | vTaskDelay(100 / portTICK_PERIOD_MS); |
50 | | - _power_write_command(AXP2101_ADDR, 0x49, 0); |
| 51 | + _power_write_command(axp2101, 0x49, 0); |
51 | 52 | vTaskDelay(100 / portTICK_PERIOD_MS); |
52 | | - _power_write_command(AXP2101_ADDR, 0x4A, 0); |
| 53 | + _power_write_command(axp2101, 0x4A, 0); |
53 | 54 | vTaskDelay(100 / portTICK_PERIOD_MS); |
54 | | - _power_write_command(AXP2101_ADDR, 0x61, 2); |
| 55 | + _power_write_command(axp2101, 0x61, 2); |
55 | 56 | vTaskDelay(100 / portTICK_PERIOD_MS); |
56 | | - _power_write_command(AXP2101_ADDR, 0x62, 4); |
| 57 | + _power_write_command(axp2101, 0x62, 4); |
57 | 58 | vTaskDelay(100 / portTICK_PERIOD_MS); |
58 | | - _power_write_command(AXP2101_ADDR, 0x63, 1); |
| 59 | + _power_write_command(axp2101, 0x63, 1); |
59 | 60 | vTaskDelay(100 / portTICK_PERIOD_MS); |
60 | 61 | // FIXME: clearbit |
61 | | - _power_write_command(AXP2101_ADDR, 0x64, 4); |
| 62 | + _power_write_command(axp2101, 0x64, 4); |
62 | 63 | vTaskDelay(100 / portTICK_PERIOD_MS); |
63 | | - _power_write_command(AXP2101_ADDR, 0x6A, 7); |
| 64 | + _power_write_command(axp2101, 0x6A, 7); |
64 | 65 | vTaskDelay(100 / portTICK_PERIOD_MS); |
65 | 66 | // FIXME: implement setbit |
66 | 67 | } |
67 | 68 |
|
68 | 69 | esp_err_t power_init(void) |
69 | 70 | { |
70 | 71 | I2C_CHECK_RET(_power_i2c_init()); |
| 72 | + I2C_CHECK_RET(_power_i2c_attach_device(AXP2101_ADDR, &axp2101)); |
71 | 73 |
|
72 | 74 | axp2101_init(); |
73 | 75 |
|
|
0 commit comments