Microchip® Advanced Software Framework

unit_tests.c File Reference

AT86RFx Wireless Module Unit Test.

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

#include <stdint.h>
#include <stdbool.h>
#include <asf.h>
#include <string.h>
#include "board.h"
#include "sysclk.h"
#include "conf_usb.h"
#include "stdio_usb.h"
#include "conf_test.h"
#include "unit_tests.h"
#include "avr2025_mac.h"
#include "common_sw_timer.h"

Macros

#define DEFAULT_CHANNEL   (20)
 
#define DEFAULT_CHANNEL_PAGE   (0)
 
#define SCAN_CHANNEL   (1ul << DEFAULT_CHANNEL)
 
#define SCAN_DURATION   (5)
 Defines the scan duration time. More...
 

Functions

int main (void)
 Run Wireless Module unit tests. More...
 
void main_cdc_set_dtr (bool b_enable)
 Call back from USB to notify a terminal connection to the CDC driver. More...
 
static void run_wpan_reset_test (const struct test_case *test)
 Performs a Reset check on AT86RFx module. More...
 
static void run_wpan_scan_test (const struct test_case *test)
 
void usr_mcps_data_conf (uint8_t msduHandle, uint8_t status, uint32_t Timestamp)
 Callback function that must be implemented by application (NHLE) for MAC service MCPS-DATA.confirm. More...
 
void usr_mcps_data_ind (wpan_addr_spec_t *SrcAddrSpec, wpan_addr_spec_t *DstAddrSpec, uint8_t msduLength, uint8_t *msdu, uint8_t mpduLinkQuality, uint8_t DSN, uint32_t Timestamp)
 
void usr_mcps_purge_conf (uint8_t msduHandle, uint8_t status)
 Callback function that must be implemented by application (NHLE) for MAC service MCPS-PURGE.confirm. More...
 
void usr_mlme_associate_conf (uint16_t AssocShortAddress, uint8_t status)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-ASSOCIATE.confirm. More...
 
void usr_mlme_associate_ind (uint64_t DeviceAddress, uint8_t CapabilityInformation)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-ASSOCIATE.indication. More...
 
void usr_mlme_beacon_notify_ind (uint8_t BSN, wpan_pandescriptor_t *PANDescriptor, uint8_t PendAddrSpec, uint8_t *AddrList, uint8_t sduLength, uint8_t *sdu)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-BEACON-NOTIFY.indication. More...
 
void usr_mlme_comm_status_ind (wpan_addr_spec_t *SrcAddrSpec, wpan_addr_spec_t *DstAddrSpec, uint8_t status)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-COMM-STATUS.indication. More...
 
void usr_mlme_disassociate_conf (uint8_t status, wpan_addr_spec_t *DeviceAddrSpec)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-DISASSOCIATE.confirm. More...
 
void usr_mlme_disassociate_ind (uint64_t DeviceAddress, uint8_t DisassociateReason)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-DISASSOCIATE.indication. More...
 
void usr_mlme_get_conf (uint8_t status, uint8_t PIBAttribute, void *PIBAttributeValue)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-GET.confirm. More...
 
void usr_mlme_orphan_ind (uint64_t OrphanAddress)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-ORPHAN.indication. More...
 
void usr_mlme_poll_conf (uint8_t status)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-POLL.confirm. More...
 
void usr_mlme_reset_conf (uint8_t status)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-RESET.confirm. More...
 
void usr_mlme_rx_enable_conf (uint8_t status)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-RX-ENABLE.confirm. More...
 
void usr_mlme_scan_conf (uint8_t status, uint8_t ScanType, uint8_t ChannelPage, uint32_t UnscannedChannels, uint8_t ResultListSize, void *ResultList)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-SCAN.confirm. More...
 
void usr_mlme_set_conf (uint8_t status, uint8_t PIBAttribute)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-SET.confirm. More...
 
void usr_mlme_start_conf (uint8_t status)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-START.confirm. More...
 
void usr_mlme_sync_loss_ind (uint8_t LossReason, uint16_t PANId, uint8_t LogicalChannel, uint8_t ChannelPage)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-SYNC-LOSS.indication. More...
 

Variables

static uint8_t wpan_reset_conf_rcvd = false
 
static uint8_t wpan_reset_conf_status = FAILURE
 
static uint8_t wpan_scan_conf_rcvd = false
 
static uint8_t wpan_scan_conf_status = FAILURE
 

#define DEFAULT_CHANNEL   (20)
#define DEFAULT_CHANNEL_PAGE   (0)

Referenced by run_wpan_scan_test().

#define SCAN_CHANNEL   (1ul << DEFAULT_CHANNEL)

Referenced by run_wpan_scan_test().

#define SCAN_DURATION   (5)

Defines the scan duration time.

Referenced by run_wpan_scan_test().

int main ( void  )

Run Wireless Module unit tests.

Initializes the clock system, board and USB. Then runs the wireless task continuously.

References board_init(), cpu_irq_enable, irq_initialize_vectors, stdio_usb_init(), sw_timer_init(), sysclk_init(), wpan_init(), and wpan_task().

void main_cdc_set_dtr ( bool  b_enable)

Call back from USB to notify a terminal connection to the CDC driver.

Parameters
b_enableindication for connect/disconnect of terminal to CDC.

References DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, run_wpan_reset_test(), run_wpan_scan_test(), and test_suite_run().

static void run_wpan_reset_test ( const struct test_case test)
static

Performs a Reset check on AT86RFx module.

This function will simply test the output of the function wpan_mlme_reset_req and returns an error in case of failure.

Parameters
testCurrent test case.

References MAC_SUCCESS, test_assert_true, wpan_mlme_reset_req(), wpan_reset_conf_rcvd, wpan_reset_conf_status, and wpan_task().

Referenced by main_cdc_set_dtr().

void usr_mcps_data_ind ( wpan_addr_spec_t SrcAddrSpec,
wpan_addr_spec_t DstAddrSpec,
uint8_t  msduLength,
uint8_t *  msdu,
uint8_t  mpduLinkQuality,
uint8_t  DSN,
uint32_t  Timestamp 
)

Referenced by mcps_data_ind().

uint8_t wpan_reset_conf_rcvd = false
static
uint8_t wpan_reset_conf_status = FAILURE
static
uint8_t wpan_scan_conf_rcvd = false
static
uint8_t wpan_scan_conf_status = FAILURE
static