Skip to content

Commit

Permalink
Enable internal pull up rather than requiring external pull ups.
Browse files Browse the repository at this point in the history
  • Loading branch information
ithinuel committed May 22, 2023
1 parent 87763ea commit 274b672
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn main() -> ! {

// Enable adc
let mut adc = Adc::new(p.ADC, &mut p.RESETS);
let mut temp_sense = adc.enable_temp_sensor();
let mut temp_sense = adc.take_temp_sensor().unwrap();

let sio = Sio::new(p.SIO);

Expand Down
44 changes: 22 additions & 22 deletions boards/pimoroni-pico-explorer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ impl PicoExplorer {
internal_pins.motor2_pos.into_function::<FunctionPwm>();
internal_pins.motor2_neg.into_function::<FunctionPwm>();

let dc = internal_pins.spi_miso.into();
let cs = internal_pins.lcd_cs.into();
let spi_sclk = internal_pins.spi_sclk.into();
let spi_mosi = internal_pins.spi_mosi.into();
let dc = internal_pins.spi_miso.into_typestate();
let cs = internal_pins.lcd_cs.into_typestate();
let spi_sclk = internal_pins.spi_sclk.into_typestate();
let spi_mosi = internal_pins.spi_mosi.into_typestate();

let spi_screen =
Spi::new(spi0, (spi_mosi, spi_sclk)).init(resets, 125u32.MHz(), 16u32.MHz(), MODE_0);
Expand All @@ -235,24 +235,24 @@ impl PicoExplorer {
screen,
},
Pins {
gpio0: internal_pins.gpio0.into(),
gpio1: internal_pins.gpio1.into(),
gpio2: internal_pins.gpio2.into(),
gpio3: internal_pins.gpio3.into(),
gpio4: internal_pins.gpio4.into(),
gpio5: internal_pins.gpio5.into(),
gpio6: internal_pins.gpio6.into(),
gpio7: internal_pins.gpio7.into(),
i2c_sda: internal_pins.i2c_sda.into(),
i2c_scl: internal_pins.i2c_scl.into(),
i2c_int: internal_pins.i2c_int.into(),
b_power_save: internal_pins.b_power_save.into(),
vbus_detect: internal_pins.vbus_detect.into(),
led: internal_pins.led.into(),
adc0: internal_pins.adc0.into(),
adc1: internal_pins.adc1.into(),
adc2: internal_pins.adc2.into(),
voltage_monitor: internal_pins.voltage_monitor.into(),
gpio0: internal_pins.gpio0.into_typestate(),
gpio1: internal_pins.gpio1.into_typestate(),
gpio2: internal_pins.gpio2.into_typestate(),
gpio3: internal_pins.gpio3.into_typestate(),
gpio4: internal_pins.gpio4.into_typestate(),
gpio5: internal_pins.gpio5.into_typestate(),
gpio6: internal_pins.gpio6.into_typestate(),
gpio7: internal_pins.gpio7.into_typestate(),
i2c_sda: internal_pins.i2c_sda.into_typestate(),
i2c_scl: internal_pins.i2c_scl.into_typestate(),
i2c_int: internal_pins.i2c_int.into_typestate(),
b_power_save: internal_pins.b_power_save.into_typestate(),
vbus_detect: internal_pins.vbus_detect.into_typestate(),
led: internal_pins.led.into_typestate(),
adc0: internal_pins.adc0.into_typestate(),
adc1: internal_pins.adc1.into_typestate(),
adc2: internal_pins.adc2.into_typestate(),
voltage_monitor: internal_pins.voltage_monitor.into_typestate(),
},
)
}
Expand Down
3 changes: 2 additions & 1 deletion boards/rp-pico/examples/pico_pio_pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ fn main() -> ! {
let installed = pio0.install(&program.program).unwrap();

// Set gpio25 to pio
let _led: hal::gpio::Pin<_, hal::gpio::FunctionPio0, hal::gpio::PullNone> = pins.led.into();
let _led: hal::gpio::Pin<_, hal::gpio::FunctionPio0, hal::gpio::PullNone> =
pins.led.into_typestate();
let led_pin_id = 25;

// Build the pio program and set pin both for set and side set!
Expand Down
7 changes: 4 additions & 3 deletions boards/rp-pico/examples/pico_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod app {
led: hal::gpio::Pin<
hal::gpio::bank0::Gpio25,
hal::gpio::FunctionSioOutput,
hal::gpio::PullNone,
hal::gpio::PullDown,
>,
}

Expand Down Expand Up @@ -57,8 +57,9 @@ mod app {
sio.gpio_bank0,
&mut resets,
);
let mut led = pins.led.into();
led.set_low().unwrap();
let led = pins
.led
.into_push_pull_output_in_state(hal::gpio::PinState::Low);

let mut timer = hal::Timer::new(c.device.TIMER, &mut resets, &clocks);
let mut alarm = timer.alarm_0().unwrap();
Expand Down
37 changes: 3 additions & 34 deletions boards/rp-pico/examples/pico_spi_sd_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,6 @@
//!
//! $ mkfs.fat /dev/sdj1
//!
//! In the following ASCII art the SD card is also connected to 5 strong pull up
//! resistors. I've found varying values for these, from 50kOhm, 10kOhm
//! down to 5kOhm.
//! Stronger pull up resistors will eat more amperes, but also allow faster
//! data rates.
//!
//! ```text
//! +3.3V
//! Pull Ups ->||||
//! 4x[5kOhm]
//! ||| \
//! _______________ ||| \
//! | DAT2/NC 9\---o|| \ _|USB|_
//! | S DAT3/CS 1|---o+----+------SS--\ |1 R 40|
//! | D CMD/DI 2|----o----+-----MOSI-+-\ |2 P 39|
//! | VSS1 3|-- GND | | | GND-|3 38|- GND
//! | C VDD 4|-- +3.3V | /--SCK--+-+----SPI0 SCK-|4 P 37|
//! | A CLK/SCK 5|---------+-/ | \----SPI0 TX--|5 I 36|- +3.3V
//! | R VSS2 6|-- GND | /--MISO-+------SPI0 RX--|6 C |
//! | D DAT0/DO 7|---------o-/ \------SPI0 CSn-|7 O |
//! | DAT1/IRQ 8|-[5k]- +3.3V | |
//! """""""""""""""" | |
//! | |
//! .........
//! |20 21|
//! """""""
//! Symbols:
//! - (+) crossing lines, not connected
//! - (o) connected lines
//! ```
//!
//! The example can either be used with a probe to receive debug output
//! and also the LED is used as status output. There are different blinking
//! patterns.
Expand Down Expand Up @@ -239,9 +208,9 @@ fn main() -> ! {
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().to_Hz());

// These are implicitly used by the spi driver if they are in the correct mode
let spi_sclk = pins.gpio2.into_function::<gpio::FunctionSpi>();
let spi_mosi = pins.gpio3.into_function::<gpio::FunctionSpi>();
let spi_miso = pins.gpio4.into_function::<gpio::FunctionSpi>();
let spi_sclk: gpio::Pin<_, gpio::FunctionSpi, gpio::PullNone> = pins.gpio2.into_typestate();
let spi_mosi: gpio::Pin<_, gpio::FunctionSpi, gpio::PullNone> = pins.gpio3.into_typestate();
let spi_miso: gpio::Pin<_, gpio::FunctionSpi, gpio::PullUp> = pins.gpio4.into_typestate();
let spi_cs = pins.gpio5.into_push_pull_output();

// Create an SPI driver instance for the SPI0 device
Expand Down
4 changes: 2 additions & 2 deletions boards/rp-pico/examples/pico_uart_irq_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ fn main() -> ! {

let uart_pins = (
// UART TX (characters sent from RP2040) on pin 1 (GPIO0)
pins.gpio0.into(),
pins.gpio0.into_typestate(),
// UART RX (characters received by RP2040) on pin 2 (GPIO1)
pins.gpio1.into(),
pins.gpio1.into_typestate(),
);

// Make a UART on the given pins
Expand Down
4 changes: 2 additions & 2 deletions boards/rp-pico/examples/pico_uart_irq_echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ fn main() -> ! {

let uart_pins = (
// UART TX (characters sent from RP2040) on pin 1 (GPIO0)
pins.gpio0.into(),
pins.gpio0.into_typestate(),
// UART RX (characters received by RP2040) on pin 2 (GPIO1)
pins.gpio1.into(),
pins.gpio1.into_typestate(),
);

// Make a UART on the given pins
Expand Down

0 comments on commit 274b672

Please sign in to comment.