驱动c文件模板

/**
 *!
 * \file        b_drv_xxxx.c
 * \version     v0.0.1
 * \date        2023/03/25
 * \author      babyos
 *******************************************************************************
 * @attention
 *
 * Copyright (c) 2023 babyos
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *******************************************************************************
 */

/*Includes ----------------------------------------------*/
#include "drivers/inc/b_drv_xxxx.h"

/**
 * \addtogroup B_DRIVER
 * \{
 */

/**
 * \addtogroup XXXX
 * \{
 */

/**
 * \defgroup XXXX_Private_TypesDefinitions
 * \{
 */

/**
 * \}
 */

/**
 * \defgroup XXXX_Private_Defines
 * \{
 */
#define DRIVER_NAME XXXX
/**
 * \}
 */

/**
 * \defgroup XXXX_Private_Macros
 * \{
 */

/**
 * \}
 */

/**
 * \defgroup XXXX_Private_Variables
 * \{
 */
bDRIVER_HALIF_TABLE(bXXXX_HalIf_t, DRIVER_NAME);

static bXXXXPrivate_t bXXXXRunInfo[bDRIVER_HALIF_NUM(bXXXX_HalIf_t, DRIVER_NAME)];

/**
 * \}
 */

/**
 * \defgroup XXXX_Private_FunctionPrototypes
 * \{
 */

/**
 * \}
 */

/**
 * \defgroup XXXX_Private_Functions
 * \{
 */

static int _bXXXXWrite(bDriverInterface_t *pdrv, uint32_t off, uint8_t *pbuf, uint32_t len)
{
    bDRIVER_GET_HALIF(_if, bXXXX_HalIf_t, pdrv);
    bDRIVER_GET_PRIVATE(_priv, bXXXXPrivate_t, pdrv);
    return len;
}

static int _bXXXXRead(bDriverInterface_t *pdrv, uint32_t off, uint8_t *pbuf, uint32_t len)
{
    bDRIVER_GET_HALIF(_if, bXXXX_HalIf_t, pdrv);
    bDRIVER_GET_PRIVATE(_priv, bXXXXPrivate_t, pdrv);
    return len;
}

static int _bXXXXCtl(bDriverInterface_t *pdrv, uint8_t cmd, void *param)
{
    bDRIVER_GET_PRIVATE(_priv, bXXXXPrivate_t, pdrv);
    return 0;
}

static int _bXXXXOpen(bDriverInterface_t *pdrv)
{
    bDRIVER_GET_HALIF(_if, bXXXX_HalIf_t, pdrv);
    return 0;
}

static int _bXXXXClose(bDriverInterface_t *pdrv)
{
    bDRIVER_GET_HALIF(_if, bXXXX_HalIf_t, pdrv);
    return 0;
}

/**
 * \}
 */

/**
 * \addtogroup XXXX_Exported_Functions
 * \{
 */
int bXXXX_Init(bDriverInterface_t *pdrv)
{
    bDRIVER_STRUCT_INIT(pdrv, DRIVER_NAME, bXXXX_Init);
    pdrv->read  = _bXXXXRead;
    pdrv->write = _bXXXXWrite;
    pdrv->ctl   = _bXXXXCtl;
    pdrv->open  = _bXXXXOpen;
    pdrv->close = _bXXXXClose;
    pdrv->_private._p = &bXXXXRunInfo[pdrv->drv_no];
    return 0;
}

bDRIVER_REG_INIT(B_DRIVER_XXXX, bXXXX_Init);

/**
 * \}
 */

/**
 * \}
 */

/**
 * \}
 */

/************************ Copyright (c) 2023 babyos*****END OF FILE****/