Remove BOARDIOC_CAN_INITIALIZE. CAN initialization is now done in the board initialization logic just like every other device driver.

This commit is contained in:
Gregory Nutt
2016-12-06 08:51:37 -06:00
parent e5e5467097
commit 35dfe25430
75 changed files with 1024 additions and 835 deletions
-9
View File
@@ -2029,15 +2029,6 @@ config BOARDCTL_TSCTEST
specific logic must provide board_tsc_setup() and
board_tsc_teardown() interfaces.
config BOARDCTL_CANINIT
bool "Enable CAN initialize interface"
default n
depends on CAN
---help---
Enables support for the BOARDIOC_CAN_INITIALIZE boardctl() command.
Architecture specific logic must provide board_can_initialize()
interface.
config BOARDCTL_GRAPHICS
bool "Enable custom graphics initialization interfaces"
default n
-15
View File
@@ -426,21 +426,6 @@ int boardctl(unsigned int cmd, uintptr_t arg)
break;
#endif
#ifdef CONFIG_BOARDCTL_CANINIT
/* CMD: BOARDIOC_CAN_INITIALIZE
* DESCRIPTION: CAN device initialization
* ARG: None
* CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_CANINIT
* DEPENDENCIES: Board logic must provide board_can_initialize()
*/
case BOARDIOC_CAN_INITIALIZE:
{
ret = board_can_initialize();
}
break;
#endif
#ifdef CONFIG_BOARDCTL_GRAPHICS
/* CMD: BOARDIOC_GRAPHICS_SETUP
* DESCRIPTION: Configure graphics that require special initialization
-1
View File
@@ -545,7 +545,6 @@ CONFIG_LIB_BOARDCTL=y
# CONFIG_BOARDCTL_RESET is not set
# CONFIG_BOARDCTL_UNIQUEID is not set
# CONFIG_BOARDCTL_TSCTEST is not set
CONFIG_BOARDCTL_CANINIT=y
# CONFIG_BOARDCTL_GRAPHICS is not set
# CONFIG_BOARDCTL_IOCTL is not set
-1
View File
@@ -544,7 +544,6 @@ CONFIG_LIB_BOARDCTL=y
# CONFIG_BOARDCTL_RESET is not set
# CONFIG_BOARDCTL_UNIQUEID is not set
# CONFIG_BOARDCTL_TSCTEST is not set
# CONFIG_BOARDCTL_CANINIT is not set
CONFIG_BOARDCTL_GRAPHICS=y
# CONFIG_BOARDCTL_IOCTL is not set
+12
View File
@@ -191,4 +191,16 @@ int stm32_pwm_setup(void);
int stm32_adc_setup(void);
#endif
/****************************************************************************
* Name: stm32_can_setup
*
* Description:
* Initialize CAN and register the CAN device
*
****************************************************************************/
#ifdef CONFIG_CAN
int stm32_can_setup(void);
#endif
#endif /* __CONFIGS_NUCLEO_F303RE_SRC_NUCLEO_F303RE_H */
@@ -141,6 +141,16 @@ int board_app_initialize(uintptr_t arg)
}
#endif
#ifdef CONFIG_CAN
/* Initialize CAN and register the CAN driver. */
ret = stm32_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_can_setup failed: %d\n", ret);
}
#endif
UNUSED(ret);
return OK;
}
+21 -29
View File
@@ -45,60 +45,52 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/drivers/can.h>
#include "stm32.h"
#if defined(CONFIG_CAN) && defined(CONFIG_STM32_CAN1)
#ifdef CONFIG_CAN
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_can_initialize
* Name: stm32_can_setup
*
* Description:
* All STM32 architectures must provide the following interface to work
* with examples/can.
* Initialize CAN and register the CAN device
*
****************************************************************************/
int board_can_initialize(void)
int stm32_can_setup(void)
{
static bool initialized = false;
#ifdef CONFIG_STM32_CAN1
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call stm32_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = stm32_caninitialize(1);
if (can == NULL)
{
/* Call stm32_caninitialize() to get an instance of the CAN interface */
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
can = stm32_caninitialize(1);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && CONFIG_STM32_CAN1 */
#endif /* CONFIG_CAN */
+13 -1
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* configs/olimex-lpc1766stk/src/lpc1766stk.h
*
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2010-2011, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -260,6 +260,18 @@
void weak_function lpc1766stk_sspdev_initialize(void);
/************************************************************************************
* Name: lpc1766stk_can_setup
*
* Description:
* Initialize CAN and register the CAN device
*
************************************************************************************/
#ifdef CONFIG_CAN
int lpc1766stk_can_setup(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* _CONFIGS_OLIMEX_LPC1766STK_SRC_LPC1766STK_H */
@@ -362,6 +362,16 @@ int board_app_initialize(uintptr_t arg)
syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret);
}
#ifdef CONFIG_CAN
/* Initialize CAN and register the CAN driver. */
ret = lpc1766stk_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: lpc1766stk_can_setup failed: %d\n", ret);
}
#endif
#ifdef CONFIG_FS_PROCFS
/* Mount the procfs file system */
+22 -29
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* configs/solimex-lpc1766stk/src/lpc17_can.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -51,7 +51,7 @@
#include "lpc17_can.h"
#include "lpc1766stk.h"
#if defined(CONFIG_CAN) && (defined(CONFIG_LPC17_CAN1) || defined(CONFIG_LPC17_CAN2))
#ifdef CONFIG_CAN
/************************************************************************************
* Pre-processor Definitions
@@ -78,48 +78,41 @@
************************************************************************************/
/************************************************************************************
* Name: board_can_initialize
* Name: lpc1766stk_can_setup
*
* Description:
* All LPC17 architectures must provide the following interface to work with
* examples/can.
* Initialize CAN and register the CAN device
*
************************************************************************************/
int board_can_initialize(void)
int lpc1766stk_can_setup(void)
{
static bool initialized = false;
#if defined(CONFIG_LPC17_CAN1) || defined(CONFIG_LPC17_CAN2)
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call lpc17_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = lpc17_caninitialize(CAN_PORT);
if (can == NULL)
{
/* Call lpc17_caninitialize() to get an instance of the CAN interface */
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
can = lpc17_caninitialize(CAN_PORT);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && (CONFIG_LPC17_CAN1 || CONFIG_LPC17_CAN2) */
#endif /* CONFIG_CAN */
@@ -246,15 +246,15 @@ int stm32_sdio_initialize(void);
#endif
/****************************************************************************
* Name: stm32_can_initialize
* Name: stm32_can_setup
*
* Description:
* Called at application startup time to initialize the CAN functionality.
* Initialize CAN and register the CAN device
*
****************************************************************************/
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
int stm32_can_initialize(void);
#ifdef CONFIG_CAN
int stm32_can_setup(void);
#endif
#endif /* __ASSEMBLY__ */
@@ -180,21 +180,19 @@ static void stm32_i2ctool(void)
int board_app_initialize(uintptr_t arg)
{
#if defined(CONFIG_CAN) || defined(CONFIG_ADC)
int ret;
#endif
/* Register I2C drivers on behalf of the I2C tool */
stm32_i2ctool();
#ifdef CONFIG_CAN
/* Configure on-board CAN if CAN support has been selected. */
/* Initialize CAN and register the CAN driver. */
ret = stm32_can_initialize();
if (ret != OK)
ret = stm32_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to initialize CAN: %d\n", ret);
syslog(LOG_ERR, "ERROR: stm32_can_setup failed: %d\n", ret);
}
#endif
@@ -231,5 +229,6 @@ int board_app_initialize(uintptr_t arg)
}
#endif
UNUSED(ret);
return OK;
}
+25 -43
View File
@@ -41,13 +41,15 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/drivers/can.h>
#include <arch/board/board.h>
#include "stm32.h"
#include "stm32_can.h"
#include "olimex-stm32-e407.h"
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
#ifdef CONFIG_CAN
/************************************************************************************
* Pre-processor Definitions
@@ -69,62 +71,42 @@
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: board_can_initialize
/****************************************************************************
* Name: stm32_can_setup
*
* Description:
* All STM32 architectures must provide the following interface to work with
* examples/can.
* Initialize CAN and register the CAN device
*
************************************************************************************/
****************************************************************************/
int board_can_initialize(void)
int stm32_can_setup(void)
{
return stm32_can_initialize();
}
/************************************************************************************
* Name: stm32_can_initialize
*
* Description:
* Called at application startup time to initialize the CAN functionality.
*
************************************************************************************/
int stm32_can_initialize(void)
{
static bool initialized = false;
#if defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2)
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call stm32_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
/* Call stm32_caninitialize() to get an instance of the CAN interface */
candbg("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
candbg("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
candbg("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
ret = can_register("/dev/can0", can);
if (ret < 0)
{
candbg("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && (CONFIG_STM32_CAN1 || CONFIG_STM32_CAN2) */
#endif /* CONFIG_CAN */
@@ -100,16 +100,16 @@ void weak_function stm32_usbinitialize(void);
int stm32_adc_setup(void);
#endif
/************************************************************************************
* Name: stm32_can_initialize
/****************************************************************************
* Name: stm32_can_setup
*
* Description:
* Called at application startup time to initialize the CAN functionality.
* Initialize CAN and register the CAN device
*
************************************************************************************/
****************************************************************************/
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
int stm32_can_initialize(void);
#ifdef CONFIG_CAN
int stm32_can_setup(void);
#endif
#endif /* __ASSEMBLY__ */
@@ -116,12 +116,12 @@ int board_app_initialize(uintptr_t arg)
#endif
#ifdef CONFIG_CAN
/* Configure on-board CAN if CAN support has been selected. */
/* Initialize CAN and register the CAN driver. */
ret = stm32_can_initialize();
if (ret != OK)
ret = stm32_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to initialize CAN: %d\n", ret);
syslog(LOG_ERR, "ERROR: stm32_can_setup failed: %d\n", ret);
}
#endif
@@ -47,14 +47,6 @@
#include "olimex-stm32-h405.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
+24 -41
View File
@@ -41,13 +41,16 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/drivers/can.h>
#include <arch/board/board.h>
#include "stm32.h"
#include "stm32_can.h"
#include "olimex-stm32-h405.h"
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
#ifdef CONFIG_CAN
/************************************************************************************
* Pre-processor Definitions
@@ -70,61 +73,41 @@
************************************************************************************/
/************************************************************************************
* Name: board_can_initialize
* Name: stm32_can_setup
*
* Description:
* All STM32 architectures must provide the following interface to work with
* examples/can.
* Initialize CAN and register the CAN device
*
************************************************************************************/
int board_can_initialize(void)
int stm32_can_setup(void)
{
return stm32_can_initialize();
}
/****************************************************************************************************
* Name: stm32_can_initialize
*
* Description:
* Called at application startup time to initialize the CAN functionality.
*
****************************************************************************************************/
int stm32_can_initialize(void)
{
static bool initialized = false;
#if defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2)
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call stm32_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
/* Call stm32_caninitialize() to get an instance of the CAN interface */
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && (CONFIG_STM32_CAN1 || CONFIG_STM32_CAN2) */
#endif /* CONFIG_CAN */
@@ -600,7 +600,6 @@ CONFIG_LIB_BOARDCTL=y
# CONFIG_BOARDCTL_UNIQUEID is not set
CONFIG_BOARDCTL_USBDEVCTRL=y
# CONFIG_BOARDCTL_TSCTEST is not set
CONFIG_BOARDCTL_CANINIT=y
# CONFIG_BOARDCTL_GRAPHICS is not set
# CONFIG_BOARDCTL_IOCTL is not set
@@ -267,15 +267,15 @@ int stm32_adc_setup(void);
#endif
/****************************************************************************
* Name: stm32_can_initialize
* Name: stm32_can_setup
*
* Description:
* Called at application startup time to initialize the CAN functionality.
* Initialize CAN and register the CAN device
*
****************************************************************************/
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
int stm32_can_initialize(void);
#ifdef CONFIG_CAN
int stm32_can_setup(void);
#endif
#endif /* __ASSEMBLY__ */
@@ -59,10 +59,6 @@
#ifdef CONFIG_LIB_BOARDCTL
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -97,14 +97,12 @@ int stm32_bringup(void)
int ret;
#ifdef CONFIG_CAN
/* Configure on-board CAN if CAN support has been selected. */
/* Initialize CAN and register the CAN driver. */
ret = stm32_can_initialize();
if (ret != OK)
ret = stm32_can_setup();
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to initialize CAN: %d\n",
ret);
syslog(LOG_ERR, "ERROR: stm32_can_setup failed: %d\n", ret);
}
#endif
+23 -41
View File
@@ -41,13 +41,15 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/drivers/can.h>
#include <arch/board/board.h>
#include "stm32.h"
#include "stm32_can.h"
#include "olimex-stm32-h407.h"
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
#ifdef CONFIG_CAN
/************************************************************************************
* Pre-processor Definitions
@@ -70,61 +72,41 @@
************************************************************************************/
/************************************************************************************
* Name: board_can_initialize
* Name: stm32_can_setup
*
* Description:
* All STM32 architectures must provide the following interface to work with
* examples/can.
* Initialize CAN and register the CAN device
*
************************************************************************************/
int board_can_initialize(void)
int stm32_can_setup(void)
{
return stm32_can_initialize();
}
/************************************************************************************
* Name: stm32_can_initialize
*
* Description:
* Called at application startup time to initialize the CAN functionality.
*
************************************************************************************/
int stm32_can_initialize(void)
{
static bool initialized = false;
#if defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2)
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call stm32_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
/* Call stm32_caninitialize() to get an instance of the CAN interface */
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && (CONFIG_STM32_CAN1 || CONFIG_STM32_CAN2) */
#endif /* CONFIG_CAN */
+4
View File
@@ -38,6 +38,10 @@
ASRCS =
CSRCS = stm32_boot.c stm32_spi.c
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += stm32_appinit.c
endif
ifeq ($(CONFIG_CAN),y)
CSRCS += stm32_can.c
endif
@@ -32,6 +32,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __CONFIGS_OLIMEX_STM32_P107_SRC_H
#define __CONFIGS_OLIMEX_STM32_P107_SRC_H
@@ -84,5 +85,17 @@
void weak_function stm32_spidev_initialize(void);
/****************************************************************************
* Name: stm32_can_setup
*
* Description:
* Initialize CAN and register the CAN device
*
****************************************************************************/
#ifdef CONFIG_CAN
int stm32_can_setup(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_OLIMEX_STM32_P107_SRC_H */
@@ -0,0 +1,105 @@
/****************************************************************************
* configs/olimex-stm32-p107/src/stm32_appinit.c
*
* Copyright (C) 2016 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <syslog.h>
#include <errno.h>
#include <nuttx/board.h>
#include "stm32.h"
#include "olimex-stm32-p107.h"
#ifdef CONFIG_LIB_BOARDCTL
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform application specific initialization. This function is never
* called directly from application code, but only indirectly via the
* (non-standard) boardctl() interface using the command BOARDIOC_INIT.
*
* CONFIG_LIB_BOARDCTL=y:
* If CONFIG_NSH_ARCHINITIALIZE=y:
* Called from the NSH library (or other application)
* Otherse, assumed to be called from some other application.
*
* Input Parameters:
* arg - The boardctl() argument is passed to the board_app_initialize()
* implementation without modification. The argument has no
* meaning to NuttX; the meaning of the argument is a contract
* between the board-specific initalization logic and the the
* matching application logic. The value cold be such things as a
* mode enumeration value, a set of DIP switch switch settings, a
* pointer to configuration data read from a file or serial FLASH,
* or whatever you would like to do with it. Every implementation
* should accept zero/NULL as a default configuration.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure to indicate the nature of the failure.
*
****************************************************************************/
int board_app_initialize(uintptr_t arg)
{
int ret;
#ifdef CONFIG_CAN
/* Initialize CAN and register the CAN driver. */
ret = stm32_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_can_setup failed: %d\n", ret);
}
#endif
UNUSED(ret);
return OK;
}
#endif /* CONFIG_LIB_BOARDCTL */
@@ -44,14 +44,6 @@
#include "up_arch.h"
#include "olimex-stm32-p107.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
@@ -78,5 +70,4 @@ void stm32_boardinitialize(void)
stm32_spidev_initialize();
}
#endif
}
+33 -31
View File
@@ -51,7 +51,7 @@
#include "stm32.h"
#include "stm32_can.h"
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
#ifdef CONFIG_CAN
/************************************************************************************
* Pre-processor Definitions
@@ -59,55 +59,57 @@
/* Configuration ********************************************************************/
/* The STM32F107VC supports CAN1 and CAN2 */
#define CAN_PORT 1
#if defined(CONFIG_STM32_CAN1) && defined(CONFIG_STM32_CAN2)
# warning "Both CAN1 and CAN2 are enabled. Only CAN1 is used."
# undef CONFIG_STM32_CAN2
#endif
#ifdef CONFIG_STM32_CAN1
# define CAN_PORT 1
#else
# define CAN_PORT 2
#endif
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: board_can_initialize
/****************************************************************************
* Name: stm32_can_setup
*
* Description:
* All STM32 architectures must provide the following interface to work with
* examples/can.
* Initialize CAN and register the CAN device
*
************************************************************************************/
****************************************************************************/
int board_can_initialize(void)
int stm32_can_setup(void)
{
static bool initialized = false;
#if defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call stm32_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
/* Call stm32_caninitialize() to get an instance of the CAN interface */
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && CONFIG_STM32_CAN1 */
#endif /* CONFIG_CAN */
-1
View File
@@ -626,7 +626,6 @@ CONFIG_LIB_BOARDCTL=y
# CONFIG_BOARDCTL_RESET is not set
# CONFIG_BOARDCTL_UNIQUEID is not set
# CONFIG_BOARDCTL_TSCTEST is not set
# CONFIG_BOARDCTL_CANINIT is not set
# CONFIG_BOARDCTL_GRAPHICS is not set
# CONFIG_BOARDCTL_IOCTL is not set
@@ -136,16 +136,16 @@ int stm32_usbhost_initialize(void);
int stm32_adc_setup(void);
#endif
/************************************************************************************
* Name: stm32_can_initialize
/****************************************************************************
* Name: stm32_can_setup
*
* Description:
* Called at application startup time to initialize the CAN functionality.
* Initialize CAN and register the CAN device
*
************************************************************************************/
****************************************************************************/
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
int stm32_can_initialize(void);
#ifdef CONFIG_CAN
int stm32_can_setup(void);
#endif
#endif /* __ASSEMBLY__ */
@@ -134,13 +134,13 @@ int board_app_initialize(uintptr_t arg)
{
int ret;
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
/* Configure on-board CAN if CAN support has been selected. */
#ifdef CONFIG_CAN
/* Initialize CAN and register the CAN driver. */
ret = stm32_can_initialize();
if (ret != OK)
ret = stm32_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to initialize CAN: %d\n", ret);
syslog(LOG_ERR, "ERROR: stm32_can_setup failed: %d\n", ret);
}
#endif
+24 -42
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* configs/olimex-stm32-p207/src/stm32_can.c
*
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2012, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -41,13 +41,15 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/drivers/can.h>
#include <arch/board/board.h>
#include "stm32.h"
#include "stm32_can.h"
#include "olimex-stm32-p207.h"
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
#ifdef CONFIG_CAN
/************************************************************************************
* Pre-processor Definitions
@@ -70,61 +72,41 @@
************************************************************************************/
/************************************************************************************
* Name: board_can_initialize
* Name: stm32_can_setup
*
* Description:
* All STM32 architectures must provide the following interface to work with
* examples/can.
* Initialize CAN and register the CAN device
*
************************************************************************************/
int board_can_initialize(void)
int stm32_can_setup(void)
{
return stm32_can_initialize();
}
/****************************************************************************************************
* Name: stm32_can_initialize
*
* Description:
* Called at application startup time to initialize the CAN functionality.
*
****************************************************************************************************/
int stm32_can_initialize(void)
{
static bool initialized = false;
#if defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2)
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call stm32_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
/* Call stm32_caninitialize() to get an instance of the CAN interface */
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && (CONFIG_STM32_CAN1 || CONFIG_STM32_CAN2) */
#endif /* CONFIG_CAN */
-1
View File
@@ -588,7 +588,6 @@ CONFIG_LIB_BOARDCTL=y
# CONFIG_BOARDCTL_RESET is not set
# CONFIG_BOARDCTL_UNIQUEID is not set
# CONFIG_BOARDCTL_TSCTEST is not set
CONFIG_BOARDCTL_CANINIT=y
# CONFIG_BOARDCTL_GRAPHICS is not set
# CONFIG_BOARDCTL_IOCTL is not set
@@ -569,7 +569,6 @@ CONFIG_LIB_BOARDCTL=y
# CONFIG_BOARDCTL_RESET is not set
# CONFIG_BOARDCTL_UNIQUEID is not set
# CONFIG_BOARDCTL_TSCTEST is not set
CONFIG_BOARDCTL_CANINIT=y
# CONFIG_BOARDCTL_GRAPHICS is not set
# CONFIG_BOARDCTL_IOCTL is not set
+12 -12
View File
@@ -200,18 +200,6 @@ void stm32_usb_set_pwr_callback(xcpt_t pwr_changed_handler);
void stm32_led_initialize(void);
#endif
/************************************************************************************
* Name: stm32_can_initialize
*
* Description:
* Called at application startup time to initialize the CAN functionality.
*
************************************************************************************/
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
int stm32_can_initialize(void);
#endif
/****************************************************************************
* Name: board_usbmsc_initialize
*
@@ -228,5 +216,17 @@ int stm32_can_initialize(void);
int board_usbmsc_initialize(int port);
#endif
/****************************************************************************
* Name: stm32_can_setup
*
* Description:
* Initialize CAN and register the CAN device
*
****************************************************************************/
#ifdef CONFIG_CAN
int stm32_can_setup(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_OLIMEXINO_STM32_SRC_OLIMEXINO_STM32_H */
@@ -105,5 +105,16 @@ int board_app_initialize(uintptr_t arg)
#endif
#endif
#ifdef CONFIG_CAN
/* Initialize CAN and register the CAN driver. */
ret = stm32_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_can_setup failed: %d\n", ret);
}
#endif
UNUSED(ret);
return ret;
}
+34 -33
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* configs/olimexino-stm32/src/stm32_can.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* David Sidrane <david_s5@nscdg.com>
*
@@ -48,13 +48,12 @@
#include "chip.h"
#include "up_arch.h"
#include "olimexino-stm32.h"
#include "stm32.h"
#include "stm32_can.h"
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
#include "olimexino-stm32.h"
#ifdef CONFIG_CAN
/************************************************************************************
* Pre-processor Definitions
@@ -62,55 +61,57 @@
/* Configuration ********************************************************************/
/* The STM32F107VC supports CAN1 and CAN2 */
#define CAN_PORT 1
#if defined(CONFIG_STM32_CAN1) && defined(CONFIG_STM32_CAN2)
# warning "Both CAN1 and CAN2 are enabled. Only CAN1 is connected."
# undef CONFIG_STM32_CAN2
#endif
#ifdef CONFIG_STM32_CAN1
# define CAN_PORT 1
#else
# define CAN_PORT 2
#endif
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: board_can_initialize
* Name: stm32_can_setup
*
* Description:
* All STM32 architectures must provide the following interface to work with
* examples/can.
* Initialize CAN and register the CAN device
*
************************************************************************************/
int board_can_initialize(void)
int stm32_can_setup(void)
{
static bool initialized = false;
#if defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2)
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call stm32_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
/* Call stm32_caninitialize() to get an instance of the CAN interface */
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
can = stm32_caninitialize(CAN_PORT);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && CONFIG_STM32_CAN1 */
#endif /* CONFIG_CAN */
-1
View File
@@ -569,7 +569,6 @@ CONFIG_LIB_BOARDCTL=y
# CONFIG_BOARDCTL_RESET is not set
# CONFIG_BOARDCTL_UNIQUEID is not set
# CONFIG_BOARDCTL_TSCTEST is not set
CONFIG_BOARDCTL_CANINIT=y
# CONFIG_BOARDCTL_GRAPHICS is not set
# CONFIG_BOARDCTL_IOCTL is not set
@@ -192,6 +192,16 @@ int board_app_initialize(uintptr_t arg)
}
#endif
#ifdef CONFIG_CAN
/* Initialize CAN and register the CAN driver. */
ret = sam_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: sam_can_setup failed: %d\n", ret);
}
#endif
#ifdef CONFIG_FS_PROCFS
/* Mount the procfs file system */
+24 -31
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* configs/sama5d3-xplained/src/sam_can.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -51,7 +51,7 @@
#include "sam_can.h"
#include "sama5d3-xplained.h"
#if defined(CONFIG_CAN) && (defined(CONFIG_SAMA5_CAN0) || defined(CONFIG_SAMA5_CAN1))
#ifdef CONFIG_CAN
/************************************************************************************
* Pre-processor Definitions
@@ -74,48 +74,41 @@
************************************************************************************/
/************************************************************************************
* Name: board_can_initialize
* Name: sam_can_setup
*
* Description:
* All STM32 architectures must provide the following interface to work with
* examples/can.
* Initialize CAN and register the CAN device
*
************************************************************************************/
int board_can_initialize(void)
int sam_can_setup(void)
{
static bool initialized = false;
#if defined(CONFIG_SAMA5_CAN0) || defined(CONFIG_SAMA5_CAN1)
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call stm32_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = sam_caninitialize(CAN_PORT);
if (can == NULL)
{
/* Call stm32_caninitialize() to get an instance of the CAN interface */
can = sam_caninitialize(CAN_PORT);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && (CONFIG_SAMA5_CAN0 || CONFIG_SAMA5_CAN1) */
#endif /* CONFIG_CAN */
@@ -763,6 +763,18 @@ int sam_pwm_setup(void);
int sam_adc_setup(void);
#endif
/************************************************************************************
* Name: sam_can_setup
*
* Description:
* Initialize CAN and register the CAN device
*
************************************************************************************/
#ifdef CONFIG_CAN
int sam_can_setup(void);
#endif
/************************************************************************************
* Name: sam_netinitialize
*
+10
View File
@@ -204,6 +204,16 @@ int board_app_initialize(uintptr_t arg)
}
#endif
#ifdef CONFIG_CAN
/* Initialize CAN and register the CAN driver. */
ret = sam_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: sam_can_setup failed: %d\n", ret);
}
#endif
#ifdef CONFIG_FS_PROCFS
/* Mount the procfs file system */
+22 -29
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* configs/sama5d3x-ek/src/sam_can.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -51,7 +51,7 @@
#include "sam_can.h"
#include "sama5d3x-ek.h"
#if defined(CONFIG_CAN) && (defined(CONFIG_SAMA5_CAN0) || defined(CONFIG_SAMA5_CAN1))
#ifdef CONFIG_CAN
/************************************************************************************
* Pre-processor Definitions
@@ -74,48 +74,41 @@
************************************************************************************/
/************************************************************************************
* Name: board_can_initialize
* Name: sam_can_setup
*
* Description:
* All STM32 architectures must provide the following interface to work with
* examples/can.
* Initialize CAN and register the CAN device
*
************************************************************************************/
int board_can_initialize(void)
int sam_can_setup(void)
{
static bool initialized = false;
#if defined(CONFIG_SAMA5_CAN0) || defined(CONFIG_SAMA5_CAN1)
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call stm32_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = sam_caninitialize(CAN_PORT);
if (can == NULL)
{
/* Call stm32_caninitialize() to get an instance of the CAN interface */
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
can = sam_caninitialize(CAN_PORT);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && (CONFIG_SAMA5_CAN0 || CONFIG_SAMA5_CAN1) */
#endif /* CONFIG_CAN */
+19 -6
View File
@@ -807,14 +807,15 @@ bool sam_writeprotected(int slotno);
void weak_function sam_usbinitialize(void);
#endif
/****************************************************************************************************
/************************************************************************************
* Name: stm32_usbhost_initialize
*
* Description:
* Called at application startup time to initialize the USB host functionality. This function will
* start a thread that will monitor for device connection/disconnection events.
* Called at application startup time to initialize the USB host functionality.
* This function will start a thread that will monitor for device connection/
* disconnection events.
*
****************************************************************************************************/
************************************************************************************/
#ifdef HAVE_USBHOST
int sam_usbhost_initialize(void);
@@ -856,7 +857,19 @@ int sam_pwm_setup(void);
int sam_adc_setup(void);
#endif
/****************************************************************************
/************************************************************************************
* Name: sam_can_setup
*
* Description:
* Initialize CAN and register the CAN device
*
************************************************************************************/
#ifdef CONFIG_CAN
int sam_can_setup(void);
#endif
/************************************************************************************
* Name: sam_wm8904_initialize
*
* Description:
@@ -871,7 +884,7 @@ int sam_adc_setup(void);
* Zero is returned on success. Otherwise, a negated errno value is
* returned to indicate the nature of the failure.
*
****************************************************************************/
************************************************************************************/
#ifdef HAVE_WM8904
int sam_wm8904_initialize(int minor);
-4
View File
@@ -732,10 +732,6 @@ MCAN1 Loopback Test
CONFIG_SAMV7_MCAN1_TXFIFOQ_SIZE=8 # There are 8 queue elements
CONFIG_SAMV7_MCAN1_TXEVENTFIFO_SIZE=0 # The event FIFO is not used
Board Selection
CONFIG_LIB_BOARDCTL=y # Needed for CAN initialization
CONFIG_BOARDCTL_CANINIT=y # Enabled CAN initialization
Enabling the CAN Loopback Test
------------------------------
Application Configuration -> Examples -> CAN Example
+33 -22
View File
@@ -43,6 +43,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <syslog.h>
#include <errno.h>
#include <debug.h>
@@ -97,14 +98,14 @@ static void sam_i2c_register(int bus)
i2c = sam_i2cbus_initialize(bus);
if (i2c == NULL)
{
_err("ERROR: Failed to get I2C%d interface\n", bus);
syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
_err("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
syslog(LOG_ERR, "ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
sam_i2cbus_uninitialize(i2c);
}
}
@@ -169,7 +170,7 @@ int sam_bringup(void)
ret = sam_emac0_setmac();
if (ret < 0)
{
_err("ERROR: sam_emac0_setmac() failed: %d\n", ret);
syslog(LOG_ERR, "ERROR: sam_emac0_setmac() failed: %d\n", ret);
}
#endif
@@ -179,8 +180,8 @@ int sam_bringup(void)
ret = mount(NULL, SAME70_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
if (ret < 0)
{
_err("ERROR: Failed to mount procfs at %s: %d\n",
SAME70_PROCFS_MOUNTPOINT, ret);
syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
SAME70_PROCFS_MOUNTPOINT, ret);
}
#endif
@@ -192,7 +193,7 @@ int sam_bringup(void)
ret = sam_at24config();
if (ret < 0)
{
_err("ERROR: sam_at24config() failed: %d\n", ret);
syslog(LOG_ERR, "ERROR: sam_at24config() failed: %d\n", ret);
}
#endif
@@ -202,8 +203,8 @@ int sam_bringup(void)
ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR);
if (ret < 0)
{
_err("ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n",
HSMCI0_SLOTNO, HSMCI0_MINOR, ret);
syslog(LOG_ERR, "ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n",
HSMCI0_SLOTNO, HSMCI0_MINOR, ret);
}
#ifdef CONFIG_SAME70XPLAINED_HSMCI0_MOUNT
@@ -219,8 +220,8 @@ int sam_bringup(void)
if (ret < 0)
{
_err("ERROR: Failed to mount %s: %d\n",
CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_MOUNTPOINT, errno);
syslog(LOG_ERR, "ERROR: Failed to mount %s: %d\n",
CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_MOUNTPOINT, errno);
}
}
@@ -241,7 +242,7 @@ int sam_bringup(void)
CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_SECTSIZE);
if (ret < 0)
{
_err("ERROR: romdisk_register failed: %d\n", -ret);
syslog(LOG_ERR, "ERROR: romdisk_register failed: %d\n", -ret);
}
else
{
@@ -252,9 +253,9 @@ int sam_bringup(void)
"romfs", MS_RDONLY, NULL);
if (ret < 0)
{
_err("ERROR: mount(%s,%s,romfs) failed: %d\n",
CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_DEVNAME,
CONFIG_SAME70XPLAINED_ROMFS_MOUNT_MOUNTPOINT, errno);
syslog(LOG_ERR, "ERROR: mount(%s,%s,romfs) failed: %d\n",
CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_DEVNAME,
CONFIG_SAME70XPLAINED_ROMFS_MOUNT_MOUNTPOINT, errno);
}
}
#endif
@@ -269,7 +270,7 @@ int sam_bringup(void)
mtd = progmem_initialize();
if (!mtd)
{
_err("ERROR: progmem_initialize failed\n");
syslog(LOG_ERR, "ERROR: progmem_initialize failed\n");
}
/* Use the FTL layer to wrap the MTD driver as a block driver */
@@ -277,7 +278,7 @@ int sam_bringup(void)
ret = ftl_initialize(PROGMEM_MTD_MINOR, mtd);
if (ret < 0)
{
_err("ERROR: Failed to initialize the FTL layer: %d\n", ret);
syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", ret);
return ret;
}
@@ -291,7 +292,7 @@ int sam_bringup(void)
ret = bchdev_register(blockdev, chardev, false);
if (ret < 0)
{
_err("ERROR: bchdev_register %s failed: %d\n", chardev, ret);
syslog(LOG_ERR, "ERROR: bchdev_register %s failed: %d\n", chardev, ret);
return ret;
}
#endif
@@ -304,7 +305,7 @@ int sam_bringup(void)
ret = sam_usbhost_initialize();
if (ret != OK)
{
_err("ERROR: Failed to initialize USB host: %d\n", ret);
syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret);
}
#endif
@@ -314,18 +315,28 @@ int sam_bringup(void)
ret = usbmonitor_start();
if (ret != OK)
{
_err("ERROR: Failed to start the USB monitor: %d\n", ret);
syslog(LOG_ERR, "ERROR: Failed to start the USB monitor: %d\n", ret);
}
#endif
#ifdef CONFIG_SAMV7_MCAN
/* Initialize CAN and register the CAN driver. */
ret = sam_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: sam_can_setup failed: %d\n", ret);
}
#endif
#ifdef HAVE_ELF
/* Initialize the ELF binary loader */
_err("Initializing the ELF binary loader\n");
syslog(LOG_ERR, "Initializing the ELF binary loader\n");
ret = elf_initialize();
if (ret < 0)
{
_err("ERROR: Initialization of the ELF loader failed: %d\n", ret);
syslog(LOG_ERR, "ERROR: Initialization of the ELF loader failed: %d\n", ret);
}
#endif
@@ -333,7 +344,7 @@ int sam_bringup(void)
ret = sam_dacdev_initialize();
if (ret < 0)
{
_err("ERROR: Initialization of the DAC module failed: %d\n", ret);
syslog(LOG_ERR, "ERROR: Initialization of the DAC module failed: %d\n", ret);
}
#endif
+22 -29
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* configs/same70-xplainedk/src/sam_mcan.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -49,7 +49,7 @@
#include "sam_mcan.h"
#include "same70-xplained.h"
#if defined(CONFIG_CAN) && (defined(CONFIG_SAMV7_MCAN0) || defined(CONFIG_SAMV7_MCAN1))
#ifdef CONFIG_SAMV7_MCAN
/************************************************************************************
* Pre-processor Definitions
@@ -72,48 +72,41 @@
************************************************************************************/
/************************************************************************************
* Name: board_can_initialize
* Name: sam_can_setup
*
* Description:
* All STM32 architectures must provide the following interface to work with
* examples/can.
* Initialize CAN and register the CAN device
*
************************************************************************************/
int board_can_initialize(void)
int sam_can_setup(void)
{
static bool initialized = false;
#if defined(CONFIG_SAMV7_MCAN0) || defined(CONFIG_SAMV7_MCAN1)
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call stm32_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = sam_mcan_initialize(CAN_PORT);
if (can == NULL)
{
/* Call stm32_caninitialize() to get an instance of the CAN interface */
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
can = sam_mcan_initialize(CAN_PORT);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && (CONFIG_SAMV7_MCAN0 || CONFIG_SAMV7_MCAN1) */
#endif /* CONFIG_SAMV7_MCAN */
@@ -400,6 +400,18 @@ int sam_hsmci_initialize(int slot, int minor);
void sam_usbinitialize(void);
#endif
/****************************************************************************
* Name: sam_can_setup
*
* Description:
* Initialize CAN and register the CAN device
*
****************************************************************************/
#ifdef CONFIG_SAMV7_MCAN
int sam_can_setup(void);
#endif
/************************************************************************************
* Name: sam_netinitialize
*
-4
View File
@@ -1322,10 +1322,6 @@ MCAN1 Loopback Test
CONFIG_SAMV7_MCAN1_TXFIFOQ_SIZE=8 # There are 8 queue elements
CONFIG_SAMV7_MCAN1_TXEVENTFIFO_SIZE=0 # The event FIFO is not used
Board Selection
CONFIG_LIB_BOARDCTL=y # Needed for CAN initialization
CONFIG_BOARDCTL_CANINIT=y # Enabled CAN initialization
Enabling the CAN Loopback Test
------------------------------
Application Configuration -> Examples -> CAN Example
+10
View File
@@ -253,6 +253,16 @@ int sam_bringup(void)
}
#endif
#ifdef CONFIG_SAMV7_MCAN
/* Initialize CAN and register the CAN driver. */
ret = sam_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: sam_can_setup failed: %d\n", ret);
}
#endif
#ifdef HAVE_MACADDR
/* Read the Ethernet MAC address from the AT24 FLASH and configure the
* Ethernet driver with that address.
+22 -29
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* configs/samv71-xultk/src/sam_mcan.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -49,7 +49,7 @@
#include "sam_mcan.h"
#include "samv71-xult.h"
#if defined(CONFIG_CAN) && (defined(CONFIG_SAMV7_MCAN0) || defined(CONFIG_SAMV7_MCAN1))
#ifdef CONFIG_SAMV7_MCAN
/************************************************************************************
* Pre-processor Definitions
@@ -72,48 +72,41 @@
************************************************************************************/
/************************************************************************************
* Name: board_can_initialize
* Name: sam_can_setup
*
* Description:
* All STM32 architectures must provide the following interface to work with
* examples/can.
* Initialize CAN and register the CAN device
*
************************************************************************************/
int board_can_initialize(void)
int sam_can_setup(void)
{
static bool initialized = false;
#if defined(CONFIG_SAMV7_MCAN0) || defined(CONFIG_SAMV7_MCAN1)
struct can_dev_s *can;
int ret;
/* Check if we have already initialized */
/* Call stm32_caninitialize() to get an instance of the CAN interface */
if (!initialized)
can = sam_mcan_initialize(CAN_PORT);
if (can == NULL)
{
/* Call stm32_caninitialize() to get an instance of the CAN interface */
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
can = sam_mcan_initialize(CAN_PORT);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_CAN && (CONFIG_SAMV7_MCAN0 || CONFIG_SAMV7_MCAN1) */
#endif /* CONFIG_SAMV7_MCAN */

Some files were not shown because too many files have changed in this diff Show More