Contains little libs to work with AVR chip internals as well as to speak with peripherpherals.
Additionally allows for compiling sketches that have been renamed sketch-name.cpp
and
have fixed paths. Please read the CMakeLists.txt
examples to understand how to tell the build
system which libraries your code needs.
The build process is based upon CMake, which plays nice with a number of IDEs. However, as we have to create some special dependencies there is a certain directory structure to be followed:
<project>
+-lib (contains directories with linkable libraries)
+-src (contains the sources for pure AVR programs)
+-sketches
+-<sketch> (a possible Arduino sketch)
+-libraries (directory with 3rd party Arduino libs)
The cmake process will scan through both the src
and lib
directory and add all
directories that contain a CMakeLists.txt
build file. These individual build files may
contain additional specific cmake configurations not covered by the general toolchain.
If the ARDUINO_SDK_PATH
variable is set (cmake -DARDUINO_SDK_PATH=...
) the
Arduino SDK is also set up and cmake will look in the
sketches
directory for Sketch and 3rd party libraries.
Be aware that sketches also need a
CMakeLists.txt
build file declaring dependencies.
SDK libraries are available, like SoftwareSerial
,Wire
, etc. The core library is
called arduino-core
and must be declared for Sketches that have no other dependencies.
Install the toolchain:
For MacOS X the simplest way to get the toolchain is homebew:
brew tap larsimmisch/avr
brew install avr-binutils avr-gcc avr-libc avrdude
brew install cmake
If you want to be able to compile Arduino sketches you will also need the Arduino SDK and set the environment variable ARDUINO_SDK_PATH.
- Edit CMakeLists.txt and set PROGRAMMER and SERIAL_DEV to your flash programmer and device.
- follow the following procedure:
mkdir build
cd build
cmake ..
make eliza-flash monitor
To flash a target use the directory name with added -flash (twitest-flash for the TWI example).
Unless you make significant changes to the CMakeLists.txt you only need to run
make
in the build directory from now on.
To run code inside of SIMAVR, just download and install simavr as well as the simduino example:
git clone [email protected]:buserror/simavr.git
cd simavr
make
cd examples/board_simduino
./obj-x86_64-apple-darwin14.4.0/simduino.elf
Now the simulator is running with the Arduino bootloader code and it tells us the tty we can use to connect and flash code on to the virtual device:
read_ihex_chunks: ATmegaBOOT_168_atmega328.ihex, unsupported check type 03
atmega328p booloader 0x07800: 1950 bytes
avr_interrupt_init
avr_special_init
uart_pty_init bridge on port *** /dev/ttys005 ***
uart_pty_connect: /tmp/simavr-uart0 now points to /dev/ttys005
Edit CMakeLists.txt
to set the correct SERIAL_DEV and then just follow the instructions above.
This lib mainly contains some macros that help debugging and will not be compiled into your code if you compile for release.
This is code I found online which I rewrote to work with the limited capacity of the atmega328p by moving most of the strings into PROGMEM.
Library to access the TWI (two wire interface, or i2c) interface in the AVR. Has the most basic functions to initialize the bus and send and receive data.
Library that talks to the ISL29125 RGB sensor via i2c. Also contains code to downsample the 48bit color depth to a more useful 24bit.
Basic communication with the board is done using the the UART. This library is basically the demo code from the avr-libc.
There are a number of executables available under src
. These are described below:
This little program puts Eliza on the board. Why? Because I wanted to learn how to program the Arduino compatible board without the IDE using just the standard toolchain avr-libc and cmake.
Another goal was to learn about how to set up the serial communication to work with the standard tools, like puts(), fgets(), printf(), etc. As a side effect I even learned something about PROGMEM.
Enjoy a little chat with Eliza!
The TWI (two wire interface, also known as i2c) is a short test program that scans the i2c bus for devices and outputs the device id.
Using the i2c library, this example talks to an ISL29125 RGB sensor and reads the data via i2c and displays the results on the serial console.
The OLED Breakout is a nice little display also found in the MicroView. In this example a few methods of accessing the display via i2c are explored and coupled with the RGB sensor.
Copyright 2015 ubirch GmbH (http://www.ubirch.com)
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.