Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of libMiMic by
NyLPC_cRingBuffer.h
00001 /********************************************************************************* 00002 * PROJECT: MiMic 00003 * -------------------------------------------------------------------------------- 00004 * 00005 * This file is part of MiMic 00006 * Copyright (C)2011 Ryo Iizuka 00007 * 00008 * MiMic is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published 00010 * by the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 * 00021 * For further information please contact. 00022 * http://nyatla.jp/ 00023 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp> 00024 * 00025 *********************************************************************************/ 00026 #ifndef NyLPC_TcRingBuffer_h 00027 #define NyLPC_TcRingBuffer_h 00028 00029 00030 00031 #include "NyLPC_stdlib.h" 00032 00033 #ifdef __cplusplus 00034 extern "C" { 00035 #endif /* __cplusplus */ 00036 00037 /********************************************************************** 00038 * 00039 * NyLPC_TcRingBuffer class 00040 * 00041 **********************************************************************/ 00042 typedef struct NyLPC_TcRingBuffer NyLPC_TcRingBuffer_t; 00043 00044 00045 struct NyLPC_TcRingBuffer 00046 { 00047 void* buf; //バッファ 00048 NyLPC_TUInt16 bl; //バッファ長さ 00049 NyLPC_TUInt16 wo; //バッファ書込み位置オフセット 00050 NyLPC_TUInt16 ro; //バッファ読み込み位置オフセット 00051 }; 00052 00053 00054 #if NyLPC_ARCH==NyLPC_ARCH_FREERTOS 00055 #elif NyLPC_ARCH==NyLPC_ARCH_WIN32 00056 /** 00057 * リングバッファをダンプします。 00058 */ 00059 void NyLPC_cRingBuffer_dump(NyLPC_TcRingBuffer_t* i_inst); 00060 #else 00061 #endif 00062 00063 00064 /** 00065 * i_bufをラップするリングバッファを作成します。 00066 */ 00067 void NyLPC_cRingBuffer_initialize(NyLPC_TcRingBuffer_t* i_inst,void* i_buf,NyLPC_TUInt16 sizeof_buf); 00068 00069 /** 00070 * この関数は、読出し可能なサイズを計算して返します。 00071 * @return 00072 * 読み出し可能なバイト数を返します。 00073 * 0以外の場合、もう一度読み出せる可能性があります。 00074 */ 00075 NyLPC_TInt16 NyLPC_cRingBuffer_getReadableSize(NyLPC_TcRingBuffer_t* i_inst); 00076 00077 /** 00078 * この関数は、書き込み可能なサイズを計算して返します。 00079 * @return 00080 * 書き込み可能なバイト数です。 00081 * この数値は、バッファ全体に対する空き領域と同じです。 00082 */ 00083 NyLPC_TInt16 NyLPC_cRingBuffer_getWritableSize(const NyLPC_TcRingBuffer_t* i_inst); 00084 00085 /** 00086 * リングバッファにデータを書き込みます。 00087 * @return 00088 * 書きこめたサイズ。 00089 */ 00090 int NyLPC_cRingBuffer_write(NyLPC_TcRingBuffer_t* i_inst,NyLPC_TUInt8* i_data,const int i_len); 00091 00092 /** 00093 * この関数は、リングバッファを初期化します。 00094 */ 00095 void NyLPC_cRingBuffer_reset(NyLPC_TcRingBuffer_t* i_inst); 00096 00097 /** 00098 * リングバッファの読出しポイントと読出し可能サイズを返します。 00099 */ 00100 NyLPC_TUInt8* NyLPC_cRingBuffer_pread(NyLPC_TcRingBuffer_t* i_inst,NyLPC_TUInt16* len); 00101 00102 /** 00103 * この関数は、リングバッファの読み取り点を前方にシークします。 00104 * @i_seek 00105 * シークするバイト数。NyLPC_cRingBuffer_getReadableSize,又はNyLPC_cRingBuffer_preadのlen以下のサイズである必要があります。 00106 */ 00107 void NyLPC_cRingBuffer_preadSeek(NyLPC_TcRingBuffer_t* i_inst,NyLPC_TUInt16 i_seek); 00108 00109 #ifdef __cplusplus 00110 } 00111 #endif /* __cplusplus */ 00112 00113 #endif
Generated on Tue Jul 12 2022 16:22:59 by
1.7.2
