Microchip® Advanced Software Framework

sam/components/cmos_image_sensor/ov7740/unit_tests/unit_tests.c File Reference

Unit tests for OV7740 driver.

Copyright (c) 2014-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...
 
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 void pio_capture_init (Pio *const p_pio, uint32_t ul_id)
 Initialize PIO capture for the OV7740 image sensor communication. More...
 
static void pio_capture_to_buffer (Pio *const p_pio, uint8_t *p_uc_buf, uint32_t ul_size)
 Capture OV7740 data to a buffer. 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...
 
static void vsync_handler (uint32_t ul_id, uint32_t ul_mask)
 Vertical synchronisation handler for the OV7740 image sensor. More...
 

Variables

uint8_t g_auc_capture_buffer [51200]
 
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)

Referenced by pio_capture_init().

#define TWI_CLK   (400000UL)

Referenced by capture_init().

static uint32_t capture_init ( void  )
static
static void init_vsync_interrupts ( void  )
static

Intialize Vsync_Handler.

References vsync_handler().

Referenced by capture_init().

static void ov7740_test_capture_process_run ( const struct test_case *const  test)
static
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, and test_assert_true.

Referenced by main().

static void pio_capture_init ( Pio *const  p_pio,
uint32_t  ul_id 
)
static

Initialize PIO capture for the OV7740 image sensor communication.

Parameters
p_pioPIO instance to be configured in PIO capture mode.
ul_idCorresponding PIO ID.

References PIO_PCMR_DSIZE_WORD, and pmc_enable_periph_clk().

Referenced by capture_init().

static void pio_capture_to_buffer ( Pio *const  p_pio,
uint8_t *  p_uc_buf,
uint32_t  ul_size 
)
static

Capture OV7740 data to a buffer.

Parameters
p_pioPIO instance which will capture data from OV7740 iamge sensor.
p_uc_bufBuffer address where captured data must be stored.
ul_sizeData frame size.

Referenced by ov7740_test_capture_process_run().

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().

static void vsync_handler ( uint32_t  ul_id,
uint32_t  ul_mask 
)
static

Vertical synchronisation handler for the OV7740 image sensor.

References g_ul_vsync_flag, and UNUSED.

Referenced by init_vsync_interrupts().

uint8_t g_auc_capture_buffer[51200]
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(), and prvSetupHardware().