![]() |
Synergy Software Package User's Manual
|
The Data Operation Circuit (DOC) HAL module provides a high-level API for DOC applications and uses the DOC peripherals on the Synergy MCU. A user-defined callback can be created to inform the CPU when an event occurs.
The DOC HAL module peripheral is used to compare 16-bit data and can detect the following events:
The following hardware features are, or are not, supported by SSP for DOC.
Legend:
| Symbol | Meaning |
|---|---|
| ✓ | Available (Tested) |
| ⌧ | Not Available (Not tested/not functional or both) |
| N/A | Not supported by MCU |
| MCU Group | Module-stop Function | Event Link Function through ELC HAL Driver |
|---|---|---|
| S124 | ✓ | ⌧ |
| S128 | ✓ | ⌧ |
| S1JA | ✓ | ⌧ |
| S3A1 | ✓ | ⌧ |
| S3A3 | ✓ | ⌧ |
| S3A6 | ✓ | ⌧ |
| S3A7 | ✓ | ⌧ |
| S5D3 | ✓ | ⌧ |
| S5D5 | ✓ | ⌧ |
| S5D9 | ✓ | ⌧ |
| S7G2 | ✓ | ⌧ |
The DOC HAL module defines APIs for opening, closing, checking the status of and writing data to the data operation circuit. The DOC HAL module uses the DOC peripheral on the Synergy MCU. A complete list of the available APIs, an example API call and a short description of each can be found in the following table. A table of status return values follows the API summary table.
DOC HAL Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| open | g_doc.p_api->open(g_doc.p_ctrl, g_doc.p_cfg)Initial configuration. |
| close | g_doc.p_api->close(g_doc.p_ctrl)Allow the driver to be reconfigured. Will reduce power consumption. |
| statusGet | g_doc.p_api->statusGet(g_doc.p_ctrl, &my_Status)Get the DOC status and stores it in the provided pointer p_status. |
| statusClear | g_doc.p_api->statusClear(g_doc.p_ctrl)Clear DOPCF status flag. |
| write | g_doc.p_api->write(g_doc.p_ctrl, value)Write to the DODIR and DODSR registers. |
| inputRegisterWrite | g_doc.p_api->inputRegisterWrite(g_doc.p_ctrl, &doc_values)Write to the DODIR register. |
| versionGet | g_doc.p_api->versionGet(g_doc.p_ctrl, &version)Retrieve the API version with the version pointer. |
Status Return Values
| Name | Description |
|---|---|
| SSP_SUCCESS | DOC successfully configured. |
| SSP_ERR_IN_USE | Module already open. |
| SSP_ERR_ASSERTION | One or more pointers point to NULL. |
| SSP_ERR_INVALID_ARGUMENT | ISR is not enabled. Enable the ISR in bsp_irq_cfg.h. |
| SSP_ERR_HW_LOCKED | DOC resource is locked. |
| SSP_ERR_NOT_OPEN | Driver not open. |
The DOC HAL module controls the DOC peripheral on a Synergy MCU. It is used to compare 16-bit data and can detect a mismatch between data values, an overflow of an addition value, or an underflow of a subtraction operation. If a callback is available and the associated interrupt is enabled, the callback function will be called in response to a DOC event.
The DOC uses two data registers to perform operations: the DOC Data Input Register (DOCDIR) holds the data to be operated on and the DOC Data Setting Register (DOCDSR) holds the value that is used to operate on the input data. In the addition and subtraction modes, this register stores the results of data operations. (Both these registers are 16-bits wide.)
The initial setting of comparison data is written to the DOC by calling the doc_api_t::write API. The doc_api_t::write API writes to the DOC DODSR and DODIR registers. The doc_api_t::write API use a variable of type doc_data_t, as illustrated below:
doc_data_t g_doc_values;
g_doc_values.dodir = 0x1000;
g_doc_values.dodsr = 0x1000;
g_doc.p_api->write(g_doc.p_ctrl, &g_doc_values);
If the data to be compared does not change, there is no need to re-write it each time a comparison is required. The input data value can be written to the DOC by using the doc_api_t::inputRegisterWrite API. The doc_api_t::inputRegisterWrite API writes only to the DOC data-input register.
Refer to the latest SSP Release Notes for any additional operational limitations for this module.
This section describes how to include the DOC HAL Module in an application using the SSP configurator.
To add the DOC Driver to an application, simply add it to a thread using the stacks selection sequence given in the following table. (The default name for the DOC Driver is g_doc0. This name can be changed in the associated Properties window.)
DOC HAL Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_doc0 Data Operation Circuit Driver on r_doc | Threads | New Stack> Driver> Monitoring> Data Operation Circuit Driver on r_doc |
When the Key Matrix Driver on r_kint is added to the thread stack as shown in the following figure, the configurator automatically adds any needed lower‑level modules. Any modules needing additional configuration information have the box text highlighted in Red. Modules with a Gray band are individual modules that stand alone. Modules with a Blue band are shared or common; they need only be added once and can be used by multiple stacks. Modules with a Pink band can require the selection of lower-level modules; these are either optional or recommended. (This is indicated in the block with the inclusion of this text.) If the addition of lower-level modules is required, the module description include Add in the text. Clicking on any Pink banded modules brings up the New icon and displays possible choices.
The DOC HAL Module must be configured by the user for the desired operation. The available configuration settings and defaults for all the user-accessible properties are given in the properties tab within the SSP configurator and are shown in the following tables for easy reference. Only properties that can be changed without causing conflicts are available for modification. Other properties are locked and not available for changes and are identified with a lock icon for the locked property in the Properties window in the ISDE. This approach simplifies the configuration process and makes it much less error-prone than previous manual approaches to configuration. The available configuration settings and defaults for all the user-accessible properties are given in the Properties tab within the SSP Configurator and are shown in the following tables for easy reference.
Configuration Settings for the DOC HAL Module on r_doc
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enable or disable the parameter error checking. |
| Name | g_doc0 | Module name. |
| Event | Comparison mismatch, Comparison match, Addition overflow, Subtraction underflow Default: Comparison mismatch | Specify the event which will trigger the DOC interrupt. |
| Callback | NULL | A user callback function can be registered in open. If this callback function is provided, it is called from the interrupt service routine (ISR) when the configured DOC event occurs. Warning: Since the callback is called from an ISR, care should be taken not to use blocking calls or lengthy processing. Spending excessive time in an ISR can affect the responsiveness of the system. |
| DOC Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Disabled | Use the pull down to set the DOC interrupt priority. |
The DOC HAL module does not require a specific clock configuration.
The DOC HAL module does not require and specific pin configurations.
The typical steps in using the DOC HAL module in an application are:
These common steps are illustrated in a typical operational flow diagram in the following figure: