/* Copyright (c) 2013 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.
*
*/
#include "pstorage.h"
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "nordic_common.h"
#include "nrf_error.h"
#include "nrf_assert.h"
#include "nrf.h"
#include "nrf_soc.h"
#include "app_util.h"
#include "app_error.h"
#define INVALID_OPCODE 0x00 /**< Invalid op code identifier. */
#define SOC_MAX_WRITE_SIZE PSTORAGE_FLASH_PAGE_SIZE /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API. */
#define RAW_MODE_APP_ID (PSTORAGE_NUM_OF_PAGES + 1) /**< Application id for raw mode. */
#if defined(NRF52)
#define SD_CMD_MAX_TRIES 1000 /**< Number of times to try a softdevice flash operatoion, specific for nRF52 to account for longest time of flash page erase*/
#else
#define SD_CMD_MAX_TRIES 3 /**< Number of times to try a softdevice flash operation when the @ref NRF_EVT_FLASH_OPERATION_ERROR sys_evt is received. */
#endif /* defined(NRF52) */
#define MASK_TAIL_SWAP_DONE (1 << 0) /**< Flag for checking if the tail restore area has been written to swap page. */
#define MASK_SINGLE_PAGE_OPERATION (1 << 1) /**< Flag for checking if command is a single flash page operation. */
#define MASK_MODULE_INITIALIZED (1 << 2) /**< Flag for checking if the module has been initialized. */
#define MASK_FLASH_API_ERR_BUSY (1 << 3) /**< Flag for checking if flash API returned NRF_ERROR_BUSY. */
/**
* @defgroup api_param_check API Parameters check macros.
*
* @details Macros that verify parameters passed to the module in the APIs. These macros
* could be mapped to nothing in final code versions to save execution and size.
*
* @{
*/
/**@brief Check if the input pointer is NULL, if so it returns NRF_ERROR_NULL.
*/
#define NULL_PARAM_CHECK(PARAM) \
if ((PARAM) == NULL) \
{ \
return NRF_ERROR_NULL; \
}
/**@brief Verifies that the module identifier supplied by the application is within permissible
* range.
*/
#define MODULE_ID_RANGE_CHECK(ID) \
if ((((ID)->module_id) >= PSTORAGE_NUM_OF_PAGES) || \
(m_app_table[(ID)->module_id].cb == NULL)) \
{ \
return NRF_ERROR_INVALID_PARAM; \
}
/**@brief Verifies that the block identifier supplied by the application is within the permissible
* range.
*/
#define BLOCK_ID_RANGE_CHECK(ID) \
if (((ID)->block_id) >= (m_app_table[(ID)->module_id].base_id + \
(m_app_table[(ID)->module_id].block_count * MODULE_BLOCK_SIZE(ID)))) \
{ \
return NRF_ERROR_INVALID_PARAM; \
}
/**@brief Verifies that the block size requested by the application can be supported by the module.
*/
#define BLOCK_SIZE_CHECK(X) \
if (((X) > PSTORAGE_MAX_BLOCK_SIZE) || ((X) < PSTORAGE_MIN_BLOCK_SIZE)) \
{ \
return NRF_ERROR_INVALID_PARAM; \
}
/**@brief Verifies the block size requested by the application in registration API.
*/
#define BLOCK_COUNT_CHECK(COUNT, SIZE) \
if (((COUNT) == 0) || \
((m_next_page_addr + ((COUNT) *(SIZE)) > PSTORAGE_SWAP_ADDR))) \
{ \
return NRF_ERROR_INVALID_PARAM; \
}
/**@brief Verifies the size parameter provided by the application in API.
*/
#define SIZE_CHECK(ID, SIZE) \
if(((SIZE) == 0) || ((SIZE) > MODULE_BLOCK_SIZE(ID))) \
{ \
return NRF_ERROR_INVALID_PARAM; \
}
/**@brief Verifies the offset parameter provided by the application in API.
*/
#define OFFSET_CHECK(ID, OFFSET, SIZE) \
if(((SIZE) + (OFFSET)) > MODULE_BLOCK_SIZE(ID)) \
{ \
return NRF_ERROR_INVALID_PARAM; \
}
#ifdef PSTORAGE_RAW_MODE_ENABLE
/**@brief Verifies the module identifier supplied by the application.
*/
#define MODULE_RAW_HANDLE_CHECK(ID) \
if ((((ID)->module_id) != RAW_MODE_APP_ID)) \
{ \
return NRF_ERROR_INVALID_PARAM; \
}
#endif // PSTORAGE_RAW_MODE_ENABLE
/**@} */
/**@brief Verify module's initialization status.
*
* @details Verify module's initialization status. Returns NRF_ERROR_INVALID_STATE when a
* module API is called without initializing the module.
*/
#define VERIFY_MODULE_INITIALIZED() \
do \
{ \
if (!(m_flags & MASK_MODULE_INITIALIZED)) \
{ \
return NRF_ERROR_INVALID_STATE; \
} \
} while(0)
/**@brief Macro to fetch the block size registered for the module. */
#define MODULE_BLOCK_SIZE(ID) (m_app_table[(ID)->module_id].block_size)
/**@brief Main
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
NRF52832蓝牙芯片通过I2C接口读取mpu9250运动传感器数据软件例程源码,通过硬件IIC(TWI)接口读取MPU9250的原始数据,包括X,Y,Z三个轴的加速度,各个轴的角速度以及地磁传感器的值。
资源推荐
资源详情
资源评论
收起资源包目录
NRF52832蓝牙芯片通过I2C接口读取mpu9250运动传感器数据软件例程源码.zip (250个子文件)
pstorage.c 59KB
fds.c 58KB
dfu_transport_ble.c 45KB
app_timer.c 38KB
app_timer_ble_gzll.c 37KB
mem_manager.c 35KB
nrf_drv_twi.c 31KB
hci_transport.c 31KB
app_pwm.c 30KB
nrf_drv_twis.c 29KB
dfu_dual_bank.c 28KB
dfu_single_bank.c 26KB
nrf_drv_uart.c 25KB
spi_5W_master.c 22KB
pstorage_nosd.c 21KB
bsp.c 21KB
nrf_drv_spi.c 20KB
nrf_drv_gpiote.c 18KB
nrf_drv_saadc.c 17KB
pstorage_raw.c 16KB
app_gpiote_fast_detect.c 16KB
nrf_drv_clock.c 14KB
nrf_drv_spis.c 13KB
bootloader.c 13KB
twi_sw_master.c 13KB
system_nrf52.c 13KB
fstorage.c 13KB
app_twi.c 12KB
hci_slip.c 12KB
nrf_drv_ppi.c 12KB
nrf_mpu9250_twi_drv.c 11KB
nrf_drv_i2s.c 11KB
bootloader_util.c 11KB
nrf_drv_pwm.c 11KB
dfu_transport_serial.c 10KB
twi_hw_master.c 10KB
nrf_log.c 10KB
dfu_init_template_signing.c 10KB
nrf_drv_rtc.c 9KB
nrf_drv_swi.c 9KB
bsp_btn_ble.c 9KB
nrf_drv_timer.c 9KB
app_scheduler_serconn.c 8KB
ble_flash.c 8KB
app_gpiote.c 8KB
hci_mem_pool.c 8KB
app_scheduler.c 7KB
nrf_drv_adc.c 7KB
dfu_init_template.c 7KB
dfu_app_handler.c 7KB
app_timer_freertos.c 7KB
app_timer_rtx.c 7KB
app_uart_fifo.c 7KB
led_softblink.c 6KB
app_button.c 6KB
low_power_pwm.c 6KB
nrf_drv_rng.c 6KB
radio_config.c 6KB
sha256.c 6KB
app_simple_timer.c 6KB
sdio.c 5KB
nrf_drv_common.c 5KB
nrf_drv_comp.c 5KB
bootloader_settings.c 5KB
nrf_drv_pdm.c 5KB
nrf_drv_qdec.c 5KB
sdk_mapped_flags.c 5KB
app_fifo.c 4KB
nrf_drv_lpcomp.c 4KB
app_mailbox.c 4KB
app_uart.c 4KB
main.c 4KB
app_error.c 4KB
slip.c 4KB
nrf_drv_wdt.c 3KB
ecc.c 3KB
nrf_nvmc.c 3KB
hardfault_handler_iar.c 3KB
hardfault_handler_iar.c 2KB
nrf_adc.c 2KB
nrf_nvic.c 2KB
nrf_ic_info.c 2KB
hardfault_handler_gcc.c 2KB
retarget.c 2KB
hardfault_handler_keil.c 2KB
sensorsim.c 2KB
hardfault_handler_gcc.c 2KB
nrf_ecb.c 2KB
app_error_weak.c 2KB
hardfault_handler_keil.c 2KB
app_util_platform.c 1KB
hardfault_implementation.c 1KB
nrf_saadc.c 1KB
app_timer_appsh.c 1KB
app_trace.c 977B
crc16.c 917B
nrf_assert.c 893B
crc32.c 892B
nrf_delay.c 747B
nrf_soc.c 600B
共 250 条
- 1
- 2
- 3
资源评论
GJZGRB
- 粉丝: 2004
- 资源: 7116
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 目标检测-零售食品LOGO检测数据集-40000张图-+对应VOC-COCO-YOLO三种格式标签+数据集划分脚本
- 目标检测-零售食品LOGO检测数据集-30000张图-+对应VOC-COCO-YOLO三种格式标签+数据集划分脚本
- 目标检测-零售食品LOGO检测数据集-20000张图-+对应VOC-COCO-YOLO三种格式标签+数据集划分脚本
- 目标检测-零售食品LOGO检测数据集-10000张图-+对应VOC-COCO-YOLO三种格式标签+数据集划分脚本
- 基于GUI+MYSQL+JAVA图书管理系统文档说明+源码(高分大作业项目).zip
- 基于Qt使用C++实现图书管理系统源码+数据库(95分以上).zip
- 基于GUI+MYSQL+JAVA票务管理系统文档介绍+源码+数据库(高分大作业).zip
- 优先编码器除法电微分运算电路 全加器函数发生电路等电路经典Multisim仿真实验源文件合集(25个).zip
- 2331308JS课堂案例.zip
- STM32H750VBT6单片机最小系统开发板AD设计硬件(原理图+PCB+3D封装库)工程文件.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功