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

Implement UART for sercom #1

Closed
wants to merge 11 commits into from
Closed

Conversation

zklapow
Copy link
Contributor

@zklapow zklapow commented Jun 14, 2018

This adds structs and corresponding serial::{Read, Write} impls for a UART on each sercom.

This works as is but needs some improvement to fully support all the features available on the samd21. Currently this is:

  • Only asynchronous
  • Only Arithmetic baud mode is supported
  • Only 8N1
  • Both TX/RX are always on

@wez

@wez wez self-requested a review June 14, 2018 14:59
@wez
Copy link
Member

wez commented Jun 14, 2018

Many thanks for this! I'll have some time to properly review on saturday.
Hmm, looks like the travis CI bits might need updating for more recent changes in rust.

@zklapow
Copy link
Contributor Author

zklapow commented Jun 14, 2018

👌 thanks @wez I'll probably update this a bit this weekend as well so no rush, at the very least I want to add a UART example but I need to clean up some of my code.

@zklapow
Copy link
Contributor Author

zklapow commented Jun 19, 2018

I also pinned the nightly version to 2018-05-16 (which was the version I was developing on) to fix some the upstream build issues. I was able to fix the panic_implementation errors by upgrading panic-abort but then got a bunch of proc-macro issues which seem to need upstream changes to get merged in cortex-m-rtfm so I just went with rolling back nightly.

@zklapow
Copy link
Contributor Author

zklapow commented Jul 2, 2018

@wez any chance you've had some time to take a look at this?

@wez
Copy link
Member

wez commented Jul 8, 2018

@zklapow sorry for not getting back to you already; I'll look at this tomorrow!

@djmcgill
Copy link
Contributor

djmcgill commented Jul 14, 2018

I've been using this branch, seems to be okay on a samd21g18a. Is there a reason that core::fmt::Write isn't implemented for the blocking variant*? Without it I was having a pretty tough time printing numbers and hex values and so on.

The version which I'm using is (the struct is only there to get around the orphan issue):

struct BlockingWrite<W>(W) where W: hal::blocking::serial::Write<u8>;
impl<W: hal::blocking::serial::Write<u8>> core::fmt::Write for BlockingWrite<W> {
    fn write_str(&mut self, s: &str) -> core::fmt::Result {
        match self.0.bwrite_all(s.as_bytes()) {
            Ok(()) => Ok(()),
            Err(_) => Err(core::fmt::Error),
        }
    }
}

*: since core::fmt::Result can't contain WouldBlock I don't think it's possible to do a non-blocking version of this.

@zklapow
Copy link
Contributor Author

zklapow commented Jul 15, 2018

@djmcgill glad its working for you! I actually had a commit with implemented the core::fmt side of things that I just forgot to push, should be there now. I think I managed to avoid the intermediate struct by moving some imports around.

@wez
Copy link
Member

wez commented Aug 23, 2018

Sorry for the long lag in reviewing; this looks great and I've pushed it to master! Many thanks!

@wez wez closed this Aug 23, 2018
jacobrosenthal added a commit to jacobrosenthal/atsamd that referenced this pull request Jan 20, 2020
sajattack pushed a commit that referenced this pull request Jan 21, 2020
…nd USB reset (#154)

* samd51 UsbBus: Fix interrupts not enabling & missing events around bus reset

Fixes #105.

* Only clear endpoint _bank ready_ bit during configuration/protocol-reset

* Pair programmin jammin (#1)

Co-authored-by: Jacob Rosenthal <[email protected]>

* Cleanup ep init logic & improve comments.

Co-authored-by: Jacob Rosenthal <[email protected]>

* Bump HAL version

* cleanup rxstp interrupts
Co-authored-by: Jacob Rosenthal <[email protected]>

* Remove unnecessary handling of trfail status in poll

Co-authored-by: Jacob Rosenthal <[email protected]>

Co-authored-by: Jacob Rosenthal <[email protected]>
sajattack pushed a commit that referenced this pull request Jan 23, 2020
…155)

* samd51 UsbBus: Fix interrupts not enabling & missing events around bus reset

Fixes #105.

* Only clear endpoint _bank ready_ bit during configuration/protocol-reset

* Pair programmin jammin (#1)

Co-authored-by: Jacob Rosenthal <[email protected]>

* Cleanup ep init logic & improve comments.

Co-authored-by: Jacob Rosenthal <[email protected]>

* Bump HAL version

* cleanup rxstp interrupts
Co-authored-by: Jacob Rosenthal <[email protected]>

* Remove unnecessary handling of trfail status in poll

Co-authored-by: Jacob Rosenthal <[email protected]>

* WIP getting USB working on samd21

* samd21 UsbBus: Fix implementation & get itsybitsy_m0 example working

* Bump crate versions

* Remove dangling reference to uart_debug

Co-authored-by: Jacob Rosenthal <[email protected]>
sajattack pushed a commit that referenced this pull request Jun 9, 2021
* Refactored method of enabling interrupts.
Added 'static bounds to Transfer::new

* Removed the need to pass &mut DmaController references to DMA Channels and Transfers

* Added waker to Transfers

* Waker is now ZST by default

* Read/write proxy for DMA channel registers

* Refactored DMAC register proxys macro

* Finish callback implementation

Track a DMAC Transfer's completed status.

* Begin implementing DMA enabled SPI transfers for atsamd11/atsamd21

* Some interrupt stuff, Transfer::recycle() (#1)

* Extend the API around DMAC interrupts

* Fix in DMAC Buffer::dma_ptr() documentation

* Introduce DmacError enum

* Add DMAC Transfer::recycle()

* Fix some CI issues

* Fix DMA SPI transfers according to the new Pads API

* DmaController::free takes back ownership of the Channels struct

* Improve documentation

* rustfmt

* Add single-buffer recycle methods

Transfers can now be recycled on either source, destination, or both.

* Added missing #[inline] attributes

* Now with lock-free with_chid!

* DMA-enabled SPI transfers for thumbv7em targets

* Added module-level docs for SPI/DMA transfers

Co-authored-by: Ian <[email protected]>
kaizensparc pushed a commit to kaizensparc/atsamd that referenced this pull request Dec 24, 2021
…nd USB reset (atsamd-rs#154)

* samd51 UsbBus: Fix interrupts not enabling & missing events around bus reset

Fixes atsamd-rs#105.

* Only clear endpoint _bank ready_ bit during configuration/protocol-reset

* Pair programmin jammin (atsamd-rs#1)

Co-authored-by: Jacob Rosenthal <[email protected]>

* Cleanup ep init logic & improve comments.

Co-authored-by: Jacob Rosenthal <[email protected]>

* Bump HAL version

* cleanup rxstp interrupts
Co-authored-by: Jacob Rosenthal <[email protected]>

* Remove unnecessary handling of trfail status in poll

Co-authored-by: Jacob Rosenthal <[email protected]>

Co-authored-by: Jacob Rosenthal <[email protected]>
kaizensparc pushed a commit to kaizensparc/atsamd that referenced this pull request Dec 24, 2021
…tsamd-rs#155)

* samd51 UsbBus: Fix interrupts not enabling & missing events around bus reset

Fixes atsamd-rs#105.

* Only clear endpoint _bank ready_ bit during configuration/protocol-reset

* Pair programmin jammin (atsamd-rs#1)

Co-authored-by: Jacob Rosenthal <[email protected]>

* Cleanup ep init logic & improve comments.

Co-authored-by: Jacob Rosenthal <[email protected]>

* Bump HAL version

* cleanup rxstp interrupts
Co-authored-by: Jacob Rosenthal <[email protected]>

* Remove unnecessary handling of trfail status in poll

Co-authored-by: Jacob Rosenthal <[email protected]>

* WIP getting USB working on samd21

* samd21 UsbBus: Fix implementation & get itsybitsy_m0 example working

* Bump crate versions

* Remove dangling reference to uart_debug

Co-authored-by: Jacob Rosenthal <[email protected]>
kaizensparc pushed a commit to kaizensparc/atsamd that referenced this pull request Dec 24, 2021
* Refactored method of enabling interrupts.
Added 'static bounds to Transfer::new

* Removed the need to pass &mut DmaController references to DMA Channels and Transfers

* Added waker to Transfers

* Waker is now ZST by default

* Read/write proxy for DMA channel registers

* Refactored DMAC register proxys macro

* Finish callback implementation

Track a DMAC Transfer's completed status.

* Begin implementing DMA enabled SPI transfers for atsamd11/atsamd21

* Some interrupt stuff, Transfer::recycle() (atsamd-rs#1)

* Extend the API around DMAC interrupts

* Fix in DMAC Buffer::dma_ptr() documentation

* Introduce DmacError enum

* Add DMAC Transfer::recycle()

* Fix some CI issues

* Fix DMA SPI transfers according to the new Pads API

* DmaController::free takes back ownership of the Channels struct

* Improve documentation

* rustfmt

* Add single-buffer recycle methods

Transfers can now be recycled on either source, destination, or both.

* Added missing #[inline] attributes

* Now with lock-free with_chid!

* DMA-enabled SPI transfers for thumbv7em targets

* Added module-level docs for SPI/DMA transfers

Co-authored-by: Ian <[email protected]>
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.

3 participants