hod5b
This commit is contained in:
@@ -70,6 +70,7 @@
|
|||||||
echo " - Target : $MBED_TARGET"
|
echo " - Target : $MBED_TARGET"
|
||||||
echo " - Compiler : ${armGcc}"
|
echo " - Compiler : ${armGcc}"
|
||||||
echo " - Commands : mbed-tools, pyocd, openocd, st-flash"
|
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
|
echo
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,60 +1,47 @@
|
|||||||
// main.cpp
|
// 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 led1(LED1);
|
||||||
DigitalOut led2(LED2);
|
DigitalOut led2(LED2);
|
||||||
DigitalOut led3(LED3);
|
|
||||||
DigitalIn button(PC_13);
|
DigitalIn button(PC_13);
|
||||||
|
|
||||||
|
Thread thread;
|
||||||
|
#define MAXIMUM_BUFFER_SIZE 32
|
||||||
|
|
||||||
|
volatile bool led_on = false;
|
||||||
|
EventFlags flag;
|
||||||
|
|
||||||
static BufferedSerial serial_port(USBTX, USBRX);
|
static BufferedSerial serial_port(USBTX, USBRX);
|
||||||
|
|
||||||
int another_press(int press_num) {
|
void led2_thread() {
|
||||||
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()
|
|
||||||
{
|
|
||||||
serial_port.set_baud(9600);
|
serial_port.set_baud(9600);
|
||||||
serial_port.set_format(
|
serial_port.set_format(
|
||||||
/* bits */ 8,
|
/* bits */ 8,
|
||||||
/* parity */ BufferedSerial::None,
|
/* parity */ BufferedSerial::None,
|
||||||
/* stop bit */ 1
|
/* stop bit */ 1);
|
||||||
);
|
while (true) {
|
||||||
|
|
||||||
char buf[MAXIMUM_BUFFER_SIZE] = {0};
|
|
||||||
|
|
||||||
int num_presses = 0;
|
|
||||||
while (1) {
|
|
||||||
led1 = 0;
|
|
||||||
led2 = 0;
|
|
||||||
led3 = 0;
|
|
||||||
|
|
||||||
if (uint32_t num = serial_port.read(buf, sizeof(buf))) {
|
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.
|
// Echo the input back to the terminal.
|
||||||
serial_port.write(buf, num);
|
serial_port.write(buf, num_presses);
|
||||||
|
|
||||||
while (num == 0) {
|
|
||||||
ThisThread::sleep_for(10ms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
thread.start(led2_thread);
|
||||||
|
led2 = !led2;
|
||||||
ThisThread::sleep_for(150ms);
|
ThisThread::sleep_for(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
led1 = !led1;
|
||||||
|
ThisThread::sleep_for(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user