::Duty) {
41 | let clamped_duty = duty.min(self.get_max_duty());
42 | hwa::trace!("set_duty: curr: {}, max: {}, next: {}",
43 | *self.duty_map.get(&channel).unwrap_or(&0),
44 | self.get_max_duty(),
45 | clamped_duty,
46 | );
47 | self.duty_map.insert(channel, clamped_duty);
48 | }
49 | fn set_period(&mut self, _: P) where P: Into { }
50 | }
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_native/src/board/mocked_peripherals/mocked_sd_card.rs:
--------------------------------------------------------------------------------
1 | use printhor_hwa_common as hwa;
2 | use std::cell::RefCell;
3 | use std::fs::File;
4 | use std::io::{Read, Seek, SeekFrom, Write};
5 | use std::path::Path;
6 | use hwa::traits::{AsyncSDBlockDevice, SDBlockDevice};
7 | use embedded_sdmmc::{Block, BlockCount, BlockIdx};
8 |
9 | #[derive(Debug, Clone)]
10 | enum Error {
11 | #[allow(unused)]
12 | Filesystem(embedded_sdmmc::Error),
13 | #[allow(unused)]
14 | Disk(embedded_sdmmc::SdCardError),
15 | }
16 |
17 | impl From> for Error {
18 | fn from(value: embedded_sdmmc::Error) -> Error {
19 | Error::Filesystem(value)
20 | }
21 | }
22 |
23 | impl From for Error {
24 | fn from(value: embedded_sdmmc::SdCardError) -> Error {
25 | Error::Disk(value)
26 | }
27 | }
28 |
29 | pub struct MockedSDCardBlockDevice {
30 | file: RefCell,
31 | }
32 |
33 | impl MockedSDCardBlockDevice {
34 | pub fn new(image_path: P) -> Result
35 | where P: AsRef,
36 | {
37 | Ok(MockedSDCardBlockDevice {
38 | file: RefCell::new(File::open(image_path)?),
39 | })
40 | }
41 | }
42 |
43 | impl AsyncSDBlockDevice for MockedSDCardBlockDevice {
44 | async fn do_retain(&self) -> Result<(), ()> {
45 | Ok(())
46 | }
47 | fn do_release(&self) -> Result<(), ()> {
48 | Ok(())
49 | }
50 | }
51 |
52 | impl SDBlockDevice for MockedSDCardBlockDevice {
53 | type Error = std::io::Error;
54 |
55 | fn read(
56 | &self,
57 | blocks: &mut [Block],
58 | start_block_idx: BlockIdx,
59 | _reason: &str,
60 | ) -> Result<(), Self::Error> {
61 | self.file
62 | .borrow_mut()
63 | .seek(SeekFrom::Start(start_block_idx.into_bytes()))?;
64 | for block in blocks.iter_mut() {
65 | self.file.borrow_mut().read_exact(&mut block.contents)?;
66 | }
67 | Ok(())
68 | }
69 |
70 | fn write(&self, blocks: &[Block], start_block_idx: BlockIdx) -> Result<(), Self::Error> {
71 | self.file
72 | .borrow_mut()
73 | .seek(SeekFrom::Start(start_block_idx.into_bytes()))?;
74 | for block in blocks.iter() {
75 | self.file.borrow_mut().write_all(&block.contents)?;
76 | }
77 | Ok(())
78 | }
79 |
80 | fn num_blocks(&self) -> Result {
81 | let num_blocks = self.file.borrow().metadata().unwrap().len() / 512;
82 | Ok(BlockCount(num_blocks as u32))
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_native/src/board/mocked_peripherals/mocked_spi.rs:
--------------------------------------------------------------------------------
1 | use embedded_hal_0::blocking::spi;
2 |
3 | pub struct MockedSpi {
4 | }
5 |
6 | impl MockedSpi {
7 | pub fn new() -> Self {
8 | Self {}
9 | }
10 |
11 | #[allow(unused)]
12 | pub fn blocking_transfer_in_place(&mut self, _buff: &mut [T]) {}
13 |
14 | #[allow(unused)]
15 | pub fn blocking_write(&mut self, _buff: &[T]) {}
16 | }
17 |
18 | impl spi::Transfer for MockedSpi {
19 | type Error = core::convert::Infallible;
20 | fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error> {
21 | Ok(words)
22 | }
23 | }
24 |
25 | impl spi::Write for MockedSpi {
26 | type Error = core::convert::Infallible;
27 | fn write<'w>(&mut self, _words: &'w [u8]) -> Result<(), Self::Error> {
28 | Ok(())
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_native/src/board/mocked_peripherals/mocked_uart.rs:
--------------------------------------------------------------------------------
1 | use printhor_hwa_common as hwa;
2 |
3 | use std::io::{stdout, Write};
4 | use embassy_executor::SendSpawner;
5 | use embassy_sync::pipe::Pipe;
6 | use embassy_time::{Duration, with_timeout};
7 | use async_std::io::ReadExt;
8 | use printhor_hwa_common::HwiContract;
9 | use crate::board::TERMINATION;
10 |
11 | pub static SERIAL_PIPE: Pipe = Pipe::::new();
12 | #[embassy_executor::task(pool_size=1)]
13 | pub async fn task_mocked_uart() {
14 |
15 | hwa::info!("[task_mocked_uart] starting");
16 |
17 | // byte-to-byte reading is required for stdin for it to work unbuffered with simple I/O management.
18 | // Another solution could be leveraging a wrapper/crate on top of native select() with the proper ioctl on stdin, but is not worthy in this case.
19 | // Unbuffered I/O requirement for piping simulator with Universal Gcode Sender and others by socat.
20 |
21 | let mut stream = async_std::io::stdin();
22 | let mut buf = [0u8; 1];
23 | let mut error_reading = false;
24 |
25 | loop {
26 | match with_timeout(
27 | Duration::from_secs(60),
28 | stream.read_exact(&mut buf)
29 | ).await {
30 | Err(_) => {
31 | if TERMINATION.signaled() {
32 | hwa::info!("[task_mocked_uart] Ending gracefully");
33 | return ();
34 | }
35 | }
36 | Ok(Ok(_)) => {
37 | error_reading = false; // Recovered
38 | SERIAL_PIPE.write(&buf[..1]).await;
39 | }
40 | Ok(Err(_e)) => { // Error reading from stdin: Closed or temporary unavailable
41 | if !error_reading {
42 | hwa::trace!("[task_mocked_uart] Error reading from stdin {:?}", _e);
43 | error_reading = true;
44 | if TERMINATION.signaled() {
45 | hwa::info!("[task_mocked_uart] Ending gracefully");
46 | return ();
47 | }
48 | }
49 | else {
50 | // Could happen. For instance in CI.
51 | // In this case we will wait to avoid respawning fast and keep trying in case it
52 | // can be recovered (practically improbable)
53 | embassy_time::Timer::after(Duration::from_secs(10)).await;
54 | }
55 | }
56 | }
57 | }
58 | }
59 |
60 | pub struct MockedUart {
61 | spawner: SendSpawner,
62 | }
63 |
64 | impl MockedUart {
65 | pub(crate) fn new(spawner: SendSpawner) -> Self {
66 |
67 | spawner.spawn(task_mocked_uart()).unwrap();
68 |
69 | Self {
70 | spawner,
71 | }
72 | }
73 |
74 | pub(crate) fn split(&self) -> (MockedUartTx, MockedUartRx) {
75 | (MockedUartTx::new(), MockedUartRx::new(self.spawner))
76 | }
77 | }
78 |
79 | pub struct MockedUartRx {
80 | }
81 |
82 | impl MockedUartRx {
83 | pub(crate) fn new(_spawner: SendSpawner) -> Self {
84 | Self {
85 | }
86 | }
87 | pub async fn read_until_idle(&mut self, buffer: &mut [u8]) -> Result {
88 | hwa::trace!("Reading from pipe");
89 | Ok(SERIAL_PIPE.read(buffer).await)
90 | }
91 | }
92 |
93 | pub struct MockedUartTx {
94 | }
95 | impl MockedUartTx {
96 | pub(crate) const fn new() -> Self {
97 | Self {
98 | }
99 | }
100 |
101 | pub async fn write_packet(&mut self, b: &[u8]) {
102 | self.wrapped_write(b).await;
103 | }
104 | pub async fn wrapped_flush(&mut self) {
105 | }
106 | pub async fn wrapped_write(&mut self, b: &[u8]) {
107 | print!("{}", std::str::from_utf8(b).unwrap());
108 | let _ = stdout().flush().ok();
109 | }
110 | }
111 |
112 | pub struct MockedUartRxInputStream {
113 | pub receiver: MockedUartRx,
114 | buffer: [u8; BUF_SIZE],
115 | bytes_read: u8,
116 | current_byte_index: u8,
117 | }
118 |
119 | impl MockedUartRxInputStream
120 | {
121 | pub fn new(receiver: MockedUartRx) -> Self {
122 | Self {
123 | receiver,
124 | buffer: [0; BUFF_SIZE],
125 | bytes_read: 0,
126 | current_byte_index: 0,
127 | }
128 | }
129 | }
130 |
131 | impl async_gcode::ByteStream for MockedUartRxInputStream
132 | {
133 | type Item = Result;
134 |
135 | async fn next(&mut self) -> Option {
136 |
137 | if self.current_byte_index < self.bytes_read {
138 | let byte = self.buffer[self.current_byte_index as usize];
139 | self.current_byte_index += 1;
140 | Some(Ok(byte))
141 | }
142 | else {
143 | self.current_byte_index = 0;
144 | self.bytes_read = 0;
145 | let r = self.receiver.read_until_idle(&mut self.buffer).await;
146 | match r {
147 | Ok(n) => {
148 | self.bytes_read = n as u8;
149 | if n > 0 {
150 | let byte = self.buffer[self.current_byte_index as usize];
151 | self.current_byte_index += 1;
152 | Some(Ok(byte))
153 | }
154 | else {
155 | hwa::error!("0 bytes read. EOF?");
156 | None
157 | }
158 | }
159 | Err(_e) => {
160 | hwa::error!("Error: {:?}", _e);
161 | None
162 | }
163 | }
164 | }
165 | }
166 |
167 | async fn recovery_check(&mut self) {
168 | }
169 |
170 | }
171 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_native/src/board/mocked_peripherals/mocked_uart_sink.rs:
--------------------------------------------------------------------------------
1 | use core::future;
2 |
3 | // A mocked Uart which does nothing
4 | pub struct MockedUartSink {
5 | }
6 |
7 | impl MockedUartSink {
8 | pub fn new() -> Self {
9 | Self {
10 | }
11 | }
12 |
13 | pub fn split(&self) -> (MockedUartSinkTx, MockedUartSinkRx) {
14 | (MockedUartSinkTx::new(), MockedUartSinkRx::new())
15 | }
16 | }
17 |
18 | pub struct MockedUartSinkRx {
19 | }
20 |
21 | impl MockedUartSinkRx {
22 | pub(crate) fn new() -> Self {
23 | Self {
24 | }
25 | }
26 | }
27 |
28 | pub struct MockedUartSinkTx {
29 | }
30 | impl MockedUartSinkTx {
31 | pub(crate) const fn new() -> Self {
32 | Self {}
33 | }
34 | pub fn blocking_flush(&mut self) {}
35 |
36 | pub async fn write(&mut self, _b: &[u8]) {}
37 |
38 | pub async fn write_packet(&mut self, _b: &[u8]) {}
39 |
40 | pub async fn wrapped_flush(&mut self) {}
41 | pub async fn wrapped_write(&mut self, _b: &[u8]) {}
42 | }
43 |
44 | pub struct MockedUartSinkRxInputStream {
45 | pub receiver: MockedUartSinkRx,
46 | }
47 |
48 | impl MockedUartSinkRxInputStream {
49 | pub fn new(receiver: MockedUartSinkRx) -> Self {
50 | Self {
51 | receiver
52 | }
53 | }
54 | }
55 |
56 | impl async_gcode::ByteStream for MockedUartSinkRxInputStream
57 | {
58 | type Item = Result;
59 |
60 |
61 | async fn next(&mut self) -> Option {
62 | future::pending().await
63 | }
64 |
65 | async fn recovery_check(&mut self) {}
66 | }
67 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_native/src/board/mocked_peripherals/mocked_wdt.rs:
--------------------------------------------------------------------------------
1 | use std::marker::PhantomData;
2 | use embassy_executor::SendSpawner;
3 |
4 | pub struct MockedWatchdog<'a, T> {
5 | _spawner: SendSpawner,
6 | _timeout: u32,
7 | p: PhantomData<&'a T>,
8 | }
9 | impl<'a, T> MockedWatchdog<'a, T> {
10 |
11 | pub(crate) const fn new(spawner: SendSpawner, timeout: u32) -> Self {
12 | Self {
13 | _spawner: spawner,
14 | _timeout: timeout,
15 | p: PhantomData,
16 | }
17 | }
18 |
19 | pub fn unleash(&mut self) {
20 | }
21 |
22 | pub fn pet(&mut self) {
23 | //println!("pet!");
24 | }
25 | }
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_native/src/board/mocked_peripherals/mod.rs:
--------------------------------------------------------------------------------
1 | #[cfg(any(feature = "with-hot-bed", feature = "with-hot-end"))]
2 | mod mocked_adc;
3 |
4 | pub(crate) mod mocked_pin;
5 | #[cfg(any(feature = "with-probe", feature = "with-hot-bed", feature = "with-hot-end", feature = "with-fan-layer", feature = "with-laser", feature = "with-fan-extra-1"))]
6 | mod mocked_pwm;
7 |
8 | cfg_if::cfg_if! {
9 | if #[cfg(feature = "with-serial-usb")] {
10 | mod mocked_uart_unix_socket;
11 | pub use mocked_uart_unix_socket::*;
12 | }
13 | }
14 |
15 | cfg_if::cfg_if! {
16 | if #[cfg(feature = "with-serial-port-1")] {
17 | mod mocked_uart;
18 | pub use mocked_uart::*;
19 | }
20 | }
21 |
22 | cfg_if::cfg_if! {
23 | if #[cfg(feature = "with-serial-port-2")] {
24 | mod mocked_uart_sink;
25 | pub use mocked_uart_sink::*;
26 | }
27 | }
28 |
29 | cfg_if::cfg_if! {
30 | if #[cfg(feature = "with-spi")] {
31 | mod mocked_spi;
32 | #[allow(unused)]
33 | pub use mocked_spi::*;
34 | }
35 | }
36 |
37 | cfg_if::cfg_if! {
38 | if #[cfg(feature = "with-i2c")] {
39 | mod mocked_i2c;
40 | pub use mocked_i2c::*;
41 | }
42 | }
43 |
44 | cfg_if::cfg_if! {
45 | if #[cfg(feature = "with-sd-card")] {
46 | mod mocked_sd_card;
47 | pub use mocked_sd_card::MockedSDCardBlockDevice;
48 | }
49 | }
50 |
51 | #[cfg(feature = "with-trinamic")]
52 | mod mocked_trinamic;
53 |
54 | mod mocked_wdt;
55 |
56 | #[allow(unused)]
57 | pub use mocked_pin::*;
58 |
59 | pub use mocked_wdt::*;
60 |
61 |
62 |
63 | #[cfg(feature = "with-spi")]
64 | pub use mocked_spi::*;
65 |
66 | #[cfg(feature = "with-trinamic")]
67 | pub use mocked_trinamic::*;
68 |
69 | #[cfg(any(feature = "with-probe", feature = "with-hot-bed", feature = "with-hot-end", feature = "with-fan-layer", feature = "with-laser", feature = "with-fan-extra-1"))]
70 | pub use mocked_pwm::*;
71 |
72 | #[cfg(any(feature = "with-hot-bed", feature = "with-hot-end"))]
73 | pub use mocked_adc::*;
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_nucleo_64_arduino_cnc_hat/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [env]
2 |
3 | ###########################
4 | ## Configuration - BEGIN ##
5 | ###########################
6 |
7 | ## Heater and bed configuration (thermistor based) ##
8 |
9 | # [Depends on the board] the pull-up resistance of hot-end sensor circuit in ohms
10 | HOT_END_THERM_PULL_UP_RESISTANCE = "4685.0"
11 | # Nominal resistance of hot-end NTC thermistor at 25ºC
12 | HOT_END_THERM_NOMINAL_RESISTANCE = "100000.0"
13 | # BETA value of hot-end NTC thermistor
14 | HOT_END_THERM_BETA = "3950.0"
15 |
16 | # [Depends on the board] the pull-up resistance of hot-bed sensor circuit in ohms
17 | HOT_BED_THERM_PULL_UP_RESISTANCE = "4685.0"
18 | # Nominal resistance of hot-bed NTC thermistor at 25ºC
19 | HOT_BED_THERM_NOMINAL_RESISTANCE = "100000.0"
20 | # BETA value of hot-bed NTC thermistor
21 | HOT_BED_THERM_BETA = "3950.0"
22 |
23 | ## Pure technical stuff ##
24 |
25 | DEFMT_LOG = "info"
26 | RUST_LOG = "warn"
27 | ASYNC_STD_THREAD_COUNT = "1"
28 | EMBASSY_USB_MAX_INTERFACE_COUNT = "2"
29 |
30 | ###########################
31 | ## Configuration - END ##
32 | ###########################
33 |
34 | [target.'cfg(all(any(board="nucleo64-f410rb"), target_arch="arm", target_os="none"))']
35 | runner = "probe-run --chip STM32F410RBTx --connect-under-reset --log-format {L}{s}"
36 | #rustflags = [ "-C", "linker=flip-link" ]
37 | #linker = "flip-link"
38 |
39 | [target.'cfg(all(any(board="nucleo64-l476rg"), target_arch="arm", target_os="none"))']
40 | runner = "probe-rs run --chip STM32L476RGTx --log-format {L}{s}"
41 | #rustflags = [ "-C", "linker=flip-link" ]
42 | #linker = "flip-link"
43 |
44 | [build]
45 | target = "thumbv7em-none-eabihf"
46 |
47 | [profile.dev.package."*"]
48 | codegen-units = 1
49 | incremental = false
50 | #opt-level = "s" # Set to "s" or even disable to play with GDB
51 | debug = 2
52 | debug-assertions = true
53 | overflow-checks = true
54 |
55 | [profile.release.package."*"]
56 | codegen-units = 1
57 | incremental = false
58 | opt-level = "z"
59 | debug = 2
60 | debug-assertions = true
61 | overflow-checks = true
62 |
63 | [profile.release-opt.package."*"]
64 | codegen-units = 1
65 | incremental = false
66 | opt-level = "z"
67 | debug = 0
68 | debug-assertions = false
69 | overflow-checks = false
70 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_nucleo_64_arduino_cnc_hat/README.md:
--------------------------------------------------------------------------------
1 | 
2 | [](https://crates.io/crates/prinThor)
3 | [](https://opensource.org/licenses/MIT)
4 | 
5 |
6 | Printhor: The highly reliable but not necessarily functional 3D printer firmware
7 |
8 | If you are using this product or like the project, please ★ this repository to show your support! 🤩
9 |
10 | # Overview
11 |
12 | There are two base boards supported in this category.
13 | The assumption/requirement is to use any of these generic purpose development board with the Arduino CNC Shield v3 (hat):
14 | 
15 |
16 | **Important**: Upgrade the Nucleo ST-LINK/V2 firmware to at least: Version: V2J43M28 Build: Jun 16 2023 16:43:19
17 |
18 | In these development boards, flash and run can be directly performed with probe-rs just connecting USB as they have a built-in SWD/JTAG interface:
19 |
20 | ### nucleo-f410rb
21 | https://os.mbed.com/platforms/ST-Nucleo-F410RB/
22 |
23 | Please, note that this board is very limited in terms of flash and memory (32kB SRAM, 128kB flash).
24 | You might not assume that a firwmare not optimized for size (LTO, etc...) will fit in flash.
25 |
26 | Note: This target uses flip-link by default, requiring flip-link tool. To change this behavior please check .cargo/config.toml
27 | ```shell
28 | cargo install flip-link
29 | ```
30 |
31 | ```shell
32 | DEFMT_LOG=info RUST_BACKTRACE=0 RUSTFLAGS='--cfg board_stm32l4="nucleo64-f410rb"' cargo run --release --no-default-features --features nucleo_64_arduino_cnc_hat,nucleo64-f410rb --target thumbv7em-none-eabihf --bin printhor
33 | ```
34 |
35 | ### nucleo-l476rg
36 | https://os.mbed.com/platforms/ST-Nucleo-L476RG/
37 |
38 | This one is a bit slower but much more RAM and flash. Enough even though with not very optimized firmware and many features
39 |
40 | ```shell
41 | DEFMT_LOG=info RUST_BACKTRACE=0 RUSTFLAGS='--cfg board_stm32l4="nucleo64-l476rg"' cargo run --release --no-default-features --features nucleo_64_arduino_cnc_hat,nucleo64-l476rg --target thumbv7em-none-eabihf --bin printhor
42 | ```
43 |
44 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_nucleo_64_arduino_cnc_hat/src/board_stm32f4/types.rs:
--------------------------------------------------------------------------------
1 | use printhor_hwa_common as hwa;
2 |
3 | //#region "General controllers lock types"
4 | pub type EventBusPubSubMutexType = hwa::AsyncNoopMutexType;
5 | pub type EventBusLockType = hwa::AsyncNoopMutexType;
6 | //#endregion
7 |
8 | //#region "HWI Shared controllers lock types"
9 | pub type WatchDogLockType = hwa::AsyncNoopMutexType;
10 |
11 | //#endregion
12 |
13 | //#region "General controllers locking strategy customization"
14 | pub type EventBusMutexStrategy = hwa::AsyncStandardStrategy>;
15 | pub type WatchDogMutexStrategy = hwa::AsyncStandardStrategy;
16 | //#endregion
17 |
18 | //#region "Shared controllers locking strategy customization"
19 | cfg_if::cfg_if! {
20 | if #[cfg(feature = "with-serial-port-1")] {
21 | pub type SerialPort1TxLockType = hwa::AsyncNoopMutexType;
22 | pub type SerialPort1TxMutexStrategy = hwa::AsyncStandardStrategy;
23 | }
24 | }
25 |
26 | cfg_if::cfg_if! {
27 | if #[cfg(feature = "with-serial-port-2")] {
28 | pub type SerialPort2TxLockType = hwa::AsyncNoopMutexType;
29 | pub type SerialPort2TxMutexStrategy = hwa::AsyncStandardStrategy;
30 | }
31 | }
32 |
33 | cfg_if::cfg_if! {
34 | if #[cfg(any(feature = "with-motion", feature = "with-hot-end", feature = "with-hot-bed"))] {
35 | pub type DeferChannelMutexType = hwa::AsyncNoopMutexType;
36 | }
37 | }
38 |
39 | cfg_if::cfg_if! {
40 | if #[cfg(feature = "with-motion")] {
41 | pub type StepActuatorMutexType = hwa::SyncCsMutexType;
42 | pub type MotionSignalMutexType = hwa::AsyncNoopMutexType;
43 | pub type MotionRingBufferMutexType = hwa::AsyncNoopMutexType;
44 | pub type MotionConfigMutexType = hwa::AsyncCsMutexType;
45 | pub type MotionStatusMutexType = hwa::AsyncNoopMutexType;
46 | pub type MotionDriverMutexType = hwa::AsyncNoopMutexType;
47 |
48 | pub type StepActuatorMuxtexStrategy = hwa::SyncStandardStrategy;
49 | }
50 | }
51 |
52 | cfg_if::cfg_if! {
53 | if #[cfg(all(feature = "with-motion", feature = "with-motion-broadcast"))] {
54 | pub type MotionBroadcastChannelMutexType = hwa::AsyncCsMutexType;
55 |
56 | pub type MotionSenderMutexType = I2cMutexType;
57 |
58 | pub type MotionSenderMutexStrategy = hwa::AsyncStandardStrategy;
59 | }
60 | }
61 |
62 | cfg_if::cfg_if! {
63 | if #[cfg(feature = "with-ps-on")] {
64 | pub type PSOnLockType = hwa::SyncNoopMutexType;
65 | pub type PSOnMutexStrategy = hwa::SyncStandardStrategy;
66 | }
67 | }
68 |
69 | cfg_if::cfg_if! {
70 | if #[cfg(feature = "with-spi")] {
71 | pub type Spi1MutexType = hwa::AsyncNoopMutexType;
72 | pub type Spi1MutexStrategyType = hwa::AsyncHoldableStrategy;
73 | }
74 | }
75 |
76 | cfg_if::cfg_if! {
77 | if #[cfg(feature = "with-i2c")] {
78 | pub type I2cMutexType = hwa::AsyncCsMutexType;
79 | pub type I2cMutexStrategyType = hwa::AsyncStandardStrategy;
80 | }
81 | }
82 |
83 | cfg_if::cfg_if! {
84 | if #[cfg(feature = "with-laser")] {
85 | pub type LaserMutexType = hwa::SyncCsMutexType;
86 | pub type LaserPwmMutexStrategy = hwa::SyncStandardStrategy;
87 | }
88 | }
89 | //#endregion
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_nucleo_64_arduino_cnc_hat/src/board_stm32l4/types.rs:
--------------------------------------------------------------------------------
1 | use printhor_hwa_common as hwa;
2 |
3 | //#region "General controllers lock types"
4 | pub type EventBusPubSubMutexType = hwa::AsyncNoopMutexType;
5 | pub type EventBusLockType = hwa::AsyncNoopMutexType;
6 | //#endregion
7 |
8 | //#region "HWI Shared controllers lock types"
9 | pub type WatchDogLockType = hwa::AsyncNoopMutexType;
10 |
11 | //#endregion
12 |
13 | //#region "General controllers locking strategy customization"
14 | pub type EventBusMutexStrategy = hwa::AsyncStandardStrategy>;
15 | pub type WatchDogMutexStrategy = hwa::AsyncStandardStrategy;
16 | //#endregion
17 |
18 | //#region "Shared controllers locking strategy customization"
19 | cfg_if::cfg_if! {
20 | if #[cfg(feature = "with-serial-port-1")] {
21 | pub type SerialPort1TxLockType = hwa::AsyncNoopMutexType;
22 | pub type SerialPort1TxMutexStrategy = hwa::AsyncStandardStrategy;
23 | }
24 | }
25 |
26 | cfg_if::cfg_if! {
27 | if #[cfg(feature = "with-serial-port-2")] {
28 | pub type SerialPort2TxLockType = hwa::AsyncNoopMutexType;
29 | pub type SerialPort2TxMutexStrategy = hwa::AsyncStandardStrategy;
30 | }
31 | }
32 |
33 | cfg_if::cfg_if! {
34 | if #[cfg(any(feature = "with-motion", feature = "with-hot-end", feature = "with-hot-bed"))] {
35 | pub type DeferChannelMutexType = hwa::AsyncNoopMutexType;
36 | }
37 | }
38 |
39 | cfg_if::cfg_if! {
40 | if #[cfg(feature = "with-motion")] {
41 | pub type StepActuatorMutexType = hwa::SyncCsMutexType;
42 | pub type MotionSignalMutexType = hwa::AsyncNoopMutexType;
43 | pub type MotionRingBufferMutexType = hwa::AsyncNoopMutexType;
44 | pub type MotionConfigMutexType = hwa::AsyncCsMutexType;
45 | pub type MotionStatusMutexType = hwa::AsyncNoopMutexType;
46 | pub type MotionDriverMutexType = hwa::AsyncNoopMutexType;
47 |
48 | pub type StepActuatorMuxtexStrategy = hwa::SyncStandardStrategy;
49 | }
50 | }
51 |
52 | cfg_if::cfg_if! {
53 | if #[cfg(all(feature = "with-motion", feature = "with-motion-broadcast"))] {
54 | pub type MotionBroadcastChannelMutexType = hwa::AsyncCsMutexType;
55 |
56 | pub type MotionSenderMutexType = I2cMutexType;
57 |
58 | pub type MotionSenderMutexStrategy = hwa::AsyncStandardStrategy;
59 | }
60 | }
61 |
62 |
63 | cfg_if::cfg_if! {
64 | if #[cfg(feature = "with-ps-on")] {
65 | pub type PSOnLockType = hwa::SyncNoopMutexType;
66 | pub type PSOnMutexStrategy = hwa::SyncStandardStrategy;
67 | }
68 | }
69 |
70 | cfg_if::cfg_if! {
71 | if #[cfg(feature = "with-spi")] {
72 | pub type Spi1MutexType = hwa::AsyncNoopMutexType;
73 | pub type Spi1MutexStrategyType = hwa::AsyncHoldableStrategy;
74 | }
75 | }
76 |
77 | cfg_if::cfg_if! {
78 | if #[cfg(feature = "with-i2c")] {
79 | pub type I2cMutexType = hwa::AsyncCsMutexType;
80 | pub type I2cMutexStrategyType = hwa::AsyncStandardStrategy;
81 | }
82 | }
83 |
84 | cfg_if::cfg_if! {
85 | if #[cfg(feature = "with-laser")] {
86 | pub type LaserMutexType = hwa::SyncCsMutexType;
87 | pub type LaserPwmMutexStrategy = hwa::SyncStandardStrategy;
88 | }
89 | }
90 |
91 | cfg_if::cfg_if! {
92 | if #[cfg(feature = "with-probe")] {
93 | pub type ProbeMutexType = hwa::SyncCsMutexType;
94 | pub type ProbePwmMutexStrategy = hwa::SyncStandardStrategy;
95 | }
96 | }
97 |
98 | cfg_if::cfg_if! {
99 | if #[cfg(any(feature="with-hot-end", feature = "with-hot-bed"))] {
100 | pub type HotEndHotBedAdcMutexType = hwa::SyncCsMutexType;
101 | pub type HotEndHotBedAdcMutexStrategy = hwa::AsyncStandardStrategy;
102 |
103 | pub type HotEndHotBedPwmMutexType = hwa::SyncNoopMutexType;
104 | pub type HotEndHotBedPwmMutexStrategy = hwa::SyncStandardStrategy;
105 | }
106 | }
107 |
108 | cfg_if::cfg_if! {
109 | if #[cfg(feature="with-hot-end")] {
110 | pub type HotEndAdcMutexStrategy = HotEndHotBedAdcMutexStrategy;
111 | pub type HotEndPwmMutexStrategy = HotEndHotBedPwmMutexStrategy;
112 | }
113 | }
114 |
115 | cfg_if::cfg_if! {
116 | if #[cfg(feature="with-hot-bed")] {
117 | pub type HotBedAdcMutexStrategy = HotEndHotBedAdcMutexStrategy;
118 | pub type HotBedPwmMutexStrategy = HotEndHotBedPwmMutexStrategy;
119 | }
120 | }
121 | //#endregion
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_nucleo_64_arduino_cnc_hat/src/lib.rs:
--------------------------------------------------------------------------------
1 | #![no_std]
2 | extern crate alloc;
3 |
4 | cfg_if::cfg_if! {
5 | if #[cfg(feature="nucleo64-f410rb")] {
6 | mod board_stm32f4;
7 | pub use board_stm32f4::Contract;
8 | }
9 | else if #[cfg(feature="nucleo64-l476rg")] {
10 | mod board_stm32l4;
11 | pub use board_stm32l4::Contract;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_rp_2040/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [env]
2 |
3 | ###########################
4 | ## Configuration - BEGIN ##
5 | ###########################
6 |
7 | ## Heater and bed configuration (thermistor based) ##
8 |
9 | # [Depends on the board_rp_2040] the pull-up resistance of hot-end sensor circuit in ohms
10 | HOT_END_THERM_PULL_UP_RESISTANCE = "4685.0"
11 | # Nominal resistance of hot-end NTC thermistor at 25ºC
12 | HOT_END_THERM_NOMINAL_RESISTANCE = "100000.0"
13 | # BETA value of hot-end NTC thermistor
14 | HOT_END_THERM_BETA = "3950.0"
15 |
16 | # [Depends on the board_rp_2040] the pull-up resistance of hot-bed sensor circuit in ohms
17 | HOT_BED_THERM_PULL_UP_RESISTANCE = "4685.0"
18 | # Nominal resistance of hot-bed NTC thermistor at 25ºC
19 | HOT_BED_THERM_NOMINAL_RESISTANCE = "100000.0"
20 | # BETA value of hot-bed NTC thermistor
21 | HOT_BED_THERM_BETA = "3950.0"
22 |
23 | ## Pure technical stuff ##
24 |
25 | DEFMT_LOG = "info"
26 | RUST_LOG = "warn"
27 | ASYNC_STD_THREAD_COUNT = "1"
28 | EMBASSY_USB_MAX_INTERFACE_COUNT = "2"
29 |
30 | ###########################
31 | ## Configuration - END ##
32 | ###########################
33 |
34 | [target.'cfg(all(any(board="rp2040"), target_arch="arm", target_os="none"))']
35 | #runner = "probe-rs run --chip RP2040"
36 | runner = "elf2uf2-rs --deploy --serial --verbose"
37 |
38 | [build]
39 | target = "thumbv6m-none-eabi"
40 |
41 | [profile.dev.package."*"]
42 | codegen-units = 1
43 | incremental = false
44 | #opt-level = "s" # Set to "s" or even disable to play with GDB
45 | debug = 2
46 | debug-assertions = true
47 | overflow-checks = true
48 |
49 | [profile.release.package."*"]
50 | codegen-units = 1
51 | incremental = false
52 | opt-level = "z"
53 | debug = 2
54 | debug-assertions = true
55 | overflow-checks = true
56 |
57 | [profile.release-opt.package."*"]
58 | codegen-units = 1
59 | incremental = false
60 | opt-level = "z"
61 | debug = 0
62 | debug-assertions = false
63 | overflow-checks = false
64 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_rp_2040/README.md:
--------------------------------------------------------------------------------
1 | 
2 | [](https://crates.io/crates/prinThor)
3 | [](https://opensource.org/licenses/MIT)
4 | 
5 |
6 | Printhor: The highly reliable but not necessarily functional 3D printer firmware
7 |
8 | If you are using this product or like the project, please ★ this repository to show your support! 🤩
9 |
10 | # Overview
11 |
12 | Doc WIP: The Printhor HWI for raspberry PI 2040 MCUs
13 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_rp_2040/rpi-pico/memory.x:
--------------------------------------------------------------------------------
1 | MEMORY {
2 | BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
3 | FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
4 |
5 | /* Pick one of the two options for RAM layout */
6 |
7 | /* OPTION A: Use all RAM banks as one big block */
8 | /* Reasonable, unless you are doing something */
9 | /* really particular with DMA or other concurrent */
10 | /* access that would benefit from striping */
11 | RAM : ORIGIN = 0x20000000, LENGTH = 264K
12 |
13 | /* OPTION B: Keep the unstriped sections separate */
14 | /* RAM: ORIGIN = 0x20000000, LENGTH = 256K */
15 | /* SCRATCH_A: ORIGIN = 0x20040000, LENGTH = 4K */
16 | /* SCRATCH_B: ORIGIN = 0x20041000, LENGTH = 4K */
17 | }
18 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_rp_2040/rpi-pico/openocd.cfg:
--------------------------------------------------------------------------------
1 | source [find interface/cmsis-dap.cfg]
2 |
3 | source [find target/rp2040.cfg]
4 |
5 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_rp_2040/src/board_rp_2040/types.rs:
--------------------------------------------------------------------------------
1 | use printhor_hwa_common as hwa;
2 |
3 | //#region "General controllers lock types"
4 | pub type EventBusPubSubMutexType = hwa::AsyncNoopMutexType;
5 | pub type EventBusLockType = hwa::AsyncNoopMutexType;
6 | //#endregion
7 |
8 | //#region "HWI Shared controllers lock types"
9 | pub type WatchDogLockType = hwa::AsyncNoopMutexType;
10 | //#endregion
11 |
12 | //#region "General controllers locking strategy customization"
13 | pub type EventBusMutexStrategy = hwa::AsyncStandardStrategy>;
14 | pub type WatchDogMutexStrategy = hwa::AsyncStandardStrategy;
15 | //#endregion
16 |
17 | cfg_if::cfg_if! {
18 | if #[cfg(feature = "with-serial-usb")] {
19 | pub type SerialUsbTxLockType = hwa::AsyncNoopMutexType;
20 | pub type SerialUsbTxMutexStrategy = hwa::AsyncStandardStrategy;
21 | }
22 | }
23 |
24 | cfg_if::cfg_if! {
25 | if #[cfg(feature = "with-serial-port-1")] {
26 | pub type SerialPort1TxLockType = hwa::AsyncNoopMutexType;
27 | pub type SerialPort1TxMutexStrategy = hwa::AsyncStandardStrategy;
28 | }
29 | }
30 |
31 | cfg_if::cfg_if! {
32 | if #[cfg(feature = "with-serial-port-2")] {
33 | pub type SerialPort2TxLockType = hwa::AsyncNoopMutexType;
34 | pub type SerialPort2TxMutexStrategy = hwa::AsyncStandardStrategy;
35 | }
36 | }
37 |
38 | cfg_if::cfg_if! {
39 | if #[cfg(any(feature = "with-motion", feature = "with-hot-end", feature = "with-hot-bed"))] {
40 | pub type DeferChannelMutexType = hwa::AsyncNoopMutexType;
41 | }
42 | }
43 |
44 | cfg_if::cfg_if! {
45 | if #[cfg(feature = "with-motion")] {
46 | pub type StepActuatorMutexType = hwa::SyncCsMutexType;
47 | pub type MotionSignalMutexType = hwa::AsyncNoopMutexType;
48 | pub type MotionRingBufferMutexType = hwa::AsyncNoopMutexType;
49 | pub type MotionConfigMutexType = hwa::AsyncCsMutexType;
50 | pub type MotionStatusMutexType = hwa::AsyncNoopMutexType;
51 | pub type MotionDriverMutexType = hwa::AsyncNoopMutexType;
52 |
53 | pub type StepActuatorMuxtexStrategy = hwa::SyncStandardStrategy;
54 | }
55 | }
56 |
57 | cfg_if::cfg_if! {
58 | if #[cfg(all(feature = "with-motion", feature = "with-motion-broadcast"))] {
59 | pub type MotionBroadcastChannelMutexType = hwa::AsyncCsMutexType;
60 |
61 | pub type MotionSenderMutexType = I2cMutexType;
62 |
63 | pub type MotionSenderMutexStrategy = hwa::AsyncStandardStrategy;
64 | }
65 | }
66 |
67 |
68 | cfg_if::cfg_if! {
69 | if #[cfg(feature = "with-ps-on")] {
70 | pub type PSOnLockType = hwa::SyncNoopMutexType;
71 | pub type PSOnMutexStrategy = hwa::SyncStandardStrategy;
72 | }
73 | }
74 |
75 | cfg_if::cfg_if! {
76 | if #[cfg(feature = "with-spi")] {
77 | pub type Spi1MutexType = hwa::AsyncNoopMutexType;
78 | pub type Spi1MutexStrategyType = hwa::AsyncHoldableStrategy;
79 | }
80 | }
81 |
82 | cfg_if::cfg_if! {
83 | if #[cfg(feature = "with-i2c")] {
84 | pub type I2cMutexType = hwa::AsyncCsMutexType;
85 | pub type I2cMutexStrategyType = hwa::AsyncStandardStrategy;
86 | }
87 | }
88 |
89 | cfg_if::cfg_if! {
90 | if #[cfg(feature = "with-laser")] {
91 | pub type LaserMutexType = hwa::SyncCsMutexType;
92 | pub type LaserPwmMutexStrategy = hwa::SyncStandardStrategy;
93 | }
94 | }
95 |
96 | cfg_if::cfg_if! {
97 | if #[cfg(feature = "with-probe")] {
98 | pub type ProbeMutexType = hwa::SyncCsMutexType;
99 | pub type ProbePwmMutexStrategy = hwa::SyncStandardStrategy;
100 | }
101 | }
102 |
103 | cfg_if::cfg_if! {
104 | if #[cfg(any(feature="with-hot-end", feature = "with-hot-bed"))] {
105 | pub type HotEndHotBedAdcMutexType = hwa::SyncCsMutexType;
106 | pub type HotEndHotBedAdcMutexStrategy = hwa::AsyncStandardStrategy;
107 |
108 | pub type HotEndHotBedPwmMutexType = hwa::SyncNoopMutexType;
109 | pub type HotEndHotBedPwmMutexStrategy = hwa::SyncStandardStrategy;
110 | }
111 | }
112 |
113 | cfg_if::cfg_if! {
114 | if #[cfg(feature="with-hot-end")] {
115 | pub type HotEndAdcMutexStrategy = HotEndHotBedAdcMutexStrategy;
116 | pub type HotEndPwmMutexStrategy = HotEndHotBedPwmMutexStrategy;
117 | }
118 | }
119 |
120 | cfg_if::cfg_if! {
121 | if #[cfg(feature="with-hot-bed")] {
122 | pub type HotBedAdcMutexStrategy = HotEndHotBedAdcMutexStrategy;
123 | pub type HotBedPwmMutexStrategy = HotEndHotBedPwmMutexStrategy;
124 | }
125 | }
126 | //#endregion
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_rp_2040/src/lib.rs:
--------------------------------------------------------------------------------
1 | #![no_std]
2 | #![allow(stable_features)]
3 | mod board_rp_2040;
4 |
5 | pub use board_rp_2040::Contract;
6 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_skr_mini_e3/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [env]
2 |
3 | ###########################
4 | ## Configuration - BEGIN ##
5 | ###########################
6 |
7 | ## Heater and bed configuration (thermistor based) ##
8 |
9 | # [Depends on the board] the pull-up resistance of hot-end sensor circuit in ohms
10 | HOT_END_THERM_PULL_UP_RESISTANCE = "4685.0"
11 | # Nominal resistance of hot-end NTC thermistor at 25ºC
12 | HOT_END_THERM_NOMINAL_RESISTANCE = "100000.0"
13 | # BETA value of hot-end NTC thermistor
14 | HOT_END_THERM_BETA = "3950.0"
15 |
16 | # [Depends on the board] the pull-up resistance of hot-bed sensor circuit in ohms
17 | HOT_BED_THERM_PULL_UP_RESISTANCE = "4685.0"
18 | # Nominal resistance of hot-bed NTC thermistor at 25ºC
19 | HOT_BED_THERM_NOMINAL_RESISTANCE = "100000.0"
20 | # BETA value of hot-bed NTC thermistor
21 | HOT_BED_THERM_BETA = "3950.0"
22 |
23 | ## Pure technical stuff ##
24 |
25 | DEFMT_LOG = "info"
26 | RUST_LOG = "warn"
27 | ASYNC_STD_THREAD_COUNT = "1"
28 | EMBASSY_USB_MAX_INTERFACE_COUNT = "2"
29 |
30 | ###########################
31 | ## Configuration - END ##
32 | ###########################
33 |
34 | [target.'cfg(all(any(board="skr_mini_e3_v3"), target_arch="arm", target_os="none"))']
35 | runner = "probe-rs run --chip STM32G0B1RETx --log-format {L}{s} --base-address 08002000 --connect-under-reset"
36 |
37 | [build]
38 | target = "thumbv6m-none-eabi"
39 |
40 | [profile.dev.package."*"]
41 | codegen-units = 1
42 | incremental = false
43 | #opt-level = "s" # Set to "s" or even disable to play with GDB
44 | debug = 2
45 | debug-assertions = true
46 | overflow-checks = true
47 |
48 | [profile.release.package."*"]
49 | codegen-units = 1
50 | incremental = false
51 | opt-level = "z"
52 | debug = 2
53 | debug-assertions = true
54 | overflow-checks = true
55 |
56 | [profile.release-opt.package."*"]
57 | codegen-units = 1
58 | incremental = false
59 | opt-level = "z"
60 | debug = 0
61 | debug-assertions = false
62 | overflow-checks = false
63 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_skr_mini_e3/README.md:
--------------------------------------------------------------------------------
1 | 
2 | [](https://crates.io/crates/prinThor)
3 | [](https://opensource.org/licenses/MIT)
4 | 
5 |
6 | Printhor: The highly reliable but not necessarily functional 3D printer firmware
7 |
8 | If you are using this product or like the project, please ★ this repository to show your support! 🤩
9 |
10 | # Overview
11 |
12 | This board are quite functional:
13 | * https://biqu.equipment/products/bigtreetech-skr-mini-e3-v2-0-32-bit-control-board-integrated-tmc2209-uart-for-ender-4
14 |
15 | ### Binary image production (standard with defmt)
16 |
17 | The firmware.bin file ready to be uploaded to the SD can be produced with the following commandline:
18 |
19 | For SKR Minit E3 V3.0:
20 | ```
21 | DEFMT_LOG=info cargo objcopy --release --no-default-features --features skr_mini_e3_v3 --target thumbv6m-none-eabi --bin printhor -- -O binary firmware.bin
22 | ```
23 | or
24 |
25 | ```shell
26 | DEFMT_LOG=info cargo objcopy --release --no-default-features --features skr_mini_e3_v3 --target thumbv6m-none-eabi --bin printhor -- -O binary firmware.bin
27 | ```
28 |
29 | Firmware size around 196kB as of now with previous settings.
30 |
31 | ### Minimal-size binary image production
32 |
33 | ```shell
34 | DEFMT_LOG=off RUST_BACKTRACE=0 cargo objcopy --profile release-opt --no-default-features --features skr_mini_e3_v3 --target thumbv6m-none-eabi --bin printhor -- -O binary firmware.bin
35 | ```
36 |
37 | Firmware size if 180kB as of now with previous settings.
38 |
39 | ### Run with JLink/SWD device
40 |
41 | ```shell
42 | DEFMT_LOG=info RUST_BACKTRACE=1 RUSTFLAGS='--cfg board="skr_mini_e3_v3"' cargo run --release --no-default-features --features skr_mini_e3_v3 --target thumbv6m-none-eabi --bin printhor
43 | ```
44 |
45 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_skr_mini_e3/skr_mini_e3_v3/memory.x:
--------------------------------------------------------------------------------
1 | /* SKR MINI E3 V3 - STM32G0B1RE */
2 | MEMORY
3 | {
4 | FLASH : ORIGIN = 0x08000000 + 8K, LENGTH = 512K - 8K /* BANK_1 + BANK_2 */
5 | RAM : ORIGIN = 0x20000000, LENGTH = 128K
6 | }
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_skr_mini_e3/skr_mini_e3_v3/openocd.cfg:
--------------------------------------------------------------------------------
1 | source [find interface/stlink.cfg]
2 |
3 | source [find target/stm32g0x.cfg]
4 |
5 |
--------------------------------------------------------------------------------
/hwi-boards/printhor-hwi_skr_mini_e3/src/lib.rs:
--------------------------------------------------------------------------------
1 | #![no_std]
2 | extern crate alloc;
3 |
4 | cfg_if::cfg_if! {
5 | if #[cfg(feature="skr_mini_e3_v3")] {
6 | mod board_stm32g0;
7 | use board_stm32g0 as board;
8 | }
9 | else {
10 | compile_error!("You didn't specify any board");
11 | }
12 |
13 | }
14 | pub use board::Contract;
--------------------------------------------------------------------------------
/openocd.gdbtpl:
--------------------------------------------------------------------------------
1 | target extended-remote :3333
2 |
3 | # print demangled symbols
4 | set print asm-demangle on
5 |
6 | # detect unhandled exceptions, hard faults and panics
7 | break DefaultHandler
8 | break HardFault
9 | break rust_begin_unwind
10 |
11 | monitor arm semihosting disable
12 |
13 | load
14 |
15 | # start the process but immediately halt the processor
16 | stepi
17 |
--------------------------------------------------------------------------------
/printhor-hwa-common-macros/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "printhor-hwa-common-macros"
3 | version = "0.0.4"
4 | edition = "2024"
5 |
6 | [features]
7 | default = ["std"]
8 | float-point-f32-impl = ["printhor-hwa-common/float-point-f32-impl"]
9 | float-point-f64-impl = ["printhor-hwa-common/float-point-f64-impl"]
10 | fixed-point-128-impl = ["printhor-hwa-common/fixed-point-128-impl"]
11 | std = []
12 |
13 | [dependencies]
14 | syn = "2.0"
15 | quote = "1.0"
16 | proc-macro2 = "1.0"
17 | cfg-if = "1"
18 |
19 | [dev-dependencies]
20 | printhor-hwa-common = {version = "0", default-features = false, path = "../printhor-hwa-common"}
21 | printhor-hwa-utils = {version = "0", default-features = false, path = "../printhor-hwa-utils"}
22 |
23 | [lib]
24 | proc-macro = true
--------------------------------------------------------------------------------
/printhor-hwa-common/.cargo/config.toml:
--------------------------------------------------------------------------------
1 |
2 | [env]
3 | #EMBASSY_EXECUTOR_TASK_ARENA_SIZE=16384
4 |
5 | [profile.dev.package."*"]
6 | codegen-units = 1
7 | incremental = false
8 | #opt-level = "s" # Set to "s" or even disable to play with GDB
9 | debug = 2
10 | debug-assertions = true
11 | overflow-checks = true
12 |
13 | [profile.release.package."*"]
14 | codegen-units = 1
15 | incremental = false
16 | opt-level = "z"
17 | debug = 2
18 | debug-assertions = true
19 | overflow-checks = true
20 |
21 | [profile.release-opt.package."*"]
22 | codegen-units = 1
23 | incremental = false
24 | opt-level = "z"
25 | debug = 0
26 | debug-assertions = false
27 | overflow-checks = false
--------------------------------------------------------------------------------
/printhor-hwa-common/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "printhor-hwa-common"
3 | version = "0.0.4"
4 | edition = "2024"
5 | authors = ["Carlos Barrales Ruiz "]
6 | description = "Printor harware abstraction utillery"
7 | readme = "README.md"
8 | repository = "https://github.com/cbruiz/printhor"
9 | keywords = ["hardware", "abstration", "library", "printhor"]
10 | categories = ["hardware-support"]
11 | license = "MIT"
12 | documentation = "https://docs.rs/printhor-hwa_common"
13 | homepage = "https://github.com/cbruiz/printhor"
14 |
15 | [lib]
16 |
17 | [features]
18 | std = ["futures-test/std", "embassy-executor/arch-std",
19 | "embassy-executor/executor-thread",
20 | "printhor-hwa-common-macros/std",
21 | "printhor-hwa-utils/std",
22 | "embassy-time/std"]
23 | default = ["std", "with-log"]
24 | nightly = []
25 | with-log = ["log", "printhor-hwa-utils/with-log"]
26 | with-defmt = ["defmt", "printhor-hwa-utils/with-defmt", "embedded-sdmmc/defmt-log"]
27 | with-serial-usb = ["async-gcode", "embedded-io-async"]
28 | with-serial-port-1 = ["async-gcode", "embedded-io-async"]
29 | with-serial-port-2 = ["async-gcode", "embedded-io-async"]
30 | with-spi = ["embedded-hal-0"]
31 | with-i2c = ["embedded-hal-0"]
32 | with-ps-on = ["embedded-hal-1"]
33 | with-probe = ["embedded-hal-0"]
34 | with-laser = ["embedded-hal-0"]
35 | with-fan-layer = ["embedded-hal-0"]
36 | with-fan-extra-1 = ["embedded-hal-0"]
37 | with-motion = ["embedded-hal-0"]
38 | with-motion-broadcast = []
39 | with-motion-cartessian-kinematics = []
40 | with-motion-delta-kinematics = []
41 | with-motion-core-xy-kinematics = []
42 | with-motion-anthropomorphic-kinematics = []
43 | with-hot-end = ["embedded-hal-0"]
44 | with-hot-bed = ["embedded-hal-0"]
45 | with-sd-card = ["async-gcode", "embedded-sdmmc", "heapless"]
46 | with-print-job = []
47 | with-trinamic = ["embassy-embedded-hal"]
48 |
49 | sd-card-spi = []
50 |
51 | float-point-f32-impl = ["printhor-hwa-common-macros/float-point-f32-impl"]
52 | float-point-f64-impl = ["printhor-hwa-common-macros/float-point-f64-impl"]
53 | fixed-point-128-impl = ["printhor-hwa-common-macros/fixed-point-128-impl", "rust_decimal", "rust_decimal_macros"]
54 |
55 | with-all-axis = [
56 | "with-e-axis",
57 | "with-x-axis", "with-y-axis", "with-z-axis",
58 | "with-a-axis", "with-b-axis", "with-c-axis",
59 | "with-i-axis", "with-j-axis", "with-k-axis",
60 | "with-u-axis", "with-v-axis", "with-w-axis",
61 | ]
62 | with-x-axis = []
63 | with-y-axis = []
64 | with-z-axis = []
65 | with-e-axis = []
66 | with-a-axis = []
67 | with-b-axis = []
68 | with-c-axis = []
69 | with-i-axis = []
70 | with-j-axis = []
71 | with-k-axis = []
72 | with-u-axis = []
73 | with-v-axis = []
74 | with-w-axis = []
75 |
76 | [dependencies]
77 | printhor-hwa-common-macros = { version = "0", default-features = false, path = "../printhor-hwa-common-macros" }
78 | printhor-hwa-utils = { version = "0", default-features = false, path = "../printhor-hwa-utils", features = [] }
79 | const_env = { version = "0.1.2"}
80 |
81 | embassy-sync = { version = "0.6.2", features = [] }
82 | embassy-executor = { version = "0.7.0", default-features = false, features = [] }
83 | embassy-time = { version = "0.4.0", features = [] }
84 | embassy-embedded-hal = { version = "0.3.0", optional = true, default-features = false, features = [] }
85 |
86 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0", default-features = false, optional = true }
87 | embedded-hal-0 = { package = "embedded-hal", version = "0.2.7", features = ["unproven"], optional = true }
88 | embedded-sdmmc = { version = "0.8.1", default-features = false, features = [], optional = true }
89 | embedded-io-async = { version = "0.6.1", default-features = false, features = [], optional = true }
90 | async-gcode = { version = "0.3.0", default-features = false, features = [], optional = true}
91 |
92 | heapless = { version = "0.8.0", default-features = false, features = [], optional = true }
93 |
94 | bitflags = { version = "2.8.0", default-features = false, features = ["bytemuck"] }
95 | cfg-if = { version = "1.0.0" }
96 | defmt = { version = "0.3.10", optional = true, default-features = false, features = [] }
97 | log = { version = "0.4.26", default-features = false, optional = true }
98 | strum = { version = "0.27.1", default-features = false, features = ["derive"] }
99 |
100 | num-traits = { version = "0.2.19", default-features = false, features = [] }
101 | micromath = { version = "2.1.0", default-features = false, features = [] }
102 | rust_decimal = { optional = true, version = "1.36.0", default-features = false, features = ["maths", "serde-with-str"] }
103 | rust_decimal_macros = { optional = true, version = "1.36.0" }
104 | ryu = {version = "1.0.19", default-features = false }
105 |
106 | [dev-dependencies]
107 | futures-test = { version = "0.3.31", default-features = false }
108 | tmc2209 = { version = "0.2.2"}
109 | env_logger = { version = "0.11.6" }
--------------------------------------------------------------------------------
/printhor-hwa-common/README.md:
--------------------------------------------------------------------------------
1 | 
2 | [](https://crates.io/crates/printhor-hwa-common)
3 | [](https://opensource.org/licenses/MIT)
4 | 
5 |
6 | Printhor: The highly reliable but not necessarily functional 3D printer firmware
7 |
8 | If you are using this product or like the project, please ★ this repository to show your support! 🤩
9 |
10 | # Overview
11 |
12 | Doc WIP: The Printhor HWA Common layer. This is a simple interface prerequisit for all printhor HWI implementations
13 |
14 |
--------------------------------------------------------------------------------
/printhor-hwa-common/src/async_utils.rs:
--------------------------------------------------------------------------------
1 | //! Asynchronous utils/adapters
2 | //#region "Async wrapper"
3 | #[allow(unused)]
4 | use crate as hwa;
5 |
6 | pub trait AsyncWrapperWriter {
7 | fn wrapped_write(
8 | &mut self,
9 | data: &[u8],
10 | ) -> impl core::future::Future