Initial support for RP2040
This commit is contained in:
		
							
								
								
									
										1
									
								
								examples/arduino-external-libs/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								examples/arduino-external-libs/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| .pio | ||||
							
								
								
									
										38
									
								
								examples/arduino-external-libs/README.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								examples/arduino-external-libs/README.rst
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| ..  Copyright 2014-present PlatformIO <contact@platformio.org> | ||||
|     Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|     you may not use this file except in compliance with the License. | ||||
|     You may obtain a copy of the License at | ||||
|        http://www.apache.org/licenses/LICENSE-2.0 | ||||
|     Unless required by applicable law or agreed to in writing, software | ||||
|     distributed under the License is distributed on an "AS IS" BASIS, | ||||
|     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
|     See the License for the specific language governing permissions and | ||||
|     limitations under the License. | ||||
|  | ||||
| How to build PlatformIO based project | ||||
| ===================================== | ||||
|  | ||||
| 1. `Install PlatformIO Core <http://docs.platformio.org/page/core.html>`_ | ||||
| 2. Download `development platform with examples <https://github.com/platformio/platform-raspberrypi/archive/develop.zip>`_ | ||||
| 3. Extract ZIP archive | ||||
| 4. Run these commands: | ||||
|  | ||||
| .. code-block:: bash | ||||
|  | ||||
|     # Change directory to example | ||||
|     > cd platform-raspberrypi/examples/arduino-external-libs | ||||
|  | ||||
|     # Build project | ||||
|     > platformio run | ||||
|  | ||||
|     # Upload firmware | ||||
|     > platformio run --target upload | ||||
|  | ||||
|     # Build specific environment | ||||
|     > platformio run -e pico | ||||
|  | ||||
|     # Upload firmware for the specific environment | ||||
|     > platformio run -e pico --target upload | ||||
|  | ||||
|     # Clean build files | ||||
|     > platformio run --target clean | ||||
							
								
								
									
										39
									
								
								examples/arduino-external-libs/include/README
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								examples/arduino-external-libs/include/README
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
|  | ||||
| This directory is intended for project header files. | ||||
|  | ||||
| A header file is a file containing C declarations and macro definitions | ||||
| to be shared between several project source files. You request the use of a | ||||
| header file in your project source file (C, C++, etc) located in `src` folder | ||||
| by including it, with the C preprocessing directive `#include'. | ||||
|  | ||||
| ```src/main.c | ||||
|  | ||||
| #include "header.h" | ||||
|  | ||||
| int main (void) | ||||
| { | ||||
|  ... | ||||
| } | ||||
| ``` | ||||
|  | ||||
| Including a header file produces the same results as copying the header file | ||||
| into each source file that needs it. Such copying would be time-consuming | ||||
| and error-prone. With a header file, the related declarations appear | ||||
| in only one place. If they need to be changed, they can be changed in one | ||||
| place, and programs that include the header file will automatically use the | ||||
| new version when next recompiled. The header file eliminates the labor of | ||||
| finding and changing all the copies as well as the risk that a failure to | ||||
| find one copy will result in inconsistencies within a program. | ||||
|  | ||||
| In C, the usual convention is to give header files names that end with `.h'. | ||||
| It is most portable to use only letters, digits, dashes, and underscores in | ||||
| header file names, and at most one dot. | ||||
|  | ||||
| Read more about using header files in official GCC documentation: | ||||
|  | ||||
| * Include Syntax | ||||
| * Include Operation | ||||
| * Once-Only Headers | ||||
| * Computed Includes | ||||
|  | ||||
| https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html | ||||
							
								
								
									
										46
									
								
								examples/arduino-external-libs/lib/README
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								examples/arduino-external-libs/lib/README
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
|  | ||||
| This directory is intended for project specific (private) libraries. | ||||
| PlatformIO will compile them to static libraries and link into executable file. | ||||
|  | ||||
| The source code of each library should be placed in a an own separate directory | ||||
| ("lib/your_library_name/[here are source files]"). | ||||
|  | ||||
| For example, see a structure of the following two libraries `Foo` and `Bar`: | ||||
|  | ||||
| |--lib | ||||
| |  | | ||||
| |  |--Bar | ||||
| |  |  |--docs | ||||
| |  |  |--examples | ||||
| |  |  |--src | ||||
| |  |     |- Bar.c | ||||
| |  |     |- Bar.h | ||||
| |  |  |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html | ||||
| |  | | ||||
| |  |--Foo | ||||
| |  |  |- Foo.c | ||||
| |  |  |- Foo.h | ||||
| |  | | ||||
| |  |- README --> THIS FILE | ||||
| | | ||||
| |- platformio.ini | ||||
| |--src | ||||
|    |- main.c | ||||
|  | ||||
| and a contents of `src/main.c`: | ||||
| ``` | ||||
| #include <Foo.h> | ||||
| #include <Bar.h> | ||||
|  | ||||
| int main (void) | ||||
| { | ||||
|   ... | ||||
| } | ||||
|  | ||||
| ``` | ||||
|  | ||||
| PlatformIO Library Dependency Finder will find automatically dependent | ||||
| libraries scanning project source files. | ||||
|  | ||||
| More information about PlatformIO Library Dependency Finder | ||||
| - https://docs.platformio.org/page/librarymanager/ldf.html | ||||
							
								
								
									
										23
									
								
								examples/arduino-external-libs/platformio.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								examples/arduino-external-libs/platformio.ini
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| ; PlatformIO Project Configuration File | ||||
| ; | ||||
| ;   Build options: build flags, source filter, extra scripting | ||||
| ;   Upload options: custom port, speed and extra flags | ||||
| ;   Library options: dependencies, extra library storages | ||||
| ; | ||||
| ; Please visit documentation for the other options and examples | ||||
| ; http://docs.platformio.org/page/projectconf.html | ||||
|  | ||||
| [env] | ||||
| platform = raspberrypi | ||||
| framework = arduino | ||||
| lib_deps = | ||||
|     SPI | ||||
|     adafruit/Adafruit 9DOF | ||||
|     arduino-libraries/Ethernet | ||||
|  | ||||
| [env:pico] | ||||
| board = pico | ||||
|  | ||||
|  | ||||
| [env:nanorp2040connect] | ||||
| board = nanorp2040connect | ||||
							
								
								
									
										109
									
								
								examples/arduino-external-libs/src/main.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								examples/arduino-external-libs/src/main.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,109 @@ | ||||
| #include <Arduino.h> | ||||
| #include <Adafruit_Sensor.h> | ||||
| #include <Adafruit_LSM303_U.h> | ||||
| #include <Adafruit_L3GD20_U.h> | ||||
| #include <Adafruit_9DOF.h> | ||||
|  | ||||
| /* Assign a unique ID to the sensors */ | ||||
| Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30301); | ||||
| Adafruit_LSM303_Mag_Unified   mag   = Adafruit_LSM303_Mag_Unified(30302); | ||||
| Adafruit_L3GD20_Unified       gyro  = Adafruit_L3GD20_Unified(20); | ||||
|  | ||||
| void displaySensorDetails(void) | ||||
| { | ||||
|   sensor_t sensor; | ||||
|  | ||||
|   accel.getSensor(&sensor); | ||||
|   Serial.println(F("----------- ACCELEROMETER ----------")); | ||||
|   Serial.print  (F("Sensor:       ")); Serial.println(sensor.name); | ||||
|   Serial.print  (F("Driver Ver:   ")); Serial.println(sensor.version); | ||||
|   Serial.print  (F("Unique ID:    ")); Serial.println(sensor.sensor_id); | ||||
|   Serial.print  (F("Max Value:    ")); Serial.print(sensor.max_value); Serial.println(F(" m/s^2")); | ||||
|   Serial.print  (F("Min Value:    ")); Serial.print(sensor.min_value); Serial.println(F(" m/s^2")); | ||||
|   Serial.print  (F("Resolution:   ")); Serial.print(sensor.resolution); Serial.println(F(" m/s^2")); | ||||
|   Serial.println(F("------------------------------------")); | ||||
|   Serial.println(F("")); | ||||
|  | ||||
|   gyro.getSensor(&sensor); | ||||
|   Serial.println(F("------------- GYROSCOPE -----------")); | ||||
|   Serial.print  (F("Sensor:       ")); Serial.println(sensor.name); | ||||
|   Serial.print  (F("Driver Ver:   ")); Serial.println(sensor.version); | ||||
|   Serial.print  (F("Unique ID:    ")); Serial.println(sensor.sensor_id); | ||||
|   Serial.print  (F("Max Value:    ")); Serial.print(sensor.max_value); Serial.println(F(" rad/s")); | ||||
|   Serial.print  (F("Min Value:    ")); Serial.print(sensor.min_value); Serial.println(F(" rad/s")); | ||||
|   Serial.print  (F("Resolution:   ")); Serial.print(sensor.resolution); Serial.println(F(" rad/s")); | ||||
|   Serial.println(F("------------------------------------")); | ||||
|   Serial.println(F("")); | ||||
|  | ||||
|   mag.getSensor(&sensor); | ||||
|   Serial.println(F("----------- MAGNETOMETER -----------")); | ||||
|   Serial.print  (F("Sensor:       ")); Serial.println(sensor.name); | ||||
|   Serial.print  (F("Driver Ver:   ")); Serial.println(sensor.version); | ||||
|   Serial.print  (F("Unique ID:    ")); Serial.println(sensor.sensor_id); | ||||
|   Serial.print  (F("Max Value:    ")); Serial.print(sensor.max_value); Serial.println(F(" uT")); | ||||
|   Serial.print  (F("Min Value:    ")); Serial.print(sensor.min_value); Serial.println(F(" uT")); | ||||
|   Serial.print  (F("Resolution:   ")); Serial.print(sensor.resolution); Serial.println(F(" uT")); | ||||
|   Serial.println(F("------------------------------------")); | ||||
|   Serial.println(F("")); | ||||
|  | ||||
|   delay(500); | ||||
| } | ||||
|  | ||||
| void setup(void) | ||||
| { | ||||
|   Serial.begin(115200); | ||||
|   Serial.println(F("Adafruit 9DOF Tester")); Serial.println(""); | ||||
|  | ||||
|   /* Initialise the sensors */ | ||||
|   if(!accel.begin()) | ||||
|   { | ||||
|     /* There was a problem detecting the ADXL345 ... check your connections */ | ||||
|     Serial.println(F("Ooops, no LSM303 detected ... Check your wiring!")); | ||||
|     while(1); | ||||
|   } | ||||
|   if(!mag.begin()) | ||||
|   { | ||||
|     /* There was a problem detecting the LSM303 ... check your connections */ | ||||
|     Serial.println("Ooops, no LSM303 detected ... Check your wiring!"); | ||||
|     while(1); | ||||
|   } | ||||
|   if(!gyro.begin()) | ||||
|   { | ||||
|     /* There was a problem detecting the L3GD20 ... check your connections */ | ||||
|     Serial.print("Ooops, no L3GD20 detected ... Check your wiring or I2C ADDR!"); | ||||
|     while(1); | ||||
|   } | ||||
|  | ||||
|   /* Display some basic information on this sensor */ | ||||
|   displaySensorDetails(); | ||||
| } | ||||
|  | ||||
| void loop(void) | ||||
| { | ||||
|   /* Get a new sensor event */ | ||||
|   sensors_event_t event; | ||||
|  | ||||
|   /* Display the results (acceleration is measured in m/s^2) */ | ||||
|   accel.getEvent(&event); | ||||
|   Serial.print(F("ACCEL ")); | ||||
|   Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print("  "); | ||||
|   Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print("  "); | ||||
|   Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print("  ");Serial.println("m/s^2 "); | ||||
|  | ||||
|   /* Display the results (magnetic vector values are in micro-Tesla (uT)) */ | ||||
|   mag.getEvent(&event); | ||||
|   Serial.print(F("MAG   ")); | ||||
|   Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print("  "); | ||||
|   Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print("  "); | ||||
|   Serial.print("Z: "); Serial.print(event.magnetic.z); Serial.print("  ");Serial.println("uT"); | ||||
|  | ||||
|   /* Display the results (gyrocope values in rad/s) */ | ||||
|   gyro.getEvent(&event); | ||||
|   Serial.print(F("GYRO  ")); | ||||
|   Serial.print("X: "); Serial.print(event.gyro.x); Serial.print("  "); | ||||
|   Serial.print("Y: "); Serial.print(event.gyro.y); Serial.print("  "); | ||||
|   Serial.print("Z: "); Serial.print(event.gyro.z); Serial.print("  ");Serial.println("rad/s "); | ||||
|  | ||||
|   Serial.println(F("")); | ||||
|   delay(1000); | ||||
| } | ||||
							
								
								
									
										11
									
								
								examples/arduino-external-libs/test/README
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								examples/arduino-external-libs/test/README
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
|  | ||||
| This directory is intended for PIO Unit Testing and project tests. | ||||
|  | ||||
| Unit Testing is a software testing method by which individual units of | ||||
| source code, sets of one or more MCU program modules together with associated | ||||
| control data, usage procedures, and operating procedures, are tested to | ||||
| determine whether they are fit for use. Unit testing finds problems early | ||||
| in the development cycle. | ||||
|  | ||||
| More information about PIO Unit Testing: | ||||
| - https://docs.platformio.org/page/plus/unit-testing.html | ||||
		Reference in New Issue
	
	Block a user