Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2021
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Jacobsson
e7020e_2021
Compare revisions
master to 93a97ba6d91396ef4c49c94a36ac7ec3e177db4e
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
jonjac-6/e7020e_2021
Select target project
No results found
93a97ba6d91396ef4c49c94a36ac7ec3e177db4e
Select Git revision
Loading items
Swap
Target
pln/e7020e_2021
Select target project
Frappe/e7020e_2021
rognda-6/e7020e_2021
Klomega/e7020e_2021
pln/e7020e_2021
CarlOsterberg/e7020e_2021
jonjac-6/e7020e_2021
deux-babiri-futari/e7020e_2021
samgra-7/e7020e_2021
JosefUtbult/e7020e_2021
edwkll-7/e7020e_2021
10 results
master
Select Git revision
Loading items
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (3)
changed main
· d9f8f110
Jonas Jacobsson
authored
4 years ago
d9f8f110
This will be removed
· 17933a37
Jonas Jacobsson
authored
4 years ago
17933a37
hej
· 93a97ba6
Jonas Jacobsson
authored
4 years ago
93a97ba6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/rtic_blinky.rs
+1
-1
1 addition, 1 deletion
examples/rtic_blinky.rs
examples/rtt-pwm.rs
+1
-1
1 addition, 1 deletion
examples/rtt-pwm.rs
src/main.rs
+100
-11
100 additions, 11 deletions
src/main.rs
with
102 additions
and
13 deletions
examples/rtic_blinky.rs
View file @
93a97ba6
...
...
@@ -40,7 +40,7 @@ const APP: () = {
let
now
=
cx
.start
;
// the start time of the system
// Schedule `toggle` to run 8e6 cycles (clock cycles) in the future
cx
.schedule
.toggle
(
now
+
8
_000_000
.cycles
())
.unwrap
();
cx
.schedule
.toggle
(
now
+
16
_000_000
.cycles
())
.unwrap
();
// power on GPIOA, RM0368 6.3.11
device
.RCC.ahb1enr
.modify
(|
_
,
w
|
w
.gpioaen
()
.set_bit
());
...
...
This diff is collapsed.
Click to expand it.
examples/rtt-pwm.rs
View file @
93a97ba6
//! cargo run --example
s
rtt-pwm
//! cargo run --example rtt-pwm
#![deny(unsafe_code)]
#![deny(warnings)]
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
View file @
93a97ba6
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_std]
#![no_main]
// pick a panicking behavior
use
panic_halt
as
_
;
// you can put a breakpoint on `rust_begin_unwind` to catch panics
// use panic_abort as _; // requires nightly
// pick a panicking behavior// use panic_abort as _; // requires nightly
// use panic_itm as _; // logs messages over ITM; requires ITM support
// use panic_semihosting as _; // logs messages to the host stderr; requires a debugger
use
cortex_m
::
asm
;
use
cortex_m_rt
::
entry
;
#[entry]
fn
main
()
->
!
{
asm
::
nop
();
// To not have main optimize to abort in release mode, remove when you add code
use
panic_halt
as
_
;
// you can put a breakpoint on `rust_begin_unwind` to catch panics
use
rtt_target
::{
rprintln
,
rtt_init_print
};
use
cortex_m
::
peripheral
::
DWT
;
use
stm32f4xx_hal
::
stm32
;
//use cortex_m::asm;
//use cortex_m_rt::entry;
use
rtic
::
cyccnt
::{
Instant
,
U32Ext
as
_
};
#[rtic::app(device
=
stm32f4xx_hal::stm32,
monotonic
=
rtic::cyccnt::CYCCNT,
peripherals
=
true
)]
const
APP
:
()
=
{
struct
Resources
{
// late resources
GPIOA
:
stm32
::
GPIOA
,
}
#[init(schedule
=
[
toggle]
)]
fn
init
(
cx
:
init
::
Context
)
->
init
::
LateResources
{
rtt_init_print!
();
rprintln!
(
"init"
);
for
i
in
0
..
11
{
rprintln!
(
"RTIC Says Hello, world {}!!"
,
i
);
}
let
mut
core
=
cx
.core
;
let
device
=
cx
.device
;
// Initialize (enable) the monotonic timer (CYCCNT)
core
.DCB
.enable_trace
();
// required on Cortex-M7 devices that software lock the DWT (e.g. STM32F7)
DWT
::
unlock
();
core
.DWT
.enable_cycle_counter
();
// semantically, the monotonic timer is frozen at time "zero" during `init`
// NOTE do *not* call `Instant::now` in this context; it will return a nonsense value
let
now
=
cx
.start
;
// the start time of the system
// Schedule `toggle` to run 8e6 cycles (clock cycles) in the future
cx
.schedule
.toggle
(
now
+
8_000_000
.cycles
())
.unwrap
();
// power on GPIOA, RM0368 6.3.11
device
.RCC.ahb1enr
.modify
(|
_
,
w
|
w
.gpioaen
()
.set_bit
());
// configure PA5 as output, RM0368 8.4.1
device
.GPIOA.moder
.modify
(|
_
,
w
|
w
.moder5
()
.bits
(
1
));
// pass on late resources
init
::
LateResources
{
GPIOA
:
device
.GPIOA
,
}
}
#[idle]
fn
idle
(
_cx
:
idle
::
Context
)
->
!
{
rprintln!
(
"lets get lazy"
);
loop
{
// your code goes here
continue
;
}
}
#[task(resources
=
[
GPIOA]
,
schedule
=
[
toggle
])]
fn
toggle
(
cx
:
toggle
::
Context
)
{
static
mut
TOGGLE
:
bool
=
false
;
rprintln!
(
"toggle @ {:?}"
,
Instant
::
now
());
if
*
TOGGLE
{
cx
.resources.GPIOA.bsrr
.write
(|
w
|
w
.bs5
()
.set_bit
());
}
else
{
cx
.resources.GPIOA.bsrr
.write
(|
w
|
w
.br5
()
.set_bit
());
}
<<<<<<<
HEAD
//cx.resources.GPIOC.PullDown;
=======
>>>>>>>
80
d2d39
(
changed
main
)
*
TOGGLE
=
!*
TOGGLE
;
cx
.schedule
.toggle
(
cx
.scheduled
+
16_000_000
.cycles
())
.unwrap
();
<<<<<<<
HEAD
=======
>>>>>>>
80
d2d39
(
changed
main
)
}
extern
"C"
{
fn
EXTI0
();
}
};
This diff is collapsed.
Click to expand it.