Added Doxygen documentation

This commit is contained in:
adamdunkels 2007-11-10 20:45:29 +00:00
parent ca6abb286b
commit b51977a693

View file

@ -1,39 +1,42 @@
/* /*
* Copyright (c) 2006, Swedish Institute of Computer Science * Copyright (c) 2006, Swedish Institute of Computer Science
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)$Id: xmem.c,v 1.2 2006/08/10 16:42:11 bg- Exp $ * @(#)$Id: xmem.c,v 1.3 2007/11/10 20:45:29 adamdunkels Exp $
*/ */
/* /**
* Device driver for the ST M25P80 40MHz 1Mbyte external memory. * \file
* Device driver for the ST M25P80 40MHz 1Mbyte external memory.
* \author
* Björn Grönvall <bg@sics.se>
* *
* Data is written bit inverted (~-operator) to flash so that * Data is written bit inverted (~-operator) to flash so that
* unwritten data will read as zeros (UNIX style). * unwritten data will read as zeros (UNIX style).
*/ */
#include <stdio.h> #include <stdio.h>
@ -64,13 +67,13 @@
#define SPI_FLASH_INS_BE 0xc7 #define SPI_FLASH_INS_BE 0xc7
#define SPI_FLASH_INS_DP 0xb9 #define SPI_FLASH_INS_DP 0xb9
#define SPI_FLASH_INS_RES 0xab #define SPI_FLASH_INS_RES 0xab
/*---------------------------------------------------------------------------*/
static void static void
spi_tx(unsigned byte) spi_tx(unsigned byte)
{ {
FASTSPI_TX(byte); FASTSPI_TX(byte);
} }
/*---------------------------------------------------------------------------*/
static void static void
write_enable(void) write_enable(void)
{ {
@ -84,7 +87,7 @@ write_enable(void)
SPI_FLASH_DISABLE(); SPI_FLASH_DISABLE();
splx(s); splx(s);
} }
/*---------------------------------------------------------------------------*/
static unsigned static unsigned
read_status_register(void) read_status_register(void)
{ {
@ -105,7 +108,7 @@ read_status_register(void)
return u; return u;
} }
/*---------------------------------------------------------------------------*/
/* /*
* Wait for a write/erase operation to finish. * Wait for a write/erase operation to finish.
*/ */
@ -118,7 +121,7 @@ wait_ready(void)
} while(u & 0x01); /* WIP=1, write in progress */ } while(u & 0x01); /* WIP=1, write in progress */
return u; return u;
} }
/*---------------------------------------------------------------------------*/
/* /*
* Erase 64k bytes of data. It takes about 1s before WIP goes low! * Erase 64k bytes of data. It takes about 1s before WIP goes low!
*/ */
@ -142,7 +145,7 @@ erase_sector(off_t offset)
SPI_FLASH_DISABLE(); SPI_FLASH_DISABLE();
splx(s); splx(s);
} }
/*---------------------------------------------------------------------------*/
/* /*
* Initialize external flash *and* SPI bus! * Initialize external flash *and* SPI bus!
*/ */
@ -157,7 +160,7 @@ xmem_init(void)
SPI_FLASH_DISABLE(); /* Unselect flash. */ SPI_FLASH_DISABLE(); /* Unselect flash. */
SPI_FLASH_UNHOLD(); SPI_FLASH_UNHOLD();
} }
/*---------------------------------------------------------------------------*/
int int
xmem_pread(void *_p, int size, off_t offset) xmem_pread(void *_p, int size, off_t offset)
{ {
@ -186,7 +189,7 @@ xmem_pread(void *_p, int size, off_t offset)
splx(s); splx(s);
return size; return size;
} }
/*---------------------------------------------------------------------------*/
static const char * static const char *
program_page(off_t offset, const unsigned char *p, int nbytes) program_page(off_t offset, const unsigned char *p, int nbytes)
{ {
@ -214,7 +217,7 @@ program_page(off_t offset, const unsigned char *p, int nbytes)
return p; return p;
} }
/*---------------------------------------------------------------------------*/
int int
xmem_pwrite(const void *_buf, int size, off_t addr) xmem_pwrite(const void *_buf, int size, off_t addr)
{ {
@ -231,7 +234,7 @@ xmem_pwrite(const void *_buf, int size, off_t addr)
} }
return size; return size;
} }
/*---------------------------------------------------------------------------*/
int int
xmem_erase(long size, off_t addr) xmem_erase(long size, off_t addr)
{ {
@ -252,3 +255,4 @@ xmem_erase(long size, off_t addr)
return size; return size;
} }
/*---------------------------------------------------------------------------*/