TWI SLAVE Example for SAM.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
#include "conf_example.h"
Macros | |
#define | STRING_EOL "\r" |
#define | STRING_HEADER |
#define | SLAVE_ADDRESS 0x50 /** Target's TWI address */ |
Information about TWIS Module. More... | |
#define | SLAVE_ADDR_LGT 2 /** Address length of virtual mem */ |
#define | VIRTUALMEM_ADDR_START 0 /** Address of virtual mem */ |
#define | TWI_MEM_SIZE 50 /** The size of the virtual mem */ |
Defines to manage a virtual TWI memory. More... | |
#define | TWI_MEM_IDLE 0 /** Idle state */ |
#define | TWI_MEM_ADDR 1 /** Address state */ |
#define | TWI_MEM_DATA 2 /** Data state */ |
Functions | |
static void | configure_console (void) |
Configure serial console. More... | |
int | main (void) |
Application entry point for TWI Slave example. More... | |
static void | twis_slave_error (void) |
Manage Error on TWIS. More... | |
static void | twis_slave_rx (uint8_t value) |
Manage the received data on TWI. More... | |
static void | twis_slave_stop (void) |
Manage stop transfer reception on TWIS. More... | |
static uint8_t | twis_slave_tx (void) |
Transmit a data on TWIS. More... | |
Variables | |
uint32_t | addr |
The current address in the virtual mem. More... | |
uint8_t | addr_pos |
Offset in the address value. More... | |
uint8_t | memory [TWI_MEM_SIZE] |
Content of the Virtual mem. More... | |
uint8_t | status_cmd = TWI_MEM_IDLE |
State variable. More... | |
struct twis_dev_inst | twis_device |
Referenced by twis_slave_rx().
#define SLAVE_ADDRESS 0x50 /** Target's TWI address */ |
Information about TWIS Module.
Referenced by main().
#define STRING_EOL "\r" |
#define STRING_HEADER |
Referenced by main().
#define TWI_MEM_ADDR 1 /** Address state */ |
Referenced by twis_slave_rx().
#define TWI_MEM_DATA 2 /** Data state */ |
Referenced by twis_slave_rx().
#define TWI_MEM_IDLE 0 /** Idle state */ |
Referenced by twis_slave_rx(), twis_slave_stop(), and twis_slave_tx().
#define TWI_MEM_SIZE 50 /** The size of the virtual mem */ |
Defines to manage a virtual TWI memory.
Referenced by twis_slave_rx(), and twis_slave_tx().
#define VIRTUALMEM_ADDR_START 0 /** Address of virtual mem */ |
Referenced by twis_slave_rx(), and twis_slave_tx().
|
static |
Configure serial console.
References uart_rs232_options::baudrate, and stdio_serial_init().
Referenced by main().
int main | ( | void | ) |
Application entry point for TWI Slave example.
References board_init(), twis_config::chip, configure_console(), twis_callback::error, twis_callback::rx, SLAVE_ADDRESS, STATUS_OK, twis_callback::stop, STRING_HEADER, sysclk_init(), twis_device, twis_enable(), twis_get_config_defaults(), twis_init(), TWIS_INTERRUPT_SLAVEADR_MATCH, twis_set_callback(), twis_slave_error(), twis_slave_rx(), twis_slave_stop(), twis_slave_tx(), and twis_callback::tx.
|
static |
|
static |
Manage the received data on TWI.
References SLAVE_ADDR_LGT, TWI_MEM_ADDR, TWI_MEM_DATA, TWI_MEM_IDLE, TWI_MEM_SIZE, and VIRTUALMEM_ADDR_START.
Referenced by main().
|
static |
Manage stop transfer reception on TWIS.
References TWI_MEM_IDLE.
Referenced by main().
|
static |
Transmit a data on TWIS.
References TWI_MEM_IDLE, TWI_MEM_SIZE, and VIRTUALMEM_ADDR_START.
Referenced by main().
uint32_t addr |
The current address in the virtual mem.
Referenced by appCmdBuffer(), at45dbx_read_byte_open(), at45dbx_write_byte_open(), hx8347a_write_ram_buffer(), inet_chksum_pseudo(), inet_chksum_pseudo_partial(), main(), NWK_SetAddr(), and print_pairing_table().
uint8_t addr_pos |
Offset in the address value.
uint8_t memory[TWI_MEM_SIZE] |
Content of the Virtual mem.
uint8_t status_cmd = TWI_MEM_IDLE |
State variable.
struct twis_dev_inst twis_device |
Referenced by main().