mirror of
https://github.com/kissste/rtl8710_Raw_Packets.git
synced 2025-07-31 12:41:05 +00:00
First commit
This commit is contained in:
commit
3fa968afe2
84 changed files with 9261 additions and 0 deletions
215
project/inc/FreeRTOSConfig.h
Normal file
215
project/inc/FreeRTOSConfig.h
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
/*
|
||||
FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.
|
||||
|
||||
FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
|
||||
http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||
* Complete, revised, and edited pdf reference manuals are also *
|
||||
* available. *
|
||||
* *
|
||||
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||
* ensuring you get running as quickly as possible and with an *
|
||||
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||
* the FreeRTOS project to continue with its mission of providing *
|
||||
* professional grade, cross platform, de facto standard solutions *
|
||||
* for microcontrollers - completely free of charge! *
|
||||
* *
|
||||
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||
* *
|
||||
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||
distribute a combined work that includes FreeRTOS without being obliged to
|
||||
provide the source code for proprietary components outside of the FreeRTOS
|
||||
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details. You should have received a copy of the GNU General Public
|
||||
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||
by writing to Richard Barry, contact details for whom are available on the
|
||||
FreeRTOS WEB site.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Having a problem? Start by reading the FAQ "My application does *
|
||||
* not run, what could be wrong?" *
|
||||
* *
|
||||
* http://www.FreeRTOS.org/FAQHelp.html *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, training, latest versions, license
|
||||
and contact details.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool.
|
||||
|
||||
Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
|
||||
the code with commercial support, indemnification, and middleware, under
|
||||
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
|
||||
provide a safety engineered and independently SIL3 certified version under
|
||||
the SafeRTOS brand: http://www.SafeRTOS.com.
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
|
||||
#include <stdint.h>
|
||||
extern uint32_t SystemCoreClock;
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_STACK_TCM_HEAP 1 // RTL871xAx/RTL8195Ax Stack priority used TCM HEAP
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 1
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
||||
#define configTICK_RATE_HZ ( ( uint32_t ) 1000 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 )
|
||||
#ifdef CONFIG_UVC
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 110 * 1024 ) ) // use HEAP5
|
||||
#else
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 90 * 1024 ) ) // use HEAP5
|
||||
#endif
|
||||
#define configMAX_TASK_NAME_LEN ( 10 )
|
||||
#define configUSE_TRACE_FACILITY 0
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 0
|
||||
#define configUSE_CO_ROUTINES 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configUSE_TIMERS 1
|
||||
|
||||
#define configMAX_PRIORITIES ( 11 )
|
||||
#define PRIORITIE_OFFSET ( 4 )
|
||||
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configUSE_ALTERNATIVE_API 0
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 0
|
||||
#define configGENERATE_RUN_TIME_STATS 1
|
||||
#if configGENERATE_RUN_TIME_STATS
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() //( ulHighFrequencyTimerTicks = 0UL )
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() xTickCount //ulHighFrequencyTimerTicks
|
||||
#undef configUSE_TRACE_FACILITY
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define portCONFIGURE_STATS_PEROID_VALUE 1000 //unit Ticks
|
||||
#endif
|
||||
|
||||
#define configTIMER_TASK_PRIORITY ( 1 )
|
||||
|
||||
#ifdef CONFIG_UVC
|
||||
#define configTIMER_QUEUE_LENGTH ( 20 )
|
||||
#else
|
||||
#define configTIMER_QUEUE_LENGTH ( 10 )
|
||||
#endif
|
||||
|
||||
#define configTIMER_TASK_STACK_DEPTH ( 512 ) //USE_MIN_STACK_SIZE modify from 512 to 256
|
||||
|
||||
#if (__IASMARM__ != 1)
|
||||
|
||||
extern void freertos_pre_sleep_processing(unsigned int *expected_idle_time);
|
||||
extern void freertos_post_sleep_processing(unsigned int *expected_idle_time);
|
||||
extern int freertos_ready_to_sleep();
|
||||
|
||||
/* Enable tickless power saving. */
|
||||
#define configUSE_TICKLESS_IDLE 1
|
||||
|
||||
/* In wlan usage, this value is suggested to use value less than 80 milliseconds */
|
||||
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2
|
||||
|
||||
/* It's magic trick that let us can use our own sleep function */
|
||||
#define configPRE_SLEEP_PROCESSING( x ) ( freertos_pre_sleep_processing(&x) )
|
||||
|
||||
#define configPOST_SLEEP_PROCESSING( x ) ( freertos_post_sleep_processing(&x) )
|
||||
|
||||
/* It's magic trick that let us can enable/disable tickless dynamically */
|
||||
#define traceLOW_POWER_IDLE_BEGIN(); do { \
|
||||
if (!freertos_ready_to_sleep()) { \
|
||||
mtCOVERAGE_TEST_MARKER(); \
|
||||
break; \
|
||||
}
|
||||
|
||||
// portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime );
|
||||
|
||||
#define traceLOW_POWER_IDLE_END(); } while (0);
|
||||
|
||||
/* It's FreeRTOS related feature but it's not included in FreeRTOS design. */
|
||||
#define configUSE_WAKELOCK_PMU 1
|
||||
|
||||
#endif // #if (__IASMARM__ != 1)
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_pcTaskGetTaskName 1
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
|
||||
/* Cortex-M specific definitions. */
|
||||
#ifdef __NVIC_PRIO_BITS
|
||||
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
|
||||
#define configPRIO_BITS __NVIC_PRIO_BITS
|
||||
#else
|
||||
#define configPRIO_BITS 4 /* 15 priority levels */
|
||||
#endif
|
||||
|
||||
|
||||
/* The lowest interrupt priority that can be used in a call to a "set priority"
|
||||
function. */
|
||||
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x0f
|
||||
|
||||
/* The highest interrupt priority that can be used by any interrupt service
|
||||
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
|
||||
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
|
||||
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
|
||||
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
|
||||
|
||||
|
||||
/* Interrupt priorities used by the kernel port layer itself. These are generic
|
||||
to all Cortex-M ports, and do not rely on any particular library functions. */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
||||
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
|
||||
//#define RTK_MODE_TIMER
|
||||
|
||||
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
7
project/inc/build_info.h
Normal file
7
project/inc/build_info.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#define UTS_VERSION "2017/05/15-21:54:34"
|
||||
#define RTL8195AFW_COMPILE_TIME "2017/05/15-21:54:34"
|
||||
#define RTL8195AFW_COMPILE_DATE "20170515"
|
||||
#define RTL8195AFW_COMPILE_BY "steve"
|
||||
#define RTL8195AFW_COMPILE_HOST ""
|
||||
#define RTL8195AFW_COMPILE_DOMAIN ""
|
||||
#define RTL195AFW_COMPILER "gcc 5.4.1"
|
||||
29
project/inc/feep_config.h
Normal file
29
project/inc/feep_config.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* feep_config.h
|
||||
*
|
||||
* Created on: 06 нояб. 2016 г.
|
||||
* Author: PVV
|
||||
*/
|
||||
|
||||
#ifndef _INC_FEEP_CONFIG_H_
|
||||
#define _INC_FEEP_CONFIG_H_
|
||||
|
||||
#define FEEP_ID_WIFI_CFG 0x5730 // id:'0W', type: struct wlan_fast_reconnect
|
||||
#define FEEP_ID_UART_CFG 0x5530 // id:'0U', type: UART_LOG_CONF
|
||||
#define FEEP_ID_LWIP_CFG 0x4C30 // id:'0L', type: struct atcmd_lwip_conf
|
||||
#define FEEP_ID_DHCP_CFG 0x4430 // id:'0D', type: struct
|
||||
|
||||
typedef struct _sdhcp_cfg {
|
||||
u8 mode; // =0 dhcp off, =1 - dhcp on, =2 Static ip, =3 - auto
|
||||
u32 ip;
|
||||
u32 mask;
|
||||
u32 gw;
|
||||
}dhcp_cfg;
|
||||
|
||||
/*
|
||||
#define FEEP_WRITE_WIFI_CFG(x) flash_write_cfg(x, FEEP_ID_WIFI_CFG, sizeof(struct wlan_fast_reconnect))
|
||||
#define FEEP_READ_WIFI_CFG(x) flash_read_cfg(x, FEEP_ID_WIFI_CFG, sizeof(struct wlan_fast_reconnect))
|
||||
*/
|
||||
|
||||
|
||||
#endif /* _INC_FEEP_CONFIG_H_ */
|
||||
381
project/inc/lwipopts.h
Normal file
381
project/inc/lwipopts.h
Normal file
|
|
@ -0,0 +1,381 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file lwipopts.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 07-October-2011
|
||||
* @brief lwIP Options Configuration.
|
||||
* This file is based on Utilities\lwip_v1.3.2\src\include\lwip\opt.h
|
||||
* and contains the lwIP configuration for the STM32F2x7 demonstration.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __LWIPOPTS_H__
|
||||
#define __LWIPOPTS_H__
|
||||
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include "platform_opts.h"
|
||||
|
||||
/**
|
||||
* LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS==1: randomize the local port for the first
|
||||
* local TCP/UDP pcb (default==0). This can prevent creating predictable port
|
||||
* numbers after booting a device.
|
||||
*/
|
||||
#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1
|
||||
|
||||
#define WIFI_LOGO_CERTIFICATION_CONFIG 1 //for ping 10k test buffer setting
|
||||
/**
|
||||
* MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library
|
||||
* instead of the lwip internal allocator. Can save code size if you
|
||||
* already use it.
|
||||
*/
|
||||
#define MEM_LIBC_MALLOC 1
|
||||
/**
|
||||
* MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator.
|
||||
* Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution
|
||||
* speed and usage from interrupts!
|
||||
*/
|
||||
#define MEMP_MEM_MALLOC 1
|
||||
|
||||
/**
|
||||
* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
|
||||
* critical regions during buffer allocation, deallocation and memory
|
||||
* allocation and deallocation.
|
||||
*/
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
/* Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores
|
||||
should be used instead */
|
||||
#define LWIP_COMPAT_MUTEX 1
|
||||
|
||||
#define ETHARP_TRUST_IP_MAC 0
|
||||
#define IP_REASSEMBLY 1
|
||||
#define IP_FRAG 1
|
||||
#define ARP_QUEUEING 0
|
||||
|
||||
/**
|
||||
* LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname
|
||||
* field.
|
||||
*/
|
||||
#define LWIP_NETIF_HOSTNAME 1
|
||||
#define LWIP_NETIF_HOSTNAME_SIZE 16
|
||||
/**
|
||||
* netif0: DEF_HOSTNAME "0", netif1: DEF_HOSTNAME "1", ..
|
||||
*/
|
||||
#define DEF_HOSTNAME "rtl871x"
|
||||
|
||||
/**
|
||||
* NO_SYS==1: Provides VERY minimal functionality. Otherwise,
|
||||
* use lwIP facilities.
|
||||
*/
|
||||
#define NO_SYS 0
|
||||
|
||||
/* ---------- Memory options ---------- */
|
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
|
||||
byte alignment -> define MEM_ALIGNMENT to 2. */
|
||||
#define MEM_ALIGNMENT 4
|
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */
|
||||
#if WIFI_LOGO_CERTIFICATION_CONFIG
|
||||
#define MEM_SIZE (10*1024) //for ping 10k test
|
||||
#else
|
||||
#define MEM_SIZE (5*1024)
|
||||
#endif
|
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this
|
||||
should be set high. */
|
||||
#define MEMP_NUM_PBUF 100
|
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */
|
||||
#define MEMP_NUM_UDP_PCB 6
|
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB 10
|
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 5
|
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */
|
||||
#define MEMP_NUM_TCP_SEG 20
|
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */
|
||||
#define MEMP_NUM_SYS_TIMEOUT 10
|
||||
|
||||
|
||||
/* ---------- Pbuf options ---------- */
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
|
||||
#if WIFI_LOGO_CERTIFICATION_CONFIG
|
||||
#define PBUF_POOL_SIZE 30 //for ping 10k test
|
||||
#else
|
||||
#define PBUF_POOL_SIZE 20
|
||||
#endif
|
||||
|
||||
/* IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.*/
|
||||
#if WIFI_LOGO_CERTIFICATION_CONFIG
|
||||
#define IP_REASS_MAX_PBUFS 30 //for ping 10k test
|
||||
#else
|
||||
#define IP_REASS_MAX_PBUFS 10
|
||||
#endif
|
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
|
||||
#define PBUF_POOL_BUFSIZE 500
|
||||
|
||||
|
||||
/* ---------- TCP options ---------- */
|
||||
#define LWIP_TCP 1
|
||||
#define TCP_TTL 255
|
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */
|
||||
#define TCP_QUEUE_OOSEQ 1
|
||||
|
||||
/* TCP Maximum segment size. */
|
||||
#define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
|
||||
|
||||
/* TCP sender buffer space (bytes). */
|
||||
#define TCP_SND_BUF (5*TCP_MSS)
|
||||
|
||||
/* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
|
||||
as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */
|
||||
|
||||
#define TCP_SND_QUEUELEN (4* TCP_SND_BUF/TCP_MSS)
|
||||
|
||||
/* TCP receive window. */
|
||||
#define TCP_WND (4*TCP_MSS)
|
||||
|
||||
|
||||
/* ---------- ICMP options ---------- */
|
||||
#define LWIP_ICMP 1
|
||||
|
||||
/* ---------- ARP options ----------- */
|
||||
#define LWIP_ARP 1
|
||||
|
||||
/* ---------- DHCP options ---------- */
|
||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
|
||||
turning this on does currently not work. */
|
||||
#define LWIP_DHCP 1
|
||||
|
||||
/* ---------- UDP options ---------- */
|
||||
#define LWIP_UDP 1
|
||||
#define UDP_TTL 255
|
||||
/* ---------- DNS options ---------- */
|
||||
#define LWIP_DNS 1
|
||||
|
||||
/* ---------- UPNP options --------- */
|
||||
#define LWIP_UPNP 0
|
||||
|
||||
/* Support Multicast */
|
||||
#define LWIP_IGMP 1
|
||||
#define LWIP_RAND() Rand()
|
||||
|
||||
/* Support TCP Keepalive */
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
/*LWIP_UART_ADAPTER==1: Enable LWIP_UART_ADAPTER when CONFIG_GAGENT is enabled,
|
||||
because some GAGENT functions denpond on the following macro definitions.*/
|
||||
#if CONFIG_EXAMPLE_UART_ADAPTER
|
||||
#define LWIP_UART_ADAPTER 1
|
||||
#else
|
||||
#define LWIP_UART_ADAPTER 0
|
||||
#endif
|
||||
|
||||
#if LWIP_UART_ADAPTER
|
||||
#undef LWIP_SO_SNDTIMEO
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
|
||||
#undef SO_REUSE
|
||||
#define SO_REUSE 1
|
||||
|
||||
#undef MEMP_NUM_NETCONN
|
||||
#define MEMP_NUM_NETCONN 10
|
||||
|
||||
#undef TCP_WND
|
||||
#define TCP_WND (4*TCP_MSS)
|
||||
|
||||
#define TCP_KEEPIDLE_DEFAULT 10000UL
|
||||
#define TCP_KEEPINTVL_DEFAULT 1000UL
|
||||
#define TCP_KEEPCNT_DEFAULT 10U
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||
#undef LWIP_SO_SNDTIMEO
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
|
||||
#undef SO_REUSE
|
||||
#define SO_REUSE 1
|
||||
|
||||
#undef MEMP_NUM_NETCONN
|
||||
#define MEMP_NUM_NETCONN 10
|
||||
|
||||
#undef MEMP_NUM_TCP_PCB
|
||||
#define MEMP_NUM_TCP_PCB (MEMP_NUM_NETCONN)
|
||||
|
||||
#undef MEMP_NUM_UDP_PCB
|
||||
#define MEMP_NUM_UDP_PCB (MEMP_NUM_NETCONN)
|
||||
|
||||
#undef TCP_WND
|
||||
#define TCP_WND (4*TCP_MSS)
|
||||
|
||||
#define TCP_KEEPIDLE_DEFAULT 10000UL
|
||||
#define TCP_KEEPINTVL_DEFAULT 1000UL
|
||||
#define TCP_KEEPCNT_DEFAULT 10U
|
||||
|
||||
#define ERRNO 1
|
||||
#endif
|
||||
|
||||
/* ---------- Statistics options ---------- */
|
||||
#define LWIP_STATS 0
|
||||
#define LWIP_PROVIDE_ERRNO 1
|
||||
|
||||
|
||||
/*
|
||||
--------------------------------------
|
||||
---------- Checksum options ----------
|
||||
--------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
The STM32F2x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware:
|
||||
- To use this feature let the following define uncommented.
|
||||
- To disable it and process by CPU comment the the checksum.
|
||||
*/
|
||||
//Do checksum by lwip - WLAN nic does not support Checksum offload
|
||||
//#define CHECKSUM_BY_HARDWARE
|
||||
|
||||
|
||||
#ifdef CHECKSUM_BY_HARDWARE
|
||||
/* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
|
||||
#define CHECKSUM_GEN_IP 0
|
||||
/* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/
|
||||
#define CHECKSUM_GEN_UDP 0
|
||||
/* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/
|
||||
#define CHECKSUM_GEN_TCP 0
|
||||
/* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/
|
||||
#define CHECKSUM_CHECK_IP 0
|
||||
/* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/
|
||||
#define CHECKSUM_CHECK_UDP 0
|
||||
/* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/
|
||||
#define CHECKSUM_CHECK_TCP 0
|
||||
#else
|
||||
/* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/
|
||||
#define CHECKSUM_GEN_IP 1
|
||||
/* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/
|
||||
#define CHECKSUM_GEN_UDP 1
|
||||
/* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/
|
||||
#define CHECKSUM_GEN_TCP 1
|
||||
/* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/
|
||||
#define CHECKSUM_CHECK_IP 1
|
||||
/* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/
|
||||
#define CHECKSUM_CHECK_UDP 1
|
||||
/* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
|
||||
#define CHECKSUM_CHECK_TCP 1
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
----------------------------------------------
|
||||
---------- Sequential layer options ----------
|
||||
----------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
|
||||
*/
|
||||
#define LWIP_NETCONN 1
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- Socket options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
|
||||
*/
|
||||
#define LWIP_SOCKET 1
|
||||
|
||||
/*
|
||||
-----------------------------------
|
||||
---------- DEBUG options ----------
|
||||
-----------------------------------
|
||||
*/
|
||||
|
||||
#define LWIP_DEBUG 0
|
||||
|
||||
/*
|
||||
---------------------------------
|
||||
---------- OS options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread.
|
||||
* The stack size value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#define TCPIP_THREAD_STACKSIZE 1000
|
||||
/**
|
||||
* TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages
|
||||
* The queue size value itself is platform-dependent, but is passed to
|
||||
* sys_mbox_new() when tcpip_init is called.
|
||||
*/
|
||||
#define TCPIP_MBOX_SIZE 6
|
||||
/**
|
||||
* DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
|
||||
* NETCONN_UDP. The queue size value itself is platform-dependent, but is passed
|
||||
* to sys_mbox_new() when the recvmbox is created.
|
||||
*/
|
||||
#define DEFAULT_UDP_RECVMBOX_SIZE 6
|
||||
/**
|
||||
* DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
|
||||
* NETCONN_TCP. The queue size value itself is platform-dependent, but is passed
|
||||
* to sys_mbox_new() when the recvmbox is created.
|
||||
*/
|
||||
#define DEFAULT_TCP_RECVMBOX_SIZE 6
|
||||
/**
|
||||
* DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
|
||||
* NETCONN_RAW. The queue size value itself is platform-dependent, but is passed
|
||||
* to sys_mbox_new() when the recvmbox is created.
|
||||
*/
|
||||
#define DEFAULT_RAW_RECVMBOX_SIZE 6
|
||||
/**
|
||||
* DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections.
|
||||
* The queue size value itself is platform-dependent, but is passed to
|
||||
* sys_mbox_new() when the acceptmbox is created.
|
||||
*/
|
||||
#define DEFAULT_ACCEPTMBOX_SIZE 6
|
||||
/**
|
||||
* DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread.
|
||||
* The stack size value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#define DEFAULT_THREAD_STACKSIZE 500
|
||||
/**
|
||||
* TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread.
|
||||
* The priority value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#define TCPIP_THREAD_PRIO (configMAX_PRIORITIES - 2)
|
||||
|
||||
/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided
|
||||
* by your system, set this to 0 and include <sys/time.h> in cc.h */
|
||||
#if defined(_SYS__TIMEVAL_H_)
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#endif
|
||||
|
||||
#endif /* __LWIPOPTS_H__ */
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
119
project/inc/main.h
Normal file
119
project/inc/main.h
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <autoconf.h>
|
||||
|
||||
#ifndef CONFIG_WLAN
|
||||
#define CONFIG_WLAN 1
|
||||
#endif
|
||||
|
||||
/* Header file declaration*/
|
||||
void wlan_network();
|
||||
|
||||
/* Interactive Mode */
|
||||
#define SERIAL_DEBUG_RX 1
|
||||
|
||||
/* WLAN and Netork */
|
||||
#define STA_MODE_SSID "ap" /* Set SSID here */
|
||||
#define AP_MODE_SSID "wlan_ap_ssid" /* Set SSID here */
|
||||
#define AP_DEFAULT_CH 6
|
||||
#define WLAN0_NAME "wlan0"
|
||||
#define WLAN1_NAME "wlan1"
|
||||
#define WPA_PASSPHRASE "1234567890" /* Max 32 cahracters */
|
||||
#define WEP40_KEY {0x12, 0x34, 0x56, 0x78, 0x90}
|
||||
|
||||
#define ATVER_1 1 // For First AT command
|
||||
#define ATVER_2 2 // For UART Module AT command
|
||||
|
||||
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||
#define ATCMD_VER ATVER_2
|
||||
#else
|
||||
#define ATCMD_VER ATVER_1
|
||||
#endif
|
||||
|
||||
#if ATCMD_VER == ATVER_2
|
||||
|
||||
extern unsigned char sta_ip[4], sta_netmask[4], sta_gw[4];
|
||||
extern unsigned char ap_ip[4], ap_netmask[4], ap_gw[4];
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define IP_ADDR0 sta_ip[0]
|
||||
#define IP_ADDR1 sta_ip[1]
|
||||
#define IP_ADDR2 sta_ip[2]
|
||||
#define IP_ADDR3 sta_ip[3]
|
||||
|
||||
/*NETMASK*/
|
||||
#define NETMASK_ADDR0 sta_netmask[0]
|
||||
#define NETMASK_ADDR1 sta_netmask[1]
|
||||
#define NETMASK_ADDR2 sta_netmask[2]
|
||||
#define NETMASK_ADDR3 sta_netmask[3]
|
||||
|
||||
/*Gateway Address*/
|
||||
#define GW_ADDR0 sta_gw[0]
|
||||
#define GW_ADDR1 sta_gw[1]
|
||||
#define GW_ADDR2 sta_gw[2]
|
||||
#define GW_ADDR3 sta_gw[3]
|
||||
|
||||
/*******************************************/
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define AP_IP_ADDR0 ap_ip[0]
|
||||
#define AP_IP_ADDR1 ap_ip[1]
|
||||
#define AP_IP_ADDR2 ap_ip[2]
|
||||
#define AP_IP_ADDR3 ap_ip[3]
|
||||
|
||||
/*NETMASK*/
|
||||
#define AP_NETMASK_ADDR0 ap_netmask[0]
|
||||
#define AP_NETMASK_ADDR1 ap_netmask[1]
|
||||
#define AP_NETMASK_ADDR2 ap_netmask[2]
|
||||
#define AP_NETMASK_ADDR3 ap_netmask[3]
|
||||
|
||||
/*Gateway Address*/
|
||||
#define AP_GW_ADDR0 ap_gw[0]
|
||||
#define AP_GW_ADDR1 ap_gw[1]
|
||||
#define AP_GW_ADDR2 ap_gw[2]
|
||||
#define AP_GW_ADDR3 ap_gw[3]
|
||||
|
||||
#else
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define IP_ADDR0 192
|
||||
#define IP_ADDR1 168
|
||||
#define IP_ADDR2 3
|
||||
#define IP_ADDR3 80
|
||||
|
||||
/*NETMASK*/
|
||||
#define NETMASK_ADDR0 255
|
||||
#define NETMASK_ADDR1 255
|
||||
#define NETMASK_ADDR2 255
|
||||
#define NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define GW_ADDR0 192
|
||||
#define GW_ADDR1 168
|
||||
#define GW_ADDR2 3
|
||||
#define GW_ADDR3 1
|
||||
|
||||
/*******************************************/
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define AP_IP_ADDR0 192
|
||||
#define AP_IP_ADDR1 168
|
||||
#define AP_IP_ADDR2 43
|
||||
#define AP_IP_ADDR3 1
|
||||
|
||||
/*NETMASK*/
|
||||
#define AP_NETMASK_ADDR0 255
|
||||
#define AP_NETMASK_ADDR1 255
|
||||
#define AP_NETMASK_ADDR2 255
|
||||
#define AP_NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define AP_GW_ADDR0 192
|
||||
#define AP_GW_ADDR1 168
|
||||
#define AP_GW_ADDR2 43
|
||||
#define AP_GW_ADDR3 1
|
||||
|
||||
#endif //#if ATCMD_VER == ATVER_2
|
||||
|
||||
#endif
|
||||
251
project/inc/platform_autoconf.h
Normal file
251
project/inc/platform_autoconf.h
Normal file
|
|
@ -0,0 +1,251 @@
|
|||
/*
|
||||
*
|
||||
*/
|
||||
#define AUTOCONF_INCLUDED
|
||||
|
||||
#define RTL8710AF
|
||||
//#define RTL8711AM
|
||||
/* Image1 on project */
|
||||
#define PRESENT_IMAGE1
|
||||
/* Image2 on project */
|
||||
#define PRESENT_IMAGE2
|
||||
/*
|
||||
* Target Platform Selection
|
||||
*/
|
||||
#define CONFIG_WITHOUT_MONITOR 1
|
||||
|
||||
#undef CONFIG_RTL8195A
|
||||
#define CONFIG_RTL8195A 1
|
||||
#undef CONFIG_FPGA
|
||||
#undef CONFIG_RTL_SIM
|
||||
#undef CONFIG_POST_SIM
|
||||
/*
|
||||
* < Mass Production Option
|
||||
*/
|
||||
#undef CONFIG_MP
|
||||
#undef CONFIG_CP
|
||||
#undef CONFIG_FT
|
||||
#define RTL8195A 1
|
||||
/* 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000? Hz,
|
||||
6 - 200000000 Hz, 7 - 10000000 Hz, 8 - 50000000 Hz, 9 - 25000000 Hz, 10 - 12500000 Hz, 11 - 4000000? Hz */
|
||||
#define CONFIG_CPU_CLK 1
|
||||
//166.6MHZ - RUN/IDLE/SLP ~63/21/6.4 mA
|
||||
//83.3MHZ - RUN/IDLE/SLP ~55/15/6.4 mA
|
||||
//41.6MHZ - RUN/IDLE ~51/11 mA
|
||||
//20.8MHZ - RUN/IDLE ~49/9.5 mA
|
||||
//4MHZ - IDLE ~8 mA
|
||||
#undef CONFIG_FPGA_CLK
|
||||
#define CONFIG_SDR_CLK 1
|
||||
#define CONFIG_SDR_100MHZ 1
|
||||
#undef CONFIG_SDR_50MHZ
|
||||
#undef CONFIG_SDR_25MHZ
|
||||
#undef CONFIG_SDR_12_5MHZ
|
||||
#define SDR_CLOCK_SEL_VALUE (0)
|
||||
#define CONFIG_BOOT_PROCEDURE 1
|
||||
#define CONFIG_IMAGE_PAGE_LOAD 1
|
||||
#undef CONFIG_IMAGE_AUTO_LOAD
|
||||
#undef CONFIG_IMAGE_PAGE_LOAD
|
||||
//#define CONFIG_IMAGE_AUTO_LOAD 1
|
||||
//#define CONFIG_BOOT_TO_UPGRADE_IMG2 1
|
||||
#undef CONFIG_PERI_UPDATE_IMG
|
||||
#define CONFIG_BOOT_FROM_JTAG 1
|
||||
#undef CONFIG_ALIGNMENT_EXCEPTION_ENABLE
|
||||
#define CONFIG_KERNEL 1
|
||||
#define PLATFORM_FREERTOS 1
|
||||
#undef PLATFORM_UCOSII
|
||||
#undef PLATFORM_ECOS
|
||||
#undef CONFIG_TASK_SCHEDUL_DIS
|
||||
#define TASK_SCHEDULER_DISABLED (0)
|
||||
#define CONFIG_NORMALL_MODE 1
|
||||
#undef CONFIG_MEMORY_VERIFY_MODE
|
||||
#define CONFIG_TIMER_EN 1
|
||||
#define CONFIG_TIMER_NORMAL 1
|
||||
#undef CONFIG_TIMER_TEST
|
||||
#define CONFIG_TIMER_MODULE 1
|
||||
#define CONFIG_WDG 1
|
||||
#undef CONFIG_WDG_NON
|
||||
#define CONFIG_WDG_NORMAL 1
|
||||
#define CONFIG_WDG_ON_IDLE 10 // wdt in sec -> main.c + tasks.c
|
||||
#define CONFIG_GDMA_EN 1
|
||||
#define CONFIG_GDMA_NORMAL 1
|
||||
#undef CONFIG_GDMA_TEST
|
||||
#define CONFIG_GDMA_MODULE 1
|
||||
#define CONFIG_WIFI_EN 1
|
||||
#define CONFIG_WIFI_NORMAL 1
|
||||
#undef CONFIG_WIFI_TEST
|
||||
#define CONFIG_WIFI_MODULE 1
|
||||
#define CONFIG_GPIO_EN 1
|
||||
#define CONFIG_GPIO_NORMAL 1
|
||||
#undef CONFIG_GPIO_TEST
|
||||
#define CONFIG_GPIO_MODULE 1
|
||||
#if defined(CONFIG_INIC) || (CONFIG_SDIOD)
|
||||
#define CONFIG_SDIO_DEVICE_EN 1
|
||||
#define CONFIG_SDIO_DEVICE_NORMAL 1
|
||||
#undef CONFIG_SDIO_DEVICE_TEST
|
||||
#define CONFIG_SDIO_DEVICE_MODULE 1
|
||||
#else
|
||||
#undef CONFIG_SDIO_DEVICE_EN
|
||||
#endif
|
||||
#define CONFIG_SDIO_HOST_EN 1
|
||||
//#define CONFIG_USB_EN 1
|
||||
#undef CONFIG_USB_NORMAL
|
||||
#define CONFIG_USB_TEST 1
|
||||
#define CONFIG_USB_MODULE 1
|
||||
#define CONFIG_USB_VERIFY 1
|
||||
#undef CONFIG_USB_ROM_LIB
|
||||
//#define CONFIG_USB_DBGINFO_EN 1
|
||||
#if defined(CONFIG_INIC) || (CONFIG_USBD)
|
||||
#define DWC_DEVICE_ONLY 1
|
||||
#else
|
||||
#define DWC_HOST_ONLY 1
|
||||
#define CONFIG_USB_HOST_ONLY 1
|
||||
#endif
|
||||
#define CONFIG_SPI_COM_EN 1
|
||||
#define CONFIG_SPI_COM_NORMAL 1
|
||||
#undef CONFIG_SPI_COM_TEST
|
||||
#define CONFIG_SPI_COM_MODULE 1
|
||||
#define CONFIG_UART_EN 1
|
||||
#define CONFIG_UART_NORMAL 1
|
||||
#undef CONFIG_UART_TEST
|
||||
#define CONFIG_UART_MODULE 1
|
||||
#define CONFIG_I2C_EN 1
|
||||
#define CONFIG_I2C_NORMAL 1
|
||||
#undef CONFIG_I2C_TEST
|
||||
#define CONFIG_I2C_MODULE 1
|
||||
#undef CONFIG_DEBUG_LOG_I2C_HAL
|
||||
#undef CONFIG_PCM_EN
|
||||
#define CONFIG_I2S_EN 1
|
||||
#define CONFIG_I2S_NORMAL 1
|
||||
#undef CONFIG_I2S_TEST
|
||||
#define CONFIG_I2S_MODULE 1
|
||||
#undef CONFIG_DEBUG_LOG_I2S_HAL
|
||||
#define CONFIG_NFC_EN 1
|
||||
#define CONFIG_NFC_NORMAL 1
|
||||
#undef CONFIG_NFC_TEST
|
||||
#define CONFIG_NFC_MODULE 1
|
||||
#define CONFIG_SOC_PS_EN 1
|
||||
#define CONFIG_SOC_PS_NORMAL 1
|
||||
#undef CONFIG_SOC_PS_TEST
|
||||
#define CONFIG_SOC_PS_MODULE 1 // hal_soc_ps_monitor.c
|
||||
//#define CONFIG_SOC_PS_VERIFY 1 // hal_soc_ps_monitor.c
|
||||
#define CONFIG_CRYPTO_EN 1
|
||||
#define CONFIG_CRYPTO_NORMAL 1
|
||||
#undef CONFIG_CRYPTO_TEST
|
||||
#define CONFIG_CRYPTO_MODULE 1
|
||||
#define CONFIG_CRYPTO_STARTUP 1
|
||||
#define CONFIG_MII_EN 0 //1
|
||||
#define CONFIG_PWM_EN 1
|
||||
#define CONFIG_PWM_NORMAL 1
|
||||
#undef CONFIG_PWM_TEST
|
||||
#define CONFIG_PWM_MODULE 1
|
||||
#define CONFIG_EFUSE_EN 1 // common/mbed/targets/hal/rtl8195a/efuse_api.c
|
||||
#define CONFIG_EFUSE_NORMAL 1
|
||||
#undef CONFIG_EFUSE_TEST
|
||||
#define CONFIG_EFUSE_MODULE 1
|
||||
#ifdef RTL8711AM
|
||||
#define CONFIG_SDR_EN 1
|
||||
#endif
|
||||
#define CONFIG_SDR_NORMAL 1
|
||||
#undef CONFIG_SDR_TEST
|
||||
#define CONFIG_SDR_MODULE 1
|
||||
#define CONFIG_SPIC_EN 1
|
||||
#define CONFIG_SPIC_NORMAL 1
|
||||
#undef CONFIG_SPIC_TEST
|
||||
#define CONFIG_SPIC_MODULE 1
|
||||
#define CONFIG_ADC_EN 1
|
||||
//#define CONFIG_DAC_EN 1
|
||||
#define CONFIG_NOR_FLASH 1
|
||||
#undef CONFIG_SPI_FLASH
|
||||
#undef CONFIG_NAND_FLASH
|
||||
#undef CONFIG_NONE_FLASH
|
||||
#undef CONFIG_BTBX_EN
|
||||
|
||||
// add pvvx
|
||||
#define CONFIG_LOG_UART_EN 1
|
||||
|
||||
/*
|
||||
* < Engineer Mode Config
|
||||
*/
|
||||
#undef CONFIG_JTAG
|
||||
#undef CONFIG_COMPILE_FLASH_DOWNLOAD_CODE
|
||||
#undef CONIFG_COMPILE_EXTERNAL_SRAM_CALIBRATE
|
||||
#undef CONFIG_CMSIS_MATH_LIB_EN
|
||||
|
||||
/*
|
||||
* < Application Config
|
||||
*/
|
||||
#define CONFIG_NETWORK 1
|
||||
#define CONFIG_RTLIB_EN 1
|
||||
#define CONFIG_RTLIB_NORMAL 1
|
||||
#undef CONFIG_RTLIB_TEST
|
||||
#define CONFIG_RTLIB_MODULE 1
|
||||
|
||||
/*
|
||||
* < System Debug Message Config
|
||||
*/
|
||||
#define CONFIG_UART_LOG_HISTORY 1
|
||||
#undef CONFIG_CONSOLE_NORMALL_MODE
|
||||
#define CONFIG_CONSOLE_VERIFY_MODE 1
|
||||
|
||||
/* CONFIG_DEBUG_LOG:
|
||||
=0 Off all diag/debug msg,
|
||||
=1 Only errors,
|
||||
=2 errors + warning, (default)
|
||||
=3 errors + warning + info,
|
||||
=4 errors + warning + info + debug,
|
||||
=5 full */
|
||||
#define CONFIG_DEBUG_LOG 2
|
||||
#if CONFIG_DEBUG_LOG > 0
|
||||
//#define CONFIG_DEBUG_ERR_MSG 1
|
||||
#define CONFIG_DEBUG_LOG_ADC_HAL 1
|
||||
#define CONFIG_DEBUG_LOG_I2S_HAL 1
|
||||
//#undef CONFIG_DEBUG_WARN_MSG
|
||||
//#undef CONFIG_DEBUG_INFO_MSG
|
||||
#endif // CONFIG_DEBUG_LOG
|
||||
/*
|
||||
* < SDK Option Config
|
||||
*/
|
||||
#undef CONFIG_MBED_ENABLED
|
||||
#undef CONFIG_APP_DEMO
|
||||
|
||||
/*
|
||||
* < Select Chip Version
|
||||
*/
|
||||
#undef CONFIG_CHIP_A_CUT
|
||||
#define CONFIG_CHIP_B_CUT 1
|
||||
#undef CONFIG_CHIP_C_CUT
|
||||
#undef CONFIG_CHIP_E_CUT
|
||||
|
||||
/*
|
||||
* < Select toolchain
|
||||
*/
|
||||
#undef CONFIG_TOOLCHAIN_ASDK
|
||||
#undef CONFIG_TOOLCHAIN_ARM_GCC
|
||||
|
||||
/*
|
||||
* < Build Option
|
||||
*/
|
||||
#define CONFIG_LINK_ROM_LIB 1
|
||||
#undef CONFIG_LINK_ROM_SYMB
|
||||
#undef CONFIG_NORMAL_BUILD
|
||||
#undef CONFIG_RELEASE_BUILD
|
||||
#undef CONFIG_RELEASE_BUILD_LIBRARIES
|
||||
#undef CONFIG_LIB_BUILD_RAM
|
||||
#define CONFIG_RELEASE_BUILD_RAM_ALL 1
|
||||
#undef CONFIG_IMAGE_ALL
|
||||
#define CONFIG_IMAGE_SEPARATE 1
|
||||
|
||||
#if CONFIG_CPU_CLK < 6
|
||||
#define CPU_CLOCK_SEL_DIV5_3 0
|
||||
#define CPU_CLOCK_SEL_VALUE CONFIG_CPU_CLK
|
||||
#else
|
||||
#define CPU_CLOCK_SEL_DIV5_3 1
|
||||
#define CPU_CLOCK_SEL_VALUE (CONFIG_CPU_CLK-6)
|
||||
#endif
|
||||
|
||||
#if CPU_CLOCK_SEL_DIV5_3
|
||||
#define PLATFORM_CLOCK (200000000ul>>CPU_CLOCK_SEL_VALUE)
|
||||
#else
|
||||
#define PLATFORM_CLOCK (((200000000ul*5ul)/6ul)>>CPU_CLOCK_SEL_VALUE)
|
||||
#endif
|
||||
|
||||
171
project/inc/platform_opts.h
Normal file
171
project/inc/platform_opts.h
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
*This file contains general configurations for ameba platform
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __PLATFORM_OPTS_H__
|
||||
#define __PLATFORM_OPTS_H__
|
||||
|
||||
/*For MP mode setting*/
|
||||
#define SUPPORT_MP_MODE 0
|
||||
|
||||
/**
|
||||
* For AT cmd Log service configurations
|
||||
*/
|
||||
#define SUPPORT_LOG_SERVICE 0
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
#define LOG_SERVICE_BUFLEN 100 //can't larger than UART_LOG_CMD_BUFLEN(127)
|
||||
#define CONFIG_LOG_HISTORY 0
|
||||
#if CONFIG_LOG_HISTORY
|
||||
#define LOG_HISTORY_LEN 5
|
||||
#endif
|
||||
#define SUPPORT_INTERACTIVE_MODE 0 //on/off wifi_interactive_mode
|
||||
#define CONFIG_LOG_SERVICE_LOCK 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For interactive mode configurations, depends on log service
|
||||
*/
|
||||
#if SUPPORT_INTERACTIVE_MODE
|
||||
#define CONFIG_INTERACTIVE_MODE 1
|
||||
#define CONFIG_INTERACTIVE_EXT 0
|
||||
#else
|
||||
#define CONFIG_INTERACTIVE_MODE 0
|
||||
#define CONFIG_INTERACTIVE_EXT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For FreeRTOS tickless configurations
|
||||
*/
|
||||
#define FREERTOS_PMU_TICKLESS_PLL_RESERVED 0 // In sleep mode, 0: close PLL clock, 1: reserve PLL clock
|
||||
#define FREERTOS_PMU_TICKLESS_SUSPEND_SDRAM 1 // In sleep mode, 1: suspend SDRAM, 0: no act
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* For common flash usage
|
||||
*/
|
||||
#define AP_SETTING_SECTOR 0x000FE000
|
||||
#define UART_SETTING_SECTOR 0x000FC000
|
||||
#define FAST_RECONNECT_DATA (0x80000 - 0x1000)
|
||||
|
||||
/**
|
||||
* For Wlan configurations
|
||||
*/
|
||||
#define CONFIG_WLAN 1
|
||||
#if CONFIG_WLAN
|
||||
#define CONFIG_LWIP_LAYER 1
|
||||
#define CONFIG_AT_USR 1 // add pvxx
|
||||
//#define CONFIG_AT_LWIP 1 // add pvxx
|
||||
//#define CONFIG_AT_SYS 1 // add pvxx
|
||||
//#define CONFIG_AT_WIFI 1 // add pvxx
|
||||
#define CONFIG_INIT_NET 1 // init lwip layer when start up
|
||||
#define CONFIG_WIFI_IND_USE_THREAD 0 // wifi indicate worker thread
|
||||
|
||||
//on/off relative commands in log service
|
||||
#define CONFIG_SSL_CLIENT 0
|
||||
#define CONFIG_WEBSERVER 0
|
||||
#define CONFIG_OTA_UPDATE 1
|
||||
#define CONFIG_BSD_TCP 1 //NOTE : Enable CONFIG_BSD_TCP will increase about 11KB code size
|
||||
#define CONFIG_AIRKISS 0 //on or off tencent airkiss
|
||||
#define CONFIG_UART_SOCKET 0 // Set: CONFIG_UART_EN, CONFIG_UART_SOCKET
|
||||
#define CONFIG_UART_XMODEM 0 //support uart xmodem upgrade or not
|
||||
#define CONFIG_TRANSPORT 0 //on or off the at command for transport socket
|
||||
|
||||
/* For WPS and P2P */
|
||||
#define CONFIG_ENABLE_WPS 1 //SK Hack
|
||||
#define CONFIG_ENABLE_P2P 1 //SK Hack
|
||||
#if CONFIG_ENABLE_P2P
|
||||
#define CONFIG_ENABLE_WPS_AP 1
|
||||
#undef CONFIG_WIFI_IND_USE_THREAD
|
||||
#define CONFIG_WIFI_IND_USE_THREAD 1
|
||||
#endif
|
||||
#if (CONFIG_ENABLE_P2P && ((CONFIG_ENABLE_WPS_AP == 0) || (CONFIG_ENABLE_WPS == 0)))
|
||||
#error "If CONFIG_ENABLE_P2P, need to define CONFIG_ENABLE_WPS_AP 1"
|
||||
#endif
|
||||
|
||||
/* For Simple Link */
|
||||
#define CONFIG_INCLUDE_SIMPLE_CONFIG 0
|
||||
|
||||
/*For wowlan service settings*/
|
||||
#define CONFIG_WOWLAN_SERVICE 0
|
||||
|
||||
#endif //end of #if CONFIG_WLAN
|
||||
/*******************************************************************************/
|
||||
|
||||
/**
|
||||
* For Ethernet configurations
|
||||
*/
|
||||
#define CONFIG_ETHERNET 0
|
||||
#if CONFIG_ETHERNET
|
||||
|
||||
#define CONFIG_LWIP_LAYER 1
|
||||
#define CONFIG_INIT_NET 1 //init lwip layer when start up
|
||||
|
||||
//on/off relative commands in log service
|
||||
#define CONFIG_SSL_CLIENT 0
|
||||
#define CONFIG_BSD_TCP 0 //NOTE : Enable CONFIG_BSD_TCP will increase about 11KB code size
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* For iNIC configurations
|
||||
*/
|
||||
#ifdef CONFIG_INIC //this flag is defined in IAR project
|
||||
#define CONFIG_INIC_EN 1 //enable iNIC mode
|
||||
#undef CONFIG_ENABLE_WPS
|
||||
#define CONFIG_ENABLE_WPS 1
|
||||
#undef CONFIG_INCLUDE_SIMPLE_CONFIG
|
||||
#define CONFIG_INCLUDE_SIMPLE_CONFIG 1
|
||||
#undef CONFIG_WOWLAN_SERVICE
|
||||
#define CONFIG_WOWLAN_SERVICE 1
|
||||
#undef LOG_SERVICE_BUFLEN
|
||||
#define LOG_SERVICE_BUFLEN 256
|
||||
#undef CONFIG_LWIP_LAYER
|
||||
#define CONFIG_LWIP_LAYER 0
|
||||
#undef CONFIG_OTA_UPDATE
|
||||
#define CONFIG_OTA_UPDATE 0
|
||||
#undef CONFIG_EXAMPLE_WLAN_FAST_CONNECT
|
||||
#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 0
|
||||
#define CONFIG_INIC_SDIO_HCI 1 //for SDIO or USB iNIC
|
||||
#define CONFIG_INIC_USB_HCI 0
|
||||
#define CONFIG_INIC_CMD_RSP 1 //need to return msg to host
|
||||
#endif
|
||||
/******************End of iNIC configurations*******************/
|
||||
|
||||
/* For UART Module AT command example */
|
||||
#define CONFIG_EXAMPLE_UART_ATCMD 0
|
||||
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||
#undef FREERTOS_PMU_TICKLESS_PLL_RESERVED
|
||||
#define FREERTOS_PMU_TICKLESS_PLL_RESERVED 1
|
||||
#undef CONFIG_OTA_UPDATE
|
||||
#define CONFIG_OTA_UPDATE 1
|
||||
#undef CONFIG_TRANSPORT
|
||||
#define CONFIG_TRANSPORT 1
|
||||
#undef LOG_SERVICE_BUFLEN
|
||||
#define LOG_SERVICE_BUFLEN 1600
|
||||
#undef CONFIG_LOG_SERVICE_LOCK
|
||||
#define CONFIG_LOG_SERVICE_LOCK 1
|
||||
#else
|
||||
#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 0
|
||||
#endif
|
||||
|
||||
//#define CONFIG_EXAMPLE_UART_ADAPTER 1
|
||||
//#define CONFIG_EXAMPLE_MDNS
|
||||
#define USE_FLASH_EEP 1
|
||||
#define CONFIG_WLAN_CONNECT_CB 1
|
||||
|
||||
//#define CONFIG_FATFS_EN 1 // FatFs & SD
|
||||
|
||||
#ifdef CONFIG_FATFS_EN
|
||||
// fatfs version
|
||||
#define FATFS_R_10C
|
||||
// fatfs disk interface
|
||||
#define FATFS_DISK_USB 0
|
||||
#define FATFS_DISK_SD 1
|
||||
#undef CONFIG_SDIO_HOST_EN
|
||||
#define CONFIG_SDIO_HOST_EN 1
|
||||
#endif
|
||||
|
||||
#endif // __PLATFORM_OPTS_H__
|
||||
96
project/inc/rtl8195a/c_types.h
Normal file
96
project/inc/rtl8195a/c_types.h
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (c) 2010 - 2011 Espressif System
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _C_TYPES_H_
|
||||
#define _C_TYPES_H_
|
||||
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed char sint8_t;
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed short sint16_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned long uint32_t;
|
||||
typedef signed long sint32_t;
|
||||
typedef signed long int32_t;
|
||||
typedef signed long long sint64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef unsigned long long u_int64_t;
|
||||
typedef float real32_t;
|
||||
typedef double real64_t;
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned char u8;
|
||||
typedef signed char sint8;
|
||||
typedef signed char int8;
|
||||
typedef signed char s8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned short u16;
|
||||
typedef signed short sint16;
|
||||
typedef signed short s16;
|
||||
typedef unsigned int uint32;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned int u32;
|
||||
typedef signed int sint32;
|
||||
typedef signed int s32;
|
||||
typedef int int32;
|
||||
typedef signed long long sint64;
|
||||
typedef unsigned long long uint64;
|
||||
typedef unsigned long long u64;
|
||||
typedef float real32;
|
||||
typedef double real64;
|
||||
|
||||
#define __le16 u16
|
||||
|
||||
typedef unsigned int size_t;
|
||||
typedef int ssize_t;
|
||||
|
||||
#ifndef _SYS_CDEFS_H_
|
||||
#define __packed __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#define LOCAL static
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif /* NULL */
|
||||
|
||||
/* probably should not put STATUS here */
|
||||
typedef enum {
|
||||
OK = 0,
|
||||
FAIL,
|
||||
PENDING,
|
||||
BUSY,
|
||||
CANCEL,
|
||||
} STATUS;
|
||||
|
||||
#define BIT(nr) (1UL << (nr))
|
||||
|
||||
#define REG_SET_BIT(_r, _b) (*(volatile uint32_t*)(_r) |= (_b))
|
||||
#define REG_CLR_BIT(_r, _b) (*(volatile uint32_t*)(_r) &= ~(_b))
|
||||
|
||||
#define DMEM_ATTR
|
||||
#define SHMEM_ATTR
|
||||
|
||||
#ifdef ICACHE_FLASH
|
||||
#define ICACHE_FLASH_ATTR
|
||||
#define ICACHE_RODATA_ATTR
|
||||
#else
|
||||
#define ICACHE_FLASH_ATTR
|
||||
#define ICACHE_RODATA_ATTR
|
||||
#endif /* ICACHE_FLASH */
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef unsigned char bool;
|
||||
//#define BOOL bool
|
||||
#define true (1)
|
||||
#define false (0)
|
||||
#define TRUE true
|
||||
#define FALSE false
|
||||
|
||||
|
||||
#endif /* !__cplusplus */
|
||||
|
||||
#endif /* _C_TYPES_H_ */
|
||||
593
project/inc/rtl8195a/os.h
Normal file
593
project/inc/rtl8195a/os.h
Normal file
|
|
@ -0,0 +1,593 @@
|
|||
/*
|
||||
* OS specific functions
|
||||
* Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef OS_H
|
||||
#define OS_H
|
||||
|
||||
//#include "basic_types.h"
|
||||
#include <autoconf.h>
|
||||
#include "osdep_service.h"
|
||||
#include "freertos/wrapper.h"
|
||||
#include "utils/rom/rom_wps_os.h"
|
||||
|
||||
typedef void* xqueue_handle_t;
|
||||
|
||||
typedef long os_time_t;
|
||||
|
||||
typedef _timer os_timer;
|
||||
|
||||
/**
|
||||
* os_sleep - Sleep (sec, usec)
|
||||
* @sec: Number of seconds to sleep
|
||||
* @usec: Number of microseconds to sleep
|
||||
*/
|
||||
void os_sleep(os_time_t sec, os_time_t usec);
|
||||
|
||||
struct os_time {
|
||||
os_time_t sec;
|
||||
os_time_t usec;
|
||||
};
|
||||
|
||||
struct os_reltime {
|
||||
os_time_t sec;
|
||||
os_time_t usec;
|
||||
};
|
||||
|
||||
/**
|
||||
* os_get_time - Get current time (sec, usec)
|
||||
* @t: Pointer to buffer for the time
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_get_time(struct os_time *t);
|
||||
|
||||
int os_get_reltime(struct os_reltime *t);
|
||||
/* Helper macros for handling struct os_time */
|
||||
/* (&timeout->time, &tmp->time) */
|
||||
#define os_time_before(a, b) \
|
||||
((a)->sec < (b)->sec || \
|
||||
((a)->sec == (b)->sec && (a)->usec < (b)->usec))
|
||||
|
||||
#define os_time_sub(a, b, res) do { \
|
||||
(res)->sec = (a)->sec - (b)->sec; \
|
||||
(res)->usec = (a)->usec - (b)->usec; \
|
||||
if ((res)->usec < 0) { \
|
||||
(res)->sec--; \
|
||||
(res)->usec += 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* os_mktime - Convert broken-down time into seconds since 1970-01-01
|
||||
* @year: Four digit year
|
||||
* @month: Month (1 .. 12)
|
||||
* @day: Day of month (1 .. 31)
|
||||
* @hour: Hour (0 .. 23)
|
||||
* @min: Minute (0 .. 59)
|
||||
* @sec: Second (0 .. 60)
|
||||
* @t: Buffer for returning calendar time representation (seconds since
|
||||
* 1970-01-01 00:00:00)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Note: The result is in seconds from Epoch, i.e., in UTC, not in local time
|
||||
* which is used by POSIX mktime().
|
||||
*/
|
||||
int os_mktime(int year, int month, int day, int hour, int min, int sec,
|
||||
os_time_t *t);
|
||||
|
||||
struct os_tm {
|
||||
int sec; /* 0..59 or 60 for leap seconds */
|
||||
int min; /* 0..59 */
|
||||
int hour; /* 0..23 */
|
||||
int day; /* 1..31 */
|
||||
int month; /* 1..12 */
|
||||
int year; /* Four digit year */
|
||||
};
|
||||
|
||||
int os_gmtime(os_time_t t, struct os_tm *tm);
|
||||
|
||||
/* Helpers for handling struct os_time */
|
||||
|
||||
/* Helpers for handling struct os_reltime */
|
||||
|
||||
static inline int os_reltime_before(struct os_reltime *a,
|
||||
struct os_reltime *b)
|
||||
{
|
||||
return os_time_before(a,b);
|
||||
}
|
||||
|
||||
|
||||
static inline void os_reltime_sub(struct os_reltime *a, struct os_reltime *b,
|
||||
struct os_reltime *res)
|
||||
{
|
||||
os_time_sub(a,b,res);
|
||||
}
|
||||
|
||||
|
||||
static inline void os_reltime_age(struct os_reltime *start,
|
||||
struct os_reltime *age)
|
||||
{
|
||||
struct os_reltime now;
|
||||
|
||||
os_get_time((struct os_time *)&now);
|
||||
os_reltime_sub(&now, start, age);
|
||||
}
|
||||
|
||||
|
||||
static inline int os_reltime_expired(struct os_reltime *now,
|
||||
struct os_reltime *ts,
|
||||
os_time_t timeout_secs)
|
||||
{
|
||||
struct os_reltime age;
|
||||
|
||||
os_reltime_sub(now, ts, &age);
|
||||
return (age.sec > timeout_secs) ||
|
||||
(age.sec == timeout_secs && age.usec > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* os_daemonize - Run in the background (detach from the controlling terminal)
|
||||
* @pid_file: File name to write the process ID to or %NULL to skip this
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_daemonize(const char *pid_file);
|
||||
|
||||
/**
|
||||
* os_daemonize_terminate - Stop running in the background (remove pid file)
|
||||
* @pid_file: File name to write the process ID to or %NULL to skip this
|
||||
*/
|
||||
void os_daemonize_terminate(const char *pid_file);
|
||||
|
||||
/**
|
||||
* os_get_random - Get cryptographically strong pseudo random data
|
||||
* @buf: Buffer for pseudo random data
|
||||
* @len: Length of the buffer
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_get_random(unsigned char *buf, size_t len);
|
||||
|
||||
/**
|
||||
* os_random - Get pseudo random value (not necessarily very strong)
|
||||
* Returns: Pseudo random value
|
||||
*/
|
||||
unsigned long os_random(void);
|
||||
|
||||
/**
|
||||
* os_rel2abs_path - Get an absolute path for a file
|
||||
* @rel_path: Relative path to a file
|
||||
* Returns: Absolute path for the file or %NULL on failure
|
||||
*
|
||||
* This function tries to convert a relative path of a file to an absolute path
|
||||
* in order for the file to be found even if current working directory has
|
||||
* changed. The returned value is allocated and caller is responsible for
|
||||
* freeing it. It is acceptable to just return the same path in an allocated
|
||||
* buffer, e.g., return strdup(rel_path). This function is only used to find
|
||||
* configuration files when os_daemonize() may have changed the current working
|
||||
* directory and relative path would be pointing to a different location.
|
||||
*/
|
||||
char * os_rel2abs_path(const char *rel_path);
|
||||
|
||||
/**
|
||||
* os_program_init - Program initialization (called at start)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is called when a programs starts. If there are any OS specific
|
||||
* processing that is needed, it can be placed here. It is also acceptable to
|
||||
* just return 0 if not special processing is needed.
|
||||
*/
|
||||
int os_program_init(void);
|
||||
|
||||
/**
|
||||
* os_program_deinit - Program deinitialization (called just before exit)
|
||||
*
|
||||
* This function is called just before a program exists. If there are any OS
|
||||
* specific processing, e.g., freeing resourced allocated in os_program_init(),
|
||||
* it should be done here. It is also acceptable for this function to do
|
||||
* nothing.
|
||||
*/
|
||||
void os_program_deinit(void);
|
||||
|
||||
/**
|
||||
* os_setenv - Set environment variable
|
||||
* @name: Name of the variable
|
||||
* @value: Value to set to the variable
|
||||
* @overwrite: Whether existing variable should be overwritten
|
||||
* Returns: 0 on success, -1 on error
|
||||
*
|
||||
* This function is only used for wpa_cli action scripts. OS wrapper does not
|
||||
* need to implement this if such functionality is not needed.
|
||||
*/
|
||||
int os_setenv(const char *name, const char *value, int overwrite);
|
||||
|
||||
/**
|
||||
* os_unsetenv - Delete environent variable
|
||||
* @name: Name of the variable
|
||||
* Returns: 0 on success, -1 on error
|
||||
*
|
||||
* This function is only used for wpa_cli action scripts. OS wrapper does not
|
||||
* need to implement this if such functionality is not needed.
|
||||
*/
|
||||
int os_unsetenv(const char *name);
|
||||
|
||||
/**
|
||||
* os_readfile - Read a file to an allocated memory buffer
|
||||
* @name: Name of the file to read
|
||||
* @len: For returning the length of the allocated buffer
|
||||
* Returns: Pointer to the allocated buffer or %NULL on failure
|
||||
*
|
||||
* This function allocates memory and reads the given file to this buffer. Both
|
||||
* binary and text files can be read with this function. The caller is
|
||||
* responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
char * os_readfile(const char *name, size_t *len);
|
||||
|
||||
//#if 0
|
||||
/**
|
||||
* os_zalloc - Allocate and zero memory
|
||||
* @size: Number of bytes to allocate
|
||||
* Returns: Pointer to allocated and zeroed memory or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
void * os_zalloc(size_t size);
|
||||
|
||||
/**
|
||||
* os_calloc - Allocate and zero memory for an array
|
||||
* @nmemb: Number of members in the array
|
||||
* @size: Number of bytes in each member
|
||||
* Returns: Pointer to allocated and zeroed memory or %NULL on failure
|
||||
*
|
||||
* This function can be used as a wrapper for os_zalloc(nmemb * size) when an
|
||||
* allocation is used for an array. The main benefit over os_zalloc() is in
|
||||
* having an extra check to catch integer overflows in multiplication.
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
static inline void * os_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
if (size && nmemb > (~(size_t) 0) / size)
|
||||
return NULL;
|
||||
return os_zalloc(nmemb * size);
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
static inline int os_memcmp_const(const void *a, const void *b, size_t len)
|
||||
{
|
||||
const u8 *aa = a;
|
||||
const u8 *bb = b;
|
||||
size_t i;
|
||||
u8 res;
|
||||
|
||||
for (res = 0, i = 0; i < len; i++)
|
||||
res |= aa[i] ^ bb[i];
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following functions are wrapper for standard ANSI C or POSIX functions.
|
||||
* By default, they are just defined to use the standard function name and no
|
||||
* os_*.c implementation is needed for them. This avoids extra function calls
|
||||
* by allowing the C pre-processor take care of the function name mapping.
|
||||
*
|
||||
* If the target system uses a C library that does not provide these functions,
|
||||
* build_config.h can be used to define the wrappers to use a different
|
||||
* function name. This can be done on function-by-function basis since the
|
||||
* defines here are only used if build_config.h does not define the os_* name.
|
||||
* If needed, os_*.c file can be used to implement the functions that are not
|
||||
* included in the C library on the target system. Alternatively,
|
||||
* OS_NO_C_LIB_DEFINES can be defined to skip all defines here in which case
|
||||
* these functions need to be implemented in os_*.c file for the target system.
|
||||
*/
|
||||
|
||||
#ifdef OS_NO_C_LIB_DEFINES
|
||||
|
||||
/**
|
||||
* os_malloc - Allocate dynamic memory
|
||||
* @size: Size of the buffer to allocate
|
||||
* Returns: Allocated buffer or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
void * os_malloc(size_t size);
|
||||
|
||||
/**
|
||||
* os_realloc - Re-allocate dynamic memory
|
||||
* @ptr: Old buffer from os_malloc() or os_realloc()
|
||||
* @size: Size of the new buffer
|
||||
* Returns: Allocated buffer or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
* If re-allocation fails, %NULL is returned and the original buffer (ptr) is
|
||||
* not freed and caller is still responsible for freeing it.
|
||||
*/
|
||||
void * os_realloc(void *ptr, size_t size);
|
||||
|
||||
/**
|
||||
* os_free - Free dynamic memory
|
||||
* @ptr: Old buffer from os_malloc() or os_realloc(); can be %NULL
|
||||
*/
|
||||
void os_free(void *ptr);
|
||||
|
||||
/**
|
||||
* os_memcpy - Copy memory area
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Number of bytes to copy
|
||||
* Returns: dest
|
||||
*
|
||||
* The memory areas src and dst must not overlap. os_memmove() can be used with
|
||||
* overlapping memory.
|
||||
*/
|
||||
void * os_memcpy(void *dest, const void *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_memmove - Copy memory area
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Number of bytes to copy
|
||||
* Returns: dest
|
||||
*
|
||||
* The memory areas src and dst may overlap.
|
||||
*/
|
||||
void *os_memmove(void *dest, const void *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_memset - Fill memory with a constant byte
|
||||
* @s: Memory area to be filled
|
||||
* @c: Constant byte
|
||||
* @n: Number of bytes started from s to fill with c
|
||||
* Returns: s
|
||||
*/
|
||||
void *os_memset(void *s, int c, size_t n);
|
||||
|
||||
/**
|
||||
* os_memcmp - Compare memory areas
|
||||
* @s1: First buffer
|
||||
* @s2: Second buffer
|
||||
* @n: Maximum numbers of octets to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_memcmp(const void *s1, const void *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strdup - Duplicate a string
|
||||
* @s: Source string
|
||||
* Returns: Allocated buffer with the string copied into it or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
char *os_strdup(const char *s);
|
||||
|
||||
/**
|
||||
* os_strlen - Calculate the length of a string
|
||||
* @s: '\0' terminated string
|
||||
* Returns: Number of characters in s (not counting the '\0' terminator)
|
||||
*/
|
||||
size_t os_strlen(const char *s);
|
||||
|
||||
/**
|
||||
* os_strcasecmp - Compare two strings ignoring case
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greatred than s2
|
||||
*/
|
||||
int os_strcasecmp(const char *s1, const char *s2);
|
||||
|
||||
/**
|
||||
* os_strncasecmp - Compare two strings ignoring case
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* @n: Maximum numbers of characters to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strchr - Locate the first occurrence of a character in string
|
||||
* @s: String
|
||||
* @c: Character to search for
|
||||
* Returns: Pointer to the matched character or %NULL if not found
|
||||
*/
|
||||
char *os_strchr(const char *s, int c);
|
||||
|
||||
/**
|
||||
* os_strrchr - Locate the last occurrence of a character in string
|
||||
* @s: String
|
||||
* @c: Character to search for
|
||||
* Returns: Pointer to the matched character or %NULL if not found
|
||||
*/
|
||||
char *os_strrchr(const char *s, int c);
|
||||
|
||||
/**
|
||||
* os_strcmp - Compare two strings
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greatred than s2
|
||||
*/
|
||||
int os_strcmp(const char *s1, const char *s2);
|
||||
|
||||
/**
|
||||
* os_strncmp - Compare two strings
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* @n: Maximum numbers of characters to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_strncmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strncpy - Copy a string
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Maximum number of characters to copy
|
||||
* Returns: dest
|
||||
*/
|
||||
char *os_strncpy(char *dest, const char *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_strstr - Locate a substring
|
||||
* @haystack: String (haystack) to search from
|
||||
* @needle: Needle to search from haystack
|
||||
* Returns: Pointer to the beginning of the substring or %NULL if not found
|
||||
*/
|
||||
char *os_strstr(const char *haystack, const char *needle);
|
||||
|
||||
/**
|
||||
* os_snprintf - Print to a memory buffer
|
||||
* @str: Memory buffer to print into
|
||||
* @size: Maximum length of the str buffer
|
||||
* @format: printf format
|
||||
* Returns: Number of characters printed (not including trailing '\0').
|
||||
*
|
||||
* If the output buffer is truncated, number of characters which would have
|
||||
* been written is returned. Since some C libraries return -1 in such a case,
|
||||
* the caller must be prepared on that value, too, to indicate truncation.
|
||||
*
|
||||
* Note: Some C library implementations of snprintf() may not guarantee null
|
||||
* termination in case the output is truncated. The OS wrapper function of
|
||||
* os_snprintf() should provide this guarantee, i.e., to null terminate the
|
||||
* output buffer if a C library version of the function is used and if that
|
||||
* function does not guarantee null termination.
|
||||
*
|
||||
* If the target system does not include snprintf(), see, e.g.,
|
||||
* http://www.ijs.si/software/snprintf/ for an example of a portable
|
||||
* implementation of snprintf.
|
||||
*/
|
||||
int os_snprintf(char *str, size_t size, const char *format, ...);
|
||||
|
||||
#else /* OS_NO_C_LIB_DEFINES */
|
||||
|
||||
#if !defined(CONFIG_PLATFORM_8195A) && !defined(CONFIG_PLATFORM_8711B)
|
||||
#ifdef CONFIG_MEM_MONITOR
|
||||
u8* os_malloc(u32 sz);
|
||||
void os_mfree(u8 *pbuf, u32 sz);
|
||||
#ifndef os_free
|
||||
#define os_free(p, sz) os_mfree(((u8*)(p)), (sz))
|
||||
#endif
|
||||
#else
|
||||
#ifndef os_malloc
|
||||
#define os_malloc(sz) _rtw_malloc(sz)
|
||||
#endif
|
||||
#ifndef os_free
|
||||
#define os_free(p, sz) _rtw_mfree(((u8*)(p)), (sz))
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
extern void *os_zalloc(size_t size);
|
||||
extern char *os_strdup(const char *string_copy_from);
|
||||
|
||||
#ifndef os_sleep
|
||||
#define os_sleep(s, us) rtw_mdelay_os((s)*1000 + (us)/1000)
|
||||
#endif
|
||||
#ifndef os_memcpy
|
||||
#define os_memcpy(d, s, n) rtw_memcpy((void*)(d), ((void*)(s)), (n))
|
||||
#endif
|
||||
#ifndef os_memmove
|
||||
#define os_memmove(d, s, n) memmove((d), (s), (n))
|
||||
#endif
|
||||
#ifndef os_memset
|
||||
#define os_memset(pbuf, c, sz) rtw_memset(pbuf, c, sz)
|
||||
#endif
|
||||
#ifndef os_memcmp
|
||||
#define os_memcmp(s1, s2, n) rtw_memcmp(((void*)(s1)), ((void*)(s2)), (n))
|
||||
#endif
|
||||
#ifndef os_memcmp_p2p
|
||||
#define os_memcmp_p2p(s1, s2, n) memcmp((s1), (s2), (n))
|
||||
#endif
|
||||
#ifndef os_get_random_bytes
|
||||
#define os_get_random_bytes(d,sz) rtw_get_random_bytes(((void*)(d)), (sz))
|
||||
#endif
|
||||
#ifndef os_strlen
|
||||
#define os_strlen(s) strlen(s)
|
||||
#endif
|
||||
#ifndef os_strcasecmp
|
||||
#ifdef _MSC_VER
|
||||
#define os_strcasecmp(s1, s2) _stricmp((s1), (s2))
|
||||
#else
|
||||
#define os_strcasecmp(s1, s2) strcasecmp((s1), (s2))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef os_strncasecmp
|
||||
#ifdef _MSC_VER
|
||||
#define os_strncasecmp(s1, s2, n) _strnicmp((s1), (s2), (n))
|
||||
#else
|
||||
#define os_strncasecmp(s1, s2, n) strncasecmp((s1), (s2), (n))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef os_init_timer
|
||||
#define os_init_timer(t, p, f, x, n) rtw_init_timer((t), (p), (f), (x), (n))
|
||||
#endif
|
||||
#ifndef os_set_timer
|
||||
#define os_set_timer(t, d) rtw_set_timer((t), (d))
|
||||
#endif
|
||||
#ifndef os_cancel_timer
|
||||
#define os_cancel_timer(t) rtw_cancel_timer(t)
|
||||
#endif
|
||||
#ifndef os_del_timer
|
||||
#define os_del_timer(t) rtw_del_timer(t)
|
||||
#endif
|
||||
#ifndef os_atoi
|
||||
#define os_atoi(s) rtw_atoi(s)
|
||||
#endif
|
||||
|
||||
#ifndef os_strchr
|
||||
#define os_strchr(s, c) strchr((s), (c))
|
||||
#endif
|
||||
#ifndef os_strcmp
|
||||
#define os_strcmp(s1, s2) strcmp((s1), (s2))
|
||||
#endif
|
||||
#ifndef os_strncmp
|
||||
#define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
|
||||
#endif
|
||||
#ifndef os_strncpy
|
||||
#define os_strncpy(d, s, n) strncpy((d), (s), (n))
|
||||
#endif
|
||||
#ifndef os_strrchr
|
||||
#define os_strrchr(s, c) strrchr((s), (c))
|
||||
#endif
|
||||
#ifndef os_strstr
|
||||
#define os_strstr(h, n) strstr((h), (n))
|
||||
#endif
|
||||
|
||||
#ifndef os_snprintf
|
||||
#ifdef _MSC_VER
|
||||
#define os_snprintf _snprintf
|
||||
#else
|
||||
#define os_snprintf snprintf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* OS_NO_C_LIB_DEFINES */
|
||||
|
||||
|
||||
static inline void * os_realloc_array(void *ptr, size_t nmemb, size_t size)
|
||||
{
|
||||
if (size && nmemb > (~(size_t) 0) / size)
|
||||
return NULL;
|
||||
return os_realloc(ptr, nmemb * size, nmemb * size);
|
||||
}
|
||||
|
||||
void *os_xqueue_create(unsigned long uxQueueLength, unsigned long uxItemSize) ;
|
||||
|
||||
int os_xqueue_receive(xqueue_handle_t xQueue, void * const pvBuffer, unsigned long xSecsToWait);
|
||||
|
||||
void os_xqueue_delete(xqueue_handle_t xQueue );
|
||||
|
||||
int os_xqueue_send(xqueue_handle_t xQueue, const void * const pvItemToQueue, unsigned long xSecsToWait);
|
||||
|
||||
|
||||
#endif /* OS_H */
|
||||
24
project/inc/rtl8195a/rom_wps_os.h
Normal file
24
project/inc/rtl8195a/rom_wps_os.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* OS specific functions
|
||||
* Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef ROM_WPS_OS_H
|
||||
#define ROM_WPS_OS_H
|
||||
|
||||
#if defined(CONFIG_PLATFORM_8195A) || defined(CONFIG_PLATFORM_8711B)
|
||||
|
||||
#include <rom_wlan_ram_map.h>
|
||||
extern struct _rom_wlan_ram_map rom_wlan_ram_map;
|
||||
#define os_malloc(sz) rom_wlan_ram_map.rtw_malloc(sz)
|
||||
#define os_free(p, sz) rom_wlan_ram_map.rtw_mfree(((u8*)(p)), (sz))
|
||||
|
||||
#endif
|
||||
|
||||
extern u8 *WPS_realloc(u8 *old_buf, u32 old_sz, u32 new_sz);
|
||||
#define os_realloc(p, os, ns) WPS_realloc(((u8*)(p)),(os),(ns))
|
||||
|
||||
#endif /* ROM_WPS_OS_H */
|
||||
15
project/inc/rtl8195a/rtl_common.h
Normal file
15
project/inc/rtl8195a/rtl_common.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (C)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __RTL_COMMON_H__
|
||||
#define __RTL_COMMON_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "c_types.h"
|
||||
|
||||
#endif
|
||||
164
project/inc/rtl8195a/rtl_libc.h
Normal file
164
project/inc/rtl8195a/rtl_libc.h
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* ROM calls
|
||||
*/
|
||||
|
||||
#ifndef _INC_RTL_LIBC_
|
||||
#define _INC_RTL_LIBC_
|
||||
|
||||
//#undef malloc
|
||||
#define malloc(size) pvPortMalloc(size)
|
||||
//#undef free
|
||||
#define free(pbuf) vPortFree(pbuf)
|
||||
|
||||
#define atoi(str) prvAtoi(str)
|
||||
|
||||
#define calloc(nelements, elementSize) calloc_freertos(nelements, elementSize)
|
||||
|
||||
#define snprintf rtl_snprintf
|
||||
#define sprintf rtl_sprintf
|
||||
#define printf rtl_printf
|
||||
#define vprintf rtl_vprintf
|
||||
#define vsnprintf rtl_vsnprintf
|
||||
#define vfprintf rtl_vfprintf
|
||||
#define memchr rtl_memchr
|
||||
#define memcmp rtl_memcmp
|
||||
#define memcpy rtl_memcpy
|
||||
#define memmove rtl_memmove
|
||||
#define memset rtl_memset
|
||||
#define strcat rtl_strcat
|
||||
#define strchr rtl_strchr
|
||||
#define strcmp rtl_strcmp
|
||||
#define strcpy rtl_strcpy
|
||||
#define strlen rtl_strlen
|
||||
#define strncat rtl_strncat
|
||||
#define strncmp rtl_strncmp
|
||||
#define strncpy rtl_strncpy
|
||||
#define strstr rtl_strstr
|
||||
#define strsep rtl_strsep
|
||||
#define strtok rtl_strtok
|
||||
|
||||
#define dtoi rtl_dtoi
|
||||
#define dtoui rtl_dtoui
|
||||
#define i2f rtl_i2f
|
||||
#define i2d rtl_i2d
|
||||
#define ui2f rtl_ui2f
|
||||
#define ui2d rtl_ui2d
|
||||
#define itoa rtl_itoa
|
||||
#define ltoa rtl_ltoa
|
||||
#define utoa rtl_utoa
|
||||
#define ultoa rtl_ultoa
|
||||
#define ftol rtl_ftol
|
||||
#define ftod rtl_ftod
|
||||
#define dtof rtl_dtof
|
||||
#define fadd rtl_fadd
|
||||
#define fsub rtl_fsub
|
||||
#define fmul rtl_fmul
|
||||
#define fdiv rtl_fdiv
|
||||
#define dadd rtl_dadd
|
||||
#define dsub rtl_dsub
|
||||
#define dmul rtl_dmul
|
||||
#define ddiv rtl_ddiv
|
||||
#define dcmpeq rtl_dcmpeq
|
||||
#define dcmplt rtl_dcmplt
|
||||
#define dcmple rtl_dcmple
|
||||
#define dcmpgt rtl_dcmpgt
|
||||
#define fcmplt rtl_fcmplt
|
||||
#define fcmpgt rtl_fcmpgt
|
||||
|
||||
#define fabsf rtl_fabsf
|
||||
#define fabs rtl_fabs
|
||||
#define cos_f32 rtl_cos_f32
|
||||
#define sin_f32 rtl_sin_f32
|
||||
|
||||
|
||||
#if 0
|
||||
extern void *calloc_freertos(size_t nelements, size_t elementSize);
|
||||
// ram_libc.c
|
||||
extern int rtl_snprintf(char *str, size_t size, const char *fmt, ...);
|
||||
extern int rtl_sprintf(char *str, const char *fmt, ...);
|
||||
extern int rtl_printf(const char *fmt, ...);
|
||||
extern int rtl_vprintf(const char *fmt, void *param);
|
||||
extern int rtl_vsnprintf(char *str, size_t size, const char *fmt, void *param);
|
||||
extern int rtl_vfprintf(FILE *fp, const char *fmt0, va_list ap);
|
||||
extern int rtl_memchr(const void *src_void, int c, size_t length);
|
||||
extern int rtl_memcmp(const void *m1, const void *m2, size_t n);
|
||||
extern int rtl_memcpy(void *dst0, const void *src0, size_t len0);
|
||||
extern int rtl_memmove(void *dst_void, const void *src_void, size_t length);
|
||||
extern int rtl_memset(void *m, int c, size_t n);
|
||||
extern char * rtl_strcat(char *s1, const char *s2);
|
||||
extern char * rtl_strchr(const char *s1, int i);
|
||||
extern int rtl_strcmp(const char *s1, const char *s2);
|
||||
extern char * rtl_strcpy(char *dst0, const char *src0);
|
||||
extern int rtl_strlen(const char *str);
|
||||
extern char * rtl_strncat(char *s1, const char *s2, size_t n);
|
||||
extern int rtl_strncmp(const char *s1, const char *s2, size_t n);
|
||||
extern char * rtl_strncpy(char *dst0, const char *src0, size_t count);
|
||||
extern char * rtl_strstr(const char *searchee, const char *lookfor);
|
||||
extern char * rtl_strsep(char **source_ptr, const char *delim);
|
||||
extern char * rtl_strtok(char *s, const char *delim);
|
||||
|
||||
//rtl_eabi_cast_ram.c
|
||||
extern int rtl_dtoi(double d);
|
||||
extern int rtl_dtoui(double d);
|
||||
extern float rtl_i2f(int val);
|
||||
extern int rtl_i2d(int val);
|
||||
extern float rtl_ui2f(unsigned int val);
|
||||
extern int rtl_ui2d(unsigned int val);
|
||||
extern char *rtl_itoa(int value, char *string, int radix);
|
||||
extern char *rtl_ltoa(int value, char *string, int radix);
|
||||
extern char *rtl_utoa(unsigned int value, char *string, int radix);
|
||||
extern char *rtl_ultoa(unsigned int value, char *string, int radix);
|
||||
extern int rtl_ftol(float f);
|
||||
extern int rtl_ftod(float f);
|
||||
extern float rtl_dtof(double d);
|
||||
extern float rtl_fadd(float a, float b);
|
||||
extern float rtl_fsub(float a, float b);
|
||||
extern float rtl_fmul(float a, float b);
|
||||
extern float rtl_fdiv(float a, float b);
|
||||
extern int rtl_dadd(double a, double b);
|
||||
extern int rtl_dsub(double a, double b);
|
||||
extern int rtl_dmul(double a, double b);
|
||||
extern int rtl_ddiv(double a, double b);
|
||||
extern int rtl_dcmpeq(double a, double b);
|
||||
extern int rtl_dcmplt(double a, double b);
|
||||
extern int rtl_dcmple(double a, double b);
|
||||
extern int rtl_dcmpgt(double a, double b);
|
||||
extern int rtl_fcmplt(float a, float b);
|
||||
extern int rtl_fcmpgt(float a, float b);
|
||||
|
||||
// rtl_math_ram.c
|
||||
extern float rtl_fabsf(float a);
|
||||
extern int rtl_fabs(double a);
|
||||
extern float rtl_cos_f32(float a);
|
||||
extern float rtl_sin_f32(float a);
|
||||
|
||||
// ram_pvvx_libc.c
|
||||
extern int snprintf(char *str, size_t size, const char *fmt, ...);
|
||||
extern int sprintf(char *str, const char *fmt, ...);
|
||||
extern int printf(const char *fmt, ...);
|
||||
extern int vprintf(const char *fmt, void *param);
|
||||
extern int vsnprintf(char *str, size_t size, const char *fmt, void *param);
|
||||
extern int vfprintf(FILE *fp, const char *fmt0, va_list ap);
|
||||
extern int memchr(const void *src_void, int c, size_t length);
|
||||
extern int memcmp(const void *m1, const void *m2, size_t n);
|
||||
extern int memcpy(void *dst0, const void *src0, size_t len0);
|
||||
extern int memmove(void *dst_void, const void *src_void, size_t length);
|
||||
extern int memset(void *m, int c, size_t n);
|
||||
extern char * strcat(char *s1, const char *s2);
|
||||
extern char * strchr(const char *s1, int i);
|
||||
extern int strcmp(const char *s1, const char *s2);
|
||||
extern char * strcpy(char *dst0, const char *src0);
|
||||
extern int strlen(const char *str);
|
||||
extern char * strncat(char *s1, const char *s2, size_t n);
|
||||
extern int strncmp(const char *s1, const char *s2, size_t n);
|
||||
extern char * strncpy(char *dst0, const char *src0, size_t count);
|
||||
extern char * strstr(const char *searchee, const char *lookfor);
|
||||
extern char * strsep(char **source_ptr, const char *delim);
|
||||
extern char * strtok(char *s, const char *delim);
|
||||
extern int sscanf(const char *buf, const char *fmt, ...);
|
||||
extern char toupper(char ch);
|
||||
extern int _stricmp (const char *s1, const char *s2);
|
||||
extern unsigned long long __aeabi_llsr(unsigned long long val, unsigned int shift);
|
||||
#endif
|
||||
|
||||
#endif // _INC_RTL_LIBC_
|
||||
8
project/inc/user/cgi-test.h
Normal file
8
project/inc/user/cgi-test.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef CGI_TEST_H
|
||||
#define CGI_TEST_H
|
||||
|
||||
|
||||
|
||||
int cgiTestbed(HttpdConnData *connData);
|
||||
|
||||
#endif
|
||||
13
project/inc/user/cgiwifi_rtl.h
Normal file
13
project/inc/user/cgiwifi_rtl.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef CGIWIFI_H
|
||||
#define CGIWIFI_H
|
||||
|
||||
#include "httpd.h"
|
||||
|
||||
httpd_cgi_state cgiWiFiScan(HttpdConnData *connData);
|
||||
httpd_cgi_state tplWlan(HttpdConnData *connData, char *token, void **arg);
|
||||
httpd_cgi_state cgiWiFi(HttpdConnData *connData);
|
||||
httpd_cgi_state cgiWiFiConnect(HttpdConnData *connData);
|
||||
httpd_cgi_state cgiWiFiSetMode(HttpdConnData *connData);
|
||||
httpd_cgi_state cgiWiFiConnStatus(HttpdConnData *connData);
|
||||
|
||||
#endif
|
||||
14
project/inc/user/http_server.h
Normal file
14
project/inc/user/http_server.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* http_server.h
|
||||
*
|
||||
* Created on: Feb 20, 2017
|
||||
* Author: user003
|
||||
*/
|
||||
|
||||
#ifndef HTTP_SERVER_H_
|
||||
#define HTTP_SERVER_H_
|
||||
|
||||
void GpioLedInit(void);
|
||||
void websocketBcast(void *arg);
|
||||
|
||||
#endif /* HTTP_SERVER_H_ */
|
||||
68
project/inc/user/main.h
Normal file
68
project/inc/user/main.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <autoconf.h>
|
||||
|
||||
#ifndef CONFIG_WLAN
|
||||
#define CONFIG_WLAN 1
|
||||
#endif
|
||||
|
||||
/* Header file declaration*/
|
||||
void wlan_network();
|
||||
|
||||
/* Interactive Mode */
|
||||
#define SERIAL_DEBUG_RX 1
|
||||
|
||||
|
||||
#define ATVER_1 1 // For First AT command
|
||||
#define ATVER_2 2 // For UART Module AT command
|
||||
|
||||
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||
#define ATCMD_VER ATVER_2
|
||||
#else
|
||||
#define ATCMD_VER ATVER_1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define IP_ADDR0 192
|
||||
#define IP_ADDR1 168
|
||||
#define IP_ADDR2 3
|
||||
#define IP_ADDR3 80
|
||||
|
||||
/*NETMASK*/
|
||||
#define NETMASK_ADDR0 255
|
||||
#define NETMASK_ADDR1 255
|
||||
#define NETMASK_ADDR2 255
|
||||
#define NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define GW_ADDR0 192
|
||||
#define GW_ADDR1 168
|
||||
#define GW_ADDR2 3
|
||||
#define GW_ADDR3 1
|
||||
|
||||
/*******************************************/
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define AP_IP_ADDR0 192
|
||||
#define AP_IP_ADDR1 168
|
||||
#define AP_IP_ADDR2 43
|
||||
#define AP_IP_ADDR3 1
|
||||
|
||||
/*NETMASK*/
|
||||
#define AP_NETMASK_ADDR0 255
|
||||
#define AP_NETMASK_ADDR1 255
|
||||
#define AP_NETMASK_ADDR2 255
|
||||
#define AP_NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define AP_GW_ADDR0 192
|
||||
#define AP_GW_ADDR1 168
|
||||
#define AP_GW_ADDR2 43
|
||||
#define AP_GW_ADDR3 1
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
29
project/inc/user/user_config.h
Normal file
29
project/inc/user/user_config.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* wc_mgr.h
|
||||
*
|
||||
* Created on: Feb 16, 2017
|
||||
* Author: sharikov
|
||||
*/
|
||||
#ifndef WC_MGR_H_
|
||||
#define WC_MGR_H_
|
||||
|
||||
#define FREERTOS
|
||||
#define HTTPD_MAX_CONNECTIONS 15
|
||||
|
||||
// #define WIFI_RESET_SETTINGS_PIN PB_1 // wifi settings reset: connect PB1 to ground
|
||||
|
||||
#define GPIO_LED_PIN PA_4
|
||||
#define BITBAND_LED BITBAND_A4
|
||||
|
||||
#define AP_SCAN_LIST_SIZE 32
|
||||
|
||||
#define FLASH_APP_BASE 0xd0000
|
||||
#define flash_size
|
||||
|
||||
#define USE_NETBIOS
|
||||
|
||||
#define HTTPD_PRIORITY (tskIDLE_PRIORITY + 1 + PRIORITIE_OFFSET)
|
||||
#define CAPDNS_PRIORITY (tskIDLE_PRIORITY + 0 + PRIORITIE_OFFSET)
|
||||
#define WEBSOC_PRIORITY (tskIDLE_PRIORITY + 1 + PRIORITIE_OFFSET)
|
||||
|
||||
#endif /* WC_MGR_H_ */
|
||||
72
project/inc/wifi_user_set.h
Normal file
72
project/inc/wifi_user_set.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* wifi_user_set.h
|
||||
*
|
||||
* Created on: 01/04/2017
|
||||
* Author: pvvx
|
||||
*/
|
||||
|
||||
#ifndef _WIFI_USER_SET_H_
|
||||
#define _WIFI_USER_SET_H_
|
||||
|
||||
//=========================================
|
||||
//==== Wlan Config ========================
|
||||
#define DEF_WIFI_MODE RTW_MODE_AP // Стартовый режим WiFi: RTW_MODE_STA_AP, RTW_MODE_AP, RTW_MODE_STA, RTW_MODE_NONE
|
||||
#define DEF_WIFI_AP_STATIONS 3 // Max number of STAs, should be 1..3, default is 3
|
||||
#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_LOAD_CFG 0 // старт в назначенном режиме по умолчанию
|
||||
//#define DEF_LOAD_CFG BID_ALL_WIFI_CFG // старт в назначенном общем режиме по умолчанию, с загрузками последних конфигураций ST и AP
|
||||
#define DEF_LOAD_CFG (BID_ALL_WIFI_CFG | BID_WIFI_CFG) // старт в записанном режиме
|
||||
|
||||
/* Опции разрешения записи конфигов по упсешному соединению или выполнению операции установок режимов WiFi без ошибок */
|
||||
#define DEF_SAVE_CFG (BID_ALL_WIFI_CFG | BID_WIFI_CFG) // сохранение по успешному соединению/выполненю для всех конфигов:
|
||||
// (для ST или AP пишутся раздельно) с проверкой на изменения
|
||||
//==== Interface 0 - wlan0 = AP ===========
|
||||
#define DEF_AP_SSID "RTL871X"
|
||||
#define DEF_AP_PASSWORD "0123456789"
|
||||
/* Варианты типов Security для AP:
|
||||
RTW_SECURITY_OPEN - Open Security
|
||||
RTW_SECURITY_WPA_TKIP_PSK - WPA Security
|
||||
RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
|
||||
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_BEACON 100 // 100...6000 ms
|
||||
#define DEF_AP_CHANNEL 1 // 1..14
|
||||
#define DEF_AP_CHANNEL 1 // 1..14
|
||||
#define DEF_AP_DHCP_MODE 1 // =0 dhcp off, =1 - dhcp on
|
||||
#define DEF_AP_IP IP4ADDR(192,168,4,1)
|
||||
#define DEF_AP_MSK IP4ADDR(255,255,255,0)
|
||||
#define DEF_AP_GW IP4ADDR(192,168,4,1)
|
||||
// if not defined DHCP_START && DHCP_STOP -> 2..255
|
||||
//#define DEF_AP_DHCP_START 2 // DHCP ip start xx.xx.xx.2
|
||||
//#define DEF_AP_DHCP_STOP 15 // DHCP ip stop xx.xx.xx.15
|
||||
//==== Interface 1 - wlan1 = STA ==========
|
||||
#define DEF_ST_SSID "HOMEAP" // Имя SSID AP (роутера) для присоединения по умолчанию (первый старт)
|
||||
#define DEF_ST_PASSWORD "0123456789" // Пароль AP (роутера) для присоединения по умолчанию (первый старт)
|
||||
#define DEF_ST_SECURITY RTW_SECURITY_WPA_WPA2_MIXED // Тип Security
|
||||
#define DEF_ST_BSSID { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } // If bssid set is not ff.ff.ff.ff.ff.ff,
|
||||
#define DEF_ST_USE_BSSID 0 // station will connect to the router with both ssid[] and bssid[] matched.
|
||||
#define DEF_ST_CHANNEL 1 // 1..14
|
||||
#define DEF_ST_AUTORECONNECT 1 // 0 - none, 1..254 - count, 255 - all
|
||||
#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_LPS_DTIM 0 // LPS DTIM
|
||||
#define DEF_ST_DHCP_MODE 1 // =0 dhcp off,
|
||||
// =1 - dhcp on, - динамический ip
|
||||
// =2 Static ip, - fixed ip
|
||||
// =3 - auto fix - старт в режиме "dhcp on", после получения ip - фиксация и переключение в режим рестартов со "Static ip"
|
||||
#define DEF_ST_IP IP4ADDR(192,168,1,100)
|
||||
#define DEF_ST_MSK IP4ADDR(255,255,255,0)
|
||||
#define DEF_ST_GW IP4ADDR(192,168,1,1)
|
||||
//==== Interface 2 - eth0 =================
|
||||
#define DEF_EH_DHCP_MODE 1 // =0 dhcp off, =1 - dhcp on
|
||||
#define DEF_EH_IP IP4ADDR(192,168,7,200)
|
||||
#define DEF_EH_MSK IP4ADDR(255,255,255,0)
|
||||
#define DEF_EH_GW IP4ADDR(192,168,7,1)
|
||||
//=========================================
|
||||
|
||||
#endif /* _WIFI_USER_SET_H_ */
|
||||
20
project/src/FreeRTOS-openocd.c
Normal file
20
project/src/FreeRTOS-openocd.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Since at least FreeRTOS V7.5.3 uxTopUsedPriority is no longer
|
||||
* present in the kernel, so it has to be supplied by other means for
|
||||
* OpenOCD's threads awareness.
|
||||
*
|
||||
* Add this file to your project, and, if you're using --gc-sections,
|
||||
* ``--undefined=uxTopUsedPriority'' (or
|
||||
* ``-Wl,--undefined=uxTopUsedPriority'' when using gcc for final
|
||||
* linking) to your LDFLAGS; same with all the other symbols you need.
|
||||
*/
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define USED __attribute__((used))
|
||||
#else
|
||||
#define USED
|
||||
#endif
|
||||
|
||||
const int USED uxTopUsedPriority = configMAX_PRIORITIES - 1;
|
||||
603
project/src/console/atcmd_user.c
Normal file
603
project/src/console/atcmd_user.c
Normal file
|
|
@ -0,0 +1,603 @@
|
|||
#include <platform_opts.h>
|
||||
|
||||
#ifdef CONFIG_AT_USR
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
#include "at_cmd/log_service.h"
|
||||
#include "at_cmd/atcmd_wifi.h"
|
||||
#include <lwip_netconf.h>
|
||||
#include "tcpip.h"
|
||||
#include <dhcp/dhcps.h>
|
||||
#include <wifi/wifi_conf.h>
|
||||
#include <wifi/wifi_util.h>
|
||||
#include "tcm_heap.h"
|
||||
#include "rtl8195a/rtl_libc.h"
|
||||
|
||||
#include "sleep_ex_api.h"
|
||||
|
||||
#include "lwip/tcp_impl.h"
|
||||
|
||||
extern char str_rom_57ch3Dch0A[]; // "=========================================================\n" 57
|
||||
|
||||
#define printf rtl_printf // DiagPrintf
|
||||
|
||||
/* RAM/TCM/Heaps info */
|
||||
extern void ShowMemInfo(void);
|
||||
/*
|
||||
void ShowMemInfo(void)
|
||||
{
|
||||
printf("\nCLK CPU\t\t%d Hz\nRAM heap\t%d bytes\nTCM heap\t%d bytes\n",
|
||||
HalGetCpuClk(), xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||
}
|
||||
*/
|
||||
//------------------------------------------------------------------------------
|
||||
// Mem, Tasks info
|
||||
//------------------------------------------------------------------------------
|
||||
LOCAL void fATST(int argc, char *argv[]) {
|
||||
ShowMemInfo();
|
||||
#if 0 //CONFIG_DEBUG_LOG > 1
|
||||
dump_mem_block_list();
|
||||
tcm_heap_dump();
|
||||
#endif;
|
||||
printf("\n");
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
char *cBuffer = pvPortMalloc(512);
|
||||
if(cBuffer != NULL) {
|
||||
vTaskGetRunTimeStats((char *)cBuffer);
|
||||
printf("%s", cBuffer);
|
||||
}
|
||||
vPortFree(cBuffer);
|
||||
#endif
|
||||
#if defined(configUSE_TRACE_FACILITY) && (configUSE_TRACE_FACILITY == 1) && (configUSE_STATS_FORMATTING_FUNCTIONS == 1)
|
||||
{
|
||||
char * pcWriteBuffer = malloc(1024);
|
||||
if(pcWriteBuffer) {
|
||||
vTaskList((char*)pcWriteBuffer);
|
||||
printf("\nTask List:\n");
|
||||
printf(&str_rom_57ch3Dch0A[7]); // "==========================================\n"
|
||||
printf("Name\t Status Priority HighWaterMark TaskNumber\n%s\n", pcWriteBuffer);
|
||||
free(pcWriteBuffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*-------------------------------------------------------------------------------------
|
||||
Копирует данные из области align(4) (flash, registers, ...) в область align(1) (ram)
|
||||
--------------------------------------------------------------------------------------*/
|
||||
extern void copy_align4_to_align1(unsigned char * pd, void * ps, unsigned int len);
|
||||
/*
|
||||
static void copy_align4_to_align1(unsigned char * pd, void * ps, unsigned int len)
|
||||
{
|
||||
union {
|
||||
unsigned char uc[4];
|
||||
unsigned int ud;
|
||||
}tmp;
|
||||
unsigned int *p = (unsigned int *)((unsigned int)ps & (~3));
|
||||
unsigned int xlen = (unsigned int)ps & 3;
|
||||
// unsigned int size = len;
|
||||
|
||||
if(xlen) {
|
||||
tmp.ud = *p++;
|
||||
while (len) {
|
||||
len--;
|
||||
*pd++ = tmp.uc[xlen++];
|
||||
if(xlen & 4) break;
|
||||
}
|
||||
}
|
||||
xlen = len >> 2;
|
||||
while(xlen) {
|
||||
tmp.ud = *p++;
|
||||
*pd++ = tmp.uc[0];
|
||||
*pd++ = tmp.uc[1];
|
||||
*pd++ = tmp.uc[2];
|
||||
*pd++ = tmp.uc[3];
|
||||
xlen--;
|
||||
}
|
||||
if(len & 3) {
|
||||
tmp.ud = *p;
|
||||
pd[0] = tmp.uc[0];
|
||||
if(len & 2) {
|
||||
pd[1] = tmp.uc[1];
|
||||
if(len & 1) {
|
||||
pd[2] = tmp.uc[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
// return size;
|
||||
}
|
||||
*/
|
||||
int print_hex_dump(uint8_t *buf, int len, unsigned char k) {
|
||||
uint32_t ss[2];
|
||||
ss[0] = 0x78323025; // "%02x"
|
||||
ss[1] = k; // ","...'\0'
|
||||
uint8_t * ptr = buf;
|
||||
int result = 0;
|
||||
while (len--) {
|
||||
if (len == 0)
|
||||
ss[1] = 0;
|
||||
result += printf((uint8_t *) &ss, *ptr++);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
extern char str_rom_hex_addr[]; // in *.ld "[Addr] .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .A .B .C .D .E .F\n"
|
||||
|
||||
void dump_bytes(uint32 addr, int size)
|
||||
{
|
||||
uint8 buf[17];
|
||||
u32 symbs_line = sizeof(buf)-1;
|
||||
printf(str_rom_hex_addr);
|
||||
while (size) {
|
||||
if (symbs_line > size) symbs_line = size;
|
||||
printf("%08X ", addr);
|
||||
copy_align4_to_align1(buf, addr, symbs_line);
|
||||
print_hex_dump(buf, symbs_line, ' ');
|
||||
int i;
|
||||
for(i = 0 ; i < symbs_line ; i++) {
|
||||
if(buf[i] < 0x20 || buf[i] > 0x7E) {
|
||||
buf[i] = '.';
|
||||
}
|
||||
}
|
||||
buf[symbs_line] = 0;
|
||||
i = (sizeof(buf)-1) - symbs_line;
|
||||
while(i--) printf(" ");
|
||||
printf(" %s\r\n", buf);
|
||||
addr += symbs_line;
|
||||
size -= symbs_line;
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
// Dump byte register
|
||||
//------------------------------------------------------------------------------
|
||||
LOCAL void fATSB(int argc, char *argv[])
|
||||
{
|
||||
/*
|
||||
int size = 16;
|
||||
uint32 addr = Strtoul(argv[1],0,16);
|
||||
if (argc > 2) {
|
||||
size = Strtoul(argv[2],0,10);
|
||||
if (size <= 0 || size > 16384)
|
||||
size = 16;
|
||||
}
|
||||
if(addr + size > SPI_FLASH_BASE) {
|
||||
flash_turnon();
|
||||
dump_bytes(addr, size);
|
||||
SpicDisableRtl8195A();
|
||||
}
|
||||
else {
|
||||
dump_bytes(addr, size);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Dump dword register
|
||||
//------------------------------------------------------------------------------
|
||||
LOCAL void fATSD(int argc, char *argv[])
|
||||
{
|
||||
/*
|
||||
if (argc > 2) {
|
||||
int size = Strtoul(argv[2],0,10);
|
||||
if (size <= 0 || size > 16384)
|
||||
argv[2] = "16";
|
||||
}
|
||||
*/
|
||||
flash_turnon();
|
||||
CmdDumpWord(argc-1, (unsigned char**)(argv+1));
|
||||
SpicDisableRtl8195A();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
// Write dword register
|
||||
//------------------------------------------------------------------------------
|
||||
LOCAL void fATSW(int argc, char *argv[])
|
||||
{
|
||||
CmdWriteWord(argc-1, (unsigned char**)(argv+1));
|
||||
}
|
||||
|
||||
/* Get one byte from the 4-byte address */
|
||||
#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0])
|
||||
#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1])
|
||||
#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2])
|
||||
#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3])
|
||||
/* These are cast to u16_t, with the intent that they are often arguments
|
||||
* to printf using the U16_F format from cc.h. */
|
||||
#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr))
|
||||
#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr))
|
||||
#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr))
|
||||
#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr))
|
||||
|
||||
#define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \
|
||||
ip4_addr2_16(ipaddr), \
|
||||
ip4_addr3_16(ipaddr), \
|
||||
ip4_addr4_16(ipaddr)
|
||||
|
||||
#define IPSTR "%d.%d.%d.%d"
|
||||
|
||||
extern const char * const tcp_state_str[];
|
||||
/*
|
||||
static const char * const tcp_state_str[] = {
|
||||
"CLOSED",
|
||||
"LISTEN",
|
||||
"SYN_SENT",
|
||||
"SYN_RCVD",
|
||||
"ESTABLISHED",
|
||||
"FIN_WAIT_1",
|
||||
"FIN_WAIT_2",
|
||||
"CLOSE_WAIT",
|
||||
"CLOSING",
|
||||
"LAST_ACK",
|
||||
"TIME_WAIT"
|
||||
};
|
||||
*/
|
||||
/******************************************************************************
|
||||
* FunctionName : debug
|
||||
* Parameters :
|
||||
* Returns :
|
||||
*******************************************************************************/
|
||||
void print_udp_pcb(void)
|
||||
{
|
||||
struct udp_pcb *pcb;
|
||||
bool prt_none = true;
|
||||
rtl_printf("UDP pcbs:\n");
|
||||
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||
rtl_printf("flg:%02x\t" IPSTR ":%d\t" IPSTR ":%d\trecv:%p\n", pcb->flags, IP2STR(&pcb->local_ip), pcb->local_port, IP2STR(&pcb->remote_ip), pcb->remote_port, pcb->recv );
|
||||
prt_none = false;
|
||||
};
|
||||
if(prt_none) rtl_printf("none\n");
|
||||
}
|
||||
/******************************************************************************
|
||||
* FunctionName : debug
|
||||
* Parameters :
|
||||
* Returns :
|
||||
*******************************************************************************/
|
||||
void print_tcp_pcb(void)
|
||||
{
|
||||
struct tcp_pcb *pcb;
|
||||
rtl_printf("Active PCB states:\n");
|
||||
bool prt_none = true;
|
||||
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||
rtl_printf("Port %d|%d\tflg:%02x\ttmr:%p\t%s\n", pcb->local_port, pcb->remote_port, pcb->flags, pcb->tmr, tcp_state_str[pcb->state]);
|
||||
prt_none = false;
|
||||
};
|
||||
if(prt_none) rtl_printf("none\n");
|
||||
rtl_printf("Listen PCB states:\n");
|
||||
prt_none = true;
|
||||
for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) {
|
||||
rtl_printf("Port %d|%d\tflg:%02x\ttmr:%p\t%s\n", pcb->local_port, pcb->remote_port, pcb->flags, pcb->tmr, tcp_state_str[pcb->state]);
|
||||
prt_none = false;
|
||||
};
|
||||
if(prt_none) rtl_printf("none\n");
|
||||
rtl_printf("TIME-WAIT PCB states:\n");
|
||||
prt_none = true;
|
||||
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||
rtl_printf("Port %d|%d\tflg:%02x\ttmr:%p \t%s\n", pcb->local_port, pcb->remote_port, pcb->flags, pcb->tmr, tcp_state_str[pcb->state]);
|
||||
prt_none = false;
|
||||
};
|
||||
if(prt_none) rtl_printf("none\n");
|
||||
}
|
||||
/******************************************************************************
|
||||
* FunctionName : debug
|
||||
* Parameters :
|
||||
* Returns :
|
||||
*******************************************************************************/
|
||||
LOCAL void fATLW(int argc, char *argv[]) // Info Lwip
|
||||
{
|
||||
print_udp_pcb();
|
||||
print_tcp_pcb();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
// Deep sleep
|
||||
//------------------------------------------------------------------------------
|
||||
LOCAL void fATDS(int argc, char *argv[])
|
||||
{
|
||||
uint32 sleep_ms = 10000;
|
||||
if(argc > 1) sleep_ms = atoi(argv[1]);
|
||||
#if 0
|
||||
if(argc > 2) {
|
||||
printf("%u ms waiting low level on PB_1 before launching Deep-Sleep...\n", sleep_ms);
|
||||
// turn off log uart
|
||||
HalDeinitLogUart(); // sys_log_uart_off();
|
||||
|
||||
// initialize wakeup pin
|
||||
gpio_t gpio_wake;
|
||||
gpio_init(&gpio_wake, PB_1);
|
||||
gpio_dir(&gpio_wake, PIN_INPUT);
|
||||
gpio_mode(&gpio_wake, PullDown);
|
||||
TickType_t sttime = xTaskGetTickCount();
|
||||
|
||||
do {
|
||||
if(gpio_read(&gpio_wake) == 0) {
|
||||
// Enter deep sleep... Wait give rising edge at PB_1 to wakeup system.
|
||||
deepsleep_ex(DSLEEP_WAKEUP_BY_GPIO, 0);
|
||||
};
|
||||
vTaskDelay(1);
|
||||
} while(xTaskGetTickCount() - sttime < sleep_ms);
|
||||
HalInitLogUart(); // sys_log_uart_on();
|
||||
printf("No set pin low in deep sleep!\n");
|
||||
}
|
||||
else {
|
||||
printf("Deep-Sleep %u ms\n", sleep_ms);
|
||||
HalLogUartWaitTxFifoEmpty();
|
||||
// Enter deep sleep... Wait timer ms
|
||||
deepsleep_ex(DSLEEP_WAKEUP_BY_TIMER, sleep_ms);
|
||||
}
|
||||
#else
|
||||
HalLogUartWaitTxFifoEmpty();
|
||||
deepsleep_ex(DSLEEP_WAKEUP_BY_TIMER, sleep_ms);
|
||||
#endif
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* power saving mode
|
||||
*----------------------------------------------------------------------------*/
|
||||
LOCAL void fATSP(int argc, char *argv[])
|
||||
{
|
||||
if(argc > 2) {
|
||||
switch (argv[1][0]) {
|
||||
case 'a': // acquire
|
||||
{
|
||||
acquire_wakelock(atoi(argv[2]));
|
||||
break;
|
||||
}
|
||||
case 'r': // release
|
||||
{
|
||||
release_wakelock(atoi(argv[2]));
|
||||
break;
|
||||
}
|
||||
};
|
||||
};
|
||||
printf("WakeLock Status %d\n", get_wakelock_status());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
#include "wlan_lib.h"
|
||||
#include "hal_com_reg.h"
|
||||
|
||||
extern struct netif xnetif[NET_IF_NUM];
|
||||
|
||||
u8 RandSK256() {
|
||||
u8 buf;
|
||||
rtw_get_random_bytes(&buf, 1);
|
||||
return buf;
|
||||
}
|
||||
|
||||
u8 RandSK(u8 max) {
|
||||
u8 buf;
|
||||
do {
|
||||
rtw_get_random_bytes(&buf, 1);
|
||||
} while (buf>max);
|
||||
return buf;
|
||||
}
|
||||
#ifdef CONFIG_PROMISC
|
||||
void fATWM(int argc, char *argv[]){
|
||||
argv[0] = "wifi_promisc";
|
||||
printf("[ATWM]x: _AT_WLAN_PROMISC_\n");
|
||||
char mac[100];
|
||||
wifi_get_mac_address(&mac);
|
||||
printf("\n\r%s\r\n", mac);
|
||||
//printf("set\n\r");
|
||||
//char mac2[100]="123456789012";
|
||||
//wifi_set_mac_address(&mac2);
|
||||
//printf("get\n\r");
|
||||
//wifi_get_mac_address(&mac);
|
||||
//printf("\n\r%s\r\n", mac);
|
||||
if(1) {
|
||||
int out_buf_size = 40;
|
||||
unsigned char buf[40];
|
||||
u8 *mac = (u8 *)LwIP_GetMAC(&xnetif[0]);
|
||||
memcpy(buf,' ',40);
|
||||
//sprintf(buf, ",,,B,%02x%02x%02x%02x%02x%02x,", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
sprintf(buf, "0123456789");
|
||||
struct pbuf * p = pbuf_alloc(PBUF_TRANSPORT, out_buf_size * sizeof(char), PBUF_REF);
|
||||
p->payload = buf;
|
||||
|
||||
struct udp_pcb *broadcast_pcb;
|
||||
struct ip_addr forward_ip;
|
||||
#define fwd_port 5001
|
||||
|
||||
broadcast_pcb = udp_new();
|
||||
//38.132.37.5
|
||||
//IP4_ADDR(&forward_ip, 38, 132, 37, 5);
|
||||
//192.168.1.3
|
||||
IP4_ADDR(&forward_ip, 192, 168, 1, 3);
|
||||
//IP4_ADDR(&forward_ip, 192, 168, 1, 1);
|
||||
|
||||
int ret = udp_sendto(broadcast_pcb, p, &forward_ip, fwd_port); //dest port
|
||||
pbuf_free(p);
|
||||
printf(">>>button UDP message sent %d==>\n", ret);
|
||||
//test_rtk();
|
||||
printf("&rltk_wlan_info= %p\n", &rltk_wlan_info);
|
||||
dump_bytes((u32)&rltk_wlan_info, 64);
|
||||
printf("[0]\n");
|
||||
_adapter *ad = rltk_wlan_info[0].dev;
|
||||
printf("adapter = %p\n", ad);
|
||||
dump_bytes((u32)ad, 16);
|
||||
printf("bSurpriseRemoved [%p] = %d, +%d\n", &ad->bSurpriseRemoved, ad->bSurpriseRemoved, (u32)&ad->bSurpriseRemoved - (u32)ad);
|
||||
dump_bytes((u32)&ad->bSurpriseRemoved, 32);
|
||||
printf("mlmepriv +%d, mlmeextpriv +%d, cmdpriv +d%\n",
|
||||
(u32)(&ad->mlmepriv) - (u32)(ad),
|
||||
(u32)(&ad->mlmeextpriv) - (u32)(ad),
|
||||
(u32)(&ad->cmdpriv) - (u32)(ad));
|
||||
printf("xmitpriv +%d, recvpriv +%d, stapriv +%d\n",
|
||||
(u32)(&ad->xmitpriv) - (u32)(ad), (u32)(&ad->recvpriv) - (u32)(ad),
|
||||
(u32)(&ad->stapriv) - (u32)(ad));
|
||||
printf("bDriverStopped %d, hw_init_completed %d, cmdThread %d\n",
|
||||
(u32)(&ad->bDriverStopped) - (u32)(ad),
|
||||
(u32)(&ad->hw_init_completed) - (u32)(ad),
|
||||
(u32)(&ad->cmdThread) - (u32)(ad));
|
||||
printf("intf_start %d, bup %d, pcodatapriv %d\n",
|
||||
(u32)(&ad->intf_start) - (u32)(ad), (u32)(&ad->bup) - (u32)(ad),
|
||||
(u32)(&ad->pcodatapriv) - (u32)(ad));
|
||||
printf("Sizeof(adapter) = %d\n", sizeof(struct _ADAPTER));
|
||||
if (sizeof(struct _ADAPTER) != 6088) {
|
||||
printf("Error: Check aligned WiFi struct!\n");
|
||||
}
|
||||
printf("[1]\n");
|
||||
ad = rltk_wlan_info[1].dev;
|
||||
printf("adapter = %p\n", ad);
|
||||
dump_bytes((u32)ad, 16);
|
||||
printf("bSurpriseRemoved [%p] = %d, +%d\n", &ad->bSurpriseRemoved, ad->bSurpriseRemoved, (u32)&ad->bSurpriseRemoved - (u32)ad);
|
||||
dump_bytes((u32)&ad->bSurpriseRemoved, 32);
|
||||
printf("mlmepriv +%d, mlmeextpriv +%d, cmdpriv +d%\n",
|
||||
(u32)(&ad->mlmepriv) - (u32)(ad),
|
||||
(u32)(&ad->mlmeextpriv) - (u32)(ad),
|
||||
(u32)(&ad->cmdpriv) - (u32)(ad));
|
||||
printf("xmitpriv +%d, recvpriv +%d, stapriv +%d\n",
|
||||
(u32)(&ad->xmitpriv) - (u32)(ad), (u32)(&ad->recvpriv) - (u32)(ad),
|
||||
(u32)(&ad->stapriv) - (u32)(ad));
|
||||
printf("bDriverStopped %d, hw_init_completed %d, cmdThread %d\n",
|
||||
(u32)(&ad->bDriverStopped) - (u32)(ad),
|
||||
(u32)(&ad->hw_init_completed) - (u32)(ad),
|
||||
(u32)(&ad->cmdThread) - (u32)(ad));
|
||||
printf("intf_start %d, bup %d, pcodatapriv %d\n",
|
||||
(u32)(&ad->intf_start) - (u32)(ad), (u32)(&ad->bup) - (u32)(ad),
|
||||
(u32)(&ad->pcodatapriv) - (u32)(ad));
|
||||
printf("Sizeof(adapter) = %d\n", sizeof(struct _ADAPTER));
|
||||
if (sizeof(struct _ADAPTER) != 6088) {
|
||||
printf("Error: Check aligned WiFi struct!\n");
|
||||
}
|
||||
printf("adhoc\n");
|
||||
printf("rltk_wlan_info[0].dev\n");
|
||||
dump_bytes(&(rltk_wlan_info[0]),32);
|
||||
dump_bytes(&(rltk_wlan_info[0].mac),6);
|
||||
printf("rltk_wlan_info[1].dev\n");
|
||||
dump_bytes(&(rltk_wlan_info[1]),32);
|
||||
dump_bytes(&(rltk_wlan_info[1].mac),6);
|
||||
|
||||
printf("prep A\n");
|
||||
//return;
|
||||
char wlan0[6] = "wlan0";
|
||||
char mac1[6] = "123456";
|
||||
char ssid[6] = "123456";
|
||||
u8 alfa[65] = "1234567890qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM_.";
|
||||
u8 packet[128] = { 0x80, 0x00, 0x00, 0x00,
|
||||
/*4*/ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
/*10*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
|
||||
/*16*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
|
||||
/*22*/ 0xc0, 0x6c,
|
||||
/*24*/ 0x83, 0x51, 0xf7, 0x8f, 0x0f, 0x00, 0x00, 0x00,
|
||||
/*32*/ 0x64, 0x00,
|
||||
/*34*/ 0x01, 0x04,
|
||||
/* SSID */
|
||||
/*36*/ 0x00, 0x06, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72,
|
||||
0x01, 0x08, 0x82, 0x84,
|
||||
0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, 0x03, 0x01,
|
||||
/*56*/ 0x04};
|
||||
u8 channel;
|
||||
//_adapter *ad0 = rltk_wlan_info[0].dev;
|
||||
while (1) {
|
||||
if(0) {
|
||||
channel = 1; //RandSK(11)+1;
|
||||
// Source MAC Address
|
||||
packet[10] = packet[16] = 1;//RandSK256();
|
||||
packet[11] = packet[17] = 1;//RandSK256();
|
||||
packet[12] = packet[18] = 1;//RandSK256();
|
||||
packet[13] = packet[19] = 1;//RandSK256();
|
||||
packet[14] = packet[20] = 1;//RandSK256();
|
||||
packet[15] = packet[21] = 1;//RandSK256();
|
||||
} else {
|
||||
channel = RandSK(11)+1;
|
||||
// Source MAC Address
|
||||
packet[10] = packet[16] = RandSK256();
|
||||
packet[11] = packet[17] = RandSK256();
|
||||
packet[12] = packet[18] = RandSK256();
|
||||
packet[13] = packet[19] = RandSK256();
|
||||
packet[14] = packet[20] = RandSK256();
|
||||
packet[15] = packet[21] = RandSK256();
|
||||
}
|
||||
// Randomize SSID (Fixed size 6. Lazy right?)
|
||||
packet[38] = alfa[RandSK(65)];
|
||||
packet[39] = alfa[RandSK(65)];
|
||||
packet[40] = alfa[RandSK(65)];
|
||||
packet[41] = alfa[RandSK(65)];
|
||||
packet[42] = alfa[RandSK(65)];
|
||||
packet[43] = alfa[RandSK(65)];
|
||||
|
||||
packet[56] = channel;
|
||||
wext_set_channel(wlan0, channel);
|
||||
rtw_msleep_os(100);
|
||||
const TickType_t xDelay = 1000 / portTICK_PERIOD_MS; //1000ms
|
||||
//while(1) {
|
||||
memcpy(&mac1,&packet[10],6);
|
||||
memcpy(&ssid,&packet[38],6);
|
||||
printf("> ch,mac,ssid = %d,%12X,%s", channel,mac,ssid);
|
||||
for(int i=0;i<4;i++) {
|
||||
//rtw_send_mgnt(ad0, &packet, 57, NULL);
|
||||
wext_send_mgnt(wlan0, &packet, 57, NULL);
|
||||
printf(".");
|
||||
taskYIELD();
|
||||
//vTaskDelay( xDelay );
|
||||
if(0) {
|
||||
ShowMemInfo();
|
||||
dump_mem_block_list();
|
||||
tcm_heap_dump();
|
||||
}
|
||||
//rtw_msleep_os(100);
|
||||
}
|
||||
}
|
||||
if(1) {
|
||||
printf("rltk_wlan_info = %p\n", &rltk_wlan_info);
|
||||
int size = 512;
|
||||
int addr = 0;
|
||||
uint8_t *blk_data = (uint8_t *)malloc(size);
|
||||
memset(blk_data, 0xff, size);
|
||||
if(blk_data) {
|
||||
uint8_t * ptr = blk_data;
|
||||
//Hal_ReadEFuse(*(_adapter **)(rltk_wlan_info[0].dev->priv), 0, 0, 512, ptr, 1);
|
||||
//rtw_flash_map_update(*(_adapter **)(rltk_wlan_info->priv), 512);
|
||||
u32 symbs_line = 16;
|
||||
while(addr < size) {
|
||||
if(symbs_line > size) symbs_line = size;
|
||||
printf("%08X ", addr);
|
||||
print_hex_dump(ptr, symbs_line, ' ');
|
||||
printf("\r\n");
|
||||
addr += symbs_line;
|
||||
ptr += symbs_line;
|
||||
size -= symbs_line;
|
||||
if(size == 0) break;
|
||||
}
|
||||
free(blk_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(0){
|
||||
printf("[ATWM]Usage: ATWM=DURATION_SECONDS[with_len]\n");
|
||||
#if CONFIG_INIC_CMD_RSP
|
||||
inic_c2h_msg("ATWM", RTW_BADARG, NULL, 0);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
cmd_promisc(2,argv);
|
||||
return;
|
||||
#if CONFIG_INIC_CMD_RSP
|
||||
inic_frame_tail = inic_frame = pvPortMalloc(sizeof(struct inic_eth_frame)*MAX_INIC_FRAME_NUM);
|
||||
if(inic_frame == NULL){
|
||||
inic_c2h_msg("ATWM", RTW_BUFFER_UNAVAILABLE_TEMPORARY, NULL, 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_PROMISC
|
||||
wifi_init_packet_filter();
|
||||
#endif
|
||||
//promisc_test(1000, 0);
|
||||
#if CONFIG_INIC_CMD_RSP
|
||||
if(inic_frame)
|
||||
vPortFree(inic_frame);
|
||||
inic_frame_tail = NULL;
|
||||
inic_frame_cnt = 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
//------------------------------------------------------------------------------
|
||||
MON_RAM_TAB_SECTION COMMAND_TABLE console_commands_at[] = {
|
||||
{"ATST", 0, fATST, ": Memory info"},
|
||||
{"ATLW", 0, fATLW, ": LwIP Info"},
|
||||
{"ATWM", 0, fATWM, ": Prom"},
|
||||
{"ATSB", 1, fATSB, "=<ADDRES(hex)>[,COUNT(dec)]: Dump byte register"},
|
||||
{"ATSD", 1, fATSD, "=<ADDRES(hex)>[,COUNT(dec)]: Dump dword register"},
|
||||
{"ATSW", 2, fATSW, "=<ADDRES(hex)>,<DATA(hex)>: Set register"},
|
||||
{"ATDS", 0, fATDS, "=[TIME(ms)]: Deep sleep"},
|
||||
{"ATSP", 0, fATSP, "=<a,r>,<wakelock_status:1|2|4|8>: Power"}
|
||||
};
|
||||
|
||||
#endif //#ifdef CONFIG_AT_USR
|
||||
99
project/src/console/gpio_irq_test.c
Normal file
99
project/src/console/gpio_irq_test.c
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* test.c
|
||||
*
|
||||
* Created on: 12 марта 2017 г.
|
||||
* Author: PVV
|
||||
*/
|
||||
|
||||
#include <platform_opts.h>
|
||||
#include "device.h"
|
||||
#include "gpio_api.h" // mbed
|
||||
#include "gpio_irq_api.h" // mbed
|
||||
#include "gpio_irq_ex_api.h" // mbed
|
||||
#include "timer_api.h"
|
||||
#include "diag.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "hal_diag.h"
|
||||
#include "rtl8195a/rtl_libc.h"
|
||||
|
||||
#define GPIO_LED_PIN PA_4
|
||||
#define GPIO_IRQ_PIN PC_4
|
||||
|
||||
gpio_irq_t gpio_btn;
|
||||
gpio_t gpio_led;
|
||||
gtimer_t my_timer;
|
||||
|
||||
uint32_t lo_time_us, hi_time_us;
|
||||
uint32_t lo_time_cnt, hi_time_cnt;
|
||||
uint32_t old_tsf;
|
||||
uint32_t lo, hi, fr;
|
||||
|
||||
uint32_t io_irq_count;
|
||||
|
||||
LOCAL void gpio_demo_irq_handler(uint32_t id, gpio_irq_event event) {
|
||||
|
||||
// gpio_irq_disable(&gpio_btn);
|
||||
io_irq_count++;
|
||||
uint32_t new_tsf = get_tsf();
|
||||
uint32_t delta_us = (uint32_t) new_tsf - (uint32_t) old_tsf;
|
||||
if (event & 1) {
|
||||
lo_time_us += delta_us;
|
||||
lo_time_cnt++;
|
||||
gpio_irq_set(&gpio_btn, IRQ_LOW, 1);
|
||||
} else {
|
||||
hi_time_us += delta_us;
|
||||
hi_time_cnt++;
|
||||
gpio_irq_set(&gpio_btn, IRQ_HIGH, 1);
|
||||
}
|
||||
old_tsf = new_tsf;
|
||||
// gpio_irq_enable(&gpio_btn);
|
||||
}
|
||||
|
||||
LOCAL void timer1_timeout_handler(uint32_t id) {
|
||||
|
||||
if (lo_time_cnt && hi_time_cnt) {
|
||||
lo = lo_time_us / lo_time_cnt;
|
||||
hi = hi_time_us / hi_time_cnt;
|
||||
fr = hi + lo;
|
||||
lo_time_cnt = 0;
|
||||
lo_time_us = 0;
|
||||
hi_time_cnt = 0;
|
||||
hi_time_us = 0;
|
||||
printf("Period: %lu us, Lo: %lu us, Hi: %lu us\n", fr, lo, hi);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Main program.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
LOCAL void fATTT(int argc, char *argv[]) {
|
||||
|
||||
lo_time_cnt = 0;
|
||||
lo_time_us = 0;
|
||||
hi_time_cnt = 0;
|
||||
hi_time_us = 0;
|
||||
|
||||
// Init LED control pin
|
||||
gpio_init(&gpio_led, GPIO_LED_PIN);
|
||||
gpio_dir(&gpio_led, PIN_OUTPUT); // Direction: Output
|
||||
gpio_mode(&gpio_led, PullNone); // No pull
|
||||
gpio_write(&gpio_led, 0);
|
||||
|
||||
// Initial Push Button pin as interrupt source
|
||||
gpio_irq_init(&gpio_btn, GPIO_IRQ_PIN, gpio_demo_irq_handler,
|
||||
(uint32_t) (&gpio_led));
|
||||
gpio_irq_set(&gpio_btn, IRQ_FALL, 1); // Falling Edge Trigger
|
||||
gpio_irq_enable(&gpio_btn);
|
||||
|
||||
// Initial a periodical timer
|
||||
gtimer_init(&my_timer, TIMER1);
|
||||
gtimer_start_periodical(&my_timer, 1000000, (void*) timer1_timeout_handler,
|
||||
(uint32_t) &gpio_led);
|
||||
}
|
||||
|
||||
MON_RAM_TAB_SECTION COMMAND_TABLE console_commands_test[] = { { "ATTT", 0,
|
||||
fATTT, ": Test" } };
|
||||
|
||||
83
project/src/console/spi_tst.c
Normal file
83
project/src/console/spi_tst.c
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* spi_test.c
|
||||
*/
|
||||
#include <platform_opts.h>
|
||||
#include "rtl8195a.h"
|
||||
#include "spi_api.h"
|
||||
#include "spi_ex_api.h"
|
||||
#include "rtl8195a/rtl_libc.h"
|
||||
|
||||
#define SPI0_MOSI PC_2
|
||||
#define SPI0_MISO PC_3
|
||||
#define SPI0_SCLK PC_1
|
||||
#define SPI0_CS PC_0
|
||||
|
||||
spi_t spi_master;
|
||||
|
||||
LOCAL void show_reg_spi(int i) {
|
||||
rtl_printf("Regs SPI:\n");
|
||||
for(int x = 0; x < 64 ; x += 4) {
|
||||
rtl_printf("0x%08x ", HAL_SSI_READ32(i, x));
|
||||
if((x & 0x0F) == 0x0C) rtl_printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL void fATSSI(int argc, char *argv[])
|
||||
{
|
||||
int len = 128;
|
||||
int count = 32;
|
||||
int clk = 1000000;
|
||||
int ssn = 0;
|
||||
if(argc > 1) {
|
||||
len = atoi(argv[1]);
|
||||
if(len > 32768 || len <= 0) {
|
||||
len = 128;
|
||||
error_printf("%s: len = %u!\n", __func__, len);
|
||||
};
|
||||
};
|
||||
if(argc > 2) {
|
||||
count = atoi(argv[2]);
|
||||
if(count > 10000 || count <= 0) {
|
||||
count = 32;
|
||||
error_printf("%s: count = %u!\n", __func__, count);
|
||||
};
|
||||
};
|
||||
if(argc > 3) {
|
||||
clk = atoi(argv[3]);
|
||||
if(clk <= 0) {
|
||||
clk = 1000000;
|
||||
error_printf("%s: clk = %u!\n", __func__, clk);
|
||||
};
|
||||
};
|
||||
if(argc > 4) {
|
||||
ssn = atoi(argv[4]);
|
||||
if(ssn > 7 || ssn < 0) {
|
||||
ssn = 0;
|
||||
error_printf("%s: ssn = %u!\n", __func__, ssn);
|
||||
};
|
||||
};
|
||||
char* buff = pvPortMalloc(len);
|
||||
if(buff) {
|
||||
spi_init(&spi_master, SPI0_MOSI, SPI0_MISO, SPI0_SCLK, SPI0_CS); // CS заданный тут нигде не используется
|
||||
spi_format(&spi_master, 16, 3, 0);
|
||||
spi_frequency(&spi_master, clk);
|
||||
spi_slave_select(&spi_master, ssn); // выбор CS
|
||||
for(int i = 0; i < len; i++) buff[i] = (char)i;
|
||||
while(count--) {
|
||||
spi_master_write_stream(&spi_master, buff, len);
|
||||
while(spi_busy(&spi_master));
|
||||
rtl_printf("Master write: %d\n", count);
|
||||
};
|
||||
// show_reg_spi(spi_master.spi_adp.Index);
|
||||
spi_free(&spi_master);
|
||||
free(buff);
|
||||
}
|
||||
else {
|
||||
error_printf("%s: error malloc!\n", __func__);
|
||||
};
|
||||
}
|
||||
|
||||
MON_RAM_TAB_SECTION COMMAND_TABLE console_commands_spitst[] = {
|
||||
{"ATSSI", 0, fATSSI, "[len[,count[,clk[,ssn]]]]: Spi test"}
|
||||
};
|
||||
324
project/src/console/wifi_console.c
Normal file
324
project/src/console/wifi_console.c
Normal file
|
|
@ -0,0 +1,324 @@
|
|||
/*
|
||||
* wifi_console.c
|
||||
*
|
||||
* Created on: 03/04/2017
|
||||
* Author: pvvx
|
||||
*/
|
||||
|
||||
#include <autoconf.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "diag.h"
|
||||
#include "wifi_api.h"
|
||||
#include "wifi_conf.h"
|
||||
#include "rtl8195a/rtl_libc.h"
|
||||
#include "hal_platform.h"
|
||||
|
||||
#include "section_config.h"
|
||||
#include "hal_diag.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
|
||||
extern struct netif xnetif[NET_IF_NUM];
|
||||
|
||||
//==========================================================
|
||||
//--- CONSOLE --------------------------
|
||||
|
||||
// ATPN=<SSID>[,password[,encryption[,auto reconnect[,reconnect pause]]]: WIFI Connect to AP
|
||||
LOCAL void fATPN(int argc, char *argv[]){
|
||||
if(argc > 1) {
|
||||
if(argv[1][0] == '?') {
|
||||
show_wifi_st_cfg();
|
||||
}
|
||||
else {
|
||||
strncpy(wifi_st_cfg.ssid, argv[1], NDIS_802_11_LENGTH_SSID);
|
||||
int pswlen;
|
||||
if(argc > 2) {
|
||||
pswlen = strlen(wifi_st_cfg.password);
|
||||
strncpy(wifi_st_cfg.password, argv[2], NDIS_802_11_LENGTH_SSID);
|
||||
if(pswlen > 7) {
|
||||
wifi_st_cfg.security = IDX_SECURITY_WPA2_AES_PSK;
|
||||
}
|
||||
else if(!pswlen) {
|
||||
wifi_st_cfg.security = IDX_SECURITY_OPEN;
|
||||
}
|
||||
else {
|
||||
printf("password len < 8!\n");
|
||||
wifi_st_cfg.security = IDX_SECURITY_OPEN;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// default
|
||||
wifi_st_cfg.password[0] = 0;
|
||||
wifi_st_cfg.security = IDX_SECURITY_OPEN;
|
||||
}
|
||||
if(argc > 3) {
|
||||
if(pswlen > 7) {
|
||||
wifi_st_cfg.security = atoi(argv[3]);
|
||||
}
|
||||
else {
|
||||
printf("password len < 8!\n");
|
||||
wifi_st_cfg.security = IDX_SECURITY_OPEN;
|
||||
}
|
||||
}
|
||||
if(argc > 4) {
|
||||
wifi_st_cfg.autoreconnect = atoi(argv[4]);
|
||||
}
|
||||
else wifi_st_cfg.autoreconnect = 0;
|
||||
if(argc > 5) {
|
||||
wifi_st_cfg.reconnect_pause = atoi(argv[5]);
|
||||
}
|
||||
else wifi_st_cfg.reconnect_pause = 5;
|
||||
show_wifi_st_cfg();
|
||||
#if CONFIG_WLAN_CONNECT_CB
|
||||
connect_close();
|
||||
#endif
|
||||
wifi_run(wifi_run_mode | RTW_MODE_STA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ATPA=<SSID>[,password[,encryption[,channel[,hidden[,max connections]]]]]: Start WIFI AP
|
||||
LOCAL void fATPA(int argc, char *argv[]){
|
||||
if(argc > 1) {
|
||||
if(argv[1][0] == '?') {
|
||||
show_wifi_ap_cfg();
|
||||
}
|
||||
else {
|
||||
strncpy(wifi_ap_cfg.ssid, argv[1], NDIS_802_11_LENGTH_SSID);
|
||||
if(argc > 2) {
|
||||
strncpy(wifi_ap_cfg.password, argv[2], NDIS_802_11_LENGTH_SSID);
|
||||
int i = strlen(wifi_ap_cfg.password);
|
||||
if(i > 7) {
|
||||
wifi_ap_cfg.security = 1; // IDX_SECURITY_WPA2_AES_PSK;
|
||||
}
|
||||
else if(i == 0) {
|
||||
wifi_ap_cfg.security = 0; // IDX_SECURITY_OPEN;
|
||||
}
|
||||
else {
|
||||
printf("password len < 8!\n");
|
||||
wifi_ap_cfg.security = 0; // IDX_SECURITY_OPEN;
|
||||
}
|
||||
}
|
||||
else {
|
||||
wifi_ap_cfg.password[0] = 0;
|
||||
wifi_ap_cfg.security = 0; // IDX_SECURITY_OPEN;
|
||||
}
|
||||
if(argc > 3) {
|
||||
wifi_ap_cfg.security = (argv[3][0] == '0')? 0 : 1; //RTW_SECURITY_OPEN : RTW_SECURITY_WPA2_AES_PSK;
|
||||
}
|
||||
if(argc > 4) {
|
||||
wifi_ap_cfg.channel = atoi(argv[4]);
|
||||
}
|
||||
else wifi_ap_cfg.channel = 1;
|
||||
if(argc > 5) {
|
||||
wifi_ap_cfg.ssid_hidden = atoi(argv[5]);
|
||||
}
|
||||
else wifi_ap_cfg.ssid_hidden = 0;
|
||||
|
||||
if(argc > 6) {
|
||||
wifi_ap_cfg.max_sta = atoi(argv[6]);
|
||||
}
|
||||
else wifi_ap_cfg.max_sta = 3;
|
||||
|
||||
show_wifi_ap_cfg();
|
||||
#if CONFIG_WLAN_CONNECT_CB
|
||||
connect_close();
|
||||
#endif
|
||||
wifi_run(wifi_run_mode | RTW_MODE_AP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WIFI Connect, Disconnect
|
||||
LOCAL void fATWR(int argc, char *argv[]){
|
||||
rtw_mode_t mode = RTW_MODE_NONE;
|
||||
if(argc > 1) mode = atoi(argv[1]);
|
||||
#if CONFIG_WLAN_CONNECT_CB
|
||||
connect_close();
|
||||
#endif
|
||||
wifi_run(mode);
|
||||
}
|
||||
|
||||
#if CONFIG_WLAN_CONNECT_CB
|
||||
// Close connections
|
||||
LOCAL void fATOF(int argc, char *argv[]){
|
||||
connect_close();
|
||||
}
|
||||
|
||||
// Open connections
|
||||
LOCAL void fATON(int argc, char *argv[]){
|
||||
connect_start();
|
||||
}
|
||||
#endif
|
||||
|
||||
LOCAL void fATWI(int argc, char *argv[]) {
|
||||
#if 1
|
||||
if(argc > 2) {
|
||||
uint8_t c = argv[1][0] | 0x20;
|
||||
if(c == 's') {
|
||||
int i = atoi(argv[2]);
|
||||
printf("Save configs(%d)..\n", i);
|
||||
write_wifi_cfg(atoi(argv[2]));
|
||||
}
|
||||
else if(c == 'l') {
|
||||
wifi_cfg.load_flg = atoi(argv[2]);
|
||||
}
|
||||
else if(c == 'm') {
|
||||
wifi_cfg.mode = atoi(argv[2]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
rtw_wifi_setting_t Setting;
|
||||
if((wifi_run_mode & RTW_MODE_AP)
|
||||
&& wifi_get_setting(wlan_ap_name, &Setting) == 0) {
|
||||
wifi_show_setting(wlan_ap_name, &Setting);
|
||||
// show_wifi_ap_ip();
|
||||
printf("\tIP: " IPSTR "\n", IP2STR(&xnetif[WLAN_AP_NETIF_NUM].ip_addr));
|
||||
}
|
||||
if((wifi_run_mode & RTW_MODE_STA)
|
||||
&& wifi_get_setting(wlan_st_name, &Setting) == 0) {
|
||||
wifi_show_setting(wlan_st_name, &Setting);
|
||||
// show_wifi_st_ip();
|
||||
printf("\tIP: " IPSTR "\n", IP2STR(&xnetif[WLAN_ST_NETIF_NUM].ip_addr));
|
||||
}
|
||||
printf("\nWIFI config:\n");
|
||||
printf(&str_rom_57ch3Dch0A[25]); // "================================\n"
|
||||
show_wifi_cfg();
|
||||
printf("\nWIFI AP config:\n");
|
||||
printf(&str_rom_57ch3Dch0A[25]); // "================================\n"
|
||||
show_wifi_ap_cfg();
|
||||
printf("\nWIFI ST config:\n");
|
||||
printf(&str_rom_57ch3Dch0A[25]); // "================================\n"
|
||||
show_wifi_st_cfg();
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
extern uint8_t rtw_power_percentage_idx;
|
||||
|
||||
LOCAL void fATWT(int argc, char *argv[]) {
|
||||
if(argc > 1) {
|
||||
int txpwr = atoi(argv[1]);
|
||||
debug_printf("set tx power (%d)...\n", txpwr);
|
||||
if(rltk_set_tx_power_percentage(txpwr) != RTW_SUCCESS) {
|
||||
error_printf("Error set tx power (%d)!", wifi_cfg.tx_pwr);
|
||||
}
|
||||
}
|
||||
printf("TX power = %d\n", rtw_power_percentage_idx);
|
||||
}
|
||||
|
||||
//-- Test tsf (64-bits counts, 1 us step) ---
|
||||
|
||||
#include "hal_com_reg.h"
|
||||
|
||||
#define ReadTSF_Lo32() (*((volatile unsigned int *)(WIFI_REG_BASE + REG_TSFTR)))
|
||||
#define ReadTSF_Hi32() (*((volatile unsigned int *)(WIFI_REG_BASE + REG_TSFTR1)))
|
||||
|
||||
LOCAL uint64_t get_tsf(void)
|
||||
{
|
||||
return *((uint64_t *)(WIFI_REG_BASE + REG_TSFTR));
|
||||
}
|
||||
|
||||
LOCAL void fATSF(int argc, char *argv[])
|
||||
{
|
||||
uint64_t tsf = get_tsf();
|
||||
printf("\nTSF: %08x%08x\n", (uint32_t)(tsf>>32), (uint32_t)(tsf));
|
||||
}
|
||||
|
||||
LOCAL void fATWP(int argc, char *argv[]) {
|
||||
if(argc > 1) {
|
||||
release_wakelock(0xffff);
|
||||
wifi_set_power_mode(1, 1);
|
||||
wifi_set_lps_dtim(atoi(argv[1]));
|
||||
}
|
||||
else {
|
||||
unsigned char x;
|
||||
if(wifi_get_lps_dtim(&x) >= 0) {
|
||||
printf("DTIM: %d\n", x);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* -------- WiFi Scan ------------------------------- */
|
||||
LOCAL void scan_result_handler(internal_scan_handler_t* ap_scan_result)
|
||||
{
|
||||
if (ap_scan_result) {
|
||||
if(ap_scan_result->scan_cnt) {
|
||||
printf("\nScan networks:\n\n");
|
||||
printf("N\tType\tMAC\t\t\tSignal\tCh\tWPS\tSecyrity\tSSID\n\n");
|
||||
for(int i = 0 ; i < ap_scan_result->scan_cnt; i++) {
|
||||
rtw_scan_result_t* record = &ap_scan_result->ap_details[i];
|
||||
printf("%d\t", i+1);
|
||||
printf("%s\t", (record->bss_type == RTW_BSS_TYPE_ADHOC)? "Adhoc": "Infra");
|
||||
printf(MAC_FMT, MAC_ARG(record->BSSID.octet));
|
||||
printf("\t%d\t", record->signal_strength);
|
||||
printf("%d\t", record->channel);
|
||||
printf("%d\t", record->wps_type);
|
||||
{
|
||||
uint8 * s = rtw_security_to_str(record->security);
|
||||
printf("%s\t", s);
|
||||
if(strlen(s) < 8) printf("\t");
|
||||
}
|
||||
record->SSID.val[record->SSID.len] = '\0';
|
||||
printf("%s\n", record->SSID.val);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
printf("Scan networks: None!\n");
|
||||
}
|
||||
}
|
||||
/* -------- WiFi Scan ------------------------------- */
|
||||
LOCAL void fATSN(int argc, char *argv[])
|
||||
{
|
||||
api_wifi_scan(scan_result_handler);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP
|
||||
extern void cmd_ap_wps(int argc, char **argv);
|
||||
extern void cmd_wps(int argc, char **argv);
|
||||
//extern void cmd_wifi_on(int argc, char **argv);
|
||||
#endif
|
||||
#if CONFIG_ENABLE_P2P
|
||||
extern void cmd_wifi_p2p_start(int argc, char **argv);
|
||||
extern void cmd_wifi_p2p_stop(int argc, char **argv);
|
||||
extern void cmd_p2p_listen(int argc, char **argv);
|
||||
extern void cmd_p2p_find(int argc, char **argv);
|
||||
extern void cmd_p2p_peers(int argc, char **argv);
|
||||
extern void cmd_p2p_info(int argc, char **argv);
|
||||
extern void cmd_p2p_disconnect(int argc, char **argv);
|
||||
extern void cmd_p2p_connect(int argc, char **argv);
|
||||
extern void cmd_wifi_p2p_auto_go_start(int argc, char **argv);
|
||||
extern void cmd_p2p_peers(int argc, char **argv);
|
||||
#endif //CONFIG_ENABLE_P2P
|
||||
|
||||
MON_RAM_TAB_SECTION COMMAND_TABLE console_cmd_wifi_api[] = {
|
||||
{"ATPN", 1, fATPN, "=<SSID>[,password[,encryption[,auto-reconnect[,reconnect pause]]]: WIFI Connect to AP"},
|
||||
{"ATPA", 1, fATPA, "=<SSID>[,password[,encryption[,channel[,hidden[,max connections]]]]]: Start WIFI AP"},
|
||||
#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP
|
||||
{"WPS_AP", 1, cmd_ap_wps, "=<pbc/pin>[,pin]: WiFi AP WPS"},
|
||||
{"WPS_ST", 1, cmd_wps, "=<pbc/pin>[,pin]: WiFi Station WPS"},
|
||||
#endif
|
||||
#if CONFIG_ENABLE_P2P
|
||||
{"P2P_START", 0, cmd_wifi_p2p_start, ": p2p start" },
|
||||
{"P2P_ASTART", 0, cmd_wifi_p2p_auto_go_start, ": p2p auto go start" },
|
||||
{"P2P_STOP", 0, cmd_wifi_p2p_stop, ": p2p stop"},
|
||||
{"P2P_PEERS", 0, cmd_p2p_peers, ": p2p peers" },
|
||||
{"P2P_FIND", 0, cmd_p2p_find, ": p2p find"},
|
||||
{"P2P_INFO", 0, cmd_p2p_info, ": p2p info"},
|
||||
{"P2P_DISCCONNECT", 0, cmd_p2p_disconnect, ": p2p disconnect"},
|
||||
{"P2P_CONNECT", 0, cmd_p2p_connect, ": p2p connect"},
|
||||
#endif
|
||||
{"ATWR", 0, fATWR, ": WIFI Connect, Disconnect"},
|
||||
#if CONFIG_WLAN_CONNECT_CB
|
||||
{"ATON", 0, fATON, ": Open connections"},
|
||||
{"ATOFF", 0, fATOF, ": Close connections"},
|
||||
#endif
|
||||
{"ATWI", 0, fATWI, ": WiFi Info"},
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
{"ATWT", 1, fATWT, "=<tx_power>: WiFi tx power: 0 - 100%, 1 - 75%, 2 - 50%, 3 - 25%, 4 - 12.5%"},
|
||||
{"ATSF", 0, fATSF, ": Test TSF value"},
|
||||
#endif
|
||||
{"ATWP", 0, fATWP, ": WiFi power"},
|
||||
{"ATSN", 0, fATSN, ": Scan networks"}
|
||||
};
|
||||
|
||||
|
||||
722
project/src/rtl_boot_s.c
Normal file
722
project/src/rtl_boot_s.c
Normal file
|
|
@ -0,0 +1,722 @@
|
|||
/*
|
||||
* BootLoader Ver 0.2
|
||||
* Created on: 12/02/2017
|
||||
* Author: pvvx
|
||||
*/
|
||||
|
||||
//#include "../../../rtl_webupdater/project/inc/platform_autoconf.h"
|
||||
#include "platform_autoconf.h"
|
||||
#include "rtl_bios_data.h"
|
||||
#include "diag.h"
|
||||
#include "rtl8195a/rtl8195a_sys_on.h"
|
||||
|
||||
#include "hal_spi_flash.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
|
||||
#define DEFAULT_BAUDRATE UART_BAUD_RATE_38400
|
||||
|
||||
/* 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000? Hz,
|
||||
6 - 200000000 Hz, 7 - 10000000 Hz, 8 - 50000000 Hz, 9 - 25000000 Hz, 10 - 12500000 Hz, 11 - 4000000? Hz */
|
||||
#define DEFAULT_BOOT_CLK_CPU 1 // Warning! If Start CLK > 100 MHz -> Errors SPIC function in Ameba SDK!
|
||||
|
||||
#ifdef DEFAULT_BOOT_CLK_CPU
|
||||
#if DEFAULT_BOOT_CLK_CPU < 6
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_DIV5_3 0
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE DEFAULT_BOOT_CLK_CPU
|
||||
#else
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_DIV5_3 1
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE (DEFAULT_BOOT_CLK_CPU-6)
|
||||
#endif
|
||||
#endif // DEFAULT_BOOT_CLK_CPU
|
||||
|
||||
#define BOOT_RAM_TEXT_SECTION // __attribute__((section(".boot.text")))
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
typedef struct _seg_header {
|
||||
uint32 size;
|
||||
uint32 ldaddr;
|
||||
} IMGSEGHEAD, *PIMGSEGHEAD;
|
||||
|
||||
typedef struct _img2_header {
|
||||
IMGSEGHEAD seg;
|
||||
uint32 sign[2];
|
||||
void (*startfunc)(void);
|
||||
uint8 rtkwin[7];
|
||||
uint8 ver[13];
|
||||
uint8 name[32];
|
||||
} IMG2HEAD, *PIMG2HEAD;
|
||||
|
||||
#ifndef FLASH_SECTOR_SIZE
|
||||
#define FLASH_SECTOR_SIZE 4096
|
||||
#endif
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
LOCAL void RtlBootToFlash(void); // image1
|
||||
LOCAL void RtlBoot1ToSram(void); // image1
|
||||
LOCAL void RtlBoot2ToSram(void); // image1
|
||||
LOCAL void RtlBoot3ToSram(void); // image1
|
||||
LOCAL void RtlBoot4ToSram(void); // image1
|
||||
|
||||
extern _LONG_CALL_ VOID HalCpuClkConfig(unsigned char CpuType);
|
||||
extern _LONG_CALL_ VOID VectorTableInitRtl8195A(u32 StackP);
|
||||
extern _LONG_CALL_ VOID HalInitPlatformLogUartV02(VOID);
|
||||
extern _LONG_CALL_ VOID HalInitPlatformTimerV02(VOID);
|
||||
//extern _LONG_CALL_ VOID DramInit_rom(IN DRAM_DEVICE_INFO *DramInfo);
|
||||
//extern _LONG_CALL_ u32 SdrCalibration_rom(VOID);
|
||||
extern _LONG_CALL_ int SdrControllerInit_rom(PDRAM_DEVICE_INFO pDramInfo);
|
||||
extern _LONG_CALL_ u32 SpicCmpDataForCalibrationRtl8195A(void); // compare read_data and golden_data
|
||||
//extern _LONG_CALL_ VOID SpicWaitWipDoneRtl8195A(SPIC_INIT_PARA SpicInitPara); // wait spi-flash status register[0] = 0
|
||||
//extern _LONG_CALL_ VOID SpicLoadInitParaFromClockRtl8195A(u8 CpuClkMode, u8 BaudRate, PSPIC_INIT_PARA pSpicInitPara);
|
||||
//extern _LONG_CALL_ VOID RtlConsolInit(IN u32 Boot, IN u32 TBLSz, IN VOID *pTBL);
|
||||
|
||||
//#pragma arm section code = ".boot.text";
|
||||
//#pragma arm section rodata = ".boot.rodata", rwdata = ".boot.data", zidata = ".boot.bss";
|
||||
|
||||
typedef void (*START_FUNC)(void);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/* Start table: */
|
||||
START_RAM_FUN_SECTION RAM_FUNCTION_START_TABLE __ram_start_table_start__ = {
|
||||
RtlBootToFlash + 1, // StartFun(), Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x80000000 )
|
||||
RtlBoot1ToSram + 1, // PatchWAKE(), Run if ( v40000210 & 0x20000000 )
|
||||
RtlBoot2ToSram + 1, // PatchFun0(), Run if ( v40000210 & 0x10000000 )
|
||||
RtlBoot3ToSram + 1, // PatchFun1(), Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x8000000 )
|
||||
RtlBoot4ToSram + 1 };// PatchFun2(), Run for Init console, if ( v40000210 & 0x4000000 )
|
||||
//-------------------------------------------------------------------------
|
||||
/* Set Debug Flags */
|
||||
LOCAL void BOOT_RAM_TEXT_SECTION SetDebugFlgs() {
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
CfgSysDebugWarn = -1;
|
||||
CfgSysDebugInfo = -1;
|
||||
CfgSysDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
ConfigDebugInfo = -1;
|
||||
ConfigDebugErr = -1;
|
||||
#elif CONFIG_DEBUG_LOG > 1
|
||||
CfgSysDebugWarn = -1;
|
||||
// CfgSysDebugInfo = 0;
|
||||
CfgSysDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
// ConfigDebugInfo = 0;
|
||||
ConfigDebugErr = -1;
|
||||
#elif CONFIG_DEBUG_LOG > 0
|
||||
// CfgSysDebugWarn = 0;
|
||||
// CfgSysDebugInfo = 0;
|
||||
CfgSysDebugErr = -1;
|
||||
// ConfigDebugWarn = 0;
|
||||
// ConfigDebugInfo = 0;
|
||||
ConfigDebugErr = -1;
|
||||
#else
|
||||
// CfgSysDebugWarn = 0;
|
||||
// CfgSysDebugInfo = 0;
|
||||
// CfgSysDebugErr = 0;
|
||||
// ConfigDebugWarn = 0;
|
||||
// ConfigDebugInfo = 0;
|
||||
// ConfigDebugErr = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* JTAG On */
|
||||
LOCAL void BOOT_RAM_TEXT_SECTION JtagOn(void) {
|
||||
ACTCK_VENDOR_CCTRL(ON);
|
||||
SLPCK_VENDOR_CCTRL(ON);
|
||||
HalPinCtrlRtl8195A(JTAG, 0, 1);
|
||||
}
|
||||
|
||||
/* GetChipId() */
|
||||
LOCAL uint8 /*INFRA_START_SECTION*/BOOT_RAM_TEXT_SECTION _Get_ChipId() {
|
||||
uint8 ChipId = CHIP_ID_8710AF;
|
||||
if (HALEFUSEOneByteReadROM(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_CTRL), 0xF8,
|
||||
&ChipId, L25EOUTVOLTAGE) != 1)
|
||||
DBG_8195A("Get Chip ID Failed\r");
|
||||
return ChipId;
|
||||
}
|
||||
|
||||
/*
|
||||
* 16 bytes FIFO ... 16*11/38400 = 0.004583 sec
|
||||
* (0.005/5)*166666666 = 166666.666 Tcpu
|
||||
*/
|
||||
LOCAL void /*INFRA_START_SECTION*/BOOT_RAM_TEXT_SECTION loguart_wait_tx_fifo_empty(void) {
|
||||
if (HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT_SOC_LOG_UART_EN) {
|
||||
int x = 16384;
|
||||
while ((!(HAL_READ8(LOG_UART_REG_BASE, 0x14) & BIT6)) && x--)
|
||||
; // иначе глючит LogUART, если переключение CLK приходится на вывод символов !
|
||||
}
|
||||
}
|
||||
|
||||
extern SPIC_INIT_PARA SpicInitParaAllClk[SpicMaxMode][CPU_CLK_TYPE_NO]; // 100021ec [144=0x90]
|
||||
LOCAL uint32 InitTabParaAllClk[3 * CPU_CLK_TYPE_NO] = {
|
||||
// SIO
|
||||
0x01310102, // 72t/byte
|
||||
0x03310101, // 0201 - 40t, 0101 - 39t, 0102 - 72t, 0103 - 104t
|
||||
0x05310001, // 39t
|
||||
0x07310001,
|
||||
0x09310001,
|
||||
0x0B310001,
|
||||
// DIO
|
||||
0x11311301, // BaudRate = 1, RdDummyCyle = 19, DelayLine = 63, DIO
|
||||
0x13311201, // 1201 - 36t
|
||||
0x15311101, // 1101 - 35t
|
||||
0x17311101,
|
||||
0x19311101,
|
||||
0x1B311101
|
||||
// QIO
|
||||
/* MXIC Flash only DIO!
|
||||
0x21311301, // BaudRate = 1, RdDummyCyle = 19, DelayLine = 63, DIO
|
||||
0x23311201, // 1201 - 36t
|
||||
0x25311101, // 1101 - 35t
|
||||
0x27311101,
|
||||
0x29311101,
|
||||
0x2B311101
|
||||
*/
|
||||
};
|
||||
|
||||
struct spic_table_flash_type {
|
||||
uint8 cmd[12];
|
||||
uint8 strlr2;
|
||||
uint8 fbaud;
|
||||
uint8 addrlen;
|
||||
uint8 fsize;
|
||||
uint32 contrl;
|
||||
uint16 validcmd[3];
|
||||
uint8 manufacturerid;
|
||||
uint8 memorytype;
|
||||
};
|
||||
|
||||
//PSPIC_INIT_PARA pSpicInitPara;
|
||||
|
||||
struct spic_table_flash_type spic_table_flash = {
|
||||
{ // for FLASH MX25L8006E/1606E
|
||||
FLASH_CMD_FREAD, // REG_SPIC_READ_FAST_SINGLE 0x400060E0 0x0B
|
||||
FLASH_CMD_DREAD, // REG_SPIC_READ_DUAL_DATA 0x400060E4 0x3B
|
||||
FLASH_CMD_DREAD, // REG_SPIC_READ_DUAL_ADDR_DATA 0x400060E8 0x3B ?
|
||||
FLASH_CMD_QREAD, // REG_SPIC_READ_QUAD_DATA 0x400060EC 0x6B
|
||||
FLASH_CMD_4READ, // REG_SPIC_READ_QUAD_ADDR_DATA 0x400060F0 0xEB ?
|
||||
FLASH_CMD_PP, // REG_SPIC_WRITE_SIGNLE 0x400060F4 0x02
|
||||
FLASH_CMD_DPP, // REG_SPIC_WRITE_DUAL_DATA 0x400060F8 0xA2
|
||||
FLASH_CMD_DPP, // REG_SPIC_WRITE_DUAL_ADDR_DATA 0x400060FC 0xA2 ?
|
||||
FLASH_CMD_QPP, // REG_SPIC_WRITE_QUAD_DATA 0x40006100 0x32
|
||||
FLASH_CMD_4PP, // REG_SPIC_WRITE_QUAD_ADDR_DATA 0x40006104 0x38
|
||||
FLASH_CMD_WREN, // REG_SPIC_WRITE_ENABLE 0x40006108 0x06
|
||||
FLASH_CMD_RDSR // REG_SPIC_READ_STATUS 0x4000610C 0x05
|
||||
},
|
||||
BIT_FIFO_ENTRY(5) | BIT_SO_DUM, // REG_SPIC_CTRLR2 0x40006110 0x51
|
||||
BIT_FSCKDV(1), // REG_SPIC_FBAUDR 0x40006114 0x01
|
||||
BIT_ADDR_PHASE_LENGTH(3), // REG_SPIC_ADDR_LENGTH 0x40006118 0x03
|
||||
BIT_FLASE_SIZE(0x0F), // REG_SPIC_FLASE_SIZE 0x40006124 0x0E ?
|
||||
BIT_CS_H_WR_DUM_LEN(2)| BIT_AUTO_ADDR__LENGTH(3) | BIT_RD_DUMMY_LENGTH(0x0), // REG_SPIC_AUTO_LENGTH 0x4000611C 0x20030001 ?
|
||||
{
|
||||
BIT_WR_BLOCKING, // REG_SPIC_VALID_CMD 0x40006120 0x200 SpicOneBitMode
|
||||
BIT_WR_BLOCKING | BIT_RD_DUAL_I, // REG_SPIC_VALID_CMD 0x40006120 0x202 SpicDualBitMode
|
||||
BIT_WR_BLOCKING | BIT_RD_DUAL_I, // REG_SPIC_VALID_CMD 0x40006120 0x202 SpicDualBitMode
|
||||
// BIT_WR_BLOCKING | BIT_RD_QUAD_O, // REG_SPIC_VALID_CMD 0x40006120 0x208 SpicQuadBitMode MXIC not QIO
|
||||
},
|
||||
0xC2, 0x20 // MX25L8006/MX25L1606
|
||||
};
|
||||
|
||||
LOCAL int BOOT_RAM_TEXT_SECTION SetSpicBitMode(uint8 BitMode) {
|
||||
PSPIC_INIT_PARA pspic = &SpicInitParaAllClk[BitMode][((HAL_SYS_CTRL_READ32(REG_SYS_CLK_CTRL1) >> 4) & 7)];
|
||||
if(pspic->Mode.Valid) {
|
||||
// Disable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0);
|
||||
HAL_SPI_WRITE32(REG_SPIC_VALID_CMD, spic_table_flash.validcmd[pspic->Mode.BitMode]);
|
||||
HAL_SPI_WRITE32(REG_SPIC_AUTO_LENGTH, (HAL_SPI_READ32(REG_SPIC_AUTO_LENGTH) & 0xFFFF0000) | pspic->RdDummyCyle);
|
||||
HAL_SPI_WRITE32(REG_SPIC_BAUDR, pspic->BaudRate);
|
||||
FLASH_DDL_FCTRL(pspic->DelayLine); // SPI_DLY_CTRL_ADDR [7:0]
|
||||
// Enable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, BIT_SPIC_EN);
|
||||
}
|
||||
SPI_FLASH_PIN_FCTRL(ON);
|
||||
// Test Read Pattern
|
||||
if(!SpicCmpDataForCalibrationRtl8195A()) {
|
||||
FLASH_DDL_FCTRL(0x31); // SPI_DLY_CTRL_ADDR [7:0]
|
||||
for(uint8 BaudRate = 1; BaudRate < 4; BaudRate++) {
|
||||
for(uint8 RdDummyCyle = 0; RdDummyCyle < 63; RdDummyCyle++) {
|
||||
// Disable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0);
|
||||
HAL_SPI_WRITE32(REG_SPIC_AUTO_LENGTH, (HAL_SPI_READ32(REG_SPIC_AUTO_LENGTH) & 0xFFFF0000) | RdDummyCyle);
|
||||
HAL_SPI_WRITE32(REG_SPIC_BAUDR, BaudRate);
|
||||
// Enable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, BIT_SPIC_EN);
|
||||
// HAL_SPI_WRITE32(REG_SPIC_FLUSH_FIFO, 1);
|
||||
if(SpicCmpDataForCalibrationRtl8195A()) {
|
||||
DiagPrintf("Spic reinit %d:%d\n", BaudRate, RdDummyCyle);
|
||||
pspic->BaudRate = BaudRate;
|
||||
pspic->RdDummyCyle = RdDummyCyle;
|
||||
pspic->DelayLine = 0x31;
|
||||
pspic->Mode.Valid = 1;
|
||||
return 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
return 0;
|
||||
};
|
||||
return 1;
|
||||
}
|
||||
|
||||
void BOOT_RAM_TEXT_SECTION InitSpicFlashType(struct spic_table_flash_type *ptable_flash) {
|
||||
u8 * ptrb = &ptable_flash->cmd;
|
||||
volatile u32 * ptrreg = (volatile u32 *)(SPI_FLASH_CTRL_BASE + REG_SPIC_READ_FAST_SINGLE);// 0x400060E0
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0); // Disable SPI_FLASH User Mode
|
||||
do {
|
||||
*ptrreg++ = *ptrb++;
|
||||
} while(ptrb < (u8 *)(&ptable_flash->fsize));
|
||||
ptrreg[0] = ptable_flash->contrl;
|
||||
ptrreg[1] = ptable_flash->validcmd[SpicOneBitMode];
|
||||
ptrreg[2] = ptable_flash->fsize;
|
||||
HAL_SPI_WRITE32(REG_SPIC_SER, BIT_SER);
|
||||
}
|
||||
|
||||
LOCAL int BOOT_RAM_TEXT_SECTION InitSpic(uint8 SpicBitMode) {
|
||||
_memset(SpicInitParaAllClk, 0, sizeof(SpicInitParaAllClk));
|
||||
uint32 * ptr = InitTabParaAllClk;
|
||||
uint8 x;
|
||||
for(x = 0; x < SpicMaxMode; x++) {
|
||||
*(uint32 *)&SpicInitParaAllClk[SpicOneBitMode][x].BaudRate = ptr[0];
|
||||
*(uint32 *)&SpicInitParaAllClk[SpicDualBitMode][x].BaudRate = ptr[CPU_CLK_TYPE_NO];
|
||||
*(uint32 *)&SpicInitParaAllClk[SpicQuadBitMode][x].BaudRate = ptr[CPU_CLK_TYPE_NO]; // MXIC not QIO
|
||||
ptr++;
|
||||
}
|
||||
ACTCK_FLASH_CCTRL(1);
|
||||
SLPCK_FLASH_CCTRL(1);
|
||||
HalPinCtrlRtl8195A(SPI_FLASH, 0, 1);
|
||||
InitSpicFlashType(&spic_table_flash);
|
||||
return SetSpicBitMode(SpicBitMode);
|
||||
}
|
||||
|
||||
|
||||
/* SYSPlatformInit */
|
||||
LOCAL void /*INFRA_START_SECTION*/BOOT_RAM_TEXT_SECTION SYSPlatformInit(void) {
|
||||
__asm__ __volatile__ ("cpsid f\n");
|
||||
JtagOn();
|
||||
SetDebugFlgs();
|
||||
//----- SYS Init
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_EFUSE_SYSCFG0,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_SYSCFG0) & (~(BIT_MASK_SYS_EEROM_LDO_PAR_07_04 << BIT_SHIFT_SYS_EEROM_LDO_PAR_07_04))) | BIT_SYS_EEROM_LDO_PAR_07_04(6)); // & 0xF0FFFFFF | 0x6000000
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_XTAL_CTRL1,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_XTAL_CTRL1) & (~(BIT_MASK_SYS_XTAL_DRV_RF1 << BIT_SHIFT_SYS_XTAL_DRV_RF1))) | BIT_SYS_XTAL_DRV_RF1(1)); // & 0xFFFFFFE7 | 8;
|
||||
//----- SDIO_Device_Off
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_HCI_CLK_CTRL0,
|
||||
HAL_PERI_ON_READ32(REG_PESOC_HCI_CLK_CTRL0) & (~BIT_SOC_ACTCK_SDIO_DEV_EN));
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_HCI_COM_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_HCI_COM_FUNC_EN) & (~(BIT_SOC_HCI_SDIOD_ON_EN | BIT_SOC_HCI_SDIOD_OFF_EN)));
|
||||
HAL_PERI_ON_WRITE32(REG_HCI_PINMUX_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_HCI_PINMUX_CTRL) & (~(BIT_HCI_SDIOD_PIN_EN)));
|
||||
//----- GPIO Adapter
|
||||
extern HAL_GPIO_ADAPTER gBoot_Gpio_Adapter;
|
||||
_memset(&gBoot_Gpio_Adapter, 0, sizeof(gBoot_Gpio_Adapter));
|
||||
_pHAL_Gpio_Adapter = &gBoot_Gpio_Adapter;
|
||||
#ifdef DEFAULT_BOOT_CLK_CPU
|
||||
//----- CLK CPU
|
||||
loguart_wait_tx_fifo_empty(); // иначе глючит LogUART, если переключение CLK приходится на вывод символов !
|
||||
#if DEFAULT_BOOT_CPU_CLOCK_SEL_DIV5_3
|
||||
// 6 - 200000000 Hz, 7 - 10000000 Hz, 8 - 50000000 Hz, 9 - 25000000 Hz, 10 - 12500000 Hz, 11 - 4000000 Hz
|
||||
HalCpuClkConfig(DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE);
|
||||
*((int *)(SYSTEM_CTRL_BASE+REG_SYS_SYSPLL_CTRL1)) |= (1<<17);// REG_SYS_SYSPLL_CTRL1 |= BIT_SYS_SYSPLL_DIV5_3
|
||||
#else
|
||||
// 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000 Hz
|
||||
*((int *) (SYSTEM_CTRL_BASE + REG_SYS_SYSPLL_CTRL1)) &= ~(1 << 17); // REG_SYS_SYSPLL_CTRL1 &= ~BIT_SYS_SYSPLL_DIV5_3
|
||||
HalCpuClkConfig(DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE);
|
||||
#endif // CPU_CLOCK_SEL_DIV5_3
|
||||
#endif // DEFAULT_CLK_CPU
|
||||
//----- System
|
||||
VectorTableInitRtl8195A(STACK_TOP); // 0x1FFFFFFC
|
||||
HalInitPlatformLogUartV02(); // Show "<RTL8195A>"... :(
|
||||
HalInitPlatformTimerV02();
|
||||
__asm__ __volatile__ ("cpsie f\n");
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------
|
||||
Копирует данные из области align(4) (flash, registers, ...) в область align(1) (ram)
|
||||
--------------------------------------------------------------------------------------*/
|
||||
LOCAL unsigned int BOOT_RAM_TEXT_SECTION flashcpy(unsigned int faddr,
|
||||
void *dist, unsigned int size) {
|
||||
union {
|
||||
unsigned char uc[4];
|
||||
unsigned int ud;
|
||||
} tmp;
|
||||
if (faddr < SPI_FLASH_BASE)
|
||||
faddr += SPI_FLASH_BASE;
|
||||
unsigned char * pd = (unsigned char *) dist;
|
||||
unsigned int *p = (unsigned int *) ((unsigned int) faddr & (~3));
|
||||
unsigned int xlen = (unsigned int) faddr & 3;
|
||||
unsigned int len = size;
|
||||
|
||||
if (xlen) {
|
||||
tmp.ud = *p++;
|
||||
while (len) {
|
||||
len--;
|
||||
*pd++ = tmp.uc[xlen++];
|
||||
if (xlen & 4)
|
||||
break;
|
||||
};
|
||||
};
|
||||
xlen = len >> 2;
|
||||
while (xlen) {
|
||||
tmp.ud = *p++;
|
||||
*pd++ = tmp.uc[0];
|
||||
*pd++ = tmp.uc[1];
|
||||
*pd++ = tmp.uc[2];
|
||||
*pd++ = tmp.uc[3];
|
||||
xlen--;
|
||||
};
|
||||
if (len & 3) {
|
||||
tmp.ud = *p;
|
||||
pd[0] = tmp.uc[0];
|
||||
if (len & 2) {
|
||||
pd[1] = tmp.uc[1];
|
||||
if (len & 1) {
|
||||
pd[2] = tmp.uc[2];
|
||||
};
|
||||
};
|
||||
};
|
||||
return size;
|
||||
}
|
||||
|
||||
enum {
|
||||
SEG_ID_ERR,
|
||||
SEG_ID_SRAM,
|
||||
SEG_ID_TCM,
|
||||
SEG_ID_SDRAM,
|
||||
SEG_ID_SOC,
|
||||
SEG_ID_FLASH,
|
||||
SEG_ID_CPU,
|
||||
SEG_ID_ROM,
|
||||
SEG_ID_MAX
|
||||
} SEG_ID;
|
||||
|
||||
LOCAL const char * const txt_tab_seg[] = {
|
||||
"UNK", // 0
|
||||
"SRAM", // 1
|
||||
"TCM", // 2
|
||||
"SDRAM", // 3
|
||||
"SOC", // 4
|
||||
"FLASH", // 5
|
||||
"CPU", // 6
|
||||
"ROM" // 7
|
||||
};
|
||||
|
||||
LOCAL const uint32 tab_seg_def[] = { 0x10000000, 0x10070000, 0x1fff0000,
|
||||
0x20000000, 0x30000000, 0x30200000, 0x40000000, 0x40800000, 0x98000000,
|
||||
0xA0000000, 0xE0000000, 0xE0010000, 0x00000000, 0x00050000 };
|
||||
|
||||
LOCAL uint32 BOOT_RAM_TEXT_SECTION get_seg_id(uint32 addr, int32 size) {
|
||||
uint32 ret = SEG_ID_ERR;
|
||||
uint32 * ptr = &tab_seg_def;
|
||||
if (size > 0) {
|
||||
do {
|
||||
ret++;
|
||||
if (addr >= ptr[0] && addr + size <= ptr[1]) {
|
||||
return ret;
|
||||
};
|
||||
ptr += 2;
|
||||
} while (ret < SEG_ID_MAX);
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL uint32 BOOT_RAM_TEXT_SECTION load_img2_head(uint32 faddr, PIMG2HEAD hdr) {
|
||||
flashcpy(faddr, hdr, sizeof(IMG2HEAD));
|
||||
uint32 ret = get_seg_id(hdr->seg.ldaddr, hdr->seg.size);
|
||||
if (hdr->sign[1] == IMG_SIGN2_RUN) {
|
||||
if (hdr->sign[0] == IMG_SIGN1_RUN) {
|
||||
ret |= 1 << 9;
|
||||
} else if (hdr->sign[0] == IMG_SIGN1_SWP) {
|
||||
ret |= 1 << 8;
|
||||
};
|
||||
}
|
||||
if (*(u32 *) (&hdr->rtkwin) == IMG2_SIGN_DW1_TXT) {
|
||||
ret |= 1 << 10;
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
|
||||
LOCAL uint32 BOOT_RAM_TEXT_SECTION load_segs(uint32 faddr, PIMG2HEAD hdr,
|
||||
uint8 flgload) {
|
||||
uint32 fnextaddr = faddr;
|
||||
uint8 segnum = 0;
|
||||
while (1) {
|
||||
uint32 seg_id = get_seg_id(hdr->seg.ldaddr, hdr->seg.size);
|
||||
DBG_8195A("fnextaddr=0x%x seg_id=0x%x\n", fnextaddr, seg_id);
|
||||
if (flgload
|
||||
&& (seg_id == SEG_ID_SRAM || seg_id == SEG_ID_TCM
|
||||
|| seg_id == SEG_ID_SDRAM)) {
|
||||
#if CONFIG_DEBUG_LOG > 1
|
||||
DBG_8195A("Load Flash seg%d: 0x%08x -> %s: 0x%08x, size: %d\n",
|
||||
segnum, faddr, txt_tab_seg[seg_id], hdr->seg.ldaddr,
|
||||
hdr->seg.size);
|
||||
#endif
|
||||
fnextaddr += flashcpy(fnextaddr, hdr->seg.ldaddr, hdr->seg.size);
|
||||
} else if (seg_id) {
|
||||
#if CONFIG_DEBUG_LOG > 2
|
||||
DBG_8195A("Skip Flash seg%d: 0x%08x -> %s: 0x%08x, size: %d\n", segnum,
|
||||
fnextaddr, txt_tab_seg[seg_id], hdr->seg.ldaddr, hdr->seg.size);
|
||||
#endif
|
||||
fnextaddr += hdr->seg.size;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
fnextaddr += flashcpy(fnextaddr, &hdr->seg, sizeof(IMGSEGHEAD));
|
||||
segnum++;
|
||||
}
|
||||
return fnextaddr;
|
||||
}
|
||||
|
||||
/* loadUserImges
|
||||
* загружает Image2 с заданным номером
|
||||
*/
|
||||
LOCAL int BOOT_RAM_TEXT_SECTION loadUserImges(int image_selection) {
|
||||
IMG2HEAD hdr;
|
||||
int image_to_load = image_selection & 0x0f;
|
||||
int current_image_num = 0;
|
||||
uint32 faddr; // с какого места искать Image2
|
||||
uint32 img_id;
|
||||
u8 faddr_from_sysarea=0;
|
||||
DBG_8195A("Selected Image %d.\n", image_selection & 0x0f);
|
||||
|
||||
//задаем начальный адрес Image2
|
||||
if ((image_selection == 0x23) || (image_selection == 0x11)) {
|
||||
int fsize = 0x200000;
|
||||
if (_Get_ChipId()==CHIP_ID_8710AF)
|
||||
fsize = 0x100000;
|
||||
// выбрана последняя прошивка - начальный адрес берем из системной области
|
||||
// (upgraded Image2)
|
||||
flashcpy(FLASH_SYSTEM_DATA_ADDR, &faddr, sizeof(faddr)); // config data + 0
|
||||
// начало прошивки только с начала блока
|
||||
faddr &= ~(FLASH_SECTOR_SIZE - 1);
|
||||
// проверим загруженный адрес
|
||||
if (faddr >= fsize)
|
||||
faddr = 0xb000; // начальный адрес в системной области неверный, будем искать прошивку
|
||||
else {
|
||||
current_image_num = image_to_load;
|
||||
faddr_from_sysarea = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
faddr = 0xb000; // default Image2
|
||||
|
||||
while (1) {
|
||||
faddr = (faddr + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
|
||||
DBG_8195A("image_to_load=%d faddr=0x%x ", image_to_load, faddr);
|
||||
DBG_8195A("current_image_num=%d faddr_from_sysarea=%d\n",current_image_num, faddr_from_sysarea);
|
||||
img_id = load_img2_head(faddr, &hdr);
|
||||
if ((img_id >> 8) > 4 || (uint8) img_id != 0) {
|
||||
faddr = load_segs(faddr + 0x10, &hdr.seg,
|
||||
current_image_num == image_to_load);
|
||||
if (current_image_num == image_to_load) {
|
||||
DBG_8195A("Image%d: %s\n", current_image_num, hdr.name);
|
||||
break;
|
||||
}
|
||||
current_image_num++;
|
||||
}
|
||||
else {
|
||||
if (current_image_num) {
|
||||
faddr = 0xb000; // default Image2
|
||||
current_image_num =0;
|
||||
if (faddr_from_sysarea) {
|
||||
// нет Image2 по адресу из FLASH_SYSTEM_DATA_ADDR
|
||||
// попробуем загрузить прошивку заданную выводами
|
||||
faddr_from_sysarea =0;
|
||||
continue;
|
||||
}
|
||||
// по заданному адресу прошивки нет
|
||||
DBG_8195A("No Image%d! Trying Image0...\n", image_to_load);
|
||||
// пробуем загрузить 0 прошивку
|
||||
image_to_load = 0;
|
||||
}
|
||||
else {
|
||||
// нет 0 прошивки, прекращаем загрузку
|
||||
current_image_num = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
return current_image_num;
|
||||
}
|
||||
|
||||
/* IsForceLoadDefaultImg2
|
||||
* считывает из системной области список выводов для выбора прошивки (максимум два)
|
||||
* и опрашивает состояние этих выводов
|
||||
* номер прошивки:
|
||||
* номер 0 - default Image2 - аварийная прошивка
|
||||
* номера 1..3 - upgraded Image2 - рабочие прошивки
|
||||
*
|
||||
* на выходе: биты 3..0 - выбранный номер прошивки
|
||||
* если выводы не заданы или заданы неправильно - возвращает 0
|
||||
* если задан 1 вывод возвращает 0...1
|
||||
* если задано 2 вывода возвращает 0...3
|
||||
* биты 7..4 - сколько выводов задано
|
||||
*/
|
||||
/*LOCAL*/ uint8 BOOT_RAM_TEXT_SECTION IsForceLoadDefaultImg2(void) {
|
||||
uint8 gpio_pin[4];
|
||||
HAL_GPIO_PIN GPIO_Pin;
|
||||
HAL_GPIO_PIN_STATE flg;
|
||||
int result;
|
||||
int mask;
|
||||
int pincount;
|
||||
u8 uart_disconnected;
|
||||
|
||||
flashcpy(FLASH_SYSTEM_DATA_ADDR + 0x08, &gpio_pin, sizeof(gpio_pin)); // config data + 8
|
||||
// _pHAL_Gpio_Adapter = &gBoot_Gpio_Adapter;
|
||||
|
||||
pincount =0;
|
||||
result=0;
|
||||
mask=1;
|
||||
uart_disconnected=0;
|
||||
for (int i = 0; i<2; i++) {
|
||||
uint8 x = gpio_pin[i];
|
||||
if (x != 0xff) {
|
||||
// если вывод в том же состоянии считаем что он выбран
|
||||
// если он в противоположном состоянии - не выбран
|
||||
if (x & 0x80) {
|
||||
GPIO_Pin.pin_mode = DIN_PULL_LOW;
|
||||
flg = GPIO_PIN_LOW;
|
||||
} else {
|
||||
GPIO_Pin.pin_mode = DIN_PULL_HIGH;
|
||||
flg = GPIO_PIN_HIGH;
|
||||
}
|
||||
|
||||
x &=0x7f;
|
||||
GPIO_Pin.pin_name = HAL_GPIO_GetIPPinName_8195a(x);
|
||||
if (GPIO_Pin.pin_name == 0xff)
|
||||
continue;
|
||||
|
||||
// PB0, PB1 - LOG UART
|
||||
// в модулях RTL00/01 PB0 не может использоваться как вход выбора прошивки.
|
||||
if (((x==0x11) || (x==0x10)) && (uart_disconnected==0)) {
|
||||
HalPinCtrlRtl8195A(LOG_UART, 0, 0); // отключим LOG UART
|
||||
uart_disconnected =1;
|
||||
}
|
||||
|
||||
HAL_GPIO_Init_8195a(&GPIO_Pin);
|
||||
HalDelayUs(50);
|
||||
if (HAL_GPIO_ReadPin_8195a(&GPIO_Pin) == flg)
|
||||
result |= mask;
|
||||
|
||||
HAL_GPIO_DeInit_8195a(&GPIO_Pin);
|
||||
mask<<=1;
|
||||
pincount++;
|
||||
}
|
||||
}; // while
|
||||
if (uart_disconnected) {
|
||||
HalPinCtrlRtl8195A(LOG_UART, 0, 1); // подключим LOG UART
|
||||
HalDelayUs(26*11); // 1/38400 * 11
|
||||
}
|
||||
|
||||
// _pHAL_Gpio_Adapter->IrqHandle.IrqFun = NULL;
|
||||
|
||||
DBG_8195A("Pin count=%d Image %d selected\n",pincount, result);
|
||||
return (result & 0x0f) | (pincount<<4);
|
||||
}
|
||||
|
||||
/* RTL Console ROM */
|
||||
LOCAL void BOOT_RAM_TEXT_SECTION RtlConsolRam(void) {
|
||||
// DiagPrintf("\r\nRTL Console ROM\r\n");
|
||||
// RtlConsolInit(ROM_STAGE, (u32) 6, (void*) &UartLogRomCmdTable);
|
||||
pUartLogCtl->RevdNo = UART_LOG_HISTORY_LEN;
|
||||
pUartLogCtl->BootRdy = 1;
|
||||
pUartLogCtl->pTmpLogBuf->UARTLogBuf[0] = '?';
|
||||
pUartLogCtl->pTmpLogBuf->BufCount = 1;
|
||||
pUartLogCtl->ExecuteCmd = 1;
|
||||
RtlConsolTaskRom(pUartLogCtl);
|
||||
}
|
||||
|
||||
/* Enter Image 1.5 */
|
||||
LOCAL void BOOT_RAM_TEXT_SECTION EnterImage15(int flg) {
|
||||
int load_result;
|
||||
|
||||
if (flg)
|
||||
_memset(&__rom_bss_start__, 0, &__rom_bss_end__ - &__rom_bss_start__);
|
||||
|
||||
SYSPlatformInit();
|
||||
|
||||
if (!flg)
|
||||
DBG_8195A("\r===== Enter FLASH-Boot ====\n");
|
||||
else
|
||||
DBG_8195A("\r===== Enter SRAM-Boot %d ====\n", flg);
|
||||
#if CONFIG_DEBUG_LOG > 1
|
||||
DBG_8195A("CPU CLK: %d Hz, SOC FUNC EN: %p\r\n", HalGetCpuClk(),
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN));
|
||||
#endif
|
||||
uint8 ChipId = _Get_ChipId();
|
||||
if (ChipId < CHIP_ID_8195AM) {
|
||||
//----- SDRAM Off
|
||||
SDR_PIN_FCTRL(OFF);
|
||||
LDO25M_CTRL(OFF);
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21)); // Flag SDRAM Off
|
||||
} else {
|
||||
//----- SDRAM On
|
||||
LDO25M_CTRL(ON);
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_REGU_CTRL0,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_REGU_CTRL0) & 0xfffff) | BIT_SYS_REGU_LDO25M_ADJ(0x0e));
|
||||
SDR_PIN_FCTRL(ON);
|
||||
};
|
||||
if (!InitSpic(SpicDualBitMode)) {
|
||||
DBG_8195A("Spic Init Error!\n");
|
||||
RtlConsolRam();
|
||||
};
|
||||
if ((HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT(21)) == 0) { // уже загружена?
|
||||
// extern DRAM_DEVICE_INFO SdrDramInfo_rom; // 50 MHz
|
||||
if (!SdrControllerInit_rom(&SdrDramInfo)) { // 100 MHz
|
||||
DBG_8195A("SDR Controller Init fail!\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
#if 0 // Test SDRAM
|
||||
else {
|
||||
uint32 *ptr = SDR_SDRAM_BASE;
|
||||
uint32 tt = 0x55AA55AA;
|
||||
for (int i = 0; i < 512 * 1024; i++) {
|
||||
ptr[i] = tt++;
|
||||
};
|
||||
tt = 0x55AA55AA;
|
||||
for (int i = 0; i < 512 * 1024; i++) {
|
||||
if (ptr[i] != tt) {
|
||||
DBG_8195A("SDR err %p %p != %p!\n", &ptr[i], ptr[i], tt);
|
||||
RtlConsolRam();
|
||||
}
|
||||
tt++;
|
||||
};
|
||||
DBG_8195A("SDR tst end\n");
|
||||
};
|
||||
#endif // test
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21));
|
||||
};
|
||||
|
||||
if (!flg) {
|
||||
load_result = loadUserImges(IsForceLoadDefaultImg2());
|
||||
}
|
||||
|
||||
|
||||
if (_strcmp((const char *) &__image2_validate_code__, IMG2_SIGN_TXT) ||
|
||||
(load_result <0)) {
|
||||
DBG_8195A("Invalid Image Signature!\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
|
||||
DBG_8195A("Img Sign: %s, Go @ 0x%08x\r\n", &__image2_validate_code__,
|
||||
__image2_entry_func__);
|
||||
__image2_entry_func__();
|
||||
}
|
||||
|
||||
/* RtlBootToSram */
|
||||
LOCAL void BOOT_RAM_TEXT_SECTION RtlBoot1ToSram(void) {
|
||||
EnterImage15(1);
|
||||
}
|
||||
/* RtlBootToSram */
|
||||
LOCAL void BOOT_RAM_TEXT_SECTION RtlBoot2ToSram(void) {
|
||||
EnterImage15(2);
|
||||
}
|
||||
/* RtlBootToSram */
|
||||
LOCAL void BOOT_RAM_TEXT_SECTION RtlBoot3ToSram(void) {
|
||||
EnterImage15(3);
|
||||
}
|
||||
/* RtlBootToSram */
|
||||
LOCAL void BOOT_RAM_TEXT_SECTION RtlBoot4ToSram(void) {
|
||||
EnterImage15(4);
|
||||
}
|
||||
|
||||
LOCAL void BOOT_RAM_TEXT_SECTION RtlBootToFlash(void) {
|
||||
EnterImage15(0);
|
||||
}
|
||||
97
project/src/user/main.c
Normal file
97
project/src/user/main.c
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "platform_autoconf.h"
|
||||
#include "autoconf.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "diag.h"
|
||||
#include "hal_crypto.h"
|
||||
#include "hal_log_uart.h"
|
||||
#include "hal_misc.h"
|
||||
#include "diag.h"
|
||||
//#include "wdt_api.h"
|
||||
//#include <osdep_service.h>
|
||||
#include "hal_platform.h"
|
||||
#include "rtl8195a_sys_on.h"
|
||||
|
||||
#ifdef CONFIG_WDG_ON_IDLE
|
||||
#include "hal_peri_on.h"
|
||||
#include "rtl8195a_peri_on.h"
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------
|
||||
* Customized Signature (Image Name)
|
||||
* ---------------------------------------------------*/
|
||||
#include "section_config.h"
|
||||
SECTION(".custom.validate.rodata")
|
||||
const unsigned char cus_sig[32] = "HTTPD Sample";
|
||||
|
||||
#ifdef CONFIG_DEBUG_LOG
|
||||
#define DEBUG_MAIN_LEVEL CONFIG_DEBUG_LOG
|
||||
#else
|
||||
#define DEBUG_MAIN_LEVEL 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_INIT_NET
|
||||
#define CONFIG_INIT_NET 1
|
||||
#endif
|
||||
#ifndef CONFIG_INTERACTIVE_MODE
|
||||
#define CONFIG_INTERACTIVE_MODE 1
|
||||
#endif
|
||||
|
||||
extern void user_init_thrd(void);
|
||||
|
||||
/* RAM/TCM/Heaps info */
|
||||
void ShowMemInfo(void)
|
||||
{
|
||||
printf("\nCLK CPU\t\t%d Hz\nRAM heap\t%d bytes\nTCM heap\t%d bytes\n",
|
||||
HalGetCpuClk(), xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||
}
|
||||
|
||||
/* main */
|
||||
void main(void)
|
||||
{
|
||||
#if DEBUG_MAIN_LEVEL > 3
|
||||
ConfigDebugErr = -1;
|
||||
ConfigDebugInfo = ~(_DBG_SPI_FLASH_);//|_DBG_TCM_HEAP_);
|
||||
ConfigDebugWarn = -1;
|
||||
CfgSysDebugErr = -1;
|
||||
CfgSysDebugInfo = -1;
|
||||
CfgSysDebugWarn = -1;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WDG_ON_IDLE
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & 0x1FFFFF);
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
WDGInitial(CONFIG_WDG_ON_IDLE * 3000); // 30 s
|
||||
#else
|
||||
WDGInitial(CONFIG_WDG_ON_IDLE * 1000); // 10 s
|
||||
#endif
|
||||
WDGStart();
|
||||
#endif
|
||||
|
||||
#if (defined(CONFIG_CRYPTO_STARTUP) && (CONFIG_CRYPTO_STARTUP))
|
||||
if(rtl_cryptoEngine_init() != 0 ) {
|
||||
DBG_8195A("Crypto engine init failed!\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DEBUG_MAIN_LEVEL > 1
|
||||
vPortFree(pvPortMalloc(4)); // Init RAM heap
|
||||
ShowMemInfo(); // RAM/TCM/Heaps info
|
||||
#endif
|
||||
|
||||
/* wlan & user_start intialization */
|
||||
xTaskCreate(user_init_thrd, "user_init", 1024, NULL, tskIDLE_PRIORITY + 1 + PRIORITIE_OFFSET, NULL);
|
||||
|
||||
/*Enable Schedule, Start Kernel*/
|
||||
#if defined(CONFIG_KERNEL) && !TASK_SCHEDULER_DISABLED
|
||||
#ifdef PLATFORM_FREERTOS
|
||||
vTaskStartScheduler();
|
||||
#endif
|
||||
#else
|
||||
RtlConsolTaskRom(NULL);
|
||||
#endif
|
||||
}
|
||||
101
project/src/user/user_init.c
Normal file
101
project/src/user/user_init.c
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* user_init.c
|
||||
*
|
||||
*/
|
||||
#include "user_config.h"
|
||||
#include "platform_opts.h"
|
||||
#include "rtl8195a.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "diag.h"
|
||||
#include "objects.h"
|
||||
#include "wifi_api.h"
|
||||
//#include "espfs.h"
|
||||
//#include "http_server.h"
|
||||
//#include "httpd.h"
|
||||
//#include "captdns.h"
|
||||
#include "netbios/netbios.h"
|
||||
#include "bitband_io.h"
|
||||
|
||||
|
||||
//extern HttpdBuiltInUrl mainInUrls[];
|
||||
|
||||
|
||||
#ifdef WIFI_RESET_SETTINGS_PIN
|
||||
|
||||
LOCAL int check_wifi_settings_reset(void)
|
||||
{
|
||||
gpio_t button_gpio;
|
||||
int time_tst = 300; // 3 sec low button
|
||||
#if WIFI_RESET_SETTINGS_PIN == PB_1
|
||||
HalDeinitLogUart(); // sys_log_uart_off();
|
||||
#endif
|
||||
gpio_init(&button_gpio, WIFI_RESET_SETTINGS_PIN);
|
||||
gpio_dir(&button_gpio, PIN_INPUT); // Direction: Input
|
||||
gpio_mode(&button_gpio, PullUp); // Pull-High
|
||||
|
||||
while(time_tst) {
|
||||
if(gpio_read(&button_gpio)) {
|
||||
break;
|
||||
};
|
||||
vTaskDelay(10);
|
||||
time_tst--;
|
||||
};
|
||||
|
||||
gpio_deinit(&button_gpio);
|
||||
#if WIFI_RESET_SETTINGS_PIN == PB_1
|
||||
vTaskDelay(1);
|
||||
HalPinCtrlRtl8195A(LOG_UART, 0, 1); // connect LOG UART // HalInitLogUart(); // sys_log_uart_on();
|
||||
#endif
|
||||
return time_tst;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void user_init_thrd(void) {
|
||||
|
||||
#ifdef WIFI_RESET_SETTINGS_PIN
|
||||
if (check_wifi_settings_reset() == 0) {
|
||||
rtl_printf("No Load Config\n");
|
||||
wifi_cfg.load_flg &= ~BID_WIFI_CFG;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef GPIO_LED_PIN
|
||||
//GpioLedInit();
|
||||
#endif
|
||||
// release_wakelock(15);
|
||||
|
||||
wifi_init();
|
||||
|
||||
netbios_init();
|
||||
|
||||
//captdnsInit();
|
||||
|
||||
debug_printf("[Before espfsInit]: RAM heap\t%d bytes\tTCM heap\t%d bytes\n",
|
||||
xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||
|
||||
//EspFsInitResult e = espFsInit((void*)FLASH_APP_BASE);
|
||||
|
||||
debug_printf("[After espfsInit]: RAM heap\t%d bytes\tTCM heap\t%d bytes\n",
|
||||
xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||
|
||||
//httpdInit(&mainInUrls, 80);
|
||||
|
||||
//if (e==0)
|
||||
// xTaskCreate(websocketBcast, "wsbcast", 300, NULL, WEBSOC_PRIORITY, NULL);
|
||||
//else
|
||||
// error_printf("Espfs not found.\n");
|
||||
|
||||
debug_printf("[After httpdInit]: RAM heap\t%d bytes\tTCM heap\t%d bytes\n",
|
||||
xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||
|
||||
/* Initilaize the console stack */
|
||||
console_init();
|
||||
|
||||
/* Kill init thread after all init tasks done */
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
291
project/src/user/wc_mgr.c
Normal file
291
project/src/user/wc_mgr.c
Normal file
|
|
@ -0,0 +1,291 @@
|
|||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "diag.h"
|
||||
#include "objects.h"
|
||||
#include "osdep_service.h"
|
||||
#include "device_lock.h"
|
||||
#include "semphr.h"
|
||||
#include "tcm_heap.h"
|
||||
|
||||
|
||||
#if CONFIG_WLAN
|
||||
#include "wifi_conf.h"
|
||||
#include "wlan_intf.h"
|
||||
#include "wifi_constants.h"
|
||||
#include "wifi_lib.h"
|
||||
|
||||
#include <wlan/wlan_test_inc.h>
|
||||
#include <wifi/wifi_conf.h>
|
||||
#include <wifi/wifi_util.h>
|
||||
#endif
|
||||
#include "lwip_netconf.h"
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include <dhcp/dhcps.h>
|
||||
#include <lwip_netconf.h>
|
||||
#include "tcpip.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "wc_mgr.h"
|
||||
#include "http_server.h"
|
||||
|
||||
//rtw_mode_t wifi_mode = RTW_MODE_STA_AP; //RTW_MODE__NONE;
|
||||
|
||||
|
||||
#if CONFIG_LWIP_LAYER
|
||||
extern struct netif xnetif[NET_IF_NUM];
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
typedef int (*wlan_init_done_ptr)(void);
|
||||
typedef int (*write_reconnect_ptr)(uint8_t *data, uint32_t len);
|
||||
extern init_done_ptr p_wlan_init_done_callback;
|
||||
//extern write_reconnect_ptr p_write_reconnect_ptr;
|
||||
|
||||
static rtw_ap_info_t ap = {0};
|
||||
|
||||
static rtw_network_info_t wifi = {
|
||||
{0}, // ssid
|
||||
{0}, // bssid
|
||||
0, // security
|
||||
NULL, // password
|
||||
0, // password len
|
||||
-1 // key id
|
||||
};
|
||||
|
||||
rtw_wifi_setting_t wifi_setting = {RTW_MODE_STA_AP, {0}, 0, RTW_SECURITY_OPEN, {0}};
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
static void init_wifi_struct(void)
|
||||
{
|
||||
memset(wifi.ssid.val, 0, sizeof(wifi.ssid.val));
|
||||
memset(wifi.bssid.octet, 0, ETH_ALEN);
|
||||
//memset(password, 0, sizeof(password));
|
||||
wifi.ssid.len = 0;
|
||||
wifi.password = NULL;
|
||||
wifi.password_len = 0;
|
||||
wifi.key_id = -1;
|
||||
memset(ap.ssid.val, 0, sizeof(ap.ssid.val));
|
||||
ap.ssid.len = 0;
|
||||
ap.password = NULL;
|
||||
ap.password_len = 0;
|
||||
ap.channel = 1;
|
||||
}
|
||||
|
||||
static void get_wifi_setting_from_if()
|
||||
{
|
||||
const char *ifname = WLAN0_NAME;
|
||||
|
||||
if(rltk_wlan_running(WLAN1_IDX))
|
||||
{//STA_AP_MODE
|
||||
ifname = WLAN1_NAME;
|
||||
}
|
||||
|
||||
wifi_get_setting(ifname, &wifi_setting);
|
||||
|
||||
rtl_printf("LoadWifiSetting(): wifi_setting.ssid=%s\n", wifi_setting.ssid);
|
||||
rtl_printf("LoadWifiSetting(): wifi_setting.channel=%d\n", wifi_setting.channel);
|
||||
rtl_printf("LoadWifiSetting(): wifi_setting.security_type=%d\n", wifi_setting.security_type);
|
||||
rtl_printf("LoadWifiSetting(): wifi_setting.password=%s\n", wifi_setting.password);
|
||||
}
|
||||
#endif
|
||||
|
||||
void show_info(uint8_t wmask) {
|
||||
rtw_wifi_setting_t Setting;
|
||||
|
||||
if (wmask & 1) {
|
||||
wifi_get_setting(WLAN0_NAME, &Setting);
|
||||
wifi_show_setting(WLAN0_NAME, &Setting);
|
||||
}
|
||||
if (wmask & 2) {
|
||||
wifi_get_setting(WLAN1_NAME, &Setting);
|
||||
wifi_show_setting(WLAN1_NAME, &Setting);
|
||||
}
|
||||
}
|
||||
|
||||
_WEAK void connect_start(void)
|
||||
{
|
||||
rtl_printf("%s\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
_WEAK void connect_close(void)
|
||||
{
|
||||
rtl_printf("%s\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
int wlan_reconnect(u8 *data, uint32_t len) {
|
||||
rtl_printf("%s\n", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
int write_reconnect_cb(u8 *data, uint32_t len)
|
||||
{
|
||||
rtl_printf("%s\n", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern void (*p_wlan_autoreconnect_hdl)(rtw_security_t, char*, int, char*, int, int);
|
||||
extern void wifi_autoreconnect_hdl (rtw_security_t, char*, int, char*, int, int);
|
||||
// (not work if lib_wlan_mp.a ?)
|
||||
int sta_autoreconnect_setup(void)
|
||||
{
|
||||
p_wlan_autoreconnect_hdl = wifi_autoreconnect_hdl;
|
||||
//WLAN0_NAME, mode, retry_times, timeout
|
||||
return wext_set_autoreconnect(WLAN0_NAME, 1, 20, 7);
|
||||
}
|
||||
|
||||
void reset_wifi_settings(void) {
|
||||
char* ssid;
|
||||
|
||||
rtl_printf("%s\n", __func__);
|
||||
|
||||
//--------- Default wi-fi settigns ---------
|
||||
// STATION settings
|
||||
ssid = "HOMEAP";
|
||||
wifi.ssid.len = strlen(ssid);
|
||||
memset((void*)&wifi.ssid.val[0], 0, sizeof(&wifi.ssid.val));
|
||||
memcpy((void*)&wifi.ssid.val[0], (void*)ssid, wifi.ssid.len);
|
||||
wifi.security_type = RTW_SECURITY_OPEN; //RTW_SECURITY_WPA2_AES_PSK;
|
||||
wifi.password = "0123456789"; //
|
||||
wifi.password_len = strlen(wifi.password);
|
||||
wifi.key_id =0;
|
||||
|
||||
// AP settings
|
||||
ssid = "RTL8710";
|
||||
ap.ssid.len = strlen(ssid);
|
||||
memset(ap.ssid.val, 0, sizeof(ap.ssid.val));
|
||||
memcpy((void*)&ap.ssid.val[0], (void*)ssid, ap.ssid.len);
|
||||
ap.security_type = RTW_SECURITY_OPEN; // RTW_SECURITY_WPA2_AES_PSK
|
||||
ap.channel = 1;
|
||||
ap.password = "0123456789";
|
||||
ap.password_len = strlen(ap.password);
|
||||
//------------------------------------------
|
||||
}
|
||||
void load_wifi_settings(void) {
|
||||
rtl_printf("%s\n", __func__);
|
||||
#if 0
|
||||
// ...
|
||||
// load settings from flash
|
||||
// ...
|
||||
#else
|
||||
reset_wifi_settings();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void wc_start(void) {
|
||||
int ret;
|
||||
void *semaphore = NULL;
|
||||
int timeout = 10000/200;
|
||||
|
||||
|
||||
|
||||
|
||||
p_wlan_init_done_callback = NULL;
|
||||
|
||||
|
||||
|
||||
LwIP_Init();
|
||||
|
||||
if (wifi_on(RTW_MODE_STA_AP) < 0) {
|
||||
printf("ERROR: Wifi on failed!\n");
|
||||
goto exit_fail;
|
||||
}
|
||||
|
||||
// stop dhcp server and client
|
||||
dhcps_deinit();
|
||||
LwIP_DHCP(0, DHCP_STOP);
|
||||
LwIP_DHCP(1, DHCP_STOP);
|
||||
|
||||
rtl_printf("Starting AP ...\n");
|
||||
ret = wifi_start_ap(
|
||||
ap.ssid.val, //char *ssid,
|
||||
ap.security_type, //rtw_security_t ecurity_type,
|
||||
ap.password, //char *password,
|
||||
ap.ssid.len, //int ssid_len,
|
||||
ap.password_len, //int password_len,
|
||||
ap.channel //int channel
|
||||
);
|
||||
if (ret != RTW_SUCCESS) {
|
||||
rtl_printf("ERROR: Operation failed!\n\n");
|
||||
return;
|
||||
}
|
||||
while(1) {
|
||||
char essid[33];
|
||||
|
||||
if(wext_get_ssid(WLAN1_NAME, (unsigned char *) essid) > 0) {
|
||||
if(strcmp((const char *) essid, (const char *)ap.ssid.val) == 0) {
|
||||
rtl_printf("%s started\n", ap.ssid.val);
|
||||
ret = RTW_SUCCESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(timeout == 0) {
|
||||
rtl_printf("ERROR: Start AP timeout!\n");
|
||||
ret = RTW_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
//vTaskDelay(1 * configTICK_RATE_HZ);
|
||||
vTaskDelay(200/portTICK_RATE_MS);
|
||||
timeout --;
|
||||
}
|
||||
rtl_printf("[AP_on]: RAM heap\t%d bytes\tTCM heap\t%d bytes\n",
|
||||
xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||
#if CONFIG_LWIP_LAYER
|
||||
LwIP_UseStaticIP(&xnetif[1]);
|
||||
#ifdef CONFIG_DONT_CARE_TP
|
||||
pnetiff->flags |= NETIF_FLAG_IPSWITCH;
|
||||
#endif
|
||||
dhcps_init(&xnetif[1]);
|
||||
#endif
|
||||
|
||||
show_info(2);
|
||||
|
||||
sta_autoreconnect_setup();
|
||||
|
||||
rtl_printf("[Wifi_on]: RAM heap\t%d bytes\tTCM heap\t%d bytes\n",
|
||||
xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||
|
||||
ret = wifi_connect(wifi.ssid.val,
|
||||
wifi.security_type,
|
||||
wifi.password,
|
||||
wifi.ssid.len,
|
||||
wifi.password_len,
|
||||
wifi.key_id,
|
||||
semaphore);
|
||||
|
||||
rtl_printf("Connected to AP\n");
|
||||
rtl_printf("[STA_connected]: RAM heap\t%d bytes\tTCM heap\t%d bytes\n",
|
||||
xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||
if(ret != RTW_SUCCESS) {
|
||||
rtl_printf("ERROR: Operation failed! Error=%d\n", ret);
|
||||
//goto exit_fail;
|
||||
} else {
|
||||
// Start DHCPClient
|
||||
LwIP_DHCP(0, DHCP_START);
|
||||
rtl_printf("Got IP\n");
|
||||
|
||||
#if CONFIG_WLAN_CONNECT_CB
|
||||
// extern void connect_start(void);
|
||||
connect_start();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
show_info(3);
|
||||
|
||||
httpd_start();
|
||||
|
||||
|
||||
|
||||
exit_fail:
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue