一个SPI口,两个驱动里都要用到,直接在驱动里操作SPI寄存器来收发,不用标准的SPI驱动,这个互斥应该怎样定义?
比如在一个驱动里定义互斥, 另外一个驱动怎样才能用这个句柄?
------解决方案--------------------
看一下WINCE 触摸屏和电池是怎么用的互斥
Wince电池驱动
------解决方案--------------------
------解决方案--------------------
同名事件
同名互斥变量
------解决方案--------------------
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.