#define STATO_AUDIO_DISCONNESSO		0
#define STATO_AUDIO_CONNESSO		1
#define STATO_AUDIO_RIPRODUZIONE	2
#define STATO_AUDIO_TONO		3
#define STATO_AUDIO_ADC			4

#define SAMPLES_BUFFER_SIZE                (1024) ///< deve essere ^2
#define SAMPLES_BUFFER_SIZE_MASK           (SAMPLES_BUFFER_SIZE - 1)
#define SINE_INCREMENT                  0.314
#define VU_DELAY                        0x3FF

extern uint8_t stato_audio;
extern char display_buffer[16];
extern uint16_t pwm_value, sample_value;
extern uint8_t rails_number;
extern uint16_t samples_ringbuf[SAMPLES_BUFFER_SIZE]; ///< buffer ad anello dei dati RX
extern uint16_t samples_ringbuf_input_index, samples_ringbuf_output_index;

uint32_t sat_sub(uint16_t x, uint16_t y);
uint16_t u16_sine(void);
uint16_t u12_sine(void);
void store_sample(uint16_t sample);
void store_samples(uint16_t *data, uint16_t size);
