亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lmp_blst.c

?? IT projecotr reference design.
?? C
?? 第 1 頁 / 共 3 頁
字號:
/****************************************************************************/
/*             TEXAS INSTRUMENTS PROPRIETARY INFORMATION                    */
/*                                                                          */
/*  (c) Copyright, Texas Instruments Incorporated, 2007.                    */
/*      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.   */
/****************************************************************************/


/****************************************************************************/
/* lmp_blst.c                                                               */
/*                                                                          */
/* This file contains the interface to the lamp ballast to support variable */
/* illumination lamps/ballasts for the UART-capable system.  Two types of   */
/* instructions - command and query, can be communicated with the ballast.  */
/*                                                                          */
/* Commands includes enable communication, selecting waveform index or      */
/* gain, and programming mailbox for manufacturer specific or any pass      */
/* through addresses within the ballast.                                    */
/*                                                                          */
/* Queries includes reading ballast manufacturer ID, ballast software and   */
/* hardware ID, current waveform ID, index, gain, and status, total         */
/* waveforms stored in the ballast, ballast status, mailbox status,         */
/* mailbox byte, and maximum and minimum gain.                              */
/*                                                                          */
/* Call LMP_BLST_EnableCommunication API to enable access to all other      */
/* commands and queries.                                                    */
/*                                                                          */
/* Call LMP_BLST_SetWaveform to select the waveform stored in the ballast.  */
/*                                                                          */
/* Call LMP_BLST_SetWaveformGain to set the output power level of the lamp. */
/*                                                                          */
/* LMP_BLST_OpenMailBox to open mailbox for all pass through commands.      */
/* LMP_BLST_WriteMailBox or LMP_BLST_ReadMailBox can be used multiple times */
/* for consecutive write or read. At the end, use LMP_BLST_CloseMailBox to  */
/* close the mailbox. Reference Ballast Specification for specific          */
/* command/address can be programmed through mailbox.                       */
/*                                                                          */
/* Call LAMP_UART_GetLampStatus is used to get current lamp safe mode to    */
/* indicate if any error occurred while switching sequence bin due to no    */
/* matching Ballast Manufacturer ID or waveform index found is out of       */
/* range.  When in safe mode, lamp sync will be disabled to protect the     */
/* lamp ballast.                                                            */
/*                                                                          */
/****************************************************************************/

#include "common.h"
#include "cw.h"
#include "seq.h"
#include "ddp_stat.h"
#include "int.h"
#include "lmp_blst.h"
#include "lmp.h"
#include "tmr.h"
#include "urt.h"
#include "rta_pub.h"
#include "rta_sem.h"
#include "rta_tsk.h"

#include "global.h"
#include "app_cfg.h"


#define LMP_BLST_LAMPON         BIT0
#define LMP_BLST_SEM_DELAY      500
#define LMP_BLST_UART_DELAY     500
#define LMP_BLST_INIT_DELAY     20

/* Global and External Variables */
static URTPORT LMP_BLST_PortNum = URT_PORT0;

static BOOL    LMP_BLST_SafeMode            = FALSE;
static int08   LMP_BLST_CurrERR             = 0;

       uint08  LMP_BLST_Numbertries         = 0;
static BOOL    LMP_BLST_Enabled             = FALSE;
static uint08  LMP_BLST_BallastMfgID        = 0;
static uint16  LMP_BLST_BallastID           = 0;
       uint08  LMP_BLST_CurrWaveformID      = 0;
static uint08  LMP_BLST_NumWaveforms        = 0;
static uint08  LMP_BLST_CurrWaveformIndex   = 0xFF;
static uint08  LMP_BLST_CurrWaveformGain    = 0;
       BOOL    LMP_BLST_CurrLmpLit          = FALSE;
static uint08  LMP_BLST_MaxGain             = 0;
static uint08  LMP_BLST_MinGain             = 0;

static uint08  write_buffer [5],    read_buffer [5];
static uint32  numBytesWritten = 0, numBytesRead = 0;

static uint32  LMP_BLST_Sem;


/****************************************************************************/
/* This function enables/disables the communication with UART capable       */
/* lamp ballast.  It also queries the information and saves for future      */
/* processing.                                                              */
/* param  Enable - TRUE - Enables communication.                            */
/*                 FALSE - Disables communication (further queries will     */
/*                                                  not work).              */
/*                                                                          */
/* return  PASS = Successful  <BR>                                          */
/*         FAIL = Unsuccessful  <BR>                                        */
/*         LMP_BLST_TIMEOUT = UART Timeout  <BR>                            */
/*         LMP_BLST_URTERR  = UART all other Errors  <BR>                   */
/*         LMP_BLST_BALLASTERR   = Ballast returned error                   */
/****************************************************************************/

int08   LMP_BLST_EnableCommunication (BOOL Enable)
{
    int08   i = 0;
    int08   error     = PASS;
    URTINIT urtInit;
    uint08 waveformIdx;

    LMP_BLST_PortNum = gpConfiguration->Illum.UartBallastPort;

    /*
       # Issue Enable Communication command (0x70)
       # If successful, issue the following queries to get value for local variables
         1. Ballast Manufacturer ID (0xf0)
         2. Ballast ID (0xf1)
         3. Number of Waveforms Stored (0xf6)
         4. Current Waveform Index (0xf3)
         5. Minimum Waveform Gain  (0xfa)
         6. Maximum Waveform Gain  (0xfb)
    */

    /* UART Initialization */
    urtInit.PortEnable  = ENABLE;
    urtInit.BaudRate    = gpConfiguration->Illum.UartBallastBaudrate;        /* URT_9600     */
    urtInit.DataBits    = gpConfiguration->Illum.UartBallastDatabits;        /* URT_8DBITS     */
    urtInit.StopBits    = gpConfiguration->Illum.UartBallastStopbits;        /* URT_1SBITS     */
    urtInit.Parity      = gpConfiguration->Illum.UartBallastParity;        /* URT_EVEN     */
    urtInit.FlowControl = URT_OFF;
    urtInit.RXTrigLevel = URT_RX_SEVEN_EIGHTHS_FULL;             
    urtInit.TXTrigLevel = URT_TX_ONE_EIGHTH_FULL; 
    urtInit.RXDPolarity = gpConfiguration->Illum.UartBallastRxdPolarity;  /* URT_NONINV_RXDPOL, URT_INV_RXDPOL */

    error = URT_FlushFIFOs   (LMP_BLST_PortNum);
    error = URT_SetConfig    (LMP_BLST_PortNum, &urtInit);
    error = URT_SetIntEnable (LMP_BLST_PortNum, 0x0000);
    error = URT_EnableFIFOs  (LMP_BLST_PortNum, ENABLE);
    error = URT_SetPortEnable(LMP_BLST_PortNum, ENABLE);
    
    if (error != PASS)
        return LMP_BLST_URTERR;


    if (!Enable)
    {
        /* Write "Turn Lamp Off" command (0x26) */
        write_buffer[0] = 0x26;
        error = URT_Write (LMP_BLST_PortNum, 1, &write_buffer[0], LMP_BLST_UART_DELAY, &numBytesWritten);
        RTA_TaskDelay(TMR_ConvertMSToTicks(LMP_BLST_INIT_DELAY));
        
        /* Exit UART mode */
    	write_buffer[0] = gpConfiguration->Illum.UartBallastExitUartModeCmd;
        error = URT_Write (LMP_BLST_PortNum, 1, &write_buffer[0], LMP_BLST_UART_DELAY, &numBytesWritten);

        LMP_BLST_Enabled = FALSE;
        return error;
    }
    
    URT_FlushReadFIFO(LMP_BLST_PortNum); /* Discard any spurious data */
    
    /* Write "Enable Communication" command (0x70) */
    write_buffer[0] = 0x70;
    
    for (i = 0; i < 5; i++)
    {
        error = URT_Write (LMP_BLST_PortNum, 1, &write_buffer[0], LMP_BLST_UART_DELAY, &numBytesWritten);
        RTA_TaskDelay(TMR_ConvertMSToTicks(LMP_BLST_INIT_DELAY));
        error = URT_Read  (LMP_BLST_PortNum, 2, &read_buffer[0],  LMP_BLST_UART_DELAY, &numBytesRead);

        if ((error == PASS) && (read_buffer[0] == 0x70))
        {
            LMP_BLST_Numbertries = i;
            break;
        }

        error = URT_FlushFIFOs     (LMP_BLST_PortNum);
        error = URT_ClearIntStatus (LMP_BLST_PortNum, 0x7F);
    }
    
    if (error == PASS)
    {
        if (read_buffer [0] == 0x70)
        {
            LMP_BLST_Enabled = TRUE;
            LMP_BLST_SetLampStatus (FALSE, PASS);
        }
        else
        {
            error = LMP_BLST_BALLASTERR;            
            LMP_BLST_SetLampStatus (TRUE, error);

            return error;
        }
    }
    else
    {  
        if (error == URT_TIMEOUT)
            error = LMP_BLST_TIMEOUT;
        else
            error = LMP_BLST_URTERR;
                
        LMP_BLST_SetLampStatus (TRUE, error);
            
        return error;
    }

     /* Read Ballast Manufacturer ID */
    write_buffer[0] = 0xF0;
    error = URT_Write (LMP_BLST_PortNum, 1, &write_buffer[0], LMP_BLST_UART_DELAY, &numBytesWritten);
    error = URT_Read  (LMP_BLST_PortNum, 2, &read_buffer[0],  LMP_BLST_UART_DELAY, &numBytesRead);
    if (error == PASS && read_buffer [0] == 0xF0)
        LMP_BLST_BallastMfgID = read_buffer[1];
        
    /* Read Ballast ID */
    write_buffer[0] = 0xF1;
    error = URT_Write (LMP_BLST_PortNum, 1, &write_buffer[0], LMP_BLST_UART_DELAY, &numBytesWritten);
    error = URT_Read  (LMP_BLST_PortNum, 3, &read_buffer[0],  LMP_BLST_UART_DELAY, &numBytesRead);
    if (error == PASS && read_buffer [0] == 0xF1)
    {
        LMP_BLST_BallastID = (read_buffer[1] << 8) | read_buffer[2];
    }
    read_buffer[2] = 0x00;
    
    /* Read Current Waveform Index */
    write_buffer[0] = 0xF3;
    error = URT_Write (LMP_BLST_PortNum, 1, &write_buffer[0], LMP_BLST_UART_DELAY, &numBytesWritten);
    error = URT_Read  (LMP_BLST_PortNum, 2, &read_buffer[0],  LMP_BLST_UART_DELAY, &numBytesRead);
    if (error == PASS && read_buffer [0] == 0xF3)
        LMP_BLST_CurrWaveformIndex = read_buffer[1];
    
    /* Read Current Waveform ID */
    write_buffer[0] = 0xF2;
    error = URT_Write (LMP_BLST_PortNum, 1, &write_buffer[0], LMP_BLST_UART_DELAY, &numBytesWritten);
    error = URT_Read  (LMP_BLST_PortNum, 2, &read_buffer[0],  LMP_BLST_UART_DELAY, &numBytesRead);
    if (error == PASS && read_buffer [0] == 0xF2)
        LMP_BLST_CurrWaveformID = read_buffer[1];
    
    /* Read Current Waveform Gain */
    write_buffer[0] = 0xF4;
    error = URT_Write (LMP_BLST_PortNum, 1, &write_buffer[0], LMP_BLST_UART_DELAY, &numBytesWritten);
    error = URT_Read  (LMP_BLST_PortNum, 2, &read_buffer[0],  LMP_BLST_UART_DELAY, &numBytesRead);
    if (error == PASS && read_buffer [0] == 0xF4)
        LMP_BLST_CurrWaveformGain = read_buffer[1];
    
    /* Read Number of Waveforms Stored */
    write_buffer[0] = 0xF6;
    error = URT_Write (LMP_BLST_PortNum, 1, &write_buffer[0], LMP_BLST_UART_DELAY, &numBytesWritten);
    error = URT_Read  (LMP_BLST_PortNum, 2, &read_buffer[0],  LMP_BLST_UART_DELAY, &numBytesRead);
    if (error == PASS && read_buffer [0] == 0xF6)
        LMP_BLST_NumWaveforms = read_buffer[1];

    /* Read Maximum Waveform Gain */
    write_buffer[0] = 0xFA;
    error = URT_Write (LMP_BLST_PortNum, 1, &write_buffer[0], LMP_BLST_UART_DELAY, &numBytesWritten);
    error = URT_Read  (LMP_BLST_PortNum, 2, &read_buffer[0],  LMP_BLST_UART_DELAY, &numBytesRead);
    if (error == PASS && read_buffer [0] == 0xFA)
        LMP_BLST_MinGain = read_buffer[1];

    /* Read Minimum Waveform Gain */
    write_buffer[0] = 0xFB;
    error = URT_Write (LMP_BLST_PortNum, 1, &write_buffer[0], LMP_BLST_UART_DELAY, &numBytesWritten);
    error = URT_Read  (LMP_BLST_PortNum, 2, &read_buffer[0],  LMP_BLST_UART_DELAY, &numBytesRead);
    if (error == PASS && read_buffer [0] == 0xFB)
        LMP_BLST_MaxGain = read_buffer[1];

    if(RTA_SemCreate(&LMP_BLST_Sem, "LAMP BALLAST Sem") != RTA_SUCCESS)
        return FAIL;

    /* Check the SEQ_GRP table for match Spin Rate, Seq Mode, and LMP_BLST_BallastMfgID */
    if( FAIL != SEQ_GetWaveformIndex( CW_GetMode(), 
                                             CW_GetSeqMode(),
                                             LMP_BLST_BallastMfgID,
                                             &waveformIdx ) )
    {                       
        error = LMP_BLST_SetWaveform( waveformIdx );
        if( error != PASS )
        {
            LMP_BLST_SetLampStatus (TRUE, error);
            return error;
        }
    }
    else
    {
        LMP_BLST_SetLampStatus (TRUE, LMP_BLST_NOSEQMATCH);
        return LMP_BLST_NOSEQMATCH;
    }
    
    return PASS;
}


/****************************************************************************/
/* This function returns if UART Communication is enabled.                  */
/*                                                                          */
/* return  TRUE  = UART Communication is enabled                            */
/*         FALSE = UART Communication is not enabled                        */
/****************************************************************************/

BOOL   LMP_BLST_IsCommunicationEnabled (void)
{
    return LMP_BLST_Enabled;
}


/****************************************************************************/
/* This function sets the waveform index to select a waveform programmed in */ 
/* the ballast.  NOTE that the waveform may be automatically                */
/* selected/overridden in the ballast whenever the sequence is changed.     */
/*                                                                          */
/*  param  Waveform_Index - I - Waveform Index range 0x0 to 0xF. This       */
/*                              should be less than the number of waveforms */
/*                              stored in the ballast. Refer to             */
/*                              LMP_BLST_GetNumWaveforms().                 */
/*                                                                          */
/*  return PASS = Successful                                                */
/*         FAIL = Unsuccessful                                              */
/*         LMP_BLST_INUSEERR     = Lamp UART is in use                      */
/*         LMP_BLST_TIMEOUT      = UART Timeout                             */
/*         LMP_BLST_URTERR       = UART all other Errors                    */
/*         LMP_BLST_WAVEFORM_OOR = waveform specified is out of range       */
/*         LMP_BLST_BALLASTERR   = Ballast returned error                   */
/****************************************************************************/

int08  LMP_BLST_SetWaveform (uint08 Waveform_Index)
{
    int08   error = PASS;

    /* Return if it is the same waveform index */
    if (Waveform_Index == LMP_BLST_CurrWaveformIndex)
        return PASS;

    /* Set the OOR flag if the index is out of range */
    if (Waveform_Index >= LMP_BLST_NumWaveforms)
    {
        error = LMP_BLST_SetLampStatus (TRUE, LMP_BLST_WAVEFORM_OOR);
        return LMP_BLST_WAVEFORM_OOR;
    }

    if(RTA_SemReserve(LMP_BLST_Sem, TMR_ConvertMSToTicks(LMP_BLST_SEM_DELAY)) != RTA_SUCCESS)
        return LMP_BLST_INUSEERR;

    URT_FlushReadFIFO(LMP_BLST_PortNum); /* Discard any spurious data */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲婷婷综合色高清在线| 日韩久久免费av| 国产成人超碰人人澡人人澡| 麻豆精品国产91久久久久久| 首页综合国产亚洲丝袜| 亚洲成人av电影在线| 亚洲国产乱码最新视频| 午夜在线电影亚洲一区| 日韩主播视频在线| 老司机免费视频一区二区三区| 日本色综合中文字幕| 日韩综合在线视频| 韩国成人精品a∨在线观看| 国产一本一道久久香蕉| 粉嫩嫩av羞羞动漫久久久| 成人av电影在线网| 色欧美88888久久久久久影院| 在线视频一区二区三区| 欧美绝品在线观看成人午夜影视| 日韩视频永久免费| 国产欧美日韩精品a在线观看| 亚洲欧洲日产国码二区| 一区二区久久久久久| 日韩精品亚洲一区二区三区免费| 国产做a爰片久久毛片| 成人av集中营| 欧美一二三区在线| 国产精品色哟哟| 亚洲成人免费视| 国产在线国偷精品产拍免费yy| 成人免费高清在线| 欧美日韩精品一区二区天天拍小说| 欧美成人a∨高清免费观看| 国产精品美女久久久久av爽李琼| 亚洲国产精品久久艾草纯爱| 国产一区二区不卡老阿姨| 色美美综合视频| 亚洲精品在线观看视频| 亚洲精品久久久蜜桃| 国产一区二区美女诱惑| 欧美亚洲综合一区| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 成人aaaa免费全部观看| 欧美久久久久中文字幕| 中文字幕亚洲成人| 国产在线不卡一区| 91精品国产综合久久精品app | 首页国产欧美日韩丝袜| 国产99精品国产| 日韩午夜激情视频| 亚洲成人动漫av| 99在线精品免费| 久久只精品国产| 日本美女视频一区二区| 91成人免费网站| 亚洲欧洲美洲综合色网| 久久99国产精品久久99| 欧美日韩在线综合| 亚洲激情第一区| 成人短视频下载| 久久综合九色综合欧美就去吻| 亚洲成av人片| 欧美性大战久久久| 一区二区三区四区高清精品免费观看 | 日本一区二区三区久久久久久久久不 | 亚洲欧美另类图片小说| 成人夜色视频网站在线观看| 日韩欧美精品在线| 青椒成人免费视频| 欧美美女bb生活片| 日本不卡视频在线观看| 91精品一区二区三区久久久久久| 亚洲国产视频在线| 欧美亚洲一区二区三区四区| 亚洲欧美精品午睡沙发| 97精品电影院| 亚洲在线免费播放| 欧美性做爰猛烈叫床潮| 亚洲va韩国va欧美va精品| 欧美日韩1区2区| 奇米影视一区二区三区| 欧美成人国产一区二区| 国产精品一区二区三区四区| 国产女人18水真多18精品一级做| 成人激情av网| 亚洲一区二区三区四区在线观看 | 欧美一区二区在线免费观看| 日本成人在线不卡视频| 欧美精品一区二区三区蜜臀| 国产精品一区二区三区乱码| 中文字幕在线不卡视频| 欧美在线观看视频一区二区| 午夜精品视频在线观看| 日韩免费视频一区二区| 国产成人高清在线| 亚洲一区在线免费观看| 日韩欧美精品在线| 波多野洁衣一区| 亚洲国产精品尤物yw在线观看| 日韩欧美一区中文| 成人一区二区三区在线观看 | 精品制服美女久久| 中文字幕一区免费在线观看| 欧美日韩高清不卡| 国产成人精品三级| 亚洲尤物视频在线| 久久亚洲一区二区三区明星换脸| 99在线精品观看| 免费成人av在线| 国产精品免费视频一区| 制服丝袜一区二区三区| 成人白浆超碰人人人人| 亚洲风情在线资源站| 国产欧美精品区一区二区三区| 欧美日韩中文精品| 成人午夜激情片| 蓝色福利精品导航| 一区二区三区国产精华| 久久精品一级爱片| 91精品国产乱| 色呦呦国产精品| 国产福利一区在线观看| 奇米一区二区三区| 亚洲国产日韩一级| 亚洲天天做日日做天天谢日日欢| 日韩三级视频在线看| 91成人在线观看喷潮| 成人app软件下载大全免费| 九九视频精品免费| 日韩影院免费视频| 一区二区不卡在线播放| 亚洲国产精华液网站w| 欧美精品一区二区不卡 | 国产一区不卡视频| 日韩国产欧美三级| 一区二区三区在线观看欧美| 国产精品美女久久久久aⅴ| 久久奇米777| 555www色欧美视频| 欧美日韩三级一区二区| 91在线视频观看| 久久成人av少妇免费| 日韩电影在线观看一区| 亚洲午夜在线观看视频在线| 亚洲激情图片一区| 亚洲精品日日夜夜| 一区在线观看视频| 国产精品家庭影院| 国产精品欧美精品| 国产精品乱人伦| 国产精品二三区| 国产精品青草久久| 国产精品卡一卡二| 综合婷婷亚洲小说| 一区二区三区四区国产精品| 亚洲制服丝袜av| 亚洲123区在线观看| 亚洲成人资源在线| 蜜臀av在线播放一区二区三区| 免费成人在线播放| 久久99国产精品免费网站| 国产伦精品一区二区三区免费迷| 国产原创一区二区| 成人少妇影院yyyy| 一本一道久久a久久精品综合蜜臀 一本一道综合狠狠老 | 色综合久久久久久久久久久| 91视频精品在这里| 欧美日韩中文国产| 精品美女一区二区三区| 国产欧美一区二区精品性色超碰 | 久久久天堂av| 中文字幕日韩一区二区| 一区二区三区中文在线| 日韩精品电影在线观看| 狠狠色综合播放一区二区| 国产精品综合网| 91亚洲精品久久久蜜桃网站| 欧美视频中文字幕| 日韩欧美中文字幕公布| 亚洲国产电影在线观看| 亚洲一区av在线| 国产一区在线看| 日本大香伊一区二区三区| 日韩一区二区三区免费看| 中文字幕精品综合| 午夜av电影一区| 国产91丝袜在线播放0| 欧美日韩极品在线观看一区| 精品国产成人在线影院| 亚洲精品日日夜夜| 国产麻豆精品95视频| 在线观看网站黄不卡| 久久人人爽人人爽| 亚洲国产精品一区二区www| 国产精品一区在线观看你懂的| 99国产欧美另类久久久精品| 日韩亚洲欧美在线观看| 亚洲黄一区二区三区| 国产激情一区二区三区| 91精品国产综合久久香蕉麻豆 |