Compare commits
3 Commits
ede7a327a6
...
5e2ebf2fd6
Author | SHA1 | Date | |
---|---|---|---|
|
5e2ebf2fd6 | ||
|
3afc770e39 | ||
|
17480e895f |
@ -312,7 +312,7 @@ void watch_peripherals_register_battery_controller_status_change_cb(BatteryContr
|
||||
uint16_t watch_peripherals_get_battery_voltage(battery_unit_e unit)
|
||||
{
|
||||
tls_gpio_write(BATTERY_VOLTAGE_DIVIDER_ENABLE, 1);
|
||||
int batteryVoltage = adc_get_inputVolt(BATTERY_VOLTAGE_ADC_CHANNEL, 1, 1) * 2 + _adc_offset;
|
||||
int batteryVoltage = adc_get_inputVolt_with_gains(BATTERY_VOLTAGE_ADC_CHANNEL, 1, 1) * 2 + _adc_offset;
|
||||
tls_gpio_write(BATTERY_VOLTAGE_DIVIDER_ENABLE, 0);
|
||||
|
||||
switch (unit)
|
||||
|
@ -1,6 +1,10 @@
|
||||
==========================================================
|
||||
| CHANGELOG: WinnerMicro Software Development Kit |
|
||||
==========================================================
|
||||
W800 SDK v1.00.10 | 2023/08/25
|
||||
==========================
|
||||
1.Wi-Fi 库更新:解决ap下sta连接;解决wifi校准参数未保存问题
|
||||
|
||||
W800 SDK v1.00.10 | 2022/12/29
|
||||
==========================
|
||||
1. 驱动更新
|
||||
|
@ -270,7 +270,23 @@ int adc_get_interTemp(void);
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int adc_get_inputVolt(u8 channel, u8 gain1, u8 gain2);
|
||||
int adc_get_inputVolt(u8 channel);
|
||||
|
||||
/** NOT PART OF THE OFFICIAL SDK **/
|
||||
/**
|
||||
* @brief This function is used to read input voltage also allowing to
|
||||
* specify ADC gains.
|
||||
*
|
||||
* @param[in] channel adc channel,from 0 to 3 is single input;8 and 9 is differential input.
|
||||
* @param[in] gain1 ADC PGA gain 1
|
||||
* @param[in] gain2 ADC PGA gain 2
|
||||
*
|
||||
* @retval voltage unit:mV
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int adc_get_inputVolt_with_gains(u8 channel, u8 gain1, u8 gain2);
|
||||
/**********************************/
|
||||
|
||||
/**
|
||||
* @brief This function is used to read internal voltage.
|
||||
|
@ -236,11 +236,32 @@ tls_os_task_t tls_os_task_id();
|
||||
|
||||
u8 tls_os_task_schedule_state();
|
||||
|
||||
/** NOT PART OF THE OFFICIAL SDK **/
|
||||
/**
|
||||
* @brief Suspends a task, if NULL is given, calling task is suspended
|
||||
*
|
||||
* @param task handle of the task to suspend or NULL for the current task
|
||||
* @return tls_os_status_t TLS_OS_SUCCESS if the call was successful
|
||||
*/
|
||||
tls_os_status_t tls_os_task_suspend(tls_os_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Resumes a suspended task with @ref tls_os_task_suspend
|
||||
*
|
||||
* @param task handle of the task to suspend or NULL for the current task
|
||||
* @return tls_os_status_t TLS_OS_SUCCESS if the call was successful
|
||||
*/
|
||||
tls_os_status_t tls_os_task_resume(tls_os_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Resumes a suspended task with @ref tls_os_task_suspend
|
||||
* from an ISR (Interrupt Service Routine)
|
||||
*
|
||||
* @param task handle of the task to suspend or NULL for the current task
|
||||
* @return tls_os_status_t TLS_OS_SUCCESS if the call was successful
|
||||
*/
|
||||
tls_os_status_t tls_os_task_resume_from_isr(tls_os_task_t task);
|
||||
/**********************************/
|
||||
|
||||
/**
|
||||
* @brief This function creates a mutual exclusion semaphore
|
||||
|
@ -84,7 +84,15 @@ void * mem_alloc_debug(u32 size);
|
||||
void mem_free_debug(void *p);
|
||||
void * mem_realloc_debug(void *mem_address, u32 size);
|
||||
void *mem_calloc_debug(u32 length, u32 size);
|
||||
|
||||
/** NOT PART OF THE OFFICIAL SDK **/
|
||||
/**
|
||||
* @brief Returns the currently available heap size in bytes
|
||||
*
|
||||
* @return u32 the size in bytes of the available heap memory
|
||||
*/
|
||||
u32 tls_mem_get_avail_heapsize(void);
|
||||
/**********************************/
|
||||
|
||||
/**
|
||||
* @defgroup System_APIs System APIs
|
||||
|
Binary file not shown.
@ -532,7 +532,7 @@ int adc_get_interTemp(void)
|
||||
return adc_temp();
|
||||
}
|
||||
|
||||
int adc_get_inputVolt(u8 channel, u8 gain1, u8 gain2)
|
||||
int adc_get_inputVolt(u8 channel)
|
||||
{
|
||||
int average = 0;
|
||||
double voltage = 0.0;
|
||||
@ -544,7 +544,7 @@ int adc_get_inputVolt(u8 channel, u8 gain1, u8 gain2)
|
||||
|
||||
tls_adc_init(0, 0);
|
||||
tls_adc_reference_sel(ADC_REFERENCE_INTERNAL);
|
||||
tls_adc_set_pga(gain1, gain2);
|
||||
tls_adc_set_pga(1,1);
|
||||
tls_adc_set_clk(0x28);
|
||||
tls_adc_start_with_cpu(channel);
|
||||
|
||||
@ -567,6 +567,43 @@ int adc_get_inputVolt(u8 channel, u8 gain1, u8 gain2)
|
||||
return average;
|
||||
}
|
||||
|
||||
/** NOT PART OF THE OFFICIAL SDK **/
|
||||
int adc_get_inputVolt_with_gains(u8 channel, u8 gain1, u8 gain2)
|
||||
{
|
||||
int average = 0;
|
||||
double voltage = 0.0;
|
||||
|
||||
if(_polyfit_param.poly_n == 0 || (channel == 8) || (channel == 9))
|
||||
{
|
||||
adc_get_offset();
|
||||
}
|
||||
|
||||
tls_adc_init(0, 0);
|
||||
tls_adc_reference_sel(ADC_REFERENCE_INTERNAL);
|
||||
tls_adc_set_pga(gain1, gain2);
|
||||
tls_adc_set_clk(0x28);
|
||||
tls_adc_start_with_cpu(channel);
|
||||
|
||||
waitForAdcDone();
|
||||
average = tls_read_adc_result();
|
||||
signedToUnsignedData(&average);
|
||||
tls_adc_stop(0);
|
||||
|
||||
if ((channel == 8) || (channel == 9))
|
||||
{
|
||||
voltage = ((double)average - (double)adc_offset)/4.0;
|
||||
voltage = voltage*(126363/1000)/1000000;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cal_voltage((double)average);
|
||||
}
|
||||
|
||||
average = (int)(voltage*1000);
|
||||
return average;
|
||||
}
|
||||
/**********************************/
|
||||
|
||||
u32 adc_get_interVolt(void)
|
||||
{
|
||||
u32 voltValue;
|
||||
|
@ -33,11 +33,30 @@ int string_to_uint(char *buf, u32 *d);
|
||||
int string_to_ipaddr(const char *buf, u8 *addr);
|
||||
char * strdup(const char *s);
|
||||
char * strndup(const char *s, size_t len);
|
||||
/** NOT PART OF THE OFFICIAL SDK **/
|
||||
/**
|
||||
* @brief The strcmp() function compares the two strings s1 and s2. It returns an integer less than, equal to, or
|
||||
* greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2.
|
||||
* The strncmp() function is similar, except it compares only the first (at most) n bytes of s1 and s2.
|
||||
*
|
||||
* @param s1 first string to compare
|
||||
* @param s2 second string to compare
|
||||
* @return int The strcmp() and strncmp() functions return an integer less than, equal to, or greater than zero if s1 (or the
|
||||
* first n bytes thereof) is found, respectively, to be less than, to match, or be greater than s2.
|
||||
*/
|
||||
int strcasecmp(const char *s1, const char *s2);
|
||||
/**********************************/
|
||||
|
||||
int sendchar(int ch);
|
||||
void dumpBuffer(char *name, char* buffer, int len);
|
||||
void dumpUint32(char *name, u32* buffer, int len);
|
||||
/** NOT PART OF THE OFFICIAL SDK **/
|
||||
/**
|
||||
* @brief Sends a character on the debug uart
|
||||
*
|
||||
* @param ch the character to send
|
||||
* @return int the character passed as input
|
||||
*/
|
||||
int sendchar_debug_uart(int ch);
|
||||
|
||||
/**********************************/
|
||||
#endif /* UTILS_H */
|
||||
|
@ -150,6 +150,7 @@ const char *tls_bt_rc_2_str(uint32_t event)
|
||||
}
|
||||
}
|
||||
|
||||
/** NOT PART OF THE OFFICIAL SDK **/
|
||||
const char *tls_bt_addr_type_2_str(uint8_t addr_type)
|
||||
{
|
||||
switch(addr_type)
|
||||
@ -194,6 +195,7 @@ const char *tls_bt_sm_ioact_2_str(uint8_t ioact)
|
||||
return "unknown io action type";
|
||||
}
|
||||
}
|
||||
/**********************************/
|
||||
|
||||
static void async_evt_func(struct ble_npl_event *ev)
|
||||
{
|
||||
|
@ -54,9 +54,30 @@ extern tls_bt_log_level_t tls_appl_trace_level;
|
||||
void tls_bt_log(uint32_t trace_set_mask, const char *fmt_str, ...);
|
||||
const char *tls_bt_gap_evt_2_str(uint32_t event);
|
||||
const char *tls_bt_rc_2_str(uint32_t event);
|
||||
/** NOT PART OF THE OFFICIAL SDK **/
|
||||
|
||||
/**
|
||||
* @brief Returns the BLE address type as a string
|
||||
*
|
||||
* @param addr_type the BLE address type
|
||||
* @return const char* the corresponding type as a string
|
||||
*/
|
||||
const char *tls_bt_addr_type_2_str(uint8_t addr_type);
|
||||
/**
|
||||
* @brief Returns the BLE GATT access option as a string
|
||||
*
|
||||
* @param op the BLE GATT access option
|
||||
* @return const char* the corresponding type as a string
|
||||
*/
|
||||
const char *tls_bt_access_opt_2_str(uint8_t op);
|
||||
/**
|
||||
* @brief Returns the BLE input/output action as a string
|
||||
*
|
||||
* @param ioact the BLE GATT input/output option
|
||||
* @return const char* the corresponding type as a string
|
||||
*/
|
||||
const char *tls_bt_sm_ioact_2_str(uint8_t ioact);
|
||||
/**********************************/
|
||||
|
||||
extern int tls_bt_util_init(void);
|
||||
extern int tls_bt_util_deinit(void);
|
||||
|
@ -934,7 +934,7 @@ static int factory_atcmd_adc_vol_proc( struct factory_atcmd_token_t *tok, char *
|
||||
if (val & (1 << i))
|
||||
{
|
||||
wm_adc_config(i);
|
||||
voltage[i] = adc_get_inputVolt(i, 1, 1);
|
||||
voltage[i] = adc_get_inputVolt(i);
|
||||
}
|
||||
}
|
||||
*res_len = sprintf(res_resp, "+OK=%d,%d,%d,%d\r\n", voltage[0], voltage[1], voltage[2], voltage[3]);
|
||||
|
Loading…
Reference in New Issue
Block a user