heptagon-arduino/parallel_led/arduinolib.c

25 lines
571 B
C

#include <avr/io.h>
#include <util/delay.h>
#include "arduinolib.h"
void Arduinolib__dwrite_step(int p, int v, Arduinolib__dwrite_out *out){
if (8 <= p && p <= 13){
int pin = p - 8;
DDRB |= (1 << pin);
PORTB |= (1 << pin);
if (v == 0) PORTB &= ~(1 << pin);
}
else if ( 0 <= p && p <= 7){
DDRD |= (1 << p);
PORTD |= (1 << p);
if (v == 0) PORTD &= ~(1 << p);
}
else { //by default
DDRB |= (1 << 5);
PORTB |= (1 << 5);
if (v == 0) PORTB &= ~(1 << 5);
}
return;
}