Skip to content

Commit

Permalink
boards: shields: Adding support for the waveshare pico ups-b shield
Browse files Browse the repository at this point in the history
Adding support for the Waveshare pico ups-b shield with documentation

Signed-off-by: Joseph Yates <joeyatessecond@gmail.com>
  • Loading branch information
joeker64 committed Oct 18, 2023
1 parent 1323b1a commit 2ef7b08
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 0 deletions.
9 changes: 9 additions & 0 deletions boards/arm/rpi_pico/rpi_pico-common.dtsi
Expand Up @@ -112,6 +112,13 @@
pinctrl-names = "default";
};

&i2c1 {
pinctrl-0 = <&i2c1_default>;
pinctrl-names = "default";

Check failure on line 117 in boards/arm/rpi_pico/rpi_pico-common.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

boards/arm/rpi_pico/rpi_pico-common.dtsi:117 code indent should use tabs where possible

Check warning on line 117 in boards/arm/rpi_pico/rpi_pico-common.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

boards/arm/rpi_pico/rpi_pico-common.dtsi:117 please, no spaces at the start of a line
status = "disabled";

Check failure on line 118 in boards/arm/rpi_pico/rpi_pico-common.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

boards/arm/rpi_pico/rpi_pico-common.dtsi:118 code indent should use tabs where possible

Check warning on line 118 in boards/arm/rpi_pico/rpi_pico-common.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

boards/arm/rpi_pico/rpi_pico-common.dtsi:118 please, no spaces at the start of a line
clock-frequency = <I2C_BITRATE_FAST>;

Check failure on line 119 in boards/arm/rpi_pico/rpi_pico-common.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

boards/arm/rpi_pico/rpi_pico-common.dtsi:119 code indent should use tabs where possible

Check warning on line 119 in boards/arm/rpi_pico/rpi_pico-common.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

boards/arm/rpi_pico/rpi_pico-common.dtsi:119 please, no spaces at the start of a line
};

&spi0 {
clock-frequency = <DT_FREQ_M(8)>;
status = "okay";
Expand Down Expand Up @@ -145,3 +152,5 @@ zephyr_udc0: &usbd {
};

pico_spi: &spi0 {};
pico_i2c0: &i2c0 {};
pico_i2c1: &i2c1 {};
8 changes: 8 additions & 0 deletions boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi
Expand Up @@ -24,6 +24,14 @@
};
};

i2c1_default: i2c1_default {
group1 {

Check failure on line 28 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:28 code indent should use tabs where possible

Check warning on line 28 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:28 please, no spaces at the start of a line
pinmux = <I2C1_SDA_P6>, <I2C1_SCL_P7>;

Check failure on line 29 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:29 code indent should use tabs where possible

Check warning on line 29 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:29 please, no spaces at the start of a line
input-enable;

Check failure on line 30 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:30 code indent should use tabs where possible

Check warning on line 30 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:30 please, no spaces at the start of a line
input-schmitt-enable;

Check failure on line 31 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:31 code indent should use tabs where possible

Check warning on line 31 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:31 please, no spaces at the start of a line
};

Check failure on line 32 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:32 code indent should use tabs where possible

Check warning on line 32 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:32 please, no spaces at the start of a line
};

Check failure on line 33 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:33 code indent should use tabs where possible

Check warning on line 33 in boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

boards/arm/rpi_pico/rpi_pico-pinctrl.dtsi:33 please, no spaces at the start of a line

spi0_default: spi0_default {
group1 {
pinmux = <SPI0_CSN_P17>, <SPI0_SCK_P18>, <SPI0_TX_P19>;
Expand Down
5 changes: 5 additions & 0 deletions boards/shields/waveshare_ups/Kconfig.shield
@@ -0,0 +1,5 @@
# Copyright (c) 2023 Joseph Yates
# SPDX-License-Identifier: Apache-2.0

config SHIELD_WAVESHARE_PICO_UPS_B
def_bool $(shields_list_contains,waveshare_pico_ups_b)
18 changes: 18 additions & 0 deletions boards/shields/waveshare_ups/boards/rpi_pico.overlay
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2023 Joseph Yates
*
* SPDX-License-Identifier: Apache-2.0
*/


&pinctrl {
i2c1_default: i2c1_default {
group1 {
bias-pull-up;
};
};
};

&pico_i2c1 {
status = "okay";
};
141 changes: 141 additions & 0 deletions boards/shields/waveshare_ups/doc/index.rst
@@ -0,0 +1,141 @@
.. _waveshare_pico_ups_b_shield:

Waveshare Pico UPS-B shield
#################################

Overview
***************************

The Waveshare Pico UPS-B shield is an uninterruptible Power supply (UPS)
module designed for the Raspberry Pi Pico which uses the Texas Instruments' INA219
current/power Monitor. It communicates with the Raspberry Pi Pico over I2C

.. figure:: waveshare_pico_ups_b.jpg
:align: center
:alt: Waveshare Pico UPS-B shield

Waveshare Pico UPS-B shield

Hardware
--------

- INA219

- Senses bus voltages from 0 to 26 V
- Reports current, voltage and power
- 16 Programmable Addresses
- SOT23-8 and SOIC-8 packages
- Calibration registers

- ETA6003

- Switching charger with power path management
- Up to 95% DC-DC efficiency
- 0mΩ power path MOSFET
- Up to 2.5A max charging current

- Connectivity

- Raspberry Pi Pico compatible (I2C)
- 2 pin jst header for Li-po battery

-------+-----------------------+---------------------------+
| Name | Function | Usage |
+=======+=======================+===========================+
| GP0 | None | |
+-------+-----------------------+---------------------------+
| GP1 | None | |
+-------+-----------------------+---------------------------+
| GP2 | None | |
+-------+-----------------------+---------------------------+
| GP3 | None | |
+-------+-----------------------+---------------------------+
| GP4 | None | |
+-------+-----------------------+---------------------------+
| GP5 | None | |
+-------+-----------------------+---------------------------+
| GP6 | I2C1_SDA ACTIVE_LOW | INA219 |
+-------+-----------------------+---------------------------+
| GP7 | I2C1_SCL ACTIVE_LOW | INA219 |
+-------+-----------------------+---------------------------+
| GP8 | None | |
+-------+-----------------------+---------------------------+
| GP9 | None | |
+-------+-----------------------+---------------------------+
| GP10 | None | |
+-------+-----------------------+---------------------------+
| GP11 | None | |
+-------+-----------------------+---------------------------+
| GP12 | None | |
+-------+-----------------------+---------------------------+
| GP13 | None | |
+-------+-----------------------+---------------------------+
| GP14 | None | |
+-------+-----------------------+---------------------------+
| GP15 | None | |
+-------+-----------------------+---------------------------+
| GP16 | None | |
+-------+-----------------------+---------------------------+
| GP17 | None | |
+-------+-----------------------+---------------------------+
| GP18 | None | |
+-------+-----------------------+---------------------------+
| GP19 | None | |
+-------+-----------------------+---------------------------+
| GP20 | None | |
+-------+-----------------------+---------------------------+
| GP21 | None | |
+-------+-----------------------+---------------------------+
| GP22 | None | |
+-------+-----------------------+---------------------------+
| GP23 | None | |
+-------+-----------------------+---------------------------+
| GP24 | None | |
+-------+-----------------------+---------------------------+
| GP25 | None | |
+-------+-----------------------+---------------------------+
| GP26 | None | |
+-------+-----------------------+---------------------------+
| GP27 | None | |
+-------+-----------------------+---------------------------+
| GP28 | None | |
+-------+-----------------------+---------------------------+


- Power Supply

- 3.3V ~ 5V

- Components

- Power switch
- Power LED
- Charging LED

For more information about the Waveshare Pico UPS-B:

- `Waveshare Pico UPS website`_
- `INA219 data sheet`_
- `ETA6003 data sheet`_

Programming
***********

Set ``-DSHIELD=waveshare_pico_ups_b`` when you invoke ``west build`` or ``cmake`` in your Zephyr application. For
example:

.. zephyr-app-commands::
:zephyr-app: samples/sensor/ina219
:tool: all
:board: rpi_pico
:shield: waveshare_pico_ups_b
:goals: build flash

.. _Waveshare Pico UPS website:
https://www.waveshare.com/wiki/Pico-UPS-B

.. _INA219 data sheet:
https://www.ti.com/lit/ds/symlink/ina219.pdf

.. _ETA6003 data sheet:
https://www.waveshare.com/w/upload/3/3f/ETA6003.pdf
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions boards/shields/waveshare_ups/waveshare_pico_ups_b.overlay
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2023 Joseph Yates
*
* SPDX-License-Identifier: Apache-2.0
*/

&pico_i2c1 {
waveshare_pico_ups: ina219@43 {
status = "okay";
compatible = "ti,ina219";
reg = <0x43>;
brng = <1>;
pg = <3>;
sadc = <12>;
badc = <12>;
shunt-milliohm = <100>;
lsb-microamp = <20>;
};
};

0 comments on commit 2ef7b08

Please sign in to comment.