diff --git a/CHANGELOG.md b/CHANGELOG.md index 05339c1fb..1c3e1b62f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added `esp:get_default_mac/0` for retrieving the default MAC address on ESP32. +- Added support for `pico` and `poci` as an alternative to `mosi` and `miso` for SPI ## [0.6.0-alpha.2] - 2023-12-10 diff --git a/libs/eavmlib/src/spi.erl b/libs/eavmlib/src/spi.erl index f7c5e711d..9021b62f1 100644 --- a/libs/eavmlib/src/spi.erl +++ b/libs/eavmlib/src/spi.erl @@ -330,14 +330,14 @@ migrate_deprecated(MaybeDeprecated) -> migrate_deprecated_iter(none, Accum) -> Accum; migrate_deprecated_iter({K, V, Iter}, Accum) -> - NewK = replace_key(K), - warn_deprecated(K, NewK), + {Status, NewK} = replace_key(K), + warn_deprecated(Status, K, NewK), migrate_deprecated_iter(maps:next(Iter), Accum#{NewK => V}). %% @private migrate_deprecated_fold({K, V}, Accum) -> - NewK = replace_key(K), - warn_deprecated(K, NewK), + {Status, NewK} = replace_key(K), + warn_deprecated(Status, K, NewK), [{NewK, V} | Accum]; migrate_deprecated_fold(E, Accum) -> [E | Accum]. @@ -345,19 +345,21 @@ migrate_deprecated_fold(E, Accum) -> %% @private replace_key(Key) -> case Key of - miso_io_num -> miso; - mosi_io_num -> mosi; - sclk_io_num -> sclk; - spi_cs_io_num -> cs; - spi_clock_hz -> clock_speed_hz; - spi_peripheral -> peripheral; - Any -> Any + pico -> {rename, mosi}; + poci -> {rename, miso}; + miso_io_num -> {warning, miso}; + mosi_io_num -> {warning, mosi}; + sclk_io_num -> {warning, sclk}; + spi_cs_io_num -> {warning, cs}; + spi_clock_hz -> {warning, clock_speed_hz}; + spi_peripheral -> {warning, peripheral}; + Any -> {ok, Any} end. -warn_deprecated(Key, Key) -> - ok; -warn_deprecated(OldKey, NewKey) -> - io:format("SPI: found deprecated ~p, use ~p instead!!!~n", [OldKey, NewKey]). +warn_deprecated(warning, OldKey, NewKey) -> + io:format("SPI: found deprecated ~p, use ~p instead!!!~n", [OldKey, NewKey]); +warn_deprecated(_Status, Key, Key) -> + ok. %% @private validate_integer_entry(Key, Map) ->