Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: SPIDriver/SPIDriver.cpp
- Revision:
- 2:f2700008c9d9
- Parent:
- 1:53b8c6b13010
- Child:
- 3:da30c350c339
diff -r 53b8c6b13010 -r f2700008c9d9 SPIDriver/SPIDriver.cpp
--- a/SPIDriver/SPIDriver.cpp Wed Apr 30 11:49:26 2014 +0000
+++ b/SPIDriver/SPIDriver.cpp Thu May 01 20:58:59 2014 +0000
@@ -0,0 +1,24 @@
+#include "SPIDriver.h"
+#include "mbed.h"
+
+SPIDriver::SPIDriver(PinName pin1, PinName pin2, PinName pin3, PinName latchpin, PinName cspin, const int freq) : spi(pin1, pin2, pin3){
+ spi.format(8, 3);
+ spi.frequency(freq);
+
+ latch = new DigitalOut(latchpin);
+ cs = new DigitalOut(cspin);
+
+ *latch = 0;
+ *cs = 1;
+}
+
+void SPIDriver::write(uint8_t ledcolor){
+ *cs = 0;
+ spi.write(ledcolor);
+ *cs = 1;
+}
+
+void SPIDriver::pulseLatch(){
+ *latch = 1;
+ *latch = 0;
+}
\ No newline at end of file