Driver for the DOC peripheral on RZ microprocessor. This module implements the DOC Interface.
Overview
Features
The DOC HAL module peripheral is used to compare, add or subtract 16-bit data and can detect the following events:
- A match or mismatch between data values
- Overflow of an addition operation
- Underflow of a subtraction operation
A user-defined callback can be created to inform the CPU when any of above events occur.
Configuration
Build Time Configurations for r_doc
The following build time configurations are defined in fsp_cfg/r_doc_cfg.h:
| Configuration | Options | Default | Description |
| Parameter Checking |
-
Default (BSP)
-
Enabled
-
Disabled
| Default (BSP) | If selected code for parameter checking is included in the build. |
| Nested Interrupt (Multiplex Interrupt) |
| Disabled | Enable nested interrupt for a single driver. |
Configurations for Monitoring > Data Operation Circuit (r_doc)
This module can be added to the Stacks tab via New Stack > Monitoring > Data Operation Circuit (r_doc).
| Configuration | Options | Default | Description |
| Name | Name must be a valid C symbol | g_doc0 | Module name. |
| Event | MCU Specific Options | | Select the event that will trigger the DOC interrupt. |
| Bit Width | MCU Specific Options | | The bit width for DOC operations. |
| Reference/Initial Data | Value must be an integer greater than or equal to 0. | 0 | Enter Initial Value for Addition/Subtraction or enter reference value for comparison. |
| Additional Reference Data | Value must be an integer greater than or equal to 0. | 0 | Additional reference data used for Window Compare modes. |
| Callback | Name must be a valid C symbol | NULL | A user callback function must be provided. This will be called from the interrupt service routine (ISR) when the configured DOC event occurs. |
Clock Configuration
The DOC HAL module does not require a specific clock configuration.
Pin Configuration
The DOC HAL module does not require and specific pin configurations.
Usage Notes
Interrupt
The DOC outputs an error signal to the ICU. ICU can output PERI_ERRn interrupt (Peripherals error event n) to GIC or cause error reset when ICU accepts error signal from DOC. To use PERI_ERRn interrupt or reset at DOC, ICU ERROR (r_icu_error) need to be configured. When the PERI_ERRn interrupt is configured to use interrupt and triggered, the callback function registered during open is called.
DMAC Integration
DOC can be used with Transfer (r_dmac) to write to the input register without CPU intervention. DMAC is more useful for most DOC applications because it can be started directly from software. To write DOC input data with DMAC, set transfer_info_t::p_dest to R_DOC->DODIR.
Basic Example
This is a basic example of minimal use of the R_DOC in an application. This example shows how this driver can be used for continuous 16 bit addition operation while reading the result at every overflow event.
#define DOC_EXAMPLE_VALUE 0xF000
uint32_t g_callback_event_counter = 0;
{
g_callback_event_counter++;
}
{
(ICU_ERROR_PERIPHERAL_ERROR_1_DOC_DOPCI == p_args->error_status))
{
}
}
void basic_example (void)
{
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
for (int i = 0; i < 5; i++)
{
assert(FSP_SUCCESS == err);
if (g_callback_event_counter >= 1)
{
uint32_t result;
assert(FSP_SUCCESS == err);
}
}
}
◆ RZT::st_doc_instance_ctrl
| struct RZT::st_doc_instance_ctrl |
DOC instance control block. Do not initialize. Initialization occurs when the RZT::doc_api_t::open function is called.
Public Attributes |
|
uint32_t | open |
| | Used by driver to check if the control structure is valid.
|
| |
|
void * | p_context |
| | User defined context passed into callback function.
|
| |
◆ doc_instance_ctrl_t
◆ R_DOC_Open()
Opens and configures the Data Operation Circuit (DOC) in comparison, addition or subtraction mode and sets initial data for addition or subtraction, or reference data for comparison.
- Return values
-
| FSP_SUCCESS | DOC successfully configured. |
| FSP_ERR_ALREADY_OPEN | Module already open. |
| FSP_ERR_ASSERTION | One or more pointers point to NULL or callback is NULL or the interrupt vector is invalid. |
◆ R_DOC_Close()
Closes the module driver. Enables module stop mode.
- Return values
-
| FSP_SUCCESS | Module successfully closed. |
| FSP_ERR_NOT_OPEN | Driver not open. |
| FSP_ERR_ASSERTION | Pointer pointing to NULL. |
- Note
- This function will disable the DOC interrupt in the GIC.
◆ R_DOC_Read()
Returns the result of addition/subtraction.
- Return values
-
| FSP_SUCCESS | Status successfully read. |
| FSP_ERR_NOT_OPEN | Driver not open. |
| FSP_ERR_ASSERTION | One or more pointers point to NULL. |
◆ R_DOC_Write()
Writes to the DODIR - DOC Input Register.
- Return values
-
| FSP_SUCCESS | Values successfully written to the registers. |
| FSP_ERR_NOT_OPEN | Driver not open. |
| FSP_ERR_ASSERTION | One or more pointers point to NULL. |
◆ R_DOC_CallbackSet()
Updates the user callback and has option of providing memory for callback structure. Implements doc_api_t::callbackSet
- Return values
-
| FSP_SUCCESS | Callback updated successfully. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |