| ISF 1.1 Intelligent Sensing Framework

- Main Page
- Data Structures
- Files
- Sensor Adapters

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Include/isf_comm.h
Go to the documentation of this file.

    00001 /*!
    00002 ********************************************************************************
    00003 * File: isf_comm.h
    00004 *
    00005 * Copyright (c) 2012, Freescale Semiconductor, Inc.
    00006 *
    00007 *******************************************************************************/
    00008 /*!
    00009 * @file isf_comm.h
    00010 * @brief \b isf_comm.h defines the common types for the  Communications Service Family of the Intelligent Sensing Framework (ISF).
    00011 * @details This common types used by components in the ISF
    00012 * Communications Service Family, including the I2C and Device Messaging
    00013 * Components. Since the Device Messaging Component abstracts various
    00014 * communications interfaces (I2C, SPI, RGPIO), it is important to ensure that
    00015 * all abstracted components use common data types and function prototypes.
    00016 * These types and prototypes are defined in the header file rather than in the Device
    00017 * Messaging header file to avoid creating a circular dependency.
    00018 */
    00019 #ifndef COMM_H
    00020 #define COMM_H
    00021
    00022 #include <isf.h>
    00023
    00024 /*! @brief This macro is used for creating sized read/write buffers. */
    00025 #define COMM_SIZED_BUFFER(bufSize) \
    00026     struct { uint16 size; uint8 buffer[(bufSize)]; }
    00027
    00028 /*! @brief This macro is used for creating concretely sized typedefs compatible with type comm_Command_t. */
    00029 #define COMM_CMD_DEFN(cmdLen) \
    00030     struct { uint16 nWrite; uint16 nRead; uint8 cmdWords[(cmdLen)]; }
    00031
    00032 /*! @brief This enum defines the possible communications channel states. */
    00033 enum comm_State_vals {
    00034     COMM_STATE_NO_INIT      = 0,      /*!< Channel has not been initialized.  */
    00035     COMM_STATE_INIT         = 1,      /*!< Channel is initialized, but not ready to use because channel is not started or configured.*/
    00036     COMM_STATE_OK           = 2,      /*!< Channel is ready to use without errors.      */
    00037     COMM_STATE_STOPPED      = 3,      /*!< Channel is currently stopped.      */
    00038     COMM_STATE_LOCKED       = 4,      /*!< Channel is locked (busy).          */
    00039     COMM_STATE_ERROR        = 5,      /*!< A null pointer was provided as an argument.  */
    00040     COMM_STATE_ARB_LOST     = 6       /*!< Channel arbitration has been lost. */
    00041 };
    00042
    00043 /*! @brief This enum defines the possible communications channel error codes. */
    00044 enum comm_Error_vals {
    00045     COMM_ERROR_INIT         = 1,      /*!< A channel initialization error has occurred. */
    00046     COMM_ERROR_STOP         = 2,      /*!< A channel stop-related error has occurred.   */
    00047     COMM_ERROR_LOCK         = 3,      /*!< A channel lock-related error has occurred.   */
    00048     COMM_ERROR_TIME_OUT     = 4,      /*!< Channel has timed out.                       */
    00049     COMM_ERROR_NULL_PTR     = 5,      /*!< A null pointer was provided as an argument.  */
    00050     COMM_ERROR_NOEXIST      = 6,      /*!< The referenced entity does not exist.        */
    00051     COMM_ERROR_BUF_SIZE     = 7,      /*!< The provided buffer is too small.            */
    00052     COMM_ERROR_NO_ACK       = 8,      /*!< An acknowledgement was not received.         */
    00053     COMM_ERROR_DEV_CLOSED   = 9,      /*!< Attempted read/write to a closed device.     */
    00054     COMM_ERROR_OTHER        = 10      /*!< An unspecified channel error has occured.    */
    00055 };
    00056
    00057 /*! @brief This type is for a numeric channel identifier- index into an array of channels
    00058  * in the system. */
    00059 typedef uint8 comm_Id_t;
    00060
    00061 /*! @brief This enum holds an enumerated value describing the state of a channel. */
    00062 typedef enum comm_State_vals comm_State_t;
    00063
    00064 /*! @brief This type is for a channel address for both 7-bit and 10-bit addresses. */
    00065 typedef uint16 comm_Address_t;
    00066
    00067 /*! @brief This is a bit array of flags governing device read/write behavior. */
    00068 typedef uint32 comm_Flags_t;
    00069
    00070 /* The design goal with these types is to reduce RAM usage requirement by allowing the static portions of the
    00071  * messages to be usable from flash memory. */
    00072
    00073 /*! @brief This structure defines a buffer to hold data read from or written to a
    00074  * device. */
    00075 typedef struct comm_MessageBuffer_struct {
    00076     uint16 size;                        /*!< The size of the buffer.*/
    00077     uint8  buffer[];                    /*!< Buffer defined to hold data.*/
    00078 } comm_MessageBuffer_t;
    00079
    00080 /*! @brief This structure defines the command sent to a device. */
    00081 typedef struct comm_Command_struct {
    00082     uint16 nWrite;                     /*!< Number of bytes to write.*/
    00083     uint16 nRead;                      /*!< Number of bytes to read. */
    00084     uint8  cmdWords[];                /*!< Command buffer associated with the data. */
    00085 } comm_Command_t;
    00086
    00087 #endif  /* COMM_H */