diff --git a/USDK/component/common/api/wifi_api.c b/USDK/component/common/api/wifi_api.c index 52c005d..9364126 100644 --- a/USDK/component/common/api/wifi_api.c +++ b/USDK/component/common/api/wifi_api.c @@ -274,7 +274,7 @@ rtw_result_t _wext_enable_powersave(int adapter_num, uint8 ips_mode, uint8 lps_m _adapter * pad = get_padaptern(adapter_num); rtw_result_t ret = RTW_ERROR; if(pad) { - ret = rtw_pm_set_ips(pad, ips_mode); // 2 режима 1,2 ! + ret = rtw_pm_set_ips(pad, ips_mode); // 2 режима 1,2 ? if(ret == RTW_SUCCESS) { LeaveAllPowerSaveMode(pad); ret = rtw_pm_set_lps(pad, lps_mode); @@ -688,7 +688,6 @@ int wifi_run(rtw_mode_t mode) { case RTW_MODE_STA_AP: ret = wifi_run_ap() | wifi_run_st(); // _wext_enable_powersave(0, 0, 0); -// _wext_set_lps_dtim(0, 0); break; case RTW_MODE_STA: ret = wifi_run_st(); diff --git a/USDK/component/common/mbed/targets/hal/rtl8195a/spi_api.c b/USDK/component/common/mbed/targets/hal/rtl8195a/spi_api.c index 1a3fe69..eaef734 100644 --- a/USDK/component/common/mbed/targets/hal/rtl8195a/spi_api.c +++ b/USDK/component/common/mbed/targets/hal/rtl8195a/spi_api.c @@ -64,7 +64,7 @@ void spi_init (spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName sse /* SsiClockDivider doesn't support odd number */ DBG_SSI_INFO("SystemClock: %d\n", SystemGetCpuClk()); - DBG_SSI_INFO("MaxSsiFreq : %d\n", (SystemClock >> 2) >> 1); + DBG_SSI_INFO("MaxSsiFreq : %d\n", (SystemGetCpuClk() >> 2) >> 1); ssi_mosi = pinmap_peripheral(mosi, PinMap_SSI_MOSI); ssi_miso = pinmap_peripheral(miso, PinMap_SSI_MISO); diff --git a/USDK/component/common/video/v4l2/inc/v4l2-dev.h b/USDK/component/common/video/v4l2/inc/v4l2-dev.h index 417eaab..e30bbb9 100644 --- a/USDK/component/common/video/v4l2/inc/v4l2-dev.h +++ b/USDK/component/common/video/v4l2/inc/v4l2-dev.h @@ -80,10 +80,10 @@ struct v4l2_file_operations { //ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); //ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); //unsigned int (*poll) (struct file *, struct poll_table_struct *); - long (*ioctl) (unsigned int, unsigned long); - long (*unlocked_ioctl) (unsigned int, unsigned long); + long (*ioctl) (unsigned int, void *); + long (*unlocked_ioctl) (unsigned int, void *); #ifdef CONFIG_COMPAT - long (*compat_ioctl32) (unsigned int, unsigned long); + long (*compat_ioctl32) (unsigned int, void *); #endif //unsigned long (*get_unmapped_area) (struct file *, unsigned long, // unsigned long, unsigned long, unsigned long); diff --git a/USDK/component/common/video/v4l2/inc/videobuf2-core.h b/USDK/component/common/video/v4l2/inc/videobuf2-core.h index c1db3d7..303c77c 100644 --- a/USDK/component/common/video/v4l2/inc/videobuf2-core.h +++ b/USDK/component/common/video/v4l2/inc/videobuf2-core.h @@ -22,7 +22,7 @@ #include "videodev2.h" -typedef int _LOCK_T; +//typedef int _LOCK_T; struct vb2_alloc_ctx; struct vb2_fileio_data; diff --git a/USDK/component/soc/realtek/8195a/fwlib/rtl8195a/src/rtl8195a_ssi.c b/USDK/component/soc/realtek/8195a/fwlib/rtl8195a/src/rtl8195a_ssi.c index c1c77aa..d896a75 100644 --- a/USDK/component/soc/realtek/8195a/fwlib/rtl8195a/src/rtl8195a_ssi.c +++ b/USDK/component/soc/realtek/8195a/fwlib/rtl8195a/src/rtl8195a_ssi.c @@ -739,7 +739,7 @@ HAL_Status HalSsiIntReadRtl8195a(VOID *Adapter, VOID *RxData, u32 Length) u32 RxFifoThresholdLevel; // u8 Index = pHalSsiAdapter->Index; - DBG_SSI_INFO("HalSsiIntReadRtl8195a: Idx=%d, RxData=0x%x, Len=0x%x\r\n", Index, RxData, Length); + DBG_SSI_INFO("HalSsiIntReadRtl8195a: Idx=%d, RxData=0x%x, Len=0x%x\r\n", pHalSsiAdapter->Index, RxData, Length); // if (HalSsiBusyRtl8195a(Adapter)) { // As a Slave mode, if the peer(Master) side is power off, the BUSY flag is always on // DBG_SSI_WARN("HalSsiIntReadRtl8195a: SSI%d is busy\n", Index); @@ -747,7 +747,7 @@ HAL_Status HalSsiIntReadRtl8195a(VOID *Adapter, VOID *RxData, u32 Length) // } if (Length == 0) { - SSI_DBG_INT_READ("SSI%d RxData addr: 0x%X, Length: %d\n", Index, RxData, Length); + SSI_DBG_INT_READ("SSI%d RxData addr: 0x%X, Length: %d\n", pHalSsiAdapter->Index, RxData, Length); return HAL_ERR_PARA; } @@ -774,7 +774,7 @@ HAL_Status HalSsiIntReadRtl8195a(VOID *Adapter, VOID *RxData, u32 Length) } pHalSsiAdapter->RxData = RxData; - DBG_SSI_INFO("SSI%d RxData addr: 0x%X, Length: %d\n", Index, + DBG_SSI_INFO("SSI%d RxData addr: 0x%X, Length: %d\n", pHalSsiAdapter->Index, pHalSsiAdapter->RxData, pHalSsiAdapter->RxLength); pHalSsiAdapter->InterruptMask |= BIT_IMR_RXFIM | BIT_IMR_RXOIM | BIT_IMR_RXUIM; diff --git a/USDK/component/soc/realtek/8195a/fwlib/src/hal_gpio.c b/USDK/component/soc/realtek/8195a/fwlib/src/hal_gpio.c index 2887654..b683a90 100644 --- a/USDK/component/soc/realtek/8195a/fwlib/src/hal_gpio.c +++ b/USDK/component/soc/realtek/8195a/fwlib/src/hal_gpio.c @@ -108,11 +108,13 @@ HAL_GPIO_Init( GPIO_PullCtrl_8195a(chip_pin, HAL_GPIO_HIGHZ); // HAL_Status ret = - HAL_GPIO_Init_8195a(GPIO_Pin); #if CONFIG_DEBUG_LOG > 3 + HAL_Status ret = HAL_GPIO_Init_8195a(GPIO_Pin); if (ret != HAL_OK) { GpioFunctionChk(chip_pin, DISABLE); } +#else + HAL_GPIO_Init_8195a(GPIO_Pin); #endif } @@ -154,11 +156,14 @@ HAL_GPIO_Irq_Init( GPIO_Pin->pin_mode); HAL_GPIO_MaskIrq_8195a(GPIO_Pin); // HAL_Status ret = - HAL_GPIO_Init_8195a(GPIO_Pin); + #if CONFIG_DEBUG_LOG > 3 + HAL_Status ret = HAL_GPIO_Init_8195a(GPIO_Pin); if (ret != HAL_OK) { GpioFunctionChk(chip_pin, DISABLE); } +#else + HAL_GPIO_Init_8195a(GPIO_Pin); #endif } diff --git a/USDK/component/soc/realtek/common/bsp/section_config.h b/USDK/component/soc/realtek/common/bsp/section_config.h index bc212b1..d461988 100644 --- a/USDK/component/soc/realtek/common/bsp/section_config.h +++ b/USDK/component/soc/realtek/common/bsp/section_config.h @@ -287,6 +287,12 @@ #define SDRAM_DATA_SECTION \ SECTION(".sdram.data") +#if defined(CONFIG_SDR_EN) +#define SDRAM_CODE_SECTION SECTION(".sdram.text") +#else +#define SDRAM_CODE_SECTION +#endif + //3 Wlan Section #define WLAN_ROM_TEXT_SECTION \ SECTION(".wlan.rom.text") diff --git a/USDK/flasher.mk b/USDK/flasher.mk index 4f281d2..444fb02 100644 --- a/USDK/flasher.mk +++ b/USDK/flasher.mk @@ -2,6 +2,7 @@ # pvvx 21.09.2016 include userset.mk include $(SDK_PATH)paths.mk +include project.mk #--------------------------- #FLASHER = stlink-v2-1 #FLASHER = stlink-v2 @@ -113,7 +114,11 @@ reset: @$(JLINK_PATH)$(JLINK_EXE) -Device CORTEX-M3 -If SWD -Speed 1000 $(FLASHER_PATH)RTL_Reset.JLinkScript runram: - @$(JLINK_PATH)$(JLINK_EXE) -Device CORTEX-M3 -If SWD -Speed 1000 $(FLASHER_PATH)RTL_RunRAM.JLinkScript +ifdef USE_SDRAM + $(JLINK_PATH)$(JLINK_EXE) -Device CORTEX-M3 -If SWD -Speed 1000 $(FLASHER_PATH)RTL_RunRAM_SDR.JLinkScript +else + $(JLINK_PATH)$(JLINK_EXE) -Device CORTEX-M3 -If SWD -Speed 1000 $(FLASHER_PATH)RTL_RunRAM.JLinkScript +endif readfullflash: @$(JLINK_PATH)$(JLINK_EXE) -Device CORTEX-M3 -If SWD -Speed 1000 $(FLASHER_PATH)RTL_FFlash.JLinkScript diff --git a/USDK/sdkset.mk b/USDK/sdkset.mk index 23a6c42..8a96605 100644 --- a/USDK/sdkset.mk +++ b/USDK/sdkset.mk @@ -53,7 +53,13 @@ mp: LIBS +=_rtsp _usbh _usbd endif # m c nosys gcc PATHLIBS = sdk/component/soc/realtek/8195a/misc/bsp/lib/common/gcc + +ifdef USE_SDRAM +LDFILE ?= rlx8195A-symbol-v04-img3.ld +else LDFILE ?= rlx8195A-symbol-v04-img2.ld +endif + BOOTS = sdk/component/soc/realtek/8195a/misc/bsp/image # Include folder list @@ -95,11 +101,14 @@ INCLUDES += sdk/component/common/drivers/wlan/realtek/src/hal/OUTSRC INCLUDES += sdk/component/common/drivers/sdio/realtek/sdio_host/inc INCLUDES += sdk/component/soc/realtek/8195a/fwlib/ram_lib/wlan/realtek/wlan_ram_map/rom INCLUDES += sdk/component/common/network/ssl/ssl_ram_map/rom -#INCLUDES += sdk/component/common/media/codec -#INCLUDES += sdk/component/common/drivers/usb_class/host/uvc/inc -#INCLUDES += sdk/component/common/drivers/usb_class/device -#INCLUDES += sdk/component/common/drivers/usb_class/device/class -#INCLUDES += sdk/component/soc/realtek/8195a/fwlib/ram_lib/usb_otg/include +ifdef USE_UVC +INCLUDES += sdk/component/common/media/codec +INCLUDES += sdk/component/common/video/v4l2/inc +INCLUDES += sdk/component/common/drivers/usb_class/host/uvc/inc +INCLUDES += sdk/component/common/drivers/usb_class/device +INCLUDES += sdk/component/common/drivers/usb_class/device/class +INCLUDES += sdk/component/soc/realtek/8195a/fwlib/ram_lib/usb_otg/include +endif # Source file list # ------------------------------------------------------------------- @@ -430,3 +439,4 @@ ADD_SRC_C += sdk/component/common/example/uart_atcmd/example_uart_atcmd.c ADD_SRC_C += sdk/component/common/example/example_entry.c ADD_SRC_C += sdk/component/common/application/xmodem/uart_fw_update.c endif + diff --git a/project.mk b/project.mk index 17fd044..e87d6d8 100644 --- a/project.mk +++ b/project.mk @@ -1,9 +1,10 @@ #============================================= # SDK CONFIG #============================================= -#WEB_INA219_DRV = 1 +WEB_INA219_DRV = 1 #WEB_ADC_DRV = 1 #USE_SDCARD = 1 +#USE_UVC = 1 #USE_AT = 1 #USE_FATFS = 1 #USE_SDIOH = 1 @@ -26,6 +27,11 @@ endif RTOSDIR=freertos_v9.0.0 LWIPDIR=lwip_v1.4.1 +ifdef USE_UVC +USE_SDRAM = 1 +USE_GCC_LIB = 1 +endif + include $(SDK_PATH)sdkset.mk #CFLAGS += -DDEFAULT_BAUDRATE=1562500 CFLAGS += -DLOGUART_STACK_SIZE=1024 @@ -45,8 +51,13 @@ ifdef USE_SDCARD ADD_SRC_C += project/src/console/sd_fat.c endif +ifdef USE_UVC +ADD_SRC_C += project/src/console/uvc_capture_tst.c +endif + ifdef WEB_INA219_DRV ADD_SRC_C += project/src/driver/i2c_drv.c +CFLAGS += -DUSE_I2C_CONSOLE=1 ADD_SRC_C += project/src/ina219/ina219drv.c CFLAGS += -DWEB_INA219_DRV=1 endif @@ -57,6 +68,7 @@ ADD_SRC_C += project/src/adc_ws/adc_ws.c CFLAGS += -DWEB_ADC_DRV=1 endif + #Web-������ INCLUDES += project/inc/web ADD_SRC_C += project/src/tcpsrv/tcp_srv_conn.c @@ -69,3 +81,4 @@ ADD_SRC_C += project/src/web/web_int_callbacks.c ADD_SRC_C += project/src/web/web_int_vars.c ADD_SRC_C += project/src/web/web_auth.c + diff --git a/project/inc/driver/i2c_drv.h b/project/inc/driver/i2c_drv.h index 59a27ad..11d8405 100644 --- a/project/inc/driver/i2c_drv.h +++ b/project/inc/driver/i2c_drv.h @@ -11,22 +11,22 @@ #include "device.h" typedef struct _I2C_HND_ { - signed char status; - unsigned char idx; - unsigned char io_sel; - unsigned char mode; // if(I2C_FIXED_SPEED_MODE != 0) user set -> i2c_mode_e + signed char status; // _i2c_status_e + unsigned char idx; // Номер контроллера I2C + unsigned char io_sel; // Location Index(Pin Mux Selection): S0 -> PC_4, PC_5 + unsigned char mode; // _i2c_mode_e, if(I2C_FIXED_SPEED_MODE != 0) user set -> i2c_mode_e void * base_regs; } i2c_drv_t, *i2c_drv_p; typedef enum { - DRV_I2C_OFF = 0, // IC I2C DeInit + DRV_I2C_OFF = 0, // IC I2C DeInit DRV_I2C_OK = 0, // DRV ret Ok - DRV_I2C_IC_OFF = 1, // IC I2C Off - DRV_I2C_IC_ENABLE = 2, // IC I2C On - DRV_I2C_ERR = -1, // DRV ret err - DRV_I2C_ABORT = -1, // IC I2C Abort - DRV_I2C_TIMEOUT = -3 // IC I2C / DRV ret Timeout + DRV_I2C_IC_OFF = 1, // IC I2C Off + DRV_I2C_IC_ENABLE = 2, // IC I2C On + DRV_I2C_ERR = -1, // DRV ret err + DRV_I2C_ABORT = -1, // IC I2C Abort + DRV_I2C_TIMEOUT = -3 // IC I2C / DRV ret Timeout } _i2c_status_e; diff --git a/project/src/console/atcmd_user.c b/project/src/console/atcmd_user.c index 784adbb..3debf5a 100644 --- a/project/src/console/atcmd_user.c +++ b/project/src/console/atcmd_user.c @@ -112,6 +112,9 @@ static void copy_align4_to_align1(unsigned char * pd, void * ps, unsigned int le // return size; } */ +/* + * int print_hex_dump(uint8_t *buf, int len, unsigned char k) + */ int print_hex_dump(uint8_t *buf, int len, unsigned char k) { uint32_t ss[2]; ss[0] = 0x78323025; // "%02x" diff --git a/project/src/driver/i2c_drv.c b/project/src/driver/i2c_drv.c index 3acc3ee..cf66257 100644 --- a/project/src/driver/i2c_drv.c +++ b/project/src/driver/i2c_drv.c @@ -88,7 +88,7 @@ LOCAL int i2c_ready(i2c_drv_t *pi2c, unsigned char flg) if(i2c_reg(REG_DW_I2C_IC_RAW_INTR_STAT) & BIT_IC_RAW_INTR_STAT_TX_ABRT) { error_printf("I2C%d Abort!\n", pi2c->idx); // Clear abort status. - i2c_reg(REG_DW_I2C_IC_CLR_TX_ABRT); + (volatile uint32)i2c_reg(REG_DW_I2C_IC_CLR_TX_ABRT); // Be sure that all interrupts flag are cleared. // i2c_reg(REG_DW_I2C_IC_CLR_INTR); pi2c->status = DRV_I2C_ABORT; @@ -131,7 +131,7 @@ int _i2c_break(i2c_drv_t *pi2c) }; pi2c->status = DRV_I2C_OFF; // All interrupts flag are cleared. - i2c_reg(REG_DW_I2C_IC_CLR_INTR); + (volatile uint32)i2c_reg(REG_DW_I2C_IC_CLR_INTR); return DRV_I2C_OK; } @@ -226,7 +226,7 @@ LOCAL int i2c_enable(i2c_drv_t *pi2c) }; }; // Be sure that all interrupts flag are cleared. - i2c_reg(REG_DW_I2C_IC_CLR_INTR); + (volatile uint32)i2c_reg(REG_DW_I2C_IC_CLR_INTR); pi2c->status = DRV_I2C_IC_ENABLE; return DRV_I2C_OK; } @@ -433,7 +433,7 @@ int _i2c_read(i2c_drv_t *pi2c, uint32 address, const char *data, int length, int *d++ = i2c_reg(REG_DW_I2C_IC_DATA_CMD); length--; } - else i2c_reg(REG_DW_I2C_IC_DATA_CMD); + else (volatile uint32)i2c_reg(REG_DW_I2C_IC_DATA_CMD); }; } while(length) { @@ -450,4 +450,121 @@ int _i2c_read(i2c_drv_t *pi2c, uint32 address, const char *data, int length, int return DRV_I2C_OK; } +#if defined(USE_I2C_CONSOLE) && USE_I2C_CONSOLE +//extern void dump_bytes(uint32 addr, int size); +extern int print_hex_dump(uint8_t *buf, int len, unsigned char k); +extern uint32 hextoul(uint8 *s); + +i2c_drv_t ti2c; +/* I2C Init: + * ati2c i [sda_pin [scl_pin [mode [speed]]]] + * I2C Deinit: + * ati2c d + * I2C Write: + * iati2c W address data1 [data2 ... [data8]...] + * I2C write + stop: + * iati2c w address data1 [data2 ... [data8]...] + * I2C Read: + * ati2c R address count + * I2C read + stop: + * ati2c r address count + */ +LOCAL void fATI2C(int argc, char *argv[]) +{ + i2c_drv_t *pi2c = &ti2c; + uint8 buf[32]; + if(argc > 1) { + if(argv[1][0] == 'i') { + // + if(!pi2c->status) { + uint8 sda = 0; + uint8 scl = 0; + uint8 mode = 0; + uint32 speed = 0; + if(argc > 2) sda = hextoul(argv[2]); + else if(argc > 3) scl = hextoul(argv[3]); + else if(argc > 4) mode = hextoul(argv[4]); + else if(argc > 5) speed = hextoul(argv[5]); + if(!sda) sda = PC_4; + if(!scl) scl = PC_5; + if(!mode) mode = DRV_I2C_FS_MODE; + if(!speed) speed = 50000; + if(_i2c_setup(pi2c, sda, scl, mode) == DRV_I2C_OK + && _i2c_init(pi2c) == DRV_I2C_OK + && _i2c_set_speed(pi2c, speed) == DRV_I2C_OK) { + rtl_printf("I2C%d Init: %02x %02x %02x %08x\n", pi2c->idx, sda, scl, mode, speed); + }; + } else { + rtl_printf("Already init!\n"); + return; + }; + } else if(argv[1][0] == '?') { + rtl_printf("I2C Init:\n\tati2c i [sda_pin [scl_pin [mode [speed]]]]\n"); + rtl_printf("I2C Deinit:\n\tati2c d\n"); + rtl_printf("I2C Write:\n\tati2c W address data1 [data2 ... [data8]...]\n"); + rtl_printf("I2C write + stop:\n\tati2c w address data1 [data2 ... [data8]...]\n"); + rtl_printf("I2C Read:\n\tati2c R address count\n"); + rtl_printf("I2C read + stop:\n\tati2c r address count\n"); + rtl_printf("I2C get:\n\tati2c g address wrcount wrdata1 [..wrdata6] rdcount\n"); + } else { + if(pi2c->status) { + if(argv[1][0] == 'd') { + _i2c_ic_off(pi2c); + rtl_printf("I2C%d DeInit\n", pi2c->idx); + return; + }; + int i; + for(i = 0; i + 2 < argc; i++) { + buf[i] = hextoul(argv[i+2]); + }; + if(i) { + if(argv[1][0] == 'w' || argv[1][0] == 'W') { + // >ati2c w 40 2 + // I2C1 write[1]: 40 02 00 + // I2C1 drvStatus = 1 + _i2c_write(pi2c, buf[0], &buf[1], i-1, argv[1][0] == 'w'); + rtl_printf("I2C%d write[%d]: ", pi2c->idx, i-1); + print_hex_dump(buf, i, ' '); + rtl_printf("\n"); + } else if(argv[1][0] == 'r' || argv[1][0] == 'R') { + // >ati2c r 40 2 + // I2C1 read[2]: 40 07 d8 + // I2C1 drvStatus = 1 + i = buf[1]; + if(i > sizeof(buf) - 1) i = sizeof(buf) - 1; + _i2c_read(pi2c, buf[0], &buf[1], i, argv[1][0] == 'r'); + rtl_printf("I2C%d read[%d]: ", pi2c->idx, i); + print_hex_dump(buf, i+1, ' '); + rtl_printf("\n"); + } else if(argv[1][0] == 'g') { + // >ati2c g 5a 1 6 3 + // I2C1 get[3]: 5a 5e 3a 6c + // I2C1 drvStatus = 1 + if (argc < 5 || buf[1] == 0 || buf[1] > sizeof(buf) - 2) { + rtl_printf("Error command string!\n"); + return; + } + if(_i2c_write(pi2c, buf[0], &buf[2], buf[1], 0) >= 0) { + i = buf[buf[1] + 2]; // кол-во байт чтения + if(i == 0 || i > sizeof(buf) - 1) i = sizeof(buf) - 1; + _i2c_read(pi2c, buf[0], &buf[1], i, 1); + rtl_printf("I2C%d get[%d]: ", pi2c->idx, i); + print_hex_dump(buf, i+1, ' '); + } + rtl_printf("\n"); + }; + }; + }; + }; + }; + rtl_printf("I2C%d Status = %d\n", pi2c->idx, pi2c->status); + return; +} + +MON_RAM_TAB_SECTION COMMAND_TABLE console_commands_i2c[] = { + {"ATI2C", 0, fATI2C, ": Test I2C, nit, einit, rite, ead"}, +}; +#endif // USE_I2C_CONSOLE + + #endif // CONFIG_I2C_EN diff --git a/project/src/ina219/ina219buf.c b/project/src/ina219/ina219buf.c index ee1aebf..f091839 100644 --- a/project/src/ina219/ina219buf.c +++ b/project/src/ina219/ina219buf.c @@ -127,6 +127,7 @@ void ina219_init(void) p->count = 0; p->errs = 0; // (!) Установки драйвера I2C заданы в структуре ina219drv +// rtl_printf("INA219 control reg = 0x%04x\n", p->config); // _i2c_setup(&p->i2c, INA219_I2C_PIN_SDA , INA219_I2C_PIN_SCL, DRV_I2C_FS_MODE); // == DRV_I2C_OK? _i2c_init(&p->i2c); // _i2c_set_speed(&p->i2c, INA219_I2C_BUS_CLK); @@ -137,10 +138,10 @@ void ina219_init(void) // Initial a periodical timer gtimer_init(&p->timer, INA219_TIMER); // Tick every 0.000532 sec (N*532 μs) - uint32 tus = (1 << ((p->config >> 3) & 7)); + uint32 tus = 1 << ((p->config >> 3) & 7); tus *= 532; - gtimer_start_periodical(&p->timer, tus, (void*)ina_tick_handler, (uint32_t)&ina219drv); rtl_printf("INA219 Read Period = %u us\n", tus); + gtimer_start_periodical(&p->timer, tus, (void*)ina_tick_handler, (uint32_t)&ina219drv); p->init = 1; } } diff --git a/project/src/ina219/ina219drv.c b/project/src/ina219/ina219drv.c index f8a2ec5..cfffa8d 100644 --- a/project/src/ina219/ina219drv.c +++ b/project/src/ina219/ina219drv.c @@ -103,7 +103,7 @@ void ina_tick_handler(void *par) { break; case 4: if (i2c_reg(REG_DW_I2C_IC_RAW_INTR_STAT) & BIT_IC_RAW_INTR_STAT_TX_ABRT) { - i2c_reg(REG_DW_I2C_IC_CLR_INTR); + (volatile uint32)i2c_reg(REG_DW_I2C_IC_CLR_INTR); p->errs++; p->status = 0; break; @@ -123,10 +123,10 @@ void ina_tick_handler(void *par) { else p->buf_rx++; }; } else { - i2c_reg(REG_DW_I2C_IC_DATA_CMD); - i2c_reg(REG_DW_I2C_IC_DATA_CMD); - i2c_reg(REG_DW_I2C_IC_DATA_CMD); - i2c_reg(REG_DW_I2C_IC_DATA_CMD); + (volatile uint32)i2c_reg(REG_DW_I2C_IC_DATA_CMD); + (volatile uint32)i2c_reg(REG_DW_I2C_IC_DATA_CMD); + (volatile uint32)i2c_reg(REG_DW_I2C_IC_DATA_CMD); + (volatile uint32)i2c_reg(REG_DW_I2C_IC_DATA_CMD); }; } case 3: @@ -279,8 +279,9 @@ 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, 532*2, (void*)ina_tick_handler, (uint32_t)&ina219drv); - rtl_printf("INA219 Timer Period = %u us\n", p->timer.hal_gtimer_adp.TimerLoadValueUs); + uint32 tus = 532*2; + gtimer_start_periodical(&p->timer, tus, (void*)ina_tick_handler, (uint32_t)&ina219drv); + rtl_printf("INA219 Timer Period = %u us\n", tus); p->init = 1; } } @@ -340,94 +341,7 @@ LOCAL void fATINA(int argc, char *argv[]) ShowIna(); } - -extern void dump_bytes(uint32 addr, int size); -extern uint32 hextoul(uint8 *s); - -i2c_drv_t ti2c; -/* Sample: - * ati2c i - * ati2c w 40 5 - * ati2c r 40 2 - */ -LOCAL void fATI2C(int argc, char *argv[]) -{ - i2c_drv_t *pi2c = &ti2c; - uint8 buf[32]; - if(argc > 1) { - if(argv[1][0] == 'i') { - if(!pi2c->status) { - uint8 sda = 0; - uint8 scl = 0; - uint8 mode = 0; - uint32 speed = 0; - if(argc > 2) sda = hextoul(argv[2]); - else if(argc > 3) scl = hextoul(argv[3]); - else if(argc > 4) mode = hextoul(argv[4]); - else if(argc > 5) speed = hextoul(argv[5]); - if(!sda) sda = PC_4; - if(!scl) scl = PC_5; - if(!mode) mode = DRV_I2C_FS_MODE; - if(!speed) speed = 400000; - if(_i2c_setup(pi2c, sda, scl, mode) == DRV_I2C_OK - && _i2c_init(pi2c) == DRV_I2C_OK - && _i2c_set_speed(pi2c, speed) == DRV_I2C_OK) { - rtl_printf("I2C%d Init\n", pi2c->idx); - }; - } else { - rtl_printf("Already init!\n"); - return; - }; - } else { - if(pi2c->status) { - if(argv[1][0] == 'd') { - _i2c_ic_off(pi2c); - rtl_printf("I2C%d DeInit\n", pi2c->idx); - return; - }; - int i; - for(i = 0; i + 2 < argc; i++) { - buf[i] = hextoul(argv[i+2]); - }; - if(i) { - if(argv[1][0] == 'w') { - _i2c_write(pi2c, buf[0], &buf[1], i-1, 1); - rtl_printf("I2C%d write[%d]:\n", pi2c->idx, i-1); - dump_bytes((uint32)&buf[0], i); - } - else if(argv[1][0] == 'r') { - i = buf[1]; - if(i > sizeof(buf) - 1) i = sizeof(buf) - 1; - _i2c_read(pi2c, buf[0], &buf[1], i, 1); - rtl_printf("I2C%d read[%d]:\n", pi2c->idx, i); - dump_bytes((uint32)&buf[0], i+1); - }; - - }; - }; - }; - }; - rtl_printf("I2C%d drvStatus = %d\n", pi2c->idx, pi2c->status); - return; -} - -LOCAL void fATLED(int argc, char *argv[]) -{ - if(argc > 1) { - EGTIM_FCTRL(1); - EGTIM_RSIG_SEL(atoi(argv[1])); - EGTIME_PIN_G0_OPT_SEL(atoi(argv[2])); - EGTIME_PIN_G1_OPT_SEL(atoi(argv[3])); - EGTIME_PIN_G1_OPT_SEL(atoi(argv[4])); - } - else { - EGTIM_FCTRL(0); - } -} - MON_RAM_TAB_SECTION COMMAND_TABLE console_commands_ina219[] = { - {"ATLED", 0, fATLED, ": Test LED"}, - {"ATI2C", 0, fATI2C, ": Test I2C, nit, einit, rite, ead"}, {"ATINA", 0, fATINA, "=[0/1]: INA219 =1 start, =0 stop"} }; diff --git a/project/src/tcpsrv/tcp_srv_conn.c b/project/src/tcpsrv/tcp_srv_conn.c index 4d97816..b49614d 100644 --- a/project/src/tcpsrv/tcp_srv_conn.c +++ b/project/src/tcpsrv/tcp_srv_conn.c @@ -19,8 +19,10 @@ #include "esp_comp.h" #ifdef CONFIG_DEBUG_LOG +#undef DEBUGSOO #define DEBUGSOO 2 // уровень вывода отладочной инфы по умолчанию = 2, =1 только error #else +#undef DEBUGSOO #define DEBUGSOO 0 #endif // Lwip funcs - http://www.ecoscentric.com/ecospro/doc/html/ref/lwip.html