pins change for LPC1114FN28

Fork of DAC by Jimmy Hack

Committer:
JimmyTheHack
Date:
Tue Jul 16 05:52:01 2013 +0000
Revision:
1:679fa19d91b2
Child:
2:4c97b3c044ec
attempted to merge with DAC_SPI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JimmyTheHack 1:679fa19d91b2 1 #ifndef DAC_SPI_CPP
JimmyTheHack 1:679fa19d91b2 2 #define DAC_SPI_CPP
JimmyTheHack 1:679fa19d91b2 3
JimmyTheHack 1:679fa19d91b2 4 #include "DAC_SPI.h"
JimmyTheHack 1:679fa19d91b2 5 /*SPI Channels */
JimmyTheHack 1:679fa19d91b2 6 //since we only have two SPI channels, which must be shared, define them here.
JimmyTheHack 1:679fa19d91b2 7 SPI SPI_A(p5, NC, p7); //If using with other serial devices, can pass a pointer to the serial channel.
JimmyTheHack 1:679fa19d91b2 8 SPI SPI_B(p11, NC, p13);
JimmyTheHack 1:679fa19d91b2 9
JimmyTheHack 1:679fa19d91b2 10 /*Initialize DAC */
JimmyTheHack 1:679fa19d91b2 11 DAC_SPI::DAC_SPI(int SPIchannelNum, PinName _CS, PinName _LDAC) : CS(_CS), LDAC(_LDAC){
JimmyTheHack 1:679fa19d91b2 12 if (SPIchannelNum ==1){
JimmyTheHack 1:679fa19d91b2 13 DACspi = &SPI_B;
JimmyTheHack 1:679fa19d91b2 14 }
JimmyTheHack 1:679fa19d91b2 15 else{
JimmyTheHack 1:679fa19d91b2 16 DACspi = &SPI_A;
JimmyTheHack 1:679fa19d91b2 17 }
JimmyTheHack 1:679fa19d91b2 18 messageBits(16);
JimmyTheHack 1:679fa19d91b2 19 }
JimmyTheHack 1:679fa19d91b2 20
JimmyTheHack 1:679fa19d91b2 21 /** Manually change the SPI frequency
JimmyTheHack 1:679fa19d91b2 22 * Must be a value supported by the mbed and DAC
JimmyTheHack 1:679fa19d91b2 23 */
JimmyTheHack 1:679fa19d91b2 24 void DAC_SPI::frequency(int freq){
JimmyTheHack 1:679fa19d91b2 25 (*DACspi).frequency(freq);
JimmyTheHack 1:679fa19d91b2 26 }
JimmyTheHack 1:679fa19d91b2 27
JimmyTheHack 1:679fa19d91b2 28
JimmyTheHack 1:679fa19d91b2 29 //specify the number of bits used in message packets to the DAC.
JimmyTheHack 1:679fa19d91b2 30 void DAC_SPI::messageBits(int bits){
JimmyTheHack 1:679fa19d91b2 31 (*DACspi).format(bits,0);
JimmyTheHack 1:679fa19d91b2 32 }
JimmyTheHack 1:679fa19d91b2 33
JimmyTheHack 1:679fa19d91b2 34 //select a DACnum for use with chips with multiple onboard DACs.
JimmyTheHack 1:679fa19d91b2 35 void DAC_SPI::select(char DACnum){
JimmyTheHack 1:679fa19d91b2 36 DACselect=DACnum;
JimmyTheHack 1:679fa19d91b2 37 }
JimmyTheHack 1:679fa19d91b2 38
JimmyTheHack 1:679fa19d91b2 39 #endif //DAC_SPI_CPP