emersonwsm

PBO595.cpp

Dec 28th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. #include "PBO595.h"
  2.  
  3. /***************************************
  4.  * *** Constructors ***                *
  5.  ***************************************/
  6.  
  7. PBO595::PBO595() {
  8.   init(PIN_CS, PIN_CLOCK, PIN_DATA_OUT, PIN_LATCH);
  9. }
  10.  
  11. // Assign values to pin numbers.
  12. PBO595::PBO595(uint8_t pinCS, uint8_t pinClock, uint8_t pinData, uint8_t pinLatch) {
  13.   init(pinCS, pinClock, pinData, pinLatch);
  14. }
  15.  
  16. /***************************************
  17.  * *** Public Methods ***              *
  18.  ***************************************/
  19.  
  20. // Begins the
  21. void PBO595::begin() {
  22. }
  23.  
  24. // Read a value from the bus.
  25. DATA_SIZE PBO595::read() {
  26.   return 0;
  27. }
  28.  
  29. // Write a value to the bus.
  30. void PBO595::write(DATA_SIZE value) {
  31.   digitalWrite(_pinLatch, HIGH);
  32.   digitalWrite(_pinCS, LOW);
  33.   shiftOut(_pinData, _pinClock, MSBFIRST, value);  
  34.   digitalWrite(_pinCS, HIGH);
  35.   digitalWrite(_pinLatch, LOW);
  36. }
  37.  
  38. /***************************************
  39.  * *** Private Methods ***             *
  40.  ***************************************/
  41.  
  42. void PBO595::init(uint8_t pinCS, uint8_t pinClock, uint8_t pinData, uint8_t pinLatch) {
  43.   // Assign control pins.
  44.   _pinCS    = pinCS;
  45.   _pinClock = pinClock;
  46.   _pinData  = pinData;  
  47.   _pinLatch = pinLatch;
  48.  
  49.   // Define directions of the control pins.
  50.   pinMode(_pinCS,    OUTPUT);
  51.   pinMode(_pinClock, OUTPUT);
  52.   pinMode(_pinData,  OUTPUT);
  53.   pinMode(_pinLatch, OUTPUT);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment