Compare commits
12 Commits
25befa26b1
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ab74582568 | |||
| b75c99b125 | |||
| 763abb0fcc | |||
| 80d7086d09 | |||
| 39cf6068f7 | |||
| 0d719751c4 | |||
| f3110c696f | |||
| 08a4bbef5d | |||
| 873ae0fb83 | |||
| 593f1d1c5b | |||
| cda370b69d | |||
| 228f6da4a3 |
@@ -64,6 +64,7 @@ static volatile bool m_flash_write_done;
|
||||
|
||||
#define SCHED_QUEUE_SIZE 32 /**< Maximum number of events in the scheduler queue. */
|
||||
#define SCHED_EVENT_DATA_SIZE NRF_DFU_SCHED_EVENT_DATA_SIZE /**< Maximum app_scheduler event size. */
|
||||
#define POST_DFU_APP_BOOT_GPREGRET2_MASK 0x02U
|
||||
|
||||
#if !(defined(NRF_BL_DFU_ENTER_METHOD_BUTTON) && \
|
||||
defined(NRF_BL_DFU_ENTER_METHOD_PINRESET) && \
|
||||
@@ -470,6 +471,7 @@ ret_code_t nrf_bootloader_init(nrf_dfu_observer_t observer)
|
||||
break;
|
||||
|
||||
case ACTIVATION_SUCCESS:
|
||||
nrf_power_gpregret2_set(nrf_power_gpregret2_get() | POST_DFU_APP_BOOT_GPREGRET2_MASK);
|
||||
bootloader_reset(true);
|
||||
NRF_LOG_ERROR("Unreachable");
|
||||
return NRF_ERROR_INTERNAL; // Should not reach this.
|
||||
|
||||
@@ -50,6 +50,8 @@ extern int imu_read_direct(void);
|
||||
extern int imu_read_temperature_x100(uint16_t *temp_x100, float *temp_c);
|
||||
extern int imu_fifo_capture_start(void);
|
||||
extern int imu_fifo_capture_stop_and_send_rim(void);
|
||||
extern int imu_fifo_capture_wait_samples_and_send_rim(uint16_t target_samples, uint32_t timeout_ms);
|
||||
extern void imu_fifo_capture_disable(void);
|
||||
extern void battery_timer_stop(void);
|
||||
extern void main_timer_start(void);
|
||||
extern void hw_i2c_init_once(void);
|
||||
|
||||
@@ -41,6 +41,7 @@ static const CmdEntry m_cmd_table[] = {
|
||||
{ "msn?", true, Cmd_msn },
|
||||
{ "mst?", true, Cmd_mst },
|
||||
{ "msp?", true, Cmd_msp },
|
||||
{ "mim?", true, Cmd_mim },
|
||||
|
||||
/* D. Piezo ultrasound */
|
||||
{ "mpa?", true, Cmd_mpa },
|
||||
@@ -49,6 +50,7 @@ static const CmdEntry m_cmd_table[] = {
|
||||
{ "mec?", true, Cmd_mec },
|
||||
{ "maa?", true, Cmd_maa },
|
||||
{ "mbb?", true, Cmd_mbb },
|
||||
{ "mab?", true, Cmd_mab }, // B-Mode Test
|
||||
{ "mtb?", true, Cmd_mtb },
|
||||
{ "mcf?", true, Cmd_mcf },
|
||||
{ "mcs?", true, Cmd_mcs },
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "cmd_device.h"
|
||||
#include "fstorage.h"
|
||||
#include "led_control.h"
|
||||
#include "app_raw.h"
|
||||
|
||||
/*==============================================================================
|
||||
* msq? -> rsq: Device power OFF
|
||||
@@ -172,6 +173,14 @@ int Cmd_mls(const ParsedCmd *cmd)
|
||||
}
|
||||
|
||||
led_set_state((led_state_t)state);
|
||||
if ((led_state_t)state == LED_STATE_OFF)
|
||||
{
|
||||
if (imu_fifo_capture_is_active())
|
||||
{
|
||||
imu_fifo_capture_disable();
|
||||
}
|
||||
}
|
||||
|
||||
dr_ble_return_1("rls:", state);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,19 @@
|
||||
#include "cmd_sensor.h" /* all_sensors() */
|
||||
#include "dr_piezo.h"
|
||||
#include "dr_adc121s051.h"
|
||||
#include "led_control.h"
|
||||
#include "../../measurement/piezo/piezo_config.h"
|
||||
|
||||
static void mtb_send_rim_after_piezo(void)
|
||||
{
|
||||
send_imu_rim_fifo();
|
||||
}
|
||||
|
||||
static void mab_led_off_after_piezo(void)
|
||||
{
|
||||
led_set_state(LED_STATE_OFF);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal clamp helpers for persisted piezo configuration
|
||||
*----------------------------------------------------------------------------*/
|
||||
@@ -58,48 +65,48 @@ static uint8_t clamp_piezo_freq_option(uint16_t raw_freq)
|
||||
|
||||
static uint8_t clamp_piezo_cycles(uint16_t cycles)
|
||||
{
|
||||
if (cycles < 3)
|
||||
if (cycles < PIEZO_CONFIG_CYCLES_MIN)
|
||||
{
|
||||
return 3;
|
||||
return (uint8_t)PIEZO_CONFIG_CYCLES_MIN;
|
||||
}
|
||||
if (cycles > 7)
|
||||
if (cycles > PIEZO_CONFIG_CYCLES_MAX)
|
||||
{
|
||||
return 7;
|
||||
return (uint8_t)PIEZO_CONFIG_CYCLES_MAX;
|
||||
}
|
||||
return (uint8_t)cycles;
|
||||
}
|
||||
|
||||
static uint16_t clamp_piezo_averaging(uint16_t averaging)
|
||||
{
|
||||
if (averaging < 1)
|
||||
if (averaging < PIEZO_CONFIG_AVERAGING_MIN)
|
||||
{
|
||||
return 1;
|
||||
return PIEZO_CONFIG_AVERAGING_MIN;
|
||||
}
|
||||
if (averaging > 10)
|
||||
if (averaging > PIEZO_CONFIG_AVERAGING_MAX)
|
||||
{
|
||||
return 10;
|
||||
return PIEZO_CONFIG_AVERAGING_MAX;
|
||||
}
|
||||
return averaging;
|
||||
}
|
||||
|
||||
static uint16_t clamp_piezo_delay_us(uint16_t delay_us)
|
||||
{
|
||||
if (delay_us > 50)
|
||||
if (delay_us > PIEZO_CONFIG_DELAY_US_MAX)
|
||||
{
|
||||
return 50;
|
||||
return PIEZO_CONFIG_DELAY_US_MAX;
|
||||
}
|
||||
return delay_us;
|
||||
}
|
||||
|
||||
static uint16_t clamp_piezo_num_samples(uint16_t num_samples)
|
||||
{
|
||||
if (num_samples < 80)
|
||||
if (num_samples < PIEZO_CONFIG_NUM_SAMPLES_MIN)
|
||||
{
|
||||
return 80;
|
||||
return PIEZO_CONFIG_NUM_SAMPLES_MIN;
|
||||
}
|
||||
if (num_samples > 119)
|
||||
if (num_samples > PIEZO_CONFIG_NUM_SAMPLES_MAX)
|
||||
{
|
||||
return 119;
|
||||
return PIEZO_CONFIG_NUM_SAMPLES_MAX;
|
||||
}
|
||||
return num_samples;
|
||||
}
|
||||
@@ -158,8 +165,8 @@ int Cmd_mpb(const ParsedCmd *cmd)
|
||||
*============================================================================*/
|
||||
int Cmd_mpc(const ParsedCmd *cmd)
|
||||
{
|
||||
uint16_t cycles = 5;
|
||||
uint16_t freq_option = 1;
|
||||
uint16_t cycles = DR_PIEZO_DEFAULT_CYCLES;
|
||||
uint16_t freq_option = PIEZO_CONFIG_FREQ_OPTION_DEFAULT;
|
||||
uint16_t piezo_ch = 0;
|
||||
|
||||
(void)dr_get_u16(cmd, 0, &cycles);
|
||||
@@ -171,7 +178,7 @@ int Cmd_mpc(const ParsedCmd *cmd)
|
||||
piezo_ch = 0;
|
||||
}
|
||||
|
||||
if (cycles < 3 || cycles > 7)
|
||||
if (cycles < PIEZO_CONFIG_CYCLES_MIN || cycles > PIEZO_CONFIG_CYCLES_MAX)
|
||||
{
|
||||
dr_ble_return_1("rpc:", 2);
|
||||
return 1;
|
||||
@@ -218,7 +225,7 @@ int Cmd_mec(const ParsedCmd *cmd)
|
||||
uint16_t freq_option = 0;
|
||||
uint16_t delay_us = 20;
|
||||
uint16_t num_samples = 140;
|
||||
uint16_t cycles = 5;
|
||||
uint16_t cycles = DR_PIEZO_DEFAULT_CYCLES;
|
||||
uint16_t averaging = 1;
|
||||
uint16_t piezo_ch = 0;
|
||||
|
||||
@@ -414,6 +421,57 @@ int Cmd_mtb(const ParsedCmd *cmd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==============================================================================
|
||||
* mab? -> reb:+raa: 6-channel asynchronous full capture + GR LED
|
||||
*
|
||||
* Request: [TAG 4B "mab?"] [CRC 2B]
|
||||
* Response: per channel reb: [num_samples 2B] [raw_data...]
|
||||
* final raa: [status 2B]
|
||||
* Error: raa: + 0xFFFE (previous capture in progress)
|
||||
* raa: + (0xFF00|err) (start failed)
|
||||
*
|
||||
* For B-Mode Test
|
||||
*============================================================================*/
|
||||
int Cmd_mab(const ParsedCmd *cmd)
|
||||
{
|
||||
dr_adc_err_t err;
|
||||
(void)cmd;
|
||||
|
||||
if (maa_async_is_busy())
|
||||
{
|
||||
dr_ble_return_1("raa:", 0xFFFE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
led_set_state(LED_STATE_ALIGN_COMPLETE);
|
||||
|
||||
err = maa_async_start(
|
||||
m_config.piezo_freq_option,
|
||||
m_config.piezo_delay_us,
|
||||
m_config.piezo_num_samples,
|
||||
m_config.piezo_cycles,
|
||||
m_config.piezo_averaging,
|
||||
ble_bin_buffer
|
||||
);
|
||||
|
||||
if (err != DR_ADC_OK)
|
||||
{
|
||||
if (g_plat.log)
|
||||
{
|
||||
g_plat.log("[Cmd_mab] start failed err=%d\r\n", err);
|
||||
}
|
||||
single_format_data(ble_bin_buffer, "raa:", (uint16_t)(0xFF00 | err));
|
||||
dr_binary_tx_safe(ble_bin_buffer, 3);
|
||||
dr_piezo_power_off();
|
||||
led_set_state(LED_STATE_OFF);
|
||||
return 1;
|
||||
}
|
||||
|
||||
maa_async_set_on_complete(mab_led_off_after_piezo);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==============================================================================
|
||||
* mcf? -> rcf: Read piezo parameters from FDS
|
||||
*
|
||||
|
||||
@@ -12,6 +12,7 @@ int Cmd_mpc(const ParsedCmd *cmd); /* mpc? -> rpc: burst generation */
|
||||
int Cmd_mec(const ParsedCmd *cmd); /* mec? -> reb:+raa: single-channel capture */
|
||||
int Cmd_maa(const ParsedCmd *cmd); /* maa? -> reb:+raa: 6-channel async capture */
|
||||
int Cmd_mbb(const ParsedCmd *cmd); /* mbb? -> rbb:+reb:+raa: sensors + capture */
|
||||
int Cmd_mab(const ParsedCmd *cmd); /* mab? -> reb:+raa: 6-channel async capture + green LED */
|
||||
int Cmd_mtb(const ParsedCmd *cmd); /* mtb? -> reb:+raa:+rim: piezo + IMU FIFO (no rbb:) */
|
||||
int Cmd_mcf(const ParsedCmd *cmd); /* mcf? -> rcf: read piezo parameters */
|
||||
int Cmd_mcs(const ParsedCmd *cmd); /* mcs? -> rcs: write piezo parameters */
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
* msn? -> rsn: battery ADC measurement
|
||||
* mst? -> rso: IMU die temperature reading
|
||||
* msp? -> rsp: IMU 6-axis single read
|
||||
* mim? -> rim: IMU FIFO 15-sample read
|
||||
* all_sensors() bulk-measurement helper used by the mbb? handler
|
||||
*============================================================================*/
|
||||
|
||||
#include "cmd_common.h"
|
||||
#include "cmd_sensor.h"
|
||||
#include "app_raw.h"
|
||||
|
||||
/*==============================================================================
|
||||
* msn? -> rsn: Battery level ADC measurement
|
||||
@@ -47,6 +49,7 @@ int Cmd_mst(const ParsedCmd *cmd)
|
||||
|
||||
/*==============================================================================
|
||||
* msp? -> rsp: IMU 6-axis single read
|
||||
* mim? -> rim: IMU FIFO 15-sample read
|
||||
*
|
||||
* Request: [TAG 4B "msp?"] [CRC 2B]
|
||||
* Response: rsp: + accel(xyz) + gyro(xyz) (transmitted inside imu_read_direct)
|
||||
@@ -56,11 +59,49 @@ int Cmd_mst(const ParsedCmd *cmd)
|
||||
int Cmd_msp(const ParsedCmd *cmd)
|
||||
{
|
||||
(void)cmd;
|
||||
|
||||
if (imu_fifo_capture_is_active())
|
||||
{
|
||||
return 1; // already owned by mtb?/mim?, ignore duplicate request
|
||||
}
|
||||
|
||||
hw_i2c_init_once();
|
||||
imu_read_direct();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==============================================================================
|
||||
* mim? -> rim: IMU FIFO-only capture
|
||||
*
|
||||
* Request: [TAG 4B "mim?"] [CRC 2B]
|
||||
* Response: rim: [total_sample_count u16 BE]
|
||||
* [samples: 12B each ax,ay,az,gx,gy,gz ...]
|
||||
*
|
||||
* Uses the same FIFO/rim path as mtb? but without piezo reb:/raa: packets.
|
||||
* At 50 Hz, 15 samples are about 300 ms; timeout leaves margin for startup.
|
||||
*============================================================================*/
|
||||
int Cmd_mim(const ParsedCmd *cmd)
|
||||
{
|
||||
int rc;
|
||||
(void)cmd;
|
||||
|
||||
if (imu_fifo_capture_is_active())
|
||||
{
|
||||
return 1; // already owned by mtb?/mim?, ignore duplicate request
|
||||
}
|
||||
|
||||
rc = imu_fifo_capture_start();
|
||||
if (rc != 0)
|
||||
{
|
||||
(void)imu_fifo_capture_stop_and_send_rim();
|
||||
imu_fifo_capture_disable();
|
||||
return 1;
|
||||
}
|
||||
|
||||
(void)imu_fifo_capture_wait_samples_and_send_rim(15, 500);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==============================================================================
|
||||
* all_sensors() - Bulk-measurement helper for the mbb? handler
|
||||
*
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
int Cmd_msn(const ParsedCmd *cmd); /* msn? -> rsn: battery ADC measurement */
|
||||
int Cmd_mst(const ParsedCmd *cmd); /* mst? -> rso: IMU die temperature */
|
||||
int Cmd_msp(const ParsedCmd *cmd); /* msp? -> rsp: IMU 6-axis single read */
|
||||
int Cmd_mim(const ParsedCmd *cmd); /* mim? -> rim: IMU FIFO 15 samples */
|
||||
/* Helper for the mbb? handler: sequentially measures battery / IMU / temperature, then emits a single rbb: response.
|
||||
* Called from Cmd_mbb() in cmd_piezo.c. */
|
||||
void all_sensors(void);
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
@echo off
|
||||
chcp 437
|
||||
setlocal EnableExtensions
|
||||
|
||||
cd /d "%~dp0"
|
||||
|
||||
set "APP_HEX=medithings_bladder_patch_0001.hex"
|
||||
set "BOOT_HEX=medithings_bladder_patch_bootloader.hex"
|
||||
set "OUT_APP_ZIP=medithings_bladder_patch_dfu.zip"
|
||||
set "OUT_BOOT_ZIP=medithings_bladder_patch_bootloader_dfu.zip"
|
||||
|
||||
REM Bootloader DFU requires a version greater than the currently installed bootloader_version.
|
||||
REM cpd/cpd_eraseALL currently install bootloader-version 1, so use 2 for this update.
|
||||
set "APP_VERSION=1"
|
||||
set "BOOTLOADER_VERSION=2"
|
||||
set "HW_VERSION=52"
|
||||
set "SD_REQ=0x0100"
|
||||
set "SD_ID=0x0100"
|
||||
|
||||
echo [1/4] Copying application HEX...
|
||||
copy /Y "..\pca10056\s140\arm5_no_packs\_build\nrf52840_xxaa.hex" "%APP_HEX%"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo [2/4] Copying bootloader HEX...
|
||||
copy /Y "..\..\..\dfu\secure_bootloader\pca10056_s140_ble\arm5_no_packs\_build\nrf52840_xxaa_s140.hex" "%BOOT_HEX%"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo [3/4] Generating application DFU package...
|
||||
nrfutil pkg generate ^
|
||||
--application "%APP_HEX%" ^
|
||||
--application-version %APP_VERSION% ^
|
||||
--hw-version %HW_VERSION% ^
|
||||
--sd-req %SD_REQ% ^
|
||||
--sd-id %SD_ID% ^
|
||||
--key-file private.key ^
|
||||
"%OUT_APP_ZIP%"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo [4/4] Generating bootloader DFU package...
|
||||
nrfutil pkg generate ^
|
||||
--bootloader "%BOOT_HEX%" ^
|
||||
--bootloader-version %BOOTLOADER_VERSION% ^
|
||||
--hw-version %HW_VERSION% ^
|
||||
--sd-req %SD_REQ% ^
|
||||
--key-file private.key ^
|
||||
"%OUT_BOOT_ZIP%"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo.
|
||||
echo Done:
|
||||
echo %OUT_APP_ZIP%
|
||||
echo %OUT_BOOT_ZIP%
|
||||
echo Bootloader version: %BOOTLOADER_VERSION%
|
||||
echo.
|
||||
echo Update order for both app and bootloader changes:
|
||||
echo 1. Send %OUT_BOOT_ZIP%
|
||||
echo 2. Power on again if the device powers off
|
||||
echo 3. Send %OUT_APP_ZIP%
|
||||
pause
|
||||
exit /b 0
|
||||
|
||||
:fail
|
||||
echo.
|
||||
echo ERROR: Failed to generate DFU package(s).
|
||||
pause
|
||||
exit /b 1
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "nrf_pwr_mgmt.h"
|
||||
#include "main.h"
|
||||
#include "debug_print.h"
|
||||
#include "../../measurement/piezo/piezo_config.h"
|
||||
|
||||
|
||||
/* FDS record identifiers */
|
||||
@@ -107,11 +108,11 @@ void fds_default_value_set(void)
|
||||
m_config.life_cycle = 0;
|
||||
|
||||
/* Piezo measurement parameter defaults */
|
||||
m_config.piezo_freq_option = 1; /* 2.1 MHz */
|
||||
m_config.piezo_delay_us = 10; /* 10 us after burst */
|
||||
m_config.piezo_num_samples = 100; /* 100 samples */
|
||||
m_config.piezo_cycles = 3; /* 7 cycles */
|
||||
m_config.piezo_averaging = 3; /* 3x averaging */
|
||||
m_config.piezo_freq_option = PIEZO_CONFIG_FREQ_OPTION_DEFAULT; /* 2.1 MHz */
|
||||
m_config.piezo_delay_us = PIEZO_CONFIG_DELAY_US_DEFAULT; /* 10 us after burst */
|
||||
m_config.piezo_num_samples = PIEZO_CONFIG_NUM_SAMPLES_DEFAULT; /* 100 samples */
|
||||
m_config.piezo_cycles = PIEZO_CONFIG_CYCLES_DEFAULT; /* 3 cycles */
|
||||
m_config.piezo_averaging = PIEZO_CONFIG_AVERAGING_DEFAULT; /* 3x averaging */
|
||||
|
||||
/* Factory provisioning — default: not provisioned */
|
||||
m_config.factory_provisioned = 0;
|
||||
|
||||
@@ -181,6 +181,7 @@
|
||||
#define POWER_OFF_DELAY 3000 /* Power-off delay: 3s after LED indication */
|
||||
#define POWER_RESET_DELAY 2000 /* Reset delay: 2s */
|
||||
#define LED_NUM 24 /* LED pin number */
|
||||
#define POST_DFU_APP_BOOT_GPREGRET2_MASK 0x02U /* Bootloader marker after DFU activation */
|
||||
|
||||
/*==============================================================================
|
||||
* BLE Instances (statically allocated via SoftDevice macros)
|
||||
@@ -230,7 +231,7 @@ static char * roles_str[] = {"INVALID_ROLE", "CENTRAL", "PERIPHERAL"};
|
||||
|
||||
/*==============================================================================
|
||||
* Global Variables
|
||||
* IEC 62304 §5.5.3: all global buffers zero-initialized for deterministic startup
|
||||
* IEC 62304 5.5.3: all global buffers zero-initialized for deterministic startup
|
||||
*============================================================================*/
|
||||
volatile uint8_t Sj_type; /* Command type identifier */
|
||||
bool power_off_duble_prohibit = false; /* Power-off double prevention flag */
|
||||
@@ -1545,7 +1546,7 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
|
||||
DBG_PRINTF("[BLE] Connected\r\n");
|
||||
|
||||
#if BLE_DEV_MODE
|
||||
/* Dev: no passkey/SEC — allow NUS TX/RX as soon as GAP is up (prod uses PM_EVT_CONN_SEC_SUCCEEDED). */
|
||||
/* Dev: no passkey/SEC - allow NUS TX/RX as soon as GAP is up (prod uses PM_EVT_CONN_SEC_SUCCEEDED). */
|
||||
ble_connection_st = BLE_CONNECTED_ST;
|
||||
battery_timer_start();
|
||||
#endif
|
||||
@@ -2076,6 +2077,7 @@ static void main_s(void * p_context)
|
||||
|
||||
bool button_released = nrf_gpio_pin_read(POWER_BUTTON);
|
||||
|
||||
|
||||
/* ---- Running phase: post-boot button polling ---- */
|
||||
if (booted)
|
||||
{
|
||||
@@ -2120,7 +2122,7 @@ static void main_s(void * p_context)
|
||||
go_device_power_off = true;
|
||||
main_timer_start();
|
||||
}
|
||||
else if (cnt_s > 250 || (m_reset_status == 2)) /* 250 x 5ms = 1.25s + α */
|
||||
else if (cnt_s > 250 || (m_reset_status == 2)) /* 250 x 5ms = 1.25s + ¥á */
|
||||
{
|
||||
DBG_PRINTF("[BTN] Boot (cnt=%d)\r\n", cnt_s);
|
||||
device_reset = false;
|
||||
@@ -2149,7 +2151,7 @@ static void main_s(void * p_context)
|
||||
cnt_s++;
|
||||
device_reset = false;
|
||||
|
||||
if (cnt_s == 250) /* 250 x 5ms = 1.25s + α */
|
||||
if (cnt_s == 250) /* 250 x 5ms = 1.25s + ¥á */
|
||||
{
|
||||
led_set_state(LED_STATE_POWER_ON);
|
||||
DBG_PRINTF("[BTN] 2.0s\r\n");
|
||||
@@ -2170,7 +2172,7 @@ int main(void)
|
||||
{
|
||||
bool erase_bonds_local = false;
|
||||
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
/*--------------------------------------------------------------------------
|
||||
* Phase 1: Basic hardware init (BLE-independent)
|
||||
*
|
||||
* - Power self-latch (P0.8 HIGH)
|
||||
@@ -2179,9 +2181,20 @@ int main(void)
|
||||
* - App timers (power polling, battery, main loop)
|
||||
* - Default config (serial number, passkey)
|
||||
* - Buttons/LEDs
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
*--------------------------------------------------------------------------*/
|
||||
power_hold_init();
|
||||
|
||||
if ((NRF_POWER->GPREGRET2 & POST_DFU_APP_BOOT_GPREGRET2_MASK) != 0)
|
||||
{
|
||||
NRF_POWER->GPREGRET2 &= ~POST_DFU_APP_BOOT_GPREGRET2_MASK;
|
||||
NRF_P0->OUTCLR = (1UL << 8);
|
||||
NRF_P0->DIRSET = (1UL << 8);
|
||||
while (true)
|
||||
{
|
||||
__WFE();
|
||||
}
|
||||
}
|
||||
|
||||
if (power_off_duble_prohibit)
|
||||
{
|
||||
return 0;
|
||||
@@ -2191,7 +2204,7 @@ int main(void)
|
||||
log_init();
|
||||
|
||||
DBG_PRINTF("\r\n========================================\r\n");
|
||||
DBG_PRINTF(" Medithings v1.17\r\n");
|
||||
DBG_PRINTF(" Medithings VesiScan-Basic\r\n");
|
||||
DBG_PRINTF("========================================\r\n");
|
||||
|
||||
DBG_PRINTF("[1] HW Init\r\n");
|
||||
@@ -2205,33 +2218,33 @@ int main(void)
|
||||
#endif
|
||||
DBG_PRINTF(" gpio/timer/config/btn OK\r\n");
|
||||
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
/*--------------------------------------------------------------------------
|
||||
* Phase 2: BLE stack init
|
||||
*
|
||||
* - Power management module (WFE/sleep when idle)
|
||||
* - SoftDevice S140 (BLE 5.0 protocol stack)
|
||||
* - DC-DC converter enable (required after SoftDevice)
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
*--------------------------------------------------------------------------*/
|
||||
DBG_PRINTF("[2] BLE Stack\r\n");
|
||||
power_management_init();
|
||||
ble_stack_init();
|
||||
APP_ERROR_CHECK(sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE));
|
||||
DBG_PRINTF(" pwr/stack/dcdc OK\r\n");
|
||||
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
/*--------------------------------------------------------------------------
|
||||
* Phase 3: Internal flash config (must init after BLE stack)
|
||||
*
|
||||
* - FDS (Flash Data Storage) init
|
||||
* - Read stored config from flash (serial, passkey, piezo, etc.)
|
||||
* - Overwrite defaults with flash values
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
*--------------------------------------------------------------------------*/
|
||||
DBG_PRINTF("[3] FDS\r\n");
|
||||
fs_storage_init();
|
||||
config_load();
|
||||
load_flash_config();
|
||||
DBG_PRINTF(" fds OK\r\n");
|
||||
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
/*--------------------------------------------------------------------------
|
||||
* Phase 4: BLE protocol setup
|
||||
*
|
||||
* - GAP: device name (serial number), connection params, passkey
|
||||
@@ -2240,7 +2253,7 @@ int main(void)
|
||||
* - Advertising: advertising data (name, UUID)
|
||||
* - Connection parameter negotiation module
|
||||
* - Security: Peer Manager (bonding/passkey)
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
*--------------------------------------------------------------------------*/
|
||||
DBG_PRINTF("[4] BLE Protocol\r\n");
|
||||
gap_params_init();
|
||||
gatt_init();
|
||||
@@ -2275,14 +2288,14 @@ int main(void)
|
||||
DBG_PRINTF(" fds defaults saved\r\n");
|
||||
}
|
||||
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
/*--------------------------------------------------------------------------
|
||||
* Phase 5: Application init
|
||||
*
|
||||
* - Command parser: process BLE received commands (log, BLE TX, CRC)
|
||||
* - Piezo driver: GPIO/Timer/PPI setup for ultrasound measurement
|
||||
* - IMU (ICM42670P) is NOT initialized here
|
||||
* -> imu_read_direct() self-configures/reads/sleeps on each msp? command
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
*--------------------------------------------------------------------------*/
|
||||
DBG_PRINTF("[5] App\r\n");
|
||||
g_plat.log = log_printf;
|
||||
g_plat.tx_bin = dr_binary_tx_safe;
|
||||
@@ -2292,9 +2305,9 @@ int main(void)
|
||||
dr_piezo_init();
|
||||
DBG_PRINTF(" parser/piezo OK\r\n");
|
||||
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
/*--------------------------------------------------------------------------
|
||||
* Boot complete -> start power button state machine
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
*--------------------------------------------------------------------------*/
|
||||
DBG_PRINTF("\r\n========================================\r\n");
|
||||
DBG_PRINTF(" READY [%s]\r\n", SERIAL_NO);
|
||||
DBG_PRINTF("========================================\r\n\r\n");
|
||||
|
||||
@@ -51,9 +51,12 @@
|
||||
* - VBTFW0119 260615 jhChun
|
||||
* : Replaced all TMP235 temperature paths with IMU register direct-read temperature and removed legacy TMP235 build references.
|
||||
* : Unify both IMU direct-read and FIFO outputs as raw data in datasheet axis convention.
|
||||
* : Added mim? command (rim:, IMU FIFO-only 15 samples at 50 Hz).
|
||||
* - VBTFW0120 260615 jhChun : Add EMC mitigation logic for BLE link stability: extended supervision timeout and dynamic TX power control based on RSSI, RSSI silence, HVN latency, and TX queue congestion.
|
||||
* - VBTFW0121 260703 jhChun : Add mim? cammand.
|
||||
* - VBTFW0122 260708 jhChun : Prevent IMU FIFO reentry and add MCLK ready timeout.
|
||||
------------------------------------------------------------------------- */
|
||||
#define FIRMWARE_VERSION "VBTFW0120"
|
||||
#define FIRMWARE_VERSION "VBTFW0122"
|
||||
|
||||
/*==============================================================================
|
||||
* Data Length Constants
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf_gpio.h"
|
||||
#include "../piezo/piezo_config.h"
|
||||
|
||||
/*==============================================================================
|
||||
* PIN CONFIGURATION
|
||||
@@ -73,8 +74,8 @@
|
||||
*============================================================================*/
|
||||
#define DR_ADC_SCLK_MHZ 8.6f /**< SPI bit-bang SCLK frequency */
|
||||
#define DR_ADC_CLOCKS_PER_SAMPLE 16 /**< ADC121S051: 16 SCLK per sample */
|
||||
#define DR_ADC_ECHO_SAMPLES_MAX 119 /**< Maximum samples */
|
||||
#define DR_ADC_ECHO_SAMPLES_DEFAULT 100 /**< Default samples */
|
||||
#define DR_ADC_ECHO_SAMPLES_MAX PIEZO_CONFIG_NUM_SAMPLES_MAX /**< Maximum samples */
|
||||
#define DR_ADC_ECHO_SAMPLES_DEFAULT PIEZO_CONFIG_NUM_SAMPLES_DEFAULT /**< Default samples */
|
||||
#define DR_ADC_SAMPLE_INTERVAL_US 1.86f /**< 16 / 8.6MHz = 1.86us per sample */
|
||||
#define DR_ADC_SOUND_SPEED_MM_US 1.54f /**< Sound speed in tissue (mm/us) */
|
||||
|
||||
|
||||
@@ -183,6 +183,11 @@ void battery_event_handler(nrf_drv_saadc_evt_t const * p_event)
|
||||
low_battery_check = false;
|
||||
safety_batt_mv = batt_lvl_in_milli_volt_1;
|
||||
|
||||
if (imu_fifo_capture_is_active())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (imu_read_temperature_x100(NULL, &imu_temp_c) != 0)
|
||||
{
|
||||
DBG_PRINTF("[SAFETY] IMU temp read failed\r\n");
|
||||
|
||||
+15
@@ -101,6 +101,7 @@ int inv_imu_switch_on_mclk(struct inv_imu_device *s)
|
||||
int status = 0;
|
||||
uint8_t data;
|
||||
struct inv_imu_transport *t = (struct inv_imu_transport *)s;
|
||||
uint64_t start;
|
||||
|
||||
/* set IDLE bit only if it is not set yet */
|
||||
if (t->need_mclk_cnt == 0) {
|
||||
@@ -112,9 +113,23 @@ int inv_imu_switch_on_mclk(struct inv_imu_device *s)
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
start = inv_imu_get_time_us();
|
||||
|
||||
/* Check if MCLK is ready */
|
||||
do {
|
||||
status = inv_imu_read_reg(s, MCLK_RDY, 1, &data);
|
||||
|
||||
/* Bound the MCLK wait so a bad IMU/I2C state cannot hang the main loop. */
|
||||
if ((inv_imu_get_time_us() - start) >= 50000U)
|
||||
{
|
||||
status = 0;
|
||||
if (inv_imu_read_reg(s, PWR_MGMT0, 1, &data) == 0)
|
||||
{
|
||||
data &= ~PWR_MGMT0_IDLE_MASK;
|
||||
(void)inv_imu_write_reg(s, PWR_MGMT0, 1, &data);
|
||||
}
|
||||
return INV_ERROR_TIMEOUT;
|
||||
}
|
||||
} while ((status != 0) || !(data & MCLK_RDY_MCLK_RDY_MASK));
|
||||
} else {
|
||||
|
||||
|
||||
@@ -385,7 +385,7 @@ void imu_callback(inv_imu_sensor_event_t *event)
|
||||
* Flow:
|
||||
* 1) Check TWI initialization (first call only)
|
||||
* 2) Gyro config: +/-2000dps, 100Hz ODR (GYRO_CONFIG0 = 0x09)
|
||||
* 3) Accel config: +/-4g, 100Hz ODR (ACCEL_CONFIG0 = 0x29)
|
||||
* 3) Accel config: +/-4g, 100Hz ODR (ACCEL_CONFIG0 = 0x49)
|
||||
* 4) Power ON: accel+gyro low-noise mode (PWR_MGMT0 = 0x0F)
|
||||
* 5) Wait 80ms (gyro startup: min 45ms + margin)
|
||||
* 6) Read 14 consecutive bytes from TEMP_DATA1 (0x09) (temp 2 + accel 6 + gyro 6)
|
||||
@@ -407,6 +407,7 @@ extern const nrfx_twi_t m_twi_icm42670;
|
||||
#define IMU_TEMP_AVG_SAMPLES 4U
|
||||
|
||||
static bool s_direct_twi_ready = false;
|
||||
static bool s_fifo_capture_active = false;
|
||||
|
||||
static void imu_direct_twi_init_once(void)
|
||||
{
|
||||
@@ -447,9 +448,9 @@ int imu_read_direct(void)
|
||||
icm42670_twi_tx(IMU_I2C_ADDR, gyro_cfg, 2, false);
|
||||
}
|
||||
|
||||
/* Accel config: ACCEL_CONFIG0(0x21) = 0x29 -> +/-4g FSR, 100Hz ODR */
|
||||
/* Accel config: ACCEL_CONFIG0(0x21) = 0x49 -> +/-4g FSR, 100Hz ODR */
|
||||
{
|
||||
uint8_t accel_cfg[2] = { 0x21, 0x29 };
|
||||
uint8_t accel_cfg[2] = { 0x21, 0x49 };
|
||||
icm42670_twi_tx(IMU_I2C_ADDR, accel_cfg, 2, false);
|
||||
}
|
||||
|
||||
@@ -569,6 +570,11 @@ int imu_read_temperature_x100(uint16_t *temp_x100, float *temp_c)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (s_fifo_capture_active)
|
||||
{
|
||||
return -4;
|
||||
}
|
||||
|
||||
imu_direct_twi_init_once();
|
||||
|
||||
/* Power ON briefly so the temperature register is refreshed before reading. */
|
||||
@@ -619,6 +625,11 @@ int imu_read_temperature_x100(uint16_t *temp_x100, float *temp_c)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool imu_fifo_capture_is_active(void)
|
||||
{
|
||||
return s_fifo_capture_active;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* mtb? FIFO capture support
|
||||
*
|
||||
@@ -642,8 +653,6 @@ int imu_read_temperature_x100(uint16_t *temp_x100, float *temp_c)
|
||||
#define RIM_MAX_SAMPLE_BYTES (BLE_NUS_MAX_DATA_LEN - 2 - RIM_PACKET_HEADER_BYTES)
|
||||
#define RIM_SAMPLES_PER_PACKET (RIM_MAX_SAMPLE_BYTES / RIM_SAMPLE_SIZE_BYTES)
|
||||
|
||||
static bool s_fifo_capture_active = false;
|
||||
|
||||
static void imu_serif_make(struct inv_imu_serif *serif)
|
||||
{
|
||||
serif->context = 0;
|
||||
@@ -675,6 +684,14 @@ static void imu_fifo_power_off(void)
|
||||
s_fifo_capture_active = false;
|
||||
}
|
||||
|
||||
void imu_fifo_capture_disable(void)
|
||||
{
|
||||
if (s_fifo_capture_active)
|
||||
{
|
||||
imu_fifo_power_off();
|
||||
}
|
||||
}
|
||||
|
||||
int imu_fifo_capture_start(void)
|
||||
{
|
||||
int rc;
|
||||
@@ -693,8 +710,8 @@ int imu_fifo_capture_start(void)
|
||||
|
||||
rc |= inv_imu_set_accel_fsr(&icm_driver, ACCEL_CONFIG0_FS_SEL_4g);
|
||||
rc |= inv_imu_set_gyro_fsr(&icm_driver, GYRO_CONFIG0_FS_SEL_500dps);
|
||||
rc |= inv_imu_set_accel_frequency(&icm_driver, ACCEL_CONFIG0_ODR_50_HZ);
|
||||
rc |= inv_imu_set_gyro_frequency(&icm_driver, GYRO_CONFIG0_ODR_50_HZ);
|
||||
rc |= inv_imu_set_accel_frequency(&icm_driver, ACCEL_CONFIG0_ODR_50_HZ); // FIFO ODR Accel 50Hz Setting
|
||||
rc |= inv_imu_set_gyro_frequency(&icm_driver, GYRO_CONFIG0_ODR_50_HZ); // FIFO ODR Gyro 50Hz Setting
|
||||
rc |= inv_imu_set_accel_ln_bw(&icm_driver, IMU_FIFO_MTB_ACCEL_LN_BW);
|
||||
rc |= inv_imu_set_gyro_ln_bw(&icm_driver, IMU_FIFO_MTB_GYRO_LN_BW);
|
||||
rc |= inv_imu_disable_high_resolution_fifo(&icm_driver);
|
||||
@@ -707,8 +724,9 @@ int imu_fifo_capture_start(void)
|
||||
rc |= inv_imu_write_reg(&icm_driver, FIFO_CONFIG1, 1, &fifo_cfg1);
|
||||
}
|
||||
rc |= inv_imu_reset_fifo(&icm_driver);
|
||||
rc |= inv_imu_enable_accel_low_noise_mode(&icm_driver);
|
||||
rc |= inv_imu_enable_gyro_low_noise_mode(&icm_driver);
|
||||
rc |= inv_imu_enable_accel_low_noise_mode(&icm_driver); // FIFO Accel Low Noise Mode
|
||||
//rc |= inv_imu_enable_accel_low_power_mode(&icm_driver); // FIFO Accel Low Power Mode TEST
|
||||
rc |= inv_imu_enable_gyro_low_noise_mode(&icm_driver); // FIFO Gyro Low Noise Mode
|
||||
dr_sd_delay_ms(IMU_FIFO_ENABLE_SETTLE_MS);
|
||||
rc |= inv_imu_reset_fifo(&icm_driver);
|
||||
|
||||
@@ -961,9 +979,55 @@ int imu_fifo_capture_stop_and_send_rim(void)
|
||||
{
|
||||
DBG_PRINTF("[IMU FIFO] drain fail %d\r\n", rc);
|
||||
imu_fifo_send_rim_packets(0);
|
||||
imu_fifo_power_off();
|
||||
return rc;
|
||||
}
|
||||
|
||||
imu_fifo_send_rim_packets(packet_count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int imu_fifo_capture_wait_samples_and_send_rim(uint16_t target_samples, uint32_t timeout_ms)
|
||||
{
|
||||
int rc = 0;
|
||||
uint8_t count_raw[2] = {0};
|
||||
uint16_t packet_count = 0;
|
||||
uint32_t waited_ms = 0;
|
||||
const uint32_t poll_ms = 10U;
|
||||
|
||||
if (target_samples == 0U)
|
||||
{
|
||||
return imu_fifo_capture_stop_and_send_rim();
|
||||
}
|
||||
|
||||
if (!s_fifo_capture_active)
|
||||
{
|
||||
imu_fifo_send_rim_packets(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (waited_ms <= timeout_ms)
|
||||
{
|
||||
rc = inv_imu_read_reg(&icm_driver, FIFO_COUNTH, 2, count_raw);
|
||||
if (rc != 0)
|
||||
{
|
||||
DBG_PRINTF("[IMU FIFO] count read fail %d\r\n", rc);
|
||||
imu_fifo_send_rim_packets(0);
|
||||
imu_fifo_power_off();
|
||||
return rc;
|
||||
}
|
||||
|
||||
packet_count = (uint16_t)count_raw[0] | ((uint16_t)count_raw[1] << 8);
|
||||
if (packet_count > target_samples)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
dr_sd_delay_ms(poll_ms);
|
||||
waited_ms += poll_ms;
|
||||
}
|
||||
|
||||
rc = imu_fifo_capture_stop_and_send_rim();
|
||||
imu_fifo_capture_disable();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#ifndef _APP_RAW_H_
|
||||
#define _APP_RAW_H_
|
||||
#include <stdbool.h>
|
||||
#include "sdk_config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -105,6 +106,11 @@ int imu_read_direct(void);
|
||||
*/
|
||||
int imu_read_temperature_x100(uint16_t *temp_x100, float *temp_c);
|
||||
|
||||
/**
|
||||
* \brief Return true while IMU FIFO capture is active.
|
||||
*/
|
||||
bool imu_fifo_capture_is_active(void);
|
||||
|
||||
/**
|
||||
* \brief Start IMU internal FIFO capture for mtb? test flow.
|
||||
* Configures accel/gyro 100 Hz and flushes FIFO before capture.
|
||||
@@ -116,6 +122,18 @@ int imu_fifo_capture_start(void);
|
||||
*/
|
||||
int imu_fifo_capture_stop_and_send_rim(void);
|
||||
|
||||
/**
|
||||
* \brief Wait until at least target_samples FIFO records are available, then drain
|
||||
* FIFO and send rim: packets.
|
||||
* \return 0=success, negative=error
|
||||
*/
|
||||
int imu_fifo_capture_wait_samples_and_send_rim(uint16_t target_samples, uint32_t timeout_ms);
|
||||
|
||||
/**
|
||||
* \brief Stop IMU FIFO capture without sending rim: packets.
|
||||
*/
|
||||
void imu_fifo_capture_disable(void);
|
||||
|
||||
/*
|
||||
* mtb? / rim: binary layout (every BLE fragment)
|
||||
* [ 'r' 'i' 'm' ':' ] [ total_sample_count u16 BE ] [ 12 * total_sample_count bytes ... ]
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf_gpio.h"
|
||||
#include "piezo_config.h"
|
||||
|
||||
/*==============================================================================
|
||||
* Power control pin (+/-20V DC/DC converter)
|
||||
@@ -64,9 +65,9 @@
|
||||
* Configuration
|
||||
*============================================================================*/
|
||||
#define DR_PIEZO_FREQ_HZ 2100000 /**< Target frequency (set PIEZO_FREQ_MHZ in .c) */
|
||||
#define DR_PIEZO_DEFAULT_CYCLES 5 /**< Default burst cycles */
|
||||
#define DR_PIEZO_MIN_CYCLES 3
|
||||
#define DR_PIEZO_MAX_CYCLES 7
|
||||
#define DR_PIEZO_DEFAULT_CYCLES PIEZO_CONFIG_CYCLES_DEFAULT /**< Default burst cycles */
|
||||
#define DR_PIEZO_MIN_CYCLES PIEZO_CONFIG_CYCLES_MIN
|
||||
#define DR_PIEZO_MAX_CYCLES PIEZO_CONFIG_CYCLES_MAX
|
||||
#define DR_PIEZO_MUX_SETTLING_US 1300 /**< MUX settling delay (us) */
|
||||
|
||||
/*==============================================================================
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*==============================================================================
|
||||
* piezo_config.h - Shared piezo measurement parameter limits/defaults
|
||||
*============================================================================*/
|
||||
#ifndef PIEZO_CONFIG_H
|
||||
#define PIEZO_CONFIG_H
|
||||
|
||||
/* Frequency option protocol:
|
||||
* 0=1.8MHz, 1=2.1MHz, 2=2.0MHz, 3=1.7MHz, 4=2.2MHz, 9=1.9MHz
|
||||
*/
|
||||
#define PIEZO_CONFIG_FREQ_OPTION_DEFAULT 1U
|
||||
|
||||
#define PIEZO_CONFIG_CYCLES_MIN 3U
|
||||
#define PIEZO_CONFIG_CYCLES_MAX 7U
|
||||
#define PIEZO_CONFIG_CYCLES_DEFAULT 7U
|
||||
|
||||
#define PIEZO_CONFIG_AVERAGING_MIN 1U
|
||||
#define PIEZO_CONFIG_AVERAGING_MAX 10U
|
||||
#define PIEZO_CONFIG_AVERAGING_DEFAULT 10U
|
||||
|
||||
#define PIEZO_CONFIG_DELAY_US_MIN 0U
|
||||
#define PIEZO_CONFIG_DELAY_US_MAX 50U
|
||||
#define PIEZO_CONFIG_DELAY_US_DEFAULT 10U
|
||||
|
||||
#define PIEZO_CONFIG_NUM_SAMPLES_MIN 80U
|
||||
#define PIEZO_CONFIG_NUM_SAMPLES_MAX 118U
|
||||
#define PIEZO_CONFIG_NUM_SAMPLES_DEFAULT 100U
|
||||
|
||||
|
||||
#endif /* PIEZO_CONFIG_H */
|
||||
+11
@@ -32,6 +32,8 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA.
|
||||
#include "system_nrf52_approtect.h"
|
||||
|
||||
#define __SYSTEM_CLOCK_64M (64000000UL)
|
||||
#define POWER_HOLD_PIN 8UL
|
||||
#define POWER_HOLD_PIN_MASK (1UL << POWER_HOLD_PIN)
|
||||
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
@@ -89,6 +91,15 @@ void SystemCoreClockUpdate(void)
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* Keep the external power latch asserted immediately after reset. */
|
||||
NRF_P0->OUTSET = POWER_HOLD_PIN_MASK;
|
||||
NRF_P0->DIRSET = POWER_HOLD_PIN_MASK;
|
||||
NRF_P0->PIN_CNF[POWER_HOLD_PIN] =
|
||||
(GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos) |
|
||||
(GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) |
|
||||
(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
|
||||
(GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) |
|
||||
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
|
||||
/* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product
|
||||
Specification to see which one). */
|
||||
#if defined (ENABLE_SWO) && defined(CLOCK_TRACECONFIG_TRACEMUX_Pos)
|
||||
|
||||
@@ -76,6 +76,8 @@ static void dfu_observer(nrf_dfu_evt_type_t evt_type)
|
||||
break;
|
||||
case NRF_DFU_EVT_DFU_STARTED:
|
||||
break;
|
||||
case NRF_DFU_EVT_DFU_COMPLETED:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
+11
@@ -32,6 +32,8 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA.
|
||||
#include "system_nrf52_approtect.h"
|
||||
|
||||
#define __SYSTEM_CLOCK_64M (64000000UL)
|
||||
#define POWER_HOLD_PIN 8UL
|
||||
#define POWER_HOLD_PIN_MASK (1UL << POWER_HOLD_PIN)
|
||||
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
@@ -89,6 +91,15 @@ void SystemCoreClockUpdate(void)
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* Keep the external power latch asserted immediately after reset. */
|
||||
NRF_P0->OUTSET = POWER_HOLD_PIN_MASK;
|
||||
NRF_P0->DIRSET = POWER_HOLD_PIN_MASK;
|
||||
NRF_P0->PIN_CNF[POWER_HOLD_PIN] =
|
||||
(GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos) |
|
||||
(GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) |
|
||||
(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
|
||||
(GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) |
|
||||
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
|
||||
/* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product
|
||||
Specification to see which one). */
|
||||
#if defined (ENABLE_SWO) && defined(CLOCK_TRACECONFIG_TRACEMUX_Pos)
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@
|
||||
<LExpSel>0</LExpSel>
|
||||
</OPTXL>
|
||||
<OPTFL>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
|
||||
@@ -141,6 +141,7 @@
|
||||
// <i> to immediately transfer a new application if it wishes.
|
||||
|
||||
#ifndef NRF_BL_DFU_CONTINUATION_TIMEOUT_MS
|
||||
/* Time to wait for an expected DFU update immediately after entering DFU mode from the application. (10 seconds) */
|
||||
#define NRF_BL_DFU_CONTINUATION_TIMEOUT_MS 10000
|
||||
#endif
|
||||
|
||||
@@ -150,7 +151,8 @@
|
||||
// <i> If 0, no inactivity timer will be used. Values 1-99 are invalid.
|
||||
|
||||
#ifndef NRF_BL_DFU_INACTIVITY_TIMEOUT_MS
|
||||
#define NRF_BL_DFU_INACTIVITY_TIMEOUT_MS 120000
|
||||
/* Time to stay in DFU mode after the last DFU activity before returning to the application. (60 seconds) */
|
||||
#define NRF_BL_DFU_INACTIVITY_TIMEOUT_MS 60000
|
||||
#endif
|
||||
|
||||
// </h>
|
||||
|
||||
Reference in New Issue
Block a user