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: so.cpp
- Revision:
- 0:32fded6e1775
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/so.cpp Sat Sep 30 17:20:23 2017 +0000 @@ -0,0 +1,42 @@ +//#include "io.h" + +#include "mbed.h" +//#define SO_CLK_PIN 11 +//#define SO_EN_PIN 10 +//#define SO_DATA_PIN 8 + +DigitalOut SO_CLK_PIN(D11); +DigitalOut SO_EN_PIN(D10); +DigitalOut SO_DATA_PIN(D8); + +void soInit(void) { + //not nedded? +} +//pulso de clock para habilitar os dados na sáida +void PulseEnClock(void){ + SO_EN_PIN = 1; + SO_EN_PIN = 0; + //digitalWrite(SO_EN_PIN, HIGH); + //digitalWrite(SO_EN_PIN, LOW); +} +//pulso de clock para enviar um bit +void PulseClockData(void){ + SO_CLK_PIN = 1; + SO_CLK_PIN = 0; + + //digitalWrite(SO_CLK_PIN, HIGH); + //digitalWrite(SO_CLK_PIN, LOW); +} +void soWrite(int value) { + char i; + SO_CLK_PIN = 0; + //digitalWrite(SO_CLK_PIN, LOW); + for (i = 0; i < 8; i++) { + //make shure its one(1) or zero(0) + SO_DATA_PIN = !(!(value & 0x80)) ; + //digitalWrite(SO_DATA_PIN, value & 0x80); + PulseClockData(); + value <<= 1; + } + PulseEnClock(); +}