CCAux  2.17.0.0
CCAux API reference
Functions
PWMOut functions

Functions

EXTERN_C CCAUXDLL_API PWMOUTHANDLE CCAUXDLL_CALLING_CONV GetPWMOut (void)
 
EXTERN_C CCAUXDLL_API void CCAUXDLL_CALLING_CONV PWMOut_release (PWMOUTHANDLE)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_setPWMOutputChannelDutyCycle (PWMOUTHANDLE, uint8_t channel, uint8_t duty_cycle)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_setPWMOutputChannelFrequency (PWMOUTHANDLE, uint8_t channel, float32_t frequency)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getPWMOutputChannelDutyCycle (PWMOUTHANDLE, uint8_t channel, uint8_t *duty_cycle)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getPWMOutputChannelFrequency (PWMOUTHANDLE, uint8_t channel, float32_t *frequency)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getPWMOutputStatus (PWMOUTHANDLE, uint8_t *status)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_setPWMOutOff (PWMOUTHANDLE, uint8_t channel)
 

Detailed Description

Functions in the PWMOut class

Function Documentation

◆ GetPWMOut()

EXTERN_C CCAUXDLL_API PWMOUTHANDLE CCAUXDLL_CALLING_CONV CrossControl::GetPWMOut ( void  )

Factory function that creates instances of the PWMOut object.

Supported Platform(s): VC, VA, VI2

Returns
PWMOUTHANDLE to an allocated PWMOut object. The returned handle needs to be deallocated using the PWMOut_release(PWMOUTHANDLE) method when it's no longer needed. Returns NULL if it fails to allocate memory.

Example Usage:

assert(pPwmOut);
pwmout_example(pPwmOut);
PWMOut_release(pPwmOut);

◆ PWMOut_getPWMOutputChannelDutyCycle()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::PWMOut_getPWMOutputChannelDutyCycle ( PWMOUTHANDLE  ,
uint8_t  channel,
uint8_t duty_cycle 
)

Get PWM Output channel duty cycle

Supported Platform(s): VC, VA, VI2

Parameters
channelWhich channel to get value from There are two output channels, 1 or 2.
duty_cycleThe read back duty cycle value NOTE: For low side PWM outputs, a duty cycle of 60% means 60% low, 40% high For high side PWM outputs, a duty cycle of 60% means 60% high, 40% low
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

unsigned char duty;
err = PWMOut_getPWMOutputChannelDutyCycle(pPwmOut, 1, &duty);
if (err != ERR_SUCCESS)
{
cout << "PWMOut_getPWMOutputChannelDutyCycle: " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "PWMOut_getPWMOutputChannelDutyCycle channel 1: " << (int)duty << "% duty cycle" << std::endl;
}

◆ PWMOut_getPWMOutputChannelFrequency()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::PWMOut_getPWMOutputChannelFrequency ( PWMOUTHANDLE  ,
uint8_t  channel,
float32_t frequency 
)

Get PWM Output frequency for a channel

Supported Platform(s): VC, VA, VI2

Parameters
channelWhich channel to set There are two output channels, 1 or 2.
frequency0.0 - 5000.0 Hz frequency value
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

float frequency;
err = PWMOut_getPWMOutputChannelFrequency(pPwmOut, 1, &frequency);
if (err != ERR_SUCCESS)
{
cout << "PWMOut_getPWMOutputChannelFrequency: " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "PWMOut_getPWMOutputChannelFrequency channel 1: " << std::fixed << frequency << "Hz" << std::endl;
}

◆ PWMOut_getPWMOutputStatus()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::PWMOut_getPWMOutputStatus ( PWMOUTHANDLE  ,
uint8_t status 
)

Get PWM Output status

Supported Platform(s): VC, VA, VI2

Parameters
statusRead back status value Bit 0 represents PWM Output channel 1. Bit 1 represents PWM Output channel 2. If bit is set, it means unconnected, short to ground or over temperature detected. The output will be turned off when the error occurrs. The error status remains until the output is turned on successfully.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

unsigned char status;
err = PWMOut_getPWMOutputStatus(pPwmOut, &status);
if (err != ERR_SUCCESS)
{
cout << "PWMOut_getPWMOutputStatus: " << GetErrorStringA(err) << std::endl;
}
else
{
if (status & 0x01)
cout << "PWMOut_getPWMOutputStatus: Status Not OK for channel 1" << std::endl;
if (status & 0x02)
cout << "PWMOut_getPWMOutputStatus: Status Not OK for channel 2" << std::endl;
if ((status & 0x03) == 0)
cout << "PWMOut_getPWMOutputStatus: Status OK for both channels" << std::endl;
}

◆ PWMOut_release()

EXTERN_C CCAUXDLL_API void CCAUXDLL_CALLING_CONV CrossControl::PWMOut_release ( PWMOUTHANDLE  )

Delete the PWMOut object.

Supported Platform(s): VC, VA, VI2

Returns
-

Example Usage:

assert(pPwmOut);
pwmout_example(pPwmOut);
PWMOut_release(pPwmOut);

◆ PWMOut_setPWMOutOff()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::PWMOut_setPWMOutOff ( PWMOUTHANDLE  ,
uint8_t  channel 
)

Turn off a PWM Output channel. This function sets both frequency and duty cycle to 0.

Supported Platform(s): VC, VA, VI2

Parameters
channelWhich channel to set
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

err = PWMOut_setPWMOutOff(pPwmOut, 1);
if (err != ERR_SUCCESS)
{
cout << "PWMOut_setPWMOutOff: " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "PWMOut_setPWMOutOff channel 1 turned off" << std::endl;
}

◆ PWMOut_setPWMOutputChannelDutyCycle()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::PWMOut_setPWMOutputChannelDutyCycle ( PWMOUTHANDLE  ,
uint8_t  channel,
uint8_t  duty_cycle 
)

Set PWM Output Duty cycle for a channel

Supported Platform(s): VC, VA, VI2

Parameters
channelWhich channel to set There are two output channels, 1 or 2.
duty_cycleWhich duty cycle (0-100 %) to use NOTE: For low side PWM outputs, a duty cycle of 60% means 60% low, 40% high For high side PWM outputs, a duty cycle of 60% means 60% high, 40% low
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

err = PWMOut_setPWMOutputChannelDutyCycle(pPwmOut, 1, 50);
if (err != ERR_SUCCESS)
{
cout << "setPWMOutputChannelDutyCycle: " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "setPWMOutputChannelDutyCycle: channel 1 set to 50% duty cycle" << std::endl;
}

◆ PWMOut_setPWMOutputChannelFrequency()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::PWMOut_setPWMOutputChannelFrequency ( PWMOUTHANDLE  ,
uint8_t  channel,
float32_t  frequency 
)

Set PWM Output frequency for a channel

Supported Platform(s): VC, VA, VI2

Parameters
channelWhich channel to set There are two output channels, 1 or 2.
frequency0.0 - 5000.0 Hz frequency value
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

err = PWMOut_setPWMOutputChannelFrequency(pPwmOut, 1, (float)100.0);
if (err != ERR_SUCCESS)
{
cout << "PWMOut_setPWMOutputChannelFrequency: " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "PWMOut_setPWMOutputChannelFrequency: channel 1 set to 100Hz" << std::endl;
}