SimpleLink MCU SDK Driver APIs  tidrivers_msp43x_3_01_01_03
Timer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, 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  */
114 #ifndef ti_drivers_Timer__include
115 #define ti_drivers_Timer__include
116 
117 #include <stdint.h>
118 
119 #ifdef __cplusplus
120 extern "C"
121 {
122 #endif
123 
127 typedef struct Timer_Config_ *Timer_Handle;
128 
140 #define TIMER_CMD_RESERVED (32)
141 
154 #define TIMER_STATUS_RESERVED (-32)
155 
162 #define TIMER_STATUS_SUCCESS (0)
163 
170 #define TIMER_STATUS_ERROR (-1)
171 
179 #define TIMER_STATUS_UNDEFINEDCMD (-2)
180 
188 typedef enum Timer_Mode_
189 {
197 } Timer_Mode;
198 
207 {
208  TIMER_PERIOD_US, /* Period in microseconds */
209  TIMER_PERIOD_HZ, /* Period in frequency */
210  TIMER_PERIOD_COUNTS /* Period in counts */
212 
222 typedef void (*Timer_CallBackFxn)(Timer_Handle handle);
223 
231 typedef struct Timer_Params_
232 {
236  uint32_t period;
237 } Timer_Params;
238 
243 typedef int_fast16_t (*Timer_ControlFxn)(Timer_Handle handle, uint_fast16_t cmd,
244  void *arg);
245 
250 typedef void (*Timer_CloseFxn)(Timer_Handle handle);
251 
256 typedef uint32_t (*Timer_GetCountFxn)(Timer_Handle handle);
257 
262 typedef void (*Timer_InitFxn)(Timer_Handle handle);
263 
268 typedef Timer_Handle (*Timer_OpenFxn)(Timer_Handle handle,
269  Timer_Params *params);
270 
275 typedef void (*Timer_StartFxn)(Timer_Handle handle);
276 
281 typedef void (*Timer_StopFxn)(Timer_Handle handle);
282 
288 typedef struct Timer_FxnTable_
289 {
305 
306 typedef struct Timer_Config_
307 {
309  void *object;
310  void const *hwAttrs;
311 } Timer_Config;
312 
332 extern int_fast16_t Timer_control(Timer_Handle handle, uint_fast16_t cmd,
333  void *arg);
334 
335 
348 extern void Timer_close(Timer_Handle handle);
349 
362 extern uint32_t Timer_getCount(Timer_Handle handle);
363 
364 
371 extern void Timer_init(void);
372 
396 extern Timer_Handle Timer_open(uint_least8_t index, Timer_Params *params);
397 
410 extern void Timer_Params_init(Timer_Params *params);
411 
423 extern void Timer_start(Timer_Handle handle);
424 
431 extern void Timer_stop(Timer_Handle handle);
432 
433 #ifdef __cplusplus
434 }
435 #endif
436 
437 #endif /* ti_driver_Timer__include */
Timer_Mode timerMode
Definition: Timer.h:233
Timer_FxnTable const * fxnTablePtr
Definition: Timer.h:308
Timer_Handle(* Timer_OpenFxn)(Timer_Handle handle, Timer_Params *params)
A function pointer to a driver specific implementation of Timer_open().
Definition: Timer.h:268
struct Timer_FxnTable_ Timer_FxnTable
The definition of a Timer function table that contains the required set of functions to control a spe...
Timer Parameters.
Definition: Timer.h:231
The definition of a Timer function table that contains the required set of functions to control a spe...
Definition: Timer.h:288
void(* Timer_StartFxn)(Timer_Handle handle)
A function pointer to a driver specific implementation of Timer_start().
Definition: Timer.h:275
Timer_Handle Timer_open(uint_least8_t index, Timer_Params *params)
Function to initialize a given Timer peripheral specified by the particular index value...
Timer_Mode_
Timer mode enum.
Definition: Timer.h:188
void Timer_init(void)
Function to initialize a timer module. This function will go through all available hardware resources...
struct Timer_Config_ Timer_Config
void const * hwAttrs
Definition: Timer.h:310
void Timer_Params_init(Timer_Params *params)
Function to initialize the Timer_Params struct to its defaults.
Definition: Timer.h:306
Timer_OpenFxn openFxn
Definition: Timer.h:299
uint32_t(* Timer_GetCountFxn)(Timer_Handle handle)
A function pointer to a driver specific implementation of Timer_getCount().
Definition: Timer.h:256
enum Timer_Mode_ Timer_Mode
Timer mode enum.
Timer_CloseFxn closeFxn
Definition: Timer.h:291
Definition: Timer.h:196
uint32_t period
Definition: Timer.h:236
void Timer_close(Timer_Handle handle)
Function to close a Timer peripheral specified by the Timer handle.
Timer_StartFxn startFxn
Definition: Timer.h:301
Definition: Timer.h:190
Timer_GetCountFxn getCountFxn
Definition: Timer.h:295
enum Timer_Period_Units_ Timer_Period_Units
Timer period unit enum.
void Timer_start(Timer_Handle handle)
Function to start Timer with the given period. The timer running mode and interval period unit are sp...
void(* Timer_CloseFxn)(Timer_Handle handle)
A function pointer to a driver specific implementation of Timer_close().
Definition: Timer.h:250
Timer_Period_Units periodUnits
Definition: Timer.h:234
void * object
Definition: Timer.h:309
void(* Timer_StopFxn)(Timer_Handle handle)
A function pointer to a driver specific implementation of Timer_stop().
Definition: Timer.h:281
int_fast16_t Timer_control(Timer_Handle handle, uint_fast16_t cmd, void *arg)
Function performs implementation specific features on a given Timer_Handle.
uint32_t Timer_getCount(Timer_Handle handle)
Function to get the current count of a started timer.
Definition: Timer.h:194
Definition: Timer.h:192
Timer_ControlFxn controlFxn
Definition: Timer.h:293
void Timer_stop(Timer_Handle handle)
Function to stop timer after Timer_start() is called with success.
Timer_StopFxn stopFxn
Definition: Timer.h:303
Definition: Timer.h:209
Definition: Timer.h:210
struct Timer_Params_ Timer_Params
Timer Parameters.
Timer_InitFxn initFxn
Definition: Timer.h:297
Timer_CallBackFxn timerCallback
Definition: Timer.h:235
int_fast16_t(* Timer_ControlFxn)(Timer_Handle handle, uint_fast16_t cmd, void *arg)
A function pointer to a driver specific implementation of Timer_control().
Definition: Timer.h:243
void(* Timer_CallBackFxn)(Timer_Handle handle)
Timer callback function.
Definition: Timer.h:222
void(* Timer_InitFxn)(Timer_Handle handle)
A function pointer to a driver specific implementation of Timer_init().
Definition: Timer.h:262
Timer_Period_Units_
Timer period unit enum.
Definition: Timer.h:206
Definition: Timer.h:208
struct Timer_Config_ * Timer_Handle
A handle that is returned from a Timer_open() call.
Definition: Timer.h:127
Copyright 2016, Texas Instruments Incorporated