Public fork of mbed-src to add generic stm32f030k6 target
Fork of mbed-src by
Diff: api/I2C.h
- Revision:
- 525:c320967f86b9
- Parent:
- 13:0645d8841f51
- Child:
- 563:536c9fb088a0
--- a/api/I2C.h Mon Apr 27 09:45:08 2015 +0100 +++ b/api/I2C.h Tue Apr 28 11:45:12 2015 +0100 @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2015 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,12 @@ #include "i2c_api.h" +#if DEVICE_I2C_ASYNCH +#include "CThunk.h" +#include "dma_api.h" +#include "FunctionPointer.h" +#endif + namespace mbed { /** An I2C Master, used for communicating with I2C slave devices @@ -129,6 +135,32 @@ */ void stop(void); +#if DEVICE_I2C_ASYNCH + + /** Start non-blocking I2C transfer. + * + * @param address 8/10 bit I2c slave address + * @param tx_buffer The TX buffer with data to be transfered + * @param tx_length The length of TX buffer + * @param rx_buffer The RX buffer which is used for received data + * @param rx_length The length of RX buffer + * @param event The logical OR of events to modify + * @param callback The event callback function + * @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); + + /** Abort the on-going I2C transfer + */ + void abort_transfer(); +protected: + void irq_handler_asynch(void); + event_callback_t _callback; + CThunk<I2C> _irq; + DMAUsage _usage; +#endif + protected: void aquire();