![]() |
Synergy Software Package User's Manual
|
The External IRQ Framework provides a high-level API for applications using the external pin interrupts with the ThreadX RTOS and supports the external IRQ pins on the Synergy microcontroller. A callback function (sf_external_irq_callback) is available that will be called from the interrupt service routine (ISR) each time the IRQn triggers.
The External IRQ framework module defines APIs for opening, waiting or closing the module. 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.
External IRQ Framework Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| open | g_sf_external_irq.p_api->open(g_sf_external_irq.p_ctrl, g_sf_external_irq.p_cfg);Acquire mutex, then handle driver initialization at the HAL layer. |
| wait | g_sf_external_irq.p_api->wait(g_sf_external_irq.p_ctrl, TX_WAIT_FOREVER);Wait for the next external interrupt expiration, then return. |
| versionGet | g_sf_external_irq.p_api->versionGet(&version);Retrieve the API version and store it in the version pointer. |
| close | g_sf_external_irq.p_api->close(g_sf_external_irq.p_ctrl);Release channel mutex and close channel at HAL layer. |
Status Return Values
| Name | Description |
|---|---|
| SSP_SUCCESS | Function successful. |
| SSP_ERR_ASSERTION | Assertion error. |
| SSP_ERR_IN_USE | Device in use. |
| SSP_ERR_NOT_OPEN | Device unopened. |
| SSP_ERR_TIMEOUT | Timeout error. |
| SSP_ERR_WAIT_ABORTED | Suspension aborted. |
| SSP_ERR_UNSUPPORTED | Function unsupported by the HAL driver. |
The External IRQ framework is a set of ThreadX-aware framework APIs. The External IRQ Framework external inputs can signal, via an internal semaphore, threads or trigger transfers via the Event Link Controller (ELC). Both the External IRQ framework module and the External IRQ HAL module need to be configured for proper operation. The HAL configuration settings allow control over hardware options such as triggering level and digital filtering settings.
This section describes how to include the External IRQ Framework Module in an application using the SSP configurator.
To add the External IRQ Framework to an application, simply add it to a thread using the stacks selection sequence given in the following table. (The default name for the External IRQ Framework is g_sf_external_irq0. This name can be changed in the associated Properties window.)
External IRQ Framework Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_sf_external_irq0 External IRQ Framework on sf_external_irq | Threads | New Stack> Framework> Input> External IRQ Framework on sf_external_irq |
When the External IRQ Framework on sf_external_irq 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 External IRQ Framework 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 External IRQ Framework Module on sf_external_irq
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Controls whether to include code for API parameter checking. |
| Name | g_sf_external_irq0 | Framework name. |
| Event | None, Semaphore Put Default: Semaphore Put | Event selection. |
Typically, only a small number of settings must be modified from the default for lower level drivers as indicated via the red text in the thread stack block. Notice that some of the configuration properties must be set to a certain value for proper framework operation and will be locked to prevent user modification. The following tables identify all the settings within the properties section for the module.
Configuration Settings for the External IRQ HAL Module on r_icu
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Parameter checking setting enables or disables the addition of parameter checking code. |
| Name | g_external_irq0 | Module name. |
| Channel | 0 | Specifies the hardware IRQ channel used. |
| Trigger | Falling, Rising, Both Edges, Low Level Default: Rising | Configures edge or level triggering. |
| Digital Filtering | Enabled, Disabled Default: Disabled | Digital filter enable/disable. |
| Digital Filtering Sample Clock (Only valid when Digital Filtering is Enabled) | PCLK/1, PLCK/8, PLCK/32, PCLK/64 Default: PCKL/64 | Sets noise filter sampling period. |
| Interrupt enabled after initialization | True, False Default: True | Determines if the interrupt is enabled immediately after initialization. |
| Callback | NULL | A user callback function can be registered in external_irq_api_t::open. If this callback function is provided, it is called from the interrupt service routine (ISR) each time the IRQn triggers. 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. |
| Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Priority 12 | An Interrupt priority can be registered in external_irq_cfg_t::irq_ipl. |
The External IRQ Framework does not require clock configuration.
The External IRQ Framework does not require pin configuration.
The steps in using the External IRQ Framework module in a typical application are:
These common steps are illustrated in a typical operational flow diagram in the following figure: