extern "C" { #include <inttypes.h> #include "WConstants.h" #include "TWI.h" }
#include <TWI.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include "WConstants.h"
#include <inttypes.h>
Go to the source code of this file.
Functions | |
unsigned char | twi_busy_p (void) |
Call this function to test if the TWI_ISR is busy transmitting. | |
unsigned char | twi_get_state (void) |
Returns the state of TWI interface. | |
void | twi_transmit (unsigned char *msg, unsigned char msg_size) |
Call this function to send a prepared message. | |
void | twi_resend (void) |
unsigned char | twi_get_data (unsigned char *msg, unsigned char msg_size) |
ISR (TWI_vect) | |
Variables | |
union twi_status_reg | twi_status_reg = {0} |
From AVR315 TWI Master Implementation, by ltwa, March 24, 2004
Definition in file TWI.c.
ISR | ( | TWI_vect | ) |
unsigned char twi_busy_p | ( | void | ) |
unsigned char twi_get_data | ( | unsigned char * | msg, | |
unsigned char | msg_size | |||
) |
Call this function to read out the requested data from the TWI transceiver buffer. I.e. first call TWI_Start_Transceiver to send a request for data to the slave. Then Run this function to collect the data when they have arrived. Include a pointer to where to place the data and the number of bytes requested (including the address field) in the function call. The function will hold execution (loop) until the TWI_ISR has completed with the previous operation, before reading out the data and returning. If there was an error in the previous transmission the function will return the TWI error code.
unsigned char twi_get_state | ( | void | ) |
Returns the state of TWI interface.
Call this function to fetch the state information of the previous operation. The function will hold execution (loop) until the TWI_ISR has completed with the previous operation. If there was an error, then the function will return the TWI State code.
void twi_resend | ( | void | ) |
Call this function to resend the last message. The driver will reuse the data previously put in the transceiver buffers. The function will hold execution (loop) until the TWI_ISR has completed with the previous operation, then initialize the next operation and return.
void twi_transmit | ( | unsigned char * | msg, | |
unsigned char | msg_size | |||
) |
Call this function to send a prepared message.
The first byte must contain the slave address and the read/write bit. Consecutive bytes contain the data to be sent, or empty locations for data to be read from the slave. Also include how many bytes that should be sent/read including the address byte. The function will hold execution (loop) until the TWI_ISR has completed with the previous operation, then initialize the next operation and return.
[in] | *msg | address in memory where the message begins |
[in] | msg_size | number of chars in the message |