keybrd library is an open source library for creating custom-keyboard firmware.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

PortMCP23S17.cpp 696B

12345678910111213141516
  1. #include "PortMCP23S17.h"
  2. /* transfer() writes data to registerAddr, reads portSate from registerAddr, and returns portState.
  3. */
  4. uint8_t PortMCP23S17::transfer(const uint8_t command, const uint8_t registerAddr, const uint8_t data)
  5. {
  6. uint8_t portState; //bit pattern
  7. digitalWrite(SS, LOW); //enable Slave Select
  8. SPI.transfer(command); //write or read command
  9. SPI.transfer(registerAddr); //register address to write data to
  10. portState = SPI.transfer(data); //write data, read portState
  11. digitalWrite(SS, HIGH); //disable Slave Select
  12. return portState;
  13. }