libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
TimerUdt Class Reference

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.
 

Detailed Description

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.

Since
0.4

Definition at line 72 of file pruio_timer.bi.

Constructor & Destructor Documentation

◆ TimerUdt()

TimerUdt::TimerUdt ( BYVAL_AS_Pruio__PTR  T)

The constructor for the TIMER features.

Parameters
TA 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.

Since
0.4

Definition at line 33 of file pruio_timer.bas.

Here is the caller graph for this function:

Member Function Documentation

◆ initialize()

FUNCTION_CDECL_AS_ZSTRING_PTR TimerUdt::initialize ( )

Initialize the register context after running the pasm_init.p instructions (private).

Returns
0 (zero) on success (may return an error string in future versions).

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.

Since
0.4

Definition at line 64 of file pruio_timer.bas.

Here is the caller graph for this function:

◆ pwm_get()

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).

Parameters
NrThe TIMER subsystem index.
FreqA pointer to output the frequency value (or 0 for no output).
DutyA pointer to output the duty value (or 0 for no output).
Returns
Zero on success, an error string otherwise.

This private functions computes the real PWM configuration of a TIMER subsystem. It's designed to get called from function PwmMod::Value().

Note
This is a private function designed for internal use. It doesn't check the validity of the Nr parameter. Values greater than PRUIO_AZ_GPIO may result in wired behaviour.
Since
0.4

Definition at line 408 of file pruio_timer.bas.

◆ pwm_set()

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).

Parameters
NrThe TIMER subsystem index.
FreqThe frequency to set (or -1 for no change).
DutyThe duty cycle to set (0.0 to 1.0, or -1 for no change).
Returns
Zero on success, an error string otherwise.

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%).

Note
This is a private function designed for internal use. It doesn't check the validity of the Nr parameter. Values greater than PRUIO_AZ_TIMER may result in wired behaviour.
Since
0.4

Definition at line 328 of file pruio_timer.bas.

◆ setValue()

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.

Parameters
BallThe header pin to get timer output from.
Dur1The low period duration in [ms] (or 0 to stop timer).
Dur2The high period duration in [ms] (or 0 for minimal duration).
ModeThe output mode (defaults to &h00).
Returns
Zero on success, an error string otherwise.

This function sets timer output on a header pin. The default output is

  • a low state for the Dur1 period of time, then high state for Dur2, repeating endless.

Parameter Mode allows manipulation of this pulse train:

  • Bit[0] inverts the signal (high first, then low).
  • Bits[1-8] enables one shot mode (pulse train stops after a number of periods).

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].

Note
Each call to this function starts a new timer period (and breaks the current).
Due to hardware limitations, the allowed range for the summ of both Dur1 and Dur2 is limited. See the table in section TIMER for details.
The pulse length is always a multiple of the hardware timer counter period. In order to get low frequencies, the counter gets pre-scaled (= slowed down). This means, the longer the 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.
Currently, for pulse trains generated by TIMER subsystems libpruio uses CLK_M_OSC (24 MHz) input clock only. CLK_32KHZ (32.768 kHz) input clock isn't supported, yet.

Wrapper function (C or Python): pruio_tim_setValue().

Since
0.4

Definition at line 157 of file pruio_timer.bas.

◆ Value()

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.

Parameters
BallThe header pin to configure.
Dur1The duration in [ms] low state.
Dur2The duration in [ms] high state.
Returns
Zero on success, an error string otherwise.

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().

Since
0.4

Definition at line 257 of file pruio_timer.bas.


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