Microchip® Advanced Software Framework

qs_i2c_master_basic_use.c File Reference

SAM SERCOM I2C Master Quick Start Guide.

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

#include <asf.h>

Macros

#define DATA_LENGTH   10
 [packet_data] More...
 
#define SLAVE_ADDRESS   0x12
 [packet_data] More...
 
#define TIMEOUT   1000
 [address] More...
 

Functions

void configure_i2c_master (void)
 [dev_inst] More...
 
int main (void)
 [initialize_i2c] More...
 

Variables

struct i2c_master_module i2c_master_instance
 [timeout] More...
 
static uint8_t read_buffer [DATA_LENGTH]
 
static uint8_t write_buffer [DATA_LENGTH]
 

#define DATA_LENGTH   10

[packet_data]

Referenced by main().

#define SLAVE_ADDRESS   0x12

[packet_data]

[address]

Referenced by main().

#define TIMEOUT   1000

[address]

[timeout]

Referenced by main().

void configure_i2c_master ( void  )

[dev_inst]

[initialize_i2c]

[init_conf]

[init_conf]

[conf_change]

[conf_change]

[init_module]

[init_module]

[enable_module]

[enable_module]

References i2c_master_config::buffer_timeout, i2c_master_enable(), i2c_master_get_config_defaults(), i2c_master_init(), i2c_master_instance, i2c_master_config::pinmux_pad0, and i2c_master_config::pinmux_pad1.

Referenced by main().

int main ( void  )

[initialize_i2c]

[init]

[config]

[config]

[timeout_counter]

[timeout_counter]

[packet]

[packet] [init]

[main]

[write_packet]

[write_packet]

[read_packet]

[read_packet]

[main]

References i2c_master_packet::address, configure_i2c_master(), i2c_master_packet::data, DATA_LENGTH, i2c_master_instance, i2c_master_read_packet_wait(), i2c_master_write_packet_wait(), read_buffer, SLAVE_ADDRESS, STATUS_OK, system_init(), TIMEOUT, and write_buffer.

struct i2c_master_module i2c_master_instance

[timeout]

[dev_inst]

uint8_t read_buffer[DATA_LENGTH]
static
uint8_t write_buffer[DATA_LENGTH]
static
Initial value:
= {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
}