Structure for TIMER subsystem features, containing all functions and variables to handle the subsystems. More...
Public Member Functions | |
TimerUdt (BYVAL_AS_Pruio__PTR) | |
The constructor for the TIMER features. More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | initialize () |
Initialize the register context after running the pasm_init.p instructions (private). More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | setValue (BYVAL_AS_UInt8, BYVAL_AS_Float_t, BYVAL_AS_Float_t, BYVAL_AS_SHORT) |
Configure timer output. More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | Value (BYVAL_AS_UInt8, BYVAL_AS_Float_t_PTR, BYVAL_AS_Float_t_PTR) |
Compute timer output. More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | pwm_set (BYVAL_AS_UInt8, BYVAL_AS_Float_t, BYVAL_AS_Float_t) |
Configure PWM output at a TIMER pin (private). More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | pwm_get (BYVAL_AS_UInt8, BYVAL_AS_Float_t_PTR, BYVAL_AS_Float_t_PTR) |
Compute PWM output configuration from a TIMER subsystem (private). More... | |
Public Attributes | |
Pruio__PTR | Top |
Pointer to the calling PruIo instance. | |
TimerSet_PTR | Init [PRUIO_AZ_TIMER+1] |
Initial subsystem configuration, used in the destructor PruIo::~PruIo(). | |
TimerSet_PTR | Conf [PRUIO_AZ_TIMER+1] |
Current subsystem configuration, used in PruIo::config(). | |
TimerArr_PTR | Raw [PRUIO_AZ_TIMER+1] |
Pointer to current raw subsystem data (IO), all 32 bits. | |
UInt32 | InitParA |
Offset to read data block. | |
UInt32 | PwmMode = &b001100001000011 |
Control register for PWM output mode. | |
UInt32 | TimMode = &b001100001000010 |
Control register for Timer mode. | |
UInt32 | TimHigh = &b000000010000000 |
Control register for stopped Timer high. | |
UInt32 | Tim_Low = &b000000000000000 |
Control register for stopped Timer low. | |
UInt32 | CapMode = &b010000110000000 |
Control register for CAP input mode. | |
ZSTRING_PTR | E0 = "TIMER subsystem not enabled" |
Common error message. | |
ZSTRING_PTR | E1 = "pin has no TIMER capability" |
Common error message. | |
ZSTRING_PTR | E2 = "pin not in TIMER mode" |
Common error message. | |
ZSTRING_PTR | E3 = "duration too short" |
Common error message. | |
ZSTRING_PTR | E4 = "duration too long" |
Common error message. | |
ZSTRING_PTR | E5 = "pin not in CAP mode" |
Common error message. | |
Structure for TIMER subsystem features, containing all functions and variables to handle the subsystems.
This UDT contains the member function to control the features in each of the four TIMER subsystems included in the TI AM335x CPU and the related variables.
Definition at line 72 of file pruio_timer.bi.
TimerUdt::TimerUdt | ( | BYVAL_AS_Pruio__PTR | T | ) |
The constructor for the TIMER features.
T | A pointer of the calling PruIo structure. |
The constructor prepares the DRam parameters to run the pasm_init.p instructions. The adresses of the subsystems and the adresses of the clock registers get prepared, and the index of the last parameter gets stored to compute the offset in the Init and Conf data blocks.
Definition at line 33 of file pruio_timer.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR TimerUdt::initialize | ( | ) |
Initialize the register context after running the pasm_init.p instructions (private).
This is a private function, designed to be called from the main constructor PruIo::PruIo(). It sets the pointers to the Init and Conf structures in the data blocks. And it initializes some register context, if the subsystem woke up and is enabled.
Definition at line 64 of file pruio_timer.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR TimerUdt::pwm_get | ( | BYVAL_AS_UInt8 | Nr, |
BYVAL_AS_Float_t_PTR | Freq = 0 , |
||
BYVAL_AS_Float_t_PTR | Duty = 0 |
||
) |
Compute PWM output configuration from a TIMER subsystem (private).
Nr | The TIMER subsystem index. |
Freq | A pointer to output the frequency value (or 0 for no output). |
Duty | A pointer to output the duty value (or 0 for no output). |
This private functions computes the real PWM configuration of a TIMER subsystem. It's designed to get called from function PwmMod::Value().
Nr
parameter. Values greater than PRUIO_AZ_GPIO may result in wired behaviour.Definition at line 408 of file pruio_timer.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR TimerUdt::pwm_set | ( | BYVAL_AS_UInt8 | Nr, |
BYVAL_AS_Float_t | Freq, | ||
BYVAL_AS_Float_t | Duty = 0. |
||
) |
Configure PWM output at a TIMER pin (private).
Nr | The TIMER subsystem index. |
Freq | The frequency to set (or -1 for no change). |
Duty | The duty cycle to set (0.0 to 1.0, or -1 for no change). |
This private function configures a TIMER subsystem for PWM output. It sets the frequency Freq
and the duty cycle Duty
. Only positive values in these parameters force a change. Pass a negative value to stay with the current setting. A Duty
parameter greater than 1.0 gets limited to 1.0 (= 100%).
Nr
parameter. Values greater than PRUIO_AZ_TIMER may result in wired behaviour.Definition at line 328 of file pruio_timer.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR TimerUdt::setValue | ( | BYVAL_AS_UInt8 | Ball, |
BYVAL_AS_Float_t | Dur1, | ||
BYVAL_AS_Float_t | Dur2 = 0. , |
||
BYVAL_AS_SHORT | Mode = 0 |
||
) |
Configure timer output.
Ball | The header pin to get timer output from. |
Dur1 | The low period duration in [ms] (or 0 to stop timer). |
Dur2 | The high period duration in [ms] (or 0 for minimal duration). |
Mode | The output mode (defaults to &h00). |
This function sets timer output on a header pin. The default output is
Dur1
period of time, then high state for Dur2
, repeating endless.Parameter Mode
allows manipulation of this pulse train:
Parameter Ball
specifies the header pin to use. Check section TIMER for available header pins. libpruio will check the pin configuration (pinmuxing) and adapt it, if necessary and possible. If unpossible an error message gets returned.
Parameter Dur1
specifies the time period of the starting state in [mSec]. Parameter Dur2
specifies the time period of the toggled state (= pulse) in [mSec]. If Dur2
is 0 (zero), the minimal pulse time is used (one clock impluse).
If the summ of both, Dur1
and Dur2
, is smaller or equal 0 (zero), the timer gets stopped (when running in continuous mode) in the state specified by bit 0 (invers bit) of parameter Mode
.
When parameter Mode
is greater than 1 the timer fires a number of pulses and stops afterwards. The maximal number of pulses is 255, and twice the pulses have to get specified. Ie Mode = 2
sends one pulse, Mode = 510
sends 255 pulses (=maximum), and Mode = 511
sends 255 pulses (=maximum) in invers mode. In one shot mode parameter Dur1
must not be less than 0.01 [mSec].
Dur1
and Dur2
is limited. See the table in section TIMER for details.Dur1
+ Dur2
summ, the longer the minimal pulse duration. The duration of a minimal pulse from an eCAP module is 50 ns and from a TIMER subsystem is between 83 ns and 21248 ns. Find further details in ARM Reference Guide, chapter 20.Wrapper function (C or Python): pruio_tim_setValue().
Definition at line 157 of file pruio_timer.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR TimerUdt::Value | ( | BYVAL_AS_UInt8 | Ball, |
BYVAL_AS_Float_t_PTR | Dur1, | ||
BYVAL_AS_Float_t_PTR | Dur2 | ||
) |
Compute timer output.
Ball | The header pin to configure. |
Dur1 | The duration in [ms] low state. |
Dur2 | The duration in [ms] high state. |
This function computes the real values for timer output durations. Since function TimerUdt::setValue() rounds the input parameters to the best matching values, this function can get used to pre-compute the final values, or get the current setting.
In order to read the current setting, pass negative values (or zero) for parameters Dur1
and Dur2
.
Wrapper function (C or Python): pruio_tim_Value().
Definition at line 257 of file pruio_timer.bas.