Skip to content

Commit

Permalink
chore: remove magic numbers dma_block_size
Browse files Browse the repository at this point in the history
  • Loading branch information
nathansbradshaw committed Jul 24, 2024
1 parent 58c49f4 commit f1efcd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/passthru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ mod app {
let buffer = ctx.local.buffer;

if audio.get_stereo(buffer) {
for (left, right) in &buffer.as_slice()[..BLOCK_SIZE ] {
for (left, right) in &buffer.as_slice()[..BLOCK_SIZE] {
let _ = audio.push_stereo((*left, *right));
}
} else {
Expand Down
10 changes: 6 additions & 4 deletions src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ impl Audio {
) -> Self {
match board_version {
crate::system::Version::Seed | crate::system::Version::Seed1_1 => {
let dma_buffer_size = block_size * 2 * 2;
let rx_buffer: &'static mut [u32] =
unsafe { &mut RX_BUFFER.as_mut_slice()[..block_size * 2 * 2] };
unsafe { &mut RX_BUFFER.as_mut_slice()[..dma_buffer_size] };
let dma_config = dma::dma::DmaConfig::default()
.priority(dma::config::Priority::High)
.memory_increment(true)
Expand All @@ -188,7 +189,7 @@ impl Audio {
);

let tx_buffer: &'static mut [u32] =
unsafe { &mut TX_BUFFER.as_mut_slice()[..block_size * 2 * 2] };
unsafe { &mut TX_BUFFER.as_mut_slice()[..dma_buffer_size] };
let dma_config = dma_config
.transfer_complete_interrupt(true)
.half_transfer_interrupt(true);
Expand Down Expand Up @@ -304,8 +305,9 @@ impl Audio {
}
}
crate::system::Version::Seed2DFM => {
let dma_buffer_size = block_size * 2 * 2;
let rx_buffer: &'static mut [u32] =
unsafe { &mut RX_BUFFER.as_mut_slice()[..block_size] };
unsafe { &mut RX_BUFFER.as_mut_slice()[..dma_buffer_size] };
let dma_config = dma::dma::DmaConfig::default()
.priority(dma::config::Priority::High)
.memory_increment(true)
Expand All @@ -321,7 +323,7 @@ impl Audio {
);

let tx_buffer: &'static mut [u32] =
unsafe { &mut TX_BUFFER.as_mut_slice()[..block_size] };
unsafe { &mut TX_BUFFER.as_mut_slice()[..dma_buffer_size] };
let dma_config = dma_config
.transfer_complete_interrupt(true)
.half_transfer_interrupt(true);
Expand Down

0 comments on commit f1efcd0

Please sign in to comment.