Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Higher level spi #158

Merged
merged 3 commits into from
Nov 26, 2018
Merged

Conversation

manuelbl
Copy link

As I've seen the pull request related to SPI initialization, I'd like to propose another change to the SPI hardware abstraction layer. Instead of the low-level API:

void hal_pin_nss (u1_t val);
u1_t hal_spi (u1_t outval);

introduce a higher-level API:

void hal_spi_write(u1_t cmd, const u1_t* buf, int len);
void hal_spi_read(u1_t cmd, u1_t* buf, int len);

The new API simplifies the code as the start and end of the SPI transactions are obvious and don't need to be indirectly derived from the NSS level. My TTN library for ESP-IDF would also profit as the ESP-IDF API for SPI is designed around entire SPI transactions.

Another benefit is that the code size of the new implementation decreases on all processors that I have tested (slightly at the expense of code readability). The RAM size stays exactly the same.

I cannot judge if there are many alternative HALs that this change will certainly break. If that's the case, feel free to reject the pull request.

@terrillmoore
Copy link
Member

Sorry, I've been very busy on another project. This seems like a reasonable idea, however we also need to initialize the HAL (thereby driving NSS inactive). This is issue #38 -- otherwise NSS drifts active, and the RFM95W responds to (interferes with) other devices on the bus. Anyway, I'll try to review this weekend.

@terrillmoore
Copy link
Member

@sjpark-mcci @svelmurugan92 (and others who have platforms that can run a quick test -- we need horizontal coverage) -- can we arrange to test this with the SAMD and STM32 ports? To check out this branch, you need to invent a local branch name, e.g. issue158 that doesn't exist yet in your repo. Then:

$ git checkout master # get to the main branch
$ git pull  # get all recent changes on master
$ git fetch origin pull/158/head:issue158  # get the changes for this pull to local branch issue158
$ git checkout issue158  # checkout the branch for the pull request.

Then build and make sure that TX and RX are working? Thanks!

@manuelbl
Copy link
Author

FYI: I've tested it with a ESP32 device and a blue pill (STM32F103).

@terrillmoore
Copy link
Member

Great. Just need to test on SAMD and (I hope) AVR, and we can accept it. MCCI will test on SAMD and STM32L0, but we have to get a volunteer to test on AVR.

@manuelbl
Copy link
Author

I've successfully tested it with an Arduino Pro mini clone (OTAA, TX, RX).

@svelmurugan92
Copy link

@terrillmoore We have tested on SAMD and STM32.
Results looks fine.

@terrillmoore
Copy link
Member

@manuelbl OK. This is a potentially-breaking change, so we'll need to bump the version to V3. As it happens, for TCXO support #95 , I'm making enough changes that it's got to be V3 anyway (even though I don't think it's breaking, there are enough differences that it makes sense to go to V3). Will process this this week.

@cyberman54
Copy link

May i ask on status of this pr? Could really need it.

@terrillmoore
Copy link
Member

@cyberman54 It's close to top of my list. We have a couple of new boards that need the fixes from #95, and it's been tedious digging through all various layers. I may be able to get to it today. Sorry for the delay.

@terrillmoore
Copy link
Member

@manuelbl I'm going to touch this up a bit and commit it.

terrillmoore added a commit that referenced this pull request Nov 26, 2018
terrillmoore added a commit that referenced this pull request Nov 26, 2018
@terrillmoore terrillmoore merged commit 5f86cb1 into mcci-catena:master Nov 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants