Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SAM4L Parallel Capture (PARC) Driver

This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration and management of the Parallel Capture module.

The Parallel Capture module samples an external 8-bit bus with an external input clock. It can be connected to a CMOS digital image sensor, an ADC, a DSP synchronous port, etc.

Devices from the following series can use this module:

The outline of this documentation is as follows:

Prerequisites

There are no prerequisites for this module.

Module Overview

The Parallel Capture (PARC) module samples an external 8-bit bus with an external input clock. It can be connected to a CMOS digital image sensor, an ADC, a DSP synchronous port, etc.

Features

The PARC module offers the following features:

Concatenated Data Capture

Captured data bytes are stored in the module's Receive Holding Register (RHR). Concatenated data can also be stored in the RHR to make 16-bit or 32-bit values, with the first byte received in the Least Significant Byte (LSB) position. Refer to the diagram entitled "parallel capture waveforms" in the parc chapter of the device-specific datasheet for more information.

Special Considerations

I/O Lines

The PARC pins are multiplexed with other peripherals. The user application must first configure the I/O Controller to yield control of the pins.

Power Management

The PARC module stops functioning when the system enters a sleep mode that disables its clock.

Clocks

The PARC module's clock is generated by the Power Manager. It can be disabled either manually via software or automatically when the system enters a sleep mode that disables the clocks to the peripheral bus modules. For correct behavior, the PARC module's clock frequency must be at least twice the PCCK frequency.

DMA

The PARC module's DMA handshake interface is connected to the Peripheral DMA Controller (PDCA). Using the PARC module's DMA functionality requires the PDCA to be configured first.

Interrupt

The PARC interrupt request line is connected to the Nested Vectored Interrupt Controller (NVIC). Using the PARC interrupt requires that the NVIC to be configured first.

Extra Information

For extra information, see Extra Information for Parallel Capture. This includes:

Examples

For a list of examples related to this driver, see Examples for Parallel Capture.

API Overview

Modules

 
 Quick Start Guide(s)
 In this section you can find a list of all Quick Start guides related to the SAM4L Parallel Capture (PARC) Driver.
 

Data Structures

struct  parc_config
 PARC configuration structure. More...
 
struct  parc_module
 PARC driver structure. More...
 

Typedefs

typedef void(* parc_callback_t )(const struct parc_module *const module_inst)
 PARC interrupt handler callback type. More...
 

Enumerations

enum  parc_callback_type {
  PARC_CALLBACK_DATA_READY = 0,
  PARC_CALLBACK_OVERRUN
}
 PARC callback type. More...
 
enum  parc_capture_mode {
  PARC_BOTH_CAPTURE = 0,
  PARC_EVEN_CAPTURE,
  PARC_ODD_CAPTURE
}
 PARC captured byte. More...
 
enum  parc_data_size {
  PARC_DSIZE_BYTE = 0,
  PARC_DSIZE_HALFWORD = 1,
  PARC_DSIZE_WORD = 2
}
 PARC data Size. More...
 
enum  parc_interrupt_source {
  PARC_INTERRUPT_DRDY = PARC_SR_DRDY,
  PARC_INTERRUPT_OVR = PARC_SR_OVR
}
 PARC interrupt source. More...
 
enum  parc_sampling_edge {
  PARC_RISING_EDGE = 0,
  PARC_FALLING_EDGE = 1
}
 PARC sampling edge. More...
 
enum  parc_smode {
  PARC_SMODE_PCEN1_H = 0,
  PARC_SMODE_PCEN1_AND_PCEN2_H,
  PARC_SMODE_PCEN1_OR_PCEN2_H,
  PARC_SMODE_ALWAYS
}
 PARC sample mode. More...
 
enum  parc_status {
  PARC_STATUS_EN = PARC_SR_EN,
  PARC_STATUS_CS = PARC_SR_CS,
  PARC_STATUS_DRDY = PARC_SR_DRDY,
  PARC_STATUS_OVR = PARC_SR_OVR
}
 PARC status. More...
 

Functions

static enum status_code parc_clear_status (struct parc_module *const module_inst, const uint32_t status)
 Clear PARC interrupt(s) status flag. More...
 
static enum status_code parc_disable (struct parc_module *const module_inst)
 Disable the PARC module. More...
 
static enum status_code parc_disable_callback (struct parc_module *const module_inst, enum parc_callback_type type)
 Disable a PARC interrupt callback function. More...
 
static enum status_code parc_disable_events (struct parc_module *const module_inst)
 Disable the PARC events mode. More...
 
static void parc_disable_interrupts (struct parc_module *const module_inst, enum parc_interrupt_source source)
 Disable PARC interrupt(s). More...
 
static enum status_code parc_enable (struct parc_module *const module_inst)
 Enable the PARC module. More...
 
static enum status_code parc_enable_callback (struct parc_module *const module_inst, enum parc_callback_type type)
 Enable a PARC interrupt callback function. More...
 
static enum status_code parc_enable_events (struct parc_module *const module_inst)
 Enable the PARC events mode. More...
 
static void parc_enable_interrupts (struct parc_module *const module_inst, enum parc_interrupt_source source)
 Enable PARC interrupt(s). More...
 
static void parc_get_config_defaults (struct parc_config *const config)
 Initialize a PARC configuration structure to default values. More...
 
static uint32_t parc_get_status (struct parc_module *const module_inst)
 Get the PARC module's current status. More...
 
static uint32_t parc_get_version (struct parc_module *const module_inst)
 Get the PARC module version. More...
 
enum status_code parc_init (struct parc_module *const module_inst, Parc *const hw, struct parc_config *const config)
 Initialize the PARC module. More...
 
static bool parc_is_data_ready (struct parc_module *const module_inst)
 Check the data ready status of PARC. More...
 
static enum status_code parc_read (struct parc_module *const module_inst, uint32_t *data)
 Get PARC data. More...
 
static uint32_t parc_read_interrupt_mask (struct parc_module *const module_inst)
 Get the PARC interrupt mask. More...
 
enum status_code parc_register_callback (struct parc_module *const module, parc_callback_t const callback_func, enum parc_callback_type callback_type)
 Register a PARC interrupt callback function. More...
 
enum status_code parc_set_config (struct parc_module *const module_inst, struct parc_config *config)
 Configure the PARC module. More...
 
static void parc_start_capture (struct parc_module *const module_inst)
 Start a PARC conversion. More...
 
static void parc_stop_capture (struct parc_module *const module_inst)
 Stop a PARC conversion. More...
 
enum status_code parc_unregister_callback (struct parc_module *const module, enum parc_callback_type callback_type)
 Unregister a PARC interrupt callback. More...
 

typedef void(* parc_callback_t)(const struct parc_module *const module_inst)

PARC interrupt handler callback type.

PARC callback type.

Enumerator
PARC_CALLBACK_DATA_READY 

Data ready callback.

PARC_CALLBACK_OVERRUN 

Data overrun callback.

PARC captured byte.

Enumerator
PARC_BOTH_CAPTURE 

Bytes are captured when data is captured every cycle.

PARC_EVEN_CAPTURE 

Even bytes are captured when data is captured every two cycles.

PARC_ODD_CAPTURE 

Odd bytes are captured when data is captured every two cycles.

PARC data Size.

Enumerator
PARC_DSIZE_BYTE 

PARC data transfer size is 8-bits.

PARC_DSIZE_HALFWORD 

PARC data transfer size is 16-bits.

PARC_DSIZE_WORD 

PARC data transfer size is 32-bits.

PARC interrupt source.

Enumerator
PARC_INTERRUPT_DRDY 

Data ready interrupt.

PARC_INTERRUPT_OVR 

Data overrun interrupt.

PARC sampling edge.

Enumerator
PARC_RISING_EDGE 

Data capture occurs on the rising edge of PCCK.

PARC_FALLING_EDGE 

Data capture occurs on the falling edge of PCCK.

enum parc_smode

PARC sample mode.

Enumerator
PARC_SMODE_PCEN1_H 

Data capture occurs with PCEN1 high.

PARC_SMODE_PCEN1_AND_PCEN2_H 

Data capture occurs with PCEN1 and PCEN2 high.

PARC_SMODE_PCEN1_OR_PCEN2_H 

Data capture occurs with either PCEN1 or PCEN2 high.

PARC_SMODE_ALWAYS 

Data capture always occurs.

PARC status.

Enumerator
PARC_STATUS_EN 

PARC module enable/disable status.

PARC_STATUS_CS 

PARC Capture mode enable/disable status.

PARC_STATUS_DRDY 

Data is ready in the receive holding register.

PARC_STATUS_OVR 

Overrun error.

static enum status_code parc_clear_status ( struct parc_module *const  module_inst,
const uint32_t  status 
)
inlinestatic

Clear PARC interrupt(s) status flag.

Parameters
[in]module_instDriver structure pointer
[in]statusA bitmask of interrupt sources to clear
Returns
The clear interrupt operation status.
Return values
STATUS_OKThe interrupt was cleared successfully

References Assert, parc_module::hw, PARC_STATUS_DRDY, PARC_STATUS_OVR, and STATUS_OK.

Referenced by _parc_interrupt_handler(), and parc_read().

static enum status_code parc_disable ( struct parc_module *const  module_inst)
inlinestatic

Disable the PARC module.

Parameters
[in]module_instDriver structure pointer
Returns
The disable procedure status.
Return values
STATUS_OKThe disable procedure was successful

References Assert, parc_module::hw, and STATUS_OK.

Referenced by run_parc_callback_test(), run_parc_ctrl_test(), and run_parc_polled_test().

static enum status_code parc_disable_callback ( struct parc_module *const  module_inst,
enum parc_callback_type  type 
)
inlinestatic

Disable a PARC interrupt callback function.

Parameters
[in,out]module_instDriver structure pointer
[in]typeInterrupt callback to disable
Returns
The status of the interrupt callback disable operation.
Return values
STATUS_OKInterrupt callback disabled successfully

References Assert, parc_module::enabled_callback_mask, and STATUS_OK.

Referenced by run_parc_callback_test().

static enum status_code parc_disable_events ( struct parc_module *const  module_inst)
inlinestatic

Disable the PARC events mode.

Parameters
[in]module_instDriver structure pointer
Returns
The status of the event disable operation.
Return values
STATUS_OKThe event was disabled successfully

References parc_module::hw, and STATUS_OK.

static void parc_disable_interrupts ( struct parc_module *const  module_inst,
enum parc_interrupt_source  source 
)
inlinestatic

Disable PARC interrupt(s).

Parameters
[in]module_instDriver structure pointer
[in]sourceBitmask of interrupt sources to disable

References Assert, and parc_module::hw.

Referenced by run_parc_callback_test().

static enum status_code parc_enable ( struct parc_module *const  module_inst)
inlinestatic

Enable the PARC module.

Parameters
[in]module_instDriver structure pointer
Returns
The enable procedure status.
Return values
STATUS_OKThe enable procedure was successful

References Assert, parc_module::hw, and STATUS_OK.

Referenced by main(), run_parc_callback_test(), run_parc_ctrl_test(), and run_parc_polled_test().

static enum status_code parc_enable_callback ( struct parc_module *const  module_inst,
enum parc_callback_type  type 
)
inlinestatic

Enable a PARC interrupt callback function.

Note
The callback function will be called from the PARC interrupt handler when the callback's corresponding interrupt is asserted.
Parameters
[in,out]module_instDriver structure pointer
[in]typeInterrupt callback to enable
Returns
The status of the interrupt callback enable operation.
Return values
STATUS_OKInterrupt callback enabled successfully

References Assert, parc_module::enabled_callback_mask, and STATUS_OK.

Referenced by run_parc_callback_test().

static enum status_code parc_enable_events ( struct parc_module *const  module_inst)
inlinestatic

Enable the PARC events mode.

Parameters
[in]module_instDriver structure pointer
Returns
The status of the event enable operation.
Return values
STATUS_OKThe event was enabled successfully

References parc_module::hw, and STATUS_OK.

static void parc_enable_interrupts ( struct parc_module *const  module_inst,
enum parc_interrupt_source  source 
)
inlinestatic

Enable PARC interrupt(s).

Parameters
[in]module_instDriver structure pointer
[in]sourceBitmask of interrupt sources to enable

References Assert, and parc_module::hw.

Referenced by run_parc_callback_test().

static void parc_get_config_defaults ( struct parc_config *const  config)
inlinestatic

Initialize a PARC configuration structure to default values.

Initializes the supplied PARC configuration structure to a set of known default values.

Note
This function should be called to populate new instances of the configuration structure before being further modified by the user application.

The default configurations are:

  • Capture every byte
  • Sample the data bus on the rising edge of the PCCK input clock
  • Sample data regardless of the levels of PCEN1 and PCEN2
  • 8-bit data width
Parameters
[out]configPointer to a PARC configuration structure

References Assert, parc_config::capture_mode, parc_config::dsize, PARC_BOTH_CAPTURE, PARC_DSIZE_BYTE, PARC_RISING_EDGE, PARC_SMODE_ALWAYS, parc_config::sampling_edge, and parc_config::smode.

Referenced by main(), run_parc_callback_test(), run_parc_ctrl_test(), and run_parc_polled_test().

static uint32_t parc_get_status ( struct parc_module *const  module_inst)
inlinestatic

Get the PARC module's current status.

Parameters
[in]module_instDriver structure pointer
Returns
The PARC module's current status as a bitmask.
Return values
PARC_STATUS_ENPARC is enabled
PARC_STATUS_CSPARC capture status
PARC_STATUS_DRDYPARC data ready
PARC_STATUS_OVRPARC overrun

References parc_module::hw.

Referenced by parc_read(), and run_parc_ctrl_test().

static uint32_t parc_get_version ( struct parc_module *const  module_inst)
inlinestatic

Get the PARC module version.

Parameters
[in]module_instDriver structure pointer
Returns
The PARC module version.

References parc_module::hw.

enum status_code parc_init ( struct parc_module *const  module_inst,
Parc *const  hw,
struct parc_config *const  config 
)

Initialize the PARC module.

Initialize the PARC driver structure and the hardware module based on the given configuration structure's contents.

Parameters
[in,out]module_instPointer to the PARC driver structure
[in]hwPointer to the PARC module hardware register structure
[in]configPointer to the PARC configuration structure
Returns
The initialization status.
Return values
STATUS_OKThe initialization was successful

References parc_module::callback, parc_module::enabled_callback_mask, parc_module::hw, module_inst, NULL, parc_module_instance, parc_set_config(), parc_module::registered_callback_mask, and sysclk_enable_peripheral_clock().

Referenced by main(), run_parc_callback_test(), run_parc_ctrl_test(), and run_parc_polled_test().

static bool parc_is_data_ready ( struct parc_module *const  module_inst)
inlinestatic

Check the data ready status of PARC.

Parameters
[in]module_instDriver structure pointer
Returns
The PARC data ready status.
Return values
falseCaptured data is not ready
trueCaptured data is ready

References parc_module::hw.

Referenced by run_parc_polled_test().

static enum status_code parc_read ( struct parc_module *const  module_inst,
uint32_t *  data 
)
inlinestatic

Get PARC data.

Parameters
[in]module_instDriver structure pointer
[out]dataPointer to store the captured data in
Returns
The status of the PARC read data request.
Return values
STATUS_OKCaptured data was read successfully
STATUS_ERR_BUSYCaptured data is not ready

References Assert, parc_module::hw, parc_clear_status(), parc_get_status(), PARC_STATUS_DRDY, STATUS_ERR_BUSY, and STATUS_OK.

Referenced by parc_complete_callback(), and run_parc_polled_test().

static uint32_t parc_read_interrupt_mask ( struct parc_module *const  module_inst)
inlinestatic

Get the PARC interrupt mask.

Parameters
[in]module_instDriver structure pointer
Returns
The PARC interrupt mask.

References parc_module::hw.

enum status_code parc_register_callback ( struct parc_module *const  module,
parc_callback_t const  callback_func,
enum parc_callback_type  callback_type 
)

Register a PARC interrupt callback function.

Note
The callback must be enabled by using parc_enable_callback.
Parameters
[in,out]moduleDriver structure pointer
[in]callback_funcPointer to a callback function
[in]callback_typeInterrupt callback type
Returns
The status of the interrupt callback register operation.
Return values
STATUS_OKPARC interrupt callback was registered successfully

References Assert, parc_module::callback, parc_module::registered_callback_mask, and STATUS_OK.

Referenced by run_parc_callback_test().

enum status_code parc_set_config ( struct parc_module *const  module_inst,
struct parc_config config 
)

Configure the PARC module.

Configure the PARC module from the supplied configuration structure.

Parameters
[in]module_instPointer to the PARC driver structure
[in]configPointer to the PARC configuration structure
Returns
The configuration status.
Return values
STATUS_OKThe configuration was successful

References Assert, parc_config::capture_mode, parc_config::dsize, parc_module::hw, PARC_BOTH_CAPTURE, PARC_EVEN_CAPTURE, PARC_FALLING_EDGE, PARC_ODD_CAPTURE, PARC_RISING_EDGE, parc_config::sampling_edge, parc_config::smode, and STATUS_OK.

Referenced by parc_init().

static void parc_start_capture ( struct parc_module *const  module_inst)
inlinestatic

Start a PARC conversion.

Parameters
[in]module_instDriver structure pointer

References Assert, and parc_module::hw.

Referenced by main(), run_parc_callback_test(), run_parc_ctrl_test(), and run_parc_polled_test().

static void parc_stop_capture ( struct parc_module *const  module_inst)
inlinestatic

Stop a PARC conversion.

Parameters
[in]module_instDriver structure pointer

References Assert, and parc_module::hw.

Referenced by run_parc_callback_test(), run_parc_ctrl_test(), and run_parc_polled_test().

enum status_code parc_unregister_callback ( struct parc_module *const  module,
enum parc_callback_type  callback_type 
)

Unregister a PARC interrupt callback.

Parameters
[in,out]moduleDriver structure pointer
[in]callback_typeInterrupt callback type
Returns
The status of the interrupt callback unregister operation.
Return values
STATUS_OKPARC interrupt callback was unregistered successfully

References Assert, parc_module::callback, NULL, parc_module::registered_callback_mask, and STATUS_OK.