Khemiri Mahrane
/
SPICommSTM32f4
SPIWithSTM32F4
main.cpp@0:ce4f87a989a6, 2016-02-09 (annotated)
- Committer:
- Mahran
- Date:
- Tue Feb 09 18:16:28 2016 +0000
- Revision:
- 0:ce4f87a989a6
SPI
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mahran | 0:ce4f87a989a6 | 1 | #include "mbed.h" |
Mahran | 0:ce4f87a989a6 | 2 | |
Mahran | 0:ce4f87a989a6 | 3 | SPISlave SPINUCLEO(PA_7,PA_6,PA_5,PA_4); |
Mahran | 0:ce4f87a989a6 | 4 | DigitalOut myled(LED1); |
Mahran | 0:ce4f87a989a6 | 5 | int main() { |
Mahran | 0:ce4f87a989a6 | 6 | int a=0; |
Mahran | 0:ce4f87a989a6 | 7 | myled = 0; |
Mahran | 0:ce4f87a989a6 | 8 | SPINUCLEO.frequency(21000000); |
Mahran | 0:ce4f87a989a6 | 9 | SPINUCLEO.reply(0x00); |
Mahran | 0:ce4f87a989a6 | 10 | |
Mahran | 0:ce4f87a989a6 | 11 | while (1) |
Mahran | 0:ce4f87a989a6 | 12 | { |
Mahran | 0:ce4f87a989a6 | 13 | if (SPINUCLEO.receive()) |
Mahran | 0:ce4f87a989a6 | 14 | { |
Mahran | 0:ce4f87a989a6 | 15 | a=SPINUCLEO.read(); |
Mahran | 0:ce4f87a989a6 | 16 | SPINUCLEO.reply(a); |
Mahran | 0:ce4f87a989a6 | 17 | myled = 1; |
Mahran | 0:ce4f87a989a6 | 18 | wait(2); |
Mahran | 0:ce4f87a989a6 | 19 | myled = 0; |
Mahran | 0:ce4f87a989a6 | 20 | wait(2); |
Mahran | 0:ce4f87a989a6 | 21 | } |
Mahran | 0:ce4f87a989a6 | 22 | |
Mahran | 0:ce4f87a989a6 | 23 | } |
Mahran | 0:ce4f87a989a6 | 24 | |
Mahran | 0:ce4f87a989a6 | 25 | } |