nuttx/boards/arm/stm32f7/stm32f746-ws/src/stm32_appinitialize.c

118 lines
3.7 KiB
C
Raw Normal View History

2016-05-23 15:05:56 +02:00
/****************************************************************************
* boards/arm/stm32f7/stm32f746-ws/src/stm32_appinitilaize.c
2016-05-23 15:05:56 +02:00
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Mark Olsson <post@markolsson.se>
*
* 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 <syslog.h>
2016-05-27 00:16:55 +02:00
#include <debug.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/leds/userled.h>
2016-05-23 15:05:56 +02:00
#include "stm32f746-ws.h"
2016-05-27 00:16:55 +02:00
#include "stm32_i2c.h"
2016-06-09 15:48:07 +02:00
static void stm32_i2c_register(int bus)
2016-05-27 00:16:55 +02:00
{
FAR struct i2c_master_s *i2c;
int ret;
2016-06-09 15:48:07 +02:00
i2c = stm32_i2cbus_initialize(bus);
2016-05-27 00:16:55 +02:00
if (i2c == NULL)
{
serr("ERROR: Failed to get I2C%d interface\n", bus);
2016-05-27 00:16:55 +02:00
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
serr("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
2016-06-09 15:48:07 +02:00
stm32_i2cbus_uninitialize(i2c);
2016-05-27 00:16:55 +02:00
}
}
}
2016-06-09 15:48:07 +02:00
static void stm32_i2ctool(void)
2016-05-27 00:16:55 +02:00
{
2016-06-09 15:48:07 +02:00
stm32_i2c_register(1);
2016-05-27 00:16:55 +02:00
}
2016-05-23 15:05:56 +02:00
/****************************************************************************
* 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.
*
****************************************************************************/
int board_app_initialize(void)
{
2016-05-27 00:16:55 +02:00
/* Register I2C drivers on behalf of the I2C tool */
2016-06-09 15:48:07 +02:00
stm32_i2ctool();
2016-05-23 15:05:56 +02:00
2016-06-19 23:06:21 +02:00
#if defined(CONFIG_FAT_DMAMEMORY)
if (stm32_dma_alloc_init() < 0)
{
syslog(LOG_ERR, "DMA alloc FAILED");
}
#endif
2016-06-25 17:55:33 +02:00
#ifdef CONFIG_STM32F7_SDMMC1
2016-06-19 23:06:21 +02:00
/* Initialize the SDIO block driver */
int ret = OK;
ret = stm32_sdio_initialize();
if (ret != OK)
{
2016-11-07 08:28:39 -06:00
ferr("ERROR: Failed to initialize MMC/SD driver: %d\n", ret);
return ret;
}
2016-06-25 17:55:33 +02:00
#endif
2016-06-19 23:06:21 +02:00
2016-05-23 15:05:56 +02:00
return OK;
}