/**@brief Function to process the current element in the queue and return the result. * * @retval NRF_SUCCESS Success. * @retval NRF_ERROR_FORBIDDEN Error. Undefined command. * @retval Any error returned by the SoftDevice flash API. */ static uint32_t queue_process_impl(void) { uint32_t ret; fs_cmd_t const * const p_cmd = &m_cmd_queue.cmd[m_cmd_queue.rp]; switch (p_cmd->op_code) { case FS_OP_STORE: ret = store_execute(p_cmd); break; case FS_OP_ERASE: ret = erase_execute(p_cmd); break; case FS_OP_NONE: ret = NRF_SUCCESS; break; default: ret = NRF_ERROR_FORBIDDEN; break; } return ret; }
/**@brief Function to process the current element in the queue and return the result. * * @retval NRF_SUCCESS Success. * @retval NRF_ERROR_FORBIDDEN Error. Undefined command. * @retval Any error returned by the SoftDevice flash API. */ static ret_code_t queue_process(void) { ret_code_t ret; fs_cmd_t * const p_cmd = &m_cmd_queue.cmd[m_cmd_queue.rp]; if (m_cmd_queue.count > 0) { switch (p_cmd->op_code) { case FS_OP_STORE: ret = store_execute(p_cmd); break; case FS_OP_ERASE: ret = erase_execute(p_cmd); break; default: ret = NRF_ERROR_INTERNAL; break; } } else { ret = NRF_SUCCESS; } /** There is ongoing flash-operation which was not * initiated by fstorage. */ if (ret == NRF_ERROR_BUSY) { // Wait for a system callback. m_flags |= FS_FLAG_FLASH_REQ_PENDING; // Stop processing the queue. m_flags &= ~FS_FLAG_PROCESSING; ret = NRF_SUCCESS; } else if (ret != NRF_SUCCESS) { // Another error has occurred. app_notify(p_cmd, ret); } return ret; }
// Processes the current element in the queue. If the queue is empty, does nothing. static void queue_process(void) { uint32_t ret; fs_op_t * const p_op = &m_queue.op[m_queue.rp]; if (m_queue.count > 0) { switch (p_op->op_code) { case FS_OP_STORE: ret = store_execute(p_op); break; case FS_OP_ERASE: ret = erase_execute(p_op); break; default: ret = FS_ERR_INTERNAL; break; } // There is a pending flash operation which was not initiated by this module. // Stop processing the queue and wait for a system event. if (ret == NRF_ERROR_BUSY) { m_flags &= ~FS_FLAG_PROCESSING; m_flags |= FS_FLAG_FLASH_REQ_PENDING; } else if (ret != NRF_SUCCESS) { // An error has occurred. send_event(p_op, FS_ERR_INTERNAL); } else { // Operation is executing. } } }