Skip to content

Commit

Permalink
update VS Code config
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Sep 17, 2024
1 parent a9185ff commit b67b9d3
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 32 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ example.
### Using VS Code

Assuming a working debug connection to your VA108xx board, you can debug using VS Code with
the [`Cortex-Debug` plugin](https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug).
the [`Cortex-Debug` plugin](https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug). Please make aure that [`objdump-multiarch` and `nm-multiarch`](https://forums.raspberrypi.com/viewtopic.php?t=333146)
are installed as well.

Some sample configuration files for VS code were provided and can be used by running
`cp -rT vscode .vscode` like specified above. After that, you can use `Run and Debug`
Expand All @@ -111,4 +112,5 @@ configuration variables in your `settings.json`:
- `"cortex-debug.gdbPath.osx"`

The provided VS Code configurations also provide an integrated RTT logger, which you can access
via the terminal at `RTT Ch:0 console`.
via the terminal at `RTT Ch:0 console`. In order for the RTT block address detection to
work properly, `objdump-multiarch` and `nm-multiarch` need to be installed.
11 changes: 8 additions & 3 deletions examples/simple/examples/timer-ticks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#![no_std]

use core::cell::Cell;
use cortex_m::asm;
use cortex_m_rt::entry;
use critical_section::Mutex;
use embedded_hal::delay::DelayNs;
use panic_rtt_target as _;
use rtt_target::{rprintln, rtt_init_print};
use simple_examples::peb1;
Expand Down Expand Up @@ -36,10 +36,11 @@ fn main() -> ! {
.xtal_n_clk_with_src_freq(peb1::EXTCLK_FREQ)
.freeze(&mut dp.sysconfig)
.unwrap();
let mut delay_provider = set_up_ms_tick(&mut dp.sysconfig, dp.tim0, &clocks);
let _ = set_up_ms_tick(&mut dp.sysconfig, dp.tim0, &clocks);
let mut second_timer = CountdownTimer::new(&mut dp.sysconfig, dp.tim1, &clocks);
second_timer.start(1.Hz());
second_timer.listen();
// let delay_provider = dp.sy
loop {
let current_ms = critical_section::with(|cs| MS_COUNTER.borrow(cs).get());
if current_ms - last_ms >= 1000 {
Expand All @@ -48,7 +49,11 @@ fn main() -> ! {
let second = critical_section::with(|cs| SEC_COUNTER.borrow(cs).get());
rprintln!("Second counter: {}", second);
}
delay_provider.delay_ms(1000);
for _ in 0..30000 {
asm::nop();
}

//delay_provider.delay_ms(1000);
}
}

Expand Down
2 changes: 1 addition & 1 deletion va416xx-hal/src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ impl<Tim: ValidTim> CountdownTimer<Tim> {
pub fn load(&mut self, timeout: impl Into<Hertz>) {
self.tim.reg().ctrl().modify(|_, w| w.enable().clear_bit());
self.curr_freq = timeout.into();
self.rst_val = self.clock.raw() / self.curr_freq.raw() - 1;
self.rst_val = (self.clock.raw() / self.curr_freq.raw()) - 1;
self.set_reload(self.rst_val);
// Decrementing counter, to set the reset value.
self.set_count(0);
Expand Down
41 changes: 15 additions & 26 deletions vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@
"runToEntryPoint": "main",
"rttConfig": {
"enabled": true,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff8000",
"address": "auto",
"decoders": [
{
"port": 0,
Expand Down Expand Up @@ -104,8 +103,7 @@
"runToEntryPoint": "main",
"rttConfig": {
"enabled": true,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff8000",
"address": "auto",
"decoders": [
{
"port": 0,
Expand Down Expand Up @@ -134,8 +132,7 @@
"runToEntryPoint": "main",
"rttConfig": {
"enabled": true,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff8000",
"address": "auto",
"decoders": [
{
"port": 0,
Expand Down Expand Up @@ -164,11 +161,11 @@
"runToEntryPoint": "main",
"rttConfig": {
"enabled": true,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff8000",
"address": "auto",
"decoders": [
{
"port": 0,
"timestamp": true,
"type": "console"
}
]
Expand All @@ -194,8 +191,7 @@
"runToEntryPoint": "main",
"rttConfig": {
"enabled": true,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff8000",
"address": "auto",
"decoders": [
{
"port": 0,
Expand Down Expand Up @@ -224,8 +220,7 @@
"runToEntryPoint": "main",
"rttConfig": {
"enabled": true,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff8000",
"address": "auto",
"decoders": [
{
"port": 0,
Expand Down Expand Up @@ -255,8 +250,7 @@
"runToEntryPoint": "main",
"rttConfig": {
"enabled": true,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff8000",
"address": "auto",
"decoders": [
{
"port": 0,
Expand Down Expand Up @@ -286,8 +280,7 @@
"runToEntryPoint": "main",
"rttConfig": {
"enabled": true,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff8000",
"address": "auto",
"decoders": [
{
"port": 0,
Expand Down Expand Up @@ -317,8 +310,7 @@
"runToEntryPoint": "main",
"rttConfig": {
"enabled": true,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff8000",
"address": "auto",
"decoders": [
{
"port": 0,
Expand Down Expand Up @@ -348,8 +340,7 @@
"runToEntryPoint": "main",
"rttConfig": {
"enabled": true,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff8004",
"address": "auto",
"decoders": [
{
"port": 0,
Expand Down Expand Up @@ -379,8 +370,7 @@
"runToEntryPoint": "main",
"rttConfig": {
"enabled": true,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff8000",
"address": "auto",
"decoders": [
{
"port": 0,
Expand Down Expand Up @@ -409,9 +399,8 @@
"interface": "swd",
"runToEntryPoint": "main",
"rttConfig": {
"enabled": false,
// Have to use exact address unfortunately. "auto" does not work for some reason..
"address": "0x1fff806c",
"enabled": true,
"address": "auto",
"decoders": [
{
"port": 0,
Expand All @@ -422,4 +411,4 @@
}
},
]
}
}
26 changes: 26 additions & 0 deletions vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@
"kind": "build",
}
},
{
"label": "timer-ticks-example",
"type": "shell",
"command": "~/.cargo/bin/cargo", // note: full path to the cargo
"args": [
"build",
"--example",
"timer-ticks"
],
"group": {
"kind": "build",
}
},
{
"label": "blinky-example",
"type": "shell",
Expand Down Expand Up @@ -160,5 +173,18 @@
"kind": "build",
}
},
{
"label": "embassy-example",
"type": "shell",
"command": "~/.cargo/bin/cargo", // note: full path to the cargo
"args": [
"build",
"--bin",
"embassy-example"
],
"group": {
"kind": "build",
}
},
]
}

0 comments on commit b67b9d3

Please sign in to comment.