mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-02 14:13:42 -04:00
7ac51f60d0
This commit changes the way libraries headers are included in source files: - If the header is in the same directory the source belongs to, so the notation '#include ""' is used with the path relative to the directory containing the source. - If the header is outside the directory containing the source, then we use the notation '#include <>' with the path relative to libraries folder. Some of the advantages of such approach: - Only one search path for libraries headers. - OSs like Windows may have a better lookup time.
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#include <AP_HAL/AP_HAL.h>
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
|
#include <stdio.h>
|
|
#include <sys/time.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <poll.h>
|
|
#include <sys/mman.h>
|
|
#include <sys/stat.h>
|
|
#include <stdint.h>
|
|
|
|
#include "GPIO.h"
|
|
#include "RCInput.h"
|
|
|
|
extern const AP_HAL::HAL& hal;
|
|
|
|
using namespace Linux;
|
|
|
|
void LinuxRCInput_ZYNQ::init(void*)
|
|
{
|
|
int mem_fd = open("/dev/mem", O_RDWR|O_SYNC);
|
|
if (mem_fd == -1) {
|
|
hal.scheduler->panic("Unable to open /dev/mem");
|
|
}
|
|
pulse_input = (volatile uint32_t*) mmap(0, 0x1000, PROT_READ|PROT_WRITE,
|
|
MAP_SHARED, mem_fd, RCIN_ZYNQ_PULSE_INPUT_BASE);
|
|
close(mem_fd);
|
|
|
|
_s0_time = 0;
|
|
}
|
|
|
|
/*
|
|
called at 1kHz to check for new pulse capture data from the PL pulse timer
|
|
*/
|
|
void LinuxRCInput_ZYNQ::_timer_tick()
|
|
{
|
|
uint32_t v;
|
|
|
|
// all F's means no samples available
|
|
while((v = *pulse_input) != 0xffffffff) {
|
|
// Hi bit indicates pin state, low bits denote pulse length
|
|
if(!(v & 0x80000000))
|
|
_s0_time = (v & 0x7fffffff)/TICK_PER_US;
|
|
else
|
|
_process_rc_pulse(_s0_time, (v & 0x7fffffff)/TICK_PER_US);
|
|
}
|
|
}
|
|
|
|
#endif // CONFIG_HAL_BOARD
|