From a6af72d129d107704970150c993e35c934911bc4 Mon Sep 17 00:00:00 2001 From: nvt-se Date: Thu, 2 Aug 2007 08:17:43 +0000 Subject: [PATCH] Style changes. --- platform/msb430/dev/infomem.c | 93 ++++++++++++++++++----------------- platform/msb430/dev/infomem.h | 29 +++++------ 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/platform/msb430/dev/infomem.c b/platform/msb430/dev/infomem.c index 3c030dbf6..f13cc0e4d 100644 --- a/platform/msb430/dev/infomem.c +++ b/platform/msb430/dev/infomem.c @@ -57,62 +57,65 @@ Berlin, 2007 #include #include "infomem.h" -void infomem_read(void* buffer, unsigned int offset, unsigned char size) { - UINT8* address = (UINT8*)INFOMEM_START + offset; - memcpy(buffer, address, size); +void +infomem_read(void *buffer, unsigned int offset, unsigned char size) +{ + UINT8 *address = (UINT8 *) INFOMEM_START + offset; + memcpy(buffer, address, size); } -bool infomem_write(unsigned int offset, unsigned char count, ...) { - char backup[INFOMEM_BLOCK_SIZE]; - - register UINT8* buffer; - register UINT16 i; - UINT8* flash; +bool +infomem_write(unsigned int offset, unsigned char count, ...) +{ + char backup[INFOMEM_BLOCK_SIZE]; + UINT8 *buffer; + UINT16 i; + UINT8 *flash; + va_list argp; + UINT16 size; + UINT8 *data; - if( offset > ( 2 * INFOMEM_BLOCK_SIZE) ) - return false; + if (offset > (2 * INFOMEM_BLOCK_SIZE)) + return false; - flash = (UINT8*)INFOMEM_START + offset; + flash = (UINT8 *) INFOMEM_START + offset; - _DINT(); + _DINT(); - // backup into RAM - memcpy(backup, flash, INFOMEM_BLOCK_SIZE); + // backup into RAM + memcpy(backup, flash, INFOMEM_BLOCK_SIZE); - // merge backup with new data - va_list argp; - va_start(argp, count); + // merge backup with new data + va_start(argp, count); - buffer = (UINT8*)backup; - for( i = 0; i < count; i++ ) { - register UINT16 size; - register UINT8* data; + buffer = (UINT8 *) backup; + for (i = 0; i < count; i++) { + data = va_arg(argp, UINT8*); + size = va_arg(argp, UINT16); + memcpy(buffer, data, size); + buffer += size; + } - data = va_arg(argp, UINT8*); - size = va_arg(argp, UINT16); - memcpy(buffer, data, size); - buffer += size; - } - va_end(argp); + va_end(argp); - // init flash access - FCTL2 = FWKEY + FSSEL1 + FN2; - FCTL3 = FWKEY; + // init flash access + FCTL2 = FWKEY + FSSEL1 + FN2; + FCTL3 = FWKEY; - // erase flash - FCTL1 = FWKEY + ERASE; - *flash = 0; + // erase flash + FCTL1 = FWKEY + ERASE; + *flash = 0; - // write flash - FCTL1 = FWKEY + WRT; - buffer = (UINT8*)backup; - for( i = 0; i < INFOMEM_BLOCK_SIZE; i++ ) { - *flash = *buffer; - buffer++; flash++; - } - FCTL1 = FWKEY; - FCTL3 = FWKEY + LOCK; + // write flash + FCTL1 = FWKEY + WRT; + buffer = (UINT8 *) backup; + for (i = 0; i < INFOMEM_BLOCK_SIZE; i++) { + *flash++ = *buffer++; + } - _EINT(); - return true; + FCTL1 = FWKEY; + FCTL3 = FWKEY + LOCK; + + _EINT(); + return true; } diff --git a/platform/msb430/dev/infomem.h b/platform/msb430/dev/infomem.h index 4fd3db9e3..c9e741ff6 100644 --- a/platform/msb430/dev/infomem.h +++ b/platform/msb430/dev/infomem.h @@ -42,21 +42,17 @@ Berlin, 2006 /** * @file infomem.h - * @addtogroup storage + * @addtogroup storage * @brief MSP430 Infomemory Storage * - * @author Michael Baar + * @author Michael Baar */ -#ifndef INFOMEM_H_ -#define INFOMEM_H_ +#ifndef INFOMEM_H +#define INFOMEM_H -/* These defines might depend on the specific CPU used and have to be defined in platform: -#define INFOMEM_START 0x1000 -#define INFOMEM_BLOCK_SIZE 128 -*/ #if !defined(INFOMEM_START) || !defined(INFOMEM_BLOCK_SIZE) - #error "Infomemory position (INFOMEM_START) and blocksize (INFOMEM_BLOCK_SIZE) need to be defined for current platform" + #error "infomem position (INFOMEM_START) and block size (INFOMEM_BLOCK_SIZE) need to be defined for the platform" #endif /** @@ -65,21 +61,22 @@ Berlin, 2006 * @param[in] offset Offset in infomemory (0-254) * @param[in] size Number of bytes to read */ -void infomem_read(void* buffer, unsigned int offset, unsigned char size); +void infomem_read(void *buffer, unsigned int offset, unsigned char 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 + * 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. + * \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 offset, but this function + * cannot write across the two blocks of infomemory. */ bool infomem_write(unsigned int offset, unsigned char count, ...); -#endif // INFOMEM_H +#endif // !INFOMEM_H