Exemplo n.º 1
0
/**@brief Function to handle system events from the SoftDevice.
 *
 * @details     This function should be dispatched system events if any of the modules used by
 *              the application rely on FStorage. Examples include @ref Peer Manager and
 *              @ref Flash Data Storage.
 *
 * @param[in]   sys_evt     System Event received.
 */
void fs_sys_event_handler(uint32_t sys_evt)
{
    fs_cmd_t const * const p_cmd = &m_cmd_queue.cmd[m_cmd_queue.rp];
    
    if (m_flags & FS_FLAG_PROCESSING)
    {
        /** A flash operation was initiated by this module.
         *  Handle its result. */
        switch (sys_evt)
        {
            case NRF_EVT_FLASH_OPERATION_SUCCESS:
                on_operation_success(p_cmd);
                break;

            case NRF_EVT_FLASH_OPERATION_ERROR:
                on_operation_failure(p_cmd);
                break;
        }
    }
    else if ((m_flags & FS_FLAG_FLASH_REQ_PENDING))
    {
        /** A flash operation was initiated outside this module.
         *  We have now receveid a callback which indicates it has
         *  finished. Clear the FS_FLAG_FLASH_REQ_PENDING flag. */
         m_flags &= ~FS_FLAG_FLASH_REQ_PENDING;
    }

    // Resume processing the queue, if necessary.
    queue_process();
}
Exemplo n.º 2
0
void fs_sys_event_handler(uint32_t sys_evt)
{
    fs_op_t * const p_op = &m_queue.op[m_queue.rp];
    
    if (m_flags & FS_FLAG_PROCESSING)
    {
        // A flash operation was initiated by this module. Handle the result.
        switch (sys_evt)
        {
            case NRF_EVT_FLASH_OPERATION_SUCCESS:
                on_operation_success(p_op);
                break;

            case NRF_EVT_FLASH_OPERATION_ERROR:
                on_operation_failure(p_op);
                break;
        }
    }
    else if ((m_flags & FS_FLAG_FLASH_REQ_PENDING))
    {
        // A flash operation was initiated outside this module.
        // A callback which indicates that it has finished was received.
        m_flags &= ~FS_FLAG_FLASH_REQ_PENDING;

        // If there are any elements left in the queue, set FS_FLAG_PROCESSING.
        if (m_queue.count > 0)
        {
           m_flags |= FS_FLAG_PROCESSING;
        }
    }

    // Resume processing the queue, if necessary.
    queue_process();
}