Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ExioController MCP23S17 mbed-rtos mbed
Diff: main.cpp
- Revision:
- 0:0b1ae70a694b
- Child:
- 1:e0679b70b51d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Oct 30 12:29:23 2016 +0000 @@ -0,0 +1,45 @@ +#include "mbed.h" +#include "rtos.h" +#include "ExioMcp23s17.h" + +SPI Spi(PC_12, PC_11, PC_10); // SPI3: mosi, miso, sclk +//SPI Spi(PA_7, PA_6, PA_5); // SPI1: mosi, miso, sclk + +// MExioMcp23s17(int hardwareaddress, SPI& spi, PinName nCs, PinName nReset); +ExioMcp23s17 Exio(0x00, Spi, PD_2, PA_13); + +void ExioMcp23s17Test() +{ + printf("\r\n\n*** ExioMcp23s17 ***\r\n"); + + // Reset MCP23S17 + Exio.reset(); + + // PORTA output + Exio.ioDirection(ExioPortA, 0x00); + + // PORTB input + Exio.ioDirection(ExioPortB, 0xFF); + // PORTB pull-up + Exio.ioPullup(ExioPortB, 0xFF); + // PORTB invert polarity + Exio.ioPolarity(ExioPortB, 0xFF); + + // LED Check + for (int i = 0; i < 8; i++) { + Exio.writePort(ExioPortA, 1 << i); + wait(0.1); + } + Exio.writePort(ExioPortB, 0x00); + + while (true) { + char data = Exio.readPort(ExioPortB); + wait_us(1); + Exio.writePort(ExioPortA, data); + } +} + +int main() +{ + ExioMcp23s17Test(); +} \ No newline at end of file