Sog Yang
/
mbed_SPIS_multiByte_example_SOG
Sog update version
Fork of mbed_SPIS_multiByte_example by
main.cpp@2:c520d7c7739d, 2017-05-31 (annotated)
- Committer:
- tsungta
- Date:
- Wed May 31 09:30:53 2017 +0000
- Revision:
- 2:c520d7c7739d
- Parent:
- 1:58f0712d9aa2
- Child:
- 4:8e796b751cd3
Modified API receive and reply; 'receive' is functional ; 'reply' need to FIX
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tsungta | 0:b7415ae44dac | 1 | #include "mbed.h" |
tsungta | 0:b7415ae44dac | 2 | |
tsungta | 0:b7415ae44dac | 3 | #include "SPISlave_multiByte.h" |
tsungta | 0:b7415ae44dac | 4 | SPISlave_multiByte device(A1, A2, A3, p3); // mosi, miso, sclk, ssel |
tsungta | 0:b7415ae44dac | 5 | Serial uart(USBTX, USBRX); |
tsungta | 0:b7415ae44dac | 6 | |
tsungta | 0:b7415ae44dac | 7 | int main() { |
tsungta | 0:b7415ae44dac | 8 | uart.printf("START!"); |
tsungta | 1:58f0712d9aa2 | 9 | device.format(8,1); |
tsungta | 2:c520d7c7739d | 10 | |
tsungta | 2:c520d7c7739d | 11 | device.reply((uint8_t*)"xyz", 3); |
tsungta | 0:b7415ae44dac | 12 | while(1) { |
tsungta | 2:c520d7c7739d | 13 | if(device.receive(3)) { |
tsungta | 0:b7415ae44dac | 14 | int v = device.read(); // Read byte from master |
tsungta | 1:58f0712d9aa2 | 15 | uart.printf("v = %s ", v); |
tsungta | 1:58f0712d9aa2 | 16 | |
tsungta | 0:b7415ae44dac | 17 | } |
tsungta | 0:b7415ae44dac | 18 | } |
tsungta | 0:b7415ae44dac | 19 | } |