some refactoring and clippies
Build and Release Firmware / build-and-release (push) Failing after 48s
Build and Release Firmware / build-and-release (push) Failing after 48s
This commit is contained in:
1 parent
bb7f701f20
commit
e255636f3a
8 files changed
+119
-102
No files matched your search
+14
-17
@@ -12,7 +12,6 @@ use core::ptr;
|
||||
use core::sync::atomic::AtomicPtr;
|
||||
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use cortex_m_rt::entry;
|
||||
use defmt;
|
||||
use defmt::debug;
|
||||
use defmt_rtt as _;
|
||||
use hal::Pin;
|
||||
@@ -110,6 +109,7 @@ const HID_INTERVAL_MS: u8 = 10;
|
||||
const HID_CMD_INTERVAL_MS: u8 = 100;
|
||||
|
||||
struct CodecPins {
|
||||
#[allow(dead_code)]
|
||||
reset: Pin<pins::Pio0_3, Gpio<Output>>,
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ pub struct FeedbackConfig {
|
||||
impl FeedbackConfig {
|
||||
pub fn new(nominal_rate: u32, target_fill_bytes: usize) -> Self {
|
||||
Self {
|
||||
nominal_rate: nominal_rate,
|
||||
nominal_rate,
|
||||
target_fill_bytes: target_fill_bytes as i32,
|
||||
deadband_bytes: 4,
|
||||
max_deviation_divider: 500, // 0.2%
|
||||
@@ -321,11 +321,6 @@ fn cur_fill() -> usize {
|
||||
produced_bytes.wrapping_sub(consumed_bytes) as usize
|
||||
}
|
||||
|
||||
/// current fill target (based on current slot size)
|
||||
fn cur_fill_target() -> i32 {
|
||||
(dma_ring().slot_size() * N_SLOTS) as i32 / 2
|
||||
}
|
||||
|
||||
/// frames per slot (based on current slot size)
|
||||
fn frames_per_slot() -> usize {
|
||||
dma_ring().slot_size() / BYTES_PER_FRAME
|
||||
@@ -572,7 +567,10 @@ impl<D: Dac<I>, I> ClockSource for Audio<'_, D, I> {
|
||||
}
|
||||
self.cur_rate = sample_rate;
|
||||
let slot_bytes = bytes_per_slot(self.cur_rate);
|
||||
dma_ring().set_slot_size(slot_bytes);
|
||||
if let Err(e) = dma_ring().set_slot_size(slot_bytes) {
|
||||
defmt::error!("Error configuring dma: {}", e);
|
||||
return Err(UsbAudioClassError::Other);
|
||||
}
|
||||
self.fb
|
||||
.update_config(FeedbackConfig::for_rate(self.cur_rate));
|
||||
if 24_576_000u32.is_multiple_of(sample_rate) {
|
||||
@@ -669,7 +667,7 @@ impl<D: Dac<I>, I, B: bus::UsbBus> AudioHandler<'_, B> for Audio<'_, D, I> {
|
||||
AudioState::Running => {}
|
||||
// If draining, check cur_fill, if it rises above QUEUE_RUNNING_UP, move back to running. If it drops to 0, move to NoData or Stopped
|
||||
AudioState::LowData => {
|
||||
let fill = cur_fill() as usize;
|
||||
let fill = cur_fill();
|
||||
// Do we check alt setting here? We shouldn't be receiving data at all if we are not in altSetting 1
|
||||
if fill >= queue_running_up_threshold() {
|
||||
self.transition(AudioState::Running);
|
||||
@@ -812,7 +810,7 @@ fn main() -> ! {
|
||||
pins::Pio1_20::take().unwrap().into_i2c4_scl_pin(&mut iocon),
|
||||
pins::Pio1_21::take().unwrap().into_i2c4_sda_pin(&mut iocon),
|
||||
);
|
||||
let codec_i2s_pins = (
|
||||
let _codec_i2s_pins = (
|
||||
pins::Pio0_21::take().unwrap().into_spi7_sck_pin(&mut iocon),
|
||||
pins::Pio0_20::take().unwrap().into_i2s7_sda_pin(&mut iocon),
|
||||
pins::Pio0_19::take().unwrap().into_i2s7_ws_pin(&mut iocon),
|
||||
@@ -995,10 +993,10 @@ fn main() -> ! {
|
||||
|
||||
if hid_update_timer.wait().is_ok() {
|
||||
let report = build_telemetry_report(&PERF, uac2.handler());
|
||||
if let Err(e) = hid.push_input(&report) {
|
||||
if e != UsbError::WouldBlock {
|
||||
defmt::error!("Failed to send HID report: {:?}", e);
|
||||
}
|
||||
if let Err(e) = hid.push_input(&report)
|
||||
&& e != UsbError::WouldBlock
|
||||
{
|
||||
defmt::error!("Failed to send HID report: {:?}", e);
|
||||
}
|
||||
// LPC55 CTIMER is not periodic; restart manually
|
||||
hid_update_timer.start(Microseconds::new(HID_INTERVAL_MS as u32 * 1000));
|
||||
@@ -1008,10 +1006,9 @@ fn main() -> ! {
|
||||
Ok(len) => {
|
||||
if let Ok((_left, cmd)) =
|
||||
AudioDeviceCommandReport::from_bytes((&cmd_report_buf[0..len], 0))
|
||||
&& let Ok(cmd) = cmd.try_into()
|
||||
{
|
||||
if let Ok(cmd) = cmd.try_into() {
|
||||
handle_cmd(cmd)
|
||||
}
|
||||
handle_cmd(cmd)
|
||||
}
|
||||
}
|
||||
Err(UsbError::WouldBlock) => {}
|
||||
|
||||
Reference in new issue
Block a user