Skip to content

h5b/arduino_uno_328p

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

arduino_uno_328p

This project is targeted at the development of various code examples for the [Arduino Uno (ATmega328P)] (http://www.arduino.cc/en/Main/arduinoBoardUno) using plain C with the AVR-GCC toolchain while automating the setup process of a development environment with VirtualBox and Vagrant.

Arduino Uno ATmega328P

Requirements

Bootstrapping the Virtual Development Machine

git clone https://github.com/h5b/arduino_uno_328p.git
cd arduino_uno_328p
git submodule init
git submodule update
vagrant up

This sets up a virtual development machine host avr-dev based on Ubuntu 18.04. with the AVR-GCC toolchain already being installed. The setup takes a couple of minutes. After the installation has finished you can login to the machine by running: vagrant ssh

Code Examples

  • pcd_8544 implements an interface to the PCD8544 Display Controller used by Nokia's 3310 and 5110 using SPI in Master Mode.

  • ds_1307 implements an interface to the Dallas Maxim DS1307 Real-time Clock (RTC) using the Software TWI (I2C) Master Mode. The Real-time Clock acts as Slave Device with the clock information being sent to UART. For details see the DS1307 Datasheet.

  • ds_1631 implements an interface to the Dallas Maxim DS1631 Temperature Sensor using the Software TWI (I2C) Master Mode. The Temperature Sensor acts as Slave Device with the measured temperature being sent to UART. For details see the DS1631 Datasheet.

  • nto_nunchuk implements an interface to the Nunchuk Controller by Nintendo using Software TWI (I2C) Master Mode. The sensor values are used to calculate the Pitch and Roll Angle with a very simple low-pass filter to smooth the output. Angles, the X- and Y-Axis of the joystick and the state of the two buttons being sent to UART as JSON string. As the Nunchuk expects 3V3 Level on I2C Bus a bi-directional Logic Level Converter is used to connect with Atmega328P's 5V. For details see nunchuk.h which contains the schematic.

  • blink_led_hw is an example in the veins of blink_led_sw to let the User LED of the Arduino Uno blink once per second. Although using a timer-based delay which is accomplished via an compare match event of TIMER1.

  • blink_led_sw implements an example to let the User LED of the Arduino Uno blink once per second. The delay is accomplished via a software delay provided by the _delay_ms() function.

  • hw_uart implements an interrupt controlled UART example using circular buffers as described by Atmel Application Note AVR306: Using the AVR UART in C.

  • sw_uart is an example of polled UART for basic input and output operation.

  • sw_i2c implements software TWI (I2C) Master Mode.

  • sw_spi implements a minimalized software SPI Master Mode.

Running Code Examples

Ensure that your programmer has been picked up by the OS. The best approach here is to plug in the programmer not before vagrant up has finished. If you encounter any problems have a look at the output of running lsusb which should in case for the AVR mkII result in:

vagrant@avr-dev:~$ lsusb
[..]
Bus 002 Device 002: ID 03eb:2104 Atmel Corp. AVR ISP mkII

The following steps show how to run the blink_led_hw example:

vagrant ssh
cd /vagrant/src/blink_led_hw
make burn

About

avr-gcc examples targeted at the Arduino Uno (ATmega328P)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages