TWi master example for megaRF device.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | TWI_EXAMPLE &TWBR |
Functions | |
int | main (void) |
TWI Master Example Main. More... | |
Slave EEPROM memory Test Pattern Constants | |
#define | PATTERN_TEST_LENGTH sizeof(test_pattern) |
const uint8_t | test_pattern [] |
const uint8_t | slave_mem_addr [SLAVE_MEM_ADDR_LENGTH] |
#define PATTERN_TEST_LENGTH sizeof(test_pattern) |
Referenced by main().
#define TWI_EXAMPLE &TWBR |
Referenced by main().
int main | ( | void | ) |
TWI Master Example Main.
Main function.
The master example begins by initializing required board resources. The system clock, basic GPIO pin mapping, and interrupt vectors are established.
A memory location on a TWI slave is written with a fixed test pattern which is then read back into a separate buffer. As a basic sanity check, the original write-buffer values are compared with values read from the slave to a separate buffer. An LED on the development board is illuminated when there is a match between the written and read data.
The SAM3X_EK, SAM3X Arduino board and SAM4C_EK use two bytes length internal address EEPROM.
References twi_package_t::addr, twi_master_options_t::baud_reg, board_init(), data_received, delay_ms, LED_On, PATTERN_TEST_LENGTH, SLAVE_BUS_ADDR, slave_mem_addr, SLAVE_MEM_ADDR_LENGTH, twi_master_options_t::speed, sysclk_enable_peripheral_clock(), sysclk_get_cpu_hz(), sysclk_init(), test_pattern, TWI_CLOCK_RATE, TWI_EXAMPLE, twi_master_init(), twi_master_read(), twi_master_write(), and TWI_SUCCESS.
const uint8_t slave_mem_addr[SLAVE_MEM_ADDR_LENGTH] |
Referenced by main().
const uint8_t test_pattern[] |