getting started with stm32nucleo and arm mbedproduct’scompliance w.r.t. specific requirements....
TRANSCRIPT
Getting started with
STM32Nucleo and ARM mbed
Davide Aliprandi
November 20th, 2017
Introduction to ARM mbed
2
What is ARM ____ ? 3
• ARM mbed™ is an online development environment for rapid prototyping of
applications based on ARM Cortex M™ microcontrollers
• Easiness of use
• Object Oriented C++ API
• Open source reusable software libraries and examples
• Oriented to embedded devices and Internet of Things (IoT)
• Big online community
• Forum for help and support
• mbed platform is owned and maintained by ARM
• ST is an official mbed partner
STM32 ARM mbed ecosystem 4
mbed community and support
mbed ApplicationsApplication examples for some of the most common use cases
STM32 Nucleo
Development Boards
STM32 Nucleo
Expansion Boards
X-Nucleo
mbed Component Librariesmbed SDK / mbed OS
Sense..
Connect
Move/Actuate
Translate
Power
mbed Developer Tools 5
mbed CLI mbed Online Compiler
• Development
• Projects can be exported to a number of IDEs (IAR, KEIL, GCC-SW4STM32)
• No debugging capabilities Do use an off-line IDE
• Fully synchronized with online repositories
• Support for various DVCS
• Git (GitHub, gitLab, bitBucket)
• Mercurial (developer.mbed.org)
• Documentation support
• Classes all documented online
mbed flavours
• mbed Classic (2.0)
• No RTOS
• No multithreading
• OS (5.x) = Classic + RTOS + Communication
• RTOS
• Multithreading
• Standardized wireless communication scaled for IoT devices
• Seamless cloud connectivity through the mbed Device Connector
• Device management through REST APIs
• Messaging, Provisioning, Update
• Built-in security
6
mbed OS Connectivity
• Native support for
• Bluetooth low energy (X-NUCLEO-IDB04A1/05A1)
• Wifi (X-NUCLEO-IDW01M1)
• 6LowPan (X-NUCLEO-IDS01Ax)
• LoRa, mbed Classic only, mbedOS coming soon (DISCO-L072CZ-LRWAN1)
• Ethernet (NUCLEO-F746ZG, NUCLEO-F429ZI)
• Thread protocol
• On discussion
• NFC (X-NUCLEO-NFC01A1/02A1)
• Rfid
• Cellular
7
mbed OS Security
• Device security through mbed uVisor
• uVisor provides sandboxed environments and resources protection for applications built for ARM Cortex-M3 and
Cortex-M4 devices
• Today it uses MPU to protect memory
• Hardware-based TrustZone technology will be used in future to ensure mobile-style security for microcontrollers
• Connection security through mbed TLS
• mbed TLS makes it easy for developers to include cryptographic and SSL/TLS capabilities in embedded products
8
ARM mbed Enabled 9
• The ARM® mbed Enabled™ Program aims to validate a
product’s compliance w.r.t. specific requirements. Validation
ensures that a product conforms to the mbed’s compliance
criteria and technical requirements, and maintains
interoperability with other mbed Enabled products.
• The Program wish to make Internet of Things (IoT) devices:
SECUREENERGY
EFFICIENT
BASED ON OPEN
STANDARS
ARM mbed Enabled 10
• Program Benefits
Visibility within the mbed ecosystem
Clear identification with the Enabled logo
Co-promotion in mbed MKTG activities
Show your products at ARM trade shows
STM32 Platforms on mbed 11
• DISCO-F334C8
• DISCO-L053C8
• DISCO-L476VG
• DISCO-L072CZ-LRWAN1
• DISCO-L475VG-IOT01A
• DISCO-F413ZH
• DISCO-F429ZI
• DISCO-F469NI
• DISCO-F746NG
• DISCO-F769NI
• B96B-F446VE
• NUCLEO-F031K6
• NUCLEO-F042K6
• NUCLEO-F303K8
• NUCLEO-L011K4
• NUCLEO-L031K6
• NUCLEO-L432KC
Nucleo-32
• NUCLEO-F401RE
• NUCLEO-F410RB
• NUCLEO-F411RE
• NUCLEO-F446RE
• NUCLEO-F030R8
• NUCLEO-F070RB
• NUCLEO-F072RB
• NUCLEO-F091RC
• NUCLEO-F103RB
• NUCLEO-F302R8
• NUCLEO-F303RE
• NUCLEO-F334R8
• NUCLEO-L053R8
• NUCLEO-L073RZ
• NUCLEO-L152RE
• NUCLEO-L476RG
Nucleo-64
• NUCLEO-F207ZG
• NUCLEO-F303ZE
• NUCLEO-F412ZG
• NUCLEO-F429ZI
• NUCLEO-F446ZE
• NUCLEO-F746ZG
• NUCLEO-F767ZI
Nucleo-144
ST is offering 40 MCU boards on mbed, of which 38 are “enabled”
• High performance
• Mainstream
• Ultra low power
November 2017
X-Nucleo Expansion Boards on mbed 12
X-NUCLEO-IKS01A1/A2MOTION MEMS AND
ENVIRONMENTAL SENSORS
X-NUCLEO-IDB04A1BLUETOOTH LOW ENERGY
X-NUCLEO-IDB05A1BLUETOOTH LOW ENERGY
X-NUCLEO-6180XA1PROXIMITY AND AMBIENT
LIGHT SENSOR
X-NUCLEO-IHM01A1STEPPER MOTOR DRIVER
X-NUCLEO-IHM02A1 TWO AXIS STEPPER MOTOR
DRIVER X-NUCLEO-NFC01A1DYNAMIC NFC TAG
X-NUCLEO-LED61A1LED DRIVER
X-NUCLEO-PLC01A1 PROGRAMMABLE LOGIC
CONTROLLER
X-NUCLEO-IHM03A1HIGH POWER STEPPER
MOTOR DRIVER
X-NUCLEO-IHM05A1 BIPOLAR STEPPER MOTOR
DRIVER
X-NUCLEO-IHM04A1DUAL BRUSH DC MOTOR
DRIVER
X-NUCLEO-IKA01A1MULTIFUNCTIONAL EXPANSION
BOARD BASED ON
OPERATIONAL AMPLIFIERS
Sensors and Analog Wireless Communication Motor driveOthers
X-NUCLEO-IPS02A1INTELLIGENT POWER SWITCH
X-NUCLEO-IHM06A1 LOW VOLTAGE STEPPER
MOTOR DRIVER
X-NUCLEO-NFC02A1DYNAMIC NFC TAG
X-NUCLEO-IHM07M1STEPPER MOTOR DRIVER
ST has the largest expansion boards offering on mbed: 24 (+1 draft - Wifi) boards, of which 19 are “enabled”
X-NUCLEO-53L0A1PROXIMITY SENSOR
X-NUCLEO-IHM12A1LOW VOLTAGE DUAL BRUSH
DC MOTOR DRIVER
X-NUCLEO-CCA01M1
SOUND TERMINAL
X-NUCLEO-CCA02M1
MEMS MICROPHONES
X-NUCLEO-IDS04A16LOWPAN EXPANSION BOARD
IoT
X-NUCLEO-IDW01M1Wi-Fi EXPANSION BOARD
IoT
IoT
X-NUCLEO-IDW04A1Wi-Fi EXPANSION BOARD
November 2017
13
Note: mbed libraries are intended as first release on https://developer.mbed.org
Sense
Connect
Power
Drive
Move
Actuate
Translate
Wished / Not Committed
Committed
X_NUCLEO_IDS01A4
X_NUCLEO_NFC03A1
X_NUCLEO_LED16A1
X_NUCLEO_IHM13A1
Q3 / 2017 Q4 / 2017 Q1 / 2018
X-NUCLEO-GNSS01A1
X-NUCLEO-BNRG01A1
X-NUCLEO-IDW04A1
Roadmap on mbedNovember 2017
SensorTile
• SensorTile development board on mbed OS now available
14
Avnet-Silica/ST board for IoT 15
SensorTile
Additional ST components:
• Spirit1
• M24SR NFC
• STSafe
• Teseo GNSS
• Qi battery charger
Avnet embracing mbed/mbedOS strategy to differentiate.
“We decided to go with a full ST board because of the wide presence
of your components on mbed”
Avnet benefitting from1. ST Support of Spirit / 6LowPan
2. ST mbedOS SensorTile porting
16
ARM mbed developer website
Access 17
• Access links
• https://www.mbed.com/
• https://os.mbed.com/
Resources 18
• Documentation
• Cookbook
• Blog
• Questions
• Activity
• Tutorials
• Wiki
Dashboard 19
• All the activities related to my account
• Notifications
• My teams
• My repositories
• My pull requests
ST Official Team Repository 20
• ST Team
• https://os.mbed.com/teams/ST/
Creating a Team 21
• Create your own teams to share code
• https://os.mbed.com/teams/
• Public vs. Private
• Category
ST Wiki 22
• ST Wiki
• https://os.mbed.com/teams/ST/wiki/Special:Allpages
• SDK changes log
• Matrix of tested boards (X-NUCLEO shields)
• Supported shields (non ST ones)
• FAQ…
ST Code 23
• ST Code
• HelloWorld examples
• More complex application examples
• X-Nucleo libraries
Boards 24
• Boards = Platforms = Targets
• Overview, Pinout, Discussion topics, Examples
• Add to compiler
Components 25
• Components = Shields = Expansion boards
Components 26
• Component’s Page
• HelloWorld example
• More complex application examples
• X-Nucleo library
• Pinout
• MCU boards tested
ST Wiki: Matrix of Tested Boards 27
• Tested combinations of Nucleo vs. X-Nucleo boards
• https://os.mbed.com/teams/ST/wiki/Matrix-of-tested-boards
• Green: Working
• Green with *: Working with HW patch
• White: Not yet tested
28
mbed ‘’NUCLEO-F401RE’’
page
Install ST-LINK/V2
• Install the ST-LINK/V2 Driver
• Choose among the two following compilers
Developing on ARM mbed
mbed CLI mbed Online Compiler
29
ARM mbed CLI
mbed CLI 30
• The mbed CLI (Command Line Interface) enables Git and Mercurial based
version control, dependencies management, code publishing, support for
remotely hosted repositories (GitHub, GitLab and mbed.org), use of the ARM
mbed OS build system, export functions, and other operations
• Available on Windows, Linux, and Mac OS X
• It can be used in a shell like the Windows' shell, Linux' shell, or in the Git bash
• Requirements• Python v.2.7.11 (mbed CLI is a Python script)
• Git (v.1.9.5 or later) and Mercurial (v.2.2.2 or later), executables must be in system’s PATH
• A command-line compiler (GCC ARM, ARM Compiler 5, IAR) or an IDE toolchain (Keil uVision, DS-5, IAR)
mbed CLI 31
• Working behind a proxy• In order to be used behind a proxy, the mbed CLI requires the following further settings (Unix-like syntax):
• export "http_proxy=http://<proxy-server>:80“
• export "https_proxy=http://<proxy-server>:80“
• Working behind a man-in-the-middle (e.g. Z-Scaler)• Store your ”my_cacert.pem” list-of-certificates-file in a folder and use its location in the following instructions:
• export "SSL_CERT_DIR=E:\Certificates"
• export "SSL_CERT_FILE=E:\Certificates\my_cacert.pem"
• export "REQUESTS_CA_BUNDLE=E:\Certificates\my_cacert.pem"
mbed CLI 32
• Configuring Git• git config --global http.proxy "http://<proxy-server>"
• git config --global https.proxy "http://<proxy-server>"
• git config --global http.sslcainfo "E:\Certificates\my_cacert.pem“
• Configuring Hg• hg config "http.proxy=<proxy-server>"
• hg config "https.proxy=<proxy-server>“
• Further information• https://codex.cro.st.com/wiki/index.php?group_id=3896&pagename=Mbed+CLI+Configuration
• https://docs.mbed.com/docs/mbed-os-handbook/en/latest/dev_tools/cli/#using-mbed-cli
mbed CLI 33
mbed CLI 34
• Importing an existing program• mbed import mbed-os-example-blinky
• Creating a new program and adding an existing library• Creating a new program implies to download the latest version of mbed, then a number of existing libraries can be
added and the user files edited
• mbed new HelloWorld_IHM01A1
• cd HelloWorld_IHM01A1
• mbed add https://os.mbed.com/teams/ST/code/X_NUCLEO_IHM01A1/
• vim main.cpp
mbed CLI 35
• Exporting to an IDE• mbed export -i GCC_ARM -m NUCLEO_F401RE
• Compiling and downloading to the target• Compiling requires to set the desired target and toolchain
• mbed compile -m NUCLEO_F401RE -t GCC_ARM
• cp ./BUILD/NUCLEO_F401RE/GCC_ARM/*.bin /g/
36
ARM mbed Online Compiler
mbed online Compiler 37
• Compiler
• https://os.mbed.com/compiler
• Basic text editor
• mbed library version could be different for each program
• Commit/Publish your work in your account
• Compile and download to a platform
Creating a new program 38
• New Program
• Select a template
• Rename the example if needed
• Don’t forget to update all programs/libraries
Importing an existing program 39
• Official ST examples are by “Team ST”
• Use the search engine or import from a Component’s page
Building 40
• Compile your program
• Drag&Drop the generated bin file
• Directly on the board virtual drive
• On your PC for later use
Updating libraries 41
• Libraries in examples are not
necessarily the latest ones
• Update them to the latest version
Exporting an example 42
• Export your code to your preferred toolchain
in order to debug offline
• Supported by ST: Keil uVision, IAR, SW4STM32
Output to the console 43• No debugger on the online Compiler
• Printing to the console can be used• “Serial” object definition not mandatory
Board Pins and Functions• Pins are defined in PinNames.h file44
• Pins Functions are defined in PeripheralPins.c file
• Pins and their Functions are visible on the board pinout
image
• Only these definitions must be used in your code
• Others applications used for BLE
• nRF Master Control Panel (Android)
• https://play.google.com/store/apps/details?id=no.nordicse
mi.android.mcp
• Light Blue Explorer (IPhone)
• https://itunes.apple.com/gb/app/lightblue-bluetooth-low-
energy/id557428110?mt=8
• Hyper-terminal
• https://developer.mbed.org/handbook/Terminals
• Tera Term
https://osdn.net/projects/ttssh2/releases/67769
45Tools
• ST BlueMS
• https://play.google.com/store/apps/details?id=com.st.bluems
• https://itunes.apple.com/us/app/st-bluems/id993670214?mt=8
• STM32 BLE Profiles application
• https://play.google.com/store/apps/details?id=com.stm.bluetoothlevalidation
• https://itunes.apple.com/it/app/stm32-ble-toolbox/id1081331769?mt=8
Demos
46
47
• MOTENV: function pack for IoT node with BLE connectivity + environmental and motion sensors
SensorTile
MOTENV on SensorTile Demo
BLE Demo 48
Linux BLE
GW
Smartphone
ST BLE GW
Device Connector
NUCLEO-L476RG
X-NUCLEO-IDB05A1
X-NUCLEO-IKS01A2
ST SensorTile
B-L475E-IOT01A
IOT Discovery Node
6LowPan Demo 49
Device Connector
Spirit1 6LowPan
Network
Border Router
NUCLEO-F429/L476
X-NUCLEO-IDS01A4/5 (sub-1 GHz)
X-NUCLEO-IKS01A2 (motion/env)
NUCLEO-F429/L476
X-NUCLEO-IDS01A4/5 (sub-1 GHz)
X-NUCLEO-6180XA1 (proximity)
NUCLEO-F429
X-NUCLEO-IDS01A4/5 (sub-1 GHz)
50
• Plug the 3 boards and the stepper motor
• https://os.mbed.com/teams/ST/code/MemsMotorControl_IHM01A1_IKS01A2/
X-NUCLEO-IKS01A2
+
X-NUCLEO-IHM01A1
+
NUCLEO-F401RE
Stepper Motor
12V
DC
MemsMotorControl Demo1
2
The motor rotates proportionally to the accelerometer values on the X axis
SunTracker_BLE Demo 51
The solar panel moves to follow the sun and maximize the efficiency
A second board can be used to control the orientation of the panel from remote
Android application to control the solar panel and get the produced voltage
1
• Build the server, and optionally the client
• https://os.mbed.com/teams/ST/code/SunTracker_BLE/
2
Server: Nucleo + BLE + Motor Control + Light Sensor
Client: Nucleo + BLE + Inertial Sensors
Hands-on!
52
Activity 1: LED blinking 53
New → New Program…
Connect your NUCLEO-F401RE to your PC via USB
Save As…
Activity 2: Adding the User Button 54
Press the User Button turn ON/OFF the LED on the NUCLEO board
• Interrupt: signal to the processor emitted by HW or SW indicating an event that needs prompt attention
• How to handle interrupts in mbed
1. Instantiate an “InterruptIn” mbed object associated to a pin
2. Define an Interrupt Service Routine (ISR)
3. Associate the ISR to the interrupt’s edge (either falling or rising)
#include "mbed.h"
DigitalOut myled(LED1);
InterruptIn button(USER_BUTTON);
void button_isr(void) {
myled = !myled;
}
int main() {
button.fall(&button_isr);
myled = 0; // LED is OFF
while (true) {
__WFE(); //Waiting For Events...
}
}
1
2
3
• Plug the 2 boards
• Go to mbed website and select:• Components Sensors Motion X-NUCLEO-IKS01A2
• Import the program HelloWorld_IKS01A2 into your mbed online compiler
• Do not check “Update this program and libraries to the latest revision”
• Compile the program and flash it on the NUCLEO board
55
1
Activity 3: Reading MEMS sensors
2
X-NUCLEO-IKS01A2
+
NUCLEO-F401RE
56
3
4
• Install a Serial Terminal on your PC• Tera Term on Windows: http://tera-term.en.lo4d.com
• minicom on Linux: http://fossies.org/linux/misc/minicom-2.7.tar.gz
• SerialTools on OS X:
https://itunes.apple.com/it/app/serialtools/id611021963?mt=12
• Plug the board, run the terminal and open a connection• COMx port in Windows
• ttyACMx in Linux
• usbmodemxxxx in OS X
• Setup
• Reset the board to start displaying values on the screen
• Serial port:• Baud rate: 9600
• Data: 8 bit
• Parity: none
• Stop: 1 bit
• Flow control: none
• Terminal:• Receive New Line: AUTO
5
6
Activity 3: Reading MEMS sensors
• Many other application examples…
• 6DOrientation_IKS01A2 To find out the 6D orientation
• FreeFall_IKS01A2 To detect the free-fall event
• MultiEvent_IKS01A2 To detect the free-fall, tap, double-tap, tilt, wake-up, 6D orientation and step events
• Pedometer_IKS01A2 To count steps
• SingleDoubleTap_IKS01A2 To detect the single and double-tap events
• Tilt_IKS01A2 To detect the tilt event
• WakeUp_IKS01A2 To detect the wake-up event
57
7
Activity 3: Reading MEMS sensors
58Activity 4: Controlling the LED with MEMS
Write a program to control the LED blinking with the accelerometer on the Y axis from 1Hz to 10Hz
/* Includes */
#include "mbed.h"
#include "XNucleoIKS01A2.h"
/* Instantiate the expansion board */
static XNucleoIKS01A2 *mems_expansion_board = XNucleoIKS01A2::instance(D14, D15, D4, D5);
/* Retrieve the composing elements of the expansion board */
static LSM6DSLSensor *acc_gyro = mems_expansion_board->acc_gyro;
/* Led. */
DigitalOut myled(LED1);
/* Led control. */
void led_control(float period_s) {
myled = 1; // LED is ON
wait(period_s / 2.0);
myled = 0; // LED is OFF
wait(period_s / 2.0);
}
/* Simple main function */
int main() {
int32_t axes[3];
float acc;
/* Enable all sensors */
acc_gyro->enable_x();
printf("\r\n--- Starting new run ---\r\n");
while (true) {
acc_gyro->get_x_axes(axes);
acc = axes[1];
acc = abs(acc);
acc = (acc <= 100.0 ? 100.0 : acc);
acc = (acc >= 1000.0 ? 1000.0 : acc);
acc = acc / 100.0;
//printf("\r\n%f", acc);
led_control(1.0 / acc);
}
}
More complex exercises
59
• Plug the 2 boards
• Go to mbed website and select:• Components Communication Bluetooth X-Nucleo-IDB04A1 Bluetooth Low Energy
• Import the program BLE_HeartRate_IDB0XA1 into your mbed online compiler• Do not check “Update this program and libraries to the latest revision”
• Compile the program and flash it on the NUCLEO board
60
X-NUCLEO-IDB04A1
+
NUCLEO-F401RE
1
2
Activity: Nucleo + BLE
61
4 5 6
Activity: Nucleo + BLE3
• Install a BLE standard application on your device
• Enable geolocalization on Android 6.0+
https://play.google.com/store/apps/detail
s?id=com.macdom.ble.blescanner
Play Store Android iTunes iOS
https://itunes.apple.com/us/app/bluetoot
h-smart-scanner/id509978131?mt=8
https://play.google.com/store/apps/detail
s?id=com.alpwise.alpwiseble
https://itunes.apple.com/it/app/alpwise-
i-ble/id573963350?mt=8
Activity: Nucleo + BLE 62
/*
* BLE_HeartRate_IDB0XA1 with heart rate increments controlled by the blue button.
* Based on BLE_HeartRate_IDB0XA1, additions shown here below.
*/
[…]
InterruptIn event(USER_BUTTON);
bool button_pressed = false;
[…]
void pressed()
{
button_pressed = true;
}
[…]
int main(void)
{
[…]
event.fall(&pressed);
[…]
while (1)
{
[…]
if (button_pressed)
{
hrmCounter++;
button_pressed = false;
}
[…]
}
}
7
Increment the heart rate by pressing the blue button on the NUCLEO board
63
• Plug the 3 boards
• Go to mbed website and select:• Components Communication Bluetooth X-Nucleo-IDB04A1 Bluetooth Low Energy
• Import the program BLE_HeartRate_IDB0XA1 into your mbed online compiler and give it a new name,
e.g.: HelloWorld_BLE_MEMS• Do not check “Update this program and libraries to the latest revision”
X-NUCLEO-IKS01A1
+
X-NUCLEO-IDB04A1
+
NUCLEO-F401RE
Activity: Nucleo + BLE + MEMS1
2
64
3
• Import the library X_NUCLEO_IKS01A1 into the program HelloWorld_BLE_MEMS
• Do not check “Update all libraries to the latest revision”
Activity: Nucleo + BLE + MEMS
65
0
4
100
Activity: Nucleo + BLE + MEMS
Modify the program so that BPM values are scaled in the range [0..100] bpm while accelerometer values
measured on the Y axis are clipped in the absolute range of [0..1000]
66
/*
* HelloWorld_BLE_MEMS.
* Based on BLE_HeartRate_IDB0XA1, additions shown here below.
*/
[…]
#include "x_nucleo_iks01a1.h"
[…]
/* Instantiate the expansion board */
static X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance(D14, D15);
/* Retrieve the composing elements of the expansion board */
static MotionSensor *accelerometer = mems_expansion_board->GetAccelerometer();
int32_t axes[3];
[…]
int main(void)
{
[…]
while (1)
{
[…]
accelerometer->Get_X_Axes(axes);
int abs_acc = abs(axes[1]);
int clipped_abs_acc = (abs_acc > 1000 ? 1000 : abs_acc);
hrmCounter = (int) (clipped_abs_acc / 10.0f);
[…]
}
}
Activity: Nucleo + BLE + MEMS4
Modify the program so that BPM values are scaled in the range [0..100] bpm while accelerometer values
measured on the Y axis are clipped in the absolute range of [0..1000]
More on Interrupt Handling 67
• Issues with ISRs
• The generic problem of any ISR is it's latency. Since most often the corresponding interrupt is disabled during the
execution of an ISR, the ISR is expected to be short in order to not to miss other interrupt requests.
• What if you have to do a lot of data processing in an ISR?
• Top and Bottom Half ISRs
• Split the ISR in two parts:
• Top-Half: critical section, must be short, the interrupt is disabled, immediate execution in interrupt context
• Bottom-Half: less-critical section, can be long, the interrupt is enabled, deferred execution in user context
• Recommendation
• Write ISRs as short as possible!
• If not possible, defer the execution of the ISR with Top and Bottom Half approach
Adding the User Button 68
#include "mbed.h"
DigitalOut myled(LED1);
InterruptIn button(USER_BUTTON);
void button_isr(void) {
myled = !myled;
}
int main() {
button.fall(&button_isr);
myled = 0; // LED is OFF
while (true) {
__WFE(); //Waiting For Events...
}
}
Immediate execution of ISR
#include "mbed.h"
DigitalOut myled(LED1);
InterruptIn button(USER_BUTTON);
static volatile bool button_irq_triggered = false;
void button_top_half_isr(void) {
button.disable_irq();
button_irq_triggered = true;
}
void button_bottom_half_isr(void) {
button.enable_irq();
myled = !myled;
printf("User Button pressed!\r\n");
// Doing other things...
}
int main() {
button.fall(&button_top_half_isr);
myled = 0; // LED is OFF
while (true) {
if (button_irq_triggered) {
button_irq_triggered = false;
button_bottom_half_isr();
} else {
__WFE(); //Waiting For Events...
}
}
}
Deferred execution of (bottom-half) ISR
Press the User Button turn ON/OFF the LED on the NUCLEO board
vs.
69
Davide Aliprandi
Advanced System Technology
Sr. System Engineer
ST Microelectronics S.r.l.
20864 Agrate Brianza, Italy
Via Camillo Olivetti, 2
Tel: +39 039 603.6324
Fax: +39 039 603.6324
Questions?
Thanks!