AMC7812B register map and functions (slow functions)

Files at this revision

API Documentation at this revision

Comitter:
mmdonatti
Date:
Thu May 03 19:58:54 2018 +0000
Commit message:
AMC7812B library - registers and slow functions

Changed in this revision

amc7812b.cpp Show annotated file Show diff for this revision Revisions of this file
amc7812b.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 4ad7f160d354 amc7812b.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/amc7812b.cpp	Thu May 03 19:58:54 2018 +0000
@@ -0,0 +1,89 @@
+/*******************************************************
+*
+* Texas Instruments AMC7812B library
+*
+* Author: Mauricio Donatti
+* E-mail: mauricio.donatti@lnls.br
+*
+* March 2018
+*
+*******************************************************/
+
+#include "amc7812b.h"
+
+//OLD FUNCTIONS
+//They are not used anymore - New functions inside main.cpp are more efficient
+
+/*
+void AMC_write(SPI spi, DigitalOut cs, uint8_t reg,uint8_t* data)
+{
+        cs = 0; // Select the device by seting chip select low
+        spi.write((reg<<4)|((data[1]&0xF0)>>4));
+        spi.write((data[0])|((data[1]&0xF)<<8));
+        cs = 1; // Deselect the device by seting chip select low    
+}
+
+void AMC_read(SPI spi, DigitalOut cs, uint8_t reg,uint8_t* data)
+{
+        uint16_t tmp;
+        cs = 0; // Select the device by seting chip select low
+        //spi.write(reg|0x80);
+        //spi.write(0x00);
+        //spi.write(0x00);
+        spi.write((reg|0x80)<<4);
+        spi.write(0x000);
+        cs = 1; // Deselect the device by seting chip select low
+        cs = 0; // Select the device by seting chip select low
+        tmp = spi.write((reg|0x80)<<4);
+        data[1] = (tmp&0xF)<<4;
+        tmp = spi.write(0x000);
+        data[1] = data[1]|((tmp&0xF00)>>8);
+        data[0] = tmp&0xFF;
+        //data[1] = spi.write(0x000);
+        //data[0] = spi.write(0x00);
+        cs = 1; // Deselect the device by seting chip select low       
+}
+
+//read_fast saves the data of the previous read_fast call 
+void AMC_read_fast(SPI spi, DigitalOut cs, uint8_t reg,uint8_t* data)
+{
+        uint16_t tmp;
+
+        cs = 0; // Select the device by seting chip select low
+        tmp = spi.write((reg|0x80)<<4);
+        data[1] = (tmp&0xF)<<4;
+        tmp = spi.write(0x000);
+        data[1] = data[1]|((tmp&0xF00)>>8);
+        data[0] = tmp&0xFF;
+        //spi.write(reg|0x80);
+        //data[1] = spi.write(0x00);
+        //data[0] = spi.write(0x00);
+        cs = 1; // Deselect the device by seting chip select low    
+}
+
+
+//read_fast saves the data of the previous read_fast call 
+void AMC_my_read(SPI spi, DigitalOut cs, uint8_t reg,uint8_t* data)
+{
+        uint16_t tmp;
+        cs = 0; // Select the device by seting chip select low
+        //spi.write(reg|0x80);
+        //data[1] = spi.write(0x00);
+        //data[0] = spi.write(0x00);
+        
+        //while (!(LPC_SSP1->SR & 2)); //if TNF-Bit = 0 (FIFO full); TNF-Bit is Bit 1 in SSPxSR
+        LPC_SSP1->DR = (reg|0x80)<<4;  // write to FIFO data register
+        while( !(LPC_SSP1->SR & 4));
+        tmp = LPC_SSP1->DR;  // hopefully the compiler won't optimize this
+        data[1] = (tmp&0xF)<<4;
+        //while (!(LPC_SSP1->SR & 2)); //if TNF-Bit = 0 (FIFO full); TNF-Bit is Bit 1 in SSPxSR
+        LPC_SSP1->DR = 0x000;  // write to FIFO data register
+        while( !(LPC_SSP1->SR & 4));  
+        //while ( (LPC_SSP1->SR & (SSPSR_BSY|SSPSR_RNE)) != SSPSR_RNE ); 
+        tmp = LPC_SSP1->DR;  // hopefully the compiler won't optimize this
+        data[1] = data[1]|((tmp&0xF00)>>8);
+        data[0] = tmp&0xFF;
+                
+        cs = 1; // Deselect the device by seting chip select low    
+}
+*/
\ No newline at end of file
diff -r 000000000000 -r 4ad7f160d354 amc7812b.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/amc7812b.h	Thu May 03 19:58:54 2018 +0000
@@ -0,0 +1,109 @@
+/*******************************************************
+*
+* Texas Instruments AMC7812B library
+*
+* Author: Mauricio Donatti
+* E-mail: mauricio.donatti@lnls.br
+*
+* March 2018
+*
+*******************************************************/
+
+#include "mbed.h"
+
+//AMC7812B register map
+#define     LT          0x00
+#define     D1          0x01
+#define     D2          0x02
+#define     T_CONF      0x0A    
+#define     T_CONV      0x0B    
+#define     D1_CORR     0x21    
+#define     D2_CORR     0x22    
+#define     ADC0        0x23    
+#define     ADC1        0x24    
+#define     ADC2        0x25    
+#define     ADC3        0x26    
+#define     ADC4        0x27    
+#define     ADC5        0x28    
+#define     ADC6        0x29    
+#define     ADC7        0x2A    
+#define     ADC8        0x2B    
+#define     ADC9        0x2C
+#define     ADC10       0x2D    
+#define     ADC11       0x2E    
+#define     ADC12       0x2F    
+#define     ADC13       0x30    
+#define     ADC14       0x31    
+#define     ADC15       0x32    
+#define     DAC0        0x33    
+#define     DAC1        0x34    
+#define     DAC2        0x35    
+#define     DAC3        0x36    
+#define     DAC4        0x37    
+#define     DAC5        0x38    
+#define     DAC6        0x39    
+#define     DAC7        0x3A    
+#define     DAC8        0x3B    
+#define     DAC9        0x3C    
+#define     DAC10       0x3D    
+#define     DAC11       0x3E    
+#define     DAC0_CLR    0x3F    
+#define     DAC1_CLR    0x40    
+#define     DAC2_CLR    0x41    
+#define     DAC3_CLR    0x42    
+#define     DAC4_CLR    0x43    
+#define     DAC5_CLR    0x44    
+#define     DAC6_CLR    0x45    
+#define     DAC7_CLR    0x46    
+#define     DAC8_CLR    0x47    
+#define     DAC9_CLR    0x48    
+#define     DAC10_CLR   0x49    
+#define     DAC11_CLR   0x4A    
+#define     GPIO        0x4B    
+#define     CONF0       0x4C    
+#define     CONF1       0x4D    
+#define     ALARM       0x4E    
+#define     STATUS      0x4F    
+#define     ADC_CH0     0x50    
+#define     ADC_CH1     0x51    
+#define     ADC_GAIN        0x52    
+#define     AUTO_DAC_CLR    0x53    
+#define     AUTO_DAC_CLR_EN 0x54    
+#define     SW_DAC_CLR      0x55    
+#define     HW_DAC_CLR0     0x56    
+#define     HW_DAC_CLR1     0x57    
+#define     DAC_CONF        0x58    
+#define     DAC_GAIN        0x59    
+#define     IN0_HIGH_TH     0x5A    
+#define     IN0_LOW_TH      0x5B    
+#define     IN1_HIGH_TH     0x5C    
+#define     IN1_LOW_TH      0x5D    
+#define     IN2_HIGH_TH     0x5E    
+#define     IN2_LOW_TH      0x5F    
+#define     IN3_HIGH_TH     0x60    
+#define     IN3_LOW_TH      0x61    
+#define     LT_HIGH_TH      0x62    
+#define     LT_LOW_TH       0x63    
+#define     D1_HIGH_TH      0x64    
+#define     D1_LOW_TH       0x65    
+#define     D2_HIGH_TH      0x66    
+#define     D2_LOW_TH       0x67    
+#define     HYST0           0x68    
+#define     HYST1           0x69    
+#define     HYST2           0x6A    
+#define     PWR_DOWN        0x6B    
+#define     ID              0x6C    
+#define     SW_RESET        0x7C        
+
+//OLD FUNCTIONS
+//They are not used anymore - New functions inside main.cpp are more efficient
+
+/*
+void AMC_write(SPI spi, DigitalOut cs, uint8_t reg,uint8_t* data);
+
+void AMC_read(SPI spi, DigitalOut cs, uint8_t reg,uint8_t* data);
+
+void AMC_read_fast(SPI spi, DigitalOut cs, uint8_t reg,uint8_t* data);
+
+void AMC_my_read(SPI spi, DigitalOut cs, uint8_t reg,uint8_t* data);
+*/