keybrd library is an open source library for creating custom-keyboard firmware.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.

PortWrite_PCA9655E.cpp 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "PortWrite_PCA9655E.h"
  2. /* begin() is called from Scanner_IOE::begin().
  3. Initiates I2C bus and configures port pins to output.
  4. PCA9655E supports I2C SCL Clock Frequencies: 100 kHz, 400 kHz, 1000 kHz (Datasheet page 1 & 6)
  5. The electrical limitation to bus speed is bus capacitance and the length of the wires involved.
  6. Longer wires require lower clock speeds.
  7. http://playground.arduino.cc/Main/WireLibraryDetailedReference > Wire.setclock()
  8. */
  9. void PortWrite_PCA9655E::begin()
  10. {
  11. Wire.begin(); //initiate I2C bus to 100 kHz
  12. //Wire.setClock(400000L); //set I2C bus to 400 kHz (have not tested 400 kHz)
  13. Wire.beginTransmission(port.DEVICE_ADDR);
  14. Wire.write(port.num + 6); //configuration byte command
  15. Wire.write(0); //configure all pins as output
  16. Wire.endTransmission();
  17. }
  18. /* write() sets pin output to logicLevel.
  19. pin is bit pattern, where pin being strobed is 1.
  20. logicLevel is HIGH or LOW.
  21. write() does not overwrite the other pins.
  22. */
  23. void PortWrite_PCA9655E::write(const uint8_t pin, const bool logicLevel)
  24. {
  25. if (logicLevel == LOW) //if pin low
  26. {
  27. port.outputVal &= ~pin; //set pin output to low
  28. }
  29. else //if strobestrobe high
  30. {
  31. port.outputVal |= pin; //set pin output to high
  32. }
  33. Wire.beginTransmission(port.DEVICE_ADDR);
  34. Wire.write(port.num + 2); //output Byte command
  35. Wire.write(port.outputVal);
  36. Wire.endTransmission();
  37. }