# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# MLA -- File I/O Library

- 1
- 2
…
- 16
- 17
- 18
- 19
- 20
…
- 82
- 83

1.5.2 Physical Layer Configuration Options
Modules
Name Description
SD-SPI Configuration Options Describes configuration options for the SD-SPI Physical Layer.
1.5.2.1 SD-SPI Configuration Options
Describes configuration options for the SD-SPI Physical Layer.
Macros
Name Description
FILEIO_SD_SendMediaCmd_Slow Define the function to send a media command at a slow clock rate
FILEIO_SD_SPI_Get_Slow Define the function to read an SPI byte at a slow clock rate
FILEIO_SD_SPI_Put_Slow Define the function to write an SPI byte at a slow clock rate
FILEIO_SD_SPIInitialize_Slow Define the function to initialize the SPI module for operation at a slow
clock rate
Description
This section describes configuration options for the SD-SPI Physical Layer.
During the media initialization sequence for SD cards, it is necessary to clock the media at a frequency between 100 kHz
and 400 kHz, since some media types power up in open drain output mode and cannot run fast initially. On PIC18 devices,
when the CPU is running at full frequency, the standard SPI prescalars cannot reach a low enough SPI frequency.
Therefore, we provide a number of function pointer configuration options to allow the user to remap the SPI functions called
during the "slow" part of the initialization to user-implemented functions that can provide the correct functionality. For
example, a bit-banged SPI module could be implemented to provide a clock between 100 and 400 kHz.
If the system clock can be scaled to provide an appropriate SPI clock frequency, these functions can simply be mapped to
the fast SPI driver functions. Alternatively, you can decrease the PIC18's system clock frequency (by disabling the PLL,
clock switching, etc) to provide a slow enough clock to allow SD Card initialization. If you choose this option, you must define
the SYS_CLK_FrequencySystemGet function in a way that will return the correct clock frequency at both given clock
frequencies.
Note:
The SD-SPI physical layer makes use of the MLA's SPI driver (drv_spi.c/h). This driver requires additional
configuration definitions to enable SPI channels or features (e.g. #define DRV_SPI_CONFIG_CHANNEL_1_ENABLE). For
more information, please see the MLA Driver help file.
1.5.2.1.1 FILEIO_SD_SendMediaCmd_Slow Macro
File
sd_spi_config_template.h
Syntax
#define FILEIO_SD_SendMediaCmd_Slow FILEIO_SD_SendCmd
Module
SD-SPI Configuration Options
Description
Define the function to send a media command at a slow clock rate
1.5 Configuring the Library MLA - File I/O Library Help Physical Layer Configuration Options
18

- 1
- 2
…
- 16
- 17
- 18
- 19
- 20
…
- 82
- 83