Gledopto Mini5In1 TLSR8258F512ET32 support
parent
1945589d60
commit
edff6aef13
36
app_cfg.h
36
app_cfg.h
|
@ -44,23 +44,15 @@ extern "C" {
|
||||||
/* HCI interface */
|
/* HCI interface */
|
||||||
#define ZBHCI_UART 0
|
#define ZBHCI_UART 0
|
||||||
|
|
||||||
/* RGB or CCT */
|
/* RGB + CCT always */
|
||||||
#define COLOR_RGB_SUPPORT 0
|
#define COLOR_RGB_SUPPORT 1
|
||||||
#define COLOR_CCT_SUPPORT 1
|
|
||||||
|
|
||||||
/* BDB */
|
/* BDB */
|
||||||
#define TOUCHLINK_SUPPORT 1
|
#define TOUCHLINK_SUPPORT 1
|
||||||
#define FIND_AND_BIND_SUPPORT 0
|
#define FIND_AND_BIND_SUPPORT 0
|
||||||
|
|
||||||
/* Board ID */
|
/* Board ID */
|
||||||
#define BOARD_826x_EVK 0
|
#define BOARD_GLC002P 0
|
||||||
#define BOARD_826x_DONGLE 1
|
|
||||||
#define BOARD_8258_EVK 2
|
|
||||||
#define BOARD_8258_DONGLE 3
|
|
||||||
#define BOARD_8278_EVK 4
|
|
||||||
#define BOARD_8278_DONGLE 5
|
|
||||||
#define BOARD_9518_EVK 6
|
|
||||||
#define BOARD_9518_DONGLE 7
|
|
||||||
|
|
||||||
/* Board define */
|
/* Board define */
|
||||||
#if defined(MCU_CORE_826x)
|
#if defined(MCU_CORE_826x)
|
||||||
|
@ -70,7 +62,7 @@ extern "C" {
|
||||||
#if (CHIP_TYPE == TLSR_8258_1M)
|
#if (CHIP_TYPE == TLSR_8258_1M)
|
||||||
#define FLASH_CAP_SIZE_1M 1
|
#define FLASH_CAP_SIZE_1M 1
|
||||||
#endif
|
#endif
|
||||||
#define BOARD BOARD_8258_DONGLE//BOARD_8258_EVK
|
#define BOARD BOARD_GLC002P
|
||||||
#define CLOCK_SYS_CLOCK_HZ 48000000
|
#define CLOCK_SYS_CLOCK_HZ 48000000
|
||||||
#elif defined(MCU_CORE_8278)
|
#elif defined(MCU_CORE_8278)
|
||||||
#define FLASH_CAP_SIZE_1M 1
|
#define FLASH_CAP_SIZE_1M 1
|
||||||
|
@ -85,22 +77,8 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Board include */
|
/* Board include */
|
||||||
#if (BOARD == BOARD_826x_EVK)
|
#if(BOARD == BOARD_GLC002P)
|
||||||
#include "board_826x_evk.h"
|
#include "board_glc002p.h"
|
||||||
#elif(BOARD == BOARD_826x_DONGLE)
|
|
||||||
#include "board_826x_dongle.h"
|
|
||||||
#elif(BOARD == BOARD_8258_DONGLE)
|
|
||||||
#include "board_8258_dongle.h"
|
|
||||||
#elif(BOARD == BOARD_8258_EVK)
|
|
||||||
#include "board_8258_evk.h"
|
|
||||||
#elif(BOARD == BOARD_8278_EVK)
|
|
||||||
#include "board_8278_evk.h"
|
|
||||||
#elif(BOARD == BOARD_8278_DONGLE)
|
|
||||||
#include "board_8278_dongle.h"
|
|
||||||
#elif (BOARD == BOARD_9518_EVK)
|
|
||||||
#include "board_9518_evk.h"
|
|
||||||
#elif (BOARD == BOARD_9518_DONGLE)
|
|
||||||
#include "board_9518_dongle.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,7 +107,7 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define ZCL_ON_OFF_SUPPORT 1
|
#define ZCL_ON_OFF_SUPPORT 1
|
||||||
#define ZCL_LEVEL_CTRL_SUPPORT 1
|
#define ZCL_LEVEL_CTRL_SUPPORT 1
|
||||||
#if (COLOR_RGB_SUPPORT || COLOR_CCT_SUPPORT)
|
#if (COLOR_RGB_SUPPORT)
|
||||||
#define ZCL_LIGHT_COLOR_CONTROL_SUPPORT 1
|
#define ZCL_LIGHT_COLOR_CONTROL_SUPPORT 1
|
||||||
#endif
|
#endif
|
||||||
#define ZCL_GROUP_SUPPORT 1
|
#define ZCL_GROUP_SUPPORT 1
|
||||||
|
|
13
app_ui.c
13
app_ui.c
|
@ -59,8 +59,9 @@ void led_off(u32 pin){
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_init(void){
|
void led_init(void){
|
||||||
led_off(LED_POWER);
|
led_off(LED_STATUS_R);
|
||||||
led_off(LED_PERMIT);
|
led_off(LED_STATUS_G);
|
||||||
|
led_off(LED_STATUS_B);
|
||||||
}
|
}
|
||||||
|
|
||||||
void localPermitJoinState(void){
|
void localPermitJoinState(void){
|
||||||
|
@ -68,9 +69,9 @@ void localPermitJoinState(void){
|
||||||
if(assocPermit != zb_getMacAssocPermit()){
|
if(assocPermit != zb_getMacAssocPermit()){
|
||||||
assocPermit = zb_getMacAssocPermit();
|
assocPermit = zb_getMacAssocPermit();
|
||||||
if(assocPermit){
|
if(assocPermit){
|
||||||
led_on(LED_PERMIT);
|
led_on(LED_STATUS_R);
|
||||||
}else{
|
}else{
|
||||||
led_off(LED_PERMIT);
|
led_off(LED_STATUS_R);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +79,10 @@ void localPermitJoinState(void){
|
||||||
void buttonKeepPressed(u8 btNum){
|
void buttonKeepPressed(u8 btNum){
|
||||||
if(btNum == VK_SW1){
|
if(btNum == VK_SW1){
|
||||||
gLightCtx.state = APP_FACTORY_NEW_DOING;
|
gLightCtx.state = APP_FACTORY_NEW_DOING;
|
||||||
|
led_on(LED_STATUS_R);
|
||||||
|
led_on(LED_STATUS_G);
|
||||||
|
led_on(LED_STATUS_B);
|
||||||
|
|
||||||
zb_factoryReset();
|
zb_factoryReset();
|
||||||
}else if(btNum == VK_SW2){
|
}else if(btNum == VK_SW2){
|
||||||
|
|
||||||
|
|
|
@ -1,295 +0,0 @@
|
||||||
/********************************************************************************************************
|
|
||||||
* @file board_8258_dongle.h
|
|
||||||
*
|
|
||||||
* @brief This is the header file for board_8258_dongle
|
|
||||||
*
|
|
||||||
* @author Zigbee Group
|
|
||||||
* @date 2021
|
|
||||||
*
|
|
||||||
* @par Copyright (c) 2021, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*******************************************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define DONGLE_8258_32 0
|
|
||||||
#define DONGLE_8258_48 1
|
|
||||||
|
|
||||||
#if defined DONGLE_8258_32 && (DONGLE_8258_32 == 1)
|
|
||||||
/*******************************************************************************************************
|
|
||||||
*********************8258Dongle with 32 Pins: Start*****************************************************
|
|
||||||
*******************************************************************************************************/
|
|
||||||
//KEY
|
|
||||||
#define BUTTON1 GPIO_PD7
|
|
||||||
#define PD7_FUNC AS_GPIO
|
|
||||||
#define PD7_OUTPUT_ENABLE 0
|
|
||||||
#define PD7_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PD7 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
#define BUTTON2 GPIO_PA1
|
|
||||||
#define PA1_FUNC AS_GPIO
|
|
||||||
#define PA1_OUTPUT_ENABLE 0
|
|
||||||
#define PA1_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PA1 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
//LED
|
|
||||||
/***************************************************************
|
|
||||||
* LED_R GPIO_PD4 //D1 -- red PWM2_N
|
|
||||||
* LED_G GPIO_PA0 //D2 -- green PWM0_N
|
|
||||||
* LED_B GPIO_PD3 //D3 -- blue PWM1_N
|
|
||||||
* LED_W GPIO_PD2 //D4 -- yellow PWM3
|
|
||||||
****************************************************************/
|
|
||||||
#if defined COLOR_RGB_SUPPORT && (COLOR_RGB_SUPPORT == 1)
|
|
||||||
|
|
||||||
#define LED_R GPIO_PD4 //D1 -- red PWM2_N
|
|
||||||
#define LED_G GPIO_PA0 //D2 -- green PWM0_N
|
|
||||||
#define LED_B GPIO_PD3 //D3 -- blue PWM1_N
|
|
||||||
|
|
||||||
#define PWM_R_CHANNEL 2//PWM2_N
|
|
||||||
#define PWM_R_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_R, AS_PWM2_N); \
|
|
||||||
drv_pwm_n_invert(PWM_R_CHANNEL); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_G_CHANNEL 0//PWM0_N
|
|
||||||
#define PWM_G_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_G, AS_PWM0_N); \
|
|
||||||
drv_pwm_n_invert(PWM_G_CHANNEL); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL 1//PWM1_N
|
|
||||||
#define PWM_B_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_B, AS_PWM1_N); \
|
|
||||||
drv_pwm_n_invert(PWM_B_CHANNEL); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define R_LIGHT_PWM_CHANNEL PWM_R_CHANNEL
|
|
||||||
#define G_LIGHT_PWM_CHANNEL PWM_G_CHANNEL
|
|
||||||
#define B_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define R_LIGHT_PWM_SET() PWM_R_CHANNEL_SET()
|
|
||||||
#define G_LIGHT_PWM_SET() PWM_G_CHANNEL_SET()
|
|
||||||
#define B_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
|
|
||||||
#define LED_W GPIO_PD2
|
|
||||||
|
|
||||||
#define PD2_FUNC AS_GPIO
|
|
||||||
#define PD2_OUTPUT_ENABLE 1
|
|
||||||
#define PD2_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER NULL
|
|
||||||
#define LED_PERMIT LED_W
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
//PWM configuration, LED_B as warm light, LED_W as cool light.
|
|
||||||
#define LED_B GPIO_PD3 //D3 -- blue PWM1_N
|
|
||||||
#define LED_W GPIO_PD2 //D4 -- yellow PWM3
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL 1//PWM1_N
|
|
||||||
#define PWM_B_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_B, AS_PWM1_N); \
|
|
||||||
drv_pwm_n_invert(PWM_B_CHANNEL); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_W_CHANNEL 3//PWM3
|
|
||||||
#define PWM_W_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_W, AS_PWM3); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define WARM_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define COOL_LIGHT_PWM_CHANNEL PWM_W_CHANNEL
|
|
||||||
#define WARM_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
#define COOL_LIGHT_PWM_SET() PWM_W_CHANNEL_SET()
|
|
||||||
|
|
||||||
//LED_R and LED_G as GPIO.
|
|
||||||
#define LED_R GPIO_PD4
|
|
||||||
#define LED_G GPIO_PA0
|
|
||||||
|
|
||||||
#define PD4_FUNC AS_GPIO
|
|
||||||
#define PD4_OUTPUT_ENABLE 1
|
|
||||||
#define PD4_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PA0_FUNC AS_GPIO
|
|
||||||
#define PA0_OUTPUT_ENABLE 1
|
|
||||||
#define PA0_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER LED_R
|
|
||||||
#define LED_PERMIT LED_G
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// UART
|
|
||||||
#if ZBHCI_UART
|
|
||||||
#error please configurate uart PIN!!!!!!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
#if UART_PRINTF_MODE
|
|
||||||
#define DEBUG_INFO_TX_PIN GPIO_PC4//print
|
|
||||||
#endif
|
|
||||||
/*******************************************************************************************************
|
|
||||||
*********************8258Dongle with 32 Pins: End*****************************************************
|
|
||||||
*******************************************************************************************************/
|
|
||||||
#elif defined DONGLE_8258_48 && (DONGLE_8258_48 == 1)
|
|
||||||
/*******************************************************************************************************
|
|
||||||
*********************8258Dongle with 48 Pins: Start*****************************************************
|
|
||||||
*******************************************************************************************************/
|
|
||||||
//KEY
|
|
||||||
#define BUTTON1 GPIO_PD6
|
|
||||||
#define PD6_FUNC AS_GPIO
|
|
||||||
#define PD6_OUTPUT_ENABLE 0
|
|
||||||
#define PD6_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PD6 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
#define BUTTON2 GPIO_PD5
|
|
||||||
#define PD5_FUNC AS_GPIO
|
|
||||||
#define PD5_OUTPUT_ENABLE 0
|
|
||||||
#define PD5_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PD5 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
//LED
|
|
||||||
/***************************************************************
|
|
||||||
* LED_R GPIO_PA3 //D2 -- red PWM1
|
|
||||||
* LED_G GPIO_PA2 //D1 -- green PWM0
|
|
||||||
* LED_B GPIO_PB0 //D4 -- blue PWM3
|
|
||||||
* LED_W GPIO_PB1 //D5 -- white PWM4
|
|
||||||
* LED_Y GPIO_PA4 //D3 -- yellow PWM2
|
|
||||||
****************************************************************/
|
|
||||||
#if defined COLOR_RGB_SUPPORT && (COLOR_RGB_SUPPORT == 1)
|
|
||||||
|
|
||||||
#define LED_R GPIO_PA3 //D2 -- red PWM1
|
|
||||||
#define LED_G GPIO_PA2 //D1 -- green PWM0
|
|
||||||
#define LED_B GPIO_PB0 //D4 -- blue PWM3
|
|
||||||
|
|
||||||
#define PWM_R_CHANNEL 1//PWM1
|
|
||||||
#define PWM_R_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_R, AS_PWM1); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_G_CHANNEL 0//PWM0
|
|
||||||
#define PWM_G_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_G, AS_PWM0); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL 3//PWM3
|
|
||||||
#define PWM_B_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_B, AS_PWM3); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define R_LIGHT_PWM_CHANNEL PWM_R_CHANNEL
|
|
||||||
#define G_LIGHT_PWM_CHANNEL PWM_G_CHANNEL
|
|
||||||
#define B_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define R_LIGHT_PWM_SET() PWM_R_CHANNEL_SET()
|
|
||||||
#define G_LIGHT_PWM_SET() PWM_G_CHANNEL_SET()
|
|
||||||
#define B_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
|
|
||||||
//LED_Y and LED_W as GPIO.
|
|
||||||
#define LED_Y GPIO_PA4
|
|
||||||
#define LED_W GPIO_PB1
|
|
||||||
|
|
||||||
#define PA4_FUNC AS_GPIO
|
|
||||||
#define PA4_OUTPUT_ENABLE 1
|
|
||||||
#define PA4_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PB1_FUNC AS_GPIO
|
|
||||||
#define PB1_OUTPUT_ENABLE 1
|
|
||||||
#define PB1_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER LED_W
|
|
||||||
#define LED_PERMIT LED_Y
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
//PWM configuration, LED_Y as warm light, LED_W as cool light.
|
|
||||||
#define LED_Y GPIO_PA4 //D3 -- yellow PWM2
|
|
||||||
#define LED_W GPIO_PB1 //D5 -- white PWM4
|
|
||||||
|
|
||||||
#define PWM_Y_CHANNEL 2//PWM2
|
|
||||||
#define PWM_Y_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_Y, AS_PWM2); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_W_CHANNEL 4//PWM4
|
|
||||||
#define PWM_W_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_W, AS_PWM4); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define WARM_LIGHT_PWM_CHANNEL PWM_Y_CHANNEL
|
|
||||||
#define COOL_LIGHT_PWM_CHANNEL PWM_W_CHANNEL
|
|
||||||
#define WARM_LIGHT_PWM_SET() PWM_Y_CHANNEL_SET()
|
|
||||||
#define COOL_LIGHT_PWM_SET() PWM_W_CHANNEL_SET()
|
|
||||||
|
|
||||||
//LED_R and LED_G as GPIO.
|
|
||||||
#define LED_R GPIO_PA3
|
|
||||||
#define LED_G GPIO_PA2
|
|
||||||
|
|
||||||
#define PA3_FUNC AS_GPIO
|
|
||||||
#define PA3_OUTPUT_ENABLE 1
|
|
||||||
#define PA3_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PA2_FUNC AS_GPIO
|
|
||||||
#define PA2_OUTPUT_ENABLE 1
|
|
||||||
#define PA2_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER LED_R
|
|
||||||
#define LED_PERMIT LED_G
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// UART
|
|
||||||
#if ZBHCI_UART
|
|
||||||
#define UART_TX_PIN UART_TX_PD7
|
|
||||||
#define UART_RX_PIN UART_RX_PA0
|
|
||||||
|
|
||||||
#define UART_PIN_CFG() uart_gpio_set(UART_TX_PIN, UART_RX_PIN);// uart tx/rx pin set
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
#if UART_PRINTF_MODE
|
|
||||||
#define DEBUG_INFO_TX_PIN GPIO_PC6//print
|
|
||||||
#endif
|
|
||||||
/*******************************************************************************************************
|
|
||||||
*********************8258Dongle with 48 Pins: End*****************************************************
|
|
||||||
*******************************************************************************************************/
|
|
||||||
#else
|
|
||||||
#error "Board defined error!"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
enum{
|
|
||||||
VK_SW1 = 0x01,
|
|
||||||
VK_SW2 = 0x02
|
|
||||||
};
|
|
||||||
|
|
||||||
#define KB_MAP_NORMAL {\
|
|
||||||
{VK_SW1,}, \
|
|
||||||
{VK_SW2,}, }
|
|
||||||
|
|
||||||
#define KB_MAP_NUM KB_MAP_NORMAL
|
|
||||||
#define KB_MAP_FN KB_MAP_NORMAL
|
|
||||||
|
|
||||||
#define KB_DRIVE_PINS {NULL }
|
|
||||||
#define KB_SCAN_PINS {BUTTON1, BUTTON2}
|
|
||||||
|
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
123
board_8258_evk.h
123
board_8258_evk.h
|
@ -1,123 +0,0 @@
|
||||||
/********************************************************************************************************
|
|
||||||
* @file board_8258_evk.h
|
|
||||||
*
|
|
||||||
* @brief This is the header file for board_8258_evk
|
|
||||||
*
|
|
||||||
* @author Zigbee Group
|
|
||||||
* @date 2021
|
|
||||||
*
|
|
||||||
* @par Copyright (c) 2021, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*******************************************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// BUTTON
|
|
||||||
#define BUTTON1 GPIO_PD1
|
|
||||||
#define PD1_FUNC AS_GPIO
|
|
||||||
#define PD1_OUTPUT_ENABLE 0
|
|
||||||
#define PD1_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PD1 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
#define BUTTON2 GPIO_PD2
|
|
||||||
#define PD2_FUNC AS_GPIO
|
|
||||||
#define PD2_OUTPUT_ENABLE 0
|
|
||||||
#define PD2_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PD2 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
// LED
|
|
||||||
/***************************************************************
|
|
||||||
* LED_R GPIO_PD0 //D5 -- red
|
|
||||||
* LED_G GPIO_PD4 //D3 -- green
|
|
||||||
* LED_B GPIO_PD5 //D2 -- blue
|
|
||||||
* LED_W GPIO_PD3 //D4 -- yellow
|
|
||||||
****************************************************************/
|
|
||||||
#if defined COLOR_RGB_SUPPORT && (COLOR_RGB_SUPPORT == 1)
|
|
||||||
#error "GPIO_PD0 can't be configured as PWM!"
|
|
||||||
#else
|
|
||||||
|
|
||||||
//PWM configuration, LED_B as warm light, LED_W as cool light.
|
|
||||||
#define LED_B GPIO_PD5 //D2 -- blue PWM0
|
|
||||||
#define LED_W GPIO_PD3 //D4 -- yellow PWM1_N
|
|
||||||
|
|
||||||
#define PWM_W_CHANNEL 1 //PWM1_N
|
|
||||||
#define PWM_W_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_W, AS_PWM1_N); \
|
|
||||||
drv_pwm_n_invert(PWM_W_CHANNEL); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL 0 //PWM0
|
|
||||||
#define PWM_B_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_B, AS_PWM0); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define WARM_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define COOL_LIGHT_PWM_CHANNEL PWM_W_CHANNEL
|
|
||||||
#define WARM_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
#define COOL_LIGHT_PWM_SET() PWM_W_CHANNEL_SET()
|
|
||||||
|
|
||||||
//LED_R and LED_G as GPIO.
|
|
||||||
#define LED_R GPIO_PD0
|
|
||||||
#define LED_G GPIO_PD4
|
|
||||||
|
|
||||||
#define PD4_FUNC AS_GPIO
|
|
||||||
#define PD4_OUTPUT_ENABLE 1
|
|
||||||
#define PD4_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PD0_FUNC AS_GPIO
|
|
||||||
#define PD0_OUTPUT_ENABLE 1
|
|
||||||
#define PD0_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER LED_R
|
|
||||||
#define LED_PERMIT LED_G
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// UART
|
|
||||||
#if ZBHCI_UART
|
|
||||||
#error please configurate uart PIN!!!!!!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
#if UART_PRINTF_MODE
|
|
||||||
#define DEBUG_INFO_TX_PIN GPIO_PC7//print
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
enum{
|
|
||||||
VK_SW1 = 0x01,
|
|
||||||
VK_SW2 = 0x02
|
|
||||||
};
|
|
||||||
|
|
||||||
#define KB_MAP_NORMAL {\
|
|
||||||
{VK_SW1,}, \
|
|
||||||
{VK_SW2,}, }
|
|
||||||
|
|
||||||
#define KB_MAP_NUM KB_MAP_NORMAL
|
|
||||||
#define KB_MAP_FN KB_MAP_NORMAL
|
|
||||||
|
|
||||||
#define KB_DRIVE_PINS {NULL }
|
|
||||||
#define KB_SCAN_PINS {BUTTON1, BUTTON2}
|
|
||||||
|
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,158 +0,0 @@
|
||||||
/********************************************************************************************************
|
|
||||||
* @file board_826x_dongle.h
|
|
||||||
*
|
|
||||||
* @brief This is the header file for board_826x_dongle
|
|
||||||
*
|
|
||||||
* @author Zigbee Group
|
|
||||||
* @date 2021
|
|
||||||
*
|
|
||||||
* @par Copyright (c) 2021, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*******************************************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//KEY
|
|
||||||
#define BUTTON1 GPIO_PD2
|
|
||||||
#define PD2_FUNC AS_GPIO
|
|
||||||
#define PD2_OUTPUT_ENABLE 0
|
|
||||||
#define PD2_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PD2 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
#define BUTTON2 GPIO_PC5
|
|
||||||
#define PC5_FUNC AS_GPIO
|
|
||||||
#define PC5_OUTPUT_ENABLE 0
|
|
||||||
#define PC5_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PC5 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
//LED
|
|
||||||
/***************************************************************
|
|
||||||
* LED_R GPIO_PC2 //D3 -- red PWM2
|
|
||||||
* LED_G GPIO_PC3 //D1 -- green PWM3
|
|
||||||
* LED_B GPIO_PB6 //D2 -- blue PWM5
|
|
||||||
* LED_W GPIO_PB4 //D4 -- white PWM4
|
|
||||||
****************************************************************/
|
|
||||||
#if defined COLOR_RGB_SUPPORT && (COLOR_RGB_SUPPORT == 1)
|
|
||||||
|
|
||||||
#define PC2_FUNC AS_PWM
|
|
||||||
#define PC2_OUTPUT_ENABLE 1
|
|
||||||
#define PC2_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PC3_FUNC AS_PWM
|
|
||||||
#define PC3_OUTPUT_ENABLE 1
|
|
||||||
#define PC3_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PB6_FUNC AS_PWM
|
|
||||||
#define PB6_OUTPUT_ENABLE 1
|
|
||||||
#define PB6_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PWM_R_CHANNEL_SET() PWM2_CFG_GPIO_C2()
|
|
||||||
#define PWM_R_CHANNEL 2//PWM2
|
|
||||||
|
|
||||||
#define PWM_G_CHANNEL_SET() PWM3_CFG_GPIO_C3()
|
|
||||||
#define PWM_G_CHANNEL 3//PWM3
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL_SET() PWM5_CFG_GPIO_B6()
|
|
||||||
#define PWM_B_CHANNEL 5//PWM5
|
|
||||||
|
|
||||||
#define R_LIGHT_PWM_CHANNEL PWM_R_CHANNEL
|
|
||||||
#define G_LIGHT_PWM_CHANNEL PWM_G_CHANNEL
|
|
||||||
#define B_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define R_LIGHT_PWM_SET() PWM_R_CHANNEL_SET()
|
|
||||||
#define G_LIGHT_PWM_SET() PWM_G_CHANNEL_SET()
|
|
||||||
#define B_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
|
|
||||||
#define LED_W GPIO_PB4
|
|
||||||
|
|
||||||
#define PB4_FUNC AS_GPIO
|
|
||||||
#define PB4_OUTPUT_ENABLE 1
|
|
||||||
#define PB4_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER NULL
|
|
||||||
#define LED_PERMIT LED_W
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
//PWM configuration, LED_B as warm light, LED_W as cool light.
|
|
||||||
#define PB6_FUNC AS_PWM
|
|
||||||
#define PB6_OUTPUT_ENABLE 1
|
|
||||||
#define PB6_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PB4_FUNC AS_PWM
|
|
||||||
#define PB4_OUTPUT_ENABLE 1
|
|
||||||
#define PB4_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL_SET() PWM5_CFG_GPIO_B6()
|
|
||||||
#define PWM_B_CHANNEL 5//PWM5
|
|
||||||
|
|
||||||
#define PWM_W_CHANNEL_SET() PWM4_CFG_GPIO_B4()
|
|
||||||
#define PWM_W_CHANNEL 4//PWM4
|
|
||||||
|
|
||||||
#define WARM_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define COOL_LIGHT_PWM_CHANNEL PWM_W_CHANNEL
|
|
||||||
#define WARM_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
#define COOL_LIGHT_PWM_SET() PWM_W_CHANNEL_SET()
|
|
||||||
|
|
||||||
#define LED_R GPIO_PC2
|
|
||||||
#define LED_G GPIO_PC3
|
|
||||||
|
|
||||||
#define PC2_FUNC AS_GPIO
|
|
||||||
#define PC2_OUTPUT_ENABLE 1
|
|
||||||
#define PC2_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PC3_FUNC AS_GPIO
|
|
||||||
#define PC3_OUTPUT_ENABLE 1
|
|
||||||
#define PC3_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER LED_R
|
|
||||||
#define LED_PERMIT LED_G
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//UART
|
|
||||||
#if ZBHCI_UART
|
|
||||||
PC2 & PC3 are configured as LED pins
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
#if UART_PRINTF_MODE
|
|
||||||
#define DEBUG_INFO_TX_PIN GPIO_PB5//print
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
enum{
|
|
||||||
VK_SW1 = 0x01,
|
|
||||||
VK_SW2 = 0x02
|
|
||||||
};
|
|
||||||
|
|
||||||
#define KB_MAP_NORMAL {\
|
|
||||||
{VK_SW1,}, \
|
|
||||||
{VK_SW2,}, }
|
|
||||||
|
|
||||||
#define KB_MAP_NUM KB_MAP_NORMAL
|
|
||||||
#define KB_MAP_FN KB_MAP_NORMAL
|
|
||||||
|
|
||||||
#define KB_DRIVE_PINS {NULL }
|
|
||||||
#define KB_SCAN_PINS {BUTTON1, BUTTON2}
|
|
||||||
|
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
158
board_826x_evk.h
158
board_826x_evk.h
|
@ -1,158 +0,0 @@
|
||||||
/********************************************************************************************************
|
|
||||||
* @file board_826x_evk.h
|
|
||||||
*
|
|
||||||
* @brief This is the header file for board_826x_evk
|
|
||||||
*
|
|
||||||
* @author Zigbee Group
|
|
||||||
* @date 2021
|
|
||||||
*
|
|
||||||
* @par Copyright (c) 2021, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*******************************************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//KEY
|
|
||||||
#define BUTTON1 GPIO_PD2
|
|
||||||
#define PD2_FUNC AS_GPIO
|
|
||||||
#define PD2_OUTPUT_ENABLE 0
|
|
||||||
#define PD2_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PD2 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
#define BUTTON2 GPIO_PC7
|
|
||||||
#define PC7_FUNC AS_GPIO
|
|
||||||
#define PC7_OUTPUT_ENABLE 0
|
|
||||||
#define PC7_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PC7 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
//LED
|
|
||||||
/***************************************************************
|
|
||||||
* LED_R GPIO_PD5 //D4 -- red PWM0
|
|
||||||
* LED_G GPIO_PD6 //D2 -- green PWM1
|
|
||||||
* LED_B GPIO_PB4 //D1 -- blue PWM4
|
|
||||||
* LED_W GPIO_PD7 //D3 -- white PWM2
|
|
||||||
****************************************************************/
|
|
||||||
#if defined COLOR_RGB_SUPPORT && (COLOR_RGB_SUPPORT == 1)
|
|
||||||
|
|
||||||
#define PD5_FUNC AS_PWM
|
|
||||||
#define PD5_OUTPUT_ENABLE 1
|
|
||||||
#define PD5_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PD6_FUNC AS_PWM
|
|
||||||
#define PD6_OUTPUT_ENABLE 1
|
|
||||||
#define PD6_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PB4_FUNC AS_PWM
|
|
||||||
#define PB4_OUTPUT_ENABLE 1
|
|
||||||
#define PB4_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PWM_R_CHANNEL_SET() PWM0_CFG_GPIO_D5()
|
|
||||||
#define PWM_R_CHANNEL 0//PWM0
|
|
||||||
|
|
||||||
#define PWM_G_CHANNEL_SET() PWM1_CFG_GPIO_D6()
|
|
||||||
#define PWM_G_CHANNEL 1//PWM1
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL_SET() PWM4_CFG_GPIO_B4()
|
|
||||||
#define PWM_B_CHANNEL 4//PWM4
|
|
||||||
|
|
||||||
#define R_LIGHT_PWM_CHANNEL PWM_R_CHANNEL
|
|
||||||
#define G_LIGHT_PWM_CHANNEL PWM_G_CHANNEL
|
|
||||||
#define B_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define R_LIGHT_PWM_SET() PWM_R_CHANNEL_SET()
|
|
||||||
#define G_LIGHT_PWM_SET() PWM_G_CHANNEL_SET()
|
|
||||||
#define B_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
|
|
||||||
#define LED_W GPIO_PD7
|
|
||||||
|
|
||||||
#define PD7_FUNC AS_GPIO
|
|
||||||
#define PD7_OUTPUT_ENABLE 1
|
|
||||||
#define PD7_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER NULL
|
|
||||||
#define LED_PERMIT LED_W
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
//PWM configuration, LED_B as warm light, LED_W as cool light.
|
|
||||||
#define PB4_FUNC AS_PWM
|
|
||||||
#define PB4_OUTPUT_ENABLE 1
|
|
||||||
#define PB4_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PD7_FUNC AS_PWM
|
|
||||||
#define PD7_OUTPUT_ENABLE 1
|
|
||||||
#define PD7_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL_SET() PWM4_CFG_GPIO_B4()
|
|
||||||
#define PWM_B_CHANNEL 4//PWM4
|
|
||||||
|
|
||||||
#define PWM_W_CHANNEL_SET() PWM2_CFG_GPIO_D7()
|
|
||||||
#define PWM_W_CHANNEL 2//PWM2
|
|
||||||
|
|
||||||
#define WARM_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define COOL_LIGHT_PWM_CHANNEL PWM_W_CHANNEL
|
|
||||||
#define WARM_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
#define COOL_LIGHT_PWM_SET() PWM_W_CHANNEL_SET()
|
|
||||||
|
|
||||||
#define LED_R GPIO_PD5
|
|
||||||
#define LED_G GPIO_PD6
|
|
||||||
|
|
||||||
#define PD5_FUNC AS_GPIO
|
|
||||||
#define PD5_OUTPUT_ENABLE 1
|
|
||||||
#define PD5_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PD6_FUNC AS_GPIO
|
|
||||||
#define PD6_OUTPUT_ENABLE 1
|
|
||||||
#define PD6_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER LED_R
|
|
||||||
#define LED_PERMIT LED_G
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//UART
|
|
||||||
#if ZBHCI_UART
|
|
||||||
#error please configurate uart PIN!!!!!!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
#if UART_PRINTF_MODE
|
|
||||||
#define DEBUG_INFO_TX_PIN GPIO_PC5//print
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
enum{
|
|
||||||
VK_SW1 = 0x01,
|
|
||||||
VK_SW2 = 0x02
|
|
||||||
};
|
|
||||||
|
|
||||||
#define KB_MAP_NORMAL {\
|
|
||||||
{VK_SW1,}, \
|
|
||||||
{VK_SW2,}, }
|
|
||||||
|
|
||||||
#define KB_MAP_NUM KB_MAP_NORMAL
|
|
||||||
#define KB_MAP_FN KB_MAP_NORMAL
|
|
||||||
|
|
||||||
#define KB_DRIVE_PINS {NULL }
|
|
||||||
#define KB_SCAN_PINS {BUTTON1, BUTTON2}
|
|
||||||
|
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,170 +0,0 @@
|
||||||
/********************************************************************************************************
|
|
||||||
* @file board_8278_dongle.h
|
|
||||||
*
|
|
||||||
* @brief This is the header file for board_8278_dongle
|
|
||||||
*
|
|
||||||
* @author Zigbee Group
|
|
||||||
* @date 2021
|
|
||||||
*
|
|
||||||
* @par Copyright (c) 2021, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*******************************************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************************************
|
|
||||||
*********************8278Dongle with 48 Pins: Start*****************************************************
|
|
||||||
*******************************************************************************************************/
|
|
||||||
//KEY
|
|
||||||
#define BUTTON1 GPIO_PD6
|
|
||||||
#define PD6_FUNC AS_GPIO
|
|
||||||
#define PD6_OUTPUT_ENABLE 0
|
|
||||||
#define PD6_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PD6 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
#define BUTTON2 GPIO_PD5
|
|
||||||
#define PD5_FUNC AS_GPIO
|
|
||||||
#define PD5_OUTPUT_ENABLE 0
|
|
||||||
#define PD5_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PD5 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
//LED
|
|
||||||
/***************************************************************
|
|
||||||
* LED_R GPIO_PA3 //D2 -- red PWM1
|
|
||||||
* LED_G GPIO_PA2 //D1 -- green PWM0
|
|
||||||
* LED_B GPIO_PB0 //D4 -- blue PWM3
|
|
||||||
* LED_W GPIO_PB1 //D5 -- white PWM4
|
|
||||||
* LED_Y GPIO_PA4 //D3 -- yellow PWM2
|
|
||||||
****************************************************************/
|
|
||||||
#if defined COLOR_RGB_SUPPORT && (COLOR_RGB_SUPPORT == 1)
|
|
||||||
|
|
||||||
#define LED_R GPIO_PA3 //D2 -- red PWM1
|
|
||||||
#define LED_G GPIO_PA2 //D1 -- green PWM0
|
|
||||||
#define LED_B GPIO_PB0 //D4 -- blue PWM3
|
|
||||||
|
|
||||||
#define PWM_R_CHANNEL 1//PWM1
|
|
||||||
#define PWM_R_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_R, AS_PWM1); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_G_CHANNEL 0//PWM0
|
|
||||||
#define PWM_G_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_G, AS_PWM0); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL 3//PWM3
|
|
||||||
#define PWM_B_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_B, AS_PWM3); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define R_LIGHT_PWM_CHANNEL PWM_R_CHANNEL
|
|
||||||
#define G_LIGHT_PWM_CHANNEL PWM_G_CHANNEL
|
|
||||||
#define B_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define R_LIGHT_PWM_SET() PWM_R_CHANNEL_SET()
|
|
||||||
#define G_LIGHT_PWM_SET() PWM_G_CHANNEL_SET()
|
|
||||||
#define B_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
|
|
||||||
//LED_Y and LED_W as GPIO.
|
|
||||||
#define LED_Y GPIO_PA4
|
|
||||||
#define LED_W GPIO_PB1
|
|
||||||
|
|
||||||
#define PA4_FUNC AS_GPIO
|
|
||||||
#define PA4_OUTPUT_ENABLE 1
|
|
||||||
#define PA4_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PB1_FUNC AS_GPIO
|
|
||||||
#define PB1_OUTPUT_ENABLE 1
|
|
||||||
#define PB1_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER LED_W
|
|
||||||
#define LED_PERMIT LED_Y
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
//PWM configuration, LED_Y as warm light, LED_W as cool light.
|
|
||||||
#define LED_Y GPIO_PA4 //D3 -- yellow PWM2
|
|
||||||
#define LED_W GPIO_PB1 //D5 -- white PWM4
|
|
||||||
|
|
||||||
#define PWM_Y_CHANNEL 2//PWM2
|
|
||||||
#define PWM_Y_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_Y, AS_PWM2); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_W_CHANNEL 4//PWM4
|
|
||||||
#define PWM_W_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_W, AS_PWM4); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define WARM_LIGHT_PWM_CHANNEL PWM_Y_CHANNEL
|
|
||||||
#define COOL_LIGHT_PWM_CHANNEL PWM_W_CHANNEL
|
|
||||||
#define WARM_LIGHT_PWM_SET() PWM_Y_CHANNEL_SET()
|
|
||||||
#define COOL_LIGHT_PWM_SET() PWM_W_CHANNEL_SET()
|
|
||||||
|
|
||||||
//LED_R and LED_G as GPIO.
|
|
||||||
#define LED_R GPIO_PA3
|
|
||||||
#define LED_G GPIO_PA2
|
|
||||||
|
|
||||||
#define PA3_FUNC AS_GPIO
|
|
||||||
#define PA3_OUTPUT_ENABLE 1
|
|
||||||
#define PA3_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PA2_FUNC AS_GPIO
|
|
||||||
#define PA2_OUTPUT_ENABLE 1
|
|
||||||
#define PA2_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER LED_R
|
|
||||||
#define LED_PERMIT LED_G
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// UART
|
|
||||||
#if ZBHCI_UART
|
|
||||||
#define UART_TX_PIN UART_TX_PD7
|
|
||||||
#define UART_RX_PIN UART_RX_PA0
|
|
||||||
|
|
||||||
#define UART_PIN_CFG() uart_gpio_set(UART_TX_PIN, UART_RX_PIN);// uart tx/rx pin set
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
#if UART_PRINTF_MODE
|
|
||||||
#define DEBUG_INFO_TX_PIN GPIO_PC6//print
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
enum{
|
|
||||||
VK_SW1 = 0x01,
|
|
||||||
VK_SW2 = 0x02
|
|
||||||
};
|
|
||||||
|
|
||||||
#define KB_MAP_NORMAL {\
|
|
||||||
{VK_SW1,}, \
|
|
||||||
{VK_SW2,}, }
|
|
||||||
|
|
||||||
#define KB_MAP_NUM KB_MAP_NORMAL
|
|
||||||
#define KB_MAP_FN KB_MAP_NORMAL
|
|
||||||
|
|
||||||
#define KB_DRIVE_PINS {NULL }
|
|
||||||
#define KB_SCAN_PINS {BUTTON1, BUTTON2}
|
|
||||||
|
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
124
board_8278_evk.h
124
board_8278_evk.h
|
@ -1,124 +0,0 @@
|
||||||
/********************************************************************************************************
|
|
||||||
* @file board_8278_evk.h
|
|
||||||
*
|
|
||||||
* @brief This is the header file for board_8278_evk
|
|
||||||
*
|
|
||||||
* @author Zigbee Group
|
|
||||||
* @date 2021
|
|
||||||
*
|
|
||||||
* @par Copyright (c) 2021, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*******************************************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// BUTTON
|
|
||||||
#define BUTTON1 GPIO_PB2
|
|
||||||
#define PB2_FUNC AS_GPIO
|
|
||||||
#define PB2_OUTPUT_ENABLE 0
|
|
||||||
#define PB2_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PB2 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
#define BUTTON2 GPIO_PB3
|
|
||||||
#define PB3_FUNC AS_GPIO
|
|
||||||
#define PB3_OUTPUT_ENABLE 0
|
|
||||||
#define PB3_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PB3 PM_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
//LED
|
|
||||||
/***************************************************************
|
|
||||||
* LED_R GPIO_PD0 //D5 -- red
|
|
||||||
* LED_G GPIO_PD4 //D3 -- green
|
|
||||||
* LED_B GPIO_PD5 //D2 -- blue
|
|
||||||
* LED_W GPIO_PD3 //D4 -- yellow
|
|
||||||
****************************************************************/
|
|
||||||
#if defined COLOR_RGB_SUPPORT && (COLOR_RGB_SUPPORT == 1)
|
|
||||||
|
|
||||||
#error "GPIO_PD0 can't be configured as PWM!"
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
//PWM configuration, LED_B as warm light, LED_W as cool light.
|
|
||||||
#define LED_B GPIO_PD2 //D2 -- blue PWM3
|
|
||||||
#define LED_W GPIO_PD4 //D4 -- white PWM2_N
|
|
||||||
|
|
||||||
#define PWM_W_CHANNEL 2 //PWM1_N
|
|
||||||
#define PWM_W_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_W, AS_PWM2_N); \
|
|
||||||
drv_pwm_n_invert(PWM_W_CHANNEL); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL 3 //PWM0
|
|
||||||
#define PWM_B_CHANNEL_SET() do{ \
|
|
||||||
gpio_set_func(LED_B, AS_PWM3); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define WARM_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define COOL_LIGHT_PWM_CHANNEL PWM_W_CHANNEL
|
|
||||||
#define WARM_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
#define COOL_LIGHT_PWM_SET() PWM_W_CHANNEL_SET()
|
|
||||||
|
|
||||||
//LED_R and LED_G as GPIO.
|
|
||||||
#define LED_R GPIO_PD5
|
|
||||||
#define LED_G GPIO_PD3
|
|
||||||
|
|
||||||
#define PD3_FUNC AS_GPIO
|
|
||||||
#define PD3_OUTPUT_ENABLE 1
|
|
||||||
#define PD3_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PD5_FUNC AS_GPIO
|
|
||||||
#define PD5_OUTPUT_ENABLE 1
|
|
||||||
#define PD5_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER LED_R
|
|
||||||
#define LED_PERMIT LED_G
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// UART
|
|
||||||
#if ZBHCI_UART
|
|
||||||
#error please configurate uart PIN!!!!!!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
#if UART_PRINTF_MODE
|
|
||||||
#define DEBUG_INFO_TX_PIN GPIO_PA2//print
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
enum{
|
|
||||||
VK_SW1 = 0x01,
|
|
||||||
VK_SW2 = 0x02
|
|
||||||
};
|
|
||||||
|
|
||||||
#define KB_MAP_NORMAL {\
|
|
||||||
{VK_SW1,}, \
|
|
||||||
{VK_SW2,}, }
|
|
||||||
|
|
||||||
#define KB_MAP_NUM KB_MAP_NORMAL
|
|
||||||
#define KB_MAP_FN KB_MAP_NORMAL
|
|
||||||
|
|
||||||
#define KB_DRIVE_PINS {NULL }
|
|
||||||
#define KB_SCAN_PINS {BUTTON1, BUTTON2}
|
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,134 +0,0 @@
|
||||||
/********************************************************************************************************
|
|
||||||
* @file board_9518_dongle.h
|
|
||||||
*
|
|
||||||
* @brief This is the header file for board_9518_dongle
|
|
||||||
*
|
|
||||||
* @author Zigbee Group
|
|
||||||
* @date 2021
|
|
||||||
*
|
|
||||||
* @par Copyright (c) 2021, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*******************************************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// BUTTON
|
|
||||||
#define BUTTON1 GPIO_PB2//SW2
|
|
||||||
#define PB2_FUNC AS_GPIO
|
|
||||||
#define PB2_OUTPUT_ENABLE 0
|
|
||||||
#define PB2_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PB2 GPIO_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
#define BUTTON2 GPIO_PB3//SW7
|
|
||||||
#define PB3_FUNC AS_GPIO
|
|
||||||
#define PB3_OUTPUT_ENABLE 0
|
|
||||||
#define PB3_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PB3 GPIO_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
// LED
|
|
||||||
/***************************************************************
|
|
||||||
* LED_R GPIO_PB4 //D9 -- red PWM0
|
|
||||||
* LED_G GPIO_PB0 //D6 -- green PWM5
|
|
||||||
* LED_B GPIO_PB7 //D8 -- blue PWM2
|
|
||||||
* LED_Y GPIO_PB5 //D7 -- yellow PWM1
|
|
||||||
*
|
|
||||||
* LED_B2 GPIO_PB1 //D10 -- blue PWM3
|
|
||||||
* LED_B3 GPIO_PE3 //D11 -- blue PWM0
|
|
||||||
****************************************************************/
|
|
||||||
#if defined COLOR_RGB_SUPPORT && (COLOR_RGB_SUPPORT == 1)
|
|
||||||
#error "To do!"
|
|
||||||
#else
|
|
||||||
//PWM configuration, LED_R as warm light, LED_B1 as cool light.
|
|
||||||
#define LED_R GPIO_PB4
|
|
||||||
#define LED_B GPIO_PB7
|
|
||||||
|
|
||||||
#define PWM_R_CHANNEL 0 //PWM0
|
|
||||||
#define PWM_R_CHANNEL_SET() do{\
|
|
||||||
pwm_set_pin(LED_R); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL 2 //PWM2
|
|
||||||
#define PWM_B_CHANNEL_SET() do{\
|
|
||||||
pwm_set_pin(LED_B); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define WARM_LIGHT_PWM_CHANNEL PWM_R_CHANNEL
|
|
||||||
#define COOL_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define WARM_LIGHT_PWM_SET() PWM_R_CHANNEL_SET()
|
|
||||||
#define COOL_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
|
|
||||||
//Others as GPIO.
|
|
||||||
#define LED_Y GPIO_PB5
|
|
||||||
#define LED_G GPIO_PB0
|
|
||||||
#define LED_B2 GPIO_PB1
|
|
||||||
#define LED_B3 GPIO_PE3
|
|
||||||
|
|
||||||
#define PB5_FUNC AS_GPIO
|
|
||||||
#define PB5_OUTPUT_ENABLE 1
|
|
||||||
#define PB5_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PB0_FUNC AS_GPIO
|
|
||||||
#define PB0_OUTPUT_ENABLE 1
|
|
||||||
#define PB0_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PB1_FUNC AS_GPIO
|
|
||||||
#define PB1_OUTPUT_ENABLE 1
|
|
||||||
#define PB1_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PE3_FUNC AS_GPIO
|
|
||||||
#define PE3_OUTPUT_ENABLE 1
|
|
||||||
#define PE3_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER LED_Y
|
|
||||||
#define LED_PERMIT LED_G
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// UART
|
|
||||||
#if ZBHCI_UART
|
|
||||||
#error please configurate uart PIN!!!!!!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
#if UART_PRINTF_MODE
|
|
||||||
#define DEBUG_INFO_TX_PIN GPIO_PC1//print
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
enum{
|
|
||||||
VK_SW1 = 0x01,
|
|
||||||
VK_SW2 = 0x02,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define KB_MAP_NORMAL {\
|
|
||||||
{VK_SW1,}, \
|
|
||||||
{VK_SW2,}, }
|
|
||||||
|
|
||||||
#define KB_MAP_NUM KB_MAP_NORMAL
|
|
||||||
#define KB_MAP_FN KB_MAP_NORMAL
|
|
||||||
|
|
||||||
#define KB_DRIVE_PINS {NULL}
|
|
||||||
#define KB_SCAN_PINS {BUTTON1, BUTTON2}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
136
board_9518_evk.h
136
board_9518_evk.h
|
@ -1,136 +0,0 @@
|
||||||
/********************************************************************************************************
|
|
||||||
* @file board_9518_evk.h
|
|
||||||
*
|
|
||||||
* @brief This is the header file for board_9518_evk
|
|
||||||
*
|
|
||||||
* @author Zigbee Group
|
|
||||||
* @date 2021
|
|
||||||
*
|
|
||||||
* @par Copyright (c) 2021, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*******************************************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// BUTTON
|
|
||||||
#define BUTTON1 GPIO_PC2
|
|
||||||
#define PC2_FUNC AS_GPIO
|
|
||||||
#define PC2_OUTPUT_ENABLE 0
|
|
||||||
#define PC2_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PC2 GPIO_PIN_PULLDOWN_100K
|
|
||||||
|
|
||||||
#define BUTTON2 GPIO_PC0
|
|
||||||
#define PC0_FUNC AS_GPIO
|
|
||||||
#define PC0_OUTPUT_ENABLE 0
|
|
||||||
#define PC0_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PC0 GPIO_PIN_PULLDOWN_100K
|
|
||||||
|
|
||||||
#define BUTTON3 GPIO_PC3
|
|
||||||
#define PC3_FUNC AS_GPIO
|
|
||||||
#define PC3_OUTPUT_ENABLE 0
|
|
||||||
#define PC3_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PC3 GPIO_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
#define BUTTON4 GPIO_PC1
|
|
||||||
#define PC1_FUNC AS_GPIO
|
|
||||||
#define PC1_OUTPUT_ENABLE 0
|
|
||||||
#define PC1_INPUT_ENABLE 1
|
|
||||||
#define PULL_WAKEUP_SRC_PC1 GPIO_PIN_PULLUP_10K
|
|
||||||
|
|
||||||
// LED
|
|
||||||
/***************************************************************
|
|
||||||
* LED_R GPIO_PB7 //D4 -- red
|
|
||||||
* LED_G GPIO_PB5 //D2 -- green
|
|
||||||
* LED_B GPIO_PB4 //D1 -- blue
|
|
||||||
* LED_W GPIO_PB6 //D3 -- white
|
|
||||||
****************************************************************/
|
|
||||||
#if defined COLOR_RGB_SUPPORT && (COLOR_RGB_SUPPORT == 1)
|
|
||||||
#error "To do!"
|
|
||||||
#else
|
|
||||||
//PWM configuration, LED_R as warm light, LED_B as cool light.
|
|
||||||
#define LED_R GPIO_PB7
|
|
||||||
#define LED_B GPIO_PB4
|
|
||||||
|
|
||||||
#define PWM_R_CHANNEL 2 //PWM2
|
|
||||||
#define PWM_R_CHANNEL_SET() do{\
|
|
||||||
pwm_set_pin(LED_R); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define PWM_B_CHANNEL 0 //PWM0
|
|
||||||
#define PWM_B_CHANNEL_SET() do{\
|
|
||||||
pwm_set_pin(LED_B); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define WARM_LIGHT_PWM_CHANNEL PWM_R_CHANNEL
|
|
||||||
#define COOL_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
|
||||||
#define WARM_LIGHT_PWM_SET() PWM_R_CHANNEL_SET()
|
|
||||||
#define COOL_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
|
||||||
|
|
||||||
//LED_W and LED_G as GPIO.
|
|
||||||
#define LED_W GPIO_PB6
|
|
||||||
#define LED_G GPIO_PB5
|
|
||||||
|
|
||||||
#define PB6_FUNC AS_GPIO
|
|
||||||
#define PB6_OUTPUT_ENABLE 1
|
|
||||||
#define PB6_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define PB5_FUNC AS_GPIO
|
|
||||||
#define PB5_OUTPUT_ENABLE 1
|
|
||||||
#define PB5_INPUT_ENABLE 0
|
|
||||||
|
|
||||||
#define LED_POWER LED_W
|
|
||||||
#define LED_PERMIT LED_G
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// UART
|
|
||||||
#if ZBHCI_UART
|
|
||||||
#error please configurate uart PIN!!!!!!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
#if UART_PRINTF_MODE
|
|
||||||
#define DEBUG_INFO_TX_PIN GPIO_PC7//print
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
enum{
|
|
||||||
VK_SW1 = 0x01,
|
|
||||||
VK_SW2 = 0x02,
|
|
||||||
VK_SW3 = 0x03,
|
|
||||||
VK_SW4 = 0x04
|
|
||||||
};
|
|
||||||
|
|
||||||
#define KB_MAP_NORMAL {\
|
|
||||||
{VK_SW1, VK_SW3}, \
|
|
||||||
{VK_SW2, VK_SW4}, }
|
|
||||||
|
|
||||||
#define KB_MAP_NUM KB_MAP_NORMAL
|
|
||||||
#define KB_MAP_FN KB_MAP_NORMAL
|
|
||||||
|
|
||||||
#define KB_DRIVE_PINS {GPIO_PC2, GPIO_PC0}
|
|
||||||
#define KB_SCAN_PINS {GPIO_PC3, GPIO_PC1}
|
|
||||||
|
|
||||||
#define KB_LINE_MODE 0
|
|
||||||
#define KB_LINE_HIGH_VALID 0
|
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -0,0 +1,142 @@
|
||||||
|
/********************************************************************************************************
|
||||||
|
* @file board_glc002p.h
|
||||||
|
*
|
||||||
|
* @brief This is the header file for mini5in1 glc002p
|
||||||
|
*
|
||||||
|
* @author Zigbee Group
|
||||||
|
* @date 2021
|
||||||
|
*
|
||||||
|
* @par Copyright (c) 2021, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*******************************************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/* Enable C linkage for C++ Compilers: */
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*******************************************************************************************************
|
||||||
|
*********************TLSR8258F512ET32 32 Pins: Start*****************************************************
|
||||||
|
*******************************************************************************************************/
|
||||||
|
// Option Button
|
||||||
|
#define BUTTON_OPT GPIO_PB7
|
||||||
|
#define PB7_FUNC AS_GPIO
|
||||||
|
#define PB7_OUTPUT_ENABLE 0
|
||||||
|
#define PB7_INPUT_ENABLE 1
|
||||||
|
#define PULL_WAKEUP_SRC_PB7 PM_PIN_PULLUP_10K
|
||||||
|
|
||||||
|
// Factory reset button
|
||||||
|
#define BUTTON_RESET GPIO_PC0
|
||||||
|
#define PC0_FUNC AS_GPIO
|
||||||
|
#define PC0_OUTPUT_ENABLE 0
|
||||||
|
#define PC0_INPUT_ENABLE 1
|
||||||
|
#define PULL_WAKEUP_SRC_PC0 PM_PIN_PULLUP_10K
|
||||||
|
|
||||||
|
// LED load Output Mapping
|
||||||
|
#define LED_B GPIO_PC2 // PWM0
|
||||||
|
#define LED_G GPIO_PC3 // PWM1
|
||||||
|
#define LED_R GPIO_PC4 // PWM2
|
||||||
|
#define LED_C GPIO_PD2 // PWM3
|
||||||
|
#define LED_W GPIO_PB4 // PWM4
|
||||||
|
|
||||||
|
#define PWM_B_CHANNEL 0//PWM0
|
||||||
|
#define PWM_B_CHANNEL_SET() do{ \
|
||||||
|
gpio_set_func(LED_B, AS_PWM0); \
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
#define PWM_G_CHANNEL 1//PWM1
|
||||||
|
#define PWM_G_CHANNEL_SET() do{ \
|
||||||
|
gpio_set_func(LED_G, AS_PWM1); \
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
#define PWM_R_CHANNEL 2//PWM2
|
||||||
|
#define PWM_R_CHANNEL_SET() do{ \
|
||||||
|
gpio_set_func(LED_R, AS_PWM2); \
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
|
||||||
|
#define PWM_C_CHANNEL 3//PWM3
|
||||||
|
#define PWM_C_CHANNEL_SET() do{ \
|
||||||
|
gpio_set_func(LED_C, AS_PWM3); \
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
#define PWM_W_CHANNEL 4//PWM4
|
||||||
|
#define PWM_W_CHANNEL_SET() do{ \
|
||||||
|
gpio_set_func(LED_W, AS_PWM4); \
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
#define R_LIGHT_PWM_CHANNEL PWM_R_CHANNEL
|
||||||
|
#define G_LIGHT_PWM_CHANNEL PWM_G_CHANNEL
|
||||||
|
#define B_LIGHT_PWM_CHANNEL PWM_B_CHANNEL
|
||||||
|
#define COOL_LIGHT_PWM_CHANNEL PWM_C_CHANNEL
|
||||||
|
#define WARM_LIGHT_PWM_CHANNEL PWM_W_CHANNEL
|
||||||
|
|
||||||
|
#define R_LIGHT_PWM_SET() PWM_R_CHANNEL_SET()
|
||||||
|
#define G_LIGHT_PWM_SET() PWM_G_CHANNEL_SET()
|
||||||
|
#define B_LIGHT_PWM_SET() PWM_B_CHANNEL_SET()
|
||||||
|
#define COOL_LIGHT_PWM_SET() PWM_C_CHANNEL_SET()
|
||||||
|
#define WARM_LIGHT_PWM_SET() PWM_W_CHANNEL_SET()
|
||||||
|
|
||||||
|
// On-Board LED Definitions for Mini 5in1
|
||||||
|
#define OB_LED_R GPIO_PA0
|
||||||
|
#define PA0_FUNC AS_GPIO
|
||||||
|
#define PA0_OUTPUT_ENABLE 1
|
||||||
|
#define PA0_INPUT_ENABLE 0
|
||||||
|
|
||||||
|
#define OB_LED_G GPIO_PA1
|
||||||
|
#define PA1_FUNC AS_GPIO
|
||||||
|
#define PA1_OUTPUT_ENABLE 1
|
||||||
|
#define PA1_INPUT_ENABLE 0
|
||||||
|
|
||||||
|
#define OB_LED_B GPIO_PB1
|
||||||
|
#define PB1_FUNC AS_GPIO
|
||||||
|
#define PB1_OUTPUT_ENABLE 1
|
||||||
|
#define PB1_INPUT_ENABLE 0
|
||||||
|
|
||||||
|
#define LED_STATUS_R OB_LED_R
|
||||||
|
#define LED_STATUS_G OB_LED_G
|
||||||
|
#define LED_STATUS_B OB_LED_B
|
||||||
|
|
||||||
|
// UART
|
||||||
|
#if ZBHCI_UART
|
||||||
|
#error please configure the uart PIN!!!!!!
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
#if UART_PRINTF_MODE
|
||||||
|
#define DEBUG_INFO_TX_PIN GPIO_PC4//print
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum{
|
||||||
|
VK_SW1 = 0x01,
|
||||||
|
VK_SW2 = 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
#define KB_MAP_NORMAL {\
|
||||||
|
{VK_SW1,}, \
|
||||||
|
{VK_SW2,}, }
|
||||||
|
|
||||||
|
#define KB_MAP_NUM KB_MAP_NORMAL
|
||||||
|
#define KB_MAP_FN KB_MAP_NORMAL
|
||||||
|
|
||||||
|
#define KB_DRIVE_PINS {NULL }
|
||||||
|
#define KB_SCAN_PINS {BUTTON_OPT, BUTTON_RESET}
|
||||||
|
|
||||||
|
|
||||||
|
/* Disable C linkage for C++ Compilers: */
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -127,20 +127,20 @@ typedef struct{
|
||||||
u8 enhancedColorMode;
|
u8 enhancedColorMode;
|
||||||
u8 numOfPrimaries;
|
u8 numOfPrimaries;
|
||||||
u16 colorCapabilities;
|
u16 colorCapabilities;
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
u8 currentHue;
|
u8 currentHue;
|
||||||
u8 currentSaturation;
|
u8 currentSaturation;
|
||||||
|
u16 currentX;
|
||||||
|
u16 currentY;
|
||||||
|
u16 enhancedCurrentHue;
|
||||||
u8 colorLoopActive;
|
u8 colorLoopActive;
|
||||||
u8 colorLoopDirection;
|
u8 colorLoopDirection;
|
||||||
u16 colorLoopTime;
|
u16 colorLoopTime;
|
||||||
u16 colorLoopStartEnhancedHue;
|
u16 colorLoopStartEnhancedHue;
|
||||||
u16 colorLoopStoredEnhancedHue;
|
u16 colorLoopStoredEnhancedHue;
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
u16 colorTemperatureMireds;
|
u16 colorTemperatureMireds;
|
||||||
u16 colorTempPhysicalMinMireds;
|
u16 colorTempPhysicalMinMireds;
|
||||||
u16 colorTempPhysicalMaxMireds;
|
u16 colorTempPhysicalMaxMireds;
|
||||||
u16 startUpColorTemperatureMireds;
|
u16 startUpColorTemperatureMireds;
|
||||||
#endif
|
|
||||||
}zcl_lightColorCtrlAttr_t;
|
}zcl_lightColorCtrlAttr_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,13 +163,10 @@ typedef struct {
|
||||||
* @brief Defined for saving color control attributes
|
* @brief Defined for saving color control attributes
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
u8 currentHue;
|
u8 currentHue;
|
||||||
u8 currentSaturation;
|
u8 currentSaturation;
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
u16 colorTemperatureMireds;
|
u16 colorTemperatureMireds;
|
||||||
u16 startUpColorTemperatureMireds;
|
u16 startUpColorTemperatureMireds;
|
||||||
#endif
|
|
||||||
}zcl_nv_colorCtrl_t;
|
}zcl_nv_colorCtrl_t;
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "zcl_include.h"
|
#include "zcl_include.h"
|
||||||
#include "sampleLight.h"
|
#include "sampleLight.h"
|
||||||
#include "sampleLightCtrl.h"
|
#include "sampleLightCtrl.h"
|
||||||
|
#include<math.h>
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL CONSTANTS
|
* LOCAL CONSTANTS
|
||||||
|
@ -107,21 +107,18 @@ void hwLight_init(void)
|
||||||
{
|
{
|
||||||
drv_pwm_init();
|
drv_pwm_init();
|
||||||
|
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
R_LIGHT_PWM_SET();
|
R_LIGHT_PWM_SET();
|
||||||
G_LIGHT_PWM_SET();
|
G_LIGHT_PWM_SET();
|
||||||
B_LIGHT_PWM_SET();
|
B_LIGHT_PWM_SET();
|
||||||
|
|
||||||
|
COOL_LIGHT_PWM_SET();
|
||||||
|
WARM_LIGHT_PWM_SET();
|
||||||
|
|
||||||
pwmInit(R_LIGHT_PWM_CHANNEL, 0);
|
pwmInit(R_LIGHT_PWM_CHANNEL, 0);
|
||||||
pwmInit(G_LIGHT_PWM_CHANNEL, 0);
|
pwmInit(G_LIGHT_PWM_CHANNEL, 0);
|
||||||
pwmInit(B_LIGHT_PWM_CHANNEL, 0);
|
pwmInit(B_LIGHT_PWM_CHANNEL, 0);
|
||||||
#else
|
|
||||||
COOL_LIGHT_PWM_SET();
|
|
||||||
pwmInit(COOL_LIGHT_PWM_CHANNEL, 0);
|
pwmInit(COOL_LIGHT_PWM_CHANNEL, 0);
|
||||||
#if COLOR_CCT_SUPPORT
|
|
||||||
WARM_LIGHT_PWM_SET();
|
|
||||||
pwmInit(WARM_LIGHT_PWM_CHANNEL, 0);
|
pwmInit(WARM_LIGHT_PWM_CHANNEL, 0);
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -136,30 +133,21 @@ void hwLight_init(void)
|
||||||
void hwLight_onOffUpdate(u8 onOff)
|
void hwLight_onOffUpdate(u8 onOff)
|
||||||
{
|
{
|
||||||
if(onOff){
|
if(onOff){
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
drv_pwm_start(R_LIGHT_PWM_CHANNEL);
|
drv_pwm_start(R_LIGHT_PWM_CHANNEL);
|
||||||
drv_pwm_start(G_LIGHT_PWM_CHANNEL);
|
drv_pwm_start(G_LIGHT_PWM_CHANNEL);
|
||||||
drv_pwm_start(B_LIGHT_PWM_CHANNEL);
|
drv_pwm_start(B_LIGHT_PWM_CHANNEL);
|
||||||
#else
|
|
||||||
#if COLOR_CCT_SUPPORT
|
|
||||||
drv_pwm_start(WARM_LIGHT_PWM_CHANNEL);
|
|
||||||
#endif
|
|
||||||
drv_pwm_start(COOL_LIGHT_PWM_CHANNEL);
|
drv_pwm_start(COOL_LIGHT_PWM_CHANNEL);
|
||||||
#endif
|
drv_pwm_start(WARM_LIGHT_PWM_CHANNEL);
|
||||||
}else{
|
}else{
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
drv_pwm_stop(R_LIGHT_PWM_CHANNEL);
|
drv_pwm_stop(R_LIGHT_PWM_CHANNEL);
|
||||||
drv_pwm_stop(G_LIGHT_PWM_CHANNEL);
|
drv_pwm_stop(G_LIGHT_PWM_CHANNEL);
|
||||||
drv_pwm_stop(B_LIGHT_PWM_CHANNEL);
|
drv_pwm_stop(B_LIGHT_PWM_CHANNEL);
|
||||||
#else
|
|
||||||
#if COLOR_CCT_SUPPORT
|
|
||||||
drv_pwm_stop(WARM_LIGHT_PWM_CHANNEL);
|
|
||||||
#endif
|
|
||||||
drv_pwm_stop(COOL_LIGHT_PWM_CHANNEL);
|
drv_pwm_stop(COOL_LIGHT_PWM_CHANNEL);
|
||||||
#endif
|
drv_pwm_stop(WARM_LIGHT_PWM_CHANNEL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn hwLight_levelUpdate
|
* @fn hwLight_levelUpdate
|
||||||
*
|
*
|
||||||
|
@ -171,13 +159,14 @@ void hwLight_onOffUpdate(u8 onOff)
|
||||||
*/
|
*/
|
||||||
void hwLight_levelUpdate(u8 level)
|
void hwLight_levelUpdate(u8 level)
|
||||||
{
|
{
|
||||||
|
/* Use this if no rgb support
|
||||||
#if !defined COLOR_RGB_SUPPORT || (COLOR_RGB_SUPPORT == 0)
|
#if !defined COLOR_RGB_SUPPORT || (COLOR_RGB_SUPPORT == 0)
|
||||||
level = (level < 0x10) ? 0x10 : level;
|
level = (level < 0x10) ? 0x10 : level;
|
||||||
|
|
||||||
u16 gammaCorrectLevel = ((u16)level * level) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
u16 gammaCorrectLevel = ((u16)level * level) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
||||||
|
|
||||||
pwmSetDuty(COOL_LIGHT_PWM_CHANNEL, gammaCorrectLevel * PWM_FULL_DUTYCYCLE);
|
pwmSetDuty(COOL_LIGHT_PWM_CHANNEL, gammaCorrectLevel * PWM_FULL_DUTYCYCLE);
|
||||||
#endif
|
#endif*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -194,12 +183,10 @@ void hwLight_levelUpdate(u8 level)
|
||||||
*/
|
*/
|
||||||
void temperatureToCW(u16 temperatureMireds, u8 level, u8 *C, u8 *W)
|
void temperatureToCW(u16 temperatureMireds, u8 level, u8 *C, u8 *W)
|
||||||
{
|
{
|
||||||
#if COLOR_CCT_SUPPORT
|
|
||||||
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
||||||
|
|
||||||
*W = (u8)(((temperatureMireds - pColor->colorTempPhysicalMinMireds) * level) / (pColor->colorTempPhysicalMaxMireds - pColor->colorTempPhysicalMinMireds));
|
*W = (u8)(((temperatureMireds - pColor->colorTempPhysicalMinMireds) * level) / (pColor->colorTempPhysicalMaxMireds - pColor->colorTempPhysicalMinMireds));
|
||||||
*C = level - (*W);
|
*C = level - (*W);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -214,7 +201,6 @@ void temperatureToCW(u16 temperatureMireds, u8 level, u8 *C, u8 *W)
|
||||||
*/
|
*/
|
||||||
void hwLight_colorUpdate_colorTemperature(u16 colorTemperatureMireds, u8 level)
|
void hwLight_colorUpdate_colorTemperature(u16 colorTemperatureMireds, u8 level)
|
||||||
{
|
{
|
||||||
#if COLOR_CCT_SUPPORT
|
|
||||||
u8 C = 0;
|
u8 C = 0;
|
||||||
u8 W = 0;
|
u8 W = 0;
|
||||||
|
|
||||||
|
@ -227,7 +213,9 @@ void hwLight_colorUpdate_colorTemperature(u16 colorTemperatureMireds, u8 level)
|
||||||
|
|
||||||
pwmSetDuty(COOL_LIGHT_PWM_CHANNEL, gammaCorrectC * PWM_FULL_DUTYCYCLE);
|
pwmSetDuty(COOL_LIGHT_PWM_CHANNEL, gammaCorrectC * PWM_FULL_DUTYCYCLE);
|
||||||
pwmSetDuty(WARM_LIGHT_PWM_CHANNEL, gammaCorrectW * PWM_FULL_DUTYCYCLE);
|
pwmSetDuty(WARM_LIGHT_PWM_CHANNEL, gammaCorrectW * PWM_FULL_DUTYCYCLE);
|
||||||
#endif
|
pwmSetDuty(R_LIGHT_PWM_CHANNEL, 0);
|
||||||
|
pwmSetDuty(G_LIGHT_PWM_CHANNEL, 0);
|
||||||
|
pwmSetDuty(B_LIGHT_PWM_CHANNEL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -246,7 +234,6 @@ void hwLight_colorUpdate_colorTemperature(u16 colorTemperatureMireds, u8 level)
|
||||||
*/
|
*/
|
||||||
void hsvToRGB(u8 hue, u8 saturation, u8 level, u8 *R, u8 *G, u8 *B)
|
void hsvToRGB(u8 hue, u8 saturation, u8 level, u8 *R, u8 *G, u8 *B)
|
||||||
{
|
{
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
u8 region;
|
u8 region;
|
||||||
u8 remainder;
|
u8 remainder;
|
||||||
u8 p, q, t;
|
u8 p, q, t;
|
||||||
|
@ -299,7 +286,6 @@ void hsvToRGB(u8 hue, u8 saturation, u8 level, u8 *R, u8 *G, u8 *B)
|
||||||
*G = p;
|
*G = p;
|
||||||
*B = q;
|
*B = q;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -315,7 +301,6 @@ void hsvToRGB(u8 hue, u8 saturation, u8 level, u8 *R, u8 *G, u8 *B)
|
||||||
*/
|
*/
|
||||||
void hwLight_colorUpdate_HSV2RGB(u8 hue, u8 saturation, u8 level)
|
void hwLight_colorUpdate_HSV2RGB(u8 hue, u8 saturation, u8 level)
|
||||||
{
|
{
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
u8 R = 0;
|
u8 R = 0;
|
||||||
u8 G = 0;
|
u8 G = 0;
|
||||||
u8 B = 0;
|
u8 B = 0;
|
||||||
|
@ -324,6 +309,10 @@ void hwLight_colorUpdate_HSV2RGB(u8 hue, u8 saturation, u8 level)
|
||||||
|
|
||||||
hsvToRGB(hue, saturation, level, &R, &G, &B);
|
hsvToRGB(hue, saturation, level, &R, &G, &B);
|
||||||
|
|
||||||
|
hwLight_colorUpdate_RGB(R,G,B);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hwLight_colorUpdate_RGB(u8 R, u8 G, u8 B) {
|
||||||
u16 gammaCorrectR = ((u16)R * R) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
u16 gammaCorrectR = ((u16)R * R) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
||||||
u16 gammaCorrectG = ((u16)G * G) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
u16 gammaCorrectG = ((u16)G * G) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
||||||
u16 gammaCorrectB = ((u16)B * B) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
u16 gammaCorrectB = ((u16)B * B) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
||||||
|
@ -331,7 +320,40 @@ void hwLight_colorUpdate_HSV2RGB(u8 hue, u8 saturation, u8 level)
|
||||||
pwmSetDuty(PWM_R_CHANNEL, gammaCorrectR * PWM_FULL_DUTYCYCLE);
|
pwmSetDuty(PWM_R_CHANNEL, gammaCorrectR * PWM_FULL_DUTYCYCLE);
|
||||||
pwmSetDuty(PWM_G_CHANNEL, gammaCorrectG * PWM_FULL_DUTYCYCLE);
|
pwmSetDuty(PWM_G_CHANNEL, gammaCorrectG * PWM_FULL_DUTYCYCLE);
|
||||||
pwmSetDuty(PWM_B_CHANNEL, gammaCorrectB * PWM_FULL_DUTYCYCLE);
|
pwmSetDuty(PWM_B_CHANNEL, gammaCorrectB * PWM_FULL_DUTYCYCLE);
|
||||||
#endif
|
pwmSetDuty(COOL_LIGHT_PWM_CHANNEL, 0);
|
||||||
|
pwmSetDuty(WARM_LIGHT_PWM_CHANNEL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static float ENFORCE_BOUNDS_FLOAT(float lowerBound, float num, float upperBound) {
|
||||||
|
return num < lowerBound ? lowerBound : num > upperBound ? upperBound : num;
|
||||||
|
}
|
||||||
|
|
||||||
|
float LINEAR_TO_SRGB_GAMMA_CORRECTION(const float part) {
|
||||||
|
return part <= 0.0031308 ? 12.92 * part : 1.055 * pow(part, 1.0 / 2.4) - 0.055;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hwLight_colorUpdate_XY2RGB(u16 xI, u16 yI, u8 level) {
|
||||||
|
float x = xI / 65536.f;
|
||||||
|
float y = yI / 65536.f;
|
||||||
|
|
||||||
|
// This does not locate the closest point in the gamma spectrum of the lamps. possible #todo
|
||||||
|
const float z = 1 - x - y;
|
||||||
|
|
||||||
|
const float Y = level / ZCL_LEVEL_ATTR_MAX_LEVEL; // This is luminance, but used as brightness
|
||||||
|
const float X = ((Y) / y) * x;
|
||||||
|
const float Z = ((Y) / y) * z;
|
||||||
|
|
||||||
|
// D65 BT.709 conversion https://en.wikipedia.org/wiki/SRGB
|
||||||
|
float r = X * 1.656492 - Y * 0.354851 - Z * 0.255038;
|
||||||
|
float g = -X * 0.707196 + Y * 1.655397 + Z * 0.036152;
|
||||||
|
float b = X * 0.051713 - Y * 0.121364 + Z * 1.011530;
|
||||||
|
|
||||||
|
// Enforce the lower and upper bounds
|
||||||
|
r = ENFORCE_BOUNDS_FLOAT(0.0, r * 255, 255.0);
|
||||||
|
g = ENFORCE_BOUNDS_FLOAT(0.0, g * 255, 255.0);
|
||||||
|
b = ENFORCE_BOUNDS_FLOAT(0.0, b * 255, 255.0);
|
||||||
|
|
||||||
|
hwLight_colorUpdate_RGB((u8)r,(u8)g,(u8)b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
|
|
@ -38,6 +38,8 @@ void hwLight_onOffUpdate(u8 onOff);
|
||||||
void hwLight_levelUpdate(u8 level);
|
void hwLight_levelUpdate(u8 level);
|
||||||
void hwLight_colorUpdate_colorTemperature(u16 colorTemperatureMireds, u8 level);
|
void hwLight_colorUpdate_colorTemperature(u16 colorTemperatureMireds, u8 level);
|
||||||
void hwLight_colorUpdate_HSV2RGB(u8 hue, u8 saturation, u8 level);
|
void hwLight_colorUpdate_HSV2RGB(u8 hue, u8 saturation, u8 level);
|
||||||
|
void hwLight_colorUpdate_RGB(u8 R, u8 G, u8 B);
|
||||||
|
void hwLight_colorUpdate_XY2RGB(u16 x, u16 y, u8 level);
|
||||||
|
|
||||||
void light_adjust(void);
|
void light_adjust(void);
|
||||||
void light_fresh(void);
|
void light_fresh(void);
|
||||||
|
|
|
@ -35,20 +35,18 @@
|
||||||
* LOCAL CONSTANTS
|
* LOCAL CONSTANTS
|
||||||
*/
|
*/
|
||||||
#ifndef ZCL_BASIC_MFG_NAME
|
#ifndef ZCL_BASIC_MFG_NAME
|
||||||
#define ZCL_BASIC_MFG_NAME {6,'T','E','L','I','N','K'}
|
#define ZCL_BASIC_MFG_NAME {8,'G','L','E','D','O','P','T','O'}
|
||||||
#endif
|
#endif
|
||||||
#ifndef ZCL_BASIC_MODEL_ID
|
#ifndef ZCL_BASIC_MODEL_ID
|
||||||
#define ZCL_BASIC_MODEL_ID {8,'T','L','S','R','8','2','x','x'}
|
#define ZCL_BASIC_MODEL_ID {9,'G','L','-','C','-','0','0','8','P'}
|
||||||
#endif
|
#endif
|
||||||
#ifndef ZCL_BASIC_SW_BUILD_ID
|
#ifndef ZCL_BASIC_SW_BUILD_ID
|
||||||
#define ZCL_BASIC_SW_BUILD_ID {10,'0','1','2','2','0','5','2','0','1','7'}
|
#define ZCL_BASIC_SW_BUILD_ID {8,'2','0','2','2','0','4','0','1'}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define COLOR_TEMPERATURE_PHYSICAL_MIN 0x009A//6500K
|
||||||
#if COLOR_CCT_SUPPORT
|
|
||||||
#define COLOR_TEMPERATURE_PHYSICAL_MIN 0x00FA//4000K
|
|
||||||
#define COLOR_TEMPERATURE_PHYSICAL_MAX 0x01C6//2200K
|
#define COLOR_TEMPERATURE_PHYSICAL_MAX 0x01C6//2200K
|
||||||
#endif
|
#define COLOR_TEMPERATURE_DEFAULT 0x00FA//4000K
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
|
@ -110,15 +108,7 @@ const u16 sampleLight_outClusterList[] =
|
||||||
const af_simple_descriptor_t sampleLight_simpleDesc =
|
const af_simple_descriptor_t sampleLight_simpleDesc =
|
||||||
{
|
{
|
||||||
HA_PROFILE_ID, /* Application profile identifier */
|
HA_PROFILE_ID, /* Application profile identifier */
|
||||||
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
|
||||||
HA_DEV_COLOR_DIMMABLE_LIGHT,
|
HA_DEV_COLOR_DIMMABLE_LIGHT,
|
||||||
#else
|
|
||||||
#ifdef ZCL_LEVEL_CTRL
|
|
||||||
HA_DEV_DIMMABLE_LIGHT, /* Application device identifier */
|
|
||||||
#else
|
|
||||||
HA_DEV_ONOFF_LIGHT, /* Application device identifier */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
SAMPLE_LIGHT_ENDPOINT, /* Endpoint */
|
SAMPLE_LIGHT_ENDPOINT, /* Endpoint */
|
||||||
1, /* Application device version */
|
1, /* Application device version */
|
||||||
0, /* Reserved */
|
0, /* Reserved */
|
||||||
|
@ -128,61 +118,13 @@ const af_simple_descriptor_t sampleLight_simpleDesc =
|
||||||
(u16 *)sampleLight_outClusterList, /* Application output cluster list */
|
(u16 *)sampleLight_outClusterList, /* Application output cluster list */
|
||||||
};
|
};
|
||||||
|
|
||||||
#if AF_TEST_ENABLE
|
|
||||||
/**
|
|
||||||
* @brief Definition for Incoming cluster / Sever Cluster
|
|
||||||
*/
|
|
||||||
const u16 sampleTest_inClusterList[] =
|
|
||||||
{
|
|
||||||
ZCL_CLUSTER_TELINK_SDK_TEST_REQ,
|
|
||||||
ZCL_CLUSTER_TELINK_SDK_TEST_RSP,
|
|
||||||
ZCL_CLUSTER_TELINK_SDK_TEST_CLEAR_REQ,
|
|
||||||
ZCL_CLUSTER_TELINK_SDK_TEST_CLEAR_RSP,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Definition for Outgoing cluster / Client Cluster
|
|
||||||
*/
|
|
||||||
const u16 sampleTest_outClusterList[] =
|
|
||||||
{
|
|
||||||
ZCL_CLUSTER_TELINK_SDK_TEST_REQ,
|
|
||||||
ZCL_CLUSTER_TELINK_SDK_TEST_RSP,
|
|
||||||
ZCL_CLUSTER_TELINK_SDK_TEST_CLEAR_REQ,
|
|
||||||
ZCL_CLUSTER_TELINK_SDK_TEST_CLEAR_RSP,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Definition for Server cluster number and Client cluster number
|
|
||||||
*/
|
|
||||||
#define SAMPLE_TEST_IN_CLUSTER_NUM (sizeof(sampleTest_inClusterList)/sizeof(sampleTest_inClusterList[0]))
|
|
||||||
#define SAMPLE_TEST_OUT_CLUSTER_NUM (sizeof(sampleTest_outClusterList)/sizeof(sampleTest_outClusterList[0]))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Definition for simple description for HA profile
|
|
||||||
*/
|
|
||||||
const af_simple_descriptor_t sampleTestDesc =
|
|
||||||
{
|
|
||||||
HA_PROFILE_ID, /* Application profile identifier */
|
|
||||||
HA_DEV_DIMMABLE_LIGHT, /* Application device identifier */
|
|
||||||
SAMPLE_TEST_ENDPOINT, /* Endpoint */
|
|
||||||
0, /* Application device version */
|
|
||||||
0, /* Reserved */
|
|
||||||
SAMPLE_TEST_IN_CLUSTER_NUM, /* Application input cluster count */
|
|
||||||
SAMPLE_TEST_OUT_CLUSTER_NUM, /* Application output cluster count */
|
|
||||||
(u16 *)sampleTest_inClusterList, /* Application input cluster list */
|
|
||||||
(u16 *)sampleTest_outClusterList, /* Application output cluster list */
|
|
||||||
};
|
|
||||||
#endif /* AF_TEST_ENABLE */
|
|
||||||
|
|
||||||
|
|
||||||
/* Basic */
|
/* Basic */
|
||||||
zcl_basicAttr_t g_zcl_basicAttrs =
|
zcl_basicAttr_t g_zcl_basicAttrs =
|
||||||
{
|
{
|
||||||
.zclVersion = 0x03,
|
.zclVersion = 0x03,
|
||||||
.appVersion = 0x00,
|
.appVersion = 0x00,
|
||||||
.stackVersion = 0x02,
|
.stackVersion = 0x00,
|
||||||
.hwVersion = 0x00,
|
.hwVersion = 0x02,
|
||||||
.manuName = ZCL_BASIC_MFG_NAME,
|
.manuName = ZCL_BASIC_MFG_NAME,
|
||||||
.modelId = ZCL_BASIC_MODEL_ID,
|
.modelId = ZCL_BASIC_MODEL_ID,
|
||||||
.powerSource = POWER_SOURCE_MAINS_1_PHASE,
|
.powerSource = POWER_SOURCE_MAINS_1_PHASE,
|
||||||
|
@ -311,29 +253,28 @@ const zclAttrInfo_t level_attrTbl[] =
|
||||||
#define ZCL_LEVEL_ATTR_NUM sizeof(level_attrTbl) / sizeof(zclAttrInfo_t)
|
#define ZCL_LEVEL_ATTR_NUM sizeof(level_attrTbl) / sizeof(zclAttrInfo_t)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
|
||||||
/* Color Control */
|
/* Color Control */
|
||||||
zcl_lightColorCtrlAttr_t g_zcl_colorCtrlAttrs =
|
zcl_lightColorCtrlAttr_t g_zcl_colorCtrlAttrs =
|
||||||
{
|
{
|
||||||
.colorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS,
|
.colorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS,
|
||||||
.options = 0,
|
.options = 0,
|
||||||
.enhancedColorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS,
|
.enhancedColorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS,
|
||||||
.colorCapabilities = ZCL_COLOR_CAPABILITIES_BIT_COLOR_TEMPERATURE,
|
.colorCapabilities = ZCL_COLOR_CAPABILITIES_BIT_COLOR_TEMPERATURE | ZCL_COLOR_CAPABILITIES_BIT_X_Y_ATTRIBUTES | ZCL_COLOR_CAPABILITIES_BIT_HUE_SATURATION,
|
||||||
.numOfPrimaries = 0,
|
.numOfPrimaries = 0,
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
.currentHue = 0x00,
|
.currentHue = 0x00,
|
||||||
.currentSaturation = 0x00,
|
.currentSaturation = 0x00,
|
||||||
|
.currentX = 0x616b,
|
||||||
|
.currentY = 0x607d,
|
||||||
|
.enhancedCurrentHue = 0x0000,
|
||||||
.colorLoopActive = 0x00,
|
.colorLoopActive = 0x00,
|
||||||
.colorLoopDirection = 0x00,
|
.colorLoopDirection = 0x00,
|
||||||
.colorLoopTime = 0x0019,
|
.colorLoopTime = 0x0019,
|
||||||
.colorLoopStartEnhancedHue = 0x2300,
|
.colorLoopStartEnhancedHue = 0x2300,
|
||||||
.colorLoopStoredEnhancedHue = 0x0000,
|
.colorLoopStoredEnhancedHue = 0x0000,
|
||||||
#elif COLOR_CCT_SUPPORT
|
.colorTemperatureMireds = COLOR_TEMPERATURE_DEFAULT,
|
||||||
.colorTemperatureMireds = COLOR_TEMPERATURE_PHYSICAL_MAX,
|
|
||||||
.colorTempPhysicalMinMireds = COLOR_TEMPERATURE_PHYSICAL_MIN,
|
.colorTempPhysicalMinMireds = COLOR_TEMPERATURE_PHYSICAL_MIN,
|
||||||
.colorTempPhysicalMaxMireds = COLOR_TEMPERATURE_PHYSICAL_MAX,
|
.colorTempPhysicalMaxMireds = COLOR_TEMPERATURE_PHYSICAL_MAX,
|
||||||
.startUpColorTemperatureMireds = ZCL_START_UP_COLOR_TEMPERATURE_MIREDS_TO_PREVIOUS,
|
.startUpColorTemperatureMireds = ZCL_START_UP_COLOR_TEMPERATURE_MIREDS_TO_PREVIOUS,
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const zclAttrInfo_t lightColorCtrl_attrTbl[] =
|
const zclAttrInfo_t lightColorCtrl_attrTbl[] =
|
||||||
|
@ -343,27 +284,25 @@ const zclAttrInfo_t lightColorCtrl_attrTbl[] =
|
||||||
{ ZCL_ATTRID_ENHANCED_COLOR_MODE, ZCL_DATA_TYPE_ENUM8, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.enhancedColorMode },
|
{ ZCL_ATTRID_ENHANCED_COLOR_MODE, ZCL_DATA_TYPE_ENUM8, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.enhancedColorMode },
|
||||||
{ ZCL_ATTRID_COLOR_CAPABILITIES, ZCL_DATA_TYPE_BITMAP16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorCapabilities },
|
{ ZCL_ATTRID_COLOR_CAPABILITIES, ZCL_DATA_TYPE_BITMAP16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorCapabilities },
|
||||||
{ ZCL_ATTRID_NUMBER_OF_PRIMARIES, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.numOfPrimaries },
|
{ ZCL_ATTRID_NUMBER_OF_PRIMARIES, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.numOfPrimaries },
|
||||||
|
{ ZCL_ATTRID_CURRENT_X, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.currentX },
|
||||||
#if COLOR_RGB_SUPPORT
|
{ ZCL_ATTRID_CURRENT_Y, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.currentY },
|
||||||
{ ZCL_ATTRID_CURRENT_HUE, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.currentHue },
|
{ ZCL_ATTRID_CURRENT_HUE, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.currentHue },
|
||||||
|
{ ZCL_ATTRID_ENHANCED_CURRENT_HUE, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.currentHue },
|
||||||
{ ZCL_ATTRID_CURRENT_SATURATION, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.currentSaturation },
|
{ ZCL_ATTRID_CURRENT_SATURATION, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.currentSaturation },
|
||||||
{ ZCL_ATTRID_COLOR_LOOP_ACTIVE, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorLoopActive },
|
{ ZCL_ATTRID_COLOR_LOOP_ACTIVE, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorLoopActive },
|
||||||
{ ZCL_ATTRID_COLOR_LOOP_DIRECTION, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorLoopDirection },
|
{ ZCL_ATTRID_COLOR_LOOP_DIRECTION, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorLoopDirection },
|
||||||
{ ZCL_ATTRID_COLOR_LOOP_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorLoopTime },
|
{ ZCL_ATTRID_COLOR_LOOP_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorLoopTime },
|
||||||
{ ZCL_ATTRID_COLOR_LOOP_START_ENHANCED_HUE, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorLoopStartEnhancedHue },
|
{ ZCL_ATTRID_COLOR_LOOP_START_ENHANCED_HUE, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorLoopStartEnhancedHue },
|
||||||
{ ZCL_ATTRID_COLOR_LOOP_STORED_ENHANCED_HUE, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorLoopStoredEnhancedHue },
|
{ ZCL_ATTRID_COLOR_LOOP_STORED_ENHANCED_HUE, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorLoopStoredEnhancedHue },
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
{ ZCL_ATTRID_COLOR_TEMPERATURE_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorTemperatureMireds },
|
{ ZCL_ATTRID_COLOR_TEMPERATURE_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorTemperatureMireds },
|
||||||
{ ZCL_ATTRID_COLOR_TEMP_PHYSICAL_MIN_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorTempPhysicalMinMireds },
|
{ ZCL_ATTRID_COLOR_TEMP_PHYSICAL_MIN_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorTempPhysicalMinMireds },
|
||||||
{ ZCL_ATTRID_COLOR_TEMP_PHYSICAL_MAX_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorTempPhysicalMaxMireds },
|
{ ZCL_ATTRID_COLOR_TEMP_PHYSICAL_MAX_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorTempPhysicalMaxMireds },
|
||||||
{ ZCL_ATTRID_START_UP_COLOR_TEMPERATURE_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8*)&g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds },
|
{ ZCL_ATTRID_START_UP_COLOR_TEMPERATURE_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8*)&g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds },
|
||||||
#endif
|
|
||||||
|
|
||||||
{ ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&zcl_attr_global_clusterRevision},
|
{ ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&zcl_attr_global_clusterRevision},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZCL_COLOR_ATTR_NUM sizeof(lightColorCtrl_attrTbl) / sizeof(zclAttrInfo_t)
|
#define ZCL_COLOR_ATTR_NUM sizeof(lightColorCtrl_attrTbl) / sizeof(zclAttrInfo_t)
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Definition for simple light ZCL specific cluster
|
* @brief Definition for simple light ZCL specific cluster
|
||||||
|
@ -372,21 +311,11 @@ const zcl_specClusterInfo_t g_sampleLightClusterList[] =
|
||||||
{
|
{
|
||||||
{ZCL_CLUSTER_GEN_BASIC, MANUFACTURER_CODE_NONE, ZCL_BASIC_ATTR_NUM, basic_attrTbl, zcl_basic_register, sampleLight_basicCb},
|
{ZCL_CLUSTER_GEN_BASIC, MANUFACTURER_CODE_NONE, ZCL_BASIC_ATTR_NUM, basic_attrTbl, zcl_basic_register, sampleLight_basicCb},
|
||||||
{ZCL_CLUSTER_GEN_IDENTIFY, MANUFACTURER_CODE_NONE, ZCL_IDENTIFY_ATTR_NUM, identify_attrTbl, zcl_identify_register, sampleLight_identifyCb},
|
{ZCL_CLUSTER_GEN_IDENTIFY, MANUFACTURER_CODE_NONE, ZCL_IDENTIFY_ATTR_NUM, identify_attrTbl, zcl_identify_register, sampleLight_identifyCb},
|
||||||
#ifdef ZCL_GROUP
|
|
||||||
{ZCL_CLUSTER_GEN_GROUPS, MANUFACTURER_CODE_NONE, ZCL_GROUP_ATTR_NUM, group_attrTbl, zcl_group_register, NULL},
|
{ZCL_CLUSTER_GEN_GROUPS, MANUFACTURER_CODE_NONE, ZCL_GROUP_ATTR_NUM, group_attrTbl, zcl_group_register, NULL},
|
||||||
#endif
|
|
||||||
#ifdef ZCL_SCENE
|
|
||||||
{ZCL_CLUSTER_GEN_SCENES, MANUFACTURER_CODE_NONE, ZCL_SCENE_ATTR_NUM, scene_attrTbl, zcl_scene_register, sampleLight_sceneCb},
|
{ZCL_CLUSTER_GEN_SCENES, MANUFACTURER_CODE_NONE, ZCL_SCENE_ATTR_NUM, scene_attrTbl, zcl_scene_register, sampleLight_sceneCb},
|
||||||
#endif
|
|
||||||
#ifdef ZCL_ON_OFF
|
|
||||||
{ZCL_CLUSTER_GEN_ON_OFF, MANUFACTURER_CODE_NONE, ZCL_ONOFF_ATTR_NUM, onOff_attrTbl, zcl_onOff_register, sampleLight_onOffCb},
|
{ZCL_CLUSTER_GEN_ON_OFF, MANUFACTURER_CODE_NONE, ZCL_ONOFF_ATTR_NUM, onOff_attrTbl, zcl_onOff_register, sampleLight_onOffCb},
|
||||||
#endif
|
|
||||||
#ifdef ZCL_LEVEL_CTRL
|
|
||||||
{ZCL_CLUSTER_GEN_LEVEL_CONTROL, MANUFACTURER_CODE_NONE, ZCL_LEVEL_ATTR_NUM, level_attrTbl, zcl_level_register, sampleLight_levelCb},
|
{ZCL_CLUSTER_GEN_LEVEL_CONTROL, MANUFACTURER_CODE_NONE, ZCL_LEVEL_ATTR_NUM, level_attrTbl, zcl_level_register, sampleLight_levelCb},
|
||||||
#endif
|
|
||||||
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
|
||||||
{ZCL_CLUSTER_LIGHTING_COLOR_CONTROL, MANUFACTURER_CODE_NONE, ZCL_COLOR_ATTR_NUM, lightColorCtrl_attrTbl, zcl_lightColorCtrl_register, sampleLight_colorCtrlCb},
|
{ZCL_CLUSTER_LIGHTING_COLOR_CONTROL, MANUFACTURER_CODE_NONE, ZCL_COLOR_ATTR_NUM, lightColorCtrl_attrTbl, zcl_lightColorCtrl_register, sampleLight_colorCtrlCb},
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
u8 SAMPLELIGHT_CB_CLUSTER_NUM = (sizeof(g_sampleLightClusterList)/sizeof(g_sampleLightClusterList[0]));
|
u8 SAMPLELIGHT_CB_CLUSTER_NUM = (sizeof(g_sampleLightClusterList)/sizeof(g_sampleLightClusterList[0]));
|
||||||
|
@ -410,7 +339,6 @@ nv_sts_t zcl_onOffAttr_save(void)
|
||||||
{
|
{
|
||||||
nv_sts_t st = NV_SUCC;
|
nv_sts_t st = NV_SUCC;
|
||||||
|
|
||||||
#ifdef ZCL_ON_OFF
|
|
||||||
#if NV_ENABLE
|
#if NV_ENABLE
|
||||||
zcl_nv_onOff_t zcl_nv_onOff;
|
zcl_nv_onOff_t zcl_nv_onOff;
|
||||||
|
|
||||||
|
@ -431,7 +359,6 @@ nv_sts_t zcl_onOffAttr_save(void)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
st = NV_ENABLE_PROTECT_ERROR;
|
st = NV_ENABLE_PROTECT_ERROR;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return st;
|
return st;
|
||||||
|
@ -450,7 +377,6 @@ nv_sts_t zcl_onOffAttr_restore(void)
|
||||||
{
|
{
|
||||||
nv_sts_t st = NV_SUCC;
|
nv_sts_t st = NV_SUCC;
|
||||||
|
|
||||||
#ifdef ZCL_ON_OFF
|
|
||||||
#if NV_ENABLE
|
#if NV_ENABLE
|
||||||
zcl_nv_onOff_t zcl_nv_onOff;
|
zcl_nv_onOff_t zcl_nv_onOff;
|
||||||
|
|
||||||
|
@ -462,7 +388,6 @@ nv_sts_t zcl_onOffAttr_restore(void)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
st = NV_ENABLE_PROTECT_ERROR;
|
st = NV_ENABLE_PROTECT_ERROR;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return st;
|
return st;
|
||||||
|
@ -481,7 +406,6 @@ nv_sts_t zcl_levelAttr_save(void)
|
||||||
{
|
{
|
||||||
nv_sts_t st = NV_SUCC;
|
nv_sts_t st = NV_SUCC;
|
||||||
|
|
||||||
#ifdef ZCL_LEVEL_CTRL
|
|
||||||
#if NV_ENABLE
|
#if NV_ENABLE
|
||||||
zcl_nv_level_t zcl_nv_level;
|
zcl_nv_level_t zcl_nv_level;
|
||||||
|
|
||||||
|
@ -502,7 +426,6 @@ nv_sts_t zcl_levelAttr_save(void)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
st = NV_ENABLE_PROTECT_ERROR;
|
st = NV_ENABLE_PROTECT_ERROR;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return st;
|
return st;
|
||||||
|
@ -521,7 +444,6 @@ nv_sts_t zcl_levelAttr_restore(void)
|
||||||
{
|
{
|
||||||
nv_sts_t st = NV_SUCC;
|
nv_sts_t st = NV_SUCC;
|
||||||
|
|
||||||
#ifdef ZCL_LEVEL_CTRL
|
|
||||||
#if NV_ENABLE
|
#if NV_ENABLE
|
||||||
zcl_nv_level_t zcl_nv_level;
|
zcl_nv_level_t zcl_nv_level;
|
||||||
|
|
||||||
|
@ -533,7 +455,6 @@ nv_sts_t zcl_levelAttr_restore(void)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
st = NV_ENABLE_PROTECT_ERROR;
|
st = NV_ENABLE_PROTECT_ERROR;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return st;
|
return st;
|
||||||
|
@ -552,50 +473,37 @@ nv_sts_t zcl_colorCtrlAttr_save(void)
|
||||||
{
|
{
|
||||||
nv_sts_t st = NV_SUCC;
|
nv_sts_t st = NV_SUCC;
|
||||||
|
|
||||||
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
|
||||||
#if NV_ENABLE
|
#if NV_ENABLE
|
||||||
bool needSave = FALSE;
|
bool needSave = FALSE;
|
||||||
zcl_nv_colorCtrl_t zcl_nv_colorCtrl;
|
zcl_nv_colorCtrl_t zcl_nv_colorCtrl;
|
||||||
|
|
||||||
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8*)&zcl_nv_colorCtrl);
|
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8*)&zcl_nv_colorCtrl);
|
||||||
|
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
if(st == NV_SUCC){
|
if(st == NV_SUCC){
|
||||||
if((zcl_nv_colorCtrl.currentHue != g_zcl_colorCtrlAttrs.currentHue) || (zcl_nv_colorCtrl.currentSaturation != g_zcl_colorCtrlAttrs.currentSaturation)){
|
if((zcl_nv_colorCtrl.currentHue != g_zcl_colorCtrlAttrs.currentHue) || (zcl_nv_colorCtrl.currentSaturation != g_zcl_colorCtrlAttrs.currentSaturation)
|
||||||
|
|| (zcl_nv_colorCtrl.colorTemperatureMireds != g_zcl_colorCtrlAttrs.colorTemperatureMireds)
|
||||||
|
|| (zcl_nv_colorCtrl.startUpColorTemperatureMireds != g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds)){
|
||||||
zcl_nv_colorCtrl.currentHue = g_zcl_colorCtrlAttrs.currentHue;
|
zcl_nv_colorCtrl.currentHue = g_zcl_colorCtrlAttrs.currentHue;
|
||||||
zcl_nv_colorCtrl.currentSaturation = g_zcl_colorCtrlAttrs.currentSaturation;
|
zcl_nv_colorCtrl.currentSaturation = g_zcl_colorCtrlAttrs.currentSaturation;
|
||||||
|
|
||||||
needSave = TRUE;
|
|
||||||
}
|
|
||||||
}else if(st == NV_ITEM_NOT_FOUND){
|
|
||||||
zcl_nv_colorCtrl.currentHue = g_zcl_colorCtrlAttrs.currentHue;
|
|
||||||
zcl_nv_colorCtrl.currentSaturation = g_zcl_colorCtrlAttrs.currentSaturation;
|
|
||||||
|
|
||||||
needSave = TRUE;
|
|
||||||
}
|
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
if(st == NV_SUCC){
|
|
||||||
if((zcl_nv_colorCtrl.colorTemperatureMireds != g_zcl_colorCtrlAttrs.colorTemperatureMireds) || (zcl_nv_colorCtrl.startUpColorTemperatureMireds != g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds)){
|
|
||||||
zcl_nv_colorCtrl.colorTemperatureMireds = g_zcl_colorCtrlAttrs.colorTemperatureMireds;
|
zcl_nv_colorCtrl.colorTemperatureMireds = g_zcl_colorCtrlAttrs.colorTemperatureMireds;
|
||||||
zcl_nv_colorCtrl.startUpColorTemperatureMireds = g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds;
|
zcl_nv_colorCtrl.startUpColorTemperatureMireds = g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds;
|
||||||
|
|
||||||
needSave = TRUE;
|
needSave = TRUE;
|
||||||
}
|
}
|
||||||
}else if(st == NV_ITEM_NOT_FOUND){
|
}else if(st == NV_ITEM_NOT_FOUND){
|
||||||
|
zcl_nv_colorCtrl.currentHue = g_zcl_colorCtrlAttrs.currentHue;
|
||||||
|
zcl_nv_colorCtrl.currentSaturation = g_zcl_colorCtrlAttrs.currentSaturation;
|
||||||
zcl_nv_colorCtrl.colorTemperatureMireds = g_zcl_colorCtrlAttrs.colorTemperatureMireds;
|
zcl_nv_colorCtrl.colorTemperatureMireds = g_zcl_colorCtrlAttrs.colorTemperatureMireds;
|
||||||
zcl_nv_colorCtrl.startUpColorTemperatureMireds = g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds;
|
zcl_nv_colorCtrl.startUpColorTemperatureMireds = g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds;
|
||||||
|
|
||||||
needSave = TRUE;
|
needSave = TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if(needSave){
|
if(needSave){
|
||||||
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8*)&zcl_nv_colorCtrl);
|
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8*)&zcl_nv_colorCtrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
st = NV_ENABLE_PROTECT_ERROR;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return st;
|
return st;
|
||||||
|
@ -614,27 +522,19 @@ nv_sts_t zcl_colorCtrlAttr_restore(void)
|
||||||
{
|
{
|
||||||
nv_sts_t st = NV_SUCC;
|
nv_sts_t st = NV_SUCC;
|
||||||
|
|
||||||
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
|
||||||
#if NV_ENABLE
|
#if NV_ENABLE
|
||||||
zcl_nv_colorCtrl_t zcl_nv_colorCtrl;
|
zcl_nv_colorCtrl_t zcl_nv_colorCtrl;
|
||||||
|
|
||||||
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8*)&zcl_nv_colorCtrl);
|
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8*)&zcl_nv_colorCtrl);
|
||||||
|
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
if(st == NV_SUCC){
|
if(st == NV_SUCC){
|
||||||
g_zcl_colorCtrlAttrs.currentHue = zcl_nv_colorCtrl.currentHue;
|
g_zcl_colorCtrlAttrs.currentHue = zcl_nv_colorCtrl.currentHue;
|
||||||
g_zcl_colorCtrlAttrs.currentSaturation = zcl_nv_colorCtrl.currentSaturation;
|
g_zcl_colorCtrlAttrs.currentSaturation = zcl_nv_colorCtrl.currentSaturation;
|
||||||
}
|
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
if(st == NV_SUCC){
|
|
||||||
g_zcl_colorCtrlAttrs.colorTemperatureMireds = zcl_nv_colorCtrl.colorTemperatureMireds;
|
g_zcl_colorCtrlAttrs.colorTemperatureMireds = zcl_nv_colorCtrl.colorTemperatureMireds;
|
||||||
g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds = zcl_nv_colorCtrl.startUpColorTemperatureMireds;
|
g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds = zcl_nv_colorCtrl.startUpColorTemperatureMireds;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
st = NV_ENABLE_PROTECT_ERROR;
|
st = NV_ENABLE_PROTECT_ERROR;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return st;
|
return st;
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
* During OTA upgrade, the upgraded device will check the rules of the following three fields.
|
* During OTA upgrade, the upgraded device will check the rules of the following three fields.
|
||||||
* Refer to ZCL OTA specification for details.
|
* Refer to ZCL OTA specification for details.
|
||||||
*/
|
*/
|
||||||
#define MANUFACTURER_CODE_TELINK 0x1141//Telink ID
|
#define MANUFACTURER_CODE_TELINK 0x124f //Gledopto ID
|
||||||
#define IMAGE_TYPE ((CHIP_TYPE << 8) | IMAGE_TYPE_LIGHT)
|
#define IMAGE_TYPE ((CHIP_TYPE << 8) | IMAGE_TYPE_LIGHT)
|
||||||
#define FILE_VERSION ((APP_RELEASE << 24) | (APP_BUILD << 16) | (STACK_RELEASE << 8) | STACK_BUILD)
|
#define FILE_VERSION ((APP_RELEASE << 24) | (APP_BUILD << 16) | (STACK_RELEASE << 8) | STACK_BUILD)
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct{
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
s32 stepHue256;
|
s32 stepHue256;
|
||||||
u16 currentHue256;
|
u16 currentHue256;
|
||||||
u16 hueRemainingTime;
|
u16 hueRemainingTime;
|
||||||
|
@ -53,20 +52,17 @@ typedef struct{
|
||||||
u16 currentSaturation256;
|
u16 currentSaturation256;
|
||||||
u16 saturationRemainingTime;
|
u16 saturationRemainingTime;
|
||||||
|
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
s32 stepColorTemp256;
|
s32 stepColorTemp256;
|
||||||
u32 currentColorTemp256;
|
u32 currentColorTemp256;
|
||||||
u16 colorTempRemainingTime;
|
u16 colorTempRemainingTime;
|
||||||
u16 colorTempMinMireds;
|
u16 colorTempMinMireds;
|
||||||
u16 colorTempMaxMireds;
|
u16 colorTempMaxMireds;
|
||||||
#endif
|
|
||||||
}zcl_colorInfo_t;
|
}zcl_colorInfo_t;
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL VARIABLES
|
* LOCAL VARIABLES
|
||||||
*/
|
*/
|
||||||
static zcl_colorInfo_t colorInfo = {
|
static zcl_colorInfo_t colorInfo = {
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
.stepHue256 = 0,
|
.stepHue256 = 0,
|
||||||
.currentHue256 = 0,
|
.currentHue256 = 0,
|
||||||
.hueRemainingTime = 0,
|
.hueRemainingTime = 0,
|
||||||
|
@ -75,19 +71,15 @@ static zcl_colorInfo_t colorInfo = {
|
||||||
.currentSaturation256 = 0,
|
.currentSaturation256 = 0,
|
||||||
.saturationRemainingTime = 0,
|
.saturationRemainingTime = 0,
|
||||||
|
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
.stepColorTemp256 = 0,
|
.stepColorTemp256 = 0,
|
||||||
.currentColorTemp256 = 0,
|
.currentColorTemp256 = 0,
|
||||||
.colorTempRemainingTime = 0,
|
.colorTempRemainingTime = 0,
|
||||||
.colorTempMinMireds = 0,
|
.colorTempMinMireds = 0,
|
||||||
.colorTempMaxMireds = 0,
|
.colorTempMaxMireds = 0,
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static ev_timer_event_t *colorTimerEvt = NULL;
|
static ev_timer_event_t *colorTimerEvt = NULL;
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
static ev_timer_event_t *colorLoopTimerEvt = NULL;
|
static ev_timer_event_t *colorLoopTimerEvt = NULL;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
@ -109,33 +101,23 @@ void sampleLight_colorInit(void)
|
||||||
{
|
{
|
||||||
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
||||||
|
|
||||||
#if COLOR_RGB_SUPPORT
|
pColor->colorCapabilities = ZCL_COLOR_CAPABILITIES_BIT_HUE_SATURATION | ZCL_COLOR_CAPABILITIES_BIT_COLOR_TEMPERATURE | ZCL_COLOR_CAPABILITIES_BIT_X_Y_ATTRIBUTES;
|
||||||
pColor->colorCapabilities = ZCL_COLOR_CAPABILITIES_BIT_HUE_SATURATION;
|
|
||||||
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_HUE_SATURATION;
|
|
||||||
pColor->enhancedColorMode = ZCL_COLOR_MODE_CURRENT_HUE_SATURATION;
|
|
||||||
|
|
||||||
colorInfo.currentHue256 = (u16)(pColor->currentHue) << 8;
|
colorInfo.currentHue256 = (u16)(pColor->currentHue) << 8;
|
||||||
colorInfo.currentSaturation256 = (u16)(pColor->currentSaturation) << 8;
|
colorInfo.currentSaturation256 = (u16)(pColor->currentSaturation) << 8;
|
||||||
|
colorInfo.currentColorTemp256 = (u32)(pColor->colorTemperatureMireds) << 8;
|
||||||
|
|
||||||
colorInfo.hueRemainingTime = 0;
|
colorInfo.hueRemainingTime = 0;
|
||||||
colorInfo.saturationRemainingTime = 0;
|
colorInfo.saturationRemainingTime = 0;
|
||||||
|
colorInfo.colorTempRemainingTime = 0;
|
||||||
|
|
||||||
light_applyUpdate(&pColor->currentHue, &colorInfo.currentHue256, &colorInfo.stepHue256, &colorInfo.hueRemainingTime,
|
// Startup is only defined for color temperature, so why would we load any colors here ...
|
||||||
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
|
|
||||||
|
|
||||||
light_applyUpdate(&pColor->currentSaturation, &colorInfo.currentSaturation256, &colorInfo.stepSaturation256, &colorInfo.saturationRemainingTime,
|
|
||||||
ZCL_COLOR_ATTR_SATURATION_MIN, ZCL_COLOR_ATTR_SATURATION_MAX, FALSE);
|
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
pColor->colorCapabilities = ZCL_COLOR_CAPABILITIES_BIT_COLOR_TEMPERATURE;
|
|
||||||
pColor->colorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
pColor->colorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
||||||
pColor->enhancedColorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
pColor->enhancedColorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
||||||
|
|
||||||
colorInfo.currentColorTemp256 = (u32)(pColor->colorTemperatureMireds) << 8;
|
|
||||||
colorInfo.colorTempRemainingTime = 0;
|
|
||||||
|
|
||||||
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
||||||
pColor->colorTempPhysicalMinMireds, pColor->colorTempPhysicalMaxMireds, FALSE);
|
pColor->colorTempPhysicalMinMireds, pColor->colorTempPhysicalMaxMireds, FALSE);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -179,11 +161,13 @@ void sampleLight_updateColor(void)
|
||||||
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
||||||
zcl_levelAttr_t *pLevel = zcl_levelAttrGet();
|
zcl_levelAttr_t *pLevel = zcl_levelAttrGet();
|
||||||
|
|
||||||
#if COLOR_RGB_SUPPORT
|
if(pColor->colorMode == ZCL_COLOR_MODE_CURRENT_X_Y) {
|
||||||
|
hwLight_colorUpdate_XY2RGB(pColor->currentX, pColor->currentY, pLevel->curLevel);
|
||||||
|
} else if(pColor->colorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION || pColor->enhancedColorMode == ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION){
|
||||||
hwLight_colorUpdate_HSV2RGB(pColor->currentHue, pColor->currentSaturation, pLevel->curLevel);
|
hwLight_colorUpdate_HSV2RGB(pColor->currentHue, pColor->currentSaturation, pLevel->curLevel);
|
||||||
#elif COLOR_CCT_SUPPORT
|
} else if(pColor->colorMode == ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS){
|
||||||
hwLight_colorUpdate_colorTemperature(pColor->colorTemperatureMireds, pLevel->curLevel);
|
hwLight_colorUpdate_colorTemperature(pColor->colorTemperatureMireds, pLevel->curLevel);
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -199,7 +183,6 @@ static s32 sampleLight_colorTimerEvtCb(void *arg)
|
||||||
{
|
{
|
||||||
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
||||||
|
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
if( (pColor->enhancedColorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION) ||
|
if( (pColor->enhancedColorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION) ||
|
||||||
(pColor->enhancedColorMode == ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION) ){
|
(pColor->enhancedColorMode == ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION) ){
|
||||||
if(colorInfo.saturationRemainingTime){
|
if(colorInfo.saturationRemainingTime){
|
||||||
|
@ -212,20 +195,14 @@ static s32 sampleLight_colorTimerEvtCb(void *arg)
|
||||||
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
|
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif COLOR_CCT_SUPPORT
|
else if(pColor->enhancedColorMode == ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS){
|
||||||
if(pColor->enhancedColorMode == ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS){
|
|
||||||
if(colorInfo.colorTempRemainingTime){
|
if(colorInfo.colorTempRemainingTime){
|
||||||
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
||||||
colorInfo.colorTempMinMireds, colorInfo.colorTempMaxMireds, FALSE);
|
colorInfo.colorTempMinMireds, colorInfo.colorTempMaxMireds, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if COLOR_RGB_SUPPORT
|
if(colorInfo.saturationRemainingTime || colorInfo.hueRemainingTime || colorInfo.colorTempRemainingTime){
|
||||||
if(colorInfo.saturationRemainingTime || colorInfo.hueRemainingTime){
|
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
if(colorInfo.colorTempRemainingTime){
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}else{
|
||||||
colorTimerEvt = NULL;
|
colorTimerEvt = NULL;
|
||||||
|
@ -249,7 +226,6 @@ static void sampleLight_colorTimerStop(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn sampleLight_colorLoopTimerEvtCb
|
* @fn sampleLight_colorLoopTimerEvtCb
|
||||||
*
|
*
|
||||||
|
@ -826,8 +802,6 @@ static void sampleLight_colorLoopSetProcess(zcl_colorCtrlColorLoopSetCmd_t *cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn sampleLight_moveToColorTemperatureProcess
|
* @fn sampleLight_moveToColorTemperatureProcess
|
||||||
*
|
*
|
||||||
|
@ -988,7 +962,6 @@ static void sampleLight_stepColorTemperatureProcess(zcl_colorCtrlStepColorTemper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn sampleLight_stopMoveStepProcess
|
* @fn sampleLight_stopMoveStepProcess
|
||||||
|
@ -1003,12 +976,9 @@ static void sampleLight_stopMoveStepProcess(void)
|
||||||
{
|
{
|
||||||
//zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
//zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
||||||
|
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
colorInfo.hueRemainingTime = 0;
|
colorInfo.hueRemainingTime = 0;
|
||||||
colorInfo.saturationRemainingTime = 0;
|
colorInfo.saturationRemainingTime = 0;
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
colorInfo.colorTempRemainingTime = 0;
|
colorInfo.colorTempRemainingTime = 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
}
|
}
|
||||||
|
@ -1028,7 +998,6 @@ status_t sampleLight_colorCtrlCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, voi
|
||||||
{
|
{
|
||||||
if(pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT){
|
if(pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT){
|
||||||
switch(cmdId){
|
switch(cmdId){
|
||||||
#if COLOR_RGB_SUPPORT
|
|
||||||
case ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_HUE:
|
case ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_HUE:
|
||||||
sampleLight_moveToHueProcess((zcl_colorCtrlMoveToHueCmd_t *)cmdPayload);
|
sampleLight_moveToHueProcess((zcl_colorCtrlMoveToHueCmd_t *)cmdPayload);
|
||||||
break;
|
break;
|
||||||
|
@ -1074,7 +1043,6 @@ status_t sampleLight_colorCtrlCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, voi
|
||||||
case ZCL_CMD_LIGHT_COLOR_CONTROL_COLOR_LOOP_SET:
|
case ZCL_CMD_LIGHT_COLOR_CONTROL_COLOR_LOOP_SET:
|
||||||
sampleLight_colorLoopSetProcess((zcl_colorCtrlColorLoopSetCmd_t *)cmdPayload);
|
sampleLight_colorLoopSetProcess((zcl_colorCtrlColorLoopSetCmd_t *)cmdPayload);
|
||||||
break;
|
break;
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
case ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_COLOR_TEMPERATURE:
|
case ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_COLOR_TEMPERATURE:
|
||||||
sampleLight_moveToColorTemperatureProcess((zcl_colorCtrlMoveToColorTemperatureCmd_t *)cmdPayload);
|
sampleLight_moveToColorTemperatureProcess((zcl_colorCtrlMoveToColorTemperatureCmd_t *)cmdPayload);
|
||||||
break;
|
break;
|
||||||
|
@ -1084,7 +1052,6 @@ status_t sampleLight_colorCtrlCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, voi
|
||||||
case ZCL_CMD_LIGHT_COLOR_CONTROL_STEP_COLOR_TEMPERATURE:
|
case ZCL_CMD_LIGHT_COLOR_CONTROL_STEP_COLOR_TEMPERATURE:
|
||||||
sampleLight_stepColorTemperatureProcess((zcl_colorCtrlStepColorTemperatureCmd_t *)cmdPayload);
|
sampleLight_stepColorTemperatureProcess((zcl_colorCtrlStepColorTemperatureCmd_t *)cmdPayload);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
case ZCL_CMD_LIGHT_COLOR_CONTROL_STOP_MOVE_STEP:
|
case ZCL_CMD_LIGHT_COLOR_CONTROL_STOP_MOVE_STEP:
|
||||||
sampleLight_stopMoveStepProcess();
|
sampleLight_stopMoveStepProcess();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -60,14 +60,11 @@ static void sampleLight_sceneRecallReqHandler(zclIncomingAddrInfo_t *pAddrInfo,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
||||||
#if COLOR_RGB_SUPPORT
|
u8 colorMode = pScene->extField[extLen+3];
|
||||||
u8 hue = pScene->extField[extLen+3];
|
u8 hue = pScene->extField[extLen+4];
|
||||||
u8 saturation = pScene->extField[extLen+4];
|
u8 saturation = pScene->extField[extLen+5];
|
||||||
extLen += 5;
|
u16 colorTemperatureMireds = BUILD_U16(pScene->extField[extLen+6], pScene->extField[extLen+7]);
|
||||||
#elif COLOR_CCT_SUPPORT
|
extLen += 8;
|
||||||
u16 colorTemperatureMireds = BUILD_U16(pScene->extField[extLen+3], pScene->extField[extLen+4]);
|
|
||||||
extLen += 5;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZCL_LEVEL_CTRL
|
#ifdef ZCL_LEVEL_CTRL
|
||||||
|
@ -80,7 +77,14 @@ static void sampleLight_sceneRecallReqHandler(zclIncomingAddrInfo_t *pAddrInfo,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
||||||
#if COLOR_RGB_SUPPORT
|
if (colorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION) {
|
||||||
|
zcl_colorCtrlMoveToColorTemperatureCmd_t move2ColorTemp;
|
||||||
|
move2ColorTemp.colorTemperature = colorTemperatureMireds;
|
||||||
|
move2ColorTemp.transitionTime = pScene->transTime;
|
||||||
|
move2ColorTemp.optPresent = 0;
|
||||||
|
|
||||||
|
sampleLight_colorCtrlCb(pAddrInfo, ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_COLOR_TEMPERATURE, &move2ColorTemp);
|
||||||
|
} else {
|
||||||
zcl_colorCtrlMoveToHueAndSaturationCmd_t move2HueAndSat;
|
zcl_colorCtrlMoveToHueAndSaturationCmd_t move2HueAndSat;
|
||||||
move2HueAndSat.hue = hue;
|
move2HueAndSat.hue = hue;
|
||||||
move2HueAndSat.saturation = saturation;
|
move2HueAndSat.saturation = saturation;
|
||||||
|
@ -88,14 +92,7 @@ static void sampleLight_sceneRecallReqHandler(zclIncomingAddrInfo_t *pAddrInfo,
|
||||||
move2HueAndSat.optPresent = 0;
|
move2HueAndSat.optPresent = 0;
|
||||||
|
|
||||||
sampleLight_colorCtrlCb(pAddrInfo, ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_HUE_AND_SATURATION, &move2HueAndSat);
|
sampleLight_colorCtrlCb(pAddrInfo, ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_HUE_AND_SATURATION, &move2HueAndSat);
|
||||||
#elif COLOR_CCT_SUPPORT
|
}
|
||||||
zcl_colorCtrlMoveToColorTemperatureCmd_t move2ColorTemp;
|
|
||||||
move2ColorTemp.colorTemperature = colorTemperatureMireds;
|
|
||||||
move2ColorTemp.transitionTime = pScene->transTime;
|
|
||||||
move2ColorTemp.optPresent = 0;
|
|
||||||
|
|
||||||
sampleLight_colorCtrlCb(pAddrInfo, ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_COLOR_TEMPERATURE, &move2ColorTemp);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,15 +134,12 @@ static void sampleLight_sceneStoreReqHandler(zcl_sceneEntry_t *pScene)
|
||||||
|
|
||||||
pScene->extField[extLen++] = LO_UINT16(ZCL_CLUSTER_LIGHTING_COLOR_CONTROL);
|
pScene->extField[extLen++] = LO_UINT16(ZCL_CLUSTER_LIGHTING_COLOR_CONTROL);
|
||||||
pScene->extField[extLen++] = HI_UINT16(ZCL_CLUSTER_LIGHTING_COLOR_CONTROL);
|
pScene->extField[extLen++] = HI_UINT16(ZCL_CLUSTER_LIGHTING_COLOR_CONTROL);
|
||||||
#if COLOR_RGB_SUPPORT
|
pScene->extField[extLen++] = 5;
|
||||||
pScene->extField[extLen++] = 2;
|
pScene->extField[extLen++] = pColor->colorMode;
|
||||||
pScene->extField[extLen++] = pColor->currentHue;
|
pScene->extField[extLen++] = pColor->currentHue;
|
||||||
pScene->extField[extLen++] = pColor->currentSaturation;
|
pScene->extField[extLen++] = pColor->currentSaturation;
|
||||||
#elif COLOR_CCT_SUPPORT
|
|
||||||
pScene->extField[extLen++] = 2;
|
|
||||||
pScene->extField[extLen++] = LO_UINT16(pColor->colorTemperatureMireds);
|
pScene->extField[extLen++] = LO_UINT16(pColor->colorTemperatureMireds);
|
||||||
pScene->extField[extLen++] = HI_UINT16(pColor->colorTemperatureMireds);
|
pScene->extField[extLen++] = HI_UINT16(pColor->colorTemperatureMireds);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pScene->extFieldLen = extLen;
|
pScene->extFieldLen = extLen;
|
||||||
|
|
Loading…
Reference in New Issue