Compare commits
3 Commits
a4b68ffadb
...
289bce290c
Author | SHA1 | Date | |
---|---|---|---|
289bce290c | |||
e600ac3f22 | |||
1f57b11676 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,7 +2,6 @@
|
||||
*.so
|
||||
*.bin
|
||||
output
|
||||
bootloader
|
||||
libs_url
|
||||
open_source
|
||||
temp
|
||||
|
@ -30,7 +30,7 @@ extern "C" {
|
||||
|
||||
#define DEVICE_HIVERSION "1.0.0"
|
||||
/* 设备固件版本号 */
|
||||
#define FIRMWARE_VER "1.0.3"
|
||||
#define FIRMWARE_VER "1.0.4"
|
||||
/* 设备硬件版本号 */
|
||||
#define HARDWARE_VER "1.0.0"
|
||||
/* 设备软件版本号 */
|
||||
|
@ -24,11 +24,13 @@ extern int myhandle_put_cct(const char* svc_id, const char* payload, unsigned in
|
||||
extern int myhandle_put_lightMode(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int myhandle_put_switch(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int myhandle_put_progressSwitch(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int myhandle_put_colourMode(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int myhandle_get_brightness(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
extern int myhandle_get_cct(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
extern int myhandle_get_lightMode(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
extern int myhandle_get_switch(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
extern int myhandle_get_progressSwitch(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
extern int myhandle_get_colourMode(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
// 声明外部函数
|
||||
extern int myhandle_put_cmd(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int myhandle_get_cmd(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
@ -42,9 +44,10 @@ extern int myhandle_get_cmd(const char* svc_id, const char* in, unsigned int in_
|
||||
static const HILINK_SvcInfo SVC_INFO[] = {
|
||||
{ "brightness", "brightness" },
|
||||
{ "cct", "cct" },
|
||||
{ "mode", "colourMode" },
|
||||
{ "mode", "lightMode" },
|
||||
{ "progressSwitch", "progressSwitch" },
|
||||
{ "switch", "switch" },
|
||||
{ "switch", "switch" }
|
||||
#ifdef CONFIG_SUPPORT_HILINK_INDIE_UPGRADE
|
||||
// { "checkSum", "checkSum" },
|
||||
#endif
|
||||
@ -145,6 +148,7 @@ int HILINK_GetSvcInfo(HILINK_SvcInfo *svcInfo[], unsigned int size)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
e_printf("HILINK_GetSvcInfo svcNum:%d\r\n", svcNum);
|
||||
return svcNum;
|
||||
}
|
||||
/* AC参数 */
|
||||
@ -166,6 +170,7 @@ extern int HILINK_HILINK_Printf(const char *format, ...);
|
||||
typedef struct{
|
||||
int brightness_brightness;
|
||||
int cct_colorTemperature;
|
||||
int colourMode_mode;
|
||||
int lightMode_mode;
|
||||
int progressSwitch_fadeTime;
|
||||
int switch_on;
|
||||
@ -218,7 +223,8 @@ int handle_get_switch(const char* svc_id, const char* in, unsigned int in_len,ch
|
||||
HILINK_Printf("%s:%d svcId:%s, *out:%s\r\n",__FUNCTION__ , __LINE__,svc_id, *out);
|
||||
return 0;
|
||||
}
|
||||
// 服务处理信息注册
|
||||
|
||||
#ifndef CONFIG_USE_CUSTOMER_SVC_INFO
|
||||
|
||||
int handle_put_brightness(const char* svc_id, const char* payload, unsigned int len)
|
||||
{
|
||||
@ -268,6 +274,30 @@ int handle_get_cct(const char* svc_id, const char* in, unsigned int in_len, char
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_put_colourMode(const char* svc_id, const char* payload, unsigned int len)
|
||||
{
|
||||
cJSON* pJson = cJSON_Parse(payload);
|
||||
if (!pJson)
|
||||
return -1;
|
||||
cJSON* mode_item = cJSON_GetObjectItem(pJson, "mode");
|
||||
if (mode_item)
|
||||
g_device_info.colourMode_mode = mode_item->valueint;
|
||||
HILINK_Printf("%s:%d svcId:%s, payload:%s\r\n", __FUNCTION__, __LINE__, svc_id, payload);
|
||||
cJSON_Delete(pJson);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_get_colourMode(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len)
|
||||
{
|
||||
*out_len = 64;
|
||||
*out = (char*)malloc(*out_len);
|
||||
if (*out == NULL)
|
||||
return -1;
|
||||
*out_len = sprintf_s(*out, *out_len, "{\"mode\":%d}", g_device_info.colourMode_mode);
|
||||
HILINK_Printf("%s:%d svcId:%s, *out:%s\r\n", __FUNCTION__, __LINE__, svc_id, *out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_put_lightMode(const char* svc_id, const char* payload, unsigned int len)
|
||||
{
|
||||
cJSON* pJson = cJSON_Parse(payload);
|
||||
@ -315,22 +345,23 @@ int handle_get_progressSwitch(const char* svc_id, const char* in, unsigned int i
|
||||
HILINK_Printf("%s:%d svcId:%s, *out:%s\r\n", __FUNCTION__, __LINE__, svc_id, *out);
|
||||
return 0;
|
||||
}
|
||||
#ifdef CONFIG_USE_CUSTOMER_SVC_INFO
|
||||
HANDLE_SVC_INFO g_device_profile[] = {
|
||||
{"brightness", myhandle_put_brightness, myhandle_get_brightness},
|
||||
{"cct", myhandle_put_cct, myhandle_get_cct},
|
||||
{"lightMode", myhandle_put_lightMode, myhandle_get_lightMode},
|
||||
{"progressSwitch", myhandle_put_progressSwitch, myhandle_get_progressSwitch},
|
||||
{"switch", myhandle_put_switch, myhandle_get_switch},
|
||||
};
|
||||
#else
|
||||
HANDLE_SVC_INFO g_device_profile[] = {
|
||||
{"brightness", handle_put_brightness, handle_get_brightness},
|
||||
{"cct", handle_put_cct, handle_get_cct},
|
||||
{"colourMode", handle_put_colourMode, handle_get_colourMode},
|
||||
{"lightMode", handle_put_lightMode, handle_get_lightMode},
|
||||
{"progressSwitch", handle_put_progressSwitch, handle_get_progressSwitch},
|
||||
{"switch", handle_put_switch, handle_get_switch},
|
||||
};
|
||||
#else
|
||||
HANDLE_SVC_INFO g_device_profile[] = {
|
||||
{"brightness", myhandle_put_brightness, myhandle_get_brightness},
|
||||
{"cct", myhandle_put_cct, myhandle_get_cct},
|
||||
{"colourMode", myhandle_put_colourMode, myhandle_get_colourMode},
|
||||
{"lightMode", myhandle_put_lightMode, myhandle_get_lightMode},
|
||||
{"progressSwitch", myhandle_put_progressSwitch, myhandle_get_progressSwitch},
|
||||
{"switch", myhandle_put_switch, myhandle_get_switch},
|
||||
};
|
||||
#endif // end of CONFIG_USE_CUSTOMER_SVC_INFO
|
||||
// 服务总数量
|
||||
int g_device_profile_count = sizeof(g_device_profile) / sizeof(HANDLE_SVC_INFO);
|
||||
@ -514,7 +545,7 @@ void HILINK_NotifyDevStatus(int status)
|
||||
/* 设备与云端连接断开,请在此处添加实现 */
|
||||
#if defined(SUPPORT_MINIMALIST_NETCFG) || defined(SUPPORT_BLE_ANCILLAY_NETCFG)
|
||||
BLE_CfgNetAdvUpdate(NULL);
|
||||
// BLE_CfgNetAdvCtrl(0);
|
||||
BLE_CfgNetAdvCtrl(0);
|
||||
(void)BLE_CfgNetAdvCtrl(0xFFFFFFFF);
|
||||
#endif
|
||||
handle_device_offline();
|
||||
@ -524,7 +555,7 @@ void HILINK_NotifyDevStatus(int status)
|
||||
#if defined(SUPPORT_MINIMALIST_NETCFG) || defined(SUPPORT_BLE_ANCILLAY_NETCFG)
|
||||
BLE_CfgNetAdvUpdate(NULL);
|
||||
BLE_CfgNetAdvCtrl(0);
|
||||
// (void)BLE_CfgNetAdvCtrl(0xFFFFFFFF);
|
||||
(void)BLE_CfgNetAdvCtrl(0xFFFFFFFF);
|
||||
#endif
|
||||
/* 设备连接云端成功,请在此处添加实现 */
|
||||
handle_device_online(); // 处理设备上线
|
||||
|
@ -22,6 +22,7 @@ static const scene_preset_t scene_presets[] = {
|
||||
{(80), (3500)}, // 模式4:回家模式 - 较高亮度,自然光
|
||||
{(100), (CCT_MIN)}, // 模式5:冬天模式 - 中等亮度,暖色调
|
||||
{(100), (CCT_MAX)}, // 模式6:夏天模式 - 较高亮度,冷色调
|
||||
{(0), (0)}, // 模式7 离家模式- 关闭
|
||||
};
|
||||
|
||||
#define SCENE_MODE_COUNT (sizeof(scene_presets) / sizeof(scene_presets[0]))
|
||||
@ -68,6 +69,13 @@ int myhandle_put_cct(const char* svc_id, const char* payload, unsigned int len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// // 在单色温模式下,不允许修改色温
|
||||
// if (g_device_control.colourMode == COLOUR_MODE_SINGLE) {
|
||||
// e_printf("Cannot change CCT in single colour mode\r\n");
|
||||
// cJSON_Delete(json);
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
int cct = item->valueint;
|
||||
if (cct < CCT_MIN) cct = CCT_MIN;
|
||||
if (cct > CCT_MAX) cct = CCT_MAX;
|
||||
@ -97,11 +105,16 @@ int myhandle_put_lightMode(const char* svc_id, const char* payload, unsigned int
|
||||
|
||||
uint16_t mode = item->valueint;
|
||||
if (mode >= 0 && mode < SCENE_MODE_COUNT) {
|
||||
// 如果切换到离家模式,设置bitmask并直接关灯
|
||||
if (mode == LIGHT_MODE_LEAVE) {
|
||||
g_device_control.elightMode = LIGHT_MODE_SET_LEAVE(LIGHT_MODE_GET_BASE(g_device_control.elightMode));
|
||||
ret = set_light(APP_CLOSE_LIGHT, -1, -1);
|
||||
} else {
|
||||
// 普通模式切换,清除离家模式位
|
||||
g_device_control.elightMode = mode;
|
||||
|
||||
// 同时更新亮度和色温
|
||||
ret = set_light(APP_CHANGE_LIGHT_MODE, BRIGHTNESS_REMOTE2LOCAL(scene_presets[mode].brightness), CCT_REMOTE2LOCAL(scene_presets[mode].cct));
|
||||
}
|
||||
}
|
||||
|
||||
cJSON_Delete(json);
|
||||
return ret;
|
||||
@ -124,6 +137,12 @@ int myhandle_put_switch(const char* svc_id, const char* payload, unsigned int le
|
||||
|
||||
bool on = (item->valueint != 0);
|
||||
if (on) {
|
||||
// 如果当前是离家模式,取消离家模式并恢复到基础模式
|
||||
if (LIGHT_MODE_IS_LEAVE(g_device_control.elightMode)) {
|
||||
lightMode_e base_mode = LIGHT_MODE_GET_BASE(g_device_control.elightMode);
|
||||
g_device_control.elightMode = base_mode;
|
||||
e_printf("从离家模式恢复,基础模式:%d\r\n", base_mode);
|
||||
}
|
||||
ret = set_light(APP_OPEN_LIGHT, -1, -1);
|
||||
} else {
|
||||
ret = set_light(APP_CLOSE_LIGHT, -1, -1);
|
||||
@ -164,7 +183,9 @@ int myhandle_get_lightMode(const char* svc_id, const char* in, unsigned int in_l
|
||||
if (NULL == *out) {
|
||||
return -1;
|
||||
}
|
||||
*out_len = sprintf_s(*out, *out_len, "{\"%s\":%d}", JSON_FIELD_MODE, g_device_control.elightMode);
|
||||
// 使用转换函数确保上报正确的模式
|
||||
lightMode_e report_mode = convert_mode_for_report(g_device_control.elightMode);
|
||||
*out_len = sprintf_s(*out, *out_len, "{\"%s\":%d}", JSON_FIELD_MODE, report_mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -219,3 +240,42 @@ int myhandle_get_progressSwitch(const char* svc_id, const char* in, unsigned int
|
||||
*out_len = sprintf_s(*out, *out_len, "{\"%s\":%d}", JSON_FIELD_FADE_TIME, g_device_control.fade_time);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 处理色温模式控制
|
||||
int myhandle_put_colourMode(const char* svc_id, const char* payload, unsigned int len)
|
||||
{
|
||||
int ret = -1;
|
||||
cJSON *json = cJSON_Parse(payload);
|
||||
if (json == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
cJSON *item = cJSON_GetObjectItem(json, JSON_FIELD_COLOUR_MODE);
|
||||
if (item == NULL || !cJSON_IsNumber(item)) {
|
||||
cJSON_Delete(json);
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t mode = item->valueint;
|
||||
g_device_control.colourMode = mode;
|
||||
if (mode == COLOUR_MODE_SINGLE) {
|
||||
ret = set_light(APP_CHANGE_LIGHT_BRIGHTNESS_CCT, -1, SINGLE_COLOUR_CCT_LOCAL);
|
||||
} else {
|
||||
ret = set_light(APP_CHANGE_LIGHT_BRIGHTNESS_CCT, g_device_control.brightness_local, g_device_control.cct_local);
|
||||
}
|
||||
|
||||
cJSON_Delete(json);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 获取色温模式状态
|
||||
int myhandle_get_colourMode(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len)
|
||||
{
|
||||
*out_len = 32;
|
||||
*out = (char*)malloc(*out_len);
|
||||
if (NULL == *out) {
|
||||
return -1;
|
||||
}
|
||||
*out_len = sprintf_s(*out, *out_len, "{\"%s\":%d}", JSON_FIELD_COLOUR_MODE, g_device_control.colourMode);
|
||||
return 0;
|
||||
}
|
||||
|
@ -11,9 +11,17 @@ typedef enum elightMode {
|
||||
LIGHT_MODE_HOME, // 回家模式
|
||||
LIGHT_MODE_WINTER, // 冬天模式
|
||||
LIGHT_MODE_SUMMER, // 夏天模式
|
||||
LIGHT_MODE_LEAVE, // 离家模式
|
||||
LIGHT_MODE_MAX // 模式数量
|
||||
} lightMode_e;
|
||||
|
||||
// 位掩码定义
|
||||
#define LIGHT_MODE_LEAVE_BIT (1 << 7) // 离家模式位
|
||||
#define LIGHT_MODE_MASK (0x7F) // 基础模式掩码(7位)
|
||||
#define LIGHT_MODE_IS_LEAVE(mode) ((mode) & LIGHT_MODE_LEAVE_BIT)
|
||||
#define LIGHT_MODE_GET_BASE(mode) ((mode) & LIGHT_MODE_MASK)
|
||||
#define LIGHT_MODE_SET_LEAVE(base_mode) ((base_mode) | LIGHT_MODE_LEAVE_BIT)
|
||||
|
||||
typedef enum {
|
||||
INIT_POWER_ON,
|
||||
NET_CONFIGING,
|
||||
@ -27,6 +35,7 @@ typedef enum {
|
||||
#define SVC_ID_CCT "cct" // 色温控制
|
||||
#define SVC_ID_LIGHT_MODE "lightMode" // 场景模式控制
|
||||
#define SVC_ID_FADE_TIME "progressSwitch" // 渐变时长的控制
|
||||
#define SVC_ID_COLOUR_MODE "colourMode" // 色温模式控制
|
||||
|
||||
// JSON字段名定义
|
||||
#define JSON_FIELD_ON "on" // 开关状态字段
|
||||
@ -34,6 +43,7 @@ typedef enum {
|
||||
#define JSON_FIELD_CCT "colorTemperature" // 色温字段
|
||||
#define JSON_FIELD_MODE "mode" // 场景模式字段
|
||||
#define JSON_FIELD_FADE_TIME "fadeTime" // 渐变时长字段
|
||||
#define JSON_FIELD_COLOUR_MODE "mode" // 色温模式字段
|
||||
|
||||
typedef enum {
|
||||
REPORT_SWITCH = 1 << 0,
|
||||
@ -41,8 +51,16 @@ typedef enum {
|
||||
REPORT_CCT = 1 << 2,
|
||||
REPORT_LIGHT_MODE = 1 << 3,
|
||||
REPORT_FADE_TIME = 1 << 4,
|
||||
REPORT_ALL = REPORT_SWITCH | REPORT_BRIGHTNESS | REPORT_CCT | REPORT_LIGHT_MODE | REPORT_FADE_TIME,
|
||||
REPORT_COLOUR_MODE = 1 << 5,
|
||||
REPORT_ALL = REPORT_SWITCH | REPORT_BRIGHTNESS | REPORT_CCT | REPORT_LIGHT_MODE | REPORT_FADE_TIME | REPORT_COLOUR_MODE,
|
||||
} report_mask_e;
|
||||
|
||||
// 色温模式定义
|
||||
typedef enum {
|
||||
COLOUR_MODE_SINGLE = 0, // 单色温模式
|
||||
COLOUR_MODE_DUAL = 1, // 双色温模式
|
||||
} colourMode_e;
|
||||
|
||||
// 当前亮度和色温状态
|
||||
typedef struct __attribute__((packed, aligned(1))) {
|
||||
// 物模型同步需要 持久化维持
|
||||
@ -51,10 +69,13 @@ typedef struct __attribute__((packed, aligned(1))) {
|
||||
uint16_t brightness_local; // 当前亮度 (0-1000)
|
||||
uint16_t fade_time; // 渐变时长(s)
|
||||
uint16_t cct_local; // 当前色温 (2700-6500)
|
||||
uint8_t colourMode; // 色温模式 (0:单色温, 1:双色温)
|
||||
// 持久化维持
|
||||
int32_t power_on_cnt; // 上电次数计数
|
||||
uint8_t is_networked; // 是否已配网
|
||||
uint8_t is_net_configured; // 设备是否曾经配网成功过
|
||||
|
||||
uint32_t reserve[10]; // 保留字段
|
||||
//运行时的数据
|
||||
uint16_t duty_cw; // 冷白LED占空比
|
||||
uint16_t duty_ww; // 暖白LED占空比
|
||||
@ -165,6 +186,20 @@ typedef enum {
|
||||
DEV_POWER_ON,
|
||||
} light_ctrl_source_e;
|
||||
|
||||
// 单色温模式的固定色温值
|
||||
#define SINGLE_COLOUR_CCT 6000 // 单色温模式固定色温 6000K
|
||||
#define SINGLE_COLOUR_CCT_LOCAL CCT_REMOTE2LOCAL(SINGLE_COLOUR_CCT) // 转换为本地值
|
||||
|
||||
#define BRIGHTNESS_PIN GPIO_04 // 冷白LED (CW)
|
||||
#define CCT_PIN GPIO_00 // 暖白LED (WW)
|
||||
#define SWITCH_PIN GPIO_13
|
||||
|
||||
#define CONFIG_PWM_GROUP_ID 2
|
||||
|
||||
#define OPEN_LIGHT GPIO_LEVEL_HIGH
|
||||
#define CLOSE_LIGHT GPIO_LEVEL_LOW
|
||||
|
||||
|
||||
#define DEFAULT_DEVICE_DATA { \
|
||||
.read_done = false, \
|
||||
.on = true, \
|
||||
@ -172,6 +207,7 @@ typedef enum {
|
||||
.cct_local = CCT_REMOTE2LOCAL(INIT_STA__CCT), \
|
||||
.brightness_local = BRIGHTNESS_REMOTE2LOCAL(INIT_STA__BRIGHTNESS), \
|
||||
.fade_time = NET_CFG_DEFAULT_FADE_TIME, \
|
||||
.colourMode = COLOUR_MODE_DUAL, \
|
||||
.is_networked = false, \
|
||||
.is_net_configured = false, \
|
||||
.duty_cw = 0, \
|
||||
@ -184,6 +220,9 @@ int set_light(light_ctrl_source_e source,
|
||||
int set_smooth_time(uint32_t smooth_time); // 设置渐变时长
|
||||
void update_pwm_output(bool on_state, uint16_t duty_cw, uint16_t duty_ww);
|
||||
|
||||
// 模式转换函数
|
||||
lightMode_e convert_mode_for_report(lightMode_e current_mode); // 将bitmask转换为上报用的枚举值
|
||||
|
||||
void stop_net_config(void);
|
||||
extern int fast_report(const char* svc_id);
|
||||
|
||||
|
@ -41,15 +41,6 @@ static bool write_device_data_to_addr(uint32_t addr, const device_data_t* data);
|
||||
static void report_device_online_status(void);
|
||||
|
||||
|
||||
#define BRIGHTNESS_PIN GPIO_04 // 冷白LED (CW)
|
||||
#define CCT_PIN GPIO_00 // 暖白LED (WW)
|
||||
#define SWITCH_PIN GPIO_13
|
||||
|
||||
#define CONFIG_PWM_GROUP_ID 2
|
||||
|
||||
#define OPEN_LIGHT GPIO_LEVEL_HIGH
|
||||
#define CLOSE_LIGHT GPIO_LEVEL_LOW
|
||||
|
||||
// 状态上报任务相关变量
|
||||
#define REPORT_TASK_PRIO 80
|
||||
#define REPORT_TASK_STACK_SIZE 0x1000
|
||||
@ -256,7 +247,9 @@ static void *fade_task(const char *arg)
|
||||
g_device_control.duty_ww = device_control.duty_ww;
|
||||
g_device_control.duty_cw = device_control.duty_cw;
|
||||
g_device_control.brightness_local = fade_ctx.current_brightness;
|
||||
if (g_device_control.colourMode == COLOUR_MODE_DUAL) {
|
||||
g_device_control.cct_local = fade_ctx.current_cct;
|
||||
}
|
||||
e_printf("[fade_task] Status report: local brightness=%d, CCT=%d\r\n",
|
||||
g_device_control.brightness_local,
|
||||
g_device_control.cct_local);
|
||||
@ -469,7 +462,7 @@ void calculate_pwm_duty(device_control_t* pdevice_control)
|
||||
{ // 如果开关关闭,则占空比为0
|
||||
uint32_t total_brightness_pwm = pdevice_control->brightness_local;
|
||||
// 计算色温比例 (0-10000)
|
||||
uint16_t cct_ratio = ((pdevice_control->cct_local - CCT_LOCAL_MIN) * 10000) / CCT_RANGE;
|
||||
uint32_t cct_ratio = ((pdevice_control->cct_local - CCT_LOCAL_MIN) * 10000) / CCT_RANGE;
|
||||
|
||||
// 根据色温比例计算CW和WW的占空比
|
||||
// 总亮度保持不变,只调整CW和WW的比例
|
||||
@ -716,12 +709,16 @@ void read_device_data(void)
|
||||
e_printf("灯光模式: %d => %d\r\n", g_device_control.elightMode, data.control.elightMode);
|
||||
e_printf("亮度: %d => %d\r\n", g_device_control.brightness_local, data.control.brightness_local);
|
||||
e_printf("色温: %d => %d\r\n", g_device_control.cct_local, data.control.cct_local);
|
||||
e_printf("色温模式: %d => %d\r\n", g_device_control.colourMode, data.control.colourMode);
|
||||
e_printf("冷白LED: %d => %d\r\n", g_device_control.duty_cw, data.control.duty_cw);
|
||||
e_printf("暖白LED: %d => %d\r\n", g_device_control.duty_ww, data.control.duty_ww);
|
||||
e_printf("渐变时间: %d => %d\r\n", g_device_control.fade_time, data.control.fade_time);
|
||||
|
||||
data.control.read_done = false;
|
||||
g_device_control = data.control;
|
||||
// fastboot的时候就已经亮起来了,所以当前测温直接变为目标值
|
||||
fade_ctx.current_brightness = g_device_control.brightness_local;
|
||||
fade_ctx.current_cct = g_device_control.cct_local;
|
||||
lab_exit:
|
||||
#endif
|
||||
g_device_control.read_done = true;
|
||||
@ -742,6 +739,7 @@ void save_device_data(void)
|
||||
last_control.brightness_local != g_device_control.brightness_local ||
|
||||
last_control.fade_time != g_device_control.fade_time ||
|
||||
last_control.cct_local != g_device_control.cct_local ||
|
||||
last_control.colourMode != g_device_control.colourMode ||
|
||||
last_control.power_on_cnt != g_device_control.power_on_cnt ||
|
||||
last_control.is_networked != g_device_control.is_networked ||
|
||||
last_control.is_net_configured != g_device_control.is_net_configured;
|
||||
@ -872,17 +870,28 @@ int set_light(light_ctrl_source_e source,
|
||||
if (APP_OPEN_LIGHT == source) {
|
||||
g_device_control.on = true;
|
||||
fade_ctx.current_brightness = 0;
|
||||
fade_ctx.current_cct = g_device_control.cct_local;
|
||||
brightness_local_target = g_device_control.brightness_local;
|
||||
if (g_device_control.colourMode == COLOUR_MODE_DUAL) {
|
||||
fade_ctx.current_cct = g_device_control.cct_local;
|
||||
cct_local_target = g_device_control.cct_local;
|
||||
} else {
|
||||
fade_ctx.current_cct = SINGLE_COLOUR_CCT_LOCAL;
|
||||
cct_local_target = SINGLE_COLOUR_CCT_LOCAL;
|
||||
}
|
||||
}
|
||||
else if (DEV_POWER_ON == source) {
|
||||
if (g_device_control.colourMode == COLOUR_MODE_SINGLE) {
|
||||
fade_ctx.current_cct = SINGLE_COLOUR_CCT_LOCAL;
|
||||
cct_local_target = SINGLE_COLOUR_CCT_LOCAL;
|
||||
}
|
||||
}
|
||||
memcpy(&tmp_fade_ctx, &fade_ctx, FADE_CTRL_DATA_SIZE(fade_ctx));
|
||||
tmp_fade_ctx.target_brightness = tmp_fade_ctx.current_brightness;
|
||||
// tmp_fade_ctx.target_brightness = tmp_fade_ctx.current_brightness;
|
||||
if (brightness_local_target >= 0) {
|
||||
BRIGHTNESS_LITME_RANGE(brightness_local_target);
|
||||
tmp_fade_ctx.target_brightness = brightness_local_target;
|
||||
}
|
||||
tmp_fade_ctx.target_cct = tmp_fade_ctx.current_cct;
|
||||
// tmp_fade_ctx.target_cct = tmp_fade_ctx.current_cct;
|
||||
if (cct_local_target >= 0) {
|
||||
CCT_LITME_RANGE(cct_local_target);
|
||||
tmp_fade_ctx.target_cct = cct_local_target;
|
||||
@ -901,7 +910,9 @@ int set_light(light_ctrl_source_e source,
|
||||
tmp_fade_ctx.fade_time = NORMAL_FADE_TIME; // 上电时,直接设置为默认渐变时长
|
||||
case APP_CHANGE_LIGHT_MODE:
|
||||
// 直接将信息更新到目标值
|
||||
if (g_device_control.colourMode == COLOUR_MODE_DUAL) {
|
||||
g_device_control.cct_local = tmp_fade_ctx.target_cct;
|
||||
}
|
||||
g_device_control.brightness_local = tmp_fade_ctx.target_brightness;
|
||||
//情景模式或者上电时直接切换到对应的色温和亮度
|
||||
tmp_fade_ctx.is_fading = true;
|
||||
@ -913,13 +924,15 @@ int set_light(light_ctrl_source_e source,
|
||||
memcpy(&fade_ctx, &tmp_fade_ctx, FADE_CTRL_DATA_SIZE(tmp_fade_ctx));
|
||||
e_printf("start fade\r\n");
|
||||
uapi_timer_start(fade_ctx.timer_handle, fade_ctx.update_interval, fade_timer_callback, 0);
|
||||
start_report_task(REPORT_SWITCH | REPORT_BRIGHTNESS | REPORT_CCT);
|
||||
start_report_task(REPORT_SWITCH | REPORT_BRIGHTNESS | REPORT_CCT | REPORT_LIGHT_MODE);
|
||||
req_save_device_data();
|
||||
return 0; // 异步上报
|
||||
break;
|
||||
case APP_CHANGE_LIGHT_BRIGHTNESS_CCT:
|
||||
// 直接将信息更新到目标值
|
||||
if (g_device_control.colourMode == COLOUR_MODE_DUAL) { //只有双色温模式下,色温才会变化
|
||||
g_device_control.cct_local = tmp_fade_ctx.target_cct;
|
||||
}
|
||||
g_device_control.brightness_local = tmp_fade_ctx.target_brightness;
|
||||
tmp_fade_ctx.is_fading = true;
|
||||
tmp_fade_ctx.fade_completed = false;
|
||||
@ -1055,6 +1068,7 @@ static void report_device_online_status(void)
|
||||
fast_report(SVC_ID_CCT);
|
||||
fast_report(SVC_ID_LIGHT_MODE);
|
||||
fast_report(SVC_ID_FADE_TIME);
|
||||
fast_report(SVC_ID_COLOUR_MODE);
|
||||
// fast_report(SVC_ID_NET_INFO);
|
||||
e_printf("Status report completed\r\n");
|
||||
}
|
||||
@ -1086,6 +1100,7 @@ static const struct {
|
||||
[REPORT_CCT] = {SVC_ID_CCT},
|
||||
[REPORT_LIGHT_MODE] = {SVC_ID_LIGHT_MODE},
|
||||
[REPORT_FADE_TIME] = {SVC_ID_FADE_TIME},
|
||||
[REPORT_COLOUR_MODE] = {SVC_ID_COLOUR_MODE},
|
||||
};
|
||||
|
||||
// 状态上报任务函数
|
||||
@ -1127,6 +1142,10 @@ static void *report_task(const char *arg)
|
||||
g_report_mask &= ~REPORT_FADE_TIME;
|
||||
fast_report(SVC_ID_FADE_TIME);
|
||||
}
|
||||
if (g_report_mask & REPORT_COLOUR_MODE) {
|
||||
g_report_mask &= ~REPORT_COLOUR_MODE;
|
||||
fast_report(SVC_ID_COLOUR_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
e_printf("[report_task] Task exited\r\n");
|
||||
@ -1352,8 +1371,13 @@ int spotlight_main(void) {
|
||||
handle_network_status();
|
||||
//上电亮灯也是需要缓慢亮起来, 如果是在配网的话就不用了。交给配网的代码进行控制
|
||||
if (g_net_breath_state == NET_CFG_IDLE && g_device_control.on == true){
|
||||
if (g_device_control.colourMode == COLOUR_MODE_SINGLE) {
|
||||
set_light(DEV_POWER_ON, g_device_control.brightness_local, SINGLE_COLOUR_CCT_LOCAL);
|
||||
} else {
|
||||
set_light(DEV_POWER_ON, g_device_control.brightness_local, g_device_control.cct_local);
|
||||
}
|
||||
// set_light(DEV_POWER_ON, g_device_control.brightness_local, g_device_control.cct_local);
|
||||
}
|
||||
|
||||
if (!g_device_control.is_networked && !g_device_control.is_net_configured) {
|
||||
try_detect_factory_test();
|
||||
@ -1415,3 +1439,14 @@ static void start_breath_timer(void)
|
||||
uapi_timer_start(breath_ctx.timer_handle, breath_ctx.update_interval, breath_timer_callback, 0);
|
||||
}
|
||||
|
||||
// 模式转换函数:将bitmask转换为上报用的枚举值
|
||||
lightMode_e convert_mode_for_report(lightMode_e current_mode)
|
||||
{
|
||||
// 如果处于离家模式,上报离家模式
|
||||
if (LIGHT_MODE_IS_LEAVE(current_mode)) {
|
||||
return LIGHT_MODE_LEAVE;
|
||||
}
|
||||
// 否则上报基础模式
|
||||
return LIGHT_MODE_GET_BASE(current_mode);
|
||||
}
|
||||
|
||||
|
55
bootloader/flashboot_ws63/CMakeLists.txt
Executable file
55
bootloader/flashboot_ws63/CMakeLists.txt
Executable file
@ -0,0 +1,55 @@
|
||||
#===============================================================================
|
||||
# @brief cmake file
|
||||
# Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
#===============================================================================
|
||||
set(COMPONENT_NAME "flashboot_common")
|
||||
|
||||
if("flashboot" IN_LIST BIN_NAME)
|
||||
set(SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/startup/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/startup/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/startup/riscv_init.S
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../commonboot/src/secure_verify_boot.c
|
||||
)
|
||||
|
||||
set(PUBLIC_HEADER
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../commonboot/include
|
||||
)
|
||||
elseif ("ssb" IN_LIST BIN_NAME)
|
||||
set(SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ssb/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ssb/riscv_init.S
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../commonboot/src/secure_verify_boot.c
|
||||
)
|
||||
|
||||
set(PUBLIC_HEADER
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../commonboot/include
|
||||
)
|
||||
endif()
|
||||
|
||||
set(PRIVATE_HEADER
|
||||
)
|
||||
|
||||
set(PRIVATE_DEFINES
|
||||
)
|
||||
|
||||
set(PUBLIC_DEFINES
|
||||
)
|
||||
|
||||
# use this when you want to add ccflags like -include xxx
|
||||
set(COMPONENT_PUBLIC_CCFLAGS
|
||||
)
|
||||
|
||||
set(COMPONENT_CCFLAGS
|
||||
)
|
||||
|
||||
set(WHOLE_LINK
|
||||
true
|
||||
)
|
||||
|
||||
set(MAIN_COMPONENT
|
||||
false
|
||||
)
|
||||
|
||||
build_component()
|
1203
bootloader/flashboot_ws63/startup/main.c
Executable file
1203
bootloader/flashboot_ws63/startup/main.c
Executable file
File diff suppressed because it is too large
Load Diff
93
bootloader/flashboot_ws63/startup/riscv_init.S
Executable file
93
bootloader/flashboot_ws63/startup/riscv_init.S
Executable file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2021-2021. All rights reserved.
|
||||
* Description: main
|
||||
*
|
||||
* Create: 2021-03-09
|
||||
*/
|
||||
|
||||
.section .text.entry
|
||||
.global _start
|
||||
.option norvc
|
||||
_start:
|
||||
j Reset_Handler
|
||||
|
||||
Reset_Handler:
|
||||
li t0,0x0
|
||||
csrw pmpcfg0,t0
|
||||
li t0,0x0
|
||||
csrw pmpcfg1,t0
|
||||
li t0,0x0
|
||||
csrw pmpcfg2,t0
|
||||
li t0,0x0
|
||||
csrw pmpcfg3,t0
|
||||
li t0,0x0
|
||||
csrw 0x7d9,t0
|
||||
la t0, __flash_boot_flag_begin__
|
||||
mv t1, a0
|
||||
lw t3, (t1)
|
||||
sw t3, (t0)
|
||||
la t0, trap_vector
|
||||
addi t0, t0, 1
|
||||
csrw mtvec, t0
|
||||
csrwi mstatus, 0
|
||||
csrwi mie, 0
|
||||
|
||||
# initialize global pointer
|
||||
la gp, _gp_
|
||||
|
||||
# initialize stack pointer
|
||||
la sp, __stack_top__
|
||||
|
||||
/* init stack */
|
||||
la t0, g_system_stack_begin
|
||||
la t1, g_system_stack_end
|
||||
beq t0, t1, end_set_stack_loop
|
||||
li t2, 0xefbeadde
|
||||
|
||||
set_stack_loop:
|
||||
sw t2, (t0)
|
||||
addi t0, t0, 4
|
||||
blt t0, t1, set_stack_loop
|
||||
end_set_stack_loop:
|
||||
|
||||
/* clear reg */
|
||||
li ra, 0
|
||||
li tp, 0
|
||||
li s0, 0
|
||||
li s1, 0
|
||||
li a0, 0
|
||||
li a1, 0
|
||||
li a2, 0
|
||||
li a3, 0
|
||||
li a4, 0
|
||||
li a5, 0
|
||||
li a6, 0
|
||||
li a7, 0
|
||||
li s2, 0
|
||||
li s3, 0
|
||||
li s4, 0
|
||||
li s5, 0
|
||||
li s6, 0
|
||||
li s7, 0
|
||||
li s8, 0
|
||||
li s9, 0
|
||||
li s10, 0
|
||||
li s11, 0
|
||||
li t3, 0
|
||||
li t4, 0
|
||||
li t5, 0
|
||||
li t6, 0
|
||||
|
||||
/* clear bss section */
|
||||
la t0, __bss_begin__
|
||||
la t1, __bss_end__
|
||||
beq t0, t1, end_clear_bss_loop
|
||||
li t2, 0x00000000
|
||||
|
||||
clear_bss_loop:
|
||||
sw t2, (t0)
|
||||
addi t0, t0, 4
|
||||
blt t0, t1, clear_bss_loop
|
||||
end_clear_bss_loop:
|
||||
|
||||
j start_fastboot
|
@ -266,7 +266,7 @@ target = {
|
||||
},
|
||||
'ws63-liteos-app-iot': {
|
||||
'base_target_name': 'target_ws63_app_rom_template',
|
||||
# 'liteos_kconfig': 'ws63_iot',
|
||||
'liteos_kconfig': 'ws63_iot', #ekko add for remove indie upgrade
|
||||
'os': 'liteos',
|
||||
'defines': [
|
||||
"USE_CMSIS_OS",
|
||||
@ -309,7 +309,7 @@ target = {
|
||||
"SUPPORT_SOFTAP_NETCFG", # softAP配网
|
||||
"SUPPORT_BLE_ANCILLAY_NETCFG", # ble辅助配网
|
||||
# "SUPPORT_QUICK_NETCFG", # 快速配网
|
||||
"CONFIG_SUPPORT_HILINK_INDIE_UPGRADE",
|
||||
# "CONFIG_SUPPORT_HILINK_INDIE_UPGRADE", #ekko remove for indie upgrade
|
||||
"CONFIG_SPOTLIGHT_UT", #EKKO ADD
|
||||
"CONFIG_USE_CUSTOMER_SVC_INFO", #EKKO ADD
|
||||
"CONFIG_DHCPS_GW",
|
||||
@ -358,10 +358,11 @@ target = {
|
||||
'cjson',
|
||||
'xo_trim_port',
|
||||
'hilink',
|
||||
'app_addr_map',
|
||||
# 'hilinkdevicesdk',
|
||||
# 'hilinkota',
|
||||
# 'hilinkbtsdk',
|
||||
# 'app_addr_map', #ekko remove for indie upgrade
|
||||
'hilinkdevicesdk', #ekko add for remove indie upgrade
|
||||
'hilinkota', #ekko add for remove indie upgrade
|
||||
'hilinkbtsdk', #ekko add for remove indie upgrade
|
||||
# 'hilinkquickcfg', #ekko add for remove indie upgrade
|
||||
'huks_sdk',
|
||||
'deviceauth',
|
||||
'little_fs', 'littlefs_adapt_ws63',
|
||||
|
Binary file not shown.
181
drivers/chips/ws63/porting/pwm/pwm_porting.c
Executable file
181
drivers/chips/ws63/porting/pwm/pwm_porting.c
Executable file
@ -0,0 +1,181 @@
|
||||
/**
|
||||
* Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
*
|
||||
* Description: Provides pwm port \n
|
||||
*
|
||||
* History: \n
|
||||
* 2022-09-16, Create file. \n
|
||||
*/
|
||||
|
||||
#include "chip_core_irq.h"
|
||||
#include "soc_osal.h"
|
||||
#include "common_def.h"
|
||||
#include "hal_pwm_v151.h"
|
||||
#include "platform_core.h"
|
||||
#include "chip_io.h"
|
||||
#include "soc_porting.h"
|
||||
#include "pwm_porting.h"
|
||||
|
||||
#define BUS_CLOCK_TIME_40M 40000000UL
|
||||
#define BIT_WIDTH_LIMIT 0xFFFF
|
||||
#define CLDO_CRG_CLK_SEL 0x44001134
|
||||
#define PWM_CKSEL_BIT 7
|
||||
|
||||
#define CLDO_SUB_CRG_CKEN_CTL0 0x44001100
|
||||
#define CLDO_CRG_DIV_CTL3 0x44001114
|
||||
#define CLDO_CRG_DIV_CTL4 0x44001118
|
||||
#define CLDO_CRG_DIV_CTL5 0x4400111C
|
||||
|
||||
#define PWM_BUS_CKEN 2
|
||||
#define PWM_CHANNEL_CKEN_LEN 9
|
||||
|
||||
#define PWM0_LOAD_DIV_EN 20
|
||||
#define PWM0_DIV1_CFG 16
|
||||
#define PWM0_DIV1_CFG_LEN 4
|
||||
#define PWM1_LOAD_DIV_EN 30
|
||||
#define PWM1_DIV1_CFG 26
|
||||
#define PWM1_DIV1_CFG_LEN 4
|
||||
#define PWM2_LOAD_DIV_EN 8
|
||||
#define PWM2_DIV1_CFG 4
|
||||
#define PWM2_DIV1_CFG_LEN 4
|
||||
#define PWM3_LOAD_DIV_EN 18
|
||||
#define PWM3_DIV1_CFG 14
|
||||
#define PWM3_DIV1_CFG_LEN 4
|
||||
#define PWM4_LOAD_DIV_EN 28
|
||||
#define PWM4_DIV1_CFG 24
|
||||
#define PWM4_DIV1_CFG_LEN 4
|
||||
#define PWM5_LOAD_DIV_EN 8
|
||||
#define PWM5_DIV1_CFG 4
|
||||
#define PWM5_DIV1_CFG_LEN 4
|
||||
#define PWM6_LOAD_DIV_EN 18
|
||||
#define PWM6_DIV1_CFG 14
|
||||
#define PWM6_DIV1_CFG_LEN 4
|
||||
#define PWM7_LOAD_DIV_EN 28
|
||||
#define PWM7_DIV1_CFG 24
|
||||
#define PWM7_DIV1_CFG_LEN 4
|
||||
|
||||
#define PWM_DIV_6 6
|
||||
#define PWM_DIV_10 10
|
||||
|
||||
uintptr_t g_pwm_base_addr = (uintptr_t)PWM_0_BASE;
|
||||
|
||||
uintptr_t pwm_porting_base_addr_get(void)
|
||||
{
|
||||
return g_pwm_base_addr;
|
||||
}
|
||||
|
||||
static int pwm_handler(int a, const void *tmp)
|
||||
{
|
||||
unused(a);
|
||||
unused(tmp);
|
||||
hal_pwm_v151_irq_handler();
|
||||
return 0;
|
||||
}
|
||||
void pwm_port_register_hal_funcs(void)
|
||||
{
|
||||
hal_pwm_register_funcs(hal_pwm_v151_funcs_get());
|
||||
}
|
||||
|
||||
void pwm_port_unregister_hal_funcs(void)
|
||||
{
|
||||
hal_pwm_unregister_funcs();
|
||||
}
|
||||
|
||||
void pwm_port_clock_enable(bool on)
|
||||
{
|
||||
if (on == true) {
|
||||
uint32_t div_cfg = PWM_DIV_6;
|
||||
#ifdef CONFIG_HIGH_FREQUENCY
|
||||
uapi_reg_setbit(CLDO_CRG_CLK_SEL, PWM_CKSEL_BIT);
|
||||
#elif defined(CONFIG_LOW_FREQUENCY)
|
||||
uapi_reg_clrbit(CLDO_CRG_CLK_SEL, PWM_CKSEL_BIT);
|
||||
if (get_tcxo_freq() == CLK24M_TCXO) {
|
||||
div_cfg = PWM_DIV_6;
|
||||
} else {
|
||||
div_cfg = PWM_DIV_10;
|
||||
}
|
||||
#endif
|
||||
reg32_setbits(CLDO_SUB_CRG_CKEN_CTL0, PWM_BUS_CKEN, PWM_CHANNEL_CKEN_LEN, 0x1FF);
|
||||
|
||||
reg32_clrbit(CLDO_CRG_DIV_CTL3, PWM0_LOAD_DIV_EN);
|
||||
reg32_setbits(CLDO_CRG_DIV_CTL3, PWM0_DIV1_CFG, PWM0_DIV1_CFG_LEN, div_cfg);
|
||||
reg32_setbit(CLDO_CRG_DIV_CTL3, PWM0_LOAD_DIV_EN);
|
||||
|
||||
reg32_clrbit(CLDO_CRG_DIV_CTL3, PWM1_LOAD_DIV_EN);
|
||||
reg32_setbits(CLDO_CRG_DIV_CTL3, PWM1_DIV1_CFG, PWM1_DIV1_CFG_LEN, div_cfg);
|
||||
reg32_setbit(CLDO_CRG_DIV_CTL3, PWM1_LOAD_DIV_EN);
|
||||
|
||||
reg32_clrbit(CLDO_CRG_DIV_CTL4, PWM2_LOAD_DIV_EN);
|
||||
reg32_setbits(CLDO_CRG_DIV_CTL4, PWM2_DIV1_CFG, PWM2_DIV1_CFG_LEN, div_cfg);
|
||||
reg32_setbit(CLDO_CRG_DIV_CTL4, PWM2_LOAD_DIV_EN);
|
||||
|
||||
reg32_clrbit(CLDO_CRG_DIV_CTL4, PWM3_LOAD_DIV_EN);
|
||||
reg32_setbits(CLDO_CRG_DIV_CTL4, PWM3_DIV1_CFG, PWM3_DIV1_CFG_LEN, div_cfg);
|
||||
reg32_setbit(CLDO_CRG_DIV_CTL4, PWM3_LOAD_DIV_EN);
|
||||
|
||||
reg32_clrbit(CLDO_CRG_DIV_CTL4, PWM4_LOAD_DIV_EN);
|
||||
reg32_setbits(CLDO_CRG_DIV_CTL4, PWM4_DIV1_CFG, PWM4_DIV1_CFG_LEN, div_cfg);
|
||||
reg32_setbit(CLDO_CRG_DIV_CTL4, PWM4_LOAD_DIV_EN);
|
||||
|
||||
reg32_clrbit(CLDO_CRG_DIV_CTL5, PWM5_LOAD_DIV_EN);
|
||||
reg32_setbits(CLDO_CRG_DIV_CTL5, PWM5_DIV1_CFG, PWM5_DIV1_CFG_LEN, div_cfg);
|
||||
reg32_setbit(CLDO_CRG_DIV_CTL5, PWM5_LOAD_DIV_EN);
|
||||
|
||||
reg32_clrbit(CLDO_CRG_DIV_CTL5, PWM6_LOAD_DIV_EN);
|
||||
reg32_setbits(CLDO_CRG_DIV_CTL5, PWM6_DIV1_CFG, PWM6_DIV1_CFG_LEN, div_cfg);
|
||||
reg32_setbit(CLDO_CRG_DIV_CTL5, PWM6_LOAD_DIV_EN);
|
||||
|
||||
reg32_clrbit(CLDO_CRG_DIV_CTL5, PWM7_LOAD_DIV_EN);
|
||||
reg32_setbits(CLDO_CRG_DIV_CTL5, PWM7_DIV1_CFG, PWM7_DIV1_CFG_LEN, div_cfg);
|
||||
reg32_setbit(CLDO_CRG_DIV_CTL5, PWM7_LOAD_DIV_EN);
|
||||
} else {
|
||||
reg32_clrbits(CLDO_SUB_CRG_CKEN_CTL0, PWM_BUS_CKEN, PWM_CHANNEL_CKEN_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
void pwm_port_register_irq(pwm_channel_t channel)
|
||||
{
|
||||
unused(channel);
|
||||
osal_irq_request((uintptr_t)PWM_ABNOR_IRQN, (osal_irq_handler)pwm_handler, NULL, NULL, NULL);
|
||||
|
||||
osal_irq_enable((uintptr_t)PWM_ABNOR_IRQN);
|
||||
}
|
||||
|
||||
void pwm_port_unregister_irq(pwm_channel_t channel)
|
||||
{
|
||||
unused(channel);
|
||||
#ifndef BUILD_NOOSAL
|
||||
osal_irq_disable((uintptr_t)PWM_ABNOR_IRQN);
|
||||
osal_irq_disable((uintptr_t)PWM_CFG_IRQN);
|
||||
osal_irq_free((uintptr_t)PWM_ABNOR_IRQN, NULL);
|
||||
osal_irq_free((uintptr_t)PWM_CFG_IRQN, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void pwm_irq_lock(uint8_t channel)
|
||||
{
|
||||
unused(channel);
|
||||
osal_irq_lock();
|
||||
}
|
||||
|
||||
void pwm_irq_unlock(uint8_t channel)
|
||||
{
|
||||
unused(channel);
|
||||
osal_irq_unlock();
|
||||
}
|
||||
|
||||
uint32_t pwm_port_get_clock_value(pwm_channel_t channel)
|
||||
{
|
||||
if (channel >= PWM_MAX_NUMBER) {
|
||||
return 0;
|
||||
}
|
||||
return BUS_CLOCK_TIME_40M;
|
||||
}
|
||||
|
||||
errcode_t pwm_port_param_check(const pwm_config_t *cfg)
|
||||
{
|
||||
if ((cfg->low_time + cfg->high_time > BIT_WIDTH_LIMIT) || (cfg->offset_time > cfg->low_time)) {
|
||||
return ERRCODE_PWM_INVALID_PARAMETER;
|
||||
}
|
||||
return ERRCODE_SUCC;
|
||||
}
|
Binary file not shown.
BIN
output/SR_light-LPT262_hilink-20250626-1.0.3.fwpkg
Normal file
BIN
output/SR_light-LPT262_hilink-20250626-1.0.3.fwpkg
Normal file
Binary file not shown.
BIN
output/SR_light-LPT262_hilink-20250703-1.0.4.fwpkg
Normal file
BIN
output/SR_light-LPT262_hilink-20250703-1.0.4.fwpkg
Normal file
Binary file not shown.
BIN
output/package(SR_light-LPT262_hilink-20250626-1.0.3).zip
Normal file
BIN
output/package(SR_light-LPT262_hilink-20250626-1.0.3).zip
Normal file
Binary file not shown.
BIN
output/package(SR_light-LPT262_hilink-20250703-1.0.4).zip
Normal file
BIN
output/package(SR_light-LPT262_hilink-20250703-1.0.4).zip
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user