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: SDFileSystem app epson mbed msp430 pl tests
mcp23s17.cpp
00001 // 00002 // Filename: mcp23s17.cpp 00003 // 00004 // Flexbook Hardware Abstraction Layer. 00005 // 00006 00007 #include "mcp23s17.h" 00008 00009 namespace HAL { 00010 00011 MCP23S17::MCP23S17(int addressin, SPI &spiin, DigitalOut &csin) 00012 : address(addressin), spi(spiin), cs(csin) 00013 { 00014 spi.format(8, 1); 00015 } 00016 00017 int MCP23S17::Read(REG_MCP23S17 reg) 00018 { 00019 cs = 0; 00020 spi.write(address | 0x41); 00021 spi.write(reg); 00022 int data = spi.write(0x00); // Write dummy value to read. 00023 cs = 1; 00024 00025 return data; 00026 } 00027 00028 void MCP23S17::Write(REG_MCP23S17 reg, int value) 00029 { 00030 cs = 0; 00031 spi.write(address | 0x40); 00032 spi.write(reg); 00033 spi.write(value); 00034 cs = 1; 00035 } 00036 00037 } // End HAL namespace. 00038
Generated on Tue Jul 12 2022 21:14:35 by
