Ejemplo n.º 1
0
int i2c_read_i2c_block_data(
   unsigned handle, unsigned reg, char *buf, uint32_t count)
{
   int bytes;
   gpioExtent_t ext[1];

   /*
   p1=handle
   p2=reg
   p3=4
   ## extension ##
   uint32_t count
   */

   ext[0].size = sizeof(uint32_t);
   ext[0].ptr = &count;

   bytes = pigpio_command_ext
      (gPigCommand, PI_CMD_I2CRI, handle, reg, 4, 1, ext, 0);

   if (bytes > 0)
   {
      bytes = recvMax(buf, count, bytes);
   }

   pthread_mutex_unlock(&command_mutex);

   return bytes;
}
Ejemplo n.º 2
0
int custom_2(int pi, unsigned arg1, char *argx, unsigned count,
             char *retBuf, uint32_t retMax)
{
   int bytes;
   gpioExtent_t ext[1];

   /*
   p1=arg1
   p2=retMax
   p3=count
   ## extension ##
   char argx[count]
   */

   ext[0].size = count;
   ext[0].ptr = argx;

   bytes = pigpio_command_ext
      (pi, PI_CMD_CF2, arg1, retMax, count, 1, ext, 0);

   if (bytes > 0)
   {
      bytes = recvMax(pi, retBuf, retMax, bytes);
   }

   _pmu(pi);

   return bytes;
}
Ejemplo n.º 3
0
int i2c_block_process_call(
   unsigned handle, unsigned reg, char *buf, unsigned count)
{
   int bytes;
   gpioExtent_t ext[1];

   /*
   p1=handle
   p2=reg
   p3=count
   ## extension ##
   char buf[count]
   */

   ext[0].size = count;
   ext[0].ptr = buf;

   bytes = pigpio_command_ext
      (gPigCommand, PI_CMD_I2CPK, handle, reg, count, 1, ext, 0);

   if (bytes > 0)
   {
      bytes = recvMax(buf, 32, bytes);
   }

   pthread_mutex_unlock(&command_mutex);

   return bytes;
}
Ejemplo n.º 4
0
int spi_xfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count)
{
   int bytes;
   gpioExtent_t ext[1];

   /*
   p1=handle
   p2=0
   p3=count
   ## extension ##
   char buf[count]
   */

   ext[0].size = count;
   ext[0].ptr = txBuf;

   bytes = pigpio_command_ext
      (gPigCommand, PI_CMD_SPIX, handle, 0, count, 1, ext, 0);

   if (bytes > 0)
   {
      bytes = recvMax(rxBuf, count, bytes);
   }

   pthread_mutex_unlock(&command_mutex);

   return bytes;
}
Ejemplo n.º 5
0
int spi_xfer(int pi, unsigned handle, char *txBuf, char *rxBuf, unsigned count)
{
   int bytes;
   gpioExtent_t ext[1];

   /*
   p1=handle
   p2=0
   p3=count
   ## extension ##
   char buf[count]
   */

   ext[0].size = count;
   ext[0].ptr = txBuf;

   bytes = pigpio_command_ext
      (pi, PI_CMD_SPIX, handle, 0, count, 1, ext, 0);

   if (bytes > 0)
   {
      bytes = recvMax(pi, rxBuf, count, bytes);
   }

   _pmu(pi);

   return bytes;
}
Ejemplo n.º 6
0
int custom_2(unsigned arg1, char *argx, unsigned count,
             char *retBuf, uint32_t retMax)
{
   int bytes;
   gpioExtent_t ext[1];

   /*
   p1=arg1
   p2=retMax
   p3=count
   ## extension ##
   char argx[count]
   */

   ext[0].size = count;
   ext[0].ptr = argx;

   bytes = pigpio_command_ext
      (gPigCommand, PI_CMD_CF2, arg1, retMax, count, 1, ext, 0);

   if (bytes > 0)
   {
      bytes = recvMax(retBuf, retMax, bytes);
   }

   pthread_mutex_unlock(&command_mutex);

   return bytes;
}
Ejemplo n.º 7
0
int bb_i2c_zip(
   int      pi,
   unsigned SDA,
   char    *inBuf,
   unsigned inLen,
   char    *outBuf,
   unsigned outLen)
{
   int bytes;
   gpioExtent_t ext[1];

   /*
   p1=SDA
   p2=0
   p3=inLen
   ## extension ##
   char inBuf[inLen]
   */

   ext[0].size = inLen;
   ext[0].ptr = inBuf;

   bytes = pigpio_command_ext
      (pi, PI_CMD_BI2CZ, SDA, 0, inLen, 1, ext, 0);

   if (bytes > 0)
   {
      bytes = recvMax(pi, outBuf, outLen, bytes);
   }

   _pmu(pi);

   return bytes;
}
Ejemplo n.º 8
0
int i2c_block_process_call(
   int pi, unsigned handle, unsigned reg, char *buf, unsigned count)
{
   int bytes;
   gpioExtent_t ext[1];

   /*
   p1=handle
   p2=reg
   p3=count
   ## extension ##
   char buf[count]
   */

   ext[0].size = count;
   ext[0].ptr = buf;

   bytes = pigpio_command_ext
      (pi, PI_CMD_I2CPK, handle, reg, count, 1, ext, 0);

   if (bytes > 0)
   {
      bytes = recvMax(pi, buf, 32, bytes);
   }

   _pmu(pi);

   return bytes;
}
Ejemplo n.º 9
0
int bb_i2c_zip(
   unsigned SDA,
   char    *inBuf,
   unsigned inLen,
   char    *outBuf,
   unsigned outLen)
{
   int bytes;
   gpioExtent_t ext[1];

   /*
   p1=SDA
   p2=0
   p3=inLen
   ## extension ##
   char inBuf[inLen]
   */

   ext[0].size = inLen;
   ext[0].ptr = inBuf;

   bytes = pigpio_command_ext
      (gPigCommand, PI_CMD_BI2CZ, SDA, 0, inLen, 1, ext, 0);

   if (bytes > 0)
   {
      bytes = recvMax(outBuf, outLen, bytes);
   }

   pthread_mutex_unlock(&command_mutex);

   return bytes;
}
Ejemplo n.º 10
0
int i2c_read_device(unsigned handle, char *buf, unsigned count)
{
   int bytes;

   bytes = pigpio_command(gPigCommand, PI_CMD_I2CRD, handle, count, 0);

   if (bytes > 0)
   {
      bytes = recvMax(buf, count, bytes);
   }

   pthread_mutex_unlock(&command_mutex);

   return bytes;
}
Ejemplo n.º 11
0
int i2c_read_block_data(int pi, unsigned handle, unsigned reg, char *buf)
{
   int bytes;

   bytes = pigpio_command(pi, PI_CMD_I2CRK, handle, reg, 0);

   if (bytes > 0)
   {
      bytes = recvMax(pi, buf, 32, bytes);
   }

   _pmu(pi);

   return bytes;
}
Ejemplo n.º 12
0
int i2c_read_device(int pi, unsigned handle, char *buf, unsigned count)
{
   int bytes;

   bytes = pigpio_command(pi, PI_CMD_I2CRD, handle, count, 0);

   if (bytes > 0)
   {
      bytes = recvMax(pi, buf, count, bytes);
   }

   _pmu(pi);

   return bytes;
}
Ejemplo n.º 13
0
int i2c_read_block_data(unsigned handle, unsigned reg, char *buf)
{
   int bytes;

   bytes = pigpio_command(gPigCommand, PI_CMD_I2CRK, handle, reg, 0);

   if (bytes > 0)
   {
      bytes = recvMax(buf, 32, bytes);
   }

   pthread_mutex_unlock(&command_mutex);

   return bytes;
}
Ejemplo n.º 14
0
int bb_serial_read(unsigned user_gpio, void *buf, size_t bufSize)
{
   int bytes;

   bytes = pigpio_command(gPigCommand, PI_CMD_SLR, user_gpio, bufSize, 0);

   if (bytes > 0)
   {
      bytes = recvMax(buf, bufSize, bytes);
   }

   pthread_mutex_unlock(&command_mutex);

   return bytes;
}
Ejemplo n.º 15
0
int bb_serial_read(int pi, unsigned user_gpio, void *buf, size_t bufSize)
{
   int bytes;

   bytes = pigpio_command(pi, PI_CMD_SLR, user_gpio, bufSize, 0);

   if (bytes > 0)
   {
      bytes = recvMax(pi, buf, bufSize, bytes);
   }

   _pmu(pi);

   return bytes;
}
Ejemplo n.º 16
0
int serial_read(unsigned handle, char *buf, unsigned count)
{
   int bytes;

   bytes = pigpio_command
      (gPigCommand, PI_CMD_SERR, handle, count, 0);

   if (bytes > 0)
   {
      bytes = recvMax(buf, count, bytes);
   }

   pthread_mutex_unlock(&command_mutex);

   return bytes;
}
Ejemplo n.º 17
0
int serial_read(int pi, unsigned handle, char *buf, unsigned count)
{
   int bytes;

   bytes = pigpio_command
      (pi, PI_CMD_SERR, handle, count, 0);

   if (bytes > 0)
   {
      bytes = recvMax(pi, buf, count, bytes);
   }

   _pmu(pi);

   return bytes;
}
Ejemplo n.º 18
0
int script_status(unsigned script_id, uint32_t *param)
{
   int status;
   uint32_t p[PI_MAX_SCRIPT_PARAMS+1]; /* space for script status */

   status = pigpio_command(gPigCommand, PI_CMD_PROCP, script_id, 0, 0);

   if (status > 0)
   {
      recvMax(p, sizeof(p), status);
      status = p[0];
      if (param) memcpy(param, p+1, sizeof(p)-4);
   }

   pthread_mutex_unlock(&command_mutex);

   return status;
}
Ejemplo n.º 19
0
int script_status(int pi, unsigned script_id, uint32_t *param)
{
   int status;
   uint32_t p[PI_MAX_SCRIPT_PARAMS+1]; /* space for script status */

   status = pigpio_command(pi, PI_CMD_PROCP, script_id, 0, 0);

   if (status > 0)
   {
      recvMax(pi, p, sizeof(p), status);
      status = p[0];
      if (param) memcpy(param, p+1, sizeof(p)-4);
   }

   _pmu(pi);

   return status;
}