Compare commits
21 Commits
master
...
2efee051ff
| Author | SHA1 | Date | |
|---|---|---|---|
| 2efee051ff | |||
| ca54784e64 | |||
| 71d952dce5 | |||
| 68c1ff13eb | |||
| e915deb1d5 | |||
| f069c3b4b2 | |||
| f43340db30 | |||
| b3aa8ea46a | |||
| b72be2fc3b | |||
| 7cbbe955bb | |||
| 14bb705e94 | |||
| 096fa7853f | |||
| 6991e5611e | |||
| caa1ff9f24 | |||
| 6defd8963f | |||
| 46837a68e4 | |||
| 698851cbfd | |||
| 788060bf38 | |||
| a4657e202f | |||
| aa554f1fe5 | |||
| b5e0708b09 |
12
Cargo.toml
12
Cargo.toml
@@ -3,13 +3,19 @@ name = "soft-serial"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies.ring-buffer]
|
||||||
|
git = "https://gitea.doryan04.ru/doryan/ring-buffer"
|
||||||
|
|
||||||
[dependencies.arduino-hal]
|
[dependencies.arduino-hal]
|
||||||
git = "https://github.com/rahix/avr-hal"
|
git = "https://github.com/rahix/avr-hal"
|
||||||
rev = "3e362624547462928a219c40f9ea8e3a64f21e5f"
|
rev = "3e362624547462928a219c40f9ea8e3a64f21e5f"
|
||||||
features = ["sparkfun-promicro"]
|
|
||||||
|
|
||||||
[dependencies.static_pins]
|
[dependencies.static-pins]
|
||||||
git = "https://gitea.doryan04.ru/TheEmbeddedRust/static_pins"
|
git = "https://gitea.doryan04.ru/TheEmbeddedRust/static-pins"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
sparkfun-promicro = ["arduino-hal/sparkfun-promicro", "static-pins/sparkfun-promicro"]
|
||||||
|
ring-buffer = ["dep:ring-buffer"]
|
||||||
|
|
||||||
[dependencies.avr-device]
|
[dependencies.avr-device]
|
||||||
version = "0.5.4"
|
version = "0.5.4"
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega1280",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega1280",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega1280",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega1284p",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega1284p",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega1284p",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega128a",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega128a",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega128a",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega164pa",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega164pa",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega164pa",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega168",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega168",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega168",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega2560",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega2560",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega2560",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega328",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega328",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega328",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega328p",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega328p",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega328p",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega32a",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega32a",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega32a",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega32u4",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega32u4",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega32u4",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega48p",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega48p",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega48p",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "atmega8",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=atmega8",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=atmega8",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "attiny167",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=attiny167",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=attiny167",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "attiny2313",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=attiny2313",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=attiny2313",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "attiny85",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=attiny85",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=attiny85",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"arch": "avr",
|
|
||||||
"atomic-cas": false,
|
|
||||||
"cpu": "attiny88",
|
|
||||||
"crt-objects-fallback": "false",
|
|
||||||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
|
|
||||||
"eh-frame-header": false,
|
|
||||||
"exe-suffix": ".elf",
|
|
||||||
"late-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-lgcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linker": "avr-gcc",
|
|
||||||
"linker-flavor": "gnu-cc",
|
|
||||||
"llvm-target": "avr-unknown-unknown",
|
|
||||||
"max-atomic-width": 8,
|
|
||||||
"metadata": {
|
|
||||||
"description": null,
|
|
||||||
"host_tools": null,
|
|
||||||
"std": null,
|
|
||||||
"tier": null
|
|
||||||
},
|
|
||||||
"no-default-libraries": false,
|
|
||||||
"pre-link-args": {
|
|
||||||
"gnu-cc": [
|
|
||||||
"-mmcu=attiny88",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
],
|
|
||||||
"gnu-lld-cc": [
|
|
||||||
"-mmcu=attiny88",
|
|
||||||
"-Wl,--as-needed,--print-memory-usage"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"relocation-model": "static",
|
|
||||||
"target-c-int-width": "16",
|
|
||||||
"target-pointer-width": "16"
|
|
||||||
}
|
|
||||||
174
src/lib.rs
174
src/lib.rs
@@ -4,7 +4,6 @@ use core::marker::PhantomData;
|
|||||||
|
|
||||||
use arduino_hal::{
|
use arduino_hal::{
|
||||||
delay_us,
|
delay_us,
|
||||||
pac::EXINT,
|
|
||||||
port::{
|
port::{
|
||||||
mode::{Input, PullUp},
|
mode::{Input, PullUp},
|
||||||
Pin, PinOps,
|
Pin, PinOps,
|
||||||
@@ -15,6 +14,10 @@ use avr_device::asm::delay_cycles;
|
|||||||
|
|
||||||
use static_pins::StaticPinOps;
|
use static_pins::StaticPinOps;
|
||||||
|
|
||||||
|
mod structures;
|
||||||
|
|
||||||
|
pub use structures::ring_buffer::*;
|
||||||
|
|
||||||
pub type PollResult = Result<(), PollError>;
|
pub type PollResult = Result<(), PollError>;
|
||||||
pub type ReadByteResult = Result<u8, CorruptedData>;
|
pub type ReadByteResult = Result<u8, CorruptedData>;
|
||||||
pub type CorruptedData = (u8, u8);
|
pub type CorruptedData = (u8, u8);
|
||||||
@@ -25,8 +28,12 @@ const SECOND_HALF_SERIAL_DELAY: u32 = SERIAL_DELAY - FIRST_HALF_SERIAL_DELAY;
|
|||||||
|
|
||||||
const READING_ADJUST: u32 = 16;
|
const READING_ADJUST: u32 = 16;
|
||||||
const FIRST_ENTRY_READING: u32 = 30;
|
const FIRST_ENTRY_READING: u32 = 30;
|
||||||
const LSB: u8 = 0x01;
|
const MSB: u16 = 0x0200;
|
||||||
const MSB: u8 = 0x80;
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn crc_calculate(value: u8) -> u8 {
|
||||||
|
((value >> 6) | (value >> 4) | (value >> 2) | value) & 0x0F
|
||||||
|
}
|
||||||
|
|
||||||
pub enum PollError {
|
pub enum PollError {
|
||||||
NotFound,
|
NotFound,
|
||||||
@@ -42,59 +49,15 @@ where
|
|||||||
P: PinOps + StaticPinOps,
|
P: PinOps + StaticPinOps,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_pin: Pin<Input<PullUp>, P>, exint: &EXINT) -> Self {
|
pub fn new(_pin: Pin<Input<PullUp>, P>) -> Self {
|
||||||
exint.eimsk.write(|w| w.bits(1 << 1));
|
|
||||||
exint.eicra.write(|w| unsafe { w.bits(!(1 << 3 | 1 << 2)) });
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
_pin: PhantomData {},
|
_pin: PhantomData {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub trait SoftSerial<P>
|
pub fn poll(&self) -> PollResult {
|
||||||
where
|
|
||||||
P: PinOps + StaticPinOps,
|
|
||||||
{
|
|
||||||
fn poll(&self) -> PollResult;
|
|
||||||
fn response(&self);
|
|
||||||
|
|
||||||
fn sync_reciever(&self);
|
|
||||||
fn sync_transmitter(&self);
|
|
||||||
|
|
||||||
fn write_byte(&self, data: u8);
|
|
||||||
fn read_byte(&self) -> ReadByteResult;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn finish_write(&self) {
|
|
||||||
P::into_pull_up_input();
|
|
||||||
while P::is_low() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write_bytes(&self, transmit_data: &[u8]) {
|
|
||||||
for byte in transmit_data {
|
|
||||||
self.write_byte(*byte);
|
|
||||||
self.sync_transmitter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_bytes(&self, recieve_buffer: &mut [u8]) {
|
|
||||||
for byte in recieve_buffer {
|
|
||||||
if let Ok(data) = self.read_byte() {
|
|
||||||
*byte = data;
|
|
||||||
}
|
|
||||||
self.sync_reciever();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<P> SoftSerial<P> for HalfDuplexSerial<P>
|
|
||||||
where
|
|
||||||
P: PinOps + StaticPinOps,
|
|
||||||
{
|
|
||||||
fn poll(&self) -> PollResult {
|
|
||||||
P::into_output();
|
P::into_output();
|
||||||
delay_cycles(1);
|
delay_cycles(4);
|
||||||
P::into_pull_up_input();
|
P::into_pull_up_input();
|
||||||
|
|
||||||
delay_us(SERIAL_DELAY);
|
delay_us(SERIAL_DELAY);
|
||||||
@@ -114,7 +77,7 @@ where
|
|||||||
PollResult::Ok(())
|
PollResult::Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn response(&self) {
|
pub fn response(&self) {
|
||||||
P::into_output_high();
|
P::into_output_high();
|
||||||
|
|
||||||
delay_us(FIRST_HALF_SERIAL_DELAY);
|
delay_us(FIRST_HALF_SERIAL_DELAY);
|
||||||
@@ -127,7 +90,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn sync_transmitter(&self) {
|
pub fn sync_transmitter(&self) {
|
||||||
P::into_output();
|
P::into_output();
|
||||||
|
|
||||||
delay_us(SERIAL_DELAY);
|
delay_us(SERIAL_DELAY);
|
||||||
@@ -136,74 +99,115 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn sync_reciever(&self) {
|
pub fn sync_reciever(&self) {
|
||||||
while P::is_high() {}
|
while P::is_high() {}
|
||||||
|
|
||||||
while P::is_low() {}
|
while P::is_low() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline]
|
||||||
fn write_byte(&self, data: u8) {
|
pub fn reset(&self) {
|
||||||
let (mut data, mut parity_bit) = (data, 0);
|
P::into_pull_up_input();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _ in 0..8 {
|
pub trait SoftSerialWriter<P, T>: SoftSerialByteWriter<P>
|
||||||
|
where
|
||||||
|
P: PinOps + StaticPinOps,
|
||||||
|
{
|
||||||
|
fn write_bytes(&self, transmit_data: T);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait SoftSerialReader<P, T>: SoftSerialByteReader<P>
|
||||||
|
where
|
||||||
|
P: PinOps + StaticPinOps,
|
||||||
|
{
|
||||||
|
fn read_bytes(&self, recieve_data: T);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait SoftSerialByteWriter<P>
|
||||||
|
where
|
||||||
|
P: PinOps + StaticPinOps,
|
||||||
|
{
|
||||||
|
#[inline(never)]
|
||||||
|
fn write_byte(&self, transmit_data: u8) {
|
||||||
|
let mut data = ((transmit_data as u16) << 4) | (crc_calculate(transmit_data) as u16);
|
||||||
|
|
||||||
|
for _ in 0..(u8::BITS + 4) {
|
||||||
if data & MSB == 0 {
|
if data & MSB == 0 {
|
||||||
P::set_high();
|
P::set_high();
|
||||||
parity_bit ^= 0;
|
|
||||||
} else {
|
} else {
|
||||||
P::set_low();
|
P::set_low();
|
||||||
parity_bit ^= 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delay_us(SERIAL_DELAY);
|
delay_us(SERIAL_DELAY);
|
||||||
|
|
||||||
data <<= 1;
|
data <<= 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Hamming code and CRC are very weightful and slow, so I use simple parity check
|
|
||||||
|
|
||||||
if parity_bit == 0 {
|
|
||||||
P::set_high();
|
|
||||||
} else {
|
|
||||||
P::set_low();
|
|
||||||
}
|
|
||||||
|
|
||||||
delay_us(SERIAL_DELAY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait SoftSerialByteReader<P>
|
||||||
|
where
|
||||||
|
P: PinOps + StaticPinOps,
|
||||||
|
{
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn read_byte(&self) -> ReadByteResult {
|
fn read_byte(&self) -> ReadByteResult {
|
||||||
let (mut data, mut reciever_parity_bit) = (0, 0);
|
let mut packet = 0u16;
|
||||||
|
|
||||||
delay_cycles(FIRST_ENTRY_READING);
|
delay_cycles(FIRST_ENTRY_READING);
|
||||||
for _ in 0..8 {
|
for _ in 0..(u8::BITS + 4) {
|
||||||
delay_us(FIRST_HALF_SERIAL_DELAY);
|
delay_us(FIRST_HALF_SERIAL_DELAY);
|
||||||
|
|
||||||
|
packet <<= 1;
|
||||||
|
|
||||||
if P::is_low() {
|
if P::is_low() {
|
||||||
data |= 1;
|
packet |= 1;
|
||||||
reciever_parity_bit ^= 1;
|
|
||||||
} else {
|
} else {
|
||||||
data |= 0;
|
packet |= 0;
|
||||||
reciever_parity_bit ^= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delay_cycles(READING_ADJUST);
|
delay_cycles(READING_ADJUST);
|
||||||
delay_us(SECOND_HALF_SERIAL_DELAY);
|
delay_us(SECOND_HALF_SERIAL_DELAY);
|
||||||
|
|
||||||
data <<= 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delay_us(FIRST_HALF_SERIAL_DELAY);
|
let received_crc = (packet & 0x000F) as u8;
|
||||||
|
let data = packet.overflowing_shr(4).0 as u8;
|
||||||
|
let calculated_crc = crc_calculate(data);
|
||||||
|
|
||||||
let transmitter_parity_bit = (P::read() >> P::PIN_NUM) & LSB;
|
if received_crc != calculated_crc {
|
||||||
|
return Err((received_crc, calculated_crc));
|
||||||
delay_cycles(READING_ADJUST);
|
|
||||||
delay_us(SECOND_HALF_SERIAL_DELAY);
|
|
||||||
|
|
||||||
if reciever_parity_bit != transmitter_parity_bit {
|
|
||||||
return Err((data, reciever_parity_bit));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(data)
|
Ok(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<P: PinOps + StaticPinOps> SoftSerialByteWriter<P> for HalfDuplexSerial<P> {}
|
||||||
|
impl<P: PinOps + StaticPinOps> SoftSerialByteReader<P> for HalfDuplexSerial<P> {}
|
||||||
|
|
||||||
|
impl<P> SoftSerialWriter<P, &[u8]> for HalfDuplexSerial<P>
|
||||||
|
where
|
||||||
|
P: PinOps + StaticPinOps,
|
||||||
|
{
|
||||||
|
fn write_bytes(&self, transmit_data: &[u8]) {
|
||||||
|
for byte in transmit_data {
|
||||||
|
self.write_byte(*byte);
|
||||||
|
self.sync_transmitter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P> SoftSerialReader<P, &mut [u8]> for HalfDuplexSerial<P>
|
||||||
|
where
|
||||||
|
P: PinOps + StaticPinOps,
|
||||||
|
{
|
||||||
|
fn read_bytes(&self, recieve_data: &mut [u8]) {
|
||||||
|
for byte in recieve_data {
|
||||||
|
if let Ok(data) = self.read_byte() {
|
||||||
|
*byte = data;
|
||||||
|
}
|
||||||
|
self.sync_reciever();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
1
src/structures/mod.rs
Normal file
1
src/structures/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod ring_buffer;
|
||||||
47
src/structures/ring_buffer.rs
Normal file
47
src/structures/ring_buffer.rs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
// Thanks to Low Byte Productions, I like this channel.
|
||||||
|
// Youtube: https://www.youtube.com/watch?v=uIJnATS9j_0
|
||||||
|
|
||||||
|
use arduino_hal::port::PinOps;
|
||||||
|
use static_pins::StaticPinOps;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
HalfDuplexSerial, SoftSerialByteReader, SoftSerialByteWriter, SoftSerialReader,
|
||||||
|
SoftSerialWriter,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "ring-buffer")]
|
||||||
|
impl<const N: usize, P> SoftSerialWriter<P, &mut RingBuffer<N>> for HalfDuplexSerial<P>
|
||||||
|
where
|
||||||
|
P: PinOps + StaticPinOps,
|
||||||
|
{
|
||||||
|
#[inline(never)]
|
||||||
|
fn write_bytes(&self, transmit_data: &mut RingBuffer<N>) {
|
||||||
|
self.write_byte(transmit_data.len() as u8);
|
||||||
|
|
||||||
|
for byte in transmit_data {
|
||||||
|
self.sync_transmitter();
|
||||||
|
self.write_byte(byte);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ring-buffer")]
|
||||||
|
impl<const N: usize, P> SoftSerialReader<P, &mut RingBuffer<N>> for HalfDuplexSerial<P>
|
||||||
|
where
|
||||||
|
P: PinOps + StaticPinOps,
|
||||||
|
{
|
||||||
|
#[inline(never)]
|
||||||
|
fn read_bytes(&self, recieve_data: &mut RingBuffer<N>) {
|
||||||
|
let byte = self.read_byte();
|
||||||
|
|
||||||
|
if let Ok(len) = byte {
|
||||||
|
for _ in 0..len {
|
||||||
|
self.sync_reciever();
|
||||||
|
|
||||||
|
if let Ok(byte) = self.read_byte() {
|
||||||
|
recieve_data.push(byte);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user