Skip to content

Fix issue if a pin has no peripheral #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cores/arduino/stm32/spi_com.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb)

/* Pins MOSI/MISO/SCLK must not be NP. ssel can be NP. */
if(spi_mosi == NP || spi_miso == NP || spi_sclk == NP) {
printf("ERROR: at least one SPI pin has no peripheral\n");
return;
}

Expand Down
6 changes: 6 additions & 0 deletions cores/arduino/stm32/twi.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ void i2c_custom_init(i2c_t *obj, i2c_timing_e timing, uint32_t addressingMode, u
I2C_TypeDef *i2c_sda = pinmap_peripheral(obj->sda, PinMap_I2C_SDA);
I2C_TypeDef *i2c_scl = pinmap_peripheral(obj->scl, PinMap_I2C_SCL);

//Pins SDA/SCL must not be NP
if(i2c_sda == NP || i2c_scl == NP) {
printf("ERROR: at least one I2C pin has no peripheral\n");
return;
}

obj->i2c = pinmap_merge_peripheral(i2c_sda, i2c_scl);

if(obj->i2c == NP) {
Expand Down
6 changes: 6 additions & 0 deletions cores/arduino/stm32/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ void uart_init(serial_t *obj)
USART_TypeDef *uart_tx = pinmap_peripheral(obj->pin_tx, PinMap_UART_TX);
USART_TypeDef *uart_rx = pinmap_peripheral(obj->pin_rx, PinMap_UART_RX);

//Pins Rx/Tx must not be NP
if(uart_rx == NP || uart_tx == NP) {
printf("ERROR: at least one UART pin has no peripheral\n");
return;
}

// Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object
obj->uart = pinmap_merge_peripheral(uart_tx, uart_rx);

Expand Down