Skip to content

Commit 9b463b0

Browse files
committed
RPI: core dump
1 parent b09d2a8 commit 9b463b0

5 files changed

Lines changed: 11 additions & 6 deletions

File tree

ArduinoCore-Linux/cores/rasperry_pi/HardwareGPIO_RPI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace arduino {
1313
static std::map<pin_size_t, gpiod_line*> gpio_lines;
1414
static gpiod_chip* gpio_chip = nullptr;
1515

16-
HardwareGPIO_RPI::HardwareGPIO_RPI() {
16+
HardwareGPIO_RPI::begin() {
1717
Logger.warning("Activating Rasperry PI: GPIO");
18-
gpio_chip = gpiod_chip_open_by_name("gpiochip0");
18+
gpio_chip = gpiod_chip_open_by_name(device_name);
1919
if (!gpio_chip) {
20-
Logger.error("HardwareGPIO_RPI", "Failed to open gpiochip0");
20+
Logger.error("HardwareGPIO_RPI", "Failed to open", device_name);
2121
} else {
2222
is_open = true;
2323
}

ArduinoCore-Linux/cores/rasperry_pi/HardwareGPIO_RPI.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ class HardwareGPIO_RPI : public HardwareGPIO {
2424
/**
2525
* @brief Constructor for HardwareGPIO_RPI.
2626
*/
27-
HardwareGPIO_RPI();
27+
HardwareGPIO_RPI() = default;
28+
HardwareGPIO_RPI(const char* devName) : device_name(devName) {}
2829

2930
/**
3031
* @brief Destructor for HardwareGPIO_RPI.
3132
*/
3233
~HardwareGPIO_RPI();
3334

35+
void begin();
36+
3437
/**
3538
* @brief Set the mode of a GPIO pin (INPUT, OUTPUT, etc).
3639
*/
@@ -108,6 +111,7 @@ class HardwareGPIO_RPI : public HardwareGPIO {
108111
/** PWM-capable pins on Raspberry Pi */
109112
int pwm_pins[4] = {12, 13, 18, 19};
110113
bool is_open = false;
114+
const char* device_name = "gpiochip0"
111115
};
112116

113117
} // namespace arduino

ArduinoCore-Linux/cores/rasperry_pi/HardwareI2C_RPI.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class HardwareI2C_RPI : public HardwareI2C {
2424
public:
2525
HardwareI2C_RPI(const char* device = "/dev/i2c-1") {
2626
i2c_device = device;
27-
begin();
2827
}
2928
~HardwareI2C_RPI() {
3029
end();

ArduinoCore-Linux/cores/rasperry_pi/HardwareSPI_RPI.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ namespace arduino {
1616
HardwareSPI_RPI::HardwareSPI_RPI(const char* device) {
1717
spi_fd = -1;
1818
this->device = device;
19-
begin();
2019
}
2120

2221
HardwareSPI_RPI::~HardwareSPI_RPI() {

ArduinoCore-Linux/cores/rasperry_pi/HardwareSetupRPI.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class HardwareSetupRPI {
3030
*/
3131
bool begin() {
3232
Logger.info("Using Raspberry Pi hardware interfaces");
33+
gpio.begin();
34+
i2c.begin();
35+
spi.begin();
3336
Hardware.gpio = &gpio;
3437
Hardware.i2c = &i2c;
3538
Hardware.spi = &spi;

0 commit comments

Comments
 (0)