Changeset 429 for EcnlProtoTool/trunk/asp3_dcre/mbed/hal/i2c_api.h
- Timestamp:
- Jul 3, 2020, 7:19:17 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/i2c_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2015 ARM Limited … … 18 21 19 22 #include "device.h" 20 #include "buffer.h" 23 #include "hal/buffer.h" 24 25 #if DEVICE_I2C_ASYNCH 26 #include "hal/dma_api.h" 27 #endif 21 28 22 29 #if DEVICE_I2C 23 30 24 31 /** 25 * @defgroup I2CEvents I2C Events Macros32 * @defgroup hal_I2CEvents I2C Events Macros 26 33 * 27 34 * @{ … … 36 43 37 44 #if DEVICE_I2C_ASYNCH 38 /** Asynch i2c halstructure45 /** Asynch I2C HAL structure 39 46 */ 40 47 typedef struct { 41 struct i2c_s i2c; /**< Target specific i2cstructure */48 struct i2c_s i2c; /**< Target specific I2C structure */ 42 49 struct buffer_s tx_buff; /**< Tx buffer */ 43 50 struct buffer_s rx_buff; /**< Rx buffer */ … … 45 52 46 53 #else 47 /** Non-asynch i2c halstructure54 /** Non-asynch I2C HAL structure 48 55 */ 49 56 typedef struct i2c_s i2c_t; … … 61 68 62 69 /** 63 * \defgroup GeneralI2C I2C Configuration Functions70 * \defgroup hal_GeneralI2C I2C Configuration Functions 64 71 * @{ 65 72 */ 66 73 67 74 /** Initialize the I2C peripheral. It sets the default parameters for I2C 68 * peripheral, and configure its specifieds pins. 69 * @param obj The i2c object 75 * peripheral, and configures its specifieds pins. 76 * 77 * @param obj The I2C object 70 78 * @param sda The sda pin 71 79 * @param scl The scl pin … … 73 81 void i2c_init(i2c_t *obj, PinName sda, PinName scl); 74 82 75 /** Configure the I2C frequency. 76 * @param obj The i2c object 83 /** Configure the I2C frequency 84 * 85 * @param obj The I2C object 77 86 * @param hz Frequency in Hz 78 87 */ 79 88 void i2c_frequency(i2c_t *obj, int hz); 80 89 81 /** Send START command. 82 * @param obj The i2c object 90 /** Send START command 91 * 92 * @param obj The I2C object 83 93 */ 84 94 int i2c_start(i2c_t *obj); 85 95 86 /** Send STOP command. 87 * @param obj The i2c object 96 /** Send STOP command 97 * 98 * @param obj The I2C object 88 99 */ 89 100 int i2c_stop(i2c_t *obj); 90 101 91 /** Blocking reading data. 92 * @param obj The i2c object 102 /** Blocking reading data 103 * 104 * @param obj The I2C object 93 105 * @param address 7-bit address (last bit is 1) 94 106 * @param data The buffer for receiving … … 97 109 * @return Number of read bytes 98 110 */ 99 int i2c_read(i2c_t *obj, int address, char *data, int length, int stop); 100 101 /** Blocking sending data. 102 * @param obj The i2c object 111 int i2c_read(i2c_t *obj, int address, char *data, int length, int stop); 112 113 /** Blocking sending data 114 * 115 * @param obj The I2C object 103 116 * @param address 7-bit address (last bit is 0) 104 117 * @param data The buffer for sending 105 * @param length Number of bytes to wr te118 * @param length Number of bytes to write 106 119 * @param stop Stop to be generated after the transfer is done 107 * @return Number of written bytes 108 */ 109 int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop); 110 111 /** Reset I2C peripheral. TODO: The action here. Most of the implementation sends stop(). 112 * @param obj The i2c object 120 * @return 121 * zero or non-zero - Number of written bytes 122 * negative - I2C_ERROR_XXX status 123 */ 124 int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop); 125 126 /** Reset I2C peripheral. TODO: The action here. Most of the implementation sends stop() 127 * 128 * @param obj The I2C object 113 129 */ 114 130 void i2c_reset(i2c_t *obj); 115 131 116 /** Read one byte. 117 * @param obj The i2c object 132 /** Read one byte 133 * 134 * @param obj The I2C object 118 135 * @param last Acknoledge 119 136 * @return The read byte 120 137 */ 121 int i2c_byte_read(i2c_t *obj, int last); 122 123 /** Write one byte. 124 * @param obj The i2c object 138 int i2c_byte_read(i2c_t *obj, int last); 139 140 /** Write one byte 141 * 142 * @param obj The I2C object 125 143 * @param data Byte to be written 126 * @return 1 if NAK was received, 0if ACK was received, 2 for timeout.127 */ 128 int 144 * @return 0 if NAK was received, 1 if ACK was received, 2 for timeout. 145 */ 146 int i2c_byte_write(i2c_t *obj, int data); 129 147 130 148 /**@}*/ … … 139 157 /** Configure I2C as slave or master. 140 158 * @param obj The I2C object 159 * @param enable_slave Enable i2c hardware so you can receive events with ::i2c_slave_receive 141 160 * @return non-zero if a value is available 142 161 */ … … 152 171 /** Configure I2C as slave or master. 153 172 * @param obj The I2C object 173 * @param data The buffer for receiving 174 * @param length Number of bytes to read 154 175 * @return non-zero if a value is available 155 176 */ … … 158 179 /** Configure I2C as slave or master. 159 180 * @param obj The I2C object 181 * @param data The buffer for sending 182 * @param length Number of bytes to write 160 183 * @return non-zero if a value is available 161 184 */ … … 177 200 178 201 /** 179 * \defgroup AsynchI2C Asynchronous I2C Hardware Abstraction Layer 180 * @{ 181 */ 182 183 /** Start i2c asynchronous transfer. 202 * \defgroup hal_AsynchI2C Asynchronous I2C Hardware Abstraction Layer 203 * @{ 204 */ 205 206 /** Start I2C asynchronous transfer 207 * 184 208 * @param obj The I2C object 185 * @param tx The buffer to send186 * @param tx_length The number of words to transmit187 * @param rx The buffer to receive188 * @param rx_length The number of words to receive189 * @param address The address to be set - 7bit or 9 209 * @param tx The transmit buffer 210 * @param tx_length The number of bytes to transmit 211 * @param rx The receive buffer 212 * @param rx_length The number of bytes to receive 213 * @param address The address to be set - 7bit or 9bit 190 214 * @param stop If true, stop will be generated after the transfer is done 191 215 * @param handler The I2C IRQ handler to be set 216 * @param event Event mask for the transfer. See \ref hal_I2CEvents 192 217 * @param hint DMA hint usage 193 218 */ … … 195 220 196 221 /** The asynchronous IRQ handler 222 * 197 223 * @param obj The I2C object which holds the transfer information 198 * @return event flags if a transfer termination condition was met or 0 otherwise.224 * @return Event flags if a transfer termination condition was met, otherwise return 0. 199 225 */ 200 226 uint32_t i2c_irq_handler_asynch(i2c_t *obj); 201 227 202 /** Attempts to determine if I2C peripheral is already in use. 203 * @param obj The I2C object 204 * @return non-zero if the I2C module is active or zero if it is not 228 /** Attempts to determine if the I2C peripheral is already in use 229 * 230 * @param obj The I2C object 231 * @return Non-zero if the I2C module is active or zero if it is not 205 232 */ 206 233 uint8_t i2c_active(i2c_t *obj); 207 234 208 /** Abort ongoing asynchronous transaction. 235 /** Abort asynchronous transfer 236 * 237 * This function does not perform any check - that should happen in upper layers. 209 238 * @param obj The I2C object 210 239 */ … … 222 251 223 252 #endif 253 254 /** @}*/
Note:
See TracChangeset
for help on using the changeset viewer.