524APP

Fork of Post_2 by Terry Lung

Committer:
TYLG
Date:
Thu May 24 11:20:14 2018 +0000
Revision:
0:c0bf253f46e0
Child:
1:a100355f82ff
524AP

Who changed what in which revision?

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