Device Specific Initialization

netconfig.c

IP addresses and host names must differ from device to device. For the netlib Support SW the device specific settings are assigned to structure adapter_t in file netconfig.c. You may also store these settings in the FLASH memory and load it during start up. These variables can be used with the Hardware Initialization and Software Initialization function instead of defines.

Example netconfig.c:

/***************************************************************************//**
@file netconfig.c
@verbatim
_ _ _
__| | ___(_) ____ _ __ | |_
/ _` | / __| |/ _` | '_ \| __|
| (_| | _ \__ \ | (_| | | | | |_
\__,_|(_) ___/_|\__, |_| |_|\__|
Signalprocessing |___/ Technology
@endverbatim
@brief @ref P_NETCONFIGP "Network Configuration File": @ref P_DEVINIT "netconfig.c"
@author D.SignT GmbH & Co. KG, Claus Hermbusche
@date 2019-06-04
@details
Define global variables for network configuration. Either use predefined
settings, or read device specific settings from FLASH and store it into
these variables before net_init() function call.
@cond Software License Agreement
Copyright (C) 2001-2019 D.SignT GmbH & Co. KG - http://www.dsignt.de
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 D.SignT GmbH & Co. KG nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
Disclaimer
THIS SOFTWARE IS PROVIDED BY D.SIGNT GMBH & CO. KG "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 D.SIGNT GMBH & CO. KG 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.
@endcond
*******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#define USE_DHCP 1
#ifdef USE_DHCP
{
ETHEMAC, // MAC type
(uint32_t)0x1C80000, // address
DNS_ENABLE, // DNS on
DHCP_ENABLE, // DHCP on
"02-00-D2-02-00-01", // board internal MAC address
"DM2DM642", // host name, up to 30 characters
"0.0.0.0", // DNS server address is set by DHCP
"255.255.255.0", // subnet_mask[16];
"192.168.168.100", // gateway[16];
AUTO_NEG, // network mode: FDX_100, FDX_10, HDX_100, HDX_10, AUTO_NEG
};
#else
{
ETHEMAC, // MAC type
(uint32_t)0x1C80000, // address
DNS_ENABLE, // DNS on
NULL, // DHCP off
"02-00-D2-02-00-01", // board internal MAC address
"192.168.168.200", // own IP address
"192.168.168.100", // DNS server address
"255.255.255.0", // subnet_mask[16];
"192.168.168.100", // gateway[16];
AUTO_NEG, // network mode: FDX_100, FDX_10, HDX_100, HDX_10, AUTO_NEG
};
#endif
#ifdef __cplusplus
}
#endif /* extern "C" */