Librairie de l'IOGS nécessaire pour utiliser le CNA AD7303

Committer:
Thur
Date:
Thu Jun 22 12:58:18 2017 +0000
Revision:
0:30a6c5c8c8eb
Intial Publication AD7303;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Thur 0:30a6c5c8c8eb 1 #include "AD7303.h"
Thur 0:30a6c5c8c8eb 2 #include "mbed.h"
Thur 0:30a6c5c8c8eb 3
Thur 0:30a6c5c8c8eb 4 AD7303::AD7303(PinName Cs,PinName Mosi, PinName Miso, PinName Sck) : CS_DAC(Cs),ad7303(Mosi,Miso,Sck) {};
Thur 0:30a6c5c8c8eb 5 /*
Thur 0:30a6c5c8c8eb 6 * Initialisation du CNA
Thur 0:30a6c5c8c8eb 7 * Internal Vref / Power-Up on both DACA and DACB
Thur 0:30a6c5c8c8eb 8 * Load DACA and DACB with VDD/2 on outputs
Thur 0:30a6c5c8c8eb 9 */
Thur 0:30a6c5c8c8eb 10 void AD7303::initDAC(void)
Thur 0:30a6c5c8c8eb 11 {
Thur 0:30a6c5c8c8eb 12 // CS DAC
Thur 0:30a6c5c8c8eb 13 CS_DAC = 1;
Thur 0:30a6c5c8c8eb 14 wait_ms(10);
Thur 0:30a6c5c8c8eb 15 CS_DAC = 0;
Thur 0:30a6c5c8c8eb 16 ad7303.write(INT_REF | UPDATE_DACA);
Thur 0:30a6c5c8c8eb 17 ad7303.write(0x80);
Thur 0:30a6c5c8c8eb 18 CS_DAC = 1;
Thur 0:30a6c5c8c8eb 19 wait_ms(10);
Thur 0:30a6c5c8c8eb 20 CS_DAC = 0;
Thur 0:30a6c5c8c8eb 21 ad7303.write(INT_REF | UPDATE_DACB);
Thur 0:30a6c5c8c8eb 22 ad7303.write(0x80);
Thur 0:30a6c5c8c8eb 23 CS_DAC = 1;
Thur 0:30a6c5c8c8eb 24 wait_ms(10);
Thur 0:30a6c5c8c8eb 25 return;
Thur 0:30a6c5c8c8eb 26 }
Thur 0:30a6c5c8c8eb 27 /*
Thur 0:30a6c5c8c8eb 28 * Changement mode de configuration
Thur 0:30a6c5c8c8eb 29 * entrees :
Thur 0:30a6c5c8c8eb 30 * mode : mode de fonctionnement souhaite
Thur 0:30a6c5c8c8eb 31 * val : valeur en sortie (8 bits)
Thur 0:30a6c5c8c8eb 32 */
Thur 0:30a6c5c8c8eb 33 void AD7303::changeModeDAC(char mode, char val)
Thur 0:30a6c5c8c8eb 34 {
Thur 0:30a6c5c8c8eb 35 CS_DAC = 0;
Thur 0:30a6c5c8c8eb 36 ad7303.write(mode);
Thur 0:30a6c5c8c8eb 37 ad7303.write(val);
Thur 0:30a6c5c8c8eb 38 CS_DAC = 1;
Thur 0:30a6c5c8c8eb 39 return;
Thur 0:30a6c5c8c8eb 40 }
Thur 0:30a6c5c8c8eb 41
Thur 0:30a6c5c8c8eb 42 /*
Thur 0:30a6c5c8c8eb 43 * Modification de la tension de sortie du DACA - Reference interne
Thur 0:30a6c5c8c8eb 44 * entree :
Thur 0:30a6c5c8c8eb 45 * val : valeur sur 8 bits de la tension a appliquer
Thur 0:30a6c5c8c8eb 46 */
Thur 0:30a6c5c8c8eb 47 void AD7303::changeDACA_IntRef(char val)
Thur 0:30a6c5c8c8eb 48 {
Thur 0:30a6c5c8c8eb 49 CS_DAC = 0;
Thur 0:30a6c5c8c8eb 50 ad7303.write(INT_REF | UPDATE_DACA);
Thur 0:30a6c5c8c8eb 51 ad7303.write(val);
Thur 0:30a6c5c8c8eb 52 CS_DAC = 1;
Thur 0:30a6c5c8c8eb 53 return;
Thur 0:30a6c5c8c8eb 54 }
Thur 0:30a6c5c8c8eb 55
Thur 0:30a6c5c8c8eb 56 /*
Thur 0:30a6c5c8c8eb 57 * Modification de la tension de sortie du DACB - Reference interne
Thur 0:30a6c5c8c8eb 58 * entree :
Thur 0:30a6c5c8c8eb 59 * val : valeur sur 8 bits de la tension a appliquer
Thur 0:30a6c5c8c8eb 60 */
Thur 0:30a6c5c8c8eb 61 void AD7303::changeDACB_IntRef(char val)
Thur 0:30a6c5c8c8eb 62 {
Thur 0:30a6c5c8c8eb 63 CS_DAC = 0;
Thur 0:30a6c5c8c8eb 64 ad7303.write(INT_REF | UPDATE_DACB);
Thur 0:30a6c5c8c8eb 65 ad7303.write(val);
Thur 0:30a6c5c8c8eb 66 CS_DAC = 1;
Thur 0:30a6c5c8c8eb 67 return;
Thur 0:30a6c5c8c8eb 68 }
Thur 0:30a6c5c8c8eb 69
Thur 0:30a6c5c8c8eb 70 /*
Thur 0:30a6c5c8c8eb 71 * Modification de la tension de sortie du DACA - Reference externe
Thur 0:30a6c5c8c8eb 72 * entree :
Thur 0:30a6c5c8c8eb 73 * val : valeur sur 8 bits de la tension a appliquer
Thur 0:30a6c5c8c8eb 74 */
Thur 0:30a6c5c8c8eb 75 void AD7303::changeDACA_ExtRef(char val)
Thur 0:30a6c5c8c8eb 76 {
Thur 0:30a6c5c8c8eb 77 CS_DAC = 0;
Thur 0:30a6c5c8c8eb 78 ad7303.write(EXT_REF | UPDATE_DACA);
Thur 0:30a6c5c8c8eb 79 ad7303.write(val);
Thur 0:30a6c5c8c8eb 80 CS_DAC = 1;
Thur 0:30a6c5c8c8eb 81 return;
Thur 0:30a6c5c8c8eb 82 }
Thur 0:30a6c5c8c8eb 83
Thur 0:30a6c5c8c8eb 84 /*
Thur 0:30a6c5c8c8eb 85 * Modification de la tension de sortie du DACB - Reference externe
Thur 0:30a6c5c8c8eb 86 * entree :
Thur 0:30a6c5c8c8eb 87 * val : valeur sur 8 bits de la tension a appliquer
Thur 0:30a6c5c8c8eb 88 */
Thur 0:30a6c5c8c8eb 89 void AD7303::changeDACB_ExtRef(char val)
Thur 0:30a6c5c8c8eb 90 {
Thur 0:30a6c5c8c8eb 91 CS_DAC = 0;
Thur 0:30a6c5c8c8eb 92 ad7303.write(EXT_REF | UPDATE_DACB);
Thur 0:30a6c5c8c8eb 93 ad7303.write(val);
Thur 0:30a6c5c8c8eb 94 CS_DAC = 1;
Thur 0:30a6c5c8c8eb 95 return;
Thur 0:30a6c5c8c8eb 96 }