FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
i2c_handler_atmega.h File Reference

ATmega I2C Manager API. More...

#include <util/delay_basic.h>
#include "i2c.h"
#include "future.h"
#include "queue.h"
#include "interrupts.h"
#include "bits.h"
#include "utilities.h"
#include "i2c_handler_common.h"
Include dependency graph for i2c_handler_atmega.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  i2c::AbstractI2CSyncATmegaManager< MODE_, HAS_STATUS_, STATUS_HOOK_, HAS_DEBUG_, DEBUG_HOOK_ >
 Abstract synchronous I2C Manager for ATmega architecture. More...
 
class  i2c::AbstractI2CAsyncManager< MODE_, POLICY_, HAS_STATUS_, STATUS_HOOK_, HAS_DEBUG_, DEBUG_HOOK_ >
 Abstract asynchronous I2C Manager. More...
 
class  i2c::I2CAsyncManager< MODE_, POLICY_ >
 Asynchronous I2C Manager for ATmega architecture. More...
 
class  i2c::I2CAsyncDebugManager< MODE_, POLICY_, DEBUG_HOOK_ >
 Asynchronous I2C Manager for ATmega architecture with debug facility. More...
 
class  i2c::I2CAsyncStatusManager< MODE_, POLICY_, STATUS_HOOK_ >
 Asynchronous I2C Manager for ATmega architecture with status notification facility. More...
 
class  i2c::I2CAsyncStatusDebugManager< MODE_, POLICY_, STATUS_HOOK_, DEBUG_HOOK_ >
 Asynchronous I2C Manager for ATmega architecture with debug and status notification facilities. More...
 
class  i2c::I2CSyncManager< MODE_ >
 Synchronous I2C Manager for ATmega architecture. More...
 
class  i2c::I2CSyncStatusManager< MODE_, STATUS_HOOK_ >
 Synchronous I2C Manager for ATmega architecture wit status notification facility. More...
 
class  i2c::I2CSyncDebugManager< MODE_, DEBUG_HOOK_ >
 Synchronous I2C Manager for ATmega architecture with debug facility. More...
 
class  i2c::I2CSyncStatusDebugManager< MODE_, STATUS_HOOK_, DEBUG_HOOK_ >
 Synchronous I2C Manager for ATmega architecture with status notification and debug facility. More...
 

Namespaces

namespace  i2c
 Define API to define and manage I2C devices.
 

Macros

#define I2C_TRUE_ASYNC   1
 This macro indicates if truly asynchronous I2C management is available for a platform: More...
 
#define REGISTER_I2C_ISR(MANAGER)
 Register the necessary ISR (Interrupt Service Routine) for an asynchronous I2C Manager to work properly. More...
 
#define REGISTER_I2C_ISR_FUNCTION(MANAGER, CALLBACK)
 Register the necessary ISR (Interrupt Service Routine) for an asynchronous I2C Manager to work properly, along with a callback function that will be called everytime an I2C transaction progresses (one command executed, whole transaction executed, error). More...
 
#define REGISTER_I2C_ISR_METHOD(MANAGER, HANDLER, CALLBACK)
 Register the necessary ISR (Interrupt Service Routine) for an asynchronous I2C Manager to work properly, along with a callback method that will be called everytime an I2C transaction progresses (one command executed, whole transaction executed, error). More...
 
#define DECL_I2C_ISR_HANDLERS_FRIEND
 This macro shall be used in a class containing a private callback method, registered by REGISTER_I2C_ISR_METHOD. More...
 

Enumerations

enum class  i2c::I2CCallback : uint8_t {
  i2c::NONE = 0 ,
  i2c::END_COMMAND ,
  i2c::END_TRANSACTION ,
  i2c::ERROR
}
 Type passed to I2C ISR registered callbacks (asynchronous I2C Manager only) when an asynchronous I2C transaction is executed. More...
 

Detailed Description

ATmega I2C Manager API.

This defines asynchronous and synchronous I2C Managers for ATmega architecture.

Definition in file i2c_handler_atmega.h.

Macro Definition Documentation

◆ I2C_TRUE_ASYNC

#define I2C_TRUE_ASYNC   1

This macro indicates if truly asynchronous I2C management is available for a platform:

  • for ATmega architecture, it is set to 1
  • for ATtiny architecture, it is set to 0

Definition at line 49 of file i2c_handler_atmega.h.

◆ REGISTER_I2C_ISR

#define REGISTER_I2C_ISR (   MANAGER)
Value:
ISR(TWI_vect) \
{ \
i2c::isr_handler::i2c_change<MANAGER>(); \
}

Register the necessary ISR (Interrupt Service Routine) for an asynchronous I2C Manager to work properly.

Parameters
MANAGERone of many asynchronous I2C managers defined in this header

Definition at line 57 of file i2c_handler_atmega.h.

◆ REGISTER_I2C_ISR_FUNCTION

#define REGISTER_I2C_ISR_FUNCTION (   MANAGER,
  CALLBACK 
)
Value:
ISR(TWI_vect) \
{ \
i2c::isr_handler::i2c_change_function<MANAGER, CALLBACK>(); \
}

Register the necessary ISR (Interrupt Service Routine) for an asynchronous I2C Manager to work properly, along with a callback function that will be called everytime an I2C transaction progresses (one command executed, whole transaction executed, error).

Parameters
MANAGERone of many asynchronous I2C managers defined in this header
CALLBACKthe function that will be called when the interrupt is triggered; it should follow this prototype: void f(I2CCallback, typename MANAGER::ABSTRACT_FUTURE&)
See also
i2c::I2CCallback

Definition at line 76 of file i2c_handler_atmega.h.

◆ REGISTER_I2C_ISR_METHOD

#define REGISTER_I2C_ISR_METHOD (   MANAGER,
  HANDLER,
  CALLBACK 
)
Value:
ISR(TWI_vect) \
{ \
i2c::isr_handler::i2c_change_method<MANAGER, HANDLER, CALLBACK>(); \
}

Register the necessary ISR (Interrupt Service Routine) for an asynchronous I2C Manager to work properly, along with a callback method that will be called everytime an I2C transaction progresses (one command executed, whole transaction executed, error).

Parameters
MANAGERone of many asynchronous I2C managers defined in this header
HANDLERthe class holding the callback method
CALLBACKthe method of HANDLER that will be called when the interrupt is triggered; this must be a proper PTMF (pointer to member function); it should follow this prototype: void f(I2CCallback, typename MANAGER::ABSTRACT_FUTURE&)
See also
i2c::I2CCallback

Definition at line 96 of file i2c_handler_atmega.h.

◆ DECL_I2C_ISR_HANDLERS_FRIEND

#define DECL_I2C_ISR_HANDLERS_FRIEND
Value:
friend struct i2c::isr_handler; \
DECL_TWI_FRIENDS

This macro shall be used in a class containing a private callback method, registered by REGISTER_I2C_ISR_METHOD.

It declares the class where it is used as a friend of all necessary functions so that the private callback method can be called properly.

Definition at line 108 of file i2c_handler_atmega.h.