Skip to content

Commit

Permalink
fix: delay and flash examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nathansbradshaw committed Jul 15, 2024
1 parent 5093839 commit 2e90a32
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_examples.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Rust Examples
name: Build LibDaisy Examples

on:
push:
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Build examples
run: |
excluded_examples="delay flash hid_blinky knob sdmmc sdram sine switch toggle usb_midi volume" # List of examples to exclude
excluded_examples="hid_blinky knob sdmmc sdram sine switch toggle usb_midi volume" # List of examples to exclude
for example in $(ls examples/*.rs); do
example_name=$(basename $example .rs)
if [[ ! " $excluded_examples " =~ " $example_name " ]]; then
Expand Down
12 changes: 8 additions & 4 deletions examples/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ mod app {
#[local]
struct Local {
audio: audio::Audio,
buffer: audio::AudioBuffer,
buffer: audio::AudioBuffer<{audio::BLOCK_SIZE_MAX}>,
sdram: &'static mut [f32],
}

#[init]
fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) {
logger::init();
let system = system::System::init(ctx.core, ctx.device);
let buffer = [(0.0, 0.0); audio::BLOCK_SIZE_MAX];

let mut core = ctx.core;
let device = ctx.device;
let ccdr = system::System::init_clocks(device.PWR, device.RCC, &device.SYSCFG);
let system = libdaisy::system_init!(core, device, ccdr);
let buffer: audio::AudioBuffer<{audio::BLOCK_SIZE_MAX}> = audio::AudioBuffer::new();

info!("Startup done!");

Expand Down Expand Up @@ -57,7 +61,7 @@ mod app {
let index: &mut usize = ctx.local.index;

if audio.get_stereo(buffer) {
for (left, right) in buffer {
for (left, right) in buffer.iter() {
audio
.push_stereo((sdram[*index], sdram[*index + 1]))
.unwrap();
Expand Down
19 changes: 14 additions & 5 deletions examples/flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,21 @@ mod app {
#[init]
fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) {
logger::init();
let mut system = system::System::init(ctx.core, ctx.device);
let mut core = ctx.core;
let device = ctx.device;
let ccdr = system::System::init_clocks(device.PWR, device.RCC, &device.SYSCFG);
let system = libdaisy::system_init!(core, device, ccdr);
info!("Startup done!");
let mut timer2 = stm32h7xx_hal::timer::TimerExt::timer(
device.TIM2,
MilliSeconds::from_ticks(100).into_rate(),
ccdr.peripheral.TIM2,
&ccdr.clocks,
);

system
.timer2
.set_freq(MilliSeconds::from_ticks(500).into_rate());
timer2.listen(stm32h7xx_hal::timer::Event::TimeOut);

timer2.set_freq(MilliSeconds::from_ticks(500).into_rate());

let mut flash = system.flash;

Expand Down Expand Up @@ -79,7 +88,7 @@ mod app {
Shared {},
Local {
seed_led: system.gpio.led,
timer2: system.timer2,
timer2,
},
init::Monotonics(),
)
Expand Down

0 comments on commit 2e90a32

Please sign in to comment.