⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddcci.c

📁 IT projecotr reference design.
💻 C
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************/
/*             TEXAS INSTRUMENTS PROPRIETARY INFORMATION                    */
/*                                                                          */
/*  (c) Copyright, Texas Instruments Incorporated, 2006.                    */
/*      All Rights Reserved.                                                */
/*                                                                          */
/*  Property of Texas Instruments Incorporated. Restricted Rights -         */
/*  Use, duplication, or disclosure is subject to restrictions set          */
/*  forth in TI's program license agreement and associated documentation.   */
/****************************************************************************/

/****************************************************************************/
/* ddcCI.c                                                                 */
/****************************************************************************/

#include <stdio.h>

#include "common.h"
#include "ddp2230_rtos_include.h"
#include "tmr.h"
#include "i2c.h"

#include "taskParm.h"
#include "ddcCI.h"



/****************************************************************************/
/* Local declarations.                                                      */
/****************************************************************************/

                            /************************************************/
                            /* Message receiver state machine states.       */
                            /************************************************/
                            
#define RSM_IDLE    0                        /* receiver state machine idle */
#define RSM_START   1                     /* receiver start condition found */
#define RSM_LENGTH  2                  /* receiver obtaining message length */
#define RSM_TEXT    3                     /*receiver obtaining message text */
#define RSM_CKSUM   4                        /* receiver obtaining checksum */

                            /************************************************/
                            /* Message transmitter state machine states.    */
                            /************************************************/
                            
#define TSM_IDLE    0                     /* transmitter state machine idle */
#define TSM_START   1                  /* transmitter start condition found */
#define TSM_TEXT    2                   /* transmitter sending message text */



/****************************************************************************/
/* Preformatted trace event strings. These are provided for table lookup to */
/* eliminate the time which would be needed to format during the read and   */
/* write callbacks.                                                         */
/****************************************************************************/

const char * const rbyte[256] =
{
    "r-00", "r-01", "r-02", "r-03", "r-04", "r-05", "r-06", "r-07", "r-08", "r-09", "r-0a", "r-0b", "r-0c", "r-0d", "r-0e", "r-0f", 
    "r-10", "r-11", "r-12", "r-13", "r-14", "r-15", "r-16", "r-17", "r-18", "r-19", "r-1a", "r-1b", "r-1c", "r-1d", "r-1e", "r-1f", 
    "r-20", "r-21", "r-22", "r-23", "r-24", "r-25", "r-26", "r-27", "r-28", "r-29", "r-2a", "r-2b", "r-2c", "r-2d", "r-2e", "r-2f", 
    "r-30", "r-31", "r-32", "r-33", "r-34", "r-35", "r-36", "r-37", "r-38", "r-39", "r-3a", "r-3b", "r-3c", "r-3d", "r-3e", "r-3f", 
    "r-40", "r-41", "r-42", "r-43", "r-44", "r-45", "r-46", "r-47", "r-48", "r-49", "r-4a", "r-4b", "r-4c", "r-4d", "r-4e", "r-4f", 
    "r-50", "r-51", "r-52", "r-53", "r-54", "r-55", "r-56", "r-57", "r-58", "r-59", "r-5a", "r-5b", "r-5c", "r-5d", "r-5e", "r-5f", 
    "r-60", "r-61", "r-62", "r-63", "r-64", "r-65", "r-66", "r-67", "r-68", "r-69", "r-6a", "r-6b", "r-6c", "r-6d", "r-6e", "r-6f", 
    "r-70", "r-71", "r-72", "r-73", "r-74", "r-75", "r-76", "r-77", "r-78", "r-79", "r-7a", "r-7b", "r-7c", "r-7d", "r-7e", "r-7f", 
    "r-80", "r-81", "r-82", "r-83", "r-84", "r-85", "r-86", "r-87", "r-88", "r-89", "r-8a", "r-8b", "r-8c", "r-8d", "r-8e", "r-8f", 
    "r-90", "r-91", "r-92", "r-93", "r-94", "r-95", "r-96", "r-97", "r-98", "r-99", "r-9a", "r-9b", "r-9c", "r-9d", "r-9e", "r-9f", 
    "r-a0", "r-a1", "r-a2", "r-a3", "r-a4", "r-a5", "r-a6", "r-a7", "r-a8", "r-a9", "r-aa", "r-ab", "r-ac", "r-ad", "r-ae", "r-af", 
    "r-b0", "r-b1", "r-b2", "r-b3", "r-b4", "r-b5", "r-b6", "r-b7", "r-b8", "r-b9", "r-ba", "r-bb", "r-bc", "r-bd", "r-be", "r-bf", 
    "r-c0", "r-c1", "r-c2", "r-c3", "r-c4", "r-c5", "r-c6", "r-c7", "r-c8", "r-c9", "r-ca", "r-cb", "r-cc", "r-cd", "r-ce", "r-cf", 
    "r-d0", "r-d1", "r-d2", "r-d3", "r-d4", "r-d5", "r-d6", "r-d7", "r-d8", "r-d9", "r-da", "r-db", "r-dc", "r-dd", "r-de", "r-df", 
    "r-e0", "r-e1", "r-e2", "r-e3", "r-e4", "r-e5", "r-e6", "r-e7", "r-e8", "r-e9", "r-ea", "r-eb", "r-ec", "r-ed", "r-ee", "r-ef", 
    "r-f0", "r-f1", "r-f2", "r-f3", "r-f4", "r-f5", "r-f6", "r-f7", "r-f8", "r-f9", "r-fa", "r-fb", "r-fc", "r-fd", "r-fe", "r-ff" 
};

const char * const tbyte[] =
{
    "t-00", "t-01", "t-02", "t-03", "t-04", "t-05", "t-06", "t-07", "t-08", "t-09", "t-0a", "t-0b", "t-0c", "t-0d", "t-0e", "t-0f", 
    "t-10", "t-11", "t-12", "t-13", "t-14", "t-15", "t-16", "t-17", "t-18", "t-19", "t-1a", "t-1b", "t-1c", "t-1d", "t-1e", "t-1f", 
    "t-20", "t-21", "t-22", "t-23", "t-24", "t-25", "t-26", "t-27", "t-28", "t-29", "t-2a", "t-2b", "t-2c", "t-2d", "t-2e", "t-2f", 
    "t-30", "t-31", "t-32", "t-33", "t-34", "t-35", "t-36", "t-37", "t-38", "t-39", "t-3a", "t-3b", "t-3c", "t-3d", "t-3e", "t-3f", 
    "t-40", "t-41", "t-42", "t-43", "t-44", "t-45", "t-46", "t-47", "t-48", "t-49", "t-4a", "t-4b", "t-4c", "t-4d", "t-4e", "t-4f", 
    "t-50", "t-51", "t-52", "t-53", "t-54", "t-55", "t-56", "t-57", "t-58", "t-59", "t-5a", "t-5b", "t-5c", "t-5d", "t-5e", "t-5f", 
    "t-60", "t-61", "t-62", "t-63", "t-64", "t-65", "t-66", "t-67", "t-68", "t-69", "t-6a", "t-6b", "t-6c", "t-6d", "t-6e", "t-6f", 
    "t-70", "t-71", "t-72", "t-73", "t-74", "t-75", "t-76", "t-77", "t-78", "t-79", "t-7a", "t-7b", "t-7c", "t-7d", "t-7e", "t-7f", 
    "t-80", "t-81", "t-82", "t-83", "t-84", "t-85", "t-86", "t-87", "t-88", "t-89", "t-8a", "t-8b", "t-8c", "t-8d", "t-8e", "t-8f", 
    "t-90", "t-91", "t-92", "t-93", "t-94", "t-95", "t-96", "t-97", "t-98", "t-99", "t-9a", "t-9b", "t-9c", "t-9d", "t-9e", "t-9f", 
    "t-a0", "t-a1", "t-a2", "t-a3", "t-a4", "t-a5", "t-a6", "t-a7", "t-a8", "t-a9", "t-aa", "t-ab", "t-ac", "t-ad", "t-ae", "t-af", 
    "t-b0", "t-b1", "t-b2", "t-b3", "t-b4", "t-b5", "t-b6", "t-b7", "t-b8", "t-b9", "t-ba", "t-bb", "t-bc", "t-bd", "t-be", "t-bf", 
    "t-c0", "t-c1", "t-c2", "t-c3", "t-c4", "t-c5", "t-c6", "t-c7", "t-c8", "t-c9", "t-ca", "t-cb", "t-cc", "t-cd", "t-ce", "t-cf", 
    "t-d0", "t-d1", "t-d2", "t-d3", "t-d4", "t-d5", "t-d6", "t-d7", "t-d8", "t-d9", "t-da", "t-db", "t-dc", "t-dd", "t-de", "t-df", 
    "t-e0", "t-e1", "t-e2", "t-e3", "t-e4", "t-e5", "t-e6", "t-e7", "t-e8", "t-e9", "t-ea", "t-eb", "t-ec", "t-ed", "t-ee", "t-ef", 
    "t-f0", "t-f1", "t-f2", "t-f3", "t-f4", "t-f5", "t-f6", "t-f7", "t-f8", "t-f9", "t-fa", "t-fb", "t-fc", "t-fd", "t-fe", "t-ff", 
};



/****************************************************************************/
/* Local data.                                                              */
/****************************************************************************/

static const char ddcciTaskName[] = "DDC/CITask";

static const I2CINIT ddcConfig =           /* DDC/CI i2c port configuration */
{
    I2C_7BIT,                                          /* MasterAddressMode */
    I2C_7BIT,                                           /* SlaveAddressMode */
    15,                                                      /* FilterValue */
    100000,                                                /*  SCLClockRate */
    FALSE                                                      /* IntEnable */
};

static  I2CPORT     ciPort;                           /* CI i2c port number */
static  uint08      ciTabSize;            /* size of message dispatch table */
static pCI_DISPATCH ciTable;                      /* message dispatch table */
static  uint32      ciEvent;                  /* CI message-available event */
        uint32      ciTaskID = ID_INVALID;                    /* CI task ID */

static  CI_MESSAGE  ciRxMsg;                 /* CI received request message */
static  CI_MESSAGE  ciTxMsg;             /* CI transmitted response message */
static  BOOL        ciResponse;               /* CI response available flag */
static  uint08      ciNullMsg[4] = { 0x50, 0x6e, 0x80, 0xbe };  /* null msg */

                            /************************************************/
                            /* Receiver state machine parameters.           */
                            /************************************************/
                            
static  uint08     *rsmAddr;             /* received message buffer pointer */
static  uint08      rsmCount;          /* receiver state machine byte count */
static  uint08      rsmState;         /* slave receiver state machine state */
static  uint08      rsmCkSum;                                   /* checksum */

                            /************************************************/
                            /* Transmitter state machine parameters.        */
                            /************************************************/
                            
static  uint08     *tsmAddr;          /* transmitted message buffer pointer */
static  uint08      tsmCount;       /* transmitted state machine byte count */
static  uint08      tsmState;      /* slave transmitter state machine state */

                            /************************************************/
                            /* Debug messaging                              */
                            /*                                              */
                            /* ddcciDbCallback() installs a function call-  */
                            /* back to send a message string to the appli-  */
                            /* cation's debug messenger. The callback is    */
                            /* invoked by calling this file's _ddcMessage() */
                            /* function.                                    */
                            /*                                              */
                            /* The static dbMessage[] array is provided to  */
                            /* format messages. No check is provided on the */
                            /* length of the formatted message.             */
                            /************************************************/
                            
static  void(*dbCallback)( char *msg ) = NULL;    /* debug message callback */
static  char  dbMessage[32];                     /* formatted debug message */



/****************************************************************************/
/* Local functions.                                                         */
/****************************************************************************/

void     _ddcMessage( char *msg );
BOOL     _ddcReadCallback ( uint08* byte, BOOL start );
DDC_COMP _ddcRestart( void );
void     _ddcTask( void );
void     _ddcWriteCallback( uint08* byte, BOOL start );



/****************************************************************************/
/* Install DDC/CI debug message callback.                                   */
/****************************************************************************/

void ddcciDbCallback( void(*callback)( char *msg ))
{
    dbCallback = callback;
}



/****************************************************************************/
/* Return task ID and task name info.                                       */
/****************************************************************************/

uint32 ddcciInfo( char **pTName )
{
   *pTName = (char*)ddcciTaskName;
   
    return ciTaskID;
}



/****************************************************************************/
/* Initialization.                                                          */
/*                                                                          */
/* Application-independent initialization.                                  */
/****************************************************************************/

DDC_COMP ddcciInit( I2CPORT port, uint32 ssize, uint32 taskpri, uint08 tabSize, pCI_DISPATCH dTable )
{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -