The type spec for spi config is incorrect

Open Beginner friendly
#2,435 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
67/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
erlang
Domain
embedded-iot

Research direction

Read the SPI config typespec in libs/avm_esp32/src/spi.erl and compare it with the driver behavior described in the issue. Check how pin values are passed down and whether -1 is used for an undefined pin. Update the accepted representation so undefined pins work, then confirm the config typing and runtime behavior agree.

Written by the indexing model from the issue text.

Description

The typespec enforces for the spi configs (like the pins) a non_negative_integer: https://github.com/atomvm/AtomVM/blob/main/libs/avm_esp32/src/spi.erl#L49

Everything down to the driver does allow -1
The driver even uses it as undefined.

Therefore we should allow -1 as undefined (pin) (or translate :undefined to -1 when passing it down to the driver

Dominant language
Erlang
Stars
2.3k
Forks
171
Avg merge
4d 11h
Merged PRs (30d)
20

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from atomvm/AtomVM

All issues in atomvm/AtomVM

Similar issues

More Embedded & IoT issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.