Lancaster University's (short term!) clone of mbed-src for micro:bit. This is a copy of the github branch https://github.com/lancaster-university/mbed-classic

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Jul 17 09:15:10 2015 +0100
Revision:
592:a274ee790e56
Parent:
579:53297373a894
Synchronized with git revision e7144f83a8d75df80c4877936b6ffe552b0be9e6

Full URL: https://github.com/mbedmicro/mbed/commit/e7144f83a8d75df80c4877936b6ffe552b0be9e6/

More API implementation for SAMR21

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 579:53297373a894 1 /**
mbed_official 579:53297373a894 2 * \page asfdoc_sam0_sercom_i2c_master_basic_use_case Quick Start Guide for SERCOM I2C Master - Basic
mbed_official 579:53297373a894 3 *
mbed_official 579:53297373a894 4 * In this use case, the I<SUP>2</SUP>C will used and set up as follows:
mbed_official 579:53297373a894 5 * - Master mode
mbed_official 579:53297373a894 6 * - 100KHz operation speed
mbed_official 579:53297373a894 7 * - Not operational in standby
mbed_official 579:53297373a894 8 * - 10000 packet timeout value
mbed_official 579:53297373a894 9 * - 65535 unknown bus state timeout value
mbed_official 579:53297373a894 10 *
mbed_official 579:53297373a894 11 *
mbed_official 579:53297373a894 12 * \section asfdoc_sam0_sercom_i2c_master_basic_use_case_prereq Prerequisites
mbed_official 579:53297373a894 13 * The device must be connected to an I<SUP>2</SUP>C slave.
mbed_official 579:53297373a894 14 *
mbed_official 579:53297373a894 15 * \section asfdoc_sam0_sercom_i2c_master_basic_use_setup Setup
mbed_official 579:53297373a894 16 *
mbed_official 579:53297373a894 17 * \subsection asfdoc_sam0_sercom_i2c_master_basic_use_setup_code Code
mbed_official 579:53297373a894 18 * The following must be added to the user application:
mbed_official 579:53297373a894 19 *
mbed_official 579:53297373a894 20 * - A sample buffer to send, a sample buffer to read:
mbed_official 579:53297373a894 21 * \snippet qs_i2c_master_basic_use.c packet_data
mbed_official 579:53297373a894 22 *
mbed_official 579:53297373a894 23 * - Slave address to access:
mbed_official 579:53297373a894 24 * \snippet qs_i2c_master_basic_use.c address
mbed_official 579:53297373a894 25 *
mbed_official 579:53297373a894 26 * - Number of times to try to send packet if it fails:
mbed_official 579:53297373a894 27 * \snippet qs_i2c_master_basic_use.c timeout
mbed_official 579:53297373a894 28 *
mbed_official 579:53297373a894 29 * - Globally accessible module structure:
mbed_official 579:53297373a894 30 * \snippet qs_i2c_master_basic_use.c dev_inst
mbed_official 579:53297373a894 31 *
mbed_official 579:53297373a894 32 * - Function for setting up the module:
mbed_official 579:53297373a894 33 * \snippet qs_i2c_master_basic_use.c initialize_i2c
mbed_official 579:53297373a894 34 *
mbed_official 579:53297373a894 35 * - Add to user application \c main():
mbed_official 579:53297373a894 36 * \snippet qs_i2c_master_basic_use.c init
mbed_official 579:53297373a894 37 *
mbed_official 579:53297373a894 38 * \subsection asfdoc_sam0_sercom_i2c_master_basic_use_setup_workflow Workflow
mbed_official 579:53297373a894 39 * -# Configure and enable module.
mbed_official 579:53297373a894 40 * \snippet qs_i2c_master_basic_use.c initialize_i2c
mbed_official 579:53297373a894 41 * -# Create and initialize configuration structure.
mbed_official 579:53297373a894 42 * \snippet qs_i2c_master_basic_use.c init_conf
mbed_official 579:53297373a894 43 * -# Change settings in the configuration.
mbed_official 579:53297373a894 44 * \snippet qs_i2c_master_basic_use.c conf_change
mbed_official 579:53297373a894 45 * -# Initialize the module with the set configurations.
mbed_official 579:53297373a894 46 * \snippet qs_i2c_master_basic_use.c init_module
mbed_official 579:53297373a894 47 * -# Enable the module.
mbed_official 579:53297373a894 48 * \snippet qs_i2c_master_basic_use.c enable_module
mbed_official 579:53297373a894 49 * -# Create a variable to see when we should stop trying to send packet.
mbed_official 579:53297373a894 50 * \snippet qs_i2c_master_basic_use.c timeout_counter
mbed_official 579:53297373a894 51 * -# Create a packet to send.
mbed_official 579:53297373a894 52 * \snippet qs_i2c_master_basic_use.c packet
mbed_official 579:53297373a894 53 *
mbed_official 579:53297373a894 54 * \section asfdoc_sam0_sercom_i2c_master_basic_use_implemenation Implementation
mbed_official 579:53297373a894 55 * \subsection asfdoc_sam0_sercom_i2c_master_basic_use_implemenation_code Code
mbed_official 579:53297373a894 56 * Add to user application \c main():
mbed_official 579:53297373a894 57 * \snippet qs_i2c_master_basic_use.c main
mbed_official 579:53297373a894 58 *
mbed_official 579:53297373a894 59 * \subsection asfdoc_sam0_sercom_i2c_master_basic_use_implemenation_workflow Workflow
mbed_official 579:53297373a894 60 * -# Write packet to slave.
mbed_official 579:53297373a894 61 * \snippet qs_i2c_master_basic_use.c write_packet
mbed_official 579:53297373a894 62 * The module will try to send the packet TIMEOUT number of times or until it is
mbed_official 579:53297373a894 63 * successfully sent.
mbed_official 579:53297373a894 64 * -# Read packet from slave.
mbed_official 579:53297373a894 65 * \snippet qs_i2c_master_basic_use.c read_packet
mbed_official 579:53297373a894 66 * The module will try to read the packet TIMEOUT number of times or until it is
mbed_official 579:53297373a894 67 * successfully read.
mbed_official 579:53297373a894 68 */
mbed_official 579:53297373a894 69 /**
mbed_official 579:53297373a894 70 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
mbed_official 579:53297373a894 71 */
mbed_official 579:53297373a894 72
mbed_official 579:53297373a894 73 #include <asf.h>
mbed_official 579:53297373a894 74 #include <conf_clocks.h>
mbed_official 579:53297373a894 75