OSDN Git Service

(none)
[hos/hos-v4a.git] / aplfw / driver / serial / pc16550 / pc16550drv_open.c
1 /** 
2  *  Hyper Operating System  Application Framework
3  *
4  * @file  scidrv.c
5  * @brief %jp{PC16550用デバイスドライバ}
6  *
7  * Copyright (C) 2006 by Project HOS
8  * http://sourceforge.jp/projects/hos/
9  */
10
11
12 #include "pc16550drv_local.h"
13
14
15 /** オープン */
16 HANDLE Pc16550Drv_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode)
17 {
18         C_PC16550DRV    *self;
19         C_CHRFILE               *pFile;
20         
21         /* upper cast */
22         self = (C_PC16550DRV *)pDrvObj;
23
24         /* create file descriptor */
25         if ( (pFile = SysMem_Alloc(sizeof(*pFile))) == NULL )
26         {
27                 return HANDLE_NULL;
28         }
29         ChrFile_Create(pFile, pDrvObj, NULL);
30
31         
32         /* オープン処理 */
33         if ( self->iOpenCount++ == 0 )
34         {
35                 Pc16550Hal_Setup(&self->Pc16550Hal);
36                 Pc16550Hal_SetSpeed(&self->Pc16550Hal, 38400);
37                 Pc16550Hal_EnableInterrupt(&self->Pc16550Hal, PC16550HAL_IER_ERBFI);
38                 SysInt_Enable(self->iIntNum);
39         }
40
41         return (HANDLE)pFile;
42 }
43
44
45 /* end of file */