Skip to content

Commit

Permalink
xtensa/esp32: Add TCP/UDP client and server configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
cwespressif committed Jun 30, 2020
1 parent cfad0c6 commit 01f8bdb
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 37 deletions.
52 changes: 20 additions & 32 deletions arch/xtensa/src/esp32/esp32_wlan.c
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
/****************************************************************************
* boards/arm/xtensa/src/esp32/esp32_wlan.c
*
* Copyright (C) 2017-2018 Gregory Nutt. All rights reserved.
* Author: Simon Piriou <[email protected]>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* arch/xtensa/src/esp32/esp32_wlan.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

Expand Down Expand Up @@ -1331,6 +1316,9 @@ static void esp_poll_work(FAR void *arg)
}
}

wd_start(priv->esp_txpoll, ESP_WDDELAY, esp_poll_expiry, 1,
(wdparm_t)priv);

net_unlock();
}

Expand Down Expand Up @@ -1875,7 +1863,7 @@ void esp_sem_initialize(FAR struct esp_dev_s *priv)
* priority inheritance enabled.
*/

nxsem_setprotocol(&priv->waitsem, SEM_PRIO_NONE);
nxsem_set_protocol(&priv->waitsem, SEM_PRIO_NONE);
}
/****************************************************************************
* Public Functions
Expand Down
9 changes: 5 additions & 4 deletions arch/xtensa/src/esp_wifi/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ task.h is included from an application file. */
#include "portmacro_priv.h"
#include <arch/esp32/freertos/semphr.h>

#include <nuttx/clock.h>
#include <nuttx/irq.h>
#include <nuttx/sched.h>

Expand Down Expand Up @@ -269,7 +270,7 @@ BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, cons
TickType_t xTaskGetTickCount( void )
{
TickType_t uxReturn;
uxReturn = clock_systimer();
uxReturn = clock_systime_ticks();

return uxReturn;
}
Expand All @@ -278,7 +279,7 @@ TickType_t xTaskGetTickCount( void )
TickType_t xTaskGetTickCountFromISR( void )
{
TickType_t uxReturn;
uxReturn = clock_systimer();
uxReturn = clock_systime_ticks();

return uxReturn;
}
Expand Down Expand Up @@ -315,8 +316,8 @@ void vTaskSuspend( TaskHandle_t xTaskToSuspend )
FAR struct tcb_s *rtcb;
/* Suspend this thread if it is still alive. */

rtcb = sched_gettcb(xTaskToSuspend);
rtcb = nxsched_get_tcb(xTaskToSuspend);
if (rtcb != NULL) {
sched_suspend(rtcb);
nxsched_suspend(rtcb);
}
}
27 changes: 27 additions & 0 deletions boards/xtensa/esp32/esp32-core/configs/wlan/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,30 @@ CONFIG_PTHREAD_MUTEX_TYPES=y
CONFIG_SIG_DEFAULT=y
CONFIG_SCHED_HPWORK=y
CONFIG_ESP32_WIRELESS=y
CONFIG_EXAMPLES_UDP=y
CONFIG_EXAMPLES_UDP_PROGNAME1="udpclient"
CONFIG_EXAMPLES_UDP_PRIORITY1=100
CONFIG_EXAMPLES_UDP_STACKSIZE1=4096
CONFIG_EXAMPLES_UDP_TARGET2=y
CONFIG_EXAMPLES_UDP_PROGNAME2="udpserver"
CONFIG_EXAMPLES_UDP_PRIORITY2=100
CONFIG_EXAMPLES_UDP_STACKSIZE2=4096
CONFIG_EXAMPLES_UDP_DEVNAME="wlan0"
CONFIG_EXAMPLES_UDP_IPv4=y
CONFIG_EXAMPLES_UDP_SERVERIP=0xC0A8672A
CONFIG_EXAMPLES_UDP_SERVER_PORTNO=5471
CONFIG_EXAMPLES_UDP_CLIENT_PORTNO=5472
CONFIG_EXAMPLES_NETTEST=y
CONFIG_EXAMPLES_NETTEST_SENDSIZE=1024
CONFIG_EXAMPLES_NETTEST_PROGNAME1="tcpclient"
CONFIG_EXAMPLES_NETTEST_STACKSIZE1=4096
CONFIG_EXAMPLES_NETTEST_PRIORITY1=100
CONFIG_EXAMPLES_NETTEST_TARGET2=y
CONFIG_EXAMPLES_NETTEST_PROGNAME2="tcpserver"
CONFIG_EXAMPLES_NETTEST_PRIORITY2=100
CONFIG_EXAMPLES_NETTEST_STACKSIZE2=4096
CONFIG_EXAMPLES_NETTEST_DEVNAME="wlan0"
CONFIG_EXAMPLES_NETTEST_PERFORMANCE=y
CONFIG_EXAMPLES_NETTEST_IPv4=y
CONFIG_EXAMPLES_NETTEST_SERVERIP=0xC0A865C6
CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO=5471
2 changes: 1 addition & 1 deletion tools/Makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ pass1dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT)

pass2dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT)
$(Q) for dir in $(KERNDEPDIRS) ; do \
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" EXTRAFLAGS="$(KDEFINE) $(EXTRAFLAGS)" depend || exit; \
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" EXTRAFLAGS="$(KDEFINE) $(EXTRAFLAGS)" depend; \
done

# Configuration targets
Expand Down

0 comments on commit 01f8bdb

Please sign in to comment.