libyggdrasil  v1.0.0
sink_driver.h File Reference

Driver to use the sink drivers. More...

Include dependency graph for sink_driver.h:

Go to the source code of this file.

Enumerations

enum  SinkDriverChannel { SinkDriverChannel_A = 0, SinkDriverChannel_B = 1, SinkDriverChannel_C = 2, SinkDriverChannel_D = 3 }
 Sink Driver Timer Channels. More...
 

Functions

C_LINKAGE void yggdrasil_SinkDriver_Init (void)
 Initialization function. More...
 
C_LINKAGE void yggdrasil_SinkDriver_Servo_Set (enum SinkDriverChannel channel, float percent)
 Set the servo arm rotation in percent relative to its maximal value. More...
 
C_LINKAGE void yggdrasil_SinkDriver_Servo_SetDeltaHighTime (enum SinkDriverChannel channel, u16 delta)
 FUnction to set the high time of the pwm pulse. More...
 
C_LINKAGE void yggdrasil_SinkDriver_PWM_SetDuty (enum SinkDriverChannel channel, float dutyCycle)
 
C_LINKAGE bool yggdrasil_SinkDriver_PWM_SetFrequency (u32 frequency, u16 resolution)
 Set the pwm frequency and (optional) the maximal ticks within on cycle for all channels. More...
 
C_LINKAGE u32 yggdrasil_SinkDriver_PWM_GetFrequency (enum SinkDriverChannel channel)
 Get the pwm frequency. More...
 
C_LINKAGE void yggdrasil_SinkDriver_Out_Set (enum SinkDriverChannel channel, bool state)
 set the sink driver pin state More...
 

Detailed Description

Driver to use the sink drivers.

Author
Fabian Weber, Nikolaij Saegesser

Enumeration Type Documentation

◆ SinkDriverChannel

Sink Driver Timer Channels.

Enumerator
SinkDriverChannel_A 

Timer channel A.

SinkDriverChannel_B 

Timer channel B.

SinkDriverChannel_C 

Timer channel C.

SinkDriverChannel_D 

Timer channel D.

Function Documentation

◆ yggdrasil_SinkDriver_Init()

C_LINKAGE void yggdrasil_SinkDriver_Init ( void  )

Initialization function.

Returns
Success

◆ yggdrasil_SinkDriver_Out_Set()

C_LINKAGE void yggdrasil_SinkDriver_Out_Set ( enum SinkDriverChannel  channel,
bool  state 
)

set the sink driver pin state

Parameters
channelChannel to set
statePin state

◆ yggdrasil_SinkDriver_PWM_GetFrequency()

C_LINKAGE u32 yggdrasil_SinkDriver_PWM_GetFrequency ( enum SinkDriverChannel  channel)

Get the pwm frequency.

Note
The frequency is for all channels the same
Parameters
channelChannel, this is used when not all channels are from the same timer
Returns
Frequency in Hz

◆ yggdrasil_SinkDriver_PWM_SetDuty()

C_LINKAGE void yggdrasil_SinkDriver_PWM_SetDuty ( enum SinkDriverChannel  channel,
float  dutyCycle 
)

◆ yggdrasil_SinkDriver_PWM_SetFrequency()

C_LINKAGE bool yggdrasil_SinkDriver_PWM_SetFrequency ( u32  frequency,
u16  resolution 
)

Set the pwm frequency and (optional) the maximal ticks within on cycle for all channels.

Note
The actual duty cycle for all channels will be restored after the changes
Implement a proper error handling, the function does not guarantee to be successful
Warning
When one channel is used as servo port, the frequency can not be changed
Parameters
frequencynew frequency in hz
resolutionof the pwm, for 0 the actual value will be used
Returns
True when the adjustment was possible, false when the parameter did not match

◆ yggdrasil_SinkDriver_Servo_Set()

C_LINKAGE void yggdrasil_SinkDriver_Servo_Set ( enum SinkDriverChannel  channel,
float  percent 
)

Set the servo arm rotation in percent relative to its maximal value.

Note
The needed high period of pwm signal to reach maximal magnitude can be configured with the setDeltaHighTime() function (This is servo specific)
Warning
If the system clock is not above 200MHz the function might not be able to set the pwm frequency to 50Hz
Parameters
channelChannel which should be changed
percentServo arm rotation in percent from -100% to 100%

◆ yggdrasil_SinkDriver_Servo_SetDeltaHighTime()

C_LINKAGE void yggdrasil_SinkDriver_Servo_SetDeltaHighTime ( enum SinkDriverChannel  channel,
u16  delta 
)

FUnction to set the high time of the pwm pulse.

Parameters
channelChannel which should be changed
deltaHigh time of the pwm pulse in ms