mbed API for Raspberry Pi boards.
mbedPi
This is an attempt to implement a limited number of mbed APIs for Raspberry Pi single-board computers. The project was inspired by and based on the arduPi library developed for the Arduino by Cooking Hacks .
Specifications
- Chip: Broadcom BCM2836 SoC
- Core architecture: Quad-core ARM Cortex-A7
- CPU frequency: 900 MHz
- GPU: Dual Core VideoCore IV® Multimedia Co-Processor
- Memory: 1GB LPDDR2
- Operating System: Boots from Micro SD card, running a version of the Linux operating system
- Power: Micro USB socket 5V, 2A
Connectors
- Ethernet: 10/100 BaseT Ethernet socket
- Video Output: HDMI (rev 1.3 & 1.4)
- Audio Output: 3.5mm jack, HDMI
- USB: 4 x USB 2.0 Connector
- GPIO Connector: 40-pin 2.54 mm (100 mil) expansion header: 2x20 strip providing 27 GPIO pins as well as +3.3 V, +5 V and GND supply lines
- Camera Connector: 15-pin MIPI Camera Serial Interface (CSI-2)
- JTAG: Not populated
- Display Connector: Display Serial Interface (DSI) 15 way flat flex cable connector with two data lanes and a clock lane
- Memory Card Slot: Micro SDIO
GPIO connector pinout
Information
Only the labels printed in blue/white or green/white (i.e. p3, gpio2 ...) must be used in your code. The other labels are given as information (alternate-functions, power pins, ...).
Building programs for the Raspberry Pi with mbedPi
I use Qt Creator for development, however you can use any other IDE available on the Raspberry Pi (e.g. Geany) if you like. For a quick try:
- Install Qt and the Qt Creator onto your Raspberry Pi. Then create a new "Blinky" Plain non-Qt C++ Project as follows:
- Change the main code as below:
main.cpp
#include "mbedPi.h" int main() { DigitalOut myled(p7); while(1) { myled = 1; // LED is ON wait(0.2); // 200 ms myled = 0; // LED is OFF wait(1.0); // 1 sec printf("Blink\r\n"); } }
- Copy the mbedPi.zip file into your project's folder and unzip.
- Add the mbedPi.h and mbedPi.cpp files to your project by right clicking on the "Blinky" project and then clicking on the "Add Existing Files..." option in the local menu:
- Double click on Blinky.pro to open it for editing and add new libraries by inserting a new line as follows:
- Compile the project.
- Connect an LED through a 1k resistor to pin 7 and the ground on the Raspberry Pi GPIO connector.
- Run the binary as sudo (sudo ./Blinky) and you should see the LED blinking.
- Press Ctrl+c to stop running the application.
raspi_wizard/RpiApplication.qbs@2:131555dc6fb7, 22 months ago (annotated)
- Committer:
- hudakz
- Date:
- Tue Dec 20 12:16:18 2022 +0000
- Revision:
- 2:131555dc6fb7
- Parent:
- rpi_wizard/qbs_rpi/RpiApplication.qbs@1:1f2d9982fa8c
Mbed API for Raspberry Pi boards equipped with BCM2836 SoC.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hudakz | 1:1f2d9982fa8c | 1 | import qbs |
hudakz | 1:1f2d9982fa8c | 2 | import qbs.Process |
hudakz | 1:1f2d9982fa8c | 3 | import qbs.File |
hudakz | 1:1f2d9982fa8c | 4 | import qbs.FileInfo |
hudakz | 1:1f2d9982fa8c | 5 | import qbs.TextFile |
hudakz | 1:1f2d9982fa8c | 6 | import "/home/zoli/.config/QtProject/qtcreator/templates/wizards/qbs_rpi/js/helpers.js" as helpers |
hudakz | 1:1f2d9982fa8c | 7 | |
hudakz | 1:1f2d9982fa8c | 8 | CppApplication { |
hudakz | 1:1f2d9982fa8c | 9 | type: "application" |
hudakz | 1:1f2d9982fa8c | 10 | consoleApplication: true |
hudakz | 1:1f2d9982fa8c | 11 | Depends { name: "cpp" } |
hudakz | 1:1f2d9982fa8c | 12 | // cpp.cppFlags: "-std=c++11" |
hudakz | 1:1f2d9982fa8c | 13 | // Depends { |
hudakz | 1:1f2d9982fa8c | 14 | // name: "Qt"; |
hudakz | 1:1f2d9982fa8c | 15 | // submodules: ["core", "gui", "widgets"] |
hudakz | 1:1f2d9982fa8c | 16 | // } |
hudakz | 1:1f2d9982fa8c | 17 | |
hudakz | 1:1f2d9982fa8c | 18 | Group { |
hudakz | 1:1f2d9982fa8c | 19 | fileTagsFilter: product.type |
hudakz | 1:1f2d9982fa8c | 20 | qbs.install: true |
hudakz | 1:1f2d9982fa8c | 21 | qbs.installDir: "bin" |
hudakz | 1:1f2d9982fa8c | 22 | qbs.installPrefix: "/mnt/workbench" |
hudakz | 1:1f2d9982fa8c | 23 | } |
hudakz | 1:1f2d9982fa8c | 24 | |
hudakz | 1:1f2d9982fa8c | 25 | property string sysPath: "/home/zoli/src/rpi/sys" |
hudakz | 1:1f2d9982fa8c | 26 | property stringList sys: [ |
hudakz | 1:1f2d9982fa8c | 27 | "drivers", |
hudakz | 1:1f2d9982fa8c | 28 | ] |
hudakz | 1:1f2d9982fa8c | 29 | property pathList sysPaths: { |
hudakz | 1:1f2d9982fa8c | 30 | var l = [] |
hudakz | 1:1f2d9982fa8c | 31 | for (var i = 0; i < sys.length; i++) { |
hudakz | 1:1f2d9982fa8c | 32 | l = l.concat(helpers.dirs(sysPath+"/"+sys[i])) |
hudakz | 1:1f2d9982fa8c | 33 | } |
hudakz | 1:1f2d9982fa8c | 34 | return l |
hudakz | 1:1f2d9982fa8c | 35 | } |
hudakz | 1:1f2d9982fa8c | 36 | |
hudakz | 1:1f2d9982fa8c | 37 | Group { |
hudakz | 1:1f2d9982fa8c | 38 | name: "sys" |
hudakz | 1:1f2d9982fa8c | 39 | condition: (sysPath != "") |
hudakz | 1:1f2d9982fa8c | 40 | files: { |
hudakz | 1:1f2d9982fa8c | 41 | var l = [] |
hudakz | 1:1f2d9982fa8c | 42 | for (var i = 0; i < sys.length; i++) { |
hudakz | 1:1f2d9982fa8c | 43 | // l = l.concat(sys[i]+"/**") |
hudakz | 1:1f2d9982fa8c | 44 | l = l.concat(sys[i]+"/**/*.cpp") |
hudakz | 1:1f2d9982fa8c | 45 | l = l.concat(sys[i]+"/**/*.c") |
hudakz | 1:1f2d9982fa8c | 46 | l = l.concat(sys[i]+"/**/*.hpp") |
hudakz | 1:1f2d9982fa8c | 47 | l = l.concat(sys[i]+"/**/*.h") |
hudakz | 1:1f2d9982fa8c | 48 | l = l.concat(sys[i]+"/**/*.s") |
hudakz | 1:1f2d9982fa8c | 49 | } |
hudakz | 1:1f2d9982fa8c | 50 | return l |
hudakz | 1:1f2d9982fa8c | 51 | } |
hudakz | 1:1f2d9982fa8c | 52 | prefix: sysPath + "/" |
hudakz | 1:1f2d9982fa8c | 53 | } |
hudakz | 1:1f2d9982fa8c | 54 | |
hudakz | 1:1f2d9982fa8c | 55 | property string libPath: "/home/zoli/src/rpi/lib" |
hudakz | 1:1f2d9982fa8c | 56 | property stringList libs: [] |
hudakz | 1:1f2d9982fa8c | 57 | property pathList libPaths: { |
hudakz | 1:1f2d9982fa8c | 58 | var l = [] |
hudakz | 1:1f2d9982fa8c | 59 | for (var i = 0; i < libs.length; i++) { |
hudakz | 1:1f2d9982fa8c | 60 | l = l.concat(helpers.dirs(libPath+"/"+libs[i])) |
hudakz | 1:1f2d9982fa8c | 61 | } |
hudakz | 1:1f2d9982fa8c | 62 | return l |
hudakz | 1:1f2d9982fa8c | 63 | } |
hudakz | 1:1f2d9982fa8c | 64 | |
hudakz | 1:1f2d9982fa8c | 65 | Group { |
hudakz | 1:1f2d9982fa8c | 66 | name: "libs" |
hudakz | 1:1f2d9982fa8c | 67 | condition: (libPath != "") |
hudakz | 1:1f2d9982fa8c | 68 | files: { |
hudakz | 1:1f2d9982fa8c | 69 | var l = [] |
hudakz | 1:1f2d9982fa8c | 70 | for (var i = 0; i < libs.length; i++) { |
hudakz | 1:1f2d9982fa8c | 71 | // l = l.concat(libs[i]+"/**") |
hudakz | 1:1f2d9982fa8c | 72 | l = l.concat(libs[i]+"/**/*.cpp") |
hudakz | 1:1f2d9982fa8c | 73 | l = l.concat(libs[i]+"/**/*.c") |
hudakz | 1:1f2d9982fa8c | 74 | l = l.concat(libs[i]+"/**/*.hpp") |
hudakz | 1:1f2d9982fa8c | 75 | l = l.concat(libs[i]+"/**/*.h") |
hudakz | 1:1f2d9982fa8c | 76 | l = l.concat(libs[i]+"/**/*.s") |
hudakz | 1:1f2d9982fa8c | 77 | } |
hudakz | 1:1f2d9982fa8c | 78 | return l |
hudakz | 1:1f2d9982fa8c | 79 | } |
hudakz | 1:1f2d9982fa8c | 80 | prefix: libPath + "/" |
hudakz | 1:1f2d9982fa8c | 81 | } |
hudakz | 1:1f2d9982fa8c | 82 | |
hudakz | 1:1f2d9982fa8c | 83 | property pathList includePaths: "" |
hudakz | 1:1f2d9982fa8c | 84 | |
hudakz | 1:1f2d9982fa8c | 85 | cpp.compilerIncludePaths: "/home/zoli/toolchain/rpi/arm-bcm2708/arm-bcm2708-linux-gnueabi/arm-bcm2708-linux-gnueabi/include/c++/4.7.1" |
hudakz | 1:1f2d9982fa8c | 86 | cpp.compilerFrameworkPaths: "/home/zoli/toolchain/rpi/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/" |
hudakz | 1:1f2d9982fa8c | 87 | cpp.compilerLibraryPaths: "/home/zoli/toolchain/rpi/arm-bcm2708/arm-bcm2708-linux-gnueabi/arm-bcm2708-linux-gnueabi/lib" |
hudakz | 1:1f2d9982fa8c | 88 | cpp.includePaths: includePaths.concat("/.", sysPaths, libPath) |
hudakz | 1:1f2d9982fa8c | 89 | //cpp.staticLibraries: ["mbed"] |
hudakz | 1:1f2d9982fa8c | 90 | cpp.dynamicLibraries: ["rt", "pthread"] |
hudakz | 1:1f2d9982fa8c | 91 | } |
hudakz | 1:1f2d9982fa8c | 92 | |
hudakz | 1:1f2d9982fa8c | 93 |