staticint ir_spi_tx(struct rc_dev *dev, unsignedint *buffer, unsignedint count)
{ int i; int ret; unsignedint len = 0; struct ir_spi_data *idata = dev->priv; struct spi_transfer xfer;
u16 *tx_buf;
/* convert the pulse/space signal to raw binary signal */ for (i = 0; i < count; i++) {
buffer[i] = DIV_ROUND_CLOSEST_ULL((u64)buffer[i] * idata->freq,
1000000);
len += buffer[i];
}
tx_buf = kmalloc_array(len, sizeof(*tx_buf), GFP_KERNEL); if (!tx_buf) return -ENOMEM;
len = 0; for (i = 0; i < count; i++) { int j;
u16 val;
/* * The first value in buffer is a pulse, so that 0, 2, 4, ... * contain a pulse duration. On the contrary, 1, 3, 5, ... * contain a space duration.
*/
val = (i % 2) ? idata->space : idata->pulse; for (j = 0; j < buffer[i]; j++)
tx_buf[len++] = val;
}
idata->negated = device_property_read_bool(dev, "led-active-low");
ret = device_property_read_u8(dev, "duty-cycle", &dc); if (ret)
dc = 50;
/* * ir_spi_set_duty_cycle() cannot fail, it returns int * to be compatible with the rc->s_tx_duty_cycle function.
*/
ir_spi_set_duty_cycle(idata->rc, dc);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.