├── Tools ├── Libraries │ └── README.md └── Functions │ └── Button_Press │ └── buttonPressed.cpp ├── Books └── STM32_ARM_Programming_for_Embedded_Systems │ ├── Exercises │ └── README.md │ ├── Preface │ └── README.md │ ├── Chapter_01 │ └── README.md │ └── README.md ├── Playground └── Peter_Griffin │ └── README.md ├── .gitattributes ├── .gitignore └── README.md /Tools/Libraries/README.md: -------------------------------------------------------------------------------- 1 | # Libraries 2 | 3 | A place to develop general purpose libraries. -------------------------------------------------------------------------------- /Books/STM32_ARM_Programming_for_Embedded_Systems/Exercises/README.md: -------------------------------------------------------------------------------- 1 | # Exercises 2 | 3 | A place to work on exercises from the book. -------------------------------------------------------------------------------- /Books/STM32_ARM_Programming_for_Embedded_Systems/Preface/README.md: -------------------------------------------------------------------------------- 1 | # Preface 2 | 3 | A place to put code and learnings related to the preface. -------------------------------------------------------------------------------- /Books/STM32_ARM_Programming_for_Embedded_Systems/Chapter_01/README.md: -------------------------------------------------------------------------------- 1 | # Chapter 1 2 | 3 | A place to put code and learnings related to Chapter 1. -------------------------------------------------------------------------------- /Playground/Peter_Griffin/README.md: -------------------------------------------------------------------------------- 1 | # Peter's Playground 2 | 3 | Feel free to take a look at (and copy) any code I post here, but please ask before editing. -------------------------------------------------------------------------------- /Books/STM32_ARM_Programming_for_Embedded_Systems/README.md: -------------------------------------------------------------------------------- 1 | # Information and Links Realted the Book 2 | 3 | * [This link includes source code from examples](http://www.microdigitaled.com/ARM/STM_ARM_books.html) 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # All files except .bat files should use 2 | # unix-style line endings 3 | 4 | * text eol=lf 5 | *.bat text eol=crlf 6 | 7 | # Images should be treated as binary 8 | # (binary is a macro for -text -diff) 9 | 10 | *.png binary 11 | *.jpeg binary 12 | *.jpg binary 13 | *.gif binary 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /Tools/Functions/Button_Press/buttonPressed.cpp: -------------------------------------------------------------------------------- 1 | // Generic function to check if a button is pressed (allows ANY pins!) 2 | // Orgininally designed for the Arduino IDE, may require adaptations for other systems 3 | bool buttonPressed(byte buttonPinNum) { 4 | static unsigned long lastStates = 0xFFFFFFFFUL; // variable value preserved between function calls, only initialized once 5 | byte state = digitalRead(buttonPinNum); 6 | if (state != ((lastStates >> buttonPinNum) & 1UL)) { 7 | lastStates ^= 1UL << buttonPinNum; // toogle the state corrisponding to the button 8 | return state == LOW; 9 | } 10 | return false; 11 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Welcome to the `Book Club Code` site! 2 | 3 | This is a place for the Embedded.fm book club to collaborate and learn together. 4 | 5 | ## Repo Structure Guide 6 | 7 | ### Top-level folders currently include: 8 | * **[Books](https://github.com/cadet702/Embedded-STM32/tree/main/Books)** - For code directly related to chapters and exercises in the books we read. 9 | * **[Playground](https://github.com/cadet702/Embedded-STM32/tree/main/Playground)** - For individuals to create their own subfolders for whatever they want. 10 | * **[Tools](https://github.com/cadet702/Embedded-STM32/tree/main/Tools)** - For sharing and iterating on general purpose code, drivers, and tools. 11 | 12 | 13 | ## Contributing to Book Club Code 14 | 15 | There are two main options for contributing to this repo: issues and pull requests. 16 | 17 | ### Issues 18 | 19 | A GitHub **[Issue](https://github.com/cadet702/Embedded-STM32/issues)** is a ticket you create that logs a specific problem, a bug, a feature request, or an inquiry. This issue will be logged centrally and responded to by other people in this community. 20 | 21 | > _**Issues are ideal when you see something which can be improved but there isn't an obvious fix.**_ 22 | 23 | ### Pull Requests 24 | 25 | A GitHub **[Pull Request](https://github.com/cadet702/Embedded-STM32/pulls)** ("PR") is a request for the site maintainers to _pull in_ changes that have been authored by other users. 26 | 27 | > _**PRs are ideal when you already know how to improve the site and want to propose a set of specific changes.**_ 28 | 29 | 30 | ## Other Important Links 31 | 32 | * [Into to GIT](https://levelup.gitconnected.com/git-doesnt-have-to-be-hard-e1e115be6668) - A great article helping GIT make slightly more sense. 33 | * [Embedded.fm](https://embedded.fm/) - Description needed... 34 | * [Keil](https://keil.com) - Place to get a variety of compilers. 35 | * [IAR](https://IAR.com) - Place to get the IAR compiler. 36 | 37 | ## Guides and Documentation 38 | 39 | * **TBD** - Guides to be added here: 40 | * Windows TBD 41 | * Mac TBD 42 | * Linux TBD 43 | * Compiling STM32 applications using gcc and make (Nathan Jones) 44 | 1) Download and install [STM32CubeMX](https://www.st.com/en/development-tools/stm32cubemx.html) (don't worry; no one is going to make you use the HAL!). 45 | 2) Once finished, open STM32CubeMX and create a new project for your specific processor. 46 | 3) Click the "Project Manager" tab and change "Toolchain/IDE" to "Makefile". 47 | 4) Change any other desired settings in CubeMX, save the project, and then click "Generate Code". 48 | - CubeMX will automatically generate code to initialize the clock based on the settings in the "Clock Configuration" tab. If you'd rather set up the clock yourself, delete the call to `SystemClock_Config()` in your main file. 49 | - The SWD pins, used for debugging and programming, are **disabled** by default. I'd recommend at least enabling them so you can debug your STM32 and so you won't have to erase your STM32 device every time you want to reflash it with a debug adapter. To do that, click the "Pinout & Configuration" tab. Under "Categories", expand "System Core" and select "SYS". In the toolbar that opens up, change "Debug" to "Serial Wire". 50 | 5) In your generated project, open up "Core/Src/main.c" and write your application! 51 | - You can find register definitions for the STM32 in "Drivers/CMSIS/Device/ST/STM32XXXX/Include". Register definitions for the Arm core are in "Drivers/CMSIS/Core/Include". 52 | - If you're slavishly opposed to using *any* of the pre-written start-up code you'll still need to generate a project using CubeMX since I don't know of any quicker way to get the linker script. Once you've created your project, delete the contents of "Core/Src/main.c" and write your application (don't forget to add the appropriate header files!). When you go to build your project, you'll need the files below. You'll also need to include ("-I") most of the folders listed in the makefile, such as "Core/Inc", "Drivers/CMSIS/Device/ST/STM32F3xx/Include", and "Drivers/CMSIS/Include". 53 | - Core/Src/main.c 54 | - Core/Src/system_stm32XXXX.c 55 | - startup_stm32XXXX.S 56 | - STM32XXX_FLASH.ld 57 | - Note: Some of the STM32 HAL will still be compiled with your application (for instance, the HAL tick, which lets you use `HAL_Delay()`). To remove this from your binary I think you'll either have to root it out by hand (i.e. follow the initialization code to find which parts start up the HAL tick and other functions and remove those function calls) or start from scratch, by deleting everything in `main.c`, as was mentioned above. 58 | 6) Compile your project by executing `make` from a terminal window opened to your project folder. 59 | 7) Upload your project using your method of choice. 60 | * Other guides 61 | --------------------------------------------------------------------------------