首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 嵌入开发 > WinCE >

wince两个驱动之间怎么用互斥

2012-02-09 
wince两个驱动之间如何用互斥?一个SPI口,两个驱动里都要用到,直接在驱动里操作SPI寄存器来收发,不用标准的

wince两个驱动之间如何用互斥?
一个SPI口,两个驱动里都要用到,直接在驱动里操作SPI寄存器来收发,不用标准的SPI驱动,这个互斥应该怎样定义?
比如在一个驱动里定义互斥, 另外一个驱动怎样才能用这个句柄?

[解决办法]
看一下WINCE 触摸屏和电池是怎么用的互斥

Wince电池驱动
[解决办法]

探讨
一个SPI口,两个驱动里都要用到,直接在驱动里操作SPI寄存器来收发,不用标准的SPI驱动,这个互斥应该怎样定义?
比如在一个驱动里定义互斥, 另外一个驱动怎样才能用这个句柄?

[解决办法]
同名事件
同名互斥变量
[解决办法]
5楼正解,可以使用同名事件来作为互斥量
[解决办法]
探讨
能否详细说明一下?就是说在两个驱动里分别定义一个事件,名字一样,其实就是一个事件?

引用:

5楼正解,可以使用同名事件来作为互斥量

[解决办法]
HANDLE CreateMutex( 
LPSECURITY_ATTRIBUTES lpMutexAttributes, 
BOOL bInitialOwner, 
LPCTSTR lpName
);

lpName
[in] Long pointer to a null-terminated string specifying the name of the mutex object. The name is limited to MAX_PATH characters and can contain any character except the backslash path-separator character (\). Name comparison is case sensitive. 
If lpName matches the name of an existing named mutex object, the bInitialOwner parameter is ignored because it has already been set by the creation process. 

If lpName is NULL, the mutex object is created without a name. 

If lpName matches the name of an existing event, semaphore, or file-mapping object, the function fails and the GetLastError function returns ERROR_INVALID_HANDLE. This occurs because these objects share the same name space.

热点排行