apps/examples: Add test of edges counting at capture
Description: Add test of the function of counting cap edges Signed-off-by: zhangkai25 <zhangkai25@xiaomi.com>
This commit is contained in:
parent
4e3f77d884
commit
39d053ef74
@ -213,6 +213,7 @@ int main(int argc, FAR char *argv[])
|
|||||||
{
|
{
|
||||||
int8_t dutycycle;
|
int8_t dutycycle;
|
||||||
int32_t frequence;
|
int32_t frequence;
|
||||||
|
int32_t edges;
|
||||||
int fd;
|
int fd;
|
||||||
int exitval = EXIT_SUCCESS;
|
int exitval = EXIT_SUCCESS;
|
||||||
int ret;
|
int ret;
|
||||||
@ -290,6 +291,24 @@ int main(int argc, FAR char *argv[])
|
|||||||
printf("pwm frequence: %"PRId32" Hz \n", frequence);
|
printf("pwm frequence: %"PRId32" Hz \n", frequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get the edges data using the ioctl */
|
||||||
|
|
||||||
|
ret = ioctl(fd, CAPIOC_EDGES,
|
||||||
|
(unsigned long)((uintptr_t)&edges));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
printf("cap_main: ioctl(CAPIOC_EDGES) failed: %d\n", errno);
|
||||||
|
exitval = EXIT_FAILURE;
|
||||||
|
goto errout_with_dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print the sample data on successful return */
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("pwm edges counting: %"PRId32" \n", edges);
|
||||||
|
}
|
||||||
|
|
||||||
/* Delay a little bit */
|
/* Delay a little bit */
|
||||||
|
|
||||||
usleep(g_capexample.delay * 1000);
|
usleep(g_capexample.delay * 1000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user