Пример #1
0
/**
 * set a single port to Output or Input - function requrired for wiringPi interface
 * @param pin - port relative to pinBase
 * @param newMode - 0 - Output; 1 - Input
 * @return new value of complete port
 */
int Max7312::configPort(int pin, bool newMode){
   if (isLowerPort(pin)) {
      if(newMode)
      {
         SETBIT(_port1_mode, (GET_LOWER_PIN_ID(pin)));
      }
      else
      {
         CLEARBIT(_port1_mode, (GET_LOWER_PIN_ID(pin)));
      }
      configPort1(_port1_mode);
      return _port1_mode;
   } else {
      if(newMode)
      {
         SETBIT(_port2_mode, (GET_HIGHER_PIN_ID(pin)));
      }
      else
      {
         CLEARBIT(_port2_mode, (GET_HIGHER_PIN_ID(pin)));
      }
      configPort2(_port2_mode);
      return _port2_mode;
   }
}
Пример #2
0
void Max7312::init(unsigned char portDirection1, unsigned char portDirection2, unsigned char timeoutFlag)
{
	initDataBuffers();
	Wire.begin();
	configPort1(portDirection1);
	configPort2(portDirection2);
	configTimeout(timeoutFlag);
}
Пример #3
0
/**
 * initialize the Max7311
 * @param portDirection1 default values of ports 0-7 (1 - input; 0 - output)
 * @param portDirection2 default values of ports 8-15 (1 - input; 0 - output)
 * @param timeoutFlag 1 enable Bus timeout, 0 disable Bus timeout
*/
void Max7312::init(unsigned char portDirection1,
                   unsigned char portDirection2,
                   unsigned char timeoutFlag)
{
   initDataBuffers();


   if ((fd = wiringPiI2CSetup (_chipAddress)) < 0)
     return;

   node = wiringPiNewNode (_pinBase, MAX7312_NUM_OF_PORTS) ;

   node->fd           = fd ;
   node->pinMode      = _configPortMax7312;
   node->digitalRead  = _readPortMax7312;
   node->digitalWrite = _writePortMax7312;
   node->data1        = readPort1 () ;
   node->data2        = readPort2 () ;
   node->thisNode     = this;
   configPort1(portDirection1);
   configPort2(portDirection2);
   configTimeout(timeoutFlag);
}