fs_x_ucos_ii.c

来自「此为整套uC/FS程序」· C语言 代码 · 共 95 行

C
95
字号
/*
*********************************************************************************************************
*                                             Micrium, Inc.
*                                         949 Crestview Circle
*                                        Weston,  FL 33327-1848
*
*                                         OS Layer for uC/FS
*
*                                   (c) Copyright 2003, Micrium, Inc.
*                                          All rights reserved.
*
* Filename    : FS_X_ucOS_ii.c
* Programmers : Jean J. Labrosse
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                            INCLUDE FILES
*********************************************************************************************************
*/

#include  "FS_Int.h"
#include  "FS_OS.h"
#include  "ucos_ii.h"

/*
*********************************************************************************************************
*                                         MACROS, DEFAULTS
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                       LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/

static  OS_EVENT  **FS_SemPtrs;

/*
*********************************************************************************************************
*                                         Initialize OS Resources
*********************************************************************************************************
*/

void  FS_X_OS_Init (unsigned nlocks)
{
    unsigned    i;
    OS_EVENT  **p_sem;


    FS_SemPtrs  = (OS_EVENT  **)FS_AllocZeroed(nlocks * sizeof(OS_EVENT *));
    p_sem       =  FS_SemPtrs;

    for(i = 0; i < nlocks; i++) {
       *p_sem   = OSSemCreate(1);
        p_sem  += 1;
    }
}

/*
*********************************************************************************************************
*                                         Unlock a file system operation
*********************************************************************************************************
*/

void  FS_X_OS_Unlock (unsigned index)
{
    OS_EVENT  *p_sem;


    p_sem    = *(FS_SemPtrs + index);
    OSSemPost(p_sem);
}

/*
*********************************************************************************************************
*                                         Unlock a file system operation
*********************************************************************************************************
*/

void  FS_X_OS_Lock (unsigned index)
{
    INT8U       err;
    OS_EVENT  *p_sem;


    p_sem    = *(FS_SemPtrs + index);
    OSSemPend(p_sem, 0, &err);
}


/*************************** End of file ****************************/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?