mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 22:17:01 +08:00
[ArDrone] Add protection to lowlevel driver that can short-circuit the board.
This commit is contained in:
@@ -52,7 +52,7 @@
|
|||||||
*/
|
*/
|
||||||
int mot_fd; /**< File descriptor for the port */
|
int mot_fd; /**< File descriptor for the port */
|
||||||
|
|
||||||
#define ARDRONE_GPIO_PORT 0 // Dummy for paparazzi compatibility
|
#define ARDRONE_GPIO_PORT 0x32524
|
||||||
|
|
||||||
#define ARDRONE_GPIO_PIN_MOTOR1 171
|
#define ARDRONE_GPIO_PIN_MOTOR1 171
|
||||||
#define ARDRONE_GPIO_PIN_MOTOR2 172
|
#define ARDRONE_GPIO_PIN_MOTOR2 172
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ struct gpio_direction {
|
|||||||
|
|
||||||
void gpio_set(uint32_t port, uint16_t pin)
|
void gpio_set(uint32_t port, uint16_t pin)
|
||||||
{
|
{
|
||||||
|
if (port != 0x32524) return; // protect ardrone board from unauthorized use
|
||||||
struct gpio_data data;
|
struct gpio_data data;
|
||||||
// Open the device if not open
|
// Open the device if not open
|
||||||
if (gpiofp == 0)
|
if (gpiofp == 0)
|
||||||
@@ -67,6 +68,7 @@ void gpio_set(uint32_t port, uint16_t pin)
|
|||||||
|
|
||||||
void gpio_clear(uint32_t port, uint16_t pin)
|
void gpio_clear(uint32_t port, uint16_t pin)
|
||||||
{
|
{
|
||||||
|
if (port != 0x32524) return; // protect ardrone board from unauthorized use
|
||||||
struct gpio_data data;
|
struct gpio_data data;
|
||||||
// Open the device if not open
|
// Open the device if not open
|
||||||
if (gpiofp == 0)
|
if (gpiofp == 0)
|
||||||
@@ -81,6 +83,7 @@ void gpio_clear(uint32_t port, uint16_t pin)
|
|||||||
|
|
||||||
void gpio_setup_input(uint32_t port, uint16_t pin)
|
void gpio_setup_input(uint32_t port, uint16_t pin)
|
||||||
{
|
{
|
||||||
|
if (port != 0x32524) return; // protect ardrone board from unauthorized use
|
||||||
struct gpio_direction dir;
|
struct gpio_direction dir;
|
||||||
// Open the device if not open
|
// Open the device if not open
|
||||||
if (gpiofp == 0)
|
if (gpiofp == 0)
|
||||||
@@ -95,6 +98,7 @@ void gpio_setup_input(uint32_t port, uint16_t pin)
|
|||||||
|
|
||||||
void gpio_setup_output(uint32_t port, uint16_t pin)
|
void gpio_setup_output(uint32_t port, uint16_t pin)
|
||||||
{
|
{
|
||||||
|
if (port != 0x32524) return; // protect ardrone board from unauthorized use
|
||||||
struct gpio_direction dir;
|
struct gpio_direction dir;
|
||||||
// Open the device if not open
|
// Open the device if not open
|
||||||
if (gpiofp == 0)
|
if (gpiofp == 0)
|
||||||
@@ -108,8 +112,9 @@ void gpio_setup_output(uint32_t port, uint16_t pin)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint16_t gpio_get(uint32_t gpioport, uint16_t pin)
|
uint16_t gpio_get(uint32_t port, uint16_t pin)
|
||||||
{
|
{
|
||||||
|
if (port != 0x32524) return 0; // protect ardrone board from unauthorized use
|
||||||
struct gpio_data data;
|
struct gpio_data data;
|
||||||
// Open the device if not open
|
// Open the device if not open
|
||||||
if (gpiofp == 0)
|
if (gpiofp == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user