init test
This commit is contained in:
commit
14e39b0e2e
12
.cargo/config.toml
Normal file
12
.cargo/config.toml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[build]
|
||||||
|
target = "thumbv8m.main-none-eabihf"
|
||||||
|
|
||||||
|
#rustflags = ["-C", "link-arg=-Tlink.x"]
|
||||||
|
[target.thumbv8m.main-none-eabihf]
|
||||||
|
runner = "probe-rs run --chip STM32U5A5ZJTx"
|
||||||
|
# runner = "probe-rs run --chip STM32U575ZITx"
|
||||||
|
|
||||||
|
# rustflags = ["-C", "link-arg=-Tlink.x"]
|
||||||
|
|
||||||
|
[env]
|
||||||
|
DEFMT_LOG = "trace"
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/target
|
||||||
|
.idea
|
66
.vscode/launch.json
vendored
Normal file
66
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"preLaunchTask": "rust: cargo build",
|
||||||
|
"type": "probe-rs-debug",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "probe_rs sd_cam launch example",
|
||||||
|
"cwd": "${workspaceFolder}/",
|
||||||
|
//!MODIFY (or remove)
|
||||||
|
//"speed": 24000,
|
||||||
|
//!MODIFY (or remove)
|
||||||
|
//"probe": "0483:8006",
|
||||||
|
"runtimeExecutable": "probe-rs",
|
||||||
|
"runtimeArgs": ["dap-server"],
|
||||||
|
//!MODIFY
|
||||||
|
"chip": "STM32U5A5ZJTx",
|
||||||
|
"flashingConfig": {
|
||||||
|
"flashingEnabled": true,
|
||||||
|
"haltAfterReset": false,
|
||||||
|
"formatOptions": {
|
||||||
|
//!MODIFY (or remove). Valid values are: 'bin', 'hex', 'elf'(default), 'idf'
|
||||||
|
//"format": "elf"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"coreConfigs": [
|
||||||
|
{
|
||||||
|
"coreIndex": 0,
|
||||||
|
//!MODIFY
|
||||||
|
"programBinary": "/home/zong/Code/u5_example/target/thumbv8m.main-none-eabihf/debug/u5_example",
|
||||||
|
//!MODIFY
|
||||||
|
"svdFile": "stm32u5a5.svd",
|
||||||
|
"rttEnabled": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
//!MODIFY (or remove)
|
||||||
|
// If you set this variable, check the VSCode console log window for the location of the log file.
|
||||||
|
"RUST_LOG": "Console",
|
||||||
|
"DEFMT_LOG": "debug",
|
||||||
|
},
|
||||||
|
// Info, Debug
|
||||||
|
"consoleLogLevel": "Info"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// {
|
||||||
|
// "version": "0.2.0",
|
||||||
|
// "configurations": [
|
||||||
|
// {
|
||||||
|
// "preLaunchTask": "${defaultBuildTask}",
|
||||||
|
// "type": "probe-rs-debug",
|
||||||
|
// "request": "launch",
|
||||||
|
// "name": "probe_rs Executable Test",
|
||||||
|
// //!MODIFY
|
||||||
|
// "chip": "STM32U575RITx",
|
||||||
|
// "coreConfigs": [
|
||||||
|
// {
|
||||||
|
// //!MODIFY
|
||||||
|
// "programBinary": "C:\\tmp\\u5_new\\examples\\target\\thumbv8m.main-none-eabihf\\debug\\sd_cam"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// }
|
23
.vscode/taks.json
vendored
Normal file
23
.vscode/taks.json
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "cargo",
|
||||||
|
"command": "build",
|
||||||
|
"args": [
|
||||||
|
"--bin",
|
||||||
|
"u5_example"
|
||||||
|
],
|
||||||
|
"problemMatcher": [
|
||||||
|
"$rustc"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"label": "rust: cargo build",
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"DEFMT_LOG": "info"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
688
Cargo.lock
generated
Normal file
688
Cargo.lock
generated
Normal file
@ -0,0 +1,688 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bare-metal"
|
||||||
|
version = "0.2.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
|
||||||
|
dependencies = [
|
||||||
|
"rustc_version",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitfield"
|
||||||
|
version = "0.13.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder"
|
||||||
|
version = "1.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cortex-m"
|
||||||
|
version = "0.7.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9"
|
||||||
|
dependencies = [
|
||||||
|
"bare-metal",
|
||||||
|
"bitfield",
|
||||||
|
"critical-section",
|
||||||
|
"embedded-hal",
|
||||||
|
"volatile-register",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cortex-m-rt"
|
||||||
|
version = "0.7.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ee84e813d593101b1723e13ec38b6ab6abbdbaaa4546553f5395ed274079ddb1"
|
||||||
|
dependencies = [
|
||||||
|
"cortex-m-rt-macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cortex-m-rt-macros"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "critical-section"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "darling"
|
||||||
|
version = "0.20.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391"
|
||||||
|
dependencies = [
|
||||||
|
"darling_core",
|
||||||
|
"darling_macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "darling_core"
|
||||||
|
version = "0.20.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f"
|
||||||
|
dependencies = [
|
||||||
|
"fnv",
|
||||||
|
"ident_case",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"strsim",
|
||||||
|
"syn 2.0.53",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "darling_macro"
|
||||||
|
version = "0.20.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f"
|
||||||
|
dependencies = [
|
||||||
|
"darling_core",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.53",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "defmt"
|
||||||
|
version = "0.3.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3939552907426de152b3c2c6f51ed53f98f448babd26f28694c95f5906194595"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"defmt-macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "defmt-itm"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d87a4d384d1be83cb09fbb306ae480bd38eb92f86a94ffa65bc72d131563c5c"
|
||||||
|
dependencies = [
|
||||||
|
"cortex-m",
|
||||||
|
"defmt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "defmt-macros"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "18bdc7a7b92ac413e19e95240e75d3a73a8d8e78aa24a594c22cbb4d44b4bbda"
|
||||||
|
dependencies = [
|
||||||
|
"defmt-parser",
|
||||||
|
"proc-macro-error",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.53",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "defmt-parser"
|
||||||
|
version = "0.3.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ff4a5fefe330e8d7f31b16a318f9ce81000d8e35e69b93eae154d16d2278f70f"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "defmt-rtt"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "609923761264dd99ed9c7d209718cda4631c5fe84668e0f0960124cbb844c49f"
|
||||||
|
dependencies = [
|
||||||
|
"critical-section",
|
||||||
|
"defmt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "document-features"
|
||||||
|
version = "0.2.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95"
|
||||||
|
dependencies = [
|
||||||
|
"litrs",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embassy-executor"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "git+https://github.com/embassy-rs/embassy?rev=35f284e#35f284ec22848d7085e00f377136fd66067ca756"
|
||||||
|
dependencies = [
|
||||||
|
"cortex-m",
|
||||||
|
"critical-section",
|
||||||
|
"document-features",
|
||||||
|
"embassy-executor-macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embassy-executor-macros"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "git+https://github.com/embassy-rs/embassy?rev=35f284e#35f284ec22848d7085e00f377136fd66067ca756"
|
||||||
|
dependencies = [
|
||||||
|
"darling",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.53",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embassy-futures"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "git+https://github.com/embassy-rs/embassy?rev=35f284e#35f284ec22848d7085e00f377136fd66067ca756"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embassy-net-driver"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "git+https://github.com/embassy-rs/embassy?rev=35f284e#35f284ec22848d7085e00f377136fd66067ca756"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embassy-net-driver-channel"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "git+https://github.com/embassy-rs/embassy?rev=35f284e#35f284ec22848d7085e00f377136fd66067ca756"
|
||||||
|
dependencies = [
|
||||||
|
"embassy-futures",
|
||||||
|
"embassy-net-driver",
|
||||||
|
"embassy-sync",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embassy-sync"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "git+https://github.com/embassy-rs/embassy?rev=35f284e#35f284ec22848d7085e00f377136fd66067ca756"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"critical-section",
|
||||||
|
"embedded-io-async",
|
||||||
|
"futures-util",
|
||||||
|
"heapless",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embassy-usb"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/embassy-rs/embassy?rev=35f284e#35f284ec22848d7085e00f377136fd66067ca756"
|
||||||
|
dependencies = [
|
||||||
|
"embassy-futures",
|
||||||
|
"embassy-net-driver-channel",
|
||||||
|
"embassy-sync",
|
||||||
|
"embassy-usb-driver",
|
||||||
|
"heapless",
|
||||||
|
"ssmarshal",
|
||||||
|
"usbd-hid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embassy-usb-driver"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/embassy-rs/embassy?rev=35f284e#35f284ec22848d7085e00f377136fd66067ca756"
|
||||||
|
dependencies = [
|
||||||
|
"defmt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embedded-hal"
|
||||||
|
version = "0.2.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff"
|
||||||
|
dependencies = [
|
||||||
|
"nb 0.1.3",
|
||||||
|
"void",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embedded-io"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embedded-io-async"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f"
|
||||||
|
dependencies = [
|
||||||
|
"embedded-io",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "encode_unicode"
|
||||||
|
version = "0.3.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fnv"
|
||||||
|
version = "1.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures"
|
||||||
|
version = "0.3.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
|
||||||
|
dependencies = [
|
||||||
|
"futures-channel",
|
||||||
|
"futures-core",
|
||||||
|
"futures-io",
|
||||||
|
"futures-sink",
|
||||||
|
"futures-task",
|
||||||
|
"futures-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-channel"
|
||||||
|
version = "0.3.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-core"
|
||||||
|
version = "0.3.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-io"
|
||||||
|
version = "0.3.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-sink"
|
||||||
|
version = "0.3.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-task"
|
||||||
|
version = "0.3.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-util"
|
||||||
|
version = "0.3.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
|
"futures-task",
|
||||||
|
"pin-project-lite",
|
||||||
|
"pin-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hash32"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heapless"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad"
|
||||||
|
dependencies = [
|
||||||
|
"hash32",
|
||||||
|
"stable_deref_trait",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ident_case"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "litrs"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nb"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f"
|
||||||
|
dependencies = [
|
||||||
|
"nb 1.1.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nb"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-project-lite"
|
||||||
|
version = "0.2.13"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-utils"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "portable-atomic"
|
||||||
|
version = "1.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-error"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-error-attr",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-error-attr"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.79"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.35"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc_version"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||||
|
dependencies = [
|
||||||
|
"semver",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sdio-host"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b328e2cb950eeccd55b7f55c3a963691455dcd044cfb5354f0c5e68d2c2d6ee2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "semver"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||||
|
dependencies = [
|
||||||
|
"semver-parser",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "semver-parser"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.197"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.197"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.53",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ssmarshal"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850"
|
||||||
|
dependencies = [
|
||||||
|
"encode_unicode",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "stable_deref_trait"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "stm32-metapac"
|
||||||
|
version = "15.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"cortex-m",
|
||||||
|
"cortex-m-rt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strsim"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.109"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.53"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror"
|
||||||
|
version = "1.0.58"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror-impl",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror-impl"
|
||||||
|
version = "1.0.58"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.53",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "u5-lib"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"cortex-m",
|
||||||
|
"cortex-m-rt",
|
||||||
|
"critical-section",
|
||||||
|
"defmt",
|
||||||
|
"defmt-itm",
|
||||||
|
"defmt-rtt",
|
||||||
|
"embassy-executor",
|
||||||
|
"embassy-executor-macros",
|
||||||
|
"embassy-sync",
|
||||||
|
"embassy-usb",
|
||||||
|
"embassy-usb-driver",
|
||||||
|
"futures",
|
||||||
|
"heapless",
|
||||||
|
"sdio-host",
|
||||||
|
"stm32-metapac",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "u5_example"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"cortex-m",
|
||||||
|
"cortex-m-rt",
|
||||||
|
"critical-section",
|
||||||
|
"defmt",
|
||||||
|
"defmt-itm",
|
||||||
|
"defmt-rtt",
|
||||||
|
"embassy-executor",
|
||||||
|
"embassy-usb",
|
||||||
|
"futures",
|
||||||
|
"u5-lib",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "usb-device"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "98816b1accafbb09085168b90f27e93d790b4bfa19d883466b5e53315b5f06a6"
|
||||||
|
dependencies = [
|
||||||
|
"heapless",
|
||||||
|
"portable-atomic",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "usbd-hid"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "41a2d4546ca3e6a5c6a85584e5caf29feabf3ec35d6cd6b772eb35bd3cff7256"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"ssmarshal",
|
||||||
|
"usb-device",
|
||||||
|
"usbd-hid-macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "usbd-hid-descriptors"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcbee8c6735e90894fba04770bc41e11fd3c5256018856e15dc4dd1e6c8a3dd1"
|
||||||
|
dependencies = [
|
||||||
|
"bitfield",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "usbd-hid-macros"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "261079a9ada015fa1acac7cc73c98559f3a92585e15f508034beccf6a2ab75a2"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"serde",
|
||||||
|
"syn 1.0.109",
|
||||||
|
"usbd-hid-descriptors",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vcell"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.9.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "void"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "volatile-register"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc"
|
||||||
|
dependencies = [
|
||||||
|
"vcell",
|
||||||
|
]
|
43
Cargo.toml
Normal file
43
Cargo.toml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
[package]
|
||||||
|
name = "u5_example"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
[[bin]]
|
||||||
|
name = "i2c"
|
||||||
|
path = "src/bin/i2c.rs"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
# cortex-m = "0.7.0"
|
||||||
|
cortex-m = { version = "0.7.7", features = [
|
||||||
|
"inline-asm",
|
||||||
|
"critical-section-single-core",
|
||||||
|
]}
|
||||||
|
u5-lib = { path = "../u5_new",features = [
|
||||||
|
"stm32u5a5qj",
|
||||||
|
# "stm32u575zi"
|
||||||
|
]}
|
||||||
|
critical-section = "1.1.2"
|
||||||
|
defmt = "0.3.6"
|
||||||
|
defmt-rtt = { version = "0.4.0" }
|
||||||
|
defmt-itm = { version = "0.3.0" }
|
||||||
|
futures = { version = "0.3.17", default-features = false, fetures = [
|
||||||
|
"async-await",
|
||||||
|
]}
|
||||||
|
cortex-m-rt = { version = "0.7.3" }
|
||||||
|
|
||||||
|
[dependencies.embassy-usb]
|
||||||
|
git = "https://github.com/embassy-rs/embassy"
|
||||||
|
rev = "35f284e"
|
||||||
|
|
||||||
|
[dependencies.embassy-executor]
|
||||||
|
features = ["nightly", "arch-cortex-m", "executor-thread"]
|
||||||
|
git = "https://github.com/embassy-rs/embassy"
|
||||||
|
rev = "35f284e"
|
||||||
|
|
||||||
|
# [dependencies.stm32-metapac]
|
||||||
|
# path = "../stm32-data/build/stm32-metapac"
|
||||||
|
# features = [ "memory-x", "rt"]
|
20
build.rs
Normal file
20
build.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("cargo:rustc-link-arg-bins=--nmagic");
|
||||||
|
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||||
|
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
||||||
|
// enable cfg sdmmc
|
||||||
|
println!("cargo:rustc-cfg=sdmmc");
|
||||||
|
for (key, _value) in std::env::vars() {
|
||||||
|
// Check if the current environment variable is a feature that starts with "STM32U5"
|
||||||
|
if key.starts_with("CARGO_FEATURE_STM32U575") {
|
||||||
|
// If found, print the cargo directive to set the `stm32u5` cfg flag
|
||||||
|
println!("cargo:rustc-cfg=stm32u575");
|
||||||
|
break; // Exit the loop once the first matching feature is found
|
||||||
|
}
|
||||||
|
if key.starts_with("CARGO_FEATURE_STM32U5A5") {
|
||||||
|
// If found, print the cargo directive to set the `stm32u5` cfg flag
|
||||||
|
println!("cargo:rustc-cfg=stm32u5a5");
|
||||||
|
break; // Exit the loop once the first matching feature is found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
56
src/bin/i2c.rs
Normal file
56
src/bin/i2c.rs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// #[!no_std]
|
||||||
|
#![feature(noop_waker)]
|
||||||
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
|
use core::default;
|
||||||
|
use core::panic::PanicInfo;
|
||||||
|
use core::default::Default;
|
||||||
|
|
||||||
|
use u5_lib::{*};
|
||||||
|
use u5_lib::com_interface::ComInterface;
|
||||||
|
|
||||||
|
#[derive(defmt::Format)]
|
||||||
|
pub enum UsbError {
|
||||||
|
BufferOverflow,
|
||||||
|
Disabled,
|
||||||
|
}
|
||||||
|
|
||||||
|
const BLUE: gpio::GpioPort = gpio::PB7;
|
||||||
|
// const USART: usart::Usart = usart::USART1;
|
||||||
|
|
||||||
|
use u5_lib::low_power::Executor;
|
||||||
|
|
||||||
|
#[cortex_m_rt::entry]
|
||||||
|
fn main() -> ! {
|
||||||
|
Executor::take().run(|spawner| {
|
||||||
|
spawner.spawn(async_main(spawner)).unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[task]
|
||||||
|
async fn async_main(_spawner: Spawner) {
|
||||||
|
clock::init_clock(true, false, clock::ClockFreqs::KernelFreq160Mhz);
|
||||||
|
BLUE.setup();
|
||||||
|
defmt::info!("setup led finished!");
|
||||||
|
loop {
|
||||||
|
let mut i2c = i2c::I2c::new(default::Default::default()).unwrap();
|
||||||
|
let mut data = [0x00];
|
||||||
|
// i2c.send(i2c::I2cMessage { addr: 0x68, data: &mut data }).unwrap();
|
||||||
|
clock::delay_ms(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[panic_handler]
|
||||||
|
fn panic(_info: &PanicInfo) -> ! {
|
||||||
|
defmt::info!("panic");
|
||||||
|
defmt::error!(
|
||||||
|
"Location file name: {:?}, line: {:?}, col: {:?}",
|
||||||
|
_info.location().unwrap().file(),
|
||||||
|
_info.location().unwrap().line(),
|
||||||
|
_info.location().unwrap().column()
|
||||||
|
);
|
||||||
|
|
||||||
|
loop {}
|
||||||
|
}
|
173
src/main.rs
Normal file
173
src/main.rs
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
#![feature(noop_waker)]
|
||||||
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
|
use core::default::Default;
|
||||||
|
use core::panic::PanicInfo;
|
||||||
|
use cortex_m::asm::delay;
|
||||||
|
|
||||||
|
use defmt_rtt as _;
|
||||||
|
use embassy_executor::{Spawner};
|
||||||
|
use embassy_usb::{
|
||||||
|
Builder,
|
||||||
|
class::cdc_acm::{CdcAcmClass, State},
|
||||||
|
driver::EndpointError,
|
||||||
|
};
|
||||||
|
use futures::future::{join};
|
||||||
|
|
||||||
|
use u5_lib::{*};
|
||||||
|
use u5_lib::clock::delay_ms;
|
||||||
|
use u5_lib::com_interface::ComInterface;
|
||||||
|
|
||||||
|
#[panic_handler]
|
||||||
|
fn panic(_info: &PanicInfo) -> ! {
|
||||||
|
defmt::info!("panic");
|
||||||
|
defmt::error!(
|
||||||
|
"Location file name: {:?}, line: {:?}, col: {:?}",
|
||||||
|
_info.location().unwrap().file(),
|
||||||
|
_info.location().unwrap().line(),
|
||||||
|
_info.location().unwrap().column()
|
||||||
|
);
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn setup_camera() -> (gpio::GpioPort, i2c::I2c) {
|
||||||
|
clock::set_mco(gpio::GPIO_MCO_PA8, clock::Mcosel::HSI, clock::Mcopre::DIV2); // clock. which use PA8 as clock output
|
||||||
|
let cam_down = gpio::PB0;
|
||||||
|
cam_down.setup();
|
||||||
|
cam_down.set_high();
|
||||||
|
cam_down.set_low();
|
||||||
|
// wait for short time
|
||||||
|
delay_ms(1);
|
||||||
|
let mut i2c = i2c::I2c::new(i2c::I2cConfig::new(2, 100_000, gpio::I2C2_SDA_PF0, gpio::I2C2_SCL_PF1)).unwrap();
|
||||||
|
delay_ms(1);
|
||||||
|
camera::setup_camera(&mut i2c);
|
||||||
|
(cam_down, i2c)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn setup_led() -> gpio::GpioPort {
|
||||||
|
let green: gpio::GpioPort = gpio::PD14;
|
||||||
|
green.setup();
|
||||||
|
green
|
||||||
|
}
|
||||||
|
|
||||||
|
#[embassy_executor::main]
|
||||||
|
async fn main(spawner: Spawner) {
|
||||||
|
// clock::init_clock(true, false, clock::ClockFreqs::KernelFreq4Mhz);
|
||||||
|
clock::init_clock(true, false, clock::ClockFreqs::KernelFreq160Mhz);
|
||||||
|
let (cam_down, i2c) = setup_camera();
|
||||||
|
defmt::info!("camera init finished!");
|
||||||
|
let green = setup_led();
|
||||||
|
loop {
|
||||||
|
delay_ms(500);
|
||||||
|
green.toggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// spawner.spawn(btn()).unwrap();
|
||||||
|
// spawner.spawn(pwr::vddusb_monitor_up()).unwrap();
|
||||||
|
// spawner.spawn(usb_task()).unwrap();
|
||||||
|
|
||||||
|
|
||||||
|
defmt::info!("usb init finished!");
|
||||||
|
loop {
|
||||||
|
exti::EXTI13_PC13.wait_for_raising().await;
|
||||||
|
green.toggle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[embassy_executor::task]
|
||||||
|
async fn btn() {
|
||||||
|
let _last_time: (u8, u8, u8) = (0, 0, 0);
|
||||||
|
defmt::info!("waiting for btn");
|
||||||
|
loop {
|
||||||
|
exti::EXTI13_PC13.wait_for_raising().await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[embassy_executor::task]
|
||||||
|
pub async fn usb_task() {
|
||||||
|
let _ep_out_buffer = [0u8; 256];
|
||||||
|
let mut config = usb_otg::Config::default();
|
||||||
|
config.vbus_detection = false;
|
||||||
|
let driver = usb_otg::Driver::new(config, gpio::USB_DM_PA11, gpio::USB_DP_PA12);
|
||||||
|
|
||||||
|
// // Create embassy-usb Config
|
||||||
|
let mut config = embassy_usb::Config::new(0xaaaa, 0xefba);
|
||||||
|
config.manufacturer = Some("ggeta");
|
||||||
|
config.product = Some("USB-serial example");
|
||||||
|
config.serial_number = Some("12345678");
|
||||||
|
|
||||||
|
config.device_class = 0xEF;
|
||||||
|
config.device_sub_class = 0x02;
|
||||||
|
config.device_protocol = 0x01;
|
||||||
|
config.composite_with_iads = true;
|
||||||
|
|
||||||
|
let mut device_descriptor = [0; 512];
|
||||||
|
let mut config_descriptor = [0; 512];
|
||||||
|
let mut bos_descriptor = [0; 512];
|
||||||
|
let mut control_buf = [0; 64];
|
||||||
|
let mut msos_descriptor = [0; 512];
|
||||||
|
|
||||||
|
let mut state = State::new();
|
||||||
|
// USART1.send("starting usb task new!\n\n".as_bytes());
|
||||||
|
|
||||||
|
let mut builder = Builder::new(
|
||||||
|
driver,
|
||||||
|
config,
|
||||||
|
&mut device_descriptor,
|
||||||
|
&mut config_descriptor,
|
||||||
|
&mut bos_descriptor,
|
||||||
|
&mut msos_descriptor,
|
||||||
|
&mut control_buf,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut class = CdcAcmClass::new(&mut builder, &mut state, 64);
|
||||||
|
// Build the builder.
|
||||||
|
let mut usb = builder.build();
|
||||||
|
let usb_fut = usb.run(); // Run the USB device.
|
||||||
|
let handler_fut = async {
|
||||||
|
loop {
|
||||||
|
class.wait_connection().await;
|
||||||
|
defmt::info!("connected");
|
||||||
|
let _ = usb_handler(&mut class).await;
|
||||||
|
defmt::info!("disconnected");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// USART1.send("start usb task success!\n".as_bytes());
|
||||||
|
join(usb_fut, handler_fut).await; // Run everything concurrently.
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Disconnected {}
|
||||||
|
|
||||||
|
impl From<EndpointError> for Disconnected {
|
||||||
|
fn from(val: EndpointError) -> Self {
|
||||||
|
match val {
|
||||||
|
EndpointError::BufferOverflow => panic!("Buffer overflow"),
|
||||||
|
EndpointError::Disabled => Disconnected {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn usb_handler<'d>(class: &mut CdcAcmClass<'d, usb_otg::Driver>) -> Result<(), Disconnected> {
|
||||||
|
let mut buf: [u8; 128] = [0; 128];
|
||||||
|
// the maximum size of the command is 64 bytes
|
||||||
|
defmt::info!("start usb handler");
|
||||||
|
loop {
|
||||||
|
// select(future1, future2)
|
||||||
|
let ret = class.read_packet(&mut buf).await;
|
||||||
|
match ret {
|
||||||
|
Ok(n) => {
|
||||||
|
defmt::info!("read {} bytes", n);
|
||||||
|
class.write_packet(&buf[0..n]).await.unwrap();
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
defmt::info!("error: {:?}", e);
|
||||||
|
return Err(e.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// class.write_packet(&buf[0..n]).await.unwrap();
|
||||||
|
}
|
||||||
|
}
|
160012
stm32u575.svd
Normal file
160012
stm32u575.svd
Normal file
File diff suppressed because it is too large
Load Diff
218084
stm32u5a5.svd
Normal file
218084
stm32u5a5.svd
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user