Stellaris Peripheral Driver Library User's Guide
Total Page:16
File Type:pdf, Size:1020Kb
Stellaris® Peripheral Driver Library USER’S GUIDE PDL-LM3S-UG-3416 Copyright © 2006-2008 Luminary Micro, Inc. Legal Disclaimers and Trademark Information INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH LUMINARY MICRO PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN LUMINARY MICRO’S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, LUMINARY MICRO ASSUMES NO LIABILITY WHATSOEVER, AND LUMINARY MICRO DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF LUMINARY MICRO’S PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICU- LAR PURPOSE, MERCHANTABILITY,OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. LUMINARY MICRO’S PRODUCTS ARE NOT INTENDED FOR USE IN MEDICAL, LIFE SAVING, OR LIFE-SUSTAINING APPLICATIONS. Luminary Micro may make changes to specifications and product descriptions at any time, without notice. Contact your local Luminary Micro sales office or your distributor to obtain the latest specifications and before placing your product order. Designers must not rely on the absence or characteristics of any features or instructions marked “reserved” or “undefined.” Luminary Micro reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them. Copyright © 2006-2008 Luminary Micro, Inc. All rights reserved. Stellaris, Luminary Micro, and the Luminary Micro logo are registered trademarks of Luminary Micro, Inc. or its subsidiaries in the United States and other countries. ARM and Thumb are registered trademarks and Cortex is a trademark of ARM Limited. Other names and brands may be claimed as the property of others. Luminary Micro, Inc. 108 Wild Basin, Suite 350 Austin, TX 78746 Main: +1-512-279-8800 Fax: +1-512-279-8879 http://www.luminarymicro.com Revision Information This is version 3416 of this document, last updated on September 29, 2008. 2 September 29, 2008 Stellaris Peripheral Driver Library User’s Guide Table of Contents Legal Disclaimers and Trademark Information ................................ 2 Revision Information ............................................... 2 1 Introduction ................................................. 9 2 Building The Code ............................................. 13 2.1 Required Software .............................................. 13 2.2 Building With Keil uVision .......................................... 13 2.3 Building with IAR Embedded Workbench ................................. 14 2.4 Building with CodeSourcery Sourcery G++ ................................ 14 2.5 Building with Code Red Technologies Tools ................................ 14 2.6 Building From The Command Line ..................................... 14 3 Boot Code .................................................. 17 4 Programming Model ............................................ 19 4.1 Introduction .................................................. 19 4.2 Direct Register Access Model ....................................... 19 4.3 Software Driver Model ............................................ 20 4.4 Combining The Models ........................................... 21 5 Analog Comparator ............................................ 23 5.1 Introduction .................................................. 23 5.2 API Functions ................................................ 23 5.3 Programming Example ........................................... 29 6 Analog to Digital Converter (ADC) .................................... 31 6.1 Introduction .................................................. 31 6.2 API Functions ................................................ 32 6.3 Programming Example ........................................... 43 7 Controller Area Network (CAN) ...................................... 45 7.1 Introduction .................................................. 45 7.2 API Functions ................................................ 45 7.3 Programming Example ........................................... 62 8 Ethernet Controller ............................................. 65 8.1 Introduction .................................................. 65 8.2 API Functions ................................................ 65 8.3 Programming Example ........................................... 78 9 Flash ..................................................... 79 9.1 Introduction .................................................. 79 9.2 API Functions ................................................ 79 9.3 Programming Example ........................................... 87 10 GPIO ..................................................... 89 10.1 Introduction .................................................. 89 10.2 API Functions ................................................ 89 10.3 Programming Example ........................................... 105 11 Hibernation Module ............................................ 107 11.1 Introduction .................................................. 107 11.2 API Functions ................................................ 107 11.3 Programming Example ........................................... 120 12 Inter-Integrated Circuit (I2C) ....................................... 125 September 29, 2008 3 Table of Contents 12.1 Introduction .................................................. 125 12.2 API Functions ................................................ 126 12.3 Programming Example ........................................... 140 13 Interrupt Controller (NVIC) ........................................ 141 13.1 Introduction .................................................. 141 13.2 API Functions ................................................ 142 13.3 Programming Example ........................................... 147 14 Memory Protection Unit (MPU) ...................................... 149 14.1 Introduction .................................................. 149 14.2 API Functions ................................................ 149 14.3 Programming Example ........................................... 156 15 Peripheral Pin Mapping .......................................... 159 15.1 Introduction .................................................. 159 15.2 API Functions ................................................ 159 15.3 Programming Example ........................................... 165 16 Pulse Width Modulator (PWM) ...................................... 167 16.1 Introduction .................................................. 167 16.2 API Functions ................................................ 167 16.3 Programming Example ........................................... 187 17 Quadrature Encoder (QEI) ........................................ 189 17.1 Introduction .................................................. 189 17.2 API Functions ................................................ 190 17.3 Programming Example ........................................... 198 18 Synchronous Serial Interface (SSI) ................................... 199 18.1 Introduction .................................................. 199 18.2 API Functions ................................................ 199 18.3 Programming Example ........................................... 208 19 System Control ............................................... 209 19.1 Introduction .................................................. 209 19.2 API Functions ................................................ 210 19.3 Programming Example ........................................... 231 20 System Tick (SysTick) ........................................... 233 20.1 Introduction .................................................. 233 20.2 API Functions ................................................ 233 20.3 Programming Example ........................................... 237 21 Timer ..................................................... 239 21.1 Introduction .................................................. 239 21.2 API Functions ................................................ 239 21.3 Programming Example ........................................... 251 22 UART ..................................................... 253 22.1 Introduction .................................................. 253 22.2 API Functions ................................................ 253 22.3 Programming Example ........................................... 267 23 uDMA Controller .............................................. 269 23.1 Introduction .................................................. 269 23.2 API Functions ................................................ 270 23.3 Programming Example ........................................... 284 24 USB Controller ............................................... 287 4 September 29, 2008 Stellaris Peripheral Driver Library User’s Guide 24.1 Introduction .................................................. 287 24.2 Using USB with the uDMA Controller ................................... 287 24.3 API Functions ................................................ 291 24.4 Programming Example ........................................... 319 25 Watchdog Timer .............................................. 321 25.1 Introduction .................................................. 321 25.2 API Functions ................................................ 321 25.3 Programming Example ........................................... 329 26 Using the ROM ..............................................