TI-RTOS for SimpleLink Wireless MCUs  2.14.03.28
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  */
174 #ifndef ti_drivers_PWM__include
175 #define ti_drivers_PWM__include
176 
177 #ifdef __cplusplus
178 extern "C" {
179 #endif
180 
181 #include <stdint.h>
182 #include <stddef.h>
183 
195 #define PWM_CMD_RESERVED 32
196 
209 #define PWM_STATUS_RESERVED -32
210 
217 #define PWM_STATUS_SUCCESS 0
218 
225 #define PWM_STATUS_ERROR -1
226 
234 #define PWM_STATUS_UNDEFINEDCMD -2
235 
239 typedef struct PWM_Config *PWM_Handle;
240 
245 typedef enum PWM_DutyMode {
249 } PWM_DutyMode;
250 
255 typedef enum PWM_Polarity {
258 } PWM_Polarity;
259 
268 typedef struct PWM_Params {
269  uint32_t period;
272  void *custom;
274 } PWM_Params;
275 
280 typedef void (*PWM_CloseFxn) (PWM_Handle handle);
281 
286 typedef int (*PWM_ControlFxn) (PWM_Handle handle,
287  unsigned int cmd,
288  void *arg);
289 
294 typedef unsigned int (*PWM_GetPeriodCountsFxn) (PWM_Handle handle);
295 
300 typedef unsigned int (*PWM_GetPeriodMicroSecsFxn)(PWM_Handle handle);
301 
306 typedef void (*PWM_InitFxn) (PWM_Handle handle);
307 
312 typedef PWM_Handle (*PWM_OpenFxn) (PWM_Handle handle,
313  PWM_Params *params);
314 
319 typedef void (*PWM_SetDutyFxn) (PWM_Handle handle,
320  uint32_t duty);
321 
327 typedef struct PWM_FxnTable {
330 
333 
336 
339 
342 
345 
348 } PWM_FxnTable;
349 
361 typedef struct PWM_Config {
364 
366  void *object;
367 
369  void const *hwAttrs;
370 } PWM_Config;
371 
381 extern void PWM_close(PWM_Handle handle);
382 
402 extern int PWM_control(PWM_Handle handle, unsigned int cmd, void *arg);
403 
413 extern unsigned int PWM_getPeriodCounts(PWM_Handle handle);
414 
424 extern unsigned int PWM_getPeriodMicroSecs(PWM_Handle handle);
425 
434 extern void PWM_init(void);
435 
454 extern PWM_Handle PWM_open(unsigned int index, PWM_Params *params);
455 
467 extern void PWM_Params_init(PWM_Params *params);
468 
478 extern void PWM_setDuty(PWM_Handle handle, uint32_t duty);
479 
480 #ifdef __cplusplus
481 }
482 #endif
483 
484 #endif /* ti_drivers_PWM__include */
PWM_Polarity
Definitions for various PWM output polarity.
Definition: PWM.h:255
PWM_GetPeriodMicroSecsFxn getPeriodMicroSecsFxn
Definition: PWM.h:338
Definition: PWM.h:248
void PWM_close(PWM_Handle handle)
Function to close a PWM peripheral specified by the PWM handle.
uint32_t period
Definition: PWM.h:269
PWM Global configuration.
Definition: PWM.h:361
PWM_OpenFxn openFxn
Definition: PWM.h:344
PWM_SetDutyFxn setDutyFxn
Definition: PWM.h:347
PWM_FxnTable const * fxnTablePtr
Definition: PWM.h:363
PWM_DutyMode dutyMode
Definition: PWM.h:270
PWM_Polarity polarity
Definition: PWM.h:271
PWM_Handle PWM_open(unsigned int index, PWM_Params *params)
This function opens a given PWM peripheral.
struct PWM_Config PWM_Config
PWM Global configuration.
PWM_CloseFxn closeFxn
Definition: PWM.h:329
void(* PWM_SetDutyFxn)(PWM_Handle handle, uint32_t duty)
A function pointer to a driver specific implementation of PWM_setDuty().
Definition: PWM.h:319
void * object
Definition: PWM.h:366
void PWM_init(void)
This function initializes the PWM module.
PWM_GetPeriodCountsFxn getPeriodCountsFxn
Definition: PWM.h:335
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:280
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:327
struct PWM_Config * PWM_Handle
A handle that is returned from a PWM_open() call.
Definition: PWM.h:239
Definition: PWM.h:246
void const * hwAttrs
Definition: PWM.h:369
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:312
PWM Parameters.
Definition: PWM.h:268
Definition: PWM.h:247
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:306
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:286
unsigned int(* PWM_GetPeriodCountsFxn)(PWM_Handle handle)
A function pointer to a driver specific implementation of PWM_getPeriodCounts().
Definition: PWM.h:294
PWM_ControlFxn controlFxn
Definition: PWM.h:332
PWM_DutyMode
Definitions for various units for specifying the PWM duty.
Definition: PWM.h:245
Definition: PWM.h:256
unsigned int(* PWM_GetPeriodMicroSecsFxn)(PWM_Handle handle)
A function pointer to a driver specific implementation of PWM_getPeriodMicroSecs().
Definition: PWM.h:300
unsigned int PWM_getPeriodCounts(PWM_Handle handle)
Get the PWM handle period in timer counts.
PWM_InitFxn initFxn
Definition: PWM.h:341
Definition: PWM.h:257
void * custom
Definition: PWM.h:272
Copyright 2015, Texas Instruments Incorporated