TI-RTOS Drivers  tidrivers_full_2_20_00_08
Data Structures | Macros | Typedefs | Enumerations | Functions
Camera.h File Reference

Detailed Description

Camera driver interface.

============================================================================

The Camera header file should be included in an application as follows:

Operation

The Camera driver is used to retrieve the data being transferred by the Camera sensor. This driver provides API for capturing the image from the Camera sensor. The camera sensor control and implementation is the responsibility of the application using the interface.

The application initializes the Camera driver by calling Camera_init() and is then ready to open a Camera by calling Camera_open() and passing in a Camera parameters data structure.

The APIs in this driver serve as an interface to a typical TI-RTOS application. The specific peripheral implementations are responsible to create all the OSAL specific primitives to allow for thread-safe operation.

Opening the driver

< Change any other params as required >
handle = Camera_open(someCamera_configIndexValue, &params);
if (!handle) {
System_printf("Camera did not open");
}

Capturing image

unsigned char captureBuffer[1920];
ret = Camera_capture(handle,&captureBuffer, sizeof(captureBuffer));

Implementation

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 Camera_FxnTable.

The Camera driver interface module is joined (at link time) to a NULL-terminated array of Camera_Config data structures named Camera_config. Camera_config is implemented in the application with each entry being an instance of a Camera peripheral. Each entry in Camera_config contains a:


#include <stdint.h>
#include <stddef.h>
Include dependency graph for Camera.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Camera_Params
 Camera Parameters. More...
 
struct  Camera_FxnTable
 The definition of a Camera function table that contains the required set of functions to control a specific Camera driver implementation. More...
 
struct  Camera_Config
 Camera Global configuration. More...
 

Macros

#define CAMERA_CMD_RESERVED   32
 
#define CAMERA_STATUS_RESERVED   -32
 
#define CAMERA_STATUS_SUCCESS   0
 Successful status code returned by Camera_control(). More...
 
#define CAMERA_STATUS_ERROR   -1
 Generic error status code returned by Camera_control(). More...
 
#define CAMERA_STATUS_UNDEFINEDCMD   -2
 An error status code returned by Camera_control() for undefined command codes. More...
 
#define Camera_WAIT_FOREVER   ~(0)
 Wait forever define. More...
 

Typedefs

typedef struct Camera_ConfigCamera_Handle
 A handle that is returned from a Camera_open() call. More...
 
typedef void(* Camera_Callback) (Camera_Handle, void *buf, size_t bufferLength)
 The definition of a callback function used by the Camera driver when used in Camera_MODE_CALLBACK. More...
 
typedef enum Camera_CaptureMode Camera_CaptureMode
 Camera capture mode settings. More...
 
typedef enum Camera_HSyncPolarity Camera_HSyncPolarity
 Camera HSync polarity. More...
 
typedef enum Camera_VSyncPolarity Camera_VSyncPolarity
 Camera VSync polarity. More...
 
typedef enum Camera_PixelClkConfig Camera_PixelClkConfig
 Camera pixel clock configuration. More...
 
typedef enum Camera_ByteOrder Camera_ByteOrder
 Camera byte order. More...
 
typedef enum Camera_IfSynchoronisation Camera_IfSynchoronisation
 Camera interface synchoronisation. More...
 
typedef enum Camera_StopCaptureConfig Camera_StopCaptureConfig
 Camera stop capture configuration. More...
 
typedef enum Camera_StartCaptureConfig Camera_StartCaptureConfig
 Camera start capture configuration. More...
 
typedef struct Camera_Params Camera_Params
 Camera Parameters. More...
 
typedef void(* Camera_CloseFxn) (Camera_Handle handle)
 A function pointer to a driver specific implementation of Camera_close(). More...
 
typedef int(* Camera_ControlFxn) (Camera_Handle handle, unsigned int cmd, void *arg)
 A function pointer to a driver specific implementation of Camera_control(). More...
 
typedef void(* Camera_InitFxn) (Camera_Handle handle)
 A function pointer to a driver specific implementation of Camera_init(). More...
 
typedef Camera_Handle(* Camera_OpenFxn) (Camera_Handle handle, Camera_Params *params)
 A function pointer to a driver specific implementation of Camera_open(). More...
 
typedef int(* Camera_CaptureFxn) (Camera_Handle handle, void *buffer, size_t bufferlen)
 A function pointer to a driver specific implementation of Camera_capture(). More...
 
typedef struct Camera_FxnTable Camera_FxnTable
 The definition of a Camera function table that contains the required set of functions to control a specific Camera driver implementation. More...
 
typedef struct Camera_Config Camera_Config
 Camera Global configuration. More...
 

Enumerations

enum  Camera_CaptureMode {
  Camera_MODE_BLOCKING,
  Camera_MODE_CALLBACK
}
 Camera capture mode settings. More...
 
enum  Camera_HSyncPolarity {
  Camera_HSYNC_POLARITY_HIGH = 0,
  Camera_HSYNC_POLARITY_LOW
}
 Camera HSync polarity. More...
 
enum  Camera_VSyncPolarity {
  Camera_VSYNC_POLARITY_HIGH = 0,
  Camera_VSYNC_POLARITY_LOW
}
 Camera VSync polarity. More...
 
enum  Camera_PixelClkConfig {
  Camera_PCLK_CONFIG_RISING_EDGE = 0,
  Camera_PCLK_CONFIG_FALLING_EDGE
}
 Camera pixel clock configuration. More...
 
enum  Camera_ByteOrder {
  Camera_BYTE_ORDER_NORMAL = 0,
  Camera_BYTE_ORDER_SWAP
}
 Camera byte order. More...
 
enum  Camera_IfSynchoronisation {
  Camera_INTERFACE_SYNC_OFF = 0,
  Camera_INTERFACE_SYNC_ON
}
 Camera interface synchoronisation. More...
 
enum  Camera_StopCaptureConfig {
  Camera_STOP_CAPTURE_IMMEDIATE = 0,
  Camera_STOP_CAPTURE_FRAME_END
}
 Camera stop capture configuration. More...
 
enum  Camera_StartCaptureConfig {
  Camera_START_CAPTURE_IMMEDIATE = 0,
  Camera_START_CAPTURE_FRAME_START
}
 Camera start capture configuration. More...
 

Functions

void Camera_close (Camera_Handle handle)
 Function to close a Camera peripheral specified by the Camera handle. More...
 
int Camera_control (Camera_Handle handle, uint32_t cmd, void *arg)
 Function performs implementation specific features on a given Camera_Handle. More...
 
void Camera_init (void)
 Function to initializes the Camera module. More...
 
Camera_Handle Camera_open (uint32_t index, Camera_Params *params)
 Function to initialize a given Camera peripheral specified by the particular index value. The parameter specifies which mode the Camera will operate. More...
 
void Camera_Params_init (Camera_Params *params)
 Function to initialize the Camera_Params structure to its defaults. More...
 
int Camera_capture (Camera_Handle handle, void *buffer, size_t bufferlen)
 Function that handles the Camera capture of a frame. More...
 

Macro Definition Documentation

#define Camera_WAIT_FOREVER   ~(0)

Wait forever define.

Typedef Documentation

typedef struct Camera_Config* Camera_Handle

A handle that is returned from a Camera_open() call.

typedef void(* Camera_Callback) (Camera_Handle, void *buf, size_t bufferLength)

The definition of a callback function used by the Camera driver when used in Camera_MODE_CALLBACK.

Parameters
Camera_HandleCamera_Handle
bufPointer to capture buffer
bufferLengthlength of frame

Camera capture mode settings.

This enum defines the capture mode for the configured Camera.

Camera HSync polarity.

This enum defines the polarity of the HSync signal.

Camera VSync polarity.

This enum defines the polarity of the VSync signal.

Camera pixel clock configuration.

This enum defines the pixel clock configuration.

Camera byte order.

This enum defines the byte order of camera capture.

In normal mode, the byte order is: | byte3 | byte2 | byte1 | byte0 |

In swap mode, the bytes are ordered as: | byte2 | byte3 | byte0 | byte1 |

Camera interface synchoronisation.

This enum defines the sensor to camera inteface synchoronisation configuration.

Camera stop capture configuration.

This enum defines the stop capture configuration.

Camera start capture configuration.

This enum defines the start capture configuration.

typedef struct Camera_Params Camera_Params

Camera Parameters.

Camera parameters are used to with the Camera_open() call. Default values for these parameters are set using Camera_Params_init().

If Camera_CaptureMode is set to Camera_MODE_BLOCKING then Camera_capture function calls will block thread execution until the capture has completed.

If Camera_CaptureMode is set to Camera_MODE_CALLBACK then Camera_capture will not block thread execution and it will call the function specified by captureCallbackFxn.

See also
Camera_Params_init()
typedef void(* Camera_CloseFxn) (Camera_Handle handle)

A function pointer to a driver specific implementation of Camera_close().

typedef int(* Camera_ControlFxn) (Camera_Handle handle, unsigned int cmd, void *arg)

A function pointer to a driver specific implementation of Camera_control().

typedef void(* Camera_InitFxn) (Camera_Handle handle)

A function pointer to a driver specific implementation of Camera_init().

typedef Camera_Handle(* Camera_OpenFxn) (Camera_Handle handle, Camera_Params *params)

A function pointer to a driver specific implementation of Camera_open().

typedef int(* Camera_CaptureFxn) (Camera_Handle handle, void *buffer, size_t bufferlen)

A function pointer to a driver specific implementation of Camera_capture().

The definition of a Camera function table that contains the required set of functions to control a specific Camera driver implementation.

typedef struct Camera_Config Camera_Config

Camera Global configuration.

The Camera_Config structure contains a set of pointers used to characterize the Camera driver implementation.

This structure needs to be defined before calling Camera_init() and it must not be changed thereafter.

See also
Camera_init()

Enumeration Type Documentation

Camera capture mode settings.

This enum defines the capture mode for the configured Camera.

Enumerator
Camera_MODE_BLOCKING 

Uses a semaphore to block while data is being sent. Context of the call must be a Task.

Camera_MODE_CALLBACK 

Non-blocking and will return immediately. When the capture by the interrupt is finished the configured callback function is called.

Camera HSync polarity.

This enum defines the polarity of the HSync signal.

Enumerator
Camera_HSYNC_POLARITY_HIGH 
Camera_HSYNC_POLARITY_LOW 

Camera VSync polarity.

This enum defines the polarity of the VSync signal.

Enumerator
Camera_VSYNC_POLARITY_HIGH 
Camera_VSYNC_POLARITY_LOW 

Camera pixel clock configuration.

This enum defines the pixel clock configuration.

Enumerator
Camera_PCLK_CONFIG_RISING_EDGE 
Camera_PCLK_CONFIG_FALLING_EDGE 

Camera byte order.

This enum defines the byte order of camera capture.

In normal mode, the byte order is: | byte3 | byte2 | byte1 | byte0 |

In swap mode, the bytes are ordered as: | byte2 | byte3 | byte0 | byte1 |

Enumerator
Camera_BYTE_ORDER_NORMAL 
Camera_BYTE_ORDER_SWAP 

Camera interface synchoronisation.

This enum defines the sensor to camera inteface synchoronisation configuration.

Enumerator
Camera_INTERFACE_SYNC_OFF 
Camera_INTERFACE_SYNC_ON 

Camera stop capture configuration.

This enum defines the stop capture configuration.

Enumerator
Camera_STOP_CAPTURE_IMMEDIATE 
Camera_STOP_CAPTURE_FRAME_END 

Camera start capture configuration.

This enum defines the start capture configuration.

Enumerator
Camera_START_CAPTURE_IMMEDIATE 
Camera_START_CAPTURE_FRAME_START 

Function Documentation

void Camera_close ( Camera_Handle  handle)

Function to close a Camera peripheral specified by the Camera handle.

Precondition
Camera_open() had to be called first.
Parameters
handleA Camera_Handle returned from Camera_open
See also
Camera_open()
int Camera_control ( Camera_Handle  handle,
uint32_t  cmd,
void *  arg 
)

Function performs implementation specific features on a given Camera_Handle.

Commands for Camera_control can originate from Camera.h or from implementation specific Camera*.h (CameraCC3200.h, etc.. ) files. While commands from Camera.h are API portable across driver implementations, not all implementations may support all these commands. Conversely, commands from driver implementation specific Camera*.h files add unique driver capabilities but are not API portable across all Camera driver implementations.

Commands supported by Camera.h follow a Camera_CMD_<cmd> naming convention.
Commands supported by Camera*.h follow a Camera*_CMD_<cmd> naming convention.
Each control command defines arg differently. The types of arg are documented with each command.

See Camera_control command codes for command codes.

See Camera_control return status codes for status codes.

Precondition
Camera_open() has to be called first.
Parameters
handleA Camera handle returned from Camera_open()
cmdCamera.h or Camera*.h commands.
argAn optional R/W (read/write) command argument accompanied with cmd
Returns
Implementation specific return codes. Negative values indicate unsuccessful operations.
See also
Camera_open()
void Camera_init ( void  )

Function to initializes the Camera module.

Precondition
The Camera_config structure must exist and be persistent before this function can be called. This function must also be called before any other Camera driver APIs. This function call does not modify any peripheral registers.
Camera_Handle Camera_open ( uint32_t  index,
Camera_Params params 
)

Function to initialize a given Camera peripheral specified by the particular index value. The parameter specifies which mode the Camera will operate.

Precondition
Camera controller has been initialized
Parameters
indexLogical peripheral number for the Camera indexed into the Camera_config table
paramsPointer to an parameter block, if NULL it will use default values. All the fields in this structure are RO (read-only).
Returns
A Camera_Handle on success or a NULL on an error or if it has been opened already.
See also
Camera_init()
Camera_close()
void Camera_Params_init ( Camera_Params params)

Function to initialize the Camera_Params structure to its defaults.

Parameters
paramsAn pointer to Camera_Params structure for initialization

Defaults values are: captureMode = Camera_MODE_BLOCKING; outputClock = 24000000; hsyncPolarity = Camera_HSYNC_POLARITY_HIGH; vsyncPolarity = Camera_VSYNC_POLARITY_HIGH; pixelClkConfig = Camera_PCLK_CONFIG_RISING_EDGE; byteOrder = Camera_BYTE_ORDER_NORMAL; interfaceSync = Camera_INTERFACE_SYNC_ON; stopConfig = Camera_STOP_CAPTURE_FRAME_END; startConfig = Camera_START_CAPTURE_FRAME_START; captureTimeout = Camera_WAIT_FOREVER; captureCallback = NULL;

int Camera_capture ( Camera_Handle  handle,
void *  buffer,
size_t  bufferlen 
)

Function that handles the Camera capture of a frame.

In Camera_MODE_BLOCKING, Camera_capture will block task execution until the capture is complete.

In Camera_MODE_CALLBACK, Camera_capture does not block task execution and calls a callback function specified by captureCallbackFxn. The Camera buffer must stay persistent until the Camera_capture function has completed!

Parameters
handleA Camera_Handle
bufferA pointer to a WO (write-only) buffer into which the captured frame is placed
bufferlenLength (in bytes) of the capture buffer
Returns
Number of bytes captured.
See also
Camera_open
Copyright 2016, Texas Instruments Incorporated