Skip to content

Commit 16cb7be

Browse files
author
Jamie C. Driver
committed
power: update twatch file for new i2c driver
Should have been included in 18881f1
1 parent fc0f40e commit 16cb7be

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

main/power/twatchs3.inc

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,70 +4,72 @@
44
#include "power/i2c.inc"
55

66
#define AXP2101_ADDR 0x34
7+
static i2c_master_dev_handle_t axp2101 = NULL;
78

89
static void axp2101_init(void)
910
{
1011
// initial stuff
1112
// Set vbus voltage limit to 4.36v
12-
_power_write_command(AXP2101_ADDR, 0x15, 6);
13+
_power_write_command(axp2101, 0x15, 6);
1314
vTaskDelay(100 / portTICK_PERIOD_MS);
1415
// Set input current limit to 100ma.
15-
_power_write_command(AXP2101_ADDR, 0x16, 0);
16+
_power_write_command(axp2101, 0x16, 0);
1617
vTaskDelay(100 / portTICK_PERIOD_MS);
1718
// Set input current limit to 100ma.
18-
_power_write_command(AXP2101_ADDR, 0x24, 0);
19+
_power_write_command(axp2101, 0x24, 0);
1920
vTaskDelay(100 / portTICK_PERIOD_MS);
2021

2122
// FIXME: disable things we do not need
2223
// TFT backlight
23-
_power_write_command(AXP2101_ADDR, 0x92, 28);
24+
_power_write_command(axp2101, 0x92, 28);
2425
vTaskDelay(100 / portTICK_PERIOD_MS);
25-
_power_write_command(AXP2101_ADDR, 0x93, 28);
26+
_power_write_command(axp2101, 0x93, 28);
2627
vTaskDelay(100 / portTICK_PERIOD_MS);
2728
// touch screen driver ALDO3
28-
_power_write_command(AXP2101_ADDR, 0x94, 28);
29+
_power_write_command(axp2101, 0x94, 28);
2930
vTaskDelay(100 / portTICK_PERIOD_MS);
30-
_power_write_command(AXP2101_ADDR, 0x95, 28);
31+
_power_write_command(axp2101, 0x95, 28);
3132
vTaskDelay(100 / portTICK_PERIOD_MS);
32-
_power_write_command(AXP2101_ADDR, 0x97, 28);
33+
_power_write_command(axp2101, 0x97, 28);
3334
vTaskDelay(100 / portTICK_PERIOD_MS);
34-
_power_write_command(AXP2101_ADDR, 0x80, 1);
35+
_power_write_command(axp2101, 0x80, 1);
3536
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);
3738
vTaskDelay(100 / portTICK_PERIOD_MS);
38-
_power_write_command(AXP2101_ADDR, 0x91, 0);
39+
_power_write_command(axp2101, 0x91, 0);
3940
vTaskDelay(100 / portTICK_PERIOD_MS);
4041

4142
// FIXME: implement setbit and clearbit
42-
_power_write_command(AXP2101_ADDR, 0x40, 0);
43+
_power_write_command(axp2101, 0x40, 0);
4344
vTaskDelay(100 / portTICK_PERIOD_MS);
44-
_power_write_command(AXP2101_ADDR, 0x41, 0);
45+
_power_write_command(axp2101, 0x41, 0);
4546
vTaskDelay(100 / portTICK_PERIOD_MS);
46-
_power_write_command(AXP2101_ADDR, 0x42, 0);
47+
_power_write_command(axp2101, 0x42, 0);
4748
vTaskDelay(100 / portTICK_PERIOD_MS);
48-
_power_write_command(AXP2101_ADDR, 0x48, 0);
49+
_power_write_command(axp2101, 0x48, 0);
4950
vTaskDelay(100 / portTICK_PERIOD_MS);
50-
_power_write_command(AXP2101_ADDR, 0x49, 0);
51+
_power_write_command(axp2101, 0x49, 0);
5152
vTaskDelay(100 / portTICK_PERIOD_MS);
52-
_power_write_command(AXP2101_ADDR, 0x4A, 0);
53+
_power_write_command(axp2101, 0x4A, 0);
5354
vTaskDelay(100 / portTICK_PERIOD_MS);
54-
_power_write_command(AXP2101_ADDR, 0x61, 2);
55+
_power_write_command(axp2101, 0x61, 2);
5556
vTaskDelay(100 / portTICK_PERIOD_MS);
56-
_power_write_command(AXP2101_ADDR, 0x62, 4);
57+
_power_write_command(axp2101, 0x62, 4);
5758
vTaskDelay(100 / portTICK_PERIOD_MS);
58-
_power_write_command(AXP2101_ADDR, 0x63, 1);
59+
_power_write_command(axp2101, 0x63, 1);
5960
vTaskDelay(100 / portTICK_PERIOD_MS);
6061
// FIXME: clearbit
61-
_power_write_command(AXP2101_ADDR, 0x64, 4);
62+
_power_write_command(axp2101, 0x64, 4);
6263
vTaskDelay(100 / portTICK_PERIOD_MS);
63-
_power_write_command(AXP2101_ADDR, 0x6A, 7);
64+
_power_write_command(axp2101, 0x6A, 7);
6465
vTaskDelay(100 / portTICK_PERIOD_MS);
6566
// FIXME: implement setbit
6667
}
6768

6869
esp_err_t power_init(void)
6970
{
7071
I2C_CHECK_RET(_power_i2c_init());
72+
I2C_CHECK_RET(_power_i2c_attach_device(AXP2101_ADDR, &axp2101));
7173

7274
axp2101_init();
7375

0 commit comments

Comments
 (0)