Data Capture Interface Library

This library provides routines for controlling the Data Capture Interface (DCAP) module. This is an 8-bit parallel interface that collects byte streaming data
from a sensor peripheral - e.g. a camera module in a 2Kbyte internal FIFO. The interface will provide a clock to the peripheral at a speed of 25MHz (max).

Library Routines

DCAP_Init

Prototype

void DCAP_Init();

Description

This function will initialize Data Capture Interface, enables camera module clock and configures corresponding pins.

Parameters

None.

Returns

Nothing.

Requires

Nothing.

Example
// Enable camera module clock and config corresponding pins
DCAP_Init();
Notes

None.

DCAP_setCount

Prototype

void DCAP_setCount(uint32_t v);

Description

This function will set the number of bytes to capture after the last trigger event. This must be in multiple of 4 bytes.

Parameters
  • v: number of bytes to capture.
Returns

Nothing.

Requires

Nothing.

Example
// Set number of bytes to capture after the last trigger event
DCAP_setCount(32);
Notes

None.

DCAP_setTrigpat

Prototype

void DCAP_setTrigpat(uint32_t v);

Description

This specifies the data capture trigger position. Data capture starts on the cycle when trigger transitions from 0 to 1.

Parameters
  • v: data capture trigger position.
Returns

Nothing.

Requires

Nothing.

Example
// Set data capture trigger position
DCAP_setTrigpat(2);
Notes

None.

DCAP_setThreshold

Prototype

void DCAP_setThreshold(uint32_t v);

Description

This function specifies the threshold value for the HAS_DATA signal. It must be a multiple of 4 bytes.

Parameters
  • v: threshold value.
Returns

None.

Requires

Nothing.

Example
// Set the threshold value
DCAP_setThreshold(64);
Notes

None.

DCAP_setClockPolarity

Prototype

void DCAP_setClockPolarity(uint32_t v);

Description

This function sets clock edge polarity on which the data will be captured.

Parameters
  • v: clock polarity. Valid values :
    Value Description
    0 Falling edge.
    1 Rising edge.
Returns

None.

Requires

Nothing.

Example
// Set the Falling edge polarity
DCAP_setClockPolarity(0);
Notes

None.

DCAP_hasData

Prototype

uint8_t DCAP_hasData();

Description

This function checks if there is at least threshold number of bytes (set by the DCAP_setThreshold routine) in FIFO buffer.

Parameters

None.

Returns
  • 0: there is no threshold number of bytes in FIFO buffer.
  • 1: threshold number of bytes is in the FIFO buffer.
Requires

This routine requires threshold to be set by the DCAP_setThreshold routine.

Example
// Wait while FIFO is filled
while(DCAP_hasData() == 0)
  ;
Notes

None.

DCAP_drain

Prototype

void DCAP_drain();

Description

This function empties FIFO buffer.

Parameters

None.

Returns

Nothing.

Requires

Nothing.

Example
// Empty FIFO buffer
DCAP_drain();
Notes

None.

DCAP_ReadFIFO

Prototype

void DCAP_ReadFIFO(uint8_t * buffIn, unsigned long numOfButes);

Description

This function will read data brom the FIFO buffer and store it in the data buffer.

Parameters
  • buffIn: input buffer to store data from FIFO.
  • numOfButes: number of bytes to be stored from FIFO
Returns

Nothing.

Requires

Nothing.

Example
uint8_t buffer[16];

DCAP_ReadFIFO(&buffer, numOfBytes);              // Read data from FIFO
Notes

The data acquisition performance from the FIFO buffer will be increased if the input buffer is aligned to 4.

Copyright (c) 2002-2015 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code