| 25 | using namespace Linux; |
| 26 | |
| 27 | void RCInput_PRU::init() |
| 28 | { |
| 29 | int mem_fd = open("/dev/mem", O_RDWR|O_SYNC|O_CLOEXEC); |
| 30 | if (mem_fd == -1) { |
| 31 | AP_HAL::panic("Unable to open /dev/mem"); |
| 32 | } |
| 33 | ring_buffer = (volatile struct ring_buffer*) mmap(0, 0x1000, PROT_READ|PROT_WRITE, |
| 34 | MAP_SHARED, mem_fd, RCIN_PRUSS_SHAREDRAM_BASE); |
| 35 | close(mem_fd); |
| 36 | ring_buffer->ring_head = 0; |
| 37 | _s0_time = 0; |
| 38 | |
| 39 | // enable the spektrum RC input power |
| 40 | hal.gpio->pinMode(BBB_P8_17, HAL_GPIO_OUTPUT); |
| 41 | hal.gpio->write(BBB_P8_17, 1); |
| 42 | } |
| 43 | |
| 44 | /* |
| 45 | called at 1kHz to check for new pulse capture data from the PRU |