Skip to content

raphaelmeyer/avr-kata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Embedded AVR atmega 8bit GPIO kata

Assignment

The push button S1 shall behave as a toggle switch to turn the led LED1 on and off.

Scenario: Initial state

    Given the device is powered on
    Then the LED is turned off
Scenario: Turn LED on

    Given the device is powered on
    When I press the button
    Then the LED is turned on
Scenario: Turn LED off

    Given the device is powered on
    When I press the button
    And I press the button again
    Then the LED is turned off

Target Hardware

Schematic: Schematic

Atmega168 pin configuration: Pin configuration

Build and Run

The qmake project provides the following make targets.

Run the unit tests:

make check

Run the feature tests:

make run-bdd

Download the firmware to the AVR

make flash

AVR GPIO cheatsheet

#ifdef __AVR
// avr-gcc defines preprocessor variable __AVR
#endif

// pin and port definitions
#include <avr/io.h>

// set pin PB0 as output, PB7-PB1 as input
DDRB = _BV(PB0);

// set pin PB0 as input, PB7-PB1 as output
DDRB = ~(_BV(PB0));

// clear PB0
PORTB &= ~(_BV(PB0));

// set PB0
PORTB |= _BV(PB0);

// toggle PB0
PORTB ^= _BV(PB0);

// read port
unsigned port = PINB

// check pin PB0
bool state = PINB & _BV(PB0)

About

Coding dojo kata with AVR atmega168

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages