Skip to content

Commit 5504074

Browse files
committed
Fix errors in examples
1 parent 11350c5 commit 5504074

File tree

9 files changed

+62
-38
lines changed

9 files changed

+62
-38
lines changed

examples/hrtim/adc-trigger.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#![no_std]
22
#![no_main]
33

4+
#[path = "../utils/mod.rs"]
5+
mod utils;
6+
use utils::logger::info;
7+
48
/// Example showcasing the use of the HRTIM peripheral to trigger the ADC at various points of the switch cycle off HRTIM_TIMA
59
use cortex_m_rt::entry;
6-
use panic_probe as _;
710
use stm32_hrtim::{
811
compare_register::HrCompareRegister, output::HrOutput, timer::HrTimer, HrParts, HrPwmAdvExt,
912
Pscl4,
@@ -23,14 +26,14 @@ use stm32g4xx_hal::{
2326
fn main() -> ! {
2427
const VREF: f32 = 3.3;
2528

26-
defmt::info!("start");
29+
info!("start");
2730

2831
let dp = Peripherals::take().unwrap();
2932
let cp = CorePeripherals::take().expect("cannot take core peripherals");
3033

3134
// Set system frequency to 16MHz * 15/1/2 = 120MHz
3235
// This would lead to HrTim running at 120MHz * 32 = 3.84...
33-
defmt::info!("rcc");
36+
info!("rcc");
3437
let pwr = dp.PWR.constrain().freeze();
3538
let mut rcc = dp.RCC.freeze(
3639
rcc::Config::pll().pll_cfg(rcc::PllConfig {
@@ -52,7 +55,7 @@ fn main() -> ! {
5255
.circular_buffer(true)
5356
.memory_increment(true);
5457

55-
defmt::info!("Setup Gpio");
58+
info!("Setup Gpio");
5659
let gpioa = dp.GPIOA.split(&mut rcc);
5760
let pa0 = gpioa.pa0.into_analog();
5861

@@ -102,7 +105,7 @@ fn main() -> ! {
102105
out1.enable_set_event(&timer); // Set high at new period
103106
out2.enable_set_event(&timer);
104107

105-
defmt::info!("Setup Adc1");
108+
info!("Setup Adc1");
106109
let mut adc12_common = dp.ADC12_COMMON.claim(Default::default(), &mut rcc);
107110
let mut adc = adc12_common.claim(dp.ADC1, &mut delay);
108111

@@ -124,7 +127,7 @@ fn main() -> ! {
124127
adc::config::SampleTime::Cycles_640_5,
125128
);
126129

127-
defmt::info!("Setup DMA");
130+
info!("Setup DMA");
128131
let first_buffer = cortex_m::singleton!(: [u16; 10] = [0; 10]).unwrap();
129132

130133
let mut transfer = dma1ch1.into_circ_peripheral_to_memory_transfer(
@@ -144,16 +147,16 @@ fn main() -> ! {
144147
let mut b = [0_u16; 4];
145148
let r = transfer.read_exact(&mut b);
146149

147-
defmt::info!("read: {}", r);
150+
info!("read: {}", r);
148151
assert!(r == b.len());
149152

150153
let millivolts = Vref::sample_to_millivolts((b[0] + b[2]) / 2);
151-
defmt::info!("pa3: {}mV", millivolts);
154+
info!("pa3: {}mV", millivolts);
152155
let temp = Temperature::temperature_to_degrees_centigrade(
153156
(b[1] + b[3]) / 2,
154157
VREF,
155158
adc::config::Resolution::Twelve,
156159
);
157-
defmt::info!("temp: {}℃C", temp);
160+
info!("temp: {}℃C", temp);
158161
}
159162
}

examples/hrtim/capture-dma.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#![no_std]
22
#![no_main]
33

4+
#[path = "../utils/mod.rs"]
5+
mod utils;
6+
use utils::logger::info;
7+
48
/// Example showcasing the use of the HRTIM peripheral's capture function to detect phase shift between a digital event and the output of HRTIM_TIMA
59
use cortex_m_rt::entry;
6-
use panic_probe as _;
710
use stm32_hrtim::{
811
capture,
912
compare_register::HrCompareRegister,
@@ -23,13 +26,13 @@ use stm32g4xx_hal::{
2326

2427
#[entry]
2528
fn main() -> ! {
26-
defmt::info!("start");
29+
info!("start");
2730

2831
let dp = Peripherals::take().unwrap();
2932

3033
// Set system frequency to 16MHz * 15/1/2 = 120MHz
3134
// This would lead to HrTim running at 120MHz * 32 = 3.84...
32-
defmt::info!("rcc");
35+
info!("rcc");
3336
let pwr = dp.PWR.constrain().freeze();
3437
let mut rcc = dp.RCC.freeze(
3538
rcc::Config::pll().pll_cfg(rcc::PllConfig {
@@ -43,7 +46,7 @@ fn main() -> ! {
4346
pwr,
4447
);
4548

46-
defmt::info!("Setup Gpio");
49+
info!("Setup Gpio");
4750
let gpioa = dp.GPIOA.split(&mut rcc);
4851
let gpiob = dp.GPIOB.split(&mut rcc);
4952

@@ -106,7 +109,7 @@ fn main() -> ! {
106109
capture.enable_interrupt(true, &mut hr_control);
107110
capture.add_event(&eev_input6);
108111

109-
defmt::info!("Setup DMA");
112+
info!("Setup DMA");
110113
let channels = dp.DMA1.split(&rcc);
111114
let config = DmaConfig::default()
112115
.transfer_complete_interrupt(false)
@@ -129,7 +132,7 @@ fn main() -> ! {
129132
transfer.read_exact(&mut data);
130133
let [t1, t2] = data.map(|x| capture::dma_value_to_signed(x, period));
131134
cr1.set_duty(duty as u16);
132-
defmt::info!("Capture: t1: {}, t2: {}, duty: {}, ", t1, t2, old_duty);
135+
info!("Capture: t1: {}, t2: {}, duty: {}, ", t1, t2, old_duty);
133136
old_duty = duty;
134137
}
135138
}

examples/hrtim/capture.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#![no_std]
22
#![no_main]
33

4+
#[path = "../utils/mod.rs"]
5+
mod utils;
6+
use utils::logger::info;
7+
48
/// Example showcasing the use of the HRTIM peripheral's capture function to detect phase shift between a digital event and the output of HRTIM_TIMA
59
use cortex_m_rt::entry;
6-
use panic_probe as _;
710
use stm32_hrtim::{
811
capture::HrCapture,
912
compare_register::HrCompareRegister,
@@ -22,13 +25,13 @@ use stm32g4xx_hal::{
2225

2326
#[entry]
2427
fn main() -> ! {
25-
defmt::info!("start");
28+
info!("start");
2629

2730
let dp = Peripherals::take().unwrap();
2831

2932
// Set system frequency to 16MHz * 15/1/2 = 120MHz
3033
// This would lead to HrTim running at 120MHz * 32 = 3.84...
31-
defmt::info!("rcc");
34+
info!("rcc");
3235
let pwr = dp.PWR.constrain().freeze();
3336
let mut rcc = dp.RCC.freeze(
3437
rcc::Config::pll().pll_cfg(rcc::PllConfig {
@@ -42,7 +45,7 @@ fn main() -> ! {
4245
pwr,
4346
);
4447

45-
defmt::info!("Setup Gpio");
48+
info!("Setup Gpio");
4649
let gpioa = dp.GPIOA.split(&mut rcc);
4750
let gpiob = dp.GPIOB.split(&mut rcc);
4851

@@ -102,7 +105,7 @@ fn main() -> ! {
102105
loop {
103106
for duty in (u32::from(period) / 10)..(9 * u32::from(period) / 10) {
104107
if let Some(value) = capture.get_signed(period) {
105-
defmt::info!(
108+
info!(
106109
"Capture: {:?}, duty: {}, diff: {}",
107110
value,
108111
old_duty,

examples/hrtim/eev-comp.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#![no_std]
22
#![no_main]
33

4+
#[path = "../utils/mod.rs"]
5+
mod utils;
6+
use utils::logger::info;
7+
48
/// Example showcasing the use of the HRTIM peripheral together with a comparator to implement a cycle by cycle current limit.
59
/// Once the comparator input exceeds the reference set by the DAC, the output is set low thus limiting the pulse width and in turn the current.
610
use cortex_m_rt::entry;
7-
use panic_probe as _;
811
use stm32_hrtim::{
912
compare_register::HrCompareRegister,
1013
external_event::{self, ToExternalEventSource},
@@ -124,10 +127,10 @@ fn main() -> ! {
124127
out.enable();
125128
timer.start(&mut hr_control.control);
126129

127-
defmt::info!("Started");
130+
info!("Started");
128131

129132
loop {
130-
defmt::info!(
133+
info!(
131134
"Comp: {}, pending: {}",
132135
comp1.output(),
133136
comp1.is_pending(&exti)

examples/hrtim/eev.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#![no_std]
22
#![no_main]
33

4+
#[path = "../utils/mod.rs"]
5+
mod utils;
6+
use utils::logger::info;
7+
48
/// Example showcasing the use of the HRTIM peripheral together with a digital input to implement a cycle by cycle current limit.
59
/// Once the digital input goes high, the output is set low thus limiting the pulse width and in turn the current.
610
use cortex_m_rt::entry;
7-
use panic_probe as _;
811
use stm32_hrtim::{
912
compare_register::HrCompareRegister,
1013
external_event::{self, ToExternalEventSource},
@@ -96,7 +99,7 @@ fn main() -> ! {
9699
out.enable();
97100
timer.start(&mut hr_control.control);
98101

99-
defmt::info!("Started");
102+
info!("Started");
100103

101104
loop {
102105
cortex_m::asm::nop()

examples/hrtim/flt-comp.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#![no_std]
22
#![no_main]
33

4+
#[path = "../utils/mod.rs"]
5+
mod utils;
6+
use utils::logger::info;
7+
48
/// Example showcasing the use of the HRTIM peripheral together with a comparator to implement a current fault.
59
/// Once the comparator input exceeds the reference set by the DAC, the output is forced low and put into a fault state.
610
use cortex_m_rt::entry;
711
use fugit::ExtU32 as _;
8-
use panic_probe as _;
912
use stm32_hrtim::{
1013
compare_register::HrCompareRegister,
1114
fault::{FaultAction, FaultMonitor},
@@ -127,12 +130,12 @@ fn main() -> ! {
127130
out1.enable();
128131
timer.start(&mut hr_control.control);
129132

130-
defmt::info!("Started");
133+
info!("Started");
131134

132135
loop {
133136
for _ in 0..5 {
134137
delay.delay(500_u32.millis());
135-
defmt::info!(
138+
info!(
136139
"State: {:?}, comp: {}, is_fault_active: _, pc1: {}",
137140
out1.get_state(),
138141
//comp3.output(), TODO
@@ -143,7 +146,7 @@ fn main() -> ! {
143146
if hr_control.fault_5.is_fault_active() {
144147
hr_control.fault_5.clear_fault(); // Clear fault every 5s
145148
out1.enable();
146-
defmt::info!("failt cleared, and output reenabled");
149+
info!("failt cleared, and output reenabled");
147150
}
148151
}
149152
}

examples/hrtim/flt.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#![no_std]
22
#![no_main]
33

4+
#[path = "../utils/mod.rs"]
5+
mod utils;
6+
use utils::logger::info;
7+
48
/// Example showcasing the use of the HRTIM peripheral together with a comparator to implement a current fault.
59
/// Once the digital input goes high, the output is forced low and put into a fault state.
610
use cortex_m_rt::entry;
7-
use panic_probe as _;
811
use stm32_hrtim::{
912
compare_register::HrCompareRegister,
1013
fault::{FaultAction, FaultMonitor},
@@ -96,17 +99,17 @@ fn main() -> ! {
9699
out.enable();
97100
timer.start(&mut hr_control.control);
98101

99-
defmt::info!("Started");
102+
info!("Started");
100103

101104
loop {
102105
for _ in 0..5 {
103106
delay.delay(500_u32.millis());
104-
defmt::info!("State: {:?}", out.get_state());
107+
info!("State: {:?}", out.get_state());
105108
}
106109
if hr_control.fault_3.is_fault_active() {
107110
hr_control.fault_3.clear_fault(); // Clear fault every 5s
108111
out.enable();
109-
defmt::info!("failt cleared, and output reenabled");
112+
info!("failt cleared, and output reenabled");
110113
}
111114
}
112115
}

examples/hrtim/hrtim.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
#[path = "../utils/mod.rs"]
55
mod utils;
6+
use utils::logger::info;
67

78
use cortex_m_rt::entry;
8-
use panic_probe as _;
99
use stm32_hrtim::{
1010
compare_register::HrCompareRegister, output::HrOutput, timer::HrTimer, HrParts, HrPwmAdvExt,
1111
Pscl4,
@@ -22,7 +22,7 @@ use stm32g4xx_hal::{
2222

2323
#[entry]
2424
fn main() -> ! {
25-
defmt::info!("Initializing...");
25+
info!("Initializing...");
2626

2727
let dp = Peripherals::take().expect("cannot take peripherals");
2828
let cp = CorePeripherals::take().expect("cannot take core");

examples/hrtim/master.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#![no_std]
22
#![no_main]
33

4+
#[path = "../utils/mod.rs"]
5+
mod utils;
6+
use utils::logger::info;
7+
48
use cortex_m_rt::entry;
5-
use panic_probe as _;
69
use stm32_hrtim::{
710
compare_register::HrCompareRegister,
811
output::HrOutput,
@@ -107,7 +110,7 @@ fn main() -> ! {
107110
mtimer.start(&mut hr_control.control);
108111
timer.start(&mut hr_control.control);
109112

110-
defmt::info!("Running");
113+
info!("Running");
111114

112115
loop {
113116
// Step frequency from 15kHz to about 146kHz(half of that when only looking at one pin)
@@ -119,7 +122,7 @@ fn main() -> ! {
119122
mtimer.set_period(new_period);
120123
timer.set_period(new_period - 1000);
121124

122-
defmt::info!(
125+
info!(
123126
"period: {}, duty: {}, get_duty: {}, get_period: {}",
124127
new_period,
125128
new_period / 3,

0 commit comments

Comments
 (0)