This is an involuntary fork, created because the repository would not update mmSPI. SPI library used to communicate with an altera development board attached to four zigbee-header pins.
Dependents: Embedded_RTOS_Project
Fork of mmSPI by
mmSPI.cpp@3:de99451ab3c0, 2013-08-14 (annotated)
- Committer:
- gatedClock
- Date:
- Wed Aug 14 10:45:33 2013 +0000
- Revision:
- 3:de99451ab3c0
- Parent:
- 2:bebcf53b72dc
- Child:
- 4:aa1fe8707bef
working on spi interface class.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gatedClock | 0:fb42c5acf810 | 1 | /*----------------------------------------------//------------------------------ |
gatedClock | 0:fb42c5acf810 | 2 | student : m-moore |
gatedClock | 0:fb42c5acf810 | 3 | class : external SPI interface |
gatedClock | 0:fb42c5acf810 | 4 | directory : mmSPI |
gatedClock | 0:fb42c5acf810 | 5 | file : mmSPI.cpp |
gatedClock | 0:fb42c5acf810 | 6 | ------------------------------------------------//----------------------------*/ |
gatedClock | 0:fb42c5acf810 | 7 | #include "mmSPI.h" |
gatedClock | 0:fb42c5acf810 | 8 | /*----------------------------------------------//------------------------------ |
gatedClock | 0:fb42c5acf810 | 9 | ------------------------------------------------//----------------------------*/ |
gatedClock | 0:fb42c5acf810 | 10 | //==============================================//============================== |
gatedClock | 0:fb42c5acf810 | 11 | mmSPI::mmSPI() // constructor. |
gatedClock | 0:fb42c5acf810 | 12 | { |
gatedClock | 3:de99451ab3c0 | 13 | allocations(); // object allocations. |
gatedClock | 0:fb42c5acf810 | 14 | } |
gatedClock | 0:fb42c5acf810 | 15 | //----------------------------------------------//------------------------------ |
gatedClock | 0:fb42c5acf810 | 16 | mmSPI::~mmSPI() // destructor. |
gatedClock | 0:fb42c5acf810 | 17 | { |
gatedClock | 3:de99451ab3c0 | 18 | if (pMOSI) {delete pMOSI; pMOSI = NULL;} // delete allocation. |
gatedClock | 3:de99451ab3c0 | 19 | if (pMISO) {delete pMISO; pMISO = NULL;} // delete allocation. |
gatedClock | 3:de99451ab3c0 | 20 | if (pSCLK) {delete pSCLK; pSCLK = NULL;} // delete allocation. |
gatedClock | 3:de99451ab3c0 | 21 | } |
gatedClock | 3:de99451ab3c0 | 22 | //----------------------------------------------//------------------------------ |
gatedClock | 3:de99451ab3c0 | 23 | void mmSPI::allocations(void) // object allocations. |
gatedClock | 3:de99451ab3c0 | 24 | { |
gatedClock | 3:de99451ab3c0 | 25 | pMOSI = new DigitalOut(mmSPI_MOSI); // SPI MOSI pin object. |
gatedClock | 3:de99451ab3c0 | 26 | if (!pMOSI) error("\n\r mmSPI::allocations : FATAL malloc error for pMOSI. \n\r"); |
gatedClock | 3:de99451ab3c0 | 27 | |
gatedClock | 3:de99451ab3c0 | 28 | pMISO = new DigitalOut(mmSPI_MISO); // SPI MISO pin object. |
gatedClock | 3:de99451ab3c0 | 29 | if (!pMISO) error("\n\r mmSPI::allocations : FATAL malloc error for pMISO. \n\r"); |
gatedClock | 3:de99451ab3c0 | 30 | |
gatedClock | 3:de99451ab3c0 | 31 | pSCLK = new DigitalOut(mmSPI_SCLK); // SPI SCLK pin object. |
gatedClock | 3:de99451ab3c0 | 32 | if (!pSCLK) error("\n\r mmSPI::allocations : FATAL malloc error for pSCLK. \n\r"); |
gatedClock | 3:de99451ab3c0 | 33 | } |
gatedClock | 0:fb42c5acf810 | 34 | //----------------------------------------------//------------------------------ |
gatedClock | 1:15706d15d123 | 35 | char mmSPI::transceive_byte(char cSend) // send/receive a byte. |
gatedClock | 1:15706d15d123 | 36 | { |
gatedClock | 2:bebcf53b72dc | 37 | *pSCLK = 1; |
gatedClock | 1:15706d15d123 | 38 | |
gatedClock | 1:15706d15d123 | 39 | |
gatedClock | 1:15706d15d123 | 40 | |
gatedClock | 1:15706d15d123 | 41 | } |
gatedClock | 1:15706d15d123 | 42 | //----------------------------------------------//------------------------------ |