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:
There are no prerequisites for this module.
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.
The PARC module offers the following features:
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.
The PARC pins are multiplexed with other peripherals. The user application must first configure the I/O Controller to yield control of the pins.
The PARC module stops functioning when the system enters a sleep mode that disables its clock.
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.
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.
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.
For extra information, see Extra Information for Parallel Capture. This includes:
For a list of examples related to this driver, see Examples for Parallel Capture.
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the SAM4L Parallel Capture (PARC) Driver. | |
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.
enum parc_callback_type |
enum parc_capture_mode |
enum parc_data_size |
enum parc_sampling_edge |
enum parc_smode |
enum parc_status |
|
inlinestatic |
Clear PARC interrupt(s) status flag.
[in] | module_inst | Driver structure pointer |
[in] | status | A bitmask of interrupt sources to clear |
STATUS_OK | The 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().
|
inlinestatic |
Disable the PARC module.
[in] | module_inst | Driver structure pointer |
STATUS_OK | The 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().
|
inlinestatic |
Disable a PARC interrupt callback function.
[in,out] | module_inst | Driver structure pointer |
[in] | type | Interrupt callback to disable |
STATUS_OK | Interrupt callback disabled successfully |
References Assert, parc_module::enabled_callback_mask, and STATUS_OK.
Referenced by run_parc_callback_test().
|
inlinestatic |
Disable the PARC events mode.
[in] | module_inst | Driver structure pointer |
STATUS_OK | The event was disabled successfully |
References parc_module::hw, and STATUS_OK.
|
inlinestatic |
Disable PARC interrupt(s).
[in] | module_inst | Driver structure pointer |
[in] | source | Bitmask of interrupt sources to disable |
References Assert, and parc_module::hw.
Referenced by run_parc_callback_test().
|
inlinestatic |
Enable the PARC module.
[in] | module_inst | Driver structure pointer |
STATUS_OK | The 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().
|
inlinestatic |
Enable a PARC interrupt callback function.
[in,out] | module_inst | Driver structure pointer |
[in] | type | Interrupt callback to enable |
STATUS_OK | Interrupt callback enabled successfully |
References Assert, parc_module::enabled_callback_mask, and STATUS_OK.
Referenced by run_parc_callback_test().
|
inlinestatic |
Enable the PARC events mode.
[in] | module_inst | Driver structure pointer |
STATUS_OK | The event was enabled successfully |
References parc_module::hw, and STATUS_OK.
|
inlinestatic |
Enable PARC interrupt(s).
[in] | module_inst | Driver structure pointer |
[in] | source | Bitmask of interrupt sources to enable |
References Assert, and parc_module::hw.
Referenced by run_parc_callback_test().
|
inlinestatic |
Initialize a PARC configuration structure to default values.
Initializes the supplied PARC configuration structure to a set of known default values.
The default configurations are:
[out] | config | Pointer 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().
|
inlinestatic |
Get the PARC module's current status.
[in] | module_inst | Driver structure pointer |
PARC_STATUS_EN | PARC is enabled |
PARC_STATUS_CS | PARC capture status |
PARC_STATUS_DRDY | PARC data ready |
PARC_STATUS_OVR | PARC overrun |
References parc_module::hw.
Referenced by parc_read(), and run_parc_ctrl_test().
|
inlinestatic |
Get the PARC module version.
[in] | module_inst | Driver structure pointer |
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.
[in,out] | module_inst | Pointer to the PARC driver structure |
[in] | hw | Pointer to the PARC module hardware register structure |
[in] | config | Pointer to the PARC configuration structure |
STATUS_OK | The 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().
|
inlinestatic |
Check the data ready status of PARC.
[in] | module_inst | Driver structure pointer |
false | Captured data is not ready |
true | Captured data is ready |
References parc_module::hw.
Referenced by run_parc_polled_test().
|
inlinestatic |
Get PARC data.
[in] | module_inst | Driver structure pointer |
[out] | data | Pointer to store the captured data in |
STATUS_OK | Captured data was read successfully |
STATUS_ERR_BUSY | Captured 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().
|
inlinestatic |
Get the PARC interrupt mask.
[in] | module_inst | Driver structure pointer |
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.
[in,out] | module | Driver structure pointer |
[in] | callback_func | Pointer to a callback function |
[in] | callback_type | Interrupt callback type |
STATUS_OK | PARC 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.
[in] | module_inst | Pointer to the PARC driver structure |
[in] | config | Pointer to the PARC configuration structure |
STATUS_OK | The 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().
|
inlinestatic |
Start a PARC conversion.
[in] | module_inst | Driver structure pointer |
References Assert, and parc_module::hw.
Referenced by main(), run_parc_callback_test(), run_parc_ctrl_test(), and run_parc_polled_test().
|
inlinestatic |
Stop a PARC conversion.
[in] | module_inst | Driver 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.
[in,out] | module | Driver structure pointer |
[in] | callback_type | Interrupt callback type |
STATUS_OK | PARC interrupt callback was unregistered successfully |
References Assert, parc_module::callback, NULL, parc_module::registered_callback_mask, and STATUS_OK.