capsules_extra

Module sdcard

Source
Expand description

Provides driver for accessing an SD Card and a userspace Driver.

This allows initialization and block reads or writes on top of SPI.

§Usage


let spi_mux = components::spi::SpiMuxComponent::new(
        &base_peripherals.spim0,
        dynamic_deferred_caller
    ).finalize(components::spi_mux_component_helper!(nrf52833::spi::SPIM));
base_peripherals.spim0.configure(
    nrf52833::pinmux::Pinmux::new(SPI_MOSI_PIN as u32), // SD MOSI
    nrf52833::pinmux::Pinmux::new(SPI_MISO_PIN as u32), // SD MISO
    nrf52833::pinmux::Pinmux::new(SPI_SCK_PIN as u32),  // SD SCK
);

let sdcard_spi = components::spi::SpiComponent::new(
        spi_mux,
        &nrf52833_peripherals.gpio_port[SPI_CS_PIN]
    ).finalize(components::spi_component_helper!(nrf52833::spi::SPIM));

let sdcard_virtual_alarm = static_init!(
     capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf52833::rtc::Rtc>,
     capsules::virtual_alarm::VirtualMuxAlarm::new(mux_alarm));
sdcard_virtual_alarm.setup();

let sdcard_tx_buffer = static_init!([u8; capsules::sdcard::TXRX_BUFFER_LENGTH],
                                    [0; capsules::sdcard::TXRX_BUFFER_LENGTH]);
let sdcard_rx_buffer = static_init!([u8; capsules::sdcard::TXRX_BUFFER_LENGTH],
                                    [0; capsules::sdcard::TXRX_BUFFER_LENGTH]);

let sdcard = static_init!(
    capsules::sdcard::SDCard<
        'static,
        capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf52833::rtc::Rtc>>,
    capsules::sdcard::SDCard::new(sdcard_spi,
                                  sdcard_virtual_alarm,
                                  Some(&SD_DETECT_PIN),
                                  sdcard_tx_buffer,
                                  sdcard_rx_buffer));
sdcard_spi.set_client(sdcard);
sdcard_virtual_alarm.set_alarm_client(sdcard);
SD_DETECT_PIN.set_client(sdcard);

let sdcard_kernel_buffer = static_init!([u8; capsules::sdcard::KERNEL_BUFFER_LENGTH],
                                        [0; capsules::sdcard::KERNEL_BUFFER_LENGTH]);

let sdcard_driver = static_init!(
    capsules::sdcard::SDCardDriver<
        'static,
        capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf52833::rtc::Rtc>>,
    capsules::sdcard::SDCardDriver::new(
        sdcard,
        sdcard_kernel_buffer,
        board_kernel.create_grant(
            capsules::sdcard::DRIVER_NUM,
            &memory_allocation_capability)));
sdcard.set_client(sdcard_driver);

Structs§

  • Holds buffers and whatnot that the application has passed us.
  • SD Card capsule, capable of being built on top of by other kernel capsules
  • Application driver for SD Card capsule.

Constants§

Traits§