SimpleLink MCU SDK Driver APIs
tidrivers_msp43x_3_01_01_03
|
Capture driver interface.
============================================================================
The Capture header file should be included in an application as follows:
The Capture driver facilitates the capture routines by using general purpose timers. Capture instances must be opened by calling Capture_open() while passing in a Capture index and parameters data structure.
When a capture instance is opened, the capture triggering edge and callback function are configured. The capture is stopped after calling Capture_open() until Capture_start() is called.
When Capture_open() is called, it tries to occupy the user-specified timer by calling Timer_open(). If that timer is already allocated for other modules, NULL is returned. Otherwise, the Capture_Handle is returned.
A capture is triggered based on the user-specified capture mode:
This module serves as the main interface for TI-RTOS applications. Its purpose is to redirect the module's APIs to specific peripheral implementations which are specified using a pointer to a Capture_FxnTable.
The Capture driver interface module is joined (at link time) to a NULL-terminated array of Capture_Config data structures named Capture_Config. Capture_Config is implemented in the application with each entry being an instance of a Capture module. Each entry in Capture_Config contains a:
The Capture driver interface produces log statements if instrumentation is enabled.
Diagnostics Mask | Log details |
---|---|
Diags_USER1 | basic operations performed |
Diags_USER2 | detailed operations performed |
#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
Data Structures | |
struct | Capture_Params_ |
Capture Parameters. More... | |
struct | Capture_FxnTable_ |
The definition of a Capture function table that contains the required set of functions to control a specific Capture driver implementation. More... | |
struct | Capture_Config_ |
Macros | |
#define | CAPTURE_CMD_RESERVED (32) |
#define | CAPTURE_STATUS_RESERVED (-32) |
#define | CAPTURE_STATUS_SUCCESS (0) |
Successful status code returned by Capture_control(). More... | |
#define | CAPTURE_STATUS_ERROR (-1) |
Generic error status code returned by Capture_control(). More... | |
#define | CAPTURE_STATUS_UNDEFINEDCMD (-2) |
An error status code returned by Capture_control() for undefined command codes. More... | |
Typedefs | |
typedef struct Capture_Config_ * | Capture_Handle |
A handle that is returned from a Capture_open() call. More... | |
typedef enum Capture_Period_Unit_ | Capture_Period_Unit |
Capture period unit enum. More... | |
typedef enum Capture_Mode_ | Capture_Mode |
Capture mode enum. More... | |
typedef void(* | Capture_CallBackFxn) (Capture_Handle handle, uint32_t interval) |
Capture callback function. More... | |
typedef struct Capture_Params_ | Capture_Params |
Capture Parameters. More... | |
typedef void(* | Capture_CloseFxn) (Capture_Handle handle) |
A function pointer to a driver specific implementation of Capture_close(). More... | |
typedef int_fast16_t(* | Capture_ControlFxn) (Capture_Handle handle, uint_fast16_t cmd, void *arg) |
A function pointer to a driver specific implementation of Capture_control(). More... | |
typedef void(* | Capture_InitFxn) (Capture_Handle handle) |
A function pointer to a driver specific implementation of Capture_init(). More... | |
typedef Capture_Handle(* | Capture_OpenFxn) (Capture_Handle handle, Capture_Params *params) |
A function pointer to a driver specific implementation of Capture_open(). More... | |
typedef void(* | Capture_StartFxn) (Capture_Handle handle) |
A function pointer to a driver specific implementation of Capture_start(). More... | |
typedef void(* | Capture_StopFxn) (Capture_Handle handle) |
A function pointer to a driver specific implementation of Capture_stop(). More... | |
typedef struct Capture_FxnTable_ | Capture_FxnTable |
The definition of a Capture function table that contains the required set of functions to control a specific Capture driver implementation. More... | |
typedef struct Capture_Config_ | Capture_Config |
Enumerations | |
enum | Capture_Period_Unit_ { CAPTURE_PERIOD_US, CAPTURE_PERIOD_HZ, CAPTURE_PERIOD_COUNTS } |
Capture period unit enum. More... | |
enum | Capture_Mode_ { CAPTURE_MODE_RISING_RISING, CAPTURE_MODE_FALLING_FALLING, CAPTURE_MODE_ANY_EDGE } |
Capture mode enum. More... | |
Functions | |
void | Capture_close (Capture_Handle handle) |
Function to close a Capture module specified by the Capture handle. More... | |
int_fast16_t | Capture_control (Capture_Handle handle, uint_fast16_t cmd, void *arg) |
Function performs implementation specific features on a given Capture_Handle. More... | |
void | Capture_init (void) |
Function to initialize Capture. More... | |
Capture_Handle | Capture_open (uint_least8_t index, Capture_Params *params) |
Function to initialize a given Capture module specified by the particular index value. The parameter specifies which mode the Capture will operate. More... | |
void | Capture_Params_init (Capture_Params *params) |
Function to initialize the Capture_Params struct to its defaults. More... | |
void | Capture_start (Capture_Handle handle) |
Function to start capture. The Capture running mode and interval period unit are specfied in the Capture_Params when calling Capture_open(). More... | |
void | Capture_stop (Capture_Handle handle) |
Function to stop Capture after Capture_start() is called with success. More... | |
#define CAPTURE_CMD_RESERVED (32) |
Common Capture_control command code reservation offset. Capture driver implementations should offset command codes with CAPTURE_CMD_RESERVED growing positively
Example implementation specific command codes:
#define CAPTURE_STATUS_RESERVED (-32) |
Common Capture_control status code reservation offset. Capture driver implementations should offset status codes with CAPTURE_STATUS_RESERVED growing negatively.
Example implementation specific status codes:
#define CAPTURE_STATUS_SUCCESS (0) |
Successful status code returned by Capture_control().
Capture_control() returns TIMER_STATUS_SUCCESS if the control code was executed successfully.
#define CAPTURE_STATUS_ERROR (-1) |
Generic error status code returned by Capture_control().
Capture_control() returns CAPTURE_STATUS_ERROR if the control code was not executed successfully.
#define CAPTURE_STATUS_UNDEFINEDCMD (-2) |
An error status code returned by Capture_control() for undefined command codes.
Capture_control() returns TIMER_STATUS_UNDEFINEDCMD if the control code is not recognized by the driver implementation.
typedef struct Capture_Config_* Capture_Handle |
A handle that is returned from a Capture_open() call.
typedef enum Capture_Period_Unit_ Capture_Period_Unit |
Capture period unit enum.
The Capture period unit needs to be passed in Capture_open() to specify the unit of two capture triggering interval.
typedef enum Capture_Mode_ Capture_Mode |
Capture mode enum.
The Capture mode needs to be passed in Capture_open() to specify the capture triggering mode.
typedef void(* Capture_CallBackFxn) (Capture_Handle handle, uint32_t interval) |
Capture callback function.
User definable callback function prototype. The Capture driver will call the defined function and pass in the Capture driver's handle and the pointer to the user-specified the argument.
handle | Capture_Handle |
interval | Interval of two triggering edge in Capture_Period_Unit |
typedef struct Capture_Params_ Capture_Params |
Capture Parameters.
Capture parameters are used to with the Capture_open() call. Default values for these parameters are set using Capture_Params_init().
typedef void(* Capture_CloseFxn) (Capture_Handle handle) |
A function pointer to a driver specific implementation of Capture_close().
typedef int_fast16_t(* Capture_ControlFxn) (Capture_Handle handle, uint_fast16_t cmd, void *arg) |
A function pointer to a driver specific implementation of Capture_control().
typedef void(* Capture_InitFxn) (Capture_Handle handle) |
A function pointer to a driver specific implementation of Capture_init().
typedef Capture_Handle(* Capture_OpenFxn) (Capture_Handle handle, Capture_Params *params) |
A function pointer to a driver specific implementation of Capture_open().
typedef void(* Capture_StartFxn) (Capture_Handle handle) |
A function pointer to a driver specific implementation of Capture_start().
typedef void(* Capture_StopFxn) (Capture_Handle handle) |
A function pointer to a driver specific implementation of Capture_stop().
typedef struct Capture_FxnTable_ Capture_FxnTable |
The definition of a Capture function table that contains the required set of functions to control a specific Capture driver implementation.
typedef struct Capture_Config_ Capture_Config |
enum Capture_Period_Unit_ |
Capture period unit enum.
The Capture period unit needs to be passed in Capture_open() to specify the unit of two capture triggering interval.
Enumerator | |
---|---|
CAPTURE_PERIOD_US | |
CAPTURE_PERIOD_HZ | |
CAPTURE_PERIOD_COUNTS |
enum Capture_Mode_ |
Capture mode enum.
The Capture mode needs to be passed in Capture_open() to specify the capture triggering mode.
void Capture_close | ( | Capture_Handle | handle | ) |
Function to close a Capture module specified by the Capture handle.
The function takes care of timer resource allocation. The corresponding timer resource to the Capture_Handle is released to be an available timer resource.
handle | A Capture_Handle returned from Capture_open |
int_fast16_t Capture_control | ( | Capture_Handle | handle, |
uint_fast16_t | cmd, | ||
void * | arg | ||
) |
Function performs implementation specific features on a given Capture_Handle.
handle | A Capture_Handle returned from Capture_open(). |
cmd | A command value defined by the driver specific implementation. |
arg | A pointer to an optional R/W (read/write) argument that is accompanied with cmd. |
void Capture_init | ( | void | ) |
Function to initialize Capture.
Capture_Handle Capture_open | ( | uint_least8_t | index, |
Capture_Params * | params | ||
) |
Function to initialize a given Capture module specified by the particular index value. The parameter specifies which mode the Capture will operate.
The function takes care of timer resource allocation. If the particular timer passed by user has already been used by other modules, the return value is NULL. If the particular timer is available to use, Capture module owns it and returns a Capture_Handle.
index | Logical instance number for the Capture indexed into the Capture_config table |
params | Pointer to an parameter block, if NULL it will use default values. All the fields in this structure are RO (read-only). |
void Capture_Params_init | ( | Capture_Params * | params | ) |
Function to initialize the Capture_Params struct to its defaults.
params | An pointer to Capture_Params structure for initialization |
Defaults values are: mode = CAPTURE_MODE_RISING_RISING callbackFxn = user_specified_callbackFxn periodUnit = Capture_PERIOD_COUNTS
void Capture_start | ( | Capture_Handle | handle | ) |
Function to start capture. The Capture running mode and interval period unit are specfied in the Capture_Params when calling Capture_open().
handle | Capture_Handle |
void Capture_stop | ( | Capture_Handle | handle | ) |
Function to stop Capture after Capture_start() is called with success.
handle | Capture_Handle |