mirror of https://github.com/ARMmbed/mbed-os.git
I2C - costness for tx buffer
parent
614c5539bc
commit
e7feba4e21
|
@ -149,7 +149,7 @@ public:
|
|||
* @param repeated Repeated start, true - do not send stop at end
|
||||
* @return Zero if the transfer has started, or -1 if I2C peripheral is busy
|
||||
*/
|
||||
int transfer(int address, char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t& callback, int event = I2C_EVENT_TRANSFER_COMPLETE, bool repeated = false);
|
||||
int transfer(int address, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t& callback, int event = I2C_EVENT_TRANSFER_COMPLETE, bool repeated = false);
|
||||
|
||||
/** Abort the on-going I2C transfer
|
||||
*/
|
||||
|
|
|
@ -92,7 +92,7 @@ void I2C::stop(void) {
|
|||
|
||||
#if DEVICE_I2C_ASYNCH
|
||||
|
||||
int I2C::transfer(int address, char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t& callback, int event, bool repeated)
|
||||
int I2C::transfer(int address, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t& callback, int event, bool repeated)
|
||||
{
|
||||
if (i2c_active(&_i2c)) {
|
||||
return -1; // transaction ongoing
|
||||
|
|
|
@ -191,7 +191,7 @@ void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask);
|
|||
* @param handler The I2C IRQ handler to be set
|
||||
* @param hint DMA hint usage
|
||||
*/
|
||||
void i2c_transfer_asynch(i2c_t *obj, void *tx, size_t tx_length, void *rx, size_t rx_length, uint32_t address, uint32_t stop, uint32_t handler, uint32_t event, DMAUsage hint);
|
||||
void i2c_transfer_asynch(i2c_t *obj, const void *tx, size_t tx_length, void *rx, size_t rx_length, uint32_t address, uint32_t stop, uint32_t handler, uint32_t event, DMAUsage hint);
|
||||
|
||||
/** The asynchronous IRQ handler
|
||||
* @param obj The I2C object which holds the transfer information
|
||||
|
|
|
@ -426,7 +426,7 @@ void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask)
|
|||
* @param handler The I2C IRQ handler to be set
|
||||
* @param hint DMA hint usage
|
||||
*/
|
||||
void i2c_transfer_asynch(i2c_t *obj, void *tx, size_t tx_length, void *rx, size_t rx_length, uint32_t address, uint32_t stop, uint32_t handler, uint32_t event, DMAUsage hint)
|
||||
void i2c_transfer_asynch(i2c_t *obj, const void *tx, size_t tx_length, void *rx, size_t rx_length, uint32_t address, uint32_t stop, uint32_t handler, uint32_t event, DMAUsage hint)
|
||||
{
|
||||
I2C_TransferReturn_TypeDef retval;
|
||||
if(i2c_active(obj)) return;
|
||||
|
@ -440,7 +440,7 @@ void i2c_transfer_asynch(i2c_t *obj, void *tx, size_t tx_length, void *rx, size_
|
|||
if((tx_length > 0) && (rx_length == 0)) {
|
||||
obj->i2c.xfer.flags = I2C_FLAG_WRITE;
|
||||
//Store buffer info
|
||||
obj->i2c.xfer.buf[0].data = tx;
|
||||
obj->i2c.xfer.buf[0].data = (void *)tx;
|
||||
obj->i2c.xfer.buf[0].len = (uint16_t) tx_length;
|
||||
} else if ((tx_length == 0) && (rx_length > 0)) {
|
||||
obj->i2c.xfer.flags = I2C_FLAG_READ;
|
||||
|
@ -450,7 +450,7 @@ void i2c_transfer_asynch(i2c_t *obj, void *tx, size_t tx_length, void *rx, size_
|
|||
} else if ((tx_length > 0) && (rx_length > 0)) {
|
||||
obj->i2c.xfer.flags = I2C_FLAG_WRITE_READ;
|
||||
//Store buffer info
|
||||
obj->i2c.xfer.buf[0].data = tx;
|
||||
obj->i2c.xfer.buf[0].data = (void *)tx;
|
||||
obj->i2c.xfer.buf[0].len = (uint16_t) tx_length;
|
||||
obj->i2c.xfer.buf[1].data = rx;
|
||||
obj->i2c.xfer.buf[1].len = (uint16_t) rx_length;
|
||||
|
|
|
@ -822,7 +822,7 @@ static void spi_activate_dma(spi_t *obj, void* rxdata, const void* txdata, int t
|
|||
true,
|
||||
false,
|
||||
(obj->spi.bits <= 8 ? (void *)&(obj->spi.spi->TXDATA) : (void *)&(obj->spi.spi->TXDOUBLE)), //When frame size > 9, point to TXDOUBLE
|
||||
(txdata == 0 ? (const void *)&fill_word : txdata), // When there is nothing to transmit, point to static fill word
|
||||
(txdata == 0 ? &fill_word : (void *)txdata), // When there is nothing to transmit, point to static fill word
|
||||
(obj->spi.bits <= 8 ? tx_length - 1 : (tx_length / 2) - 1)); // When using TXDOUBLE, recalculate transfer length
|
||||
} else {
|
||||
/* Frame size == 9 */
|
||||
|
@ -860,7 +860,7 @@ static void spi_activate_dma(spi_t *obj, void* rxdata, const void* txdata, int t
|
|||
true,
|
||||
false,
|
||||
(void *)&(obj->spi.spi->TXDATAX), //When frame size > 9, point to TXDOUBLE
|
||||
(txdata == 0 ? (const void *)&fill_word : txdata), // When there is nothing to transmit, point to static fill word
|
||||
(txdata == 0 ? &fill_word : (void *)txdata), // When there is nothing to transmit, point to static fill word
|
||||
(tx_length / 2) - 1); // When using TXDOUBLE, recalculate transfer length
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue