Git Product home page Git Product logo

stm32f4-discovery-example's Introduction

stm32f4-discovery-example is a very simple example of how to program
an stm32f4 discovery board.


License
-------

Licensed under the terms of the GNU Lesser General Public License
(LGPL), version 3 or later.

See COPYING and COPYING.LESSER for details.



In short:
--------
Choose an example: "cd rotate-chars"

Ensure arm dev tools, libopencm3, and stlink are installed,
and the paths match in the Makefile.

Use "make" to build the firmware.

Use "make flash" to push the firmware to the stm32f4-discovery.

Use GNU screen to test the stm32f4-discovery's firmware.


====================================================================

The project started as Kendrick Shaw's slightly modified version of
the USB CDC example.

The original example just echoed back whatever it received, so
to be more convincing that something is happening, a little code was
added to swap each letter with the another letter in the alphabet and
flash the LEDs when data comes in.

Next an example using SPI to read data from the on-board accelerometer
was added. Everytime a character is sent, the accelerometer's X, Y,
and Z values are returned.

To build an example:

 * Install the libopencm3 libraries, for example
   git clone -o upstream https://github.com/libopencm3/libopencm3.git
   git clone -o upstream https://github.com/libopencm3/libopencm3-examples.git

 * Install the arm developer tools (and add to PATH) with
   debian:
   sudo apt-get install \
	gcc-arm-none-eabi \
	gdb-arm-none-eabi \
	binutils-arm-none-eabi

 * Install stlink
   sudo apt install stlink-tools
   st-flash --version
   st-info --probe

OR:
 * Build stlink from https://github.com/texane/stlink
   git clone -o upstream https://github.com/texane/stlink
   mkdir -pv build-stlink
   cd build-stlink
   export STLINK_PREFIX=${HOME}/builds/stlink
   cmake -DCMAKE_INSTALL_PREFIX=$STLINK_PREFIX ../stlink
   make install
 * put the st-flash command from stlink somewhere in your path
   export LD_LIBRARY_PATH=${STLINK_PREFIX}/lib:
   export PATH=$PATH:${STLINK_PREFIX}/bin
   st-flash --version
 * install the udev rules from stlink as described in the stlink README

 * cd to an example directory, for instance "cd rotate-chars"
 * if needed, adjust the path of the LIBOPENCM3_DIR variable in the Makefile
 * run "make" in the example directory


To flash the example to the discovery board:

 * Connect the usb-mini cable to the board and your computer
   (not the usb-micro)

 * run "make flash"
   If you get a permissions error, either run it as root or chmod the device
   it's complaining about to give yourself write access

 * Press the reset button on the discovery board


To test an example:

 * It may be useful to unplug other USB devies like phones or Arduinos
   so you don't have to figure out which ttyACM* device to use

 * Connect the discovery board to the computer through the usb-micro
   connector (in addition to the usb-mini connection)

 * "dmesg" and "ls -l /dev/ttyACM*" to determine device name

 * run "screen -l /dev/ttyACM0" (or whatever the device name is)

 * Type some things, and confirm that the LEDs near the reset switch on
   the discovery board toggle as you type keys.

 * If running the "rotate-chars" example, you may confirm that the
   letters you see on the screen are thirteen letters further in the
   alphabet from what you typed. (An easy test of "rot13" is simply typing
   again the output and it should be transformed back to what you typed
   in the first place.)

 * Press 'Ctrl-A' 'k' and then 'y' to close the screen session when
   you're done.

Cheers!

stm32f4-discovery-example's People

Contributors

ericherman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.