mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-20 12:11:07 +00:00

* Fix protobuf structs handling (#4140) * Fix protobuf structs handling * Log instead of assert --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * BLE based logging (#4146) * WIP log characteristic * Bluetooth logging plumbing * Characteristic * Callback * Check for nullptr * Esp32 bluetooth impl * Formatting * Add thread name and log level * Add settings guard * Remove comments * Field name * Fixes esp32 * Open it up * Whoops * Move va_end past our logic * Use `upload_protocol = esptool` as with the other heltec devices instead of `esp-builtin` (#4151) * Standardize lat/lon position logs (#4156) * Standardize lat/lon position logs * Missed sone and condensed logs * [create-pull-request] automated change (#4157) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Pause BLE logging during want_config flow (#4162) * Update NimBLE to 1.4.2 (#4163) * Implement replies for all telemetry types based on variant tag (#4164) * Implement replies for all telemetry types based on variant tag * Remove check for `ignoreRequest`: modules can set this, don't need to check --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Esptool is better * Explicitly set characteristic * fix INA3221 sensor (#4168) - pass wire to begin() - remove redundant setAddr() (already set in header) * Show compass on waypoint frame; clear when waypoint deleted (#4116) * Clear expired or deleted waypoint frame * Return 0 to CallbackObserver * Add a missing comment * Draw compass for waypoint frame * Display our own waypoints * [create-pull-request] automated change (#4171) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Add semihosting support for nrf52 devices (#4137) * Turn off vscode cmake prompt - we don't use cmake on meshtastic * Add rak4631_dap variant for debugging with NanoDAP debug probe device. * The rak device can also run freertos (which is underneath nrf52 arduino) * Add semihosting support for nrf52840 devices Initial platformio.ini file only supports rak4630 Default to non TCP for the semihosting log output for now... Fixes https://github.com/meshtastic/firmware/issues/4135 * fix my botched merge - keep board_level = extra flag for rak3631_dbg --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * [create-pull-request] automated change (#4174) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Display alerts (#4170) * Move static functions into Screen.h, show compass during calibration * Move to _fontHeight macro to avoid collision * Move some alert functions to new alert handler * Catch missed reboot code * ESP32 fixes * Bump esp8266-oled-ssd1306 * Fixes for when a device has no screen * Use new startAlert(char*) helper class * Add EINK bits back to alert handling * Add noop class for no-display devices --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Send file system manifest up on want_config (#4176) * Send file system manifest up on want_config * Platform specific methods * Helps to actually make the change * Clear * tell vscode, if formatting, use whatever our trunk formatter wants (#4186) without this flag if the user has set some other formatter (clang) in their user level settings, it will be looking in the wrong directory for the clang options (we want the options in .trunk/clang) Note: formatOnSave is true in master, which means a bunch of our older files are non compliant and if you edit them it will generate lots of formatting related diffs. I guess I'll start letting that happen with my future commits ;-). * fix the build - would loop forever if there were no files to send (#4188) * Show owner.short_name on boot (and E-Ink sleep screen) (#4134) * Show owner.short_name on boot and sleep screen (on e-ink) * Update Screen.cpp - new line for short_name Boot screen short_name now below the region setting. Looks better on small screens. * Draw short_name on right --------- Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> Co-authored-by: todd-herbert <herbert.todd@gmail.com> Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * nrf52 soft device will watchdog if you use ICE while BT on... (#4189) so have debugger disable bluetooth. * correct xiao_ble build preventing sx1262 init (#4191) * Force a compile time failur if FromRadio or ToRadio get larger than (#4190) a BLE packet size. We are actually very close to this threshold so important to make sure we don't accidentally pass it. * Clear vector after complete config state (#4194) * Clear after complete config * Don't collect . entries * Log file name and size * [create-pull-request] automated change (#4200) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Make the logs Colorful! (#4199) * Squash needlessly static functions (#4183) * Trim extra vprintf and filter for unprintable characters * Deprecate Router Client role (and make it Client) (#4201) * [create-pull-request] automated change (#4205) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Move waypoint (#4202) * Move waypoint screen draw into the waypoint module * Get the observer set up for the waypoint screen draw * Static squashing: screen dimensions Macros moved back to Screen.cpp, as a band-aid until we eventually move all those static functions into the Screen class. * Move getCompassDiam into Screen class (supress compiler warnings) At this stage, the method is still static, because it's used by drawNodeInfo, which has no tidy reference to our screen instance. This is probably just another band-aid until these static functions all move. * Use new getCompassDiam function in AccelerometerThread * Properly gate display code in WaypointModule --------- Co-authored-by: Todd Herbert <herbert.todd@gmail.com> * Fix flakey phone api transition from file manifest to complete (#4209) * Try fix flakey phone api transition from file manifest to complete * Skip * enable colors in platformio serial monitor (#4217) * When talking via serial, encapsulate log messages in protobufs if necessary (#4187) * clean up RedirectablePrint::log so it doesn't have three very different implementations inline. * remove NoopPrint - it is no longer needed * when talking to API clients via serial, don't turn off log msgs instead encapsuate them * fix the build - would loop forever if there were no files to send * don't use Segger code if not talking to a Segger debugger * when encapsulating logs, make sure the strings always has nul terminators * nrf52 soft device will watchdog if you use ICE while BT on... so have debugger disable bluetooth. * Important to not print debug messages while writing to the toPhone scratch buffer * don't include newlines if encapsulating log records as protobufs --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * [create-pull-request] automated change (#4218) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Fix SHT41 support (#4222) * Add SHT41 Serial to I2c Detection Code On the Seeed Wio-WM1110 Dev Kit board, the SHT41 chip was being incorrectly detected as SHT31. This patch adds the necessary serial number for the SHT41 chip to be correctly detected. fixes meshtastic/firmware#4221 * Add missing sensor read for SHT41 * Typo fix in logs - mhz - MHz (#4225) As reported by karamo, a few different places in our logs had incorrect capitalization of MHz. fixes meshtastic/firmware#4126 * New new BLE logging characteristic with LogRecord protos (#4220) * New UUID * New log radio characteristic with LogRecord protobuf * LogRecord * Merge derp * How did you get there * Trunk * Fix length * Remove assert * minor cleanup proposal (#4169) * MESHTASTIC_EXCLUDE_WIFI and HAS_WIFI cleanup... Our code was checking HAS_WIFI and the new MESHTASTIC_EXCLUDE_WIFI flags in various places (even though EXCLUDE_WIFI forces HAS_WIFI to 0). Instead just check HAS_WIFI, only use EXCLUDE_WIFI inside configuration.h * cleanup: use HAS_NETWORKING instead of HAS_WIFI || HAS_ETHERNET We already had HAS_NETWORKING as flag in MQTT to mean 'we have tcpip'. Generallize that and move it into configuration.h so that we can use it elsewhere. * Use #pragma once, because supported by gcc and all modern compilers instead of #ifdef DOTHFILE_H etc... --------- Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz> * Add PowerMon support (#4155) * Turn off vscode cmake prompt - we don't use cmake on meshtastic * Add rak4631_dap variant for debugging with NanoDAP debug probe device. * The rak device can also run freertos (which is underneath nrf52 arduino) * Add semihosting support for nrf52840 devices Initial platformio.ini file only supports rak4630 Default to non TCP for the semihosting log output for now... Fixes https://github.com/meshtastic/firmware/issues/4135 * powermon WIP (for https://github.com/meshtastic/firmware/issues/4136 ) * oops - mean't to mark the _dbg variant as an 'extra' board. * powermon wip * Make serial port on wio-sdk-wm1110 board work By disabling the (inaccessible) adafruit USB * Instrument (radiolib only for now) lora for powermon per https://github.com/meshtastic/firmware/issues/4136 * powermon gps support https://github.com/meshtastic/firmware/issues/4136 * Add CPU deep and light sleep powermon states https://github.com/meshtastic/firmware/issues/4136 * Change the board/swversion bootstring so it is a new "structured" log msg. * powermon wip * add example script for getting esp S3 debugging working Not yet used but I didn't want these nasty tricks to get lost yet. * Add PowerMon reporting for screen and bluetooth pwr. * make power.powermon_enables config setting work. * update to latest protobufs * fix bogus shellcheck warning * make powermon optional (but default enabled because tiny and no runtime impact) * tell vscode, if formatting, use whatever our trunk formatter wants without this flag if the user has set some other formatter (clang) in their user level settings, it will be looking in the wrong directory for the clang options (we want the options in .trunk/clang) Note: formatOnSave is true in master, which means a bunch of our older files are non compliant and if you edit them it will generate lots of formatting related diffs. I guess I'll start letting that happen with my future commits ;-). * add PowerStress module * nrf52 arduino is built upon freertos, so let platformio debug it * don't accidentally try to Segger ICE if we are using another ICE * clean up RedirectablePrint::log so it doesn't have three very different implementations inline. * remove NoopPrint - it is no longer needed * when talking to API clients via serial, don't turn off log msgs instead encapsuate them * fix the build - would loop forever if there were no files to send * don't use Segger code if not talking to a Segger debugger * when encapsulating logs, make sure the strings always has nul terminators * nrf52 soft device will watchdog if you use ICE while BT on... so have debugger disable bluetooth. * Important to not print debug messages while writing to the toPhone scratch buffer * don't include newlines if encapsulating log records as protobufs * update to latest protobufs (needed for powermon goo) * PowerStress WIP * fix linter warning * Cleanup buffer * Merge hex for wm1110 target(s) * Only sdk * Sudo * Fix exclude macros (#4233) * fix MESHTASTIC_EXCLUDE_BLUETOOTH * fix HAS_SCREEN=0 * fix MESHTASTIC_EXCLUDE_GPS * fix typo in build-nrf52.sh (#4231) chmod is the command, '+x' is the argument. * Tidy Wireless Paper variant files (#4238) * Quick tidy of pins_arduino.h Matches requests made at https://github.com/meshtastic/firmware/pull/4226#discussion_r1664183480) * Tidy variant.h * Change deprecated ADC attenuation parameter From 11dB to 12dB. Resolves compiler warning. Allegly, no impact on function: `This is deprecated, it behaves the same as `ADC_ATTEN_DB_12` * Updated raspbian CI to update apt repository ahead of libbluetooth. (#4243) * Fix BLE logging on nrf52 (#4244) * allow ble logrecords to be fetched either by NOTIFY or INDICATE ble types This allows 'lossless' log reading. If client has requested INDICATE (rather than NOTIFY) each log record emitted via log() will have to fetched by the client device before the meshtastic node can continue. * Fix serious problem with nrf52 BLE logging. When doing notifies of LogRecords it is important to use the binary write routines - writing using the 'string' write won't work. Because protobufs can contain \0 nuls inside of them which if being parsed as a string will cause only a portion of the protobuf to be sent. I noticed this because some log messages were not getting through. --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Fix build when HAS_NETWORKING is false on nrf52 (#4237) (tested on a rak4631 by setting HAS_ETHERNET false when shrinking image) * If `toPhoneQueue` is full, still increment `fromNum` to avoid client never getting packets (#4246) * Update to SoftDevice 7.3.0 for wio-sdk-wm1110 and wio-tracker-wm1110 (#4248) * Update variant.h * Update wio-tracker-wm1110.json * Update wio-sdk-wm1110.json * Update platformio.ini * Update platformio.ini * Add files via upload * Add files via upload * Update variant.h --------- Co-authored-by: Mike <mikhael.skvortsov@gmail.com> Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Mike G <mkgin@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Co-authored-by: Warren Guy <5602790+warrenguy@users.noreply.github.com> Co-authored-by: todd-herbert <herbert.todd@gmail.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz> Co-authored-by: Alexander <156134901+Dorn8010@users.noreply.github.com> Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> Co-authored-by: quimnut <github@dopegoat.com> Co-authored-by: Manuel <71137295+mverch67@users.noreply.github.com> Co-authored-by: Agent Blu, 006 <blu006@ucr.edu> Co-authored-by: Mark Trevor Birss <markbirss@gmail.com>
381 lines
19 KiB
C
381 lines
19 KiB
C
/*
|
|
* Copyright (c) Nordic Semiconductor ASA
|
|
* All rights reserved.
|
|
*
|
|
* 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, except as embedded into a Nordic
|
|
* Semiconductor ASA integrated circuit in a product or a software update for
|
|
* such product, 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 of Nordic Semiconductor ASA nor the names of its
|
|
* contributors may be used to endorse or promote products derived from this
|
|
* software without specific prior written permission.
|
|
*
|
|
* 4. This software, with or without modification, must only be used with a
|
|
* Nordic Semiconductor ASA integrated circuit.
|
|
*
|
|
* 5. Any software provided in binary form under this license must not be reverse
|
|
* engineered, decompiled, modified and/or disassembled.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
|
|
*/
|
|
|
|
/**
|
|
@defgroup nrf_sdm_api SoftDevice Manager API
|
|
@{
|
|
|
|
@brief APIs for SoftDevice management.
|
|
|
|
*/
|
|
|
|
#ifndef NRF_SDM_H__
|
|
#define NRF_SDM_H__
|
|
|
|
#include "nrf.h"
|
|
#include "nrf_error.h"
|
|
#include "nrf_error_sdm.h"
|
|
#include "nrf_soc.h"
|
|
#include "nrf_svc.h"
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/** @addtogroup NRF_SDM_DEFINES Defines
|
|
* @{ */
|
|
#ifdef NRFSOC_DOXYGEN
|
|
/// Declared in nrf_mbr.h
|
|
#define MBR_SIZE 0
|
|
#warning test
|
|
#endif
|
|
|
|
/** @brief The major version for the SoftDevice binary distributed with this header file. */
|
|
#define SD_MAJOR_VERSION (7)
|
|
|
|
/** @brief The minor version for the SoftDevice binary distributed with this header file. */
|
|
#define SD_MINOR_VERSION (3)
|
|
|
|
/** @brief The bugfix version for the SoftDevice binary distributed with this header file. */
|
|
#define SD_BUGFIX_VERSION (0)
|
|
|
|
/** @brief The SoftDevice variant of this firmware. */
|
|
#define SD_VARIANT_ID 140
|
|
|
|
/** @brief The full version number for the SoftDevice binary this header file was distributed
|
|
* with, as a decimal number in the form Mmmmbbb, where:
|
|
* - M is major version (one or more digits)
|
|
* - mmm is minor version (three digits)
|
|
* - bbb is bugfix version (three digits). */
|
|
#define SD_VERSION (SD_MAJOR_VERSION * 1000000 + SD_MINOR_VERSION * 1000 + SD_BUGFIX_VERSION)
|
|
|
|
/** @brief SoftDevice Manager SVC Base number. */
|
|
#define SDM_SVC_BASE 0x10
|
|
|
|
/** @brief SoftDevice unique string size in bytes. */
|
|
#define SD_UNIQUE_STR_SIZE 20
|
|
|
|
/** @brief Invalid info field. Returned when an info field does not exist. */
|
|
#define SDM_INFO_FIELD_INVALID (0)
|
|
|
|
/** @brief Defines the SoftDevice Information Structure location (address) as an offset from
|
|
the start of the SoftDevice (without MBR)*/
|
|
#define SOFTDEVICE_INFO_STRUCT_OFFSET (0x2000)
|
|
|
|
/** @brief Defines the absolute SoftDevice Information Structure location (address) when the
|
|
* SoftDevice is installed just above the MBR (the usual case). */
|
|
#define SOFTDEVICE_INFO_STRUCT_ADDRESS (SOFTDEVICE_INFO_STRUCT_OFFSET + MBR_SIZE)
|
|
|
|
/** @brief Defines the offset for the SoftDevice Information Structure size value relative to the
|
|
* SoftDevice base address. The size value is of type uint8_t. */
|
|
#define SD_INFO_STRUCT_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET)
|
|
|
|
/** @brief Defines the offset for the SoftDevice size value relative to the SoftDevice base address.
|
|
* The size value is of type uint32_t. */
|
|
#define SD_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x08)
|
|
|
|
/** @brief Defines the offset for FWID value relative to the SoftDevice base address. The FWID value
|
|
* is of type uint16_t. */
|
|
#define SD_FWID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x0C)
|
|
|
|
/** @brief Defines the offset for the SoftDevice ID relative to the SoftDevice base address. The ID
|
|
* is of type uint32_t. */
|
|
#define SD_ID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x10)
|
|
|
|
/** @brief Defines the offset for the SoftDevice version relative to the SoftDevice base address in
|
|
* the same format as @ref SD_VERSION, stored as an uint32_t. */
|
|
#define SD_VERSION_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x14)
|
|
|
|
/** @brief Defines the offset for the SoftDevice unique string relative to the SoftDevice base address.
|
|
* The SD_UNIQUE_STR is stored as an array of uint8_t. The size of array is @ref SD_UNIQUE_STR_SIZE.
|
|
*/
|
|
#define SD_UNIQUE_STR_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x18)
|
|
|
|
/** @brief Defines a macro for retrieving the actual SoftDevice Information Structure size value
|
|
* from a given base address. Use @ref MBR_SIZE as the argument when the SoftDevice is
|
|
* installed just above the MBR (the usual case). */
|
|
#define SD_INFO_STRUCT_SIZE_GET(baseaddr) (*((uint8_t *)((baseaddr) + SD_INFO_STRUCT_SIZE_OFFSET)))
|
|
|
|
/** @brief Defines a macro for retrieving the actual SoftDevice size value from a given base
|
|
* address. Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above
|
|
* the MBR (the usual case). */
|
|
#define SD_SIZE_GET(baseaddr) (*((uint32_t *)((baseaddr) + SD_SIZE_OFFSET)))
|
|
|
|
/** @brief Defines the amount of flash that is used by the SoftDevice.
|
|
* Add @ref MBR_SIZE to find the first available flash address when the SoftDevice is installed
|
|
* just above the MBR (the usual case).
|
|
*/
|
|
#define SD_FLASH_SIZE 0x26000
|
|
|
|
/** @brief Defines a macro for retrieving the actual FWID value from a given base address. Use
|
|
* @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the usual
|
|
* case). */
|
|
#define SD_FWID_GET(baseaddr) (*((uint16_t *)((baseaddr) + SD_FWID_OFFSET)))
|
|
|
|
/** @brief Defines a macro for retrieving the actual SoftDevice ID from a given base address. Use
|
|
* @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the
|
|
* usual case). */
|
|
#define SD_ID_GET(baseaddr) \
|
|
((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_ID_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \
|
|
? (*((uint32_t *)((baseaddr) + SD_ID_OFFSET))) \
|
|
: SDM_INFO_FIELD_INVALID)
|
|
|
|
/** @brief Defines a macro for retrieving the actual SoftDevice version from a given base address.
|
|
* Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR
|
|
* (the usual case). */
|
|
#define SD_VERSION_GET(baseaddr) \
|
|
((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_VERSION_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \
|
|
? (*((uint32_t *)((baseaddr) + SD_VERSION_OFFSET))) \
|
|
: SDM_INFO_FIELD_INVALID)
|
|
|
|
/** @brief Defines a macro for retrieving the address of SoftDevice unique str based on a given base address.
|
|
* Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR
|
|
* (the usual case). */
|
|
#define SD_UNIQUE_STR_ADDR_GET(baseaddr) \
|
|
((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_UNIQUE_STR_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \
|
|
? (((uint8_t *)((baseaddr) + SD_UNIQUE_STR_OFFSET))) \
|
|
: SDM_INFO_FIELD_INVALID)
|
|
|
|
/**@defgroup NRF_FAULT_ID_RANGES Fault ID ranges
|
|
* @{ */
|
|
#define NRF_FAULT_ID_SD_RANGE_START 0x00000000 /**< SoftDevice ID range start. */
|
|
#define NRF_FAULT_ID_APP_RANGE_START 0x00001000 /**< Application ID range start. */
|
|
/**@} */
|
|
|
|
/**@defgroup NRF_FAULT_IDS Fault ID types
|
|
* @{ */
|
|
#define NRF_FAULT_ID_SD_ASSERT \
|
|
(NRF_FAULT_ID_SD_RANGE_START + 1) /**< SoftDevice assertion. The info parameter is reserved for future used. */
|
|
#define NRF_FAULT_ID_APP_MEMACC \
|
|
(NRF_FAULT_ID_APP_RANGE_START + 1) /**< Application invalid memory access. The info parameter will contain 0x00000000, \
|
|
in case of SoftDevice RAM access violation. In case of SoftDevice peripheral \
|
|
register violation the info parameter will contain the sub-region number of \
|
|
PREGION[0], on whose address range the disallowed write access caused the \
|
|
memory access fault. */
|
|
/**@} */
|
|
|
|
/** @} */
|
|
|
|
/** @addtogroup NRF_SDM_ENUMS Enumerations
|
|
* @{ */
|
|
|
|
/**@brief nRF SoftDevice Manager API SVC numbers. */
|
|
enum NRF_SD_SVCS {
|
|
SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */
|
|
SD_SOFTDEVICE_DISABLE, /**< ::sd_softdevice_disable */
|
|
SD_SOFTDEVICE_IS_ENABLED, /**< ::sd_softdevice_is_enabled */
|
|
SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, /**< ::sd_softdevice_vector_table_base_set */
|
|
SVC_SDM_LAST /**< Placeholder for last SDM SVC */
|
|
};
|
|
|
|
/** @} */
|
|
|
|
/** @addtogroup NRF_SDM_DEFINES Defines
|
|
* @{ */
|
|
|
|
/**@defgroup NRF_CLOCK_LF_ACCURACY Clock accuracy
|
|
* @{ */
|
|
|
|
#define NRF_CLOCK_LF_ACCURACY_250_PPM (0) /**< Default: 250 ppm */
|
|
#define NRF_CLOCK_LF_ACCURACY_500_PPM (1) /**< 500 ppm */
|
|
#define NRF_CLOCK_LF_ACCURACY_150_PPM (2) /**< 150 ppm */
|
|
#define NRF_CLOCK_LF_ACCURACY_100_PPM (3) /**< 100 ppm */
|
|
#define NRF_CLOCK_LF_ACCURACY_75_PPM (4) /**< 75 ppm */
|
|
#define NRF_CLOCK_LF_ACCURACY_50_PPM (5) /**< 50 ppm */
|
|
#define NRF_CLOCK_LF_ACCURACY_30_PPM (6) /**< 30 ppm */
|
|
#define NRF_CLOCK_LF_ACCURACY_20_PPM (7) /**< 20 ppm */
|
|
#define NRF_CLOCK_LF_ACCURACY_10_PPM (8) /**< 10 ppm */
|
|
#define NRF_CLOCK_LF_ACCURACY_5_PPM (9) /**< 5 ppm */
|
|
#define NRF_CLOCK_LF_ACCURACY_2_PPM (10) /**< 2 ppm */
|
|
#define NRF_CLOCK_LF_ACCURACY_1_PPM (11) /**< 1 ppm */
|
|
|
|
/** @} */
|
|
|
|
/**@defgroup NRF_CLOCK_LF_SRC Possible LFCLK oscillator sources
|
|
* @{ */
|
|
|
|
#define NRF_CLOCK_LF_SRC_RC (0) /**< LFCLK RC oscillator. */
|
|
#define NRF_CLOCK_LF_SRC_XTAL (1) /**< LFCLK crystal oscillator. */
|
|
#define NRF_CLOCK_LF_SRC_SYNTH (2) /**< LFCLK Synthesized from HFCLK. */
|
|
|
|
/** @} */
|
|
|
|
/** @} */
|
|
|
|
/** @addtogroup NRF_SDM_TYPES Types
|
|
* @{ */
|
|
|
|
/**@brief Type representing LFCLK oscillator source. */
|
|
typedef struct {
|
|
uint8_t source; /**< LF oscillator clock source, see @ref NRF_CLOCK_LF_SRC. */
|
|
uint8_t rc_ctiv; /**< Only for ::NRF_CLOCK_LF_SRC_RC: Calibration timer interval in 1/4 second
|
|
units (nRF52: 1-32).
|
|
@note To avoid excessive clock drift, 0.5 degrees Celsius is the
|
|
maximum temperature change allowed in one calibration timer
|
|
interval. The interval should be selected to ensure this.
|
|
|
|
@note Must be 0 if source is not ::NRF_CLOCK_LF_SRC_RC. */
|
|
uint8_t rc_temp_ctiv; /**< Only for ::NRF_CLOCK_LF_SRC_RC: How often (in number of calibration
|
|
intervals) the RC oscillator shall be calibrated if the temperature
|
|
hasn't changed.
|
|
0: Always calibrate even if the temperature hasn't changed.
|
|
1: Only calibrate if the temperature has changed (legacy - nRF51 only).
|
|
2-33: Check the temperature and only calibrate if it has changed,
|
|
however calibration will take place every rc_temp_ctiv
|
|
intervals in any case.
|
|
|
|
@note Must be 0 if source is not ::NRF_CLOCK_LF_SRC_RC.
|
|
|
|
@note For nRF52, the application must ensure calibration at least once
|
|
every 8 seconds to ensure +/-500 ppm clock stability. The
|
|
recommended configuration for ::NRF_CLOCK_LF_SRC_RC on nRF52 is
|
|
rc_ctiv=16 and rc_temp_ctiv=2. This will ensure calibration at
|
|
least once every 8 seconds and for temperature changes of 0.5
|
|
degrees Celsius every 4 seconds. See the Product Specification
|
|
for the nRF52 device being used for more information.*/
|
|
uint8_t accuracy; /**< External clock accuracy used in the LL to compute timing
|
|
windows, see @ref NRF_CLOCK_LF_ACCURACY.*/
|
|
} nrf_clock_lf_cfg_t;
|
|
|
|
/**@brief Fault Handler type.
|
|
*
|
|
* When certain unrecoverable errors occur within the application or SoftDevice the fault handler will be called back.
|
|
* The protocol stack will be in an undefined state when this happens and the only way to recover will be to
|
|
* perform a reset, using e.g. CMSIS NVIC_SystemReset().
|
|
* If the application returns from the fault handler the SoftDevice will call NVIC_SystemReset().
|
|
*
|
|
* @note It is recommended to either perform a reset in the fault handler or to let the SoftDevice reset the device.
|
|
* Otherwise SoC peripherals may behave in an undefined way. For example, the RADIO peripherial may
|
|
* continously transmit packets.
|
|
*
|
|
* @note This callback is executed in HardFault context, thus SVC functions cannot be called from the fault callback.
|
|
*
|
|
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
|
|
* @param[in] pc The program counter of the instruction that triggered the fault.
|
|
* @param[in] info Optional additional information regarding the fault. Refer to each Fault identifier for details.
|
|
*
|
|
* @note When id is set to @ref NRF_FAULT_ID_APP_MEMACC, pc will contain the address of the instruction being executed at the time
|
|
* when the fault is detected by the CPU. The CPU program counter may have advanced up to 2 instructions (no branching) after the
|
|
* one that triggered the fault.
|
|
*/
|
|
typedef void (*nrf_fault_handler_t)(uint32_t id, uint32_t pc, uint32_t info);
|
|
|
|
/** @} */
|
|
|
|
/** @addtogroup NRF_SDM_FUNCTIONS Functions
|
|
* @{ */
|
|
|
|
/**@brief Enables the SoftDevice and by extension the protocol stack.
|
|
*
|
|
* @note Some care must be taken if a low frequency clock source is already running when calling this function:
|
|
* If the LF clock has a different source then the one currently running, it will be stopped. Then, the new
|
|
* clock source will be started.
|
|
*
|
|
* @note This function has no effect when returning with an error.
|
|
*
|
|
* @post If return code is ::NRF_SUCCESS
|
|
* - SoC library and protocol stack APIs are made available.
|
|
* - A portion of RAM will be unavailable (see relevant SDS documentation).
|
|
* - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation).
|
|
* - Interrupts will not arrive from protected peripherals or interrupts.
|
|
* - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the SoftDevice.
|
|
* - Interrupt latency may be affected by the SoftDevice (see relevant SDS documentation).
|
|
* - Chosen low frequency clock source will be running.
|
|
*
|
|
* @param p_clock_lf_cfg Low frequency clock source and accuracy.
|
|
If NULL the clock will be configured as an RC source with rc_ctiv = 16 and .rc_temp_ctiv = 2
|
|
In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to
|
|
the actual characteristics of your XTAL clock.
|
|
* @param fault_handler Callback to be invoked in case of fault, cannot be NULL.
|
|
*
|
|
* @retval ::NRF_SUCCESS
|
|
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied.
|
|
* @retval ::NRF_ERROR_INVALID_STATE SoftDevice is already enabled, and the clock source and fault handler cannot be updated.
|
|
* @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDevice interrupt is already enabled, or an enabled interrupt has
|
|
an illegal priority level.
|
|
* @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected.
|
|
* @retval ::NRF_ERROR_INVALID_PARAM Invalid clock source configuration supplied in p_clock_lf_cfg.
|
|
*/
|
|
SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t,
|
|
sd_softdevice_enable(nrf_clock_lf_cfg_t const *p_clock_lf_cfg, nrf_fault_handler_t fault_handler));
|
|
|
|
/**@brief Disables the SoftDevice and by extension the protocol stack.
|
|
*
|
|
* Idempotent function to disable the SoftDevice.
|
|
*
|
|
* @post SoC library and protocol stack APIs are made unavailable.
|
|
* @post All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest).
|
|
* @post All peripherals used by the SoftDevice will be reset to default values.
|
|
* @post All of RAM become available.
|
|
* @post All interrupts are forwarded to the application.
|
|
* @post LFCLK source chosen in ::sd_softdevice_enable will be left running.
|
|
*
|
|
* @retval ::NRF_SUCCESS
|
|
*/
|
|
SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void));
|
|
|
|
/**@brief Check if the SoftDevice is enabled.
|
|
*
|
|
* @param[out] p_softdevice_enabled If the SoftDevice is enabled: 1 else 0.
|
|
*
|
|
* @retval ::NRF_SUCCESS
|
|
*/
|
|
SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t *p_softdevice_enabled));
|
|
|
|
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the SoftDevice
|
|
*
|
|
* This function is only intended to be called when a bootloader is enabled.
|
|
*
|
|
* @param[in] address The base address of the interrupt vector table for forwarded interrupts.
|
|
|
|
* @retval ::NRF_SUCCESS
|
|
*/
|
|
SVCALL(SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, uint32_t, sd_softdevice_vector_table_base_set(uint32_t address));
|
|
|
|
/** @} */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif // NRF_SDM_H__
|
|
|
|
/**
|
|
@}
|
|
*/
|