/* * AS5043.c * * Created on: Feb 28, 2012 * Author: sebastian */ #include "AS5043.h" void AS5043_setup(void) { // Set MOSI and SCK, SS/CS output, all others input DDRB = (1<> PB4) == AS5043_calcParity(data)) { data |= 1; } else { data &= ~1; } // CS high PORTB |= (1 << PB2); return data; } uint8_t AS5043_calcParity(uint16_t data) { uint8_t i,bit; bit = 0; for(i = 0; i < 15; i++) { data = data >> 1; // We shift first since the LSB is the paritybit bit = bit ^ (data & 1); } return bit; }