Application network and initialization module


Detailed Description

The module brings up the eWicht and the TCP/IP stack as configured by the user.

The module therefore loads the persistent stored EEPROM data for the network stack. After configuring the network it starts the network stack and checks for occuring errors. If the start fails, the user and the application are informed. If no error occurs, the application can start with the usage of a configured network.


Files

file  bootup.c
 Implementation of the boot process of the eWicht application.
file  bootup.h
 Prototypes for calling the eWicht application boot up and network routines.

Data Structures

struct  _IP_CONFIG
 This typedef defines the local structure for TCP/IP stack parameters. More...
struct  sIPFlags
 This structure is used in the PCOMMON_CONFIG structure to define some IP related flags. More...
struct  PCOMMON_CONFIG
 This typedef defines the peristent structure for common settings and TCP/IP stack parameters. More...

Defines

#define HOSTNAME   ((ROM BYTE *) 0x01fbf0)
 The hostname of this device located in flash memory.

Enumerations

enum  eWichtProjects
 Enumerates the different projects an eWicht can be used for. More...

Functions

void BootupInit (void)
 This function initializes the application network module.
BOOL bBootupMain (void)
 This function must be called periodically by the application.
void BootupSetIP (void)
 By calling this function the eWicht enters the IP Menu.
void BootupResetToFactory (void)
 Sometimes the reset of the persistent data in the EEPROM to a well known state is needed.
void BootupEnterBootloader (void)
 Calling this function prepares the bootloader entry.
void BootupRestoreState (void)
 Writes back the current bootup state (located in RAM) to persistent storage (EEPROM).

Variables

static SM_BOOTUP _eBootUpSM
 The local state machine.
static BOOL _bFirstTime
 Indicator for being here the first time (After bootup).
static BYTE _au8NetworkDataForBootloader [12]
 Stores the network related data like MAC address and IP address for reboot.
IP_CONFIG sIPConfig
 This field stores the local TCP/IP parameters.
PCOMMON_CONFIG sPCommonConfig
 The persistent data field.


Define Documentation

#define HOSTNAME   ((ROM BYTE *) 0x01fbf0)

The hostname of this device located in flash memory.

Release versions of the firmware get the name from the bootloader section.

Definition at line 63 of file bootup.h.


Enumeration Type Documentation

Enumerates the different projects an eWicht can be used for.

Definition at line 101 of file bootup.h.


Function Documentation

BOOL bBootupMain ( void   ) 

This function must be called periodically by the application.

First of all the function displays the current installed firmware version and does a LED blinking check. After it the function tries to configure and to start the network due directly accessing the TCP/IP stack and its parameters. Several reasons in the network or on the local device can lead to a non working network. The function is able to detect this and report it to the calling application and displaying it to the user as well.

Possible reasons for network failures:

  • The network cable is unplugged or disconnected somewhere.
  • An address conflict is detected on the network.

As long the eWicht has no valid IP address, it is possible to enter the IP menu. The function checks for a pressed encoder button by itself. After a valid IP is obtained, the application can start the IP Menu due calling the function BootupSetIP.

Precondition:
The application network module must be initialized by a call of BootupInit.
Return values:
TRUE The network module is ready, the application can start using the network.
FALSE The network is not ready due several reasons (see above).
Remarks:
None

Definition at line 147 of file bootup.c.

void BootupEnterBootloader ( void   ) 

Calling this function prepares the bootloader entry.

After restarting the device the bootloader remains active and uses the prepared MAC and IP address.

Definition at line 557 of file bootup.c.

void BootupInit ( void   ) 

This function initializes the application network module.

The network data persitant stored in EEPROM is loaded and the TCP/IP Stack is configured with this settings. If the function detects an empty EEPROM it loads the factory settings to ensure proper operation of the eWicht device.

Returns:
None
Remarks:
None

Definition at line 94 of file bootup.c.

void BootupResetToFactory ( void   ) 

Sometimes the reset of the persistent data in the EEPROM to a well known state is needed.

The call of this function resets eWicht to the following parameters:

Manual settings: IP: 192.168.0.10 Subnet: 255.255.255.0 (/24) Gateway: 192.168.0.1

The network address is accquired automatically (by DHCP or AutoIP), the first AutoIP address is generated and saved in EEPROM.

Definition at line 579 of file bootup.c.

void BootupSetIP ( void   ) 

By calling this function the eWicht enters the IP Menu.

The call only configures the internal application network module state machine. Due calling periodically the main routine bBootupMain, the Menu will be handled. After the menu has been finished, the main routine configures the network stack with the new data and tries to restart the stack. If succeeded, the application can use the new configured network stack.

Precondition:
The application network module must be initialized by a call of BootupInit.
Remarks:
None

Definition at line 138 of file bootup.c.


Variable Documentation

BYTE _au8NetworkDataForBootloader[12] [static]

Stores the network related data like MAC address and IP address for reboot.

Definition at line 81 of file bootup.c.

BOOL _bFirstTime [static]

Indicator for being here the first time (After bootup).

Definition at line 75 of file bootup.c.

SM_BOOTUP _eBootUpSM [static]

The local state machine.

Definition at line 70 of file bootup.c.

This field stores the local TCP/IP parameters.

Some of them will be loaded from the persistent data fields. Other fields are updated dynamically if the TCP/IP stack configuration changes.

Definition at line 148 of file bootup.h.

The persistent data field.

The field stores common settings of the eWicht and for the network. At the beginning the application must call BootupInit. This function loads the data which is stored in the data EEPROM into this SRAM field. The IP Menu or the function BootupResetToFactory can change these fields and store it back to the EEPROM.

Definition at line 156 of file bootup.h.


Generated on Sun Nov 27 20:02:40 2011 for eWicht by  doxygen 1.5.5