2018-03-26 10:37:32 -06:00
|
|
|
/****************************************************************************
|
2021-03-08 18:39:04 -03:00
|
|
|
* boards/arm/nrf52/nrf52832-dk/src/nrf52_bringup.c
|
2018-03-26 10:37:32 -06:00
|
|
|
*
|
2021-03-17 18:14:12 +01: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
|
2018-03-26 10:37:32 -06:00
|
|
|
*
|
2021-03-17 18:14:12 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-03-26 10:37:32 -06:00
|
|
|
*
|
2021-03-17 18:14:12 +01: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.
|
2018-03-26 10:37:32 -06:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2018-04-20 07:23:57 -06:00
|
|
|
|
2018-03-26 10:37:32 -06:00
|
|
|
#include <sys/types.h>
|
2018-04-20 07:23:57 -06:00
|
|
|
#include <syslog.h>
|
2018-03-26 10:37:32 -06:00
|
|
|
|
2021-12-17 15:53:10 +01:00
|
|
|
#include <nuttx/fs/fs.h>
|
|
|
|
|
2018-11-18 07:51:24 -06:00
|
|
|
#ifdef CONFIG_NRF52_WDT
|
2020-10-28 14:40:35 -03:00
|
|
|
# include "nrf52_wdt_lowerhalf.h"
|
2018-11-18 07:51:24 -06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_USERLED
|
|
|
|
# include <nuttx/leds/userled.h>
|
|
|
|
#endif
|
2018-04-30 16:30:13 -06:00
|
|
|
|
2023-03-14 10:38:08 +01:00
|
|
|
#ifdef CONFIG_INPUT_BUTTONS
|
|
|
|
# include <nuttx/input/buttons.h>
|
|
|
|
#endif
|
|
|
|
|
2023-09-29 10:58:00 +02:00
|
|
|
#ifdef CONFIG_TIMER
|
|
|
|
# include "nrf52_timer.h"
|
|
|
|
#endif
|
|
|
|
|
2023-05-30 12:22:11 +02:00
|
|
|
#ifdef CONFIG_NRF52_PROGMEM
|
|
|
|
# include "nrf52_progmem.h"
|
|
|
|
#endif
|
|
|
|
|
2021-12-17 15:54:01 +01:00
|
|
|
#ifdef CONFIG_NRF52_SOFTDEVICE_CONTROLLER
|
|
|
|
# include "nrf52_sdc.h"
|
|
|
|
#endif
|
|
|
|
|
2024-02-16 21:17:42 +01:00
|
|
|
#ifdef CONFIG_IEEE802154_MRF24J40
|
|
|
|
# include "nrf52_mrf24j40.h"
|
|
|
|
#endif
|
|
|
|
|
2021-12-17 15:53:10 +01:00
|
|
|
#include "nrf52832-dk.h"
|
|
|
|
|
2023-09-29 10:58:00 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2024-01-25 17:50:53 +01:00
|
|
|
#define NRF52_TIMER (1)
|
2023-09-29 10:58:00 +02:00
|
|
|
|
2018-03-26 10:37:32 -06:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: nrf52_bringup
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform architecture-specific initialization
|
|
|
|
*
|
2019-02-18 15:32:00 -06:00
|
|
|
* CONFIG_BOARD_LATE_INITIALIZE=y :
|
|
|
|
* Called from board_late_initialize().
|
2018-03-26 10:37:32 -06:00
|
|
|
*
|
2021-08-01 15:00:54 +08:00
|
|
|
* CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y :
|
2018-03-26 10:37:32 -06:00
|
|
|
* Called from the NSH library
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int nrf52_bringup(void)
|
|
|
|
{
|
2018-04-20 07:23:57 -06:00
|
|
|
int ret;
|
|
|
|
|
2021-12-17 15:53:10 +01:00
|
|
|
#ifdef CONFIG_FS_PROCFS
|
|
|
|
/* Mount the procfs file system */
|
|
|
|
|
|
|
|
ret = nx_mount(NULL, NRF52_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
syslog(LOG_ERR,
|
|
|
|
"ERROR: Failed to mount the PROC filesystem: %d\n", ret);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_FS_PROCFS */
|
|
|
|
|
2018-04-20 07:23:57 -06:00
|
|
|
#ifdef CONFIG_NRF52_WDT
|
|
|
|
/* Start Watchdog timer */
|
|
|
|
|
|
|
|
ret = nrf52_wdt_initialize(CONFIG_WATCHDOG_DEVPATH, 1, 1);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
syslog(LOG_ERR, "ERROR: nrf52_wdt_initialize failed: %d\n", ret);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-11-18 07:51:24 -06:00
|
|
|
#ifdef CONFIG_USERLED
|
|
|
|
/* Register the LED driver */
|
|
|
|
|
|
|
|
ret = userled_lower_initialize(CONFIG_EXAMPLES_LEDS_DEVPATH);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-03-14 10:38:08 +01:00
|
|
|
#ifdef CONFIG_INPUT_BUTTONS
|
|
|
|
/* Register the BUTTON driver */
|
|
|
|
|
|
|
|
ret = btn_lower_initialize("/dev/buttons");
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-09-29 10:58:00 +02:00
|
|
|
#if defined(CONFIG_TIMER) && defined(CONFIG_NRF52_TIMER)
|
|
|
|
/* Configure TIMER driver */
|
|
|
|
|
|
|
|
ret = nrf52_timer_driver_setup("/dev/timer0", NRF52_TIMER);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
syslog(LOG_ERR,
|
|
|
|
"ERROR: Failed to initialize timer driver: %d\n",
|
|
|
|
ret);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-12-17 15:54:01 +01:00
|
|
|
#ifdef CONFIG_NRF52_SOFTDEVICE_CONTROLLER
|
|
|
|
ret = nrf52_sdc_initialize();
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
syslog(LOG_ERR, "ERROR: nrf52_sdc_initialize() failed: %d\n", ret);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-05-30 12:22:11 +02:00
|
|
|
#ifdef CONFIG_NRF52_PROGMEM
|
|
|
|
ret = nrf52_progmem_init();
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
syslog(LOG_ERR, "ERROR: Failed to initialize MTD progmem: %d\n", ret);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_MTD */
|
|
|
|
|
2024-02-16 21:17:42 +01:00
|
|
|
#ifdef CONFIG_IEEE802154_MRF24J40
|
|
|
|
/* Configure MRF24J40 wireless */
|
|
|
|
|
|
|
|
ret = nrf52_mrf24j40_initialize();
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
syslog(LOG_ERR, "ERROR: nrf52_mrf24j40_initialize() failed: %d\n",
|
|
|
|
ret);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-04-20 07:23:57 -06:00
|
|
|
UNUSED(ret);
|
2018-03-26 10:37:32 -06:00
|
|
|
return OK;
|
|
|
|
}
|