mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2024-11-22 05:54:19 +00:00
update
This commit is contained in:
parent
437e8beb33
commit
25e75da8fd
9 changed files with 70 additions and 12 deletions
|
@ -85,7 +85,7 @@ extern uint32_t SystemCoreClock;
|
|||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_STACK_TCM_HEAP 1 // RTL871xAx/RTL8195Ax Stack priority used TCM HEAP
|
||||
#define configUSE_STACK_TCM_HEAP 5 // RTL871xAx/RTL8195Ax Stack priority used TCM HEAP
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 1
|
||||
#define configUSE_TICK_HOOK 0
|
||||
|
|
55
project/inc/ina219/ina219drv.h
Normal file
55
project/inc/ina219/ina219drv.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/**************************************************************************
|
||||
* Драйвер для INA219
|
||||
**************************************************************************/
|
||||
#ifndef _INA219DRV_H_
|
||||
#define _INA219DRV_H_
|
||||
#include "ina219/ina219.h"
|
||||
#include "device.h"
|
||||
#include "timer_api.h"
|
||||
#include "driver/i2c_drv.h"
|
||||
|
||||
typedef struct _ina219_data {
|
||||
union {
|
||||
signed short voltage; // Voltage, 1mV
|
||||
unsigned char vuc[2];
|
||||
} v;
|
||||
union {
|
||||
signed short current; // Current, 50uA?
|
||||
unsigned char iuc[2];
|
||||
} i;
|
||||
} INA219DATA, *PINA219DATA;
|
||||
|
||||
typedef struct _ina219drv {
|
||||
unsigned char status;
|
||||
unsigned char addr; // адрес INA219 на шине I2C (формат 7 bit)
|
||||
signed char init;
|
||||
unsigned char tmp;
|
||||
|
||||
unsigned short config; // регистр конфигурации INA219
|
||||
unsigned short calibration; // коэф. шунта для INA219
|
||||
|
||||
unsigned short count; // счетчик считанных значений
|
||||
unsigned short overrun; // счет переполнений буфера
|
||||
|
||||
unsigned short errs; // счет ошибок на I2C
|
||||
unsigned short buf_idx; // объем буфера pbuf[buf_idx+1], максимальный индекс-номер замера
|
||||
unsigned short buf_rx; // индекс-номер ещё не считанного замера
|
||||
unsigned short buf_tx; // индекс-номер для записи следующего замера
|
||||
PINA219DATA pbuf;
|
||||
gtimer_t timer;
|
||||
union { // буфер
|
||||
unsigned char uc[4];
|
||||
unsigned short us[2];
|
||||
signed short ss[2];
|
||||
unsigned int ui;
|
||||
} buf_i2c;
|
||||
volatile i2c_drv_t i2c;
|
||||
} INA219DRV, *PINA219DRV;
|
||||
|
||||
|
||||
#define INA219_I2C_PIN_SDA PC_4
|
||||
#define INA219_I2C_PIN_SCL PC_5
|
||||
#define INA219_I2C_BUS_CLK 300000 //hz
|
||||
#define INA219_TIMER TIMER3 // используемый таймер
|
||||
|
||||
#endif // _INA219DRV_H_
|
|
@ -15,7 +15,7 @@
|
|||
#define DEF_WIFI_COUNTRY RTW_COUNTRY_RU // Регион использования WiFi...
|
||||
#define DEF_WIFI_TX_PWR RTW_TX_PWR_PERCENTAGE_25 // RTW_TX_PWR_PERCENTAGE_75 // RTW_TX_PWR_PERCENTAGE_100
|
||||
#define DEF_WIFI_BGN RTW_NETWORK_BGN // rtw_network_mode_t
|
||||
#define DEF_WIFI_ADAPTIVITY RTW_ADAPTIVITY_NORMAL // RTW_ADAPTIVITY_DISABLE/RTW_ADAPTIVITY_NORMAL/RTW_ADAPTIVITY_CARRIER_SENSE
|
||||
#define DEF_WIFI_ADAPTIVITY RTW_ADAPTIVITY_DISABLE // RTW_ADAPTIVITY_NORMAL // RTW_ADAPTIVITY_DISABLE/RTW_ADAPTIVITY_NORMAL/RTW_ADAPTIVITY_CARRIER_SENSE
|
||||
|
||||
/* Опции загрузки конфигов по старту */
|
||||
//#define DEF_LOAD_CFG 0 // старт в назначенном режиме по умолчанию
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
#include "freertos_pmu.h"
|
||||
#include "at_cmd/log_service.h"
|
||||
#include "at_cmd/atcmd_wifi.h"
|
||||
#include <lwip_netconf.h>
|
||||
|
@ -332,17 +333,17 @@ LOCAL void fATSP(int argc, char *argv[])
|
|||
switch (argv[1][0]) {
|
||||
case 'a': // acquire
|
||||
{
|
||||
acquire_wakelock(atoi(argv[2]));
|
||||
pmu_acquire_wakelock(atoi(argv[2]));
|
||||
break;
|
||||
}
|
||||
case 'r': // release
|
||||
{
|
||||
release_wakelock(atoi(argv[2]));
|
||||
pmu_release_wakelock(atoi(argv[2]));
|
||||
break;
|
||||
}
|
||||
};
|
||||
};
|
||||
printf("WakeLock Status %d\n", get_wakelock_status());
|
||||
printf("WakeLock Status %d\n", pmu_get_wakelock_status());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "wifi_conf.h"
|
||||
#include "rtl8195a/rtl_libc.h"
|
||||
#include "hal_platform.h"
|
||||
#include "freertos_pmu.h"
|
||||
|
||||
#include "section_config.h"
|
||||
#include "hal_diag.h"
|
||||
|
@ -226,7 +227,7 @@ LOCAL void fATSF(int argc, char *argv[])
|
|||
|
||||
LOCAL void fATWP(int argc, char *argv[]) {
|
||||
if(argc > 1) {
|
||||
release_wakelock(0xffff);
|
||||
pmu_release_wakelock(0xffff);
|
||||
wifi_set_power_mode(1, 1);
|
||||
wifi_set_lps_dtim(atoi(argv[1]));
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ INA219DRV ina219drv = {
|
|||
INA219_CONFIG_BVOLTAGERANGE_16V | // INA219_CONFIG_BVOLTAGERANGE_32V
|
||||
INA219_CONFIG_GAIN_8_320MV | // INA219_CONFIG_GAIN_1_40MV |
|
||||
INA219_CONFIG_BADCRES_12BIT |
|
||||
INA219_CONFIG_SADCRES_12BIT_2S_1060US | // INA219_CONFIG_SADCRES_12BIT_128S_69MS |
|
||||
INA219_CONFIG_SADCRES_12BIT_1S_532US | //INA219_CONFIG_SADCRES_12BIT_2S_1060US | // INA219_CONFIG_SADCRES_12BIT_1S_532US | //
|
||||
INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS,
|
||||
.calibration = 8192, // при шунте 0.1 Ом
|
||||
.buf_idx = 709, // циклический буфер на 710 замеров (по 4 байт -> sizeof(INA219DATA))
|
||||
|
@ -227,7 +227,7 @@ int ina219_ws(TCP_SERV_CONN *ts_conn, char cmd)
|
|||
};
|
||||
_i2c_init(&p->i2c);
|
||||
gtimer_init(&p->timer, INA219_TIMER);
|
||||
gtimer_start_periodical(&p->timer, 1000, (void*)ina_tick_handler, (uint32_t)&ina219drv);
|
||||
gtimer_start_periodical(&p->timer, 532*2, (void*)ina_tick_handler, (uint32_t)&ina219drv);
|
||||
p->init = 1;
|
||||
// return 0;
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ void ina219_init(void)
|
|||
// Tick every 0.000532 sec (N*532 μs)
|
||||
// uint32 tus = (1 << ((p->config >> 3) & 7));
|
||||
// tus *= 532;
|
||||
gtimer_start_periodical(&p->timer, 1000, (void*)ina_tick_handler, (uint32_t)&ina219drv);
|
||||
gtimer_start_periodical(&p->timer, 532*2, (void*)ina_tick_handler, (uint32_t)&ina219drv);
|
||||
rtl_printf("INA219 Timer Period = %u us\n", p->timer.hal_gtimer_adp.TimerLoadValueUs);
|
||||
p->init = 1;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ void user_init_thrd(void) {
|
|||
webserver_init(syscfg.web_port);
|
||||
|
||||
if(syscfg.cfg.b.powersave_enable) {
|
||||
release_wakelock(~WAKELOCK_WLAN);
|
||||
pmu_release_wakelock(~WAKELOCK_WLAN);
|
||||
}
|
||||
|
||||
// xTaskCreate(x_init_thrd, "wifi_init", 1024, NULL, tskIDLE_PRIORITY + 1 + PRIORITIE_OFFSET, NULL);
|
||||
|
|
|
@ -148,8 +148,8 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *
|
|||
else ifcmp("pinclr") syscfg.cfg.b.pin_clear_cfg_enable = (val)? 1 : 0;
|
||||
else ifcmp("sleep") {
|
||||
syscfg.cfg.b.powersave_enable = (val)? 1 : 0;
|
||||
if(val) release_wakelock(~WAKELOCK_WLAN);
|
||||
else acquire_wakelock(~WAKELOCK_WLAN);
|
||||
if(val) pmu_release_wakelock(~WAKELOCK_WLAN);
|
||||
else pmu_acquire_wakelock(~WAKELOCK_WLAN);
|
||||
}
|
||||
else ifcmp("debug") {
|
||||
syscfg.cfg.b.debug_print_enable = val;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# User defined
|
||||
#=============================================
|
||||
SDK_PATH ?= ../RTL00MP3/RTL00_SDKV35a/
|
||||
#SDK_PATH ?= ../SDKRTLA/USD40a/
|
||||
#GCC_PATH = d:/MCU/GNU_Tools_ARM_Embedded/5.2_2015q4/bin/# + or set in PATH
|
||||
#OPENOCD_PATH = d:/MCU/OpenOCD/bin/# + or set in PATH
|
||||
TOOLS_PATH ?= $(SDK_PATH)component/soc/realtek/8195a/misc/iar_utility/common/tools/
|
||||
|
|
Loading…
Reference in a new issue