WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
PWM.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9#include "wpi/hal/Types.h"
10
11/**
12 * @defgroup hal_pwm PWM Output Functions
13 * @ingroup hal_capi
14 * @{
15 */
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/**
22 * Initializes a PWM port.
23 *
24 * @param[in] channel the smartio channel
25 * @param[in] allocationLocation the location where the allocation is occurring
26 * (can be null)
27 * @param[out] status Error status variable. 0 on success.
28 * @return the created pwm handle
29 */
31 const char* allocationLocation,
32 int32_t* status);
33
34/**
35 * Frees a PWM port.
36 *
37 * @param[in] pwmPortHandle the pwm handle
38 */
40
41/**
42 * Checks if a pwm channel is valid.
43 *
44 * @param channel the channel to check
45 * @return true if the channel is valid, otherwise false
46 */
48
49/**
50 * Indicates the pwm is used by a simulated device.
51 *
52 * @param handle the pwm handle
53 * @param device simulated device handle
54 */
56
57/**
58 * Sets a PWM channel to the desired pulse width in microseconds.
59 *
60 *
61 * @param[in] pwmPortHandle the PWM handle
62 * @param[in] microsecondPulseTime the PWM value to set
63 * @param[out] status Error status variable. 0 on success.
64 */
66 int32_t microsecondPulseTime,
67 int32_t* status);
68
69/**
70 * Gets the current microsecond pulse time from a PWM channel.
71 *
72 * @param[in] pwmPortHandle the PWM handle
73 * @param[out] status Error status variable. 0 on success.
74 * @return the current PWM microsecond pulse time
75 */
77 int32_t* status);
78
79/**
80 * Sets the PWM output period.
81 *
82 * @param[in] pwmPortHandle the PWM handle.
83 * @param[in] period 0 for 5ms, 1 or 2 for 10ms, 3 for 20ms
84 * @param[out] status Error status variable. 0 on success.
85 */
86void HAL_SetPWMOutputPeriod(HAL_DigitalHandle pwmPortHandle, int32_t period,
87 int32_t* status);
88#ifdef __cplusplus
89} // extern "C"
90#endif
91/** @} */
void HAL_SetPWMPulseTimeMicroseconds(HAL_DigitalHandle pwmPortHandle, int32_t microsecondPulseTime, int32_t *status)
Sets a PWM channel to the desired pulse width in microseconds.
void HAL_SetPWMOutputPeriod(HAL_DigitalHandle pwmPortHandle, int32_t period, int32_t *status)
Sets the PWM output period.
HAL_DigitalHandle HAL_InitializePWMPort(int32_t channel, const char *allocationLocation, int32_t *status)
Initializes a PWM port.
void HAL_SetPWMSimDevice(HAL_DigitalHandle handle, HAL_SimDeviceHandle device)
Indicates the pwm is used by a simulated device.
HAL_Bool HAL_CheckPWMChannel(int32_t channel)
Checks if a pwm channel is valid.
int32_t HAL_GetPWMPulseTimeMicroseconds(HAL_DigitalHandle pwmPortHandle, int32_t *status)
Gets the current microsecond pulse time from a PWM channel.
void HAL_FreePWMPort(HAL_DigitalHandle pwmPortHandle)
Frees a PWM port.
int32_t HAL_Bool
Definition Types.h:75
HAL_Handle HAL_SimDeviceHandle
Definition Types.h:53
HAL_Handle HAL_DigitalHandle
Definition Types.h:31