|
Contiki 3.x
|
cc2538 I2C Control Module More...
Files | |
| file | i2c.c |
| Implementation file of the I2C Control module. | |
| file | i2c.h |
| Header file with declarations for the I2C Control module. | |
I2C registers | |
| #define | I2CM_CR 0x40020020 /* I2C master config */ |
| #define | I2CM_TPR 0x4002000C /* I2C master timer period */ |
| #define | I2CM_SA 0x40020000 /* I2C master slave address */ |
| #define | I2CM_DR 0x40020008 /* I2C master data */ |
| #define | I2CM_CTRL 0x40020004 /* Master control in write */ |
| #define | I2CM_STAT I2CM_CTRL /* Master status in read */ |
I2C Functions | |
| void | i2c_init (uint8_t port_sda, uint8_t pin_sda, uint8_t port_scl, uint8_t pin_scl, uint32_t bus_speed) |
| Initialize the I2C peripheral and pins. More... | |
| void | i2c_master_enable (void) |
| Enable master I2C module. | |
| void | i2c_master_disable (void) |
| Disable master I2C module. | |
| void | i2c_set_frequency (uint32_t freq) |
| Initialize I2C peripheral clock with given frequency. More... | |
| void | i2c_master_set_slave_address (uint8_t slave_addr, uint8_t access_mode) |
| Set the address of slave and access mode for the next I2C communication. More... | |
| void | i2c_master_data_put (uint8_t data) |
| Prepare data to be transmitted. More... | |
| uint8_t | i2c_master_data_get (void) |
| Return received data from I2C. More... | |
| void | i2c_master_command (uint8_t cmd) |
| Control the state of the master module for send and receive operations. More... | |
| uint8_t | i2c_master_busy (void) |
| Return the busy state of I2C module. More... | |
| uint8_t | i2c_master_error (void) |
| Return the status register if error occurred during last communication. More... | |
| uint8_t | i2c_single_send (uint8_t slave_addr, uint8_t data) |
| Perform all operations to send a byte to a slave. More... | |
| uint8_t | i2c_single_receive (uint8_t slave_addr, uint8_t *data) |
| Perform all operations to receive a byte from a slave. More... | |
| uint8_t | i2c_burst_send (uint8_t slave_addr, uint8_t *data, uint8_t len) |
| Perform all operations to send multiple bytes to a slave. More... | |
| uint8_t | i2c_burst_receive (uint8_t slave_addr, uint8_t *data, uint8_t len) |
| Perform all operations to receive multiple bytes from a slave. More... | |
cc2538 I2C Control Module
| uint8_t i2c_burst_receive | ( | uint8_t | slave_addr, |
| uint8_t * | data, | ||
| uint8_t | len | ||
| ) |
Perform all operations to receive multiple bytes from a slave.
| slave_addr | The address of the slave from which data are received |
| data | A pointer to store the received data |
| len | Number of bytes to receive |
Definition at line 218 of file i2c.c.
References i2c_master_busy(), i2c_master_command(), i2c_master_data_get(), i2c_master_error(), i2c_master_set_slave_address(), i2c_single_receive(), and NULL.
Referenced by I2C(), and tmp102_read().
| uint8_t i2c_burst_send | ( | uint8_t | slave_addr, |
| uint8_t * | data, | ||
| uint8_t | len | ||
| ) |
Perform all operations to send multiple bytes to a slave.
| slave_addr | The address of the slave to which data are sent |
| data | A pointer to the data to send to the slave |
| len | Number of bytes to send |
Definition at line 188 of file i2c.c.
References i2c_master_busy(), i2c_master_command(), i2c_master_data_put(), i2c_master_error(), i2c_master_set_slave_address(), i2c_single_send(), and NULL.
Referenced by I2C().
| void i2c_init | ( | uint8_t | port_sda, |
| uint8_t | pin_sda, | ||
| uint8_t | port_scl, | ||
| uint8_t | pin_scl, | ||
| uint32_t | bus_speed | ||
| ) |
Initialize the I2C peripheral and pins.
| port_sda | The GPIO number of the pin used fort SDA |
| pin_sda | The pin number used for SDA |
| port_scl | The GPIO number of the pin used fort SCL |
| pin_scl | The pin number used for SCL |
| bus_speed | The clock frequency used by I2C module |
bus_speed can take the following values:
Definition at line 49 of file i2c.c.
References clock_delay_usec(), GPIO_PERIPHERAL_CONTROL, GPIO_PIN_MASK, GPIO_PORT_TO_BASE, GPIO_SET_INPUT, i2c_master_enable(), i2c_set_frequency(), IOC_I2CMSSCL, IOC_I2CMSSDA, ioc_input_sel, IOC_OVERRIDE_DIS, ioc_set_over(), ioc_set_sel(), SYS_CTRL_RCGCI2C, and SYS_CTRL_SRI2C.
Referenced by board_init(), main(), rtcc_init(), and tmp102_init().
| uint8_t i2c_master_busy | ( | void | ) |
Return the busy state of I2C module.
| 0 | The I2C module is not busy |
| 1 | The I2C module is busy |
Definition at line 141 of file i2c.c.
Referenced by i2c_burst_receive(), i2c_burst_send(), i2c_single_receive(), and i2c_single_send().
| void i2c_master_command | ( | uint8_t | cmd | ) |
Control the state of the master module for send and receive operations.
| cmd | The operation to perform |
cmd can take the following values:
Definition at line 133 of file i2c.c.
References clock_delay_usec().
Referenced by i2c_burst_receive(), i2c_burst_send(), i2c_single_receive(), and i2c_single_send().
| uint8_t i2c_master_data_get | ( | void | ) |
Return received data from I2C.
Definition at line 127 of file i2c.c.
Referenced by i2c_burst_receive(), and i2c_single_receive().
| void i2c_master_data_put | ( | uint8_t | data | ) |
Prepare data to be transmitted.
| data | The byte of data to be transmitted from the I2C master |
Definition at line 121 of file i2c.c.
Referenced by i2c_burst_send(), and i2c_single_send().
| uint8_t i2c_master_error | ( | void | ) |
Return the status register if error occurred during last communication.
| I2C_MASTER_ERR_NONE | Return 0 if no error occurred |
If an error occurred, return the status register of the I2C module. Use the result with the I2CM_STAT_* flags to custom your processing
Definition at line 147 of file i2c.c.
Referenced by i2c_burst_receive(), i2c_burst_send(), i2c_single_receive(), i2c_single_send(), and tmp102_read().
| void i2c_master_set_slave_address | ( | uint8_t | slave_addr, |
| uint8_t | access_mode | ||
| ) |
Set the address of slave and access mode for the next I2C communication.
| slave_addr | The receiver slave address on 7 bits |
| access_mode | The I2C access mode (send/receive) |
access_mode can take the following values:
Definition at line 111 of file i2c.c.
Referenced by i2c_burst_receive(), i2c_burst_send(), i2c_single_receive(), and i2c_single_send().
| void i2c_set_frequency | ( | uint32_t | freq | ) |
Initialize I2C peripheral clock with given frequency.
| freq | The desired frequency |
freq can take the following values:
Definition at line 103 of file i2c.c.
Referenced by i2c_init().
| uint8_t i2c_single_receive | ( | uint8_t | slave_addr, |
| uint8_t * | data | ||
| ) |
Perform all operations to receive a byte from a slave.
| slave_addr | The address of the slave from which data are received |
| data | A pointer to store the received data |
Definition at line 172 of file i2c.c.
References i2c_master_busy(), i2c_master_command(), i2c_master_data_get(), i2c_master_error(), and i2c_master_set_slave_address().
Referenced by i2c_burst_receive().
| uint8_t i2c_single_send | ( | uint8_t | slave_addr, |
| uint8_t | data | ||
| ) |
Perform all operations to send a byte to a slave.
| slave_addr | The adress of the slave to which data are sent |
| data | The data to send to the slave |
Definition at line 159 of file i2c.c.
References i2c_master_busy(), i2c_master_command(), i2c_master_data_put(), i2c_master_error(), and i2c_master_set_slave_address().
Referenced by i2c_burst_send(), and tmp102_read().
1.8.6