Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Heizung
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
c3pb
Heizung
Commits
d66e1a26
Commit
d66e1a26
authored
1 year ago
by
Benjamin Koch
Browse files
Options
Downloads
Patches
Plain Diff
do not transmit continuously
parent
e84cb4f4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
firmware/rust1/src/dont_abort.rs
+13
-4
13 additions, 4 deletions
firmware/rust1/src/dont_abort.rs
firmware/rust1/src/rs485.rs
+9
-6
9 additions, 6 deletions
firmware/rust1/src/rs485.rs
with
22 additions
and
10 deletions
firmware/rust1/src/dont_abort.rs
+
13
−
4
View file @
d66e1a26
...
@@ -2,9 +2,15 @@ use core::future::*;
...
@@ -2,9 +2,15 @@ use core::future::*;
use
core
::
pin
::
Pin
;
use
core
::
pin
::
Pin
;
use
core
::
task
::
*
;
use
core
::
task
::
*
;
pub
enum
DontAbortMode
{
PanicIfReused
,
HangIfReused
,
}
pub
struct
DontAbort
<
A
>
{
pub
struct
DontAbort
<
A
>
{
a
:
A
,
a
:
A
,
done
:
bool
done
:
bool
,
mode
:
DontAbortMode
,
}
}
pub
struct
DontAbortFuture
<
'a
,
A
>
{
pub
struct
DontAbortFuture
<
'a
,
A
>
{
...
@@ -12,8 +18,8 @@ pub struct DontAbortFuture<'a, A> {
...
@@ -12,8 +18,8 @@ pub struct DontAbortFuture<'a, A> {
}
}
impl
<
A
>
DontAbort
<
A
>
{
impl
<
A
>
DontAbort
<
A
>
{
pub
fn
new
(
a
:
A
)
->
DontAbort
<
A
>
{
pub
fn
new
(
a
:
A
,
mode
:
DontAbortMode
)
->
DontAbort
<
A
>
{
DontAbort
{
a
,
done
:
false
}
DontAbort
{
a
,
done
:
false
,
mode
}
}
}
#[allow(dead_code)]
#[allow(dead_code)]
...
@@ -38,7 +44,10 @@ where
...
@@ -38,7 +44,10 @@ where
fn
poll
(
self
:
Pin
<&
mut
Self
>
,
cx
:
&
mut
Context
<
'_
>
)
->
Poll
<
Self
::
Output
>
{
fn
poll
(
self
:
Pin
<&
mut
Self
>
,
cx
:
&
mut
Context
<
'_
>
)
->
Poll
<
Self
::
Output
>
{
let
this
=
unsafe
{
self
.get_unchecked_mut
()
};
let
this
=
unsafe
{
self
.get_unchecked_mut
()
};
if
this
.inner.done
{
if
this
.inner.done
{
panic!
(
"Ready future is called again!"
);
match
this
.inner.mode
{
DontAbortMode
::
PanicIfReused
=>
panic!
(
"Ready future is called again!"
),
DontAbortMode
::
HangIfReused
=>
return
Poll
::
Pending
,
// will never finish because we haven't scheduled ourselves again
}
}
}
let
a
=
unsafe
{
Pin
::
new_unchecked
(
&
mut
this
.inner.a
)
};
let
a
=
unsafe
{
Pin
::
new_unchecked
(
&
mut
this
.inner.a
)
};
if
let
Poll
::
Ready
(
x
)
=
a
.poll
(
cx
)
{
if
let
Poll
::
Ready
(
x
)
=
a
.poll
(
cx
)
{
...
...
This diff is collapsed.
Click to expand it.
firmware/rust1/src/rs485.rs
+
9
−
6
View file @
d66e1a26
...
@@ -15,6 +15,7 @@ use fixed::traits::ToFixed;
...
@@ -15,6 +15,7 @@ use fixed::traits::ToFixed;
use
fixed_macro
::
types
::
U56F8
;
use
fixed_macro
::
types
::
U56F8
;
use
crate
::
dont_abort
::
DontAbort
;
use
crate
::
dont_abort
::
DontAbort
;
use
crate
::
dont_abort
::
DontAbortMode
::
*
;
pub
struct
RS485
{
pub
struct
RS485
{
pio
:
peripherals
::
PIO0
,
pio
:
peripherals
::
PIO0
,
...
@@ -255,7 +256,6 @@ impl RS485 {
...
@@ -255,7 +256,6 @@ impl RS485 {
}
}
tx_data
[
i
]
=
x
|
((
parity
&
1
)
<<
8
);
tx_data
[
i
]
=
x
|
((
parity
&
1
)
<<
8
);
}
}
info!
(
"tx_data: {:?}"
,
tx_data
);
let
mut
dma_in_ref
=
self
.dma_channel
.into_ref
();
let
mut
dma_in_ref
=
self
.dma_channel
.into_ref
();
...
@@ -263,8 +263,8 @@ impl RS485 {
...
@@ -263,8 +263,8 @@ impl RS485 {
let
mut
din
=
[
42u32
;
9
];
let
mut
din
=
[
42u32
;
9
];
let
mut
bit_index
=
0
;
let
mut
bit_index
=
0
;
let
mut
rx_buf
=
[
0
;
1
];
let
mut
rx_buf
=
[
0
;
1
];
let
mut
rx_future
=
DontAbort
::
new
(
self
.rx
.read
(
&
mut
rx_buf
));
let
mut
rx_future
=
DontAbort
::
new
(
self
.rx
.read
(
&
mut
rx_buf
)
,
PanicIfReused
);
let
mut
tx_future
=
DontAbort
::
new
(
sm1
.tx
()
.dma_push
(
dma_tx_ref
.reborrow
(),
&
tx_data
));
let
mut
tx_future
=
DontAbort
::
new
(
sm1
.tx
()
.dma_push
(
dma_tx_ref
.reborrow
(),
&
tx_data
)
,
HangIfReused
);
loop
{
loop
{
let
x
=
select4
(
let
x
=
select4
(
irq0
.wait
(),
irq0
.wait
(),
...
@@ -361,20 +361,23 @@ impl RS485 {
...
@@ -361,20 +361,23 @@ impl RS485 {
}
}
},
},
Either4
::
Third
(
_
)
=>
{
Either4
::
Third
(
_
)
=>
{
drop
(
tx_future
);
//
drop(tx_future);
tx_future
=
DontAbort
::
new
(
sm1
.tx
()
.dma_push
(
dma_tx_ref
.reborrow
(),
&
tx_data
));
//
tx_future = DontAbort::new(sm1.tx().dma_push(dma_tx_ref.reborrow(), &tx_data)
, HangIfReused
);
},
},
Either4
::
Fourth
(
Either
::
First
(
x
))
=>
{
Either4
::
Fourth
(
Either
::
First
(
x
))
=>
{
drop
(
rx_future
);
drop
(
rx_future
);
match
x
{
match
x
{
Result
::
Ok
(())
=>
{
Result
::
Ok
(())
=>
{
info!
(
"RX {:?}"
,
rx_buf
);
info!
(
"RX {:?}"
,
rx_buf
);
drop
(
tx_future
);
tx_future
=
DontAbort
::
new
(
sm1
.tx
()
.dma_push
(
dma_tx_ref
.reborrow
(),
&
tx_data
),
HangIfReused
);
},
},
Result
::
Err
(
e
)
=>
{
Result
::
Err
(
e
)
=>
{
info!
(
"RX error {:?}"
,
e
);
info!
(
"RX error {:?}"
,
e
);
},
},
}
}
rx_future
=
DontAbort
::
new
(
self
.rx
.read
(
&
mut
rx_buf
));
rx_future
=
DontAbort
::
new
(
self
.rx
.read
(
&
mut
rx_buf
)
,
PanicIfReused
);
},
},
_
=>
{
_
=>
{
},
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment