LLD for SDMMC (STM32F7)

Issue #187 resolved
Patryk Kubiak created an issue

General Description

The task is part of #186. The goal of the task is to provide support for SDMMC driver in the LLD of STM32F7 target.

The related task on the trello board: https://trello.com/c/d3YiDTBr

Related tasks

  • [ #191 ] - Implementation of SDMMC driver - General SDMMC architecture
  • [ #192 ] - Implementation of SDMMC LLD Mode
  • [ #189 ] - LLD for SDMMC (STM32F4)

Required LLD interface

// stores SDMMC command
typedef uint8_t oC_SDMMC_LLD_CommandIndex_t;

typedef enum
{
    oC_SDMMC_LLD_ResponseType_None , 
    oC_SDMMC_LLD_ResponseType_ShortResponse , 
    oC_SDMMC_LLD_ResponseType_LongResponse , 
    oC_SDMMC_LLD_ResponseType_NumberOfElements
} oC_SDMMC_LLD_ResponseType_t;

// Stores source of the interrupt
typedef enum
{
   oC_SDMMC_LLD_InterruptSource_None = 0 ,  // None interrupt source
   oC_SDMMC_LLD_InterruptSource_CommandSent = (1<<0) , // Interrupt is fired when the command has been sent
   oC_SDMMC_LLD_InterruptSource_CommandResponseReceived = (1<<1) , // Interrupt is fired when the response for the command has been received  
   oC_SDMMC_LLD_InterruptSource_DataReadyToReceive = (1<<2) , // Interrupt is fired when Rx FIFO is not empty - some data waits to be read 
   oC_SDMMC_LLD_InterruptSource_ReadyToSendNewData = (1<<3) , // Interrupt is fired when Tx FIFO is not full    
   oC_SDMMC_LLD_InterruptSource_TransmissionError = (1<<4), // Interrupt is fired in case of error 
} oC_SDMMC_LLD_InterruptSource_t;

// Stores pointer to the interrupt handler
typedef void (*oC_SDMMC_LLD_InterruptHandler_t)( oC_SDMMC_Channel_t Channel , oC_SDMMC_LLD_InterruptSource_t InterruptSource ); 

// stores SDMMC command
typedef struct
{
    oC_SDMMC_LLD_CommandIndex_t    CommandIndex; // index of the command 
    uint32_t  Argument; // Argument for the command
    bool SuspendCommand; // If it is set, the command to be sent is a suspend command (to be used only with SDIO card)
    oC_SDMMC_LLD_ResponseType_t ResponseType;    
} oC_SDMMC_LLD_Command_t;

// stores response for the SDMMC command
typedef struct
{
     oC_SDMMC_LLD_CommandIndex_t  CommandIndex; // Index of the command
     uint32_t      Response[4];   // Response for the command
} oC_SDMMC_LLD_CommandResponse_t;

typedef enum
{
    oC_SDMMC_LLD_WideBus_1Bit , // Only D0 is used - default bus mode
    oC_SDMMC_LLD_WideBus_4Bit , // D[0:3] is used
    oC_SDMMC_LLD_WideBus_8Bit , // D[0:7] is used
    oC_SDMMC_LLD_WideBus_NumberOfElements
} oC_SDMMC_LLD_WideBus_t;

// Stores SDMMC LLD configuration
typedef struct
{
    oC_SDMMC_LLD_WideBus_t WideBus;   // Wide of the 
    oC_MemorySize_t SectorSize; // Size of the sector (block) in bytes
    oC_SDMMC_Channel_t Channel; // Channel of the SDMMC
} oC_SDMMC_LLD_Config_t;

// Initializes the SDMMC LLD
extern oC_ErrorCode_t oC_SDMMC_LLD_TurnOn( void );
// releases the SDMMC LLD
extern oC_ErrorCode_t oC_SDMMC_LLD_TurnOff( void );
// Sets address of the interrupt handler
extern oC_ErrorCode_t oC_SDMMC_LLD_SetInterruptHandler( oC_SDMMC_LLD_InterruptHandler_t Handler, oC_SDMMC_LLD_InterruptSource_t EnabledSources );
// configures the SDMMC LLD 
extern oC_ErrorCode_t oC_SDMMC_LLD_Configure( const oC_SDMMC_LLD_Config_t * Config );
// unconfigures SDMMC LLD
extern oC_ErrorCode_t oC_SDMMC_LLD_Unconfigure( oC_SDMMC_Channel_t Channel );
// configures the given pin to work with the SDMMC driver
 extern oC_ErrorCode_t oC_SDMMC_LLD_ConfigurePin( oC_SDMMC_Channel_t Channel , oC_Pin_t Pin , oC_SDMMC_PinFunction_t PinFunction );
// Checks if the given pin can work with the given function for the SDMMC driver
extern bool oC_SDMMC_LLD_IsPinAvailble( oC_SDMMC_Channel_t Channel , oC_Pin_t Pin , oC_SDMMC_PinFunction_t PinFunction );
// Unconfigures SDMMC pin
extern oC_ErrorCode_t oC_SDMMC_LLD_UnconfigurePin( oC_Pin_t Pin );
// Sends SDMMC command
extern oC_ErrorCode_t oC_SDMMC_LLD_SendCommand( oC_SDMMC_Channel_t Channel, const oC_SDMMC_LLD_Command_t * Command ); 
// Reads command response
extern oC_ErrorCode_t oC_SDMMC_LLD_ReadCommandResponse( oC_SDMMC_Channel_t Channel , oC_SDMMC_LLD_CommandResponse_t * outResponse );
// Writes data to the FIFO
extern oC_ErrorCode_t oC_SDMMC_LLD_WriteDataPackage( oC_SDMMC_Channel_t Channel, oC_DataPackage_t * DataPackage );  
// Reads data from the FIFO
extern oC_ErrorCode_t oC_SDMMC_LLD_ReadDataPackage( oC_SDMMC_Channel_t Channel, oC_DataPackage_t * DataPackage );

Comments (21)

  1. Log in to comment