📄 smb380userdll.cpp
字号:
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_get_high_g_duration failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_get_high_g_duration Out<<<+++\r\n")));
return 0;
}
/** set threshold value for any_motion feature
\param th set the threshold a macro \ref SMB380_ANY_MOTION_THRES_IN_G() is available for that
\return result 0 -> success; -1 -> fail;
\see SMB380_ANY_MOTION_THRES_IN_G()
*/
int smb380_set_any_motion_threshold(unsigned char th)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_set_any_motion_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_ANY_MOTION_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_any_motion_threshold failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_set_any_motion_threshold Out<<<+++\r\n")));
return 0;
}
/** get threshold value for any_motion feature
\param *th read back any_motion threshold from image register
\return result 0 -> success; -1 -> fail;
\see SMB380_ANY_MOTION_THRES_IN_G()
*/
int smb380_get_any_motion_threshold(unsigned char *th)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_get_any_motion_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_ANY_MOTION_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_any_motion_threshold failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_get_any_motion_threshold Out<<<+++\r\n")));
return 0;
}
/** set counter value for any_motion feature
\param amc set the counter value, constants are available for that
\return result 0 -> success; -1 -> fail;
\see SMB380_ANY_MOTION_DUR_1, SMB380_ANY_MOTION_DUR_3, SMB380_ANY_MOTION_DUR_5, SMB380_ANY_MOTION_DUR_7
*/
int smb380_set_any_motion_count(unsigned char amc)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_set_any_motion_count 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_ANY_MOTION_COUNT,
&amc,
sizeof(unsigned char),
NULL,
0,
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_set_any_motion_count failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_set_any_motion_count Out<<<+++\r\n")));
return 0;
}
/** get counter value for any_motion feature from image register
\param *amc readback pointer for counter value
\return result 0 -> success; -1 -> fail;
\see SMB380_ANY_MOTION_DUR_1, SMB380_ANY_MOTION_DUR_3, SMB380_ANY_MOTION_DUR_5, SMB380_ANY_MOTION_DUR_7
*/
int smb380_get_any_motion_count(unsigned char *amc)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_get_any_motion_count 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_ANY_MOTION_COUNT,
NULL,
0,
amc,
sizeof(unsigned char),
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_get_any_motion_count failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_get_any_motion_count Out<<<+++\r\n")));
return 0;
}
/** set the interrupt mask for SMB380's interrupt features in one mask
\param mask input for interrupt mask
\return result 0 -> success; -1 -> fail;
\see SMB380_INT_ALERT, SMB380_INT_ANY_MOTION, SMB380_INT_EN_ADV_INT, SMB380_INT_NEW_DATA, SMB380_INT_LATCH, SMB380_INT_HG, SMB380_INT_LG
*/
int smb380_set_interrupt_mask(unsigned char mask)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_set_interrupt_mask 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_INTERRUPT_MASK,
&mask,
sizeof(unsigned char),
NULL,
0,
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_set_interrupt_mask failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_set_interrupt_mask Out<<<+++\r\n")));
return 0;
}
/** get the current interrupt mask settings from SMB380 image registers
\param *mask return variable pointer for interrupt mask
\return result 0 -> success; -1 -> fail;
\see SMB380_INT_ALERT, SMB380_INT_ANY_MOTION, SMB380_INT_EN_ADV_INT, SMB380_INT_NEW_DATA, SMB380_INT_LATCH, SMB380_INT_HG, SMB380_INT_LG
*/
int smb380_get_interrupt_mask(unsigned char *mask)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_get_interrupt_mask 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_INTERRUPT_MASK,
NULL,
0,
mask,
sizeof(unsigned char),
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_get_interrupt_mask failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_get_interrupt_mask Out<<<+++\r\n")));
return 0;
}
/** resets the SMB380 interrupt status
\return result 0 -> success; -1 -> fail;
\note this feature can be used to reset a latched interrupt
*/
int smb380_reset_interrupt()
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_reset_interrupt 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_RESET_INTERRUPT,
NULL,
0,
NULL,
0,
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_reset_interrupt failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_reset_interrupt Out<<<+++\r\n")));
return 0;
}
/* Data Readout */
/** X-axis acceleration data readout
\param *a_x pointer for 16 bit 2's complement data output (LSB aligned)
\return result 0 -> success; -1 -> fail;
*/
int smb380_read_accel_x(short *a_x)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_read_accel_x 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_READ_ACCEL_X,
NULL,
0,
a_x,
sizeof(unsigned short),
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_read_accel_x failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_read_accel_x Out<<<+++\r\n")));
return 0;
}
/** Y-axis acceleration data readout
\param *a_y pointer for 16 bit 2's complement data output (LSB aligned)
\return result 0 -> success; -1 -> fail;
*/
int smb380_read_accel_y(short *a_y)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_read_accel_y 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_READ_ACCEL_Y,
NULL,
0,
a_y,
sizeof(unsigned short),
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_read_accel_y failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_read_accel_y Out<<<+++\r\n")));
return 0;
}
/** Z-axis acceleration data readout
\param *a_z pointer for 16 bit 2's complement data output (LSB aligned)
\return result 0 -> success; -1 -> fail;
*/
int smb380_read_accel_z(short *a_z)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_read_accel_z 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_READ_ACCEL_Z,
NULL,
0,
a_z,
sizeof(unsigned short),
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_read_accel_z failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_read_accel_z Out<<<+++\r\n")));
return 0;
}
/** 8 bit temperature data readout
\param *temp pointer for 8 bit temperature output (offset binary)
\return result 0 -> success; -1 -> fail;
\note: an output of 0 equals -30癈, 1 LSB equals 0.5癈
*/
int smb380_read_temperature(unsigned char * temp)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_read_temperature 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_READ_TEMPERATURE,
NULL,
0,
temp,
sizeof(unsigned char),
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_read_temperature failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_read_temperature Out<<<+++\r\n")));
return 0;
}
/** X,Y and Z-axis acceleration data readout
\param *acc pointer to \ref smb380acc_t structure for x,y,z data readout
\return result 0 -> success; -1 -> fail;
\note data will be read by multi-byte protocol into a 6 byte structure
*/
int smb380_read_accel_xyzt(smb380acc_t * acc)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_read_accel_xyz 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_READ_ACCEL_XYZT,
NULL,
0,
acc,
sizeof(smb380acc_t),
NULL,
NULL );
//
// if the operation failed, log an error condition
//
if(fRet == FALSE )
{
DEBUGMSG(1,(_T("smb380_read_accel_xyz failed!\r\n")));
return -1;
}
DEBUGMSG(1,(_T("smb380_read_accel_xyz Out<<<+++\r\n")));
return 0;
}
/** check current interrupt status from interrupt status register in SMB380 image register
\param *ist pointer to interrupt status byte
\return result 0 -> success; -1 -> fail;
\see SMB380_INT_STATUS_HG, SMB380_INT_STATUS_LG, SMB380_INT_STATUS_HG_LATCHED, SMB380_INT_STATUS_LG_LATCHED, SMB380_INT_STATUS_ALERT, SMB380_INT_STATUS_ST_RESULT
*/
int smb380_get_interrupt_status(unsigned char * ist)
{
BOOL fRet = TRUE;
DEBUGMSG(1,(_T("smb380_get_interrupt_status 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,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -