TI-RTOS Drivers  tidrivers_cc13xx_cc26xx_2_16_00_08
PWM.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
168 #ifndef ti_drivers_PWM__include
169 #define ti_drivers_PWM__include
170 
171 #ifdef __cplusplus
172 extern "C" {
173 #endif
174 
175 #include <stdint.h>
176 #include <stddef.h>
177 
195 #define PWM_CMD_RESERVED 32
196 
209 #define PWM_STATUS_RESERVED -32
210 
224 #define PWM_STATUS_SUCCESS 0
225 
232 #define PWM_STATUS_ERROR -1
233 
241 #define PWM_STATUS_UNDEFINEDCMD -2
242 
252 /* Add PWM_CMD_<commands> here */
253 
261 typedef struct PWM_Config *PWM_Handle;
262 
267 typedef enum PWM_DutyMode {
271 } PWM_DutyMode;
272 
277 typedef enum PWM_Polarity {
280 } PWM_Polarity;
281 
290 typedef struct PWM_Params {
291  uint32_t period;
294  uintptr_t custom;
296 } PWM_Params;
297 
302 typedef void (*PWM_CloseFxn) (PWM_Handle handle);
303 
308 typedef int (*PWM_ControlFxn) (PWM_Handle handle,
309  unsigned int cmd,
310  void *arg);
311 
316 typedef unsigned int (*PWM_GetPeriodCountsFxn) (PWM_Handle handle);
317 
322 typedef unsigned int (*PWM_GetPeriodMicroSecsFxn)(PWM_Handle handle);
323 
328 typedef void (*PWM_InitFxn) (PWM_Handle handle);
329 
334 typedef PWM_Handle (*PWM_OpenFxn) (PWM_Handle handle,
335  PWM_Params *params);
336 
341 typedef void (*PWM_SetDutyFxn) (PWM_Handle handle,
342  uint32_t duty);
343 
349 typedef struct PWM_FxnTable {
352 
355 
358 
361 
364 
367 
370 } PWM_FxnTable;
371 
383 typedef struct PWM_Config {
386 
388  void *object;
389 
391  void const *hwAttrs;
392 } PWM_Config;
393 
403 extern void PWM_close(PWM_Handle handle);
404 
442 extern int PWM_control(PWM_Handle handle, unsigned int cmd, void *arg);
443 
453 extern unsigned int PWM_getPeriodCounts(PWM_Handle handle);
454 
464 extern unsigned int PWM_getPeriodMicroSecs(PWM_Handle handle);
465 
474 extern void PWM_init(void);
475 
494 extern PWM_Handle PWM_open(unsigned int index, PWM_Params *params);
495 
507 extern void PWM_Params_init(PWM_Params *params);
508 
518 extern void PWM_setDuty(PWM_Handle handle, uint32_t duty);
519 
520 #ifdef __cplusplus
521 }
522 #endif
523 
524 #endif /* ti_drivers_PWM__include */
PWM_Polarity
Definitions for various PWM output polarity.
Definition: PWM.h:277
PWM_GetPeriodMicroSecsFxn getPeriodMicroSecsFxn
Definition: PWM.h:360
Definition: PWM.h:270
void PWM_close(PWM_Handle handle)
Function to close a PWM peripheral specified by the PWM handle.
uint32_t period
Definition: PWM.h:291
PWM Global configuration.
Definition: PWM.h:383
PWM_OpenFxn openFxn
Definition: PWM.h:366
PWM_SetDutyFxn setDutyFxn
Definition: PWM.h:369
PWM_FxnTable const * fxnTablePtr
Definition: PWM.h:385
PWM_DutyMode dutyMode
Definition: PWM.h:292
PWM_Polarity polarity
Definition: PWM.h:293
PWM_Handle PWM_open(unsigned int index, PWM_Params *params)
This function opens a given PWM peripheral.
uintptr_t custom
Definition: PWM.h:294
struct PWM_Config PWM_Config
PWM Global configuration.
PWM_CloseFxn closeFxn
Definition: PWM.h:351
void(* PWM_SetDutyFxn)(PWM_Handle handle, uint32_t duty)
A function pointer to a driver specific implementation of PWM_setDuty().
Definition: PWM.h:341
void * object
Definition: PWM.h:388
void PWM_init(void)
This function initializes the PWM module.
PWM_GetPeriodCountsFxn getPeriodCountsFxn
Definition: PWM.h:357
struct PWM_Params PWM_Params
PWM Parameters.
void(* PWM_CloseFxn)(PWM_Handle handle)
A function pointer to a driver specific implementation of PWM_close().
Definition: PWM.h:302
int PWM_control(PWM_Handle handle, unsigned int cmd, void *arg)
Function performs implementation specific features on a given PWM_Handle.
The definition of a PWM function table that contains the required set of functions to control a speci...
Definition: PWM.h:349
struct PWM_Config * PWM_Handle
A handle that is returned from a PWM_open() call.
Definition: PWM.h:261
Definition: PWM.h:268
void const * hwAttrs
Definition: PWM.h:391
void PWM_setDuty(PWM_Handle handle, uint32_t duty)
Function to set the duty cycle of the specified PWM handle.
struct PWM_FxnTable PWM_FxnTable
The definition of a PWM function table that contains the required set of functions to control a speci...
void PWM_Params_init(PWM_Params *params)
Function to initialize the PWM_Params struct to its defaults.
PWM_Handle(* PWM_OpenFxn)(PWM_Handle handle, PWM_Params *params)
A function pointer to a driver specific implementation of PWM_open().
Definition: PWM.h:334
PWM Parameters.
Definition: PWM.h:290
Definition: PWM.h:269
unsigned int PWM_getPeriodMicroSecs(PWM_Handle handle)
Get the PWM handle period in microseconds.
void(* PWM_InitFxn)(PWM_Handle handle)
A function pointer to a driver specific implementation of PWM_init().
Definition: PWM.h:328
int(* PWM_ControlFxn)(PWM_Handle handle, unsigned int cmd, void *arg)
A function pointer to a driver specific implementation of PWM_control().
Definition: PWM.h:308
unsigned int(* PWM_GetPeriodCountsFxn)(PWM_Handle handle)
A function pointer to a driver specific implementation of PWM_getPeriodCounts().
Definition: PWM.h:316
PWM_ControlFxn controlFxn
Definition: PWM.h:354
PWM_DutyMode
Definitions for various units for specifying the PWM duty.
Definition: PWM.h:267
Definition: PWM.h:278
unsigned int(* PWM_GetPeriodMicroSecsFxn)(PWM_Handle handle)
A function pointer to a driver specific implementation of PWM_getPeriodMicroSecs().
Definition: PWM.h:322
unsigned int PWM_getPeriodCounts(PWM_Handle handle)
Get the PWM handle period in timer counts.
PWM_InitFxn initFxn
Definition: PWM.h:363
Definition: PWM.h:279
Copyright 2016, Texas Instruments Incorporated