SAMV71 Xplained Ultra Software Package 1.5

Media.h File Reference

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  MEDTransfer
 Media transfer. More...
struct  sMedia
 Media object. More...

Defines

#define MED_STATUS_SUCCESS   0x00
 Operation result code returned by media methods.
#define MED_STATUS_ERROR   0x01
#define MED_STATUS_BUSY   0x02
#define MED_STATUS_PROTECTED   0x04
#define MED_STATE_NOT_READY   0xFF
 Media statuses.
#define MED_STATE_READY   0x00
#define MED_STATE_BUSY   0x01

Typedefs

typedef void(* MediaCallback )(void *argument, uint8_t status, uint32_t transferred, uint32_t remaining)
typedef uint8_t(* Media_write )(sMedia *pMedia, uint32_t address, void *data, uint32_t length, MediaCallback callback, void *argument)
typedef uint8_t(* Media_read )(sMedia *pMedia, uint32_t address, void *data, uint32_t length, MediaCallback callback, void *argument)
typedef uint8_t(* Media_cancelIo )(sMedia *pMedia)
typedef uint8_t(* Media_lock )(sMedia *pMedia, uint32_t start, uint32_t end, uint32_t *pActualStart, uint32_t *pActualEnd)
typedef uint8_t(* Media_unlock )(sMedia *pMedia, uint32_t start, uint32_t end, uint32_t *pActualStart, uint32_t *pActualEnd)
typedef uint8_t(* Media_ioctl )(sMedia *pMedia, uint8_t ctrl, void *buff)
typedef uint8_t(* Media_flush )(sMedia *pMedia)
typedef void(* Media_handler )(sMedia *pMedia)

Functions

uint8_t MED_Write (sMedia *pMedia, uint32_t address, void *data, uint32_t length, MediaCallback callback, void *argument)
 Writes data on a media.
uint8_t MED_Read (sMedia *pMedia, uint32_t address, void *data, uint32_t length, MediaCallback callback, void *argument)
 Reads a specified amount of data from a media.
uint8_t MED_Lock (sMedia *pMedia, uint32_t start, uint32_t end, uint32_t *pActualStart, uint32_t *pActualEnd)
 Locks all the regions in the given address range.
uint8_t MED_Unlock (sMedia *pMedia, uint32_t start, uint32_t end, uint32_t *pActualStart, uint32_t *pActualEnd)
 Unlocks all the regions in the given address range.
uint8_t MED_Flush (sMedia *pMedia)
void MED_Handler (sMedia *pMedia)
 Invokes the interrupt handler of the specified media.
void MED_DeInit (sMedia *pMedia)
 Reset the media interface to un-configured state.
uint8_t MED_IsInitialized (sMedia *pMedia)
 Check if the Media instance is ready to use.
uint8_t MED_IsBusy (sMedia *pMedia)
 Check if the Media instance is busy in transfer.
uint8_t MED_IsMappedRDSupported (sMedia *pMedia)
 Check if the Media supports mapped reading.
uint8_t MED_IsMappedWRSupported (sMedia *pMedia)
 Check if the Media supports mapped writing.
uint8_t MED_IsProtected (sMedia *pMedia)
 Check if the Media is write protected.
void MED_HandleAll (sMedia *pMedias, uint8_t numMedias)
 Handle interrupts on specified media.
uint8_t MED_GetState (sMedia *pMedia)
 Return current state of the Media.
uint32_t MED_GetBlockSize (sMedia *pMedia)
 Return block size in bytes.
uint32_t MED_GetSize (sMedia *pMedia)
 Return Media size in number of blocks.
uint32_t MED_GetMappedAddress (sMedia *pMedia, uint32_t dwBlk)
 Return mapped memory address for a block on media.

Variables

uint32_t gNbMedias

Detailed Description

Purpose

Generic Media type, which provides transparent access to all types of memories.

Note:
The physical or HW related media operations (physical device connection & protection detecting, PIO configurations and interface driver initialization) are excluded.

Usage

  1. Do PIO initialization for peripheral interfaces.
  2. Initialize peripheral interface driver & device driver.
  3. Initialize specific media interface and link to this initialized driver.

Definition in file Media.h.


Function Documentation

void MED_DeInit ( sMedia *  pMedia  ) 

Reset the media interface to un-configured state.

Parameters:
media Pointer to the Media instance to use

Definition at line 154 of file Media.c.

uint8_t MED_Flush ( sMedia *  pMedia  ) 
Parameters:
media Pointer to the Media instance to use

Definition at line 132 of file Media.c.

uint32_t MED_GetBlockSize ( sMedia *  pMedia  ) 

Return block size in bytes.

Parameters:
pMedia Pointer to the Media instance to use

Definition at line 217 of file Media.c.

uint32_t MED_GetMappedAddress ( sMedia *  pMedia,
uint32_t  dwBlk 
)

Return mapped memory address for a block on media.

Parameters:
pMedia Pointer to the Media instance to use

Definition at line 235 of file Media.c.

uint32_t MED_GetSize ( sMedia *  pMedia  ) 

Return Media size in number of blocks.

Parameters:
pMedia Pointer to the Media instance to use

Definition at line 226 of file Media.c.

uint8_t MED_GetState ( sMedia *  pMedia  ) 

Return current state of the Media.

Parameters:
pMedia Pointer to the Media instance to use

Definition at line 208 of file Media.c.

void MED_HandleAll ( sMedia *  pMedia,
uint8_t  bNumMedia 
)

Handle interrupts on specified media.

Parameters:
pMedia List of media
bNumMedia Number of media in list
See also:
S_media

Definition at line 247 of file Media.c.

Here is the call graph for this function:

void MED_Handler ( sMedia *  pMedia  ) 

Invokes the interrupt handler of the specified media.

Parameters:
media Pointer to the Media instance to use

Definition at line 144 of file Media.c.

uint8_t MED_IsBusy ( sMedia *  pMedia  ) 

Check if the Media instance is busy in transfer.

Parameters:
pMedia Pointer to the Media instance to use

Definition at line 172 of file Media.c.

uint8_t MED_IsInitialized ( sMedia *  pMedia  ) 

Check if the Media instance is ready to use.

Parameters:
media Pointer to the Media instance to use

Definition at line 163 of file Media.c.

uint8_t MED_IsMappedRDSupported ( sMedia *  pMedia  ) 

Check if the Media supports mapped reading.

Parameters:
pMedia Pointer to the Media instance to use

Definition at line 181 of file Media.c.

uint8_t MED_IsMappedWRSupported ( sMedia *  pMedia  ) 

Check if the Media supports mapped writing.

Parameters:
pMedia Pointer to the Media instance to use

Definition at line 190 of file Media.c.

uint8_t MED_IsProtected ( sMedia *  pMedia  ) 

Check if the Media is write protected.

Parameters:
pMedia Pointer to the Media instance to use

Definition at line 199 of file Media.c.

uint8_t MED_Lock ( sMedia *  pMedia,
uint32_t  start,
uint32_t  end,
uint32_t *  pActualStart,
uint32_t *  pActualEnd 
)

Locks all the regions in the given address range.

Parameters:
media Pointer to a Media instance
start Start address of lock range.
end End address of lock range.
pActualStart Start address of the actual lock range (optional).
pActualEnd End address of the actual lock range (optional).
Returns:
0 if successful; otherwise returns an error code.

Definition at line 99 of file Media.c.

uint8_t MED_Read ( sMedia *  pMedia,
uint32_t  address,
void *  data,
uint32_t  length,
MediaCallback  callback,
void *  argument 
)

Reads a specified amount of data from a media.

Parameters:
media Pointer to a Media instance
address Address of the data to read
data Pointer to the buffer in which to store the retrieved data
length Length of the buffer
callback Optional pointer to a callback function to invoke when the operation is finished
argument Optional pointer to an argument for the callback
Returns:
Operation result code
See also:
TransferCallback

Definition at line 83 of file Media.c.

uint8_t MED_Unlock ( sMedia *  pMedia,
uint32_t  start,
uint32_t  end,
uint32_t *  pActualStart,
uint32_t *  pActualEnd 
)

Unlocks all the regions in the given address range.

Parameters:
media Pointer to a Media instance
start Start address of unlock range.
end End address of unlock range.
pActualStart Start address of the actual unlock range (optional).
pActualEnd End address of the actual unlock range (optional).
Returns:
0 if successful; otherwise returns an error code.

Definition at line 118 of file Media.c.

uint8_t MED_Write ( sMedia *  pMedia,
uint32_t  address,
void *  data,
uint32_t  length,
MediaCallback  callback,
void *  argument 
)

Writes data on a media.

Parameters:
media Pointer to a Media instance
address Address at which to write
data Pointer to the data to write
length Size of the data buffer
callback Optional pointer to a callback function to invoke when the write operation terminates
argument Optional argument for the callback function
Returns:
Operation result code
See also:
TransferCallback

Definition at line 61 of file Media.c.


Variable Documentation

uint32_t gNbMedias

Number of medias which are effectively used.

Definition at line 43 of file Media.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines