feat: don't inline time-critical functions

This commit is contained in:
Naxdy 2024-04-30 13:59:52 +02:00
parent a09d21b4fd
commit b6b5bb25a7
Signed by: Naxdy
GPG key ID: CC15075846BCE91B
4 changed files with 9 additions and 3 deletions

View file

@ -58,7 +58,7 @@ codegen-units = 1
debug = 2 debug = 2
debug-assertions = true debug-assertions = true
incremental = false incremental = false
opt-level = 's' opt-level = 3
lto = "fat" lto = "fat"
overflow-checks = true overflow-checks = true
@ -71,7 +71,7 @@ incremental = false
lto = 'fat' lto = 'fat'
# opt level needs to be benchmarked after every major feature # opt level needs to be benchmarked after every major feature
# due to the changes in binary size and alignment # due to the changes in binary size and alignment
opt-level = 's' opt-level = 3
overflow-checks = false overflow-checks = false
# do not optimize proc-macro crates = faster builds from scratch # do not optimize proc-macro crates = faster builds from scratch

View file

@ -179,7 +179,7 @@ pub struct KalmanState {
} }
impl KalmanState { impl KalmanState {
// runs kalman filter #[inline(never)]
#[link_section = ".time_critical.run_kalman"] #[link_section = ".time_critical.run_kalman"]
pub fn run_kalman( pub fn run_kalman(
&mut self, &mut self,
@ -292,6 +292,7 @@ impl KalmanState {
/// output at the rim longer when released. /// output at the rim longer when released.
/// ///
/// Output is a tuple of the x and y positions. /// Output is a tuple of the x and y positions.
#[inline(never)]
#[link_section = ".time_critical.run_waveshaping"] #[link_section = ".time_critical.run_waveshaping"]
pub fn run_waveshaping( pub fn run_waveshaping(
x_pos: f32, x_pos: f32,

View file

@ -82,6 +82,7 @@ pub enum StickAxis {
YAxis, YAxis,
} }
#[inline(never)]
#[link_section = ".time_critical.read_ext_adc"] #[link_section = ".time_critical.read_ext_adc"]
pub fn read_ext_adc< pub fn read_ext_adc<
'a, 'a,
@ -125,6 +126,7 @@ pub fn read_ext_adc<
/// Gets the average stick state over a 1ms interval in a non-blocking fashion. /// Gets the average stick state over a 1ms interval in a non-blocking fashion.
/// Will wait until end_time is reached before continuing after reading the ADCs. /// Will wait until end_time is reached before continuing after reading the ADCs.
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
#[inline(never)]
#[link_section = ".time_critical.update_stick_states"] #[link_section = ".time_critical.update_stick_states"]
async fn update_stick_states( async fn update_stick_states(
current_stick_state: &StickState, current_stick_state: &StickState,
@ -540,6 +542,7 @@ pub async fn update_button_state_task(
/// ///
/// Has to run on core0 because it makes use of SPI0. /// Has to run on core0 because it makes use of SPI0.
#[embassy_executor::task] #[embassy_executor::task]
#[inline(never)]
#[link_section = ".time_critical.update_stick_states_task"] #[link_section = ".time_critical.update_stick_states_task"]
pub async fn update_stick_states_task( pub async fn update_stick_states_task(
spi: Spi<'static, SPI0, embassy_rp::spi::Blocking>, spi: Spi<'static, SPI0, embassy_rp::spi::Blocking>,

View file

@ -882,6 +882,7 @@ pub fn calc_stick_values(angle: f32) -> (f32, f32) {
(x, y) (x, y)
} }
#[inline(never)]
#[link_section = ".time_critical.linearize"] #[link_section = ".time_critical.linearize"]
pub fn linearize(point: f32, coefficients: &[f32; NUM_COEFFS]) -> f32 { pub fn linearize(point: f32, coefficients: &[f32; NUM_COEFFS]) -> f32 {
coefficients[0] * (point * point * point) coefficients[0] * (point * point * point)
@ -890,6 +891,7 @@ pub fn linearize(point: f32, coefficients: &[f32; NUM_COEFFS]) -> f32 {
+ coefficients[3] + coefficients[3]
} }
#[inline(never)]
#[link_section = ".time_critical.notch_remap"] #[link_section = ".time_critical.notch_remap"]
pub fn notch_remap( pub fn notch_remap(
x_in: f32, x_in: f32,