Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b576f31113 | ||
|
|
3ab37b7845 |
@@ -833,6 +833,15 @@
|
|||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="apps/usr_app/app_function.h" />
|
<Unit filename="apps/usr_app/app_function.h" />
|
||||||
|
<Unit filename="apps/usr_app/app_audio_debug.h" />
|
||||||
|
<Unit filename="apps/usr_app/car_audio_test.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="apps/usr_app/car_audio_test.h" />
|
||||||
|
<Unit filename="apps/usr_app/app_no_disturb.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="apps/usr_app/app_no_disturb.h" />
|
||||||
<Unit filename="apps/usr_app/app_shake_wake.c">
|
<Unit filename="apps/usr_app/app_shake_wake.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|||||||
@@ -412,6 +412,7 @@ c_SRC_FILES := \
|
|||||||
apps/usr_app/app_boot.c \
|
apps/usr_app/app_boot.c \
|
||||||
apps/usr_app/app_function.c \
|
apps/usr_app/app_function.c \
|
||||||
apps/usr_app/app_no_disturb.c \
|
apps/usr_app/app_no_disturb.c \
|
||||||
|
apps/usr_app/car_audio_test.c \
|
||||||
apps/usr_app/app_shake_wake.c \
|
apps/usr_app/app_shake_wake.c \
|
||||||
apps/usr_le_code/ble_proto.c \
|
apps/usr_le_code/ble_proto.c \
|
||||||
apps/usr_le_code/bleproto.c \
|
apps/usr_le_code/bleproto.c \
|
||||||
|
|||||||
@@ -236,9 +236,9 @@ _notify:
|
|||||||
}
|
}
|
||||||
if (key_event_remap(&e)) {
|
if (key_event_remap(&e)) {
|
||||||
sys_event_notify(&e);
|
sys_event_notify(&e);
|
||||||
#if TCFG_KEY_TONE_EN
|
// #if TCFG_KEY_TONE_EN
|
||||||
audio_key_tone_play();
|
// audio_key_tone_play();
|
||||||
#endif
|
// #endif
|
||||||
}
|
}
|
||||||
_scan_end:
|
_scan_end:
|
||||||
scan_para->last_key = cur_key_value;
|
scan_para->last_key = cur_key_value;
|
||||||
|
|||||||
@@ -735,8 +735,7 @@ struct port_wakeup port0 = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if BOARD_CHG_ENABLE
|
#if BOARD_CHG_ENABLE
|
||||||
/* R18 is not fitted on CBC4, so VBUS never reaches VPWR in softoff. Wake on
|
/* TP4056 CHRG falls when charging starts; use it for softoff charge wake. */
|
||||||
* the fitted ME4054 CHG_ON signal instead; it falls when charging starts. */
|
|
||||||
struct port_wakeup board_chg_wakeup_port = {
|
struct port_wakeup board_chg_wakeup_port = {
|
||||||
.pullup_down_enable = ENABLE,
|
.pullup_down_enable = ENABLE,
|
||||||
.edge = FALLING_EDGE,
|
.edge = FALLING_EDGE,
|
||||||
@@ -1001,8 +1000,9 @@ void board_set_soft_poweroff(void)
|
|||||||
soff_gpio_protect(TCFG_IOKEY_POWER_ONE_PORT);
|
soff_gpio_protect(TCFG_IOKEY_POWER_ONE_PORT);
|
||||||
#endif
|
#endif
|
||||||
#if BOARD_CHG_ENABLE
|
#if BOARD_CHG_ENABLE
|
||||||
/* Preserve PG8 input state and its external pull-up for softoff wake. */
|
/* Preserve both TP4056 open-drain inputs and their pull-ups in softoff. */
|
||||||
soff_gpio_protect(BOARD_CHG_PIN);
|
soff_gpio_protect(BOARD_CHG_PIN);
|
||||||
|
soff_gpio_protect(BOARD_STDBY_PIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (!(TCFG_LP_TOUCH_KEY_ENABLE && TCFG_LP_TOUCH_KEY1_EN))
|
#if (!(TCFG_LP_TOUCH_KEY_ENABLE && TCFG_LP_TOUCH_KEY1_EN))
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef APP_AUDIO_DEBUG_H
|
||||||
|
#define APP_AUDIO_DEBUG_H
|
||||||
|
|
||||||
|
#include "app_config.h"
|
||||||
|
#include "system/includes.h"
|
||||||
|
|
||||||
|
/* UTF-8 中文日志;只在状态变化时打印,不在音频采样循环内连续打印。 */
|
||||||
|
#if TCFG_MAGIC_AUDIO_DEBUG_ENABLE
|
||||||
|
#define MAGIC_AUDIO_LOG(fmt, ...) printf("[魔盒声音] " fmt "\n", ##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define MAGIC_AUDIO_LOG(...) do { } while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* APP_AUDIO_DEBUG_H */
|
||||||
@@ -127,8 +127,10 @@ static uint8_t boot_skip_key_wait(void)
|
|||||||
|
|
||||||
/* USB 在位(充电口有电):说明是插着电源,不是用户凭空按键开机 */
|
/* USB 在位(充电口有电):说明是插着电源,不是用户凭空按键开机 */
|
||||||
for (i = 0; i < 10; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
if (bsp_chg_is_low() || bsp_vpwr_is_online()
|
/* VPWR/LDO5V are the authoritative external-power indicators.
|
||||||
|| get_ldo5v_online_hw()) {
|
* CHRG is open-drain and is only meaningful after VPWR is present;
|
||||||
|
* do not let an abnormal low PG8 skip the key wait by itself. */
|
||||||
|
if (get_ldo5v_online_hw()) {
|
||||||
log_info("boot usb, skip key wait\n");
|
log_info("boot usb, skip key wait\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include "app_led.h"
|
#include "app_led.h"
|
||||||
#include "app_shake_wake.h"
|
#include "app_shake_wake.h"
|
||||||
#include "app_no_disturb.h"
|
#include "app_no_disturb.h"
|
||||||
|
#include "car_audio_test.h"
|
||||||
|
#include "app_audio_debug.h"
|
||||||
#include "app_time_util.h"
|
#include "app_time_util.h"
|
||||||
#include "bsp_hw.h"
|
#include "bsp_hw.h"
|
||||||
#include "board_pin.h"
|
#include "board_pin.h"
|
||||||
@@ -254,6 +256,10 @@ static void function_play_mode_apply(uint8_t mode)
|
|||||||
{
|
{
|
||||||
uint8_t old_mode = s_func.play_mode;
|
uint8_t old_mode = s_func.play_mode;
|
||||||
|
|
||||||
|
MAGIC_AUDIO_LOG("模式切换请求:旧=%u,请求=%u,DP4=%u,功能开关=%u,充电=%u,关机中=%u,OTA=%u",
|
||||||
|
old_mode, mode, gDevData.beep_trig, s_func.app_power,
|
||||||
|
app_power_usb_online(), app_power_poweroff_pending(), app_led_is_ota());
|
||||||
|
|
||||||
if (mode > PLAY_MODE_5) {
|
if (mode > PLAY_MODE_5) {
|
||||||
mode = 0;
|
mode = 0;
|
||||||
}
|
}
|
||||||
@@ -273,10 +279,17 @@ static void function_play_mode_apply(uint8_t mode)
|
|||||||
} else {
|
} else {
|
||||||
app_mode_start(mode);
|
app_mode_start(mode);
|
||||||
}
|
}
|
||||||
|
// MAGIC_AUDIO_LOG("模式切换结果:旧=%u,实际=%u;当前测试不拦截DP4", old_mode, mode);
|
||||||
if (mode != old_mode) {
|
if (mode != old_mode) {
|
||||||
app_led_request_mode_blink(); /* 模式真变了才闪两下 */
|
app_led_request_mode_blink(); /* 模式真变了才闪两下 */
|
||||||
|
|
||||||
|
/* DP4:0=关闭模式切换鸟叫,1=允许播放 */
|
||||||
|
//&& gDevData.beep_trig
|
||||||
|
if ((mode != PLAY_MODE_0) && gDevData.beep_trig) {
|
||||||
|
Car_Audio_Test_Play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 跟随 APP 下发的 DP1 自动模式
|
* @brief 跟随 APP 下发的 DP1 自动模式
|
||||||
@@ -373,7 +386,7 @@ static void function_hand_poll(void)
|
|||||||
s_func.play_mode = 0;
|
s_func.play_mode = 0;
|
||||||
s_func.play_ms = 0;
|
s_func.play_ms = 0;
|
||||||
gDevData.play_mode = 0;
|
gDevData.play_mode = 0;
|
||||||
app_mode_stop(); /* 自动切手动:先停自动玩法 */
|
app_mode_stop();
|
||||||
s_func.hand_busy = 1;
|
s_func.hand_busy = 1;
|
||||||
s_func.hand_ms = 0;
|
s_func.hand_ms = 0;
|
||||||
gDevData.hand_mode = cmd;
|
gDevData.hand_mode = cmd;
|
||||||
@@ -384,10 +397,10 @@ static void function_hand_poll(void)
|
|||||||
bsp_drive_set(BSP_MOTOR_STOP, 0,
|
bsp_drive_set(BSP_MOTOR_STOP, 0,
|
||||||
BSP_MOTOR_FORWARD, 5500);
|
BSP_MOTOR_FORWARD, 5500);
|
||||||
}
|
}
|
||||||
app_led_request_mode_blink(); /* 自动/空闲切到手动,闪两下提示 */
|
app_led_request_mode_blink();
|
||||||
log_info("hand cmd=%d %s max=%ums\n", cmd,
|
if (gDevData.beep_trig) {
|
||||||
(cmd == HAND_MODE_1) ? "upper" : "lower",
|
Car_Audio_Test_Play();
|
||||||
(unsigned)BOARD_HAND_PULSE_MS);
|
}
|
||||||
} else {
|
} else {
|
||||||
gDevData.hand_mode = HAND_MODE_0;
|
gDevData.hand_mode = HAND_MODE_0;
|
||||||
if (s_func.hand_busy) {
|
if (s_func.hand_busy) {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ void app_function_dp_hand_write(uint8_t cmd);
|
|||||||
/** CBC4 DP6 震动开机开关。 */
|
/** CBC4 DP6 震动开机开关。 */
|
||||||
void app_function_set_shake_wake(uint8_t enable);
|
void app_function_set_shake_wake(uint8_t enable);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 跟随 APP 下发的 DP0/DP1,并处理 DP2 手动点动,每个业务 tick 调用一次
|
* @brief 跟随 APP 下发的 DP0/DP1,并处理 DP2 手动点动,每个业务 tick 调用一次
|
||||||
* @return 无
|
* @return 无
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
#include "app_no_disturb.h"
|
#include "app_no_disturb.h"
|
||||||
#include "usr_rtc.h"
|
|
||||||
#include "system/includes.h"
|
#include "system/includes.h"
|
||||||
|
#include "usr_rtc.h"
|
||||||
|
|
||||||
|
#define APP_NO_DISTURB_VM_ID 28U
|
||||||
|
#define APP_NO_DISTURB_MAGIC 0x4e44U
|
||||||
|
#define APP_NO_DISTURB_VERSION 1U
|
||||||
#define APP_MINUTES_PER_DAY (24U * 60U)
|
#define APP_MINUTES_PER_DAY (24U * 60U)
|
||||||
#define APP_NO_DISTURB_VM_MAGIC 0x444e4431UL
|
|
||||||
#define APP_NO_DISTURB_VM_VERSION 1U
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint16_t magic;
|
||||||
|
uint8_t version;
|
||||||
|
uint8_t cfg[APP_NO_DISTURB_CFG_LEN];
|
||||||
|
} AppNoDisturbVm_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t enabled;
|
uint8_t enabled;
|
||||||
@@ -13,36 +20,65 @@ typedef struct {
|
|||||||
uint16_t end_minute;
|
uint16_t end_minute;
|
||||||
} AppNoDisturbCtx_t;
|
} AppNoDisturbCtx_t;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t magic;
|
|
||||||
uint8_t version;
|
|
||||||
uint8_t length;
|
|
||||||
uint16_t checksum;
|
|
||||||
uint8_t data[APP_NO_DISTURB_DATA_LEN];
|
|
||||||
} AppNoDisturbVm_t;
|
|
||||||
|
|
||||||
static AppNoDisturbCtx_t s_no_disturb;
|
static AppNoDisturbCtx_t s_no_disturb;
|
||||||
static uint8_t s_saved_data[APP_NO_DISTURB_DATA_LEN];
|
|
||||||
static uint8_t s_saved_valid;
|
|
||||||
|
|
||||||
static uint16_t app_no_disturb_checksum(const uint8_t *data)
|
static uint8_t app_no_disturb_cfg_valid(const uint8_t cfg[APP_NO_DISTURB_CFG_LEN])
|
||||||
{
|
{
|
||||||
uint16_t checksum = 0xa55aU;
|
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
for (i = 0; i < APP_NO_DISTURB_DATA_LEN; i++) {
|
if (!cfg || cfg[0] > 1U || cfg[9] >= 24U || cfg[11] >= 24U ||
|
||||||
checksum = (uint16_t)((checksum << 5) | (checksum >> 11));
|
cfg[10] >= 60U || cfg[12] >= 60U) {
|
||||||
checksum ^= data[i];
|
return 0;
|
||||||
}
|
}
|
||||||
return checksum;
|
for (i = 0; i < 7U; i++) {
|
||||||
|
if (cfg[2U + i] > 1U) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t app_no_disturb_vm_valid(const AppNoDisturbVm_t *vm)
|
void app_no_disturb_configure(uint8_t enable, uint8_t weekdays_mask,
|
||||||
|
uint16_t start_minute, uint16_t end_minute)
|
||||||
{
|
{
|
||||||
return vm->magic == APP_NO_DISTURB_VM_MAGIC &&
|
s_no_disturb.enabled = !!enable;
|
||||||
vm->version == APP_NO_DISTURB_VM_VERSION &&
|
s_no_disturb.weekdays_mask = weekdays_mask & 0x7fU;
|
||||||
vm->length == APP_NO_DISTURB_DATA_LEN &&
|
s_no_disturb.start_minute = start_minute;
|
||||||
vm->checksum == app_no_disturb_checksum(vm->data);
|
s_no_disturb.end_minute = end_minute;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t app_no_disturb_storage_load(uint8_t cfg[APP_NO_DISTURB_CFG_LEN])
|
||||||
|
{
|
||||||
|
AppNoDisturbVm_t vm;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!cfg) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memset(&vm, 0, sizeof(vm));
|
||||||
|
ret = syscfg_read(APP_NO_DISTURB_VM_ID, &vm, sizeof(vm));
|
||||||
|
if (ret != (int)sizeof(vm) || vm.magic != APP_NO_DISTURB_MAGIC ||
|
||||||
|
vm.version != APP_NO_DISTURB_VERSION || !app_no_disturb_cfg_valid(vm.cfg)) {
|
||||||
|
memset(cfg, 0, APP_NO_DISTURB_CFG_LEN);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memcpy(cfg, vm.cfg, APP_NO_DISTURB_CFG_LEN);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t app_no_disturb_storage_save(const uint8_t cfg[APP_NO_DISTURB_CFG_LEN])
|
||||||
|
{
|
||||||
|
AppNoDisturbVm_t vm;
|
||||||
|
|
||||||
|
if (!app_no_disturb_cfg_valid(cfg)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memset(&vm, 0, sizeof(vm));
|
||||||
|
vm.magic = APP_NO_DISTURB_MAGIC;
|
||||||
|
vm.version = APP_NO_DISTURB_VERSION;
|
||||||
|
memcpy(vm.cfg, cfg, APP_NO_DISTURB_CFG_LEN);
|
||||||
|
return (uint8_t)(syscfg_write(APP_NO_DISTURB_VM_ID, &vm, sizeof(vm)) ==
|
||||||
|
(int)sizeof(vm));
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t app_no_disturb_weekday_monday0(const struct sys_time *time)
|
static uint8_t app_no_disturb_weekday_monday0(const struct sys_time *time)
|
||||||
@@ -66,15 +102,6 @@ static uint8_t app_no_disturb_day_selected(uint8_t weekday)
|
|||||||
return (uint8_t)((s_no_disturb.weekdays_mask & (1U << weekday)) != 0U);
|
return (uint8_t)((s_no_disturb.weekdays_mask & (1U << weekday)) != 0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_no_disturb_configure(uint8_t enable, uint8_t weekdays_mask,
|
|
||||||
uint16_t start_minute, uint16_t end_minute)
|
|
||||||
{
|
|
||||||
s_no_disturb.enabled = !!enable;
|
|
||||||
s_no_disturb.weekdays_mask = weekdays_mask & 0x7fU;
|
|
||||||
s_no_disturb.start_minute = start_minute;
|
|
||||||
s_no_disturb.end_minute = end_minute;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t app_no_disturb_is_active_at(const struct sys_time *time)
|
uint8_t app_no_disturb_is_active_at(const struct sys_time *time)
|
||||||
{
|
{
|
||||||
uint8_t weekday;
|
uint8_t weekday;
|
||||||
@@ -83,12 +110,10 @@ uint8_t app_no_disturb_is_active_at(const struct sys_time *time)
|
|||||||
if (!time || !s_no_disturb.enabled || !s_no_disturb.weekdays_mask ||
|
if (!time || !s_no_disturb.enabled || !s_no_disturb.weekdays_mask ||
|
||||||
s_no_disturb.start_minute >= APP_MINUTES_PER_DAY ||
|
s_no_disturb.start_minute >= APP_MINUTES_PER_DAY ||
|
||||||
s_no_disturb.end_minute >= APP_MINUTES_PER_DAY ||
|
s_no_disturb.end_minute >= APP_MINUTES_PER_DAY ||
|
||||||
time->month < 1U || time->month > 12U ||
|
time->month < 1U || time->month > 12U || time->day < 1U ||
|
||||||
time->day < 1U || time->day > 31U ||
|
time->day > 31U || time->hour > 23U || time->min > 59U) {
|
||||||
time->hour > 23U || time->min > 59U) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
weekday = app_no_disturb_weekday_monday0(time);
|
weekday = app_no_disturb_weekday_monday0(time);
|
||||||
now_minute = (uint16_t)(time->hour * 60U + time->min);
|
now_minute = (uint16_t)(time->hour * 60U + time->min);
|
||||||
|
|
||||||
@@ -118,51 +143,3 @@ uint8_t app_no_disturb_is_active(void)
|
|||||||
}
|
}
|
||||||
return app_no_disturb_is_active_at(&time);
|
return app_no_disturb_is_active_at(&time);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t app_no_disturb_storage_load(uint8_t data[APP_NO_DISTURB_DATA_LEN])
|
|
||||||
{
|
|
||||||
AppNoDisturbVm_t vm;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memset(&vm, 0, sizeof(vm));
|
|
||||||
ret = syscfg_read(CFG_USER_NO_DISTURB, (uint8_t *)&vm, sizeof(vm));
|
|
||||||
if (ret != (int)sizeof(vm) || !app_no_disturb_vm_valid(&vm)) {
|
|
||||||
s_saved_valid = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memcpy(data, vm.data, APP_NO_DISTURB_DATA_LEN);
|
|
||||||
memcpy(s_saved_data, vm.data, APP_NO_DISTURB_DATA_LEN);
|
|
||||||
s_saved_valid = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t app_no_disturb_storage_save(const uint8_t data[APP_NO_DISTURB_DATA_LEN])
|
|
||||||
{
|
|
||||||
AppNoDisturbVm_t vm;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (s_saved_valid &&
|
|
||||||
!memcmp(s_saved_data, data, APP_NO_DISTURB_DATA_LEN)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&vm, 0, sizeof(vm));
|
|
||||||
vm.magic = APP_NO_DISTURB_VM_MAGIC;
|
|
||||||
vm.version = APP_NO_DISTURB_VM_VERSION;
|
|
||||||
vm.length = APP_NO_DISTURB_DATA_LEN;
|
|
||||||
memcpy(vm.data, data, APP_NO_DISTURB_DATA_LEN);
|
|
||||||
vm.checksum = app_no_disturb_checksum(vm.data);
|
|
||||||
ret = syscfg_write(CFG_USER_NO_DISTURB, (uint8_t *)&vm, sizeof(vm));
|
|
||||||
if (ret != (int)sizeof(vm)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memcpy(s_saved_data, data, APP_NO_DISTURB_DATA_LEN);
|
|
||||||
s_saved_valid = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "system/sys_time.h"
|
#include "system/sys_time.h"
|
||||||
|
|
||||||
#define APP_NO_DISTURB_DATA_LEN 13U
|
#define APP_NO_DISTURB_CFG_LEN 13
|
||||||
|
|
||||||
/* weekdays_mask bit 0..6 means Monday..Sunday. */
|
/* DP7: bytes 2..8 are Monday..Sunday, byte 1 is reserved. */
|
||||||
void app_no_disturb_configure(uint8_t enable, uint8_t weekdays_mask,
|
void app_no_disturb_configure(uint8_t enable, uint8_t weekdays_mask,
|
||||||
uint16_t start_minute, uint16_t end_minute);
|
uint16_t start_minute, uint16_t end_minute);
|
||||||
|
uint8_t app_no_disturb_storage_load(uint8_t cfg[APP_NO_DISTURB_CFG_LEN]);
|
||||||
|
uint8_t app_no_disturb_storage_save(const uint8_t cfg[APP_NO_DISTURB_CFG_LEN]);
|
||||||
uint8_t app_no_disturb_is_active(void);
|
uint8_t app_no_disturb_is_active(void);
|
||||||
uint8_t app_no_disturb_is_active_at(const struct sys_time *time);
|
uint8_t app_no_disturb_is_active_at(const struct sys_time *time);
|
||||||
uint8_t app_no_disturb_storage_load(uint8_t data[APP_NO_DISTURB_DATA_LEN]);
|
|
||||||
uint8_t app_no_disturb_storage_save(const uint8_t data[APP_NO_DISTURB_DATA_LEN]);
|
|
||||||
|
|
||||||
#endif /* __APP_NO_DISTURB_H__ */
|
#endif /* __APP_NO_DISTURB_H__ */
|
||||||
|
|||||||
+67
-26
@@ -36,14 +36,21 @@
|
|||||||
#define BAT_BOOT_MS 3000 /* 上电 3s 内不因低电深睡 */
|
#define BAT_BOOT_MS 3000 /* 上电 3s 内不因低电深睡 */
|
||||||
#define BAT_LOG_MS 10000
|
#define BAT_LOG_MS 10000
|
||||||
#define BAT_PERIODIC_LOG_ENABLE 0 /* Production standby must not wake UART periodically. */
|
#define BAT_PERIODIC_LOG_ENABLE 0 /* Production standby must not wake UART periodically. */
|
||||||
|
#define CHG_ON_CONFIRM_MS 50u
|
||||||
|
#define CHG_OFF_CONFIRM_MS 150u
|
||||||
|
#define CHG_FULL_RECHECK_MS 1000u
|
||||||
#define BAT_LOW_WIN 3 /* 连续约 2.4s 才进低电告警(仅闪灯,不关机) */
|
#define BAT_LOW_WIN 3 /* 连续约 2.4s 才进低电告警(仅闪灯,不关机) */
|
||||||
|
|
||||||
/** 充电检测:CHG/VPWR 消抖后的结果 */
|
/** TP4056 CHRG/STDBY debounced charging state. */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t usb_online;
|
uint8_t usb_online;
|
||||||
uint8_t charge_led; /**< 0=无 1=充电红 2=充满绿 */
|
uint8_t charge_led;
|
||||||
uint8_t charge_led_last; /**< 仅用于变化时打日志 */
|
uint8_t charge_led_last;
|
||||||
uint16_t full_ms; /**< 拔电瞬间 CHG 先变高,需等满 1s 才当充满 */
|
uint16_t charging_ms;
|
||||||
|
uint16_t unplugged_ms;
|
||||||
|
uint16_t full_ms;
|
||||||
|
uint16_t full_recheck_ms;
|
||||||
|
uint8_t full_latched;
|
||||||
} AppChargeState_t;
|
} AppChargeState_t;
|
||||||
|
|
||||||
/** 电量采样:滑动平均 + 百分比 */
|
/** 电量采样:滑动平均 + 百分比 */
|
||||||
@@ -221,7 +228,7 @@ static void power_do_poweroff(void *priv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 充电检测:CHG 低=充电中;VPWR 在且 CHG 高满 1s=充满;拔电报 USB_OUT
|
* @brief TP4056 CHRG/STDBY 组合检测,稳定状态变化后报告 USB 事件
|
||||||
* @param dt 距上次调用的毫秒数
|
* @param dt 距上次调用的毫秒数
|
||||||
* @return USB 插拔边沿事件
|
* @return USB 插拔边沿事件
|
||||||
*/
|
*/
|
||||||
@@ -229,37 +236,71 @@ static AppPowerEvt_t power_charge_tick(uint16_t dt)
|
|||||||
{
|
{
|
||||||
AppChargeState_t *c = &s_power.charge;
|
AppChargeState_t *c = &s_power.charge;
|
||||||
uint8_t chg_low = bsp_chg_is_low();
|
uint8_t chg_low = bsp_chg_is_low();
|
||||||
uint8_t vpwr = bsp_vpwr_is_online();
|
uint8_t stby_low = bsp_stby_is_low();
|
||||||
uint8_t usb;
|
uint8_t usb = c->usb_online;
|
||||||
AppPowerEvt_t evt = APP_POWER_EVT_NONE;
|
AppPowerEvt_t evt = APP_POWER_EVT_NONE;
|
||||||
|
|
||||||
if (chg_low) {
|
if (chg_low && stby_low) {
|
||||||
/* CHG 拉低:正在充电,红灯 */
|
/* 00 is invalid: keep the previous stable state. */
|
||||||
|
c->charging_ms = 0;
|
||||||
|
c->unplugged_ms = 0;
|
||||||
c->full_ms = 0;
|
c->full_ms = 0;
|
||||||
|
c->full_recheck_ms = 0;
|
||||||
|
} else if (!chg_low && !stby_low) {
|
||||||
|
/* 11: charger absent. */
|
||||||
|
c->charging_ms = 0;
|
||||||
|
c->full_ms = 0;
|
||||||
|
c->full_recheck_ms = 0;
|
||||||
|
c->unplugged_ms = app_add_ms(c->unplugged_ms, dt);
|
||||||
|
if (c->unplugged_ms >= CHG_OFF_CONFIRM_MS) {
|
||||||
|
c->charge_led = 0;
|
||||||
|
c->full_latched = 0;
|
||||||
|
usb = 0;
|
||||||
|
}
|
||||||
|
} else if (chg_low) {
|
||||||
|
/* 01: charging. */
|
||||||
|
c->unplugged_ms = 0;
|
||||||
|
c->full_ms = 0;
|
||||||
|
if (c->full_latched) {
|
||||||
|
c->charging_ms = 0;
|
||||||
|
c->full_recheck_ms = app_add_ms(c->full_recheck_ms, dt);
|
||||||
|
if (c->full_recheck_ms >= CHG_FULL_RECHECK_MS) {
|
||||||
|
c->full_latched = 0;
|
||||||
c->charge_led = 1;
|
c->charge_led = 1;
|
||||||
gDevData.charge = CHARGE_1;
|
}
|
||||||
usb = 1;
|
usb = 1;
|
||||||
} else if (vpwr) {
|
} else {
|
||||||
/* VPWR 在但 CHG 已高:可能是充满,也可能是拔电瞬间 CHG 先变高。
|
c->full_recheck_ms = 0;
|
||||||
* 等满 BOARD_CHG_FULL_MS 才当真充满,避免拔电误报绿灯 */
|
c->charging_ms = app_add_ms(c->charging_ms, dt);
|
||||||
|
if (c->charging_ms >= CHG_ON_CONFIRM_MS) {
|
||||||
|
c->charge_led = 1;
|
||||||
|
usb = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* 10: charge complete. */
|
||||||
|
c->charging_ms = 0;
|
||||||
|
c->unplugged_ms = 0;
|
||||||
|
c->full_recheck_ms = 0;
|
||||||
|
if (c->full_latched) {
|
||||||
|
c->charge_led = 2;
|
||||||
|
usb = 1;
|
||||||
|
} else {
|
||||||
c->full_ms = app_add_ms(c->full_ms, dt);
|
c->full_ms = app_add_ms(c->full_ms, dt);
|
||||||
if (c->full_ms >= BOARD_CHG_FULL_MS) {
|
if (c->full_ms >= BOARD_CHG_FULL_MS) {
|
||||||
c->charge_led = 2;
|
c->charge_led = 2;
|
||||||
}
|
c->full_latched = 1;
|
||||||
gDevData.charge = (c->charge_led == 1) ? CHARGE_1 : CHARGE_2;
|
|
||||||
usb = 1;
|
usb = 1;
|
||||||
} else {
|
|
||||||
/* USB 不在位:充电灯灭 */
|
|
||||||
c->full_ms = 0;
|
|
||||||
c->charge_led = 0;
|
|
||||||
gDevData.charge = CHARGE_2;
|
|
||||||
usb = 0;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gDevData.charge = (c->charge_led == 1) ? CHARGE_1 : CHARGE_2;
|
||||||
|
|
||||||
if (usb != c->usb_online) {
|
if (usb != c->usb_online) {
|
||||||
c->usb_online = usb;
|
c->usb_online = usb;
|
||||||
log_info("usb %s vpwr=%d chg=%d mv=%d pair=%d goto=%d\n",
|
log_info("charge input %s chg_low=%d stby_low=%d pair=%d goto=%d\n",
|
||||||
usb ? "in" : "out", vpwr, chg_low, bsp_vpwr_mv(),
|
usb ? "in" : "out", chg_low, stby_low,
|
||||||
usr_get_pair_flag(), usr_var.usr_goto_pair);
|
usr_get_pair_flag(), usr_var.usr_goto_pair);
|
||||||
usr_var.usr_power_charge_flag = usb ? 1 : 2;
|
usr_var.usr_power_charge_flag = usb ? 1 : 2;
|
||||||
if (usb) {
|
if (usb) {
|
||||||
@@ -272,10 +313,10 @@ static AppPowerEvt_t power_charge_tick(uint16_t dt)
|
|||||||
|
|
||||||
if (c->charge_led != c->charge_led_last) {
|
if (c->charge_led != c->charge_led_last) {
|
||||||
c->charge_led_last = c->charge_led;
|
c->charge_led_last = c->charge_led;
|
||||||
log_info("charge_led=%d chg=%d vpwr=%d mv=%d\n",
|
log_info("charge_led=%d chg_low=%d stby_low=%d\n",
|
||||||
c->charge_led, chg_low, vpwr, bsp_vpwr_mv());
|
c->charge_led, chg_low, stby_low);
|
||||||
if (c->charge_led == 2) {
|
if (c->charge_led == 2) {
|
||||||
/* 硬件(CHG+VPWR 满 BOARD_CHG_FULL_MS)判定充满,电量强制收尾到
|
/* STDBY 持续为低满 BOARD_CHG_FULL_MS 后判定充满,电量强制收尾到
|
||||||
* 100%,避免电压拟合曲线因基准/温漂等原因走不到 100% 就卡住 */
|
* 100%,避免电压拟合曲线因基准/温漂等原因走不到 100% 就卡住 */
|
||||||
app_battery_set_percent(100);
|
app_battery_set_percent(100);
|
||||||
s_power.sample.pct = 100;
|
s_power.sample.pct = 100;
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* @file car_audio_test.c
|
||||||
|
* @brief Car audio hardware test using the SDK key-tone sine path.
|
||||||
|
*
|
||||||
|
* Notes:
|
||||||
|
* - The SDK sine sample rate is 16 kHz; points is the PCM sample count.
|
||||||
|
* - freq is specified as actual frequency * 512.
|
||||||
|
* - decay=0 keeps amplitude constant for observing DAC/PA end behavior.
|
||||||
|
* - The parameter array has static storage because playback is asynchronous.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "system/includes.h"
|
||||||
|
#include "tone_player.h"
|
||||||
|
#include "application/audio_dec_app.h"
|
||||||
|
#include "car_audio_test.h"
|
||||||
|
#include "app_audio_debug.h"
|
||||||
|
|
||||||
|
static uint16_t s_car_audio_restart_guard_ms;
|
||||||
|
|
||||||
|
int Car_Audio_Test_Play(void)
|
||||||
|
{
|
||||||
|
/* bird.mp3 is packed as a standalone file in the internal resource area. */
|
||||||
|
int ret;
|
||||||
|
MAGIC_AUDIO_LOG("鸟叫接口进入:资源=%s,当前播放状态=%d",
|
||||||
|
SDFILE_RES_ROOT_PATH"bird.mp3", audio_key_tone_is_play());
|
||||||
|
ret = audio_key_tone_play_name(SDFILE_RES_ROOT_PATH"bird.mp3", 1);
|
||||||
|
MAGIC_AUDIO_LOG("鸟叫请求返回=%d(0仅表示请求已提交,不代表已经出声)", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Car_Audio_Test_Loop(uint16_t dt_ms)
|
||||||
|
{
|
||||||
|
if (s_car_audio_restart_guard_ms > dt_ms) {
|
||||||
|
s_car_audio_restart_guard_ms -= dt_ms;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audio_key_tone_is_play()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Car_Audio_Test_Play() == 0) {
|
||||||
|
/*
|
||||||
|
* 防止播放请求刚入队、SDK 尚未更新播放状态时被重复提交。
|
||||||
|
*/
|
||||||
|
s_car_audio_restart_guard_ms = 50;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* @file car_audio_test.h
|
||||||
|
* @brief Car audio hardware test API using the SDK key-tone sine path.
|
||||||
|
******************************************************************************/
|
||||||
|
#include <stdint.h>
|
||||||
|
#ifndef __CAR_AUDIO_TEST_H__
|
||||||
|
#define __CAR_AUDIO_TEST_H__
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Play the bird-call MP3 stored in the internal resource area.
|
||||||
|
*
|
||||||
|
* The API only queues a request. Playback is asynchronous in the SDK key-tone
|
||||||
|
* task; it does not wait for completion or block the caller. This test is not
|
||||||
|
* triggered automatically; call it explicitly from test code.
|
||||||
|
*
|
||||||
|
* @return 0=request queued; negative value=module unavailable/request failed.
|
||||||
|
*/
|
||||||
|
int Car_Audio_Test_Play(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 开机状态下维护循环测试音。
|
||||||
|
* @param dt_ms 距离上次调用的毫秒数
|
||||||
|
*/
|
||||||
|
void Car_Audio_Test_Loop(uint16_t dt_ms);
|
||||||
|
|
||||||
|
#endif /* __CAR_AUDIO_TEST_H__ */
|
||||||
@@ -30,7 +30,6 @@ static volatile uint32_t timerMs;
|
|||||||
#define JB_DND_START_MIN_OFFSET 10
|
#define JB_DND_START_MIN_OFFSET 10
|
||||||
#define JB_DND_END_HOUR_OFFSET 11
|
#define JB_DND_END_HOUR_OFFSET 11
|
||||||
#define JB_DND_END_MIN_OFFSET 12
|
#define JB_DND_END_MIN_OFFSET 12
|
||||||
|
|
||||||
static void jbNoDisturbApply(uint8_t *cfg)
|
static void jbNoDisturbApply(uint8_t *cfg)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
@@ -67,7 +66,7 @@ void userInit(void)
|
|||||||
gDevData.beep_trig = 0; /* DP4 声音开关 0=关 1=开 */
|
gDevData.beep_trig = 0; /* DP4 声音开关 0=关 1=开 */
|
||||||
gDevData.battery = 0; /* DP5 电量上报 */
|
gDevData.battery = 0; /* DP5 电量上报 */
|
||||||
gDevData.shake_wake = 0; /* DP6 震动触发开机 0=关 1=开 */
|
gDevData.shake_wake = 0; /* DP6 震动触发开机 0=关 1=开 */
|
||||||
memset(gDevData.no_disturb_enable, 0, 13); /* DP7 勿扰模式开关 */
|
memset(gDevData.no_disturb_enable, 0, APP_NO_DISTURB_CFG_LEN); /* DP7 勿扰模式开关 */
|
||||||
app_no_disturb_storage_load(gDevData.no_disturb_enable);
|
app_no_disturb_storage_load(gDevData.no_disturb_enable);
|
||||||
gDevData.charge = 0; /* CHARGE_0 (不支持充电) */
|
gDevData.charge = 0; /* CHARGE_0 (不支持充电) */
|
||||||
gDevData.reserva_dp3 = 0; /* DP10 预留DP3 */
|
gDevData.reserva_dp3 = 0; /* DP10 预留DP3 */
|
||||||
@@ -148,19 +147,12 @@ int8_t jbEventProcess(jb_event_info_t *info, jb_data_point_t *ctrl)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* ── DP7 勿扰模式开关 (raw) ── */
|
/* ── DP7 勿扰模式开关 (raw) ── */
|
||||||
case DP_ID_NO_DISTURB_ENABLE: {
|
case DP_ID_NO_DISTURB_ENABLE:
|
||||||
uint8_t previous[JB_DND_LEN];
|
|
||||||
|
|
||||||
memcpy(previous, gDevData.no_disturb_enable, JB_DND_LEN);
|
|
||||||
memcpy(gDevData.no_disturb_enable, ctrl->no_disturb_enable,
|
memcpy(gDevData.no_disturb_enable, ctrl->no_disturb_enable,
|
||||||
JB_DND_LEN);
|
JB_DND_LEN);
|
||||||
jbNoDisturbApply(gDevData.no_disturb_enable);
|
jbNoDisturbApply(gDevData.no_disturb_enable);
|
||||||
if (memcmp(previous, gDevData.no_disturb_enable, JB_DND_LEN) &&
|
app_no_disturb_storage_save(gDevData.no_disturb_enable);
|
||||||
!app_no_disturb_storage_save(gDevData.no_disturb_enable)) {
|
|
||||||
printf("dnd vm write failed\n");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
/* ── DP10 预留DP3 (uint32) ── */
|
/* ── DP10 预留DP3 (uint32) ── */
|
||||||
case DP_ID_RESERVA_DP3:
|
case DP_ID_RESERVA_DP3:
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include "system/includes.h"
|
#include "system/includes.h"
|
||||||
#include "app_config.h"
|
#include "app_config.h"
|
||||||
|
#include "asm/dac.h"
|
||||||
#include "app_main.h"
|
#include "app_main.h"
|
||||||
#include "app_task.h"
|
#include "app_task.h"
|
||||||
#include "user_cfg.h"
|
#include "user_cfg.h"
|
||||||
@@ -52,11 +53,13 @@
|
|||||||
#include "app_pair.h"
|
#include "app_pair.h"
|
||||||
#include "app_boot.h"
|
#include "app_boot.h"
|
||||||
#include "app_function.h"
|
#include "app_function.h"
|
||||||
|
#include "app_audio_debug.h"
|
||||||
#include "app_mode.h"
|
#include "app_mode.h"
|
||||||
#include "app_led.h"
|
#include "app_led.h"
|
||||||
#include "key_manager.h"
|
#include "key_manager.h"
|
||||||
#include "asm/power/power_api.h"
|
#include "asm/power/power_api.h"
|
||||||
|
|
||||||
|
|
||||||
#define LOG_TAG_CONST APP
|
#define LOG_TAG_CONST APP
|
||||||
#define LOG_TAG "[USR_JB]"
|
#define LOG_TAG "[USR_JB]"
|
||||||
#define LOG_INFO_ENABLE
|
#define LOG_INFO_ENABLE
|
||||||
@@ -285,6 +288,13 @@ void usr_jb_init(void)
|
|||||||
{
|
{
|
||||||
usr_log_boot_version(); /* UART 已在 app_main 起来,按键判定前就能看到版本 */
|
usr_log_boot_version(); /* UART 已在 app_main 起来,按键判定前就能看到版本 */
|
||||||
|
|
||||||
|
MAGIC_AUDIO_LOG("诊断固件启动:编译=%s %s,UART0使能=%d,TX引脚编号=%u,波特率=%u",
|
||||||
|
__DATE__, __TIME__, TCFG_UART0_ENABLE,
|
||||||
|
(unsigned)TCFG_UART0_TX_PORT, (unsigned)TCFG_UART0_BAUDRATE);
|
||||||
|
MAGIC_AUDIO_LOG("配置:提示音=%d,MP3=%d,DAC=%d,DAC通道=%d,DAC模式=%d,音量类型=%d",
|
||||||
|
TCFG_KEY_TONE_EN, TCFG_DEC_MP3_ENABLE, TCFG_AUDIO_DAC_ENABLE,
|
||||||
|
TCFG_AUDIO_DAC_CONNECT_MODE, TCFG_AUDIO_DAC_MODE, SYS_VOL_TYPE);
|
||||||
|
MAGIC_AUDIO_LOG("鸟叫资源路径=%s,中文显示请使用UTF-8", SDFILE_RES_ROOT_PATH"bird.mp3");
|
||||||
bsp_hw_init();
|
bsp_hw_init();
|
||||||
app_led_init(); /* 提前到按键判定之前:3s/5s/拒绝开机低电闪都要直接用灯效事件表 */
|
app_led_init(); /* 提前到按键判定之前:3s/5s/拒绝开机低电闪都要直接用灯效事件表 */
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#define BOARD_LED_ENABLE 1 /**< 1=红绿 LED */
|
#define BOARD_LED_ENABLE 1 /**< 1=红绿 LED */
|
||||||
#define BOARD_KEY_ENABLE 1 /**< 1=按键 PB1 */
|
#define BOARD_KEY_ENABLE 1 /**< 1=按键 PB1 */
|
||||||
#define BOARD_CHG_ENABLE 1 /**< 1=充电检测 PG8 + VPWR */
|
#define BOARD_CHG_ENABLE 1 /**< 1=TP4056: PG8 CHRG + PC5 STDBY */
|
||||||
#define BOARD_MOTOR_ENABLE 1 /**< 1=双电机 U13 + U18 */
|
#define BOARD_MOTOR_ENABLE 1 /**< 1=双电机 U13 + U18 */
|
||||||
#define BOARD_SHAKE_ENABLE 1 /**< 1=震动输入 PA3 */
|
#define BOARD_SHAKE_ENABLE 1 /**< 1=震动输入 PA3 */
|
||||||
|
|
||||||
@@ -39,14 +39,16 @@
|
|||||||
#define BOARD_RIGHT_BACKWARD_PIN IO_PORTC_03 /**< U18-INA,右轮后退 */
|
#define BOARD_RIGHT_BACKWARD_PIN IO_PORTC_03 /**< U18-INA,右轮后退 */
|
||||||
#define BOARD_RIGHT_FORWARD_PIN IO_PORTC_04 /**< U18-INB,右轮前进 */
|
#define BOARD_RIGHT_FORWARD_PIN IO_PORTC_04 /**< U18-INB,右轮前进 */
|
||||||
#define BOARD_SHAKE_PIN IO_PORTA_03 /**< 震动开机,常闭开关断开时高脉冲有效 */
|
#define BOARD_SHAKE_PIN IO_PORTA_03 /**< 震动开机,常闭开关断开时高脉冲有效 */
|
||||||
#define BOARD_LED_RED_PIN IO_PORTA_08 /**< 红灯 LED_PWR,低电平亮 */
|
#define BOARD_LED_RED_PIN IO_PORTA_07 /**< 红灯 LED_PWR,低电平亮 */
|
||||||
#define BOARD_LED_GREEN_PIN IO_PORTA_07 /**< 绿灯 LED_CHG,低电平亮 */
|
#define BOARD_LED_GREEN_PIN IO_PORTA_08 /**< 绿灯 LED_CHG,低电平亮 */
|
||||||
#define BOARD_KEY_PIN IO_PORTB_01 /**< 按键,低电平按下 */
|
#define BOARD_KEY_PIN IO_PORTB_01 /**< 按键,低电平按下 */
|
||||||
#define BOARD_CHG_PIN IO_PORTG_08 /**< ME4054 CHG,外部 2.2k 上拉 */
|
#define BOARD_CHG_PIN IO_PORTG_08 /**< TP4056 CHRG, active low, internal pull-up */
|
||||||
|
#define BOARD_STDBY_PIN IO_PORTC_05 /**< TP4056 STDBY, active low, internal pull-up */
|
||||||
|
|
||||||
#define BOARD_LED_ON_LEVEL 0 /**< LED 点亮电平:0=低亮 */
|
#define BOARD_LED_ON_LEVEL 0 /**< LED 点亮电平:0=低亮 */
|
||||||
#define BOARD_KEY_ACTIVE_LEVEL 0 /**< 按键有效电平:0=按下为低 */
|
#define BOARD_KEY_ACTIVE_LEVEL 0 /**< 按键有效电平:0=按下为低 */
|
||||||
#define BOARD_CHG_CHARGING_LEVEL 0 /**< CHG 充电中为低 */
|
#define BOARD_CHG_CHARGING_LEVEL 0 /**< CHG 充电中为低 */
|
||||||
|
#define BOARD_STDBY_FULL_LEVEL 0 /**< STDBY 充满时为低 */
|
||||||
|
|
||||||
#define BOARD_SHAKE_ACTIVE_LEVEL 1 /**< 常闭震动开关:断开时高脉冲有效 */
|
#define BOARD_SHAKE_ACTIVE_LEVEL 1 /**< 常闭震动开关:断开时高脉冲有效 */
|
||||||
|
|
||||||
@@ -62,9 +64,9 @@
|
|||||||
#define BOARD_VBAT_LOW_HYST_MV 50 /**< 低电恢复回差 */
|
#define BOARD_VBAT_LOW_HYST_MV 50 /**< 低电恢复回差 */
|
||||||
#define BOARD_VBAT_SHUTDOWN_MV 3250 /**< 约 5%,仅开机拦截用:关机状态下 app_battery 尚未运行,只能摸裸电压 */
|
#define BOARD_VBAT_SHUTDOWN_MV 3250 /**< 约 5%,仅开机拦截用:关机状态下 app_battery 尚未运行,只能摸裸电压 */
|
||||||
#define BOARD_BATTERY_SHUTDOWN_PCT 5 /**< 运行中显示电量 <= 此值才自动关机,跟 APP 看到的百分比对齐 */
|
#define BOARD_BATTERY_SHUTDOWN_PCT 5 /**< 运行中显示电量 <= 此值才自动关机,跟 APP 看到的百分比对齐 */
|
||||||
#define BOARD_VPWR_ONLINE_MV 4000 /**< VPWR 判定 USB 插入 */
|
#define BOARD_VPWR_ONLINE_MV 4000
|
||||||
#define BOARD_VPWR_OFF_MV 1500 /**< 低于此值认定已拔出 */
|
#define BOARD_VPWR_OFF_MV 1500
|
||||||
#define BOARD_CHG_FULL_MS 1000 /**< CHG 已高且 VPWR 在,满 1s 认充满 */
|
#define BOARD_CHG_FULL_MS 1000 /**< STDBY low confirmation time */
|
||||||
|
|
||||||
/*============================================================================*/
|
/*============================================================================*/
|
||||||
/* 按键 / 灯效 */
|
/* 按键 / 灯效 */
|
||||||
@@ -124,8 +126,7 @@
|
|||||||
#define BOARD_SHAKE_TRIGGER_WINDOW_MS 250u /**< 保留窗口参数,便于恢复多脉冲策略 */
|
#define BOARD_SHAKE_TRIGGER_WINDOW_MS 250u /**< 保留窗口参数,便于恢复多脉冲策略 */
|
||||||
#define BOARD_SHAKE_POLL_MS 10u /**< 与业务调度器共用的采样节拍 */
|
#define BOARD_SHAKE_POLL_MS 10u /**< 与业务调度器共用的采样节拍 */
|
||||||
|
|
||||||
/* PG8/CHG_ON is the only fitted USB-related signal that changes while the
|
/* PG8/CHRG is used to detect charge insertion while in softoff. */
|
||||||
* product is in softoff; VPWR is disconnected on boards with R18 not fitted. */
|
|
||||||
#define BOARD_CHG_WAKEUP_INDEX 3u
|
#define BOARD_CHG_WAKEUP_INDEX 3u
|
||||||
|
|
||||||
#endif /* __BOARD_PIN_H__ */
|
#endif /* __BOARD_PIN_H__ */
|
||||||
|
|||||||
@@ -233,13 +233,20 @@ BspHw_Ret_t bsp_hw_init(void)
|
|||||||
#if BOARD_CHG_ENABLE
|
#if BOARD_CHG_ENABLE
|
||||||
/* PORTG 作数字输入必须开 dieh,否则读不到 ME4054 CHG */
|
/* PORTG 作数字输入必须开 dieh,否则读不到 ME4054 CHG */
|
||||||
gpio_disable_fun_output_port(BOARD_CHG_PIN);
|
gpio_disable_fun_output_port(BOARD_CHG_PIN);
|
||||||
gpio_set_pull_up(BOARD_CHG_PIN, 0);
|
/* ME4054 CHRG is open-drain/high-Z when not charging. Keep PG8 pulled
|
||||||
|
* high so the digital input has a deterministic level in that state. */
|
||||||
|
gpio_set_pull_up(BOARD_CHG_PIN, 1);
|
||||||
gpio_set_pull_down(BOARD_CHG_PIN, 0);
|
gpio_set_pull_down(BOARD_CHG_PIN, 0);
|
||||||
gpio_set_die(BOARD_CHG_PIN, 1);
|
gpio_set_die(BOARD_CHG_PIN, 1);
|
||||||
gpio_set_dieh(BOARD_CHG_PIN, 1);
|
gpio_set_dieh(BOARD_CHG_PIN, 1);
|
||||||
gpio_direction_input(BOARD_CHG_PIN);
|
gpio_direction_input(BOARD_CHG_PIN);
|
||||||
adc_add_sample_ch(AD_CH_LDO5V);
|
|
||||||
adc_set_sample_freq(AD_CH_LDO5V, 500);
|
gpio_disable_fun_output_port(BOARD_STDBY_PIN);
|
||||||
|
gpio_set_pull_up(BOARD_STDBY_PIN, 1);
|
||||||
|
gpio_set_pull_down(BOARD_STDBY_PIN, 0);
|
||||||
|
gpio_set_die(BOARD_STDBY_PIN, 1);
|
||||||
|
gpio_set_dieh(BOARD_STDBY_PIN, 1);
|
||||||
|
gpio_direction_input(BOARD_STDBY_PIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOARD_MOTOR_ENABLE
|
#if BOARD_MOTOR_ENABLE
|
||||||
@@ -423,6 +430,16 @@ uint8_t bsp_chg_is_low(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return 1 when TP4056 STDBY is low; otherwise 0. */
|
||||||
|
uint8_t bsp_stby_is_low(void)
|
||||||
|
{
|
||||||
|
#if BOARD_CHG_ENABLE
|
||||||
|
return (uint8_t)(gpio_read(BOARD_STDBY_PIN) == BOARD_STDBY_FULL_LEVEL);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 读取电池电压
|
* @brief 读取电池电压
|
||||||
* @return 电池电压,单位 mV
|
* @return 电池电压,单位 mV
|
||||||
|
|||||||
@@ -101,6 +101,9 @@ uint8_t bsp_key_is_pressed(void);
|
|||||||
*/
|
*/
|
||||||
uint8_t bsp_chg_is_low(void);
|
uint8_t bsp_chg_is_low(void);
|
||||||
|
|
||||||
|
/** @return 1 when TP4056 STDBY is low; otherwise 0. */
|
||||||
|
uint8_t bsp_stby_is_low(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 读取电池电压
|
* @brief 读取电池电压
|
||||||
* @return 电池电压,单位 mV
|
* @return 电池电压,单位 mV
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
3DBA0ACD41A68B534365C721F7B23619914B4106E1024B5592A0A49D1DD417152E4DCF18
|
|
||||||
@@ -4,6 +4,7 @@ cd %~dp0
|
|||||||
|
|
||||||
copy ..\..\script.ver .
|
copy ..\..\script.ver .
|
||||||
copy ..\..\tone.cfg .
|
copy ..\..\tone.cfg .
|
||||||
|
copy ..\..\bird.mp3 .
|
||||||
copy ..\..\p11_code.bin .
|
copy ..\..\p11_code.bin .
|
||||||
copy ..\..\br28loader.bin .
|
copy ..\..\br28loader.bin .
|
||||||
copy ..\..\ota.bin .
|
copy ..\..\ota.bin .
|
||||||
@@ -15,7 +16,7 @@ if not exist p11_code.bin (
|
|||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
set "ISD_CMD=..\..\isd_download.exe ..\..\isd_config.ini -tonorflash -dev br28 -boot 0x120000 -div8 -wait 300 -uboot ..\..\uboot.boot -app ..\..\app.bin -res ..\..\cfg_tool.bin tone.cfg p11_code.bin -uboot_compress"
|
set "ISD_CMD=..\..\isd_download.exe ..\..\isd_config.ini -tonorflash -dev br28 -boot 0x120000 -div8 -wait 300 -uboot ..\..\uboot.boot -app ..\..\app.bin -res ..\..\cfg_tool.bin tone.cfg bird.mp3 p11_code.bin -uboot_compress"
|
||||||
|
|
||||||
if not exist RS-5B88.key (
|
if not exist RS-5B88.key (
|
||||||
echo [download] ERROR: RS-5B88.key not found
|
echo [download] ERROR: RS-5B88.key not found
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
# SOC 代码生成模板 — 分支索引
|
|
||||||
|
|
||||||
本仓库按 **「厂商-型号」** 组织分支,每个分支是一套完整的 SOC 工程模板。
|
|
||||||
|
|
||||||
远程仓库:[soc-codegen-template](https://git.jianbao-tech.com/pets-device/soc-codegen-template)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 分支列表
|
|
||||||
|
|
||||||
| 分支 | 厂商 | 型号 | 平台 | 默认能力 | 状态 |
|
|
||||||
|------|------|------|------|----------|------|
|
|
||||||
| [`JieLi-JL7016`](https://git.jianbao-tech.com/pets-device/soc-codegen-template/src/branch/JieLi-JL7016) | 杰理 JieLi | JL7016 / AC7016C | BR28 | 耳机 SDK + BLE + jb_protocol + OTA | ✅ 可用 |
|
|
||||||
|
|
||||||
> 新模板上线后在此表追加一行即可。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 如何获取某 SOC 模板
|
|
||||||
|
|
||||||
### 见宝工具箱 / 自动化脚本
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://git.jianbao-tech.com/pets-device/soc-codegen-template.git
|
|
||||||
cd soc-codegen-template
|
|
||||||
git checkout JieLi-JL7016
|
|
||||||
```
|
|
||||||
|
|
||||||
### 仅下载指定分支(浅克隆)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone --branch JieLi-JL7016 --single-branch \
|
|
||||||
https://git.jianbao-tech.com/pets-device/soc-codegen-template.git jl7016-template
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 分支命名规范
|
|
||||||
|
|
||||||
```
|
|
||||||
<厂商>-<型号>
|
|
||||||
```
|
|
||||||
|
|
||||||
示例:`JieLi-JL7016`、`JieLi-AC701N`
|
|
||||||
|
|
||||||
- 默认包含耳机应用与 jb_protocol,分支名**不加**多余后缀
|
|
||||||
- 同一芯片多种工程结构差异过大时,再考虑加后缀:`JieLi-JL7016-dongle`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 新增 SOC 模板(维护者)
|
|
||||||
|
|
||||||
1. 从 `main` 拉新分支:`git checkout -b <厂商>-<型号> main`
|
|
||||||
2. 合入该 SOC 完整工程(apps + cpu + include_lib + tools)
|
|
||||||
3. 更新本文件分支表 + `main/README.md` 快速索引
|
|
||||||
4. 推送分支并在 Gitea 设为受保护分支(可选)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 各分支 README
|
|
||||||
|
|
||||||
每个 SOC 分支根目录有独立的 `README.md`(构建、打包、协议对接说明)。
|
|
||||||
@@ -172,7 +172,6 @@ u8 *syscfg_ptr_read(u16 item_id, u16 *len);
|
|||||||
#define CFG_USER_PLAN_INFO1 25+1
|
#define CFG_USER_PLAN_INFO1 25+1
|
||||||
|
|
||||||
#define CFG_USER_BATTERY_LEVEL 26+1
|
#define CFG_USER_BATTERY_LEVEL 26+1
|
||||||
#define CFG_USER_NO_DISTURB 28
|
|
||||||
|
|
||||||
|
|
||||||
#define CFG_USER_DEFINE_END 49
|
#define CFG_USER_DEFINE_END 49
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# 改动日志
|
||||||
|
|
||||||
|
日期:2026-09-08
|
||||||
|
|
||||||
|
## 本次 MAGIC_BOX_FW 音频与充电对齐
|
||||||
|
|
||||||
|
1. 文件:`apps/earphone/board/br28/board_jl701n_demo_cfg.h`
|
||||||
|
- 行号:104,369(修改后行号以当前文件为准)
|
||||||
|
- 原代码:`TCFG_KEY_TONE_EN` 为 `DISABLE`;DAC 模式为 `DAC_MODE_L_SINGLE`。
|
||||||
|
- 修改后:启用 `TCFG_KEY_TONE_EN`;DAC 模式改为 `DAC_MODE_H2_SINGLE`。
|
||||||
|
- 原因:启用 SDK key-tone 播放任务,并匹配 FK_CAR_FW 使用 ROUT 单端输出的配置。
|
||||||
|
|
||||||
|
2. 文件:`apps/usr_app/app_function.c`
|
||||||
|
- 行号:约 26、254-259
|
||||||
|
- 原代码:模式改变时只调用 `app_led_request_mode_blink()`。
|
||||||
|
- 修改后:模式改变且 `mode != PLAY_MODE_0` 时调用 `Car_Audio_Test_Play()`。
|
||||||
|
- 原因:每次实际切换到运行模式时播放一次鸟叫;不放入 1ms tick,因此不会连续调用。
|
||||||
|
|
||||||
|
3. 文件:`apps/usr_app/car_audio_test.c`、`apps/usr_app/car_audio_test.h`
|
||||||
|
- 原代码:MAGIC_BOX_FW 未纳入该音频测试模块。
|
||||||
|
- 修改后:加入 FK_CAR_FW 当前版本的鸟叫播放接口,路径为 `mnt/sdfile/res/bird.mp3`。
|
||||||
|
- 原因:提供模式切换调用的播放实现。
|
||||||
|
|
||||||
|
4. 文件:`Makefile`
|
||||||
|
- 行号:约 414
|
||||||
|
- 原代码:源文件列表不含 `apps/usr_app/car_audio_test.c`。
|
||||||
|
- 修改后:加入该源文件。
|
||||||
|
- 原因:确保编译、链接播放接口实现。
|
||||||
|
|
||||||
|
5. 文件:`cpu/br28/tools/download/earphone/download_app_ota.bat`
|
||||||
|
- 行号:约 5、18
|
||||||
|
- 原代码:未复制 `bird.mp3`,资源参数只有 `tone.cfg p11_code.bin`。
|
||||||
|
- 修改后:复制 `bird.mp3`,并在 `-res` 参数中加入 `bird.mp3`。
|
||||||
|
- 原因:将鸟叫文件打包进内部资源区。
|
||||||
|
|
||||||
|
6. 文件:`cpu/br28/tools/bird.mp3`
|
||||||
|
- 原代码:MAGIC_BOX_FW 中缺少可供下载脚本复制的鸟叫文件。
|
||||||
|
- 修改后:加入当前 FK_CAR_FW 使用的 `bird.mp3`。
|
||||||
|
- 原因:提供资源打包输入文件。
|
||||||
|
|
||||||
|
说明:MAGIC_BOX_FW 当前 `app_power.c` 的充电状态主逻辑已经是 CHRG+STDBY 组合检测,与当前 FK_CAR_FW 一致;本次未重复改写该逻辑,保留其 VPWR 辅助函数未被应用层使用。
|
||||||
|
|
||||||
|
7. 文件:`apps/earphone/board/br28/board_jl701n_demo_cfg.h`
|
||||||
|
- 行号:825
|
||||||
|
- 原代码:`#define TCFG_DRC_ENABLE 0 /*DRC .../`(块注释未闭合)。
|
||||||
|
- 修改后:将该注释改为合法的 `/*DRC */`。
|
||||||
|
- 原因:首次完整编译发现该处导致 `line 828: expected identifier or '('`,属于当前工程已有的语法错误,必须修复后才能验证本次功能。
|
||||||
|
|
||||||
|
8. 同一配置文件第1197行:补齐损坏的 `#error` 字符串结束引号,消除预处理语法错误。
|
||||||
Reference in New Issue
Block a user