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
b8016459
Commit
b8016459
authored
1 year ago
by
Benjamin Koch
Browse files
Options
Downloads
Patches
Plain Diff
use StaticCell to avoid unsafe
parent
16ab2497
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
firmware/rust1/src/bin/heizung.rs
+12
-4
12 additions, 4 deletions
firmware/rust1/src/bin/heizung.rs
with
12 additions
and
4 deletions
firmware/rust1/src/bin/heizung.rs
+
12
−
4
View file @
b8016459
...
@@ -6,6 +6,7 @@ use core::sync::atomic::*;
...
@@ -6,6 +6,7 @@ use core::sync::atomic::*;
use
defmt
::
*
;
use
defmt
::
*
;
use
embassy_executor
::
Spawner
;
use
embassy_executor
::
Spawner
;
use
embassy_executor
::
_export
::
StaticCell
;
//use embassy_futures::join::join;
//use embassy_futures::join::join;
//use embassy_futures::select::*;
//use embassy_futures::select::*;
use
embassy_rp
::
adc
::{
self
,
Adc
};
use
embassy_rp
::
adc
::{
self
,
Adc
};
...
@@ -30,6 +31,15 @@ use heizung::rs485::RS485;
...
@@ -30,6 +31,15 @@ use heizung::rs485::RS485;
use
heizung
::
uf2updater
::
UF2UpdateHandler
;
use
heizung
::
uf2updater
::
UF2UpdateHandler
;
use
heizung
::
watchdog
::
WatchdogFixed
;
use
heizung
::
watchdog
::
WatchdogFixed
;
macro_rules!
singleton
{
(
$val:expr
)
=>
{{
type
T
=
impl
Sized
;
static
STATIC_CELL
:
StaticCell
<
T
>
=
StaticCell
::
new
();
let
(
x
,)
=
STATIC_CELL
.init
((
$val
,));
x
}};
}
#[embassy_executor::task]
#[embassy_executor::task]
async
fn
i2c_task
(
mut
i2c_peri
:
embassy_rp
::
peripherals
::
I2C0
,
async
fn
i2c_task
(
mut
i2c_peri
:
embassy_rp
::
peripherals
::
I2C0
,
mut
scl
:
embassy_rp
::
peripherals
::
PIN_13
,
mut
sda
:
embassy_rp
::
peripherals
::
PIN_12
,
mut
scl
:
embassy_rp
::
peripherals
::
PIN_13
,
mut
sda
:
embassy_rp
::
peripherals
::
PIN_12
,
...
@@ -646,12 +656,10 @@ async fn main2(spawner: Spawner) {
...
@@ -646,12 +656,10 @@ async fn main2(spawner: Spawner) {
static
OUTPUTS_ACTIVE
:
AtomicU8
=
AtomicU8
::
new
(
0
);
static
OUTPUTS_ACTIVE
:
AtomicU8
=
AtomicU8
::
new
(
0
);
unwrap!
(
spawner
.spawn
(
adc_task
(
&
ADC_DATA
,
p
.ADC
,
en_measure_current
,
analog_in1
,
current2
,
current1
,
measure_vcc
,
&
OUTPUTS_ACTIVE
)));
unwrap!
(
spawner
.spawn
(
adc_task
(
&
ADC_DATA
,
p
.ADC
,
en_measure_current
,
analog_in1
,
current2
,
current1
,
measure_vcc
,
&
OUTPUTS_ACTIVE
)));
static
mut
RX_BUFFER
:
[
u8
;
256
]
=
[
0
;
256
];
let
rx_buf
=
singleton!
([
0u8
;
256
]);
//SAFETY: We only borrow it once because this function will only be called once.
let
rx_buffer_ref
=
unsafe
{
&
mut
RX_BUFFER
};
let
rs485
=
RS485
::
new
(
let
rs485
=
RS485
::
new
(
p
.UART0
,
rx
,
tx
,
tx_en
,
interrupt
::
take!
(
UART0_IRQ
),
p
.UART0
,
rx
,
tx
,
tx_en
,
interrupt
::
take!
(
UART0_IRQ
),
p
.DMA_CH1
,
default_modbus_config
(),
rx_buf
fer_ref
,
p
.DMA_CH1
,
default_modbus_config
(),
rx_buf
,
p
.PIO0
,
p
.DMA_CH0
,
p
.DMA_CH2
,
p
.PIO0
,
p
.DMA_CH0
,
p
.DMA_CH2
,
ModbusServer
::
new
(
ModBusRegs
{
ModbusServer
::
new
(
ModBusRegs
{
led_g
,
led_g
,
...
...
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