Skip to content

Commit

Permalink
Revert "Use assembly impl"
Browse files Browse the repository at this point in the history
This reverts commit 698c8e7.
  • Loading branch information
Tomas Pilar committed Feb 17, 2021
1 parent 698c8e7 commit 2e1d3da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 39 deletions.
16 changes: 11 additions & 5 deletions src/Joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

#include <avr/io.h>

extern "C" void joystickInitImpl();
extern "C" int analogReadImpl();

#define IDLE_VALUE 512

Joystick::Joystick(unsigned int sensitivity) : invertedSensitivity(IDLE_VALUE - sensitivity)
{
joystickInitImpl();
DDRB &= ~(1 << DDB0);

ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);
ADMUX |= (1 << REFS0);
ADCSRA |= (1 << ADEN);
}

unsigned int Joystick::getX() const
Expand Down Expand Up @@ -64,5 +65,10 @@ bool Joystick::isPressed() const

unsigned int Joystick::analogRead() const
{
return analogReadImpl();
ADCSRA |= (1 << ADSC);
while (ADCSRA & (1 << ADSC))
{
// wait for the reading
}
return ADC;
}
34 changes: 0 additions & 34 deletions src/JoystickImpl.S

This file was deleted.

0 comments on commit 2e1d3da

Please sign in to comment.