Nut/OS  4.10.3
API Reference
serialflash.h
Go to the documentation of this file.
00001 #ifndef _DEV_SERIALFLASH_H_
00002 #define _DEV_SERIALFLASH_H_
00003 
00004 /*
00005  * Copyright (C) 2010 by egnite GmbH
00006  *
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met:
00012  *
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  * 3. Neither the name of the copyright holders nor the names of
00019  *    contributors may be used to endorse or promote products derived
00020  *    from this software without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00029  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00030  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00031  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00032  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00033  * SUCH DAMAGE.
00034  *
00035  * For additional information see http://www.ethernut.de/
00036  */
00037 
00038 #include <dev/spibus.h>
00039 
00044 
00046 #ifndef SERIALFLASH_MAX_UNITS
00047 #if defined(__AVR__)
00048 #define SERIALFLASH_MAX_UNITS   65535
00049 #else
00050 #define SERIALFLASH_MAX_UNITS   65536
00051 #endif
00052 #endif
00053 
00054 #if SERIALFLASH_MAX_UNITS <= 65535
00055 typedef uint16_t sf_unit_t;
00056 typedef uint_fast16_t sf_unit_fast_t;
00057 #else
00058 typedef uint32_t sf_unit_t;
00059 typedef uint_fast32_t sf_unit_fast_t;
00060 #endif
00061 
00065 typedef struct _NUTSERIALFLASH NUTSERIALFLASH;
00066 
00070 struct _NUTSERIALFLASH {
00072     NUTSPINODE *sf_node;
00074     void *sf_info;
00076     size_t sf_unit_size;
00078     sf_unit_t sf_units;
00080     sf_unit_t sf_rsvbot;
00082     sf_unit_t sf_rsvtop;
00084     int (*sf_init) (NUTSERIALFLASH *);
00086     void (*sf_exit) (NUTSERIALFLASH *);
00088     int (*sf_check) (NUTSERIALFLASH *, sf_unit_t, int);
00090     int (*sf_read) (NUTSERIALFLASH *, sf_unit_t, int, void *, int);
00092     int (*sf_compare) (NUTSERIALFLASH *, sf_unit_t, int, CONST void *, int);
00094     int (*sf_used) (NUTSERIALFLASH *, sf_unit_t, int);
00096     int (*sf_write) (NUTSERIALFLASH *, sf_unit_t, int, CONST void *, int);
00098     int (*sf_copy) (NUTSERIALFLASH *, sf_unit_t, sf_unit_t);
00100     int (*sf_commit) (NUTSERIALFLASH *, sf_unit_t);
00102     int (*sf_erase) (NUTSERIALFLASH *, sf_unit_t, int);
00103 };
00104 
00107 #endif