This commit is contained in:
pvvx 2017-12-12 23:34:32 +03:00
parent b3dc0dda87
commit 0830a1244a
29 changed files with 240 additions and 152 deletions

View file

@ -30,6 +30,7 @@ extern int inic_stop(void);
#if CONFIG_DEBUG_LOG > 0
#undef printf
extern int rtl_printf(const char *fmt, ...);
#define printf(...) rtl_printf(__VA_ARGS__)
#else
#undef printf
@ -832,13 +833,13 @@ int wifi_on(rtw_mode_t mode) {
wifi_set_mib();
printf("Initializing WIFI ...\n");
for (idx = 0; idx < devnum; idx++) {
ret = rltk_wlan_init(idx, mode);
ret = rltk_wlan_init(idx, mode); // 56
if (ret < 0)
return ret;
}
for (idx = 0; idx < devnum; idx++)
for (idx = 0; idx < devnum; idx++) {
rltk_wlan_start(idx);
}
while (1) {
if (rltk_wlan_running(devnum - 1)) {
printf("WIFI initialized\n");

View file

@ -8,6 +8,7 @@
#include <osdep_service.h>
#include <wlan/wlan_test_inc.h>
#include <dhcp/dhcps.h>
#include <wifi_constants.h>
#include <wifi/wifi_conf.h>
#include <wifi/wifi_util.h>
#include <platform/platform_stdlib.h>
@ -382,7 +383,7 @@ static void cmd_wifi_connect(int argc, char **argv)
char *ssid;
rtw_security_t security_type;
char *password;
int ssid_len;
// int ssid_len;
int password_len;
int key_id;
void *semaphore;
@ -411,21 +412,21 @@ static void cmd_wifi_connect(int argc, char **argv)
if(argc == 2){
security_type = RTW_SECURITY_OPEN;
password = NULL;
ssid_len = strlen((const char *)argv[1]);
// ssid_len = strlen((const char *)argv[1]);
password_len = 0;
key_id = 0;
semaphore = NULL;
}else if(argc ==3){
security_type = RTW_SECURITY_WPA2_AES_PSK;
password = argv[2];
ssid_len = strlen((const char *)argv[1]);
// ssid_len = strlen((const char *)argv[1]);
password_len = strlen((const char *)argv[2]);
key_id = 0;
semaphore = NULL;
}else{
security_type = RTW_SECURITY_WEP_PSK;
password = argv[2];
ssid_len = strlen((const char *)argv[1]);
// ssid_len = strlen((const char *)argv[1]);
password_len = strlen((const char *)argv[2]);
key_id = atoi(argv[3]);
if(( password_len != 5) && (password_len != 13)) {

View file

@ -96,12 +96,14 @@ void wait_ms(int ms) { // До 1073741 секунд? 298 часов
void wait_us(int us) { // До 2.147483648 секунды!
uint32_t start;
#ifdef WAIT_US_USE_CYCCNT
if(us < 1) return;
if (us < 327) { // G-timer resolution is ~31 us (1/32K), use DWT->CYCCNT...
if((uint32_t)us < 1) return;
if ((uint32_t)us < 327) { // G-timer resolution is ~31 us (1/32K), use DWT->CYCCNT...
if(!(DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk)) { // уже включен?
// taskENTER_CRITICAL();
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; // открыть доступ
DWT->CYCCNT = 0; // обнулить и запустить
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; // запустить счет
// taskEXIT_CRITICAL();
}
start = DWT->CYCCNT + us * (PLATFORM_CLOCK / 1000000ul);
while ((int32_t)(start - DWT->CYCCNT) > 0);

View file

@ -28,7 +28,6 @@ void us_ticker_init(void)
{
if (us_ticker_inited) return;
us_ticker_inited = 1;
// Initial a G-Timer
Timer6Adapter.IrqDis = 1; // Disable Irq
@ -44,6 +43,7 @@ void us_ticker_init(void)
HalTimerOp.HalTimerInit((VOID*) &Timer6Adapter);
DBG_TIMER_INFO("%s: Timer_Id=%d\n", __FUNCTION__, APP_TIM_ID);
us_ticker_inited = 1;
}
#if (!TICK_READ_FROM_CPU) || !defined(PLATFORM_FREERTOS)
@ -56,9 +56,9 @@ uint32_t us_ticker_read()
uint64_t us_tick;
//1 Our G-timer resolution is ~31 us (1/32K), and is a countdown timer
// if (!us_ticker_inited) {
// us_ticker_init();
// }
if (!us_ticker_inited) {
us_ticker_init();
}
tick_cnt = HalTimerOp.HalTimerReadCount(SYS_TIM_ID);
tick_cnt = 0xffffffff - tick_cnt; // it's a down counter
ticks_125ms = tick_cnt/(GTIMER_CLK_HZ/8);