恢复到4aa84e1版本
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
#include "light_transition.h"
|
#include "light_transition.h"
|
||||||
#include "pwm.h"
|
#include "pwm.h"
|
||||||
#include "rf433_decoder.h"
|
#include "rf433_decoder.h"
|
||||||
#include "timeslice.h"
|
|
||||||
union rf433_flag rf_flag = {0};
|
union rf433_flag rf_flag = {0};
|
||||||
unsigned char high_level_time;
|
unsigned char high_level_time;
|
||||||
unsigned char low_level_time;
|
unsigned char low_level_time;
|
||||||
@@ -18,6 +17,8 @@ uint32_t receive_data;
|
|||||||
|
|
||||||
|
|
||||||
uint8_t res_data=255; //433返回的最后一个控制字节(低八位)
|
uint8_t res_data=255; //433返回的最后一个控制字节(低八位)
|
||||||
|
static uint16_t long_time=0; //表示长按短按 该值一定要大与68,68是指68ms通过逻辑分析仪测量一帧433的时间
|
||||||
|
static uint16_t time_300ms=1; //表示:当长按的时候要300ms执行一次
|
||||||
static uint8_t POWER_flag;
|
static uint8_t POWER_flag;
|
||||||
|
|
||||||
uint32_t flag_1h =0;
|
uint32_t flag_1h =0;
|
||||||
@@ -98,19 +99,10 @@ static uint8_t pair_command_replay;
|
|||||||
#define PAIR_HOLD_FRAME_COUNT 4U
|
#define PAIR_HOLD_FRAME_COUNT 4U
|
||||||
#define PAIR_FRAME_SILENCE_TICKS 100U
|
#define PAIR_FRAME_SILENCE_TICKS 100U
|
||||||
#define PAIRING_WINDOW_TICKS 50000UL
|
#define PAIRING_WINDOW_TICKS 50000UL
|
||||||
|
#define RF433_RELEASE_TIMEOUT_TICKS 1500U
|
||||||
#define RF433_MS_TO_SAMPLE_TICKS(ms) ((uint16_t)((ms) * (1000U / RF433_DECODER_SAMPLE_US)))
|
#define RF433_MS_TO_SAMPLE_TICKS(ms) ((uint16_t)((ms) * (1000U / RF433_DECODER_SAMPLE_US)))
|
||||||
#define RF433_HOLD_GAP_TICKS ((uint32_t)RF433_MS_TO_SAMPLE_TICKS(250U))
|
|
||||||
#define RF433_REPEAT_TICKS ((uint32_t)RF433_MS_TO_SAMPLE_TICKS(500U))
|
|
||||||
uint8_t long_flag_s=0;
|
uint8_t long_flag_s=0;
|
||||||
|
|
||||||
static volatile uint32_t rf_sample_ticks;
|
|
||||||
static uint16_t rf_dispatch_sequence;
|
|
||||||
static uint32_t rf_hold_code;
|
|
||||||
static uint32_t rf_hold_last_frame_tick;
|
|
||||||
static uint32_t rf_hold_next_repeat_tick;
|
|
||||||
static uint8_t rf_hold_key;
|
|
||||||
static uint8_t rf_hold_active;
|
|
||||||
|
|
||||||
void _433_fun(void);
|
void _433_fun(void);
|
||||||
|
|
||||||
// Keep paired addresses ordered from oldest to newest.
|
// Keep paired addresses ordered from oldest to newest.
|
||||||
@@ -379,6 +371,7 @@ static void Rf433_Decoder_Frame_Poll(void)
|
|||||||
res_data = frame.key;
|
res_data = frame.key;
|
||||||
rf_frame_sequence++;
|
rf_frame_sequence++;
|
||||||
rf_flag.rf_receive_flag.receive_finish = 1U;
|
rf_flag.rf_receive_flag.receive_finish = 1U;
|
||||||
|
long_time = RF433_RELEASE_TIMEOUT_TICKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Encoder_key(){
|
void Encoder_key(){
|
||||||
@@ -388,11 +381,54 @@ void Encoder_key(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t KEY_STATE_Click; // 单击
|
||||||
|
uint32_t KEY_STATE_LONG_PRESS; // 长按
|
||||||
|
} _Key_TypeDef;
|
||||||
|
_Key_TypeDef Key_TypeDef={0,0};
|
||||||
|
uint32_t KEY_STATE_re=0; // 长按
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//该函数选择那个按键为单击,哪个为长按按键
|
||||||
|
static void set_click(){
|
||||||
|
if(res_data==Mode_add||res_data==Mode_dow||res_data==F_ON_OFF||res_data==F_Mode_choose||res_data==ON||res_data==OFF){
|
||||||
|
Key_TypeDef.KEY_STATE_Click=1; //单击
|
||||||
|
}else{
|
||||||
|
Key_TypeDef.KEY_STATE_LONG_PRESS=1; //长按
|
||||||
|
KEY_STATE_re=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void rf433_receive(void)//RF433 sample, called every 100 us
|
void rf433_receive(void)//RF433 sample, called every 100 us
|
||||||
{
|
{
|
||||||
rf433_decoder_sample((RF_DATA == HIGH_LEVEL) ? 1U : 0U);
|
rf433_decoder_sample((RF_DATA == HIGH_LEVEL) ? 1U : 0U);
|
||||||
rf_sample_ticks++;
|
|
||||||
long_flag_s = 0U;
|
if(long_time > 0U)
|
||||||
|
{
|
||||||
|
long_time--;
|
||||||
|
long_flag_s = 0U;
|
||||||
|
if(KEY_STATE_re == 1U)
|
||||||
|
{
|
||||||
|
if(time_300ms == 0U)
|
||||||
|
{
|
||||||
|
time_300ms = RF433_MS_TO_SAMPLE_TICKS(Short_time);
|
||||||
|
long_flag_s = 1U;
|
||||||
|
KEY_STATE_re = 0U;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
time_300ms--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
time_300ms = RF433_MS_TO_SAMPLE_TICKS(LongPress_time);
|
||||||
|
long_flag_s = 0U;
|
||||||
|
Key_TypeDef.KEY_STATE_Click = 0U;
|
||||||
|
KEY_STATE_re = 0U;
|
||||||
|
}
|
||||||
|
|
||||||
if(time_5s <= PAIRING_WINDOW_TICKS)
|
if(time_5s <= PAIRING_WINDOW_TICKS)
|
||||||
{
|
{
|
||||||
@@ -415,7 +451,9 @@ void _433_fun(){
|
|||||||
pair_deferred_receive_data = receive_data;
|
pair_deferred_receive_data = receive_data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(Key_TypeDef.KEY_STATE_Click==1||KEY_STATE_re==1) return;
|
||||||
|
set_click();
|
||||||
|
sss=1;//记忆标志位
|
||||||
switch(res_data){
|
switch(res_data){
|
||||||
//椭圆
|
//椭圆
|
||||||
case ON://单击
|
case ON://单击
|
||||||
@@ -496,92 +534,33 @@ void _433_fun(){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
set_TaskComps_timer(2U, 1000U);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//3748
|
//3748
|
||||||
static uint8_t Rf433_Address_Matched(uint32_t code)
|
|
||||||
{
|
|
||||||
uint8_t high = (uint8_t)((code >> 16) & 0xffU);
|
|
||||||
uint8_t low = (uint8_t)((code >> 8) & 0xffU);
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
if(match_success == 0U) return 1U;
|
|
||||||
|
|
||||||
for(i = 0U; i < 5U; i++)
|
|
||||||
{
|
|
||||||
if(adress_H_array[i] == high && adress_L_array[i] == low)
|
|
||||||
return 1U;
|
|
||||||
}
|
|
||||||
return 0U;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t Rf433_Time_Reached(uint32_t now, uint32_t deadline)
|
|
||||||
{
|
|
||||||
return ((int32_t)(now - deadline) >= 0) ? 1U : 0U;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Rf433_Run_Command(uint32_t code, uint8_t key)
|
|
||||||
{
|
|
||||||
receive_data = code;
|
|
||||||
res_data = key;
|
|
||||||
_433_fun();
|
|
||||||
}
|
|
||||||
|
|
||||||
void scan_433(){
|
void scan_433(){
|
||||||
uint32_t now = rf_sample_ticks;
|
|
||||||
|
if(power==0){
|
||||||
if(power != 0U) return;
|
if(rf_flag.rf_receive_flag.receive_finish==1){
|
||||||
|
if(match_success==1){
|
||||||
if(rf_hold_active &&
|
if((adress_H_array[0]==((receive_data >> 16) & 0xff)&&adress_L_array[0]==((receive_data >> 8) & 0xff))||
|
||||||
(uint32_t)(now - rf_hold_last_frame_tick) > RF433_HOLD_GAP_TICKS)
|
(adress_H_array[1]==((receive_data >> 16) & 0xff)&&adress_L_array[1]==((receive_data >> 8) & 0xff))||
|
||||||
{
|
(adress_H_array[2]==((receive_data >> 16) & 0xff)&&adress_L_array[2]==((receive_data >> 8) & 0xff))||
|
||||||
rf_hold_active = 0U;
|
(adress_H_array[3]==((receive_data >> 16) & 0xff)&&adress_L_array[3]==((receive_data >> 8) & 0xff))||
|
||||||
}
|
(adress_H_array[4]==((receive_data >> 16) & 0xff)&&adress_L_array[4]==((receive_data >> 8) & 0xff))
|
||||||
|
){
|
||||||
if(rf_dispatch_sequence != rf_frame_sequence)
|
_433_fun();
|
||||||
{
|
}
|
||||||
uint32_t code = receive_data;
|
}else if(match_success==0){
|
||||||
uint8_t key = res_data;
|
_433_fun();
|
||||||
uint32_t frame_gap = (uint32_t)(now - rf_hold_last_frame_tick);
|
}
|
||||||
|
}
|
||||||
rf_dispatch_sequence = rf_frame_sequence;
|
rf_flag.rf_receive_flag.receive_finish=0;
|
||||||
rf_flag.rf_receive_flag.receive_finish = 0U;
|
}
|
||||||
|
|
||||||
if(!Rf433_Address_Matched(code))
|
|
||||||
{
|
|
||||||
rf_hold_active = 0U;
|
|
||||||
}
|
|
||||||
else if(key >= 16U)
|
|
||||||
{
|
|
||||||
/* Color-ring frames stay unthrottled for smooth sliding. */
|
|
||||||
rf_hold_active = 0U;
|
|
||||||
Rf433_Run_Command(code, key);
|
|
||||||
}
|
|
||||||
else if(!rf_hold_active || rf_hold_code != code ||
|
|
||||||
frame_gap > RF433_HOLD_GAP_TICKS)
|
|
||||||
{
|
|
||||||
/* The first valid frame is an immediate short-press action. */
|
|
||||||
rf_hold_active = 1U;
|
|
||||||
rf_hold_code = code;
|
|
||||||
rf_hold_key = key;
|
|
||||||
rf_hold_last_frame_tick = now;
|
|
||||||
rf_hold_next_repeat_tick = now + RF433_REPEAT_TICKS;
|
|
||||||
Rf433_Run_Command(code, key);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rf_hold_last_frame_tick = now;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rf_hold_active &&
|
|
||||||
(uint32_t)(now - rf_hold_last_frame_tick) <= RF433_HOLD_GAP_TICKS &&
|
|
||||||
Rf433_Time_Reached(now, rf_hold_next_repeat_tick))
|
|
||||||
{
|
|
||||||
Rf433_Run_Command(rf_hold_code, rf_hold_key);
|
|
||||||
rf_hold_next_repeat_tick = now + RF433_REPEAT_TICKS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -396,7 +396,6 @@ int main(void)
|
|||||||
xc_fmc_spi_flash_wake_up();
|
xc_fmc_spi_flash_wake_up();
|
||||||
|
|
||||||
fmc_spi_read();
|
fmc_spi_read();
|
||||||
power_restore_apply_on_boot();
|
|
||||||
timer0_2_init();
|
timer0_2_init();
|
||||||
bluetooth_init();
|
bluetooth_init();
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "PWM.h"
|
#include "PWM.h"
|
||||||
#include "RF433.h"
|
#include "RF433.h"
|
||||||
#include "xc60xx.h"
|
#include "xc60xx.h"
|
||||||
#include "timeslice.h"
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------------
|
||||||
Macros
|
Macros
|
||||||
@@ -74,15 +73,6 @@ unsigned char get_checksum(unsigned char *ptrdata, unsigned char length)
|
|||||||
#define FLASH_BRIGHTNESS_PERCENT_MARK 0xA5U
|
#define FLASH_BRIGHTNESS_PERCENT_MARK 0xA5U
|
||||||
#define FLASH_MODE_LAYOUT_INDEX 26U
|
#define FLASH_MODE_LAYOUT_INDEX 26U
|
||||||
#define FLASH_MODE_LAYOUT_MARK 0xA6U
|
#define FLASH_MODE_LAYOUT_MARK 0xA6U
|
||||||
#define FLASH_POWER_MODE_MARK_INDEX 27U
|
|
||||||
#define FLASH_POWER_MODE_INDEX 28U
|
|
||||||
#define FLASH_POWER_CYCLE_INDEX 29U
|
|
||||||
#define FLASH_POWER_MODE_MARK 0xA7U
|
|
||||||
#define USER_STATE_SAVE_DELAY_MS 1000U
|
|
||||||
#define POWER_CYCLE_BOOT_SAVE_DELAY_MS 100U
|
|
||||||
|
|
||||||
uint8_t power_restore_policy = POWER_RESTORE_CYCLE_STATIC;
|
|
||||||
static uint8_t power_cycle_next_color;
|
|
||||||
|
|
||||||
void read_user_data(void)
|
void read_user_data(void)
|
||||||
{
|
{
|
||||||
@@ -151,20 +141,6 @@ void read_user_data(void)
|
|||||||
}
|
}
|
||||||
if(choose_mode_falsg > CUSTOM_TEMPERATURE_MODE)
|
if(choose_mode_falsg > CUSTOM_TEMPERATURE_MODE)
|
||||||
choose_mode_falsg = EFFECT_MODE_MIN;
|
choose_mode_falsg = EFFECT_MODE_MIN;
|
||||||
if(r_data[FLASH_POWER_MODE_MARK_INDEX] == FLASH_POWER_MODE_MARK)
|
|
||||||
{
|
|
||||||
power_restore_policy = r_data[FLASH_POWER_MODE_INDEX];
|
|
||||||
if(power_restore_policy > POWER_RESTORE_CYCLE_STATIC)
|
|
||||||
power_restore_policy = POWER_RESTORE_CYCLE_STATIC;
|
|
||||||
power_cycle_next_color = r_data[FLASH_POWER_CYCLE_INDEX];
|
|
||||||
if(power_cycle_next_color > 2U)
|
|
||||||
power_cycle_next_color = 0U;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
power_restore_policy = POWER_RESTORE_CYCLE_STATIC;
|
|
||||||
power_cycle_next_color = 0U;
|
|
||||||
}
|
|
||||||
//choose_mode_bh=r_data[31];
|
//choose_mode_bh=r_data[31];
|
||||||
driveMode=r_data[32];
|
driveMode=r_data[32];
|
||||||
flag_1h = (r_data[36] << 24) | (r_data[35] << 16) | (r_data[34] << 8) | r_data[33];
|
flag_1h = (r_data[36] << 24) | (r_data[35] << 16) | (r_data[34] << 8) | r_data[33];
|
||||||
@@ -211,9 +187,9 @@ void wright_user_data(void)
|
|||||||
app_data[24]=adress_H_array[4];
|
app_data[24]=adress_H_array[4];
|
||||||
app_data[25]=adress_L_array[4];
|
app_data[25]=adress_L_array[4];
|
||||||
app_data[FLASH_MODE_LAYOUT_INDEX]=FLASH_MODE_LAYOUT_MARK;
|
app_data[FLASH_MODE_LAYOUT_INDEX]=FLASH_MODE_LAYOUT_MARK;
|
||||||
app_data[FLASH_POWER_MODE_MARK_INDEX]=FLASH_POWER_MODE_MARK;
|
app_data[27]=0;
|
||||||
app_data[FLASH_POWER_MODE_INDEX]=power_restore_policy;
|
app_data[28]=0;
|
||||||
app_data[FLASH_POWER_CYCLE_INDEX]=power_cycle_next_color;
|
app_data[29]=0;
|
||||||
app_data[30]=choose_mode_falsg;
|
app_data[30]=choose_mode_falsg;
|
||||||
app_data[31]=choose_mode_bh;
|
app_data[31]=choose_mode_bh;
|
||||||
app_data[32]=driveMode;
|
app_data[32]=driveMode;
|
||||||
@@ -239,56 +215,3 @@ void fmc_spi_read(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void power_restore_policy_set(uint8_t policy)
|
|
||||||
{
|
|
||||||
if(policy > POWER_RESTORE_CYCLE_STATIC) return;
|
|
||||||
|
|
||||||
/* Re-sending the active policy must not restart the color sequence. */
|
|
||||||
if(policy == POWER_RESTORE_CYCLE_STATIC &&
|
|
||||||
power_restore_policy != POWER_RESTORE_CYCLE_STATIC)
|
|
||||||
power_cycle_next_color = 0U;
|
|
||||||
|
|
||||||
power_restore_policy = policy;
|
|
||||||
set_TaskComps_timer(2U, USER_STATE_SAVE_DELAY_MS);
|
|
||||||
}
|
|
||||||
|
|
||||||
void power_restore_apply_on_boot(void)
|
|
||||||
{
|
|
||||||
uint8_t color;
|
|
||||||
|
|
||||||
if(power_restore_policy != POWER_RESTORE_CYCLE_STATIC) return;
|
|
||||||
|
|
||||||
color = power_cycle_next_color;
|
|
||||||
if(color > 2U) color = 0U;
|
|
||||||
|
|
||||||
deviceStatus = POWERON;
|
|
||||||
Mode = mode0;
|
|
||||||
choose_mode_falsg = color;
|
|
||||||
choose_mode_bh = 0U;
|
|
||||||
|
|
||||||
if(color == 0U)
|
|
||||||
{
|
|
||||||
W_PWM = 100U;
|
|
||||||
C_PWM = 0U;
|
|
||||||
driveMode = 1U;
|
|
||||||
}
|
|
||||||
else if(color == 1U)
|
|
||||||
{
|
|
||||||
W_PWM = 0U;
|
|
||||||
C_PWM = 100U;
|
|
||||||
driveMode = 2U;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
W_PWM = 50U;
|
|
||||||
C_PWM = 50U;
|
|
||||||
driveMode = 0U;
|
|
||||||
}
|
|
||||||
|
|
||||||
power_cycle_next_color = (uint8_t)((color + 1U) % 3U);
|
|
||||||
|
|
||||||
/* Persist the next color after startup while input power is stable.
|
|
||||||
* This sequence does not depend on a shutdown-time flash write.
|
|
||||||
*/
|
|
||||||
set_TaskComps_timer(2U, POWER_CYCLE_BOOT_SAVE_DELAY_MS);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ extern "C" {
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define POWER_RESTORE_FULL_MEMORY 0U
|
|
||||||
#define POWER_RESTORE_CYCLE_STATIC 1U
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------------
|
||||||
Macros
|
Macros
|
||||||
-------------------------------------------------------------------------------------*/
|
-------------------------------------------------------------------------------------*/
|
||||||
@@ -52,15 +49,12 @@ extern "C" {
|
|||||||
Global Variables
|
Global Variables
|
||||||
-------------------------------------------------------------------------------------*/
|
-------------------------------------------------------------------------------------*/
|
||||||
extern uint8_t data[];
|
extern uint8_t data[];
|
||||||
extern uint8_t power_restore_policy;
|
|
||||||
/*------------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------------
|
||||||
Exported Functions
|
Exported Functions
|
||||||
-------------------------------------------------------------------------------------*/
|
-------------------------------------------------------------------------------------*/
|
||||||
void fmc_spi_wright(void);
|
void fmc_spi_wright(void);
|
||||||
void fmc_spi_dma_demo(void);
|
void fmc_spi_dma_demo(void);
|
||||||
void fmc_spi_read(void);
|
void fmc_spi_read(void);
|
||||||
void power_restore_apply_on_boot(void);
|
|
||||||
void power_restore_policy_set(uint8_t policy);
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ TASK_COMPONENTS TaskComps[] =
|
|||||||
{0,1,1,choice_mode},
|
{0,1,1,choice_mode},
|
||||||
{0,5,5,set_mode},
|
{0,5,5,set_mode},
|
||||||
{0,1,1,Set_timing},
|
{0,1,1,Set_timing},
|
||||||
{0,10,10,scan_433},
|
{0,100,100,scan_433},
|
||||||
{0,3,3,Encoder_key},
|
{0, 100,3, Encoder_key},
|
||||||
{0,1,1,My_ADC_Get_Value},
|
{0,1,1,My_ADC_Get_Value},
|
||||||
{0,50,50,ble_state_sync_poll},
|
{0,50,50,ble_state_sync_poll},
|
||||||
{0, 311, 1, app_op_flash}, //用户数据持久化 fmc_spi_read9
|
{0, 311, 1, app_op_flash}, //用户数据持久化 fmc_spi_read9
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "timeslice.h"
|
#include "timeslice.h"
|
||||||
#include "fmc_spi.h"
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------------
|
||||||
Macros
|
Macros
|
||||||
@@ -84,6 +83,7 @@ void uart_receive_cb(uint8_t *buff, uint16_t len)
|
|||||||
void scan_uar_data(uint8_t *frame){
|
void scan_uar_data(uint8_t *frame){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
extern uint8_t sss;
|
||||||
uint8_t rx_date;
|
uint8_t rx_date;
|
||||||
void scan_uart(uint8_t *arr)
|
void scan_uart(uint8_t *arr)
|
||||||
{
|
{
|
||||||
@@ -105,6 +105,8 @@ void scan_uart(uint8_t *arr)
|
|||||||
checksum += user_rx_buf[i];
|
checksum += user_rx_buf[i];
|
||||||
}
|
}
|
||||||
user_rx_buf[5] = checksum; // 校验位
|
user_rx_buf[5] = checksum; // 校验位
|
||||||
|
sss=1;
|
||||||
|
// printf("sss=%d\r\n",sss);
|
||||||
switch (user_rx_buf[4])
|
switch (user_rx_buf[4])
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -132,11 +134,13 @@ void scan_uart(uint8_t *arr)
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(POWEROFF==deviceStatus)break;
|
if(POWEROFF==deviceStatus)break;
|
||||||
if(user_rx_buf[1] < BRIGHTNESS_MIN_PERCENT)
|
if(Mode==mode0){
|
||||||
user_rx_buf[1] = BRIGHTNESS_MIN_PERCENT;
|
if(user_rx_buf[1] < BRIGHTNESS_MIN_PERCENT)
|
||||||
else if(user_rx_buf[1] > BRIGHTNESS_MAX_PERCENT)
|
user_rx_buf[1] = BRIGHTNESS_MIN_PERCENT;
|
||||||
user_rx_buf[1] = BRIGHTNESS_MAX_PERCENT;
|
else if(user_rx_buf[1] > BRIGHTNESS_MAX_PERCENT)
|
||||||
Brightness = user_rx_buf[1];
|
user_rx_buf[1] = BRIGHTNESS_MAX_PERCENT;
|
||||||
|
Brightness = user_rx_buf[1];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if(POWEROFF==deviceStatus)break;
|
if(POWEROFF==deviceStatus)break;
|
||||||
@@ -168,14 +172,11 @@ void scan_uart(uint8_t *arr)
|
|||||||
flag_1h=flag_1h*60000;
|
flag_1h=flag_1h*60000;
|
||||||
//flag_1h=2000;
|
//flag_1h=2000;
|
||||||
break;
|
break;
|
||||||
case 12:
|
|
||||||
power_restore_policy_set(user_rx_buf[1]);
|
|
||||||
break;
|
|
||||||
case 9:
|
case 9:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
set_TaskComps_timer(2U, 1000U);
|
//set_TaskComps_timer(2,1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "usr_server.h"
|
#include "usr_server.h"
|
||||||
#include "Mode.h"
|
#include "Mode.h"
|
||||||
#include "PWM.h"
|
#include "PWM.h"
|
||||||
#include "fmc_spi.h"
|
|
||||||
#if (BLE_APP_PRESENT)
|
#if (BLE_APP_PRESENT)
|
||||||
|
|
||||||
uint8_t srv_user_lid = GATT_INVALID_USER_LID;
|
uint8_t srv_user_lid = GATT_INVALID_USER_LID;
|
||||||
@@ -92,8 +91,7 @@ uint8_t send_flag=1;
|
|||||||
#define BLE_STATE_DIRTY_BRIGHTNESS 0x04U
|
#define BLE_STATE_DIRTY_BRIGHTNESS 0x04U
|
||||||
#define BLE_STATE_DIRTY_SPEED 0x08U
|
#define BLE_STATE_DIRTY_SPEED 0x08U
|
||||||
#define BLE_STATE_DIRTY_TEMPERATURE 0x10U
|
#define BLE_STATE_DIRTY_TEMPERATURE 0x10U
|
||||||
#define BLE_STATE_DIRTY_POWER_MODE 0x20U
|
#define BLE_STATE_DIRTY_ALL 0x1FU
|
||||||
#define BLE_STATE_DIRTY_ALL 0x3FU
|
|
||||||
|
|
||||||
static uint8_t ble_state_dirty = BLE_STATE_DIRTY_ALL;
|
static uint8_t ble_state_dirty = BLE_STATE_DIRTY_ALL;
|
||||||
static uint8_t ble_last_power;
|
static uint8_t ble_last_power;
|
||||||
@@ -101,7 +99,6 @@ static uint8_t ble_last_mode;
|
|||||||
static uint8_t ble_last_brightness;
|
static uint8_t ble_last_brightness;
|
||||||
static uint8_t ble_last_speed;
|
static uint8_t ble_last_speed;
|
||||||
static uint8_t ble_last_temperature;
|
static uint8_t ble_last_temperature;
|
||||||
static uint8_t ble_last_power_mode;
|
|
||||||
|
|
||||||
static uint8_t ble_temperature_value(void)
|
static uint8_t ble_temperature_value(void)
|
||||||
{
|
{
|
||||||
@@ -135,8 +132,6 @@ void ble_state_sync_poll(void)
|
|||||||
ble_state_dirty |= BLE_STATE_DIRTY_SPEED;
|
ble_state_dirty |= BLE_STATE_DIRTY_SPEED;
|
||||||
if(Mode == mode0 && ble_temperature_value() != ble_last_temperature)
|
if(Mode == mode0 && ble_temperature_value() != ble_last_temperature)
|
||||||
ble_state_dirty |= BLE_STATE_DIRTY_TEMPERATURE;
|
ble_state_dirty |= BLE_STATE_DIRTY_TEMPERATURE;
|
||||||
if(power_restore_policy != ble_last_power_mode)
|
|
||||||
ble_state_dirty |= BLE_STATE_DIRTY_POWER_MODE;
|
|
||||||
|
|
||||||
if(!send_flag || !ble_state_dirty) return;
|
if(!send_flag || !ble_state_dirty) return;
|
||||||
|
|
||||||
@@ -164,18 +159,12 @@ void ble_state_sync_poll(void)
|
|||||||
data[3] = 0x05U;
|
data[3] = 0x05U;
|
||||||
sent_mask = BLE_STATE_DIRTY_SPEED;
|
sent_mask = BLE_STATE_DIRTY_SPEED;
|
||||||
}
|
}
|
||||||
else if(ble_state_dirty & BLE_STATE_DIRTY_TEMPERATURE)
|
else
|
||||||
{
|
{
|
||||||
value = ble_temperature_value();
|
value = ble_temperature_value();
|
||||||
data[3] = 0x06U;
|
data[3] = 0x06U;
|
||||||
sent_mask = BLE_STATE_DIRTY_TEMPERATURE;
|
sent_mask = BLE_STATE_DIRTY_TEMPERATURE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
value = power_restore_policy;
|
|
||||||
data[3] = 0x0CU;
|
|
||||||
sent_mask = BLE_STATE_DIRTY_POWER_MODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
data[0] = value;
|
data[0] = value;
|
||||||
if(slave_send_data(data, sizeof(data), CUSTOM_SVC_TX_CHAR_VAL) == GATT_NO_ERROR)
|
if(slave_send_data(data, sizeof(data), CUSTOM_SVC_TX_CHAR_VAL) == GATT_NO_ERROR)
|
||||||
@@ -184,8 +173,7 @@ void ble_state_sync_poll(void)
|
|||||||
else if(sent_mask == BLE_STATE_DIRTY_MODE) ble_last_mode = value;
|
else if(sent_mask == BLE_STATE_DIRTY_MODE) ble_last_mode = value;
|
||||||
else if(sent_mask == BLE_STATE_DIRTY_BRIGHTNESS) ble_last_brightness = value;
|
else if(sent_mask == BLE_STATE_DIRTY_BRIGHTNESS) ble_last_brightness = value;
|
||||||
else if(sent_mask == BLE_STATE_DIRTY_SPEED) ble_last_speed = value;
|
else if(sent_mask == BLE_STATE_DIRTY_SPEED) ble_last_speed = value;
|
||||||
else if(sent_mask == BLE_STATE_DIRTY_TEMPERATURE) ble_last_temperature = value;
|
else ble_last_temperature = value;
|
||||||
else ble_last_power_mode = value;
|
|
||||||
ble_state_dirty &= (uint8_t)(~sent_mask);
|
ble_state_dirty &= (uint8_t)(~sent_mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
LOAD 0x11011000
|
LOAD 0x1100E000
|
||||||
{
|
{
|
||||||
EXE 0x11011000
|
EXE 0x1100E000
|
||||||
{
|
{
|
||||||
startup_xinc.o (RESET, +FIRST)
|
startup_xinc.o (RESET, +FIRST)
|
||||||
* (+RO)
|
* (+RO)
|
||||||
@@ -20,8 +20,7 @@ LOAD 0x11011000
|
|||||||
*(ram_em)
|
*(ram_em)
|
||||||
}
|
}
|
||||||
ScatterAssert((0x530077b0)+ImageLength(RW2) < 0x53008000)
|
ScatterAssert((0x530077b0)+ImageLength(RW2) < 0x53008000)
|
||||||
/* User settings start at flash offset 0x1E000. */
|
ScatterAssert(ImageLength(EXE) <= 0x10000)
|
||||||
ScatterAssert(ImageLength(EXE) <= 0xD000)
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -338,7 +338,7 @@
|
|||||||
<v6Rtti>0</v6Rtti>
|
<v6Rtti>0</v6Rtti>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls>--gnu --diag_suppress=66 --feedback fb.txt</MiscControls>
|
<MiscControls>--gnu --diag_suppress=66 --feedback fb.txt</MiscControls>
|
||||||
<Define>WDT_ON=1 APP_SCAN_FUNCTION=0 CFG_MIN_STACK CONFIG_BT_WAKEUP_VIA_GPIO=0 CONFIG_HFCLK_IS_OSC32M_PLL_32M=1 SCATTER_LOAD_RAM_EM=1 SDK_VERSION="2b8e78c6" RC_32K=1 XC60XX CFG_BLE CFG_EMB CFG_STATIC HCI_TEST_NO_IP=0 CFG_ACT=20 CFG_CON=1 CFG_RAL=1 CFG_HOST CFG_APP CFG_APP_PRF CFG_RF_EXTRC CFG_AES_RPA CFG_PERIPHERAL USE_XIP=1 DEBUG_ENABLE ROM_ENV_ENABLE=0 CODE_USE_XIP CFG_PRF_BASS USE_ROM_FLASH=1 CFG_ADV_LOW_POWER CFG_CONN_OPTIMIZE_0x3E</Define>
|
<Define>APP_SCAN_FUNCTION=0 CFG_MIN_STACK CONFIG_BT_WAKEUP_VIA_GPIO=0 CONFIG_HFCLK_IS_OSC32M_PLL_32M=1 SCATTER_LOAD_RAM_EM=1 SDK_VERSION="2b8e78c6" RC_32K=1 XC60XX CFG_BLE CFG_EMB CFG_STATIC HCI_TEST_NO_IP=0 CFG_ACT=20 CFG_CON=1 CFG_RAL=1 CFG_HOST CFG_APP CFG_APP_PRF CFG_RF_EXTRC CFG_AES_RPA CFG_PERIPHERAL USE_XIP=1 DEBUG_ENABLE ROM_ENV_ENABLE=0 CODE_USE_XIP CFG_PRF_BASS USE_ROM_FLASH=1 CFG_ADV_LOW_POWER CFG_CONN_OPTIMIZE_0x3E</Define>
|
||||||
<Undefine></Undefine>
|
<Undefine></Undefine>
|
||||||
<IncludePath>..\..\..\..\..\component\ble\Include;..\app\api;..\..\..\..\..\component\ble\modules\aes\api;..\..\..\..\..\component\ble\modules\aes\src;..\..\..\..\..\component\ble\modules\common\api;..\..\..\..\..\component\ble\modules\common\src;..\..\..\..\..\component\ble\modules\ecc_p256\api;..\..\..\..\..\component\ble\modules\ecc_p256\src;..\..\..\..\..\component\ble\modules\h4tl\api;..\..\..\..\..\component\ble\modules\h4tl\src;..\..\..\..\..\component\ble\modules\ke\api;..\..\..\..\..\component\ble\modules\ke\src;..\..\..\..\..\component\ble\modules\nvds\api;..\..\..\..\..\component\ble\modules\nvds\src;..\..\..\..\..\component\ble\modules\rf\api;..\..\..\..\..\component\ble\modules\rf\src;..\..\..\..\..\component\ble\modules\rwip\api;..\..\..\..\..\component\ble\modules\rwip\src;..\..\..\..\..\component\ble\ip\ahi\api;..\..\..\..\..\component\ble\ip\ahi\src;..\..\..\..\..\component\ble\ip\ble\gaf\api;..\..\..\..\..\component\ble\ip\ble\gaf\inc;..\..\..\..\..\component\ble\ip\ble\gaf\src;..\..\..\..\..\component\ble\ip\ble\gaf\src\acc;..\..\..\..\..\component\ble\ip\ble\gaf\src\al;..\..\..\..\..\component\ble\ip\ble\gaf\src\arc;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\bc;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\capa;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\codec;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\uc;..\..\..\..\..\component\ble\ip\ble\gaf\src\iap;..\..\..\..\..\component\ble\ip\ble\hl\api;..\..\..\..\..\component\ble\ip\ble\hl\inc;..\..\..\..\..\component\ble\ip\ble\hl\src;..\..\..\..\..\component\ble\ip\ble\hl\src\gap;..\..\..\..\..\component\ble\ip\ble\hl\src\gap\gapc;..\..\..\..\..\component\ble\ip\ble\hl\src\gap\gapm;..\..\..\..\..\component\ble\ip\ble\hl\src\gatt;..\..\..\..\..\component\ble\ip\ble\hl\src\inc;..\..\..\..\..\component\ble\ip\ble\hl\src\l2cap;..\..\..\..\..\component\ble\ip\ble\ll\api;..\..\..\..\..\component\ble\ip\ble\ll\src;..\..\..\..\..\component\ble\ip\ble\ll\src\co;..\..\..\..\..\component\ble\ip\ble\ll\src\llc;..\..\..\..\..\component\ble\ip\ble\ll\src\lld;..\..\..\..\..\component\ble\ip\ble\ll\src\lli;..\..\..\..\..\component\ble\ip\ble\ll\src\llm;..\..\..\..\..\component\ble\ip\ble\profiles\bas\bass\api;..\..\..\..\..\component\ble\ip\ble\profiles\bas\bass\src;..\..\..\..\..\component\ble\ip\em\api;..\..\..\..\..\component\ble\ip\em\src;..\..\..\..\..\component\ble\ip\hci\api;..\..\..\..\..\component\ble\ip\hci\src;..\..\..\..\..\component\ble\ip\sch\api;..\..\..\..\..\component\ble\ip\sch\src;..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw;..\app\api;..\app\src;..\..\..\..\..\component\ble\plf\refip\src\arch;..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm;..\..\..\..\..\component\ble\plf\refip\src\arch\ll\gnuarm;..\..\..\..\..\component\ble\plf\refip\src\driver\reg;..\..\..\..\..\component\ble\plf\refip\src\arch\boot\rvds;..\..\..\..\..\component\ble\plf\refip\src\driver\syscntl;..\..\..\..\..\component\ble\plf\refip\src\driver\emi;..\..\..\..\..\component\ble\plf\refip\src\driver\intc;..\..\..\..\..\component\ble\plf\refip\src\driver\uart;..\..\..\..\..\component\ble\plf\refip\src\driver\flash;..\..\..\..\..\component\ble\plf\refip\src\driver\led;..\..\..\..\..\component\ble\modules\dbg\api;..\..\..\..\..\component\ble\plf\refip\src\driver\uart;..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS;..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device;..\..\..\..\..\component\xc6xx_drivers\Drivers\Startup;..\..\..\..\..\component\xc6xx_drivers\Drivers\Startup\xc60xx;..\..\..\..\..\component\xc6xx_drivers\Drivers\Periph_HAL_Driver;..\..\..\..\..\component\xc6xx_drivers\Drivers\Periph_HAL_Driver\Bitfields;..\..\..\..\..\component\xc6xx_drivers\Drivers\Periph_HAL_Driver\Ringbuffer;..\..\..\..\..\component\xc6xx_drivers\Drivers\test_case\PWR;..\..\..\..\..\component\xc6xx_drivers\Drivers\test_case\TIMER;..\..\..\..\..\component\ble\ip\ble\api;..\..\..\..\..\component\ble\ip\ble\ll_rom_port;..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver;..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register;..\..\..\..\..\component\ble\modules\flash;..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver;..\..\..\driver\adc_mic_pga\app\api;..\app\src\project_config;..\app\src\elk_leds</IncludePath>
|
<IncludePath>..\..\..\..\..\component\ble\Include;..\app\api;..\..\..\..\..\component\ble\modules\aes\api;..\..\..\..\..\component\ble\modules\aes\src;..\..\..\..\..\component\ble\modules\common\api;..\..\..\..\..\component\ble\modules\common\src;..\..\..\..\..\component\ble\modules\ecc_p256\api;..\..\..\..\..\component\ble\modules\ecc_p256\src;..\..\..\..\..\component\ble\modules\h4tl\api;..\..\..\..\..\component\ble\modules\h4tl\src;..\..\..\..\..\component\ble\modules\ke\api;..\..\..\..\..\component\ble\modules\ke\src;..\..\..\..\..\component\ble\modules\nvds\api;..\..\..\..\..\component\ble\modules\nvds\src;..\..\..\..\..\component\ble\modules\rf\api;..\..\..\..\..\component\ble\modules\rf\src;..\..\..\..\..\component\ble\modules\rwip\api;..\..\..\..\..\component\ble\modules\rwip\src;..\..\..\..\..\component\ble\ip\ahi\api;..\..\..\..\..\component\ble\ip\ahi\src;..\..\..\..\..\component\ble\ip\ble\gaf\api;..\..\..\..\..\component\ble\ip\ble\gaf\inc;..\..\..\..\..\component\ble\ip\ble\gaf\src;..\..\..\..\..\component\ble\ip\ble\gaf\src\acc;..\..\..\..\..\component\ble\ip\ble\gaf\src\al;..\..\..\..\..\component\ble\ip\ble\gaf\src\arc;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\bc;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\capa;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\codec;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\uc;..\..\..\..\..\component\ble\ip\ble\gaf\src\iap;..\..\..\..\..\component\ble\ip\ble\hl\api;..\..\..\..\..\component\ble\ip\ble\hl\inc;..\..\..\..\..\component\ble\ip\ble\hl\src;..\..\..\..\..\component\ble\ip\ble\hl\src\gap;..\..\..\..\..\component\ble\ip\ble\hl\src\gap\gapc;..\..\..\..\..\component\ble\ip\ble\hl\src\gap\gapm;..\..\..\..\..\component\ble\ip\ble\hl\src\gatt;..\..\..\..\..\component\ble\ip\ble\hl\src\inc;..\..\..\..\..\component\ble\ip\ble\hl\src\l2cap;..\..\..\..\..\component\ble\ip\ble\ll\api;..\..\..\..\..\component\ble\ip\ble\ll\src;..\..\..\..\..\component\ble\ip\ble\ll\src\co;..\..\..\..\..\component\ble\ip\ble\ll\src\llc;..\..\..\..\..\component\ble\ip\ble\ll\src\lld;..\..\..\..\..\component\ble\ip\ble\ll\src\lli;..\..\..\..\..\component\ble\ip\ble\ll\src\llm;..\..\..\..\..\component\ble\ip\ble\profiles\bas\bass\api;..\..\..\..\..\component\ble\ip\ble\profiles\bas\bass\src;..\..\..\..\..\component\ble\ip\em\api;..\..\..\..\..\component\ble\ip\em\src;..\..\..\..\..\component\ble\ip\hci\api;..\..\..\..\..\component\ble\ip\hci\src;..\..\..\..\..\component\ble\ip\sch\api;..\..\..\..\..\component\ble\ip\sch\src;..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw;..\app\api;..\app\src;..\..\..\..\..\component\ble\plf\refip\src\arch;..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm;..\..\..\..\..\component\ble\plf\refip\src\arch\ll\gnuarm;..\..\..\..\..\component\ble\plf\refip\src\driver\reg;..\..\..\..\..\component\ble\plf\refip\src\arch\boot\rvds;..\..\..\..\..\component\ble\plf\refip\src\driver\syscntl;..\..\..\..\..\component\ble\plf\refip\src\driver\emi;..\..\..\..\..\component\ble\plf\refip\src\driver\intc;..\..\..\..\..\component\ble\plf\refip\src\driver\uart;..\..\..\..\..\component\ble\plf\refip\src\driver\flash;..\..\..\..\..\component\ble\plf\refip\src\driver\led;..\..\..\..\..\component\ble\modules\dbg\api;..\..\..\..\..\component\ble\plf\refip\src\driver\uart;..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS;..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device;..\..\..\..\..\component\xc6xx_drivers\Drivers\Startup;..\..\..\..\..\component\xc6xx_drivers\Drivers\Startup\xc60xx;..\..\..\..\..\component\xc6xx_drivers\Drivers\Periph_HAL_Driver;..\..\..\..\..\component\xc6xx_drivers\Drivers\Periph_HAL_Driver\Bitfields;..\..\..\..\..\component\xc6xx_drivers\Drivers\Periph_HAL_Driver\Ringbuffer;..\..\..\..\..\component\xc6xx_drivers\Drivers\test_case\PWR;..\..\..\..\..\component\xc6xx_drivers\Drivers\test_case\TIMER;..\..\..\..\..\component\ble\ip\ble\api;..\..\..\..\..\component\ble\ip\ble\ll_rom_port;..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver;..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register;..\..\..\..\..\component\ble\modules\flash;..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver;..\..\..\driver\adc_mic_pga\app\api;..\app\src\project_config;..\app\src\elk_leds</IncludePath>
|
||||||
</VariousControls>
|
</VariousControls>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.\output_tool\xinchip_bootloader2_tool.exe .\output_tool\boot2 ^
|
.\output_tool\xinchip_bootloader2_tool.exe .\output_tool\boot2 ^
|
||||||
.\output_tool\host 0x11002000 0 ^
|
.\output_tool\host 0x11002000 0 ^
|
||||||
app.bin 0x11011000 1 ^
|
app.bin 0x1100E000 1 ^
|
||||||
.\output_bin\ble_peripheral.bin 1
|
.\output_bin\ble_peripheral.bin 1
|
||||||
|
|
||||||
copy .\output_bin\ble_peripheral.bin .\
|
copy .\output_bin\ble_peripheral.bin .\
|
||||||
|
|||||||
Reference in New Issue
Block a user