Buffered Test

Dependencies:   ExioBufferdController MCP23S17 mbed-rtos mbed

Committer:
ryood
Date:
Fri Nov 04 19:48:29 2016 +0000
Revision:
0:7578a6b316b7
Child:
1:1046d9aef179
Test ExioInBuffer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ryood 0:7578a6b316b7 1 /*
ryood 0:7578a6b316b7 2 * ExioBufferdController Test
ryood 0:7578a6b316b7 3 *
ryood 0:7578a6b316b7 4 * mbed: revison 121
ryood 0:7578a6b316b7 5 * mbed-rtos: revision 117
ryood 0:7578a6b316b7 6 *
ryood 0:7578a6b316b7 7 * Created: 2016.11.05
ryood 0:7578a6b316b7 8 *
ryood 0:7578a6b316b7 9 */
ryood 0:7578a6b316b7 10
ryood 0:7578a6b316b7 11 #include "mbed.h"
ryood 0:7578a6b316b7 12 #include "rtos.h"
ryood 0:7578a6b316b7 13
ryood 0:7578a6b316b7 14 #include "ExioMcp23s17.h"
ryood 0:7578a6b316b7 15 #include "ExioInBuffer.h"
ryood 0:7578a6b316b7 16
ryood 0:7578a6b316b7 17 SPI Spi(PC_12, PC_11, PC_10); // SPI3: mosi, miso, sclk
ryood 0:7578a6b316b7 18 //SPI Spi(PA_7, PA_6, PA_5); // SPI1: mosi, miso, sclk
ryood 0:7578a6b316b7 19
ryood 0:7578a6b316b7 20 // MExioMcp23s17(int hardwareaddress, SPI& spi, PinName nCs, PinName nReset);
ryood 0:7578a6b316b7 21 ExioMcp23s17 Exio(0x00, Spi, PD_2, PA_13);
ryood 0:7578a6b316b7 22
ryood 0:7578a6b316b7 23 void testExioInBuffer()
ryood 0:7578a6b316b7 24 {
ryood 0:7578a6b316b7 25 printf("*** Test ExioInBuffer ***\r\n");
ryood 0:7578a6b316b7 26
ryood 0:7578a6b316b7 27 // Reset MCP23S17
ryood 0:7578a6b316b7 28 Exio.reset();
ryood 0:7578a6b316b7 29
ryood 0:7578a6b316b7 30 // set the port as input
ryood 0:7578a6b316b7 31 Exio.ioDirection(ExioPortB, 0xff);
ryood 0:7578a6b316b7 32 Exio.ioPullup(ExioPortB, 0xff);
ryood 0:7578a6b316b7 33 Exio.ioPolarity(ExioPortB, 0xff);
ryood 0:7578a6b316b7 34
ryood 0:7578a6b316b7 35 ExioInBuffer exioInBuffer(&Exio, ExioPortB, 10);
ryood 0:7578a6b316b7 36
ryood 0:7578a6b316b7 37 exioInBuffer.run();
ryood 0:7578a6b316b7 38
ryood 0:7578a6b316b7 39 while (true) {
ryood 0:7578a6b316b7 40 uint8_t v = exioInBuffer.readPort();
ryood 0:7578a6b316b7 41 printf("%d\r\n", v);
ryood 0:7578a6b316b7 42 //Thread::wait(10);
ryood 0:7578a6b316b7 43 }
ryood 0:7578a6b316b7 44 }
ryood 0:7578a6b316b7 45
ryood 0:7578a6b316b7 46 int main()
ryood 0:7578a6b316b7 47 {
ryood 0:7578a6b316b7 48 testExioInBuffer();
ryood 0:7578a6b316b7 49 }