MMC and SD Media Driver for Atmel SAM User Guide

Similar documents
FTL NOR RAM Flash Driver User Guide

USB Atmel Host Controller User Guide

USB MAX3421 Host Controller User Guide

USB EHCI Host Controller User Guide

Network Driver for Microchip LAN7500 and LAN9500 User Guide

Embedded USB Host Hub Class Driver User Guide

HCC-Embedded. Embedded Flash File System Flash Translation Layer Developer Guide

CDC-ACM Driver for Windows Installation Guide

Application Note AN101

SD Mode SD Memory Card Driver Firmware Integration Technology

C:\Users\Jacob Christ\Documents\MtSAC\ELEC74 Mt SAC - chipkit\homework Sheets.docx

EDBG. Description. Programmers and Debuggers USER GUIDE

Interfacing Z8 Encore! XP MCUs with an I 2 C-Based Character LCD

Device: MOD This document Version: 1.0. Matches module version: v3 [29 June 2016] Date: 23 October 2017

Clock Synchronous Control Module for Serial Flash Memory Access Firmware Integration Technology

Kinetis Bootloader to Update Multiple Devices in a Field Bus Network

Adafruit seesaw. Created by Dean Miller. Last updated on :30:23 AM UTC

USER GUIDE EDBG. Description

A33 Nand Flash Controller Specification

PropIO V2 User Guide. Wayne Warthen RetroBrew Computers

Application Note: AN00144 xcore-xa - xcore ARM Boot Library

AT03262: SAM D/R/L/C System Pin Multiplexer (SYSTEM PINMUX) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

UM2379. The BlueNRG-1, BlueNRG-2 radio driver. User manual. Introduction

1 Introduction Revision History... 4

BDTIC

C:\Users\jacob\Documents\MtSAC\ELEC74 Mt SAC - chipkit\homework Sheets.docx

User Guide for USBX Device Stack

AN127 FLASH PROGRAMMING VIA THE C2 INTERFACE. Relevant Devices. Introduction. C2 Interface

,879 B FAT #1 FAT #2 root directory data. Figure 1: Disk layout for a 1.44 Mb DOS diskette. B is the boot sector.

Application Note: AN00142 xcore-xa - xcore ARM Bridge Library

USB-910H API DLL and Include File Reference Manual

SAINT2. System Analysis Interface Tool 2. Emulation User Guide. Version 2.5. May 27, Copyright Delphi Automotive Systems Corporation 2009, 2010

GENOVATION. Application Note: MiniTerm USB Low-Level Programming

AN5200. Getting started with STM32H7 Series SDMMC host controller. Application note. Introduction

AN4491 Application note

AN434: CP2110/4 Interface Specification

ESP8266 Application Note Firmware Download Protocol

AN EZ-USB FX3 I 2 C Boot Option. Application Note Abstract. Introduction. FX3 Boot Options

Final Exam. 11 May 2018, 120 minutes, 26 questions, 100 points

Installation and operation manual PCIe-CAN-01 / PCIe-CAN-02

F2MC-8FX EEPROM Library

MP3 Trigger v2 User Guide

RFID A1 Module User Manual V1.183

AntiLogReader Command Line Application User Guide

Genesys Logic, Inc. GL823K. USB 2.0 SD/MSPRO Card Reader Controller. Datasheet. Devin Qiu Q:

SC2004MBS 20x4 Characters MODBUS RTU Slave LCD

Real-Time Systems / Real-Time Operating Systems EE445M/EE380L.6, Spring 2016

Read section 8 of this document for detailed instructions on how to use this interface spec with LibUSB For OSX

11. SD/MMC Controller

ATAES132A Firmware Development Library. Introduction. Features. Atmel CryptoAuthentication USER GUIDE

What is SmartUPS. Connections. Button and LED Indicator. SmartUPS User Guide

IP-48DAC channel 16-bit Digital/Analog Converter With memory Industry Pack Module PROGRAMMING MANUAL Version 1.

AN3281 Application note

SPI (Serial & Peripheral Interface)

Smart.IO Host Interface Layer and Demo Programs

Experiment 1. Development Platform. Ahmad Khayyat, Hazem Selmi, Saleh AlSaleh

Serial Communication. Simplex Half-Duplex Duplex

0x42c Documentation. Release José Manuel Díez

System Summary Based On System Specification Version 3.31 MMCA Technical Committee

User's Manual. USB 2.0 Audio PCA with 16 Bit I/O, 4 x 4 Audio Mixer

CAN / RS485. Product Description. Technical Reference Note. Interface Adapter. Special Features

Generic MPF NFC imx6/imx28 BBT User Manual

AVR Subroutine Basics

DEVBOARD3 DATASHEET. 10Mbits Ethernet & SD card Development Board PIC18F67J60 MICROCHIP

RFID MODULE Mifare Reader / Writer SL030 User Manual Version 2.4 Nov 2011 StrongLink

User Guide. Micron NAND Flash Simulator (NSIM)

User Manual SUSI 4.0. Secured & Unified Smart Interface Software APIs

AN5179. RS232 communications with a terminal using the STM8 Nucleo-64 boards. Application note. Introduction

smxfs Portable FAT File System

Hitex ARM Conference. Future Proof Software

Secure Digital Input/Output (SDIO) Host Controller Data Sheet

Chapter 5 Input/Output

Using the I 2 C Interface on the ATmega328P and MC908JL16

Digi-Pas. Installation and Operation Guidelines for DWL5000XY, DWL5500XY and DWL5800XY Tilt Sensor Modules. Rev

Flash Standards for Embedded Systems

System Specification Version 3.31 MMCA Technical Committee

Intel Platform Innovation Framework for EFI SMBus Host Controller Protocol Specification. Version 0.9 April 1, 2004

GLS55LC200 NAND Controller (CompactFlash Interface)

Panther Programmer USER MANUAL. Version 1.01 November, 2017

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification

February 28,

Ausgewählte Betriebssysteme - Mark Russinovich & David Solomon (used with permission of authors)

APPLICATION NOTE 5306 Programming Baud Rates of the MAX3108 UART

External memory code execution on STM32F7x0 Value line and STM32H750 Value line MCUs

Adding a Second Ethernet Driver to NET+OS

nrf5x Command Line Tools v9.2.0

4th Generation USB 2.0 Flash Media Controller with Integrated Card Power FETs and HS Hub

AT03255: SAM D/R/L/C Serial Peripheral Interface (SERCOM SPI) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

SLC Commercial and Industrial Secure Digital (SD/SDHC) Card

Using the MPC5777M MCAN Module to Exchange CAN FD Messages

AN5153 Application note

Using SDCard and SDIO with the Intel PXA250 Applications Processor MMC Controller

Input/Output Programming

N720 OpenLinux Software User Guide Version 1.2

Programming Flash Devices

ArduCAM-M-2MP Camera Shield

Models LR-F28335DAQ & LR-F28335DAQ8x8. Technical Reference Manual. August 25, Document Number:

EE445M/EE380L.6 Quiz 2 Spring 2017 Solution Page 1 of 5

Hello, and welcome to this presentation of the STM32 Flash memory interface. It covers all the new features of the STM32F7 Flash memory.

Application Note: AN00189 Using QuadSPI for application overlay data

Transcription:

MMC and SD Media Driver for Atmel SAM User Guide Version 1.60 For use with MMC and SD Media Driver for Atmel SAM versions 2.03 and above Date: 18-Aug-2017 15:15 All rights reserved. This document and the associated software are the sole property of HCC Embedded. Reproduction or duplication by any means of any portion of this document without the prior written consent of HCC Embedded is expressly forbidden. HCC Embedded reserves the right to make changes to this document and to the related software at any time and without notice. The information in this document has been carefully checked for its accuracy; however, HCC Embedded makes no warranty relating to the correctness of this document. Copyright HCC Embedded 2017 1 www.hcc-embedded.com

Table of Contents System Overview 3 Introduction 3 Feature Check 4 Device 5 Packages and Documents 6 Packages 6 Documents 6 Change History 7 Source File List 8 API Header File 8 Configuration File 8 Source Code Files 8 Version File 8 Platform Support Package (PSP) Files 9 Configuration Options 10 Application Programming Interface 11 mmcsd_initfunc 11 F_DRIVER Structure 12 Error Codes 13 Integration 14 OS Abstraction Layer 14 PSP Porting 15 psp_mmcsd_init 16 psp_mmcsd_delete 17 psp_mmcsd_power 18 psp_mmcsd_card_plugged 19 psp_mmcsd_card_writeprotect 20 psp_mmcsd_drive_cmd 21 psp_mmcsd_drive_d0 22 Copyright HCC Embedded 2017 2 www.hcc-embedded.com

1 System Overview 1.1 Introduction This guide is for those who want to use HCC Embedded's MMC and SD Media Driver for the Atmel SAM range of micro-controllers. This supports the Atmel SAM9G, SAM3S, SAM4E, and SAM4S families. These use the Atmel SDIO Secure Digital (SD) controller. This guide covers all aspects of configuration and use. This media driver conforms to the HCC Media Driver Interface Specification. It provides an interface for a file system to read from and write to Secure Digital (SD), MultiMediaCard (MMC), or emmc (embedded MMC) storage devices. A single media driver can support one or more physical media, each of these being represented as a different drive at the media driver interface. The file system handles all drives identically, regardless of their internal design features. If emmc is used, this media driver can be used with HCC's emmc Management Driver. This is an extension to HCC's MMC and SD media drivers and is independent of any particular micro-controller and its MMC/SD controller. For details, see the HCC emmc Management Extension for MMC and SD Drivers User Guide. The diagram below shows a typical system architecture including a file system, media driver and media. As an example, this shows one MMC, one emmc, and one SD card. Copyright HCC Embedded 2017 3 www.hcc-embedded.com

1.2 Feature Check The main features of the media driver are the following: Conforms to the HCC Advanced Embedded Framework. Designed for integration with both RTOS and non-rtos based systems. Conforms to the HCC Media Driver Interface Specification. Supports multiple MMC/SD devices. Supports the Atmel SDIO controller used in the SAM range of microcontrollers (the Atmel SAM9G, SAM3S, SAM4E, and SAM4S families). Supports multiple card types: MMC and SD and also SDHC (Secure Digital High Capacity) and SDXC (Secure Digital extended Capacity). Supports emmc (embedded MMC) and can be used with HCC's emmc Management Driver. Supports Direct Memory Access (DMA) transfers. Supports 4 and 8 bit modes. Copyright HCC Embedded 2017 4 www.hcc-embedded.com

1.3 Device This table summarizes the properties of the relevant device types: SAM3S SAM4E SAM4S SAM9G Flash (kb) 64 to 512 SRAM (kb) 16 to 64 1 64 L1 cache memory (kb) 2 x 32 Error-Correcting Code (ECC) 64 1 bit SLC Planes 2 2 Bus width x8 x16 Requirement 1 bit per 528 bytes. The sample driver includes a software ECC algorithm. This can be modified to use hardware ECC if this is provided by the host micro-controller. Copyright HCC Embedded 2017 5 www.hcc-embedded.com

1.4 Packages and Documents Packages The table below lists the packages that you need in order to use this module: Package hcc_base_doc media_drv_base This contains the two guides that will help you get started. The base media driver package that includes the framework all media drivers use. media_drv_mmcsd_init The generic mmcsd_initcad() routine used by MMC/SD media drivers to initialize a card. util_hcc_mem media_drv_mmcsd_atmel_mcipdc The HCC memory management utility. The media driver package described in this document. Documents For an overview of HCC file systems and data storage, see Product Information on the main HCC website. Readers should note the points in the HCC Documentation Guidelines on the HCC documentation website. HCC Firmware Quick Start Guide This document describes how to install packages provided by HCC in the target development environment. Also follow the Quick Start Guide when HCC provides package updates. HCC Source Tree Guide This document describes the HCC source tree. It gives an overview of the system to make clear the logic behind its organization. HCC Media Driver Interface Guide This document describes the HCC Media Driver Interface Specification. HCC emmc Management Extension for MMC and SD Drivers User Guide This document describes HCC's embedded MMC extension. HCC MMC and SD Media Driver for Atmel SAM User Guide This is this document. Copyright HCC Embedded 2017 6 www.hcc-embedded.com

1.5 Change History This section describes past changes to this manual. To view or download earlier manuals, see Archive: MMC and SD Media Driver for Atmel SAM User Guide. For the history of changes made to the package code itself, see History: media_drv_atmel_mcipdc. The current version of this manual is 1.60. The full list of versions is as follows: Manual Date Software Reason for change version version 1.60 2017-08-18 2.03 Updated Packages list. 1.50 2017-06-23 2.03 New Change History format. 1.40 2017-04-24 2.03 Reverted module name to media_drv_atmel_mcipdc. 1.30 2016-01-20 2.02 Added OS Abstraction Layer section. Removed some PSP functions. 1.20 2015-05-08 2.01 Renamed module. 1.10 2015-04-22 2.01 Added functions to PSP Porting. 1.00 2015-03-20 1.04 First online version. Copyright HCC Embedded 2017 7 www.hcc-embedded.com

2 Source File List This section describes all the source code files included in the system. These files follow the HCC Embedded standard source tree system, described in the HCC Source Tree Guide. All references to file pathnames refer to locations within this standard source tree, not within the package you initially receive. Note: Do not modify any files except the configuration file and PSP files. 2.1 API Header File The file src/api/api_mdriver_mmcsd.h is the only file that should be included by an application using this module. For details of the single API function, see Application Programming Interface. 2.2 Configuration File The file src/config/config_mdriver_mmcsd.h contains all the configurable parameters of the system. Configure these as required. For details of these options, see Configuration Options. 2.3 Source Code Files These files in the directory src/media-drv/mmcsd hold the source code for the media driver. These files should only be modified by HCC. File mmcsd.c mmcsd.h mmcsd_mci_regs.h Main source code. Header file. Register definitions. 2.4 Version File The file src/version/ver_mdriver_mmcsd.h contains the module version number. The version number is checked by all modules that use a module to ensure system consistency over upgrades. Copyright HCC Embedded 2017 8 www.hcc-embedded.com

2.5 Platform Support Package (PSP) Files These files in the directory src/psp/target/mmcsd provide functions and other elements the core code needs to use, depending on the hardware. Modify these files as required for your hardware. Note: You must modify these PSP implementations for your specific microcontroller and development board; see PSP Porting for details. File psp_mmcsd.c psp_mmcsd.h Source code. Function definitions and other elements. Copyright HCC Embedded 2017 9 www.hcc-embedded.com

3 Configuration Options Set the system configuration options in the file available configuration options and their default values. MMCSD_NUM_UNITS The number of MMC/SD channels (units). The default is 1. src/config/config_mdriver_mmcsd.h. This section lists the MMCSD1_VOLTAGE_RANGE_170_195, MMCSD1_VOLTAGE_RANGE_270_360 These two options set the voltage range in which unit 1's signals operate: Set the first to 1 to set the valid voltage range to 1.7-1.95V. Its default is 0. Set the second to 1 to set the valid voltage range to 2.7-3.6V. This is the default. MMCSD2_VOLTAGE_RANGE_170_195, MMCSD2_VOLTAGE_RANGE_270_360 These two options set the voltage range in which unit 2's signals operate: Set the first to 1 to set the valid voltage range to 1.7-1.95V. Its default is 0. Set the second to 1 to set the valid voltage range to 2.7-3.6V. This is the default. MMCSD1_ALLOW_4BIT, MMCSD1_ALLOW_8BIT To set the mode of unit 1 to 4 bit, keep the first option at the default of 1, and the second at 0. To set 8 bit mode, reverse the settings. MMCSD2_ALLOW_4BIT, MMCSD2_ALLOW_8BIT To set the mode of unit 2 to 4 bit, keep the first option at the default of 1, and the second at 0. To set 8 bit mode, reverse the settings. MMCSD1_SPEED_LIMIT, MMCSD2_SPEED_LIMIT For each unit, set this to the maximum desired frequency in khz when testing prototype boards with wiring that supports only lower speeds. The defaults are both 20000. Setting an option to 0 disables the speed limit. MCIPDC_DMA_SECTORS The number of sectors the DMA buffer holds. The default is 32. The DMA buffer is required for non-aligned transfers only. MMCSD_ALLOW_EMMC_MANAGEMENT This emmc management option is for future use so not supported in this driver version. Do not change this from the default of 0. Copyright HCC Embedded 2017 10 www.hcc-embedded.com

4 Application Programming Interface This section describes the single function, the structure it uses, and the error codes. When the media driver is used: 1. 2. The file system calls the media driver's atmel_mcipdc_initfunc() function. atmel_mcipdc_initfunc() returns a pointer to an F_DRIVER structure containing a set of functions for accessing the media driver. 4.1 mmcsd_initfunc Use this function to initialize the interface with the driver. The caller passes a parameter to the initialization function of a conforming driver. The driver returns a pointer to an F_DRIVER structure defining the interface to that driver. Note: The call must allocate or use a static structure for the F_DRIVER structure. It must return a pointer to this structure, which must contain all the driver entry points, and also other data as required. Format extern F_DRIVER * mmcsd_initfunc ( unsigned long driver_param ); Arguments Argument Type driver_param The drive to use. 0 is the first drive. unsigned long Return values Return value F_DRIVER * A pointer to the driver structure, or NULL if the request failed. Copyright HCC Embedded 2017 11 www.hcc-embedded.com

4.2 F_DRIVER Structure This is the format of the F_DRIVER structure. This structure is defined in the HCC Media Driver Interface Specification. Element Type separated int Non-zero if the driver is separated. user_data unsigned long User-defined data. user_ptr void * User-defined pointer. writesector F_WRITESECTOR Write a sector to the drive. This is mandatory if format or any write access is required. writemultiplesector F_WRITEMULTIPLESECTOR Write a series of sectors to the drive. If this is unavailable F_WRITESECTOR may be used. readsector F_READSECTOR Read a sector from the drive. readmultiplesector F_READMULTIPLESECTOR Read a series of sectors from the drive. If this is unavailable F_READSECTOR may be used. getphy F_GETPHY Used to get the physical properties of the drive, such as the number of sectors. getstatus F_GETSTATUS (Only for removable drives) Used to test whether a drive has been removed or changed. release F_RELEASE Release any resources associated with a drive when it is freed by the host (file) system. ioctl F_IOCTL Used to send user-defined messages to the driver and get a response. Copyright HCC Embedded 2017 12 www.hcc-embedded.com

4.3 Error Codes If a function executes successfully, it returns with MMCSD_NO_ERROR, a value of zero. The following table shows the meaning of the error codes. Return Value Value MMCSD_ERR_NOTPLUGGED -1 For high level. MMCSD_NO_ERROR 0x00 Successful execution. MMCSD_ERR_NOTINITIALIZED 0x65 Driver not initialized. MMCSD_ERR_INIT 0x66 Initialization error. MMCSD_ERR_CMD 0x67 CMD error. MMCSD_ERR_TRANS 0x68 Transfer error. MMCSD_ERR_STARTBIT 0x69 Start bit error. MMCSD_ERR_BUSY 0x6A CMD error. MMCSD_ERR_CRC 0x6B CRC error. MMCSD_ERR_WRITE 0x6C Write error. MMCSD_ERR_WRITEPROTECT 0x6D Media is write-protected. MMCSD_ERR_NOTAVAILABLE 0x6E Resource not available. Copyright HCC Embedded 2017 13 www.hcc-embedded.com

5 Integration This section describes all aspects of the module that require integration with your target project. This includes porting and configuration of external resources. 5.1 OS Abstraction Layer All HCC modules use the OS Abstraction Layer (OAL). This allows modules to run seamlessly with a wide variety of RTOSes, or without an RTOS. This module uses the following OAL components: OAL Resource Number Required Tasks 0 Mutexes 1 Events 0 Copyright HCC Embedded 2017 14 www.hcc-embedded.com

5.2 PSP Porting The Platform Support Package (PSP) is designed to hold all platform-specific functionality, either because it relies on specific features of a target system, or because this provides the most efficient or flexible solution for the developer. The module makes use of the following standard PSP functions: Function Package Component psp_memcpy() psp_base psp_string Copies a block of memory. The result is a binary copy of the data. psp_memset() psp_base psp_string Sets the specified area of memory to the defined value. The module makes use of the following PSP functions. These functions are provided by the PSP to perform various tasks. Their design makes it easy for you to port them to work with your hardware solution. The package includes samples in the PSP file src/psp/target/mmcsd/psp_mmcsd.c: Function psp_mmcsd_init() psp_mmcsd_delete() psp_mmcsd_power() psp_mmcsd_card_plugged() psp_mmcsd_card_writeprotect() psp_mmcsd_drive_cmd() psp_mmcsd_drive_d0() Initializes the device (clocks, GPIO pin, and so on). Deletes the device, releasing the associated resources. Turns on the card power. (On the default development board this has no effect). Checks whether an MMC/SD card is present. Checks whether the card's write-protect switch is on. (On the default development board this has no effect). Selects push-pull or open-drain mode on the CMD pin. Enables or disables pull-up on the D0 pin. These functions are described in the following sections. Copyright HCC Embedded 2017 15 www.hcc-embedded.com

psp_mmcsd_init This function is provided by the PSP to initialize the device. This enables the clocks, GPIO pin, and so on. Format int psp_mmcsd_init ( void ) Arguments None. Return Values Return value MMCSD_NO_ERROR MMCSD_ERROR_INIT Successful execution. Operation failed. Copyright HCC Embedded 2017 16 www.hcc-embedded.com

psp_mmcsd_delete This function is provided by the PSP to delete the device, releasing the associated resources. Format int psp_mmcsd_delete ( void ) Arguments None. Return Values Return value MMCSD_NO_ERROR MMCSD_ERROR Successful execution. Operation failed. Copyright HCC Embedded 2017 17 www.hcc-embedded.com

psp_mmcsd_power This function is provided by the PSP to turn on the card's power. This call blocks: it only returns when the power level is correct. Note: On the default development board the MMC/SD power cannot be turned off, so this call has no effect. Format void psp_mmcsd_power ( int on ) Arguments Parameter Type on The power setting. int Return Values Return value MMCSD_NO_ERROR MMCSD_ERROR Successful execution. Operation failed. Copyright HCC Embedded 2017 18 www.hcc-embedded.com

psp_mmcsd_card_plugged This function is provided by the PSP to check whether an MMC/SD card is present. This returns the state of the CD pin. Format int psp_mmcsd_card_plugged ( void ) Arguments None. Return Values Return value 0 No card is present. 1 A card is present. Copyright HCC Embedded 2017 19 www.hcc-embedded.com

psp_mmcsd_card_writeprotect This function is provided by the PSP to check a card's write-protect state. Note: On the default development board the write-protect switch is not connected to the MCU, so this call always returns non-protected status. Format int psp_mmcsd_card_writeprotect ( void ) Arguments None. Return Values Return value 0 The card is not write-protected. 1 The card is write-protected. Copyright HCC Embedded 2017 20 www.hcc-embedded.com

psp_mmcsd_drive_cmd This function is provided by the PSP to select push-pull or open-drain mode on the CMD pin. Format void psp_mmcsd_drive_cmd ( uint32_t uid, uint32_t push_pull ) Arguments Parameter Type uid The unit ID. This is ignored in this implementation. uint32_t push_pull Set this to 1 to activate push-pull mode. Otherwise, the pin is in open-drain mode. uint32_t Return Values Return value MMCSD_NO_ERROR MMCSD_ERROR Successful execution. Operation failed. Copyright HCC Embedded 2017 21 www.hcc-embedded.com

psp_mmcsd_drive_d0 This function is provided by the PSP to enable or disable pull-up on the D0 pin. Format void psp_mmcsd_drive_d0 ( uint32_t uid, uint32_t pull_up ) Arguments Parameter Type uid pull-up The MMC/SD unit ID. This is ignored in this implementation. Set this to 1 to enable pull-up on D0. Set it to 0 to disable it. uint32_t uint32_t Return Values Return value MMCSD_NO_ERROR MMCSD_ERROR Successful execution. Operation failed. Copyright HCC Embedded 2017 22 www.hcc-embedded.com