6#include "dawn/porting/encoder.hxx"
10#include <nuttx/sensors/qencoder.h>
14#include "dawn/debug.hxx"
16int encoder_open(
const char *path)
18 int fd = open(path, O_RDWR);
19 DAWNINFO(
"ENC: open %s %d\n", path, fd);
22 DAWNERR(
"Failed to open encoder file %s (error %d)\n", path, fd);
29void encoder_close(
int fd)
37int encoder_read_position(
int fd, int32_t *pos)
39 int ret = ioctl(fd, QEIOC_POSITION,
reinterpret_cast<unsigned long>(pos));
42 DAWNERR(
"QEIOC_POSITION failed %d\n", -errno);
51 struct qe_index_s idx;
54 ret = ioctl(fd, QEIOC_GETINDEX,
reinterpret_cast<unsigned long>(&idx));
57 DAWNERR(
"QEIOC_GETINDEX failed %d\n", -errno);
61 index->qenc_pos = idx.qenc_pos;
62 index->indx_pos = idx.indx_pos;
63 index->indx_cnt = idx.indx_cnt;
68int encoder_reset(
int fd)
70 int ret = ioctl(fd, QEIOC_RESET, 0);
73 DAWNERR(
"QEIOC_RESET failed %d\n", -errno);
80int encoder_set_posmax(
int fd, uint32_t posmax)
82 int ret = ioctl(fd, QEIOC_SETPOSMAX,
static_cast<unsigned long>(posmax));
85 DAWNERR(
"QEIOC_SETPOSMAX failed %d\n", -errno);
Quadrature encoder index sample.