/*
Copyright 2007, Freie Universitaet Berlin. All rights reserved.

These sources were developed at the Freie Universität Berlin, Computer
Systems and Telematics group.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
- Neither the name of Freie Universitaet Berlin (FUB) nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

This software is provided by FUB and the contributors on an "as is"
basis, without any representations or warranties of any kind, express
or implied including, but not limited to, representations or
warranties of non-infringement, merchantability or fitness for a
particular purpose. In no event shall FUB or contributors be liable
for any direct, indirect, incidental, special, exemplary, or
consequential damages (including, but not limited to, procurement of
substitute goods or services; loss of use, data, or profits; or
business interruption) however caused and on any theory of liability,
whether in contract, strict 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 such damage.

This implementation was developed by the CST group at the FUB.

For documentation and questions please use the web site
http://scatterweb.mi.fu-berlin.de and the mailinglist
scatterweb@lists.spline.inf.fu-berlin.de (subscription via the Website).
Berlin, 2007
*/

/**
 * @defgroup	infomem	Infomemory Driver
 * @ingroup		driver
 *
 * <p>This module contains functions to store and read data from the two infomemories (2 x 128 Bytes).
 * Offset addresses start at zero, size has a maximum of 128, write operations
 * across both blocks are not allowed.
 *
 * <p>ScatterWeb currently uses the infomemory (A) to store configuration data
 * (see config_t, Configuration_load) and panic messages.
 * Infomem B may be used freely by user applications (see #INFOMEM_USER).
 */

/**
 * @file		ScatterWeb.Infomem.h
 * @ingroup		infomem
 * @brief		MSP430 Infomemory Storage
 * @version		$Revision: 224 $
 * 
 * $Id: ScatterWeb.Infomem.h 224 2007-11-09 11:37:36Z hutta@PCPOOL.MI.FU-BERLIN.DE $
 */

/**
 * @addtogroup	infomem
 * @{
 */

#ifndef INFOMEM_H_
#define INFOMEM_H_

#define INFOMEM_START		(&__infomem)
#define INFOMEM_BLOCK_SIZE	0x0080u
#define INFOMEM_BLOCK_MASK	0x007fu		///< block bits
#define INFOMEM_MASK		0x00ffu		///< valid infomem addresses

#define INFOMEM_CONFIG		0x0000u		///< start of config data
/// start of panic message
#define INFOMEM_PANIC		(INFOMEM_CONFIG + sizeof(config_t) + 1)
#define INFOMEM_PANIC_SIZE	0x0040u		///< size of panic message field
#define INFOMEM_USER		0x0080u		///< start of user defined data
/**
 * @brief	Read bytes from infomemory
 * @param[out]		buffer		Pointer to buffer for read data
 * @param[in]		offset		Offset in infomemory (0-254)
 * @param[in]		size		Number of bytes to read
 */
void Infomem_read(void* buffer, uint16_t offset, uint8_t size);

/**
 * @brief	Write bytes to infomemory
 * @param[in]		offset		Offset in infomemory (0-254)
 * @param[in]		count		Number of items following
 *								each item is a pair pointer, length
 *
 * Example: Infomem_write( 0, 2, &a,3, &b,1 );
 *
 * \note: The MSP430 has two consecutive blocks of infomemory. Each is 128 Bytes large.
 *        The offset is the relative address starting at the beginning of the first block.
 *        You can write an arbitrary number of bytes at any offse, but this 
 *        function cannot write across the two blocks of infomemory.
 */
bool Infomem_write(uint16_t offset, uint8_t count, ...);

#endif // /** @} */
