/* --COPYRIGHT--,BSD
* Copyright (c) 2012, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
/******************************************************************************/
// command.c
// Definition of TI_DALI_Command(), DALI commands 0-255
//
//
// Chris Sterzik
// Texas Instruments
// Built with CCS Version: 5.20
//
// Revision 1.1 09/17/2012
/******************************************************************************/
// THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
// REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
// INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
// COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
// TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
// POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
// INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
// YOUR USE OF THE PROGRAM.
//
// IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
// CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
// THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
// OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
// EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
// REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
// OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
// USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
// AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
// YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
// (U.S.$500).
//
// Unless otherwise stated, the Program written and copyrighted
// by Texas Instruments is distributed as "freeware". You may,
// only under TI's copyright in the Program, use and modify the
// Program without any charge or restriction. You may
// distribute to third parties, provided that you transfer a
// copy of this license to the third party and the third party
// agrees to these terms by its first use of the Program. You
// must reproduce the copyright notice and any other legend of
// ownership on each copy or partial copy, of the Program.
//
// You acknowledge and agree that the Program contains
// copyrighted material, trade secrets and other TI proprietary
// information and is protected by copyright laws,
// international copyright treaties, and trade secret laws, as
// well as other intellectual property laws. To protect TI's
// rights in the Program, you agree not to decompile, reverse
// engineer, disassemble or otherwise translate any object code
// versions of the Program to a human-readable form. You agree
// that in no event will you alter, remove or destroy any
// copyright notice included in the Program. TI reserves all
// rights not specifically granted under this license. Except
// as specifically provided herein, nothing in this agreement
// shall be construed as conferring by implication, estoppel,
// or otherwise, upon you, any license or other right under any
// TI patents, copyrights or trade secrets.
#include "dali_demo_hw.h"
#include "dali.h"
#include "command.h"
/*** fade_200ms: fade up or down 200ms at the selected fade rate **************/
/* This number represents the number of to be added to or subtracted from the */
/* actual_level to achieve the new target_level. */
const unsigned char fade_200ms[16] =
{ OFF, FADE_200ms_1, FADE_200ms_2, FADE_200ms_3, FADE_200ms_4, FADE_200ms_5,
FADE_200ms_6, FADE_200ms_7, FADE_200ms_8, FADE_200ms_9, FADE_200ms_A,
FADE_200ms_B, FADE_200ms_C, FADE_200ms_D, FADE_200ms_E, FADE_200ms_F
};
/*** fade_rate_table **********************************************************/
/* This array is used to set fade_step_size (in WDT intervals). This */
/* represents the number of times the WDT ISR is called before the arc power */
/* level is updated. */
const unsigned int fade_rate_table[16] =
{ OFF, FADE_RATE_1, FADE_RATE_2, FADE_RATE_3, FADE_RATE_4, FADE_RATE_5,
FADE_RATE_6, FADE_RATE_7, FADE_RATE_8, FADE_RATE_9, FADE_RATE_A, FADE_RATE_B,
FADE_RATE_C, FADE_RATE_D, FADE_RATE_E, FADE_RATE_F
};
/*** fade_time_table **********************************************************/
/* This array represents the amount of time (in WDT intervals) that the */
/* control gear will take to get from the actual_level to the target_level. */
/* This array divided by the (target_level-acutal_level) provides the fade */
/* rate which is loaded into fade_step_size. */
const unsigned long int fade_time_table[16] =
{ OFF, FADE_TIME_1, FADE_TIME_2, FADE_TIME_3, FADE_TIME_4, FADE_TIME_5,
FADE_TIME_6, FADE_TIME_7, FADE_TIME_8, FADE_TIME_9, FADE_TIME_A, FADE_TIME_B,
FADE_TIME_C, FADE_TIME_D, FADE_TIME_E, FADE_TIME_F
};
/*** fast_fade_time_table *****************************************************/
/* This fast fade time is to be used when fade time is 0. */
const unsigned long int fast_fade_time_table[28] =
{ OFF, FAST_FADE_TIME_1, FAST_FADE_TIME_2, FAST_FADE_TIME_3, FAST_FADE_TIME_4,
FAST_FADE_TIME_5, FAST_FADE_TIME_6, FAST_FADE_TIME_7, FAST_FADE_TIME_8,
FAST_FADE_TIME_9, FAST_FADE_TIME_A, FAST_FADE_TIME_B, FAST_FADE_TIME_C,
FAST_FADE_TIME_D, FAST_FADE_TIME_E, FAST_FADE_TIME_F, FAST_FADE_TIME_10,
FAST_FADE_TIME_11, FAST_FADE_TIME_12, FAST_FADE_TIME_13, FAST_FADE_TIME_14,
FAST_FADE_TIME_15, FAST_FADE_TIME_16, FAST_FADE_TIME_17, FAST_FADE_TIME_18,
FAST_FADE_TIME_19, FAST_FADE_TIME_1A, FAST_FADE_TIME_1B
};
/******************************************************************************/
/*execute_command */
/******************************************************************************/
unsigned char TI_DALI_Command(unsigned char *rx_msg)
{
unsigned char response=0;
unsigned char update_value;
if(rx_msg[0] & BIT0) // Selector bit
{ /* Command is found in rx_ms