CCAux  2.20.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, uint16_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, uint16_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, uint16_t *status)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getPWMOutputStatus2 (PWMOUTHANDLE, uint8_t channel, uint16_t *status)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_setPWMOutOff (PWMOUTHANDLE, uint8_t channel)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getActiveIomcu (PWMOUTHANDLE, uint8_t *ioindex)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_setActiveIomcu (PWMOUTHANDLE, uint8_t ioindex)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getPWMOutputPU (PWMOUTHANDLE, uint8_t channel, uint16_t *status)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_setPWMOutputPU (PWMOUTHANDLE, uint8_t channel, uint16_t status)
 

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): Yukon, V510, V710

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);
EXTERN_C CCAUXDLL_API PWMOUTHANDLE CCAUXDLL_CALLING_CONV GetPWMOut(void)
EXTERN_C CCAUXDLL_API void CCAUXDLL_CALLING_CONV PWMOut_release(PWMOUTHANDLE)
void * PWMOUTHANDLE
Definition: PWMOut.h:38

◆ PWMOut_getActiveIomcu()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::PWMOut_getActiveIomcu ( PWMOUTHANDLE  ,
uint8_t ioindex 
)

Get active io mcu number

Supported Platform(s): Yukon, V510, V710

Parameters
ioindexIo mcu number, valid values are 1-4.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

uint8_t mcu;
err = PWMOut_getActiveIomcu(pPwmOut, &mcu);
if (err != ERR_SUCCESS)
{
cout << "PWMOut_setActiveIomcu: " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "PWMOut_setActiveIomcu: Active io mcu: " << (int)mcu << std::endl;
}
unsigned char uint8_t
Definition: CCAuxTypes.h:37
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getActiveIomcu(PWMOUTHANDLE, uint8_t *ioindex)
EXTERN_C CCAUXDLL_API char_t const *CCAUXDLL_CALLING_CONV GetErrorStringA(eErr errCode)
@ ERR_SUCCESS
Definition: CCAuxTypes.h:163

◆ PWMOut_getPWMOutputChannelDutyCycle()

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

Get current PWM output duty cycle

Supported Platform(s): Yukon, V510, V710

Parameters
channelChannel to get value from. Numbering starts from 1.
duty_cycleCurrent duty cycle value (0-4095) that corresponds to 0-100%.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

unsigned short 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;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getPWMOutputChannelDutyCycle(PWMOUTHANDLE, uint8_t channel, uint16_t *duty_cycle)

◆ PWMOut_getPWMOutputChannelFrequency()

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

Get current PWM output frequency

Supported Platform(s): Yukon, V510, V710

Parameters
channelChannel to get value from. Numbering starts from 1.
frequencyCurrent frequency in Hz (1.0 - 5000Hz)
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;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getPWMOutputChannelFrequency(PWMOUTHANDLE, uint8_t channel, float32_t *frequency)

◆ PWMOut_getPWMOutputPU()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::PWMOut_getPWMOutputPU ( PWMOUTHANDLE  ,
uint8_t  channel,
uint16_t status 
)

Get pull up resistor status used for open load detection

Supported Platform(s): Yukon, V510, V710

Parameters
channelChannel. Numbering starts from 1.
statusStatus of the pull up resistor for the selected channel. Inactive = 0 Active = 1
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

uint16_t pu_status = 0;
err = PWMOut_getPWMOutputPU(pPwmOut, 1, &pu_status);
if (err != ERR_SUCCESS)
{
cout << "PWMOut_getPWMOutputPU " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "PWMOut_getPWMOutputPU: PWM output pullup resistor status for channel 1 is: " << pu_status << std::endl;
}
unsigned short uint16_t
Definition: CCAuxTypes.h:38
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getPWMOutputPU(PWMOUTHANDLE, uint8_t channel, uint16_t *status)

◆ PWMOut_getPWMOutputStatus()

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

Get PWM Output status for all outputs at once

Supported Platform(s): Yukon, V510, V710

Parameters
statusThe current pwm output status as a bit mask where each channel is represented by one bit. Bit 0 represents PWM output channel 1, Bit 1 represents PWM output channel 2 and so on. If bit is set, it means an error is detected. The output will be turned off when an error is detected. The error status remains until the output is turned off manually or restarted.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

unsigned short 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;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getPWMOutputStatus(PWMOUTHANDLE, uint16_t *status)

◆ PWMOut_getPWMOutputStatus2()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::PWMOut_getPWMOutputStatus2 ( PWMOUTHANDLE  ,
uint8_t  channel,
uint16_t status 
)

Get PWM output status details

Supported Platform(s): Yukon, V510, V710

Parameters
channelChannel to get status for. Numbering starts from 1.
statusOutput channel status details. Note that not all outputs are able to detect all errors. The error status remains until the output is turned off manually or restarted. OK (no error) = 0 Short to ground = 1 Short to battery = 2 Over current = 4 Over temperature = 8 Open load = 16 Generic error = 32
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

err = PWMOut_getPWMOutputStatus2(pPwmOut, 1, &status);
if (err != ERR_SUCCESS)
{
cout << "PWMOut_getPWMOutputStatus2 channel 1 error: " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "PWMOut_getPWMOutputStatus2: Status for channel 1: " << (int)status << std::endl;
}
err = PWMOut_getPWMOutputStatus2(pPwmOut, 2, &status);
if (err != ERR_SUCCESS)
{
cout << "PWMOut_getPWMOutputStatus2 channel 2 error: " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "PWMOut_getPWMOutputStatus2: Status for channel 2: " << (int)status << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_getPWMOutputStatus2(PWMOUTHANDLE, uint8_t channel, uint16_t *status)

◆ PWMOut_release()

EXTERN_C CCAUXDLL_API void CCAUXDLL_CALLING_CONV CrossControl::PWMOut_release ( PWMOUTHANDLE  )

Release the PWMOut object.

Supported Platform(s): Yukon, V510, V710

Returns
-

Example Usage:

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

◆ PWMOut_setActiveIomcu()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::PWMOut_setActiveIomcu ( PWMOUTHANDLE  ,
uint8_t  ioindex 
)

Set active io mcu

Supported Platform(s): Yukon, V510, V710

Parameters
ioindexIo mcu number, valid values are 1-4.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

err = PWMOut_setActiveIomcu(pPwmOut, 1);
if (err != ERR_SUCCESS)
{
cout << "PWMOut_setActiveIomcu: " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "Active io mcu set to 1" << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_setActiveIomcu(PWMOUTHANDLE, uint8_t ioindex)

◆ PWMOut_setPWMOutOff()

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

Turn off PWM output This function sets duty cycle to 0 and frequency to 1 Hz.

Supported Platform(s): Yukon, V510, V710

Parameters
channelChannel to turn off. Numbering starts from 1.
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;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_setPWMOutOff(PWMOUTHANDLE, uint8_t channel)

◆ PWMOut_setPWMOutputChannelDutyCycle()

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

Set PWM output duty cycle

Supported Platform(s): Yukon, V510, V710

Parameters
channelChannel to set. Numbering starts from 1.
duty_cycleDuty cycle value (0-4095) that corresponds to 0-100%.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

err = PWMOut_setPWMOutputChannelDutyCycle(pPwmOut, 1, 2048);
if (err != ERR_SUCCESS)
{
cout << "setPWMOutputChannelDutyCycle: " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "setPWMOutputChannelDutyCycle: channel 1 set to 50% duty cycle" << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_setPWMOutputChannelDutyCycle(PWMOUTHANDLE, uint8_t channel, uint16_t duty_cycle)

◆ PWMOut_setPWMOutputChannelFrequency()

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

Set PWM output frequency

Supported Platform(s): Yukon, V510, V710

Parameters
channelChannel to set. Numbering starts from 1.
frequencyFrequency (1.0 - 5000.0Hz)
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;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_setPWMOutputChannelFrequency(PWMOUTHANDLE, uint8_t channel, float32_t frequency)

◆ PWMOut_setPWMOutputPU()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::PWMOut_setPWMOutputPU ( PWMOUTHANDLE  ,
uint8_t  channel,
uint16_t  status 
)

Activate or deactivate pull up resistor used for open load detection

Supported Platform(s): Yukon, V510, V710

Parameters
channelChannel. Numbering starts from 1.
statusStatus to set. Inactive = 0 Active = 1
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

err = PWMOut_setPWMOutputPU(pPwmOut, 1, 1);
if (err != ERR_SUCCESS)
{
cout << "PWMOut_setPWMOutputPU " << GetErrorStringA(err) << std::endl;
}
else
{
cout << "PWMOut_setPWMOutputPU: PWM output pullup resistor set to 1 (active) for channel 1" << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PWMOut_setPWMOutputPU(PWMOUTHANDLE, uint8_t channel, uint16_t status)