webradio/config.c File Reference


Detailed Description

Radio configuration.

 * $Id$
 * 

Copyright (C) 2006-2007 by egnite Software GmbH. All rights reserved. Copyright (C) 2008 by egnite GmbH. All rights reserved.

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

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 3. Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.

For additional information see http://www.ethernut.de/

 *
 * $Log$
 *
 * 

Definition in file config.c.

Go to the source code of this file.

Defines

#define CONFIG_MAGIC   "ir1"
#define CONFOS_SECTOR   0
#define CONFNET_SECTOR   1
#define CONFIG_SECTOR   2
#define DF_WRITE_POLLS   1000
#define DFCMD_READ_STATUS   0xD7
#define DFCMD_CONT_READ   0xE8
#define DFCMD_BUF1_WRITE   0x84
#define DFCMD_BUF1_FLASH   0x83
#define DFCMD_PAGE_ERASE   0x81
#define VS10XX_XCS_BIT   31
#define VS10XX_XCS_PIO_ID   PIOA_ID
#define VS10XX_XDCS_BIT   30
#define VS10XX_XDCS_PIO_ID   PIOB_ID
#define VS10XX_DREQ_BIT   30
#define VS10XX_DREQ_PIO_ID   PIOA_ID
#define VS10XX_SIGNAL   sig_INTERRUPT1
#define VS_XRESET_BIT   31

Functions

int InitElektorHardware (void)
int SpiSetMode (void)
static u_char SpiByte (u_char val)
int At91SpiTransfer2 (u_int base, u_int cs, CONST void *txbuf, void *rxbuf, int xlen, CONST void *txnbuf, void *rxnbuf, int xnlen)
size_t ConfigSize (void)
 Calculate total size of configuration data.
void ConfigFlush (void)
static void ConfigPut (u_char ch)
static u_char ConfigGet (void)
void ConfigSaveString (char *str)
size_t ConfigLoadString (char *str, size_t size)
void ConfigSaveBinary (void *data, size_t len)
void ConfigLoadBinary (void *data, size_t len)
void ConfigRewind (u_long pgn)
int NutLoadConfig (void)
 Load Nut/OS configuration from non-volatile memory.
int NutSaveConfig (void)
 Save Nut/OS configuration in non-volatile memory.
int NutNetLoadConfig (CONST char *name)
 Load network configuration from non-volatile memory.
int NutNetSaveConfig (void)
 Save network configuration in non-volatile memory.
int ConfigSave (void)
 Save configuration in non volatile memory.
int ConfigLoad (void)
void ConfigResetFactory (void)
 Reset configuration to factory defaults.
int ConfigInit (void)

Variables

static int at45db
static u_int page_size
HTTP_PROXY proxy
 HTTP proxy configuration.
static u_long pgnum
static int pgpos = -1
static u_char pgbuf [1056]
CONFOS confos
CONFNET confnet


Define Documentation

#define CONFIG_MAGIC   "ir1"

Definition at line 61 of file config.c.

Referenced by ConfigLoad(), and ConfigSave().

#define CONFOS_SECTOR   0

Definition at line 62 of file config.c.

Referenced by NutLoadConfig(), and NutSaveConfig().

#define CONFNET_SECTOR   1

Definition at line 63 of file config.c.

Referenced by NutNetLoadConfig(), and NutNetSaveConfig().

#define CONFIG_SECTOR   2

Definition at line 64 of file config.c.

Referenced by ConfigLoad(), and ConfigSave().

#define DF_WRITE_POLLS   1000

Definition at line 74 of file config.c.

#define DFCMD_READ_STATUS   0xD7

Definition at line 76 of file config.c.

#define DFCMD_CONT_READ   0xE8

Definition at line 77 of file config.c.

#define DFCMD_BUF1_WRITE   0x84

Definition at line 78 of file config.c.

#define DFCMD_BUF1_FLASH   0x83

Definition at line 79 of file config.c.

#define DFCMD_PAGE_ERASE   0x81

Definition at line 80 of file config.c.

#define VS10XX_XCS_BIT   31

Definition at line 84 of file config.c.

Referenced by InitElektorHardware().

#define VS10XX_XCS_PIO_ID   PIOA_ID

Definition at line 85 of file config.c.

#define VS10XX_XDCS_BIT   30

Definition at line 86 of file config.c.

Referenced by InitElektorHardware().

#define VS10XX_XDCS_PIO_ID   PIOB_ID

Definition at line 87 of file config.c.

#define VS10XX_DREQ_BIT   30

Definition at line 88 of file config.c.

#define VS10XX_DREQ_PIO_ID   PIOA_ID

Definition at line 89 of file config.c.

#define VS10XX_SIGNAL   sig_INTERRUPT1

Definition at line 90 of file config.c.

#define VS_XRESET_BIT   31

Definition at line 91 of file config.c.

Referenced by InitElektorHardware().


Function Documentation

int InitElektorHardware ( void   ) 

Definition at line 96 of file config.c.

References VS10XX_XCS_BIT, VS10XX_XDCS_BIT, and VS_XRESET_BIT.

Referenced by ConfigInit().

int SpiSetMode ( void   ) 

Definition at line 152 of file config.c.

Referenced by At91SpiTransfer2().

static u_char SpiByte ( u_char  val  )  [static]

Definition at line 163 of file config.c.

Referenced by At91SpiTransfer2().

int At91SpiTransfer2 ( u_int  base,
u_int  cs,
CONST void *  txbuf,
void *  rxbuf,
int  xlen,
CONST void *  txnbuf,
void *  rxnbuf,
int  xnlen 
)

Definition at line 177 of file config.c.

References SpiByte(), and SpiSetMode().

Here is the call graph for this function:

SpiByteSpiSetMode

size_t ConfigSize ( void   ) 

Calculate total size of configuration data.

Should be used to avoid configuration data overflow. Untested.

Returns:
Number of bytes used by configuration data.

Definition at line 223 of file config.c.

void ConfigFlush ( void   ) 

Definition at line 248 of file config.c.

Referenced by ConfigPut(), ConfigSave(), FavListSave(), NutNetSaveConfig(), and NutSaveConfig().

static void ConfigPut ( u_char  ch  )  [static]

Definition at line 256 of file config.c.

References ConfigFlush(), page_size, pgbuf, pgnum, and pgpos.

Referenced by ConfigSaveBinary(), and ConfigSaveString().

Here is the call graph for this function:

ConfigFlush

static u_char ConfigGet ( void   )  [static]

Definition at line 270 of file config.c.

References at45db, page_size, pgbuf, pgnum, and pgpos.

Referenced by ConfigLoadBinary(), and ConfigLoadString().

void ConfigSaveString ( char *  str  ) 

Definition at line 280 of file config.c.

Referenced by ConfigSave(), and FavListSave().

size_t ConfigLoadString ( char *  str,
size_t  size 
)

Definition at line 288 of file config.c.

Referenced by ConfigLoad(), and FavListLoad().

void ConfigSaveBinary ( void *  data,
size_t  len 
)

Definition at line 302 of file config.c.

Referenced by ConfigSave(), NutNetSaveConfig(), and NutSaveConfig().

void ConfigLoadBinary ( void *  data,
size_t  len 
)

Definition at line 312 of file config.c.

Referenced by ConfigLoad(), NutLoadConfig(), and NutNetLoadConfig().

void ConfigRewind ( u_long  pgn  ) 

Definition at line 321 of file config.c.

Referenced by ConfigLoad(), ConfigSave(), FavListLoad(), FavListSave(), NutLoadConfig(), NutNetLoadConfig(), NutNetSaveConfig(), and NutSaveConfig().

int NutLoadConfig ( void   ) 

Load Nut/OS configuration from non-volatile memory.

This routine is automatically called during system initialization.

Returns:
0 if OK, -1 if configuration isn't available.

Definition at line 341 of file config.c.

References ConfigInit(), ConfigLoadBinary(), ConfigRewind(), confos, and CONFOS_SECTOR.

Referenced by main().

Here is the call graph for this function:

ConfigInitConfigLoadBinaryConfigRewind

int NutSaveConfig ( void   ) 

Save Nut/OS configuration in non-volatile memory.

Returns:
0 if OK, -1 on failures.

Definition at line 359 of file config.c.

References ConfigFlush(), ConfigRewind(), ConfigSaveBinary(), confos, and CONFOS_SECTOR.

Referenced by CgiSettings().

Here is the call graph for this function:

ConfigFlushConfigRewindConfigSaveBinary

int NutNetLoadConfig ( CONST char *  name  ) 

Load network configuration from non-volatile memory.

If no configuration is available in EEPROM, all configuration parameters are cleared to zero. Except the MAC address, which is set to the Ethernet broadcast address.

Parameters:
name Name of the device.
Returns:
0 if configuration has been read. Otherwise the return value is -1.

Definition at line 383 of file config.c.

References ConfigInit(), ConfigLoadBinary(), ConfigRewind(), confnet, and CONFNET_SECTOR.

Here is the call graph for this function:

ConfigInitConfigLoadBinaryConfigRewind

int NutNetSaveConfig ( void   ) 

Save network configuration in non-volatile memory.

Returns:
0 if OK, -1 on failures.

Definition at line 403 of file config.c.

References ConfigFlush(), ConfigRewind(), ConfigSaveBinary(), confnet, and CONFNET_SECTOR.

Referenced by CgiSettings().

Here is the call graph for this function:

ConfigFlushConfigRewindConfigSaveBinary

int ConfigSave ( void   ) 

Save configuration in non volatile memory.

Definition at line 416 of file config.c.

Referenced by CgiSettings(), and main().

int ConfigLoad ( void   ) 

Definition at line 438 of file config.c.

Referenced by main().

void ConfigResetFactory ( void   ) 

Reset configuration to factory defaults.

Definition at line 470 of file config.c.

Referenced by CgiSettings(), and main().

int ConfigInit ( void   ) 

Definition at line 480 of file config.c.

Referenced by main(), NutLoadConfig(), and NutNetLoadConfig().


Variable Documentation

int at45db [static]

Definition at line 66 of file config.c.

Referenced by ConfigFlush(), ConfigGet(), and ConfigInit().

u_int page_size [static]

Definition at line 67 of file config.c.

Referenced by ConfigFlush(), ConfigGet(), ConfigInit(), and ConfigPut().

HTTP_PROXY proxy

HTTP proxy configuration.

Definition at line 72 of file config.c.

Referenced by CgiSettings(), SendHttpRequest(), ShoutCastGetPlayList(), StationConnect(), and TcpHostConnect().

u_long pgnum [static]

Definition at line 244 of file config.c.

Referenced by ConfigFlush(), ConfigGet(), ConfigPut(), and ConfigRewind().

int pgpos = -1 [static]

Definition at line 245 of file config.c.

Referenced by ConfigFlush(), ConfigGet(), ConfigPut(), and ConfigRewind().

u_char pgbuf[1056] [static]

Definition at line 246 of file config.c.

Referenced by ConfigFlush(), ConfigGet(), and ConfigPut().

CONFOS confos

Definition at line 330 of file config.c.

Referenced by CgiSettings(), main(), NutLoadConfig(), and NutSaveConfig().

CONFNET confnet

Definition at line 331 of file config.c.

Referenced by CgiSettings(), main(), NutNetLoadConfig(), and NutNetSaveConfig().


© 2008 by egnite GmbH - visit www.ethernut.de