-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nrfconnect] Add support for nRF52840 Dongle to lighting-app (#8080)
* [nrfconnect] Add support for nRF52840 Dongle to lighting-app Allow to build nRF Connect Lighting Example for the nRF52840 Dongle. * Apply code review comments * Restyled by prettier-markdown Co-authored-by: Restyled.io <commits@restyled.io>
- Loading branch information
Showing
12 changed files
with
173 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# | ||
# Copyright (c) 2021 Project CHIP Authors | ||
# | ||
# Licensed 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. | ||
# | ||
|
||
# Make sure the pairing window starts automatically upon startup as the nRF52840 Dongle | ||
# has only one button and it is reserved for the factory reset | ||
CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y | ||
|
||
# Configure shell and logging over USB | ||
CONFIG_USB=y | ||
CONFIG_USB_UART_CONSOLE=y | ||
CONFIG_UART_INTERRUPT_DRIVEN=y | ||
CONFIG_UART_LINE_CTRL=y | ||
CONFIG_UART_SHELL_ON_DEV_NAME="CDC_ACM_0" | ||
CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51 | ||
|
||
# The minimal logging mode does not work properly with the USB CDC device, so use the deferred mode | ||
CONFIG_LOG_MODE_MINIMAL=n | ||
CONFIG_LOG_MODE_DEFERRED=y | ||
CONFIG_LOG_STRDUP_MAX_STRING=128 | ||
CONFIG_LOG_STRDUP_BUF_COUNT=24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,4 @@ CONFIG_MPU_STACK_GUARD=y | |
|
||
# CHIP configuration | ||
CONFIG_CHIP_PROJECT_CONFIG="main/include/CHIPProjectConfig.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
#ifndef CONFIG_BOARD_NRF52840DONGLE_NRF52840 | ||
#error "The command for triggerring the DFU is available for nRF52840 Dongle only" | ||
#endif | ||
|
||
#include <drivers/gpio.h> | ||
#include <shell/shell.h> | ||
|
||
namespace { | ||
constexpr const char * kGPIOController = "GPIO_0"; | ||
constexpr gpio_pin_t kGPIOResetPin = 19; | ||
|
||
int cmd_dfu(const struct shell * shell, size_t argc, char ** argv) | ||
{ | ||
// nRF52840 Dongle contains immutable bootloader which supports the DFU over a serial port. | ||
// Normally, a user must press the Reset button to reboot into the bootloader, but it can | ||
// also be done programatically by setting an appropriate GPIO pin. | ||
|
||
const device * gpioController = device_get_binding(kGPIOController); | ||
|
||
if (!gpioController) | ||
{ | ||
shell_fprintf(shell, SHELL_NORMAL, "Cannot find GPIO controller"); | ||
return -ENOEXEC; | ||
} | ||
|
||
if (gpio_pin_configure(gpioController, kGPIOResetPin, GPIO_OUTPUT)) | ||
{ | ||
shell_fprintf(shell, SHELL_NORMAL, "Cannot configure GPIO reset pin"); | ||
return -ENOEXEC; | ||
} | ||
|
||
if (gpio_pin_set_raw(gpioController, kGPIOResetPin, 0)) | ||
{ | ||
shell_fprintf(shell, SHELL_NORMAL, "Cannot set GPIO reset pin"); | ||
return -ENOEXEC; | ||
} | ||
|
||
return 0; | ||
} | ||
} // namespace | ||
|
||
SHELL_CMD_ARG_REGISTER(dfu, NULL, "Trigger DFU over serial port", cmd_dfu, 0, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters