mirror of https://github.com/ArduPilot/ardupilot
HAL_PX4: added uartD
This commit is contained in:
parent
c000a08d6f
commit
0b25ff0a16
|
@ -46,17 +46,20 @@ static PX4GPIO gpioDriver;
|
||||||
#define UARTA_DEFAULT_DEVICE "/dev/ttyACM0"
|
#define UARTA_DEFAULT_DEVICE "/dev/ttyACM0"
|
||||||
#define UARTB_DEFAULT_DEVICE "/dev/ttyS3"
|
#define UARTB_DEFAULT_DEVICE "/dev/ttyS3"
|
||||||
#define UARTC_DEFAULT_DEVICE "/dev/ttyS1"
|
#define UARTC_DEFAULT_DEVICE "/dev/ttyS1"
|
||||||
|
#define UARTD_DEFAULT_DEVICE "/dev/null"
|
||||||
|
|
||||||
// 3 UART drivers, for GPS plus two mavlink-enabled devices
|
// 3 UART drivers, for GPS plus two mavlink-enabled devices
|
||||||
static PX4UARTDriver uartADriver(UARTA_DEFAULT_DEVICE, "APM_uartA");
|
static PX4UARTDriver uartADriver(UARTA_DEFAULT_DEVICE, "APM_uartA");
|
||||||
static PX4UARTDriver uartBDriver(UARTB_DEFAULT_DEVICE, "APM_uartB");
|
static PX4UARTDriver uartBDriver(UARTB_DEFAULT_DEVICE, "APM_uartB");
|
||||||
static PX4UARTDriver uartCDriver(UARTC_DEFAULT_DEVICE, "APM_uartC");
|
static PX4UARTDriver uartCDriver(UARTC_DEFAULT_DEVICE, "APM_uartC");
|
||||||
|
static PX4UARTDriver uartDDriver(UARTD_DEFAULT_DEVICE, "APM_uartD");
|
||||||
|
|
||||||
HAL_PX4::HAL_PX4() :
|
HAL_PX4::HAL_PX4() :
|
||||||
AP_HAL::HAL(
|
AP_HAL::HAL(
|
||||||
&uartADriver, /* uartA */
|
&uartADriver, /* uartA */
|
||||||
&uartBDriver, /* uartB */
|
&uartBDriver, /* uartB */
|
||||||
&uartCDriver, /* uartC */
|
&uartCDriver, /* uartC */
|
||||||
|
&uartDDriver, /* uartD */
|
||||||
&i2cDriver, /* i2c */
|
&i2cDriver, /* i2c */
|
||||||
&spiDeviceManager, /* spi */
|
&spiDeviceManager, /* spi */
|
||||||
&analogIn, /* analogin */
|
&analogIn, /* analogin */
|
||||||
|
@ -107,6 +110,7 @@ static int main_loop(int argc, char **argv)
|
||||||
hal.uartA->begin(115200);
|
hal.uartA->begin(115200);
|
||||||
hal.uartB->begin(38400);
|
hal.uartB->begin(38400);
|
||||||
hal.uartC->begin(57600);
|
hal.uartC->begin(57600);
|
||||||
|
hal.uartD->begin(57600);
|
||||||
hal.scheduler->init(NULL);
|
hal.scheduler->init(NULL);
|
||||||
hal.rcin->init(NULL);
|
hal.rcin->init(NULL);
|
||||||
hal.rcout->init(NULL);
|
hal.rcout->init(NULL);
|
||||||
|
@ -188,6 +192,7 @@ void HAL_PX4::init(int argc, char * const argv[]) const
|
||||||
int i;
|
int i;
|
||||||
const char *deviceA = UARTA_DEFAULT_DEVICE;
|
const char *deviceA = UARTA_DEFAULT_DEVICE;
|
||||||
const char *deviceC = UARTC_DEFAULT_DEVICE;
|
const char *deviceC = UARTC_DEFAULT_DEVICE;
|
||||||
|
const char *deviceD = UARTD_DEFAULT_DEVICE;
|
||||||
|
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
printf("%s: missing command (try '%s start')",
|
printf("%s: missing command (try '%s start')",
|
||||||
|
@ -206,8 +211,9 @@ void HAL_PX4::init(int argc, char * const argv[]) const
|
||||||
|
|
||||||
uartADriver.set_device_path(deviceA);
|
uartADriver.set_device_path(deviceA);
|
||||||
uartCDriver.set_device_path(deviceC);
|
uartCDriver.set_device_path(deviceC);
|
||||||
printf("Starting %s on %s and %s\n",
|
uartDDriver.set_device_path(deviceD);
|
||||||
SKETCHNAME, deviceA, deviceC);
|
printf("Starting %s uartA=%s uartC=%s uartD=%s\n",
|
||||||
|
SKETCHNAME, deviceA, deviceC, deviceD);
|
||||||
|
|
||||||
_px4_thread_should_exit = false;
|
_px4_thread_should_exit = false;
|
||||||
daemon_task = task_spawn_cmd(SKETCHNAME,
|
daemon_task = task_spawn_cmd(SKETCHNAME,
|
||||||
|
@ -256,6 +262,17 @@ void HAL_PX4::init(int argc, char * const argv[]) const
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(argv[i], "-d3") == 0) {
|
||||||
|
// set uartD terminal device
|
||||||
|
if (argc > i + 1) {
|
||||||
|
deviceD = strdup(argv[i+1]);
|
||||||
|
} else {
|
||||||
|
printf("missing parameter to -d3 DEVICE\n");
|
||||||
|
usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usage();
|
usage();
|
||||||
|
|
|
@ -282,6 +282,7 @@ void *PX4Scheduler::_uart_thread(void)
|
||||||
((PX4UARTDriver *)hal.uartA)->_timer_tick();
|
((PX4UARTDriver *)hal.uartA)->_timer_tick();
|
||||||
((PX4UARTDriver *)hal.uartB)->_timer_tick();
|
((PX4UARTDriver *)hal.uartB)->_timer_tick();
|
||||||
((PX4UARTDriver *)hal.uartC)->_timer_tick();
|
((PX4UARTDriver *)hal.uartC)->_timer_tick();
|
||||||
|
((PX4UARTDriver *)hal.uartD)->_timer_tick();
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
void PX4UARTDriver::begin(uint32_t b, uint16_t rxS, uint16_t txS)
|
void PX4UARTDriver::begin(uint32_t b, uint16_t rxS, uint16_t txS)
|
||||||
{
|
{
|
||||||
|
if (strcmp(_devpath, "/dev/null") == 0) {
|
||||||
|
// leave uninitialised
|
||||||
|
return;
|
||||||
|
}
|
||||||
// on PX4 we have enough memory to have a larger transmit and
|
// on PX4 we have enough memory to have a larger transmit and
|
||||||
// receive buffer for all ports. This means we don't get delays
|
// receive buffer for all ports. This means we don't get delays
|
||||||
// while waiting to write GPS config packets
|
// while waiting to write GPS config packets
|
||||||
|
|
Loading…
Reference in New Issue