upgrade to sdk12

This commit is contained in:
Shuanglei Tao
2024-12-17 00:45:30 +08:00
parent 3d7db302aa
commit 75b5b9105a
1934 changed files with 201917 additions and 194447 deletions

View File

@@ -1,13 +1,41 @@
/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
/**
* Copyright (c) 2012 - 2017, 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.
*
*/
#include "ble_flash.h"
@@ -42,7 +70,7 @@ uint16_t ble_flash_crc16_compute(uint8_t * p_data, uint16_t size, uint16_t * p_c
/**@brief Function for erasing a page in flash.
*
*
* @param[in] p_page Pointer to first word in page to be erased.
*/
static void flash_page_erase(uint32_t * p_page)
@@ -89,7 +117,7 @@ static void flash_word_unprotected_write(uint32_t * p_address, uint32_t value)
// Do nothing.
}
*p_address = value;
// Wait flash write to finish
while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
{
@@ -237,7 +265,7 @@ uint32_t ble_flash_page_read(uint8_t page_num, uint32_t * p_out_array, uint8_t *
uint16_t calc_crc;
uint32_t tmp;
p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_num);
p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_num);
p_curr_addr = p_page;
// Check if block is valid

View File

@@ -1,13 +1,41 @@
/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
/**
* Copyright (c) 2012 - 2017, 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.
*
*/
/** @file
@@ -34,20 +62,24 @@
#include <stdbool.h>
#include "nrf.h"
#ifdef __cplusplus
extern "C" {
#endif
#define BLE_FLASH_PAGE_SIZE ((uint16_t)NRF_FICR->CODEPAGESIZE) /**< Size of one flash page. */
#define BLE_FLASH_MAGIC_NUMBER 0x45DE0000 /**< Magic value to identify if flash contains valid data. */
#define BLE_FLASH_EMPTY_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */
/**@brief Macro for getting the end of the flash available for application.
*
* @details The result flash page number indicates the end boundary of the flash available
* to the application. If a bootloader is used, the end will be the start of the
* bootloader region. Otherwise, the end will be the size of the flash.
*
* @details The result flash page number indicates the end boundary of the flash available
* to the application. If a bootloader is used, the end will be the start of the
* bootloader region. Otherwise, the end will be the size of the flash.
*/
#define BLE_FLASH_PAGE_END \
((NRF_UICR->BOOTLOADERADDR != BLE_FLASH_EMPTY_MASK) \
? (NRF_UICR->BOOTLOADERADDR / BLE_FLASH_PAGE_SIZE) \
((NRF_UICR->NRFFW[0] != BLE_FLASH_EMPTY_MASK) \
? (NRF_UICR->NRFFW[0] / BLE_FLASH_PAGE_SIZE) \
: NRF_FICR->CODESIZE)
/**@brief Function for erasing the specified flash page, and then writes the given data to this page.
@@ -66,12 +98,12 @@ uint32_t ble_flash_page_write(uint8_t page_num, uint32_t * p_in_array, uint8_t w
/**@brief Function for reading data from flash to RAM.
*
* @param[in] page_num Page number to read.
* @param[out] p_out_array Pointer to a RAM area where the found data will be written.
* @param[out] p_out_array Pointer to a RAM area where the found data will be written.
* This area has to be 32 bits aligned.
* @param[out] p_word_count Number of 32 bits words read.
*
* @return NRF_SUCCESS on successful upload, NRF_ERROR_NOT_FOUND if no valid data has been found
* in flash (first 32 bits not equal to the MAGIC_NUMBER+CRC).
* in flash (first 32 bits not equal to the MAGIC_NUMBER + CRC).
*/
uint32_t ble_flash_page_read(uint8_t page_num, uint32_t * p_out_array, uint8_t * p_word_count);
@@ -118,7 +150,7 @@ uint32_t ble_flash_block_write(uint32_t * p_address, uint32_t * p_in_array, uint
uint32_t ble_flash_page_addr(uint8_t page_num, uint32_t ** pp_page_addr);
/**@brief Function for calculating a 16 bit CRC using the CRC-16-CCITT scheme.
*
*
* @param[in] p_data Pointer to data on which the CRC is to be calulated.
* @param[in] size Number of bytes on which the CRC is to be calulated.
* @param[in] p_crc Initial CRC value (if NULL, a preset value is used as the initial value).
@@ -137,6 +169,11 @@ uint16_t ble_flash_crc16_compute(uint8_t * p_data, uint16_t size, uint16_t * p_c
*/
void ble_flash_on_radio_active_evt(bool radio_active);
#ifdef __cplusplus
}
#endif
#endif // BLE_FLASH_H__
/** @} */