Atmel Software Framework

xmega/drivers/twi/unit_tests/unit_tests.c File Reference

Unit tests for TWI driver.

Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <asf.h>
#include <conf_test.h>

Functions

int main (void)
 Run TWI unit tests. More...
 
TWI unit test helper functions
static void slave_process (void)
 Pointer to process data function for TWI slave. More...
 
 ISR (TWIF_TWIS_vect)
 Interrupt routine for TWI slave Calls TWI_SlaveInterruptHandler. More...
 
TWI unit test functions
static void run_twi_master_send_test (const struct test_case *test)
 This test sends a packet from the master, and checks that the sending happens without errors. More...
 
static void run_twi_slave_recv_test (const struct test_case *test)
 This test sends a packet from the master to the slave, and checks that the correct packet is received. More...
 
static void run_twi_master_recv_test (const struct test_case *test)
 This test requests a packet to be sent from the slave, and checks that the correct packet is received by the master. More...
 

TWI unit test definitions

#define TWI_MASTER   TWIC
 TWI master module. More...
 
#define TWI_MASTER_PORT   PORTC
 TWI master module port. More...
 
#define TWI_SLAVE   TWIF
 TWI slave module. More...
 
#define TWI_SPEED   50000
 TWI data transfer rate. More...
 
#define TWI_MASTER_ADDR   0x50
 TWI master address. More...
 
#define TWI_SLAVE_ADDR   0x60
 TWI slave address. More...
 
#define PATTERN_TEST_LENGTH   sizeof(test_pattern)
 Test Pattern size. More...
 
const uint8_t test_pattern []
 Test Pattern. More...
 
TWI_Slave_t slave
 TWI slave struct. More...
 

#define PATTERN_TEST_LENGTH   sizeof(test_pattern)
#define TWI_MASTER   TWIC
#define TWI_MASTER_ADDR   0x50
#define TWI_MASTER_PORT   PORTC

TWI master module port.

Referenced by main().

#define TWI_SLAVE   TWIF
#define TWI_SLAVE_ADDR   0x60
#define TWI_SPEED   50000

ISR ( TWIF_TWIS_vect  )

Interrupt routine for TWI slave Calls TWI_SlaveInterruptHandler.

References TWI_SlaveInterruptHandler().

int main ( void  )

Run TWI unit tests.

Initializes the clock system, board and serial output, then sets up the TWI unit test suite and runs it.

References usart_rs232_options::baudrate, board_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, run_twi_master_recv_test(), run_twi_master_send_test(), run_twi_slave_recv_test(), stdio_serial_init(), sysclk_init, test_suite_run(), TWI_MASTER_PORT, and usart_serial_options.

static void run_twi_master_recv_test ( const struct test_case test)
static
static void run_twi_master_send_test ( const struct test_case test)
static
static void slave_process ( void  )
static

Pointer to process data function for TWI slave.

Referenced by run_twi_master_recv_test(), run_twi_master_send_test(), and run_twi_slave_recv_test().

const uint8_t test_pattern[]
Initial value:
= {
0x55,
0xA5,
0x5A,
0x77,
0x99
}

Test Pattern.

Referenced by main(), run_twi_master_recv_test(), run_twi_master_send_test(), and run_twi_slave_recv_test().