Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
Tiva1294Ethernet.cxx File Reference
#include <stdint.h>
#include <new>
#include <stdio.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_ints.h"
#include "inc/hw_gpio.h"
#include "inc/hw_emac.h"
#include "inc/hw_flash.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/emac.h"
#include "driverlib/flash.h"
#include "FreeRTOSConfig.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
#include "timers.h"
#include "Tiva1294Ethernet.hxx"
#include "FreeRTOSIPConfig.h"
#include "FreeRTOS_IP.h"
#include "NetworkInterface.h"
#include "NetworkBufferManagement.h"
#include "FreeRTOS_IP_Private.h"
#include "FreeRTOS_Sockets.h"

Go to the source code of this file.

Classes

struct  EMACIODescriptor
 

Macros

#define TraceNet   0
 
#define IOBUSY   0x01
 
#define NUM_TX_DESCRIPTORS   3
 
#define NUM_RX_DESCRIPTORS   5
 
#define BUFFER_SIZE   (ipTOTAL_ETHERNET_FRAME_SIZE + ipBUFFER_PADDING)
 
#define BUFFER_SIZE_ROUNDED_UP   ((BUFFER_SIZE + 7) & ~0x07UL)
 

Functions

void PrintBuffer (uint8_t *Buffer, size_t Len)
 
void PrintStr (const char *Str)
 
void PrintHex (uint32_t Val)
 
void Print (char ch)
 
void vNetworkInterfaceAllocateRAMToBuffers (NetworkBufferDescriptor_t pxNetworkBuffers[ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS])
 
static bool get_mac_address (uint8_t MACAddr[6])
 
bool network_layer_preinit (void)
 Called before the TCP stack is initialized in FreeRTOS.
 
static bool InitialiseEthernet (void)
 
static bool InitialiseDIH (void)
 
static EMACIODescriptorGetNextRxDescriptor (void)
 
static void SendData (EMACIODescriptor *pxTxIOD, uint32_t DataLength)
 
void prvEMACDeferredInterruptHandlerTask (void *pvParameters)
 
BaseType_t xNetworkInterfaceInitialise (void)
 
BaseType_t xNetworkInterfaceOutput (NetworkBufferDescriptor_t *const pxDescriptor, BaseType_t xReleaseAfterSend)
 
void ethernet_interrupt_handler (void)
 

Variables

const long unsigned cm3_cpu_clock_hz
 
const int EMACIODescriptorExtra
 
static EMACIODescriptor RxDescriptor [NUM_RX_DESCRIPTORS]
 
static EMACIODescriptor TxDescriptor [NUM_TX_DESCRIPTORS]
 
static uint16_t RxDescIndex
 
static uint16_t TxDescIndex
 
static QueueHandle_t TxBufferQueue = NULL
 
static QueueHandle_t xEMACEventQueue = NULL
 
static TaskHandle_t xDIHTask = NULL
 
static bool LinkDown
 
static bool Initialised = false
 
uint8_t Buffers [ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS][BUFFER_SIZE_ROUNDED_UP]
 
uint8_t RxBuffers [NUM_RX_DESCRIPTORS][ipTOTAL_ETHERNET_FRAME_SIZE]
 
uint8_t TxBuffers [NUM_TX_DESCRIPTORS][ipTOTAL_ETHERNET_FRAME_SIZE]
 
int FramesRecv = 0
 
int FrameLen = 0
 
unsigned char * Frame
 

Detailed Description

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.

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 HOLDER 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.

This file provides the network layer interface to the FreeRTOSPlus TCP stack.

Author
Sidney McHarg
Date
23 March 2016

Definition in file Tiva1294Ethernet.cxx.

Macro Definition Documentation

◆ BUFFER_SIZE

#define BUFFER_SIZE   (ipTOTAL_ETHERNET_FRAME_SIZE + ipBUFFER_PADDING)

Definition at line 120 of file Tiva1294Ethernet.cxx.

◆ BUFFER_SIZE_ROUNDED_UP

#define BUFFER_SIZE_ROUNDED_UP   ((BUFFER_SIZE + 7) & ~0x07UL)

Definition at line 121 of file Tiva1294Ethernet.cxx.

◆ IOBUSY

#define IOBUSY   0x01

Definition at line 103 of file Tiva1294Ethernet.cxx.

◆ NUM_RX_DESCRIPTORS

#define NUM_RX_DESCRIPTORS   5

Definition at line 106 of file Tiva1294Ethernet.cxx.

◆ NUM_TX_DESCRIPTORS

#define NUM_TX_DESCRIPTORS   3

Definition at line 105 of file Tiva1294Ethernet.cxx.

◆ TraceNet

#define TraceNet   0

Definition at line 39 of file Tiva1294Ethernet.cxx.

Function Documentation

◆ ethernet_interrupt_handler()

void ethernet_interrupt_handler ( void  )

Definition at line 654 of file Tiva1294Ethernet.cxx.

◆ get_mac_address()

static bool get_mac_address ( uint8_t  MACAddr[6])
static

Definition at line 147 of file Tiva1294Ethernet.cxx.

◆ GetNextRxDescriptor()

static EMACIODescriptor * GetNextRxDescriptor ( void  )
static

Definition at line 426 of file Tiva1294Ethernet.cxx.

◆ InitialiseDIH()

static bool InitialiseDIH ( void  )
static

Definition at line 192 of file Tiva1294Ethernet.cxx.

◆ InitialiseEthernet()

static bool InitialiseEthernet ( void  )
static

Definition at line 217 of file Tiva1294Ethernet.cxx.

◆ network_layer_preinit()

bool network_layer_preinit ( void  )

Called before the TCP stack is initialized in FreeRTOS.

Definition at line 175 of file Tiva1294Ethernet.cxx.

◆ Print()

void Print ( char  ch)

Definition at line 89 of file Tiva1294Ethernet.cxx.

◆ PrintBuffer()

void PrintBuffer ( uint8_t *  Buffer,
size_t  Len 
)

Definition at line 80 of file Tiva1294Ethernet.cxx.

◆ PrintHex()

void PrintHex ( uint32_t  Val)

Definition at line 86 of file Tiva1294Ethernet.cxx.

◆ PrintStr()

void PrintStr ( const char *  Str)

Definition at line 83 of file Tiva1294Ethernet.cxx.

◆ prvEMACDeferredInterruptHandlerTask()

void prvEMACDeferredInterruptHandlerTask ( void *  pvParameters)

Definition at line 495 of file Tiva1294Ethernet.cxx.

◆ SendData()

static void SendData ( EMACIODescriptor pxTxIOD,
uint32_t  DataLength 
)
static

Definition at line 446 of file Tiva1294Ethernet.cxx.

◆ vNetworkInterfaceAllocateRAMToBuffers()

void vNetworkInterfaceAllocateRAMToBuffers ( NetworkBufferDescriptor_t  pxNetworkBuffers[ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS])

Definition at line 405 of file Tiva1294Ethernet.cxx.

◆ xNetworkInterfaceInitialise()

BaseType_t xNetworkInterfaceInitialise ( void  )

Definition at line 418 of file Tiva1294Ethernet.cxx.

◆ xNetworkInterfaceOutput()

BaseType_t xNetworkInterfaceOutput ( NetworkBufferDescriptor_t *const  pxDescriptor,
BaseType_t  xReleaseAfterSend 
)

Definition at line 460 of file Tiva1294Ethernet.cxx.

Variable Documentation

◆ Buffers

uint8_t Buffers[ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS][BUFFER_SIZE_ROUNDED_UP]

Definition at line 124 of file Tiva1294Ethernet.cxx.

◆ EMACIODescriptorExtra

const int EMACIODescriptorExtra
Initial value:
=
(sizeof(EMACIODescriptor) - sizeof(tEMACDMADescriptor) + 3) / 4

Definition at line 99 of file Tiva1294Ethernet.cxx.

◆ Frame

unsigned char* Frame

Definition at line 145 of file Tiva1294Ethernet.cxx.

◆ FrameLen

int FrameLen = 0

Definition at line 144 of file Tiva1294Ethernet.cxx.

◆ FramesRecv

int FramesRecv = 0

Definition at line 144 of file Tiva1294Ethernet.cxx.

◆ Initialised

bool Initialised = false
static

Definition at line 117 of file Tiva1294Ethernet.cxx.

◆ LinkDown

bool LinkDown
static

Definition at line 117 of file Tiva1294Ethernet.cxx.

◆ RxBuffers

uint8_t RxBuffers[NUM_RX_DESCRIPTORS][ipTOTAL_ETHERNET_FRAME_SIZE]

Definition at line 129 of file Tiva1294Ethernet.cxx.

◆ RxDescIndex

uint16_t RxDescIndex
static

Definition at line 109 of file Tiva1294Ethernet.cxx.

◆ RxDescriptor

EMACIODescriptor RxDescriptor[NUM_RX_DESCRIPTORS]
static

Definition at line 107 of file Tiva1294Ethernet.cxx.

◆ TxBufferQueue

QueueHandle_t TxBufferQueue = NULL
static

Definition at line 111 of file Tiva1294Ethernet.cxx.

◆ TxBuffers

uint8_t TxBuffers[NUM_TX_DESCRIPTORS][ipTOTAL_ETHERNET_FRAME_SIZE]

Definition at line 130 of file Tiva1294Ethernet.cxx.

◆ TxDescIndex

uint16_t TxDescIndex
static

Definition at line 109 of file Tiva1294Ethernet.cxx.

◆ TxDescriptor

EMACIODescriptor TxDescriptor[NUM_TX_DESCRIPTORS]
static

Definition at line 108 of file Tiva1294Ethernet.cxx.

◆ xDIHTask

TaskHandle_t xDIHTask = NULL
static

Definition at line 115 of file Tiva1294Ethernet.cxx.

◆ xEMACEventQueue

QueueHandle_t xEMACEventQueue = NULL
static

Definition at line 113 of file Tiva1294Ethernet.cxx.