8.2.10. How to Implement an Ethernet Port
foxBMS 2 uses the FreeRTOS TCP/IP port for ethernet communication. This is already implemented and can be activated as described in rtos. If the implementation needs to be modified, the required steps are described here. For instructions on using the existing implementation, refer to How to Test TCP/IP.
8.2.10.1. Configure the Hardware
The TI TMS570 is already configured for the DP83869-PHY mounted on the BMS-Master. In case the hardware is changed, the following steps have to be done in TI HALCoGen. If the BMS-Master is unchanged, these steps can be skipped.
Configure Pinmux:
Enable the MII peripherals
Configure GIOs
Configure GIOA[1] for Reset
Configure GIOB[6] for Power Down
Configure EMAC
EMAC Configuration
Select an appropiate EMAC Address
Set the correct Physical Address (1)
Enable Transmit, Receive, MII
Ensure that Loopback Communication is disabled
PHY
Select Custom driver for your PHY-Driver.
Configure Interrupts
For the ethernet connection the Interrupt handler 77 and 79 are relevant. They have to be activated and have to be used in the PHY-Driver.
8.2.10.2. PHY-Driver
With foxBMS 2 a driver for the DP83869-PHY which is mounted on the foxBMS 2 master is provided. For other PHYs the changes are:
Different register map, including extended register addresses
Need for activating MII mode
Loopback settings
Selecting transmission speed
Auto-negotiation process
8.2.10.3. Porting FreeRTOS-Plus-TCP
In order to use the FreeRTOS-Plus-TCP stack it has to be adapted to the used Compiler EMAC-Driver and PHY-Driver.
In addition to adapting the compiler, EMAC driver and PHY driver, the memory
and buffer configuration of the TCP/IP stack must be checked carefully.
Relevant parameters are configured primarily in FreeRTOSIPConfig.h and in
the application startup code.
In particular, the number and size of network
buffers (for example ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS and the
associated buffer sizes), the stack sizes and priorities of the TCP/IP task and
network-interface tasks, and the overall heap configuration
(configTOTAL_HEAP_SIZE or the linker-based heap setup) must be chosen
according to the expected network load.
An undersized configuration can lead to dropped packets or connection
failures, while an oversized configuration may waste RAM.
8.2.10.3.1. Compiler configuration
The compiler configuration is done in
src/os/freertos/freertos-plus/freertos-plus-tcp/source/portable/Compiler.
This is already configured for foxBMS 2.
8.2.10.3.2. Network Interface Port layer
The network interface port layer connects the EMAC driver with the TCP/IP stack. This porting is implemented in the Network Interface.
The following functions must be provided:
extern int pxTMS570_FillInterfaceDescriptor( BaseType_t xEMACIndex, NetworkInterface_t * pxInterface )BaseType_t xNetworkInterfaceInitialise( struct xNetworkInterface * pxDescriptor )extern void xNetworkInterfaceInput( void *pvParameters )BaseType_t xNetworkInterfaceOutput(struct xNetworkInterface * pxDescriptor, NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t xReleaseAfterSend )void uxNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ] )