2016-02-17 21:25:26 -04:00
|
|
|
#pragma once
|
2014-09-18 10:35:22 -03:00
|
|
|
|
2014-11-05 09:56:12 -04:00
|
|
|
#include <stdint.h>
|
2015-08-11 03:28:43 -03:00
|
|
|
#include "AP_HAL_Linux.h"
|
2014-09-18 10:35:22 -03:00
|
|
|
|
|
|
|
#define LOW 0
|
|
|
|
#define HIGH 1
|
|
|
|
|
|
|
|
#define PAGE_SIZE (4*1024)
|
|
|
|
#define BLOCK_SIZE (4*1024)
|
|
|
|
|
|
|
|
// Raspberry Pi GPIO mapping
|
2016-06-20 11:10:59 -03:00
|
|
|
#define RPI_GPIO_2 2 // Pin 3
|
|
|
|
#define RPI_GPIO_3 3 // Pin 5
|
|
|
|
#define RPI_GPIO_4 4 // Pin 7
|
|
|
|
#define RPI_GPIO_5 5 // Pin 29
|
|
|
|
#define RPI_GPIO_6 6 // Pin 31
|
|
|
|
#define RPI_GPIO_7 7 // Pin 26
|
|
|
|
#define RPI_GPIO_8 8 // Pin 24
|
|
|
|
#define RPI_GPIO_9 9 // Pin 21
|
|
|
|
#define RPI_GPIO_10 10 // Pin 19
|
|
|
|
#define RPI_GPIO_11 11 // Pin 23
|
|
|
|
#define RPI_GPIO_12 12 // Pin 32
|
|
|
|
#define RPI_GPIO_13 13 // Pin 33
|
|
|
|
#define RPI_GPIO_14 14 // Pin 8
|
|
|
|
#define RPI_GPIO_15 15 // Pin 10
|
2015-08-17 23:32:29 -03:00
|
|
|
#define RPI_GPIO_16 16 // Pin 36
|
2016-06-20 11:10:59 -03:00
|
|
|
#define RPI_GPIO_17 17 // Pin 11
|
|
|
|
#define RPI_GPIO_18 18 // Pin 12
|
|
|
|
#define RPI_GPIO_19 19 // Pin 35
|
|
|
|
#define RPI_GPIO_20 20 // Pin 38
|
|
|
|
#define RPI_GPIO_21 21 // Pin 40
|
|
|
|
#define RPI_GPIO_22 22 // Pin 15
|
|
|
|
#define RPI_GPIO_23 23 // Pin 16
|
|
|
|
#define RPI_GPIO_24 24 // Pin 18
|
|
|
|
#define RPI_GPIO_25 25 // Pin 22
|
|
|
|
#define RPI_GPIO_26 26 // Pin 37
|
2015-08-17 23:32:29 -03:00
|
|
|
#define RPI_GPIO_27 27 // Pin 13
|
2014-09-18 10:35:22 -03:00
|
|
|
#define RPI_GPIO_28 28 // Pin 3
|
|
|
|
#define RPI_GPIO_29 29 // Pin 4
|
|
|
|
#define RPI_GPIO_30 30 // Pin 5
|
|
|
|
#define RPI_GPIO_31 31 // Pin 6
|
|
|
|
|
2016-07-29 16:14:02 -03:00
|
|
|
namespace Linux {
|
|
|
|
|
|
|
|
class GPIO_RPI : public AP_HAL::GPIO {
|
2014-09-18 10:35:22 -03:00
|
|
|
public:
|
2015-10-20 18:13:25 -03:00
|
|
|
GPIO_RPI();
|
2019-08-15 01:02:02 -03:00
|
|
|
void init() override;
|
|
|
|
void pinMode(uint8_t pin, uint8_t output) override;
|
|
|
|
void pinMode(uint8_t pin, uint8_t output, uint8_t alt) override;
|
|
|
|
uint8_t read(uint8_t pin) override;
|
|
|
|
void write(uint8_t pin, uint8_t value) override;
|
|
|
|
void toggle(uint8_t pin) override;
|
2014-09-18 10:35:22 -03:00
|
|
|
|
|
|
|
/* Alternative interface: */
|
2019-08-15 01:02:02 -03:00
|
|
|
AP_HAL::DigitalSource* channel(uint16_t n) override;
|
2014-09-18 10:35:22 -03:00
|
|
|
|
|
|
|
/* return true if USB cable is connected */
|
2019-08-15 01:02:02 -03:00
|
|
|
bool usb_connected(void) override;
|
2016-06-20 11:10:59 -03:00
|
|
|
|
|
|
|
private:
|
|
|
|
volatile uint32_t *_gpio;
|
2014-09-18 10:35:22 -03:00
|
|
|
};
|
2016-07-29 16:14:02 -03:00
|
|
|
|
|
|
|
}
|