static int lm75_readtemp(FAR struct lm75_dev_s *priv, FAR b16_t *temp) { b16_t temp16; int ret; /* Read the raw temperature data (b16_t) */ ret = lm75_readb16(priv, LM75_TEMP_REG, &temp16); if (ret < 0) { sndbg("lm75_readb16 failed: %d\n", ret); return ret; } sndbg("Centigrade: %08x\n", temp16); /* Was fahrenheit requested? */ if (priv->fahrenheit) { /* Centigrade to Fahrenheit conversion: F = 9*C/5 + 32 */ temp16 = b16mulb16(temp16, B16_9DIV5) + B16_32; sndbg("Fahrenheit: %08x\n", temp16); } *temp = temp16; return OK; }
static b16_t nxgl_interpolate(b16_t x, b16_t dy, b16_t dxdy) { b16_t dx = b16mulb16(dy, dxdy); return x + dx; }