This commit is contained in:
pvvx 2017-09-22 10:44:42 +03:00
parent 9ffd9dac1a
commit eac35630e6
31 changed files with 185 additions and 130 deletions

View file

@ -157,13 +157,22 @@
// //
// memory management // memory management
// //
#ifndef CONFIG_MBED_ENABLED #undef malloc
extern void *pvPortMalloc(size_t xWantedSize); extern void *pvPortMalloc(size_t xWantedSize);
extern void vPortFree( void *pv );
#define malloc pvPortMalloc #define malloc pvPortMalloc
#undef zalloc
extern void *pvPortZalloc(size_t xWantedSize);
#define zalloc pvPortZalloc #define zalloc pvPortZalloc
#undef realloc
extern void *pvPortReAlloc(void *pv, size_t xWantedSize);
#define realloc pvPortReAlloc
#undef free
extern void vPortFree(void *pv);
#define free vPortFree #define free vPortFree
#endif
#elif defined (CONFIG_PLATFORM_8711B) #elif defined (CONFIG_PLATFORM_8711B)
#if defined (__IARSTDLIB__) #if defined (__IARSTDLIB__)

View file

@ -19,9 +19,8 @@
extern void _promisc_deinit(_adapter *padapter); extern void _promisc_deinit(_adapter *padapter);
extern int _promisc_recv_func(_adapter *padapter, recv_frame *rframe); extern int _promisc_recv_func(_adapter *padapter, recv_frame *rframe);
extern int _promisc_set(rtw_rcr_level_t enabled, void (*callback)(unsigned char *, unsigned int, void *), unsigned char len_used); extern int _promisc_set(rtw_rcr_level_t enabled, void (*callback)(unsigned char *, unsigned int, void *), unsigned char len_used);
extern unsigned char is_promisc_enabled(void); extern unsigned char _is_promisc_enabled(void);
extern int promisc_get_fixed_channel(void *fixed_bssid, unsigned char *ssid, int *ssid_length); extern int _promisc_get_fixed_channel(void *fixed_bssid, unsigned char *ssid, int *ssid_length);
extern unsigned char is_promisc_enabled(void);
#endif #endif

View file

@ -127,7 +127,7 @@ LOCAL int _wifi_scan_networks(rtw_scan_result_handler_t results_handler) {
pscan_rec->user_data = NULL; pscan_rec->user_data = NULL;
wifi_reg_event_handler(WIFI_EVENT_SCAN_RESULT_REPORT, wifi_scan_each_report_hdl, NULL); wifi_reg_event_handler(WIFI_EVENT_SCAN_RESULT_REPORT, wifi_scan_each_report_hdl, NULL);
wifi_reg_event_handler(WIFI_EVENT_SCAN_DONE, _wifi_scan_done_hdl, NULL); wifi_reg_event_handler(WIFI_EVENT_SCAN_DONE, _wifi_scan_done_hdl, NULL);
if(wext_set_scan(WLAN0_NAME, NULL, 0, RTW_SCAN_TYPE_ACTIVE | (RTW_SCAN_COMMAMD << 4) | (RTW_BSS_TYPE_ANY << 8)) == RTW_SUCCESS) { if(wext_set_scan(WLAN0_NAME, NULL, 0, RTW_SCAN_TYPE_ACTIVE | (RTW_SCAN_COMMAMD << 4) | (RTW_BSS_TYPE_ANY << 8)) == RTW_SUCCESS) { // Только RTW_SCAN_TYPE_ACTIVE ?
return RTW_SUCCESS; return RTW_SUCCESS;
} }
}; };

View file

@ -109,7 +109,7 @@ SD_RESULT SD_GetCapacity(uint32_t *sector_count) {
//----- SD_ReadBlocks //----- SD_ReadBlocks
SD_RESULT SD_ReadBlocks(u32 sector, u8 *data, u32 count) { SD_RESULT SD_ReadBlocks(u32 sector, u8 *data, u32 count) {
int rd_count; int rd_count = 0;
unsigned char * buf; unsigned char * buf;
if ((u32) data & 3) { if ((u32) data & 3) {
@ -145,7 +145,7 @@ SD_RESULT SD_ReadBlocks(u32 sector, u8 *data, u32 count) {
//----- SD_WriteBlocks //----- SD_WriteBlocks
SD_RESULT SD_WriteBlocks(u32 sector, const u8 *data, u32 count) { SD_RESULT SD_WriteBlocks(u32 sector, const u8 *data, u32 count) {
int wr_count; int wr_count = 0;
unsigned char * buf; unsigned char * buf;
if ((u32) data & 3) { if ((u32) data & 3) {

View file

@ -186,7 +186,7 @@ s8 sdio_write_blocks(uint32_t sector, const uint8_t *buffer, uint32_t count) {
rtl_memset(gAdmaTbls, 0, sizeof(ADMA2_DESC_FMT) * count); rtl_memset(gAdmaTbls, 0, sizeof(ADMA2_DESC_FMT) * count);
if (1) { if (1) {
ADMA2_DESC_FMT *p = gAdmaTbls; ADMA2_DESC_FMT *p = gAdmaTbls;
u8 * pbuf = buffer; u8 * pbuf = (u8 *)buffer;
int i = 0; int i = 0;
while (i < count) { while (i < count) {
i++; i++;
@ -255,14 +255,14 @@ s8 sdio_sd_setClock(SD_CLK_FREQUENCY SDCLK) {
if (sdio_status <= SDIO_SD_NONE) { if (sdio_status <= SDIO_SD_NONE) {
return -1; return -1;
} }
ADMA2_DESC_FMT * padma = rtw_zmalloc(sizeof(ADMA2_DESC_FMT)); ADMA2_DESC_FMT * padma = (ADMA2_DESC_FMT *) rtw_zmalloc(sizeof(ADMA2_DESC_FMT));
if (!padma) { if (!padma) {
DBG_SDIO_ERR("Malloc ADMA2 table fail.\n"); DBG_SDIO_ERR("Malloc ADMA2 table fail.\n");
return -1; return -1;
} }
DBG_SDIO_INFO("SD card set CLK %d Hz\n", PLATFORM_CLOCK/(2 << (SD_CLK_41_6MHZ - SDCLK))); DBG_SDIO_INFO("SD card set CLK %d Hz\n", PLATFORM_CLOCK/(2 << (SD_CLK_41_6MHZ - SDCLK)));
sta = HalSdioHostOp.HalSdioHostChangeSdClock(&SdioHostAdapter, SDCLK); sta = HalSdioHostOp.HalSdioHostChangeSdClock(&SdioHostAdapter, SDCLK);
rtw_mfree(padma, sizeof(ADMA2_DESC_FMT)); rtw_mfree((u8 *)padma, sizeof(ADMA2_DESC_FMT));
if (sta) if (sta)
return -1; return -1;
return 0; return 0;
@ -296,11 +296,10 @@ s8 sdio_sd_setProtection(bool protection) {
} }
LABEL_8: LABEL_8:
sd_protected = protection; sd_protected = protection;
LABEL_7:
DBG_SDIO_INFO("Set SD card Protection done.\n"); DBG_SDIO_INFO("Set SD card Protection done.\n");
result = 0; result = 0;
LABEL_17: LABEL_17:
rtw_mfree(padma, sizeof(ADMA2_DESC_FMT)); rtw_mfree((u8 *)padma, sizeof(ADMA2_DESC_FMT));
return result; return result;
} }
return -1; return -1;

View file

@ -6,12 +6,11 @@
* This module is a confidential and proprietary property of RealTek and * This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek. * possession or use of this module requires written permission of RealTek.
*/ */
#include "integer.h" //#if FATFS_DISK_SD
#include <disk_if/inc/sdcard.h>
#if FATFS_DISK_SD
#include "sd.h" // sd card driver with sdio interface #include "sd.h" // sd card driver with sdio interface
#include "integer.h"
#include <disk_if/inc/sdcard.h>
#define SD_BLOCK_SIZE 512 #define SD_BLOCK_SIZE 512
@ -66,7 +65,6 @@ DRESULT SD_disk_write(const BYTE *buff, DWORD sector, UINT count){
DRESULT SD_disk_ioctl (BYTE cmd, void* buff){ DRESULT SD_disk_ioctl (BYTE cmd, void* buff){
DRESULT res = RES_ERROR; DRESULT res = RES_ERROR;
SD_RESULT result; SD_RESULT result;
DWORD last_blk_addr, block_size;
switch(cmd){ switch(cmd){
/* Generic command (used by FatFs) */ /* Generic command (used by FatFs) */
@ -118,6 +116,7 @@ DRESULT SD_disk_ioctl (BYTE cmd, void* buff){
} }
#endif #endif
ll_diskio_drv SD_disk_Driver = { ll_diskio_drv SD_disk_Driver = {
.disk_initialize = SD_disk_initialize, .disk_initialize = SD_disk_initialize,
.disk_status = SD_disk_status, .disk_status = SD_disk_status,
@ -130,4 +129,5 @@ ll_diskio_drv SD_disk_Driver ={
#endif #endif
.TAG = "SD" .TAG = "SD"
}; };
#endif
//#endif // FATFS_DISK_SD

View file

@ -335,6 +335,7 @@ int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) #define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -87,7 +87,7 @@ DRESULT disk_write (
) )
{ {
DRESULT res = RES_PARERR; DRESULT res = RES_PARERR;
int index = 0; // int index = 0;
if (pdrv < 0 || pdrv >= disk.nbr || buff == (void*)0 || count <= 0) if (pdrv < 0 || pdrv >= disk.nbr || buff == (void*)0 || count <= 0)
return RES_PARERR; // Return if the parameter is invalid return RES_PARERR; // Return if the parameter is invalid

View file

@ -119,8 +119,6 @@
#include "diskio.h" /* Declarations of disk I/O functions */ #include "diskio.h" /* Declarations of disk I/O functions */
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
Module Private Definitions Module Private Definitions
@ -595,9 +593,14 @@ int mem_cmp (const void* dst, const void* src, UINT cnt) {
return r; return r;
} }
#else #else
#define mem_cpy memcpy typedef unsigned int size_t;
#define mem_set memset extern int rtl_memcmp(const void * m1 , const void * m2 , size_t n);
#define mem_cmp memcmp extern void * rtl_memcpy(void * dst0 , const void * src0 , size_t len0);
extern void * rtl_memset(void * m , int c , size_t n);
#define mem_cpy rtl_memcpy
#define mem_set rtl_memset
#define mem_cmp rtl_memcmp
#endif #endif
/* Check if chr is contained in the string */ /* Check if chr is contained in the string */

View file

@ -167,7 +167,7 @@ void sys_adc_calibration(u8 write, u16 *offset, u16 *gain)
extern flash_t flash; extern flash_t flash;
if(write){ if(write){
// backup // backup
u8 *pbuf = RtlMalloc(FLASH_SECTOR_SIZE); u8 *pbuf = malloc(FLASH_SECTOR_SIZE);
if(!pbuf) return; if(!pbuf) return;
device_mutex_lock(RT_DEV_LOCK_FLASH); device_mutex_lock(RT_DEV_LOCK_FLASH);
flash_stream_read(&flash, FLASH_SYSTEM_DATA_ADDR, FLASH_SECTOR_SIZE, pbuf); flash_stream_read(&flash, FLASH_SYSTEM_DATA_ADDR, FLASH_SECTOR_SIZE, pbuf);
@ -180,7 +180,7 @@ extern flash_t flash;
flash_erase_sector(&flash, FLASH_SYSTEM_DATA_ADDR); flash_erase_sector(&flash, FLASH_SYSTEM_DATA_ADDR);
flash_stream_write(&flash, FLASH_SYSTEM_DATA_ADDR, FLASH_SECTOR_SIZE, pbuf); flash_stream_write(&flash, FLASH_SYSTEM_DATA_ADDR, FLASH_SECTOR_SIZE, pbuf);
device_mutex_unlock(RT_DEV_LOCK_FLASH); device_mutex_unlock(RT_DEV_LOCK_FLASH);
RtlMfree(pbuf, FLASH_SECTOR_SIZE); free(pbuf);
printf("Store ADC calibration success.\n"); printf("Store ADC calibration success.\n");
} }
device_mutex_lock(RT_DEV_LOCK_FLASH); device_mutex_lock(RT_DEV_LOCK_FLASH);

View file

@ -98,6 +98,7 @@ struct stream_context
#define RTP_PT_H263 34 #define RTP_PT_H263 34
#define RTP_PT_RTCP_BASE 72 #define RTP_PT_RTCP_BASE 72
#define RTP_PT_DYN_BASE 96 #define RTP_PT_DYN_BASE 96
#undef RTP_PT_UNKNOWN
#define RTP_PT_UNKNOWN -1 #define RTP_PT_UNKNOWN -1
#include "section_config.h" #include "section_config.h"

View file

@ -291,7 +291,7 @@
/* /*
* combine the four dirtypenrsize parameters to one cmd parameter * combine the four dir<EFBFBD>Atype<EFBFBD>Anr<EFBFBD>Asize parameters to one cmd parameter
* *
*/ */
#ifndef _IOC #ifndef _IOC
@ -511,40 +511,40 @@ found:
static inline unsigned long find_next_zero_bit( static inline unsigned long find_next_zero_bit(
const unsigned long *addr,unsigned long size, unsigned long offset) const unsigned long *addr,unsigned long size, unsigned long offset)
{ {
const unsigned long *p = addr + BIT_WORD(offset); // offset位于p指向的long地址32位空? const unsigned long *p = addr + BIT_WORD(offset); // offset<EFBFBD><EFBFBD>_p<EFBFBD><EFBFBD><EFBFBD>V<EFBFBD><EFBFBD>long<EFBFBD>a<EFBFBD>}32<33><32><EFBFBD>?
unsigned long result = offset & ~(BITS_PER_LONG-1); // offset是第result?4字? unsigned long result = offset & ~(BITS_PER_LONG-1); // offset<EFBFBD>O<EFBFBD><EFBFBD>result?4<>r?
unsigned long tmp; unsigned long tmp;
if (offset >= size) if (offset >= size)
return size; return size;
size -= result; // ?整32位整倍?上 size -= result; // ?<EFBFBD><EFBFBD>32<EFBFBD><EFBFBD>㭿?<3F>W
offset %= BITS_PER_LONG; // offset位于32位的第几位 offset %= BITS_PER_LONG; // offset<EFBFBD><EFBFBD>_32<EFBFBD><EFBFBD>ĤL<EFBFBD><EFBFBD>
if (offset) { // offset不在一?long?据的第0位上,在1-31位中[luther.gliethttp] if (offset) { // offset<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>@?long?<3F>u<EFBFBD><75><EFBFBD><EFBFBD>0<EFBFBD><30>W,<2C>b1-31<33>[luther.gliethttp]
tmp = *(p++); tmp = *(p++);
tmp |= ~0UL >> (BITS_PER_LONG - offset); // ?0-offset?据填充上1. tmp |= ~0UL >> (BITS_PER_LONG - offset); // ?0-offset?<EFBFBD>u<EFBFBD><EFBFBD>R<EFBFBD>W1.
if (size < BITS_PER_LONG) // 不足32bits if (size < BITS_PER_LONG) // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>32bits
goto found_first; goto found_first;
if (~tmp) // 取非非0?明含有0值 if (~tmp) // <EFBFBD><EFBFBD><EFBFBD>D<EFBFBD>D0?<3F><><EFBFBD>t<EFBFBD><74>0<EFBFBD><30>
goto found_middle; goto found_middle;
size -= BITS_PER_LONG; // 如果上面~tmp等于0,那么?明?*p?据?32位全1.[luther.gliethttp] size -= BITS_PER_LONG; // <EFBFBD>p<EFBFBD>G<EFBFBD>W<EFBFBD><EFBFBD>~tmp<6D><70><EFBFBD>_0,<2C><><EFBFBD>\?<3F><>?*p?<3F>u?32<33><32><EFBFBD>1.[luther.gliethttp]
result += BITS_PER_LONG; result += BITS_PER_LONG;
} }
while (size & ~(BITS_PER_LONG-1)) { // 好了,?行到?里,我?的offset已??在4字?的第0位上,下面?行 while (size & ~(BITS_PER_LONG-1)) { // <EFBFBD>n<EFBFBD>F,?<3F><><EFBFBD>?<3F><>,<2C><>?<3F><>offset<65>w??<3F>b4<62>r?<3F><><EFBFBD><EFBFBD>0<EFBFBD><30>W,<2C>U<EFBFBD><55>?<3F><>
if (~(tmp = *(p++))) // 4字?快速查?.如果~tmp非0,?明?32位?据中含有0?据,找到.[luther.gliethttp] if (~(tmp = *(p++))) // 4<EFBFBD>r?<3F>ֳt<D6B3>d?.<2E>p<EFBFBD>G~tmp<6D>D0,?<3F><>?32<33><32>?<3F>u<EFBFBD><75><EFBFBD>t<EFBFBD><74>0?<3F>u,<2C><><EFBFBD>.[luther.gliethttp]
goto found_middle; goto found_middle;
result += BITS_PER_LONG; // 到下一?4字?空? result += BITS_PER_LONG; // <EFBFBD><EFBFBD>U<EFBFBD>@?4<>r?<3F><>?
size -= BITS_PER_LONG; // ?少4字??据 size -= BITS_PER_LONG; // ?<EFBFBD><EFBFBD>4<EFBFBD>r??<3F>u
} }
if (!size) // size等于0,?明首先size等于4字?整倍?,其次所有?据已?查完, if (!size) // size<EFBFBD><EFBFBD><EFBFBD>_0,?<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>size<7A><65><EFBFBD>_4<5F>r?<3F>㭿?,<2C><EFBFBD>Ҧ<EFBFBD>?<3F>u<EFBFBD>w?<3F>d<EFBFBD><64>,
return result; // 所有?据全部?1,?有??0位,result等于size.[luther.gliethttp] return result; // <EFBFBD>Ҧ<EFBFBD>?<3F>u<EFBFBD><75><EFBFBD><EFBFBD>?1,?<3F><>??0<><30>,result<6C><74><EFBFBD>_size.[luther.gliethttp]
tmp = *p; // size不是32位整倍?,?剩几?bit?有?查,???行下面?查工作.[luther.gliethtp] tmp = *p; // size<EFBFBD><EFBFBD><EFBFBD>O32<EFBFBD><EFBFBD>㭿?,?<3F>ѤL?bit?<3F><>?<3F>d,???<3F><>U<EFBFBD><55>?<3F>d<EFBFBD>u<EFBFBD>@.[luther.gliethtp]
found_first: found_first:
tmp |= ~0UL << size; // ?在0-size?有效?据,size-31?未使用空?,所以先?size-31置成全1. tmp |= ~0UL << size; // ?<EFBFBD>b0-size?<3F><><EFBFBD><EFBFBD>?<3F>u,size-31?<3F><><EFBFBD>ϥΪ<CFA5>?,<2C>ҥH<D2A5><48>?size-31<33>m<EFBFBD><6D><EFBFBD><EFBFBD>1.
if (tmp == ~0UL) /* Are any bits zero? */ // 如果tmp全1,那么?明就?找找1? if (tmp == ~0UL) /* Are any bits zero? */ // <EFBFBD>p<EFBFBD>Gtmp<EFBFBD><EFBFBD>1,<2C><><EFBFBD>\?<3F><><EFBFBD>N?<3F><><EFBFBD>1?
return result + size; /* Nope. */ // result+size就等于函??入的??size大小.[luther.gliethttp] return result + size; /* Nope. */ // result+size<EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><EFBFBD>??<3F>J<EFBFBD><4A>??size<7A>j<EFBFBD>p.[luther.gliethttp]
found_middle: found_middle:
return result + ffz(tmp); // 我?在32位?据的0-31中??必定存在0位值,?算他是第几位.[luther.gliethttp] return result + ffz(tmp); // <EFBFBD><EFBFBD>?<3F>b32<33><32>?<3F>u<EFBFBD><75>0-31<33><31>??<3F><><EFBFBD>w<EFBFBD>s<EFBFBD>b0<62><30><EFBFBD>,?<3F><>L<EFBFBD>O<EFBFBD>ĤL<C4A4><4C>.[luther.gliethttp]
} }
//int find_next_zero_bit(const void * p, int size, int offset); //int find_next_zero_bit(const void * p, int size, int offset);
@ -570,7 +570,7 @@ static inline void set_bit(int nr, volatile unsigned long *addr)
unsigned long mask = BIT_MASK(nr); unsigned long mask = BIT_MASK(nr);
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
unsigned long flags; unsigned long flags;
(void)flags;
//taskENTER_CRITICAL(); //taskENTER_CRITICAL();
_atomic_spin_lock_irqsave(p, flags); _atomic_spin_lock_irqsave(p, flags);
*p |= mask; *p |= mask;
@ -593,7 +593,7 @@ static inline void clear_bit(int nr, volatile unsigned long *addr)
unsigned long mask = BIT_MASK(nr); unsigned long mask = BIT_MASK(nr);
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
unsigned long flags; unsigned long flags;
(void)flags;
_atomic_spin_lock_irqsave(p, flags); _atomic_spin_lock_irqsave(p, flags);
//taskENTER_CRITICAL(); //taskENTER_CRITICAL();
*p &= ~mask; *p &= ~mask;
@ -616,7 +616,7 @@ static inline void change_bit(int nr, volatile unsigned long *addr)
unsigned long mask = BIT_MASK(nr); unsigned long mask = BIT_MASK(nr);
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
unsigned long flags; unsigned long flags;
(void)flags;
//taskENTER_CRITICAL(); //taskENTER_CRITICAL();
_atomic_spin_lock_irqsave(p, flags); _atomic_spin_lock_irqsave(p, flags);
*p ^= mask; *p ^= mask;
@ -638,8 +638,8 @@ static inline int test_and_set_bit(int nr, volatile unsigned long *addr)
unsigned long mask = BIT_MASK(nr); unsigned long mask = BIT_MASK(nr);
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
unsigned long old; unsigned long old;
//unsigned long flags; unsigned long flags;
(void)flags;
//taskENTER_CRITICAL(); //taskENTER_CRITICAL();
_atomic_spin_lock_irqsave(p, flags); _atomic_spin_lock_irqsave(p, flags);
@ -666,7 +666,7 @@ static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
unsigned long old; unsigned long old;
unsigned long flags; unsigned long flags;
(void)flags;
//taskENTER_CRITICAL(); //taskENTER_CRITICAL();
_atomic_spin_lock_irqsave(p, flags); _atomic_spin_lock_irqsave(p, flags);
old = *p; old = *p;
@ -691,7 +691,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
unsigned long old; unsigned long old;
unsigned long flags; unsigned long flags;
(void)flags;
_atomic_spin_lock_irqsave(p, flags); _atomic_spin_lock_irqsave(p, flags);
old = *p; old = *p;
*p = old ^ mask; *p = old ^ mask;
@ -725,6 +725,7 @@ static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1,
static inline int atomic_inc_return(volatile atomic_t *v) static inline int atomic_inc_return(volatile atomic_t *v)
{ {
unsigned long flags; unsigned long flags;
(void)flags;
int retval; int retval;
cris_atomic_save(v, flags); cris_atomic_save(v, flags);
retval = ++(v->counter); retval = ++(v->counter);

View file

@ -804,9 +804,9 @@ osStatus osMailFree (osMailQId queue_id, void *mail);
#endif // Mail Queues available #endif // Mail Queues available
//#undef malloc #undef malloc
#define malloc(size) pvPortMalloc(size) #define malloc(size) pvPortMalloc(size)
//#undef free #undef free
#define free(pbuf) vPortFree(pbuf) #define free(pbuf) vPortFree(pbuf)
extern void *calloc_freertos(size_t nelements, size_t elementSize); extern void *calloc_freertos(size_t nelements, size_t elementSize);

View file

@ -414,7 +414,7 @@ LOCAL uint32 BOOT_RAM_TEXT_SECTION get_seg_id(uint32 addr, int32 size) {
ptr += 2; ptr += 2;
} while (ret < SEG_ID_MAX); } while (ret < SEG_ID_MAX);
}; };
return 0; return 0; // UNK
} }
LOCAL uint32 BOOT_RAM_TEXT_SECTION load_img2_head(uint32 faddr, PIMG2HEAD hdr) { LOCAL uint32 BOOT_RAM_TEXT_SECTION load_img2_head(uint32 faddr, PIMG2HEAD hdr) {
@ -422,13 +422,13 @@ LOCAL uint32 BOOT_RAM_TEXT_SECTION load_img2_head(uint32 faddr, PIMG2HEAD hdr) {
uint32 ret = get_seg_id(hdr->seg.ldaddr, hdr->seg.size); uint32 ret = get_seg_id(hdr->seg.ldaddr, hdr->seg.size);
if (hdr->sign[1] == IMG_SIGN2_RUN) { if (hdr->sign[1] == IMG_SIGN2_RUN) {
if (hdr->sign[0] == IMG_SIGN1_RUN) { if (hdr->sign[0] == IMG_SIGN1_RUN) {
ret |= 1 << 9; ret |= 1 << 9; // есть сигнатура RUN
} else if (hdr->sign[0] == IMG_SIGN1_SWP) { } else if (hdr->sign[0] == IMG_SIGN1_SWP) {
ret |= 1 << 8; ret |= 1 << 8; // есть сигнатура SWP
}; };
} }
if (*(u32 *) (&hdr->rtkwin) == IMG2_SIGN_DW1_TXT) { if (*(u32 *) (&hdr->rtkwin) == IMG2_SIGN_DW1_TXT) {
ret |= 1 << 10; ret |= 1 << 10; // есть подпись "RTKW"
}; };
return ret; return ret;
} }
@ -474,21 +474,23 @@ LOCAL int BOOT_RAM_TEXT_SECTION loadUserImges(int imgnum) {
while (1) { while (1) {
faddr = (faddr + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1)); faddr = (faddr + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
uint32 img_id = load_img2_head(faddr, &hdr); uint32 img_id = load_img2_head(faddr, &hdr); // проверить заголовки запись
if ((img_id >> 8) > 4 || (uint8) img_id != 0) { if ((img_id >> 8) > 4 && (uint8) img_id != 0) { // есть подпись "RTKW" + RUN или SWP, сегмент != unknown
faddr = load_segs(faddr + 0x10, (PIMG2HEAD) &hdr.seg, imagenum == imgnum); // загрузить, если imagenum == imgnum
if (imagenum == imgnum) { faddr = load_segs(faddr + 0x10, (PIMG2HEAD) &hdr.seg, imagenum == imgnum); // faddr == fnextaddr
if (imagenum == imgnum) { // если искомая img
// DBG_8195A("Image%d: %s\n", imgnum, hdr.name); // DBG_8195A("Image%d: %s\n", imgnum, hdr.name);
break; break;
} }
imagenum++; imagenum++; // перейти к следующей
} else if (imagenum) { } else if (imagenum) { // нет подписей у заданной imgnum
DBG_8195A("No Image%d! Trying Image0...\n", imgnum); DBG_8195A("No Image%d! Trying Image0...\n", imgnum);
// пробуем загрузить image по умолчанию, по записи в секторе установок // пробуем загрузить image по умолчанию, по записи в секторе установок
flashcpy(FLASH_SYSTEM_DATA_ADDR, &faddr, sizeof(faddr)); flashcpy(FLASH_SYSTEM_DATA_ADDR, &faddr, sizeof(faddr));
if (faddr < 0x8000000) if (faddr < 0x8000000)
faddr += SPI_FLASH_BASE; faddr += SPI_FLASH_BASE;
if (get_seg_id(faddr, 0x100) == SEG_ID_FLASH) { if (get_seg_id(faddr, 0x100) == SEG_ID_FLASH) { // указывает в Flash?
// будем пробовать грузить
imagenum = 0; imagenum = 0;
imgnum = 0; imgnum = 0;
} else { } else {
@ -497,7 +499,7 @@ LOCAL int BOOT_RAM_TEXT_SECTION loadUserImges(int imgnum) {
break; break;
}; };
} else { } else {
imagenum = -1; imagenum = -1; // нет записей image
break; break;
} }
}; };
@ -605,6 +607,15 @@ LOCAL void BOOT_RAM_TEXT_SECTION EnterImage15(int flg) {
}; };
DBG_8195A("SDR tst end\n"); DBG_8195A("SDR tst end\n");
}; };
#endif // test
#ifdef CONFIG_SDR_EN
// Тест и ожидание загрузки Jlink-ом sdram.bin (~7 sec)
if(flg && *((uint32 *)0x1FFF0000) == 0x12345678) {
*((volatile uint32 *)0x1FFF0000) = 0x87654321;
uint32 tt = 0x03ffffff; // ~7 sec
DBG_8195A("Waiting for SDRAM to load...\n");
while(*((volatile uint32 *)0x1FFF0000) == 0x87654321 && tt--);
}
#endif // test #endif // test
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21)); // Flag SDRAM Init HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21)); // Flag SDRAM Init
}; };

View file

@ -1358,7 +1358,7 @@ struct usb_hcd {
unsigned long hcd_priv[0]; unsigned long hcd_priv[0];
#elif defined (__GNUC__) #elif defined (__GNUC__)
unsigned long hcd_priv[0]; unsigned long hcd_priv[0];
__attribute__ ((aligned(sizeof(s64)))); //? __attribute__ ((aligned(sizeof(s64))));
#endif #endif
}; };
@ -2067,7 +2067,7 @@ struct usb_device_id {
kernel_ulong_t driver_info; kernel_ulong_t driver_info;
#elif defined (__GNUC__) #elif defined (__GNUC__)
kernel_ulong_t driver_info; kernel_ulong_t driver_info;
__attribute__((aligned(sizeof(kernel_ulong_t)))); //? __attribute__((aligned(sizeof(kernel_ulong_t))));
#endif #endif
}; };

View file

@ -73,7 +73,7 @@ HAL_Status SdioHostSdClkCtrl(void *Data, int En, u8 Divisor) { // SD_CLK_DIVISOR
static HAL_Status CheckSramAddress(void* address) static HAL_Status CheckSramAddress(void* address)
{ {
// SRAM: 0x10000000... 0x1006ffff // SRAM: 0x10000000... 0x1006ffff
if (address >= 0x10070000 || address < 0x10000000 || ((uint32_t)address & 3) !=0) if ((uint32_t)address >= 0x10070000 || (uint32_t)address < 0x10000000 || ((uint32_t)address & 3) !=0)
return HAL_ERR_PARA; return HAL_ERR_PARA;
return HAL_OK; return HAL_OK;
} }
@ -351,7 +351,7 @@ void SdioHostIsrHandle(void *Data) {
*/ */
} }
} }
ir_end: // ir_end:
HAL_SDIOH_REG16(REG_SDIO_HOST_NORMAL_INT_SIG_EN) HAL_SDIOH_REG16(REG_SDIO_HOST_NORMAL_INT_SIG_EN)
= NOR_INT_SIG_EN_CMD_COMP = NOR_INT_SIG_EN_CMD_COMP
| NOR_INT_SIG_EN_XFER_COMP | NOR_INT_SIG_EN_XFER_COMP
@ -485,7 +485,7 @@ HAL_Status SdioHostSwitchFunction(void *Data, int Mode, int Fn2Sel, int Fn1Sel,
if (result) if (result)
return result; return result;
HAL_SDIOH_REG32(REG_SDIO_HOST_ADMA_SYS_ADDR) = pAdmaDescTbl; HAL_SDIOH_REG32(REG_SDIO_HOST_ADMA_SYS_ADDR) = (uint32_t)pAdmaDescTbl;
HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_SIZE) = 64; HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_SIZE) = 64;
HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_CNT) =1; HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_CNT) =1;
HAL_SDIOH_REG16(REG_SDIO_HOST_XFER_MODE) = HAL_SDIOH_REG16(REG_SDIO_HOST_XFER_MODE) =
@ -610,7 +610,7 @@ HAL_Status HalSdioHostChangeSdClockRtl8195a(IN VOID *Data, IN uint8_t Frequency)
// а malloc не гарантирует размещение в SRAM в любых ситуациях // а malloc не гарантирует размещение в SRAM в любых ситуациях
StatusData = (uint8_t*)pAdmaDescTbl + sizeof(ADMA2_DESC_FMT); StatusData = (uint8_t*)pAdmaDescTbl + sizeof(ADMA2_DESC_FMT);
HAL_SDIOH_REG32(REG_SDIO_HOST_ADMA_SYS_ADDR) = pAdmaDescTbl; HAL_SDIOH_REG32(REG_SDIO_HOST_ADMA_SYS_ADDR) = (uint32_t)pAdmaDescTbl;
HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_SIZE) = 8; // v40058004 = 8; HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_SIZE) = 8; // v40058004 = 8;
HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_CNT) =1; HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_CNT) =1;
HAL_SDIOH_REG16(REG_SDIO_HOST_XFER_MODE) = HAL_SDIOH_REG16(REG_SDIO_HOST_XFER_MODE) =
@ -625,7 +625,7 @@ HAL_Status HalSdioHostChangeSdClockRtl8195a(IN VOID *Data, IN uint8_t Frequency)
pAdmaDescTbl->Attrib1.Int = 0; pAdmaDescTbl->Attrib1.Int = 0;
pAdmaDescTbl->Attrib1.Act1= 0; pAdmaDescTbl->Attrib1.Act1= 0;
pAdmaDescTbl->Attrib1.Act2=1; pAdmaDescTbl->Attrib1.Act2=1;
pAdmaDescTbl->Addr1 = StatusData; pAdmaDescTbl->Addr1 = (uint32_t)StatusData;
pAdmaDescTbl->Len1 = 8; pAdmaDescTbl->Len1 = 8;
result = SdioHostChkCmdInhibitCMD(); result = SdioHostChkCmdInhibitCMD();
@ -797,8 +797,8 @@ HAL_Status HalSdioHostReadBlocksDmaRtl8195a(IN VOID *Data, IN u64 ReadAddr,
admadesc_ptr = psha->AdmaDescTbl; admadesc_ptr = psha->AdmaDescTbl;
// проверка валидности адреса и дескриптора ADMA2 // проверка валидности адреса и дескриптора ADMA2
result = CheckSramAddress(admadesc_ptr) | result = CheckSramAddress((void*)admadesc_ptr) |
CheckSramAddress(admadesc_ptr->Addr1); CheckSramAddress((void*)admadesc_ptr->Addr1);
if (result) if (result)
return result; return result;
@ -807,7 +807,7 @@ HAL_Status HalSdioHostReadBlocksDmaRtl8195a(IN VOID *Data, IN u64 ReadAddr,
sd_read_addr =ReadAddr >> 9; // sdhc: адрес в блоках sd_read_addr =ReadAddr >> 9; // sdhc: адрес в блоках
HAL_SDIOH_REG32(REG_SDIO_HOST_ADMA_SYS_ADDR) =admadesc_ptr; HAL_SDIOH_REG32(REG_SDIO_HOST_ADMA_SYS_ADDR) = (uint32_t)admadesc_ptr;
HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_SIZE) = DATA_BLK_LEN; HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_SIZE) = DATA_BLK_LEN;
result = SdioHostChkCmdInhibitCMD(); result = SdioHostChkCmdInhibitCMD();
if (result) { if (result) {
@ -1058,7 +1058,7 @@ HAL_Status HalSdioHostWriteBlocksDmaRtl8195a(IN VOID *Data, IN uint64 WriteAddr,
// проверка валидности адреса и дескриптора ADMA2 // проверка валидности адреса и дескриптора ADMA2
admadesc_ptr = psha->AdmaDescTbl; admadesc_ptr = psha->AdmaDescTbl;
// проверим адрес дескриптора ADMA2 // проверим адрес дескриптора ADMA2
if (CheckSramAddress(admadesc_ptr) || CheckSramAddress(admadesc_ptr->Addr1)) if (CheckSramAddress((void *)admadesc_ptr) || CheckSramAddress((void *)admadesc_ptr->Addr1))
return HAL_ERR_PARA; return HAL_ERR_PARA;
// адрес в байтах или блоках ? // адрес в байтах или блоках ?
if (psha->IsSdhc) if (psha->IsSdhc)
@ -1220,7 +1220,7 @@ HAL_Status HalSdioHostGetCardStatusRtl8195a(IN VOID *Data) {
if (result) if (result)
return result; return result;
// Send Status command // Send Status command
Cmd.Arg = Cmd.Arg = psha->RCA << 16; Cmd.Arg = psha->RCA << 16;
Cmd.CmdFmt.CmdIdx = CMD_SEND_STATUS; Cmd.CmdFmt.CmdIdx = CMD_SEND_STATUS;
Cmd.CmdFmt.RespType = RSP_LEN_48; Cmd.CmdFmt.RespType = RSP_LEN_48;
Cmd.CmdFmt.CmdCrcChkEn = 1; Cmd.CmdFmt.CmdCrcChkEn = 1;
@ -1280,7 +1280,7 @@ HAL_Status HalSdioHostGetSdStatusRtl8195a(IN VOID *Data) {
pAdmaDescTbl->Attrib1.End=1; pAdmaDescTbl->Attrib1.End=1;
pAdmaDescTbl->Attrib1.Act1=0; pAdmaDescTbl->Attrib1.Act1=0;
pAdmaDescTbl->Attrib1.Act2=1; pAdmaDescTbl->Attrib1.Act2=1;
pAdmaDescTbl->Addr1 = &psha->SdStatus[0]; pAdmaDescTbl->Addr1 = (uint32_t) &psha->SdStatus[0];
pAdmaDescTbl->Attrib1.Valid =1; pAdmaDescTbl->Attrib1.Valid =1;
//memset(&psha->SdStatus[0], 0x55, SD_STATUS_LEN); //memset(&psha->SdStatus[0], 0x55, SD_STATUS_LEN);
@ -1325,7 +1325,7 @@ HAL_Status HalSdioHostGetSdStatusRtl8195a(IN VOID *Data) {
if (result) if (result)
return result; return result;
HAL_SDIOH_REG32(REG_SDIO_HOST_ADMA_SYS_ADDR) = pAdmaDescTbl; HAL_SDIOH_REG32(REG_SDIO_HOST_ADMA_SYS_ADDR) = (uint32_t)pAdmaDescTbl;
HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_SIZE) = 64; HAL_SDIOH_REG16(REG_SDIO_HOST_BLK_SIZE) = 64;
HAL_SDIOH_REG16(REG_SDIO_HOST_XFER_MODE) = HAL_SDIOH_REG16(REG_SDIO_HOST_XFER_MODE) =
@ -1388,7 +1388,7 @@ HAL_Status HalSdioHostIrqInitRtl8195a(IN VOID *Data) // PIRQ_HANDLE Data
HAL_Status result; HAL_Status result;
PIRQ_HANDLE pih = (PIRQ_HANDLE)Data; PIRQ_HANDLE pih = (PIRQ_HANDLE)Data;
if (pih) { if (pih) {
pih->Data = Data; pih->Data = (uint32_t)Data;
pih->IrqNum = SDIO_HOST_IRQ; pih->IrqNum = SDIO_HOST_IRQ;
pih->IrqFun = SdioHostIsrHandle; pih->IrqFun = SdioHostIsrHandle;
pih->Priority = 6; pih->Priority = 6;
@ -1516,7 +1516,7 @@ HAL_Status HalSdioHostDeInitRtl8195a(IN VOID *Data) {
//----- HalSdioHostStopTransferRtl8195a //----- HalSdioHostStopTransferRtl8195a
HAL_Status HalSdioHostStopTransferRtl8195a(IN VOID *Data) { HAL_Status HalSdioHostStopTransferRtl8195a(IN VOID *Data) {
HAL_Status result; // HAL_Status result;
SDIO_HOST_CMD Cmd; SDIO_HOST_CMD Cmd;
PHAL_SDIO_HOST_ADAPTER psha = (PHAL_SDIO_HOST_ADAPTER)Data; PHAL_SDIO_HOST_ADAPTER psha = (PHAL_SDIO_HOST_ADAPTER)Data;
uint32_t x; uint32_t x;
@ -1757,7 +1757,7 @@ IN uint64_t EndAddr) {
HAL_Status HalSdioHostGetWriteProtectRtl8195a(IN VOID *Data) { HAL_Status HalSdioHostGetWriteProtectRtl8195a(IN VOID *Data) {
PHAL_SDIO_HOST_ADAPTER psha = (PHAL_SDIO_HOST_ADAPTER)Data; PHAL_SDIO_HOST_ADAPTER psha = (PHAL_SDIO_HOST_ADAPTER)Data;
HAL_Status result; HAL_Status result;
SDIO_HOST_CMD Cmd; // [sp+0h] [bp-18h]@1 // SDIO_HOST_CMD Cmd; // [sp+0h] [bp-18h]@1
if (!psha) if (!psha)
return HAL_ERR_PARA; return HAL_ERR_PARA;

View file

@ -98,7 +98,7 @@ HAL_Status HalSdioHostDisable(IN VOID *Data) {
//----- HalSdioHostOpInit(PHAL_SDIO_HOST_ADAPTER) //----- HalSdioHostOpInit(PHAL_SDIO_HOST_ADAPTER)
void HalSdioHostOpInit(void *Data) { void HalSdioHostOpInit(void *Data) {
PHAL_SDIO_HOST_OP phsha = (PHAL_SDIO_HOST_ADAPTER)Data; PHAL_SDIO_HOST_OP phsha = (PHAL_SDIO_HOST_OP)Data;
phsha->HalSdioHostInitHost = &HalSdioHostInitHostRtl8195a; phsha->HalSdioHostInitHost = &HalSdioHostInitHostRtl8195a;
phsha->HalSdioHostInitCard = &HalSdioHostInitCardRtl8195a; phsha->HalSdioHostInitCard = &HalSdioHostInitCardRtl8195a;
phsha->HalSdioHostDeInit = &HalSdioHostDeInitRtl8195a; phsha->HalSdioHostDeInit = &HalSdioHostDeInitRtl8195a;

View file

@ -222,10 +222,11 @@ if $rtl8710_flasher_capacity == 0
monitor go monitor go
FlasherWait FlasherWait
set $id = {int}($rtl8710_flasher_buffer + 0x0C) set $id = {int}($rtl8710_flasher_buffer + 0x0C)
set $rtl8710_flasher_capacity = 1 << (($id >> 16) & 0x0ff)
if ($id == 0x1420c2) if ($id == 0x1420c2)
set $rtl8710_flasher_capacity = 1 << (($id >> 16) & 0x0ff)
printf "Flash ID = 0x%08x : MX25L8006E (%d kbytes)\n", $id, $rtl8710_flasher_capacity>>10 printf "Flash ID = 0x%08x : MX25L8006E (%d kbytes)\n", $id, $rtl8710_flasher_capacity>>10
else else
set $rtl8710_flasher_capacity = {int}(1024*1024)
printf "Flash ID = 0x%08x : (%d kbytes)\n", $id, $rtl8710_flasher_capacity>>10 printf "Flash ID = 0x%08x : (%d kbytes)\n", $id, $rtl8710_flasher_capacity>>10
end end
printf "RTL8710 flasher initialized\n" printf "RTL8710 flasher initialized\n"

View file

@ -41,8 +41,8 @@ if $rtl8710_flasher_capacity == 0
set $rtl8710_flasher_capacity = 1 << (($id >> 16) & 0x0ff) set $rtl8710_flasher_capacity = 1 << (($id >> 16) & 0x0ff)
printf "Flash ID = 0x%08x : MX25L8006E (%d kbytes)\n", $id, $rtl8710_flasher_capacity>>10 printf "Flash ID = 0x%08x : MX25L8006E (%d kbytes)\n", $id, $rtl8710_flasher_capacity>>10
else else
set $rtl8710_flasher_capacity = 1024*1024) set $rtl8710_flasher_capacity = {int}(1024*1024)
error "Flash ID = 0x%08x : ?\n", $id printf "Flash ID = 0x%08x : (%d kbytes)\n", $id, $rtl8710_flasher_capacity>>10
end end
printf "RTL8710 flasher initialized\n" printf "RTL8710 flasher initialized\n"
else else

View file

@ -47,9 +47,13 @@ ifdef USE_SDIOH
#LIBS += _sdcard_v2 #LIBS += _sdcard_v2
CFLAGS += -DCONFIG_FATFS_EN=1 CFLAGS += -DCONFIG_FATFS_EN=1
endif endif
ifdef USE_UVC
all: LIBS +=_rtsp _usbh _usbd
mp: LIBS +=_rtsp _usbh _usbd
endif
# m c nosys gcc # m c nosys gcc
PATHLIBS = sdk/component/soc/realtek/8195a/misc/bsp/lib/common/gcc PATHLIBS = sdk/component/soc/realtek/8195a/misc/bsp/lib/common/gcc
LDFILE = rlx8195A-symbol-v04-img2.ld LDFILE ?= rlx8195A-symbol-v04-img2.ld
BOOTS = sdk/component/soc/realtek/8195a/misc/bsp/image BOOTS = sdk/component/soc/realtek/8195a/misc/bsp/image
# Include folder list # Include folder list
@ -376,6 +380,7 @@ SRC_C += sdk/component/common/file_system/fatfs/r0.10c/src/diskio.c
SRC_C += sdk/component/common/file_system/fatfs/r0.10c/src/ff.c SRC_C += sdk/component/common/file_system/fatfs/r0.10c/src/ff.c
SRC_C += sdk/component/common/file_system/fatfs/r0.10c/src/option/ccsbcs.c SRC_C += sdk/component/common/file_system/fatfs/r0.10c/src/option/ccsbcs.c
endif endif
ifdef USE_SDIOH ifdef USE_SDIOH
INCLUDES += sdk/component/common/file_system/fatfs/disk_if/inc INCLUDES += sdk/component/common/file_system/fatfs/disk_if/inc
SRC_C += sdk/component/common/file_system/fatfs/disk_if/src/sdcard.c SRC_C += sdk/component/common/file_system/fatfs/disk_if/src/sdcard.c

View file

@ -31,7 +31,7 @@ typedef struct _ina219drv {
signed short ss[2]; signed short ss[2];
unsigned int ui; unsigned int ui;
} buf_i2c; } buf_i2c;
volatile i2c_drv_t i2c; i2c_drv_t i2c;
} INA219DRV, *PINA219DRV; } INA219DRV, *PINA219DRV;

View file

@ -43,7 +43,7 @@ typedef struct _ina219drv {
signed short ss[2]; signed short ss[2];
unsigned int ui; unsigned int ui;
} buf_i2c; } buf_i2c;
volatile i2c_drv_t i2c; i2c_drv_t i2c;
} INA219DRV, *PINA219DRV; } INA219DRV, *PINA219DRV;

View file

@ -185,6 +185,7 @@ a lot of data that needs to be copied, this should be set high. */
/* Support Multicast */ /* Support Multicast */
#define LWIP_IGMP 1 #define LWIP_IGMP 1
extern __attribute__ ((long_call)) unsigned int Rand(void); extern __attribute__ ((long_call)) unsigned int Rand(void);
#define LWIP_RAND() Rand() #define LWIP_RAND() Rand()

View file

@ -12,9 +12,11 @@
#include "lwip/err.h" #include "lwip/err.h"
#undef mMIN
#define mMIN(a, b) ((a < b)? a : b) #define mMIN(a, b) ((a < b)? a : b)
#define mMAX(a, b) ((a>b)?a:b) #define mMAX(a, b) ((a>b)?a:b)
enum srvconn_state { enum srvconn_state {
SRVCONN_NONE =0, SRVCONN_NONE =0,
SRVCONN_CLOSEWAIT, // ожидает закрытия SRVCONN_CLOSEWAIT, // ожидает закрытия

View file

@ -6,6 +6,8 @@
#ifndef _WEBSOCK_H_ #ifndef _WEBSOCK_H_
#define _WEBSOCK_H_ #define _WEBSOCK_H_
#include "lwip/err.h"
#include "tcpsrv/tcp_srv_conn.h"
//#define WS_NONBLOCK 0x02 //#define WS_NONBLOCK 0x02

View file

@ -33,7 +33,7 @@
RTW_SECURITY_WPA_TKIP_PSK - WPA Security RTW_SECURITY_WPA_TKIP_PSK - WPA Security
RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers */ RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers */
#define DEF_AP_SECURITY RTW_SECURITY_WPA2_AES_PSK // WEP security is NOT IMPLEMENTED. It is NOT SECURE! #define DEF_AP_SECURITY RTW_ENCRYPTION_WPA2_MIXED // WEP security is NOT IMPLEMENTED. It is NOT SECURE!
#define DEF_AP_BEACON 100 // 100...6000 ms #define DEF_AP_BEACON 100 // 100...6000 ms
#define DEF_AP_CHANNEL 1 // 1..14 #define DEF_AP_CHANNEL 1 // 1..14
#define DEF_AP_CHANNEL 1 // 1..14 #define DEF_AP_CHANNEL 1 // 1..14
@ -54,7 +54,7 @@
#define DEF_ST_AUTORECONNECT 1 // 0 - none, 1..254 - count, 255 - all #define DEF_ST_AUTORECONNECT 1 // 0 - none, 1..254 - count, 255 - all
#define DEF_ST_RECONNECT_PAUSE 1 // 5 sec #define DEF_ST_RECONNECT_PAUSE 1 // 5 sec
#define DEF_ST_SLEEP 3 // 0 - Off, 1 - IPS, 2 - LPS, 3 - IPS/LPS mode #define DEF_ST_SLEEP 3 // 0 - Off, 1 - IPS, 2 - LPS, 3 - IPS/LPS mode
#define DEF_ST_LPS_DTIM 0 // LPS DTIM #define DEF_ST_LPS_DTIM 1 // LPS DTIM
#define DEF_ST_DHCP_MODE 1 // =0 dhcp off, #define DEF_ST_DHCP_MODE 1 // =0 dhcp off,
// =1 - dhcp on, - динамический ip // =1 - dhcp on, - динамический ip
// =2 Static ip, - fixed ip // =2 Static ip, - fixed ip

View file

@ -243,7 +243,6 @@ LOCAL void fATHF(int argc, char *argv[]) {
if (pbuf != NULL) { if (pbuf != NULL) {
DIR dir; DIR dir;
FILINFO fno; FILINFO fno;
struct os_tm tm;
fno.lfname = (TCHAR*) pbuf; fno.lfname = (TCHAR*) pbuf;
fno.lfsize = 512; fno.lfsize = 512;
u8 * sdir; u8 * sdir;
@ -270,7 +269,7 @@ LOCAL void fATHF(int argc, char *argv[]) {
} else } else
printf("FATFS: Open dir fail!\n"); printf("FATFS: Open dir fail!\n");
free(pbuf); free(pbuf);
if(sdir != logical_drv) free(sdir); if((void *)sdir != (void *)logical_drv) free(sdir);
} }
} }
sd_unmount(fs); sd_unmount(fs);
@ -348,7 +347,7 @@ LOCAL void fATHS(int argc, char *argv[]) {
} else } else
printf("FATFS: Open dir fail!\n"); printf("FATFS: Open dir fail!\n");
free(pbuf); free(pbuf);
if(sdir != logical_drv) free(sdir); if((void *)sdir != (void *)logical_drv) free(sdir);
} }
} }
sd_unmount(fs); sd_unmount(fs);

View file

@ -193,7 +193,9 @@ LOCAL void fATWI(int argc, char *argv[]) {
show_wifi_st_cfg(); show_wifi_st_cfg();
printf("\nWIFI AP clients:\n"); printf("\nWIFI AP clients:\n");
printf(&str_rom_57ch3Dch0A[25]); // "================================\n" printf(&str_rom_57ch3Dch0A[25]); // "================================\n"
#if SDK_VER_NUM > 0x4000
show_wifi_ap_clients(); show_wifi_ap_clients();
#endif
printf("\n"); printf("\n");
} }

View file

@ -20,7 +20,7 @@
//#include "hal_diag.h" //#include "hal_diag.h"
#include "rtl8195a/rtl_libc.h" #include "rtl8195a/rtl_libc.h"
void dump_bytes(uint32 addr, int size); extern void dump_bytes(uint32 addr, int size);
extern Rltk_wlan_t rltk_wlan_info[2]; // in wrapper.h extern Rltk_wlan_t rltk_wlan_info[2]; // in wrapper.h
LOCAL void tst_wlan_struct(int argc, char *argv[]) LOCAL void tst_wlan_struct(int argc, char *argv[])
@ -55,6 +55,21 @@ LOCAL void tst_wlan_struct(int argc, char *argv[])
}; };
} }
LOCAL void show_wlan_param(int argc, char *argv[]) {
(void)argc; (void)argv;
_adapter * ad = *(_adapter **)((rltk_wlan_info[0].dev)->priv);
#if 1
printf("reconnect_deauth_filtered\t%u\n", ad->mlmeextpriv.reconnect_deauth_filtered);
printf("reconnect_times\t%u\n", ad->mlmeextpriv.reconnect_times);
printf("reconnect_cnt\t%u\n", ad->mlmeextpriv.reconnect_cnt);
printf("reconnect_timeout\t%u\n", ad->mlmeextpriv.reconnect_timeout);
#endif
}
MON_RAM_TAB_SECTION COMMAND_TABLE console_wlan_tst[] = { MON_RAM_TAB_SECTION COMMAND_TABLE console_wlan_tst[] = {
{"CHKWL", 0, tst_wlan_struct, ": Chk wlan struct"} {"CHKWL", 0, tst_wlan_struct, ": Chk wlan struct"},
{"CHKAP", 0, show_wlan_param, ": Chow wlan parm"}
}; };

View file

@ -5,6 +5,7 @@
* Author: pvvx * Author: pvvx
*/ */
#include "driver/i2c_drv.h" #include "driver/i2c_drv.h"
#include "rtl_lib.h"
#if CONFIG_I2C_EN #if CONFIG_I2C_EN
@ -44,14 +45,14 @@ static const PinMapI2C PinMap_I2C[] = {
}; };
static void * i2c_base_reg[4] = { static void * i2c_base_reg[4] = {
I2C0_REG_BASE, (void *)I2C0_REG_BASE,
I2C1_REG_BASE, (void *)I2C1_REG_BASE,
I2C2_REG_BASE, (void *)I2C2_REG_BASE,
I2C3_REG_BASE (void *)I2C3_REG_BASE
}; };
#if 1 #if 1
#define test_printf #define test_printf(...)
#define i2c_dump_regs(p) #define i2c_dump_regs(p)
#else #else
#define test_printf rtl_printf #define test_printf rtl_printf
@ -87,9 +88,9 @@ 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) { 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); error_printf("I2C%d Abort!\n", pi2c->idx);
// Clear abort status. // Clear abort status.
(volatile)i2c_reg(REG_DW_I2C_IC_CLR_TX_ABRT); i2c_reg(REG_DW_I2C_IC_CLR_TX_ABRT);
// Be sure that all interrupts flag are cleared. // Be sure that all interrupts flag are cleared.
// (volatile)i2c_reg(REG_DW_I2C_IC_CLR_INTR); // i2c_reg(REG_DW_I2C_IC_CLR_INTR);
pi2c->status = DRV_I2C_ABORT; pi2c->status = DRV_I2C_ABORT;
return DRV_I2C_ABORT; return DRV_I2C_ABORT;
} }
@ -116,7 +117,7 @@ LOCAL int i2c_ready(i2c_drv_t *pi2c, unsigned char flg)
int _i2c_break(i2c_drv_t *pi2c) int _i2c_break(i2c_drv_t *pi2c)
{ {
test_printf("%s\n", __func__); test_printf("%s\n", __func__);
// (volatile)i2c_reg(REG_DW_I2C_IC_CLR_INTR); // i2c_reg(REG_DW_I2C_IC_CLR_INTR);
// ABORT operation // ABORT operation
int poll_count = DRV_I2C_POOL_TIMEOUT; int poll_count = DRV_I2C_POOL_TIMEOUT;
i2c_reg(REG_DW_I2C_IC_ENABLE) |= 2; i2c_reg(REG_DW_I2C_IC_ENABLE) |= 2;
@ -130,7 +131,7 @@ int _i2c_break(i2c_drv_t *pi2c)
}; };
pi2c->status = DRV_I2C_OFF; pi2c->status = DRV_I2C_OFF;
// All interrupts flag are cleared. // All interrupts flag are cleared.
(volatile)i2c_reg(REG_DW_I2C_IC_CLR_INTR); i2c_reg(REG_DW_I2C_IC_CLR_INTR);
return DRV_I2C_OK; return DRV_I2C_OK;
} }
@ -225,7 +226,7 @@ LOCAL int i2c_enable(i2c_drv_t *pi2c)
}; };
}; };
// Be sure that all interrupts flag are cleared. // Be sure that all interrupts flag are cleared.
(volatile)i2c_reg(REG_DW_I2C_IC_CLR_INTR); i2c_reg(REG_DW_I2C_IC_CLR_INTR);
pi2c->status = DRV_I2C_IC_ENABLE; pi2c->status = DRV_I2C_IC_ENABLE;
return DRV_I2C_OK; return DRV_I2C_OK;
} }
@ -286,7 +287,7 @@ int _i2c_setup(i2c_drv_t *pi2c, PinName sda, PinName scl, unsigned char mode)
return DRV_I2C_ERR; return DRV_I2C_ERR;
} }
// Pins -> index // Pins -> index
PinMapI2C *p = PinMap_I2C; PinMapI2C *p = (PinMapI2C *)PinMap_I2C;
while(p->sda != 0xFF) { while(p->sda != 0xFF) {
if(p->sda == sda && p->scl == scl) { if(p->sda == sda && p->scl == scl) {
pi2c->io_sel = RTL_GET_PERI_SEL(p->sel); pi2c->io_sel = RTL_GET_PERI_SEL(p->sel);
@ -432,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); *d++ = i2c_reg(REG_DW_I2C_IC_DATA_CMD);
length--; length--;
} }
else (volatile) i2c_reg(REG_DW_I2C_IC_DATA_CMD); else i2c_reg(REG_DW_I2C_IC_DATA_CMD);
}; };
} }
while(length) { while(length) {

View file

@ -21,6 +21,8 @@
#include "rtl8195a/rtl_libc.h" #include "rtl8195a/rtl_libc.h"
#include "driver/i2c_drv.h" #include "driver/i2c_drv.h"
#include "platform_stdlib.h" #include "platform_stdlib.h"
#include "web_websocket.h"
#include "tcpsrv/tcp_srv_conn.h"
#include "hal_com_reg.h" #include "hal_com_reg.h"
@ -101,7 +103,7 @@ void ina_tick_handler(void *par) {
break; break;
case 4: case 4:
if (i2c_reg(REG_DW_I2C_IC_RAW_INTR_STAT) & BIT_IC_RAW_INTR_STAT_TX_ABRT) { if (i2c_reg(REG_DW_I2C_IC_RAW_INTR_STAT) & BIT_IC_RAW_INTR_STAT_TX_ABRT) {
uint32 tmp = i2c_reg(REG_DW_I2C_IC_CLR_INTR); i2c_reg(REG_DW_I2C_IC_CLR_INTR);
p->errs++; p->errs++;
p->status = 0; p->status = 0;
break; break;
@ -121,10 +123,10 @@ void ina_tick_handler(void *par) {
else p->buf_rx++; else p->buf_rx++;
}; };
} else { } else {
(volatile)i2c_reg(REG_DW_I2C_IC_DATA_CMD); i2c_reg(REG_DW_I2C_IC_DATA_CMD);
(volatile)i2c_reg(REG_DW_I2C_IC_DATA_CMD); i2c_reg(REG_DW_I2C_IC_DATA_CMD);
(volatile)i2c_reg(REG_DW_I2C_IC_DATA_CMD); i2c_reg(REG_DW_I2C_IC_DATA_CMD);
(volatile)i2c_reg(REG_DW_I2C_IC_DATA_CMD); i2c_reg(REG_DW_I2C_IC_DATA_CMD);
}; };
} }
case 3: case 3:
@ -183,7 +185,8 @@ size_t ina219_getdata(void *pd, uint16 cnt)
taskENABLE_INTERRUPTS(); taskENABLE_INTERRUPTS();
return cnt * sizeof(INA219DATA) + 4; return cnt * sizeof(INA219DATA) + 4;
} }
#define mMIN(a, b) ((a<b)?a:b)
//#define mMIN(a, b) ((a<b)?a:b)
#define mMAX(a, b) ((a>b)?a:b) #define mMAX(a, b) ((a>b)?a:b)
#include "web_srv.h" #include "web_srv.h"
@ -390,14 +393,14 @@ LOCAL void fATI2C(int argc, char *argv[])
if(argv[1][0] == 'w') { if(argv[1][0] == 'w') {
_i2c_write(pi2c, buf[0], &buf[1], i-1, 1); _i2c_write(pi2c, buf[0], &buf[1], i-1, 1);
rtl_printf("I2C%d write[%d]:\n", pi2c->idx, i-1); rtl_printf("I2C%d write[%d]:\n", pi2c->idx, i-1);
dump_bytes(&buf[0], i); dump_bytes((uint32)&buf[0], i);
} }
else if(argv[1][0] == 'r') { else if(argv[1][0] == 'r') {
i = buf[1]; i = buf[1];
if(i > sizeof(buf) - 1) i = sizeof(buf) - 1; if(i > sizeof(buf) - 1) i = sizeof(buf) - 1;
_i2c_read(pi2c, buf[0], &buf[1], i, 1); _i2c_read(pi2c, buf[0], &buf[1], i, 1);
rtl_printf("I2C%d read[%d]:\n", pi2c->idx, i); rtl_printf("I2C%d read[%d]:\n", pi2c->idx, i);
dump_bytes(&buf[0], i+1); dump_bytes((uint32)&buf[0], i+1);
}; };
}; };