微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI无线射频设计 > CC1310 Flash写操作NVS_write函数

CC1310 Flash写操作NVS_write函数

时间:12-23 整理:3721RD 点击:

 关于CC1310 Flash操作的问题:

使用API函数NVS_write写入时长度只允许是4的倍数吗?这个在哪可以修改吗?为什么?

目前需要其他长度字节写入,每次都要转换为4的倍数,浪费了Flash空间。

通过NVS_write()函数来写入,函数的第2个参数为起始地址,并且必须4字节对齐。

和芯片硬件结构有关系的!有的是单字节,有的是双字节,cortex m系列内部

flash通常4字节写。

/*!
 * @brief Write data to an NVS region.
 *
 * @param handle A handle returned from NVS_open()
 *
 * @param offset The byte offset into the NVS region to start
 * writing.
 *
 * @param buffer A buffer containing data to write to
 * the NVS region.
 *
 * @param bufferSize The size of the buffer (number of bytes to write).
 *
 * @param flags Write flags (NVS_WRITE_ERASE, NVS_WRITE_PRE_VERIFY,
 * NVS_WRITE_POST_VERIFY).
 *
 * @return NVS_STATUS_SUCCESS Success.
 * @return NVS_STATUS_ERROR If the internal flash write operation
 * failed, or if 'NVS_WRITE_POST_VERIFY'
 * was requested and the destination flash
 * range does not match the source
 * 'buffer' data.
 * @return NVS_STATUS_INV_OFFSET If 'offset + size' exceed the size
 * of the region.
 * @return NVS_STATUS_INV_WRITE If 'NVS_WRITE_PRE_VERIFY' is requested
 * and the destination flash address range
 * cannot be change to the values desired.
 * @return NVS_STATUS_INV_ALIGNMENT If 'NVS_WRITE_ERASE' is requested
 * and 'offset' is not aligned on
 * a sector bondary
 *
 * @remark This call may region to ensure atomic access to the region.
 */
extern int_fast16_t NVS_write(NVS_Handle handle, size_t offset, void *buffer,
                     size_t bufferSize, uint_fast16_t flags);


没有 这种要求吧DD

有的,为啥咱们的.h不一样

/*!
* @brief Write data to an NVS block.
*
* @param handle A handle returned from NVS_open()
*
* @param offset The byte offset into the NVS block to start
* writing. offset must be 4-byte aligned.
*
* @param buffer A buffer conntaining data to write to
* the NVS block. If buffer is NULL, the block
* will be erased. A non-NULL buffer must be
* aligned on a 4-byte boundary.
*
* @param bufferSize The size of the buffer (number of bytes to write).
* bufferSize must be a multiple of 4 bytes.
*
* @param flags Write flags (NVS_WRITE_EXCLUSIVE, NVS_WRITE_ERASE,
* NVS_WRITE_VALIDATE).
*
* @return NVS_SOK Success.
* @return NVS_EOFFSET The location and size to write to does not
* lie completely within the NVS block.
* @return NVS_EALIGN The offset or bufferSize is not 4-byte aligned.
* @return NVS_ALREADYWRITTEN
* The region to write to (the bufferSize region
* starting at offset into the block) has already
* been written to since the last erase, and
* NVS_WRITE_EXCLUSIVE is set in the flags parameter.
*
* @remark This call may block to ensure atomic access to the block.
*/
extern int NVS_write(NVS_Handle handle, size_t offset, void *buffer,
size_t bufferSize, unsigned int flags);

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top