qcc3086默认只支持模拟输入和usb audio,这里实际就是用spdif取代了模拟输入。
/*!
\copyright Copyright (c) 2021 - 2023 Qualcomm Technologies International, Ltd.\n
All Rights Reserved.\n
Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\version %version
\file state_of_charge.c
\ingroup state_of_charge
\brief
*/
#ifndef HAVE_NO_BATTERY
#define DEBUG_LOG_MODULE_NAME state_of_charge
#include <logging.h>
DEBUG_LOG_DEFINE_LEVEL_VAR
#include <ps.h>
#include <panic.h>
#include <pio.h>
#include <vm.h>
#include <hydra_macros.h>
#include <limits.h>
#include <task_list.h>
#include <logging.h>
#include <led.h>
#ifdef INCLUDE_DFU
#include <upgrade.h>
#endif
#include "adk_log.h"
#include "state_of_charge_private.h"
#include "battery_monitor.h"
#include "charger_monitor.h"
#include "battery_monitor_config.h"
#include "unexpected_message.h"
#include <stdlib.h>
/* Make the type used for message IDs available in debug tools */
LOGGING_PRESERVE_MESSAGE_ENUM(soc_messages)
ASSERT_MESSAGE_GROUP_NOT_OVERFLOWED(STATE_OF_CHARGE, STATE_OF_CHARGE_MESSAGE_END)
typedef struct
{
const soc_lookup_t* soc_config_table;
unsigned soc_config_size;
}soc_ctx_t;
static soc_ctx_t soc_ctx;
soc_data_t app_battery_charge;
/*!
\brief Send battery state of charge update message to all registered clients.
\param battery_region pointer to battery_region_data_t structure
*/
static void soc_ServiceClients(soc_data_t *battery_charge)
{
socRegisteredClient *client = NULL;
for (client = battery_charge->client_list; client != NULL; client = client->next)
{
uint8 percent = (uint8)battery_charge->state_of_charge;
if (percent != client->percent)
{
MESSAGE_MAKE(msg, MESSAGE_SOC_UPDATE_T);
msg->percent = percent;
client->percent = percent;
MessageSend(client->form.task, SOC_UPDATE_IND, msg);
}
}
}
/*! Add a client to the list of clients */
static bool soc_ClientAdd(soc_data_t *battery_charge, soc_registration_form_t *form)
{
socRegisteredClient *new = calloc(1, sizeof(*new));
if (new)
{
new->form = *form;
new->next = battery_charge->client_list;
battery_charge->client_list = new;
return TRUE;
}
return FALSE;
}
/*! Remove a client from the list of clients */
static void soc_ClientRemove(soc_data_t *battery_charge, Task task)
{
socRegisteredClient **head;
for (head = &battery_charge->client_list; *head != NULL; head = &(*head)->next)
{
if ((*head)->form.task == task)
{
socRegisteredClient *toremove = *h