#include <avr32/io.h>
#include "compiler.h"
#include "intc.h"
#include "twim.h"
#include <includes.h>
Functions | |
CPU_INT32U | BSP_INTC_IntReg (CPU_FNCT_VOID handler, CPU_INT32U irq, CPU_INT32U int_level) |
int | twi_master_init (volatile avr32_twim_t *twi, const twi_options_t *opt) |
Initialize the twi master module. More... | |
static void | twi_master_interrupt_handler (void) |
TWI interrupt handler. More... | |
int | twi_master_read (volatile avr32_twim_t *twi, const twi_package_t *package) |
Read multiple bytes from a TWI compatible slave device. More... | |
int | twi_probe (volatile avr32_twim_t *twi, char chip_addr) |
Test if a chip answers for a given twi address. More... | |
int | twi_set_speed (volatile avr32_twim_t *twi, unsigned int speed, unsigned long pba_hz) |
Set the twi bus speed in conjunction with the clock frequency. More... | |
int | twim_chained_transfer (volatile avr32_twim_t *twi, volatile twim_transfer_t *first, volatile twim_transfer_t *second, bool tenbit) |
void | twim_disable_interrupt (volatile avr32_twim_t *twi) |
int | twim_read (volatile avr32_twim_t *twi, unsigned char *buffer, int nbytes, int saddr, bool tenbit) |
int | twim_read_packet (volatile avr32_twim_t *twi, const twi_package_t *package) |
Read multiple bytes from a TWI compatible slave device. More... | |
int | twim_write (volatile avr32_twim_t *twi, unsigned const char *buffer, int nbytes, int saddr, bool tenbit) |
int | twim_write_packet (volatile avr32_twim_t *twi, const twi_package_t *package) |
Write multiple bytes to a TWI compatible slave device. More... | |
Variables | |
static volatile avr32_twim_t * | twim_inst |
Pointer to the instance 1 of the TWIM registers for IT. More... | |
static volatile unsigned long | twim_it_mask |
IT mask. More... | |
static volatile bool | twim_nack = false |
Add NACK boolean. More... | |
static volatile unsigned char *volatile | twim_rx_data = NULL |
Pointer to the applicative TWI receive buffer. More... | |
static volatile int | twim_rx_nb_bytes = 0 |
Remaining number of bytes to receive. More... | |
static const unsigned char *volatile | twim_tx_data = NULL |
Pointer to the applicative TWI transmit buffer. More... | |
static volatile int | twim_tx_nb_bytes = 0 |
Remaining number of bytes to transmit. More... | |
CPU_INT32U BSP_INTC_IntReg | ( | CPU_FNCT_VOID | handler, |
CPU_INT32U | irq, | ||
CPU_INT32U | int_level | ||
) |
Referenced by BSP_Init(), controller_init(), and twi_master_init().
int twi_master_init | ( | volatile avr32_twim_t * | twi, |
const twi_options_t * | opt | ||
) |
Initialize the twi master module.
twi | Base address of the TWI (i.e. &AVR32_TWI). |
*opt | Options for initializing the twi module (see twim_options_t) |
References BSP_INTC_IntReg(), Disable_global_interrupt, Enable_global_interrupt, Is_global_interrupt_enabled, twi_options_t::pba_hz, twi_options_t::smbus, twi_options_t::speed, TWI_INVALID_CLOCK_DIV, twi_master_interrupt_handler(), twi_set_speed(), TWI_SUCCESS, and UL.
Referenced by twi_init().
|
static |
TWI interrupt handler.
References twim_inst, twim_it_mask, twim_nack, twim_rx_data, twim_rx_nb_bytes, twim_tx_data, and twim_tx_nb_bytes.
Referenced by twi_master_init().
int twi_master_read | ( | volatile avr32_twim_t * | twi, |
const twi_package_t * | package | ||
) |
Read multiple bytes from a TWI compatible slave device.
twi | Base address of the TWI (i.e. &AVR32_TWI). |
package | Package information and data (see twi_package_t) |
References twi_package_t::addr, twi_package_t::addr_length, twi_package_t::buffer, twi_package_t::chip, twi_package_t::length, Swap32, TWI_SUCCESS, twim_read(), and twim_write().
Referenced by at42qt1060_get_status(), and at42qt1060_read_reg().
int twi_probe | ( | volatile avr32_twim_t * | twi, |
char | chip_addr | ||
) |
Test if a chip answers for a given twi address.
twi | Base address of the TWI (i.e. &AVR32_TWI). |
chip_addr | Address of the chip which is searched for |
References twi_package_t::addr, twi_package_t::addr_length, twi_package_t::buffer, twi_package_t::chip, twi_package_t::length, and twim_write_packet().
int twi_set_speed | ( | volatile avr32_twim_t * | twi, |
unsigned int | speed, | ||
unsigned long | pba_hz | ||
) |
Set the twi bus speed in conjunction with the clock frequency.
twi | Base address of the TWI (i.e. &AVR32_TWI). |
speed | The desired twi bus speed |
pba_hz | The current running PBA clock frequency |
References TWI_INVALID_CLOCK_DIV, and TWI_SUCCESS.
Referenced by twi_master_init().
int twim_chained_transfer | ( | volatile avr32_twim_t * | twi, |
volatile twim_transfer_t * | first, | ||
volatile twim_transfer_t * | second, | ||
bool | tenbit | ||
) |
void twim_disable_interrupt | ( | volatile avr32_twim_t * | twi | ) |
References Disable_global_interrupt, Is_global_interrupt_enabled, and UL.
Referenced by twim_read(), twim_read_packet(), and twim_write().
int twim_read | ( | volatile avr32_twim_t * | twi, |
unsigned char * | buffer, | ||
int | nbytes, | ||
int | saddr, | ||
bool | tenbit | ||
) |
References Enable_global_interrupt, TWI_RECEIVE_NACK, TWI_SUCCESS, twim_disable_interrupt(), twim_inst, twim_it_mask, twim_nack, and twim_rx_data.
Referenced by twi_master_read().
int twim_read_packet | ( | volatile avr32_twim_t * | twi, |
const twi_package_t * | package | ||
) |
Read multiple bytes from a TWI compatible slave device.
twi | Base address of the TWI (i.e. &AVR32_TWI). |
package | Package information and data (see twi_package_t) |
References twi_package_t::addr, twi_package_t::addr_length, twi_package_t::buffer, twi_package_t::chip, Enable_global_interrupt, twi_package_t::length, TWI_RECEIVE_NACK, TWI_SUCCESS, twim_disable_interrupt(), twim_inst, twim_it_mask, twim_nack, twim_rx_data, twim_rx_nb_bytes, twim_tx_data, and twim_tx_nb_bytes.
int twim_write | ( | volatile avr32_twim_t * | twi, |
unsigned const char * | buffer, | ||
int | nbytes, | ||
int | saddr, | ||
bool | tenbit | ||
) |
References Enable_global_interrupt, TWI_RECEIVE_NACK, TWI_SUCCESS, twim_disable_interrupt(), twim_inst, twim_it_mask, twim_nack, twim_tx_data, and twim_tx_nb_bytes.
Referenced by twi_master_read(), and twi_master_write().
int twim_write_packet | ( | volatile avr32_twim_t * | twi, |
const twi_package_t * | package | ||
) |
Write multiple bytes to a TWI compatible slave device.
twi | Base address of the TWI (i.e. &AVR32_TWI). |
*package | Package information and data (see twi_package_t) |
References twi_package_t::addr, twi_package_t::addr_length, twi_package_t::buffer, twi_package_t::chip, twi_package_t::length, TWI_RECEIVE_NACK, TWI_SUCCESS, twim_tx_data, and twim_tx_nb_bytes.
Referenced by twi_probe().
|
static |
Pointer to the instance 1 of the TWIM registers for IT.
Referenced by twi_master_interrupt_handler(), twim_read(), twim_read_packet(), and twim_write().
|
static |
IT mask.
Referenced by twi_master_interrupt_handler(), twim_read(), twim_read_packet(), and twim_write().
Add NACK boolean.
Referenced by twi_master_interrupt_handler(), twim_read(), twim_read_packet(), and twim_write().
|
static |
Pointer to the applicative TWI receive buffer.
Referenced by twi_master_interrupt_handler(), twim_chained_transfer(), twim_read(), and twim_read_packet().
|
static |
Remaining number of bytes to receive.
Referenced by twi_master_interrupt_handler(), and twim_read_packet().
|
static |
Pointer to the applicative TWI transmit buffer.
Referenced by twi_master_interrupt_handler(), twim_chained_transfer(), twim_read_packet(), twim_write(), and twim_write_packet().
|
static |
Remaining number of bytes to transmit.
Referenced by twi_master_interrupt_handler(), twim_chained_transfer(), twim_read_packet(), twim_write(), and twim_write_packet().