Microchip® Advanced Software Framework

twi_megarf.c File Reference

megaRF TWI master and slave driver.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include "twi_megarf.h"

Macros

#define MASTER   0
 TWI Mode of operation. More...
 
#define SLAVE   1
 

Functions

 ISR (TWI_vect)
 TWI interrupt Vector. More...
 
static void twi_interrupt_handler (void)
 TWI Interrupt Handler. More...
 
static void twi_master_addr_ack (void)
 Notification that address byte was written to the TWI and need to send ACK or NACK. More...
 
static void twi_master_bus_reset (void)
 Reset TWI bus. More...
 
static void twi_master_data_write (void)
 Sending data to twi bus. More...
 
status_code_t twi_master_get_status (void)
 returns the status of TWI bus More...
 
status_code_t twi_master_init (volatile void *twi, twi_master_options_t *opt)
 Inits TWI module as master. More...
 
static void twi_master_internal_addr_write (void)
 Sending internal device address to twi bus. More...
 
status_code_t twi_master_read (volatile void *twi, const twi_package_t *package)
 Reads the series of bytes from the TWI bus. More...
 
static void twi_master_read_done (uint8_t data)
 Notification that byte was read by the TWI. More...
 
static void twi_master_read_last_byte (uint8_t data)
 Notification that last byte was read from the TWI. More...
 
static void twi_master_start (void)
 Notification about the start condition was sent. More...
 
status_code_t twi_master_write (volatile void *twi, const twi_package_t *package)
 Perform a TWI master write transfer. More...
 
static void twi_master_write_done (void)
 Notification that byte was written to the TWI. More...
 
static void twi_slave_bus_reset (void)
 Reset TWI bus. More...
 
static void twi_slave_data_read (uint8_t data)
 Read received data. More...
 
static void twi_slave_data_write (void)
 Sending data to twi bus. More...
 
static void twi_slave_enable (void)
 Enable TWI as slave. More...
 
status_code_t twi_slave_init (uint8_t twi_slave_ownadd)
 Initialize TWI as Slave. More...
 
static void twi_slave_last_byte_write_done (void)
 Notification of Last byte is transmitted. More...
 
status_code_t twi_slave_start (slave_data_buffer_t *package)
 Start the slave Transceiver. More...
 
int twi_slave_state_get (void)
 Get the state of TWI transceiver. More...
 
int twi_slave_status_get (void)
 Get the status of TWI transceiver. More...
 
void twi_slave_status_reset (void)
 Resets the slave state and status to initial for next transmission/reception. More...
 
static void twi_slave_write_byte (uint8_t data)
 writing an byte to TWI. More...
 

Variables

struct {
   int   addr_count
 
   unsigned int   data_count
 
   twi_package_t *   pkg
 
   uint8_t   state
 
   status_code_t   status
 
master_transfer
 Master Transfer Descriptor. More...
 
struct {
   slave_data_buffer_t *   data_buffer
 
   unsigned int   data_count
 
   uint8_t   state
 
   int   status
 
slave_transfer
 Slave Transfer Descriptor. More...
 
static volatile bool twi_master_busy = false
 
static volatile bool twi_mode = MASTER
 

#define MASTER   0

TWI Mode of operation.

Referenced by twi_interrupt_handler(), and twi_master_init().

#define SLAVE   1

Referenced by twi_slave_status_reset().

ISR ( TWI_vect  )

TWI interrupt Vector.

References twi_interrupt_handler().

int addr_count
slave_data_buffer_t* data_buffer

Referenced by main().

unsigned int data_count
uint8_t state
int status
volatile bool twi_mode = MASTER
static