Using a hardware timer (eCAP?) to measure the width of a pulse from a Ultrasonic Range finder

I have a HC-SR04 Ultrasonic Ranging Module[1] I want to interface to the Bone. It outputs a pulse whose width is proportional to the distance to the object.

The AM335x TRM says the eCAP Module (Enhanced Capture) can measure the time of a pulse. Has anyone written an eCAP kernel driver? Are there other ways to access the eCAP hardware?

I’m running the 1-July-2014 Debian image.

Thanks…

–Mark

[1] https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=0CC4QFjAC&url=https%3A%2F%2Fdocs.google.com%2Fdocument%2Fd%2F1Y-yZnNhMYy7rwhAgyL_pfa39RsB-x2qR4vP8saG73rE%2Fedit&ei=cJG-U7ayGsyMyATGpoKIAQ&usg=AFQjCNEl7_92OTpEqYieKiT6D1fHJEwi9Q&sig2=aa8OnjEBQAGcLrjgDM4wSQ

I came across this today https://github.com/Teknoman117/beaglebot/tree/master/hcsr04-demo

Might be just what you need.

Troy:
Thanks for the quick response. That’s a great lead.

I found I can get maybe 0.2 ms accuracy just using JavaScript. That translates to around 4cm, which isn’t back.

When I have the time I’ll see how much the PRU improves things.

–Mark