forked from Archive/PX4-Autopilot
remove unused pca8574 and oreoled drivers
This commit is contained in:
parent
b4709d229a
commit
6ab5c2170e
|
@ -30,7 +30,6 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/rgbled
|
||||
magnetometer # all available magnetometer drivers
|
||||
mkblctrl
|
||||
|
|
|
@ -30,13 +30,11 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/rgbled
|
||||
#lights/rgbled_pwm
|
||||
magnetometer # all available magnetometer drivers
|
||||
#md25
|
||||
mkblctrl
|
||||
lights/pca8574
|
||||
#optical_flow # all available optical flow drivers
|
||||
#optical_flow/pmw3901
|
||||
optical_flow/px4flow
|
||||
|
|
|
@ -32,8 +32,6 @@ px4_add_board(
|
|||
#imu # all available imu drivers
|
||||
irlock
|
||||
lights/blinkm
|
||||
#lights/oreoled
|
||||
#lights/pca8574
|
||||
#lights/rgbled
|
||||
#lights/rgbled_ncp5623c
|
||||
#lights/rgbled_pwm
|
||||
|
|
|
@ -35,8 +35,6 @@ px4_add_board(
|
|||
imu/icm20948
|
||||
irlock
|
||||
#lights/blinkm
|
||||
#lights/oreoled
|
||||
#lights/pca8574
|
||||
lights/rgbled
|
||||
magnetometer # all available magnetometer drivers
|
||||
#md25
|
||||
|
|
|
@ -32,7 +32,6 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
lights/rgbled_pwm
|
||||
|
|
|
@ -25,7 +25,6 @@ px4_add_board(
|
|||
imu/mpu6000
|
||||
#irlock
|
||||
#lights/blinkm
|
||||
#lights/oreoled
|
||||
lights/rgbled
|
||||
#magnetometer # all available magnetometer drivers
|
||||
magnetometer/hmc5883
|
||||
|
|
|
@ -42,7 +42,6 @@ px4_add_board(
|
|||
#iridiumsbd
|
||||
#irlock
|
||||
#lights/blinkm
|
||||
#lights/oreoled
|
||||
lights/rgbled
|
||||
#magnetometer # all available magnetometer drivers
|
||||
magnetometer/hmc5883
|
||||
|
|
|
@ -39,7 +39,6 @@ px4_add_board(
|
|||
#iridiumsbd
|
||||
irlock
|
||||
#lights/blinkm
|
||||
#lights/oreoled
|
||||
lights/rgbled
|
||||
#magnetometer # all available magnetometer drivers
|
||||
magnetometer/hmc5883
|
||||
|
|
|
@ -39,7 +39,6 @@ px4_add_board(
|
|||
#iridiumsbd
|
||||
#irlock
|
||||
#lights/blinkm
|
||||
#lights/oreoled
|
||||
lights/rgbled
|
||||
#magnetometer # all available magnetometer drivers
|
||||
magnetometer/hmc5883
|
||||
|
|
|
@ -38,14 +38,12 @@ px4_add_board(
|
|||
imu/icm20948
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
#lights/rgbled_pwm
|
||||
magnetometer # all available magnetometer drivers
|
||||
#md25
|
||||
mkblctrl
|
||||
lights/pca8574
|
||||
#optical_flow # all available optical flow drivers
|
||||
optical_flow/px4flow
|
||||
pca9685
|
||||
|
|
|
@ -37,7 +37,6 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
#lights/rgbled_pwm
|
||||
|
@ -46,7 +45,6 @@ px4_add_board(
|
|||
mkblctrl
|
||||
#optical_flow # all available optical flow drivers
|
||||
optical_flow/px4flow
|
||||
lights/pca8574
|
||||
pca9685
|
||||
protocol_splitter
|
||||
pwm_input
|
||||
|
|
|
@ -37,8 +37,6 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/pca8574
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
#lights/rgbled_pwm
|
||||
|
|
|
@ -28,7 +28,6 @@ px4_add_board(
|
|||
imu # all available imu drivers
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
magnetometer # all available magnetometer drivers
|
||||
|
|
|
@ -28,7 +28,6 @@ px4_add_board(
|
|||
imu # all available imu drivers
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
magnetometer # all available magnetometer drivers
|
||||
|
|
|
@ -28,7 +28,6 @@ px4_add_board(
|
|||
imu # all available imu drivers
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
magnetometer # all available magnetometer drivers
|
||||
|
|
|
@ -36,8 +36,6 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/pca8574
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
#lights/rgbled_pwm
|
||||
|
|
|
@ -35,14 +35,12 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
#lights/rgbled_pwm
|
||||
magnetometer # all available magnetometer drivers
|
||||
#md25
|
||||
mkblctrl
|
||||
lights/pca8574
|
||||
#optical_flow # all available optical flow drivers
|
||||
optical_flow/px4flow
|
||||
pca9685
|
||||
|
|
|
@ -35,8 +35,6 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/pca8574
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
lights/rgbled_pwm
|
||||
|
|
|
@ -35,8 +35,6 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/pca8574
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
lights/rgbled_pwm
|
||||
|
|
|
@ -35,8 +35,6 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/pca8574
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
lights/rgbled_pwm
|
||||
|
|
|
@ -29,7 +29,6 @@ px4_add_board(
|
|||
imu/mpu6000
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
lights/rgbled_pwm
|
||||
|
|
|
@ -26,7 +26,6 @@ px4_add_board(
|
|||
gps
|
||||
imu/bmi055
|
||||
imu/mpu6000
|
||||
lights/pca8574
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
lights/rgbled_pwm
|
||||
|
|
|
@ -34,8 +34,6 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/pca8574
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
lights/rgbled_pwm
|
||||
|
|
|
@ -34,8 +34,6 @@ px4_add_board(
|
|||
#imu/mpu9250
|
||||
#irlock
|
||||
#lights/blinkm
|
||||
#lights/oreoled
|
||||
lights/pca8574
|
||||
lights/rgbled
|
||||
#lights/rgbled_ncp5623c
|
||||
lights/rgbled_pwm
|
||||
|
|
|
@ -36,8 +36,6 @@ px4_add_board(
|
|||
imu/mpu6000
|
||||
irlock
|
||||
lights/blinkm
|
||||
lights/oreoled
|
||||
lights/pca8574
|
||||
lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
magnetometer # all available magnetometer drivers
|
||||
|
|
|
@ -31,7 +31,6 @@ px4_add_board(
|
|||
imu/mpu9250
|
||||
irlock
|
||||
#lights/blinkm
|
||||
#lights/oreoled
|
||||
#lights/rgbled
|
||||
lights/rgbled_ncp5623c
|
||||
#magnetometer # all available magnetometer drivers
|
||||
|
|
|
@ -1,219 +0,0 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012-2013 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file drv_oreoled.h
|
||||
*
|
||||
* Oreo led device API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/* oreoled device path */
|
||||
#define OREOLED0_DEVICE_PATH "/dev/oreoled0"
|
||||
|
||||
/*
|
||||
* ioctl() definitions
|
||||
*/
|
||||
|
||||
#define _OREOLEDIOCBASE (0x2d00)
|
||||
#define _OREOLEDIOC(_n) (_IOC(_OREOLEDIOCBASE, _n))
|
||||
|
||||
/** set constant RGB values */
|
||||
#define OREOLED_SET_RGB _OREOLEDIOC(1)
|
||||
|
||||
/** run macro */
|
||||
#define OREOLED_RUN_MACRO _OREOLEDIOC(2)
|
||||
|
||||
/** send bytes */
|
||||
#define OREOLED_SEND_BYTES _OREOLEDIOC(3)
|
||||
|
||||
/** send reset */
|
||||
#define OREOLED_SEND_RESET _OREOLEDIOC(4)
|
||||
|
||||
/** boot ping */
|
||||
#define OREOLED_BL_PING _OREOLEDIOC(5)
|
||||
|
||||
/** boot version */
|
||||
#define OREOLED_BL_VER _OREOLEDIOC(6)
|
||||
|
||||
/** boot write flash */
|
||||
#define OREOLED_BL_FLASH _OREOLEDIOC(7)
|
||||
|
||||
/** boot application version */
|
||||
#define OREOLED_BL_APP_VER _OREOLEDIOC(8)
|
||||
|
||||
/** boot application crc */
|
||||
#define OREOLED_BL_APP_CRC _OREOLEDIOC(9)
|
||||
|
||||
/** boot startup colour */
|
||||
#define OREOLED_BL_SET_COLOUR _OREOLEDIOC(10)
|
||||
|
||||
/** boot application */
|
||||
#define OREOLED_BL_BOOT_APP _OREOLEDIOC(11)
|
||||
|
||||
/** force an i2c gencall */
|
||||
#define OREOLED_FORCE_SYNC _OREOLEDIOC(12)
|
||||
|
||||
/* Oreo LED driver supports up to 4 leds */
|
||||
#define OREOLED_NUM_LEDS 4
|
||||
|
||||
/* instance of 0xff means apply to all instances */
|
||||
#define OREOLED_ALL_INSTANCES 0xff
|
||||
|
||||
/* maximum command length that can be sent to LEDs */
|
||||
#define OREOLED_CMD_LENGTH_MAX 70
|
||||
|
||||
/* maximum command length that can be read from LEDs */
|
||||
#define OREOLED_CMD_READ_LENGTH_MAX 10
|
||||
|
||||
/* maximum number of commands retries */
|
||||
#define OEROLED_COMMAND_RETRIES 10
|
||||
|
||||
/* magic number used to verify the software reset is valid */
|
||||
#define OEROLED_RESET_NONCE 0x2A
|
||||
|
||||
/* microseconds to hold-off between write and reads */
|
||||
#define OREOLED_WRITE_READ_HOLDOFF_US 500
|
||||
|
||||
/* microseconds to hold-off between retries */
|
||||
#define OREOLED_RETRY_HOLDOFF_US 200
|
||||
|
||||
#define OEROLED_BOOT_COMMAND_RETRIES 25
|
||||
#define OREOLED_BOOT_FLASH_WAITMS 10
|
||||
|
||||
#define OREOLED_BOOT_SUPPORTED_VER 0x01
|
||||
|
||||
#define OREOLED_BOOT_CMD_PING 0x40
|
||||
#define OREOLED_BOOT_CMD_BL_VER 0x41
|
||||
#define OREOLED_BOOT_CMD_APP_VER 0x42
|
||||
#define OREOLED_BOOT_CMD_APP_CRC 0x43
|
||||
#define OREOLED_BOOT_CMD_SET_COLOUR 0x44
|
||||
|
||||
#define OREOLED_BOOT_CMD_WRITE_FLASH_A 0x50
|
||||
#define OREOLED_BOOT_CMD_WRITE_FLASH_B 0x51
|
||||
#define OREOLED_BOOT_CMD_FINALISE_FLASH 0x55
|
||||
|
||||
#define OREOLED_BOOT_CMD_BOOT_APP 0x60
|
||||
|
||||
#define OREOLED_BOOT_CMD_PING_NONCE 0x2A
|
||||
#define OREOLED_BOOT_CMD_BOOT_NONCE 0xA2
|
||||
|
||||
#define OREOLED_FW_FILE_HEADER_LENGTH 2
|
||||
#define OREOLED_FW_FILE_SIZE_LIMIT 6144
|
||||
#define OREOLED_FW_FILE "/etc/firmware/oreoled.bin"
|
||||
|
||||
/* enum passed to OREOLED_SET_MODE ioctl()
|
||||
* defined by hardware */
|
||||
enum oreoled_pattern {
|
||||
OREOLED_PATTERN_OFF = 0,
|
||||
OREOLED_PATTERN_SINE = 1,
|
||||
OREOLED_PATTERN_SOLID = 2,
|
||||
OREOLED_PATTERN_SIREN = 3,
|
||||
OREOLED_PATTERN_STROBE = 4,
|
||||
OREOLED_PATTERN_FADEIN = 5,
|
||||
OREOLED_PATTERN_FADEOUT = 6,
|
||||
OREOLED_PATTERN_PARAMUPDATE = 7,
|
||||
OREOLED_PATTERN_ENUM_COUNT
|
||||
};
|
||||
|
||||
/* enum passed to OREOLED_SET_MODE ioctl()
|
||||
* defined by hardware */
|
||||
enum oreoled_param {
|
||||
OREOLED_PARAM_BIAS_RED = 0,
|
||||
OREOLED_PARAM_BIAS_GREEN = 1,
|
||||
OREOLED_PARAM_BIAS_BLUE = 2,
|
||||
OREOLED_PARAM_AMPLITUDE_RED = 3,
|
||||
OREOLED_PARAM_AMPLITUDE_GREEN = 4,
|
||||
OREOLED_PARAM_AMPLITUDE_BLUE = 5,
|
||||
OREOLED_PARAM_PERIOD = 6,
|
||||
OREOLED_PARAM_REPEAT = 7,
|
||||
OREOLED_PARAM_PHASEOFFSET = 8,
|
||||
OREOLED_PARAM_MACRO = 9,
|
||||
OREOLED_PARAM_RESET = 10,
|
||||
OREOLED_PARAM_APP_CHECKSUM = 11,
|
||||
OREOLED_PARAM_ENUM_COUNT
|
||||
};
|
||||
|
||||
/* enum of available macros
|
||||
* defined by hardware */
|
||||
enum oreoled_macro {
|
||||
OREOLED_PARAM_MACRO_RESET = 0,
|
||||
OREOLED_PARAM_MACRO_COLOUR_CYCLE = 1,
|
||||
OREOLED_PARAM_MACRO_BREATH = 2,
|
||||
OREOLED_PARAM_MACRO_STROBE = 3,
|
||||
OREOLED_PARAM_MACRO_FADEIN = 4,
|
||||
OREOLED_PARAM_MACRO_FADEOUT = 5,
|
||||
OREOLED_PARAM_MACRO_RED = 6,
|
||||
OREOLED_PARAM_MACRO_GREEN = 7,
|
||||
OREOLED_PARAM_MACRO_BLUE = 8,
|
||||
OREOLED_PARAM_MACRO_YELLOW = 9,
|
||||
OREOLED_PARAM_MACRO_WHITE = 10,
|
||||
OREOLED_PARAM_MACRO_AUTOMOBILE = 11,
|
||||
OREOLED_PARAM_MACRO_AVIATION = 12,
|
||||
OREOLED_PARAM_MACRO_ENUM_COUNT
|
||||
};
|
||||
|
||||
/*
|
||||
structure passed to OREOLED_SET_RGB ioctl()
|
||||
Note that the driver scales the brightness to 0 to 255, regardless
|
||||
of the hardware scaling
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t instance;
|
||||
oreoled_pattern pattern;
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
} oreoled_rgbset_t;
|
||||
|
||||
/*
|
||||
structure passed to OREOLED_RUN_MACRO ioctl()
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t instance;
|
||||
oreoled_macro macro;
|
||||
} oreoled_macrorun_t;
|
||||
|
||||
/*
|
||||
structure passed to send_bytes method (only used for testing)
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t led_num;
|
||||
uint8_t num_bytes;
|
||||
uint8_t buff[OREOLED_CMD_LENGTH_MAX];
|
||||
} oreoled_cmd_t;
|
||||
|
|
@ -32,8 +32,6 @@
|
|||
############################################################################
|
||||
|
||||
add_subdirectory(blinkm)
|
||||
add_subdirectory(oreoled)
|
||||
add_subdirectory(pca8574)
|
||||
add_subdirectory(rgbled)
|
||||
add_subdirectory(rgbled_ncp5623c)
|
||||
add_subdirectory(rgbled_pwm)
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2015 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__oreoled
|
||||
MAIN oreoled
|
||||
COMPILE_FLAGS
|
||||
SRCS
|
||||
oreoled.cpp
|
||||
DEPENDS
|
||||
)
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,40 +0,0 @@
|
|||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2015 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__pca8574
|
||||
MAIN pca8574
|
||||
COMPILE_FLAGS
|
||||
SRCS
|
||||
pca8574.cpp
|
||||
DEPENDS
|
||||
)
|
|
@ -1,520 +0,0 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012-2014 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file pca8574.cpp
|
||||
*
|
||||
* Driver for an 8 I/O controller (PC8574) connected via I2C.
|
||||
*
|
||||
* @author Lorenz Meier <lm@inf.ethz.ch>
|
||||
* @author Julian Oes <joes@student.ethz.ch>
|
||||
* @author Anton Babushkin <anton.babushkin@me.com>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <drivers/device/i2c.h>
|
||||
#include <drivers/drv_io_expander.h>
|
||||
#include <px4_getopt.h>
|
||||
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
|
||||
#include <systemlib/err.h>
|
||||
|
||||
|
||||
#define PCA8574_ONTIME 120
|
||||
#define PCA8574_OFFTIME 120
|
||||
#define PCA8574_DEVICE_PATH "/dev/pca8574"
|
||||
|
||||
#define ADDR 0x20 ///< I2C adress of PCA8574 (default, A0-A2 pulled to GND)
|
||||
|
||||
class PCA8574 : public device::I2C, public px4::ScheduledWorkItem
|
||||
{
|
||||
public:
|
||||
PCA8574(int bus, int pca8574);
|
||||
virtual ~PCA8574() = default;
|
||||
|
||||
virtual int probe();
|
||||
virtual int info();
|
||||
virtual int ioctl(struct file *filp, int cmd, unsigned long arg);
|
||||
bool is_running() { return _running; }
|
||||
|
||||
private:
|
||||
uint8_t _values_out;
|
||||
uint8_t _values_in;
|
||||
uint8_t _blinking;
|
||||
uint8_t _blink_phase;
|
||||
|
||||
enum IOX_MODE _mode;
|
||||
bool _running;
|
||||
int _led_interval;
|
||||
bool _should_run;
|
||||
bool _update_out;
|
||||
int _counter;
|
||||
|
||||
void Run() override;
|
||||
|
||||
int send_led_enable(uint8_t arg);
|
||||
int send_led_values();
|
||||
|
||||
int get(uint8_t &vals);
|
||||
};
|
||||
|
||||
/* for now, we only support one PCA8574 */
|
||||
namespace
|
||||
{
|
||||
PCA8574 *g_pca8574;
|
||||
}
|
||||
|
||||
void pca8574_usage();
|
||||
|
||||
extern "C" __EXPORT int pca8574_main(int argc, char *argv[]);
|
||||
|
||||
PCA8574::PCA8574(int bus, int pca8574) :
|
||||
I2C("pca8574", PCA8574_DEVICE_PATH, bus, pca8574, 100000),
|
||||
ScheduledWorkItem(px4::device_bus_to_wq(get_device_id())),
|
||||
_values_out(0),
|
||||
_values_in(0),
|
||||
_blinking(0),
|
||||
_blink_phase(0),
|
||||
_mode(IOX_MODE_OFF),
|
||||
_running(false),
|
||||
_led_interval(80),
|
||||
_should_run(false),
|
||||
_update_out(false),
|
||||
_counter(0)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
PCA8574::probe()
|
||||
{
|
||||
uint8_t val;
|
||||
return get(val);
|
||||
}
|
||||
|
||||
int
|
||||
PCA8574::info()
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
PCA8574::ioctl(struct file *filp, int cmd, unsigned long arg)
|
||||
{
|
||||
int ret = ENOTTY;
|
||||
|
||||
switch (cmd) {
|
||||
case IOX_SET_VALUE ...(IOX_SET_VALUE + 8): {
|
||||
// set the specified on / off state
|
||||
uint8_t position = (1 << (cmd - IOX_SET_VALUE));
|
||||
uint8_t prev = _values_out;
|
||||
|
||||
if (arg) {
|
||||
_values_out |= position;
|
||||
|
||||
} else {
|
||||
_values_out &= ~(position);
|
||||
}
|
||||
|
||||
if (_values_out != prev) {
|
||||
if (_values_out) {
|
||||
_mode = IOX_MODE_ON;
|
||||
}
|
||||
|
||||
send_led_values();
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
case IOX_SET_MASK:
|
||||
send_led_enable(arg);
|
||||
return OK;
|
||||
|
||||
case IOX_GET_MASK: {
|
||||
uint8_t val;
|
||||
ret = get(val);
|
||||
|
||||
if (ret == OK) {
|
||||
return val;
|
||||
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
case IOX_SET_MODE:
|
||||
|
||||
if (_mode != (IOX_MODE)arg) {
|
||||
|
||||
switch ((IOX_MODE)arg) {
|
||||
case IOX_MODE_OFF:
|
||||
_values_out = 0xFF;
|
||||
break;
|
||||
|
||||
case IOX_MODE_ON:
|
||||
_values_out = 0;
|
||||
break;
|
||||
|
||||
case IOX_MODE_TEST_OUT:
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
_mode = (IOX_MODE)arg;
|
||||
send_led_values();
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
default:
|
||||
// see if the parent class can make any use of it
|
||||
ret = CDev::ioctl(filp, cmd, arg);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main loop function
|
||||
*/
|
||||
void
|
||||
PCA8574::Run()
|
||||
{
|
||||
if (_mode == IOX_MODE_TEST_OUT) {
|
||||
|
||||
// we count only seven states
|
||||
_counter &= 0xF;
|
||||
_counter++;
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (i < _counter) {
|
||||
_values_out |= (1 << i);
|
||||
|
||||
} else {
|
||||
_values_out &= ~(1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
_update_out = true;
|
||||
_should_run = true;
|
||||
|
||||
} else if (_mode == IOX_MODE_OFF) {
|
||||
_update_out = true;
|
||||
_should_run = false;
|
||||
|
||||
} else {
|
||||
|
||||
// Any of the normal modes
|
||||
if (_blinking > 0) {
|
||||
/* we need to be running to blink */
|
||||
_should_run = true;
|
||||
|
||||
} else {
|
||||
_should_run = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_update_out) {
|
||||
uint8_t msg;
|
||||
|
||||
if (_blinking) {
|
||||
msg = (_values_out & _blinking & _blink_phase);
|
||||
|
||||
// wipe out all positions that are marked as blinking
|
||||
msg &= ~(_blinking);
|
||||
|
||||
// fill blink positions
|
||||
msg |= ((_blink_phase) ? _blinking : 0);
|
||||
|
||||
_blink_phase = !_blink_phase;
|
||||
|
||||
} else {
|
||||
msg = _values_out;
|
||||
}
|
||||
|
||||
int ret = transfer(&msg, sizeof(msg), nullptr, 0);
|
||||
|
||||
if (!ret) {
|
||||
_update_out = false;
|
||||
}
|
||||
}
|
||||
|
||||
// check if any activity remains, else stp
|
||||
if (!_should_run) {
|
||||
_running = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// re-queue ourselves to run again later
|
||||
_running = true;
|
||||
|
||||
ScheduleDelayed(_led_interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sent ENABLE flag to LED driver
|
||||
*/
|
||||
int
|
||||
PCA8574::send_led_enable(uint8_t arg)
|
||||
{
|
||||
int ret = transfer(&arg, sizeof(arg), nullptr, 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 8 outputs
|
||||
*/
|
||||
int
|
||||
PCA8574::send_led_values()
|
||||
{
|
||||
_update_out = true;
|
||||
|
||||
// if not active, kick it
|
||||
if (!_running) {
|
||||
_running = true;
|
||||
ScheduleNow();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
PCA8574::get(uint8_t &vals)
|
||||
{
|
||||
uint8_t result;
|
||||
int ret;
|
||||
|
||||
ret = transfer(nullptr, 0, &result, 1);
|
||||
|
||||
if (ret == OK) {
|
||||
_values_in = result;
|
||||
vals = result;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
pca8574_usage()
|
||||
{
|
||||
warnx("missing command: try 'start', 'test', 'info', 'off', 'stop', 'val 0 1'");
|
||||
warnx("options:");
|
||||
warnx(" -b i2cbus (%d)", PX4_I2C_BUS_LED);
|
||||
warnx(" -a addr (0x%x)", ADDR);
|
||||
}
|
||||
|
||||
int
|
||||
pca8574_main(int argc, char *argv[])
|
||||
{
|
||||
int i2cdevice = -1;
|
||||
int pca8574adr = ADDR; // 7bit
|
||||
|
||||
int myoptind = 1;
|
||||
int ch;
|
||||
const char *myoptarg = nullptr;
|
||||
|
||||
|
||||
// jump over start/off/etc and look at options first
|
||||
while ((ch = px4_getopt(argc, argv, "a:b:", &myoptind, &myoptarg)) != EOF) {
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
pca8574adr = strtol(myoptarg, NULL, 0);
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
i2cdevice = strtol(myoptarg, NULL, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
pca8574_usage();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (myoptind >= argc) {
|
||||
pca8574_usage();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
const char *verb = argv[myoptind];
|
||||
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
if (!strcmp(verb, "start")) {
|
||||
if (g_pca8574 != nullptr) {
|
||||
errx(1, "already started");
|
||||
}
|
||||
|
||||
if (i2cdevice == -1) {
|
||||
// try the external bus first
|
||||
i2cdevice = PX4_I2C_BUS_EXPANSION;
|
||||
g_pca8574 = new PCA8574(PX4_I2C_BUS_EXPANSION, pca8574adr);
|
||||
|
||||
if (g_pca8574 != nullptr && OK != g_pca8574->init()) {
|
||||
delete g_pca8574;
|
||||
g_pca8574 = nullptr;
|
||||
}
|
||||
|
||||
if (g_pca8574 == nullptr) {
|
||||
// fall back to default bus
|
||||
if (PX4_I2C_BUS_LED == PX4_I2C_BUS_EXPANSION) {
|
||||
errx(1, "init failed");
|
||||
}
|
||||
|
||||
i2cdevice = PX4_I2C_BUS_LED;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_pca8574 == nullptr) {
|
||||
g_pca8574 = new PCA8574(i2cdevice, pca8574adr);
|
||||
|
||||
if (g_pca8574 == nullptr) {
|
||||
errx(1, "new failed");
|
||||
}
|
||||
|
||||
if (OK != g_pca8574->init()) {
|
||||
delete g_pca8574;
|
||||
g_pca8574 = nullptr;
|
||||
errx(1, "init failed");
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// need the driver past this point
|
||||
if (g_pca8574 == nullptr) {
|
||||
warnx("not started, run pca8574 start");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!strcmp(verb, "test")) {
|
||||
fd = open(PCA8574_DEVICE_PATH, 0);
|
||||
|
||||
if (fd == -1) {
|
||||
errx(1, "Unable to open " PCA8574_DEVICE_PATH);
|
||||
}
|
||||
|
||||
ret = ioctl(fd, IOX_SET_MODE, (unsigned long)IOX_MODE_TEST_OUT);
|
||||
|
||||
close(fd);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
if (!strcmp(verb, "info")) {
|
||||
g_pca8574->info();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!strcmp(verb, "off")) {
|
||||
fd = open(PCA8574_DEVICE_PATH, 0);
|
||||
|
||||
if (fd < 0) {
|
||||
errx(1, "Unable to open " PCA8574_DEVICE_PATH);
|
||||
}
|
||||
|
||||
ret = ioctl(fd, IOX_SET_MODE, (unsigned long)IOX_MODE_OFF);
|
||||
close(fd);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
if (!strcmp(verb, "stop")) {
|
||||
fd = open(PCA8574_DEVICE_PATH, 0);
|
||||
|
||||
if (fd == -1) {
|
||||
errx(1, "Unable to open " PCA8574_DEVICE_PATH);
|
||||
}
|
||||
|
||||
ret = ioctl(fd, IOX_SET_MODE, (unsigned long)IOX_MODE_OFF);
|
||||
close(fd);
|
||||
|
||||
// wait until we're not running any more
|
||||
for (unsigned i = 0; i < 15; i++) {
|
||||
if (!g_pca8574->is_running()) {
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(50000);
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
|
||||
if (!g_pca8574->is_running()) {
|
||||
delete g_pca8574;
|
||||
g_pca8574 = nullptr;
|
||||
exit(0);
|
||||
|
||||
} else {
|
||||
warnx("stop failed.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(verb, "val")) {
|
||||
if (argc < 4) {
|
||||
errx(1, "Usage: pca8574 val <channel> <0 or 1>");
|
||||
}
|
||||
|
||||
fd = open(PCA8574_DEVICE_PATH, 0);
|
||||
|
||||
if (fd == -1) {
|
||||
errx(1, "Unable to open " PCA8574_DEVICE_PATH);
|
||||
}
|
||||
|
||||
unsigned channel = strtol(argv[2], NULL, 0);
|
||||
unsigned val = strtol(argv[3], NULL, 0);
|
||||
|
||||
if (channel < 8) {
|
||||
ret = ioctl(fd, (IOX_SET_VALUE + channel), val);
|
||||
|
||||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
pca8574_usage();
|
||||
exit(0);
|
||||
}
|
Loading…
Reference in New Issue