mbed library sources
Fork of mbed-src by
targets/hal/TARGET_Atmel/TARGET_SAM21/drivers/sercom/i2c/quick_start_master_dma/qs_i2c_master_dma.h@592:a274ee790e56, 2015-07-17 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 579:53297373a894 | 1 | /** |
mbed_official | 579:53297373a894 | 2 | * \page asfdoc_sam0_sercom_i2c_master_dma_use_case Quick Start Guide for Using DMA with SERCOM I2C Master |
mbed_official | 579:53297373a894 | 3 | * |
mbed_official | 579:53297373a894 | 4 | * The supported board list: |
mbed_official | 579:53297373a894 | 5 | * - SAMD21 Xplained Pro |
mbed_official | 579:53297373a894 | 6 | * - SAMR21 Xplained Pro |
mbed_official | 579:53297373a894 | 7 | * - SAML21 Xplained Pro |
mbed_official | 579:53297373a894 | 8 | * |
mbed_official | 579:53297373a894 | 9 | * In this use case, the I<SUP>2</SUP>C will used and set up as follows: |
mbed_official | 579:53297373a894 | 10 | * - Master mode |
mbed_official | 579:53297373a894 | 11 | * - 100KHz operation speed |
mbed_official | 579:53297373a894 | 12 | * - Not operational in standby |
mbed_official | 579:53297373a894 | 13 | * - 10000 packet timeout value |
mbed_official | 579:53297373a894 | 14 | * - 65535 unknown bus state timeout value |
mbed_official | 579:53297373a894 | 15 | * |
mbed_official | 579:53297373a894 | 16 | * |
mbed_official | 579:53297373a894 | 17 | * \section asfdoc_sam0_sercom_i2c_master_dma_use_case_prereq Prerequisites |
mbed_official | 579:53297373a894 | 18 | * The device must be connected to an I<SUP>2</SUP>C slave. |
mbed_official | 579:53297373a894 | 19 | * |
mbed_official | 579:53297373a894 | 20 | * \section asfdoc_sam0_sercom_i2c_master_dma_use_setup Setup |
mbed_official | 579:53297373a894 | 21 | * |
mbed_official | 579:53297373a894 | 22 | * \subsection asfdoc_sam0_sercom_i2c_master_dma_use_setup_code Code |
mbed_official | 579:53297373a894 | 23 | * The following must be added to the user application: |
mbed_official | 579:53297373a894 | 24 | * |
mbed_official | 579:53297373a894 | 25 | * - A sample buffer to send, number of entries to send and address of slave: |
mbed_official | 579:53297373a894 | 26 | * \snippet qs_i2c_master_dma.c packet_data |
mbed_official | 579:53297373a894 | 27 | * |
mbed_official | 579:53297373a894 | 28 | * Number of times to try to send packet if it fails: |
mbed_official | 579:53297373a894 | 29 | * \snippet qs_i2c_master_dma.c timeout |
mbed_official | 579:53297373a894 | 30 | * |
mbed_official | 579:53297373a894 | 31 | * - Globally accessible module structure: |
mbed_official | 579:53297373a894 | 32 | * \snippet qs_i2c_master_dma.c dev_i2c_inst |
mbed_official | 579:53297373a894 | 33 | * |
mbed_official | 579:53297373a894 | 34 | * - Function for setting up the module: |
mbed_official | 579:53297373a894 | 35 | * \snippet qs_i2c_master_dma.c initialize_i2c |
mbed_official | 579:53297373a894 | 36 | * |
mbed_official | 579:53297373a894 | 37 | * - Globally accessible DMA module structure: |
mbed_official | 579:53297373a894 | 38 | * \snippet qs_i2c_master_dma.c dma_resource |
mbed_official | 579:53297373a894 | 39 | * |
mbed_official | 579:53297373a894 | 40 | * - Globally transfer done flag: |
mbed_official | 579:53297373a894 | 41 | * \snippet qs_i2c_master_dma.c transfer_done_flag |
mbed_official | 579:53297373a894 | 42 | * |
mbed_official | 579:53297373a894 | 43 | * - Globally accessible DMA transfer descriptor: |
mbed_official | 579:53297373a894 | 44 | * \snippet qs_i2c_master_dma.c transfer_descriptor |
mbed_official | 579:53297373a894 | 45 | * |
mbed_official | 579:53297373a894 | 46 | * - Function for transfer done callback: |
mbed_official | 579:53297373a894 | 47 | * \snippet qs_i2c_master_dma.c transfer_done |
mbed_official | 579:53297373a894 | 48 | * |
mbed_official | 579:53297373a894 | 49 | * - Function for setting up the DMA resource: |
mbed_official | 579:53297373a894 | 50 | * \snippet qs_i2c_master_dma.c config_dma_resource |
mbed_official | 579:53297373a894 | 51 | * |
mbed_official | 579:53297373a894 | 52 | * - Function for setting up the DMA transfer descriptor: |
mbed_official | 579:53297373a894 | 53 | * \snippet qs_i2c_master_dma.c setup_dma_transfer_descriptor |
mbed_official | 579:53297373a894 | 54 | * - Add to user application \c main(): |
mbed_official | 579:53297373a894 | 55 | * \snippet qs_i2c_master_dma.c init |
mbed_official | 579:53297373a894 | 56 | * |
mbed_official | 579:53297373a894 | 57 | * \subsection asfdoc_sam0_sercom_i2c_master_dma_use_setup_workflow Workflow |
mbed_official | 579:53297373a894 | 58 | * \subsubsection asfdoc_sam0_sercom_i2c_master_dma_use_setup_workflow_i2c Configure and enable SERCOM: |
mbed_official | 579:53297373a894 | 59 | * \snippet qs_i2c_master_dma.c config_i2c |
mbed_official | 579:53297373a894 | 60 | * -# Create and initialize configuration structure. |
mbed_official | 579:53297373a894 | 61 | * \snippet qs_i2c_master_dma.c init_conf |
mbed_official | 579:53297373a894 | 62 | * -# Change settings in the configuration. |
mbed_official | 579:53297373a894 | 63 | * \snippet qs_i2c_master_dma.c conf_change |
mbed_official | 579:53297373a894 | 64 | * -# Initialize the module with the set configurations. |
mbed_official | 579:53297373a894 | 65 | * \snippet qs_i2c_master_dma.c init_module |
mbed_official | 579:53297373a894 | 66 | * -# Enable the module. |
mbed_official | 579:53297373a894 | 67 | * \snippet qs_i2c_master_dma.c enable_module |
mbed_official | 579:53297373a894 | 68 | * |
mbed_official | 579:53297373a894 | 69 | * \subsubsection asfdoc_sam0_sercom_i2c_master_dma_use_setup_workflow_dma Configure DMA |
mbed_official | 579:53297373a894 | 70 | * -# Create a DMA resource configuration structure, which can be filled out to |
mbed_official | 579:53297373a894 | 71 | * adjust the configuration of a single DMA transfer. |
mbed_official | 579:53297373a894 | 72 | * \snippet qs_i2c_master_dma.c dma_setup_1 |
mbed_official | 579:53297373a894 | 73 | * |
mbed_official | 579:53297373a894 | 74 | * -# Initialize the DMA resource configuration struct with the module's |
mbed_official | 579:53297373a894 | 75 | * default values. |
mbed_official | 579:53297373a894 | 76 | * \snippet qs_i2c_master_dma.c dma_setup_2 |
mbed_official | 579:53297373a894 | 77 | * \note This should always be performed before using the configuration |
mbed_official | 579:53297373a894 | 78 | * struct to ensure that all values are initialized to known default |
mbed_official | 579:53297373a894 | 79 | * settings. |
mbed_official | 579:53297373a894 | 80 | * |
mbed_official | 579:53297373a894 | 81 | * -# Set extra configurations for the DMA resource. It is using peripheral |
mbed_official | 579:53297373a894 | 82 | * trigger. SERCOM TX trigger causes a transaction transfer in |
mbed_official | 579:53297373a894 | 83 | * this example. |
mbed_official | 579:53297373a894 | 84 | * \snippet qs_i2c_master_dma.c dma_setup_3 |
mbed_official | 579:53297373a894 | 85 | * |
mbed_official | 579:53297373a894 | 86 | * -# Allocate a DMA resource with the configurations. |
mbed_official | 579:53297373a894 | 87 | * \snippet qs_i2c_master_dma.c dma_setup_4 |
mbed_official | 579:53297373a894 | 88 | * |
mbed_official | 579:53297373a894 | 89 | * -# Create a DMA transfer descriptor configuration structure, which can be |
mbed_official | 579:53297373a894 | 90 | * filled out to adjust the configuration of a single DMA transfer. |
mbed_official | 579:53297373a894 | 91 | * \snippet qs_i2c_master_dma.c dma_setup_5 |
mbed_official | 579:53297373a894 | 92 | * |
mbed_official | 579:53297373a894 | 93 | * -# Initialize the DMA transfer descriptor configuration struct with the module's |
mbed_official | 579:53297373a894 | 94 | * default values. |
mbed_official | 579:53297373a894 | 95 | * \snippet qs_i2c_master_dma.c dma_setup_6 |
mbed_official | 579:53297373a894 | 96 | * \note This should always be performed before using the configuration |
mbed_official | 579:53297373a894 | 97 | * struct to ensure that all values are initialized to known default |
mbed_official | 579:53297373a894 | 98 | * settings. |
mbed_official | 579:53297373a894 | 99 | * |
mbed_official | 579:53297373a894 | 100 | * -# Set the specific parameters for a DMA transfer with transfer size, source |
mbed_official | 579:53297373a894 | 101 | * address, and destination address. |
mbed_official | 579:53297373a894 | 102 | * \snippet qs_i2c_master_dma.c dma_setup_7 |
mbed_official | 579:53297373a894 | 103 | * |
mbed_official | 579:53297373a894 | 104 | * -# Create the DMA transfer descriptor. |
mbed_official | 579:53297373a894 | 105 | * \snippet qs_i2c_master_dma.c dma_setup_8 |
mbed_official | 579:53297373a894 | 106 | * |
mbed_official | 579:53297373a894 | 107 | * \section asfdoc_sam0_sercom_i2c_master_dma_use_implemenation Implementation |
mbed_official | 579:53297373a894 | 108 | * \subsection asfdoc_sam0_sercom_i2c_master_dma_use_implemenation_code Code |
mbed_official | 579:53297373a894 | 109 | * Add to user application \c main(): |
mbed_official | 579:53297373a894 | 110 | * \snippet qs_i2c_master_dma.c main |
mbed_official | 579:53297373a894 | 111 | * |
mbed_official | 579:53297373a894 | 112 | * \subsection asfdoc_sam0_sercom_i2c_master_dma_use_implemenation_workflow Workflow |
mbed_official | 579:53297373a894 | 113 | * -# Start the DMA transfer job. |
mbed_official | 579:53297373a894 | 114 | * \snippet qs_i2c_master_dma.c start_transfer_job |
mbed_official | 579:53297373a894 | 115 | * |
mbed_official | 579:53297373a894 | 116 | * -# Set the auto address length and enable flag. |
mbed_official | 579:53297373a894 | 117 | * \snippet qs_i2c_master_dma.c set_i2c_addr |
mbed_official | 579:53297373a894 | 118 | * |
mbed_official | 579:53297373a894 | 119 | * -# Waiting for transfer complete. |
mbed_official | 579:53297373a894 | 120 | * \snippet qs_i2c_master_dma.c waiting_for_complete |
mbed_official | 579:53297373a894 | 121 | * |
mbed_official | 579:53297373a894 | 122 | * -# Enter an infinite loop once transfer complete. |
mbed_official | 579:53297373a894 | 123 | * \snippet qs_i2c_master_dma.c inf_loop |
mbed_official | 579:53297373a894 | 124 | */ |
mbed_official | 579:53297373a894 | 125 | /** |
mbed_official | 579:53297373a894 | 126 | * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> |
mbed_official | 579:53297373a894 | 127 | */ |