Merge remote-tracking branch 'upstream/master'

This commit is contained in:
raiden00pl 2017-07-23 11:37:24 +02:00
commit 87ca3d1521
29 changed files with 150 additions and 56 deletions

View File

@ -41,7 +41,7 @@
* are provided by common STM32 logic. To use this common SPI logic on your
* board:
*
* 1. Provide logic in stm32l4_boardinitialize() to configure SPI chip select
* 1. Provide logic in stm32l4_board_initialize() to configure SPI chip select
* pins.
* 2. Provide stm32l4_spi1/2/3select() and stm32l4_spi1/2/3status() functions in your
* board-specific logic. These functions will perform chip selection and

View File

@ -97,7 +97,7 @@ FAR struct spi_dev_s *stm32l4_spibus_initialize(int bus);
* (including stm32l4_spibus_initialize()) are provided by common STM32 logic. To use this
* common SPI logic on your board:
*
* 1. Provide logic in stm32l4_boardinitialize() to configure SPI chip select
* 1. Provide logic in stm32l4_board_initialize() to configure SPI chip select
* pins.
* 2. Provide stm32l4_spi1/2/...select() and stm32l4_spi1/2/...status() functions in your
* board-specific logic. These functions will perform chip selection and

View File

@ -53,6 +53,7 @@
#include "stm32l4.h"
#include "stm32l4_gpio.h"
#include "stm32l4_userspace.h"
#include "stm32l4_start.h"
#ifdef CONFIG_ARCH_FPU
# include "nvic.h"
@ -358,7 +359,7 @@ void __start(void)
/* Initialize onboard resources */
stm32l4_boardinitialize();
stm32l4_board_initialize();
showprogress('F');
/* Then start NuttX */

View File

@ -0,0 +1,59 @@
/************************************************************************************
* arch/arm/src/stm32l4/stm32l4_start.h
*
* Copyrigth (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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.
*
************************************************************************************/
#ifndef __ARCH_ARM_SRC_STM32L4_STM32L4_START_H
#define __ARCH_ARM_SRC_STM32L4_STM32L4_START_H
/************************************************************************************
* Included Files
************************************************************************************/
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: stm32l4_board_initialize
*
* Description:
* All STM32L4 architectures must provide the following entry point. This entry
* point is called early in the initialization -- after all memory has been
* configured and mapped but before any devices have been initialized.
*
************************************************************************************/
void stm32l4_board_initialize(void);
#endif /* __ARCH_ARM_SRC_STM32L4_STM32L4_START_H */

View File

@ -249,7 +249,7 @@ board/libboard$(LIBEXT):
# Change the names of most symbols that conflict with libc symbols.
GNU:
$(Q) mkdir ./GNU
$(Q) mkdir -p ./GNU
GNU/Linux-names.dat: GNU nuttx-names.dat
$(Q) cp nuttx-names.dat $@

View File

@ -43,6 +43,7 @@
#include <stdbool.h>
#include <sched.h>
#include <errno.h>
#include <fcntl.h>
#include <nuttx/fs/fs.h>
@ -97,12 +98,13 @@ static ssize_t devconsole_read(struct file *filep, char *buffer, size_t len)
* on the first read.
*/
ch = simuart_getc();
ch = simuart_getc(!(filep->f_oflags & O_NONBLOCK));
if (ch < 0)
{
set_errno(EIO);
/* errno is set in upper layer according to returned value */
sched_unlock();
return ERROR;
return ch;
}
*buffer++ = ch;

View File

@ -262,7 +262,7 @@ void up_registerblockdevice(void);
void simuart_start(void);
int simuart_putc(int ch);
int simuart_getc(void);
int simuart_getc(bool block);
bool simuart_checkc(void);
void simuart_terminate(void);

View File

@ -171,6 +171,12 @@ void netdriver_loop(void)
{
FAR struct eth_hdr_s *eth;
/* Check for new frames. If so, then poll the network for new XMIT data */
net_lock();
(void)devif_poll(&g_sim_dev, sim_txpoll);
net_unlock();
/* netdev_read will return 0 on a timeout event and >0 on a data received event */
g_sim_dev.d_len = netdev_read((FAR unsigned char *)g_sim_dev.d_buf,

View File

@ -42,6 +42,7 @@
#include <string.h>
#include <termios.h>
#include <pthread.h>
#include <errno.h>
/****************************************************************************
* Pre-processor Definitions
@ -268,7 +269,7 @@ int simuart_putc(int ch)
* Name: simuart_getc
****************************************************************************/
int simuart_getc(void)
int simuart_getc(bool block)
{
int index;
int ch;
@ -282,6 +283,12 @@ int simuart_getc(void)
{
/* Wait for a byte to become available */
if (!block && (g_uarthead == g_uarttail))
{
sched_unlock();
return -EAGAIN;
}
while (g_uarthead == g_uarttail)
{
simuart_wait();

View File

@ -43,6 +43,7 @@
#include <arch/board/board.h>
#include "up_arch.h"
#include "stm32l4_start.h"
#include "b-l475e-iot01a.h"
/************************************************************************************
@ -50,16 +51,16 @@
************************************************************************************/
/************************************************************************************
* Name: stm32_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32 architectures must provide the following entry point. This entry point
* is called early in the initialization -- after all memory has been configured
* and mapped but before any devices have been initialized.
* All STM32L4 architectures must provide the following entry point. This entry
* point is called early in the initialization -- after all memory has been
* configured and mapped but before any devices have been initialized.
*
************************************************************************************/
void stm32l4_boardinitialize(void)
void stm32l4_board_initialize(void)
{
#ifdef CONFIG_ARCH_LEDS
/* Configure on-board LEDs if LED support has been selected. */

View File

@ -243,7 +243,7 @@ extern "C"
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32L4 architectures must provide the following entry point. This entry point
@ -252,7 +252,7 @@ extern "C"
*
************************************************************************************/
void stm32l4_boardinitialize(void);
void stm32l4_board_initialize(void);
#undef EXTERN
#if defined(__cplusplus)

View File

@ -64,7 +64,7 @@
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32L4 architectures must provide the following entry point. This entry point
@ -73,7 +73,7 @@
*
************************************************************************************/
void stm32l4_boardinitialize(void)
void stm32l4_board_initialize(void)
{
/* Configure on-board LEDs if LED support has been selected. */

View File

@ -114,7 +114,7 @@ void stm32l4_spiinitialize(void)
* are provided by common STM32 logic. To use this common SPI logic on your
* board:
*
* 1. Provide logic in stm32l4_boardinitialize() to configure SPI chip select
* 1. Provide logic in stm32l4_board_initialize() to configure SPI chip select
* pins.
* 2. Provide stm32l4_spi1/2select() and stm32l4_spi1/2status() functions in your
* board-specific logic. These functions will perform chip selection and

View File

@ -252,7 +252,7 @@ extern "C"
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32L4 architectures must provide the following entry point. This entry point
@ -261,7 +261,7 @@ extern "C"
*
************************************************************************************/
void stm32l4_boardinitialize(void);
void stm32l4_board_initialize(void);
#undef EXTERN
#if defined(__cplusplus)

View File

@ -53,7 +53,7 @@
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32 architectures must provide the following entry point. This entry point
@ -62,7 +62,7 @@
*
************************************************************************************/
void stm32l4_boardinitialize(void)
void stm32l4_board_initialize(void)
{
#ifdef CONFIG_ARCH_LEDS
/* Configure on-board LEDs if LED support has been selected. */

View File

@ -117,7 +117,7 @@ void weak_function stm32l4_spiinitialize(void)
* are provided by common STM32 logic. To use this common SPI logic on your
* board:
*
* 1. Provide logic in stm32l4_boardinitialize() to configure SPI chip select
* 1. Provide logic in stm32l4_board_initialize() to configure SPI chip select
* pins.
* 2. Provide stm32l4_spi1/2/3select() and stm32l4_spi1/2/3status() functions in your
* board-specific logic. These functions will perform chip selection and

View File

@ -249,7 +249,7 @@ extern "C"
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32L4 architectures must provide the following entry point. This entry point
@ -258,7 +258,7 @@ extern "C"
*
************************************************************************************/
void stm32l4_boardinitialize(void);
void stm32l4_board_initialize(void);
#undef EXTERN
#if defined(__cplusplus)

View File

@ -64,7 +64,7 @@
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32L4 architectures must provide the following entry point. This entry point
@ -73,7 +73,7 @@
*
************************************************************************************/
void stm32l4_boardinitialize(void)
void stm32l4_board_initialize(void)
{
/* Configure on-board LEDs if LED support has been selected. */

View File

@ -126,7 +126,7 @@ void weak_function stm32l4_spiinitialize(void)
* are provided by common STM32 logic. To use this common SPI logic on your
* board:
*
* 1. Provide logic in stm32l4_boardinitialize() to configure SPI chip select
* 1. Provide logic in stm32l4_board_initialize() to configure SPI chip select
* pins.
* 2. Provide stm32l4_spi1/2/3select() and stm32l4_spi1/2/3status() functions in your
* board-specific logic. These functions will perform chip selection and

View File

@ -438,7 +438,7 @@ extern "C"
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32 architectures must provide the following entry point. This entry point
@ -447,7 +447,7 @@ extern "C"
*
************************************************************************************/
void stm32l4_boardinitialize(void);
void stm32l4_board_initialize(void);
#undef EXTERN
#if defined(__cplusplus)

View File

@ -53,7 +53,7 @@
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32 architectures must provide the following entry point. This entry point
@ -62,7 +62,7 @@
*
************************************************************************************/
void stm32l4_boardinitialize(void)
void stm32l4_board_initialize(void)
{
#ifdef CONFIG_ARCH_LEDS
/* Configure on-board LEDs if LED support has been selected. */

View File

@ -135,7 +135,7 @@ extern "C"
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32L4 architectures must provide the following entry point. This entry
@ -144,7 +144,7 @@ extern "C"
*
************************************************************************************/
void stm32l4_boardinitialize(void);
void stm32l4_board_initialize(void);
#undef EXTERN
#if defined(__cplusplus)

View File

@ -56,7 +56,7 @@
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32L4 architectures must provide the following entry point. This entry point
@ -65,7 +65,7 @@
*
************************************************************************************/
void stm32l4_boardinitialize(void)
void stm32l4_board_initialize(void)
{
/* Configure on-board LEDs if LED support has been selected. */

View File

@ -293,7 +293,7 @@ extern "C"
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32L4 architectures must provide the following entry point. This entry point
@ -302,7 +302,7 @@ extern "C"
*
************************************************************************************/
void stm32l4_boardinitialize(void);
void stm32l4_board_initialize(void);
#undef EXTERN
#if defined(__cplusplus)

View File

@ -56,7 +56,7 @@
************************************************************************************/
/************************************************************************************
* Name: stm32l4_boardinitialize
* Name: stm32l4_board_initialize
*
* Description:
* All STM32L4 architectures must provide the following entry point. This entry point
@ -65,7 +65,7 @@
*
************************************************************************************/
void stm32l4_boardinitialize(void)
void stm32l4_board_initialize(void)
{
/* Configure on-board LEDs if LED support has been selected. */

View File

@ -238,17 +238,27 @@ static ssize_t adc_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
ainfo("buflen: %d\n", (int)buflen);
if (buflen % 5 == 0)
msglen = 5;
{
msglen = 5;
}
else if (buflen % 4 == 0)
msglen = 4;
{
msglen = 4;
else if (buflen % 3 == 0)
msglen = 3;
{
msglen = 3;
}
else if (buflen % 2 == 0)
msglen = 2;
{
msglen = 2;
}
else if (buflen == 1)
msglen = 1;
{
msglen = 1;
}
else
msglen = 5;
{
msglen = 5;
if (buflen >= msglen)
{
@ -336,6 +346,7 @@ static ssize_t adc_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
*(int32_t *)&buffer[nread + 1] = msg->am_data;
buffer[nread] = msg->am_channel;
}
nread += msglen;
/* Increment the head of the circular message buffer */

View File

@ -198,6 +198,7 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents,
*/
FAR struct epoll_head *eph = (FAR struct epoll_head *)((intptr_t)epfd);
int counter;
int rc;
int i;
@ -219,13 +220,19 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents,
return rc;
}
for (i = 0; i < rc; i++)
/* Iterate over non NULL event fds */
for (i = 0, counter = 0; i < rc && counter < eph->size; counter++)
{
evs[i].data.fd = (pollevent_t)eph->evs[i].data.fd;
evs[i].events = (pollevent_t)eph->evs[i].revents;
if (eph->evs[counter].revents != 0)
{
evs[i].data.fd = eph->evs[counter].data.fd;
evs[i].events = eph->evs[counter].revents;
i += 1;
}
}
return rc;
return i;
}
#endif /* CONFIG_DISABLE_POLL */

View File

@ -614,7 +614,7 @@ static int local_poll(FAR struct socket *psock, FAR struct pollfd *fds,
{
/* Perform the TCP/IP poll() teardown */
return loal_pollteardown(psock, fds);
return local_pollteardown(psock, fds);
}
#endif /* HAVE_LOCAL_POLL */
}

View File

@ -72,7 +72,7 @@ static int pkt_connect(FAR struct socket *psock,
static int pkt_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
FAR socklen_t *addrlen, FAR struct socket *newsock);
#ifndef CONFIG_DISABLE_POLL
static int pkt_poll(FAR struct socket *psock,
static int pkt_poll_local(FAR struct socket *psock,
FAR struct pollfd *fds, bool setup);
#endif
static ssize_t pkt_send(FAR struct socket *psock, FAR const void *buf,
@ -97,7 +97,7 @@ const struct sock_intf_s g_pkt_sockif =
pkt_connect, /* si_connect */
pkt_accept, /* si_accept */
#ifndef CONFIG_DISABLE_POLL
pkt_poll, /* si_poll */
pkt_poll_local, /* si_poll */
#endif
pkt_send, /* si_send */
pkt_sendto, /* si_sendto */
@ -475,8 +475,8 @@ int pkt_listen(FAR struct socket *psock, int backlog)
****************************************************************************/
#ifndef CONFIG_DISABLE_POLL
static int pkt_poll(FAR struct socket *psock, FAR struct pollfd *fds,
bool setup)
static int pkt_poll_local(FAR struct socket *psock, FAR struct pollfd *fds,
bool setup)
{
return -ENOSYS;
}