/**************************************************************************** * boards/arm/nrf52/nrf52832-dk/src/nrf52_bringup.c * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * 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. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include #include #include #include #ifdef CONFIG_NRF52_WDT # include "nrf52_wdt_lowerhalf.h" #endif #ifdef CONFIG_USERLED # include #endif #ifdef CONFIG_INPUT_BUTTONS # include #endif #ifdef CONFIG_TIMER # include "nrf52_timer.h" #endif #ifdef CONFIG_NRF52_PROGMEM # include "nrf52_progmem.h" #endif #ifdef CONFIG_NRF52_SOFTDEVICE_CONTROLLER # include "nrf52_sdc.h" #endif #ifdef CONFIG_IEEE802154_MRF24J40 # include "nrf52_mrf24j40.h" #endif #include "nrf52832-dk.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ #define NRF52_TIMER (1) /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: nrf52_bringup * * Description: * Perform architecture-specific initialization * * CONFIG_BOARD_LATE_INITIALIZE=y : * Called from board_late_initialize(). * * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y : * Called from the NSH library * ****************************************************************************/ int nrf52_bringup(void) { int ret; #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 */ #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 #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 #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 #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 #ifdef CONFIG_NRF52_SOFTDEVICE_CONTROLLER ret = nrf52_sdc_initialize(); if (ret < 0) { syslog(LOG_ERR, "ERROR: nrf52_sdc_initialize() failed: %d\n", ret); } #endif #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 */ #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 UNUSED(ret); return OK; }