2013-01-01 03:15:43 -04:00
|
|
|
#include <AP_HAL.h>
|
|
|
|
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "Console.h"
|
2013-01-02 20:03:05 -04:00
|
|
|
#include "UARTDriver.h"
|
2013-01-01 03:15:43 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
using namespace PX4;
|
|
|
|
|
|
|
|
PX4ConsoleDriver::PX4ConsoleDriver() {}
|
|
|
|
|
2013-01-02 20:03:05 -04:00
|
|
|
void PX4ConsoleDriver::init(void* uart)
|
2013-01-01 03:15:43 -04:00
|
|
|
{
|
2013-01-02 20:03:05 -04:00
|
|
|
_uart = (PX4UARTDriver *)uart;
|
2013-01-01 03:15:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PX4ConsoleDriver::backend_open()
|
|
|
|
{}
|
|
|
|
|
|
|
|
void PX4ConsoleDriver::backend_close()
|
|
|
|
{}
|
|
|
|
|
|
|
|
size_t PX4ConsoleDriver::backend_read(uint8_t *data, size_t len) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t PX4ConsoleDriver::backend_write(const uint8_t *data, size_t len) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PX4ConsoleDriver::print_P(const prog_char_t *pstr) {
|
|
|
|
print(pstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PX4ConsoleDriver::println_P(const prog_char_t *pstr) {
|
|
|
|
println(pstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PX4ConsoleDriver::printf(const char *fmt, ...) {
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
2013-01-02 20:03:05 -04:00
|
|
|
_uart->vprintf(fmt, ap);
|
2013-01-01 03:15:43 -04:00
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PX4ConsoleDriver::_printf_P(const prog_char *fmt, ...) {
|
|
|
|
va_list ap;
|
2013-01-02 20:03:05 -04:00
|
|
|
va_start(ap, fmt);
|
|
|
|
_uart->vprintf(fmt, ap);
|
2013-01-01 03:15:43 -04:00
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PX4ConsoleDriver::vprintf(const char *fmt, va_list ap) {
|
2013-01-02 20:03:05 -04:00
|
|
|
_uart->vprintf(fmt, ap);
|
2013-01-01 03:15:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PX4ConsoleDriver::vprintf_P(const prog_char *fmt, va_list ap) {
|
2013-01-02 20:03:05 -04:00
|
|
|
_uart->vprintf(fmt, ap);
|
2013-01-01 03:15:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int16_t PX4ConsoleDriver::available() {
|
2013-01-02 20:03:05 -04:00
|
|
|
return _uart->available();
|
2013-01-01 03:15:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int16_t PX4ConsoleDriver::txspace() {
|
2013-01-02 20:03:05 -04:00
|
|
|
return _uart->txspace();
|
2013-01-01 03:15:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int16_t PX4ConsoleDriver::read() {
|
2013-01-02 20:03:05 -04:00
|
|
|
return _uart->read();
|
2013-01-01 03:15:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t PX4ConsoleDriver::write(uint8_t c) {
|
2013-01-02 20:03:05 -04:00
|
|
|
return _uart->write(c);
|
2013-01-01 03:15:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|