All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CapMod Class Reference

UDT for PWMSS-CAP modules, containing the functions to drive the hardware. More...

## Public Member Functions

| CapMod (BYVAL_AS_Pruio__PTR)
| The constructor for the CAP feature of the PWMSS. More...
FUNCTION_CDECL_AS_ZSTRING_PTR | config (BYVAL_AS_UInt8, BYVAL_AS_Float_t)
| Configure a header pin as eCAP input. More...
FUNCTION_CDECL_AS_ZSTRING_PTR | Value (BYVAL_AS_UInt8, BYVAL_AS_Float_t_PTR, BYVAL_AS_Float_t_PTR)
| Analyse a digital pulse train, get frequency and duty cycle. More...

## Public Attributes

Pruio__PTR | Top
| pointer to the calling PruIo instance
ZSTRING_PTR | E0 = "pin has no CAP capability"
| common error message
ZSTRING_PTR | E1 = "pin not in CAP mode"
| common error message
ZSTRING_PTR | E2 = "CAP not enabled"
| common error message

## Detailed Description

UDT for PWMSS-CAP modules, containing the functions to drive the hardware.

This structure contains the functions to drive the hardware of the eCAP modul in the PWMSS subsystems in input mode.

See ARM Reference Guide, chapter 15.3 for hardware details.

Definition at line 243 of file pruio_pwmss.bi.

## Constructor & Destructor Documentation

CapMod::CapMod | ( | BYVAL_AS_Pruio__PTR | T | ) |

The constructor for the CAP feature of the PWMSS.

Parameters

  T | A pointer of the calling PruIo structure.

Each of the three Pulse Width Modulation SubSystem (PWMSS) in the CPU contains modules (PWM, CAP and QEP). In order to create a clear API from the user point of view, the functions to control the modules are separated to extra classes. This UDT contains functions to control the CAP module, which is used to analyse the frequency and duty cycle of a digital pulse train.

The constructor just copies a pointer to the calling main UDT PruIo.

Since
  0.2

Definition at line 540 of file pruio_pwmss.bas.

Here is the caller graph for this function:

## Member Function Documentation

FUNCTION_CDECL_AS_ZSTRING_PTR CapMod::config | ( | BYVAL_AS_UInt8 | Ball,
|  | BYVAL_AS_Float_t | FLow = `0.`
| ) |  |

Configure a header pin as eCAP input.

Parameters

  Ball | The CPU ball number to configure.
  FLow | Minimal frequency to measure in Hz (> .0232831).

Returns
  Zero on success (otherwise a string with an error message).

This function configures a header pin for Capture and Analyse Pulse (CAP) trains. The pins configuration gets checked. If it's not configured as input for the CAP module in the PWMSS subsystem, libpruio tries to adapt the pinmuxing. This fails if the program isn't executed with admin privileges.

Currently CAP is available on pins P9_42 and P9_28. The later is used for MCASP-0 on the BBB.

The parameter FLow specifies the minimal frequency to measure in Hz. When not set (values < .0232831) and the input doesn't change, the counter runs until an overflow before it returns the new values (in this case frequency = 0 and duty cycle = 0). This lasts about 43 seconds before the new values are available. To shorten this time, you can specify the lowest frequency. When a period without change is over, the counter gets restarted.

Since
  0.2

Definition at line 569 of file pruio_pwmss.bas.

Here is the caller graph for this function:

FUNCTION_CDECL_AS_ZSTRING_PTR CapMod::Value | ( | BYVAL_AS_UInt8 | Ball,
|  | BYVAL_AS_Float_t_PTR | Hz = `0`,
|  | BYVAL_AS_Float_t_PTR | Du = `0`
| ) |  |

Analyse a digital pulse train, get frequency and duty cycle.

Parameters

  Ball | The CPU ball number to test.
  Hz | A pointer to store the frequency value (or null).
  Du | A pointer to store the duty cycle value (or null).

Returns
  Zero on success (otherwise a string with an error message).

This function returns the frequency and duty cycle of a digital pulse train on a header pin. The header pin needs to get configured first by a call to function CapMod::config().

The parameters Hz and Du contain the results of the last measured period. You can pass a zero pointer to either of them if you don't need this value.

A period is limited by the counter resolution. The minimal frequency is 0.0232831 Hz, so a period lasts maximal 43 seconds. When the state of the input pin doesn't change twice during a period, the counter restarts and zero gets returned for both results (Hz and Du). The minimal frequency can get adapted by parameter FLow in the previous call to function CapMod::config().

Since
  0.2

Definition at line 640 of file pruio_pwmss.bas.

Here is the caller graph for this function:

The documentation for this class was generated from the following files:

- src/pruio/pruio_pwmss.bi
- src/pruio/pruio_pwmss.bas