Commit graph

461 commits

Author SHA1 Message Date
Jan Niehusmann a9763837a9 Add comment regarding release mode 2022-01-28 22:18:32 +00:00
Jan Niehusmann f6b2e3365e use dht-sensor crate and fix comments 2022-01-28 21:36:30 +00:00
Jan Niehusmann bb6b7706f9 Add dht11 example 2022-01-28 19:44:26 +00:00
Jonathan Pallant 5771f872f2
Merge pull request #269 from 9names/fix_uart_example_clock
Use .freq() to avoid moving clock
2022-01-28 15:03:23 +00:00
Wilfried Chauveau d08bfac989 Fix i2c peripheral mode state machine
The start_det flag is set as soon as a start condition occurs
whereas rd_req flag is only set once the address byte is received.
2022-01-29 00:01:32 +11:00
Derek Hageman f279945315 Add intrinsics for the hardware divider
Implement intrinsic functions so basic operators use the hardware divider.
2022-01-26 19:37:06 -07:00
Derek Hageman 35704d9799 Change divider delay to explicit NOPs
Use explicit NOPs since cortex_m::asm::delay actually delays for
longer than we need to.
2022-01-26 19:37:06 -07:00
Derek Hageman c2d3b21d91 Make hardware divisor interrupt safe
Copy the pico-sdk logic for save and restore of the hardware divider
for making it interrupt safe.
2022-01-26 19:37:06 -07:00
9names 57e9943836 Set hw reset bits for watchdog 2022-01-20 21:55:16 +11:00
9names c8b75204ee Use .freq() to avoid moving clock 2022-01-20 18:28:51 +11:00
Victor Koenders d6e3c7b615
Set the uart config default baud rate to 115200 2022-01-18 17:28:13 +01:00
Victor Koenders b3b4d9ff6f
Fixed doc test 2022-01-18 11:32:48 +01:00
Victor Koenders 9e75cec551
Added impl Default for UartConfig 2022-01-18 11:17:01 +01:00
Wilfried Chauveau 7840d0f833 embassy-traits: Fix unexpected restart on repeated read. 2022-01-13 19:28:23 +11:00
Jonathan 'theJPster' Pallant d3c9c3b4e2
Merge pull request #263 from WeirdConstructor/fix_alarm_schedule_race_cond
Fix alarm schedule race condition
2022-01-12 20:07:59 +00:00
Weird Constructor 7a23247ca1 Fix alarm schedule() race condition. 2022-01-12 06:41:03 +01:00
Weird Constructor a7b71bd5aa Fix compilation bug in the documentation 2022-01-09 15:16:01 +01:00
Weird Constructor 9e84c961a8 (Hopefully) Improved documentation of bsp_pins!() 2022-01-09 13:50:57 +01:00
Jonathan 'theJPster' Pallant f23ababb1a
Merge pull request #197 from chinoto/pio_sound_send
pio: Fix unsound Send clippy warning
2022-01-06 12:57:26 +00:00
Jonathan 'theJPster' Pallant 43650b3248
Merge pull request #248 from jannic/bump-versions
Bump versions of HAL and BSPs
2021-12-27 11:00:31 +00:00
Jonathan Pallant 67d9da85e6 Fix docs for SerialInfallible. 2021-12-26 20:57:04 +00:00
Jonathan Pallant 55acbdb1b0 Fix build errors in eh_1.0 mode. 2021-12-26 20:56:48 +00:00
Jan Niehusmann 2f9a950cbe Bump versions of HAL and BSPs
The change to UartPeripheral in #210 was a breaking change:
Bump the version of the HAL and all dependent BSP crates.
2021-12-26 19:52:04 +00:00
Jonathan Pallant 7da16a726f Fixing typos spotted in the review. 2021-12-26 19:39:16 +00:00
Jonathan Pallant (Ferrous Systems) d3bd232885 Added two UART IRQ examples.
They are in the pico BSP as they need the 'rt' feature. Also includes
changes to the UART driver for enabling/disabling interrupts.
2021-12-26 19:33:23 +00:00
Victor Koenders 8f63be0f22
Fixed failing doctest 2021-12-25 09:49:32 +01:00
Victor Koenders 86444448a4
Migrated examples to the new uart system 2021-12-25 09:46:40 +01:00
Victor Koenders c41c273131
Added reader/writer split to UartPeripheral 2021-12-25 09:46:38 +01:00
Victor Koenders 84b8fb05b0
Fixed compile errors on eh1_0_alpha feature 2021-12-25 09:46:34 +01:00
Victor Koenders a8a27672b8
Constraint the uart::pin:: traits to UartDevice 2021-12-25 09:45:57 +01:00
Victor Koenders a4a0bcf987
Added pins to the uart constructor functions 2021-12-25 09:45:54 +01:00
Victor Koenders bdfb4d82c9
Split uart in separate files, introduced a typesystem constraint for valid UART pin configurations 2021-12-25 09:45:45 +01:00
Jonathan Pallant 4959afe151 Include manufacturer in BSP crate name.
Avoids ambiguity.
2021-12-20 21:28:00 +00:00
Jonathan Pallant 7278c36e93 Add MSRV 2021-12-20 20:05:40 +00:00
Jonathan Pallant 96c2273dce Noted 0.3.0 includes many bug fixes. 2021-12-20 19:53:15 +00:00
Jonathan Pallant 5701ab431f Revised CHANGELOG.
Added extra items to 0.3.0.
Reformatted 0.2.0 entry.
2021-12-20 19:52:31 +00:00
Jonathan Pallant bebf85d4d9 Set up for 0.3.0 release.
Somehow we already had a bunch of commits talking about 0.3.0, but it
was never released. Hence why this maybe doesn't change as many version
numbers as you might expect.
2021-12-19 19:22:15 +00:00
Jonathan Pallant a9f6ab8de4 Comment out embassy traits.
The git dep prevents us from publishing, rp2040-hal, and embassy
aren't doing a release any time soon.
2021-12-18 19:09:37 +00:00
Jonathan 'theJPster' Pallant 53d9dbdf52
Update to pio-rs v0.1.0 (#239)
* Update to PIO 0.1.0

* Update to latest ws2812-pio and i2c-pio.

These depend on pio 0.1.0, avoiding a conflict

* Rename CI tests.

Also check we can cargo build. And remove 'on host tests' that didn't
do anything.

Co-authored-by: Jonathan Pallant <jonathan.pallant@42technology.com>
2021-12-14 10:52:32 +11:00
Pedro Ferreira 24a417f01a
Make fields in UartConfig public (#233)
Otherwise it's impossible to have a configuration which differs from the provided default options.
2021-12-14 10:47:35 +11:00
9names 427344667e
Add basic multicore FIFO example (#226)
* Add basic multicore fifo example

* Add documentation for multicore

* Send system_clock frequency to core1 over FIFO in example

* Add Stack::new() to HAL. Use Stack::new() in example
2021-12-08 19:34:39 +11:00
Jonathan 'theJPster' Pallant 539f6db0f7
Merge pull request #231 from ithinuel/bump-embassy
Bump embassy's dependencies
2021-12-05 18:03:03 +00:00
Jonathan 'theJPster' Pallant b94a5ab885
Merge pull request #232 from jannic/refactor-uart-init
Refactor uart init
2021-12-05 18:02:44 +00:00
Wilfried Chauveau fee8881801
bump embassy's dependencies 2021-12-05 12:39:25 +00:00
Jan Niehusmann b380b3ddf6 Reset UART in new() 2021-12-05 07:05:12 +00:00
9names 422da14e19
Merge branch 'main' into reexport_mod_structs 2021-12-05 01:04:08 +11:00
9names 0e7abdc705
Make BSPs provide boot2 as a default feature (#153)
* Add boot2 feature. Add boot2 linkage into each BSP optional on feature

* Enable boot2 feature in BSPs by default. Remove boot2 decl from all BSP examples

* Add EXTERN in memory.x for BOOT2_FIRMWARE, rename bootloader static slice to BOOT2_FIRMWARE

* Update new examples and itsy_bitsy BSP to use boot2 feature

* Remove boot2 as a dev-dependency for the BSPs, no longer needed

* Add no_mangle BOOT2_FIRMWARE to adafruit_macropad

* Fix itsy-bitsy blinky - it wasn't using the BSP, so it didn't get BOOT2_FIRMWARE linked in
2021-12-05 01:00:09 +11:00
9names dc8ceffd09 Move uses of sio::Sio to Sio 2021-12-04 16:20:27 +11:00
9names 11aa0b87af Cargo fmt 2021-12-04 15:38:25 +11:00
Jan Niehusmann 26fa532fa3 Refactor Uart initialization 2021-12-03 21:24:50 +00:00
9names 33ff337631
Merge branch 'rp-rs:main' into reexport_mod_structs 2021-12-04 00:43:14 +11:00
9names 6ab9cd7ed3 Generate sev in sio.fifo.write() 2021-12-04 00:42:46 +11:00
9names 55a8b4acf9 Re-export mod structs 2021-12-04 00:04:45 +11:00
9names a7d5dc2bee Add safety docs from atsamd-rs to GPIO traits 2021-12-03 23:42:45 +11:00
Gus Caplan 5dafe3985f use user-provided stack for core 1
Fixes: https://github.com/rp-rs/rp-hal/issues/218
2021-12-03 20:24:53 +11:00
9names d84e641390
Add simple interrupt_disable+spinlock critical-section impl (#151)
* Add basic interrupt_disable+spinlock critical-section

* Update impl based on feedback from jannic

* Get rid of count variable, switch to AtomicU8 for lock state

* Remove interrupt::disable that isn't necessary for safety

* Rename variables, re-write most of the comments

* Add fences to ensure ordering
2021-12-02 00:03:41 +11:00
devsnek e1f99443d9
multicore (#89)
mvp multicore implementation

Co-authored-by: Jan Niehusmann <jan@gondor.com>
2021-12-01 23:52:53 +11:00
Trangar f68f148d12
Added RtcClock DateTime and alarms (#213)
* Added RealTimeClock, DateTime and RTC alarms

* Improved documentation on weird behaviors in the RealTimeClock

* Fixed incorrect leap_year_check in RealTimeClock

* Fixed rtc-datetime PR feedback
2021-11-29 21:15:20 +11:00
Jonathan 'theJPster' Pallant fad1dfa259
Merge pull request #191 from jannic/rename-set_instruction
Rename set_instruction to exec_instruction
2021-11-25 19:08:13 +00:00
Jonathan 'theJPster' Pallant 3a3280575f
Merge pull request #204 from rp-rs/add_sio_fifo
Add SIO FIFO
2021-11-25 19:05:40 +00:00
Jan Niehusmann bb8531445e Fix fmt
Thats what happens when editing files directly on github...
2021-11-25 16:44:57 +00:00
Jan Niehusmann 15c162757f
Update docs in rp2040-hal/src/pio.rs
Co-authored-by: Wilfried Chauveau <wilfried.chauveau@ithinuel.me>
2021-11-25 17:38:18 +01:00
Jonathan Pallant (Ferrous Systems) 69255f7b8c Fix wfe/sev semantics.
We must sev on write, so the other core can wfe on read.
2021-11-25 15:14:03 +00:00
Jonathan Pallant (Ferrous Systems) e9694bbb91 Use released 0.2.0 PAC. 2021-11-25 14:45:28 +00:00
Jonathan Pallant ed860ed106
Merge pull request #208 from VictorKoenders/spinlock
Added spinlocks
2021-11-25 14:44:46 +00:00
Jonathan Pallant 968e49aa03
Merge pull request #198 from VictorKoenders/alarm
Added timer alarms
2021-11-25 14:33:06 +00:00
Jonathan Pallant 292a6f13c8
Merge pull request #205 from jannic/eh-1_alpha6
Update eh1_0_alpha feature for embedded-hal 1.0.0-alpha.6
2021-11-25 14:30:02 +00:00
Victor Koenders 111b355da2
Fixed error in spinlock's documentation 2021-11-24 11:59:43 +01:00
Victor Koenders 88fbc38f8b
Added spinlocks 2021-11-24 08:19:42 +01:00
Victor Koenders a9d96f352e
Removed incorret unsafe impl Sync, added interrupt_free around obtaining an alarm 2021-11-24 07:41:04 +01:00
Victor Koenders 1fd04d3384
Made the alarmX take exclusive ownership of Timer on functions that could cause UB when run in parallel 2021-11-24 07:41:03 +01:00
Victor Koenders 97a5bd355c
Added AlarmX::disable_interrupt, made AlarmX::schedule able to return an error if the time is too short 2021-11-24 07:41:00 +01:00
Victor Koenders 119c5a94e8
Added timer alarms 2021-11-24 07:40:56 +01:00
Damian J Pound c7c5fb00d8 pio: Fix unsound Send clippy warning 2021-11-21 22:32:22 -06:00
Jan Niehusmann 3ab84702b7 Update comments 2021-11-21 13:16:03 +00:00
Jan Niehusmann 9a018ac359 Update uart implementation of embedded-hal 1.x to 1.0.0-alpha.6 2021-11-19 22:46:55 +00:00
Jan Niehusmann 1294f556e9 Update SPI implementation of embedded-hal 1.x to 1.0.0-alpha.6 2021-11-19 22:46:55 +00:00
Jonathan Pallant 68602fa6e1 0.1.6 had breaking changes, so I yanked it and made 0.2.0. 2021-11-19 22:30:43 +00:00
Jonathan Pallant 84b903b12a PAC 0.1.6 is now released. 2021-11-19 22:22:29 +00:00
Jan Niehusmann 0f3bb8e88c Update I2C implementation of embedded-hal 1.x to 1.0.0-alpha.6 2021-11-19 21:41:45 +00:00
Jan Niehusmann 76aff05cec Update dependency on embedded-hal 1.x to 1.0.0-alpha.6 2021-11-19 21:41:00 +00:00
Jonathan Pallant 038f792e21 Apply clippy's suggestions. 2021-11-19 17:38:32 +00:00
Jonathan Pallant 68014469dd Add SIO FIFO interface. 2021-11-19 17:19:04 +00:00
Jonathan Pallant 23bafb6980 Point at PAC release branch. 2021-11-19 12:22:52 +00:00
Jonathan Pallant 0a082c0f03 Changes to work with upcoming PAC 0.16. 2021-11-19 12:16:50 +00:00
Jan Niehusmann aafa3dd587 Keep old function as a deprecated alternative, for now
Mainly so i2c-pio-rs doesn't fail, as it is used by examples.
Should be removed once i2c-pio-rs is updated.
2021-11-16 22:27:08 +00:00
Jan Niehusmann 3756cd2fb5 Rename set_instruction to exec_instruction 2021-11-16 22:27:08 +00:00
Jonathan Pallant b9497d9b82 Resolve review comments.
Adds same functions to RX FIFO.
2021-11-16 21:45:52 +00:00
Jonathan Pallant 5c1bcd2604 Adds some useful functions when using PIO FIFOs with DMA. 2021-11-16 19:18:32 +00:00
contradict f9b3d8341d
Document properties needed for PIO Send safety (#190)
Start to address #186 (Safety requirement must be verbosely advertised to not be overlooked in future changes).

#177 (Mark PIO StateMachine, Rx and Tx as Send) added the Send trait to StateMachine, Tx and Rx, That documentation was expanded as suggested.

PIO, UninitStateMachine, Interrupt were marked Send before #177, added some documentation to those as well.
2021-11-10 21:55:37 +11:00
Wilfried Chauveau 620d5f0e0c
Use the PIOn peripherals in pin functions rather than creating an enum. (#193)
This allows the `FuncionPio?` to be inferred from the `pac::PIO?` used.
This change shall be transparent for anyone using the `FunctionPio?` aliases.
2021-11-10 21:27:46 +11:00
Wilfried Chauveau 990d964a93
Implement peripheral support for i2c and an advanced example (#162)
* Implement peripheral support for i2c and an advanced example for the pico board.

* Simplify i2c peripheral bootstrap and add a "free" function to allow switching modes.

* Set dependency to futures & nostd_async to specific version/revision.

* move enum & struct to the start of the file

* Add a bit of documentation to the pico_i2c_controller_peripheral demo.

* Migrate to pico_i2c_controller_peripheral to embassy & simplify the peripheral support

nostd_async is broken since last stable roll out.
The pico_i2c_controller_peripheral is being migrated to use embassy's executor.
The Controller Async API is now aligned with embassy's traits to facilitate integration.

The peripheral no longer require async to run and now appears as an event iterator.

Embassy's support relies on unstable features (generic_associated_types and type_alias_impl_traits)
and is therefore gated behind the `embassy-traits` feature flag.

* make futures & embassy optional for the pico board too

* Pin embassy to a specific rev.

* Impl embassy_traits::i2c::WriteIter & enable unlimited transfer size on i2c

* Applies comment suggestion from @9names for the advanced i2c example.

Co-authored-by: 9names <60134748+9names@users.noreply.github.com>

* use `I2C block` instead of `IP`.

* Fix formatting (unnecessary space at end of line)

* Enhance explanation for why `rd_req()`  is not cleared in `Iterator::next`'s
implementation.

Co-authored-by: 9names <60134748+9names@users.noreply.github.com>
2021-11-08 23:23:28 +11:00
Benno 6d917f498e
Change UART raw read return type and fix full read (#189)
* UART read_raw returns bytes read

This also fixed broken read_full_blocking code.

* chang documentation to reflect return value change
2021-11-01 10:24:24 +11:00
contradict fb69308058 Add methods to set and clear the PWM Interrupt force register. 2021-10-30 20:40:33 +11:00
Jan Niehusmann b1dc9aec8c Fix UART init code
Set uartlcr_h before enabling the UART.
Writing uartlcr_h while the UART is enabled is forbidden by the datasheet.

Details can be found here:
https://developer.arm.com/documentation/ddi0183/g/programmers-model/register-descriptions/line-control-register--uartlcr-h?lang=en
(As referenced from the Datasheet)
2021-10-30 10:19:13 +11:00
Jan Niehusmann 73431a847b
fix UART rx (#187) 2021-10-30 10:16:43 +11:00
contradict fe1e55b8c0
Mark PIO StateMachine, Rx and Tx as Send (#177)
* Mark PIO StateMachine, Rx and Tx as Send

* Improve comment grammar.

Co-authored-by: Wilfried Chauveau <wilfried.chauveau@ithinuel.me>
2021-10-27 21:34:08 +11:00
Wilfried Chauveau 73e2c6921f Make ReadableOutput public to match the visibility of other Type-level variant of PinMode. 2021-10-27 21:32:38 +11:00
Jan Niehusmann 9f55608f92 Correct limit for PIOBuilder::out_pins count argument
This value is written to the PINCTRL register field
OUT_COUNT, which accoding to the data sheet has a valid range
of 0-32.

Fixes #181
2021-10-23 13:34:05 +00:00
contradict 11aaf9be79
API to enable/disable interrupts for each PWM channel. (#175)
* API to enable/disable interrupts for each PWM channel.

* Better name for overflow check.
2021-10-23 22:47:08 +11:00
contradict 97079489ef Mark Timer as sync
Since all accesses are read-only there is no synchronizing to be done.
2021-10-23 00:03:30 +11:00
Jan Niehusmann 4c4d12e23c minor docs improvements in pio.rs 2021-10-22 23:52:14 +11:00
Jan Niehusmann bac6714f09
Use volatile register access for gpio interrupts (#170)
* Use volatile register access for gpio interrupts

* Provide functions for atomic register updates

* Use atomic register access functions in pio.rs

* Improve doc comments

* Limit visibility of atomic register access functions

Also remove write_xor for now, as it's not yet used anywhere
2021-10-22 23:30:30 +11:00
Wilfried Chauveau 0eb65ee99b
Add PIO features required for PIO as I2C support (#179)
* Implements methods to allow presetting the pin state & direction

Enabling those methods allows to save a few valuable instructions
in the PIO's memory.

* Use IntoIterator rather than Iterator.

* Use proper types instead of bool to be more idiomatic.

* Change set_pindirs_with_mask to a more idiomatic rust approach.

* Update pio_proc_blink with new set_pindirs_with_iter

* Force reset on startup to guaranty consistency with type-states.

* Expose more accessors to allow more advanced driver to be implemented.

* Add the ability to restart the state machine from its wrap point.

This method also clears the ISR/OSR to give the state machine a clean
restart.

* Add a comment about the impact of autopull on OUT & PULL instructions

* Fix broken internal doc reference & add an important note on Tx<SM>::has_stalled

* rename block methods to register_block.

This change is made to avoid confusion with "block" as a verb.
2021-10-22 22:09:10 +11:00
Wilfried Chauveau 2eb7923ebe
Implements methods to allow presetting the pin state & direction (#167)
* Implements methods to allow presetting the pin state & direction

Enabling those methods allows to save a few valuable instructions
in the PIO's memory.

* Update pio_proc_blink with new set_pindirs
2021-10-22 21:13:22 +11:00
Jonathan Pallant (42 Technology) e48323c983 Ah, missed one after the rebase. 2021-10-18 10:58:38 +01:00
Jonathan Pallant (42 Technology) 8e66ddcfb1 Switch to new rp2040-boot2 crate. 2021-10-18 10:53:17 +01:00
Rich Lane c8bb2e43c7 spi: support zero post-divide
This allows you to use a 62.5 MHz SPI baud rate assuming the default 125
MHz peripheral clock. It would previously crash due to a division by
zero.
2021-10-17 21:38:53 +11:00
Jonathan Pallant (42 Technology) 6a4a4fd247 Formatting. 2021-10-11 16:41:51 +01:00
Jonathan Pallant (42 Technology) 74ea262f65 Cleaning up the comment summaries. 2021-10-11 16:40:23 +01:00
Jonathan Pallant (42 Technology) 2423e42eb9 Clean up comments. 2021-10-11 16:39:12 +01:00
Jonathan Pallant (42 Technology) 5c55af76d2 Typo 2021-10-11 16:37:50 +01:00
Jonathan Pallant (42 Technology) e1afb70bd2 Moved float and double functions into modules.
Makes the docs cleaner.
2021-10-11 16:37:16 +01:00
Jonathan Pallant (42 Technology) ae66ac4cb6 Tweak doc comments. 2021-10-11 16:22:35 +01:00
Jonathan Pallant (42 Technology) 64207a62e5 Add comment to calc_delta function as it's non-obvious. 2021-10-11 16:22:11 +01:00
Jonathan Pallant (42 Technology) f56369e1c7 Add example which uses the ROM functions 2021-10-11 15:45:44 +01:00
Jonathan Pallant (42 Technology) 7a05b8f3a7 Fix the ROM function table code.
The floating point table lookup was incorrect.
2021-10-11 15:45:34 +01:00
9names a0740a5ac3
Merge pull request #147 from Lichtso/feature/gpio_interrupt
Add GPIO interrupt configuration functions
2021-10-07 09:52:21 +11:00
9names f92c9900cf
Merge pull request #152 from anall/feature/rom_data_unsafe_reapply
split rom_data into safe and unsafe functions (reapply due to inadvertent revert)
2021-10-07 09:40:57 +11:00
Jan Niehusmann e63f1f6dee Make pio-proc a dev-dependency
It's only used in an example, so it doesn't need to be a regular
dependency.
2021-10-07 09:39:08 +11:00
Andrea Nall dab619d627 split rom_data into safe and unsafe functions
This was originally applied in 71a7057b76
and got inadvertently reverted as part of e3be4f8025
2021-10-02 11:22:32 -05:00
Jan Niehusmann ad68c9d696
Fix i2c write read (#146)
* i2c write_read: don't continue with read if write aborted

* i2c write_read: use correct length of read buffer
2021-10-02 17:43:05 +10:00
9names ede25a4f15
Merge pull request #143 from mgottschlag/pio-rework
Rework the PIO API
2021-10-02 16:41:38 +10:00
Alexander Meißner 90470b6ff3
Adds reset for timer, otherwise it would not run. (#136) 2021-10-02 15:41:04 +10:00
Jan Niehusmann 2b6de3a3c9
implement embedded-hal 1.0.0-alpha.5 (#131)
* implement embedded-hal 1.0.0-alpha.5

* Depend on specific alpha version of embedded-hal.

* enable feature eh1_0_alpha for CI check
2021-10-02 15:36:40 +10:00
Mathias Gottschlag 4db944ad4e pio: Fix clippy warnings and examples in doc comments. 2021-10-01 18:41:10 +02:00
Alexander Meißner dbd4c7dfea Implements interrupts for GPIO pins. 2021-10-01 14:32:24 +02:00
Mathias Gottschlag 2fc42e07f2 pio: Rename read_rx/write_tx to read/write. 2021-10-01 08:47:16 +02:00
Mathias Gottschlag 207f5aebdb pio: Split RX and TX FIFO functions into different types.
We need separate types for any blocking or DMA operations - otherwise, it
would not be possible to perform both RX and TX transfers at the same time.
2021-09-30 09:07:15 +02:00
Mathias Gottschlag dbe7f48699 pio: Identify state machines via generic parameters.
Eventually, the read and write FIFOs need to be split into separate
objects for DMA. To be able to safely rejoin them only when they belong to
the same state machine, the state machine index needs to be encoded into
the type.
2021-09-29 21:42:05 +02:00
Mathias Gottschlag 64fa8441d8 pio: Fix bugs spotted in the review. 2021-09-29 20:55:24 +02:00
Mathias Gottschlag 684f483859 pio: Improve documentation and add an example that uses pio_proc::pio!(). 2021-09-28 21:48:05 +02:00
Mathias Gottschlag 515eac5553 pio: Differentiate between uninitialized/stopped/running state machines.
Some operations must only be performed in a specific state. For example,
pin directions must not be changed while the state machine is running, as
the operation modifies PINCTRL. The new API makes wrong usage a lot harder.

Also, the code now supports uninitializing state machines to free
instruction space or to select a different function.
2021-09-28 21:15:28 +02:00
Mathias Gottschlag 4d97d9fe75 pio: Enable code sharing between SMs via objects for installed programs.
Multiple state machines may want to execute the same program (e.g., two
state machines are used to implement two I2C buses), in which code sharing
saves space.
2021-09-28 20:27:40 +02:00
Mathias Gottschlag 959f714fb9 pio: Fix marking used instruction space. 2021-09-28 20:27:40 +02:00
Mathias Gottschlag 2ff9ae156f pio: Fix some doc comments. 2021-09-28 20:27:40 +02:00
Mathias Gottschlag e5a7c325b0 pio: Split PIO into multiple objects that can be moved around separately.
One PIO block often implements multiple functions that are used in
different parts of the codebase. Previously, that would be impossible, as
PIO contained all StateMachine instances.

Now, StateMachine instances use atomic operations whenever accessing shared
registers, so they can be used concurrently.
2021-09-28 20:27:22 +02:00
Jonathan Pallant da89888ccb
Merge pull request #137 from 42-technology-ltd/ensure-hal-examples-non-board-specific
Working on README and examples
2021-09-28 10:46:42 +01:00
Jonathan Pallant (42 Technology) fc0075a381 Addressing review comments. 2021-09-28 09:26:31 +01:00
Jonathan Pallant (42 Technology) 0beedde69b Ugh. Thanks, rustfmt. 2021-09-27 19:03:07 +01:00
Jonathan Pallant (42 Technology) d251627e47 Make trait comments more consistent. 2021-09-27 19:01:46 +01:00
Jonathan Pallant (42 Technology) 8876159687 Ah, rustfmt. 2021-09-27 18:58:16 +01:00
Jonathan Pallant (42 Technology) c04f439020 Polish the watchdog example. 2021-09-27 18:57:19 +01:00
Jonathan Pallant (42 Technology) b005128a73 Oh, make sure uart example actually builds. 2021-09-27 18:57:10 +01:00
Jonathan Pallant (42 Technology) 7e03772687 Polish the UART example. 2021-09-27 18:52:13 +01:00
Jonathan Pallant (42 Technology) b894ab9ce7 Cleaning up. 2021-09-27 18:43:01 +01:00
Jonathan Pallant (42 Technology) 225eabb449 Use peripheral clock to describe the clock signal given to peripherals. 2021-09-27 18:42:36 +01:00
Jonathan Pallant (42 Technology) 17afa25d2a Polish PWM blink example. 2021-09-27 18:37:29 +01:00
Jonathan Pallant (42 Technology) b370bb5270 Polish SPI example. 2021-09-27 18:37:20 +01:00
Jonathan Pallant (42 Technology) 0336458344 Update LCD example. 2021-09-27 18:14:54 +01:00
Jonathan Pallant (42 Technology) b7acc7c373 Polish I2C example. 2021-09-27 17:30:29 +01:00
Jonathan Pallant (42 Technology) 193972bb9f Polish GPIO example. 2021-09-27 17:30:18 +01:00
Jonathan Pallant (42 Technology) d5a07bc398 Remove hard coded clock speed from blink example. 2021-09-27 17:30:06 +01:00
Jonathan Pallant (42 Technology) 07c183a636 Remove hard coded clock speed from ADC example. 2021-09-27 17:29:50 +01:00
Jonathan Pallant 77787e760d
Merge pull request #133 from jannic/pio-blinky-example
Add a simple example for PIO.
2021-09-27 15:35:26 +01:00
Jonathan Pallant (42 Technology) b0bcbe68d8 Update blinky example. 2021-09-27 14:47:25 +01:00
Jonathan Pallant (42 Technology) ed27dc9949 Update ADC example. 2021-09-27 14:42:19 +01:00
Jonathan Pallant (42 Technology) 0fa6bf9e0e README updates.
Trying to clarify what is HAL specific and what is RP specific.
2021-09-27 14:32:11 +01:00
Jan Niehusmann fbe2a8834f Update comment on top of pio_blink.rs 2021-09-27 12:36:23 +00:00
Jan Niehusmann c93ea0b97c Update comments in examples/pio_blink.rs 2021-09-26 13:51:48 +00:00
Jan Niehusmann 105dcfddd7
Implement bus keep inputs, as documented in C SDK (#134)
When both pull-up and pull-down are enabled, the RP2040 enters a
so-called "bus keep" function, which uses a weak pull to tue current
high/low state of the GPIO.

See for example
https://raspberrypi.github.io/pico-sdk-doxygen/group__hardware__gpio.html#gab6bf9552da32b3dd0a5d0db45d8374fc
2021-09-26 23:38:07 +10:00
Rob Young d93c4fc4c8
Implement RngCore for RingOscillator (#135)
Implement rand_core::RngCore for RingOscillator from the get_random_bit
function. This is not suitable for security purposes so
rand_core::CryptoRng has not been implemented.
2021-09-26 20:51:01 +10:00
Jan Niehusmann b79f859d72 Add a simple example for PIO. 2021-09-25 13:22:13 +00:00
9names b0c15ccc77
Update changelog and bump verson for hal release 0.3.0 (#121)
* Update CHANGELOG.md and Cargo.toml for release 0.3.0

* Bump BSP hal dep version
2021-09-22 20:43:30 +10:00
Jonathan Nilsson be4a7e0498
Make Spi::set_baudrate public (#116) 2021-09-22 20:41:21 +10:00
Jonathan Pallant (42 Technology) 3e036cf9b0 Polishing the blinky examples. 2021-09-21 10:03:47 +01:00
Henrik Lievonen 904b6f0ab9
Implement GPIO override (#123)
* Implement GPIO override

Interrupt status, input, output enable and output can be overridden.
See documentation for GPIO0_CTRL.

* Fix override enum names

* Use override_value instead of raw identifier
2021-09-20 19:38:12 +10:00
Henrik Lievonen 25e477b73e
Fix PWM set/clr_inverted (#122) 2021-09-20 12:20:42 +10:00
9names ac7a17f6e1
Add doc example for i2c (#112) 2021-09-19 22:34:11 +10:00
9names 0942a170f1
Add basic SPI example (#113) 2021-09-19 22:33:36 +10:00
Wilfried Chauveau 1d5dd15092 Work around enumeration issues with small ep0 max packet size.
Prevents DataIn of the previous request from being sent to the host when
a new setup is received.
2021-09-19 22:27:17 +10:00
9names 98b8e3ae9c
Handle usb interrupt flags in driver (#106)
Set interrupt enable flags in USB driver. The flags were already being cleared in the USB driver.
Update USB examples to remove interrupt flag set/check as it is no longer necessary.
2021-09-17 09:40:10 +10:00
Wilfried Chauveau c509b9d22f
Add embedded_hal::timer support (#110)
* Add embedded_hal::timer support

* fixup: add pico countdown based blinky example & rework get_counter(&self) -> u16
2021-09-16 18:47:34 +10:00
Gus Caplan 833b69819e use pio instruction encoding apis 2021-09-16 17:40:25 +10:00
Jonathan Nilsson b399c96cf5
Fixed u8 overflow in spi with large postdiv (#111) 2021-09-16 10:12:58 +10:00
Henrik Lievonen d941f5637b
PIO support (#74)
Initial implementation of PIO 

Add all of the infrastructure required to include PIO programs and interact with PIO peripheral registers.
This was a massive effort between @devsnek and @henkkuli. It's great that it's now ready to go.

Co-authored-by: Gus Caplan <me@gus.host>
2021-09-16 00:32:00 +10:00
Jonathan Nilsson 8a42d6cf8a
Update pac so we can use rt 0.7 (#107)
* Update pac so we can use rt 0.7

* Update pac in all board crates
2021-09-15 15:07:25 +10:00
9names 7afa19a82b
Usb fixes (#104)
* Remove check for ep0 buffer.len == 64

* Simplify EP buffer check
2021-09-11 18:31:45 +10:00
Jonathan Nilsson 0e5d582363 Fix adc giving wrong values on sequential reads of multiple channels 2021-09-10 20:34:24 +10:00
Wilfried Chauveau db11231f49
Implement usb_device for rp2040 (#98)
Implement usb_device for rp2040

Limitations
- RP2040-E5 (Device enumeration workaround) is not implemented
- Suspend/resume is not implemented
- VBus detection is not tested and may not be fully implemented
2021-09-09 17:55:30 +10:00
9names 9d2e18dc70
Add ADC example and doc-example (#93) 2021-09-02 22:40:13 +10:00
9names 301281cba8
i2c lockup fix (#94)
* Fix check for empty tx-fifo

* Add read trait

* Move from asserts to Err for read/write errors
2021-09-02 22:34:12 +10:00
Hmvp ffa39f65f5
Pwm improvements (#61)
* Reimplement PWM driver using typestates
* Improve docs
2021-09-02 09:37:17 +10:00
Hmvp 216aad2c76 Update and move readmes
The READMEs that go to crates.io need to be in the crate dir
2021-08-26 00:18:55 +10:00
Jonathan 'theJPster' Pallant db7217192a
Merge pull request #96 from 9names/gpio-doc
Add doc example for gpio
2021-08-23 22:31:36 +01:00
9names 4c38af0079 Add doc-example to gpio 2021-08-23 23:15:20 +10:00
Jonathan 'theJPster' Pallant ee5e6ee1cb
Merge pull request #90 from 9names/i2c-hacks
I2c fixes
2021-08-21 19:43:04 +01:00
9names fae1caaca9
Watchdog example (#86)
* Add watchdog example

* Add watchdog doc-example

* Add changes to the change log
2021-08-21 21:05:55 +10:00
9names 151b754d90 Remove setting fields set by default() 2021-08-21 15:17:51 +10:00
9names 021221ede3 Switch the modify where C SDK does 2021-08-21 02:16:25 +10:00
9names 31b9aa85d1 Ensure only pull-up or pull-down is enabled 2021-08-21 02:09:26 +10:00
9names e00a432ed5 Enable internal pullups for i2c 2021-08-21 02:07:56 +10:00
9names dbcaf1933a Fix limits on acceptable ranges 2021-08-21 01:47:11 +10:00
9names 50dbb8a22f Fix transposed variable names 2021-08-21 01:46:39 +10:00
Gus Caplan 04424fb7d4 implement timer counter 2021-08-15 12:42:56 +10:00
Hmvp d4ec87b2f7 Prepare for first release 2021-08-14 20:03:02 +10:00
Hmvp bfe6903751 Correct clobbering registers in pwm subsystem 2021-08-14 18:49:14 +10:00
Hmvp d3cb29b113
Fix doc examples and add checking (#76)
* Fix doc examples for peripheral drivers
* Add no_run to doc examples so they can be built by CI
* Enable building doc examples in CI check workflow
2021-08-11 10:53:42 +10:00
Derek Witt a03052355e
Correctly configure watchdog tick generation (#78)
Fix: The divider for watchdog tick generation is now being set to the
  source clock frequency in MHz, instead of the clock frequency in Hz.
  Watchdog ticks will now be generated at 1 microsecond intervals
  as intended.
2021-08-09 13:47:50 +10:00
9names 369ac5a23f
Add UART example + core::fmt support to UART (#73)
* Add standalone UART example
* Add UART example to docs in UART module
* Add core::fmt::write_str to UART module to allow easy use of format! macro in user code
2021-08-08 15:36:56 +10:00