osd: rename driver to atxxxx

This commit is contained in:
Beat Küng
2019-02-19 10:55:55 +01:00
committed by Daniele Pettenuzzo
parent c3f9294b49
commit 717e52fa57
6 changed files with 103 additions and 62 deletions
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
#
# OmnibusF4SD specific board extras init
#------------------------------------------------------------------------------
if ! param compare OSD_ATXXXX_CFG 0
then
atxxxx start
fi
+3 -8
View File
@@ -1,6 +1,6 @@
############################################################################ ############################################################################
# #
# Copyright (c) 2018 PX4 Development Team. All rights reserved. # Copyright (c) 2019 PX4 Development Team. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
@@ -30,10 +30,5 @@
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
# #
############################################################################ ############################################################################
px4_add_module(
MODULE drivers__osd add_subdirectory(atxxxx)
MAIN osd
SRCS
osd.cpp
)
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
+38
View File
@@ -0,0 +1,38 @@
############################################################################
#
# Copyright (c) 2018-2019 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
px4_add_module(
MODULE drivers__atxxxx
MAIN atxxxx
SRCS
atxxxx.cpp
)
@@ -32,21 +32,20 @@
****************************************************************************/ ****************************************************************************/
/** /**
* @file osd.cpp * @file atxxxx.cpp
* @author Daniele Pettenuzzo * @author Daniele Pettenuzzo
* *
* Driver for the ATXXXX chip on the omnibus fcu connected via SPI. * Driver for the ATXXXX chip on the omnibus fcu connected via SPI.
*/ */
#include "osd.h" #include "atxxxx.h"
OSD::OSD(int bus) : OSDatxxxx::OSDatxxxx(int bus) :
SPI("OSD", OSD_DEVICE_PATH, bus, OSD_SPIDEV, SPIDEV_MODE0, OSD_SPI_BUS_SPEED), SPI("OSD", OSD_DEVICE_PATH, bus, OSD_SPIDEV, SPIDEV_MODE0, OSD_SPI_BUS_SPEED),
_measure_ticks(0), _measure_ticks(0),
_sample_perf(perf_alloc(PC_ELAPSED, "osd_read")), _sample_perf(perf_alloc(PC_ELAPSED, "osd_read")),
_comms_errors(perf_alloc(PC_COUNT, "osd_com_err")), _comms_errors(perf_alloc(PC_COUNT, "osd_com_err")),
_tx_mode(1),
_battery_sub(-1), _battery_sub(-1),
_local_position_sub(-1), _local_position_sub(-1),
_vehicle_status_sub(-1), _vehicle_status_sub(-1),
@@ -58,18 +57,14 @@ OSD::OSD(int bus) :
_arming_state(1), _arming_state(1),
_arming_timestamp(0) _arming_timestamp(0)
{ {
// enable debug() calls _p_tx_mode = param_find("OSD_ATXXXX_CFG");
_debug_enabled = false; param_get(_p_tx_mode, &_tx_mode);
// get params
_p_tx_mode = param_find("OSD_TX_MODE");
param_get(_p_tx_mode, (int32_t *)&_tx_mode);
// work_cancel in the dtor will explode if we don't do this... // work_cancel in the dtor will explode if we don't do this...
memset(&_work, 0, sizeof(_work)); memset(&_work, 0, sizeof(_work));
} }
OSD::~OSD() OSDatxxxx::~OSDatxxxx()
{ {
/* make sure we are truly inactive */ /* make sure we are truly inactive */
stop(); stop();
@@ -81,7 +76,7 @@ OSD::~OSD()
int int
OSD::init() OSDatxxxx::init()
{ {
/* do SPI init (and probe) first */ /* do SPI init (and probe) first */
if (SPI::init() != PX4_OK) { if (SPI::init() != PX4_OK) {
@@ -115,7 +110,7 @@ fail:
int int
OSD::probe() OSDatxxxx::probe()
{ {
uint8_t data = 0; uint8_t data = 0;
int ret = PX4_OK; int ret = PX4_OK;
@@ -131,12 +126,12 @@ OSD::probe()
} }
int int
OSD::init_osd() OSDatxxxx::init_osd()
{ {
int ret = PX4_OK; int ret = PX4_OK;
uint8_t data = OSD_ZERO_BYTE; uint8_t data = OSD_ZERO_BYTE;
if (_tx_mode) { if (_tx_mode == 2) {
data |= OSD_PAL_TX_MODE; data |= OSD_PAL_TX_MODE;
} }
@@ -155,20 +150,20 @@ OSD::init_osd()
int int
OSD::ioctl(device::file_t *filp, int cmd, unsigned long arg) OSDatxxxx::ioctl(device::file_t *filp, int cmd, unsigned long arg)
{ {
return -1; return -1;
} }
ssize_t ssize_t
OSD::read(device::file_t *filp, char *buffer, size_t buflen) OSDatxxxx::read(device::file_t *filp, char *buffer, size_t buflen)
{ {
return -1; return -1;
} }
int int
OSD::readRegister(unsigned reg, uint8_t *data, unsigned count) OSDatxxxx::readRegister(unsigned reg, uint8_t *data, unsigned count)
{ {
uint8_t cmd[5]; // read up to 4 bytes uint8_t cmd[5]; // read up to 4 bytes
int ret; int ret;
@@ -191,7 +186,7 @@ OSD::readRegister(unsigned reg, uint8_t *data, unsigned count)
int int
OSD::writeRegister(unsigned reg, uint8_t data) OSDatxxxx::writeRegister(unsigned reg, uint8_t data)
{ {
uint8_t cmd[2]; // write 1 byte uint8_t cmd[2]; // write 1 byte
int ret; int ret;
@@ -212,7 +207,7 @@ OSD::writeRegister(unsigned reg, uint8_t data)
} }
int int
OSD::add_character_to_screen(char c, uint8_t pos_x, uint8_t pos_y) OSDatxxxx::add_character_to_screen(char c, uint8_t pos_x, uint8_t pos_y)
{ {
uint16_t position = (OSD_CHARS_PER_ROW * pos_y) + pos_x; uint16_t position = (OSD_CHARS_PER_ROW * pos_y) + pos_x;
@@ -235,13 +230,13 @@ OSD::add_character_to_screen(char c, uint8_t pos_x, uint8_t pos_y)
} }
int int
OSD::add_battery_symbol(uint8_t pos_x, uint8_t pos_y) OSDatxxxx::add_battery_symbol(uint8_t pos_x, uint8_t pos_y)
{ {
return add_character_to_screen(146, pos_x, pos_y); return add_character_to_screen(146, pos_x, pos_y);
} }
int int
OSD::add_battery_info(uint8_t pos_x, uint8_t pos_y) OSDatxxxx::add_battery_info(uint8_t pos_x, uint8_t pos_y)
{ {
char buf[5]; char buf[5];
int ret = PX4_OK; int ret = PX4_OK;
@@ -268,13 +263,13 @@ OSD::add_battery_info(uint8_t pos_x, uint8_t pos_y)
} }
int int
OSD::add_altitude_symbol(uint8_t pos_x, uint8_t pos_y) OSDatxxxx::add_altitude_symbol(uint8_t pos_x, uint8_t pos_y)
{ {
return add_character_to_screen(154, pos_x, pos_y); return add_character_to_screen(154, pos_x, pos_y);
} }
int int
OSD::add_altitude(uint8_t pos_x, uint8_t pos_y) OSDatxxxx::add_altitude(uint8_t pos_x, uint8_t pos_y)
{ {
char buf[5]; char buf[5];
int ret = PX4_OK; int ret = PX4_OK;
@@ -291,13 +286,13 @@ OSD::add_altitude(uint8_t pos_x, uint8_t pos_y)
} }
int int
OSD::add_flighttime_symbol(uint8_t pos_x, uint8_t pos_y) OSDatxxxx::add_flighttime_symbol(uint8_t pos_x, uint8_t pos_y)
{ {
return add_character_to_screen(112, pos_x, pos_y); return add_character_to_screen(112, pos_x, pos_y);
} }
int int
OSD::add_flighttime(float flight_time, uint8_t pos_x, uint8_t pos_y) OSDatxxxx::add_flighttime(float flight_time, uint8_t pos_x, uint8_t pos_y)
{ {
char buf[6]; char buf[6];
int ret = PX4_OK; int ret = PX4_OK;
@@ -312,7 +307,7 @@ OSD::add_flighttime(float flight_time, uint8_t pos_x, uint8_t pos_y)
} }
int int
OSD::enable_screen() OSDatxxxx::enable_screen()
{ {
uint8_t data; uint8_t data;
int ret = PX4_OK; int ret = PX4_OK;
@@ -324,7 +319,7 @@ OSD::enable_screen()
} }
int int
OSD::disable_screen() OSDatxxxx::disable_screen()
{ {
uint8_t data; uint8_t data;
int ret = PX4_OK; int ret = PX4_OK;
@@ -337,7 +332,7 @@ OSD::disable_screen()
int int
OSD::update_topics()//TODO have an argument to choose what to update and return validity OSDatxxxx::update_topics()//TODO have an argument to choose what to update and return validity
{ {
struct battery_status_s battery = {}; struct battery_status_s battery = {};
// struct vehicle_local_position_s local_position = {}; // struct vehicle_local_position_s local_position = {};
@@ -419,7 +414,7 @@ OSD::update_topics()//TODO have an argument to choose what to update and return
int int
OSD::update_screen() OSDatxxxx::update_screen()
{ {
int ret = PX4_OK; int ret = PX4_OK;
@@ -447,20 +442,20 @@ OSD::update_screen()
void void
OSD::start() OSDatxxxx::start()
{ {
/* schedule a cycle to start things */ /* schedule a cycle to start things */
work_queue(LPWORK, &_work, (worker_t)&OSD::cycle_trampoline, this, USEC2TICK(OSD_US)); work_queue(LPWORK, &_work, (worker_t)&OSDatxxxx::cycle_trampoline, this, USEC2TICK(OSD_US));
} }
void void
OSD::stop() OSDatxxxx::stop()
{ {
work_cancel(LPWORK, &_work); work_cancel(LPWORK, &_work);
} }
int int
OSD::reset() OSDatxxxx::reset()
{ {
int ret = writeRegister(0x00, 0x02); int ret = writeRegister(0x00, 0x02);
usleep(100); usleep(100);
@@ -469,15 +464,15 @@ OSD::reset()
} }
void void
OSD::cycle_trampoline(void *arg) OSDatxxxx::cycle_trampoline(void *arg)
{ {
OSD *dev = (OSD *)arg; OSDatxxxx *dev = (OSDatxxxx *)arg;
dev->cycle(); dev->cycle();
} }
void void
OSD::cycle() OSDatxxxx::cycle()
{ {
update_topics(); update_topics();
@@ -488,14 +483,14 @@ OSD::cycle()
/* schedule a fresh cycle call when the measurement is done */ /* schedule a fresh cycle call when the measurement is done */
work_queue(LPWORK, work_queue(LPWORK,
&_work, &_work,
(worker_t)&OSD::cycle_trampoline, (worker_t)&OSDatxxxx::cycle_trampoline,
this, this,
USEC2TICK(OSD_UPDATE_RATE)); USEC2TICK(OSD_UPDATE_RATE));
} }
void void
OSD::print_info() OSDatxxxx::print_info()
{ {
perf_print_counter(_sample_perf); perf_print_counter(_sample_perf);
perf_print_counter(_comms_errors); perf_print_counter(_comms_errors);
@@ -513,7 +508,7 @@ OSD::print_info()
namespace osd namespace osd
{ {
OSD *g_dev; OSDatxxxx *g_dev;
int start(int spi_bus); int start(int spi_bus);
int stop(); int stop();
@@ -535,7 +530,7 @@ start(int spi_bus)
} }
/* create the driver */ /* create the driver */
g_dev = new OSD(spi_bus); g_dev = new OSDatxxxx(spi_bus);
if (g_dev == nullptr) { if (g_dev == nullptr) {
goto fail; goto fail;
@@ -606,7 +601,7 @@ info()
*/ */
void usage() void usage()
{ {
PX4_INFO("usage: osd {start|stop|status'}"); PX4_INFO("usage: atxxxx {start|stop|status'}");
PX4_INFO(" [-b SPI_BUS]"); PX4_INFO(" [-b SPI_BUS]");
} }
@@ -614,7 +609,7 @@ void usage()
int int
osd_main(int argc, char *argv[]) atxxxx_main(int argc, char *argv[])
{ {
if (argc < 2) { if (argc < 2) {
osd::usage(); osd::usage();
@@ -34,7 +34,7 @@
#pragma once #pragma once
/** /**
* @file osd.h * @file atxxxx.h
* @author Daniele Pettenuzzo * @author Daniele Pettenuzzo
* *
* Driver for the ATXXXX chip on the omnibus fcu connected via SPI. * Driver for the ATXXXX chip on the omnibus fcu connected via SPI.
@@ -92,12 +92,12 @@
# error This requires CONFIG_SCHED_WORKQUEUE. # error This requires CONFIG_SCHED_WORKQUEUE.
#endif #endif
class OSD : public device::SPI class OSDatxxxx : public device::SPI
{ {
public: public:
OSD(int bus = OSD_BUS); OSDatxxxx(int bus = OSD_BUS);
virtual ~OSD(); virtual ~OSDatxxxx();
virtual int init(); virtual int init();
@@ -196,4 +196,4 @@ private:
/* /*
* Driver 'main' command. * Driver 'main' command.
*/ */
extern "C" __EXPORT int osd_main(int argc, char *argv[]); extern "C" __EXPORT int atxxxx_main(int argc, char *argv[]);
@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
* *
* Copyright (c) 2018 PX4 Development Team. All rights reserved. * Copyright (c) 2018-2019 PX4 Development Team. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@@ -32,14 +32,16 @@
****************************************************************************/ ****************************************************************************/
/** /**
* ATXXX OSD Chip * Enable/Disable the ATXXX OSD Chip
* *
* Select Transmission Standard * Configure the ATXXXX OSD Chip (mounted on the OmnibusF4SD board) and
* select the transmission standard.
* *
* @value 0 NTSC * @value 0 Disabled
* @value 1 PAL * @value 1 NTSC
* @value 2 PAL
* *
* @reboot_required true * @reboot_required true
* *
*/ */
PARAM_DEFINE_INT32(OSD_TX_MODE, 0); PARAM_DEFINE_INT32(OSD_ATXXXX_CFG, 0);