4.9.1 I2C
I2C (also known as Two-Wire Interface (TWI))
4.9.1.1 Introduction
MCC Melody I2C Driver with Host and Client Interfaces
The Inter-Integrated Circuit (I2C) bus is a multi-host serial data communication bus, supported by a Two Wire Interface (TWI) peripheral on AVR MCUs. Devices communicate in a host/client environment where the host devices initiate the communication. A client device is controlled through addressing.
4.9.1.2 Supported Device Families
ATtiny |
4.9.1.3 Required header files:
For host mode, include the following files in your application to use the I2C abstract driver:
#include <stdbool.h>
#include <stdint.h>
#include "mcc_generated_files/i2c_host/i2c_host_interface.h"
For client mode, include the following files in your application to use the I2C abstract driver:
#include <stdbool.h>
#include <stdint.h>
#include "mcc_generated_files/i2c_client/i2c_client_interface.h"
4.9.1.4 How to Use the TWI PLIB Driver
For use-cases for the TWI, see:
The examples there use the portable API interface of the driver, but could easily be modified to directly us the PLIB API.
4.9.1.5 Specific MISRA C:2012 Deviations
- Global ISR (TWI0_TWIS_vect)
-
Advisory: misra-c2012-2.7
Justification: False positive - ISR is a pre-processor macro defined in interrupt.h and is wrongly treated as a function by the CPP Checker. - Global ISR (TWI0_TWIM_vect)
-
Advisory: misra-c2012-2.7
Justification: False positive - ISR is a pre-processor macro defined in interrupt.h and is wrongly treated as a function by the CPP Checker.Required: misra-c2012-5.5
Justification: False positive - ISR is a pre-processor macro defined in interrupt.h file provided by XC8 compiler and is redefined in utils/interrupt_avr.h this file is out of scope for the MISRA check here but is considered by CPP Checker.
4.9.1.6 Module Documentation
4.9.1.6.1 I2C_CLIENT
This header file provides the prototypes for the portable firmware interfaces for I2C client.
Module description
This header file provides the prototypes for the portable firmware interfaces for I2C client.
Data structures
struct i2c_client_interface_t
This structure contains the portable interfaces for I2C client.
4.9.1.6.2 I2C_CLIENT_TYPES
This header file provides helper structures for the I2C driver implementation.
This header file provides helper structures for the I2C driver implementation.
4.9.1.6.3 TWI0_client
This header file provides APIs for the TWI0 driver.
Module description
This header file provides APIs for the TWI0 driver.
4.9.1.6.4 I2C_HOST_EVENT
This header file provides helper structures for the I2C driver implementation.
Module description
This header file provides helper structures for the I2C driver implementation.
Enumerations
enum i2c_event_states_t { I2C_STATE_IDLE = 0, I2C_STATE_SEND_RD_ADDR, I2C_STATE_SEND_WR_ADDR, I2C_STATE_TX, I2C_STATE_RX, I2C_STATE_NACK, I2C_STATE_ERROR, I2C_STATE_STOP, I2C_STATE_RESET, I2C_STATE_IDLE = 0, I2C_STATE_SEND_RD_ADDR, I2C_STATE_SEND_WR_ADDR, I2C_STATE_TX, I2C_STATE_RX, I2C_STATE_NACK, I2C_STATE_ERROR, I2C_STATE_STOP, I2C_STATE_RESET }
Enumeration for I2C states.
Enumeration Type Documentation
i2c_event_states_t
enum enum i2c_event_states_t
Enumeration for I2C states.
I2C_STATE_IDLE | |
I2C_STATE_SEND_RD_ADDR | |
I2C_STATE_SEND_WR_ADDR | |
I2C_STATE_TX | |
I2C_STATE_RX | |
I2C_STATE_NACK | |
I2C_STATE_ERROR | |
I2C_STATE_STOP | |
I2C_STATE_RESET | |
I2C_STATE_IDLE | |
I2C_STATE_SEND_RD_ADDR | |
I2C_STATE_SEND_WR_ADDR | |
I2C_STATE_TX | |
I2C_STATE_RX | |
I2C_STATE_NACK | |
I2C_STATE_ERROR | |
I2C_STATE_STOP | |
I2C_STATE_RESET |
4.9.1.6.5 I2C_HOST
This header file provides the prototypes for the portable firmware interfaces for I2C host.
Module description
This header file provides the prototypes for the portable firmware interfaces for I2C host.
Data structures
struct i2c_host_interface_t
This structure contains the portable interfaces for I2C host.
Functions
void TWI0_Initialize (void)
Initializes the TWI0 module based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI.
void TWI0_Deinitialize (void)
Resets the registers to their default Power-on Reset (POR) values.
bool TWI0_Write (uint16_t address, uint8_t *data, size_t dataLength)
Writes data to a client on the bus. The function will attempt to write the length number of bytes from the data buffer to a client whose address is specified by the address argument.
bool TWI0_Read (uint16_t address, uint8_t *data, size_t dataLength)
Reads data from an I2C client on the bus. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function.
bool TWI0_WriteRead (uint16_t address, uint8_t *writeData, size_t writeLength, uint8_t *readData, size_t readLength)
Writes data from the writeData to the bus and then reads the data from the client. After that, it stores the received data in the readData.
i2c_host_error_t TWI0_ErrorGet (void)
Retrieves the error that occurred during I2C transmission and reception. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function.
bool TWI0_IsBusy (void)
This API checks if I2C is busy.
void TWI0_CallbackRegister (void(*callbackHandler)(void))
Setter function for the TWI interrupt callback. This will be called when any error is generated.
void TWI0_ErrorCallbackRegister (void(*handler)(void))
Setter function for the TWI error interrupt callback.
void TWI0_Tasks (void)
Handles TWI tasks when peripheral interrupts are disabled.
This function must be called in application.
Function Documentation
TWI0_CallbackRegister()
void TWI0_CallbackRegister (void(*)(void) callbackHandler)
Setter function for the TWI interrupt callback. This will be called when any error is generated.
CallbackHandler |
- Pointer to custom callback |
None. |
TWI0_Deinitialize()
void TWI0_Deinitialize (void )
Resets the registers to their default Power-on Reset (POR) values.
None. |
None. Sets the registers to Power-on Reset (POR) values. |
None. |
None. Resets the registers to their default Power-on Reset (POR) values. |
None. |
None. Sets the registers to Power-on Reset (POR) values. |
None. |
None. |
TWI0_ErrorCallbackRegister()
void TWI0_ErrorCallbackRegister (void(*)(void) handler)
Setter function for the TWI error interrupt callback.
*handler |
- pointer to the custom callback |
None. |
TWI0_ErrorGet()
i2c_host_error_t TWI0_ErrorGet (void )
Retrieves the error that occurred during I2C transmission and reception. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function.
None |
I2C_ERROR_NONE - Indicates no error I2C_ERROR_ADDR_NACK - Indicates that the I2C client did not acknowledge the address I2C_ERROR_DATA_NACK - Indicates that the I2C client did not acknowledge the data I2C_ERROR_BUS_COLLISION - Indicates an error caused due to bus collision This function the error occurred during I2C Transmit and Receive. |
None |
I2C_ERROR_NONE - Indicates no error I2C_ERROR_ADDR_NACK - Indicates that the I2C client did not acknowledge the address I2C_ERROR_DATA_NACK - Indicates that the I2C client did not acknowledge the data I2C_ERROR_BUS_COLLISION - Indicates an error caused due to bus collision Retrieves the error that occurred during I2C transmission and reception. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function. |
None. |
I2C_CLIENT_ERROR_BUS_COLLISION - I2C Bus Collision Error I2C_CLIENT_ERROR_WRITE_COLLISION - I2C Write Collision Error I2C_CLIENT_ERROR_RECEIVE_OVERFLOW - I2C Receive Overflow I2C_CLIENT_ERROR_NONE - No Error |
This function the error occurred during I2C Transmit and Receive.
None |
I2C_ERROR_NONE - Indicates no error I2C_ERROR_ADDR_NACK - Indicates that the I2C client did not acknowledge the address I2C_ERROR_DATA_NACK - Indicates that the I2C client did not acknowledge the data I2C_ERROR_BUS_COLLISION - Indicates an error caused due to bus collision |
TWI0_Initialize()
void TWI0_Initialize (void )
Initializes the TWI0 module based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI.
None. |
None. |
TWI0_IsBusy()
bool TWI0_IsBusy (void )
This API checks if I2C is busy.
None. |
True - I2C is busy False - I2C is free |
TWI0_Read()
bool TWI0_Read (uint16_t address, uint8_t * data, size_t dataLength)
Reads data from an I2C client on the bus. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function.
This function attempts to read a specified number of bytes received from the I2C client with the given address into the data buffer. The I2C Host initiates a Start condition, reads the data, and then generates a Stop condition. If the client NAKs the request or a bus error occurs, the transfer is terminated. The application can call the TWI0_ErrorGet() function to determine the cause of the error.
This function is non-blocking; it starts the bus activity and returns immediately. The transfer is completed in the peripheral interrupt. In Polling mode, the user must call TWI0_Tasks within the while loop. A new transfer request cannot be initiated while another transfer is in progress. Calling this function during an ongoing transfer will result in the function returning false.
in | address |
- 7-bit or 10-bit client address |
out | data |
- Pointer to the destination buffer where the received data will be stored |
in | dataLength |
- The total number of bytes to be received |
true - The request was successfully placed, and bus activity has started. false - The request failed as another transfer was already in progress when this function was called. |
TWI0_Tasks()
void TWI0_Tasks (void )
Handles TWI tasks when peripheral interrupts are disabled.
This function must be called in application.None. |
None. Handles TWI tasks when peripheral interrupts are disabled. This function must be called in application. |
None. |
None. |
TWI0_Write()
bool TWI0_Write (uint16_t address, uint8_t * data, size_t dataLength)
Writes data to a client on the bus. The function will attempt to write the length number of bytes from the data buffer to a client whose address is specified by the address argument.
The TWI host will generate a Start condition, write the data and then generate a Stop condition. If the client NAKs the request or a bus error was encountered on the bus, the transfer is terminated. The application can call the TWI0_ErrorGet() function to check the cause of the error. The function is non-blocking, initiating the bus activity and returning immediately. The transfer is then completed in the peripheral interrupt. For the Polling mode, the user has to call TWI0_Tasks in the while loop. A transfer request cannot be placed when another transfer is in progress. Calling this function when another function is already in progress will cause the function to return false.
in | address |
- 7-bit/10-bit client address |
in | *data |
- Pointer to source data buffer that contains the data to be transmitted |
in | dataLength |
- The number of bytes to be written |
True - The request was placed successfully and the bus activity was initiated False - The request fails, if there was already a transfer in progress when this function was called |
TWI0_WriteRead()
bool TWI0_WriteRead (uint16_t address, uint8_t * writeData, size_t writeLength, uint8_t * readData, size_t readLength)
Writes data from the writeData to the bus and then reads the data from the client. After that, it stores the received data in the readData.
The function generates a Start condition on the bus and will then send the writeLength number of bytes contained in the writeData. The function will then insert a Repeated Start condition and proceed to read the readLength number of bytes from the client. The received bytes are stored in the readData buffer. A Stop condition is generated after the last byte has been received.
If the client NAKs the request or a bus error was encountered on the bus, the transfer is terminated. The application will call the TWI0_ErrorGet() function to know the cause of the error.
The function is non-blocking, initiating the bus activity and returning immediately. The transfer is then completed in the peripheral interrupt. For the Polling mode, the user has to call TWI0_Tasks in the while loop. A transfer request cannot be placed when another transfer is in progress. Calling this function when another function is already in progress will cause the function to return false.
in | address |
- 7-bit/10-bit client address |
out | *writeData |
- Pointer to write data buffer |
in | writeLength |
- The number of bytes to be written |
in | *readData |
- Pointer to read data buffer |
in | readLength |
- The number of bytes to be read |
True - The request was placed successfully and the bus activity was initiated False - The request fails, if there was already a transfer in progress when this function was called |
4.9.1.6.6 I2C
This header file provides helper structures for the I2C driver implementation.
Module description
This header file provides helper structures for the I2C driver implementation.
Data structures
struct I2C_TRANSFER_SETUP
Structure for clock configurations.
Enumerations
enum i2c_host_error_t { I2C_ERROR_NONE, I2C_ERROR_ADDR_NACK, I2C_ERROR_DATA_NACK, I2C_ERROR_BUS_COLLISION, I2C_ERROR_NONE, I2C_ERROR_ADDR_NACK, I2C_ERROR_DATA_NACK, I2C_ERROR_BUS_COLLISION }
Enumeration for the potential error types in the I2C host driver.
Enumeration Type Documentation
i2c_host_error_t
enum enum i2c_host_error_t
Enumeration for the potential error types in the I2C host driver.
I2C_ERROR_NONE | |
I2C_ERROR_ADDR_NACK | |
I2C_ERROR_DATA_NACK | |
I2C_ERROR_BUS_COLLISION | |
I2C_ERROR_NONE | |
I2C_ERROR_ADDR_NACK | |
I2C_ERROR_DATA_NACK | |
I2C_ERROR_BUS_COLLISION |
4.9.1.6.7 TWI0_HOST
This header file provides APIs for the TWI0 driver.
Module description
This header file provides APIs for the TWI0 driver.
4.9.1.7 Data Structure Documentation
4.9.1.7.1 i2c_client_interface_t Struct Reference
This structure contains the portable interfaces for I2C client.
Detailed Description
This structure contains the portable interfaces for I2C client.
#include <i2c_client_interface.h>
Data Fields
void(* Initialize )(void)
Pointer to the function that initializes the I2C client.
void(* Deinitialize )(void)
Pointer to the function that deinitializes the I2C client.
void(* WriteByte )(uint8_t data)
Pointer to the function that sends data to a host on bus.
uint8_t(* ReadByte )(void)
Pointer to the function that reads data from a host on bus.
i2c_client_error_t(* ErrorGet )(void)
Pointer to the function that returns the last error that occurred on the I2C bus.
i2c_client_transfer_dir_t(* TransferDirGet )(void)
Pointer to the function that returns the direction of data transfer between client and a host on bus.
i2c_client_ack_status_t(* LastByteAckStatusGet )(void)
Pointer to the function that retrieves the acknowledgment status of the last byte transferred.
void(* CallbackRegister )(bool(*handler)(i2c_client_transfer_event_t clientEvent))
Pointer to the function that registers a callback handler for I2C client.
void(* Tasks )(void)
Pointer to the function that is polled for I2C client events.
Field Documentation
The documentation for this struct was generated from the following file:
source/interrupt/i2c_client/
CallbackRegister
void(* CallbackRegister
Pointer to the function that registers a callback handler for I2C client.
Deinitialize
void(* Deinitialize
Pointer to the function that deinitializes the I2C client.
ErrorGet
i2c_client_error_t(* ErrorGet
Pointer to the function that returns the last error that occurred on the I2C bus.
Initialize
void(* Initialize
Pointer to the function that initializes the I2C client.
LastByteAckStatusGet
i2c_client_ack_status_t(* LastByteAckStatusGet
Pointer to the function that retrieves the acknowledgment status of the last byte transferred.
ReadByte
uint8_t(* ReadByte
Pointer to the function that reads data from a host on bus.
Tasks
void(* Tasks
Pointer to the function that is polled for I2C client events.
TransferDirGet
i2c_client_transfer_dir_t(* TransferDirGet
Pointer to the function that returns the direction of data transfer between client and a host on bus.
WriteByte
void(* WriteByte
Pointer to the function that sends data to a host on bus.
4.9.1.7.2 i2c_event_status_t Struct Reference
#include <i2c_host_event_types.h>
Data Fields
bool busy
bool switchToRead
uint8_t * writePtr
uint8_t * readPtr
size_t writeLength
size_t readLength
uint16_t address
Field Documentation
The documentation for this struct was generated from the following file:
source/interrupt/i2c_host/
address
uint16_t address
busy
bool busy
errorState
i2c_host_error_t errorState
readLength
size_t readLength
readPtr
uint8_t * readPtr
state
i2c_event_states_t state
switchToRead
bool switchToRead
writeLength
size_t writeLength
writePtr
uint8_t * writePtr
4.9.1.7.3 i2c_host_interface_t Struct Reference
This structure contains the portable interfaces for I2C host.
Detailed Description
This structure contains the portable interfaces for I2C host.
#include <i2c_host_interface.h>
Data Fields
void(* Initialize )(void)
Pointer to the function that initializes the I2C host, setting up any necessary hardware or software resources.
void(* Deinitialize )(void)
Pointer to the function that deinitializes the I2C host, by resetting the I2C registers to Power On Default (POR) values.
bool(* Write )(uint16_t address, uint8_t *data, size_t dataLength)
Pointer to the write function of the I2C host.
bool(* Read )(uint16_t address, uint8_t *data, size_t dataLength)
Pointer to the read function of the I2C host.
bool(* WriteRead )(uint16_t address, uint8_t *writeData, size_t writeLength, uint8_t *readData, size_t readLength)
Pointer to the write and read function of the I2C host.
bool(* TransferSetup )(struct i2c_transfer_setup *setup, uint32_t srcClkFreq)
Pointer to the function that sets up the transfer parameters of the I2C host.
i2c_host_error_t(* ErrorGet )(void)
Pointer to the function that returns the last error that occurred on the I2C bus.
bool(* IsBusy )(void)
Pointer to the function that checks if the I2C bus is busy.
void(* CallbackRegister )(void(*callback)(void))
Pointer to the function that Registers a callback function for I2C events.
void(* Tasks )(void)
Pointer to the function that is polled for I2C host events.
Field Documentation
The documentation for this struct was generated from the following file:
source/interrupt/i2c_host/
CallbackRegister
void(* CallbackRegister
Pointer to the function that Registers a callback function for I2C events.
Deinitialize
void(* Deinitialize
Pointer to the function that deinitializes the I2C host, by resetting the I2C registers to Power On Default (POR) values.
ErrorGet
i2c_host_error_t(* ErrorGet
Pointer to the function that returns the last error that occurred on the I2C bus.
Initialize
void(* Initialize
Pointer to the function that initializes the I2C host, setting up any necessary hardware or software resources.
IsBusy
bool(* IsBusy
Pointer to the function that checks if the I2C bus is busy.
Read
bool(* Read
Pointer to the read function of the I2C host.
Tasks
void(* Tasks
Pointer to the function that is polled for I2C host events.
TransferSetup
bool(* TransferSetup
Pointer to the function that sets up the transfer parameters of the I2C host.
Write
bool(* Write
Pointer to the write function of the I2C host.
WriteRead
bool(* WriteRead
Pointer to the write and read function of the I2C host.
4.9.1.7.4 i2c_transfer_setup Struct Reference
Detailed Description
Structure for clock configurations.
The documentation for this struct was generated from the following file:
source/interrupt/i2c_host/
4.9.1.8 File Documentation
4.9.1.8.1 source/interrupt/i2c_client/i2c_client_interface.h File Reference
#include <stdbool.h> #include <stdint.h> #include "i2c_client_types.h"
Data structures
struct i2c_client_interface_t
This structure contains the portable interfaces for I2C client.
Detailed Description
A header file generated by I2C client driver
4.9.1.8.2 source/polling/i2c_client/i2c_client_interface.h File Reference
#include <stdbool.h> #include <stdint.h> #include "i2c_client_types.h"
Data structures
struct i2c_client_interface_t
This structure contains the portable interfaces for I2C client.
Detailed Description
A header file generated by I2C client driver
4.9.1.8.3 source/interrupt/i2c_client/i2c_client_types.h File Reference
Enumerations
enum i2c_client_transfer_dir_t { I2C_CLIENT_TRANSFER_DIR_WRITE = 0, I2C_CLIENT_TRANSFER_DIR_READ = 1, I2C_CLIENT_TRANSFER_DIR_WRITE = 0, I2C_CLIENT_TRANSFER_DIR_READ = 1 }
Enumeration for the data direction of the I2C client driver.
enum i2c_client_ack_status_t { I2C_CLIENT_ACK_STATUS_RECEIVED_ACK = 0, I2C_CLIENT_ACK_STATUS_RECEIVED_NACK = 1, I2C_CLIENT_ACK_STATUS_RECEIVED_ACK = 0, I2C_CLIENT_ACK_STATUS_RECEIVED_NACK = 1 }
Enumeration for the I2C client driver ACK/NACK status.
enum i2c_client_transfer_event_t { I2C_CLIENT_TRANSFER_EVENT_NONE = 0, I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH, I2C_CLIENT_TRANSFER_EVENT_RX_READY, I2C_CLIENT_TRANSFER_EVENT_TX_READY, I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED, I2C_CLIENT_TRANSFER_EVENT_ERROR, I2C_CLIENT_TRANSFER_EVENT_NONE = 0, I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH, I2C_CLIENT_TRANSFER_EVENT_RX_READY, I2C_CLIENT_TRANSFER_EVENT_TX_READY, I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED, I2C_CLIENT_TRANSFER_EVENT_ERROR }
Enumeration for the types of I2C events.
enum i2c_client_error_t { I2C_CLIENT_ERROR_NONE = 0, I2C_CLIENT_ERROR_BUS_ERROR, I2C_CLIENT_ERROR_COLLISION, I2C_CLIENT_ERROR_NONE = 0, I2C_CLIENT_ERROR_BUS_ERROR, I2C_CLIENT_ERROR_COLLISION }
Enumeration defining the potential error types in the I2C client driver.
Enumeration Type Documentation
i2c_client_ack_status_t
enum i2c_client_ack_status_t
Enumeration for the I2C client driver ACK/NACK status.
I2C_CLIENT_ACK_STATUS_RECEIVED_ACK |
I2C Host sends ACK to client |
I2C_CLIENT_ACK_STATUS_RECEIVED_NACK |
I2C Host sends NACK to client |
I2C_CLIENT_ACK_STATUS_RECEIVED_ACK |
I2C Host sends ACK to client |
I2C_CLIENT_ACK_STATUS_RECEIVED_NACK |
I2C Host sends NACK to client |
i2c_client_error_t
enum i2c_client_error_t
Enumeration defining the potential error types in the I2C client driver.
I2C_CLIENT_ERROR_NONE |
I2C error none |
I2C_CLIENT_ERROR_BUS_ERROR |
I2C Bus Error occurred |
I2C_CLIENT_ERROR_COLLISION |
I2C Collision occurred |
I2C_CLIENT_ERROR_NONE |
I2C error none |
I2C_CLIENT_ERROR_BUS_ERROR |
I2C Bus Error occurred |
I2C_CLIENT_ERROR_COLLISION |
I2C Collision occurred |
i2c_client_transfer_dir_t
enum i2c_client_transfer_dir_t
Enumeration for the data direction of the I2C client driver.
I2C_CLIENT_TRANSFER_DIR_WRITE |
I2C Host is writing to client |
I2C_CLIENT_TRANSFER_DIR_READ |
I2C Host is reading from client |
I2C_CLIENT_TRANSFER_DIR_WRITE |
I2C Host is writing to client |
I2C_CLIENT_TRANSFER_DIR_READ |
I2C Host is reading from client |
i2c_client_transfer_event_t
enum i2c_client_transfer_event_t
Enumeration for the types of I2C events.
I2C_CLIENT_TRANSFER_EVENT_NONE |
I2C Bus Idle state |
I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH |
Address match event |
I2C_CLIENT_TRANSFER_EVENT_RX_READY |
Data sent by I2C Host is available |
I2C_CLIENT_TRANSFER_EVENT_TX_READY |
I2C client can respond to data read request from I2C Host |
I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED |
I2C stop bit received |
I2C_CLIENT_TRANSFER_EVENT_ERROR |
I2C Bus error occurred |
I2C_CLIENT_TRANSFER_EVENT_NONE |
I2C Bus Idle state |
I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH |
Address match event |
I2C_CLIENT_TRANSFER_EVENT_RX_READY |
Data sent by I2C Host is available |
I2C_CLIENT_TRANSFER_EVENT_TX_READY |
I2C client can respond to data read request from I2C Host |
I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED |
I2C stop bit received |
I2C_CLIENT_TRANSFER_EVENT_ERROR |
I2C Bus error occurred |
4.9.1.8.4 source/polling/i2c_client/i2c_client_types.h File Reference
Enumerations
enum i2c_client_transfer_dir_t { I2C_CLIENT_TRANSFER_DIR_WRITE = 0, I2C_CLIENT_TRANSFER_DIR_READ = 1, I2C_CLIENT_TRANSFER_DIR_WRITE = 0, I2C_CLIENT_TRANSFER_DIR_READ = 1 }
enum i2c_client_ack_status_t { I2C_CLIENT_ACK_STATUS_RECEIVED_ACK = 0, I2C_CLIENT_ACK_STATUS_RECEIVED_NACK = 1, I2C_CLIENT_ACK_STATUS_RECEIVED_ACK = 0, I2C_CLIENT_ACK_STATUS_RECEIVED_NACK = 1 }
enum i2c_client_transfer_event_t { I2C_CLIENT_TRANSFER_EVENT_NONE = 0, I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH, I2C_CLIENT_TRANSFER_EVENT_RX_READY, I2C_CLIENT_TRANSFER_EVENT_TX_READY, I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED, I2C_CLIENT_TRANSFER_EVENT_ERROR, I2C_CLIENT_TRANSFER_EVENT_NONE = 0, I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH, I2C_CLIENT_TRANSFER_EVENT_RX_READY, I2C_CLIENT_TRANSFER_EVENT_TX_READY, I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED, I2C_CLIENT_TRANSFER_EVENT_ERROR }
enum i2c_client_error_t { I2C_CLIENT_ERROR_NONE = 0, I2C_CLIENT_ERROR_BUS_ERROR, I2C_CLIENT_ERROR_COLLISION, I2C_CLIENT_ERROR_NONE = 0, I2C_CLIENT_ERROR_BUS_ERROR, I2C_CLIENT_ERROR_COLLISION }
Enumeration Type Documentation
i2c_client_ack_status_t
enum i2c_client_ack_status_t
I2C_CLIENT_ACK_STATUS_RECEIVED_ACK |
I2C Host sends ACK to client |
I2C_CLIENT_ACK_STATUS_RECEIVED_NACK |
I2C Host sends NACK to client |
I2C_CLIENT_ACK_STATUS_RECEIVED_ACK |
I2C Host sends ACK to client |
I2C_CLIENT_ACK_STATUS_RECEIVED_NACK |
I2C Host sends NACK to client |
i2c_client_error_t
enum i2c_client_error_t
I2C_CLIENT_ERROR_NONE |
I2C error none |
I2C_CLIENT_ERROR_BUS_ERROR |
I2C Bus Error occurred |
I2C_CLIENT_ERROR_COLLISION |
I2C Collision occurred |
I2C_CLIENT_ERROR_NONE |
I2C error none |
I2C_CLIENT_ERROR_BUS_ERROR |
I2C Bus Error occurred |
I2C_CLIENT_ERROR_COLLISION |
I2C Collision occurred |
i2c_client_transfer_dir_t
enum i2c_client_transfer_dir_t
I2C_CLIENT_TRANSFER_DIR_WRITE |
I2C Host is writing to client |
I2C_CLIENT_TRANSFER_DIR_READ |
I2C Host is reading from client |
I2C_CLIENT_TRANSFER_DIR_WRITE |
I2C Host is writing to client |
I2C_CLIENT_TRANSFER_DIR_READ |
I2C Host is reading from client |
i2c_client_transfer_event_t
enum i2c_client_transfer_event_t
I2C_CLIENT_TRANSFER_EVENT_NONE |
I2C Bus Idle state |
I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH |
Address match event |
I2C_CLIENT_TRANSFER_EVENT_RX_READY |
Data sent by I2C Host is available |
I2C_CLIENT_TRANSFER_EVENT_TX_READY |
I2C client can respond to data read request from I2C Host |
I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED |
I2C stop bit received |
I2C_CLIENT_TRANSFER_EVENT_ERROR |
I2C Bus error occurred |
I2C_CLIENT_TRANSFER_EVENT_NONE |
I2C Bus Idle state |
I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH |
Address match event |
I2C_CLIENT_TRANSFER_EVENT_RX_READY |
Data sent by I2C Host is available |
I2C_CLIENT_TRANSFER_EVENT_TX_READY |
I2C client can respond to data read request from I2C Host |
I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED |
I2C stop bit received |
I2C_CLIENT_TRANSFER_EVENT_ERROR |
I2C Bus error occurred |
4.9.1.8.5 source/interrupt/i2c_client/src/twi0.c File Reference
#include "../twi0.h" #include <stdbool.h> #include "../../system/utils/compiler.h"
Functions
static void TWI0_EventHandler (void)
static void TWI0_ErrorEventHandler (void)
void TWI0_Initialize (void)
Initializes the TWI0 module based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI.
void TWI0_Deinitialize (void)
Resets the registers to their default Power-on Reset (POR) values.
void TWI0_WriteByte (uint8_t wrByte)
Writes data to a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
uint8_t TWI0_ReadByte (void)
Reads data from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
uint16_t TWI0_ReadAddr (void)
Reads the requested address from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
i2c_client_error_t TWI0_ErrorGet (void)
Retrieves the error that occurred during I2C transmission and reception. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function.
i2c_client_transfer_dir_t TWI0_TransferDirGet (void)
Returns the I2C Transfer direction. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
i2c_client_ack_status_t TWI0_LastByteAckStatusGet (void)
Returns the I2C Host ACK status. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
void TWI0_CallbackRegister (bool(*callback)(i2c_client_transfer_event_t clientEvent))
Sets the pointer to be called "back" when the given I2C transfer events, Bus collision and Write collision occur.
ISR (TWI0_TWIS_vect)
Variables
static volatile i2c_client_error_t twi0ErrorState
static bool(* TWI0_InterruptHandler )(i2c_client_transfer_event_t clientEvent)
Detailed Description
TWI0 Generated Driver File
This file provides API implementation for the TWI0 driver.
Function Documentation
ISR()
ISR (TWI0_TWIS_vect )
MISRA C:2012 Deviation Advisory: misra-c2012-2.7
Justification: False positive - ISR is a pre-processor macro defined in interrupt.h and is wrongly treated as a function by the CPP Checker.@misradeviation{Required:,8.2,Required:,8.4} False positive - ISR is a pre-processor macro defined in interrupt.h. The CPP Checker wrongly treats ISR as a function and expects a declaration to be available.
TWI0_CallbackRegister()
void TWI0_CallbackRegister (bool(*)(i2c_client_transfer_event_t clientEvent) callback)
Sets the pointer to be called "back" when the given I2C transfer events, Bus collision and Write collision occur.
handler |
- A pointer to a function |
None. |
TWI0_ErrorEventHandler()
static void TWI0_ErrorEventHandler (void )[static]
TWI0_EventHandler()
static void TWI0_EventHandler (void )[static]
TWI0_LastByteAckStatusGet()
i2c_client_ack_status_t TWI0_LastByteAckStatusGet (void )
Returns the I2C Host ACK status. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
I2C_CLIENT_ACK_STATUS_RECEIVED_ACK - I2C Host sends ACK to client I2C_CLIENT_ACK_STATUS_RECEIVED_NACK - I2C Host sends NACK to client |
TWI0_ReadAddr()
uint16_t TWI0_ReadAddr (void )
Reads the requested address from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
address byte -TWI0 client read byte |
TWI0_ReadByte()
uint8_t TWI0_ReadByte (void )
Reads data from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
data byte -TWI0 client read byte |
TWI0_TransferDirGet()
i2c_client_transfer_dir_t TWI0_TransferDirGet (void )
Returns the I2C Transfer direction. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
I2C_CLIENT_TRANSFER_DIR_WRITE - I2C Host writes to client I2C_CLIENT_TRANSFER_DIR_READ - I2C Host reads from client |
TWI0_WriteByte()
void TWI0_WriteByte (uint8_t wrByte)
Writes data to a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
in | wrByte |
TWI0 client write byte |
None. |
Variable Documentation
I2C2_Client
const i2c_client_interface_t I2C2_Client
Initial value:
= { .Initialize = TWI0_Initialize, .Deinitialize = TWI0_Deinitialize, .WriteByte = TWI0_WriteByte, .ReadByte = TWI0_ReadByte, .TransferDirGet = TWI0_TransferDirGet, .LastByteAckStatusGet = TWI0_LastByteAckStatusGet, .ErrorGet = TWI0_ErrorGet, .CallbackRegister = TWI0_CallbackRegister, .Tasks = NULL }
@misradeviation {Advisory:,8.7} False postive - A few MCC generated driver APIs are made available to users through external linkage. This rule ID has been disabled at the project level due to numerous instances across various files. Consequently, in the application project, this rule ID should be disabled in the MPLAB-X IDE by navigating to Tools -> Options -> Embedded -> MISRA Check.
TWI0_InterruptHandler
bool(* TWI0_InterruptHandler) (i2c_client_transfer_event_t clientEvent)[static]
twi0ErrorState
volatile i2c_client_error_t twi0ErrorState[static]
4.9.1.8.6 source/interrupt/i2c_host/src/twi0.c File Reference
This file contains the API implementation for TWI0 driver.
#include "../twi0.h" #include <stdbool.h> #include <stdlib.h> #include "../../system/utils/compiler.h"
Functions
static void TWI0_Close (void)
static void TWI0_ReadStart (void)
static void TWI0_WriteStart (void)
static void TWI0_EventHandler (void)
static void TWI0_ErrorEventHandler (void)
static i2c_event_states_t I2C_EVENT_IDLE (void)
static i2c_event_states_t I2C_EVENT_SEND_RD_ADDR (void)
static i2c_event_states_t I2C_EVENT_SEND_WR_ADDR (void)
static i2c_event_states_t I2C_EVENT_TX (void)
static i2c_event_states_t I2C_EVENT_RX (void)
static i2c_event_states_t I2C_EVENT_NACK (void)
static i2c_event_states_t I2C_EVENT_ERROR (void)
static i2c_event_states_t I2C_EVENT_STOP (void)
static i2c_event_states_t I2C_EVENT_RESET (void)
void TWI0_Initialize (void)
Initializes the TWI0 module based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI.
void TWI0_Deinitialize (void)
Sets the registers to Power-on Reset (POR) values.
bool TWI0_Write (uint16_t address, uint8_t *data, size_t dataLength)
Writes data to a client on the bus. The function will attempt to write the length number of bytes from the data buffer to a client whose address is specified by the address argument.
bool TWI0_Read (uint16_t address, uint8_t *data, size_t dataLength)
Reads data from an I2C client on the bus. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function.
bool TWI0_WriteRead (uint16_t address, uint8_t *writeData, size_t writeLength, uint8_t *readData, size_t readLength)
Writes data from the writeData to the bus and then reads the data from the client. After that, it stores the received data in the readData.
i2c_host_error_t TWI0_ErrorGet (void)
This function the error occurred during I2C Transmit and Receive.
bool TWI0_IsBusy (void)
This API checks if I2C is busy.
void TWI0_CallbackRegister (void(*callbackHandler)(void))
Setter function for the TWI interrupt callback. This will be called when any error is generated.
ISR (TWI0_TWIM_vect)
Variables
static void(* TWI0_Callback )(void)
volatile i2c_event_status_t twi0_Status = {0}
const twi0eventHandler twi0_eventTable []
Detailed Description
This file contains the API implementation for TWI0 driver.
TWI0 Generated Driver File
Function Documentation
I2C_EVENT_ERROR()
static i2c_event_states_t I2C_EVENT_ERROR (void )[static]
I2C_EVENT_IDLE()
static i2c_event_states_t I2C_EVENT_IDLE (void )[static]
I2C_EVENT_NACK()
static i2c_event_states_t I2C_EVENT_NACK (void )[static]
I2C_EVENT_RESET()
static i2c_event_states_t I2C_EVENT_RESET (void )[static]
I2C_EVENT_RX()
static i2c_event_states_t I2C_EVENT_RX (void )[static]
I2C_EVENT_SEND_RD_ADDR()
static i2c_event_states_t I2C_EVENT_SEND_RD_ADDR (void )[static]
I2C_EVENT_SEND_WR_ADDR()
static i2c_event_states_t I2C_EVENT_SEND_WR_ADDR (void )[static]
I2C_EVENT_STOP()
static i2c_event_states_t I2C_EVENT_STOP (void )[static]
I2C_EVENT_TX()
static i2c_event_states_t I2C_EVENT_TX (void )[static]
ISR()
ISR (TWI0_TWIM_vect )
MISRA C:2012 Deviation Advisory: misra-c2012-2.7
Justification: False positive - ISR is a pre-processor macro defined in interrupt.h and is wrongly treated as a function by the CPP Checker.@misradeviation{Required:,8.2,Required:,8.4} False positive - ISR is a pre-processor macro defined in interrupt.h. The CPP Checker wrongly treats ISR as a function and expects a declaration to be available.
MISRA C:2012 Deviation Required: misra-c2012-5.5
Justification: False positive - ISR is a pre-processor macro defined in interrupt.h file provided by XC8 compiler and is redefined in utils/interrupt_avr.h this file is out of scope for the MISRA check here but is considered by CPP Checker.TWI0_Close()
static void TWI0_Close (void )[static]
@misradeviation {Advisory:,8.7} Some Melody-generated driver APIs are made available to users through external linkage. Users have the option to add these APIs in the application.This rule ID is disabled at project level due to its multiple occurrences in several files.Therefore, in the application project, this rule ID must be disabled in the MPLAB-X IDE from Tools -> Options -> Embedded -> MISRA Check.
TWI0_ErrorEventHandler()
static void TWI0_ErrorEventHandler (void )[static]
TWI0_EventHandler()
static void TWI0_EventHandler (void )[static]
TWI0_ReadStart()
static void TWI0_ReadStart (void )[static]
Section: Private Interfaces
TWI0_WriteStart()
static void TWI0_WriteStart (void )[static]
Variable Documentation
I2C2_Host
const i2c_host_interface_t I2C2_Host
Initial value:
= { .Initialize = TWI0_Initialize, .Deinitialize = TWI0_Deinitialize, .Write = TWI0_Write, .Read = TWI0_Read, .WriteRead = TWI0_WriteRead, .TransferSetup = NULL, .ErrorGet = TWI0_ErrorGet, .IsBusy = TWI0_IsBusy, .CallbackRegister = TWI0_CallbackRegister, .Tasks = NULL }
Section: Driver Interface
TWI0_Callback
void(* TWI0_Callback) (void)[static]
Section: Private Variable Definitions
twi0_eventTable
const twi0eventHandler twi0_eventTable[]
Initial value:
= { I2C_EVENT_IDLE, I2C_EVENT_SEND_RD_ADDR, I2C_EVENT_SEND_WR_ADDR, I2C_EVENT_TX, I2C_EVENT_RX, I2C_EVENT_NACK, I2C_EVENT_ERROR, I2C_EVENT_STOP, I2C_EVENT_RESET }
twi0_Status
volatile i2c_event_status_t twi0_Status = {0}
4.9.1.8.7 source/polling/i2c_client/src/twi0.c File Reference
#include "../twi0.h" #include <stdbool.h> #include "../../system/utils/compiler.h"
Functions
static void TWI0_EventHandler (void)
static void TWI0_ErrorEventHandler (void)
void TWI0_Initialize (void)
Initializes the TWI0 module based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI.
void TWI0_Deinitialize (void)
Sets the registers to Power-on Reset (POR) values.
void TWI0_WriteByte (uint8_t wrByte)
Writes data to a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
uint8_t TWI0_ReadByte (void)
Reads data from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
uint16_t TWI0_ReadAddr (void)
Reads the requested address from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
i2c_client_error_t TWI0_ErrorGet (void)
This function the error occurred during I2C Transmit and Receive.
i2c_client_transfer_dir_t TWI0_TransferDirGet (void)
Returns the I2C Transfer direction. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
i2c_client_ack_status_t TWI0_LastByteAckStatusGet (void)
Returns the I2C Host ACK status. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
void TWI0_CallbackRegister (bool(*callback)(i2c_client_transfer_event_t clientEvent))
Sets the pointer to be called "back" when the given I2C transfer events, Bus collision and Write collision occur.
void TWI0_Tasks (void)
Polling function for all TWI0 clients. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
Variables
static volatile i2c_client_error_t twi0ErrorState
static bool(* TWI0_InterruptHandler )(i2c_client_transfer_event_t clientEvent)
Detailed Description
TWI0 Generated Driver File
This file provides API implementation for the TWI0 driver.
Function Documentation
TWI0_CallbackRegister()
void TWI0_CallbackRegister (bool(*)(i2c_client_transfer_event_t clientEvent) callback)
Sets the pointer to be called "back" when the given I2C transfer events, Bus collision and Write collision occur.
handler |
- A pointer to a function |
None. |
TWI0_ErrorEventHandler()
static void TWI0_ErrorEventHandler (void )[static]
TWI0_EventHandler()
static void TWI0_EventHandler (void )[static]
TWI0_LastByteAckStatusGet()
i2c_client_ack_status_t TWI0_LastByteAckStatusGet (void )
Returns the I2C Host ACK status. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
I2C_CLIENT_ACK_STATUS_RECEIVED_ACK - I2C Host sends ACK to client I2C_CLIENT_ACK_STATUS_RECEIVED_NACK - I2C Host sends NACK to client |
TWI0_ReadAddr()
uint16_t TWI0_ReadAddr (void )
Reads the requested address from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
address byte -TWI0 client read byte |
TWI0_ReadByte()
uint8_t TWI0_ReadByte (void )
Reads data from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
data byte -TWI0 client read byte |
TWI0_TransferDirGet()
i2c_client_transfer_dir_t TWI0_TransferDirGet (void )
Returns the I2C Transfer direction. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
I2C_CLIENT_TRANSFER_DIR_WRITE - I2C Host writes to client I2C_CLIENT_TRANSFER_DIR_READ - I2C Host reads from client |
TWI0_WriteByte()
void TWI0_WriteByte (uint8_t wrByte)
Writes data to a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
in | wrByte |
TWI0 client write byte |
None. |
Variable Documentation
I2C1_Client
const i2c_client_interface_t I2C1_Client
Initial value:
= { .Initialize = TWI0_Initialize, .Deinitialize = TWI0_Deinitialize, .WriteByte = TWI0_WriteByte, .ReadByte = TWI0_ReadByte, .TransferDirGet = TWI0_TransferDirGet, .LastByteAckStatusGet = TWI0_LastByteAckStatusGet, .ErrorGet = TWI0_ErrorGet, .CallbackRegister = TWI0_CallbackRegister, .Tasks = TWI0_Tasks }
@misradeviation {Advisory:,8.7} False postive - A few MCC generated driver APIs are made available to users through external linkage. This rule ID has been disabled at the project level due to numerous instances across various files. Consequently, in the application project, this rule ID should be disabled in the MPLAB-X IDE by navigating to Tools -> Options -> Embedded -> MISRA Check.
TWI0_InterruptHandler
bool(* TWI0_InterruptHandler) (i2c_client_transfer_event_t clientEvent)[static]
twi0ErrorState
volatile i2c_client_error_t twi0ErrorState[static]
4.9.1.8.8 source/polling/i2c_host/src/twi0.c File Reference
This file contains the API implementation for TWI0 driver.
#include "../twi0.h" #include <stdbool.h> #include <stdlib.h> #include "../../system/utils/compiler.h"
Functions
static void TWI0_Close (void)
static void TWI0_ReadStart (void)
static void TWI0_WriteStart (void)
static void TWI0_EventHandler (void)
static void TWI0_ErrorEventHandler (void)
static i2c_event_states_t I2C_EVENT_IDLE (void)
static i2c_event_states_t I2C_EVENT_SEND_RD_ADDR (void)
static i2c_event_states_t I2C_EVENT_SEND_WR_ADDR (void)
static i2c_event_states_t I2C_EVENT_TX (void)
static i2c_event_states_t I2C_EVENT_RX (void)
static i2c_event_states_t I2C_EVENT_NACK (void)
static i2c_event_states_t I2C_EVENT_ERROR (void)
static i2c_event_states_t I2C_EVENT_STOP (void)
static i2c_event_states_t I2C_EVENT_RESET (void)
void TWI0_Initialize (void)
Initializes the TWI0 module based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI.
void TWI0_Deinitialize (void)
Sets the registers to Power-on Reset (POR) values.
bool TWI0_Write (uint16_t address, uint8_t *data, size_t dataLength)
Writes data to a client on the bus. The function will attempt to write the length number of bytes from the data buffer to a client whose address is specified by the address argument.
bool TWI0_Read (uint16_t address, uint8_t *data, size_t dataLength)
Reads data from an I2C client on the bus. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function.
bool TWI0_WriteRead (uint16_t address, uint8_t *writeData, size_t writeLength, uint8_t *readData, size_t readLength)
Writes data from the writeData to the bus and then reads the data from the client. After that, it stores the received data in the readData.
i2c_host_error_t TWI0_ErrorGet (void)
This function the error occurred during I2C Transmit and Receive.
bool TWI0_IsBusy (void)
This API checks if I2C is busy.
void TWI0_CallbackRegister (void(*callbackHandler)(void))
Setter function for the TWI interrupt callback. This will be called when any error is generated.
void TWI0_Tasks (void)
Polling function for all TWI0 clients. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
Variables
static void(* TWI0_Callback )(void)
volatile i2c_event_status_t twi0_Status = {0}
const twi0eventHandler twi0_eventTable []
Detailed Description
This file contains the API implementation for TWI0 driver.
TWI0 Generated Driver File
Function Documentation
I2C_EVENT_ERROR()
static i2c_event_states_t I2C_EVENT_ERROR (void )[static]
I2C_EVENT_IDLE()
static i2c_event_states_t I2C_EVENT_IDLE (void )[static]
I2C_EVENT_NACK()
static i2c_event_states_t I2C_EVENT_NACK (void )[static]
I2C_EVENT_RESET()
static i2c_event_states_t I2C_EVENT_RESET (void )[static]
I2C_EVENT_RX()
static i2c_event_states_t I2C_EVENT_RX (void )[static]
I2C_EVENT_SEND_RD_ADDR()
static i2c_event_states_t I2C_EVENT_SEND_RD_ADDR (void )[static]
I2C_EVENT_SEND_WR_ADDR()
static i2c_event_states_t I2C_EVENT_SEND_WR_ADDR (void )[static]
I2C_EVENT_STOP()
static i2c_event_states_t I2C_EVENT_STOP (void )[static]
I2C_EVENT_TX()
static i2c_event_states_t I2C_EVENT_TX (void )[static]
TWI0_Close()
static void TWI0_Close (void )[static]
@misradeviation {Advisory:,8.7} Some Melody-generated driver APIs are made available to users through external linkage. Users have the option to add these APIs in the application.This rule ID is disabled at project level due to its multiple occurrences in several files.Therefore, in the application project, this rule ID must be disabled in the MPLAB-X IDE from Tools -> Options -> Embedded -> MISRA Check.
TWI0_ErrorEventHandler()
static void TWI0_ErrorEventHandler (void )[static]
TWI0_EventHandler()
static void TWI0_EventHandler (void )[static]
TWI0_ReadStart()
static void TWI0_ReadStart (void )[static]
Section: Private Interfaces
TWI0_WriteStart()
static void TWI0_WriteStart (void )[static]
Variable Documentation
I2C1_Host
const i2c_host_interface_t I2C1_Host
Initial value:
= { .Initialize = TWI0_Initialize, .Deinitialize = TWI0_Deinitialize, .Write = TWI0_Write, .Read = TWI0_Read, .WriteRead = TWI0_WriteRead, .TransferSetup = NULL, .ErrorGet = TWI0_ErrorGet, .IsBusy = TWI0_IsBusy, .CallbackRegister = TWI0_CallbackRegister, .Tasks = TWI0_Tasks }
Section: Driver Interface
TWI0_Callback
void(* TWI0_Callback) (void)[static]
Section: Private Variable Definitions
twi0_eventTable
const twi0eventHandler twi0_eventTable[]
Initial value:
= { I2C_EVENT_IDLE, I2C_EVENT_SEND_RD_ADDR, I2C_EVENT_SEND_WR_ADDR, I2C_EVENT_TX, I2C_EVENT_RX, I2C_EVENT_NACK, I2C_EVENT_ERROR, I2C_EVENT_STOP, I2C_EVENT_RESET }
twi0_Status
volatile i2c_event_status_t twi0_Status = {0}
4.9.1.8.9 source/interrupt/i2c_client/twi0.h File Reference
#include <stdbool.h> #include <stdint.h> #include "i2c_client_types.h" #include "i2c_client_interface.h"
Functions
void TWI0_Initialize (void)
Initializes the TWI0 module based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI.
void TWI0_Deinitialize (void)
Sets the registers to Power-on Reset (POR) values.
void TWI0_WriteByte (uint8_t wrByte)
Writes data to a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
uint8_t TWI0_ReadByte (void)
Reads data from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
uint16_t TWI0_ReadAddr (void)
Reads the requested address from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
i2c_client_error_t TWI0_ErrorGet (void)
This function the error occurred during I2C Transmit and Receive.
i2c_client_transfer_dir_t TWI0_TransferDirGet (void)
Returns the I2C Transfer direction. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
i2c_client_ack_status_t TWI0_LastByteAckStatusGet (void)
Returns the I2C Host ACK status. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
void TWI0_CallbackRegister (bool(*callback)(i2c_client_transfer_event_t clientEvent))
Sets the pointer to be called "back" when the given I2C transfer events, Bus collision and Write collision occur.
Macros
#define I2C2_Client_WriteByte TWI0_WriteByte
#define I2C2_Client_ReadByte TWI0_ReadByte
#define I2C2_Client_ReadAddr TWI0_ReadAddr
#define I2C2_Client_ErrorGet TWI0_ErrorGet
#define I2C2_Client_LastByteAckStatusGet TWI0_LastByteAckStatusGet
Variables
Detailed Description
TWI0 Generated Driver API Header File
Function Documentation
TWI0_CallbackRegister()
void TWI0_CallbackRegister (bool(*)(i2c_client_transfer_event_t clientEvent) callback)
Sets the pointer to be called "back" when the given I2C transfer events, Bus collision and Write collision occur.
handler |
- A pointer to a function |
None. |
TWI0_Deinitialize()
void TWI0_Deinitialize (void )
Sets the registers to Power-on Reset (POR) values.
None. |
None. Sets the registers to Power-on Reset (POR) values. |
None. |
None. |
TWI0_ErrorGet()
i2c_client_error_t TWI0_ErrorGet (void )
This function the error occurred during I2C Transmit and Receive.
None. |
I2C_CLIENT_ERROR_BUS_COLLISION - I2C Bus Collision Error I2C_CLIENT_ERROR_WRITE_COLLISION - I2C Write Collision Error I2C_CLIENT_ERROR_RECEIVE_OVERFLOW - I2C Receive Overflow I2C_CLIENT_ERROR_NONE - No Error |
This function the error occurred during I2C Transmit and Receive.
None |
I2C_ERROR_NONE - Indicates no error I2C_ERROR_ADDR_NACK - Indicates that the I2C client did not acknowledge the address I2C_ERROR_DATA_NACK - Indicates that the I2C client did not acknowledge the data I2C_ERROR_BUS_COLLISION - Indicates an error caused due to bus collision |
TWI0_Initialize()
void TWI0_Initialize (void )
Initializes the TWI0 module based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI.
None. |
None. |
TWI0_LastByteAckStatusGet()
i2c_client_ack_status_t TWI0_LastByteAckStatusGet (void )
Returns the I2C Host ACK status. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
I2C_CLIENT_ACK_STATUS_RECEIVED_ACK - I2C Host sends ACK to client I2C_CLIENT_ACK_STATUS_RECEIVED_NACK - I2C Host sends NACK to client |
TWI0_ReadAddr()
uint16_t TWI0_ReadAddr (void )
Reads the requested address from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
address byte -TWI0 client read byte |
TWI0_ReadByte()
uint8_t TWI0_ReadByte (void )
Reads data from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
data byte -TWI0 client read byte |
TWI0_TransferDirGet()
i2c_client_transfer_dir_t TWI0_TransferDirGet (void )
Returns the I2C Transfer direction. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
I2C_CLIENT_TRANSFER_DIR_WRITE - I2C Host writes to client I2C_CLIENT_TRANSFER_DIR_READ - I2C Host reads from client |
TWI0_WriteByte()
void TWI0_WriteByte (uint8_t wrByte)
Writes data to a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
in | wrByte |
TWI0 client write byte |
None. |
Macro Definition Documentation
I2C2_Client_CallbackRegister
#define I2C2_Client_CallbackRegister TWI0_CallbackRegister
i2c2_client_client_interface
#define i2c2_client_client_interface I2C2_Client
@misradeviation {Advisory:,2.5} False positive - A few macros in this file are used as arguments but are not getting recognized by the tool. This rule ID has been disabled at the project level due to numerous instances across various files. Consequently, in the application project, this rule ID should be disabled in the MPLAB-X IDE by navigating to Tools -> Options -> Embedded -> MISRA Check.
I2C2_Client_Deinitialize
#define I2C2_Client_Deinitialize TWI0_Deinitialize
I2C2_Client_ErrorGet
#define I2C2_Client_ErrorGet TWI0_ErrorGet
I2C2_Client_Initialize
#define I2C2_Client_Initialize TWI0_Initialize
I2C2_Client_LastByteAckStatusGet
#define I2C2_Client_LastByteAckStatusGet TWI0_LastByteAckStatusGet
I2C2_Client_ReadAddr
#define I2C2_Client_ReadAddr TWI0_ReadAddr
I2C2_Client_ReadByte
#define I2C2_Client_ReadByte TWI0_ReadByte
I2C2_Client_TransferDirGet
#define I2C2_Client_TransferDirGet TWI0_TransferDirGet
I2C2_Client_WriteByte
#define I2C2_Client_WriteByte TWI0_WriteByte
Variable Documentation
I2C2_Client
const i2c_client_interface_t I2C2_Client
@misradeviation {Advisory:,8.7} False postive - A few MCC generated driver APIs are made available to users through external linkage. This rule ID has been disabled at the project level due to numerous instances across various files. Consequently, in the application project, this rule ID should be disabled in the MPLAB-X IDE by navigating to Tools -> Options -> Embedded -> MISRA Check.
4.9.1.8.10 source/interrupt/i2c_host/twi0.h File Reference
#include <stdbool.h> #include <stdint.h> #include "i2c_host_types.h" #include "i2c_host_interface.h" #include "i2c_host_event_types.h"
Functions
void TWI0_Initialize (void)
Initializes the TWI0 module based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI.
void TWI0_Deinitialize (void)
Resets the registers to their default Power-on Reset (POR) values.
bool TWI0_Write (uint16_t address, uint8_t *data, size_t dataLength)
Writes data to a client on the bus. The function will attempt to write the length number of bytes from the data buffer to a client whose address is specified by the address argument.
bool TWI0_Read (uint16_t address, uint8_t *data, size_t dataLength)
Reads data from an I2C client on the bus. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function.
bool TWI0_WriteRead (uint16_t address, uint8_t *writeData, size_t writeLength, uint8_t *readData, size_t readLength)
Writes data from the writeData to the bus and then reads the data from the client. After that, it stores the received data in the readData.
i2c_host_error_t TWI0_ErrorGet (void)
Retrieves the error that occurred during I2C transmission and reception. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function.
bool TWI0_IsBusy (void)
This API checks if I2C is busy.
void TWI0_CallbackRegister (void(*callbackHandler)(void))
Setter function for the TWI interrupt callback. This will be called when any error is generated.
void TWI0_ErrorCallbackRegister (void(*handler)(void))
Setter function for the TWI error interrupt callback.
Macros
#define i2c2_host_host_interface I2C2_Host
#define I2C2_Host_Initialize TWI0_Initialize
#define I2C2_Host_Write TWI0_Write
#define I2C2_Host_Read TWI0_Read
#define I2C2_Host_WriteRead TWI0_WriteRead
#define I2C2_Host_ErrorGet TWI0_ErrorGet
#define I2C2_Host_IsBusy TWI0_IsBusy
#define TWI0_BAUD(F_SCL, T_RISE) ((((((float)3333333 / (float)(F_SCL))) - 10 - ((float)3333333 * (T_RISE) / 1000000U))) / 2)
Variables
Detailed Description
TWI0 Generated Driver API Header File
Macro Definition Documentation
I2C2_Host_CallbackRegister
#define I2C2_Host_CallbackRegister TWI0_CallbackRegister
I2C2_Host_Deinitialize
#define I2C2_Host_Deinitialize TWI0_Deinitialize
I2C2_Host_ErrorGet
#define I2C2_Host_ErrorGet TWI0_ErrorGet
i2c2_host_host_interface
#define i2c2_host_host_interface I2C2_Host
@misradeviation {Advisory:,2.5} False positive - This rule ID has been disabled at the project level due to numerous instances across various files, particularly for false positives where macros used as arguments are not recognized by the tool. Consequently, in the application project, this rule ID should be disabled in the MPLAB-X IDE by navigating to Tools -> Options -> Embedded -> MISRA Check. Section: Data Type Definitions
I2C2_Host_Initialize
#define I2C2_Host_Initialize TWI0_Initialize
I2C2_Host_IsBusy
#define I2C2_Host_IsBusy TWI0_IsBusy
I2C2_Host_Read
#define I2C2_Host_Read TWI0_Read
I2C2_Host_Write
#define I2C2_Host_Write TWI0_Write
I2C2_Host_WriteRead
#define I2C2_Host_WriteRead TWI0_WriteRead
TWI0_BAUD
#define TWI0_BAUD( F_SCL, T_RISE) ((((((float)3333333 / (float)(F_SCL))) - 10 - ((float)3333333 * (T_RISE) / 1000000U))) / 2)
Variable Documentation
I2C2_Host
const i2c_host_interface_t I2C2_Host
Section: Data Type Definitions
Section: Driver Interface
4.9.1.8.11 source/polling/i2c_client/twi0.h File Reference
#include <stdbool.h> #include <stdint.h> #include "i2c_client_types.h" #include "i2c_client_interface.h"
Functions
void TWI0_Initialize (void)
Initializes the TWI0 module based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI.
void TWI0_Deinitialize (void)
Sets the registers to Power-on Reset (POR) values.
void TWI0_WriteByte (uint8_t wrByte)
Writes data to a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
uint8_t TWI0_ReadByte (void)
Reads data from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
uint16_t TWI0_ReadAddr (void)
Reads the requested address from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
i2c_client_error_t TWI0_ErrorGet (void)
This function the error occurred during I2C Transmit and Receive.
i2c_client_transfer_dir_t TWI0_TransferDirGet (void)
Returns the I2C Transfer direction. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
i2c_client_ack_status_t TWI0_LastByteAckStatusGet (void)
Returns the I2C Host ACK status. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
void TWI0_CallbackRegister (bool(*callback)(i2c_client_transfer_event_t clientEvent))
Sets the pointer to be called "back" when the given I2C transfer events, Bus collision and Write collision occur.
void TWI0_Tasks (void)
Polling function for all TWI0 clients. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
Macros
#define I2C1_Client_WriteByte TWI0_WriteByte
#define I2C1_Client_ReadByte TWI0_ReadByte
#define I2C1_Client_ReadAddr TWI0_ReadAddr
#define I2C1_Client_ErrorGet TWI0_ErrorGet
#define I2C1_Client_LastByteAckStatusGet TWI0_LastByteAckStatusGet
#define I2C1_Client_Tasks TWI0_Tasks
Variables
Detailed Description
TWI0 Generated Driver API Header File
Function Documentation
TWI0_CallbackRegister()
void TWI0_CallbackRegister (bool(*)(i2c_client_transfer_event_t clientEvent) callback)
Sets the pointer to be called "back" when the given I2C transfer events, Bus collision and Write collision occur.
handler |
- A pointer to a function |
None. |
TWI0_LastByteAckStatusGet()
i2c_client_ack_status_t TWI0_LastByteAckStatusGet (void )
Returns the I2C Host ACK status. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
I2C_CLIENT_ACK_STATUS_RECEIVED_ACK - I2C Host sends ACK to client I2C_CLIENT_ACK_STATUS_RECEIVED_NACK - I2C Host sends NACK to client |
TWI0_ReadAddr()
uint16_t TWI0_ReadAddr (void )
Reads the requested address from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
address byte -TWI0 client read byte |
TWI0_ReadByte()
uint8_t TWI0_ReadByte (void )
Reads data from a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
data byte -TWI0 client read byte |
TWI0_Tasks()
void TWI0_Tasks (void )
Polling function for all TWI0 clients. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
None. |
TWI0_TransferDirGet()
i2c_client_transfer_dir_t TWI0_TransferDirGet (void )
Returns the I2C Transfer direction. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
None. |
I2C_CLIENT_TRANSFER_DIR_WRITE - I2C Host writes to client I2C_CLIENT_TRANSFER_DIR_READ - I2C Host reads from client |
TWI0_WriteByte()
void TWI0_WriteByte (uint8_t wrByte)
Writes data to a host on the bus. TWI0 must be intitialized with TWI0_Initialize() before calling this API.
in | wrByte |
TWI0 client write byte |
None. |
Macro Definition Documentation
I2C1_Client_CallbackRegister
#define I2C1_Client_CallbackRegister TWI0_CallbackRegister
i2c1_client_client_interface
#define i2c1_client_client_interface I2C1_Client
@misradeviation {Advisory:,2.5} False positive - A few macros in this file are used as arguments but are not getting recognized by the tool. This rule ID has been disabled at the project level due to numerous instances across various files. Consequently, in the application project, this rule ID should be disabled in the MPLAB-X IDE by navigating to Tools -> Options -> Embedded -> MISRA Check.
I2C1_Client_Deinitialize
#define I2C1_Client_Deinitialize TWI0_Deinitialize
I2C1_Client_ErrorGet
#define I2C1_Client_ErrorGet TWI0_ErrorGet
I2C1_Client_Initialize
#define I2C1_Client_Initialize TWI0_Initialize
I2C1_Client_LastByteAckStatusGet
#define I2C1_Client_LastByteAckStatusGet TWI0_LastByteAckStatusGet
I2C1_Client_ReadAddr
#define I2C1_Client_ReadAddr TWI0_ReadAddr
I2C1_Client_ReadByte
#define I2C1_Client_ReadByte TWI0_ReadByte
I2C1_Client_Tasks
#define I2C1_Client_Tasks TWI0_Tasks
I2C1_Client_TransferDirGet
#define I2C1_Client_TransferDirGet TWI0_TransferDirGet
I2C1_Client_WriteByte
#define I2C1_Client_WriteByte TWI0_WriteByte
Variable Documentation
I2C1_Client
const i2c_client_interface_t I2C1_Client
@misradeviation {Advisory:,8.7} False postive - A few MCC generated driver APIs are made available to users through external linkage. This rule ID has been disabled at the project level due to numerous instances across various files. Consequently, in the application project, this rule ID should be disabled in the MPLAB-X IDE by navigating to Tools -> Options -> Embedded -> MISRA Check.
4.9.1.8.12 source/polling/i2c_host/twi0.h File Reference
#include <stdbool.h> #include <stdint.h> #include "i2c_host_types.h" #include "i2c_host_interface.h" #include "i2c_host_event_types.h"
Functions
void TWI0_Initialize (void)
Initializes the TWI0 module based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI.
void TWI0_Deinitialize (void)
Resets the registers to their default Power-on Reset (POR) values.
bool TWI0_Write (uint16_t address, uint8_t *data, size_t dataLength)
Writes data to a client on the bus. The function will attempt to write the length number of bytes from the data buffer to a client whose address is specified by the address argument.
bool TWI0_Read (uint16_t address, uint8_t *data, size_t dataLength)
Reads data from an I2C client on the bus. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function.
bool TWI0_WriteRead (uint16_t address, uint8_t *writeData, size_t writeLength, uint8_t *readData, size_t readLength)
Writes data from the writeData to the bus and then reads the data from the client. After that, it stores the received data in the readData.
i2c_host_error_t TWI0_ErrorGet (void)
Retrieves the error that occurred during I2C transmission and reception. Ensure the TWI0 host is initialized using TWI0_Initialize() before invoking this function.
bool TWI0_IsBusy (void)
This API checks if I2C is busy.
void TWI0_Tasks (void)
Handles TWI tasks when peripheral interrupts are disabled.
This function must be called in application.void TWI0_CallbackRegister (void(*callbackHandler)(void))
Setter function for the TWI interrupt callback. This will be called when any error is generated.
Macros
#define i2c1_host_host_interface I2C1_Host
#define I2C1_Host_Initialize TWI0_Initialize
#define I2C1_Host_Write TWI0_Write
#define I2C1_Host_Read TWI0_Read
#define I2C1_Host_WriteRead TWI0_WriteRead
#define I2C1_Host_ErrorGet TWI0_ErrorGet
#define I2C1_Host_IsBusy TWI0_IsBusy
#define I2C1_Host_Tasks TWI0_Tasks
#define TWI0_BAUD(F_SCL, T_RISE) ((((((float)3333333 / (float)(F_SCL))) - 10 - ((float)3333333 * (T_RISE) / 1000000U))) / 2)
Variables
Detailed Description
TWI0 Generated Driver API Header File
Macro Definition Documentation
I2C1_Host_CallbackRegister
#define I2C1_Host_CallbackRegister TWI0_CallbackRegister
I2C1_Host_Deinitialize
#define I2C1_Host_Deinitialize TWI0_Deinitialize
I2C1_Host_ErrorGet
#define I2C1_Host_ErrorGet TWI0_ErrorGet
i2c1_host_host_interface
#define i2c1_host_host_interface I2C1_Host
@misradeviation {Advisory:,2.5} False positive - This rule ID has been disabled at the project level due to numerous instances across various files, particularly for false positives where macros used as arguments are not recognized by the tool. Consequently, in the application project, this rule ID should be disabled in the MPLAB-X IDE by navigating to Tools -> Options -> Embedded -> MISRA Check. Section: Data Type Definitions
I2C1_Host_Initialize
#define I2C1_Host_Initialize TWI0_Initialize
I2C1_Host_IsBusy
#define I2C1_Host_IsBusy TWI0_IsBusy
I2C1_Host_Read
#define I2C1_Host_Read TWI0_Read
I2C1_Host_Tasks
#define I2C1_Host_Tasks TWI0_Tasks
I2C1_Host_Write
#define I2C1_Host_Write TWI0_Write
I2C1_Host_WriteRead
#define I2C1_Host_WriteRead TWI0_WriteRead
TWI0_BAUD
#define TWI0_BAUD( F_SCL, T_RISE) ((((((float)3333333 / (float)(F_SCL))) - 10 - ((float)3333333 * (T_RISE) / 1000000U))) / 2)
Variable Documentation
I2C1_Host
const i2c_host_interface_t I2C1_Host
Section: Data Type Definitions
Section: Driver Interface
4.9.1.8.13 source/interrupt/i2c_host/i2c_host_event_types.h File Reference
#include "i2c_host_types.h"
Data structures
struct i2c_event_status_t
Macros
#define I2C_EVENTS (9)
Typedefs
typedef i2c_event_states_t(* twi0eventHandler) (void)
Enumerations
enum i2c_event_states_t { I2C_STATE_IDLE = 0, I2C_STATE_SEND_RD_ADDR, I2C_STATE_SEND_WR_ADDR, I2C_STATE_TX, I2C_STATE_RX, I2C_STATE_NACK, I2C_STATE_ERROR, I2C_STATE_STOP, I2C_STATE_RESET, I2C_STATE_IDLE = 0, I2C_STATE_SEND_RD_ADDR, I2C_STATE_SEND_WR_ADDR, I2C_STATE_TX, I2C_STATE_RX, I2C_STATE_NACK, I2C_STATE_ERROR, I2C_STATE_STOP, I2C_STATE_RESET }
Enumeration for I2C states.
Variables
volatile i2c_event_status_t twi0_Status
Macro Definition Documentation
I2C_EVENTS
#define I2C_EVENTS (9)
Typedef Documentation
twi0eventHandler
typedef i2c_event_states_t(* twi0eventHandler) (void)
Variable Documentation
twi0_eventTable
const twi0eventHandler twi0_eventTable[I2C_EVENTS]
twi0_Status
volatile i2c_event_status_t twi0_Status
4.9.1.8.14 source/polling/i2c_host/i2c_host_event_types.h File Reference
#include "i2c_host_types.h"
Data structures
struct i2c_event_status_t
Macros
#define I2C_EVENTS (9)
Typedefs
typedef i2c_event_states_t(* twi0eventHandler) (void)
Enumerations
enum i2c_event_states_t { I2C_STATE_IDLE = 0, I2C_STATE_SEND_RD_ADDR, I2C_STATE_SEND_WR_ADDR, I2C_STATE_TX, I2C_STATE_RX, I2C_STATE_NACK, I2C_STATE_ERROR, I2C_STATE_STOP, I2C_STATE_RESET, I2C_STATE_IDLE = 0, I2C_STATE_SEND_RD_ADDR, I2C_STATE_SEND_WR_ADDR, I2C_STATE_TX, I2C_STATE_RX, I2C_STATE_NACK, I2C_STATE_ERROR, I2C_STATE_STOP, I2C_STATE_RESET }
Variables
volatile i2c_event_status_t twi0_Status
Macro Definition Documentation
I2C_EVENTS
#define I2C_EVENTS (9)
Typedef Documentation
twi0eventHandler
typedef i2c_event_states_t(* twi0eventHandler) (void)
Enumeration Type Documentation
i2c_event_states_t
enum i2c_event_states_t
I2C_STATE_IDLE | |
I2C_STATE_SEND_RD_ADDR | |
I2C_STATE_SEND_WR_ADDR | |
I2C_STATE_TX | |
I2C_STATE_RX | |
I2C_STATE_NACK | |
I2C_STATE_ERROR | |
I2C_STATE_STOP | |
I2C_STATE_RESET | |
I2C_STATE_IDLE | |
I2C_STATE_SEND_RD_ADDR | |
I2C_STATE_SEND_WR_ADDR | |
I2C_STATE_TX | |
I2C_STATE_RX | |
I2C_STATE_NACK | |
I2C_STATE_ERROR | |
I2C_STATE_STOP | |
I2C_STATE_RESET |
Variable Documentation
twi0_eventTable
const twi0eventHandler twi0_eventTable[I2C_EVENTS]
twi0_Status
volatile i2c_event_status_t twi0_Status
4.9.1.8.15 source/interrupt/i2c_host/i2c_host_interface.h File Reference
#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include "i2c_host_types.h"
Data structures
struct i2c_host_interface_t
This structure contains the portable interfaces for I2C host.
Detailed Description
A header file generated by I2C host driver
4.9.1.8.16 source/polling/i2c_host/i2c_host_interface.h File Reference
#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include "i2c_host_types.h"
Data structures
struct i2c_host_interface_t
This structure contains the portable interfaces for I2C host.
Detailed Description
A header file generated by I2C host driver
4.9.1.8.17 source/interrupt/i2c_host/i2c_host_types.h File Reference
Data structures
struct i2c_transfer_setup
Typedefs
typedef struct i2c_transfer_setup i2c_host_transfer_setup_t
Enumerations
enum i2c_host_error_t { I2C_ERROR_NONE, I2C_ERROR_ADDR_NACK, I2C_ERROR_DATA_NACK, I2C_ERROR_BUS_COLLISION, I2C_ERROR_NONE, I2C_ERROR_ADDR_NACK, I2C_ERROR_DATA_NACK, I2C_ERROR_BUS_COLLISION }
Enumeration for the potential error types in the I2C host driver.
Detailed Description
I2C Generated Driver API Header File
Typedef Documentation
i2c_host_transfer_setup_t
typedef struct i2c_transfer_setup i2c_host_transfer_setup_t
@misradeviation{Advisory:,2.4,Advisory:,2.3}These declarations provided by the Melody-generated drivers for the user's application. It is up to the user if these declarations will be implemented in their application.
4.9.1.8.18 source/polling/i2c_host/i2c_host_types.h File Reference
Data structures
struct i2c_transfer_setup
Typedefs
typedef struct i2c_transfer_setup i2c_host_transfer_setup_t
Enumerations
Detailed Description
I2C Generated Driver API Header File
Typedef Documentation
i2c_host_transfer_setup_t
typedef struct i2c_transfer_setup i2c_host_transfer_setup_t
@misradeviation{Advisory:,2.4,Advisory:,2.3}These declarations provided by the Melody-generated drivers for the user's application. It is up to the user if these declarations will be implemented in their application.
Enumeration Type Documentation
i2c_host_error_t
enum i2c_host_error_t
I2C_ERROR_NONE | |
I2C_ERROR_ADDR_NACK | |
I2C_ERROR_DATA_NACK | |
I2C_ERROR_BUS_COLLISION | |
I2C_ERROR_NONE | |
I2C_ERROR_ADDR_NACK | |
I2C_ERROR_DATA_NACK | |
I2C_ERROR_BUS_COLLISION |