Fix code style

This commit is contained in:
George Oikonomou 2018-04-07 14:32:00 +01:00
parent f88b195de4
commit f6bd7ba47a
3 changed files with 39 additions and 47 deletions

View File

@ -114,12 +114,14 @@ static spi_device_t flash_spi_configuration_default = {
* Get spi configuration, return default configuration if NULL
*/
static spi_device_t *
get_spi_conf(spi_device_t *conf) {
get_spi_conf(spi_device_t *conf)
{
if(conf == NULL) {
return &flash_spi_configuration_default;
}
return conf;
}/*---------------------------------------------------------------------------*/
}
/*---------------------------------------------------------------------------*/
/**
* Clear external flash CSN line
*/

View File

@ -43,20 +43,22 @@
#include "contiki-conf.h"
#include "dev/xmem.h"
/*** MX25R8035F Memory Organization
The memory is organized as:
8Mbit = 1048576 bytes (8 bits each)
256 sectors (32 Kbits, 4096 bytes each)
4096 pages (256 bytes each).
Each page can be individually programmed (bits are programmed from 1 to 0). The device is
sector or bulk erasable (bits are erased from 0 to 1) but not page erasable
/*
* MX25R8035F Memory Organization
* The memory is organized as:
* 8Mbit = 1048576 bytes (8 bits each)
* 256 sectors (32 Kbits, 4096 bytes each)
* 4096 pages (256 bytes each).
* Each page can be individually programmed (bits are programmed from 1 to 0).
* The device is sector or bulk erasable (bits are erased from 0 to 1) but not
* page erasable
*/
#define COFFEE_XMEM_TOTAL_SIZE_KB 1024UL //Total size of the External Flash Memory in the Z1
#define COFFEE_XMEM_TOTAL_SIZE_KB 1024UL /* Total size of the External Flash Memory in the Z1 */
/* Coffee configuration parameters. */
#define COFFEE_SECTOR_SIZE 4096UL
#define COFFEE_PAGE_SIZE 256UL
#define COFFEE_START 0UL //COFFEE_SECTOR_SIZE
#define COFFEE_START 0UL /* COFFEE_SECTOR_SIZE */
#define COFFEE_SIZE (COFFEE_XMEM_TOTAL_SIZE_KB * 1024UL - COFFEE_START)
#define COFFEE_NAME_LENGTH 16
#define COFFEE_MAX_OPEN_FILES 6
@ -67,11 +69,6 @@ sector or bulk erasable (bits are erased from 0 to 1) but not page erasable
#define COFFEE_MICRO_LOGS 1
/* Flash operations. */
#define COFFEE_WRITE(buf, size, offset) \
xmem_pwrite((char *)(buf), (size), COFFEE_START + (offset))

View File

@ -49,21 +49,17 @@
#define XMEM_BUFF_LENGHT 128
#if 0
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...) do {} while(0)
#endif
void
xmem_init(void)
{
ext_flash_open(NULL);
}
int
xmem_pread(void *_p, int size, unsigned long addr)
{
@ -87,14 +83,13 @@ xmem_pread(void *_p, int size, unsigned long addr)
ext_flash_close(NULL);
if(rv)
if(rv) {
return size;
}
PRINTF("Could not read flash memory!\n");
return -1;
}
int
xmem_pwrite(const void *_buf, int size, unsigned long addr)
{
@ -128,8 +123,6 @@ xmem_pwrite(const void *_buf, int size, unsigned long addr)
return size;
}
int
xmem_erase(long size, unsigned long addr)
{
@ -137,7 +130,6 @@ xmem_erase(long size, unsigned long addr)
rv = ext_flash_open(NULL);
if(!rv) {
PRINTF("Could not open flash to save config\n");
ext_flash_close(NULL);
@ -160,8 +152,9 @@ xmem_erase(long size, unsigned long addr)
watchdog_periodic();
if(rv)
if(rv) {
return size;
}
PRINTF("Could not erase flash memory\n");
return -1;