From f6616d570865fce92ae7a669611e495038e9c111 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 17 Dec 2015 16:11:31 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8616 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/src/hal_buffers.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 os/hal/src/hal_buffers.c (limited to 'os/hal/src') diff --git a/os/hal/src/hal_buffers.c b/os/hal/src/hal_buffers.c new file mode 100644 index 000000000..62d1dbbb4 --- /dev/null +++ b/os/hal/src/hal_buffers.c @@ -0,0 +1,86 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file hal_buffers.c + * @brief I/O Buffers code. + * + * @addtogroup HAL_BUFFERS + * @{ + */ + +#include "hal.h" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables and types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/** + * @brief Initializes an I/O buffer object. + * + * @param[out] iobp pointer to the @p input_double_buffer_t object + * @param[in] bp pointer to a memory area allocated as buffer + * @param[in] size size of the buffers + * + * @init + */ +void iobInit(io_buffer_t *iobp, uint8_t *bp, size_t size) { + + iobp->buffer = bp; + iobp->limit = bp; + iobp->top = bp + size; +} + +/** + * @brief Initializes an input double buffer object. + * + * @param[out] idbp pointer to the @p input_double_buffer_t object + * @param[in] b1p pointer to a memory area allocated as buffer 1 + * @param[in] b2p pointer to a memory area allocated as buffer 2 + * @param[in] size size of the buffers + * + * @init + */ +void idbObjectInit(input_double_buffer_t *idbp, + uint8_t *b1p, uint8_t *b2p, size_t size, + dbnotify_t infy, void *link) { + + iobInit(&idbp->buffers[0], b1p, size); + iobInit(&idbp->buffers[1], b2p, size); + idbp->counter = 0; + idbp->brdptr = &idbp->buffers[0]; + idbp->bwrptr = &idbp->buffers[0]; + idbp->notify = infy; + idbp->link = link; +} + +/** @} */ -- cgit v1.2.3