forked from mohr/ArduinoIO
Compare commits
24 Commits
5f32dbb595
...
mueller/ma
Author | SHA1 | Date | |
---|---|---|---|
3ea528dc5f | |||
05bc5e474c | |||
162cb8d90d | |||
80cc6b6098 | |||
976c15c9b6 | |||
651ae6ed44 | |||
3af98f2025 | |||
b9f8798538 | |||
2bc352afb3 | |||
de9bb974c4 | |||
a343c9728b | |||
0571eb9c89 | |||
4176037c2c | |||
8442bf45f3 | |||
5fe5ad5b88 | |||
9dc8c6f4d7 | |||
1bd2fd0b0a | |||
866ed4a577 | |||
1e8a64c7bf | |||
3b8c1a5fba | |||
a1d2f30e08 | |||
e72df1c557 | |||
aa83552739 | |||
a9543a6f7e |
1
.gitignore
vendored
1
.gitignore
vendored
@ -104,3 +104,4 @@ local.properties
|
|||||||
.scala_dependencies
|
.scala_dependencies
|
||||||
.worksheet
|
.worksheet
|
||||||
/Release/
|
/Release/
|
||||||
|
/sloeber.ino.cpp
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define ARDUINOCONFIG_H_
|
#define ARDUINOCONFIG_H_
|
||||||
|
|
||||||
static const uint8_t COMMAND_TRANSFER_SPI = 1;
|
static const uint8_t COMMAND_TRANSFER_SPI = 1;
|
||||||
|
static const uint8_t COMMAND_TRANSFER_I2C = 2;
|
||||||
|
|
||||||
// Can be set to one for additional programming information from the primary
|
// Can be set to one for additional programming information from the primary
|
||||||
// serial port which is usually also used to flash the Arduino
|
// serial port which is usually also used to flash the Arduino
|
||||||
@ -9,7 +10,7 @@ static const uint8_t COMMAND_TRANSFER_SPI = 1;
|
|||||||
// serial communication logic
|
// serial communication logic
|
||||||
#define PROGRAMMING_OUTPUT 1
|
#define PROGRAMMING_OUTPUT 1
|
||||||
|
|
||||||
#define BAUD_RATE 115200
|
#define BAUD_RATE 9600
|
||||||
#define SERIAL_RX_BUFFER_SIZE 256
|
#define SERIAL_RX_BUFFER_SIZE 256
|
||||||
#define RING_BUFFER_SIZE 100
|
#define RING_BUFFER_SIZE 100
|
||||||
#define MAX_PACKET_LENGTH 100
|
#define MAX_PACKET_LENGTH 100
|
||||||
|
@ -126,6 +126,7 @@ void transferSPI(uint8_t address, uint8_t *data, size_t datalen) {
|
|||||||
// requires the slave select to be driven low.
|
// requires the slave select to be driven low.
|
||||||
CS_PORT = ~address;
|
CS_PORT = ~address;
|
||||||
SPI.transfer(data, datalen);
|
SPI.transfer(data, datalen);
|
||||||
|
// some MGM stuff. This delay might not be needed for other devices.
|
||||||
delay(100);
|
delay(100);
|
||||||
// Pull the slave select high again.
|
// Pull the slave select high again.
|
||||||
CS_PORT = 0xff;
|
CS_PORT = 0xff;
|
||||||
|
88
README.md
Normal file
88
README.md
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
Arduino IO Interface Board for EIVE
|
||||||
|
======
|
||||||
|
|
||||||
|
## General Information
|
||||||
|
|
||||||
|
This is the software for an Arduino board to set it up as an interface board.
|
||||||
|
The interface board will be used to relay commands from a host computer serial
|
||||||
|
interface to connected I2C or SPI sensors. This allows device handler testing
|
||||||
|
on a host machine. There are 2 options to build and flash an Arduino with this repository:
|
||||||
|
1. The software is compiled and programmed on the Arduino with make and avrdude, provided the AVR GCC toolchain is installed
|
||||||
|
2. Eclipse with the Sloeber plugin is used. The plugin and Eclipse take care of the build management, and an Arduino IDE like interface is provided in Eclipse
|
||||||
|
|
||||||
|
It is recommended to use Sloeber for enhanced convenience, as it takes care of the building process. Furthermore, the interface is similar to the Arduino IDE, which lowers the entry barrier for new developers. It is also integrated into Eclipse, which has a powerful indexer and several other tools to ease development.
|
||||||
|
|
||||||
|
## Instructions to build with make
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
1. When compiling on a Windows system, make sure the [Windows Development Tools](https://xpack.github.io/windows-build-tools/install/) are installed and added to the system path.This is required for make to work.
|
||||||
|
|
||||||
|
2. Install the [AVR toolchain](https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers) for your OS
|
||||||
|
|
||||||
|
3. If building the binary with make, initiate the contained arduino\_core submodule and the required core contained within that submodule by running
|
||||||
|
```sh
|
||||||
|
git submodule update --init --recursively
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build Instructions
|
||||||
|
Make sure to add `WINDOWS=1` when building on Windows!
|
||||||
|
|
||||||
|
1. Run following command to build the software.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make all -j
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Run following command to clean up the directories
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make clean -j
|
||||||
|
```
|
||||||
|
|
||||||
|
## Instructions build with Sloeber
|
||||||
|
|
||||||
|
### Prerequisite
|
||||||
|
|
||||||
|
1. Install [Eclipse for C/C++ developers](https://www.eclipse.org/downloads/packages/installer)
|
||||||
|
|
||||||
|
2. Install the Eclipse Sloeber plugin by going to Help → Eclipse Marketplace and searching for Sloeber V4 and installing it
|
||||||
|
|
||||||
|
3. First time setup:
|
||||||
|
- Create a new Arduino sketch by going to File → New → Other → Arduino Sketch.
|
||||||
|
|
||||||
|
- Unselect Use Default destination and pick the arduino folder inside eive\_obsw. The name does not really matter, arduino was taken for the example.
|
||||||
|
- The board specific information can changed later so its okay to take any option here and change it later.
|
||||||
|
- Take any example sketch (.cpp or .ino). An example file will be generated and should be deleted manually in the tree view on the left
|
||||||
|
- Eclipse should ask whether it should switch to the Arduino View. Confirm this with yes.
|
||||||
|
|
||||||
|
Now the top menu should have an Arduino section which can be used to install all required libraries and Arduino cores. The project properties can be accessed in the tree view on the left by right clicking on the arduino folder and selecting properties
|
||||||
|
|
||||||
|
4. It is recommended to get familiar with the interface provided by the plugin. A majority of functions is provided by top bar elements as shown in the following picture.
|
||||||
|
|
||||||
|
<img src="helper/eclipse_top_bar.png" width="80%"> <br>
|
||||||
|
|
||||||
|
5. The Sloeber plugin build mangement system will parse the arduino folder and all contained subfolders for source files. If you want to exclude source files from the build (for example, to exclude the arduino\_core, Sloeber will take care to include the core files via its integrated board manager!), right click on project folder (arduino) in the tree view on the left, go to Resource Configureation and configure Exclude from Build.
|
||||||
|
|
||||||
|
6. Set up the plugin for the used board and install all required libraries.
|
||||||
|
|
||||||
|
- Install all required board libraries by going to Arduino → Preferences and using the options Library Manager and Platform and Boards.
|
||||||
|
- It is necessary to install the `arduino-timer` library by searching for timer in the Library Manager.
|
||||||
|
- It is recommended to install the Arduino AVR Boards and the Arduino megaAVR Boards in the Platforms and Boards manager.
|
||||||
|
- It is also necessary to go to Arduino → Preferences → Add a library to the selected project and then adding the `arduino-timer` and `SPI` library there.
|
||||||
|
|
||||||
|
### Build and flash instructions
|
||||||
|
|
||||||
|
1. Right click on the arduino folder inside the tree view on the left and go to Preferences.
|
||||||
|
Go to the Arduino section and make sure the Arduino Board Selection tab is configured correctly.
|
||||||
|
Please note that board libraries and libaries need to be installed and added as beforehand as specified in Prerequisites.
|
||||||
|
It is recommended to go to the Compile Options tab and addding following define to `to append to C and C++`
|
||||||
|
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DSERIAL_RX_BUFFER_SIZE=256
|
||||||
|
```
|
||||||
|
|
||||||
|
2. An Arduino like bar can be seen at the top, which can be used to compile the software and flash it to the board. The check symbol is used to compile while the right arrow symbol is used to flash the software. There are also symbols to open the serial monitor or the serial plot.
|
||||||
|
|
||||||
|
3. The serial monitor can be opened in the Serial monitor view tab at the bottom or with the icons at the top bar. Take care to pick the correct USB port and baud rate.
|
BIN
helper/eclipse_top_bar.png
Normal file
BIN
helper/eclipse_top_bar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
15
main.cpp
15
main.cpp
@ -1,10 +1,7 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
#include "IOBoard.h"
|
#include "IOBoard.h"
|
||||||
#include "ArduinoConfig.h"
|
#include "ArduinoConfig.h"
|
||||||
|
|
||||||
// TODO: Copy this header into arduino_core, so it can be used without
|
#include <Arduino.h>
|
||||||
// Eclipse Sloeber as well.
|
|
||||||
#include <arduino-timer.h>
|
#include <arduino-timer.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
@ -12,7 +9,10 @@
|
|||||||
//from the core and we need to include it explicitly
|
//from the core and we need to include it explicitly
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
|
// Crete default timer which is able to manage 10 concurrent tasks
|
||||||
|
// and uses milliseconds as a timebase.
|
||||||
auto timer = timer_create_default();
|
auto timer = timer_create_default();
|
||||||
|
bool periodicHandler1(void* args);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Set data direction of selected port to output.
|
// Set data direction of selected port to output.
|
||||||
@ -30,18 +30,19 @@ void setup() {
|
|||||||
Serial.println(" bytes");
|
Serial.println(" bytes");
|
||||||
#endif
|
#endif
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
|
// Call periodic handler with certain interval
|
||||||
|
timer.every(RING_BUFFER_CHECK_INTVL, periodicHandler1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool periodicHandler1(void* args) {
|
bool periodicHandler1(void* args) {
|
||||||
if(args) {};
|
if(args) {};
|
||||||
IOBoard::handleNewData();
|
IOBoard::handleNewData();
|
||||||
return false;
|
// repeat action
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
timer.tick();
|
timer.tick();
|
||||||
timer.every(RING_BUFFER_CHECK_INTVL, periodicHandler1);
|
|
||||||
//delay(1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user