Skip to content

Commit e5478f0

Browse files
committed
Some fixes
1 parent 943f37b commit e5478f0

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

i2c/ina260_i2c/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ add_executable(ina260_i2c
33
)
44
target_link_libraries(ina260_i2c
55
pico_stdlib
6+
pico_status_led
67
hardware_i2c
78
)
89
pico_add_extra_outputs(ina260_i2c)
10+
pico_enable_stdio_usb(ina260_i2c 1)
11+
pico_enable_stdio_uart(ina260_i2c 1)
332 KB
Loading

i2c/ina260_i2c/ina260_i2c.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <stdio.h>
22
#include "pico/stdlib.h"
33
#include "hardware/i2c.h"
4+
#include "pico/status_led.h"
45

56
#define CURRENT_REGISTER 0x01
67
#define VOLTAGE_REGISTER 0x02
@@ -24,7 +25,7 @@ static uint16_t read_reg(uint8_t reg) {
2425
}
2526

2627
int main() {
27-
setup_default_uart();
28+
stdio_init_all();
2829
printf("ina260 test\n");
2930

3031
// Initialise i2c
@@ -34,7 +35,9 @@ int main() {
3435
gpio_pull_up(PICO_DEFAULT_I2C_SDA_PIN);
3536
gpio_pull_up(PICO_DEFAULT_I2C_SCL_PIN);
3637

38+
hard_assert(status_led_init());
3739
while(true) {
40+
status_led_set_state(true);
3841

3942
// Read current and convert to mA
4043
float ma = read_reg(CURRENT_REGISTER) * 1.250f;
@@ -45,7 +48,9 @@ int main() {
4548
uint16_t mw = read_reg(POWER_REGISTER) * 10;
4649

4750
// Display results
48-
printf("current: %.2f mA voltage: %.2f v power: %u mW\n", ma, v, mw);
51+
printf("current: %.2f mA voltage: %.2f V power: %u mW\n", ma, v, mw);
52+
53+
status_led_set_state(false);
4954
sleep_ms(1000);
5055
}
5156
return 0;

0 commit comments

Comments
 (0)