Commit 9d83f90c authored by Camille Segall's avatar Camille Segall
Browse files

add attiny.c

parent 803d65f7
#include "attiny.h"
#include <stdlib.h>
attiny new_slave( void ){
attiny slave;
slave.stateled = 0;
slave.adresse = 0;
return slave;
}
attiny define_slave( char* buffer ){
attiny slave;
slave.stateled = buffer[0] - 48;
if (buffer[1] < 57 && buffer[2] < 57) {
slave.adresse = ((buffer[1] - 48)*16 + buffer[2] - 48)*2;
} else if ( buffer[1] > 64 && buffer[2] < 57) {
slave.adresse = ((buffer[1] - 55)*16 + buffer[2] - 48)*2;
} else if ( buffer[1] < 57 && buffer[2] > 64) {
slave.adresse = ((buffer[1] - 48)*16 + buffer[2] - 55)*2;
} else if ( buffer[1] > 64 && buffer[2] > 64) {
slave.adresse = ((buffer[1] - 55)*16 + buffer[2] - 55)*2;
}
return slave;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment