clean up unused code
This commit is contained in:
parent
a091567aa2
commit
74a9fb3073
4 changed files with 9 additions and 53 deletions
|
@ -1,5 +1,3 @@
|
||||||
use core::ops::Deref;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct GccState {
|
pub struct GccState {
|
||||||
pub a: bool,
|
pub a: bool,
|
||||||
|
|
|
@ -1,17 +1,14 @@
|
||||||
use cortex_m::{delay::Delay, singleton};
|
use cortex_m::delay::Delay;
|
||||||
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
||||||
use rp_pico::{
|
use rp_pico::{
|
||||||
hal::{
|
hal::{
|
||||||
dma::{double_buffer, single_buffer, DMAExt},
|
|
||||||
gpio::{Pin, PinId, PinMode, Pins, ValidPinMode},
|
|
||||||
pio::{
|
pio::{
|
||||||
InstalledProgram, Rx, StateMachine, StateMachineIndex, Stopped, Tx, UninitStateMachine,
|
InstalledProgram, Rx, StateMachine, StateMachineIndex, Stopped, Tx, UninitStateMachine,
|
||||||
ValidStateMachine, PIO, SM0,
|
PIO,
|
||||||
},
|
},
|
||||||
prelude::_rphal_pio_PIOExt,
|
prelude::_rphal_pio_PIOExt,
|
||||||
Sio,
|
|
||||||
},
|
},
|
||||||
pac::{self, Peripherals, PIO0, RESETS},
|
pac::{PIO0, RESETS},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -119,6 +116,7 @@ pub fn datatransfer(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// poll
|
||||||
if data == 0x40 {
|
if data == 0x40 {
|
||||||
let mut state = GccState::new();
|
let mut state = GccState::new();
|
||||||
|
|
||||||
|
@ -139,7 +137,7 @@ pub fn datatransfer(
|
||||||
|
|
||||||
while rx.read().is_none() {}
|
while rx.read().is_none() {}
|
||||||
|
|
||||||
let rumble = loop {
|
let _rumble = loop {
|
||||||
match rx.read() {
|
match rx.read() {
|
||||||
Some(x) => break x as u8,
|
Some(x) => break x as u8,
|
||||||
None => continue,
|
None => continue,
|
||||||
|
@ -148,22 +146,6 @@ pub fn datatransfer(
|
||||||
|
|
||||||
delay.delay_us(8);
|
delay.delay_us(8);
|
||||||
|
|
||||||
// let (st, installed) = s.uninit(rx, tx);
|
|
||||||
|
|
||||||
// (sm, rx, tx) =
|
|
||||||
// init_state_machine_with_installed_program(st, datapin.id().num, installed);
|
|
||||||
|
|
||||||
// sm.exec_instruction(pio::Instruction {
|
|
||||||
// operands: pio::InstructionOperands::JMP {
|
|
||||||
// condition: pio::JmpCondition::Always,
|
|
||||||
// address: offset + offset_outmode as u8,
|
|
||||||
// },
|
|
||||||
// delay: 0,
|
|
||||||
// side_set: None,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// s = sm.start();
|
|
||||||
|
|
||||||
let mut st = s.stop();
|
let mut st = s.stop();
|
||||||
st.exec_instruction(pio::Instruction {
|
st.exec_instruction(pio::Instruction {
|
||||||
operands: pio::InstructionOperands::JMP {
|
operands: pio::InstructionOperands::JMP {
|
||||||
|
@ -178,12 +160,7 @@ pub fn datatransfer(
|
||||||
for i in 0..pio_response.len() {
|
for i in 0..pio_response.len() {
|
||||||
while !tx.write((*pio_response)[i]) {}
|
while !tx.write((*pio_response)[i]) {}
|
||||||
}
|
}
|
||||||
|
// origin
|
||||||
// if rumble & 1 == 1 {
|
|
||||||
// ledpin.set_high().unwrap();
|
|
||||||
// } else {
|
|
||||||
// ledpin.set_low().unwrap();
|
|
||||||
// }
|
|
||||||
} else if data == 0x41 {
|
} else if data == 0x41 {
|
||||||
let origin_response: [u8; 10] = [0x00, 0x80, 127, 127, 127, 127, 0, 0, 0, 0];
|
let origin_response: [u8; 10] = [0x00, 0x80, 127, 127, 127, 127, 0, 0, 0, 0];
|
||||||
let pio_response: PioResponse<6> = to_pio_response(origin_response);
|
let pio_response: PioResponse<6> = to_pio_response(origin_response);
|
||||||
|
@ -204,8 +181,7 @@ pub fn datatransfer(
|
||||||
for i in 0..pio_response.len() {
|
for i in 0..pio_response.len() {
|
||||||
while !tx.write((*pio_response)[i]) {}
|
while !tx.write((*pio_response)[i]) {}
|
||||||
}
|
}
|
||||||
|
// probe
|
||||||
// make ledpin blink twice with 500 ms delay
|
|
||||||
} else if data == 0 {
|
} else if data == 0 {
|
||||||
let probe_response: [u8; 3] = [0x09, 0x00, 0x03];
|
let probe_response: [u8; 3] = [0x09, 0x00, 0x03];
|
||||||
let pio_response: PioResponse<2> = to_pio_response(probe_response);
|
let pio_response: PioResponse<2> = to_pio_response(probe_response);
|
||||||
|
@ -226,6 +202,7 @@ pub fn datatransfer(
|
||||||
for i in 0..pio_response.len() {
|
for i in 0..pio_response.len() {
|
||||||
while !tx.write((*pio_response)[i]) {}
|
while !tx.write((*pio_response)[i]) {}
|
||||||
}
|
}
|
||||||
|
// something else (probably snippet of some other message)
|
||||||
} else {
|
} else {
|
||||||
ledpin.set_high().unwrap();
|
ledpin.set_high().unwrap();
|
||||||
let (st, installed) = s.uninit(rx, tx);
|
let (st, installed) = s.uninit(rx, tx);
|
||||||
|
|
|
@ -7,10 +7,9 @@
|
||||||
use bsp::entry;
|
use bsp::entry;
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use defmt_rtt as _;
|
use defmt_rtt as _;
|
||||||
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
|
||||||
use panic_probe as _;
|
use panic_probe as _;
|
||||||
|
|
||||||
use rp2040_hal::xosc::CrystalOscillator;
|
|
||||||
// Provide an alias for our BSP so we can switch targets quickly.
|
// Provide an alias for our BSP so we can switch targets quickly.
|
||||||
// Uncomment the BSP you included in Cargo.toml, the rest of the code does not need to change.
|
// Uncomment the BSP you included in Cargo.toml, the rest of the code does not need to change.
|
||||||
use rp_pico as bsp;
|
use rp_pico as bsp;
|
||||||
|
@ -28,7 +27,6 @@ use crate::joybus::datatransfer;
|
||||||
mod gccstate;
|
mod gccstate;
|
||||||
mod joybus;
|
mod joybus;
|
||||||
mod pio;
|
mod pio;
|
||||||
mod types;
|
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
|
|
17
src/types.rs
17
src/types.rs
|
@ -1,17 +0,0 @@
|
||||||
struct GccState {
|
|
||||||
a: u8,
|
|
||||||
b: u8,
|
|
||||||
x: u8,
|
|
||||||
y: u8,
|
|
||||||
start: u8,
|
|
||||||
dup: u8,
|
|
||||||
dleft: u8,
|
|
||||||
dright: u8,
|
|
||||||
ddown: u8,
|
|
||||||
l: u8,
|
|
||||||
r: u8,
|
|
||||||
lstickx: i8,
|
|
||||||
lsticky: i8,
|
|
||||||
rstickx: i8,
|
|
||||||
rsticky: i8,
|
|
||||||
}
|
|
Loading…
Reference in a new issue