[riot-notifications] [RIOT-OS/RIOT] cpu/sam0_common/spi: demux SPI output pins before entering deep sleep (#14105)

Juergen Fitschen notifications at github.com
Wed May 20 14:43:04 CEST 2020

The RIOT community cares a lot about code quality.
Therefore, before describing what your contribution is about, we would like
you to make sure that your modifications are compliant with the RIOT
coding conventions, see https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions.

### Contribution description

The output pins of `periph_spi` becomes HIGH-Z when entering a deep sleep power mode. 

If no external pull resistors are present, this will lead to undefined voltage levels and will create unwanted current draw by connected SPI slaves.
This can be observed with the `samr30` CPU as it has a sub-GHz transceiver inside its package that disables its pull resistor once it has been initialized.

### Testing procedure

Grab a `samr30-xpro` board and observe the current draw of the board with `examples/default`:

$ make BOARD=samr30-xpro flash term
2020-05-20 14:25:40,931 # main(): This is RIOT! (Version: 2020.04-devel-2669-g03322-fix/sam0_spi_deep-sleep)
2020-05-20 14:25:40,932 # Welcome to RIOT!
> ifconfig 4 set state SLEEP
2020-05-20 14:25:55,728 #  ifconfig 4 set state SLEEP
2020-05-20 14:25:55,732 # success: set state of interface 4 to SLEEP
> pm set 1
2020-05-20 14:26:03,830 #  pm set 1
2020-05-20 14:26:03,833 # CPU is entering power mode 1.
2020-05-20 14:26:03,836 # Now waiting for a wakeup event...

Without this patch, the board draws ~600uA. With this patch, it drops down to ~4uA.

If you want to test it with another `sam0_common`-based board, call `pm set 1` and try to pull the SPI pins with a resistor to VCC and GND. If this works, you verified these pins to be HIGH-Z.

You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * cpu/sam0_common/spi: demux out pins before entering deep sleep

-- File Changes --

    M cpu/sam0_common/include/periph_cpu_common.h (22)
    M cpu/sam0_common/periph/spi.c (22)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200520/67ba1e14/attachment-0001.htm>

More information about the notifications mailing list