2 * Hyper Operating System Application Framework
4 * @file at91uartdrv_read.c
5 * @brief %jp{ATMEL AT91シリーズUART用デバイスドライバ}
7 * Copyright (C) 2006-2007 by Project HOS
8 * http://sourceforge.jp/projects/hos/
12 #include "at91uartdrv_local.h"
16 FILE_SIZE At91UartDrv_Read(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, void *pBuf, FILE_SIZE Size)
20 unsigned char *pubBuf;
25 self = (C_AT91UARTDRV *)pDrvObj;
26 pChrFile = (C_CHRFILE *)pFileObj;
28 pubBuf = (unsigned char *)pBuf;
31 SysMtx_Lock(self->hMtxRecv);
33 for ( i = 0; i < Size; i++ )
35 while ( (c = StreamBuf_RecvChar(&self->StmBufRecv)) < 0 )
37 if ( pChrFile->cReadMode == FILE_RMODE_BLOCKING )
39 /* ブロッキングなら受信イベントを待つ */
40 SysEvt_Wait(self->hEvtRecv);
41 SysEvt_Clear(self->hEvtRecv);
49 *pubBuf++ = (unsigned char)c;
54 SysMtx_Unlock(self->hMtxRecv);