📄 smb380userdll.cpp
字号:
{
DEBUGMSG(1,(_T("smb380_write_ee failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_write_ee Out<<<+++\r\n")));
return 0;
}
/** start SMB380s integrated selftest function
\param st 1 = selftest0, 3 = selftest1 (see also)
\return result 0 -> success; -1 -> fail;
\see SMB380_SELF_TEST0_ON
\see SMB380_SELF_TEST1_ON
*/
int smb380_selftest(unsigned char st)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_selftest In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_SELFTEST,
&st,
sizeof(unsigned char),
NULL,
0,
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_selftest failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_selftest Out<<<+++\r\n")));
return 0;
}
/** set smb380s range
\param range
\return result 0 -> success; -1 -> fail;
\see SMB380_RANGE_2G
\see SMB380_RANGE_4G
\see SMB380_RANGE_8G
*/
int smb380_set_range(char range)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_set_range In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_SET_RANGE,
&range,
sizeof(char),
NULL,
0,
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_set_range failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_set_range Out<<<+++\r\n")));
return 0;
}
/** readout select range from SMB380
\param *range pointer to range setting
\return result 0 -> success; -1 -> fail;
\see SMB380_RANGE_2G, SMB380_RANGE_4G, SMB380_RANGE_8G
\see smb380_set_range()
*/
int smb380_get_range(unsigned char *range)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_get_range In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_GET_RANGE,
NULL,
0,
range,
sizeof(unsigned char),
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_get_range failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_get_range Out<<<+++\r\n")));
return 0;
}
/** set SMB380s operation mode
\param mode 0 = normal, 2 = sleep, 3 = auto wake up
\return result 0 -> success; -1 -> fail;
\note Available constants see below
\see SMB380_MODE_NORMAL, SMB380_MODE_SLEEP, SMB380_MODE_WAKE_UP
\see smb380_get_mode()
*/
int smb380_set_mode(unsigned char mode)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_set_mode In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_SET_MODE,
&mode,
sizeof(unsigned char),
NULL,
0,
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_set_mode failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_set_mode Out<<<+++\r\n")));
return 0;
}
/** get selected mode
\param point mode returns back the current mode
\return result 0 -> success; -1 -> fail;
\note this function returns the mode stored in \ref smb380_t structure
\see SMB380_MODE_NORMAL, SMB380_MODE_SLEEP, SMB380_MODE_WAKE_UP
\see smb380_set_mode()
*/
int smb380_get_mode(unsigned char *mode)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_get_mode In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_GET_MODE,
NULL,
0,
mode,
sizeof(unsigned char),
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_get_mode failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_get_mode Out<<<+++\r\n")));
return 0;
}
/** set SMB380 internal filter bandwidth
\param bw bandwidth (see bandwidth constants)
\return result 0 -> success; -1 -> fail;
\see #define SMB380_BW_25HZ, SMB380_BW_50HZ, SMB380_BW_100HZ, SMB380_BW_190HZ, SMB380_BW_375HZ, SMB380_BW_750HZ, SMB380_BW_1500HZ
\see smb380_get_bandwidth()
*/
int smb380_set_bandwidth(char bw)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_set_bandwidth In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_SET_BANDWIDTH,
&bw,
sizeof(char),
NULL,
0,
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_set_bandwidth failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_set_bandwidth Out<<<+++\r\n")));
return 0;
}
/** read selected bandwidth from SMB380
\param *bw pointer to bandwidth return value
\return result 0 -> success; -1 -> fail;
\see #define SMB380_BW_25HZ, SMB380_BW_50HZ, SMB380_BW_100HZ, SMB380_BW_190HZ, SMB380_BW_375HZ, SMB380_BW_750HZ, SMB380_BW_1500HZ
\see smb380_set_bandwidth()
*/
int smb380_get_bandwidth(unsigned char *bw) {
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_get_bandwidth In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_GET_BANDWIDTH,
NULL,
0,
bw,
sizeof(unsigned char),
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_get_bandwidth failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_get_bandwidth Out<<<+++\r\n")));
return 0;
}
/** set SMB380 auto wake up pause
\param wup wake_up_pause parameters
\return result 0 -> success; -1 -> fail;
\see SMB380_WAKE_UP_PAUSE_20MS, SMB380_WAKE_UP_PAUSE_80MS, SMB380_WAKE_UP_PAUSE_320MS, SMB380_WAKE_UP_PAUSE_2560MS
\see smb380_get_wake_up_pause()
*/
int smb380_set_wake_up_pause(unsigned char wup)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_set_wake_up_pause In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_SET_WAKE_UP_PAUSE,
&wup,
sizeof(unsigned char),
NULL,
0,
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_set_wake_up_pause failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_set_wake_up_pause Out<<<+++\r\n")));
return 0;
}
/** read SMB380 auto wake up pause from image
\param *wup wake up pause read back pointer
\return result 0 -> success; -1 -> fail;
\see SMB380_WAKE_UP_PAUSE_20MS, SMB380_WAKE_UP_PAUSE_80MS, SMB380_WAKE_UP_PAUSE_320MS, SMB380_WAKE_UP_PAUSE_2560MS
\see smb380_set_wake_up_pause()
*/
int smb380_get_wake_up_pause(unsigned char *wup)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_get_wake_up_pause In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_GET_WAKE_UP_PAUSE,
NULL,
0,
wup,
sizeof(unsigned char),
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_get_wake_up_pause failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_get_wake_up_pause Out<<<+++\r\n")));
return 0;
}
/* Thresholds and Interrupt Configuration */
/** set low-g interrupt threshold
\param th set the threshold
\return result 0 -> success; -1 -> fail;
\note the threshold depends on configured range. A macro \ref SMB380_LG_THRES_IN_G() for range to register value conversion is available.
\see SMB380_LG_THRES_IN_G()
\see smb380_get_low_g_threshold()
*/
int smb380_set_low_g_threshold(unsigned char th)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_set_low_g_threshold In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_SET_LOW_G_THRESHOLD,
&th,
sizeof(unsigned char),
NULL,
0,
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_set_low_g_threshold failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_set_low_g_threshold Out<<<+++\r\n")));
return 0;
}
/** set low-g interrupt hyst
\param hyst set the hyst
\return result 0 -> success; -1 -> fail;
*/
int smb380_set_low_g_hysteresis(unsigned char hyst)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_set_low_g_hysteresis In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_SET_LOW_G_HYST,
&hyst,
sizeof(unsigned char),
NULL,
0,
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_set_low_g_hysteresis failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_set_low_g_hysteresis Out<<<+++\r\n")));
return 0;
}
/** set high-g interrupt hyst
\param th set the hyst
\return result 0 -> success; -1 -> fail;
*/
int smb380_set_high_g_hysteresis(unsigned char hyst)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_set_high_g_hysteresis In>>>---\r\n")));
if(smb380handle == NULL){
DEBUGMSG(1,(_T("Should do smb380_open first to get device handle\r\n")));
return -1;
}
fRet = DeviceIoControl( smb380handle,
IOCTL_SMB380_SET_HIGH_G_HYST,
&hyst,
sizeof(unsigned char),
NULL,
0,
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_set_high_g_hysteresis failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_set_high_g_hysteresis Out<<<+++\r\n")));
return 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -