Avr-Libc Reference Manual 1.4.6
Total Page:16
File Type:pdf, Size:1020Kb
avr-libc Reference Manual 1.4.6 Generated by Doxygen 1.4.7 Tue May 15 14:56:11 2007 CONTENTS i Contents 1 AVR Libc 1 1.1 Introduction ............................... 1 1.2 General information about this library ................. 1 1.3 Supported Devices ........................... 2 1.4 avr-libc License ............................. 6 2 avr-libc Module Index 7 2.1 avr-libc Modules ............................ 7 3 avr-libc Data Structure Index 8 3.1 avr-libc Data Structures ......................... 8 4 avr-libc File Index 9 4.1 avr-libc File List ............................. 9 5 avr-libc Page Index 12 5.1 avr-libc Related Pages .......................... 12 6 avr-libc Module Documentation 13 6.1 <assert.h>: Diagnostics ........................ 13 6.1.1 Detailed Description ...................... 13 6.1.2 Define Documentation ..................... 13 6.2 <ctype.h>: Character Operations ................... 14 6.2.1 Detailed Description ...................... 14 6.2.2 Function Documentation .................... 15 6.3 <errno.h>: System Errors ....................... 17 6.3.1 Detailed Description ...................... 17 6.3.2 Define Documentation ..................... 17 6.4 <inttypes.h>: Integer Type conversions ................ 17 6.4.1 Detailed Description ...................... 17 6.4.2 Define Documentation ..................... 20 6.4.3 Typedef Documentation .................... 29 Generated on Tue May 15 14:56:11 2007 for avr-libc by Doxygen CONTENTS ii 6.5 <math.h>: Mathematics ........................ 29 6.5.1 Detailed Description ...................... 29 6.5.2 Define Documentation ..................... 30 6.5.3 Function Documentation .................... 31 6.6 <setjmp.h>: Non-local goto ...................... 34 6.6.1 Detailed Description ...................... 34 6.6.2 Function Documentation .................... 35 6.7 <stdint.h>: Standard Integer Types .................. 36 6.7.1 Detailed Description ...................... 36 6.7.2 Define Documentation ..................... 39 6.7.3 Typedef Documentation .................... 45 6.8 <stdio.h>: Standard IO facilities .................... 48 6.8.1 Detailed Description ...................... 48 6.8.2 Define Documentation ..................... 52 6.8.3 Function Documentation .................... 55 6.9 <stdlib.h>: General utilities ...................... 66 6.9.1 Detailed Description ...................... 66 6.9.2 Define Documentation ..................... 68 6.9.3 Typedef Documentation .................... 68 6.9.4 Function Documentation .................... 68 6.9.5 Variable Documentation .................... 77 6.10 <string.h>: Strings ........................... 77 6.10.1 Detailed Description ...................... 77 6.10.2 Define Documentation ..................... 78 6.10.3 Function Documentation .................... 79 6.11 <avr/boot.h>: Bootloader Support Utilities .............. 88 6.11.1 Detailed Description ...................... 88 6.11.2 Define Documentation ..................... 90 6.12 <avr/eeprom.h>: EEPROM handling ................. 94 6.12.1 Detailed Description ...................... 94 6.12.2 Define Documentation ..................... 95 Generated on Tue May 15 14:56:11 2007 for avr-libc by Doxygen CONTENTS iii 6.12.3 Function Documentation .................... 96 6.13 <avr/interrupt.h>: Interrupts ...................... 97 6.13.1 Detailed Description ...................... 97 6.13.2 Define Documentation ..................... 114 6.14 <avr/pgmspace.h>: Program Space Utilities ............. 116 6.14.1 Detailed Description ...................... 116 6.14.2 Define Documentation ..................... 118 6.14.3 Typedef Documentation .................... 120 6.14.4 Function Documentation .................... 122 6.15 <avr/power.h>: Power Reduction Management ............ 128 6.16 Additional notes from <avr/sfr_defs.h> ................ 131 6.17 <avr/sfr_defs.h>: Special function registers .............. 133 6.17.1 Detailed Description ...................... 133 6.17.2 Define Documentation ..................... 134 6.18 <avr/sleep.h>: Power Management and Sleep Modes ......... 136 6.18.1 Detailed Description ...................... 136 6.18.2 Define Documentation ..................... 137 6.18.3 Function Documentation .................... 138 6.19 <avr/version.h>: avr-libc version macros ............... 138 6.19.1 Detailed Description ...................... 138 6.19.2 Define Documentation ..................... 139 6.20 <avr/wdt.h>: Watchdog timer handling ................ 140 6.20.1 Detailed Description ...................... 140 6.20.2 Define Documentation ..................... 141 6.21 <util/crc16.h>: CRC Computations .................. 143 6.21.1 Detailed Description ...................... 143 6.21.2 Function Documentation .................... 144 6.22 <util/delay.h>: Convenience functions for busy-wait delay loops ... 147 6.22.1 Detailed Description ...................... 147 6.22.2 Function Documentation .................... 147 6.23 <util/delay_basic.h>: Basic busy-wait delay loops .......... 148 Generated on Tue May 15 14:56:11 2007 for avr-libc by Doxygen CONTENTS iv 6.23.1 Detailed Description ...................... 148 6.23.2 Function Documentation .................... 148 6.24 <util/parity.h>: Parity bit generation .................. 149 6.24.1 Detailed Description ...................... 149 6.24.2 Define Documentation ..................... 149 6.25 <util/twi.h>: TWI bit mask definitions ................ 150 6.25.1 Detailed Description ...................... 150 6.25.2 Define Documentation ..................... 151 6.26 <compat/deprecated.h>: Deprecated items .............. 154 6.26.1 Detailed Description ...................... 154 6.26.2 Define Documentation ..................... 155 6.26.3 Function Documentation .................... 157 6.27 <compat/ina90.h>: Compatibility with IAR EWB 3.x ........ 157 6.28 Demo projects .............................. 158 6.28.1 Detailed Description ...................... 158 6.29 Combining C and assembly source files ................ 159 6.29.1 Hardware setup ......................... 160 6.29.2 A code walkthrough ...................... 160 6.29.3 The source code ........................ 162 6.30 A simple project ............................. 162 6.30.1 The Project ........................... 162 6.30.2 The Source Code ........................ 165 6.30.3 Compiling and Linking ..................... 166 6.30.4 Examining the Object File ................... 167 6.30.5 Linker Map Files ........................ 171 6.30.6 Generating Intel Hex Files ................... 173 6.30.7 Letting Make Build the Project ................. 174 6.30.8 Reference to the source code .................. 176 6.31 A more sophisticated project ...................... 177 6.31.1 Hardware setup ......................... 177 6.31.2 Functional overview ...................... 180 Generated on Tue May 15 14:56:11 2007 for avr-libc by Doxygen CONTENTS v 6.31.3 A code walkthrough ...................... 181 6.31.4 The source code ........................ 184 6.32 Using the standard IO facilities ..................... 184 6.32.1 Hardware setup ......................... 184 6.32.2 Functional overview ...................... 186 6.32.3 A code walkthrough ...................... 186 6.32.4 The source code ........................ 191 6.33 Example using the two-wire interface (TWI) .............. 192 6.33.1 Introduction into TWI ..................... 192 6.33.2 The TWI example project ................... 192 6.33.3 The Source Code ........................ 193 7 avr-libc Data Structure Documentation 197 7.1 div_t Struct Reference ......................... 197 7.1.1 Detailed Description ...................... 197 7.1.2 Field Documentation ...................... 197 7.2 ldiv_t Struct Reference ......................... 197 7.2.1 Detailed Description ...................... 197 7.2.2 Field Documentation ...................... 197 8 avr-libc File Documentation 198 8.1 assert.h File Reference ......................... 198 8.1.1 Detailed Description ...................... 198 8.2 atoi.S File Reference .......................... 198 8.2.1 Detailed Description ...................... 198 8.3 atol.S File Reference .......................... 198 8.3.1 Detailed Description ...................... 198 8.4 boot.h File Reference .......................... 199 8.4.1 Detailed Description ...................... 199 8.4.2 Define Documentation ..................... 200 8.5 crc16.h File Reference ......................... 205 8.5.1 Detailed Description ...................... 205 Generated on Tue May 15 14:56:11 2007 for avr-libc by Doxygen CONTENTS vi 8.6 ctype.h File Reference ......................... 205 8.6.1 Detailed Description ...................... 205 8.7 delay.h File Reference ......................... 206 8.7.1 Detailed Description ...................... 206 8.8 delay_basic.h File Reference ...................... 206 8.8.1 Detailed Description ...................... 206 8.9 eeprom.h File Reference ........................ 207 8.9.1 Detailed Description ...................... 207 8.10 errno.h File Reference ......................... 208 8.10.1 Detailed Description ...................... 208 8.11 fdevopen.c File Reference ....................... 208 8.11.1 Detailed Description ...................... 208 8.12 ffs.S File Reference ........................... 209 8.12.1 Detailed Description ...................... 209 8.13 ffsl.S File Reference .......................... 209 8.13.1 Detailed Description ...................... 209 8.14 ffsll.S File Reference .......................... 209