ATS

Committer:
TYLG
Date:
Wed Apr 25 02:00:00 2018 +0000
Revision:
0:d5c2f505a436
ATS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TYLG 0:d5c2f505a436 1 #include "mbed.h"
TYLG 0:d5c2f505a436 2
TYLG 0:d5c2f505a436 3 DigitalOut led(LED2);
TYLG 0:d5c2f505a436 4 SPI spi(D11, D12, D13); // mosi, miso, sclk
TYLG 0:d5c2f505a436 5 DigitalOut CS(D8);
TYLG 0:d5c2f505a436 6
TYLG 0:d5c2f505a436 7 Serial pc(PC_6, PC_7);
TYLG 0:d5c2f505a436 8
TYLG 0:d5c2f505a436 9 int main() {
TYLG 0:d5c2f505a436 10 // specify period first
TYLG 0:d5c2f505a436 11 led = 1;
TYLG 0:d5c2f505a436 12 spi.format(8,3);
TYLG 0:d5c2f505a436 13 spi.frequency(2000000);
TYLG 0:d5c2f505a436 14 CS = 1;
TYLG 0:d5c2f505a436 15
TYLG 0:d5c2f505a436 16 pc.baud(2000000);
TYLG 0:d5c2f505a436 17
TYLG 0:d5c2f505a436 18 while(1)
TYLG 0:d5c2f505a436 19 {
TYLG 0:d5c2f505a436 20 //CS = 0;
TYLG 0:d5c2f505a436 21 //spi.write(0x8F);
TYLG 0:d5c2f505a436 22 //spi.write(0x00);
TYLG 0:d5c2f505a436 23 //CS = 1;
TYLG 0:d5c2f505a436 24 pc.printf("5");
TYLG 0:d5c2f505a436 25
TYLG 0:d5c2f505a436 26 }
TYLG 0:d5c2f505a436 27 // 4 second period
TYLG 0:d5c2f505a436 28 //led.write(0.5f); // 50% duty cycle, relative to period
TYLG 0:d5c2f505a436 29 //led = 0.5f; // shorthand for led.write()
TYLG 0:d5c2f505a436 30 //led.pulsewidth(2); // alternative to led.write, set duty cycle time in seconds
TYLG 0:d5c2f505a436 31 //while(1);
TYLG 0:d5c2f505a436 32 }