Microchip® Advanced Software Framework

unit_tests_1.c File Reference

Unit tests for OV7740 driver.

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

#include "asf.h"
#include <unit_test/suite.h>
#include "stdio_serial.h"
#include "conf_board.h"
#include "conf_clock.h"
#include "conf_test.h"

Macros

#define PIO_PCMR_DSIZE_WORD   PIO_PCMR_DSIZE(2)
 
#define TWI_CLK   (400000UL)
 

Functions

static uint32_t capture_init (void)
 Initialize PIO capture and the OV7740 image sensor. More...
 
static void init_vsync_interrupts (void)
 Intialize Vsync_Handler. More...
 
void ISI_Handler (void)
 Vertical synchronisation handler for the OV7740 image sensor. More...
 
static void isi_module_init (void)
 ISI initialization. More...
 
int main (void)
 Application entry point for image sensor capture example. More...
 
static void ov7740_test_capture_process_run (const struct test_case *const test)
 Start capture process. More...
 
static void ov7740_test_color_run (const struct test_case *const test)
 Test color of the reference picture from OV7740 image sensor. More...
 
static void ov7740_test_initialization_run (const struct test_case *const test)
 Test the OV7740 initialization. More...
 
static uint32_t test_color (uint8_t *p_uc_ref_color, uint8_t *p_uc_capture_data, uint32_t ul_index_capture)
 Test color of a reference picture. More...
 

Variables

COMPILER_WORD_ALIGNED struct
isi_frame_buffer_descriptors 
buf_desc
 
uint8_t g_auc_capture_buffer [153600]
 
const uint8_t g_auc_data_black_color [4]
 
const uint8_t g_auc_data_blue_color [4]
 
const uint8_t g_auc_data_cyan_color [4]
 
const uint8_t g_auc_data_green_color [4]
 
const uint8_t g_auc_data_purple_color [4]
 
const uint8_t g_auc_data_red_color [4]
 
const uint8_t g_auc_data_white_color [4]
 
const uint8_t g_auc_data_yellow_color [4]
 
static volatile uint32_t g_ul_init_error_flag = false
 
static volatile uint32_t g_ul_vsync_flag = false
 
const usart_serial_options_t usart_serial_options
 

#define PIO_PCMR_DSIZE_WORD   PIO_PCMR_DSIZE(2)
#define TWI_CLK   (400000UL)

Referenced by capture_init().

static uint32_t capture_init ( void  )
static

Initialize PIO capture and the OV7740 image sensor.

Returns
0 on success, 1 otherwise.

References delay_ms, twihs_options::master_clk, ov_configure(), ov_init(), ov_power(), ov_reset(), pmc_enable_periph_clk(), twihs_options::speed, sysclk_get_cpu_hz(), TEST_PATTERN, TWI_CLK, and twihs_master_init().

Referenced by ov7740_test_initialization_run().

static void init_vsync_interrupts ( void  )
static

Intialize Vsync_Handler.

References isi_enable_interrupt().

Referenced by ov7740_test_capture_process_run().

void ISI_Handler ( void  )

Vertical synchronisation handler for the OV7740 image sensor.

References g_ul_vsync_flag.

int main ( void  )
static void ov7740_test_capture_process_run ( const struct test_case *const  test)
static

Start capture process.

Parameters
testCurrent test case.

References g_ul_init_error_flag, g_ul_vsync_flag, init_vsync_interrupts(), isi_capture(), isi_disable_interrupt(), isi_get_status(), and test_assert_true.

Referenced by main().

static void ov7740_test_color_run ( const struct test_case *const  test)
static
static void ov7740_test_initialization_run ( const struct test_case *const  test)
static

Test the OV7740 initialization.

Parameters
testCurrent test case.

References capture_init(), g_ul_init_error_flag, isi_module_init(), and test_assert_true.

Referenced by main().

static uint32_t test_color ( uint8_t *  p_uc_ref_color,
uint8_t *  p_uc_capture_data,
uint32_t  ul_index_capture 
)
static

Test color of a reference picture.

Parameters
p_uc_ref_colorBuffer which contains the reference color.
p_uc_capture_dataBuffer which contains data from the captured picture.
ul_index_captureIndex in p_uc_capture_data.
Returns
1 on error; 0 if no difference between picture data and corresponding color reference was found.

Referenced by ov7740_test_color_run().

uint8_t g_auc_capture_buffer[153600]
const uint8_t g_auc_data_black_color[4]
Initial value:
= {
0xFF,
0x80,
0xFF,
0x80
}

Referenced by ov7740_test_color_run().

const uint8_t g_auc_data_blue_color[4]
Initial value:
= {
0xE5,
0x04,
0xE5,
0x90
}

Referenced by ov7740_test_color_run().

const uint8_t g_auc_data_cyan_color[4]
Initial value:
= {
0x6F,
0x6F,
0x6F,
0xFB
}

Referenced by ov7740_test_color_run().

const uint8_t g_auc_data_green_color[4]
Initial value:
= {
0x88,
0xFB,
0x88,
0xFB
}

Referenced by ov7740_test_color_run().

const uint8_t g_auc_data_purple_color[4]
Initial value:
= {
0xA3,
0x04,
0xA3,
0x04
}

Referenced by ov7740_test_color_run().

const uint8_t g_auc_data_red_color[4]
Initial value:
= {
0xBD,
0x94,
0xBD,
0x04
}

Referenced by ov7740_test_color_run().

const uint8_t g_auc_data_white_color[4]
Initial value:
= {
0x33,
0x80,
0x33,
0x80
}

Referenced by ov7740_test_color_run().

const uint8_t g_auc_data_yellow_color[4]
Initial value:
= {
0x49,
0xFB,
0x49,
0x72
}

Referenced by ov7740_test_color_run().

volatile uint32_t g_ul_init_error_flag = false
static
volatile uint32_t g_ul_vsync_flag = false
static
const usart_serial_options_t usart_serial_options
Initial value:
= {
.baudrate = CONF_TEST_BAUDRATE,
.charlength = CONF_TEST_CHARLENGTH,
.paritytype = CONF_TEST_PARITY,
.stopbits = CONF_TEST_STOPBITS
}

Referenced by main().