This commit is contained in:
Filipriec
2025-11-06 11:48:52 +01:00
parent a56cd2f92c
commit 7e7f4b471a
2 changed files with 30 additions and 42 deletions

View File

@@ -70,6 +70,7 @@
echo " - Target : $MBED_TARGET"
echo " - Compiler : ${armGcc}"
echo " - Commands : mbed-tools, pyocd, openocd, st-flash"
echo "probe-rs run --chip STM32U575ZITxQ cmake_build/NUCLEO_U575ZI_Q/develop/GCC_ARM/mbed-os-example-blinky.elf"
echo
'';
};

View File

@@ -1,60 +1,47 @@
// main.cpp
#include "mbed.h"
#define MAXIMUM_BUFFER_SIZE 32
/*
* Copyright (c) 2020 Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*/
#include "mbed.h"
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalIn button(PC_13);
Thread thread;
#define MAXIMUM_BUFFER_SIZE 32
volatile bool led_on = false;
EventFlags flag;
static BufferedSerial serial_port(USBTX, USBRX);
int another_press(int press_num) {
press_num += 1;
if (press_num >= 8) {
press_num = 0;
};
return press_num;
}
void set_led(int number) {
led1 = (number & 1) ? 1 : 0;
led2 = (number & 2) ? 1 : 0;
led3 = (number & 4) ? 1 : 0;
}
int main()
{
void led2_thread() {
serial_port.set_baud(9600);
serial_port.set_format(
/* bits */ 8,
/* parity */ BufferedSerial::None,
/* stop bit */ 1
);
char buf[MAXIMUM_BUFFER_SIZE] = {0};
int num_presses = 0;
while (1) {
led1 = 0;
led2 = 0;
led3 = 0;
/* stop bit */ 1);
while (true) {
if (uint32_t num = serial_port.read(buf, sizeof(buf))) {
num_presses = another_press(num_presses);
set_led(num_presses);
// Echo the input back to the terminal.
serial_port.write(buf, num);
while (num == 0) {
ThisThread::sleep_for(10ms);
serial_port.write(buf, num_presses);
}
}
ThisThread::sleep_for(150ms);
thread.start(led2_thread);
led2 = !led2;
ThisThread::sleep_for(1000);
}
}
int main()
{
while (true) {
led1 = !led1;
ThisThread::sleep_for(500);
}
}