2020-11-20 08:12:55 +01:00
|
|
|
/****************************************************************************
|
2021-03-08 22:39:04 +01:00
|
|
|
* boards/arm/stm32/stm32butterfly2/src/stm32_boot.c
|
2016-08-14 16:32:11 +02:00
|
|
|
*
|
2021-06-11 06:47:35 +02:00
|
|
|
* 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
|
2016-08-14 16:32:11 +02:00
|
|
|
*
|
2021-06-11 06:47:35 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2016-08-14 16:32:11 +02:00
|
|
|
*
|
2021-06-11 06:47:35 +02:00
|
|
|
* 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.
|
2016-08-14 16:32:11 +02:00
|
|
|
*
|
2016-08-17 21:34:51 +02:00
|
|
|
****************************************************************************/
|
2016-08-14 16:32:11 +02:00
|
|
|
|
2020-11-20 08:12:55 +01:00
|
|
|
/****************************************************************************
|
2016-08-14 16:32:11 +02:00
|
|
|
* Included Files
|
2016-08-17 21:34:51 +02:00
|
|
|
****************************************************************************/
|
2016-08-14 16:32:11 +02:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <arch/board/board.h>
|
2016-08-15 17:34:43 +02:00
|
|
|
#include <syslog.h>
|
|
|
|
|
|
|
|
#include "stm32_butterfly2.h"
|
2016-08-14 16:32:11 +02:00
|
|
|
|
2020-11-20 08:12:55 +01:00
|
|
|
/****************************************************************************
|
2016-08-14 16:32:11 +02:00
|
|
|
* Public Functions
|
2016-08-17 21:34:51 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2020-11-20 08:12:55 +01:00
|
|
|
/****************************************************************************
|
2016-08-17 21:34:51 +02:00
|
|
|
* Name: stm32_boardinitialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initializes low level pins for the drivers.
|
|
|
|
****************************************************************************/
|
2016-08-14 16:32:11 +02:00
|
|
|
|
|
|
|
void stm32_boardinitialize(void)
|
|
|
|
{
|
|
|
|
stm32_led_initialize();
|
2016-08-15 17:34:43 +02:00
|
|
|
stm32_spidev_initialize();
|
2016-08-17 20:13:17 +02:00
|
|
|
stm32_usb_initialize();
|
2016-08-14 16:32:11 +02:00
|
|
|
}
|
2016-08-14 17:16:49 +02:00
|
|
|
|
2020-11-20 08:12:55 +01:00
|
|
|
/****************************************************************************
|
2016-08-17 21:34:51 +02:00
|
|
|
* Name: board_app_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initializes upper half drivers with board specific settings
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2018-09-14 14:55:45 +02:00
|
|
|
* 0 on success or errno value of failed init function.
|
2016-08-17 21:34:51 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2016-08-14 17:16:49 +02:00
|
|
|
int board_app_initialize(uintptr_t arg)
|
|
|
|
{
|
2016-12-06 00:06:08 +01:00
|
|
|
int ret = 0;
|
2016-08-17 21:34:51 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_MMCSD
|
2016-12-06 00:06:08 +01:00
|
|
|
ret = stm32_mmcsd_initialize(CONFIG_NSH_MMCSDMINOR);
|
|
|
|
if (ret < 0)
|
2016-08-15 17:34:43 +02:00
|
|
|
{
|
2020-11-20 08:11:28 +01:00
|
|
|
syslog(LOG_ERR, "Failed to initialize SD slot: %d\n", ret);
|
2016-12-06 00:06:08 +01:00
|
|
|
return ret;
|
2016-08-15 17:34:43 +02:00
|
|
|
}
|
2016-08-17 21:34:51 +02:00
|
|
|
#endif
|
2016-08-15 17:34:43 +02:00
|
|
|
|
2016-08-17 21:34:51 +02:00
|
|
|
#ifdef CONFIG_USBHOST
|
2016-12-06 00:06:08 +01:00
|
|
|
ret = stm32_usbhost_initialize();
|
|
|
|
if (ret < 0)
|
2016-08-17 20:13:17 +02:00
|
|
|
{
|
2016-12-06 00:06:08 +01:00
|
|
|
syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret);
|
|
|
|
return ret;
|
2016-08-17 20:13:17 +02:00
|
|
|
}
|
2016-08-17 21:34:51 +02:00
|
|
|
#endif
|
2016-08-17 20:13:17 +02:00
|
|
|
|
2016-12-06 00:06:08 +01:00
|
|
|
#ifdef CONFIG_ADC
|
|
|
|
/* Initialize ADC and register the ADC driver. */
|
|
|
|
|
|
|
|
ret = stm32_adc_setup();
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
syslog(LOG_ERR, "ERROR: stm32_adc_setup failed: %d\n", ret);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
UNUSED(ret);
|
|
|
|
return ret;
|
2016-08-14 17:16:49 +02:00
|
|
|
}
|