Iztech Fork

Dependencies:   mbed

Fork of A2_Interface3_V_0_0 by Roger McArdell

Committer:
Iztech
Date:
Thu Aug 17 13:36:28 2017 +0000
Revision:
2:18608d894fc4
Parent:
0:ea876cfd7385
AndyR v3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rogermcardell 0:ea876cfd7385 1 /*
rogermcardell 0:ea876cfd7385 2 Programmer: Roger McArdell
rogermcardell 0:ea876cfd7385 3 Date: 04/08/2017
rogermcardell 0:ea876cfd7385 4
rogermcardell 0:ea876cfd7385 5 For Texas Instraments TLV320ADC3101
rogermcardell 0:ea876cfd7385 6
rogermcardell 0:ea876cfd7385 7 Versions
rogermcardell 0:ea876cfd7385 8 V0.1 First version
rogermcardell 0:ea876cfd7385 9
rogermcardell 0:ea876cfd7385 10 */
rogermcardell 0:ea876cfd7385 11
rogermcardell 0:ea876cfd7385 12 static uint8_t DSPAddWrite = '\x30'; // 7 bit Address is \x18 + write bit = \x30
rogermcardell 0:ea876cfd7385 13 static uint8_t DSPAddRead = '\x31'; // 7 bit address is \x18 + read bit = \x31
rogermcardell 0:ea876cfd7385 14
rogermcardell 0:ea876cfd7385 15 // Prototypes
rogermcardell 0:ea876cfd7385 16
rogermcardell 0:ea876cfd7385 17
rogermcardell 0:ea876cfd7385 18
rogermcardell 0:ea876cfd7385 19 void ReadDSP(char Page, char RegAdd, uint8_t Bytes)
rogermcardell 0:ea876cfd7385 20 {
rogermcardell 0:ea876cfd7385 21 char TempRead[Bytes];
rogermcardell 0:ea876cfd7385 22 char TempWrite[5];
rogermcardell 0:ea876cfd7385 23
rogermcardell 0:ea876cfd7385 24 TempWrite[0] = Page;
rogermcardell 0:ea876cfd7385 25 TempWrite[1] = '\x0';
rogermcardell 0:ea876cfd7385 26
rogermcardell 0:ea876cfd7385 27 I2CBus.start();
rogermcardell 0:ea876cfd7385 28 2CBus.write(DSPAddWrite, &TempWrite, 2); // Select page N (Write data N to register 0 regardless of the current page number). assumed repeated-START condition is not required
rogermcardell 0:ea876cfd7385 29 I2CBus.read(DSPAddRead, TempRead, Bytes); // Read or write data from/to valid registers in page N.
rogermcardell 0:ea876cfd7385 30 // Read or write data from/to valid registers in page N.
rogermcardell 0:ea876cfd7385 31 // Select new page M (Write data M to register 0 regardless of the current page number).
rogermcardell 0:ea876cfd7385 32 // Read or write data from/to valid registers in page M.
rogermcardell 0:ea876cfd7385 33 // Repeat as desired
rogermcardell 0:ea876cfd7385 34 I2CBus.stop();
rogermcardell 0:ea876cfd7385 35
rogermcardell 0:ea876cfd7385 36 pc.printf("DSP Register %d: \r\n",SlaveAdd);
rogermcardell 0:ea876cfd7385 37 for (uint8_t I = 0; I < Bytes; I++)
rogermcardell 0:ea876cfd7385 38 {
rogermcardell 0:ea876cfd7385 39 pc.printf("Value is %d: \r\n",TempRead[I]);
rogermcardell 0:ea876cfd7385 40 }
rogermcardell 0:ea876cfd7385 41 }