New simpler test firmware

This commit is contained in:
Thammi 2013-12-17 00:46:37 +01:00
parent 274cf1e054
commit 05a2b057f5
2 changed files with 47 additions and 100 deletions

View File

@ -1,19 +1,13 @@
# Test firmware # Test firmware
Use this firmware to test all hardware components of a Pentabug. It can test Use this firmware to test all hardware components of a Pentabug. It can test
nearly all hardware features of the device. nearly all hardware features of the device. It offers the following features:
The following things exist in all modes: * the left led blinks when no input is present
* receiving an IR signal activates the right led
* right LED is on when IR signals are received (use a remote or first mode to * pressing the left button sends an IR signal (triggering the right led)
test) * pressing the right button activates the motor
* pressing the right button activates next mode, plays a sound using BUZZR * each button plays a sound using a different pin of the buzzer
* the pins of the extension board are constantly cycled through (add a
Here is a description what happens on a right button press in which mode: pentatonic to visualize all but one pin)
* activate left LED and send IR signal
* activates motor
* plays sound using BUZZGND
* activates all pins on the extension board for a short time (add a penetatonic
to get feedback on all but one of those pins)

View File

@ -12,35 +12,14 @@
#define FLASH(port, pin) { port &= ~(1 << pin); _delay_ms(50); port |= 1 << pin;} #define FLASH(port, pin) { port &= ~(1 << pin); _delay_ms(50); port |= 1 << pin;}
static volatile uint32_t button_state = 0;
static volatile uint8_t next_mode = 0;
static volatile uint8_t ir_active = 0; static volatile uint8_t ir_active = 0;
enum test_modes {
PHOTONS,
MOTOR,
AUDIO,
SHIELD,
// the end ... wrap
MODE_MAX,
};
ISR(TIMER0_COMPA_vect) { ISR(TIMER0_COMPA_vect) {
if(ir_active) { if(ir_active) {
PORTD ^= 1 << 2; PORTD ^= 1 << 2;
} else { } else {
PORTD &= ~(1 << 2); PORTD &= ~(1 << 2);
} }
if(PINB & (1 << 1)) {
button_state = 0;
} else {
++button_state;
}
if(button_state == (38l * 1000 / 2)) {
next_mode = 1;
}
} }
static void reset_hw(void) { static void reset_hw(void) {
@ -70,7 +49,6 @@ static void reset_hw(void) {
} }
int main(void) { int main(void) {
uint8_t vib_delay = 0;
uint16_t count = 0; uint16_t count = 0;
// we need to get real fast (8MHz) to handle 38kHz IR frequency ... // we need to get real fast (8MHz) to handle 38kHz IR frequency ...
@ -96,79 +74,54 @@ int main(void) {
// looping // looping
enum test_modes mode = PHOTONS;
for ever { for ever {
// next mode? // blinking left led
if(next_mode) { if(count % 0x4000 == 0) {
// cleanup PORTD ^= 1 << 4;
switch(mode) {
case PHOTONS:
ir_active = 0;
break;
case MOTOR:
case AUDIO:
case SHIELD:
break;
case MODE_MAX: break;
}
reset_hw();
++mode;
if(mode == MODE_MAX) {
mode = 0;
}
uint32_t i;
for(i = 0; i < 50; ++i) {
PORTB ^= 1 << 7;
_delay_ms(1);
}
next_mode = 0;
} }
uint8_t button = !(PINB & (1 << 0)); ++count;
// right led on ir
not_follow(PIND & (1 << 3), PORTC, 2); not_follow(PIND & (1 << 3), PORTC, 2);
switch(mode) { // left button
case PHOTONS:
{
ir_active = button;
if(count % 0x2000 == 0) {
PORTD ^= 1 << 4;
}
++count;
break;
}
case MOTOR:
not_follow(button, PORTB, 6);
break;
case AUDIO:
{
if(button) {
PORTC ^= 1 << 0;
_delay_ms(2);
}
break; const uint8_t button_r = !(PINB & (1 << 0));
} const uint8_t button_l = !(PINB & (1 << 1));
case SHIELD:
if(button) { // ir
FLASH(PORTB, 2);
FLASH(PORTD, 5); ir_active = button_r;
FLASH(PORTD, 6);
FLASH(PORTD, 7); // motor
FLASH(PORTC, 5);
FLASH(PORTC, 4); not_follow(button_l, PORTB, 6);
}
break; // sound stuff
case MODE_MAX: break;
if(button_l) {
PORTC ^= 1 << 0;
_delay_ms(2);
} }
if(button_r) {
PORTC ^= 1 << 0;
_delay_ms(4);
}
// cycle pins on extension board
const uint8_t step = (count >> 13) & 7;
follow(step == 0, PORTB, 2);
follow(step == 1, PORTD, 5);
follow(step == 2, PORTD, 6);
follow(step == 3, PORTD, 7);
follow(step == 4, PORTC, 5);
follow(step == 5, PORTC, 4);
} }
/* never return 0; */ /* never return 0; */