#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

void throwError( uint16_t error);

void setBitUint8(uint8_t *value, uint8_t &n); 
void setBitInt8(int8_t *value, uint8_t &n); 
void setBitUint16(uint16_t *value, uint8_t &n); 
void setBitInt16(int16_t *value, uint8_t &n); 

void unsetBitUint8(uint8_t *value, uint8_t &n); 
void unsetBitInt8(int8_t *value, uint8_t &n); 
void unsetBitUint16(uint16_t *value, uint8_t &n); 
void unsetBitInt16(int16_t *value, uint8_t &n); 

void toggleBitUint8(uint8_t *value, uint8_t &n); 
void toggleBitInt8(int8_t *value, uint8_t &n); 
void toggleBitUint16(uint16_t *value, uint8_t &n); 
void toggleBitInt16(int16_t *value, uint8_t &n); 

uint8_t getBitUint8(uint8_t *value, uint8_t &n); 
int8_t getBitInt8(int8_t *value, uint8_t &n); 
uint16_t getBitUint16(uint16_t *value, uint8_t &n); 
int16_t getBitInt16(int16_t *value, uint8_t &n); 

void changeBitUint8(uint8_t *value, uint8_t &n, uint8_t &x); 
void changeBitInt8(int8_t *value, uint8_t &n, uint8_t &x); 
void changeBitUint16(uint16_t *value, uint8_t &n, uint8_t &x); 
void changeBitInt16(int16_t *value, uint8_t &n, uint8_t &x); 

uint8_t get_n_bits_lsb_uint8(uint8_t *value, uint8_t &bits); 
int8_t get_n_bits_lsb_int8(int8_t *value, uint8_t &bits); 
uint16_t get_n_bits_lsb_uint16(uint16_t *value, uint8_t &bits); 
int16_t get_n_bits_lsb_int16(int16_t *value, uint8_t &bits); 

uint8_t get_n_bits_msb_uint8(uint8_t *value, uint8_t &bits);
int8_t get_n_bits_msb_int8(int8_t *value, uint8_t &bits);
uint16_t get_n_bits_msb_uint16(uint16_t *value, uint8_t &bits);
int16_t get_n_bits_msb_int16(int16_t *value, uint8_t &bits);

uint8_t get_bits_range_uint8(uint8_t *value, uint8_t &startBit, uint8_t &stopBit); 
int8_t get_bits_range_int8(int8_t *value, uint8_t &startBit, uint8_t &stopBit); 
uint16_t get_bits_range_uint16(uint16_t *value, uint8_t &startBit, uint8_t &stopBit); 
int16_t get_bits_range_int16(int16_t *value, uint8_t &startBit, uint8_t &stopBit); 

void set_bits_range_uint16(uint16_t *value, uint8_t &startBit, uint8_t &stopBit, uint16_t &replace);
void set_bits_range_uint8(uint8_t *value, uint8_t &startBit, uint8_t &stopBit, uint8_t &replace);
