Atmel Software Framework

twi_slave_example.c File Reference
#include <avr32/io.h>
#include "board.h"
#include "print_funcs.h"
#include "gpio.h"
#include "pm.h"
#include "twi.h"

Macros

#define EEPROM_ADDR_LGT   3
 
#define EEPROM_ADDRESS   0x50
 
#define PATTERN_TEST_LENGTH   (sizeof(test_pattern)/sizeof(U8))
 Constants to define the sent and received pattern. More...
 
#define TWI_MEM_ADDR   1
 
#define TWI_MEM_DATA   2
 
#define TWI_MEM_IDLE   0
 
#define TWI_MEM_SIZE   20
 Defines & Variables to manage a virtual TWI memory. More...
 
#define TWI_SPEED   50000
 
#define VIRTUALMEM_ADDR_START   0x123456
 

Functions

int main (void)
 Main function. More...
 
static void twi_slave_rx (U8 u8_value)
 Manage the received data on TWI. More...
 
static void twi_slave_stop (void)
 Manage stop transfer reception on TWI. More...
 
static U8 twi_slave_tx (void)
 Transmit a data on TWI. More...
 

Variables

U8 s_memory [TWI_MEM_SIZE] ={0}
 
U8 s_status_cmd = TWI_MEM_IDLE
 
U32 s_u32_addr
 
U8 s_u8_addr_pos
 
const U8 test_pattern []
 

#define EEPROM_ADDR_LGT   3

Referenced by twi_slave_rx().

#define EEPROM_ADDRESS   0x50

Referenced by main().

#define PATTERN_TEST_LENGTH   (sizeof(test_pattern)/sizeof(U8))

Constants to define the sent and received pattern.

#define TWI_MEM_ADDR   1

Referenced by twi_slave_rx().

#define TWI_MEM_DATA   2

Referenced by twi_slave_rx(), and twi_slave_tx().

#define TWI_MEM_IDLE   0

Referenced by twi_slave_rx(), and twi_slave_stop().

#define TWI_MEM_SIZE   20

Defines & Variables to manage a virtual TWI memory.

Referenced by twi_slave_rx(), and twi_slave_tx().

#define TWI_SPEED   50000

Referenced by main().

#define VIRTUALMEM_ADDR_START   0x123456

Referenced by twi_slave_rx(), and twi_slave_tx().

static void twi_slave_rx ( U8  u8_value)
static
static void twi_slave_stop ( void  )
static

Manage stop transfer reception on TWI.

References s_status_cmd, and TWI_MEM_IDLE.

Referenced by main().

static U8 twi_slave_tx ( void  )
static

Transmit a data on TWI.

References s_memory, s_status_cmd, s_u32_addr, TWI_MEM_DATA, TWI_MEM_SIZE, and VIRTUALMEM_ADDR_START.

Referenced by main().

U8 s_memory[TWI_MEM_SIZE] ={0}

Referenced by twi_slave_rx(), and twi_slave_tx().

U8 s_status_cmd = TWI_MEM_IDLE
U32 s_u32_addr

Referenced by twi_slave_rx(), and twi_slave_tx().

U8 s_u8_addr_pos

Referenced by twi_slave_rx().

const U8 test_pattern[]
Initial value:
= {
0xAA,
0x55,
0xA5,
0x5A,
0x77,
0x99}