Hello.
I recently moved to PlatformIO, because my main code editor is Vim.
My code is:
#include <stm32l0xx.h>
#include <stm32l0xx_hal.h>
#include <stm32l0xx_hal_gpio.h>int main(void)
{
HAL_Init();__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();GPIO_InitTypeDef gpio;
gpio.Pin = GPIO_PIN_5;
gpio.Mode = GPIO_MODE_OUTPUT_PP;
gpio.Pull = GPIO_NOPULL;
gpio.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &gpio);gpio.Pin = GPIO_PIN_13; // konfigurujemy pin 13
gpio.Mode = GPIO_MODE_INPUT; // jako wejście
gpio.Pull = GPIO_PULLUP; // włączamy rezystor podciągający
HAL_GPIO_Init(GPIOC, &gpio); // port GPIOCwhile (1)
{
if (HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_RESET) { // jesli przycisk jest przycisniety,
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); // zapal diode
} else {
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
}
}
}
which is meant to light the LED on board after pressing a button.
Yet… after uploading it with PlatformIO Led lights we acting weirdly, I have to press two buttons at once.
I tried the same code on OpenSTM32, and it works just fine.
My board is Nucleo L073RZ if it helps.
Also, my platformio.ini:
[env:nucleo_l073rz]
platform = ststm32
board = nucleo_l073rz
framework = stm32cube
I’m under Arch Linux.