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

Raspberry Pico Maple Bus TX/RX implemetation #1

Open
wants to merge 4,992 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
4992 commits
Select commit Hold shift + click to select a range
54f332f
Fix cdc peeks()
Apr 30, 2021
6acfa14
Fix bug in cdc_peek
Apr 30, 2021
5add664
Remove n from tu_fifo_get_write_info() and fix bug in vendor class
Apr 30, 2021
5259693
Small typos (#366)
lurch May 1, 2021
4c83c10
make spi_init return baud rate set (#296)
kilograham May 1, 2021
18c35bb
some text fomarting, update unit test to test get buffer info for fifo
hathach May 2, 2021
1e1bcda
update changelog for peek api
hathach May 2, 2021
42a1d2f
Merge pull request #804 from hathach/audio_make_dma_ready
hathach May 2, 2021
d35d1b3
Fix path + typo in README.md (#347)
Exr0n May 2, 2021
c979ca5
disable core 0 SIO FIFO IRQ handler during core 1 launch in case some…
kilograham May 4, 2021
6796faf
add PICO_DIVIDER_DISABLE_INTERRUPTS flag which makes PICO_DIVIDER dis…
kilograham May 4, 2021
b7da70a
make all non hardware_ libraries foo add C preprocessor definition LI…
kilograham May 4, 2021
b6f812f
Change various (confusing to user) message to be DEBUG only (#365)
kilograham May 4, 2021
929ede7
add small delay to stdio_get_until to prevent starvation of USB IRQ h…
kilograham May 4, 2021
18c3985
Some cmake build improvements (#376)
kilograham May 4, 2021
ee00918
Merge pull request #803 from pigrew/usbtmc_default_rm
hathach May 5, 2021
8f3c3ff
i2c: improve communication with i2c devices in i2c_write_blocking
fivdi Apr 11, 2021
7fc75d8
Definitions for IC_TX_BUFFER_DEPTH inconsistent (fixes #335) (#381)
Wren6991 May 5, 2021
53f1915
Add hardware_exception for setting exception handlers at runtime (#380)
kilograham May 5, 2021
ec0dc7a
add __always_inline to trivial super low level inline functions (#379)
kilograham May 5, 2021
6d87da4
Rework lock_core / timers (#378)
kilograham May 5, 2021
8d4f4e1
remove spurious sys/select.h include (#377)
kilograham May 5, 2021
dab1ed6
Add example to be tested
xmos-jmccarthy May 5, 2021
b51e0eb
Fix typo
xmos-jmccarthy May 5, 2021
05892a5
Merge branch 'master' of github.com:xmos-jmccarthy/tinyusb
xmos-jmccarthy May 6, 2021
5316c4e
Update main.c
corvus-ossifragus May 7, 2021
13b510a
Update hcd_rp2040.c
corvus-ossifragus May 7, 2021
4cd6ec2
Merge pull request #820 from corvus-ossifragus/update-host-example
hathach May 8, 2021
505ee0c
Merge pull request #821 from corvus-ossifragus/debug_build_errors
hathach May 8, 2021
0621df8
Update main.c
corvus-ossifragus May 9, 2021
5d69b2a
fix hid report descriptor
ogatatsu May 10, 2021
13de8f5
minor clean up
hathach May 10, 2021
1e8a129
Merge pull request #824 from corvus-ossifragus/fix-keyboard-hid-repor…
hathach May 10, 2021
2a343ba
Merge pull request #826 from hathach/minor-cleanup
hathach May 10, 2021
114dc5a
Fixup IRQ_PRIORITY #define values (#393)
lurch May 10, 2021
ecf66bf
Correct doxygen for mutex_try_enter (#392)
lurch May 10, 2021
9396b9c
Fix a bunch of doxygen typos (#391)
lurch May 10, 2021
74ca189
audio_device: Fix build error
kasjer May 10, 2021
72f5202
Update trace statements that referenced deprecated structure elements.
corvus-ossifragus May 10, 2021
23e5642
Update .gitignore
corvus-ossifragus May 10, 2021
59affc9
Merge pull request #828 from corvus-ossifragus/fix-ep-struct-trace-st…
hathach May 10, 2021
e2f7950
Allow build for NRF5340 MCU
kasjer May 11, 2021
9233269
only apply errata walkaround for nrf52
hathach May 11, 2021
c5e95a8
Merge pull request #829 from kasjer/kasjer/fix-build-for-nrf5340
hathach May 11, 2021
e57b99a
Rework ordering of cmake, so that libraries in subdirectories can add…
kilograham May 11, 2021
36dda1c
Fix some hardware_library dependencies (#383)
kilograham May 11, 2021
508828f
allow setting exception handler to the same value, as this might happ…
kilograham May 11, 2021
6182a2a
make host pico_platform.h and binary_info.h CMakeLists.txt safe for i…
kilograham May 11, 2021
b05d863
Add basic CMSIS core headers (#384)
kilograham May 11, 2021
2d15e11
Merge pull request #827 from kasjer/kasjer/fix-audio-rx_done_cb
hathach May 11, 2021
54c78bf
Fix the PICO_CONFIG default value for PICO_CMSIS_RENAME_EXCEPTIONS (#…
lurch May 12, 2021
c6c4eeb
add timeout_us/until to mutex/sem blocking methods (#402)
kilograham May 12, 2021
574fdee
Fixup divider save_restore for floating point too; improve tests (#405)
kilograham May 13, 2021
607b420
fix pico_promote_common_scope_vars (#397)
kilograham May 13, 2021
5384b6b
add comment about using clk_gpout0 enable bit (Fixes #413)
kahara May 16, 2021
e163f85
clean up, rename some HID device symbol/API
hathach May 18, 2021
7e9e682
update to use HID spec protocol value for get/set_protocol()
hathach May 18, 2021
a26752a
fix build error
hathach May 18, 2021
4f84185
Merge pull request #837 from hathach/fix-835-hid-cleanup
hathach May 18, 2021
1dd2cd4
add hcd_ehci.h as interface for ehci port
hathach Feb 24, 2021
98f5082
rename var to be consistent
hathach Feb 24, 2021
f1148ca
reworking hid host
hathach Feb 24, 2021
68fa17e
more API rename
hathach Feb 24, 2021
2666e1e
add tuh_inited() and tud_inited()
hathach May 1, 2021
3a7f8b3
separte tusb_init/inited() to tud/tuh init/inited
hathach May 11, 2021
13613ea
correct ehci control endpoint address report on xfer complete
hathach May 11, 2021
4023d05
minor clean up
hathach May 11, 2021
e83bdcd
reworking hid host
hathach May 12, 2021
e0dbb48
rename CFG_TUSB_HOST_ENUM_BUFFER_SIZE to CFG_TUH_ENUMERATION_BUFSZIE
hathach May 12, 2021
510beef
make tuh_msc_mount_cb() tuh_msc_unmount_cb() as weak callback
hathach May 12, 2021
be165a6
reworking host hid API
hathach May 12, 2021
a5cd81a
correct hid host mount/unmount callback
hathach May 12, 2021
69defb5
rename and moving
hathach May 12, 2021
b7a8b27
rename tuh_device_is_configured() to tuh_device_configured()
hathach May 12, 2021
791efec
add tuh_device_ready()
hathach May 12, 2021
db8ea7e
clean up
hathach May 13, 2021
7305fec
change hid device report len from uint8 to uint16
hathach May 13, 2021
9324fd8
more hid host API rework
hathach May 13, 2021
cc1b834
continue with hid host rework
hathach May 13, 2021
641f55f
remove CFG_TUH_HID_KEYBOARD and CFG_TUH_HID_MOUSE
hathach May 13, 2021
9ddc3bf
more host hid API
hathach May 13, 2021
dfa8b41
adding hid parser
hathach May 14, 2021
9366104
more API update
hathach May 14, 2021
5b2d117
fix compile
hathach May 14, 2021
da6a7fb
update hid report descriptor macro
hathach May 17, 2021
ffdcf9a
move report_info to application
hathach May 17, 2021
40cd3a7
Merge branch 'master' into host-hid
hathach May 18, 2021
2df5a53
update hid host get/set protocol to match device
hathach May 18, 2021
a32d614
pioasm: prevent double inclusion for C SDK generated headers (#417)
rafaelmartins May 18, 2021
7d0fb6f
enable ci for esp32s3 boards
hathach May 19, 2021
327336e
fix build for rp2040
hathach May 19, 2021
7bb8489
Merge pull request #840 from hathach/enable-ci-esp32s3
hathach May 19, 2021
0b12572
fix uac2_headset example: type of bRequest should be uint8_t, not enu…
noodlefighter May 20, 2021
cdb063f
Merge pull request #841 from noodlefighter/fix-uac2_headset
hathach May 20, 2021
99add05
simplify hid api
hathach May 22, 2021
89dad1a
update app
hathach May 22, 2021
350dfb2
more hid api rename
hathach May 22, 2021
ad845db
improve hid parser
hathach May 22, 2021
63c57ed
clean p
hathach May 22, 2021
df65c35
implement hid host set report with control transfer
hathach May 22, 2021
b8e019d
rename tuh_hid_get_report_cb to tuh_hid_report_received_cb()
hathach May 22, 2021
a2c4a48
add tuh_hid_report_sent_cb()
hathach May 22, 2021
f13a3c0
fix missing report in tuh_hid_set_report()
hathach May 22, 2021
56577d9
Merge pull request #834 from hathach/host-hid
hathach May 22, 2021
a1dab16
get protocol when enum with hid boot interface
hathach May 22, 2021
056cd6b
Merge pull request #845 from hathach/hid-host-get-protocol-when-enum
hathach May 22, 2021
8cffe48
change hid device internal boot_mode to protocol_mode
hathach May 23, 2021
3654d96
only invoke tuh_msc_umount_cb() if needed
hathach May 23, 2021
4f03332
clean up
hathach May 23, 2021
596d08e
Add missing cast to uint32_t in hw_divider_u32_quotient for host (#436)
jonathangjertsen May 23, 2021
ca8724e
Merge pull request #846 from hathach/house-keeping
hathach May 24, 2021
060123d
Optional feature to get the max level that has ever been held by a qu…
jonathangjertsen May 24, 2021
b2832b3
Fix wrong format string in alarm_pool_dump_key (#437)
jonathangjertsen May 24, 2021
17ee1a8
Add support for Arduino Nano RP2040 Connect (#425)
facchinm May 24, 2021
777ccb8
Fix function-name misspelling (#443)
lurch May 24, 2021
94b8331
Update host multicore.h to match multicore.h in rp2_common (#439)
jonathangjertsen May 24, 2021
d79dd21
Implement `uart_write_blocking` and `uart_read_blocking` for host (#438)
jonathangjertsen May 24, 2021
80356a4
Define `__STRING` for other compilers than MSVC in the host platform.…
jonathangjertsen May 24, 2021
048fcde
Prevent warnings about some unused parameters in pico_stdio_usb when …
jonathangjertsen May 24, 2021
cc8b215
Define `void operator delete[](void *p, std::size_t n)` in new_delete…
jonathangjertsen May 24, 2021
b8dc054
queue: make data pointers const in queue_try_add and queue_add_blocki…
jonathangjertsen May 24, 2021
2eb76bb
- interp_ fixes (#428)
Reneg973 May 24, 2021
6994a38
-some typo fixes (#408)
Reneg973 May 24, 2021
ce59d69
Merge remote-tracking branch 'official/master'
xmos-jmccarthy May 25, 2021
954056d
fix warnings cast function type for nrf, fix pico osal warning
hathach May 25, 2021
a531123
Prevent the literal string DEBUG from being appended to some messages…
jonathangjertsen May 25, 2021
aca2320
fix uac2_headset example
noodlefighter May 26, 2021
e411ce1
Merge pull request #849 from noodlefighter/fix-uac2_headset
hathach May 26, 2021
689d74a
fix board test example build with nrf
hathach May 26, 2021
9fa9b67
test separate ci workflow for msp430
hathach May 26, 2021
f8e9c6d
separate ci workflow, remove artifact & release upload
hathach May 26, 2021
220f441
Merge pull request #850 from hathach/fix-warnings
hathach May 26, 2021
dbef50f
Merge branch 'master' into xmos-jmccarthy-master
hathach May 26, 2021
f9c542a
fix dfu example build
hathach May 26, 2021
85186ab
Merge pull request #754 from xmos-jmccarthy/master
hathach May 26, 2021
ac47a33
Update README.md
hathach May 26, 2021
4e2684f
Merge pull request #825 from ogatatsu/hid_desc
hathach May 26, 2021
faa3115
rename usbd_edpt_iso_xfer to usbd_edpt_xfer_fifo
hathach May 26, 2021
814edec
clean up
hathach May 26, 2021
c7cecf2
clean up
hathach May 26, 2021
9736e54
include clean up
hathach May 27, 2021
b36b211
clean up tusb_fifo.h include
hathach May 27, 2021
f384d6f
more with clean up
hathach May 27, 2021
9ad6fad
more include clean up
hathach May 27, 2021
5ad072a
Add function to get the currently selected channel (#451)
jonathangjertsen May 27, 2021
7c66c51
update doc
hathach May 27, 2021
81d238b
Merge pull request #854 from hathach/more-housekeeping
hathach May 27, 2021
e0872a3
Add missing board detection macros (#448)
2bndy5 May 27, 2021
1996a21
dma_channel_transfer_[from/to]_buffer_now: added const volatile to re…
geurtv May 27, 2021
e9c22e4
increase version for release
hathach May 28, 2021
164778a
update limit each transfer not less than 64
hathach May 28, 2021
4f97915
Update bug_report.md
hathach May 30, 2021
3973ec4
rp2040: fix debug compilation error
kilograham Apr 8, 2021
eb8ca14
add level 3 log for info, add generic TU_LOG()
hathach May 30, 2021
6498ee1
fix incorrect data toggle when max packet size < 64
hathach May 30, 2021
54c9150
add errata number
hathach May 30, 2021
c2a0c15
add more comment
hathach May 30, 2021
edbccb5
don't override CFG_TUSB_OS in cdc_dual_ports example
kilograham May 30, 2021
95f2478
Rework rp2040 examples and CMake build:
kilograham May 30, 2021
5cf930d
fix cast-align warning in msc host
hathach May 31, 2021
3fb80e7
remove obsolete hcd_pipe_queue_xfer()/hcd_pipe_xfer()
hathach May 31, 2021
65e5872
add hub_port_set_feature()
hathach May 31, 2021
4b2f32b
update hub
hathach May 31, 2021
04797bc
clean up
hathach May 31, 2021
da8000d
clean up ohci, remove obsolete api
hathach May 31, 2021
4e98ce9
use hcd_frame_number() instead of uframe
hathach May 31, 2021
31077f4
correct ohci endpoint address in xfer complete
hathach May 31, 2021
bc0a038
clean up
hathach May 31, 2021
5d161b7
Fix up build_family style builds:
kilograham May 31, 2021
13951b4
set PICO_TINYUSB_PATH for when building from within tinyusb without p…
kilograham May 31, 2021
db138a5
Switch checks to use tinyusb-0.10.0 branch of pico-sdk due to circula…
kilograham May 31, 2021
90d7483
guard stdio_uart_init_full with LIB_PICO_STDUI_UART as the function d…
kilograham May 31, 2021
9b17acd
actually fix pico-sdk checkout to checkout the right branch
kilograham May 31, 2021
f5572e2
restore unintentionally modified submodules
kilograham May 31, 2021
c573775
Change the quick-start instructions to include installation of the (#92)
ewpa May 31, 2021
abf83c6
add note for custom class driver
hathach Jun 1, 2021
8782d0b
fix rp2040 examples build from local tinyusb tree
kilograham Jun 1, 2021
6e29bf6
rename family.cmake to family_common.cmake
kilograham Jun 1, 2021
ebf6461
damn submodules!
kilograham Jun 1, 2021
42cbdcb
added spi_get_baudrate() + some consistency changes (#395)
Reneg973 Jun 1, 2021
109d025
remove TINYUSB_FAMILT_PROJECT_NAME_INCLUDES_BOARD setting
kilograham Jun 1, 2021
a6b5e20
Merge pull request #862 from hathach/host-rp2040
hathach Jun 1, 2021
6e2cf2a
clean up log
hathach Jun 1, 2021
5410710
fix missing TU_LOG symbol
hathach Jun 1, 2021
ff1a112
Merge pull request #868 from hathach/host-hcd
hathach Jun 1, 2021
d026118
Allow lengthening xosc startup delay with a compile option (#457)
dhalbert Jun 1, 2021
30041d8
Add hardware_gpio accessors for Schmitt, slew rate, drive strength (f…
Wren6991 Jun 1, 2021
bef33d1
move core definition of source file includes from SDK into family.cmake
Jun 2, 2021
1fb211f
minor comment change to force rebuild
kilograham Jun 2, 2021
895bad7
Add some spin lock related doxygen
kilograham May 25, 2021
27c1a89
review fixes
kilograham May 27, 2021
66c54d8
fix PICO_CONFIG entry
kilograham May 27, 2021
496ff66
Make PICO_CONFIG descriptions unique
kilograham May 31, 2021
de436e1
undo search replace error
kilograham Jun 2, 2021
fea5cba
fixed net_lwip_webserver cmake build
kilograham Jun 2, 2021
8ea0dfb
Merge pull request #865 from kilograham/pico-0.10.0
hathach Jun 2, 2021
561502c
Move to Tinyusb 0.10.0 (still with RP patches) (#462)
kilograham Jun 2, 2021
b3e1d2d
Add usb device dpram to svd file. Fixes #351 (#465)
liamfraser Jun 2, 2021
91e9327
Add PICO_PANIC_FUNCTION define to allow replacement of the default pa…
kilograham Jun 2, 2021
5afa363
Small API additions and minor fixes (#406)
kilograham Jun 2, 2021
a50fd96
increase version for release, update changelog
hathach Jun 2, 2021
d49938d
change ci to pico-sdk develop
hathach Jun 2, 2021
eeb6b50
fix qtpy rp2040 uart rx rev B (#466)
hathach Jun 2, 2021
4b0dea4
Move to upstream tinyusb (#467)
kilograham Jun 2, 2021
8d7bdd2
change version to 1.2.0 proper
kilograham Jun 2, 2021
bba0420
Add gpio_set_irqover to match inover/outover/oeover (fixes #265) (#470)
Wren6991 Jun 3, 2021
c44e62d
Added board definition (#471)
ZodiusInfuser Jun 3, 2021
45a1e08
fix sem_acquire_block_until function name
kilograham Jun 3, 2021
fdf695b
remove incorrect default from PICO_PANIC_FUNCTION PICO_CONFIG entry
kilograham Jun 3, 2021
bfcbefa
Merge pull request #472 from raspberrypi/release.1.2.0
kilograham Jun 3, 2021
b2b99d2
Improve control setup logging
May 3, 2021
15851f1
Improve logging for response descriptors
May 3, 2021
17508b2
rp2040: Fix max transfer descriptor calculation
Jun 26, 2021
24fda03
rp2040: Fix multi packet transfers
Jun 26, 2021
5958431
Move pico into sub directory
Jan 25, 2022
746df66
Add xpad project. It doesn't do anything right now.
Jan 25, 2022
2199eb2
rename pico to maplebus
Jan 26, 2022
3ce8479
Add 'rp2040/pico-sdk/' from commit 'bfcbefafc5d2a210551a4d9d80b4303d4…
Jan 26, 2022
ec1181b
pico-sdk: Remove tinyusb submodule
Jan 26, 2022
1b0ee74
Add 'rp2040/pico-sdk/lib/tinyusb/' from commit 'd49938d0f5052bce70e55…
Jan 26, 2022
b252af8
Merge commit '24fda03263d0430bc3aaad41e712829a1b67c05c' into pico
Jan 26, 2022
29f0003
tinyusb: Add tusb_desc_t
Jan 26, 2022
fdbf8c2
tinyusb: rp2040: Increase verbosity
Jan 26, 2022
0a4603d
tinyusb: Implement config descriptor logging
Jan 26, 2022
fd0dbf7
fixup! tinyusb: rp2040: Increase verbosity
Jan 26, 2022
9aad859
tinyusb: rp2040: Log transferred bytes
Jan 26, 2022
98c9a23
tinyusb: rp2040: Add additional logging
Jan 26, 2022
d992f92
tinyusb: rp2040: Print get descriptor request
Jan 26, 2022
297469a
tinyusb: x360: Add vendor driver for the xbox 360 controller
Jan 27, 2022
878c579
fixup! Add xpad project. It doesn't do anything right now.
Jan 27, 2022
47d8a1b
rp2040: maplebus: Use included pico-sdk
Jan 27, 2022
a6b38a6
maplebus: rp2040: Cleanup hardware init api
Jan 28, 2022
5bda86c
maplebus: rp2040: Convert pio_maplebus_tx_blocking to new ID API
Jan 28, 2022
57a62f1
maplebus: rp2040: Use a better test packet
Jan 29, 2022
bef69df
maplebus: rp2040: Print data in buffer
Jan 29, 2022
e97136f
maplebus: rp2040: Enable compiler warnings
Jan 29, 2022
2ae8805
maplebus: rp2040: Convert pio_maplebus_rx_blocking to new API
Jan 29, 2022
a35ff80
rp2040: Add clang format
Feb 1, 2022
6cc3090
maplebus: rp2040: Format using clang-format
Feb 1, 2022
15fd85c
maplebus: rp2040: Fix asserts
Feb 1, 2022
837c6f8
maplebus: rp2040: Move maplebus_buffer up
Feb 1, 2022
84caff1
maplebus: rp2040: Implement a futures API
Feb 1, 2022
f5fe65a
maplebus: rp2040: link in futures library
Feb 1, 2022
a409539
maplebus: rp2040: Add async maplebus_tx
Feb 1, 2022
5b21d27
maplebus: rp2040: Make the test packet more complex
Feb 6, 2022
b36d4fa
maplebus: rp2040: Fix typo in error message
Feb 6, 2022
36320fe
maplebus: rp2040: memcmp the tx and rx buffer
Feb 6, 2022
b90487f
maplebus: rp3040: Rename tx buffer
Feb 6, 2022
0ddb41c
maplebus: rp2040: Add maplebux_rx
Feb 6, 2022
5de3801
maplebus: rp2040: Switch over to using maplebus_rx
Feb 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
560 changes: 560 additions & 0 deletions rp2040/.clang-format

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions rp2040/futures/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
add_library(futures INTERFACE)
target_include_directories(futures INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_sources(futures INTERFACE
futures.c
)
# target_link_libraries(futures INTERFACE <libs>)
19 changes: 19 additions & 0 deletions rp2040/futures/futures.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2022 Raul E Rangel
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#include <futures.h>
#include <pico/platform.h>

static inline enum future_state future_complete(
__unused struct future *future, __unused struct wait_context *ctx)
{
return FUTURE_DONE;
}

void complete_future(struct future *future)
{
future->poll = future_complete;
}
27 changes: 27 additions & 0 deletions rp2040/futures/include/futures.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2022 Raul E Rangel
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#ifndef _FUTURES_H
#define _FUTURES_H

#include "pico/types.h"

enum future_state {
FUTURE_PENDING,
FUTURE_DONE,
};

struct wait_context {
/* TODO */
};

struct future {
enum future_state (*poll)(struct future *future, struct wait_context *ctx);
};

void complete_future(struct future *future);

#endif /* _FUTURES_H */
34 changes: 34 additions & 0 deletions rp2040/maplebus/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2021 Raul E Rangel
#
# SPDX-License-Identifier: GPL-2.0-or-later

cmake_minimum_required(VERSION 3.13)

set(PICO_SDK_PATH ../../pico-sdk)
include(pico_sdk_import.cmake)

add_subdirectory(../futures build-futures)

project(maplebus)

pico_sdk_init()

add_executable(maplebus)

pico_enable_stdio_uart(maplebus 1)

pico_generate_pio_header(maplebus ${CMAKE_CURRENT_LIST_DIR}/maplebus.pio)

target_sources(maplebus PRIVATE
main.c
maplebus.c
)

target_link_libraries(maplebus PRIVATE pico_stdlib hardware_pio futures)
target_compile_options(maplebus PRIVATE -Wall -Wextra -Wconversion -Werror)
target_compile_definitions(maplebus PRIVATE
PARAM_ASSERTIONS_ENABLE_ALL=1 # want to check all the assertions for compilation warnings
)

pico_add_extra_outputs(maplebus)

3 changes: 3 additions & 0 deletions rp2040/maplebus/load.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target remote localhost:3333
load
monitor reset init
114 changes: 114 additions & 0 deletions rp2040/maplebus/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* Copyright (c) 2021 Raul E Rangel
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#include <stdio.h>
#include <string.h>

#include "pico/stdlib.h"
#include "maplebus.h"

#define PIN_HEARTBEAT 4
#define PIN_SDCKA 3
#define PIN_SDCKB 2

struct {
struct maplebus_header header;
// Max number of additional frames
uint32_t data[255];
} rx_buffer;

_Static_assert (sizeof(rx_buffer) == 1024, "rx_buffer is not 1024 bytes long");

struct maplebus_header device_info_request = {
.command = 0x01,
.destination = 0x20,
.source = 0x00,
.length = 0x00,
};

struct test_packet {
struct maplebus_header header;
uint32_t data[4];
} test_packet = {
.header = {
.command = 0x99,
.destination = 0x88,
.source = 0x77,
.length = sizeof(struct test_packet) / 4 - 1,
},
.data = {
0x66 << 0,
0x55 << 8,
0x44 << 16,
0x33 << 24
}
};

int main() {
stdio_init_all();

printf("Maple Bus starting!\n");

// gpio_init(PIN_HEARTBEAT);
// gpio_set_dir(PIN_HEARTBEAT, GPIO_OUT);

maplebus_tx_id_t tx_id;
maplebus_rx_id_t rx_id;

struct future tx_future;
struct maplebus_rx_future rx_future;

maplebus_tx_pio_init(pio0);
maplebus_rx_pio_init(pio1);

tx_id = maplebus_tx_init(PIN_SDCKA, PIN_SDCKB);
rx_id = maplebus_rx_init(PIN_SDCKA, PIN_SDCKB);

uint iteration = 0;

while (true) {
printf("Maple Bus iteration %u\n", iteration);

//gpio_put(PIN_HEARTBEAT, 1);
maplebux_tx(tx_id, &tx_future, &test_packet.header, sizeof(test_packet));
maplebus_rx(rx_id, &rx_future, &rx_buffer.header, sizeof(rx_buffer));
while (tx_future.poll(&tx_future, NULL) != FUTURE_DONE || rx_future.future.poll(&rx_future.future, NULL) != FUTURE_DONE)
;

switch (rx_future.status) {
case MAPLEBUS_OK:
maplebus_print(&rx_buffer.header);
break;
case MAPLEBUS_UNKNOWN_FRAME_TYPE:
printf("invalid frame type\n");
break;
case MAPLEBUS_INVALID_ARGS:
printf("invalid args\n");
break;
case MAPLEBUS_CRC_ERROR:
printf("crc error\n");
break;
case MAPLEBUS_MESSAGE_TRUNCATED:
printf("rx truncated\n");
break;
case MAPLEBUS_TIMEOUT:
printf("rx timeout\n");
break;
default:
printf("Unknown return code %d\n", rx_future.status);
}
//gpio_put(PIN_HEARTBEAT, 0);

if (memcmp(&test_packet, &rx_buffer, sizeof(test_packet)))
printf("Packet doesn't match!\n");

iteration++;

sleep_ms(1000);
}

return 0;
}
Loading