Navio: GPIO driver command fix and update ifdefs

This commit is contained in:
Hidenori 2016-07-19 11:00:49 -04:00 committed by Lorenz Meier
parent 3049b9af01
commit ff647e7bc8
4 changed files with 23 additions and 17 deletions

View File

@ -145,10 +145,10 @@ int navio_gpio_main(int argc, char *argv[])
}
if (!strcmp(argv[1], "start")) {
PX4_WARN("gpio should only be started directly for debugging");
if (gpio != nullptr && gpio->isMapped()) {
PX4_WARN("already mapped");
/* this is not an error */
return 0;
}
@ -156,13 +156,14 @@ int navio_gpio_main(int argc, char *argv[])
if (gpio == nullptr) {
PX4_ERR("alloc failed");
return -1;
return 1;
}
int ret = gpio->start();
if (ret != 0) {
PX4_ERR("start failed");
return 1;
}
return 0;
@ -170,12 +171,16 @@ int navio_gpio_main(int argc, char *argv[])
if (!strcmp(argv[1], "stop")) {
if (gpio == nullptr || gpio->isMapped()) {
PX4_WARN("not mapped");
/* this is not an error */
if (gpio == nullptr) {
PX4_WARN("gpio not started from navio_gpio");
return 0;
}
if (!gpio->isMapped()) {
PX4_WARN("not mapped");
return 1;
}
gpio->stop();
delete gpio;
@ -185,7 +190,12 @@ int navio_gpio_main(int argc, char *argv[])
}
if (!strcmp(argv[1], "status")) {
if (gpio != nullptr && gpio->isMapped()) {
if (gpio == nullptr) {
PX4_WARN("gpio not started from navio_gpio");
return 0;
}
if (gpio->isMapped()) {
PX4_INFO("mapped");
} else {

View File

@ -86,13 +86,10 @@ namespace navio_gpio
class Gpio
{
public:
Gpio() :
_isMapped(false)
{
}
Gpio()
{ }
~Gpio()
{
}
{ }
int start();
int stop();
@ -102,7 +99,7 @@ public:
bool gpioread(uint32_t pinset);
void gpiowrite(uint32_t pinset, bool value);
bool isMapped() { return _isMapped; }
bool isMapped() { return _gpio_map != nullptr; }
private:
void atomic_modify(uint32_t addr,
@ -111,7 +108,6 @@ private:
unsigned int value);
void *_gpio_map;
bool _isMapped;
SyncObj m_lock;
};

View File

@ -59,7 +59,7 @@ __END_DECLS
# define HW_ARCH "EAGLE"
#elif defined(CONFIG_ARCH_BOARD_EXCELSIOR)
# define HW_ARCH "EXCELSIOR"
#elif defined(CONFIG_ARCH_BOARD_RPI) || defined(CONFIG_ARCH_BOARD_NAVIO2)
#elif defined(CONFIG_ARCH_BOARD_RPI)
# define HW_ARCH "RPI"
#elif defined(CONFIG_ARCH_BOARD_BEBOP)
# define HW_ARCH "BEBOP"

View File

@ -267,7 +267,7 @@ int led_init()
{
blink_msg_end = 0;
#ifndef CONFIG_ARCH_BOARD_NAVIO2
#ifndef CONFIG_ARCH_BOARD_RPI
/* first open normal LEDs */
DevMgr::getHandle(LED0_DEVICE_PATH, h_leds);
@ -305,7 +305,7 @@ int led_init()
void led_deinit()
{
#ifndef CONFIG_ARCH_BOARD_NAVIO2
#ifndef CONFIG_ARCH_BOARD_RPI
DevMgr::releaseHandle(h_leds);
#endif
DevMgr::releaseHandle(h_rgbleds);