SAM I2C Master Interrupt Driver.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include "i2c_master_interrupt.h"
Functions | |
enum status_code | _i2c_master_address_response (struct i2c_master_module *const module) |
static void | _i2c_master_async_address_response (struct i2c_master_module *const module) |
void | _i2c_master_interrupt_handler (uint8_t instance) |
static void | _i2c_master_read (struct i2c_master_module *const module) |
static enum status_code | _i2c_master_read_packet (struct i2c_master_module *const module, struct i2c_master_packet *const packet) |
enum status_code | _i2c_master_send_hs_master_code (struct i2c_master_module *const module, uint8_t hs_master_code) |
enum status_code | _i2c_master_wait_for_bus (struct i2c_master_module *const module) |
static void | _i2c_master_write (struct i2c_master_module *const module) |
static enum status_code | _i2c_master_write_packet (struct i2c_master_module *const module, struct i2c_master_packet *const packet) |
enum status_code | i2c_master_read_bytes (struct i2c_master_module *const module, struct i2c_master_packet *const packet) |
enum status_code | i2c_master_read_packet_job (struct i2c_master_module *const module, struct i2c_master_packet *const packet) |
Initiates a read packet operation. More... | |
enum status_code | i2c_master_read_packet_job_no_nack (struct i2c_master_module *const module, struct i2c_master_packet *const packet) |
Initiates a read packet operation without sending a NACK signal and a STOP condition when done. More... | |
enum status_code | i2c_master_read_packet_job_no_stop (struct i2c_master_module *const module, struct i2c_master_packet *const packet) |
Initiates a read packet operation without sending a STOP condition when done. More... | |
void | i2c_master_register_callback (struct i2c_master_module *const module, const i2c_master_callback_t callback, enum i2c_master_callback callback_type) |
Registers callback for the specified callback type. More... | |
void | i2c_master_unregister_callback (struct i2c_master_module *const module, enum i2c_master_callback callback_type) |
Unregisters callback for the specified callback type. More... | |
enum status_code | i2c_master_write_bytes (struct i2c_master_module *const module, struct i2c_master_packet *const packet) |
enum status_code | i2c_master_write_packet_job (struct i2c_master_module *const module, struct i2c_master_packet *const packet) |
Initiates a write packet operation. More... | |
enum status_code | i2c_master_write_packet_job_no_stop (struct i2c_master_module *const module, struct i2c_master_packet *const packet) |
Initiates a write packet operation without sending a STOP condition when done. More... | |
enum status_code _i2c_master_address_response | ( | struct i2c_master_module *const | module | ) |
|
static |
Acts on slave address response. Checks for errors concerning master->slave handshake.
[in,out] | module | Pointer to software module structure |
References _i2c_master_read(), _i2c_master_write(), Assert, I2C_TRANSFER_WRITE, STATUS_BUSY, STATUS_ERR_BAD_ADDRESS, and STATUS_ERR_PACKET_COLLISION.
Referenced by _i2c_master_interrupt_handler().
void _i2c_master_interrupt_handler | ( | uint8_t | instance | ) |
Interrupt handler for I2C master.
[in] | instance | SERCOM instance that triggered the interrupt |
References _i2c_master_async_address_response(), _i2c_master_read(), _i2c_master_write(), _sercom_instances, Assert, I2C_MASTER_CALLBACK_ERROR, I2C_MASTER_CALLBACK_READ_COMPLETE, I2C_MASTER_CALLBACK_WRITE_COMPLETE, I2C_TRANSFER_READ, I2C_TRANSFER_WRITE, STATUS_BUSY, STATUS_ERR_PACKET_COLLISION, and STATUS_OK.
Referenced by i2c_master_init().
|
static |
Read next data. Used by interrupt handler to get next data byte from slave.
[in,out] | module | Pointer to software module structure |
References Assert.
Referenced by _i2c_master_async_address_response(), and _i2c_master_interrupt_handler().
|
static |
Starts a read packet operation.
[in,out] | module | Pointer to software module struct |
[in,out] | packet | Pointer to I2C packet to transfer |
STATUS_OK | If reading was started successfully |
STATUS_BUSY | If module is currently busy with another transfer |
References _i2c_master_address_response(), _i2c_master_send_hs_master_code(), _i2c_master_wait_for_bus(), i2c_master_packet::address, Assert, i2c_master_packet::data, i2c_master_packet::data_length, i2c_master_packet::high_speed, i2c_master_packet::hs_master_code, I2C_TRANSFER_READ, STATUS_BUSY, STATUS_OK, and i2c_master_packet::ten_bit_address.
Referenced by i2c_master_read_packet_job(), i2c_master_read_packet_job_no_nack(), and i2c_master_read_packet_job_no_stop().
enum status_code _i2c_master_send_hs_master_code | ( | struct i2c_master_module *const | module, |
uint8_t | hs_master_code | ||
) |
Send master code for high speed transfer.
[in,out] | module | Pointer to software module structure |
[in] | hs_master_code | 8-bit master code (0000 1XXX) |
STATUS_OK | No error happen |
References _i2c_master_wait_for_bus().
Referenced by _i2c_master_read_packet(), and _i2c_master_write_packet().
enum status_code _i2c_master_wait_for_bus | ( | struct i2c_master_module *const | module | ) |
|
static |
Write next data. Used by interrupt handler to send next data byte to slave.
[in,out] | module | Pointer to software module structure |
References Assert, and STATUS_ERR_OVERFLOW.
Referenced by _i2c_master_async_address_response(), and _i2c_master_interrupt_handler().
|
static |
Initiates a write packet operation
[in,out] | module | Pointer to software module struct |
[in,out] | packet | Pointer to I2C packet to transfer |
STATUS_OK | If writing was started successfully |
STATUS_BUSY | If module is currently busy with another transfer |
References _i2c_master_send_hs_master_code(), i2c_master_packet::address, Assert, i2c_master_packet::data, i2c_master_packet::data_length, i2c_master_packet::high_speed, i2c_master_packet::hs_master_code, I2C_TRANSFER_WRITE, STATUS_BUSY, STATUS_OK, and i2c_master_packet::ten_bit_address.
Referenced by i2c_master_write_packet_job(), and i2c_master_write_packet_job_no_stop().