forked from W4D/soundcube-firmware
feierabend
This commit is contained in:
@ -4,9 +4,12 @@
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <I2S.h>
|
||||
#include "codec.h"
|
||||
|
||||
I2S i2s(INPUT_PULLUP);
|
||||
|
||||
TLV320AIC3204 codec;
|
||||
|
||||
#define SIZE 16
|
||||
#define ECHO 192000
|
||||
int16_t buffer[SIZE];
|
||||
@ -36,45 +39,6 @@ void codec_receive(){
|
||||
}
|
||||
}
|
||||
|
||||
void cw(unsigned char first, unsigned char second){
|
||||
Wire1.beginTransmission(0x18);
|
||||
Wire1.write(first);
|
||||
Wire1.write(second);
|
||||
int result = Wire1.endTransmission();
|
||||
Serial.print(0x18, HEX);
|
||||
Serial.print(" ");
|
||||
Serial.print(first, HEX);
|
||||
Serial.print(" ");
|
||||
Serial.print(second, HEX);
|
||||
Serial.print(" : ");
|
||||
if(result == 0) {
|
||||
Serial.println("OK");
|
||||
} else {
|
||||
Serial.print("ERROR: ");
|
||||
Serial.println(result);
|
||||
}
|
||||
delay(5);
|
||||
}
|
||||
|
||||
void cr(unsigned char first, size_t len){
|
||||
Wire1.beginTransmission(0x18);
|
||||
Wire1.write(first); // set register for read
|
||||
Wire1.endTransmission(false); // false to not release the line
|
||||
|
||||
Wire1.requestFrom(0x18, len, true); // request bytes from register XY
|
||||
|
||||
Serial.print(first, HEX);
|
||||
Serial.print(" ");
|
||||
|
||||
byte buff[len];
|
||||
Wire1.readBytes(buff, len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
Serial.print(buff[i], HEX);
|
||||
Serial.print(" ");
|
||||
Serial.println(buff[i], BIN);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
i2s.setSysClk(48000);
|
||||
|
||||
@ -94,7 +58,8 @@ void setup() {
|
||||
pinMode(20, OUTPUT); // CODEC reset
|
||||
digitalWrite(20, HIGH);
|
||||
|
||||
|
||||
codec.begin(&Wire1);
|
||||
/*
|
||||
// GENERAL
|
||||
cw(0x00, 0x00); // select page 0
|
||||
cw(0x01, 0x01); // soft reset
|
||||
@ -192,6 +157,8 @@ void setup() {
|
||||
Serial.println("P0_42 - Sticky Flags");
|
||||
cr(0x2A, 1);
|
||||
|
||||
*/
|
||||
|
||||
i2s.onTransmit(codec_transmit);
|
||||
i2s.onReceive(codec_receive);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user