⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smb380userdll.cpp

📁 Sample codes to change orientation using 3-Axis accel. chip, SMB380
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}

/** get low-g interrupt hyst
   \param *hyst get the hyst  value from sensor image
   \return result 0 -> success; -1 -> fail;
   \see smb380_set_low_g_hysteresis()
*/
int smb380_get_low_g_hysteresis(unsigned char *hyst)
{
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_get_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_GET_LOW_G_HYST,
    	NULL, 
    	0,
      	hyst, 
    	sizeof(unsigned char),
    	NULL, 
    	NULL );

     //
     // if the operation failed, log an error condition
     //
     if(fRet == FALSE )
     {
     	DEBUGMSG(1,(_T("smb380_get_low_g_hysteresis failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_get_low_g_hysteresis Out<<<+++\r\n")));
	return 0;
}

/** get high-g interrupt hyst
   \param *hyst get the hyst  value from sensor image
   \return result 0 -> success; -1 -> fail;
   \see smb380_set_high_g_hysteresis()
*/
int smb380_get_high_g_hysteresis(unsigned char *hyst)
{
    BOOL fRet = TRUE;
    
    DEBUGMSG(1,(_T("smb380_get_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_GET_HIGH_G_HYST,
    	NULL, 
    	0,
      	hyst, 
    	sizeof(unsigned char),
    	NULL, 
    	NULL );

     //
     // if the operation failed, log an error condition
     //
     if(fRet == FALSE )
     {
     	DEBUGMSG(1,(_T("smb380_get_high_g_hysteresis failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_get_high_g_hysteresis Out<<<+++\r\n")));
	return 0;
}

/** get low-g interrupt threshold
   \param *th get the threshold  value from sensor image
   \return result 0 -> success; -1 -> fail;
   \see smb380_set_low_g_threshold()
*/
int smb380_get_low_g_threshold(unsigned char *th)
{
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_get_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_GET_LOW_G_THRESHOLD,
    	NULL, 
    	0,
      	th, 
    	sizeof(unsigned char),
    	NULL, 
    	NULL );

     //
     // if the operation failed, log an error condition
     //
     if(fRet == FALSE )
     {
     	DEBUGMSG(1,(_T("smb380_get_low_g_threshold failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_get_low_g_threshold Out<<<+++\r\n")));
	return 0;
}


/** set low-g interrupt countdown
   \param cnt get the countdown value from sensor image
   \return result 0 -> success; -1 -> fail;
   \see smb380_get_low_g_countdown()
*/
int smb380_set_low_g_countdown(unsigned char cnt)
{
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_set_low_g_countdown 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_COUNTDOWN,
    	&cnt, 
    	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_countdown failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_set_low_g_countdown Out<<<+++\r\n")));
	return 0;
}

/** get low-g interrupt countdown
   \param cnt get the countdown  value from sensor image
   \return result 0 -> success; -1 -> fail;
   \see smb380_set_low_g_countdown()
*/
int smb380_get_low_g_countdown(unsigned char *cnt)
{
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_get_low_g_countdown 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_LOW_G_COUNTDOWN,
    	NULL, 
    	0,
      	cnt, 
    	sizeof(unsigned char),
    	NULL, 
    	NULL );

     //
     // if the operation failed, log an error condition
     //
     if(fRet == FALSE )
     {
     	DEBUGMSG(1,(_T("smb380_get_low_g_countdown failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_get_low_g_countdown Out<<<+++\r\n")));
	return 0;
}

/** set high-g interrupt countdown
   \param cnt get the countdown value from sensor image
   \return result 0 -> success; -1 -> fail;
   \see smb380_get_high_g_countdown()
*/
int smb380_set_high_g_countdown(unsigned char cnt)
{
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_set_high_g_countdown 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_COUNTDOWN,
    	&cnt, 
    	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_countdown failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_set_high_g_countdown Out<<<+++\r\n")));
	return 0;
}

/** get high-g interrupt countdown
   \param cnt get the countdown  value from sensor image
   \return result 0 -> success; -1 -> fail;
   \see smb380_set_high_g_countdown()
*/
int smb380_get_high_g_countdown(unsigned char *cnt)
{
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_get_high_g_countdown 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_HIGH_G_COUNTDOWN,
    	NULL, 
    	0,
      	cnt, 
    	sizeof(unsigned char),
    	NULL, 
    	NULL );

     //
     // if the operation failed, log an error condition
     //
     if(fRet == FALSE )
     {
     	DEBUGMSG(1,(_T("smb380_get_high_g_countdown failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_get_high_g_countdown Out<<<+++\r\n")));
	return 0;
}


/** configure low-g duration value
	\param dur low-g duration in miliseconds
    \return result 0 -> success; -1 -> fail;
	\see smb380_get_low_g_duration(), smb380_get_high_g_duration(), smb380_set_high_g_duration()
*/
int smb380_set_low_g_duration(unsigned char dur) 
{
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_set_low_g_duration 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_DURATION,
    	&dur, 
    	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_duration failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_set_low_g_duration Out<<<+++\r\n")));
	return 0;
}

/** read out low-g duration value from sensor image
	\param dur low-g duration in miliseconds
    \return result 0 -> success; -1 -> fail;
	\see smb380_set_low_g_duration(), smb380_get_high_g_duration(), smb380_set_high_g_duration()
*/
int smb380_get_low_g_duration(unsigned char *dur) {
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_get_low_g_duration 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_LOW_G_DURATION,
    	NULL, 
    	0,
      	dur, 
    	sizeof(unsigned char),
    	NULL, 
    	NULL );

     //
     // if the operation failed, log an error condition
     //
     if(fRet == FALSE )
     {
     	DEBUGMSG(1,(_T("smb380_get_low_g_duration failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_get_low_g_duration Out<<<+++\r\n")));
	return 0;
}

/** 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_HG_THRES_IN_G() for range to register value conversion is available.
   \see SMB380_HG_THRES_IN_G()   
   \see smb380_get_high_g_threshold()
*/
int smb380_set_high_g_threshold(unsigned char th) 
{
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_set_high_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_HIGH_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_high_g_threshold failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_set_high_g_threshold Out<<<+++\r\n")));
	return 0;
}

/** get high-g interrupt threshold
   \param *th get the threshold  value from sensor image
   \return result 0 -> success; -1 -> fail;
   \see smb380_set_high_g_threshold()
*/
int smb380_get_high_g_threshold(unsigned char *th)
{
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_get_high_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_GET_HIGH_G_THRESHOLD,
    	NULL, 
    	0,
      	th, 
    	sizeof(unsigned char),
    	NULL, 
    	NULL );

     //
     // if the operation failed, log an error condition
     //
     if(fRet == FALSE )
     {
     	DEBUGMSG(1,(_T("smb380_get_high_g_threshold failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_get_high_g_threshold Out<<<+++\r\n")));
	return 0;
}



/** configure high-g duration value
	\param dur high-g duration in miliseconds
    \return result 0 -> success; -1 -> fail;
	\see  smb380_get_high_g_duration(), smb380_set_low_g_duration(), smb380_get_low_g_duration()
*/
int smb380_set_high_g_duration(unsigned char dur) 
{
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_set_high_g_duration 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_DURATION,
    	&dur, 
    	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_duration failed!\r\n")));
	return -1;
     }

	DEBUGMSG(1,(_T("smb380_set_high_g_duration Out<<<+++\r\n")));
	return 0;
}

/** read out high-g duration value from sensor image
	\param dur high-g duration in miliseconds
    \return result 0 -> success; -1 -> fail;
	\see  smb380_set_high_g_duration(), smb380_get_low_g_duration(), smb380_set_low_g_duration(),
*/
int smb380_get_high_g_duration(unsigned char *dur) {	
    BOOL fRet = TRUE;
    

    DEBUGMSG(1,(_T("smb380_get_high_g_duration 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_HIGH_G_DURATION,
    	NULL, 
    	0,
      	dur, 
    	sizeof(unsigned char),
    	NULL, 
    	NULL );

     //

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -