Commit 8d0cc329 authored by limm's avatar limm

V1.0

parents
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
eclipse.preferences.version=1
iarToolchainValidator.dontBotherInvalidPaths=
eclipse.preferences.version=1
environment/project/com.silabs.ss.framework.project.toolchain.core.default\#com.silabs.ss.tool.ide.arm.toolchain.iar\:7.80.4.12462/PATH/delimiter=;
environment/project/com.silabs.ss.framework.project.toolchain.core.default\#com.silabs.ss.tool.ide.arm.toolchain.iar\:7.80.4.12462/PATH/operation=prepend
environment/project/com.silabs.ss.framework.project.toolchain.core.default\#com.silabs.ss.tool.ide.arm.toolchain.iar\:7.80.4.12462/PATH/value=D\:\\SiliconLabs\\SimplicityStudio\\v4\\support\\common\\build\\msys\\1.0\\bin
environment/project/com.silabs.ss.framework.project.toolchain.core.default\#com.silabs.ss.tool.ide.arm.toolchain.iar\:7.80.4.12462/append=true
environment/project/com.silabs.ss.framework.project.toolchain.core.default\#com.silabs.ss.tool.ide.arm.toolchain.iar\:7.80.4.12462/appendContributed=true
<?xml version="1.0"?>
<configurator>
<domain name="General" spec="zcl-7.0-07-5123-07" certifiable="true">
<older spec="zcl6-errata-14-0129-15" />
<older spec="zcl-6.0-15-02017-001" />
<older spec="zcl-1.0-07-5123-03" />
</domain>
<domain name="Lighting &amp; Occupancy" spec="l&amp;o-1.0-15-0014-04" certifiable="false" />
<domain name="HA" spec="ha-1.2.1-05-3520-30" dependsOn="zcl-1.0-07-5123-03" certifiable="false">
<older spec="ha-1.2-05-3520-29" dependsOn="zcl-1.0-07-5123-03" certifiable="true"/>
<older spec="ha-1.1-05-3520-27" dependsOn="zcl-1.0-07-5123-03" certifiable="true"/>
</domain>
<cluster>
<name>OptTunnel</name>
<domain>General</domain>
<description>The private cluster of the Konke company is used for the extended use of the private protocol </description>
<code>0xFCC0</code>
<define>OPT_TUNNEL_CLUSTER</define>
<client tick="false" init="true">true</client>
<server tick="false" init="true">true</server>
<attribute side="server" code="0x0000" define="OPT_DATA" type="CHAR_STRING" length="254" writable="true" default="" optional="true" >OptData</attribute>
<attribute side="server" code="0x0001" define="TTS" type="CHAR_STRING" length="254" writable="true" default="" optional="true" >TTS</attribute>
<attribute side="server" code="0x0002" define="MTO_RR_RspRandom" type="INT16U" min="0x00" max="0xFFFF" writable="true" default="" optional="true" >MTO_RR_RspRandom</attribute>
<attribute side="server" code="0x0003" define="AssociatedAnnounce" type="CHAR_STRING" length="16" writable="true" default="" optional="true" >AssociatedAnnounce</attribute>
<attribute side="server" code="0x0010" define="CMEI" type="CHAR_STRING" length="32" writable="true" default="" optional="true" >CMEI</attribute>
<attribute side="server" code="0x0011" define="ISN" type="CHAR_STRING" length="32" writable="true" default="" optional="true" >ISN</attribute>
<attribute side="server" code="0x0012" define="InstallCode" type="CHAR_STRING" length="32" writable="false" default="" optional="true" >InstallCode</attribute>
<attribute side="server" code="0x0013" define="CHUNK_N1" type="CHAR_STRING" length="32" writable="true" default="" optional="true" >CHUNK_N1</attribute>
</cluster>
</configurator>
#ifndef __IKONKE_MODULE_BATTERY_H_______________________________
#define __IKONKE_MODULE_BATTERY_H_______________________________
#include "app/framework/include/af.h"
#if defined(ADC_COUNT) && (ADC_COUNT > 0)
/* DESP: Battery adc sample init
* Auth: maozj.20200325.
* */
void kBatteryMonitorInit(void);
/* DESP: This function will sample the ADC according to flag whether need to write to attribute
* Auth: maozj.20200325.
* */
uint16_t kBatteryMonitorReadVotage(bool bIsWriteAttr);
#endif
#endif
#ifndef __IKONKE_MODULE_BUTTON_H_______________________________
#define __IKONKE_MODULE_BUTTON_H_______________________________
#include "app/framework/include/af.h"
#include "../general/ikk-module-def.h"
#include "../general/ikk-debug.h"
// Maximum number of buttons supported!
#define BTN_SUPPORT_MAXN 8
#define BTN_UNKNOW_ID 0 // Valid[1,254], 255 for Operate all at the same time!
#define BTN_ALLOPT_ID 255 // Valid[1,254], 255 for Operate all at the same time!
typedef enum { EBP_LOW = 0, EBP_HIGH, EBP_BOTH }BtnPolarityEnum;
typedef enum { EBA_IDLE = 0, EBA_CLICK, EBA_DCLICK, EBA_LONGPRESS, EBA_PRESSED, EBA_RELEASED}BtnActionEnum;
typedef void (*pBtnActionCallback)(unsigned char btnIndex, BtnActionEnum action );
typedef struct tag_button_configeration {
unsigned char u8ButtonId;
GPIO_Port_TypeDef port;
unsigned int pin;
BtnPolarityEnum eActionPolarity;
bool bSupportDClick;
bool bSupportPressedSend; //true:key always long pressed will send pressed message interval 1 second.used to sensor
unsigned int u32LongPressDuration; // MS
}BtnConfSt;
/* DESP: Assign an unused interrupt number.
* Auth: dingmz_frc.20191108.
* */
uint8_t kBtnAssignIRQNO(uint8_t btn_index, unsigned int pin );
/* DESP:Get usefull assign irq index for other interrupt gpio include button
* Auth: maozj.20200325.
* */
uint8_t kBtnGetAssignUsefullIndex(void);
/* DESP: single Button instance register interface.
* Auth: dingmz_frc.20191108. modify by maozj 20200326
* */
kk_err_t kBtnRegister(uint8_t id, GPIO_Port_TypeDef port, unsigned int pin, BtnPolarityEnum ePolarity, \
bool bSupportDClick, bool bSupportPressedSend, uint32_t u32LongPressDuration );
/* DESP: button module Initialize configuration interface.
* Note: Button initialization interface supports one-time registration of multiple buttons!
* Auth: dingmz_frc.20191107.
* */
kk_err_t kBtnModuleInit(BtnConfSt *btnlist, unsigned char btn_number, pBtnActionCallback pBtnActionCallback );
/* DESP: get button information by button id
* Auth: maozj.20191123.
* */
kk_err_t kBtnGetInfoByButtonId(uint8_t id, BtnConfSt *btnConf);
#endif
This diff is collapsed.
#ifndef __IKONKE_MODULE_LED_H_______________________________
#define __IKONKE_MODULE_LED_H_______________________________
#include "app/framework/include/af.h"
#include "../general/ikk-module-def.h"
#define LED_OBJS_SUPPORT_MAXN 8
// the number of physical gpios that can be mapped for a single LED control instance!
#define LED_GPIO_MAPPING_MAXN 4
#define LED_UNKNOW_ID 0 // Valid[1,254], 255 for Operate all at the same time!
#define LED_ALLOPT_ID 255 // Valid[1,254], 255 for Operate all at the same time!
#define BLINK_DEAD 0xffffffff
#define BLINK_NONE 0x0
// LED STATUS
typedef enum { LED_OFF = 0, LED_ON = 1, LED_TOGGLE, LED_IGNORE = 2 }LedOptEnum;
typedef enum { ELP_LOW = 0/* low to on */, ELP_HIGH/* high to on */ }LedPolarityEnum;
typedef struct {
GPIO_Port_TypeDef port;
unsigned int pin;
unsigned int pwmId; //0 :not use pwm
}LedGpioListSt;
// led configuration struct
typedef struct tag_led_config_st {
unsigned char u8LedId; // 0 ~ 254
unsigned char u8GpioMappNum;
LedGpioListSt gpios[LED_GPIO_MAPPING_MAXN];
LedPolarityEnum eActionPolarity;
//uint8_t pwmIds[LED_GPIO_MAPPING_MAXN]; //band pwm id
}LedConfSt;
typedef void (*pLedActionDoneCallback)(unsigned char id);
/* DESP: Indicator lamp behavior control interface.
Auth: dingmz_frc.20191108.
*/
void kLedOptTrigger(uint8_t id, uint32_t duration_on_ms, uint32_t duration_off_ms, uint32_t times, LedOptEnum start, LedOptEnum end );
/* DESP: Toggle LED
Auth: maozj.20200226.
*/
void kLedOptToggle(uint8_t id);
// Turn ON
#define LED_OPT_ON(id) do { \
kLedOptTrigger(id, 0, 0, 0, LED_ON, LED_IGNORE); \
}while(0)
// Turn OFF
#define LED_OPT_OFF(id) do { \
kLedOptTrigger(id, 0, 0, 0, LED_OFF, LED_IGNORE); \
}while(0)
// Turn TOGGLE add by maozj 20200226
#define LED_OPT_TOGGLE(id) do { \
kLedOptToggle(id); \
}while(0)
/* DESP: Check if the specified led indicator is bliking.
* Auth: dingmz_frc.20191108.
* */
bool kLedIsBlinking(uint8_t led_id );
/* DESP: single LED instance register interface.
* Auth: dingmz_frc.20191108.
* */
kk_err_t kLedRegister(uint8_t id, uint8_t gpio_num, LedGpioListSt gpio_list[], LedPolarityEnum ePolarity);
/* DESP: led control module Initialize configuration interface.
* Note: Led initialization interface supports one-time registration of multiple LEDs!
* Auth: dingmz_frc.20191108.
* */
kk_err_t kLedModuleInit(LedConfSt *ledlist, unsigned char led_number, pLedActionDoneCallback pCallback);
/* DESP: led control module Initialize modify by led id.
* Note: Led initialization interface
* Auth: maozj.20191226.
* */
kk_err_t kLedModuleInfoModifyGpioById(uint8_t id, LedConfSt ledconf);
#endif
This diff is collapsed.
#ifndef __IKONKE_MODULE_PWM_H_______________________________
#define __IKONKE_MODULE_PWM_H_______________________________
#include "app/framework/include/af.h"
#include "../general/ikk-module-def.h"
#include "em_timer.h"
#define PWM_OBJS_SUPPORT_MAXN 6
#define PWM_UNKNOW_ID 0 // Valid[1,254], 255 for Operate all at the same time!
#define PWM_ALLOPT_ID 255 // Valid[1,254], 255 for Operate all at the same time!
#define PWM_TIMER_MAX_DUTY_CYCLE_NUM 65535
#define PWM_TIMER_MID_DUTY_CYCLE_NUM 500
#define PWM_TIMER_MIN_DUTY_CYCLE_NUM 0
typedef enum {ELP_MIN = 0, ELP_MID,ELP_ANY, ELP_MAX, ELP_TO_BRIGHT/* min to max */, ELP_TO_DARKEN/* max to min */, ELP_OPT_DEFAULT=0xff }PwmGradientDirectionEnum;
typedef enum {KK_TIMER_CC0=0, KK_TIMER_CC1, KK_TIMER_CC2}PwmTimerChannelEnum;
typedef enum {KTIMER0=0, KTIMER1, KTIMER2, KTIMER3}TIMER_ENUM;
typedef struct {
GPIO_Port_TypeDef port;
unsigned int pin;
TIMER_ENUM pwmTimer;
PwmTimerChannelEnum pwmChannel;
}PwmGpioListSt;
// led configuration struct
typedef struct tag_pwm_config_st {
unsigned char u8PwmId; // 0 ~ 254
PwmGpioListSt gpioInfo;
//TIMER_TypeDef timer;
//uint8_t pwmChannel;
}PwmConfSt;
//funtion callback when pwm duty cycle is changed to max or min
typedef void (*pPwmActionDoneCallback)(unsigned char id, PwmGradientDirectionEnum opt);
/* DESP: get the pwm index by led_id.
* Auth: maozj.20200211.
* */
uint8_t kPwmGetIndexByID(uint8_t pwm_id );
/* DESP: Check whether all pwm have stopped action detection.
* Auth: maozj.20200211.
* */
bool kPwmGradientChangeIsGoing(void);
/* DESP: Check if the specified pwm is changing.
* Auth: maozj.20200211.
* */
bool kPwmIsChanging(uint8_t pwm_id );
/* DESP: registration the system pwm driver processing function interface.
Auth: maozj.20200211.
*/
void kPwmDriverhandler(uint8_t pwm_index, PwmGradientDirectionEnum st, uint16_t value);
/* DESP: pwm frequence init interface.
* Auth: maozj.20200212.
* */
void kPwmFrequencySetInit(uint16_t frequency_hz, uint16_t init_duty_cycle, PwmGpioListSt gpioInfo);
/* DESP: pwm control module Initialize configuration interface.
* Note: pwm initialization interface supports one-time registration of multiple pwm channel!
* Auth: maozj.20200219.
* */
kk_err_t kPwmModuleInit(PwmConfSt pwmlist[], unsigned char pwm_number, pPwmActionDoneCallback pCallback);
/* DESP: Indicator pwm trigger behavior control interface.
Auth: maozj.20200211.
*/
void kPwmOptTrigger(uint8_t id, uint32_t start_value, uint32_t end_value, uint32_t duration_time );
/* DESP: clear pwm gradient counter interface by pwm id.
* Auth: maozj.20200212.
* */
bool kPwmClearGradientCounterById(uint8_t pwm_id);
#endif
#ifndef __IKONKE_MODULE_ZERO_ACCESS_H_______________________________
#define __IKONKE_MODULE_ZERO_ACCESS_H_______________________________
#include "app/framework/include/af.h"
#include "../general/ikk-module-def.h"
#define RELAY_OBJS_SUPPORT_MAXN 8
// the number of physical gpios that can be mapped for a single Zero-Access channel instance!
#define RELAY_GPIO_MAPPING_MAXN 4
#define RELAY_CHNN_UNKNOW_ID 0 // Valid[1,254], 255 for Operate all at the same time!
#define RELAY_CHNN_ALLOPT_ID 255 // Valid[1,254], 255 for Operate all at the same time!
typedef enum { EZAO_OFF = 0, EZAO_ON = 1 , EZAO_DEFAULT = 0xFF}RelayOptEnum;
// Zero-Access channel status
typedef enum { EZAP_LOW = 0/* low to on */, EZAP_HIGH/* high to on */ }RelayPolarityEnum;
typedef struct {
GPIO_Port_TypeDef port;
unsigned int pin;
}RelayGpioListSt;
// ZA channel configuration struct
typedef struct tag_relay_config_st {
unsigned char u8RelayChannelId; // 0 ~ 254
unsigned char u8GpioMappNum; //relay numbers
RelayGpioListSt gpios[RELAY_OBJS_SUPPORT_MAXN]; //relay gpio buffer
RelayPolarityEnum eActionPolarity;
}RelayChannelConfSt;
typedef struct {
unsigned char u8RelayChannelId; // 0 ~ 254
RelayOptEnum opt;
}RelayStatusSt;
//user led control callback when relay on off
typedef void (*pRelayOptLedCallback)(RelayStatusSt stRelayStatus);
/* DESP: Zero-Access channel operate interface.
Auth: dingmz_frc.20191115.
*/
void kRelayChannelOpt(uint8_t channel_id, RelayOptEnum opt );
/* DESP: Relay control module Initialize configuration interface.alse zero gpio is not necessary
* PARAM[port]: the GPIO port for Zero-Access detection.
* PARAM[pin]: the GPIO pin for Zero-Access detection.
* PARAM[zero_on_time]: relay delay on time when get zero interrupt
* PARAM[zero_off_time]: relay delay off time when get zero interrupt
* PARAM[ePolarity]: the Zero GPIO pin interrupt edge
* PARAM[list]: the config list of all relay dection
* PARAM[channel_num]: total group number of relay.
* PARAM[callback]: callback function after relay operate done
* Auth: maozj.20191115.
* */
kk_err_t kRelayModuleInit(GPIO_Port_TypeDef port, uint8_t pin, uint32_t zero_on_time, uint32_t zero_off_time \
, RelayPolarityEnum ePolarity, RelayChannelConfSt *list, uint8_t channel_num, pRelayOptLedCallback callback);
#endif
#include "stdint.h"
#include "stdbool.h"
//#include "stack/include/ember-types.h"
#include "em_gpio.h"
#include "../driver/ikk-led.h"
#include "ikk-timer.h"
#include "../general/ikk-debug.h"
uint32_t lastcount = 0;
#define ONSHOT_MIN_TIMER_US (10)
pTimerPollCallback g_pTimer2PollCallback = NULL;
pTimerPollCallback g_pTimer2StopCallback = NULL;
static bool g_bIsTimer2Going = false;
pTimerPollCallback g_pTimer3PollCallback = NULL;
pTimerPollCallback g_pTimer3StopCallback = NULL;
static bool g_bIsTimer3Going = false;
//这里用于过零检测延时使用
void kTimer3Init(bool bIsOneShot, uint32_t time_us)
{
/* Enable clock for TIMER0 module */
CMU_ClockEnable(cmuClock_TIMER3, true);
//CMU_ClockEnable(cmuClock_HCLK, true); //开启高速外设时钟
CMU_ClockSelectSet(cmuClock_TIMER3, cmuSelect_HFXO);
/* Select TIMER0 parameters */
TIMER_Init_TypeDef timerInit =
{
.enable= false,//by kid
.debugRun= true,
.prescale= timerPrescale8,
.clkSel = timerClkSelHFPerClk,
.fallAction = timerInputActionNone,
.riseAction = timerInputActionNone,
.mode = timerModeUp,
.dmaClrAct= false,
.quadModeX4 = false,
.oneShot = bIsOneShot, //单次或循环
.sync= false,
};
// Configure TIMER3 Compare/Capture for output compare
TIMER_InitCC_TypeDef timerCCInit = TIMER_INITCC_DEFAULT;
timerCCInit.mode = timerCCModeCompare;
timerCCInit.cmoa = timerOutputActionNone; // none output on compare match //by kid
/* Configure TIMER */
TIMER_Init(TIMER3, &timerInit);
//TIMER_InitCC(TIMER3, 0, &timerCCInit
uint32_t g_u32TimerFreq = CMU_ClockFreqGet(cmuClock_TIMER3); /// (timerInit.prescale + 1);
uint32_t clkFreq = CMU_ClockFreqGet(cmuClock_HCLK);
iKonkeAfSelfPrint("\r\n\r\n######TIMER3 freq = %d clkFreq = %d #######\r\n", g_u32TimerFreq, clkFreq);
// Set compare value to the first compare value
// lastcount = time_ms;
// TIMER_CompareSet(TIMER3, 0, time_ms);
// Set Top value
// Note each overflow event constitutes 1/2 the signal period
g_u32TimerFreq = CMU_ClockFreqGet(cmuClock_TIMER3)/(timerInit.prescale + 1);
uint32_t topValue = (uint32_t)(g_u32TimerFreq / 1000000.0 * (time_us));
// uint32_t topValue = timerFreq * time_us;
TIMER_TopSet (TIMER3, topValue);
// Enable TIMER3 interrupts
//TIMER_IntEnable(TIMER3, TIMER_IEN_CC0);
TIMER_IntEnable(TIMER3, TIMER_IF_OF);
NVIC_EnableIRQ(TIMER3_IRQn);
// Enable the TIMER
TIMER_Enable(TIMER3, true);
}
//unsigned char test_timer3 = 0;
void TIMER3_IRQHandler(void)
{
uint32_t flags = TIMER_IntGet(TIMER3);
TIMER_IntClear(TIMER3, flags);
//test_timer3 ++ ;
//LED_OPT_TOGGLE(5);
if (g_pTimer3PollCallback){
g_pTimer3PollCallback();
}
g_bIsTimer3Going = false;
}
void TIMER2_IRQHandler(void)
{
uint32_t flags = TIMER_IntGet(TIMER2);
TIMER_IntClear(TIMER2, flags);
//test_timer3 ++ ;
//LED_OPT_TOGGLE(5);
//GPIO_PinOutToggle(gpioPortC, 3);
if (g_pTimer2PollCallback){
g_pTimer2PollCallback();
}
g_bIsTimer2Going = false;
}
void kTimer3Start(bool bIsOneShot, uint32_t time_us, pTimerPollCallback start_callback, pTimerPollCallback stop_callback)
{
g_bIsTimer3Going = true;
g_pTimer3PollCallback = start_callback;
g_pTimer3StopCallback = stop_callback;
kTimer3Init(bIsOneShot, time_us);
}
void kTimer3Stop(void)
{
NVIC_ClearPendingIRQ(TIMER3_IRQn);
NVIC_DisableIRQ(TIMER3_IRQn);
// Disable the TIMER
TIMER_Enable(TIMER3, false);
if (g_pTimer3StopCallback){
g_pTimer3StopCallback();
}
}
bool kTimer3IsGoing(void)
{
return g_bIsTimer3Going;
}
void kTimer2Init(bool bIsOneShot, uint32_t time_us)
{
/* Enable clock for TIMER0 module */
CMU_ClockEnable(cmuClock_TIMER2, true);
//CMU_ClockEnable(cmuClock_HCLK, true); //开启高速外设时钟
CMU_ClockSelectSet(cmuClock_TIMER2, cmuSelect_HFXO);
/* Select TIMER0 parameters */
TIMER_Init_TypeDef timerInit =
{
.enable= false,//by kid
.debugRun= true,
.prescale= timerPrescale8,
.clkSel = timerClkSelHFPerClk,
.fallAction = timerInputActionNone,
.riseAction = timerInputActionNone,
.mode = timerModeUp,
.dmaClrAct= false,
.quadModeX4 = false,
.oneShot = bIsOneShot, //单次或循环
.sync= false,
};
// Configure TIMER3 Compare/Capture for output compare
TIMER_InitCC_TypeDef timerCCInit = TIMER_INITCC_DEFAULT;
timerCCInit.mode = timerCCModeCompare;
timerCCInit.cmoa = timerOutputActionNone; // none output on compare match //by kid
/* Configure TIMER */
TIMER_Init(TIMER2, &timerInit);
//TIMER_InitCC(TIMER3, 0, &timerCCInit
uint32_t g_u32TimerFreq = CMU_ClockFreqGet(cmuClock_TIMER2); /// (timerInit.prescale + 1);
uint32_t clkFreq = CMU_ClockFreqGet(cmuClock_HCLK);
iKonkeAfSelfPrint("\r\n\r\n######TIMER2 freq = %d clkFreq = %d #######\r\n", g_u32TimerFreq, clkFreq);
// Set compare value to the first compare value
// lastcount = time_ms;
// TIMER_CompareSet(TIMER3, 0, time_ms);
// Set Top value
// Note each overflow event constitutes 1/2 the signal period
g_u32TimerFreq = CMU_ClockFreqGet(cmuClock_TIMER2)/(timerInit.prescale + 1);
uint32_t topValue = (uint32_t)(g_u32TimerFreq / 1000000.0 * (time_us));
// uint32_t topValue = timerFreq * time_us;
TIMER_TopSet (TIMER2, topValue);
// Enable TIMER3 interrupts
//TIMER_IntEnable(TIMER3, TIMER_IEN_CC0);
TIMER_IntEnable(TIMER2, TIMER_IF_OF);
NVIC_EnableIRQ(TIMER2_IRQn);
// Enable the TIMER
TIMER_Enable(TIMER2, true);
}
void kTimer2Start(bool bIsOneShot, uint32_t time_us, pTimerPollCallback start_callback, pTimerPollCallback stop_callback)
{
g_bIsTimer2Going = true;
g_pTimer2PollCallback = start_callback;
g_pTimer2StopCallback = stop_callback;
kTimer2Init(bIsOneShot, time_us);
}
void kTimer2Stop(void)
{
NVIC_ClearPendingIRQ(TIMER2_IRQn);
NVIC_DisableIRQ(TIMER2_IRQn);
// Disable the TIMER
TIMER_Enable(TIMER2, false);
if (g_pTimer2StopCallback){
g_pTimer2StopCallback();
}
}
bool kTimer2IsGoing(void)
{
return g_bIsTimer2Going;
}
#ifndef __IKONKE_MODULE_TIMER_H_______________________________
#define __IKONKE_MODULE_TIMER_H_______________________________
#include "app/framework/include/af.h"
//#include "../general/ikk-module-def.h"
#include "em_timer.h"
#if 0
#if defined(RTCC_PRESENT) && (RTCC_COUNT == 1)
#define RTCDRV_USE_RTCC
#else
#define RTCDRV_USE_RTC
#endif
#if defined(RTCDRV_USE_RTCC)
#include "em_rtcc.h"
#else
#include "em_rtc.h"
#endif
#endif
//#include "rtcdriver.h"
extern unsigned char test_timer3;
extern uint32_t lastcount;
typedef void (*pTimerPollCallback)(void);
void kTimer3Init(bool bIsOneShot, uint32_t time_us);
bool kTimer3IsGoing(void);
void kTimer3Start(bool bIsOneShot, uint32_t time_us, pTimerPollCallback start_callback, pTimerPollCallback stop_callback);
void kTimer3Stop(void);
void kTimer2Init(bool bIsOneShot, uint32_t time_us);
bool kTimer2IsGoing(void);
void kTimer2Start(bool bIsOneShot, uint32_t time_us, pTimerPollCallback start_callback, pTimerPollCallback stop_callback);
void kTimer2Stop(void);
#endif
This diff is collapsed.
#ifndef __IKONKE_MODULE_UART_H_______________________________
#define __IKONKE_MODULE_UART_H_______________________________
#include "stdint.h"
#include "ctype.h"
#include "app/framework/include/af.h"
#include "../general/ikk-module-def.h"
#include "serial/com.h"
// MSG BUFFER OF NODE MAXLENGTH
#define UMSG_NODE_SIZE 32
// Maximum number of message nodes in the queue
#define UMSG_NODE_MAX 3
// Maximum Cache Length of Message Receiver
#define UART_RECEIVER_CACHE_SIZE 128
//
typedef enum { EQU_RECV = 0, EQU_SENT }QueueEm;
// uart recv/send buffer node
typedef struct tag_uart_message_node {
unsigned char buffer[UMSG_NODE_SIZE];
unsigned char length;
// just for sending, Used to match instruction responses. For example, according to the instruction opcode!
unsigned char matcher[4];
unsigned char matcher_offset;
unsigned char matcher_n;
// just for sending, need to dispatch the response message?
bool bRspNeedtoDispatch;
// Attempt to send number of times, decreases to 0 when invalid!!!
unsigned char sent_try;
}UMsgNodeSt;
typedef struct tag_uart_message_queue {
UMsgNodeSt node[UMSG_NODE_MAX];
unsigned char counter;
}UMsgQueueSt;
typedef bool (*PFUNC_CRC)(uint8_t *pdat, int length );
typedef void (*PFUNC_INCOMING_CALLBACK)(UMsgNodeSt *pMsgNode );
typedef struct tag_uart_manager_st {
COM_Port_t port;
uint8_t recv_header[4];
uint8_t recv_header_n;
// head detection assistant chunk!
uint8_t header_chunk[4];
uint8_t header_chunk_index;
PFUNC_CRC pfunc_crc;
PFUNC_INCOMING_CALLBACK pfunc_incoming;
// support for sleepy device. when waking up, the serial port receives automatically,
// and after receiving, it sleeps actively.
bool bSleepSupport;
// support for sleepy device. the countdown ends and goes to sleep!
uint16_t u16SleepCounter;
}UartManagerSt;
#if 0
typedef enum {
UCOM_USART0 = 1,
UCOM_USART1 = 2,
UCOM_USART2 = 3,
}UCOMPortEm;
typedef enum { // parity
USART_PARITY_NONE = 0,
USART_PARITY_EVEN,
USART_PARITY_ODD,
}UParityTypeEm;
#endif
extern EmberEventControl ikkUartRecvLoopCheckEvent;
extern EmberEventControl ikkUartMsgDispatchEvent;
/* DESP: serial usart message data sent interface.
Auth: dingmz_frc.20190627.
*/
kk_err_t kUartMsgSent(UMsgNodeSt *pMsgNode );
/* DESP: In sleep mode, this interface is needed to activate the Uart module when the system is awakened.
* Auth: dingmz_frc.20191113.
* */
void kUartActiveTrigger(void );
/* DESP: serial usart driver init interface.
* PARAM[recv_header]: Recognition Sequence of recv effective data frame header and detection of Data Frame start.
* PARAM[recv_header_n]: the length of recv data frame header.
* PARAM[pfunc_crc]: CRC function.
* PARAM[pfunc_incoming]: Callback function when valid data frame is detected, provided by youself.
* PARAM[bSleepSupport]: support for sleepy device function.
* Auth: dingmz_frc.20190620.
* */
kk_err_t kUartModuleInit(COM_Port_t port, uint32_t rate, USART_Parity_TypeDef parity, uint8_t stopBits
, uint8_t recv_header[], uint8_t recv_header_n
, PFUNC_CRC pfunc_crc, PFUNC_INCOMING_CALLBACK pfunc_incoming
, bool bSleepSupport );
#endif
#ifndef __IKONKE_MODULE_ZCL_H________________________________
#define __IKONKE_MODULE_ZCL_H________________________________
#include "stdint.h"
#include "ctype.h"
#include "app/framework/include/af.h"
#include "ikk-module-def.h"
#include "Z3LightPanelDemoTest.h"
// sleepy device poll procedule control manager
typedef struct tag_poll_control_manager {
uint8_t nodata_counter;
uint8_t nodata_upperline;
bool bAutoAdjustUpperLine;
}PollControlManagerSt;
typedef struct tag_zcl_report_table{
uint8_t endpoint;
bool reportEnable;
bool sceneRecallFlg;
bool reportGatewayEnable;
bool reportChildDeviceEnable;
}ZclReportTableSt;
typedef enum{ EOOC_OFF = 0, EOOC_ON, EOOC_TOGGLE, EOOC_UNKNOW }OnOffCtrlEnum;
typedef enum{ EOOS_OFF = 0, EOOS_ON, EOOS_UNKNOW }OnOffStatusEnum;
#ifdef ZCL_USING_IAS_ZONE_CLUSTER_SERVER
typedef enum{
BIT_INIT=0,\
ALARM1=0, ALARM2, TAMPER, BATTERY, SUPERVISION_REPORT, \
RESTOR_REPORT, TROUBLE, AC_MAINS, TEST, BATTRY_DEFECT
}IasZoneStatusBitEnum;
#endif
typedef void (*pOnOffClusterOnOffStatusCallback)(uint8_t endpoint, OnOffStatusEnum estatus );
typedef void (*pSceneClusterRecallCallback)(uint8_t endpoint, uint16_t cluster, uint8_t command_id
, bool reportEnable, bool sceneRecallFlg, bool reportGatewayEnable, bool reportChildDeviceEnable);
/* DESP: get the onoff status of the specified endpoint.
* Auth: dingmz_frc.20191112.
* */
OnOffStatusEnum kZclOnOffClusterServerOnOffGet(uint8_t endpoint );
/* DESP: update(write) the onoff cluster onoff attribute value.
* Auth: dingmz_frc.20191112.
* */
kk_err_t kZclOnOffClusterServerOnOffControl(uint8_t endpoint, OnOffCtrlEnum ctrlopt );
/* DESP: on-off cluster initialization interface.
* Auth: dingmz_frc.20191112.
* */
kk_err_t kZclOnOffClusterServerInit(pOnOffClusterOnOffStatusCallback pOnOffStatusCallback );
/* DESP: OTA cluster client initialization interface.
* Auth: dingmz_frc.20191112.
* */
kk_err_t kZclOTAClusterClientInit(uint8_t led_id );
/* DESP: IAS status report common interface.
* Note: When bRetryAction == true, it means that the operation is a retransmit operation after detecting the network.
* This time, the network state is no longer detected.
* Auth: dingmz_frc.20190626.
* */
kk_err_t kZclIASZoneStatusUpdate(uint8_t end_point, uint8_t status, bool bRetryAction );
/* DESP: Reset the reporting procedure for the specified attribute, running from the start point.
* PARAM[bImmediateEffect][bool]: Is it effective immediately?
* Auth: dingmz_frc.20190513.
* */
bool kkResetReportingProcedure2StartPoint(uint8_t endpoint, uint16_t cluster_id, uint16_t attribute_id
, bool bImmediateEffect );
/* DESP: reset all server attribute period report, force to start.
* Auth: dingmz_frc.20190512.
* */
void kMsgSetServerAttributesReportingPeriod(void );
/* DESP: reset the reporting period of the specified attribute.
* PARAM[min_interval][uint16_t]: min period to be reset.
* PARAM[max_interval][uint16_t]: max period to be set.
* PARAM[reportable_change][uint32_t]: Set the number of analog changes that can be reported
* PARAM[bReset][bool]: reset period timer to zero!
* Auth: dingmz_frc.20190513.
* */
bool kkResetReportingPeriod(uint8_t endpoint, uint16_t cluster_id, uint16_t attribute_id,
uint16_t min_interval, uint16_t max_interval, uint32_t reportable_change, bool bReset );
bool kkClusterGetReportingPeriod(uint8_t endpoint, uint16_t cluster_id, uint16_t attribute_id,uint16_t *min_interval, uint16_t *max_interval );
/* DESP: trigger poll procedule based on current sleepy device status detection.
* PARAM[poll_attempts] number of polls without data!
* Auth: dingmz_frc.20190711.
* */
void kkPollProceduleTrigger(uint8_t poll_attempts, bool bAutoAdjust );
/* DESP: poll procedule completed callback interface.
* Auth: dingmz_frc.20190711.
* */
void kkPollProceduleCompletedCallback(EmberStatus status );
/* DESP: prevent sensor flg clear when short poll or long poll.
* Auth: maozj.20191209.
* */
void kkClearPreventSensorFlg(void);
/* DESP: prevent sensor flg get when short poll or long poll.
* Auth: maozj.20191209.
* */
bool kkGetPreventSensorFlg(void);
/* DESP: Get Remote Gataway Type.
* Auth: maozj.20191209.
* */
bool kIsKonkeRemoteGateway(void);
/* DESP: heartbeat report
* Auth: maozj.20191213.
* */
void kZclClusterHeartbeatControl(uint8_t endpoint, uint16_t clusterId, uint16_t attributeId);
void kOptTunnelReportingPlagiarizeOriginal(uint8_t endpoint, uint16_t clusterId, uint16_t attributeId, uint8_t mask );
#ifdef ZCL_USING_SCENES_CLUSTER_SERVER
void kZclClusterSceneRecallCallbackInit(pSceneClusterRecallCallback callback);
#endif
bool kZclClusterGetPermitReportInfo(uint8_t endpoint, ZclReportTableSt *zclReportPermit);
bool kZclClusterSetPermitReportInfo(uint8_t endpoint, bool reportEnable, bool sceneRecallFlg, bool reportGatewayEnable, bool reportChildDeviceEnable);
#if 0
/* DESP: Send different data separately according to whether or not to bind multiple controllers
* Auth: maozj.20200511.
* */
void kZclClusterConditionallySendReport(uint8_t endpoint, EmberAfClusterId clusterId, bool sendToGateway, bool sendToChildDevice);
#endif
/* DESP: Check whether the binding table is bound to a non-gateway Ieee address
* Note: just for the standard specification clusters.
* Auth: maozj.20200511.
* */
bool kZclNodeIsBindNotGatewayIeeeAddress(uint8_t src_endpoint, uint16_t cluster_id);
#endif
#ifndef __IKONKE_MODULE_DEBUG_H______________________________
#define __IKONKE_MODULE_DEBUG_H______________________________
#define IKONKE_DEBUG_LOG_ENABLE (1) // ENABLE
#define PROMPT_DSR ""
#if (IKONKE_DEBUG_LOG_ENABLE)
#define iKonkeAfSelfPrint(...) do { \
emberAfPrint(0xffff, PROMPT_DSR); \
emberAfPrint(0xffff, __VA_ARGS__); \
}while(0)
#define iKonkeAfSelfDebugExec(x) if ( emberAfPrintEnabled(0xffff) ) { x; }
#define iKonkeAfSelfPrintBuffer(buffer, len, withSpace) emberAfPrintBuffer(0xffff, (buffer), (len), (withSpace))
#define iKonkeAfSelfPrintString(buffer) emberAfPrintString(0xffff, (buffer))
#else
#define iKonkeAfSelfPrint(...)
#define iKonkeAfSelfDebugExec(x)
#define iKonkeAfSelfPrintBuffer(buffer, len, withSpace)
#define iKonkeAfSelfPrintString(buffer)
#endif
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment