Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rtic_f4xx_nucleo
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
Edvin Åkerfeldt
rtic_f4xx_nucleo
Commits
805bf5b5
Commit
805bf5b5
authored
Dec 7, 2020
by
Edvin Åkerfeldt
Browse files
Options
Downloads
Patches
Plain Diff
dsi_debug
parent
3d058cc9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/dsi_debug.rs
+118
-0
118 additions, 0 deletions
examples/dsi_debug.rs
with
118 additions
and
0 deletions
examples/dsi_debug.rs
0 → 100644
+
118
−
0
View file @
805bf5b5
//#![deny(warnings)]
#![no_main]
#![no_std]
use
cortex_m
::
peripheral
::
syst
::
SystClkSource
;
use
cortex_m
::{
asm
,
peripheral
::
DWT
};
use
panic_rtt_target
as
_
;
use
rtt_target
::{
rprintln
,
rtt_init_print
};
use
stm32f4
;
use
stm32f4
::
stm32f413
::
GPIOA
;
//use stm32f411::{GPIOA, RCC};
//const bit_string: u16 = 0x0FFF;
const
bit_string
:
u16
=
0xF000
;
/*(
0x0FFF full
0 11111111 1111
start | data | stop
0x07dF half
0x000F off
*/
const
big_endian
:
bool
=
true
;
#[rtic::app(device
=
stm32f4::stm32f413,
peripherals
=
true
)]
const
APP
:
()
=
{
struct
Resources
{
dwt
:
DWT
,
ON
:
bool
,
point
:
u16
,
}
#[init]
fn
init
(
mut
cx
:
init
::
Context
)
->
init
::
LateResources
{
rtt_init_print!
();
rprintln!
(
"init"
);
// Initialize (enable) the monotonic timer (CYCCNT)
cx
.core.DCB
.enable_trace
();
cx
.core.DWT
.enable_cycle_counter
();
let
mut
c
=
cx
.core.SYST
;
c
.set_clock_source
(
SystClkSource
::
Core
);
//c.set_reload(8_000_000 / 150);
c
.set_reload
(
3333
);
c
.clear_current
();
c
.enable_counter
();
c
.enable_interrupt
();
//let p = cx.RCC;
// power on GPIOA
let
rcc
=
cx
.device.RCC
;
rcc
.ahb1enr
.modify
(|
_
,
w
|
w
.gpioaen
()
.set_bit
());
// configure PA5 as output
let
gpioa
=
cx
.device.GPIOA
;
gpioa
.moder
.modify
(|
_
,
w
|
unsafe
{
w
.moder5
()
.bits
(
1
)
});
let
mut
point
:
u16
=
0x0
;
init
::
LateResources
{
dwt
:
cx
.core.DWT
,
ON
:
false
,
point
:
point
,
}
}
#[idle]
fn
idle
(
_cx
:
idle
::
Context
)
->
!
{
rprintln!
(
"idle"
);
/*
unsafe { cx.resources.dwt.cyccnt.write(0) };
asm::bkpt();
rtic::pend(stm32f411::Interrupt::EXTI0);
asm::bkpt();
*/
loop
{
continue
;
}
}
#[task(binds
=
SysTick,
resources
=
[
ON,
point]
,)]
fn
syst
(
cx
:
syst
::
Context
)
{
let
r
=
cx
.resources
;
*
r
.ON
=
!*
r
.ON
;
if
*
r
.ON
==
true
{
if
*
r
.point
==
15
{
*
r
.point
=
0
;
}
else
{
*
r
.point
=
*
r
.point
+
1
;
}
}
let
bit
:
u16
=
(
bit_string
&
(
0x8000
>>
*
r
.point
))
>>
(
15
-
*
r
.point
);
let
t
:
u16
=
bit
^
(
*
r
.ON
as
u16
);
let
mut
wr
:
bool
;
if
t
==
1
{
wr
=
true
;
}
else
if
t
==
0
{
wr
=
false
;
}
else
{
panic!
();
}
wr
=
*
r
.ON
;
unsafe
{
(
*
GPIOA
::
ptr
())
.odr
.modify
(|
_
,
w
|
w
.odr5
()
.bit
(
wr
));
}
//rprintln!(*r.point);
//rprintln!("SysTick");
//asm::bkpt();
}
/*
#[task(binds = EXTI0)]
fn exti0(_cx: exti0::Context) {
asm::bkpt();
}
*/
};
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