diff --git a/include/nuttx/sensors/qencoder.h b/include/nuttx/sensors/qencoder.h index ab1e8f9f0b..8632165baf 100644 --- a/include/nuttx/sensors/qencoder.h +++ b/include/nuttx/sensors/qencoder.h @@ -54,15 +54,20 @@ * Argument: uint32_t maximum position * QEIOC_SETINDEX - Set the index position for the encoder. * Argument: uint32_t index position + * QEIOC_GETINDEX - Get the index position and count of the encoder. + * The structure also contains current position so QEIOC_POSITION + * is not required when QEIOC_GETINDEX is used. + * Argment: qe_index_s structure (refer below) */ #define QEIOC_POSITION _QEIOC(0x0001) /* Arg: int32_t* pointer */ #define QEIOC_RESET _QEIOC(0x0002) /* Arg: None */ #define QEIOC_SETPOSMAX _QEIOC(0x0003) /* Arg: uint32_t */ #define QEIOC_SETINDEX _QEIOC(0x0004) /* Arg: uint32_t */ +#define QEIOC_GETINDEX _QEIOC(0x0005) /* Arg: qe_index_s struct */ #define QE_FIRST 0x0001 /* First required command */ -#define QE_NCMDS 4 /* 4 required commands */ +#define QE_NCMDS 5 /* 5 required commands */ /* User defined ioctl commands are also supported. These will be forwarded * by the upper-half QE driver to the lower-half QE driver via the ioctl() @@ -138,6 +143,18 @@ struct qe_ops_s int cmd, unsigned long arg); }; +/* Structure qe_index_s is used for QEIOC_GETINDEX call. This call returns + * current encoder position, the last index position and number of index + * occurances. + */ + +struct qe_index_s +{ + int32_t qenc_pos; /* Qencoder actual position */ + int32_t indx_pos; /* Index last position */ + int16_t indx_cnt; /* Number of index occurances */ +}; + /* This is the interface between the lower half quadrature encoder driver * and the upper half quadrature encoder driver. A (device-specific) * instance of this structure is passed to the upper-half driver when the