Microchip® Advanced Software Framework

unit_tests.c File Reference

Unit tests for EMAC driver.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "board.h"
#include <sysclk.h>
#include "emac.h"
#include <string.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include "conf_test.h"
#include "conf_board.h"
#include "mini_ip.h"
#include "rstc.h"
#include "ethernet_phy.h"

Macros

#define EMAC_UINT_TEST_MAX_RETRY_TIME   50
 

Functions

void EMAC_Handler (void)
 EMAC interrupt handler. More...
 
int main (void)
 Run EMAC driver unit tests. More...
 
static void run_emac_link_test (const struct test_case *test)
 EMAC link test function. More...
 
static void run_emac_read_write_test (const struct test_case *test)
 Test EMAC read/write interfaces. More...
 

Variables

static uint8_t gs_arp_frame []
 
static emac_device_t gs_emac_dev
 The EMAC driver instance. More...
 
static uint8_t gs_uc_eth_buffer [EMAC_FRAME_LENTGH_MAX]
 Buffer for ethernet packets. More...
 
static uint8_t gs_uc_mac_address []
 The MAC address used for the test. More...
 

#define EMAC_UINT_TEST_MAX_RETRY_TIME   50

void EMAC_Handler ( void  )

EMAC interrupt handler.

References emac_handler().

static void run_emac_read_write_test ( const struct test_case test)
static

Test EMAC read/write interfaces.

Parameters
testCurrent test case.

References emac_dev_read(), emac_dev_write(), EMAC_OK, EMAC_UINT_TEST_MAX_RETRY_TIME, gs_arp_frame, gs_uc_eth_buffer, gs_uc_mac_address, and test_assert_true.

Referenced by main().

uint8_t gs_arp_frame[]
static
Initial value:
= {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
ETHERNET_CONF_ETHADDR5, 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01,
ETHERNET_CONF_IPADDR3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
#define ETHERNET_CONF_IPADDR0
The IP address being used.
Definition: conf_eth.h:66
#define ETHERNET_CONF_IPADDR2
Definition: conf_eth.h:68
#define ETHERNET_CONF_ETHADDR2
Definition: conf_eth.h:60
#define ETHERNET_CONF_IPADDR3
Definition: conf_eth.h:69
#define ETHERNET_CONF_GATEWAY_ADDR1
Definition: conf_eth.h:73
#define ETHERNET_CONF_ETHADDR0
MAC address definition.
Definition: conf_eth.h:58
#define ETHERNET_CONF_ETHADDR4
Definition: conf_eth.h:62
#define ETHERNET_CONF_ETHADDR5
Definition: conf_eth.h:63
#define ETHERNET_CONF_ETHADDR1
Definition: conf_eth.h:59
#define ETHERNET_CONF_GATEWAY_ADDR3
Definition: conf_eth.h:75
#define ETHERNET_CONF_GATEWAY_ADDR0
The gateway address being used.
Definition: conf_eth.h:72
#define ETHERNET_CONF_ETHADDR3
Definition: conf_eth.h:61
#define ETHERNET_CONF_IPADDR1
Definition: conf_eth.h:67
#define ETHERNET_CONF_GATEWAY_ADDR2
Definition: conf_eth.h:74

Referenced by run_emac_read_write_test().

emac_device_t gs_emac_dev
static

The EMAC driver instance.

uint8_t gs_uc_eth_buffer[EMAC_FRAME_LENTGH_MAX]
static

Buffer for ethernet packets.

Referenced by run_emac_read_write_test().

uint8_t gs_uc_mac_address[]
static
Initial value:
=
}
#define ETHERNET_CONF_ETHADDR2
Definition: conf_eth.h:60
#define ETHERNET_CONF_ETHADDR0
MAC address definition.
Definition: conf_eth.h:58
#define ETHERNET_CONF_ETHADDR4
Definition: conf_eth.h:62
#define ETHERNET_CONF_ETHADDR5
Definition: conf_eth.h:63
#define ETHERNET_CONF_ETHADDR1
Definition: conf_eth.h:59
#define ETHERNET_CONF_ETHADDR3
Definition: conf_eth.h:61

The MAC address used for the test.

Referenced by run_emac_link_test(), and run_emac_read_write_test().