From df7dd1a6e07112c16b9aa6cd7cb2bc601b09e63a Mon Sep 17 00:00:00 2001 From: "Michael D. M. Dryden" Date: Tue, 10 Feb 2015 00:04:11 -0500 Subject: [PATCH] Convert to use make to build. --- .gitignore | 8 + .../Makefile.avr.in => DSTAT-temp/Makefile | 928 ++--- DSTAT-temp/config.mk | 109 + DSTAT-temp/doxySettings.xml | 11 - DSTAT-temp/doxyfile | 8 +- DSTAT1/DSTAT1.cproj | 940 ----- DSTAT1/atmel_devices_cdc.inf | 119 - DSTAT1/src/ads1255.c | 493 --- DSTAT1/src/ads1255.h | 82 - DSTAT1/src/algorithm | 40 - DSTAT1/src/asf.h | 120 - DSTAT1/src/asf/common/boards/board.h | 264 -- .../src/asf/common/boards/user_board/init.c | 17 - .../asf/common/boards/user_board/user_board.h | 17 - DSTAT1/src/asf/common/services/clock/genclk.h | 172 - DSTAT1/src/asf/common/services/clock/osc.h | 158 - DSTAT1/src/asf/common/services/clock/pll.h | 314 -- DSTAT1/src/asf/common/services/clock/sysclk.h | 163 - .../src/asf/common/services/clock/xmega/osc.h | 462 --- .../src/asf/common/services/clock/xmega/pll.h | 260 -- .../asf/common/services/clock/xmega/sysclk.c | 227 -- .../asf/common/services/clock/xmega/sysclk.h | 1098 ------ DSTAT1/src/asf/common/services/delay/delay.h | 133 - .../services/delay/xmega/cycle_counter.h | 111 - .../services/hugemem/avr8/avr8_hugemem.c | 195 - .../common/services/hugemem/avr8/hugemem.h | 163 - .../common/services/hugemem/generic/hugemem.h | 112 - .../src/asf/common/services/hugemem/hugemem.h | 140 - .../src/asf/common/services/ioport/ioport.h | 515 --- .../asf/common/services/ioport/xmega/ioport.h | 337 -- .../services/ioport/xmega/ioport_compat.c | 70 - .../services/ioport/xmega/ioport_compat.h | 315 -- .../asf/common/services/sleepmgr/sleepmgr.h | 236 -- .../common/services/sleepmgr/xmega/sleepmgr.c | 61 - .../common/services/sleepmgr/xmega/sleepmgr.h | 116 - .../src/asf/common/services/spi/spi_master.h | 266 -- .../src/asf/common/services/spi/usart_spi.h | 97 - .../services/spi/xmega_spi/spi_master.c | 187 - .../services/spi/xmega_spi/spi_master.h | 257 -- .../services/spi/xmega_usart_spi/usart_spi.c | 135 - .../services/spi/xmega_usart_spi/usart_spi.h | 237 -- .../services/usb/class/cdc/device/udi_cdc.c | 1232 ------ .../services/usb/class/cdc/device/udi_cdc.h | 507 --- .../usb/class/cdc/device/udi_cdc_conf.h | 137 - .../usb/class/cdc/device/udi_cdc_desc.c | 212 -- .../services/usb/class/cdc/usb_protocol_cdc.h | 313 -- DSTAT1/src/asf/common/services/usb/udc/udc.c | 1084 ------ DSTAT1/src/asf/common/services/usb/udc/udc.h | 242 -- .../asf/common/services/usb/udc/udc_desc.h | 129 - DSTAT1/src/asf/common/services/usb/udc/udd.h | 390 -- DSTAT1/src/asf/common/services/usb/udc/udi.h | 128 - .../src/asf/common/services/usb/usb_atmel.h | 180 - .../asf/common/services/usb/usb_protocol.h | 408 -- DSTAT1/src/asf/common/utils/interrupt.h | 135 - .../common/utils/interrupt/interrupt_avr8.h | 136 - DSTAT1/src/asf/common/utils/parts.h | 671 ---- DSTAT1/src/asf/common/utils/stdio/read.c | 161 - .../common/utils/stdio/stdio_usb/stdio_usb.c | 120 - .../common/utils/stdio/stdio_usb/stdio_usb.h | 126 - DSTAT1/src/asf/common/utils/stdio/write.c | 141 - DSTAT1/src/asf/xmega/drivers/cpu/ccp.h | 118 - DSTAT1/src/asf/xmega/drivers/cpu/ccp.s | 98 - .../asf/xmega/drivers/cpu/xmega_reset_cause.h | 103 - DSTAT1/src/asf/xmega/drivers/dma/dma.c | 280 -- DSTAT1/src/asf/xmega/drivers/dma/dma.h | 1394 ------- DSTAT1/src/asf/xmega/drivers/ioport/ioport.c | 65 - DSTAT1/src/asf/xmega/drivers/ioport/ioport.h | 421 --- DSTAT1/src/asf/xmega/drivers/nvm/nvm.c | 755 ---- DSTAT1/src/asf/xmega/drivers/nvm/nvm.h | 1050 ------ DSTAT1/src/asf/xmega/drivers/nvm/nvm_asm.s | 195 - DSTAT1/src/asf/xmega/drivers/pmic/pmic.h | 347 -- DSTAT1/src/asf/xmega/drivers/rtc/rtc.c | 226 -- DSTAT1/src/asf/xmega/drivers/rtc/rtc.h | 292 -- DSTAT1/src/asf/xmega/drivers/sleep/sleep.h | 164 - DSTAT1/src/asf/xmega/drivers/spi/spi.c | 114 - DSTAT1/src/asf/xmega/drivers/spi/spi.h | 161 - DSTAT1/src/asf/xmega/drivers/tc/tc.c | 1076 ------ DSTAT1/src/asf/xmega/drivers/tc/tc.h | 1610 -------- DSTAT1/src/asf/xmega/drivers/usart/usart.c | 458 --- DSTAT1/src/asf/xmega/drivers/usart/usart.h | 553 --- DSTAT1/src/asf/xmega/drivers/usb/usb_device.c | 1448 -------- DSTAT1/src/asf/xmega/drivers/usb/usb_device.h | 385 -- DSTAT1/src/asf/xmega/utils/assembler.h | 154 - DSTAT1/src/asf/xmega/utils/assembler/gas.h | 119 - .../asf/xmega/utils/bit_handling/clz_ctz.h | 210 -- DSTAT1/src/asf/xmega/utils/compiler.h | 1023 ----- DSTAT1/src/asf/xmega/utils/parts.h | 175 - .../asf/xmega/utils/preprocessor/mrepeat.h | 333 -- .../xmega/utils/preprocessor/preprocessor.h | 49 - .../asf/xmega/utils/preprocessor/stringz.h | 79 - .../src/asf/xmega/utils/preprocessor/tpaste.h | 99 - DSTAT1/src/asf/xmega/utils/progmem.h | 97 - DSTAT1/src/asf/xmega/utils/status_codes.h | 96 - DSTAT1/src/avr-stl/include/algorithm | 40 - DSTAT1/src/avr-stl/include/avr_config.h | 41 - DSTAT1/src/avr-stl/include/basic_definitions | 48 - DSTAT1/src/avr-stl/include/bitset | 1078 ------ DSTAT1/src/avr-stl/include/cctype | 37 - DSTAT1/src/avr-stl/include/char_traits.h | 166 - DSTAT1/src/avr-stl/include/concept_checks.h | 811 ---- .../src/avr-stl/include/container_concepts.h | 249 -- DSTAT1/src/avr-stl/include/cstddef | 58 - DSTAT1/src/avr-stl/include/deque | 41 - DSTAT1/src/avr-stl/include/functional | 26 - DSTAT1/src/avr-stl/include/hash_map | 40 - DSTAT1/src/avr-stl/include/hash_set | 40 - DSTAT1/src/avr-stl/include/iomanip | 173 - DSTAT1/src/avr-stl/include/ios | 525 --- DSTAT1/src/avr-stl/include/iosfwd | 110 - DSTAT1/src/avr-stl/include/iostream | 105 - DSTAT1/src/avr-stl/include/istream | 601 --- DSTAT1/src/avr-stl/include/istream_helpers | 344 -- DSTAT1/src/avr-stl/include/iterator | 47 - DSTAT1/src/avr-stl/include/lcdostream | 192 - DSTAT1/src/avr-stl/include/limits | 537 --- DSTAT1/src/avr-stl/include/list | 40 - DSTAT1/src/avr-stl/include/locale | 88 - DSTAT1/src/avr-stl/include/map | 40 - DSTAT1/src/avr-stl/include/memory | 134 - DSTAT1/src/avr-stl/include/new | 17 - DSTAT1/src/avr-stl/include/new.cpp | 41 - DSTAT1/src/avr-stl/include/numeric | 51 - DSTAT1/src/avr-stl/include/ostream | 497 --- DSTAT1/src/avr-stl/include/ostream_helpers | 537 --- DSTAT1/src/avr-stl/include/queue | 45 - .../src/avr-stl/include/sequence_concepts.h | 204 - DSTAT1/src/avr-stl/include/serstream | 293 -- DSTAT1/src/avr-stl/include/set | 40 - DSTAT1/src/avr-stl/include/slist | 28 - DSTAT1/src/avr-stl/include/sstream | 384 -- DSTAT1/src/avr-stl/include/stack | 41 - DSTAT1/src/avr-stl/include/stl_algo.h | 3297 ----------------- DSTAT1/src/avr-stl/include/stl_algobase.h | 698 ---- DSTAT1/src/avr-stl/include/stl_alloc.h | 945 ----- DSTAT1/src/avr-stl/include/stl_bvector.h | 897 ----- DSTAT1/src/avr-stl/include/stl_config.h | 601 --- DSTAT1/src/avr-stl/include/stl_construct.h | 124 - DSTAT1/src/avr-stl/include/stl_ctraits_fns.h | 69 - DSTAT1/src/avr-stl/include/stl_deque.h | 1664 --------- DSTAT1/src/avr-stl/include/stl_function.h | 729 ---- DSTAT1/src/avr-stl/include/stl_hash_fun.h | 93 - DSTAT1/src/avr-stl/include/stl_hash_map.h | 532 --- DSTAT1/src/avr-stl/include/stl_hash_set.h | 514 --- DSTAT1/src/avr-stl/include/stl_hashtable.h | 1080 ------ DSTAT1/src/avr-stl/include/stl_heap.h | 297 -- DSTAT1/src/avr-stl/include/stl_iterator.h | 965 ----- .../src/avr-stl/include/stl_iterator_base.h | 367 -- DSTAT1/src/avr-stl/include/stl_list.h | 885 ----- DSTAT1/src/avr-stl/include/stl_map.h | 295 -- DSTAT1/src/avr-stl/include/stl_multimap.h | 282 -- DSTAT1/src/avr-stl/include/stl_multiset.h | 274 -- DSTAT1/src/avr-stl/include/stl_numeric.h | 255 -- DSTAT1/src/avr-stl/include/stl_pair.h | 101 - DSTAT1/src/avr-stl/include/stl_queue.h | 243 -- DSTAT1/src/avr-stl/include/stl_range_errors.h | 71 - .../avr-stl/include/stl_raw_storage_iter.h | 81 - DSTAT1/src/avr-stl/include/stl_relops.h | 62 - DSTAT1/src/avr-stl/include/stl_set.h | 268 -- DSTAT1/src/avr-stl/include/stl_slist.h | 1048 ------ DSTAT1/src/avr-stl/include/stl_stack.h | 143 - DSTAT1/src/avr-stl/include/stl_string_fwd.h | 40 - DSTAT1/src/avr-stl/include/stl_tempbuf.h | 162 - DSTAT1/src/avr-stl/include/stl_tree.h | 1369 ------- .../src/avr-stl/include/stl_uninitialized.h | 279 -- DSTAT1/src/avr-stl/include/stl_vector.h | 879 ----- DSTAT1/src/avr-stl/include/streambuf | 329 -- DSTAT1/src/avr-stl/include/string | 2453 ------------ DSTAT1/src/avr-stl/include/type_traits.h | 373 -- DSTAT1/src/avr-stl/include/utility | 38 - DSTAT1/src/avr-stl/include/valarray | 1780 --------- DSTAT1/src/avr-stl/include/vector | 42 - DSTAT1/src/config/conf_board.h | 28 - DSTAT1/src/config/conf_clock.h | 93 - DSTAT1/src/config/conf_rtc.h | 49 - DSTAT1/src/config/conf_sleepmgr.h | 47 - DSTAT1/src/config/conf_spi_master.h | 47 - DSTAT1/src/config/conf_usart_spi.h | 45 - DSTAT1/src/config/conf_usb.h | 143 - DSTAT1/src/main.cpp | 1416 ------- DSTAT1/src/main.h | 54 - DSTAT1/src/main1.c | 206 - DSTAT1/src/max5443.c | 89 - DSTAT1/src/max5443.h | 18 - 183 files changed, 604 insertions(+), 63936 deletions(-) rename DSTAT1/src/asf/common/utils/make/Makefile.avr.in => DSTAT-temp/Makefile (85%) create mode 100644 DSTAT-temp/config.mk delete mode 100644 DSTAT-temp/doxySettings.xml delete mode 100644 DSTAT1/DSTAT1.cproj delete mode 100644 DSTAT1/atmel_devices_cdc.inf delete mode 100644 DSTAT1/src/ads1255.c delete mode 100644 DSTAT1/src/ads1255.h delete mode 100644 DSTAT1/src/algorithm delete mode 100644 DSTAT1/src/asf.h delete mode 100644 DSTAT1/src/asf/common/boards/board.h delete mode 100644 DSTAT1/src/asf/common/boards/user_board/init.c delete mode 100644 DSTAT1/src/asf/common/boards/user_board/user_board.h delete mode 100644 DSTAT1/src/asf/common/services/clock/genclk.h delete mode 100644 DSTAT1/src/asf/common/services/clock/osc.h delete mode 100644 DSTAT1/src/asf/common/services/clock/pll.h delete mode 100644 DSTAT1/src/asf/common/services/clock/sysclk.h delete mode 100644 DSTAT1/src/asf/common/services/clock/xmega/osc.h delete mode 100644 DSTAT1/src/asf/common/services/clock/xmega/pll.h delete mode 100644 DSTAT1/src/asf/common/services/clock/xmega/sysclk.c delete mode 100644 DSTAT1/src/asf/common/services/clock/xmega/sysclk.h delete mode 100644 DSTAT1/src/asf/common/services/delay/delay.h delete mode 100644 DSTAT1/src/asf/common/services/delay/xmega/cycle_counter.h delete mode 100644 DSTAT1/src/asf/common/services/hugemem/avr8/avr8_hugemem.c delete mode 100644 DSTAT1/src/asf/common/services/hugemem/avr8/hugemem.h delete mode 100644 DSTAT1/src/asf/common/services/hugemem/generic/hugemem.h delete mode 100644 DSTAT1/src/asf/common/services/hugemem/hugemem.h delete mode 100644 DSTAT1/src/asf/common/services/ioport/ioport.h delete mode 100644 DSTAT1/src/asf/common/services/ioport/xmega/ioport.h delete mode 100644 DSTAT1/src/asf/common/services/ioport/xmega/ioport_compat.c delete mode 100644 DSTAT1/src/asf/common/services/ioport/xmega/ioport_compat.h delete mode 100644 DSTAT1/src/asf/common/services/sleepmgr/sleepmgr.h delete mode 100644 DSTAT1/src/asf/common/services/sleepmgr/xmega/sleepmgr.c delete mode 100644 DSTAT1/src/asf/common/services/sleepmgr/xmega/sleepmgr.h delete mode 100644 DSTAT1/src/asf/common/services/spi/spi_master.h delete mode 100644 DSTAT1/src/asf/common/services/spi/usart_spi.h delete mode 100644 DSTAT1/src/asf/common/services/spi/xmega_spi/spi_master.c delete mode 100644 DSTAT1/src/asf/common/services/spi/xmega_spi/spi_master.h delete mode 100644 DSTAT1/src/asf/common/services/spi/xmega_usart_spi/usart_spi.c delete mode 100644 DSTAT1/src/asf/common/services/spi/xmega_usart_spi/usart_spi.h delete mode 100644 DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc.c delete mode 100644 DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc.h delete mode 100644 DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc_conf.h delete mode 100644 DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc_desc.c delete mode 100644 DSTAT1/src/asf/common/services/usb/class/cdc/usb_protocol_cdc.h delete mode 100644 DSTAT1/src/asf/common/services/usb/udc/udc.c delete mode 100644 DSTAT1/src/asf/common/services/usb/udc/udc.h delete mode 100644 DSTAT1/src/asf/common/services/usb/udc/udc_desc.h delete mode 100644 DSTAT1/src/asf/common/services/usb/udc/udd.h delete mode 100644 DSTAT1/src/asf/common/services/usb/udc/udi.h delete mode 100644 DSTAT1/src/asf/common/services/usb/usb_atmel.h delete mode 100644 DSTAT1/src/asf/common/services/usb/usb_protocol.h delete mode 100644 DSTAT1/src/asf/common/utils/interrupt.h delete mode 100644 DSTAT1/src/asf/common/utils/interrupt/interrupt_avr8.h delete mode 100644 DSTAT1/src/asf/common/utils/parts.h delete mode 100644 DSTAT1/src/asf/common/utils/stdio/read.c delete mode 100644 DSTAT1/src/asf/common/utils/stdio/stdio_usb/stdio_usb.c delete mode 100644 DSTAT1/src/asf/common/utils/stdio/stdio_usb/stdio_usb.h delete mode 100644 DSTAT1/src/asf/common/utils/stdio/write.c delete mode 100644 DSTAT1/src/asf/xmega/drivers/cpu/ccp.h delete mode 100644 DSTAT1/src/asf/xmega/drivers/cpu/ccp.s delete mode 100644 DSTAT1/src/asf/xmega/drivers/cpu/xmega_reset_cause.h delete mode 100644 DSTAT1/src/asf/xmega/drivers/dma/dma.c delete mode 100644 DSTAT1/src/asf/xmega/drivers/dma/dma.h delete mode 100644 DSTAT1/src/asf/xmega/drivers/ioport/ioport.c delete mode 100644 DSTAT1/src/asf/xmega/drivers/ioport/ioport.h delete mode 100644 DSTAT1/src/asf/xmega/drivers/nvm/nvm.c delete mode 100644 DSTAT1/src/asf/xmega/drivers/nvm/nvm.h delete mode 100644 DSTAT1/src/asf/xmega/drivers/nvm/nvm_asm.s delete mode 100644 DSTAT1/src/asf/xmega/drivers/pmic/pmic.h delete mode 100644 DSTAT1/src/asf/xmega/drivers/rtc/rtc.c delete mode 100644 DSTAT1/src/asf/xmega/drivers/rtc/rtc.h delete mode 100644 DSTAT1/src/asf/xmega/drivers/sleep/sleep.h delete mode 100644 DSTAT1/src/asf/xmega/drivers/spi/spi.c delete mode 100644 DSTAT1/src/asf/xmega/drivers/spi/spi.h delete mode 100644 DSTAT1/src/asf/xmega/drivers/tc/tc.c delete mode 100644 DSTAT1/src/asf/xmega/drivers/tc/tc.h delete mode 100644 DSTAT1/src/asf/xmega/drivers/usart/usart.c delete mode 100644 DSTAT1/src/asf/xmega/drivers/usart/usart.h delete mode 100644 DSTAT1/src/asf/xmega/drivers/usb/usb_device.c delete mode 100644 DSTAT1/src/asf/xmega/drivers/usb/usb_device.h delete mode 100644 DSTAT1/src/asf/xmega/utils/assembler.h delete mode 100644 DSTAT1/src/asf/xmega/utils/assembler/gas.h delete mode 100644 DSTAT1/src/asf/xmega/utils/bit_handling/clz_ctz.h delete mode 100644 DSTAT1/src/asf/xmega/utils/compiler.h delete mode 100644 DSTAT1/src/asf/xmega/utils/parts.h delete mode 100644 DSTAT1/src/asf/xmega/utils/preprocessor/mrepeat.h delete mode 100644 DSTAT1/src/asf/xmega/utils/preprocessor/preprocessor.h delete mode 100644 DSTAT1/src/asf/xmega/utils/preprocessor/stringz.h delete mode 100644 DSTAT1/src/asf/xmega/utils/preprocessor/tpaste.h delete mode 100644 DSTAT1/src/asf/xmega/utils/progmem.h delete mode 100644 DSTAT1/src/asf/xmega/utils/status_codes.h delete mode 100644 DSTAT1/src/avr-stl/include/algorithm delete mode 100644 DSTAT1/src/avr-stl/include/avr_config.h delete mode 100644 DSTAT1/src/avr-stl/include/basic_definitions delete mode 100644 DSTAT1/src/avr-stl/include/bitset delete mode 100644 DSTAT1/src/avr-stl/include/cctype delete mode 100644 DSTAT1/src/avr-stl/include/char_traits.h delete mode 100644 DSTAT1/src/avr-stl/include/concept_checks.h delete mode 100644 DSTAT1/src/avr-stl/include/container_concepts.h delete mode 100644 DSTAT1/src/avr-stl/include/cstddef delete mode 100644 DSTAT1/src/avr-stl/include/deque delete mode 100644 DSTAT1/src/avr-stl/include/functional delete mode 100644 DSTAT1/src/avr-stl/include/hash_map delete mode 100644 DSTAT1/src/avr-stl/include/hash_set delete mode 100644 DSTAT1/src/avr-stl/include/iomanip delete mode 100644 DSTAT1/src/avr-stl/include/ios delete mode 100644 DSTAT1/src/avr-stl/include/iosfwd delete mode 100644 DSTAT1/src/avr-stl/include/iostream delete mode 100644 DSTAT1/src/avr-stl/include/istream delete mode 100644 DSTAT1/src/avr-stl/include/istream_helpers delete mode 100644 DSTAT1/src/avr-stl/include/iterator delete mode 100644 DSTAT1/src/avr-stl/include/lcdostream delete mode 100644 DSTAT1/src/avr-stl/include/limits delete mode 100644 DSTAT1/src/avr-stl/include/list delete mode 100644 DSTAT1/src/avr-stl/include/locale delete mode 100644 DSTAT1/src/avr-stl/include/map delete mode 100644 DSTAT1/src/avr-stl/include/memory delete mode 100644 DSTAT1/src/avr-stl/include/new delete mode 100644 DSTAT1/src/avr-stl/include/new.cpp delete mode 100644 DSTAT1/src/avr-stl/include/numeric delete mode 100644 DSTAT1/src/avr-stl/include/ostream delete mode 100644 DSTAT1/src/avr-stl/include/ostream_helpers delete mode 100644 DSTAT1/src/avr-stl/include/queue delete mode 100644 DSTAT1/src/avr-stl/include/sequence_concepts.h delete mode 100644 DSTAT1/src/avr-stl/include/serstream delete mode 100644 DSTAT1/src/avr-stl/include/set delete mode 100644 DSTAT1/src/avr-stl/include/slist delete mode 100644 DSTAT1/src/avr-stl/include/sstream delete mode 100644 DSTAT1/src/avr-stl/include/stack delete mode 100644 DSTAT1/src/avr-stl/include/stl_algo.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_algobase.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_alloc.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_bvector.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_config.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_construct.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_ctraits_fns.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_deque.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_function.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_hash_fun.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_hash_map.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_hash_set.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_hashtable.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_heap.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_iterator.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_iterator_base.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_list.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_map.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_multimap.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_multiset.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_numeric.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_pair.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_queue.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_range_errors.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_raw_storage_iter.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_relops.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_set.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_slist.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_stack.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_string_fwd.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_tempbuf.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_tree.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_uninitialized.h delete mode 100644 DSTAT1/src/avr-stl/include/stl_vector.h delete mode 100644 DSTAT1/src/avr-stl/include/streambuf delete mode 100644 DSTAT1/src/avr-stl/include/string delete mode 100644 DSTAT1/src/avr-stl/include/type_traits.h delete mode 100644 DSTAT1/src/avr-stl/include/utility delete mode 100644 DSTAT1/src/avr-stl/include/valarray delete mode 100644 DSTAT1/src/avr-stl/include/vector delete mode 100644 DSTAT1/src/config/conf_board.h delete mode 100644 DSTAT1/src/config/conf_clock.h delete mode 100644 DSTAT1/src/config/conf_rtc.h delete mode 100644 DSTAT1/src/config/conf_sleepmgr.h delete mode 100644 DSTAT1/src/config/conf_spi_master.h delete mode 100644 DSTAT1/src/config/conf_usart_spi.h delete mode 100644 DSTAT1/src/config/conf_usb.h delete mode 100644 DSTAT1/src/main.cpp delete mode 100644 DSTAT1/src/main.h delete mode 100644 DSTAT1/src/main1.c delete mode 100644 DSTAT1/src/max5443.c delete mode 100644 DSTAT1/src/max5443.h diff --git a/.gitignore b/.gitignore index 2d1836a..f0feb21 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,11 @@ obj/ _ReSharper*/ [Tt]est[Rr]esult* DSTAT-temp/doxygen/ +*.bin +*.elf +*.hex +*.lss +*.map +*.sym +*.d +*.o diff --git a/DSTAT1/src/asf/common/utils/make/Makefile.avr.in b/DSTAT-temp/Makefile similarity index 85% rename from DSTAT1/src/asf/common/utils/make/Makefile.avr.in rename to DSTAT-temp/Makefile index f6742f3..f190753 100644 --- a/DSTAT1/src/asf/common/utils/make/Makefile.avr.in +++ b/DSTAT-temp/Makefile @@ -1,445 +1,483 @@ -# List of available make goals: -# -# all Default target, builds the project -# clean Clean up the project -# rebuild Rebuild the project -# -# doc Build the documentation -# cleandoc Clean up the documentation -# rebuilddoc Rebuild the documentation -# -# -# Copyright (c) 2009-2010 Atmel Corporation. All rights reserved. -# -# \asf_license_start -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# 3. The name of Atmel may not be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# 4. This software may only be redistributed and used in connection with an -# Atmel microcontroller product. -# -# THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE -# EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# \asf_license_stop -# - -# Include the config.mk file from the current working path, e.g., where the -# user called make. -include config.mk - -# Tool to use to generate documentation from the source code -DOCGEN ?= doxygen - -# Look for source files relative to the top-level source directory -VPATH := $(PRJ_PATH) - -# Output target file -target := $(TARGET) - -# Output project name (target name minus suffix) -project := $(basename $(target)) - -# Output target file (typically ELF or static library) -ifeq ($(suffix $(target)),.a) -target_type := lib -else -ifeq ($(suffix $(target)),.elf) -target_type := elf -else -$(error "Target type $(target_type) is not supported") -endif -endif - -# Allow override of operating system detection. The user can add OS=Linux or -# OS=Windows on the command line to explicit set the host OS. -# -# This allows to work around broken uname utility on certain systems. -ifdef OS - ifeq ($(strip $(OS)), Linux) - os_type := Linux - endif - ifeq ($(strip $(OS)), Windows) - os_type := windows32_64 - endif -endif - -os_type ?= $(strip $(shell uname)) - -ifeq ($(os_type),windows32) -os := Windows -else -ifeq ($(os_type),windows64) -os := Windows -else -ifeq ($(os_type),windows32_64) -os ?= Windows -else -ifeq ($(os_type),) -os := Windows -else -# Default to Linux style operating system. Both Cygwin and mingw are fully -# compatible (for this Makefile) with Linux. -os := Linux -endif -endif -endif -endif - -# Output documentation directory and configuration file. -docdir := ../doxygen/html -doccfg := ../doxygen/doxyfile.doxygen - -CROSS ?= avr- -AR := $(CROSS)ar -AS := $(CROSS)as -CC := $(CROSS)gcc -CPP := $(CROSS)gcc -E -CXX := $(CROSS)g++ -LD := $(CROSS)g++ -NM := $(CROSS)nm -OBJCOPY := $(CROSS)objcopy -OBJDUMP := $(CROSS)objdump -SIZE := $(CROSS)size - -RM := rm -ifeq ($(os),Windows) -RMDIR := rmdir /S /Q -else -RMDIR := rmdir -p --ignore-fail-on-non-empty -endif - -# Strings for beautifying output -MSG_CLEAN_FILES = "RM *.o *.d" -MSG_CLEAN_DIRS = "RMDIR $(strip $(clean-dirs))" -MSG_CLEAN_DOC = "RMDIR $(docdir)" -MSG_MKDIR = "MKDIR $(dir $@)" - -MSG_INFO = "INFO " - -MSG_ARCHIVING = "AR $@" -MSG_ASSEMBLING = "AS $@" -MSG_BINARY_IMAGE = "OBJCOPY $@" -MSG_COMPILING = "CC $@" -MSG_COMPILING_CXX = "CXX $@" -MSG_EEPROM_IMAGE = "OBJCOPY $@" -MSG_EXTENDED_LISTING = "OBJDUMP $@" -MSG_IHEX_IMAGE = "OBJCOPY $@" -MSG_LINKING = "LN $@" -MSG_PREPROCESSING = "CPP $@" -MSG_SIZE = "SIZE $@" -MSG_SYMBOL_TABLE = "NM $@" - -MSG_GENERATING_DOC = "DOXYGEN $(docdir)" - -# Don't use make's built-in rules and variables -MAKEFLAGS += -rR - -# Don't print 'Entering directory ...' -MAKEFLAGS += --no-print-directory - -# Function for reversing the order of a list -reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1)) - -# Hide command output by default, but allow the user to override this -# by adding V=1 on the command line. -# -# This is inspired by the Kbuild system used by the Linux kernel. -ifdef V - ifeq ("$(origin V)", "command line") - VERBOSE = $(V) - endif -endif -ifndef VERBOSE - VERBOSE = 0 -endif - -ifeq ($(VERBOSE), 1) - Q = -else - Q = @ -endif - -arflags-gnu-y := $(ARFLAGS) -asflags-gnu-y := $(ASFLAGS) -cflags-gnu-y := $(CFLAGS) -cxxflags-gnu-y := $(CXXFLAGS) -cppflags-gnu-y := $(CPPFLAGS) -cpuflags-gnu-y := -dbgflags-gnu-y := $(DBGFLAGS) -libflags-gnu-y := $(foreach LIB,$(LIBS),-l$(LIB)) -ldflags-gnu-y := $(LDFLAGS) -flashflags-gnu-y := $(FLASHFLAGS) -eepromflags-gnu-y := $(EEPROMFLAGS) -clean-files := -clean-dirs := - -clean-files += $(wildcard $(target) $(project).map) -clean-files += $(wildcard $(project).hex $(project).eep) -clean-files += $(wildcard $(project).lss $(project).sym) -clean-files += $(wildcard $(build)) - -# Use pipes instead of temporary files for communication between processes -cflags-gnu-y += -pipe -asflags-gnu-y += -pipe -ldflags-gnu-y += -pipe - -# Archiver flags. -arflags-gnu-y += rcs - -# Always enable warnings. And be very careful about implicit -# declarations. -cflags-gnu-y += -Wall -Wstrict-prototypes -Wmissing-prototypes -cflags-gnu-y += -Werror-implicit-function-declaration -cxxflags-gnu-y += -Wall -# IAR doesn't allow arithmetic on void pointers, so warn about that. -cflags-gnu-y += -Wpointer-arith -cxxflags-gnu-y += -Wpointer-arith - -# Preprocessor flags. -cppflags-gnu-y += $(foreach INC,$(addprefix $(PRJ_PATH)/,$(INC_PATH)),-I$(INC)) -asflags-gnu-y += $(foreach INC,$(addprefix $(PRJ_PATH)/,$(INC_PATH)),'-Wa,-I$(INC)') - -# CPU specific flags. -cpuflags-gnu-y += -mmcu=$(MCU) - -# Dependency file flags. -depflags = -MD -MP -MQ $@ - -# Debug specific flags. -ifdef BUILD_DEBUG_LEVEL -dbgflags-gnu-y += -g$(BUILD_DEBUG_LEVEL) -else -dbgflags-gnu-y += -gdwarf-2 -endif - -# Optimization specific flags. -ifdef BUILD_OPTIMIZATION -optflags-gnu-y = -O$(BUILD_OPTIMIZATION) -else -optflags-gnu-y = $(OPTIMIZATION) -endif - -# Relax compilation and linking. -cflags-gnu-y += -mrelax -cxxflags-gnu-y += -mrelax -asflags-gnu-y += -mrelax -ldflags-gnu-y += -Wl,--relax - -# Always preprocess assembler files. -asflags-gnu-y += -x assembler-with-cpp -# Compile C files using the GNU99 standard. -cflags-gnu-y += -std=gnu99 -# Compile C++ files using the GNU++98 standard. -cxxflags-gnu-y += -std=gnu++98 - -# Use unsigned character type when compiling. -cflags-gnu-y += -funsigned-char -cxxflags-gnu-y += -funsigned-char - -# Separate each function and data into its own separate section to allow -# garbage collection of unused sections. -cflags-gnu-y += -ffunction-sections -fdata-sections -cxxflags-gnu-y += -ffunction-sections -fdata-sections - -# Garbage collect unreferred sections when linking. -ldflags-gnu-y += -Wl,--gc-sections - -# Output a link map file and a cross reference table -ldflags-gnu-y += -Wl,-Map=$(project).map,--cref - -# Add library search paths relative to the top level directory. -ldflags-gnu-y += $(foreach _LIB_PATH,$(addprefix $(PRJ_PATH)/,$(LIB_PATH)),-L$(_LIB_PATH)) - -a_flags = $(cpuflags-gnu-y) $(depflags) $(cppflags-gnu-y) $(asflags-gnu-y) -D__ASSEMBLY__ -c_flags = $(cpuflags-gnu-y) $(dbgflags-gnu-y) $(depflags) $(optflags-gnu-y) $(cppflags-gnu-y) $(cflags-gnu-y) -cxx_flags= $(cpuflags-gnu-y) $(dbgflags-gnu-y) $(depflags) $(optflags-gnu-y) $(cppflags-gnu-y) $(cxxflags-gnu-y) -l_flags = $(cpuflags-gnu-y) $(optflags-gnu-y) $(ldflags-gnu-y) -ar_flags = $(arflags-gnu-y) - -# Intel Hex file production flags -flashflags-gnu-y += -R .eeprom -R .usb_descriptor_table - -# Eeprom file production flags -eepromflags-gnu-y += -j .eeprom -eepromflags-gnu-y += --set-section-flags=.eeprom="alloc,load" -eepromflags-gnu-y += --change-section-lma .eeprom=0 - -# Source files list and part informations must already be included before -# running this makefile - -# Create object files list from source files list. -obj-y := $(addsuffix .o,$(basename $(CSRCS) $(ASSRCS))) -# Create dependency files list from source files list. -dep-files := $(wildcard $(foreach f,$(obj-y),$(basename $(f)).d)) - -clean-files += $(wildcard $(obj-y)) -clean-files += $(dep-files) - -clean-dirs += $(call reverse,$(sort $(wildcard $(dir $(obj-y))))) - -# Default target. -.PHONY: all -ifeq ($(target_type),lib) -all: $(target) $(project).lss $(project).sym -else -ifeq ($(target_type),elf) -all: $(target) $(project).hex $(project).lss $(project).sym -endif -endif - -# Clean up the project. -.PHONY: clean -clean: - @$(if $(strip $(clean-files)),echo $(MSG_CLEAN_FILES)) - $(if $(strip $(clean-files)),$(Q)$(RM) $(clean-files),) - @$(if $(strip $(clean-dirs)),echo $(MSG_CLEAN_DIRS)) -# Remove created directories, and make sure we only remove existing -# directories, since recursive rmdir might help us a bit on the way. -ifeq ($(os),Windows) - $(Q)$(if $(strip $(clean-dirs)), \ - $(RMDIR) $(strip $(subst /,\,$(clean-dirs)))) -else - $(Q)$(if $(strip $(clean-dirs)), \ - for directory in $(strip $(clean-dirs)); do \ - if [ -d "$$directory" ]; then \ - $(RMDIR) $$directory; \ - fi \ - done \ - ) -endif - -# Rebuild the project. -.PHONY: rebuild -rebuild: clean all - -.PHONY: objfiles -objfiles: $(obj-y) - -# Create object files from C source files. -%.o: %.c $(PRJ_PATH)/common/utils/make/Makefile.avr.in config.mk - $(Q)test -d $(dir $@) || echo $(MSG_MKDIR) -ifeq ($(os),Windows) - $(Q)test -d $(dir $@) || mkdir $(subst /,\,$(dir $@)) -else - $(Q)test -d $(dir $@) || mkdir -p $(dir $@) -endif - @echo $(MSG_COMPILING) - $(Q)$(CC) $(c_flags) -c $< -o $@ - -# Create object files from C++ source files. -%.o: %.cpp $(PRJ_PATH)/common/utils/make/Makefile.avr.in config.mk - $(Q)test -d $(dir $@) || echo $(MSG_MKDIR) -ifeq ($(os),Windows) - $(Q)test -d $(dir $@) || mkdir $(subst /,\,$(dir $@)) -else - $(Q)test -d $(dir $@) || mkdir -p $(dir $@) -endif - @echo $(MSG_COMPILING_CXX) - $(Q)$(CXX) $(cxx_flags) -c $< -o $@ - -# Preprocess and assemble: create object files from assembler source files. -%.o: %.s $(PRJ_PATH)/common/utils/make/Makefile.avr.in config.mk - $(Q)test -d $(dir $@) || echo $(MSG_MKDIR) -ifeq ($(os),Windows) - $(Q)test -d $(dir $@) || mkdir $(subst /,\,$(dir $@)) -else - $(Q)test -d $(dir $@) || mkdir -p $(dir $@) -endif - @echo $(MSG_ASSEMBLING) - $(Q)$(CC) $(a_flags) -c $< -o $@ - -# Preprocess and assemble: create object files from assembler source files. -%.o: %.S $(PRJ_PATH)/common/utils/make/Makefile.avr.in config.mk - $(Q)test -d $(dir $@) || echo $(MSG_MKDIR) -ifeq ($(os),Windows) - $(Q)test -d $(dir $@) || mkdir $(subst /,\,$(dir $@)) -else - $(Q)test -d $(dir $@) || mkdir -p $(dir $@) -endif - @echo $(MSG_ASSEMBLING) - $(Q)$(CC) $(a_flags) -c $< -o $@ - -# Include all dependency files to add depedency to all header files in use. -include $(dep-files) - -ifeq ($(target_type),lib) -# Archive object files into an archive -$(target): $(PRJ_PATH)/common/utils/make/Makefile.avr.in config.mk $(obj-y) - @echo $(MSG_ARCHIVING) - $(Q)$(AR) $(ar_flags) $@ $(obj-y) - @echo $(MSG_SIZE) - $(Q)$(SIZE) -Bxt $@ -else -ifeq ($(target_type),elf) -# Link the object files into an ELF file. Also make sure the target is rebuilt -# if the common Makefile.avr.in or project config.mk is changed. -$(target): $(PRJ_PATH)/common/utils/make/Makefile.avr.in config.mk $(obj-y) - @echo $(MSG_LINKING) - $(Q)$(CC) $(l_flags) $(obj-y) $(libflags-gnu-y) -o $@ - @echo $(MSG_SIZE) - $(Q)$(SIZE) -Ax $@ - $(Q)$(SIZE) -Bx $@ -endif -endif - -# Create extended function listing from target output file. -%.lss: $(target) - @echo $(MSG_EXTENDED_LISTING) - $(Q)$(OBJDUMP) -h -S $< > $@ - -# Create symbol table from target output file. -%.sym: $(target) - @echo $(MSG_SYMBOL_TABLE) - $(Q)$(NM) -n $< > $@ - -# Create Intel HEX image from ELF output file. -%.hex: $(target) - @echo $(MSG_IHEX_IMAGE) - $(Q)$(OBJCOPY) -O ihex $(flashflags-gnu-y) $< $@ - -# Create EEPROM Intel HEX image from ELF output file. -%.eep: $(target) - @echo $(MSG_EEPROM_IMAGE) - $(Q)$(OBJCOPY) $(eepromflags-gnu-y) -O ihex $< $@ || exit 0 - -# Provide information about the detected host operating system. -.SECONDARY: info-os -info-os: - @echo $(MSG_INFO)$(os) build host detected - -# Build Doxygen generated documentation. -.PHONY: doc -doc: - @echo $(MSG_GENERATING_DOC) - $(Q)cd $(dir $(doccfg)) && $(DOCGEN) $(notdir $(doccfg)) - -# Clean Doxygen generated documentation. -.PHONY: cleandoc -cleandoc: - @$(if $(wildcard $(docdir)),echo $(MSG_CLEAN_DOC)) - $(Q)$(if $(wildcard $(docdir)),$(RM) --recursive $(docdir)) - -# Rebuild the Doxygen generated documentation. -.PHONY: rebuilddoc -rebuilddoc: cleandoc doc +# List of available make goals: +# +# all Default target, builds the project +# clean Clean up the project +# rebuild Rebuild the project +# +# doc Build the documentation +# cleandoc Clean up the documentation +# rebuilddoc Rebuild the documentation +# +# +# Copyright (c) 2009 - 2013 Atmel Corporation. All rights reserved. +# +# \asf_license_start +# +# \page License +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. The name of Atmel may not be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 4. This software may only be redistributed and used in connection with an +# Atmel microcontroller product. +# +# THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE +# EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# \asf_license_stop +# + +# Include the config.mk file from the current working path, e.g., where the +# user called make. +include config.mk + +# Tool to use to generate documentation from the source code +DOCGEN ?= doxygen + +# Look for source files relative to the top-level source directory +VPATH := $(PRJ_PATH) + +# Output target file +target := $(TARGET) + +# Output project name (target name minus suffix) +project := $(basename $(target)) + +# Output target file (typically ELF or static library) +ifeq ($(suffix $(target)),.a) +target_type := lib +else +ifeq ($(suffix $(target)),.elf) +target_type := elf +else +$(error "Target type $(target_type) is not supported") +endif +endif + +# Allow override of operating system detection. The user can add OS=Linux or +# OS=Windows on the command line to explicit set the host OS. +# +# This allows to work around broken uname utility on certain systems. +ifdef OS + ifeq ($(strip $(OS)), Linux) + os_type := Linux + endif + ifeq ($(strip $(OS)), Windows) + os_type := windows32_64 + endif +endif + +os_type ?= $(strip $(shell uname)) + +ifeq ($(os_type),windows32) +os := Windows +else +ifeq ($(os_type),windows64) +os := Windows +else +ifeq ($(os_type),windows32_64) +os ?= Windows +else +ifeq ($(os_type),) +os := Windows +else +# Default to Linux style operating system. Both Cygwin and mingw are fully +# compatible (for this Makefile) with Linux. +os := Linux +endif +endif +endif +endif + +# Output documentation directory and configuration file. +docdir := ./doxygen/ +doccfg := ./doxyfile + +CROSS ?= avr- +AR := $(CROSS)ar +AS := $(CROSS)as +CC := $(CROSS)gcc +CPP := $(CROSS)gcc -E +CXX := $(CROSS)g++ +LD := $(CROSS)gcc +NM := $(CROSS)nm +OBJCOPY := $(CROSS)objcopy +OBJDUMP := $(CROSS)objdump +SIZE := $(CROSS)size + +RM := rm +ifeq ($(os),Windows) +RMDIR := rmdir /S /Q +else +RMDIR := rm -R +endif + +# On Windows, we need to override the shell to force the use of cmd.exe +ifeq ($(os),Windows) +SHELL := cmd +endif + +# Strings for beautifying output +MSG_CLEAN_FILES = "RM *.o *.d" +MSG_CLEAN_DIRS = "RMDIR $(strip $(clean-dirs))" +MSG_CLEAN_DOC = "RMDIR $(docdir)" +MSG_MKDIR = "MKDIR $(dir $@)" + +MSG_INFO = "INFO " +MSG_PREBUILD = "PREBUILD $(PREBUILD_CMD)" +MSG_POSTBUILD = "POSTBUILD $(POSTBUILD_CMD)" + +MSG_ARCHIVING = "AR $@" +MSG_ASSEMBLING = "AS $@" +MSG_BINARY_IMAGE = "OBJCOPY $@" +MSG_COMPILING = "CC $@" +MSG_COMPILING_CXX = "CXX $@" +MSG_EEPROM_IMAGE = "OBJCOPY $@" +MSG_EXTENDED_LISTING = "OBJDUMP $@" +MSG_IHEX_IMAGE = "OBJCOPY $@" +MSG_LINKING = "LN $@" +MSG_PREPROCESSING = "CPP $@" +MSG_SIZE = "SIZE $@" +MSG_SYMBOL_TABLE = "NM $@" + +MSG_GENERATING_DOC = "DOXYGEN $(docdir)" + +# Don't use make's built-in rules and variables +MAKEFLAGS += -rR + +# Don't print 'Entering directory ...' +MAKEFLAGS += --no-print-directory + +# Function for reversing the order of a list +reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1)) + +# Hide command output by default, but allow the user to override this +# by adding V=1 on the command line. +# +# This is inspired by the Kbuild system used by the Linux kernel. +ifdef V + ifeq ("$(origin V)", "command line") + VERBOSE = $(V) + endif +endif +ifndef VERBOSE + VERBOSE = 0 +endif + +ifeq ($(VERBOSE), 1) + Q = +else + Q = @ +endif + +arflags-gnu-y := $(ARFLAGS) +asflags-gnu-y := $(ASFLAGS) +cflags-gnu-y := $(CFLAGS) +cxxflags-gnu-y := $(CXXFLAGS) +cppflags-gnu-y := $(CPPFLAGS) +cpuflags-gnu-y := +dbgflags-gnu-y := $(DBGFLAGS) +libflags-gnu-y := $(foreach LIB,$(LIBS),-l$(LIB)) +ldflags-gnu-y := $(LDFLAGS) +flashflags-gnu-y := $(FLASHFLAGS) +eepromflags-gnu-y := $(EEPROMFLAGS) +clean-files := +clean-dirs := + +clean-files += $(wildcard $(target) $(project).map) +clean-files += $(wildcard $(project).hex $(project).eep) +clean-files += $(wildcard $(project).lss $(project).sym) +clean-files += $(wildcard $(build)) + +# Use pipes instead of temporary files for communication between processes +cflags-gnu-y += -pipe +asflags-gnu-y += -pipe +ldflags-gnu-y += -pipe + +# Archiver flags. +arflags-gnu-y += rcs + +# Always enable warnings. And be very careful about implicit +# declarations. +cflags-gnu-y += -Wall -Wstrict-prototypes -Wmissing-prototypes +cflags-gnu-y += -Werror-implicit-function-declaration +cxxflags-gnu-y += -Wall +# IAR doesn't allow arithmetic on void pointers, so warn about that. +cflags-gnu-y += -Wpointer-arith +cxxflags-gnu-y += -Wpointer-arith + +# Preprocessor flags. +cppflags-gnu-y += $(foreach INC,$(addprefix $(PRJ_PATH),$(INC_PATH)),-I$(INC)) +asflags-gnu-y += $(foreach INC,$(addprefix $(PRJ_PATH),$(INC_PATH)),'-Wa,-I$(INC)') + +# CPU specific flags. +cpuflags-gnu-y += -mmcu=$(MCU) + +# Dependency file flags. +depflags = -MD -MP -MQ $@ + +# Debug specific flags. +ifdef BUILD_DEBUG_LEVEL +dbgflags-gnu-y += -g$(BUILD_DEBUG_LEVEL) +else +dbgflags-gnu-y += -gdwarf-2 +endif + +# Optimization specific flags. +ifdef BUILD_OPTIMIZATION +optflags-gnu-y = -O$(BUILD_OPTIMIZATION) +else +optflags-gnu-y = $(OPTIMIZATION) +endif + +# Relax compilation and linking. +cflags-gnu-y += -mrelax +cxxflags-gnu-y += -mrelax +asflags-gnu-y += -mrelax +ldflags-gnu-y += -Wl,--relax + +# Always preprocess assembler files. +asflags-gnu-y += -x assembler-with-cpp +# Compile C files using the GNU99 standard. +cflags-gnu-y += -std=gnu99 +# Compile C++ files using the GNU++98 standard. +cxxflags-gnu-y += -std=gnu++98 + +# Use unsigned character type when compiling. +cflags-gnu-y += -funsigned-char +cxxflags-gnu-y += -funsigned-char + +# Don't use strict aliasing (very common in embedded applications). +cflags-gnu-y += -fno-strict-aliasing +cxxflags-gnu-y += -fno-strict-aliasing + +# Separate each function and data into its own separate section to allow +# garbage collection of unused sections. +cflags-gnu-y += -ffunction-sections -fdata-sections +cxxflags-gnu-y += -ffunction-sections -fdata-sections + +# Garbage collect unreferred sections when linking. +ldflags-gnu-y += -Wl,--gc-sections + +# Output a link map file and a cross reference table +ldflags-gnu-y += -Wl,-Map=$(project).map,--cref + +# Add library search paths relative to the top level directory. +ldflags-gnu-y += $(foreach _LIB_PATH,$(addprefix $(PRJ_PATH),$(LIB_PATH)),-L$(_LIB_PATH)) + +a_flags = $(cpuflags-gnu-y) $(depflags) $(cppflags-gnu-y) $(asflags-gnu-y) -D__ASSEMBLY__ +c_flags = $(cpuflags-gnu-y) $(dbgflags-gnu-y) $(depflags) $(optflags-gnu-y) $(cppflags-gnu-y) $(cflags-gnu-y) +cxx_flags= $(cpuflags-gnu-y) $(dbgflags-gnu-y) $(depflags) $(optflags-gnu-y) $(cppflags-gnu-y) $(cxxflags-gnu-y) +l_flags = $(cpuflags-gnu-y) $(optflags-gnu-y) $(ldflags-gnu-y) +ar_flags = $(arflags-gnu-y) + +# Intel Hex file production flags +flashflags-gnu-y += -R .eeprom -R .usb_descriptor_table + +# Eeprom file production flags +eepromflags-gnu-y += -j .eeprom +eepromflags-gnu-y += --set-section-flags=.eeprom="alloc,load" +eepromflags-gnu-y += --change-section-lma .eeprom=0 + +# Source files list and part informations must already be included before +# running this makefile + +# If a custom build directory is specified, use it -- force trailing / in directory name. +ifdef BUILD_DIR + build-dir := $(dir $(BUILD_DIR))$(if $(notdir $(BUILD_DIR)),$(notdir $(BUILD_DIR))/) +else + build-dir = +endif + +# Create object files list from source files list. +obj-y := $(addprefix $(build-dir), $(addsuffix .o,$(basename $(CSRCS) $(ASSRCS)))) + +# Create dependency files list from source files list. +dep-files := $(wildcard $(foreach f,$(obj-y),$(basename $(f)).d)) + +clean-files += $(wildcard $(obj-y)) +clean-files += $(dep-files) + +clean-dirs += $(call reverse,$(sort $(wildcard $(dir $(obj-y))))) + +# Default target. +.PHONY: all +ifeq ($(target_type),lib) +all: $(target) $(project).lss $(project).sym +else +ifeq ($(target_type),elf) +all: prebuild $(target) $(project).lss $(project).sym $(project).hex $(project).bin postbuild +endif +endif + +prebuild: +ifneq ($(strip $(PREBUILD_CMD)),) + @echo $(MSG_PREBUILD) + $(Q)$(PREBUILD_CMD) +endif + +postbuild: +ifneq ($(strip $(POSTBUILD_CMD)),) + @echo $(MSG_POSTBUILD) + $(Q)$(POSTBUILD_CMD) +endif + +# Clean up the project. +.PHONY: clean +clean: + @$(if $(strip $(clean-files)),echo $(MSG_CLEAN_FILES)) + $(if $(strip $(clean-files)),$(Q)$(RM) $(clean-files),) + @$(if $(strip $(clean-dirs)),echo $(MSG_CLEAN_DIRS)) +# Remove created directories, and make sure we only remove existing +# directories, since recursive rmdir might help us a bit on the way. +ifeq ($(os),Windows) + $(Q)$(if $(strip $(clean-dirs)), \ + $(RMDIR) $(strip $(subst /,\,$(clean-dirs)))) +else + $(Q)$(if $(strip $(clean-dirs)), \ + for directory in $(strip $(clean-dirs)); do \ + if [ -d "$$directory" ]; then \ + $(RMDIR) $$directory; \ + fi \ + done \ + ) +endif + +# Rebuild the project. +.PHONY: rebuild +rebuild: clean all + +.PHONY: objfiles +objfiles: $(obj-y) + +# Create object files from C source files. +$(build-dir)%.o: %.c $(MAKEFILE_PATH) config.mk + $(Q)test -d $(dir $@) || echo $(MSG_MKDIR) +ifeq ($(os),Windows) + $(Q)test -d $(patsubst %/,%,$(dir $@)) || mkdir $(subst /,\,$(dir $@)) +else + $(Q)test -d $(dir $@) || mkdir -p $(dir $@) +endif + @echo $(MSG_COMPILING) + $(Q)$(CC) $(c_flags) -c $< -o $@ + +# Create object files from C++ source files. +$(build-dir)%.o: %.cpp $(MAKEFILE_PATH) config.mk + $(Q)test -d $(dir $@) || echo $(MSG_MKDIR) +ifeq ($(os),Windows) + $(Q)test -d $(patsubst %/,%,$(dir $@)) || mkdir $(subst /,\,$(dir $@)) +else + $(Q)test -d $(dir $@) || mkdir -p $(dir $@) +endif + @echo $(MSG_COMPILING_CXX) + $(Q)$(CXX) $(cxx_flags) -c $< -o $@ + +# Preprocess and assemble: create object files from assembler source files. +$(build-dir)%.o: %.s $(MAKEFILE_PATH) config.mk + $(Q)test -d $(dir $@) || echo $(MSG_MKDIR) +ifeq ($(os),Windows) + $(Q)test -d $(patsubst %/,%,$(dir $@)) || mkdir $(subst /,\,$(dir $@)) +else + $(Q)test -d $(dir $@) || mkdir -p $(dir $@) +endif + @echo $(MSG_ASSEMBLING) + $(Q)$(CC) $(a_flags) -c $< -o $@ + +# Preprocess and assemble: create object files from assembler source files. +$(build-dir)%.o: %.S $(MAKEFILE_PATH) config.mk + $(Q)test -d $(dir $@) || echo $(MSG_MKDIR) +ifeq ($(os),Windows) + $(Q)test -d $(patsubst %/,%,$(dir $@)) || mkdir $(subst /,\,$(dir $@)) +else + $(Q)test -d $(dir $@) || mkdir -p $(dir $@) +endif + @echo $(MSG_ASSEMBLING) + $(Q)$(CC) $(a_flags) -c $< -o $@ + +# Include all dependency files to add depedency to all header files in use. +include $(dep-files) + +ifeq ($(target_type),lib) +# Archive object files into an archive +$(target): $(MAKEFILE_PATH) config.mk $(obj-y) + @echo $(MSG_ARCHIVING) + $(Q)$(AR) $(ar_flags) $@ $(obj-y) + @echo $(MSG_SIZE) + $(Q)$(SIZE) -Bxt $@ +else +ifeq ($(target_type),elf) +# Link the object files into an ELF file. Also make sure the target is rebuilt +# if the common Makefile.avr.in or project config.mk is changed. +$(target): $(MAKEFILE_PATH) config.mk $(obj-y) + @echo $(MSG_LINKING) + $(Q)$(LD) $(l_flags) $(obj-y) $(libflags-gnu-y) -o $@ + @echo $(MSG_SIZE) + $(Q)$(SIZE) -Ax $@ + $(Q)$(SIZE) -Bx $@ +endif +endif + +# Create extended function listing from target output file. +%.lss: $(target) + @echo $(MSG_EXTENDED_LISTING) + $(Q)$(OBJDUMP) -h -S $< > $@ + +# Create symbol table from target output file. +%.sym: $(target) + @echo $(MSG_SYMBOL_TABLE) + $(Q)$(NM) -n $< > $@ + +# Create Intel HEX image from ELF output file. +%.hex: $(target) + @echo $(MSG_IHEX_IMAGE) + $(Q)$(OBJCOPY) -O ihex $(flashflags-gnu-y) $< $@ + +# Create EEPROM Intel HEX image from ELF output file. +%.eep: $(target) + @echo $(MSG_EEPROM_IMAGE) + $(Q)$(OBJCOPY) $(eepromflags-gnu-y) -O ihex $< $@ || exit 0 + +# Create binary image from ELF output file. +%.bin: $(target) + @echo $(MSG_BINARY_IMAGE) + $(Q)$(OBJCOPY) -O binary $< $@ + +# Provide information about the detected host operating system. +.SECONDARY: info-os +info-os: + @echo $(MSG_INFO)$(os) build host detected + +# Build Doxygen generated documentation. +.PHONY: doc +doc: + @echo $(MSG_GENERATING_DOC) + $(Q)cd $(dir $(doccfg)) && $(DOCGEN) $(notdir $(doccfg)) + +# Clean Doxygen generated documentation. +.PHONY: cleandoc +cleandoc: + @$(if $(wildcard $(docdir)),echo $(MSG_CLEAN_DOC)) + $(Q)$(if $(wildcard $(docdir)),$(RM) --recursive $(docdir)) + +# Rebuild the Doxygen generated documentation. +.PHONY: rebuilddoc +rebuilddoc: cleandoc doc diff --git a/DSTAT-temp/config.mk b/DSTAT-temp/config.mk new file mode 100644 index 0000000..df9f608 --- /dev/null +++ b/DSTAT-temp/config.mk @@ -0,0 +1,109 @@ +# +# Copyright (c) 2010 Atmel Corporation. All rights reserved. +# +# \asf_license_start +# +# \page License +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. The name of Atmel may not be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 4. This software may only be redistributed and used in connection with an +# Atmel microcontroller product. +# +# THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE +# EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# \asf_license_stop +# + +PRJ_PATH = +BUILD_DIR = + +# Microcontroller: atxmega128a1, atmega128, attiny261, etc. +MCU = atxmega256a3u +F_CPU = 20000000 + +# Application target name. Given with suffix .a for library and .elf for a +# standalone application. +TARGET = dstat-firmware.elf + +# C source files located from the top-level source directory +CSRCS = ${shell find ./src -type f -name "*.c" -print} + +# Assembler source files located from the top-level source directory +ASSRCS = ${shell find ./src -type f -name "*.s" -print} + +# Include path located from the top-level source directory +INC_PATH = ${shell find . -type d -print} + +# Library paths from the top-level source directory +LIB_PATH = + +# Libraries to link with the project +LIBS = + +# Additional options for debugging. By default the common Makefile.in will +# add -gdwarf-2. +DBGFLAGS = + +# Optimization settings +OPTIMIZATION = -Os + +# Extra flags used when creating an EEPROM Intel HEX file. By default the +# common Makefile.in will add -j .eeprom +# --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0. +EEPROMFLAGS = + +# Extra flags used when creating an Intel HEX file. By default the common +# Makefile.in will add -R .eeprom -R .usb_descriptor_table. +FLASHFLAGS = + +# Extra flags to use when archiving. +ARFLAGS = + +# Extra flags to use when assembling. +ASFLAGS = + +# Extra flags to use when compiling. +CFLAGS = + +# Extra flags to use when preprocessing. +# +# Preprocessor symbol definitions +# To add a definition use the format "-D name[=definition]". +# To cancel a definition use the format "-U name". +# +# The most relevant symbols to define for the preprocessor are: +# BOARD Target board in use, see boards/board.h for a list. +# EXT_BOARD Optional extension board in use, see boards/board.h for a list. +CPPFLAGS = \ + -D BOARD=USER_BOARD \ + -D IOPORT_XMEGA_COMPAT \ + -D F_CPU=$(F_CPU)UL + +# Extra flags to use when linking +LDFLAGS = -Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt + +# Pre- and post-build commands +PREBUILD_CMD = +POSTBUILD_CMD = \ No newline at end of file diff --git a/DSTAT-temp/doxySettings.xml b/DSTAT-temp/doxySettings.xml deleted file mode 100644 index 97643ad..0000000 --- a/DSTAT-temp/doxySettings.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\doxySettings.xml - DSTAT-temp - C:\Users\mdryden\AppData\Local\Atmel\AtmelStudio\6.2\Extensions\Atmel\Doxygen Integrator\1.2.0.14\Doxygen/doxygen.exe - true - false - C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\doxyfile - C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\doxygen - false - \ No newline at end of file diff --git a/DSTAT-temp/doxyfile b/DSTAT-temp/doxyfile index 6cb8e0d..efb92c9 100644 --- a/DSTAT-temp/doxyfile +++ b/DSTAT-temp/doxyfile @@ -26,7 +26,7 @@ DOXYFILE_ENCODING = UTF-8 # identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. -PROJECT_NAME ="DSTAT-temp" +PROJECT_NAME ="DSTAT-firmware" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or @@ -52,7 +52,7 @@ PROJECT_LOGO = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY ="C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\doxygen" +OUTPUT_DIRECTORY = ./doxygen # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -655,7 +655,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT ="C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\boards\user_board\init.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\boards\user_board\user_board.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\boards\board.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\clock\xmega\osc.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\clock\xmega\pll.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\clock\xmega\sysclk.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\clock\xmega\sysclk.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\clock\genclk.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\clock\osc.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\clock\pll.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\clock\sysclk.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\delay\xmega\cycle_counter.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\delay\delay.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\hugemem\avr8\avr8_hugemem.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\hugemem\avr8\hugemem.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\hugemem\generic\hugemem.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\hugemem\hugemem.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\ioport\xmega\ioport.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\ioport\xmega\ioport_compat.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\ioport\xmega\ioport_compat.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\ioport\ioport.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\sleepmgr\xmega\sleepmgr.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\sleepmgr\xmega\sleepmgr.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\sleepmgr\sleepmgr.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\spi\xmega_usart_spi\usart_spi.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\spi\xmega_usart_spi\usart_spi.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\spi\usart_spi.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\class\cdc\device\udi_cdc.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\class\cdc\device\udi_cdc.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\class\cdc\device\udi_cdc_conf.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\class\cdc\device\udi_cdc_desc.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\class\cdc\usb_protocol_cdc.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\udc\udc.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\udc\udc.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\udc\udc_desc.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\udc\udd.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\udc\udi.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\usb_atmel.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\services\usb\usb_protocol.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\utils\interrupt\interrupt_avr8.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\utils\make\Makefile.avr.in" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\utils\stdio\stdio_usb\stdio_usb.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\utils\stdio\stdio_usb\stdio_usb.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\utils\stdio\read.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\utils\stdio\write.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\utils\interrupt.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\common\utils\parts.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\cpu\ccp.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\cpu\ccp.s" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\cpu\xmega_reset_cause.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\dma\dma.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\dma\dma.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\nvm\nvm.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\nvm\nvm.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\nvm\nvm_asm.s" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\pmic\pmic.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\rtc\rtc.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\rtc\rtc.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\sleep\sleep.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\tc\tc.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\tc\tc.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\usart\usart.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\usart\usart.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\usb\usb_device.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\drivers\usb\usb_device.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\utils\assembler\gas.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\utils\bit_handling\clz_ctz.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\utils\preprocessor\mrepeat.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\utils\preprocessor\preprocessor.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\utils\preprocessor\stringz.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\utils\preprocessor\tpaste.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\utils\assembler.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\utils\compiler.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\utils\progmem.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf\xmega\utils\status_codes.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\config\conf_board.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\config\conf_clock.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\config\conf_experiment.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\config\conf_rtc.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\config\conf_sleepmgr.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\config\conf_usart_spi.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\config\conf_usb.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\ads1255.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\ads1255.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\asf.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\experiment.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\experiment.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\main.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\main.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\main1.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\max5443.c" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\src\max5443.h" "C:\Users\mdryden\Documents\src\dstat-firmware\DSTAT-temp\atmel_devices_cdc.inf" +INPUT ="../src" # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -679,7 +679,7 @@ FILE_PATTERNS = # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. -RECURSIVE = NO +RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a diff --git a/DSTAT1/DSTAT1.cproj b/DSTAT1/DSTAT1.cproj deleted file mode 100644 index 1fb507f..0000000 --- a/DSTAT1/DSTAT1.cproj +++ /dev/null @@ -1,940 +0,0 @@ - - - - 2.0 - 6.1 - {38800372-2811-4812-8069-46107ea45aa8} - $(MSBuildProjectName) - $(MSBuildProjectName) - $(MSBuildProjectName) - 2.11.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ATxmega256A3U - xmegaa - CPP - com.Atmel.AVRGCC8.CPP - - $(MSBuildProjectDirectory)\$(Configuration) - $(MSBuildProjectName) - .elf - Executable - Native - true - false - exception_table - 0 - PDI - com.atmel.avrdbg.tool.avrdragon - - com.atmel.avrdbg.tool.ispmk2 - AVRISP mkII - 000200071128 - true - false - - - - 127.0.0.1 - 49295 - False - - - PDI - - 1000000 - 1000000 - 150000 - false - false - 0 - 0 - 0 - 0 - - - - - com.atmel.avrdbg.tool.avrdragon - AVR Dragon - 00A200028349 - true - false - - - - 127.0.0.1 - 49167 - False - - - PDI - - 1000000 - 1000000 - 150000 - false - false - 0 - 0 - 0 - 0 - - - - true - true - 0x20000000 - - 2 - - - - True - True - True - True - - - True - True - True - True - False - - - BOARD=USER_BOARD - - - - - ../src - ../src/asf/common/applications/user_application/user_board - ../src/asf/common/boards - ../src/asf/common/boards/user_board - ../src/asf/common/utils - ../src/asf/xmega/utils - ../src/asf/xmega/utils/preprocessor - ../src/config - ../src/asf/common/services/usb/class/cdc/device - ../src/asf/xmega/drivers/cpu - ../src/asf/xmega/drivers/ioport - ../src/asf/xmega/drivers/nvm - ../src/asf/xmega/drivers/sleep - ../src/asf/common/services/clock - ../src/asf/common/services/delay - ../src/asf/common/services/sleepmgr - ../src/asf/common/services/usb - ../src/asf/common/services/usb/class/cdc - ../src/asf/common/services/usb/udc - ../src/asf/xmega/drivers/usb - ../src/asf/common/utils/stdio/stdio_usb - ../src/asf/xmega/drivers/spi - ../src/asf/common/services/spi/xmega_spi - ../src/asf/common/services/spi - ../src/asf/xmega/drivers/pmic - ../src/asf/xmega/drivers/tc - ../src/asf/xmega/drivers/rtc - ../src/asf/xmega/drivers/usart - - - Optimize more (-O2) - -fdata-sections - True - -Werror-implicit-function-declaration -Wmissing-prototypes -Wpointer-arith -Wstrict-prototypes -mrelax -std=gnu99 - - - BOARD=USER_BOARD - - - - - ../src - ../src/asf/common/applications/user_application/user_board - ../src/asf/common/boards - ../src/asf/common/boards/user_board - ../src/asf/common/utils - ../src/asf/xmega/utils - ../src/asf/xmega/utils/preprocessor - ../src/config - ../src/asf/common/services/usb/class/cdc/device - ../src/asf/xmega/drivers/cpu - ../src/asf/xmega/drivers/ioport - ../src/asf/xmega/drivers/nvm - ../src/asf/xmega/drivers/sleep - ../src/asf/common/services/clock - ../src/asf/common/services/delay - ../src/asf/common/services/sleepmgr - ../src/asf/common/services/usb - ../src/asf/common/services/usb/class/cdc - ../src/asf/common/services/usb/udc - ../src/asf/xmega/drivers/usb - ../src/asf/common/utils/stdio/stdio_usb - ../src/asf/xmega/drivers/spi - ../src/asf/common/services/spi/xmega_spi - ../src/asf/common/services/spi - ../src/asf/xmega/drivers/pmic - ../src/asf/xmega/drivers/tc - ../src/asf/xmega/drivers/rtc - ../src/avr-stl/include - ../src/asf/xmega/drivers/usart - - - Optimize more (-O2) - - - libprintf_flt.a - libc.a - libm - - - -Wl,-u,vfprintf -lm - - - ../src - ../src/asf/common/applications/user_application/user_board - ../src/asf/common/boards - ../src/asf/common/boards/user_board - ../src/asf/common/utils - ../src/asf/xmega/utils - ../src/asf/xmega/utils/preprocessor - ../src/config - ../src/asf/common/services/usb/class/cdc/device - ../src/asf/xmega/drivers/cpu - ../src/asf/xmega/drivers/ioport - ../src/asf/xmega/drivers/nvm - ../src/asf/xmega/drivers/sleep - ../src/asf/common/services/clock - ../src/asf/common/services/delay - ../src/asf/common/services/sleepmgr - ../src/asf/common/services/usb - ../src/asf/common/services/usb/class/cdc - ../src/asf/common/services/usb/udc - ../src/asf/xmega/drivers/usb - ../src/asf/common/utils/stdio/stdio_usb - ../src/asf/xmega/drivers/spi - ../src/asf/common/services/spi/xmega_spi - ../src/asf/common/services/spi - ../src/asf/xmega/drivers/pmic - ../src/asf/xmega/drivers/tc - ../src/asf/xmega/drivers/rtc - ../src/avr-stl/include - ../src/asf/xmega/drivers/usart - - - - - - - - True - True - True - True - - - True - True - True - True - False - - - BOARD=USER_BOARD - - - - - ../src - ../src/asf/common/applications/user_application/user_board - ../src/asf/common/boards - ../src/asf/common/boards/user_board - ../src/asf/common/utils - ../src/asf/xmega/utils - ../src/asf/xmega/utils/preprocessor - ../src/config - ../src/asf/common/services/usb/class/cdc/device - ../src/asf/xmega/drivers/cpu - ../src/asf/xmega/drivers/ioport - ../src/asf/xmega/drivers/nvm - ../src/asf/xmega/drivers/sleep - ../src/asf/common/services/clock - ../src/asf/common/services/delay - ../src/asf/common/services/sleepmgr - ../src/asf/common/services/usb - ../src/asf/common/services/usb/class/cdc - ../src/asf/common/services/usb/udc - ../src/asf/xmega/drivers/usb - ../src/asf/common/utils/stdio/stdio_usb - ../src/asf/xmega/drivers/spi - ../src/asf/common/services/spi/xmega_spi - ../src/asf/common/services/spi - ../src/asf/xmega/drivers/pmic - ../src/asf/xmega/drivers/tc - ../src/asf/xmega/drivers/rtc - ../src/asf/xmega/drivers/usart - - - Optimize (-O1) - -fdata-sections - Maximum (-g3) - True - -Werror-implicit-function-declaration -Wmissing-prototypes -Wpointer-arith -Wstrict-prototypes -mrelax -std=gnu99 - - - - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/DSTAT1/atmel_devices_cdc.inf b/DSTAT1/atmel_devices_cdc.inf deleted file mode 100644 index f9ac73b..0000000 --- a/DSTAT1/atmel_devices_cdc.inf +++ /dev/null @@ -1,119 +0,0 @@ -; Windows 2000, XP, Vista and 7 (x32 and x64) setup file for Atmel CDC Devices - -; Copyright (c) 2000 Microsoft Corporation -; Copyright (C) 2000-2011 ATMEL, Inc. - -[Version] -Signature="$Windows NT$" -Class=Ports -ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} - -Provider=%ATMEL% -LayoutFile=layout.inf -DriverVer=10/15/1999,5.0.2153.1 - -;---------------------------------------------------------- -; Targets -;---------------------------------------------------------- -[Manufacturer] -%ATMEL%=ATMEL, NTamd64 - -[ATMEL] -%ATMEL_CDC_XPLAINED%=Reader, USB\VID_03EB&PID_2122 -%ATMEL_CDC_SFW_EXAMPLE%=Reader, USB\VID_03EB&PID_2307 -%ATMEL_CDC_EVK1XXX%=Reader, USB\VID_03EB&PID_2310 -%ATMEL_CDC_ASF_EXAMPLE%=Reader, USB\VID_03EB&PID_2404 -%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE2%=Reader, USB\VID_03EB&PID_2421&MI_00 -%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE4%=Reader, USB\VID_03EB&PID_2424&MI_00 -%ATMEL_CDC_ASF_EXAMPLE2_COM1%=Reader, USB\VID_03EB&PID_2425&MI_00 -%ATMEL_CDC_ASF_EXAMPLE2_COM2%=Reader, USB\VID_03EB&PID_2425&MI_02 - -[ATMEL.NTamd64] -%ATMEL_CDC_XPLAINED%=DriverInstall, USB\VID_03EB&PID_2122 -%ATMEL_CDC_SFW_EXAMPLE%=DriverInstall, USB\VID_03EB&PID_2307 -%ATMEL_CDC_EVK1XXX%=DriverInstall, USB\VID_03EB&PID_2310 -%ATMEL_CDC_ASF_EXAMPLE%=DriverInstall, USB\VID_03EB&PID_2404 -%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE2%=DriverInstall, USB\VID_03EB&PID_2421&MI_00 -%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE4%=DriverInstall, USB\VID_03EB&PID_2424&MI_00 -%ATMEL_CDC_ASF_EXAMPLE2_COM1%=DriverInstall, USB\VID_03EB&PID_2425&MI_00 -%ATMEL_CDC_ASF_EXAMPLE2_COM2%=DriverInstall, USB\VID_03EB&PID_2425&MI_02 - -;---------------------------------------------------------- -; Windows 2K, XP, and Vista32 -;---------------------------------------------------------- -[Reader_Install.NTx86] - - -[DestinationDirs] -DefaultDestDir=12 -Reader.NT.Copy=12 - -[Reader.NT] -include=mdmcpq.inf -CopyFiles=Reader.NT.Copy -AddReg=Reader.NT.AddReg - -[Reader.NT.Copy] -usbser.sys - -[Reader.NT.AddReg] -HKR,,DevLoader,,*ntkern -HKR,,NTMPDriver,,usbser.sys -HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" - -[Reader.NT.Services] -AddService = usbser, 0x00000002, Service_Inst - -[Service_Inst] -DisplayName = %Serial.SvcDesc% -ServiceType = 1 ; SERVICE_KERNEL_DRIVER -StartType = 3 ; SERVICE_DEMAND_START -ErrorControl = 1 ; SERVICE_ERROR_NORMAL -ServiceBinary = %12%\usbser.sys -LoadOrderGroup = Base - - -;---------------------------------------------------------- -; Vista64 -;---------------------------------------------------------- - -[DriverInstall.NTamd64] -include=mdmcpq.inf -CopyFiles=DriverCopyFiles.NTamd64 -AddReg=DriverInstall.NTamd64.AddReg - -[DriverCopyFiles.NTamd64] -usbser.sys,,,0x20 - -[DriverInstall.NTamd64.AddReg] -HKR,,DevLoader,,*ntkern -HKR,,NTMPDriver,,usbser.sys -HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" - -[DriverInstall.NTamd64.Services] -AddService=usbser, 0x00000002, DriverService.NTamd64 - -[DriverService.NTamd64] -DisplayName=%Serial.SvcDesc% -ServiceType=1 -StartType=3 -ErrorControl=1 -ServiceBinary=%12%\usbser.sys - -;---------------------------------------------------------- -; String -;---------------------------------------------------------- - -[Strings] -ATMEL = "ATMEL, Inc." -ATMEL_CDC_XPLAINED = "XPLAINED Virtual Com Port" -ATMEL_CDC_SFW_EXAMPLE = "Communication Device Class SFW example" -ATMEL_CDC_EVK1XXX = "EVK1XXX Virtual Com Port" -ATMEL_CDC_ASF_EXAMPLE = "Communication Device Class ASF example" -ATMEL_CDC_ASF_COMPOSITE_EXAMPLE2 = "Communication Device Class ASF composite example 2" -ATMEL_CDC_ASF_COMPOSITE_EXAMPLE4 = "Communication Device Class ASF composite example 4" -ATMEL_CDC_ASF_EXAMPLE2_COM1 = "Communication Device Class ASF example2, COM1" -ATMEL_CDC_ASF_EXAMPLE2_COM2 = "Communication Device Class ASF example2, COM2" - -Serial.SvcDesc = "USB Serial emulation driver" - diff --git a/DSTAT1/src/ads1255.c b/DSTAT1/src/ads1255.c deleted file mode 100644 index 0ec05cf..0000000 --- a/DSTAT1/src/ads1255.c +++ /dev/null @@ -1,493 +0,0 @@ -/* - * ads1255.c - * - * Created: 04/04/2012 2:13:47 PM - * Author: mdryden - */ - - -#include -//#include - -uint8_t buffer_iter = 0; - -struct usart_spi_device spi_device_conf = { - .id = IOPORT_CREATE_PIN(PORTE, 4) - }; - -// struct spi_device spi_device_conf = { -// .id = IOPORT_CREATE_PIN(PORTE, 4) -// }; - - -void ads1255_init_pins(void) - { - ioport_configure_port_pin(&PORTE, PIN4_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTE, PIN5_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTE, PIN6_bm, IOPORT_DIR_INPUT); - ioport_configure_port_pin(&PORTE, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - //DRDY -// ioport_configure_port_pin(&PORTE, PIN3_bm, IOPORT_DIR_INPUT | IOPORT_FALLING); v1 Board - ioport_configure_port_pin(&PORTD, PIN5_bm, IOPORT_DIR_INPUT | IOPORT_FALLING); - } - - - void ads1255_init_module(void) - { -// spi_master_init(&SPIE); -// spi_master_setup_device(&SPIE, &spi_device_conf, SPI_MODE_1, 2300000UL, 0); -// spi_enable(&SPIE); - - usart_spi_init(&USARTE1); - usart_spi_setup_device(&USARTE1, &spi_device_conf, SPI_MODE_1, 2300000UL, 0); -// USARTE1.BAUDCTRLB = 0; -// USARTE1.BAUDCTRLA = 0b10; -// delay_s(1); - -// usart_spi_enable(&USARTE1); - } - -void ads1255_sync(void){ -// uint8_t ctrlbuffer = ADS_SYNC; - -// spi_select_device(&SPIE, &spi_device_conf); -// spi_write_packet(&SPIE, &ctrlbuffer, 1); -// spi_deselect_device(&SPIE, &spi_device_conf); - - usart_spi_select_device(&USARTE1, &spi_device_conf); - usart_spi_transmit(&USARTE1, ADS_SYNC); - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - - return; -} - - -int32_t ads1255_single_read(void){ - - union{ - uint8_t uint[4]; - int32_t int32; - } input_buffer; - -// spi_select_device(&SPIE, &spi_device_conf); -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); -// spi_write_single(&SPIE, ADS_RDATA); -// delay_us(6.5); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[2] = spi_get(&SPIE); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[1] = spi_get(&SPIE); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[0] = spi_get(&SPIE); -// spi_write_single(&SPIE, ADS_STANDBY); -// -// spi_deselect_device(&SPIE, &spi_device_conf); - - usart_spi_select_device(&USARTE1, &spi_device_conf); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - usart_spi_transmit(&USARTE1, ADS_RDATA); - delay_us(6.5); - for (int i = 2; i >= 0; --i) - { - while (usart_data_register_is_empty(&USARTE1) == false); - usart_put(&USARTE1, CONFIG_USART_SPI_DUMMY); - while (usart_rx_is_complete(&USARTE1) == false); - input_buffer.uint[i] = usart_get(&USARTE1); - } - while (!usart_tx_is_complete(&USARTE1)); - usart_clear_tx_complete(&USARTE1); - - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - - - ads1255_standby(); - - if (input_buffer.uint[2] > 0x7F) - input_buffer.uint[3] = 0xFF; - else - input_buffer.uint[3] = 0x0; - - #ifdef ADS1255_DBG - printf(logstr1, "ADS1255 result=%li\n\r",input_buffer.int32); - #endif - - if (input_buffer.int32 > ADS_OVERCURRENT_THRESHOLD || (-1*input_buffer.int32) > (ADS_OVERCURRENT_THRESHOLD)) - { - over_under[buffer_iter] = 1; - if (buffer_iter == (ADS_OVER_UNDER_SAMPLES - 1)) - buffer_iter = 0; - else - buffer_iter++; - } - else if (input_buffer.int32 < ADS_UNDERCURRENT_THRESHOLD && (input_buffer.int32*-1) < (ADS_UNDERCURRENT_THRESHOLD)) - { - over_under[buffer_iter] = -1; - if (buffer_iter == (ADS_OVER_UNDER_SAMPLES - 1)) - buffer_iter = 0; - else - buffer_iter++; - } - else - { - over_under[buffer_iter] = 0; - if (buffer_iter == (ADS_OVER_UNDER_SAMPLES - 1)) - buffer_iter = 0; - else - buffer_iter++; - } - - return input_buffer.int32; -} -int16_t ads1255_read_fast(void){ - - - union{ - uint8_t uint[2]; - int16_t int16; - } input_buffer; - -// spi_select_device(&SPIE, &spi_device_conf); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[1] = spi_get(&SPIE); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[0] = spi_get(&SPIE); -// spi_deselect_device(&SPIE, &spi_device_conf); - - - usart_spi_select_device(&USARTE1, &spi_device_conf); - - for (int i = 1; i >= 0; --i){ - while (usart_data_register_is_empty(&USARTE1) == false); - usart_put(&USARTE1, CONFIG_USART_SPI_DUMMY); - while (usart_rx_is_complete(&USARTE1) == false); - input_buffer.uint[i] = usart_get(&USARTE1); - } - while (!usart_tx_is_complete(&USARTE1)); - usart_clear_tx_complete(&USARTE1); - - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - -// printf("ADS1255 result=%x\n\r", input_buffer.int16); - - return input_buffer.int16; -} - -int16_t ads1255_read_fast_single(void){ - - - union{ - uint8_t uint[2]; - int16_t int16; - } input_buffer; - -// uint8_t commandbuffer = ADS_RDATA; - -// spi_select_device(&SPIE, &spi_device_conf); -// spi_write_packet(&SPIE, &commandbuffer,1); -// delay_us(6.5); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[1] = spi_get(&SPIE); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[0] = spi_get(&SPIE); -// spi_deselect_device(&SPIE, &spi_device_conf); - - usart_spi_select_device(&USARTE1, &spi_device_conf); - usart_spi_transmit(&USARTE1, ADS_RDATA); - delay_us(6.5); - for (int i = 1; i >= 0; --i){ - while (usart_data_register_is_empty(&USARTE1) == false); - usart_put(&USARTE1, CONFIG_USART_SPI_DUMMY); - while (usart_rx_is_complete(&USARTE1) == false); - input_buffer.uint[i] = usart_get(&USARTE1); - } - while (!usart_tx_is_complete(&USARTE1)); - usart_clear_tx_complete(&USARTE1); - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - - ads1255_standby(); - - #ifdef ADS1255_DBG - printf("ADS1255 result=%li\n\r", input_buffer.int16); - #endif - - return input_buffer.int16; -} - -int32_t ads1255_read(void){ - -/* irqflags_t flags;*/ - union{ - uint8_t uint[4]; - int32_t int32; - } input_buffer; - - //int32_t returnvalue = 0; - -/* while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3)));*/ - -/* flags = cpu_irq_save();*/ - -// spi_select_device(&SPIE, &spi_device_conf); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[2] = spi_get(&SPIE); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[1] = spi_get(&SPIE); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[0] = spi_get(&SPIE); -// -// spi_deselect_device(&SPIE, &spi_device_conf); -/* cpu_irq_restore(flags);*/ - - usart_spi_select_device(&USARTE1, &spi_device_conf); - for (int i = 2; i >= 0; --i) - { - while (usart_data_register_is_empty(&USARTE1) == false); - usart_put(&USARTE1, CONFIG_USART_SPI_DUMMY); - while (usart_rx_is_complete(&USARTE1) == false); - input_buffer.uint[i] = usart_get(&USARTE1); - } - while (!usart_tx_is_complete(&USARTE1)); - usart_clear_tx_complete(&USARTE1); - -// usart_spi_read_packet(&USARTE1, (uint8_t*)&(input_buffer.uint[2]),1); -// usart_spi_read_packet(&USARTE1, (uint8_t*)&(input_buffer.uint[1]),1); -// usart_spi_read_packet(&USARTE1, (uint8_t*)&(input_buffer.uint[0]),1); - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - -// printf("%x, %x, %x\n\r", input_buffer.uint[2],input_buffer.uint[1], input_buffer.uint[0]); - - if (input_buffer.uint[2] > 0x7F) - input_buffer.uint[3] = 0xFF; - else - input_buffer.uint[3] = 0x0; - - #ifdef ADS1255_DBG - printf("ADS1255 result=%li\n\r", input_buffer.int32); - #endif - - if (input_buffer.int32 > ADS_OVERCURRENT_THRESHOLD || (-1*input_buffer.int32) > (ADS_OVERCURRENT_THRESHOLD)) - { - over_under[buffer_iter] = 1; - if (buffer_iter == (ADS_OVER_UNDER_SAMPLES - 1)) - buffer_iter = 0; - else - buffer_iter++; - } - else if (input_buffer.int32 < ADS_UNDERCURRENT_THRESHOLD && (input_buffer.int32*-1) < (ADS_UNDERCURRENT_THRESHOLD)) - { - over_under[buffer_iter] = -1; - if (buffer_iter == (ADS_OVER_UNDER_SAMPLES - 1)) - buffer_iter = 0; - else - buffer_iter++; - } - else - { - over_under[buffer_iter] = 0; - if (buffer_iter == (ADS_OVER_UNDER_SAMPLES - 1)) - buffer_iter = 0; - else - buffer_iter++; - } - - return input_buffer.int32; -} - -int32_t ads1255_read_fast24(void){ - - union{ - uint8_t uint[4]; - int32_t int32; - } input_buffer; - - input_buffer.int32 = 0; - -// spi_select_device(&SPIE, &spi_device_conf); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[2] = spi_get(&SPIE); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[1] = spi_get(&SPIE); -// spi_write_single(&SPIE, CONFIG_SPI_MASTER_DUMMY); -// while(!spi_is_rx_full(&SPIE)); -// input_buffer.uint[0] = spi_get(&SPIE); -// -// spi_deselect_device(&SPIE, &spi_device_conf); - - usart_spi_select_device(&USARTE1, &spi_device_conf); - for (int i = 2; i >= 0; --i){ - while (usart_data_register_is_empty(&USARTE1) == false); - usart_put(&USARTE1, CONFIG_USART_SPI_DUMMY); - while (usart_rx_is_complete(&USARTE1) == false); - input_buffer.uint[i] = usart_get(&USARTE1); - } - while (!usart_tx_is_complete(&USARTE1)); - usart_clear_tx_complete(&USARTE1); - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - - if (input_buffer.uint[2] > 0x7F) - input_buffer.uint[3] = 0xFF; - else - input_buffer.uint[3] = 0x0; - - printf("%x, %x, %x\n\r", input_buffer.uint[2],input_buffer.uint[1], input_buffer.uint[0]); - - return input_buffer.int32; -} - - -void ads1255_reg_read(uint8_t address){ - uint8_t command_buffer[2]; - command_buffer[0] = address; - command_buffer[0] |= (1 << 4); - command_buffer[1] = 4; - uint8_t input_buffer[5]; - -// spi_select_device(&SPIE, &spi_device_conf); -// //delay_us(50); -// -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); -// -// spi_write_packet(&SPIE, &command_buffer[0], 2); -// delay_us(6.5); -// spi_read_packet(&SPIE, (uint8_t*) &input_buffer, 5); -// spi_deselect_device(&SPIE, &spi_device_conf); - - usart_spi_select_device(&USARTE1, &spi_device_conf); - - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - - usart_spi_write_packet(&USARTE1, &(command_buffer[0]), 2); - delay_us(6.5); - usart_spi_read_packet(&USARTE1, (uint8_t*) &input_buffer, 5); - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - - for (int i=0;i<5;i++) - { - printf("ADS1255: Register %u=%.2x\n\r",i+1,input_buffer[i]); - } - - return; -} - -void ads1255_reset(){ -// uint8_t command_buffer = ADS_RESET; -// -// spi_select_device(&SPIE, &spi_device_conf); -// //delay_us(50); -// -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); -// spi_write_packet(&SPIE, (uint8_t*) &command_buffer, 1); -// - - usart_spi_select_device(&USARTE1, &spi_device_conf); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - usart_spi_transmit(&USARTE1, ADS_RESET); - - #ifdef ADS1255_DBG - printf("ADS1255: Sending RESET\n\r"); - printf("ADS1255: Waiting for calibration\n\r"); - #endif - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); - -// spi_deselect_device(&SPIE, &spi_device_conf); - - return; -} - -void ads1255_setup(uint8_t buff, uint8_t rate, uint8_t pga){ -// uint8_t ctrlbuffer = ADS_SDATAC; - uint8_t command_buffer[6] = {0x50,0x03,buff,0x01,pga,rate}; - -// spi_select_device(&SPIE, &spi_device_conf); -// //delay_us(50); -// -// //while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); -// -// spi_write_packet(&SPIE, &ctrlbuffer, 1); -// //while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); -// -// spi_write_packet(&SPIE, (uint8_t*)&command_buffer, 6); -// -// ctrlbuffer = ADS_SYNC; -// spi_write_packet(&SPIE, &ctrlbuffer, 1); -// ctrlbuffer = ADS_SELFCAL; -// spi_write_packet(&SPIE, &ctrlbuffer, 1); -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); -// -// -// spi_deselect_device(&SPIE, &spi_device_conf); - - usart_spi_select_device(&USARTE1, &spi_device_conf); -// usart_spi_transmit(&USARTE1, ADS_SDATAC); - usart_spi_transmit(&USARTE1, ADS_SDATAC); - usart_spi_write_packet(&USARTE1, (uint8_t*)&command_buffer, 6); - usart_spi_transmit(&USARTE1, ADS_SYNC); - usart_spi_transmit(&USARTE1, ADS_SELFCAL); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - - return; -} - -void ads1255_standby(void){ -// uint8_t ctrlbuffer = ADS_STANDBY; -// -// spi_select_device(&SPIE, &spi_device_conf); -// spi_write_packet(&SPIE, &ctrlbuffer, 1); -// spi_deselect_device(&SPIE, &spi_device_conf); - - usart_spi_select_device(&USARTE1, &spi_device_conf); - usart_spi_transmit(&USARTE1, ADS_STANDBY); - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - - return; -} - -void ads1255_wakeup(void){ -// uint8_t ctrlbuffer = ADS_WAKEUP; -// -// spi_select_device(&SPIE, &spi_device_conf); -// spi_write_packet(&SPIE, &ctrlbuffer, 1); -// spi_deselect_device(&SPIE, &spi_device_conf); - - usart_spi_select_device(&USARTE1, &spi_device_conf); - usart_spi_transmit(&USARTE1, ADS_WAKEUP); - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - - return; -} - -void ads1255_rdatac(void){ -// uint8_t ctrlbuffer = ADS_RDATAC; -// -// spi_select_device(&SPIE, &spi_device_conf); -// //delay_us(50); -// -// spi_write_packet(&SPIE, &ctrlbuffer, 1); -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); -// -// spi_deselect_device(&SPIE, &spi_device_conf); - - usart_spi_select_device(&USARTE1, &spi_device_conf); - usart_spi_transmit(&USARTE1, ADS_RDATAC); -// while(!usart_spi_is_rx_full(&USARTE1)); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - usart_spi_deselect_device(&USARTE1, &spi_device_conf); - - return; -} \ No newline at end of file diff --git a/DSTAT1/src/ads1255.h b/DSTAT1/src/ads1255.h deleted file mode 100644 index d9a4cb6..0000000 --- a/DSTAT1/src/ads1255.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * ads1255.h - * - * Created: 05/03/2012 12:19:33 AM - * Author: mdryden - */ - - -#ifndef ADS1255_H_ -#define ADS1255_H_ - -//#define ADS1255_DBG - -#define ADS_WAKEUP 0x0 -#define ADS_RDATA 0x01 -#define ADS_RDATAC 0x03 -#define ADS_SDATAC 0x0f -#define ADS_SELFCAL 0xf0 -#define ADS_SELFOCAL 0xf1 -#define ADS_SELFGCAL 0xf2 -#define ADS_SYSOCAL 0xf3 -#define ADS_SYSGCAL 0xf4 -#define ADS_SYNC 0xfc -#define ADS_STANDBY 0xfd -#define ADS_RESET 0xfe - -#define ADS_DR_2_5 0b00000011 -#define ADS_DR_5 0b00010011 -#define ADS_DR_10 0b00100011 -#define ADS_DR_15 0b00110011 -#define ADS_DR_25 0b01000011 -#define ADS_DR_30 0b01010011 -#define ADS_DR_50 0b01100011 -#define ADS_DR_60 0b01110010 -#define ADS_DR_100 0b10000010 -#define ADS_DR_500 0b10010010 -#define ADS_DR_1000 0b10100001 -#define ADS_DR_2000 0b10110000 -#define ADS_DR_3750 0b11000000 -#define ADS_DR_7500 0b11010000 -#define ADS_DR_15000 0b11100000 -#define ADS_DR_30000 0b11110000 - -#define ADS_PGA_1 0b000 -#define ADS_PGA_2 0b001 -#define ADS_PGA_4 0b010 -#define ADS_PGA_8 0b011 -#define ADS_PGA_16 0b100 -#define ADS_PGA_32 0b101 -#define ADS_PGA_64 0b110 - -#define ADS_BUFF_OFF 0b0000 -#define ADS_BUFF_ON 0b0010 - -#define ADS_OVERCURRENT_THRESHOLD 6000000L -#define ADS_UNDERCURRENT_THRESHOLD 200000L -#define ADS_OVER_UNDER_SAMPLES 3 - -#include -#include - -int8_t over_under[ADS_OVER_UNDER_SAMPLES]; - -void ads1255_sync(void); -void ads1255_init_pins(void); -void ads1255_init_module(void); -int32_t ads1255_single_read(void); -int32_t ads1255_read(void); -int16_t ads1255_read_fast(void); -int16_t ads1255_read_fast_single(void); -int32_t ads1255_read_fast24(void); -void ads1255_reg_read(uint8_t address); -void ads1255_reset(void); -void ads1255_setup(uint8_t buff, uint8_t rate, uint8_t pga); -void ads1255_standby(void); -void ads1255_wakeup(void); -void ads1255_rdatac(void); - - - -#endif /* ADS1255_H_ */ - diff --git a/DSTAT1/src/algorithm b/DSTAT1/src/algorithm deleted file mode 100644 index 1ba584f..0000000 --- a/DSTAT1/src/algorithm +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_ALGORITHM -#define __SGI_STL_ALGORITHM - -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_ALGORITHM */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/asf.h b/DSTAT1/src/asf.h deleted file mode 100644 index e44fdfe..0000000 --- a/DSTAT1/src/asf.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - * \file - * - * \brief Autogenerated API include file for the Atmel Software Framework (ASF) - * - * Copyright (c) 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef ASF_H -#define ASF_H - -/* - * This file includes all API header files for the selected drivers from ASF. - * Note: There might be duplicate includes required by more than one driver. - * - * The file is automatically generated and will be re-written when - * running the ASF driver selector tool. Any changes will be discarded. - */ - -// From module: CPU specific features -#include -#include - -// From module: Generic board support -#include - -// From module: IOPORT - Input/Output Port Controller -#include - -// From module: Interrupt management - XMEGA implementation -#include - -// From module: NVM - Non Volatile Memory -#include - -// From module: PMIC - Programmable Multi-level Interrupt Controller -#include - -// From module: RTC - Real Time Counter -#include - -// From module: SPI - Serial Peripheral Interface -#include - -// From module: SPI - XMEGA implementation -#include -#include -//#include - -// From module: Sleep Controller driver -#include - -// From module: Sleep manager - XMEGA A/AU/B/D implementation -#include -#include - -// From module: System Clock Control - XMEGA A1U/A3U/A3BU/A4U implementation -#include - -// From module: TC - Timer Counter -#include - -// From module: TIMING - Delay routines -#include - -// From module: USART - Universal Synchronous/Asynchronous Receiver/Transmitter -#include - -// From module: USB CDC Protocol -#include - -// From module: USB Device CDC (Single Interface Device) -#include - -// From module: USB Device Stack Core -#include -#include - -// From module: USB/CDC Standard I/O (stdio) -#include - -// From module: XMEGA compiler driver -#include -#include -#include - -#endif // ASF_H diff --git a/DSTAT1/src/asf/common/boards/board.h b/DSTAT1/src/asf/common/boards/board.h deleted file mode 100644 index 2ea9962..0000000 --- a/DSTAT1/src/asf/common/boards/board.h +++ /dev/null @@ -1,264 +0,0 @@ -/** - * \file - * - * \brief Standard board header file. - * - * This file includes the appropriate board header file according to the - * defined board (parameter BOARD). - * - * Copyright (c) 2009-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _BOARD_H_ -#define _BOARD_H_ - -/** - * \defgroup group_common_boards Generic board support - * - * The generic board support module includes board-specific definitions - * and function prototypes, such as the board initialization function. - * - * \{ - */ - -#include "compiler.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/*! \name Base Boards - */ -//! @{ -#define EVK1100 1 //!< AT32UC3A EVK1100 board. -#define EVK1101 2 //!< AT32UC3B EVK1101 board. -#define UC3C_EK 3 //!< AT32UC3C UC3C_EK board. -#define EVK1104 4 //!< AT32UC3A3 EVK1104 board. -#define EVK1105 5 //!< AT32UC3A EVK1105 board. -#define STK600_RCUC3L0 6 //!< STK600 RCUC3L0 board. -#define UC3L_EK 7 //!< AT32UC3L-EK board. -#define XPLAIN 8 //!< ATxmega128A1 Xplain board. -#define STK600_RC064X 10 //!< ATxmega256A3 STK600 board. -#define STK600_RC100X 11 //!< ATxmega128A1 STK600 board. -#define UC3_A3_XPLAINED 13 //!< ATUC3A3 UC3-A3 Xplained board. -#define UC3_C2_XPLAINED 14 //!< ATUC3A3 UC3-C2 Xplained board. -#define UC3_L0_XPLAINED 15 //!< ATUC3L0 UC3-L0 Xplained board. -#define STK600_RCUC3D 16 //!< STK600 RCUC3D board. -#define STK600_RCUC3C0 17 //!< STK600 RCUC3C board. -#define XMEGA_B1_XPLAINED 18 //!< ATxmega128B1 Xplained board. -#define XMEGA_A1_XPLAINED 19 //!< ATxmega128A1 Xplain-A1 board. -#define STK600_RCUC3L4 21 //!< ATUCL4 STK600 board -#define UC3_L0_XPLAINED_BC 22 //!< ATUC3L0 UC3-L0 Xplained board controller board -#define MEGA1284P_XPLAINED_BC 23 //!< ATmega1284P-Xplained board controller board -#define STK600_RC044X 24 //!< STK600 with RC044X routing card board. -#define STK600_RCUC3B 25 //!< STK600 RCUC3B board. -#define UC3_L0_QT600 26 //!< QT600 UC3L0 MCU board. -#define XMEGA_A3BU_XPLAINED 27 //!< ATxmega256A3BU Xplained board. -#define STK600_RC064X_LCDX 28 //!< XMEGAB3 STK600 RC064X LCDX board. -#define STK600_RC100X_LCDX 29 //!< XMEGAB1 STK600 RC100X LCDX board. -#define UC3B_BOARD_CONTROLLER 30 //!< AT32UC3B1 board controller for Atmel boards -#define RZ600 31 //!< AT32UC3A RZ600 MCU board. -#define SAM3S_EK 32 //!< SAM3S-EK board. -#define SAM3U_EK 33 //!< SAM3U-EK board. -#define SAM3X_EK 34 //!< SAM3X-EK board. -#define SAM3N_EK 35 //!< SAM3N-EK board. -#define SAM3S_EK2 36 //!< SAM3S-EK2 board. -#define SAM4S_EK 37 //!< SAM4S-EK board. -#define SIMULATOR_XMEGA_A1 97 //!< Simulator for XMEGA A1 devices -#define AVR_SIMULATOR_UC3 98 //!< AVR SIMULATOR for AVR UC3 device family. -#define USER_BOARD 99 //!< User-reserved board (if any). -#define DUMMY_BOARD 100 //!< Dummy board to support board-independent applications (e.g. bootloader) -//! @} - -/*! \name Extension Boards - */ -//! @{ -#define EXT1102 1 //!< AT32UC3B EXT1102 board -#define MC300 2 //!< AT32UC3 MC300 board -#define SENSORS_XPLAINED_INERTIAL_1 3 //!< Xplained inertial sensor board 1 -#define SENSORS_XPLAINED_INERTIAL_2 4 //!< Xplained inertial sensor board 2 -#define SENSORS_XPLAINED_PRESSURE_1 5 //!< Xplained pressure sensor board -#define SENSORS_XPLAINED_LIGHTPROX_1 6 //!< Xplained light & proximity sensor board -#define SENSORS_XPLAINED_INERTIAL_A1 7 //!< Xplained inertial sensor board "A" -#define RZ600_AT86RF231 8 //!< AT86RF231 RF board in RZ600 -#define RZ600_AT86RF230B 9 //!< AT86RF231 RF board in RZ600 -#define RZ600_AT86RF212 10 //!< AT86RF231 RF board in RZ600 -#define SENSORS_XPLAINED_BREADBOARD 11 //!< Xplained sensor development breadboard - -#define USER_EXT_BOARD 99 //!< User-reserved extension board (if any). -//! @} - -#if BOARD == EVK1100 - #include "evk1100/evk1100.h" -#elif BOARD == EVK1101 - #include "evk1101/evk1101.h" -#elif BOARD == UC3C_EK - #include "uc3c_ek/uc3c_ek.h" -#elif BOARD == EVK1104 - #include "evk1104/evk1104.h" -#elif BOARD == EVK1105 - #include "evk1105/evk1105.h" -#elif BOARD == STK600_RCUC3L0 - #include "stk600/rcuc3l0/stk600_rcuc3l0.h" -#elif BOARD == UC3L_EK - #include "uc3l_ek/uc3l_ek.h" -#elif BOARD == STK600_RCUC3L4 - #include "stk600/rcuc3l4/stk600_rcuc3l4.h" -#elif BOARD == XPLAIN - #include "xplain/xplain.h" -#elif BOARD == STK600_RC044X - #include "stk600/rc044x/stk600_rc044x.h" -#elif BOARD == STK600_RC064X - #include "stk600/rc064x/stk600_rc064x.h" -#elif BOARD == STK600_RC100X - #include "stk600/rc100x/stk600_rc100x.h" -#elif BOARD == UC3_A3_XPLAINED - #include "uc3_a3_xplained/uc3_a3_xplained.h" -#elif BOARD == UC3_C2_XPLAINED - #include "uc3_c2_xplained/uc3_c2_xplained.h" - #elif BOARD == UC3_L0_XPLAINED - #include "uc3_l0_xplained/uc3_l0_xplained.h" -#elif BOARD == STK600_RCUC3B - #include "stk600/rcuc3b/stk600_rcuc3b.h" -#elif BOARD == STK600_RCUC3D - #include "stk600/rcuc3d/stk600_rcuc3d.h" -#elif BOARD == STK600_RCUC3C0 - #include "stk600/rcuc3c0/stk600_rcuc3c0.h" -#elif BOARD == XMEGA_B1_XPLAINED - #include "xmega_b1_xplained/xmega_b1_xplained.h" -#elif BOARD == STK600_RC064X_LCDX - #include "stk600/rc064x_lcdx/stk600_rc064x_lcdx.h" -#elif BOARD == STK600_RC100X_LCDX - #include "stk600/rc100x_lcdx/stk600_rc100x_lcdx.h" -#elif BOARD == XMEGA_A1_XPLAINED - #include "xmega_a1_xplained/xmega_a1_xplained.h" -#elif BOARD == UC3_L0_XPLAINED_BC - #include "uc3_l0_xplained_bc/uc3_l0_xplained_bc.h" -#elif BOARD == SAM3S_EK - #include "sam3s_ek/sam3s_ek.h" - #include "system_sam3s.h" -#elif BOARD == SAM3S_EK2 - #include "sam3s_ek2/sam3s_ek2.h" - #include "system_sam3sd8.h" -#elif BOARD == SAM3U_EK - #include "sam3u_ek/sam3u_ek.h" - #include "system_sam3u.h" -#elif BOARD == SAM3X_EK - #include "sam3x_ek/sam3x_ek.h" - #include "system_sam3x.h" -#elif BOARD == SAM3N_EK - #include "sam3n_ek/sam3n_ek.h" - #include "system_sam3n.h" -#elif BOARD == SAM4S_EK - #include "sam4s_ek/sam4s_ek.h" - #include "system_sam4s.h" -#elif BOARD == MEGA1284P_XPLAINED_BC - #include "mega1284p_xplained_bc/mega1284p_xplained_bc.h" -#elif BOARD == UC3_L0_QT600 - #include "uc3_l0_qt600/uc3_l0_qt600.h" -#elif BOARD == XMEGA_A3BU_XPLAINED - #include "xmega_a3bu_xplained/xmega_a3bu_xplained.h" -#elif BOARD == UC3B_BOARD_CONTROLLER - #include "uc3b_board_controller/uc3b_board_controller.h" -#elif BOARD == RZ600 - #include "rz600/rz600.h" -#elif BOARD == SIMULATOR_XMEGA_A1 - #include "simulator/xmega_a1/simulator_xmega_a1.h" -#elif BOARD == AVR_SIMULATOR_UC3 - #include "avr_simulator_uc3/avr_simulator_uc3.h" -#elif BOARD == USER_BOARD - // User-reserved area: #include the header file of your board here (if any). - #include "user_board.h" -#elif BOARD == DUMMY_BOARD - #include "dummy/dummy_board.h" -#else - #error No known AVR board defined -#endif - -#if (defined EXT_BOARD) - #if EXT_BOARD == MC300 - #include "mc300/mc300.h" - #elif (EXT_BOARD == SENSORS_XPLAINED_INERTIAL_1) || \ - (EXT_BOARD == SENSORS_XPLAINED_INERTIAL_2) || \ - (EXT_BOARD == SENSORS_XPLAINED_INERTIAL_A1) || \ - (EXT_BOARD == SENSORS_XPLAINED_PRESSURE_1) || \ - (EXT_BOARD == SENSORS_XPLAINED_LIGHTPROX_1) || \ - (EXT_BOARD == SENSORS_XPLAINED_BREADBOARD) - #include "sensors_xplained/sensors_xplained.h" - #elif EXT_BOARD == RZ600_AT86RF231 - #include "at86rf231/at86rf231.h" - #elif EXT_BOARD == RZ600_AT86RF230B - #include "at86rf230b/at86rf230b.h" - #elif EXT_BOARD == RZ600_AT86RF212 - #include "at86rf212/at86rf212.h" - #elif EXT_BOARD == USER_EXT_BOARD - // User-reserved area: #include the header file of your extension board here - // (if any). - #endif -#endif - - -#if (defined(__GNUC__) && defined(__AVR32__)) || (defined(__ICCAVR32__) || defined(__AAVR32__)) -#ifdef __AVR32_ABI_COMPILER__ // Automatically defined when compiling for AVR32, not when assembling. - -/*! \brief This function initializes the board target resources - * - * This function should be called to ensure proper initialization of the target - * board hardware connected to the part. - */ -extern void board_init(void); - -#endif // #ifdef __AVR32_ABI_COMPILER__ -#else -/*! \brief This function initializes the board target resources - * - * This function should be called to ensure proper initialization of the target - * board hardware connected to the part. - */ -extern void board_init(void); -#endif - - -#ifdef __cplusplus -} -#endif - -/** - * \} - */ - -#endif // _BOARD_H_ diff --git a/DSTAT1/src/asf/common/boards/user_board/init.c b/DSTAT1/src/asf/common/boards/user_board/init.c deleted file mode 100644 index d849882..0000000 --- a/DSTAT1/src/asf/common/boards/user_board/init.c +++ /dev/null @@ -1,17 +0,0 @@ -/** - * \file - * - * \brief User board initialization template - * - */ - -#include -#include - -void board_init(void) -{ - /* This function is meant to contain board-specific initialization code - * for, e.g., the I/O pins. The initialization can rely on application- - * specific board configuration, found in conf_board.h. - */ -} diff --git a/DSTAT1/src/asf/common/boards/user_board/user_board.h b/DSTAT1/src/asf/common/boards/user_board/user_board.h deleted file mode 100644 index 84b3c24..0000000 --- a/DSTAT1/src/asf/common/boards/user_board/user_board.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * \file - * - * \brief User board definition template - * - */ - -#ifndef USER_BOARD_H -#define USER_BOARD_H - -/* This file is intended to contain definitions and configuration details for - * features and devices that are available on the board, e.g., frequency and - * startup time for an external crystal, external memory devices, LED and USART - * pins. - */ - -#endif // USER_BOARD_H diff --git a/DSTAT1/src/asf/common/services/clock/genclk.h b/DSTAT1/src/asf/common/services/clock/genclk.h deleted file mode 100644 index d8f1f62..0000000 --- a/DSTAT1/src/asf/common/services/clock/genclk.h +++ /dev/null @@ -1,172 +0,0 @@ -/** - * \file - * - * \brief Generic clock management - * - * Copyright (c) 2010-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef CLK_GENCLK_H_INCLUDED -#define CLK_GENCLK_H_INCLUDED - -#include "parts.h" - -#if SAM3S -# include "sam3s/genclk.h" -#elif SAM3U -# include "sam3u/genclk.h" -#elif SAM3N -# include "sam3n/genclk.h" -#elif SAM3XA -# include "sam3x/genclk.h" -#elif SAM4S -# include "sam4s/genclk.h" -#elif (UC3A0 || UC3A1) -# include "uc3a0_a1/genclk.h" -#elif UC3A3 -# include "uc3a3_a4/genclk.h" -#elif UC3B -# include "uc3b0_b1/genclk.h" -#elif UC3C -# include "uc3c/genclk.h" -#elif UC3D -# include "uc3d/genclk.h" -#elif UC3L -# include "uc3l/genclk.h" -#else -# error Unsupported chip type -#endif - -/** - * \ingroup clk_group - * \defgroup genclk_group Generic Clock Management - * - * Generic clocks are configurable clocks which run outside the system - * clock domain. They are often connected to peripherals which have an - * asynchronous component running independently of the bus clock, e.g. - * USB controllers, low-power timers and RTCs, etc. - * - * Note that not all platforms have support for generic clocks; on such - * platforms, this API will not be available. - * - * @{ - */ - -/** - * \def GENCLK_DIV_MAX - * \brief Maximum divider supported by the generic clock implementation - */ -/** - * \enum genclk_source - * \brief Generic clock source ID - * - * Each generic clock may be generated from a different clock source. - * These are the available alternatives provided by the chip. - */ - -//! \name Generic clock configuration -//@{ -/** - * \struct genclk_config - * \brief Hardware representation of a set of generic clock parameters - */ -/** - * \fn void genclk_config_defaults(struct genclk_config *cfg, - * unsigned int id) - * \brief Initialize \a cfg to the default configuration for the clock - * identified by \a id. - */ -/** - * \fn void genclk_config_read(struct genclk_config *cfg, unsigned int id) - * \brief Read the currently active configuration of the clock - * identified by \a id into \a cfg. - */ -/** - * \fn void genclk_config_write(const struct genclk_config *cfg, - * unsigned int id) - * \brief Activate the configuration \a cfg on the clock identified by - * \a id. - */ -/** - * \fn void genclk_config_set_source(struct genclk_config *cfg, - * enum genclk_source src) - * \brief Select a new source clock \a src in configuration \a cfg. - */ -/** - * \fn void genclk_config_set_divider(struct genclk_config *cfg, - * unsigned int divider) - * \brief Set a new \a divider in configuration \a cfg. - */ -/** - * \fn void genclk_enable_source(enum genclk_source src) - * \brief Enable the source clock \a src used by a generic clock. - */ - //@} - -//! \name Enabling and disabling Generic Clocks -//@{ -/** - * \fn void genclk_enable(const struct genclk_config *cfg, unsigned int id) - * \brief Activate the configuration \a cfg on the clock identified by - * \a id and enable it. - */ -/** - * \fn void genclk_disable(unsigned int id) - * \brief Disable the generic clock identified by \a id. - */ -//@} - -/** - * \brief Enable the configuration defined by \a src and \a divider - * for the generic clock identified by \a id. - * - * \param id The ID of the generic clock. - * \param src The source clock of the generic clock. - * \param divider The divider used to generate the generic clock. - */ -static inline void genclk_enable_config(unsigned int id, enum genclk_source src, unsigned int divider) -{ - struct genclk_config gcfg; - - genclk_config_defaults(&gcfg, id); - genclk_enable_source(src); - genclk_config_set_source(&gcfg, src); - genclk_config_set_divider(&gcfg, divider); - genclk_enable(&gcfg, id); -} - -//! @} - -#endif /* CLK_GENCLK_H_INCLUDED */ diff --git a/DSTAT1/src/asf/common/services/clock/osc.h b/DSTAT1/src/asf/common/services/clock/osc.h deleted file mode 100644 index 7dc331b..0000000 --- a/DSTAT1/src/asf/common/services/clock/osc.h +++ /dev/null @@ -1,158 +0,0 @@ -/** - * \file - * - * \brief Oscillator management - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef OSC_H_INCLUDED -#define OSC_H_INCLUDED - -#include "parts.h" -#include "conf_clock.h" - -#if SAM3S -# include "sam3s/osc.h" -#elif SAM3XA -# include "sam3x/osc.h" -#elif SAM3U -# include "sam3u/osc.h" -#elif SAM3N -# include "sam3n/osc.h" -#elif SAM4S -# include "sam4s/osc.h" -#elif (UC3A0 || UC3A1) -# include "uc3a0_a1/osc.h" -#elif UC3A3 -# include "uc3a3_a4/osc.h" -#elif UC3B -# include "uc3b0_b1/osc.h" -#elif UC3C -# include "uc3c/osc.h" -#elif UC3D -# include "uc3d/osc.h" -#elif UC3L -# include "uc3l/osc.h" -#elif XMEGA -# include "xmega/osc.h" -#else -# error Unsupported chip type -#endif - -/** - * \ingroup clk_group - * \defgroup osc_group Oscillator Management - * - * This group contains functions and definitions related to configuring - * and enabling/disabling on-chip oscillators. Internal RC-oscillators, - * external crystal oscillators and external clock generators are - * supported by this module. What all of these have in common is that - * they swing at a fixed, nominal frequency which is normally not - * adjustable. - * - * \par Example: Enabling an oscillator - * - * The following example demonstrates how to enable the external - * oscillator on XMEGA A and wait for it to be ready to use. The - * oscillator identifiers are platform-specific, so while the same - * procedure is used on all platforms, the parameter to osc_enable() - * will be different from device to device. - * \code - osc_enable(OSC_ID_XOSC); - osc_wait_ready(OSC_ID_XOSC); \endcode - * - * \section osc_group_board Board-specific Definitions - * If external oscillators are used, the board code must provide the - * following definitions for each of those: - * - \b BOARD__HZ: The nominal frequency of the oscillator. - * - \b BOARD__STARTUP_US: The startup time of the - * oscillator in microseconds. - * - \b BOARD__TYPE: The type of oscillator connected, i.e. - * whether it's a crystal or external clock, and sometimes what kind - * of crystal it is. The meaning of this value is platform-specific. - * - * @{ - */ - -//! \name Oscillator Management -//@{ -/** - * \fn void osc_enable(uint8_t id) - * \brief Enable oscillator \a id - * - * The startup time and mode value is automatically determined based on - * definitions in the board code. - */ -/** - * \fn void osc_disable(uint8_t id) - * \brief Disable oscillator \a id - */ -/** - * \fn osc_is_ready(uint8_t id) - * \brief Determine whether oscillator \a id is ready. - * \retval true Oscillator \a id is running and ready to use as a clock - * source. - * \retval false Oscillator \a id is not running. - */ -/** - * \fn uint32_t osc_get_rate(uint8_t id) - * \brief Return the frequency of oscillator \a id in Hz - */ - -#ifndef __ASSEMBLY__ - -/** - * \brief Wait until the oscillator identified by \a id is ready - * - * This function will busy-wait for the oscillator identified by \a id - * to become stable and ready to use as a clock source. - * - * \param id A number identifying the oscillator to wait for. - */ -static inline void osc_wait_ready(uint8_t id) -{ - while (!osc_is_ready(id)) { - /* Do nothing */ - } -} - -#endif /* __ASSEMBLY__ */ - -//@} - -//! @} - -#endif /* OSC_H_INCLUDED */ diff --git a/DSTAT1/src/asf/common/services/clock/pll.h b/DSTAT1/src/asf/common/services/clock/pll.h deleted file mode 100644 index 1e700c3..0000000 --- a/DSTAT1/src/asf/common/services/clock/pll.h +++ /dev/null @@ -1,314 +0,0 @@ -/** - * \file - * - * \brief PLL management - * - * Copyright (c) 2010-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef CLK_PLL_H_INCLUDED -#define CLK_PLL_H_INCLUDED - -#include "parts.h" -#include "conf_clock.h" - -#if SAM3S -# include "sam3s/pll.h" -#elif SAM3XA -# include "sam3x/pll.h" -#elif SAM3U -# include "sam3u/pll.h" -#elif SAM3N -# include "sam3n/pll.h" -#elif SAM4S -# include "sam4s/pll.h" -#elif (UC3A0 || UC3A1) -# include "uc3a0_a1/pll.h" -#elif UC3A3 -# include "uc3a3_a4/pll.h" -#elif UC3B -# include "uc3b0_b1/pll.h" -#elif UC3C -# include "uc3c/pll.h" -#elif UC3D -# include "uc3d/pll.h" -#elif (UC3L0128 || UC3L0256 || UC3L3_L4) -# include "uc3l/pll.h" -#elif XMEGA -# include "xmega/pll.h" -#else -# error Unsupported chip type -#endif - -/** - * \ingroup clk_group - * \defgroup pll_group PLL Management - * - * This group contains functions and definitions related to configuring - * and enabling/disabling on-chip PLLs. A PLL will take an input signal - * (the \em source), optionally divide the frequency by a configurable - * \em divider, and then multiply the frequency by a configurable \em - * multiplier. - * - * Some devices don't support input dividers; specifying any other - * divisor than 1 on these devices will result in an assertion failure. - * Other devices may have various restrictions to the frequency range of - * the input and output signals. - * - * \par Example: Setting up PLL0 with default parameters - * - * The following example shows how to configure and enable PLL0 using - * the default parameters specified using the configuration symbols - * listed above. - * \code - pll_enable_config_defaults(0); \endcode - * - * To configure, enable PLL0 using the default parameters and to disable - * a specific feature like Wide Bandwidth Mode (a UC3A3-specific - * PLL option.), you can use this initialization process. - * \code - struct pll_config pllcfg; - if (pll_is_locked(pll_id)) { - return; // Pll already running - } - pll_enable_source(CONFIG_PLL0_SOURCE); - pll_config_defaults(&pllcfg, 0); - pll_config_set_option(&pllcfg, PLL_OPT_WBM_DISABLE); - pll_enable(&pllcfg, 0); - pll_wait_for_lock(0); \endcode - * - * When the last function call returns, PLL0 is ready to be used as the - * main system clock source. - * - * \section pll_group_config Configuration Symbols - * - * Each PLL has a set of default parameters determined by the following - * configuration symbols in the application's configuration file: - * - \b CONFIG_PLLn_SOURCE: The default clock source connected to the - * input of PLL \a n. Must be one of the values defined by the - * #pll_source enum. - * - \b CONFIG_PLLn_MUL: The default multiplier (loop divider) of PLL - * \a n. - * - \b CONFIG_PLLn_DIV: The default input divider of PLL \a n. - * - * These configuration symbols determine the result of calling - * pll_config_defaults() and pll_get_default_rate(). - * - * @{ - */ - -//! \name Chip-specific PLL characteristics -//@{ -/** - * \def PLL_MAX_STARTUP_CYCLES - * \brief Maximum PLL startup time in number of slow clock cycles - */ -/** - * \def NR_PLLS - * \brief Number of on-chip PLLs - */ - -/** - * \def PLL_MIN_HZ - * \brief Minimum frequency that the PLL can generate - */ -/** - * \def PLL_MAX_HZ - * \brief Maximum frequency that the PLL can generate - */ -/** - * \def PLL_NR_OPTIONS - * \brief Number of PLL option bits - */ -//@} - -/** - * \enum pll_source - * \brief PLL clock source - */ - -//! \name PLL configuration -//@{ - -/** - * \struct pll_config - * \brief Hardware-specific representation of PLL configuration. - * - * This structure contains one or more device-specific values - * representing the current PLL configuration. The contents of this - * structure is typically different from platform to platform, and the - * user should not access any fields except through the PLL - * configuration API. - */ - -/** - * \fn void pll_config_init(struct pll_config *cfg, - * enum pll_source src, unsigned int div, unsigned int mul) - * \brief Initialize PLL configuration from standard parameters. - * - * \note This function may be defined inline because it is assumed to be - * called very few times, and usually with constant parameters. Inlining - * it will in such cases reduce the code size significantly. - * - * \param cfg The PLL configuration to be initialized. - * \param src The oscillator to be used as input to the PLL. - * \param div PLL input divider. - * \param mul PLL loop divider (i.e. multiplier). - * - * \return A configuration which will make the PLL run at - * (\a mul / \a div) times the frequency of \a src - */ -/** - * \def pll_config_defaults(cfg, pll_id) - * \brief Initialize PLL configuration using default parameters. - * - * After this function returns, \a cfg will contain a configuration - * which will make the PLL run at (CONFIG_PLLx_MUL / CONFIG_PLLx_DIV) - * times the frequency of CONFIG_PLLx_SOURCE. - * - * \param cfg The PLL configuration to be initialized. - * \param pll_id Use defaults for this PLL. - */ -/** - * \def pll_get_default_rate(pll_id) - * \brief Get the default rate in Hz of \a pll_id - */ -/** - * \fn void pll_config_set_option(struct pll_config *cfg, - * unsigned int option) - * \brief Set the PLL option bit \a option in the configuration \a cfg. - * - * \param cfg The PLL configuration to be changed. - * \param option The PLL option bit to be set. - */ -/** - * \fn void pll_config_clear_option(struct pll_config *cfg, - * unsigned int option) - * \brief Clear the PLL option bit \a option in the configuration \a cfg. - * - * \param cfg The PLL configuration to be changed. - * \param option The PLL option bit to be cleared. - */ -/** - * \fn void pll_config_read(struct pll_config *cfg, unsigned int pll_id) - * \brief Read the currently active configuration of \a pll_id. - * - * \param cfg The configuration object into which to store the currently - * active configuration. - * \param pll_id The ID of the PLL to be accessed. - */ -/** - * \fn void pll_config_write(const struct pll_config *cfg, - * unsigned int pll_id) - * \brief Activate the configuration \a cfg on \a pll_id - * - * \param cfg The configuration object representing the PLL - * configuration to be activated. - * \param pll_id The ID of the PLL to be updated. - */ - -//@} - -//! \name Interaction with the PLL hardware -//@{ -/** - * \fn void pll_enable(const struct pll_config *cfg, - * unsigned int pll_id) - * \brief Activate the configuration \a cfg and enable PLL \a pll_id. - * - * \param cfg The PLL configuration to be activated. - * \param pll_id The ID of the PLL to be enabled. - */ -/** - * \fn void pll_disable(unsigned int pll_id) - * \brief Disable the PLL identified by \a pll_id. - * - * After this function is called, the PLL identified by \a pll_id will - * be disabled. The PLL configuration stored in hardware may be affected - * by this, so if the caller needs to restore the same configuration - * later, it should either do a pll_config_read() before disabling the - * PLL, or remember the last configuration written to the PLL. - * - * \param pll_id The ID of the PLL to be disabled. - */ -/** - * \fn bool pll_is_locked(unsigned int pll_id) - * \brief Determine whether the PLL is locked or not. - * - * \param pll_id The ID of the PLL to check. - * - * \retval true The PLL is locked and ready to use as a clock source - * \retval false The PLL is not yet locked, or has not been enabled. - */ -/** - * \fn void pll_enable_source(enum pll_source src) - * \brief Enable the source of the pll. - * The source is enabled, if the source is not already running. - * - * \param src The ID of the PLL source to enable. - */ -/** - * \fn void pll_enable_config_defaults(unsigned int pll_id) - * \brief Enable the pll with the default configuration. - * PLL is enabled, if the PLL is not already locked. - * - * \param pll_id The ID of the PLL to enable. - */ - -/** - * \brief Wait for PLL \a pll_id to become locked - * - * \todo Use a timeout to avoid waiting forever and hanging the system - * - * \param pll_id The ID of the PLL to wait for. - * - * \retval STATUS_OK The PLL is now locked. - * \retval ERR_TIMEOUT Timed out waiting for PLL to become locked. - */ -static inline int pll_wait_for_lock(unsigned int pll_id) -{ - Assert(pll_id < NR_PLLS); - - while (!pll_is_locked(pll_id)) { - /* Do nothing */ - } - - return 0; -} - -//@} -//! @} - -#endif /* CLK_PLL_H_INCLUDED */ diff --git a/DSTAT1/src/asf/common/services/clock/sysclk.h b/DSTAT1/src/asf/common/services/clock/sysclk.h deleted file mode 100644 index 6930f3b..0000000 --- a/DSTAT1/src/asf/common/services/clock/sysclk.h +++ /dev/null @@ -1,163 +0,0 @@ -/** - * \file - * - * \brief System clock management - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef SYSCLK_H_INCLUDED -#define SYSCLK_H_INCLUDED - -#include "parts.h" -#include "conf_clock.h" - -#if SAM3S -# include "sam3s/sysclk.h" -#elif SAM3U -# include "sam3u/sysclk.h" -#elif SAM3N -# include "sam3n/sysclk.h" -#elif SAM3XA -# include "sam3x/sysclk.h" -#elif SAM4S -# include "sam4s/sysclk.h" -#elif (UC3A0 || UC3A1) -# include "uc3a0_a1/sysclk.h" -#elif UC3A3 -# include "uc3a3_a4/sysclk.h" -#elif UC3B -# include "uc3b0_b1/sysclk.h" -#elif UC3C -# include "uc3c/sysclk.h" -#elif UC3D -# include "uc3d/sysclk.h" -#elif UC3L -# include "uc3l/sysclk.h" -#elif XMEGA -# include "xmega/sysclk.h" -#else -# error Unsupported chip type -#endif - -/** - * \defgroup clk_group Clock Management - */ - -/** - * \ingroup clk_group - * \defgroup sysclk_group System Clock Management - * - * The sysclk API covers the system clock and all - * clocks derived from it. The system clock is a chip-internal clock on - * which all synchronous clocks, i.e. CPU and bus/peripheral - * clocks, are based. The system clock is typically generated from one - * of a variety of sources, which may include crystal and RC oscillators - * as well as PLLs. The clocks derived from the system clock are - * sometimes also known as synchronous clocks, since they - * always run synchronously with respect to each other, as opposed to - * generic clocks which may run from different oscillators or - * PLLs. - * - * Most applications should simply call sysclk_init() to initialize - * everything related to the system clock and its source (oscillator, - * PLL or DFLL), and leave it at that. More advanced applications, and - * platform-specific drivers, may require additional services from the - * clock system, some of which may be platform-specific. - * - * \section sysclk_group_platform Platform Dependencies - * - * The sysclk API is partially chip- or platform-specific. While all - * platforms provide mostly the same functionality, there are some - * variations around how different bus types and clock tree structures - * are handled. - * - * The following functions are available on all platforms with the same - * parameters and functionality. These functions may be called freely by - * portable applications, drivers and services: - * - sysclk_init() - * - sysclk_set_source() - * - sysclk_get_main_hz() - * - sysclk_get_cpu_hz() - * - sysclk_get_peripheral_bus_hz() - * - * The following functions are available on all platforms, but there may - * be variations in the function signature (i.e. parameters) and - * behaviour. These functions are typically called by platform-specific - * parts of drivers, and applications that aren't intended to be - * portable: - * - sysclk_enable_peripheral_clock() - * - sysclk_disable_peripheral_clock() - * - sysclk_enable_module() - * - sysclk_disable_module() - * - sysclk_module_is_enabled() - * - sysclk_set_prescalers() - * - * All other functions should be considered platform-specific. - * Enabling/disabling clocks to specific peripherals as well as - * determining the speed of these clocks should be done by calling - * functions provided by the driver for that peripheral. - * - * @{ - */ - -//! \name System Clock Initialization -//@{ -/** - * \fn void sysclk_init(void) - * \brief Initialize the synchronous clock system. - * - * This function will initialize the system clock and its source. This - * includes: - * - Mask all synchronous clocks except for any clocks which are - * essential for normal operation (for example internal memory - * clocks). - * - Set up the system clock prescalers as specified by the - * application's configuration file. - * - Enable the clock source specified by the application's - * configuration file (oscillator or PLL) and wait for it to become - * stable. - * - Set the main system clock source to the clock specified by the - * application's configuration file. - * - * Since all non-essential peripheral clocks are initially disabled, it - * is the responsibility of the peripheral driver to re-enable any - * clocks that are needed for normal operation. - */ -//@} - -//! @} - -#endif /* SYSCLK_H_INCLUDED */ diff --git a/DSTAT1/src/asf/common/services/clock/xmega/osc.h b/DSTAT1/src/asf/common/services/clock/xmega/osc.h deleted file mode 100644 index c6b6c22..0000000 --- a/DSTAT1/src/asf/common/services/clock/xmega/osc.h +++ /dev/null @@ -1,462 +0,0 @@ -/** - * \file - * - * \brief Chip-specific oscillator management functions - * - * Copyright (c) 2010-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef XMEGA_OSC_H_INCLUDED -#define XMEGA_OSC_H_INCLUDED - -#include -#include - -/** - * \weakgroup osc_group - * - * \section osc_group_errata Errata - * - Auto-calibration does not work on XMEGA A1 revision H and - * earlier. - * @{ - */ - -//! \name Oscillator identifiers -//@{ -//! 2 MHz Internal RC Oscillator -#define OSC_ID_RC2MHZ OSC_RC2MEN_bm -//! 32 MHz Internal RC Oscillator -#define OSC_ID_RC32MHZ OSC_RC32MEN_bm -//! 32 KHz Internal RC Oscillator -#define OSC_ID_RC32KHZ OSC_RC32KEN_bm -//! External Oscillator -#define OSC_ID_XOSC OSC_XOSCEN_bm -/** - * \brief Reference from USB Start Of Frame - * \note This cannot be enabled or disabled, but can be used as a reference for - * the autocalibration (DFLL). - */ -#define OSC_ID_USBSOF 0xff -//@} - -//! \name External oscillator types -//@{ -#define XOSC_TYPE_EXTERNAL 0 //!< External clock signal -#define XOSC_TYPE_32KHZ 2 //!< 32.768 kHz resonator on TOSC -#define XOSC_TYPE_XTAL 3 //!< 0.4 to 16 MHz resonator on XTAL -//@} - -/** - * \def CONFIG_XOSC_32KHZ_LPM - * \brief Define for enabling Low Power Mode for 32 kHz external oscillator. - */ -#ifdef __DOXYGEN__ -# define CONFIG_XOSC_32KHZ_LPM -#endif /* __DOXYGEN__ */ - -/** - * \def CONFIG_XOSC_STARTUP - * \brief Board-dependent value that determines the number of start-up cycles - * for external resonators, based on BOARD_XOSC_STARTUP_US. This is written to - * the two MSB of the XOSCSEL field of OSC.XOSCCTRL. - * - * \note This is automatically computed from BOARD_XOSC_HZ and - * BOARD_XOSC_STARTUP_US if it is not manually set. - */ - -//! \name XTAL resonator start-up cycles -//@{ -#define XOSC_STARTUP_256 0 //!< 256 cycle start-up time -#define XOSC_STARTUP_1024 1 //!< 1 k cycle start-up time -#define XOSC_STARTUP_16384 2 //!< 16 k cycle start-up time -//@} - -/** - * \def CONFIG_XOSC_RANGE - * \brief Board-dependent value that sets the frequencye range of the external - * oscillator. This is written to the FRQRANGE field of OSC.XOSCCTRL. - * - * \note This is automatically computed from BOARD_XOSC_HZ if it is not manually - * set. - */ - -//! \name XTAL resonator frequency range -//@{ -//! 0.4 to 2 MHz frequency range -#define XOSC_RANGE_04TO2 OSC_FRQRANGE_04TO2_gc -//! 2 to 9 MHz frequency range -#define XOSC_RANGE_2TO9 OSC_FRQRANGE_2TO9_gc -//! 9 to 12 MHz frequency range -#define XOSC_RANGE_9TO12 OSC_FRQRANGE_9TO12_gc -//! 12 to 16 MHz frequency range -#define XOSC_RANGE_12TO16 OSC_FRQRANGE_12TO16_gc -//@} - -/** - * \def XOSC_STARTUP_TIMEOUT - * \brief Number of us to wait for XOSC to start - * - * This is the number of slow clock cycles corresponding to - * OSC0_STARTUP_VALUE with an additional 25% safety margin. If the - * oscillator isn't running when this timeout has expired, it is assumed - * to have failed to start. - */ - -// If application intends to use XOSC. -#ifdef BOARD_XOSC_HZ -// Get start-up config for XOSC, if not manually set. -# ifndef CONFIG_XOSC_STARTUP -# ifndef BOARD_XOSC_STARTUP_US -# error BOARD_XOSC_STARTUP_US must be configured. -# else -//! \internal Number of start-up cycles for the board's XOSC. -# define BOARD_XOSC_STARTUP_CYCLES \ - (BOARD_XOSC_HZ / 1000000 * BOARD_XOSC_STARTUP_US) - -# if (BOARD_XOSC_TYPE == XOSC_TYPE_XTAL) -# if (BOARD_XOSC_STARTUP_CYCLES > 16384) -# error BOARD_XOSC_STARTUP_US is too high for current BOARD_XOSC_HZ. - -# elif (BOARD_XOSC_STARTUP_CYCLES > 1024) -# define CONFIG_XOSC_STARTUP XOSC_STARTUP_16384 -# define XOSC_STARTUP_TIMEOUT (16384*(1000000/BOARD_XOSC_HZ)) - -# elif (BOARD_XOSC_STARTUP_CYCLES > 256) -# define CONFIG_XOSC_STARTUP XOSC_STARTUP_1024 -# define XOSC_STARTUP_TIMEOUT (1024*(1000000/BOARD_XOSC_HZ)) - -# else -# define CONFIG_XOSC_STARTUP XOSC_STARTUP_256 -# define XOSC_STARTUP_TIMEOUT (256*(1000000/BOARD_XOSC_HZ)) -# endif -# else /* BOARD_XOSC_TYPE == XOSC_TYPE_XTAL */ -# define CONFIG_XOSC_STARTUP 0 -# endif -# endif /* BOARD_XOSC_STARTUP_US */ -# endif /* CONFIG_XOSC_STARTUP */ - -// Get frequency range setting for XOSC, if not manually set. -# ifndef CONFIG_XOSC_RANGE -# if (BOARD_XOSC_TYPE == XOSC_TYPE_XTAL) -# if (BOARD_XOSC_HZ < 400000) -# error BOARD_XOSC_HZ is below minimum frequency of 400 kHz. - -# elif (BOARD_XOSC_HZ < 2000000) -# define CONFIG_XOSC_RANGE XOSC_RANGE_04TO2 - -# elif (BOARD_XOSC_HZ < 9000000) -# define CONFIG_XOSC_RANGE XOSC_RANGE_2TO9 - -# elif (BOARD_XOSC_HZ < 12000000) -# define CONFIG_XOSC_RANGE XOSC_RANGE_9TO12 - -# elif (BOARD_XOSC_HZ <= 16000000) -# define CONFIG_XOSC_RANGE XOSC_RANGE_12TO16 - -# else -# error BOARD_XOSC_HZ is above maximum frequency of 16 MHz. -# endif -# else /* BOARD_XOSC_TYPE == XOSC_TYPE_XTAL */ -# define CONFIG_XOSC_RANGE 0 -# endif -# endif /* CONFIG_XOSC_RANGE */ -#endif /* BOARD_XOSC_HZ */ - -#ifndef __ASSEMBLY__ - -/** - * \internal - * \brief Enable internal oscillator \a id - * - * Do not call this function directly. Use osc_enable() instead. - */ -static inline void osc_enable_internal(uint8_t id) -{ - irqflags_t flags; - - Assert(id != OSC_ID_USBSOF); - - flags = cpu_irq_save(); - OSC.CTRL |= id; - cpu_irq_restore(flags); -} - -#if defined(BOARD_XOSC_HZ) || defined(__DOXYGEN__) - -/** - * \internal - * \brief Enable external oscillator \a id - * - * Do not call this function directly. Use osc_enable() instead. Also - * note that this function is only available if the board actually has - * an external oscillator crystal. - */ -static inline void osc_enable_external(uint8_t id) -{ - irqflags_t flags; - - Assert(id == OSC_ID_XOSC); - -#ifndef CONFIG_XOSC_32KHZ_LPM - OSC.XOSCCTRL = BOARD_XOSC_TYPE | (CONFIG_XOSC_STARTUP << 2) | - CONFIG_XOSC_RANGE; -#else - OSC.XOSCCTRL = BOARD_XOSC_TYPE | (CONFIG_XOSC_STARTUP << 2) | - CONFIG_XOSC_RANGE | OSC_X32KLPM_bm; -#endif /* CONFIG_XOSC_32KHZ_LPM */ - - flags = cpu_irq_save(); - OSC.CTRL |= id; - cpu_irq_restore(flags); -} -#else - -static inline void osc_enable_external(uint8_t id) -{ - Assert(false); // No external oscillator on the selected board -} -#endif - -static inline void osc_disable(uint8_t id) -{ - irqflags_t flags; - - Assert(id != OSC_ID_USBSOF); - - flags = cpu_irq_save(); - OSC.CTRL &= ~id; - cpu_irq_restore(flags); -} - -static inline void osc_enable(uint8_t id) -{ - if (id != OSC_ID_XOSC) { - osc_enable_internal(id); - } else { - osc_enable_external(id); - } -} - -static inline bool osc_is_ready(uint8_t id) -{ - Assert(id != OSC_ID_USBSOF); - - return OSC.STATUS & id; -} - -//! \name XMEGA-Specific Oscillator Features -//@{ - -/** - * \brief Enable DFLL-based automatic calibration of an internal - * oscillator. - * - * The XMEGA features two Digital Frequency Locked Loops (DFLLs) which - * can be used to improve the accuracy of the 2 MHz and 32 MHz internal - * RC oscillators. The DFLL compares the oscillator frequency with a - * more accurate reference clock to do automatic run-time calibration of - * the oscillator. - * - * This function enables auto-calibration for either the 2 MHz or 32 MHz - * internal oscillator using either the 32.768 kHz calibrated internal - * oscillator or an external crystal oscillator as a reference. If the - * latter option is used, the crystal must be connected to the TOSC pins - * and run at 32.768 kHz. - * - * \param id The ID of the oscillator for which to enable - * auto-calibration: - * \arg \c OSC_ID_RC2MHZ or \c OSC_ID_RC32MHZ. - * \param ref_id The ID of the oscillator to use as a reference: - * \arg \c OSC_ID_RC32KHZ or \c OSC_ID_XOSC for internal or external 32 kHz - * reference, respectively. - * \arg \c OSC_ID_USBSOF for 32 MHz only when USB is available and running. - */ -static inline void osc_enable_autocalibration(uint8_t id, uint8_t ref_id) -{ - irqflags_t flags; - - flags = cpu_irq_save(); - switch (id) { - case OSC_ID_RC2MHZ: - Assert((ref_id == OSC_ID_RC32KHZ) || (ref_id == OSC_ID_XOSC)); - - if (ref_id == OSC_ID_XOSC) { - OSC.DFLLCTRL |= OSC_RC2MCREF_bm; - } else { - OSC.DFLLCTRL &= ~(OSC_RC2MCREF_bm); - } - DFLLRC2M.CTRL |= DFLL_ENABLE_bm; - break; - - case OSC_ID_RC32MHZ: -#if XMEGA_AU || XMEGA_B || XMEGA_C - Assert((ref_id == OSC_ID_RC32KHZ) - || (ref_id == OSC_ID_XOSC) - || (ref_id == OSC_ID_USBSOF)); - - OSC.DFLLCTRL &= ~(OSC_RC32MCREF_gm); - - if (ref_id == OSC_ID_XOSC) { - OSC.DFLLCTRL |= OSC_RC32MCREF_XOSC32K_gc; - } - else if (ref_id == OSC_ID_USBSOF) { - /* - * Calibrate 32MRC at 48MHz using USB SOF - * 48MHz / 1kHz = 0xBB80 - */ - DFLLRC32M.COMP1 = 0x80; - DFLLRC32M.COMP2 = 0xBB; - OSC.DFLLCTRL |= OSC_RC32MCREF_USBSOF_gc; - } - else if (ref_id == OSC_ID_RC32KHZ) { - /* - * Calibrate 32MRC at 48MHz using USB SOF - * 48MHz / 1kHz = 0xBB80 - */ - DFLLRC32M.COMP1 = 0x80; - DFLLRC32M.COMP2 = 0xBB; - osc_enable(OSC_ID_RC32KHZ); - OSC.DFLLCTRL |= OSC_RC32MCREF_RC32K_gc; - } -#else - Assert((ref_id == OSC_ID_RC32KHZ) || (ref_id == OSC_ID_XOSC)); - - if (ref_id == OSC_ID_XOSC) { - OSC.DFLLCTRL |= OSC_RC32MCREF_bm; - } - else { - OSC.DFLLCTRL &= ~(OSC_RC32MCREF_bm); - } -#endif - DFLLRC32M.CTRL |= DFLL_ENABLE_bm; - break; - - default: - Assert(false); - break; - } - cpu_irq_restore(flags); -} - -/** - * \brief Disable DFLL-based automatic calibration of an internal - * oscillator. - * - * \see osc_enable_autocalibration - * - * \param id The ID of the oscillator for which to disable - * auto-calibration: - * \arg \c OSC_ID_RC2MHZ or \c OSC_ID_RC32MHZ. - */ -static inline void osc_disable_autocalibration(uint8_t id) -{ - switch (id) { - case OSC_ID_RC2MHZ: - DFLLRC2M.CTRL = 0; - break; - - case OSC_ID_RC32MHZ: - DFLLRC32M.CTRL = 0; - break; - - default: - Assert(false); - break; - } -} - -/** - * \brief Load a specific calibration value for the specified oscillator. - * - * \param id The ID of the oscillator for which to disable - * auto-calibration: - * \arg \c OSC_ID_RC2MHZ or \c OSC_ID_RC32MHZ. - * \param calib The specific calibration value required: - * - */ -static inline void osc_user_calibration(uint8_t id, uint16_t calib) -{ - switch (id) { - case OSC_ID_RC2MHZ: - DFLLRC2M.CALA=LSB(calib); - DFLLRC2M.CALB=MSB(calib); - break; - - case OSC_ID_RC32MHZ: - DFLLRC32M.CALA=LSB(calib); - DFLLRC32M.CALB=MSB(calib); - break; - - default: - Assert(false); - break; - } -} -//@} - -static inline uint32_t osc_get_rate(uint8_t id) -{ - Assert(id != OSC_ID_USBSOF); - - switch (id) { - case OSC_ID_RC2MHZ: - return 2000000UL; - - case OSC_ID_RC32MHZ: -#ifdef CONFIG_OSC_RC32_CAL - return CONFIG_OSC_RC32_CAL; -#else - return 32000000UL; -#endif - - case OSC_ID_RC32KHZ: - return 32768UL; - -#ifdef BOARD_XOSC_HZ - case OSC_ID_XOSC: - return BOARD_XOSC_HZ; -#endif - - default: - Assert(false); - return 0; - } -} - -#endif /* __ASSEMBLY__ */ - -//! @} - -#endif /* XMEGA_OSC_H_INCLUDED */ diff --git a/DSTAT1/src/asf/common/services/clock/xmega/pll.h b/DSTAT1/src/asf/common/services/clock/xmega/pll.h deleted file mode 100644 index e046c80..0000000 --- a/DSTAT1/src/asf/common/services/clock/xmega/pll.h +++ /dev/null @@ -1,260 +0,0 @@ -/** - * \file - * - * \brief Chip-specific PLL management functions - * - * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef XMEGA_PLL_H_INCLUDED -#define XMEGA_PLL_H_INCLUDED - -#include - -/** - * \weakgroup pll_group - * @{ - */ - -#define NR_PLLS 1 -#define PLL_MIN_HZ 10000000UL -#define PLL_MAX_HZ 200000000UL -#define PLL_NR_OPTIONS 0 - -enum pll_source { - //! 2 MHz Internal RC Oscillator - PLL_SRC_RC2MHZ = OSC_PLLSRC_RC2M_gc, - //! 32 MHz Internal RC Oscillator - PLL_SRC_RC32MHZ = OSC_PLLSRC_RC32M_gc, - //! External Clock Source - PLL_SRC_XOSC = OSC_PLLSRC_XOSC_gc, -}; - -#define pll_get_default_rate(pll_id) \ - pll_get_default_rate_priv(CONFIG_PLL##pll_id##_SOURCE, \ - CONFIG_PLL##pll_id##_MUL, \ - CONFIG_PLL##pll_id##_DIV) - -/** - * \internal - * \brief Return clock rate for specified PLL settings. - * - * \note Due to the hardware implementation of the PLL, \a div must be 4 if the - * 32 MHz RC oscillator is used as reference and 1 otherwise. The reference must - * be above 440 kHz, and the output between 10 and 200 MHz. - * - * \param src ID of the PLL's reference source oscillator. - * \param mul Multiplier for the PLL. - * \param div Divisor for the PLL. - * - * \retval Output clock rate from PLL. - */ -static inline uint32_t pll_get_default_rate_priv(enum pll_source src, - unsigned int mul, unsigned int div) -{ - uint32_t rate; - - switch (src) { - case PLL_SRC_RC2MHZ: - rate = 2000000UL; - Assert(div == 1); - break; - - case PLL_SRC_RC32MHZ: -#ifdef CONFIG_OSC_RC32_CAL //32MHz oscillator is calibrated to another frequency - rate = CONFIG_OSC_RC32_CAL / 4; -#else - rate = 8000000UL; - #endif - Assert(div == 4); - break; - - case PLL_SRC_XOSC: - rate = osc_get_rate(OSC_ID_XOSC); - Assert(div == 1); - break; - - default: - break; - } - - Assert(rate >= 440000UL); - - rate *= mul; - - Assert(rate >= PLL_MIN_HZ); - Assert(rate <= PLL_MAX_HZ); - - return rate; -} - -struct pll_config { - uint8_t ctrl; -}; - -/** - * \note The XMEGA PLL hardware uses hard-wired input dividers, so the - * user must ensure that \a div is set as follows: - * - If \a src is PLL_SRC_32MHZ, \a div must be set to 4. - * - Otherwise, \a div must be set to 1. - */ -static inline void pll_config_init(struct pll_config *cfg, enum pll_source src, - unsigned int div, unsigned int mul) -{ - Assert(mul >= 1 && mul <= 31); - - if (src == PLL_SRC_RC32MHZ) { - Assert(div == 4); - } else { - Assert(div == 1); - } - - /* Initialize the configuration */ - cfg->ctrl = src | (mul << OSC_PLLFAC_gp); -} - -#define pll_config_defaults(cfg, pll_id) \ - pll_config_init(cfg, \ - CONFIG_PLL##pll_id##_SOURCE, \ - CONFIG_PLL##pll_id##_DIV, \ - CONFIG_PLL##pll_id##_MUL) - -static inline void pll_config_read(struct pll_config *cfg, unsigned int pll_id) -{ - Assert(pll_id < NR_PLLS); - - cfg->ctrl = OSC.PLLCTRL; -} - -static inline void pll_config_write(const struct pll_config *cfg, - unsigned int pll_id) -{ - Assert(pll_id < NR_PLLS); - - OSC.PLLCTRL = cfg->ctrl; -} - -/** - * \note If a different PLL reference oscillator than those enabled by - * \ref sysclk_init() is used, the user must ensure that the desired reference - * is enabled prior to calling this function. - */ -static inline void pll_enable(const struct pll_config *cfg, - unsigned int pll_id) -{ - irqflags_t flags; - - Assert(pll_id < NR_PLLS); - - flags = cpu_irq_save(); - pll_config_write(cfg, pll_id); - OSC.CTRL |= OSC_PLLEN_bm; - cpu_irq_restore(flags); -} - -/*! \note This will not automatically disable the reference oscillator that is - * configured for the PLL. - */ -static inline void pll_disable(unsigned int pll_id) -{ - irqflags_t flags; - - Assert(pll_id < NR_PLLS); - - flags = cpu_irq_save(); - OSC.CTRL &= ~OSC_PLLEN_bm; - cpu_irq_restore(flags); -} - -static inline bool pll_is_locked(unsigned int pll_id) -{ - Assert(pll_id < NR_PLLS); - - return OSC.STATUS & OSC_PLLRDY_bm; -} - -static inline void pll_enable_source(enum pll_source src) -{ - switch (src) { - case PLL_SRC_RC2MHZ: - break; - - case PLL_SRC_RC32MHZ: - if (!osc_is_ready(OSC_ID_RC32MHZ)) { - osc_enable(OSC_ID_RC32MHZ); - osc_wait_ready(OSC_ID_RC32MHZ); - } - break; - - case PLL_SRC_XOSC: - if (!osc_is_ready(OSC_ID_XOSC)) { - osc_enable(OSC_ID_XOSC); - osc_wait_ready(OSC_ID_XOSC); - } - break; - default: - Assert(false); - break; - } -} - -static inline void pll_enable_config_defaults(unsigned int pll_id) -{ - struct pll_config pllcfg; - - if (pll_is_locked(pll_id)) { - return; // Pll already running - } - switch (pll_id) { -#ifdef CONFIG_PLL0_SOURCE - case 0: - pll_enable_source(CONFIG_PLL0_SOURCE); - pll_config_init(&pllcfg, - CONFIG_PLL0_SOURCE, - CONFIG_PLL0_DIV, - CONFIG_PLL0_MUL); - break; -#endif - default: - Assert(false); - break; - } - pll_enable(&pllcfg, pll_id); - while (!pll_is_locked(pll_id)); -} - -//! @} - -#endif /* XMEGA_PLL_H_INCLUDED */ diff --git a/DSTAT1/src/asf/common/services/clock/xmega/sysclk.c b/DSTAT1/src/asf/common/services/clock/xmega/sysclk.c deleted file mode 100644 index 42c6e84..0000000 --- a/DSTAT1/src/asf/common/services/clock/xmega/sysclk.c +++ /dev/null @@ -1,227 +0,0 @@ -/** - * \file - * - * \brief Chip-specific system clock management functions - * - * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#include - -#include -#include -#include - -#if XMEGA_AU || XMEGA_B || XMEGA_C -# include -#endif - - -void sysclk_init(void) -{ - uint8_t *reg = (uint8_t *)&PR.PRGEN; - uint8_t i; -#ifdef CONFIG_OSC_RC32_CAL - uint16_t cal; -#endif - /* Turn off all peripheral clocks that can be turned off. */ - for (i = 0; i <= SYSCLK_PORT_F; i++) { - *(reg++) = 0xff; - } - - /* Set up system clock prescalers if different from defaults */ - if ((CONFIG_SYSCLK_PSADIV != SYSCLK_PSADIV_1) - || (CONFIG_SYSCLK_PSBCDIV != SYSCLK_PSBCDIV_1_1)) { - sysclk_set_prescalers(CONFIG_SYSCLK_PSADIV, - CONFIG_SYSCLK_PSBCDIV); - } -#if (CONFIG_OSC_RC32_CAL==48000000UL) - MSB(cal) = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(USBRCOSC)); - LSB(cal) = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(USBRCOSCA)); - /* - * If a device has an uncalibrated value in the - * production signature row (early sample part), load a - * sane default calibration value. - */ - if (cal == 0xFFFF) { - cal = 0x2340; - } - osc_user_calibration(OSC_ID_RC32MHZ,cal); -#endif - /* - * Switch to the selected initial system clock source, unless - * the default internal 2 MHz oscillator is selected. - */ - if (CONFIG_SYSCLK_SOURCE != SYSCLK_SRC_RC2MHZ) { - bool need_rc2mhz = false; - - switch (CONFIG_SYSCLK_SOURCE) { - case SYSCLK_SRC_RC32MHZ: - osc_enable(OSC_ID_RC32MHZ); - osc_wait_ready(OSC_ID_RC32MHZ); - break; - - case SYSCLK_SRC_RC32KHZ: - osc_enable(OSC_ID_RC32KHZ); - osc_wait_ready(OSC_ID_RC32KHZ); - break; - - case SYSCLK_SRC_XOSC: - osc_enable(OSC_ID_XOSC); - osc_wait_ready(OSC_ID_XOSC); - break; - -#ifdef CONFIG_PLL0_SOURCE - case SYSCLK_SRC_PLL: - if (CONFIG_PLL0_SOURCE == PLL_SRC_RC2MHZ) { - need_rc2mhz = true; - } - pll_enable_config_defaults(0); - break; -#endif - default: - //unhandled_case(CONFIG_SYSCLK_SOURCE); - return; - } - - ccp_write_io((uint8_t *)&CLK.CTRL, CONFIG_SYSCLK_SOURCE); - Assert(CLK.CTRL == CONFIG_SYSCLK_SOURCE); - -#ifdef CONFIG_OSC_AUTOCAL - osc_enable_autocalibration(CONFIG_OSC_AUTOCAL,CONFIG_OSC_AUTOCAL_REF_OSC); - if (CONFIG_OSC_AUTOCAL == OSC_ID_RC2MHZ - || CONFIG_OSC_AUTOCAL_REF_OSC == OSC_ID_RC2MHZ) { - need_rc2mhz = true; - } -#endif - - if (!need_rc2mhz) { - osc_disable(OSC_ID_RC2MHZ); - } - } -} - -void sysclk_enable_module(enum sysclk_port_id port, uint8_t id) -{ - irqflags_t flags = cpu_irq_save(); - - *((uint8_t *)&PR.PRGEN + port) &= ~id; - - cpu_irq_restore(flags); -} - -void sysclk_disable_module(enum sysclk_port_id port, uint8_t id) -{ - irqflags_t flags = cpu_irq_save(); - - *((uint8_t *)&PR.PRGEN + port) |= id; - - cpu_irq_restore(flags); -} - -#if XMEGA_AU || XMEGA_B || XMEGA_C || defined(__DOXYGEN__) - -/** - * \brief Enable clock for the USB module - * - * \pre CONFIG_USBCLK_SOURCE must be defined. - * - * \param frequency The required USB clock frequency in MHz: - * \arg \c 6 for 6 MHz - * \arg \c 48 for 48 MHz - */ -void sysclk_enable_usb(uint8_t frequency) -{ - uint8_t prescaler; - - Assert((frequency == 6) || (frequency == 48)); - - /* - * Enable or disable prescaler depending on if the USB frequency is 6 - * MHz or 48 MHz. Only 6 MHz USB frequency requires prescaling. - */ - if (frequency == 6) { - prescaler = CLK_USBPSDIV_8_gc; - } - else { - prescaler = 0; - } - - /* - * Switch to the system clock selected by the user. - */ - switch (CONFIG_USBCLK_SOURCE) { - case USBCLK_SRC_RCOSC: - if (!osc_is_ready(OSC_ID_RC32MHZ)) { - osc_enable(OSC_ID_RC32MHZ); - osc_wait_ready(OSC_ID_RC32MHZ); -#ifdef CONFIG_OSC_AUTOCAL - osc_enable_autocalibration(CONFIG_OSC_AUTOCAL,CONFIG_OSC_AUTOCAL_REF_OSC); -#endif - } - ccp_write_io((uint8_t *)&CLK.USBCTRL, (prescaler) - | CLK_USBSRC_RC32M_gc - | CLK_USBSEN_bm); - break; - -#ifdef CONFIG_PLL0_SOURCE - case USBCLK_SRC_PLL: - pll_enable_config_defaults(0); - ccp_write_io((uint8_t *)&CLK.USBCTRL, (prescaler) - | CLK_USBSRC_PLL_gc - | CLK_USBSEN_bm); - break; -#endif - - default: - Assert(false); - break; - } - - sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_USB); -} - -/** - * \brief Disable clock for the USB module - */ -void sysclk_disable_usb(void) -{ - sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_USB); - ccp_write_io((uint8_t *)&CLK.USBCTRL, 0); -} -#endif // XMEGA_AU || XMEGA_B || XMEGA_C diff --git a/DSTAT1/src/asf/common/services/clock/xmega/sysclk.h b/DSTAT1/src/asf/common/services/clock/xmega/sysclk.h deleted file mode 100644 index 14bdaf5..0000000 --- a/DSTAT1/src/asf/common/services/clock/xmega/sysclk.h +++ /dev/null @@ -1,1098 +0,0 @@ -/** - * \file - * - * \brief Chip-specific system clock management functions - * - * Copyright (c) 2010-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef XMEGA_SYSCLK_H_INCLUDED -#define XMEGA_SYSCLK_H_INCLUDED - -#include -#include -#include -#include -#include -#include - -// Include clock configuration for the project. -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// Use 2 MHz with no prescaling if config was empty. -#ifndef CONFIG_SYSCLK_SOURCE -# define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC2MHZ -#endif /* CONFIG_SYSCLK_SOURCE */ - -#ifndef CONFIG_SYSCLK_PSADIV -# define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_1 -#endif /* CONFIG_SYSCLK_PSADIV */ - -#ifndef CONFIG_SYSCLK_PSBCDIV -# define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_1 -#endif /* CONFIG_SYSCLK_PSBCDIV */ - -/** - * \weakgroup sysclk_group - * - * \section sysclk_group_config Configuration Symbols - * - * The following configuration symbols may be used to specify the - * initial system clock configuration. If any of the symbols are not - * set, reasonable defaults will be provided. - * - \b CONFIG_SYSCLK_SOURCE: The initial system clock source. - * - \b CONFIG_SYSCLK_PSADIV: The initial Prescaler A setting. - * - \b CONFIG_SYSCLK_PSBCDIV: The initial Prescaler B setting. - * - \b CONFIG_USBCLK_SOURCE: The initial USB clock source. - * - * @{ - */ - -//! \name System Clock Sources -//@{ -//! Internal 2 MHz RC oscillator -#define SYSCLK_SRC_RC2MHZ CLK_SCLKSEL_RC2M_gc -//! Internal 32 MHz RC oscillator -#define SYSCLK_SRC_RC32MHZ CLK_SCLKSEL_RC32M_gc -//! Internal 32 KHz RC oscillator -#define SYSCLK_SRC_RC32KHZ CLK_SCLKSEL_RC32K_gc -//! External oscillator -#define SYSCLK_SRC_XOSC CLK_SCLKSEL_XOSC_gc -//! Phase-Locked Loop -#define SYSCLK_SRC_PLL CLK_SCLKSEL_PLL_gc -//@} - -//! \name Prescaler A Setting (relative to CLKsys) -//@{ -#define SYSCLK_PSADIV_1 CLK_PSADIV_1_gc //!< Do not prescale -#define SYSCLK_PSADIV_2 CLK_PSADIV_2_gc //!< Prescale CLKper4 by 2 -#define SYSCLK_PSADIV_4 CLK_PSADIV_4_gc //!< Prescale CLKper4 by 4 -#define SYSCLK_PSADIV_8 CLK_PSADIV_8_gc //!< Prescale CLKper4 by 8 -#define SYSCLK_PSADIV_16 CLK_PSADIV_16_gc //!< Prescale CLKper4 by 16 -#define SYSCLK_PSADIV_32 CLK_PSADIV_32_gc //!< Prescale CLKper4 by 32 -#define SYSCLK_PSADIV_64 CLK_PSADIV_64_gc //!< Prescale CLKper4 by 64 -#define SYSCLK_PSADIV_128 CLK_PSADIV_128_gc //!< Prescale CLKper4 by 128 -#define SYSCLK_PSADIV_256 CLK_PSADIV_256_gc //!< Prescale CLKper4 by 256 -#define SYSCLK_PSADIV_512 CLK_PSADIV_512_gc //!< Prescale CLKper4 by 512 -//@} - -//! \name Prescaler B and C Setting (relative to CLKper4) -//@{ -//! Do not prescale -#define SYSCLK_PSBCDIV_1_1 CLK_PSBCDIV_1_1_gc -//! Prescale CLKper and CLKcpu by 2 -#define SYSCLK_PSBCDIV_1_2 CLK_PSBCDIV_1_2_gc -//! Prescale CLKper2, CLKper and CLKcpu by 4 -#define SYSCLK_PSBCDIV_4_1 CLK_PSBCDIV_4_1_gc -//! Prescale CLKper2 by 2, CLKper and CLKcpu by 4 -#define SYSCLK_PSBCDIV_2_2 CLK_PSBCDIV_2_2_gc -//@} - -//! \name System Clock Port Numbers -enum sysclk_port_id { - SYSCLK_PORT_GEN, //!< Devices not associated with a specific port. - SYSCLK_PORT_A, //!< Devices on PORTA - SYSCLK_PORT_B, //!< Devices on PORTB - SYSCLK_PORT_C, //!< Devices on PORTC - SYSCLK_PORT_D, //!< Devices on PORTD - SYSCLK_PORT_E, //!< Devices on PORTE - SYSCLK_PORT_F, //!< Devices on PORTF -}; - -/*! \name Clocks not associated with any port - * - * \note See the datasheet for available modules in the device. - */ -//@{ -#define SYSCLK_DMA PR_DMA_bm //!< DMA Controller -#define SYSCLK_EVSYS PR_EVSYS_bm //!< Event System -#define SYSCLK_RTC PR_RTC_bm //!< Real-Time Counter -#define SYSCLK_EBI PR_EBI_bm //!< Ext Bus Interface -#define SYSCLK_AES PR_AES_bm //!< AES Module -#define SYSCLK_USB PR_USB_bm //!< USB Module -//@} - -/*! \name Clocks on PORTA and PORTB - * - * \note See the datasheet for available modules in the device. - */ -//@{ -#define SYSCLK_AC PR_AC_bm //!< Analog Comparator -#define SYSCLK_ADC PR_ADC_bm //!< A/D Converter -#define SYSCLK_DAC PR_DAC_bm //!< D/A Converter -//@} - -/*! \name Clocks on PORTC, PORTD, PORTE and PORTF - * - * \note See the datasheet for available modules in the device. - */ -//@{ -#define SYSCLK_TC0 PR_TC0_bm //!< Timer/Counter 0 -#define SYSCLK_TC1 PR_TC1_bm //!< Timer/Counter 1 -#define SYSCLK_HIRES PR_HIRES_bm //!< Hi-Res Extension -#define SYSCLK_SPI PR_SPI_bm //!< SPI controller -#define SYSCLK_USART0 PR_USART0_bm //!< USART 0 -#define SYSCLK_USART1 PR_USART1_bm //!< USART 1 -#define SYSCLK_TWI PR_TWI_bm //!< TWI controller -//@} - - -#if XMEGA_AU || XMEGA_B || XMEGA_C -//! \name USB Clock Sources -//@{ -//! Internal 32 MHz RC oscillator -#define USBCLK_SRC_RCOSC 0 -//! Phase-Locked Loop -#define USBCLK_SRC_PLL 1 -//@} - -/** - * \def CONFIG_USBCLK_SOURCE - * \brief Configuration symbol for the USB clock source - * - * If the device features an USB module, and this is intended to be used, this - * symbol must be defined with the clock source configuration. - * - * Define this as one of the \c USBCLK_SRC_xxx definitions. If the PLL is - * selected, it must be configured to run at 48 MHz. If the 32 MHz RC oscillator - * is selected, it must be tuned to 48 MHz by means of the DFLL. - */ -#ifdef __DOXYGEN__ -# define CONFIG_USBCLK_SOURCE -#endif - -#endif // XMEGA_AU || XMEGA_B || XMEGA_C - -#ifndef __ASSEMBLY__ - -/** - * \name Querying the system clock and its derived clocks - */ -//@{ - -/** - * \brief Return the current rate in Hz of the main system clock - * - * \todo This function assumes that the main clock source never changes - * once it's been set up, and that PLL0 always runs at the compile-time - * configured default rate. While this is probably the most common - * configuration, which we want to support as a special case for - * performance reasons, we will at some point need to support more - * dynamic setups as well. - * - * \return Frequency of the main system clock, in Hz. - */ -static inline uint32_t sysclk_get_main_hz(void) -{ - switch (CONFIG_SYSCLK_SOURCE) { - case SYSCLK_SRC_RC2MHZ: - return 2000000UL; - - case SYSCLK_SRC_RC32MHZ: -#ifdef CONFIG_OSC_RC32_CAL - return CONFIG_OSC_RC32_CAL; -#else - return 32000000UL; -#endif - - case SYSCLK_SRC_RC32KHZ: - return 32768UL; - -#ifdef BOARD_XOSC_HZ - case SYSCLK_SRC_XOSC: - return BOARD_XOSC_HZ; -#endif - -#ifdef CONFIG_PLL0_SOURCE - case SYSCLK_SRC_PLL: - return pll_get_default_rate(0); -#endif - - default: - //unhandled_case(CONFIG_SYSCLK_SOURCE); - return 0; - } -} - -/** - * \brief Return the current rate in Hz of clk_PER4. - * - * This clock can run up to four times faster than the CPU clock. - * - * \return Frequency of the clk_PER4 clock, in Hz. - */ -static inline uint32_t sysclk_get_per4_hz(void) -{ - uint8_t shift = 0; - - if (CONFIG_SYSCLK_PSADIV & (1U << CLK_PSADIV_gp)) { - shift = (CONFIG_SYSCLK_PSADIV >> (1 + CLK_PSADIV_gp)) + 1; - } - - return sysclk_get_main_hz() >> shift; -} - -/** - * \brief Return the current rate in Hz of clk_PER2. - * - * This clock can run up to two times faster than the CPU clock. - * - * \return Frequency of the clk_PER2 clock, in Hz. - */ -static inline uint32_t sysclk_get_per2_hz(void) -{ - switch (CONFIG_SYSCLK_PSBCDIV) { - case SYSCLK_PSBCDIV_1_1: /* Fall through */ - case SYSCLK_PSBCDIV_1_2: - return sysclk_get_per4_hz(); - - case SYSCLK_PSBCDIV_4_1: - return sysclk_get_per4_hz() / 4; - - case SYSCLK_PSBCDIV_2_2: - return sysclk_get_per4_hz() / 2; - - default: - //unhandled_case(CONFIG_SYSCLK_PSBCDIV); - return 0; - } -} - -/** - * \brief Return the current rate in Hz of clk_PER. - * - * This clock always runs at the same rate as the CPU clock unless the divider - * is set. - * - * \return Frequency of the clk_PER clock, in Hz. - */ -static inline uint32_t sysclk_get_per_hz(void) -{ - if (CONFIG_SYSCLK_PSBCDIV & (1U << CLK_PSBCDIV_gp)) - return sysclk_get_per2_hz() / 2; - else - return sysclk_get_per2_hz(); -} - -/** - * \brief Return the current rate in Hz of the CPU clock. - * - * \return Frequency of the CPU clock, in Hz. - */ -static inline uint32_t sysclk_get_cpu_hz(void) -{ - return sysclk_get_per_hz(); -} - -/** - * \brief Retrieves the current rate in Hz of the Peripheral Bus clock attached - * to the specified peripheral. - * - * \param module Pointer to the module's base address. - * - * \return Frequency of the bus attached to the specified peripheral, in Hz. - */ -static inline uint32_t sysclk_get_peripheral_bus_hz(const volatile void *module) -{ - if (module == NULL) { - Assert(false); - return 0; - } -#ifdef AES - else if (module == &AES) { - return sysclk_get_per_hz(); - } -#endif -#ifdef EBI - else if (module == &EBI) { - return sysclk_get_per2_hz(); - } -#endif -#ifdef RTC - else if (module == &RTC) { - return sysclk_get_per_hz(); - } -#endif -#ifdef EVSYS - else if (module == &EVSYS) { - return sysclk_get_per_hz(); - } -#endif -#ifdef DMA - else if (module == &DMA) { - return sysclk_get_per_hz(); - } -#endif -#ifdef ACA - else if (module == &ACA) { - return sysclk_get_per_hz(); - } -#endif -#ifdef ACB - else if (module == &ACB) { - return sysclk_get_per_hz(); - } -#endif -#ifdef ADCA - else if (module == &ADCA) { - return sysclk_get_per_hz(); - } -#endif -#ifdef ADCB - else if (module == &ADCB) { - return sysclk_get_per_hz(); - } -#endif -#ifdef DACA - else if (module == &DACA) { - return sysclk_get_per_hz(); - } -#endif -// Workaround for bad XMEGA D header file -#ifndef XMEGA_D -#ifdef DACB - else if (module == &DACB) { - return sysclk_get_per_hz(); - } -#endif -#endif // Workaround end -#ifdef TCC0 - else if (module == &TCC0) { - return sysclk_get_per_hz(); - } -#endif -#ifdef TCD0 - else if (module == &TCD0) { - return sysclk_get_per_hz(); - } -#endif -#ifdef TCE0 - else if (module == &TCE0) { - return sysclk_get_per_hz(); - } -#endif -#ifdef TCF0 - else if (module == &TCF0) { - return sysclk_get_per_hz(); - } -#endif -#ifdef TCC1 - else if (module == &TCC1) { - return sysclk_get_per_hz(); - } -#endif -#ifdef TCD1 - else if (module == &TCD1) { - return sysclk_get_per_hz(); - } -#endif -#ifdef TCE1 - else if (module == &TCE1) { - return sysclk_get_per_hz(); - } -#endif -#ifdef TCF1 - else if (module == &TCF1) { - return sysclk_get_per_hz(); - } -#endif -#ifdef HIRESC - else if (module == &HIRESC) { - return sysclk_get_per4_hz(); - } -#endif -#ifdef HIRESD - else if (module == &HIRESD) { - return sysclk_get_per4_hz(); - } -#endif -#ifdef HIRESE - else if (module == &HIRESE) { - return sysclk_get_per4_hz(); - } -#endif -#ifdef HIRESF - else if (module == &HIRESF) { - return sysclk_get_per4_hz(); - } -#endif -#ifdef SPIC - else if (module == &SPIC) { - return sysclk_get_per_hz(); - } -#endif -#ifdef SPID - else if (module == &SPID) { - return sysclk_get_per_hz(); - } -#endif -#ifdef SPIE - else if (module == &SPIE) { - return sysclk_get_per_hz(); - } -#endif -#ifdef SPIF - else if (module == &SPIF) { - return sysclk_get_per_hz(); - } -#endif -#ifdef USART0C - else if (module == &USART0C) { - return sysclk_get_per_hz(); - } -#endif -#ifdef USART0D - else if (module == &USART0D) { - return sysclk_get_per_hz(); - } -#endif -#ifdef USART0E - else if (module == &USART0E) { - return sysclk_get_per_hz(); - } -#endif -#ifdef USART0F - else if (module == &USART0F) { - return sysclk_get_per_hz(); - } -#endif -#ifdef USART1C - else if (module == &USART1C) { - return sysclk_get_per_hz(); - } -#endif -#ifdef USART1D - else if (module == &USART1D) { - return sysclk_get_per_hz(); - } -#endif -#ifdef USART1E - else if (module == &USART1E) { - return sysclk_get_per_hz(); - } -#endif -#ifdef USART1F - else if (module == &USART1F) { - return sysclk_get_per_hz(); - } -#endif -#ifdef TWIC - else if (module == &TWIC) { - return sysclk_get_per_hz(); - } -#endif -#ifdef TWID - else if (module == &TWID) { - return sysclk_get_per_hz(); - } -#endif -#ifdef TWIE - else if (module == &TWIE) { - return sysclk_get_per_hz(); - } -#endif -#ifdef TWIF - else if (module == &TWIF) { - return sysclk_get_per_hz(); - } -#endif - else { - Assert(false); - return 0; - } -} - -//@} - -//! \name Enabling and disabling synchronous clocks -//@{ - -/** - * \brief Enable the clock to peripheral \a id on port \a port - * - * \param port ID of the port to which the module is connected (one of - * the \c SYSCLK_PORT_* definitions). - * \param id The ID (bitmask) of the peripheral module to be enabled. - */ -extern void sysclk_enable_module(enum sysclk_port_id port, uint8_t id); - -/** - * \brief Disable the clock to peripheral \a id on port \a port - * - * \param port ID of the port to which the module is connected (one of - * the \c SYSCLK_PORT_* definitions). - * \param id The ID (bitmask) of the peripheral module to be disabled. - */ -extern void sysclk_disable_module(enum sysclk_port_id port, uint8_t id); - -/** - * \brief Enable a peripheral's clock from its base address. - * - * Enables the clock to a peripheral, given its base address. If the peripheral - * has an associated clock on the HSB bus, this will be enabled also. - * - * \param module Pointer to the module's base address. - */ -static inline void sysclk_enable_peripheral_clock(const volatile void *module) -{ - if (module == NULL) { - Assert(false); - } -#ifdef AES - else if (module == &AES) { - sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_AES); - } -#endif -#ifdef EBI - else if (module == &EBI) { - sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_EBI); - } -#endif -#ifdef RTC - else if (module == &RTC) { - sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_RTC); - } -#endif -#ifdef EVSYS - else if (module == &EVSYS) { - sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_EVSYS); - } -#endif -#ifdef DMA - else if (module == &DMA) { - sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_DMA); - } -#endif -#ifdef ACA - else if (module == &ACA) { - sysclk_enable_module(SYSCLK_PORT_A, SYSCLK_AC); - } -#endif -#ifdef ACB - else if (module == &ACB) { - sysclk_enable_module(SYSCLK_PORT_B, SYSCLK_AC); - } -#endif -#ifdef ADCA - else if (module == &ADCA) { - sysclk_enable_module(SYSCLK_PORT_A, SYSCLK_ADC); - } -#endif -#ifdef ADCB - else if (module == &ADCB) { - sysclk_enable_module(SYSCLK_PORT_B, SYSCLK_ADC); - } -#endif -#ifdef DACA - else if (module == &DACA) { - sysclk_enable_module(SYSCLK_PORT_A, SYSCLK_DAC); - } -#endif -// Workaround for bad XMEGA D header file -#ifndef XMEGA_D -#ifdef DACB - else if (module == &DACB) { - sysclk_enable_module(SYSCLK_PORT_B, SYSCLK_DAC); - } -#endif -#endif // Workaround end -#ifdef TCC0 - else if (module == &TCC0) { - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_TC0); - } -#endif -#ifdef TCD0 - else if (module == &TCD0) { - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_TC0); - } -#endif -#ifdef TCE0 - else if (module == &TCE0) { - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_TC0); - } -#endif -#ifdef TCF0 - else if (module == &TCF0) { - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_TC0); - } -#endif -#ifdef TCC1 - else if (module == &TCC1) { - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_TC1); - } -#endif -#ifdef TCD1 - else if (module == &TCD1) { - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_TC1); - } -#endif -#ifdef TCE1 - else if (module == &TCE1) { - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_TC1); - } -#endif -#ifdef TCF1 - else if (module == &TCF1) { - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_TC1); - } -#endif -#ifdef HIRESC - else if (module == &HIRESC) { - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_HIRES); - } -#endif -#ifdef HIRESD - else if (module == &HIRESD) { - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_HIRES); - } -#endif -#ifdef HIRESE - else if (module == &HIRESE) { - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_HIRES); - } -#endif -#ifdef HIRESF - else if (module == &HIRESF) { - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_HIRES); - } -#endif -#ifdef SPIC - else if (module == &SPIC) { - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_SPI); - } -#endif -#ifdef SPID - else if (module == &SPID) { - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_SPI); - } -#endif -#ifdef SPIE - else if (module == &SPIE) { - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_SPI); - } -#endif -#ifdef SPIF - else if (module == &SPIF) { - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_SPI); - } -#endif -#ifdef USARTC0 - else if (module == &USARTC0) { - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_USART0); - } -#endif -#ifdef USARTD0 - else if (module == &USARTD0) { - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_USART0); - } -#endif -#ifdef USARTE0 - else if (module == &USARTE0) { - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_USART0); - } -#endif -#ifdef USARTF0 - else if (module == &USARTF0) { - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_USART0); - } -#endif -#ifdef USARTC1 - else if (module == &USARTC1) { - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_USART1); - } -#endif -#ifdef USARTD1 - else if (module == &USARTD1) { - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_USART1); - } -#endif -#ifdef USARTE1 - else if (module == &USARTE1) { - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_USART1); - } -#endif -#ifdef USARTF1 - else if (module == &USARTF1) { - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_USART1); - } -#endif -#ifdef TWIC - else if (module == &TWIC) { - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_TWI); - } -#endif -#ifdef TWID - else if (module == &TWID) { - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_TWI); - } -#endif -#ifdef TWIE - else if (module == &TWIE) { - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_TWI); - } -#endif -#ifdef TWIF - else if (module == &TWIF) { - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_TWI); - } -#endif - else { - Assert(false); - } -} - -/** - * \brief Disable a peripheral's clock from its base address. - * - * Disables the clock to a peripheral, given its base address. If the peripheral - * has an associated clock on the HSB bus, this will be disabled also. - * - * \param module Pointer to the module's base address. - */ -static inline void sysclk_disable_peripheral_clock(const volatile void *module) -{ - if (module == NULL) { - Assert(false); - } -#ifdef AES - else if (module == &AES) { - sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_AES); - } -#endif -#ifdef EBI - else if (module == &EBI) { - sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_EBI); - } -#endif -#ifdef RTC - else if (module == &RTC) { - sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_RTC); - } -#endif -#ifdef EVSYS - else if (module == &EVSYS) { - sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_EVSYS); - } -#endif -#ifdef DMA - else if (module == &DMA) { - sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_DMA); - } -#endif -#ifdef ACA - else if (module == &ACA) { - sysclk_disable_module(SYSCLK_PORT_A, SYSCLK_AC); - } -#endif -#ifdef ACB - else if (module == &ACB) { - sysclk_disable_module(SYSCLK_PORT_B, SYSCLK_AC); - } -#endif -#ifdef ADCA - else if (module == &ADCA) { - sysclk_disable_module(SYSCLK_PORT_A, SYSCLK_ADC); - } -#endif -#ifdef ADCB - else if (module == &ADCB) { - sysclk_disable_module(SYSCLK_PORT_B, SYSCLK_ADC); - } -#endif -#ifdef DACA - else if (module == &DACA) { - sysclk_disable_module(SYSCLK_PORT_A, SYSCLK_DAC); - } -#endif -// Workaround for bad XMEGA D header file -#ifndef XMEGA_D -#ifdef DACB - else if (module == &DACB) { - sysclk_disable_module(SYSCLK_PORT_B, SYSCLK_DAC); - } -#endif -#endif // Workaround end -#ifdef TCC0 - else if (module == &TCC0) { - sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_TC0); - } -#endif -#ifdef TCD0 - else if (module == &TCD0) { - sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_TC0); - } -#endif -#ifdef TCE0 - else if (module == &TCE0) { - sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_TC0); - } -#endif -#ifdef TCF0 - else if (module == &TCF0) { - sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_TC0); - } -#endif -#ifdef TCC1 - else if (module == &TCC1) { - sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_TC1); - } -#endif -#ifdef TCD1 - else if (module == &TCD1) { - sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_TC1); - } -#endif -#ifdef TCE1 - else if (module == &TCE1) { - sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_TC1); - } -#endif -#ifdef TCF1 - else if (module == &TCF1) { - sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_TC1); - } -#endif -#ifdef HIRESC - else if (module == &HIRESC) { - sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_HIRES); - } -#endif -#ifdef HIRESD - else if (module == &HIRESD) { - sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_HIRES); - } -#endif -#ifdef HIRESE - else if (module == &HIRESE) { - sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_HIRES); - } -#endif -#ifdef HIRESF - else if (module == &HIRESF) { - sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_HIRES); - } -#endif -#ifdef SPIC - else if (module == &SPIC) { - sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_SPI); - } -#endif -#ifdef SPID - else if (module == &SPID) { - sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_SPI); - } -#endif -#ifdef SPIE - else if (module == &SPIE) { - sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_SPI); - } -#endif -#ifdef SPIF - else if (module == &SPIF) { - sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_SPI); - } -#endif -#ifdef USART0C - else if (module == &USART0C) { - sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_USART0); - } -#endif -#ifdef USART0D - else if (module == &USART0D) { - sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_USART0); - } -#endif -#ifdef USART0E - else if (module == &USART0E) { - sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_USART0); - } -#endif -#ifdef USART0F - else if (module == &USART0F) { - sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_USART0); - } -#endif -#ifdef USART1C - else if (module == &USART1C) { - sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_USART1); - } -#endif -#ifdef USART1D - else if (module == &USART1D) { - sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_USART1); - } -#endif -#ifdef USART1E - else if (module == &USART1E) { - sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_USART1); - } -#endif -#ifdef USART1F - else if (module == &USART1F) { - sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_USART1); - } -#endif -#ifdef TWIC - else if (module == &TWIC) { - sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_TWI); - } -#endif -#ifdef TWID - else if (module == &TWID) { - sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_TWI); - } -#endif -#ifdef TWIE - else if (module == &TWIE) { - sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_TWI); - } -#endif -#ifdef TWIF - else if (module == &TWIF) { - sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_TWI); - } -#endif - else { - Assert(false); - } -} - -/** - * \brief Check if the synchronous clock is enabled for a module - * - * \param port ID of the port to which the module is connected (one of - * the \c SYSCLK_PORT_* definitions). - * \param id The ID (bitmask) of the peripheral module to check (one of - * the \c SYSCLK_* module definitions). - * - * \retval true If the clock for module \a id on \a port is enabled. - * \retval false If the clock for module \a id on \a port is disabled. - */ -static inline bool sysclk_module_is_enabled(enum sysclk_port_id port, - uint8_t id) -{ - uint8_t mask = *((uint8_t *)&PR.PRGEN + port); - return (mask & id) == 0; -} - -#if XMEGA_AU || XMEGA_B || XMEGA_C || defined(__DOXYGEN__) -# if defined(CONFIG_USBCLK_SOURCE) || defined(__DOXYGEN__) -# if (CONFIG_USBCLK_SOURCE == USBCLK_SRC_RCOSC) -# define USBCLK_STARTUP_TIMEOUT 1 -# elif (CONFIG_USBCLK_SOURCE == USBCLK_SRC_PLL) -# if (CONFIG_PLL0_SOURCE == PLL_SRC_XOSC) -# define USBCLK_STARTUP_TIMEOUT XOSC_STARTUP_TIMEOUT -# elif (CONFIG_PLL0_SOURCE == PLL_SRC_RC32MHZ) -# define USBCLK_STARTUP_TIMEOUT 1 -# elif (CONFIG_PLL0_SOURCE == PLL_SRC_RC2MHZ) -# define USBCLK_STARTUP_TIMEOUT 1 -# else -# error Unknow value for CONFIG_PLL0_SOURCE, see conf_clock.h. -# endif -# endif -# else /* CONFIG_USBCLK_SOURCE not defined */ -# define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC -# define USBCLK_STARTUP_TIMEOUT 1 -# endif /* CONFIG_USBCLK_SOURCE */ -void sysclk_enable_usb(uint8_t frequency); -void sysclk_disable_usb(void); -#endif /* XMEGA_AU || XMEGA_B || XMEGA_C */ -//@} - -//! \name System Clock Source and Prescaler configuration -//@{ - -/** - * \brief Set system clock prescaler configuration - * - * This function will change the system clock prescaler configuration to - * match the parameters. - * - * \note The parameters to this function are device-specific. - * - * \param psadiv The prescaler A setting (one of the \c SYSCLK_PSADIV_* - * definitions). This determines the clkPER4 frequency. - * \param psbcdiv The prescaler B and C settings (one of the \c SYSCLK_PSBCDIV_* - * definitions). These determine the clkPER2, clkPER and clkCPU frequencies. - */ -static inline void sysclk_set_prescalers(uint8_t psadiv, uint8_t psbcdiv) -{ - ccp_write_io((uint8_t *)&CLK.PSCTRL, psadiv | psbcdiv); -} - -/** - * \brief Change the source of the main system clock. - * - * \param src The new system clock source. Must be one of the constants - * from the System Clock Sources section. - */ -static inline void sysclk_set_source(uint8_t src) -{ - ccp_write_io((uint8_t *)&CLK.CTRL, src); -} - -/** - * \brief Lock the system clock configuration - * - * This function will lock the current system clock source and prescaler - * configuration, preventing any further changes. - */ -static inline void sysclk_lock(void) -{ - ccp_write_io((uint8_t *)&CLK.LOCK, CLK_LOCK_bm); -} - -//@} - -//! \name System Clock Initialization -//@{ - -extern void sysclk_init(void); - -//@} - -#endif /* !__ASSEMBLY__ */ - -//! @} - -#ifdef __cplusplus -} -#endif - -#endif /* XMEGA_SYSCLK_H_INCLUDED */ diff --git a/DSTAT1/src/asf/common/services/delay/delay.h b/DSTAT1/src/asf/common/services/delay/delay.h deleted file mode 100644 index c739053..0000000 --- a/DSTAT1/src/asf/common/services/delay/delay.h +++ /dev/null @@ -1,133 +0,0 @@ -/** - * \file - * - * \brief Common Delay Service - * - * Copyright (c) 2011 - 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef _delay_h_ -#define _delay_h_ - -#ifdef __cplusplus -extern "C" { -#endif - - -#include - -#if defined(UC3) -# include -#elif defined(XMEGA) -# include "xmega/cycle_counter.h" -#endif - - -/** - * @defgroup group_common_services_delay Busy-Wait Delay Routines - * - * This module provides simple loop-based delay routines for those - * applications requiring a brief wait during execution. Common API - * for UC3, XMEGA, and AVR MEGA. - * - * @{ - */ - -/** - * @def F_CPU - * @brief MCU Clock Frequency (Hertz) - * - * @deprecated - * The \ref F_CPU configuration constant is used for compatibility with the - * \ref group_common_services_delay routines. The common loop-based delay - * routines are designed to use the \ref clk_group modules while anticipating - * support for legacy applications assuming a statically defined clock - * frequency. Applications using a statically configured MCU clock frequency - * can define \ref F_CPU (Hertz), in which case the common delay routines will - * use this value rather than calling sysclk_get_cpu_hz() to get the current - * MCU clock frequency. - */ -#ifndef F_CPU -# define F_CPU sysclk_get_cpu_hz() -#endif - -/** - * @def delay_init - * - * @brief Initialize the delay driver. - * @param fcpu_hz CPU frequency in Hz - * - * @deprecated - * This function is provided for compatibility with ASF applications that - * may not have been updated to configure the system clock via the common - * clock service; e.g. sysclk_init() and a configuration header file are - * used to configure clocks. - * - * The functions in this module call \ref sysclk_get_cpu_hz() function to - * obtain the system clock frequency. - */ -#define delay_init(fcpu_hz) - -/** - * @def delay_s - * @brief Delay in seconds. - * @param delay Delay in seconds - */ -#define delay_s(delay) cpu_delay_ms(1000 * delay, F_CPU) - -/** - * @def delay_ms - * @brief Delay in milliseconds. - * @param delay Delay in milliseconds - */ -#define delay_ms(delay) cpu_delay_ms(delay, F_CPU) - -/** - * @def delay_us - * @brief Delay in microseconds. - * @param delay Delay in microseconds - */ -#define delay_us(delay) cpu_delay_us(delay, F_CPU) - - -#ifdef __cplusplus -} -#endif - -/** - * @} - */ - -#endif /* _delay_h_ */ diff --git a/DSTAT1/src/asf/common/services/delay/xmega/cycle_counter.h b/DSTAT1/src/asf/common/services/delay/xmega/cycle_counter.h deleted file mode 100644 index 5bd5438..0000000 --- a/DSTAT1/src/asf/common/services/delay/xmega/cycle_counter.h +++ /dev/null @@ -1,111 +0,0 @@ -/** - * \file - * - * \brief AVR functions for busy-wait delay loops - * - * Copyright (c) 2011 - 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef _cycle_counter_h_ -#define _cycle_counter_h_ - -#ifdef __cplusplus -extern "C" { -#endif - - -#include - -/** - * @name Convenience functions for busy-wait delay loops - * - * @def delay_cycles - * @brief Delay program execution for a specified number of CPU cycles. - * @param n number of CPU cycles to wait - * - * @def cpu_delay_ms - * @brief Delay program execution for a specified number of milliseconds. - * @param delay number of milliseconds to wait - * @param f_cpu CPU frequency in Hertz - * - * @def cpu_delay_us - * @brief Delay program execution for a specified number of microseconds. - * @param delay number of microseconds to wait - * @param f_cpu CPU frequency in Hertz - * - * @def cpu_ms_2_cy - * @brief Convert milli-seconds into CPU cycles. - * @param ms number of milliseconds - * @param f_cpu CPU frequency in Hertz - * @return the converted number of CPU cycles - * - * @def cpu_us_2_cy - * @brief Convert micro-seconds into CPU cycles. - * @param ms number of microseconds - * @param f_cpu CPU frequency in Hertz - * @return the converted number of CPU cycles - * - * @{ - */ -__always_optimize -static inline void __portable_avr_delay_cycles(unsigned long n) -{ - do { barrier(); } while (--n); -} - -#if !defined(__DELAY_CYCLE_INTRINSICS__) -# define delay_cycles __portable_avr_delay_cycles -# define cpu_ms_2_cy(ms, f_cpu) (((uint64_t)(ms) * (f_cpu) + 999) / 6e3) -# define cpu_us_2_cy(us, f_cpu) (((uint64_t)(us) * (f_cpu) + 999999ul) / 6e6) -#else -# if defined(__GNUC__) -# define delay_cycles __builtin_avr_delay_cycles -# elif defined(__ICCAVR__) -# define delay_cycles __delay_cycles -# endif -# define cpu_ms_2_cy(ms, f_cpu) (((uint64_t)(ms) * (f_cpu) + 999) / 1e3) -# define cpu_us_2_cy(us, f_cpu) (((uint64_t)(us) * (f_cpu) + 999999ul) / 1e6) -#endif - -#define cpu_delay_ms(delay, f_cpu) delay_cycles(cpu_ms_2_cy(delay, f_cpu)) -#define cpu_delay_us(delay, f_cpu) delay_cycles(cpu_us_2_cy(delay, f_cpu)) -//! @} - - -#ifdef __cplusplus -} -#endif - -#endif /* _cycle_counter_h_ */ diff --git a/DSTAT1/src/asf/common/services/hugemem/avr8/avr8_hugemem.c b/DSTAT1/src/asf/common/services/hugemem/avr8/avr8_hugemem.c deleted file mode 100644 index 44bb9c1..0000000 --- a/DSTAT1/src/asf/common/services/hugemem/avr8/avr8_hugemem.c +++ /dev/null @@ -1,195 +0,0 @@ -/** - * \file - * - * \brief Access to huge data memory with 8-bit AVR - * - * Copyright (c) 2009-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include "hugemem.h" -#include "compiler.h" -#include "conf_board.h" - -#if defined(CONFIG_HAVE_HUGEMEM) || defined(__DOXYGEN__) -# if defined(__GNUC__) || defined(__DOXYGEN__) -uint_fast16_t hugemem_read16(const hugemem_ptr_t from) -{ - uint16_t value; - - asm( - "movw r30, %A1 \n\t" - "out %2, %C1 \n\t" - "ld %A0, Z+ \n\t" - "ld %B0, Z \n\t" - "out %2, __zero_reg__ \n\t" - : "=r"(value) - : "r"(from), "i"(&RAMPZ) - : "r30", "r31" - ); - - return value; -} - -uint_fast32_t hugemem_read32(const hugemem_ptr_t from) -{ - uint32_t value; - - asm( - "movw r30, %A1 \n\t" - "out %2, %C1 \n\t" - "ld %A0, Z+ \n\t" - "ld %B0, Z+ \n\t" - "ld %C0, Z+ \n\t" - "ld %D0, Z \n\t" - "out %2, __zero_reg__ \n\t" - : "=r"(value) - : "r"(from), "i"(&RAMPZ) - : "r30", "r31" - ); - - return value; -} - -void hugemem_read_block(void *to, const hugemem_ptr_t from, size_t size) -{ - // Ensure that the address range to copy to is within 64 kB boundary. - Assert(((uint32_t)to + size) <= 0x10000); - - if (size > 0) { - asm volatile( - "movw r30, %A2 \n\t" - "out %3, %C2 \n\t" - "get_%=: \n\t" - "ld __tmp_reg__, Z+ \n\t" - "st X+, __tmp_reg__ \n\t" - "sbiw %A1, 1 \n\t" - "brne get_%= \n\t" - "out %3, __zero_reg__ \n\t" - : "+x"(to), "+w"(size) - : "r"(from), "i"(&RAMPZ) - : "r30", "r31" - ); - } -} - -void hugemem_write16(hugemem_ptr_t to, uint_fast16_t val) -{ - asm( - "movw r30, %A0 \n\t" - "out %2, %C0 \n\t" - "st Z+, %A1 \n\t" - "st Z, %B1 \n\t" - "out %2, __zero_reg__ \n\t" - : - : "r"(to), "r"(val), "i"(&RAMPZ) - : "r30", "r31" - ); -} - -void hugemem_write32(hugemem_ptr_t to, uint_fast32_t val) -{ - asm( - "movw r30, %A0 \n\t" - "out %2, %C0 \n\t" - "st Z+, %A1 \n\t" - "st Z+, %B1 \n\t" - "st Z+, %C1 \n\t" - "st Z, %D1 \n\t" - "out %2, __zero_reg__ \n\t" - : - : "r"(to), "r"(val), "i"(&RAMPZ) - : "r30", "r31" - ); -} - -void hugemem_write_block(hugemem_ptr_t to, const void *from, size_t size) -{ - // Ensure that the address range to copy from is within 64 kB boundary. - Assert(((uint32_t)from + size) <= 0x10000); - - if (size > 0) { - asm volatile( - "movw r30, %A2 \n\t" - "out %3, %C2 \n\t" - "put_%=: \n\t" - "ld __tmp_reg__, X+ \n\t" - "st Z+, __tmp_reg__ \n\t" - "sbiw %A1, 1 \n\t" - "brne put_%= \n\t" - "out %3, __zero_reg__ \n\t" - : "+x"(from), "+w"(size) - : "r"(to), "i"(&RAMPZ) - : "r30", "r31" - ); - } -} -# endif /* __GNUC__ */ - -# ifdef __ICCAVR__ -void hugemem_read_block(void *to, const hugemem_ptr_t from, size_t size) -{ - uint8_t *to_ptr; - uint8_t __huge *from_ptr; - - // Ensure that the address range to copy to is within 64 kB boundary. - Assert(((uint32_t)to + size) <= 0x10000); - - to_ptr = (uint8_t *)to; - from_ptr = (uint8_t __huge *)from; - - for (; size > 0; size--) { - *to_ptr++ = *from_ptr++; - } -} - -void hugemem_write_block(hugemem_ptr_t to, const void *from, size_t size) -{ - uint8_t __huge *to_ptr; - uint8_t *from_ptr; - - // Ensure that the address range to copy from is within 64 kB boundary. - Assert(((uint32_t)from + size) <= 0x10000); - - to_ptr = (uint8_t __huge *)to; - from_ptr = (uint8_t *)from; - - for (; size > 0; size--) { - *to_ptr++ = *from_ptr++; - } -} -# endif /* __ICCAVR__ */ -#endif /* CONFIG_HAVE_HUGEMEM */ diff --git a/DSTAT1/src/asf/common/services/hugemem/avr8/hugemem.h b/DSTAT1/src/asf/common/services/hugemem/avr8/hugemem.h deleted file mode 100644 index 76a612b..0000000 --- a/DSTAT1/src/asf/common/services/hugemem/avr8/hugemem.h +++ /dev/null @@ -1,163 +0,0 @@ -/** - * \file - * - * \brief Access to huge data memory with 8-bit AVR - * - * Do not include this file directly, but rather . - * - * Copyright (c) 2009-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef AVR8_HUGEMEM_H_INCLUDED -#define AVR8_HUGEMEM_H_INCLUDED - -#include -#include "conf_board.h" - -/** - * \weakgroup hugemem_group - * @{ - */ - -/** - * \internal - * \defgroup hugemem_avr8_group Hugemem implementation for 8-bit AVR. - * - * GCC does not have native support for 24-bit pointers, and therefore requires - * custom assembly functions for this purpose. The implemented functions leave - * RAMPZ cleared upon exit.\par - * - * If the chip does not support huge memory, i.e., \a CONFIG_HAVE_HUGEMEM is - * not defined, a generic implementation will be used. - */ - -#if defined(CONFIG_HAVE_HUGEMEM) || defined(__DOXYGEN__) -# if XMEGA && !(XMEGA_A1 || XMEGA_A1U) -# error CONFIG_HAVE_HUGEMEM is not supported on XMEGA parts without EBI. -# endif -# if defined(__GNUC__) || defined(__DOXYGEN__) -#include - -#include "compiler.h" - -typedef uint32_t hugemem_ptr_t; - -#define HUGEMEM_NULL 0 - -static inline uint_fast8_t hugemem_read8(const hugemem_ptr_t from) -{ - uint8_t value; - - asm volatile( - "movw r30, %A1 \n\t" - "out %2, %C1 \n\t" - "ld %0, Z \n\t" - "out %2, __zero_reg__ \n\t" - : "=r"(value) - : "r"(from), "i"(&RAMPZ) - : "r30", "r31" - ); - - return value; -} - -uint_fast16_t hugemem_read16(const hugemem_ptr_t from); -uint_fast32_t hugemem_read32(const hugemem_ptr_t from); - -static inline void hugemem_write8(hugemem_ptr_t to, uint_fast8_t val) -{ - asm volatile( - "movw r30, %A0 \n\t" - "out %2, %C0 \n\t" - "st Z, %1 \n\t" - "out %2, __zero_reg__ \n\t" - : - : "r"(to), "r"(val), "i"(&RAMPZ) - : "r30", "r31" - ); -} - -void hugemem_write16(hugemem_ptr_t to, uint_fast16_t val); -void hugemem_write32(hugemem_ptr_t to, uint_fast32_t val); - -# elif defined(__ICCAVR__) -#include - -typedef void __huge *hugemem_ptr_t; - -#define HUGEMEM_NULL NULL - -static inline uint_fast8_t hugemem_read8(const hugemem_ptr_t from) -{ - return *(volatile __huge uint8_t *)from; -} - -static inline uint_fast16_t hugemem_read16(const hugemem_ptr_t from) -{ - return *(volatile __huge uint16_t *)from; -} - -static inline uint_fast32_t hugemem_read32(const hugemem_ptr_t from) -{ - return *(volatile __huge uint32_t *)from; -} - -static inline void hugemem_write8(hugemem_ptr_t to, uint_fast8_t val) -{ - *(__huge uint8_t *)to = val; -} - -static inline void hugemem_write16(hugemem_ptr_t to, uint_fast16_t val) -{ - *(__huge uint16_t *)to = val; -} - -static inline void hugemem_write32(hugemem_ptr_t to, uint_fast32_t val) -{ - *(__huge uint32_t *)to = val; -} -# endif /* __ICCAVR__ */ - -void hugemem_read_block(void *to, const hugemem_ptr_t from, size_t size); -void hugemem_write_block(hugemem_ptr_t to, const void *from, size_t size); - -#else -# include -#endif /* CONFIG_HAVE_HUGEMEM */ -//@} - -#endif /* AVR8_HUGEMEM_H */ diff --git a/DSTAT1/src/asf/common/services/hugemem/generic/hugemem.h b/DSTAT1/src/asf/common/services/hugemem/generic/hugemem.h deleted file mode 100644 index 5f43e01..0000000 --- a/DSTAT1/src/asf/common/services/hugemem/generic/hugemem.h +++ /dev/null @@ -1,112 +0,0 @@ -/** - * \file - * - * \brief Generic implementation of huge data memory access - * - * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef GENERIC_HUGEMEM_H_INCLUDED -#define GENERIC_HUGEMEM_H_INCLUDED - -#include -#include - -/** - * \weakgroup hugemem_group - * @{ - */ - -/** - * \internal - * \defgroup hugemem_generic_group Generic hugemem implementation. - * - * These functions are needed for code compatibility between 8- and 32-bit AVR, - * as well as a different application configurations on 8-bit AVR, i.e., if huge - * data memory is optional. - */ - -typedef void * hugemem_ptr_t; - -#define HUGEMEM_NULL NULL - -static inline uint8_t hugemem_read8(const hugemem_ptr_t from) -{ - return *(uint8_t *)from; -} - -static inline uint16_t hugemem_read16(const hugemem_ptr_t from) -{ - return *(uint16_t *)from; -} - -static inline uint32_t hugemem_read32(const hugemem_ptr_t from) -{ - return *(uint32_t *)from; -} - -static inline void hugemem_read_block(void *to, const hugemem_ptr_t from, - size_t size) -{ - memcpy(to, from, size); -} - -static inline void hugemem_write8(hugemem_ptr_t to, uint8_t val) -{ - *(uint8_t *)to = val; -} - -static inline void hugemem_write16(hugemem_ptr_t to, uint16_t val) -{ - *(uint16_t *)to = val; -} - - -static inline void hugemem_write32(hugemem_ptr_t to, uint32_t val) -{ - *(uint32_t *)to = val; -} - -static inline void hugemem_write_block(hugemem_ptr_t to, const void *from, - size_t size) -{ - memcpy(to, from, size); -} - -//@} - -#endif /* GENERIC_HUGEMEM_H */ diff --git a/DSTAT1/src/asf/common/services/hugemem/hugemem.h b/DSTAT1/src/asf/common/services/hugemem/hugemem.h deleted file mode 100644 index fca4947..0000000 --- a/DSTAT1/src/asf/common/services/hugemem/hugemem.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - * \file - * - * \brief Huge data memory space access - * - * Copyright (c) 2009-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef HUGEMEM_H_INCLUDED -#define HUGEMEM_H_INCLUDED - -#include -#include - -#if defined(__AVR32__) || defined(__ICCAVR32__) -# include -#elif defined(__AVR__) || defined (__ICCAVR__) -# include -#else -# error Unknown architecture passed to hugemem interface. -# error Expected __AVR32__ or __AVR__. -#endif - -/** - * \defgroup hugemem_group Data in Huge Data Memory Space - * - * Due to shortcomings of the GCC compiler for 8-bit AVR, custom functions are - * needed for access to data beyond the 64 kB boundary, i.e., addresses that - * are larger than 16-bit. - * - * The definition of huge memory space can differ between architectures, so the - * implementation is architecture specific. - * - * This module supplies functions for copying a number of bytes between huge - * and 64 kB data memory space, and is needed solely for code compatibility - * across compilers. - * - * @{ - */ - -/** - * \typedef hugemem_ptr_t - * - * \brief Type to use for pointers to huge memory. - */ - -/** - * \def HUGEMEM_NULL - * - * \brief Hugemem null pointer, similar to NULL, but works across different - * platforms. - */ - -/** - * \fn uint_fast8_t hugemem_read8(const hugemem_ptr_t from) - * - * \brief Read 8-bit value stored at huge memory address \a from. - */ - -/** - * \fn uint_fast16_t hugemem_read16(const hugemem_ptr_t from) - * - * \brief Read 16-bit value stored at huge memory address \a from. - */ - -/** - * \fn void hugemem_read_block(void *to, const hugemem_ptr_t from, size_t size) - * - * \brief Read \a size bytes from huge memory address \a from into buffer at - * address \a to. - */ - -/** - * \fn uint_fast32_t hugemem_read32(const hugemem_ptr_t from) - * - * \brief Read 32-bit value stored at huge memory address \a from. - */ - -/** - * \fn void hugemem_write8(hugemem_ptr_t to, uint_fast8_t val) - * - * \brief Write 8-bit value \a val to huge memory address \a to. - */ - -/** - * \fn void hugemem_write16(hugemem_ptr_t to, uint_fast16_t val) - * - * \brief Write 16-bit value \a val to huge memory address \a to. - */ - -/** - * \fn void hugemem_write32(hugemem_ptr_t to, uint_fast32_t val) - * - * \brief Write 32-bit value \a val to huge memory address \a to. - */ - -/** - * \fn void hugemem_write_block(hugemem_ptr_t to, const void *from, size_t size) - * - * \brief Write \a size bytes from buffer at address \a from to huge memory - * address \a to. - */ - -//@} - -#endif /* HUGEMEM_H_INCLUDED */ diff --git a/DSTAT1/src/asf/common/services/ioport/ioport.h b/DSTAT1/src/asf/common/services/ioport/ioport.h deleted file mode 100644 index a27fb7b..0000000 --- a/DSTAT1/src/asf/common/services/ioport/ioport.h +++ /dev/null @@ -1,515 +0,0 @@ -/** - * \file - * - * \brief Common IOPORT service main header file for AVR, UC3 and ARM - * architectures. - * - * Copyright (c) 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef IOPORT_H -#define IOPORT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** - * \defgroup ioport_group Common IOPORT API - * - * See \ref ioport_quickstart. - * - * This is common IOPORT service for GPIO pin configuration and control in a - * standardized manner across the XMEGA, UC3 and ARM devices. - * - * Port pin control code is optimized for each platform, and should produce - * both compact and fast execution times when used with constant values. - * - * \section dependencies Dependencies - * This driver depends on the following modules: - * - \ref sysclk_group for clock speed and functions. - * @{ - */ - -/** - * \def IOPORT_CREATE_PIN(port, pin) - * \brief Create IOPORT pin number - * - * Create a IOPORT pin number for use with the IOPORT functions. - * - * \param port IOPORT port (e.g. PORTA, PA or PIOA depending on chosen - * architecture) - * \param pin IOPORT zero-based index of the I/O pin - */ - -/** \brief IOPORT pin directions */ -enum ioport_direction { - IOPORT_DIR_INPUT, /*!< IOPORT input direction */ - IOPORT_DIR_OUTPUT, /*!< IOPORT output direction */ -}; - -/** \brief IOPORT levels */ -enum ioport_value { - IOPORT_PIN_LEVEL_LOW, /*!< IOPORT pin value low */ - IOPORT_PIN_LEVEL_HIGH, /*!< IOPORT pin value high */ -}; - -/** \brief IOPORT edge sense modes */ -enum ioport_sense { - IOPORT_SENSE_BOTHEDGES, /*!< IOPORT sense both rising and falling edges */ - IOPORT_SENSE_RISING, /*!< IOPORT sense rising edges */ - IOPORT_SENSE_FALLING, /*!< IOPORT sense falling edges */ -}; - -#if XMEGA -# include "xmega/ioport.h" -# if defined(IOPORT_XMEGA_COMPAT) -# include "xmega/ioport_compat.h" -# endif -#elif UC3 -# include "uc3/ioport.h" -#elif SAM -# if SAM4L -# include "sam/ioport_gpio.h" -# else -# include "sam/ioport_pio.h" -# endif -#endif - -/** - * \brief Initializes the IOPORT service, ready for use. - * - * This function must be called before using any other functions in the IOPORT - * service. - */ -static inline void ioport_init(void) -{ - arch_ioport_init(); -} - -/** - * \brief Enable an IOPORT pin, based on a pin created with \ref - * IOPORT_CREATE_PIN(). - * - * \param pin IOPORT pin to enable - */ -static inline void ioport_enable_pin(ioport_pin_t pin) -{ - arch_ioport_enable_pin(pin); -} - -/** - * \brief Enable multiple pins in a single IOPORT port. - * - * \param port IOPORT port to enable - * \param mask Mask of pins within the port to enable - */ -static inline void ioport_enable_port(ioport_port_t port, - ioport_port_mask_t mask) -{ - arch_ioport_enable_port(port, mask); -} - -/** - * \brief Disable IOPORT pin, based on a pin created with \ref - * IOPORT_CREATE_PIN(). - * - * \param pin IOPORT pin to disable - */ -static inline void ioport_disable_pin(ioport_pin_t pin) -{ - arch_ioport_disable_pin(pin); -} - -/** - * \brief Disable multiple pins in a single IOPORT port. - * - * \param port IOPORT port to disable - * \param mask Pin mask of pins to disable - */ -static inline void ioport_disable_port(ioport_port_t port, - ioport_port_mask_t mask) -{ - arch_ioport_disable_port(port, mask); -} - -/** - * \brief Set multiple pin modes in a single IOPORT port, such as pull-up, - * pull-down, etc. configuration. - * - * \param port IOPORT port to configure - * \param mask Pin mask of pins to configure - * \param mode Mode masks to configure for the specified pins (\ref - * ioport_modes) - */ -static inline void ioport_set_port_mode(ioport_port_t port, - ioport_port_mask_t mask, ioport_mode_t mode) -{ - arch_ioport_set_port_mode(port, mask, mode); -} - -/** - * \brief Set pin mode for one single IOPORT pin. - * - * \param pin IOPORT pin to configure - * \param mode Mode masks to configure for the specified pin (\ref ioport_modes) - */ -static inline void ioport_set_pin_mode(ioport_pin_t pin, ioport_mode_t mode) -{ - arch_ioport_set_pin_mode(pin, mode); -} - -/** - * \brief Reset multiple pin modes in a specified IOPORT port to defaults. - * - * \param port IOPORT port to configure - * \param mask Mask of pins whose mode configuration is to be reset - */ -static inline void ioport_reset_port_mode(ioport_port_t port, - ioport_port_mask_t mask) -{ - arch_ioport_set_port_mode(port, mask, 0); -} - -/** - * \brief Reset pin mode configuration for a single IOPORT pin - * - * \param pin IOPORT pin to configure - */ -static inline void ioport_reset_pin_mode(ioport_pin_t pin) -{ - arch_ioport_set_pin_mode(pin, 0); -} - -/** - * \brief Set I/O direction for a group of pins in a single IOPORT. - * - * \param port IOPORT port to configure - * \param mask Pin mask of pins to configure - * \param dir Direction to set for the specified pins (\ref ioport_direction) - */ -static inline void ioport_set_port_dir(ioport_port_t port, - ioport_port_mask_t mask, enum ioport_direction dir) -{ - arch_ioport_set_port_dir(port, mask, dir); -} - -/** - * \brief Set direction for a single IOPORT pin. - * - * \param pin IOPORT pin to configure - * \param dir Direction to set for the specified pin (\ref ioport_direction) - */ -static inline void ioport_set_pin_dir(ioport_pin_t pin, - enum ioport_direction dir) -{ - arch_ioport_set_pin_dir(pin, dir); -} - -/** - * \brief Set an IOPORT pin to a specified logical value. - * - * \param pin IOPORT pin to configure - * \param level Logical value of the pin - */ -static inline void ioport_set_pin_level(ioport_pin_t pin, bool level) -{ - arch_ioport_set_pin_level(pin, level); -} - -/** - * \brief Set a group of IOPORT pins in a single port to a specified logical - * value. - * - * \param port IOPORT port to write to - * \param mask Pin mask of pins to modify - * \param level Level of the pins to be modified - */ -static inline void ioport_set_port_level(ioport_port_t port, - ioport_port_mask_t mask, ioport_port_mask_t level) -{ - arch_ioport_set_port_level(port, mask, level); -} - -/** - * \brief Get current value of an IOPORT pin, which has been configured as an - * input. - * - * \param pin IOPORT pin to read - * \return Current logical value of the specified pin - */ -static inline bool ioport_get_pin_level(ioport_pin_t pin) -{ - return arch_ioport_get_pin_level(pin); -} - -/** - * \brief Get current value of several IOPORT pins in a single port, which have - * been configured as an inputs. - * - * \param port IOPORT port to read - * \param mask Pin mask of pins to read - * \return Logical levels of the specified pins from the read port, returned as - * a mask. - */ -static inline ioport_port_mask_t ioport_get_port_level(ioport_pin_t port, - ioport_port_mask_t mask) -{ - return arch_ioport_get_port_level(port, mask); -} - -/** - * \brief Toggle the value of an IOPORT pin, which has previously configured as - * an output. - * - * \param pin IOPORT pin to toggle - */ -static inline void ioport_toggle_pin_level(ioport_pin_t pin) -{ - arch_ioport_toggle_pin_level(pin); -} - -/** - * \brief Toggle the values of several IOPORT pins located in a single port. - * - * \param port IOPORT port to modify - * \param mask Pin mask of pins to toggle - */ -static inline void ioport_toggle_port_level(ioport_port_t port, - ioport_port_mask_t mask) -{ - arch_ioport_toggle_port_level(port, mask); -} - -/** - * \brief Set the pin sense mode of a single IOPORT pin. - * - * \param pin IOPORT pin to configure - * \param pin_sense Edge to sense for the pin (\ref ioport_sense) - */ -static inline void ioport_set_pin_sense_mode(ioport_pin_t pin, - enum ioport_sense pin_sense) -{ - arch_ioport_set_pin_sense_mode(pin, pin_sense); -} - -/** - * \brief Set the pin sense mode of a multiple IOPORT pins on a single port. - * - * \param port IOPORT port to configure - * \param mask Bitmask if pins whose edge sense is to be configured - * \param pin_sense Edge to sense for the pins (\ref ioport_sense) - */ -static inline void ioport_set_port_sense_mode(ioport_port_t port, - ioport_port_mask_t mask, - enum ioport_sense pin_sense) -{ - arch_ioport_set_port_sense_mode(port, mask, pin_sense); -} - -/** - * \brief Convert a pin ID into a its port ID. - * - * \param pin IOPORT pin ID to convert - * \retval Port ID for the given pin ID - */ -static inline ioport_port_t ioport_pin_to_port_id(ioport_pin_t pin) -{ - return arch_ioport_pin_to_port_id(pin); -} - -/** - * \brief Convert a pin ID into a bitmask mask for the given pin on its port. - * - * \param pin IOPORT pin ID to convert - * \retval Bitmask with a bit set that corresponds to the given pin ID in its port - */ -static inline ioport_port_mask_t ioport_pin_to_mask(ioport_pin_t pin) -{ - return arch_ioport_pin_to_mask(pin); -} - -/** @} */ - -/** - * \page ioport_quickstart Quick start guide for the common IOPORT service - * - * This is the quick start guide for the \ref ioport_group, with - * step-by-step instructions on how to configure and use the service in a - * selection of use cases. - * - * The use cases contain several code fragments. The code fragments in the - * steps for setup can be copied into a custom initialization function, while - * the steps for usage can be copied into, e.g., the main application function. - * - * \section ioport_quickstart_basic Basic use case - * In this use case we will configure one IO pin for button input and one for - * LED control. Then it will read the button state and output it on the LED. - * - * \section ioport_quickstart_basic_setup Setup steps - * - * \subsection ioport_quickstart_basic_setup_code Example code - * \code - * #define MY_LED IOPORT_CREATE_PIN(PORTA, 5) - * #define MY_BUTTON IOPORT_CREATE_PIN(PORTA, 6) - * - * ioport_init(); - * - * ioport_set_pin_dir(MY_LED, IOPORT_DIR_OUTPUT); - * ioport_set_pin_dir(MY_BUTTON, IOPORT_DIR_INPUT); - * ioport_set_pin_mode(MY_BUTTON, IOPORT_MODE_PULLUP); - * \endcode - * - * \subsection ioport_quickstart_basic_setup_flow Workflow - * -# It's useful to give the GPIOs symbolic names and this can be done with - * the \ref IOPORT_CREATE_PIN macro. We define one for a LED and one for a - * button. - * - \code - * #define MY_LED IOPORT_CREATE_PIN(PORTA, 5) - * #define MY_BUTTON IOPORT_CREATE_PIN(PORTA, 6) - * \endcode - * - \note The usefulness of the \ref IOPORT_CREATE_PIN macro and port names - * differ between architectures: - * - XMEGA: Use \ref IOPORT_CREATE_PIN macro with port definitions - * PORTA, PORTB ... - * - UC3: Most convenient to pick up the device header file pin definition - * and us it directly. E.g.: AVR32_PIN_PB06 - * - SAM: Most convenient to pick up the device header file pin definition - * and us it directly. E.g.: PIO_PA5_IDX
- * \ref IOPORT_CREATE_PIN can also be used with port definitions - * PIOA, PIOB ... - * -# Initialize the ioport service. This typically enables the IO module if - * needed. - * - \code ioport_init(); \endcode - * -# Set the LED GPIO as output: - * - \code ioport_set_pin_dir(MY_LED, IOPORT_DIR_OUTPUT); \endcode - * -# Set the button GPIO as input: - * - \code ioport_set_pin_dir(MY_BUTTON, IOPORT_DIR_INPUT); \endcode - * -# Enable pull-up for the button GPIO: - * - \code ioport_set_pin_mode(MY_BUTTON, IOPORT_MODE_PULLUP); \endcode - * - * \section ioport_quickstart_basic_usage Usage steps - * - * \subsection ioport_quickstart_basic_usage_code Example code - * \code - * bool value; - * - * value = ioport_get_pin_level(MY_BUTTON); - * ioport_set_pin_level(MY_LED, value); - * \endcode - * - * \subsection ioport_quickstart_basic_usage_flow Workflow - * -# Define a boolean variable for state storage: - * - \code bool value; \endcode - * -# Read out the button level into variable value: - * - \code value = ioport_get_pin_level(MY_BUTTON); \endcode - * -# Set the LED to read out value from the button: - * - \code ioport_set_pin_level(MY_LED, value); \endcode - * - * \section ioport_quickstart_advanced Advanced use cases - * - \subpage ioport_quickstart_use_case_1 : Port access - */ - -/** - * \page ioport_quickstart_use_case_1 Advanced use case doing port access - * - * In this case we will read out the pins from one whole port and write the - * read value to another port. - * - * \section ioport_quickstart_use_case_1_setup Setup steps - * - * \subsection ioport_quickstart_use_case_1_setup_code Example code - * \code - * #define IN_PORT IOPORT_PORTA - * #define OUT_PORT IOPORT_PORTB - * #define MASK 0x00000060 - * - * ioport_init(); - * - * ioport_set_port_dir(IN_PORT, MASK, IOPORT_DIR_INPUT); - * ioport_set_port_dir(OUT_PORT, MASK, IOPORT_DIR_OUTPUT); - * \endcode - * - * \subsection ioport_quickstart_basic_setup_flow Workflow - * -# It's useful to give the ports symbolic names: - * - \code - * #define IN_PORT IOPORT_PORTA - * #define OUT_PORT IOPORT_PORTB - * \endcode - * - \note The port names differ between architectures: - * - XMEGA: There are predefined names for ports: IOPORT_PORTA, - * IOPORT_PORTB ... - * - UC3: Use the index value of the different IO blocks: 0, 1 ... - * - SAM: There are predefined names for ports: IOPORT_PIOA, IOPORT_PIOB - * ... - * -# Also useful to define a mask for the bits to work with: - * - \code #define MASK 0x00000060 \endcode - * -# Initialize the ioport service. This typically enables the IO module if - * needed. - * - \code ioport_init(); \endcode - * -# Set one of the ports as input: - * - \code ioport_set_pin_dir(IN_PORT, MASK, IOPORT_DIR_INPUT); \endcode - * -# Set the other port as output: - * - \code ioport_set_pin_dir(OUT_PORT, MASK, IOPORT_DIR_OUTPUT); \endcode - * - * \section ioport_quickstart_basic_usage Usage steps - * - * \subsection ioport_quickstart_basic_usage_code Example code - * \code - * ioport_port_mask_t value; - * - * value = ioport_get_port_level(IN_PORT, MASK); - * ioport_set_port_level(OUT_PORT, MASK, value); - * \endcode - * - * \subsection ioport_quickstart_basic_usage_flow Workflow - * -# Define a variable for port date storage: - * - \code ioport_port_mask_t value; \endcode - * -# Read out from one port: - * - \code value = ioport_get_port_level(IN_PORT, MASK); \endcode - * -# Put the read data out on the other port: - * - \code ioport_set_port_level(OUT_PORT, MASK, value); \endcode - */ - -#ifdef __cplusplus -} -#endif - -#endif /* IOPORT_H */ diff --git a/DSTAT1/src/asf/common/services/ioport/xmega/ioport.h b/DSTAT1/src/asf/common/services/ioport/xmega/ioport.h deleted file mode 100644 index 5b2f21f..0000000 --- a/DSTAT1/src/asf/common/services/ioport/xmega/ioport.h +++ /dev/null @@ -1,337 +0,0 @@ -/** - * \file - * - * \brief XMEGA architecture specific IOPORT service implementation header file. - * - * Copyright (c) 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef IOPORT_XMEGA_H -#define IOPORT_XMEGA_H - -#define IOPORT_CREATE_PIN(port, pin) ((IOPORT_ ## port) * 8 + (pin)) -#define IOPORT_BASE_ADDRESS 0x600 -#define IOPORT_PORT_OFFSET 0x20 - -/** \name IOPORT port numbers */ -/** @{ */ -#if !XMEGA_B3 -# define IOPORT_PORTA 0 -#endif - -#define IOPORT_PORTB 1 -#define IOPORT_PORTC 2 -#define IOPORT_PORTD 3 - -#if !XMEGA_B3 -# define IOPORT_PORTE 4 -#endif - -#if XMEGA_A1 || XMEGA_A1U || XMEGA_A3 || XMEGA_A3U || XMEGA_A3B || XMEGA_A3BU ||\ - XMEGA_C3 || XMEGA_D3 -# define IOPORT_PORTF 5 -#endif - -#if XMEGA_B1 || XMEGA_B3 -# define IOPORT_PORTG 6 -#endif - -#if XMEGA_A1 || XMEGA_A1U -# define IOPORT_PORTH 7 -# define IOPORT_PORTJ 8 -# define IOPORT_PORTK 9 -#endif - -#if XMEGA_B1 || XMEGA_B3 -# define IOPORT_PORTM 11 -#endif - -#if XMEGA_A1 || XMEGA_A1U -# define IOPORT_PORTQ 14 -#endif - -#define IOPORT_PORTR 15 -/** @} */ - -/** - * \weakgroup ioport_group - * \section ioport_modes IOPORT Modes - * - * For details on these please see the XMEGA Manual. - * - * @{ - */ - -/** \name IOPORT Mode bit definitions */ -/** @{ */ -#define IOPORT_MODE_TOTEM (0x00 << 3) /*!< Totem-pole */ -#define IOPORT_MODE_BUSKEEPER (0x01 << 3) /*!< Buskeeper */ -#define IOPORT_MODE_PULLDOWN (0x02 << 3) /*!< Pull-down */ -#define IOPORT_MODE_PULLUP (0x03 << 3) /*!< Pull-up */ -#define IOPORT_MODE_WIREDOR (0x04 << 3) /*!< Wired OR */ -#define IOPORT_MODE_WIREDAND (0x05 << 3) /*!< Wired AND */ -#define IOPORT_MODE_WIREDORPULL (0x06 << 3) /*!< Wired OR with pull-down */ -#define IOPORT_MODE_WIREDANDPULL (0x07 << 3) /*!< Wired AND with pull-up */ -#define IOPORT_MODE_INVERT_PIN (0x01 << 6) /*!< Invert output and input */ -#define IOPORT_MODE_SLEW_RATE_LIMIT (0x01 << 7) /*!< Slew rate limiting */ -/** @} */ - -/** @} */ - -typedef uint8_t ioport_mode_t; -typedef uint8_t ioport_pin_t; -typedef uint8_t ioport_port_t; -typedef uint8_t ioport_port_mask_t; - -__always_inline static ioport_port_t arch_ioport_pin_to_port_id(ioport_pin_t pin) -{ - return pin >> 3; -} - -__always_inline static PORT_t *arch_ioport_port_to_base(ioport_port_t port) -{ - return (PORT_t *)((uintptr_t)IOPORT_BASE_ADDRESS + - (port * IOPORT_PORT_OFFSET)); -} - -__always_inline static PORT_t *arch_ioport_pin_to_base(ioport_pin_t pin) -{ - return arch_ioport_port_to_base(arch_ioport_pin_to_port_id(pin)); -} - -__always_inline static ioport_port_mask_t arch_ioport_pin_to_mask(ioport_pin_t pin) -{ - return 1U << (pin & 0x07); -} - -__always_inline static ioport_port_mask_t arch_ioport_pin_to_index(ioport_pin_t pin) -{ - return (pin & 0x07); -} - -__always_inline static void arch_ioport_init(void) -{ - -} - -__always_inline static void arch_ioport_enable_port(ioport_port_t port, - ioport_port_mask_t mask) -{ - PORT_t *base = arch_ioport_port_to_base(port); - volatile uint8_t *pin_ctrl = &base->PIN0CTRL; - - uint8_t flags = cpu_irq_save(); - - for (uint8_t i = 0; i < 8; i++) { - if (mask & arch_ioport_pin_to_mask(i)) { - pin_ctrl[i] &= ~PORT_ISC_gm; - } - } - - cpu_irq_restore(flags); -} - -__always_inline static void arch_ioport_enable_pin(ioport_pin_t pin) -{ - PORT_t *base = arch_ioport_pin_to_base(pin); - volatile uint8_t *pin_ctrl = - (&base->PIN0CTRL + arch_ioport_pin_to_index(pin)); - - uint8_t flags = cpu_irq_save(); - - *pin_ctrl &= ~PORT_ISC_gm; - - cpu_irq_restore(flags); -} - -__always_inline static void arch_ioport_disable_port(ioport_port_t port, - ioport_port_mask_t mask) -{ - PORT_t *base = arch_ioport_port_to_base(port); - volatile uint8_t *pin_ctrl = &base->PIN0CTRL; - - uint8_t flags = cpu_irq_save(); - - for (uint8_t i = 0; i < 8; i++) { - if (mask & arch_ioport_pin_to_mask(i)) { - pin_ctrl[i] |= PORT_ISC_INPUT_DISABLE_gc; - } - } - - cpu_irq_restore(flags); -} - -__always_inline static void arch_ioport_disable_pin(ioport_pin_t pin) -{ - PORT_t *base = arch_ioport_pin_to_base(pin); - volatile uint8_t *pin_ctrl = - (&base->PIN0CTRL + arch_ioport_pin_to_index(pin)); - - uint8_t flags = cpu_irq_save(); - - *pin_ctrl |= PORT_ISC_INPUT_DISABLE_gc; - - cpu_irq_restore(flags); -} - -__always_inline static void arch_ioport_set_port_mode(ioport_port_t port, - ioport_port_mask_t mask, ioport_mode_t mode) -{ - PORT_t *base = arch_ioport_port_to_base(port); - - PORTCFG.MPCMASK = mask; - base->PIN0CTRL = mode; -} - -__always_inline static void arch_ioport_set_pin_mode(ioport_pin_t pin, - ioport_mode_t mode) -{ - PORT_t *base = arch_ioport_pin_to_base(pin); - - PORTCFG.MPCMASK = arch_ioport_pin_to_mask(pin); - base->PIN0CTRL = mode; -} - -__always_inline static void arch_ioport_set_port_dir(ioport_port_t port, - ioport_port_mask_t mask, enum ioport_direction dir) -{ - PORT_t *base = arch_ioport_port_to_base(port); - - if (dir == IOPORT_DIR_OUTPUT) { - base->DIRSET = mask; - } else if (dir == IOPORT_DIR_INPUT) { - base->DIRCLR = mask; - } -} - -__always_inline static void arch_ioport_set_pin_dir(ioport_pin_t pin, - enum ioport_direction dir) -{ - PORT_t *base = arch_ioport_pin_to_base(pin); - - if (dir == IOPORT_DIR_OUTPUT) { - base->DIRSET = arch_ioport_pin_to_mask(pin); - } else if (dir == IOPORT_DIR_INPUT) { - base->DIRCLR = arch_ioport_pin_to_mask(pin); - } -} - -__always_inline static void arch_ioport_set_pin_level(ioport_pin_t pin, - bool level) -{ - PORT_t *base = arch_ioport_pin_to_base(pin); - - if (level) { - base->OUTSET = arch_ioport_pin_to_mask(pin); - } else { - base->OUTCLR = arch_ioport_pin_to_mask(pin); - } -} - -__always_inline static void arch_ioport_set_port_level(ioport_port_t port, - ioport_port_mask_t mask, ioport_port_mask_t level) -{ - PORT_t *base = arch_ioport_port_to_base(port); - - base->OUTSET = mask & level; - base->OUTCLR = mask & ~level; -} - -__always_inline static bool arch_ioport_get_pin_level(ioport_pin_t pin) -{ - PORT_t *base = arch_ioport_pin_to_base(pin); - - return base->IN & arch_ioport_pin_to_mask(pin); -} - -__always_inline static ioport_port_mask_t arch_ioport_get_port_level( - ioport_port_t port, ioport_port_mask_t mask) -{ - PORT_t *base = arch_ioport_port_to_base(port); - - return base->IN & mask; -} - -__always_inline static void arch_ioport_toggle_pin_level(ioport_pin_t pin) -{ - PORT_t *base = arch_ioport_pin_to_base(pin); - - base->OUTTGL = arch_ioport_pin_to_mask(pin); -} - -__always_inline static void arch_ioport_toggle_port_level(ioport_port_t port, - ioport_port_mask_t mask) -{ - PORT_t *base = arch_ioport_port_to_base(port); - - base->OUTTGL = mask; -} - -__always_inline static void arch_ioport_set_pin_sense_mode(ioport_pin_t pin, - enum ioport_sense pin_sense) -{ - PORT_t *base = arch_ioport_pin_to_base(pin); - volatile uint8_t *pin_ctrl = - (&base->PIN0CTRL + arch_ioport_pin_to_index(pin)); - - uint8_t flags = cpu_irq_save(); - - *pin_ctrl &= ~PORT_ISC_gm; - *pin_ctrl |= (pin_sense & PORT_ISC_gm); - - cpu_irq_restore(flags); -} - -__always_inline static void arch_ioport_set_port_sense_mode(ioport_port_t port, - ioport_port_mask_t mask, enum ioport_sense pin_sense) -{ - PORT_t *base = arch_ioport_port_to_base(port); - volatile uint8_t *pin_ctrl = &base->PIN0CTRL; - uint8_t new_sense_bits = (pin_sense & PORT_ISC_gm); - - uint8_t flags = cpu_irq_save(); - - for (uint8_t i = 0; i < 8; i++) { - if (mask & arch_ioport_pin_to_mask(i)) { - pin_ctrl[i] = (pin_ctrl[i] & ~PORT_ISC_gm) | new_sense_bits; - } - } - - cpu_irq_restore(flags); -} - -#endif /* IOPORT_XMEGA_H */ diff --git a/DSTAT1/src/asf/common/services/ioport/xmega/ioport_compat.c b/DSTAT1/src/asf/common/services/ioport/xmega/ioport_compat.c deleted file mode 100644 index af81a81..0000000 --- a/DSTAT1/src/asf/common/services/ioport/xmega/ioport_compat.c +++ /dev/null @@ -1,70 +0,0 @@ -/** - * \file - * - * \brief XMEGA legacy IOPORT software compatibility driver interface. - * - * Copyright (c) 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include "ioport_compat.h" - -#if defined(IOPORT_XMEGA_COMPAT) -void ioport_configure_port_pin(void *port, pin_mask_t pin_mask, - port_pin_flags_t flags) -{ - uint8_t pin; - - for (pin = 0; pin < 8; pin++) { - if (pin_mask & (1 << pin)) { - *((uint8_t *)port + PORT_PIN0CTRL + pin) = flags >> 8; - } - } - /* Select direction and initial pin state */ - if (flags & IOPORT_DIR_OUTPUT) { - if (flags & IOPORT_INIT_HIGH) { - *((uint8_t *)port + PORT_OUTSET) = pin_mask; - } else { - *((uint8_t *)port + PORT_OUTCLR) = pin_mask; - } - - *((uint8_t *)port + PORT_DIRSET) = pin_mask; - } else { - *((uint8_t *)port + PORT_DIRCLR) = pin_mask; - } -} - -#endif diff --git a/DSTAT1/src/asf/common/services/ioport/xmega/ioport_compat.h b/DSTAT1/src/asf/common/services/ioport/xmega/ioport_compat.h deleted file mode 100644 index 91ed6ec..0000000 --- a/DSTAT1/src/asf/common/services/ioport/xmega/ioport_compat.h +++ /dev/null @@ -1,315 +0,0 @@ -/** - * \file - * - * \brief XMEGA legacy IOPORT software compatibility driver interface header - * file. - * - * Copyright (c) 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef IOPORT_XMEGA_COMPAT_H_ -#define IOPORT_XMEGA_COMPAT_H_ - -#include "../ioport.h" - -/** - * \brief A pin mask - * - * This type is used to describe the port pin mask on the part. - */ -typedef uint8_t pin_mask_t; - -/** - * \brief A PORT pin - * - * This type is used to describe the PORT pins on the part. - */ -typedef uint8_t port_pin_t; - -/** - * \brief Pin configuration flags - * - * This is a bitmask containing configuration flags for the pins that shall be - * configured. - */ -typedef uint16_t port_pin_flags_t; - -/** - * \brief A port id - * - * This type is used to describe the port id on the part (0 is PORTA). - */ -typedef uint8_t port_id_t; - -/** \name Initial Output State Flags */ -/** @{ */ -#define IOPORT_INIT_LOW (0 << 1) /*!< Initial Output State Low */ -#define IOPORT_INIT_HIGH (1 << 1) /*!< Initial Output State High */ -/** @} */ - -/** \name Input/Sense Configuration Flags */ -/** @{ */ -#define IOPORT_BOTHEDGES (0 << 8) /*!< Sense Both Edges */ -#define IOPORT_RISING (1 << 8) /*!< Sense Rising Edge */ -#define IOPORT_FALLING (2 << 8) /*!< Sense Falling Edge */ -#define IOPORT_LEVEL (3 << 8) /*!< Sense Low Level */ -#define IOPORT_INPUT_DISABLE (7 << 8) /*!< Input Buffer Disabled */ -/** @} */ - -/** \name Output and Pull Configuration Flags */ -/** @{ */ -#define IOPORT_TOTEM (0 << 11) /*!< Normal push/pull output */ -#define IOPORT_BUSKEEPER (1 << 11) /*!< Bus Keeper */ -#define IOPORT_PULL_DOWN (2 << 11) /*!< Pull-Down (when input) */ -#define IOPORT_PULL_UP (3 << 11) /*!< Pull-Up (when input) */ -#define IOPORT_WIRED_OR (4 << 11) /*!< Wired OR */ -#define IOPORT_WIRED_AND (5 << 11) /*!< Wired AND */ -#define IOPORT_WIRED_OR_PULL_DOWN (6 << 11) /*!< Wired OR and Pull-Down */ -#define IOPORT_WIRED_AND_PULL_UP (7 << 11) /*!< Wired AND and Pull-Up */ -/** @} */ - -/** \name Inverted I/O Configuration Flags */ -/** @{ */ -#define IOPORT_INV_ENABLED (1 << 14) /*!< I/O is Inverted */ -#define IOPORT_INV_DISABLE (0 << 14) /*!< I/O is Not Inverted */ -/** @} */ - -/** \name Slew Rate Limit Configuration Flags */ -/** @{ */ -#define IOPORT_SRL_ENABLED (1 << 15) /*!< Slew Rate Limit Enabled */ -#define IOPORT_SRL_DISABLED (0 << 15) /*!< Slew Rate Limit Disabled */ -/** @} */ - -/** - * \internal - * \name PORT fields structure offset - * - * These macros are used to compute the field offset number with the PORT_t - * structure. - */ -/** @{ */ -#define PORT_DIR 0x00 /*!< Data Direction */ -#define PORT_DIRSET 0x01 /*!< Data Direction Set */ -#define PORT_DIRCLR 0x02 /*!< Data Direction Clear */ -#define PORT_DIRTGL 0x03 /*!< Data Direction Toggle */ -#define PORT_OUT 0x04 /*!< Data Output Value */ -#define PORT_OUTSET 0x05 /*!< Data Output Value Set */ -#define PORT_OUTCLR 0x06 /*!< Data Output Value Clear */ -#define PORT_OUTTGL 0x07 /*!< Data Output Value Toggle */ -#define PORT_IN 0x08 /*!< Data Input Value */ -#define PORT_INTCTRL 0x09 /*!< Interrupt Control */ -#define PORT_INT0MASK 0x0A /*!< Interrupt 0 Mask */ -#define PORT_INT1MASK 0x0B /*!< Interrupt 1 Mask */ -#define PORT_INTFLAGS 0x0C /*!< Interrupt Flags */ -#define PORT_PIN0CTRL 0x10 /*!< Pin 0 Configuration */ -#define PORT_PIN1CTRL 0x11 /*!< Pin 1 Configuration */ -#define PORT_PIN2CTRL 0x12 /*!< Pin 2 Configuration */ -#define PORT_PIN3CTRL 0x13 /*!< Pin 3 Configuration */ -#define PORT_PIN4CTRL 0x14 /*!< Pin 4 Configuration */ -#define PORT_PIN5CTRL 0x15 /*!< Pin 5 Configuration */ -#define PORT_PIN6CTRL 0x16 /*!< Pin 6 Configuration */ -#define PORT_PIN7CTRL 0x17 /*!< Pin 7 Configuration */ -/** @} */ - -static inline PORT_t *ioport_pin_to_port(port_pin_t pin) -{ - return arch_ioport_pin_to_base(pin); -} - -static inline PORT_t *ioport_id_pin_to_port(port_id_t port) -{ - return arch_ioport_port_to_base(port); -} - -/** - * \brief Configure the IO PORT pin function for a set of pins on a port - * - * \param port Pointer to the port - * \param pin_mask Mask containing the pins that should be configured - * \param flags Bitmask of flags specifying additional configuration - * parameters. - */ -void ioport_configure_port_pin(void *port, pin_mask_t pin_mask, - port_pin_flags_t flags); - -/** - * \brief Select the port function for a single pin - * - * \param pin The pin to configure - * \param flags Bitmask of flags specifying additional configuration - * parameters. - */ -static inline void ioport_configure_pin(port_pin_t pin, port_pin_flags_t flags) -{ - ioport_configure_port_pin(arch_ioport_pin_to_base(pin), - arch_ioport_pin_to_mask(pin), flags); -} - -/** - * \brief Configure a group of I/O pins on a specified port number - * - * \param port The port number - * \param pin_mask The pin mask to configure - * \param flags Bitmask of flags specifying additional configuration - * parameters. - */ -static inline void ioport_configure_group(port_id_t port, pin_mask_t pin_mask, - port_pin_flags_t flags) -{ - ioport_configure_port_pin(arch_ioport_port_to_base(port), pin_mask, flags); -} - -/** - * \brief Drive a PORT pin to a given state - * - * This function will only have an effect if \a pin is configured as - * an output. - * - * \param pin A number identifying the pin to act on. - * \param value The desired state of the pin. \a true means drive the - * pin high (towards Vdd), while \a false means drive the pin low - * (towards Vss). - */ -static inline void ioport_set_value(port_pin_t pin, bool value) -{ - arch_ioport_set_pin_level(pin, value); -} - -/** - * \brief Drive a PORT pin to a low level - * - * This function will only have an effect if \a pin is configured as - * an output. - * - * \param pin A number identifying the pin to act on. - */ -static inline void ioport_set_pin_low(port_pin_t pin) -{ - arch_ioport_set_pin_level(pin, false); -} - -/** - * \brief Drive a PORT pin to a high level - * - * This function will only have an effect if \a pin is configured as - * an output. - * - * \param pin A number identifying the pin to act on. - */ -static inline void ioport_set_pin_high(port_pin_t pin) -{ - arch_ioport_set_pin_level(pin, true); -} - -/** - * \brief Read the current state of a PORT pin - * - * \param pin A number identifying the pin to read. - * \retval true The pin is currently high (close to Vdd) - * \retval false The pin is currently low (close to Vss) - */ -static inline bool ioport_get_value(port_pin_t pin) -{ - return arch_ioport_get_pin_level(pin); -} - -/** - * \brief Read the current state of a PORT pin and test high level - * - * \param pin A number identifying the pin to read. - * \retval true The pin is currently high (close to Vdd) - * \retval false The pin is currently low (close to Vss) - */ -static inline bool ioport_pin_is_high(port_pin_t pin) -{ - return (arch_ioport_get_pin_level(pin) == true); -} - -/** - * \brief Read the current state of a PORT pin and test high level - * - * \param pin A number identifying the pin to read. - * \retval true The pin is currently high (close to Vdd) - * \retval false The pin is currently low (close to Vss) - */ -static inline bool ioport_pin_is_low(port_pin_t pin) -{ - return (arch_ioport_get_pin_level(pin) == false); -} - -/** - * \brief Toggle the current state of a PORT pin - * - * \param pin A number identifying the pin to act on. - */ -static inline void ioport_toggle_pin(port_pin_t pin) -{ - arch_ioport_toggle_pin_level(pin); -} - -/*! \brief Drives a group of I/O pin of a port to high level. - * - * \param port_id The port number. - * \param port_mask The mask. - */ -static inline void ioport_set_group_high(port_id_t port_id, - pin_mask_t port_mask) -{ - arch_ioport_set_port_level(port_id, port_mask, port_mask); -} - -/*! \brief Drives a group of I/O pin of a port to low level. - * - * \param port_id The port number. - * \param port_mask The mask. - */ -static inline void ioport_set_group_low(port_id_t port_id, pin_mask_t port_mask) -{ - arch_ioport_set_port_level(port_id, port_mask, 0); -} - -/*! \brief Toggles a group of I/O pin of a port. - * - * \param port_id The port number. - * \param port_mask The mask. - */ -static inline void ioport_tgl_group(port_id_t port_id, pin_mask_t port_mask) -{ - arch_ioport_toggle_port_level(port_id, port_mask); -} - -#endif /* IOPORT_COMPAT_H_ */ diff --git a/DSTAT1/src/asf/common/services/sleepmgr/sleepmgr.h b/DSTAT1/src/asf/common/services/sleepmgr/sleepmgr.h deleted file mode 100644 index baeca3f..0000000 --- a/DSTAT1/src/asf/common/services/sleepmgr/sleepmgr.h +++ /dev/null @@ -1,236 +0,0 @@ -/** - * \file - * - * \brief Sleep manager - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef SLEEPMGR_H -#define SLEEPMGR_H - -#include -#include -#include - -#if defined(XMEGA) -# include "xmega/sleepmgr.h" -#elif (defined(__GNUC__) && defined(__AVR32__)) || (defined(__ICCAVR32__) || defined(__AAVR32__)) -# include "uc3/sleepmgr.h" -#else -# error Unsupported device. -#endif - -/** - * \defgroup sleepmgr_group Sleep manager - * - * The sleep manager is a service for ensuring that the device is not put to - * sleep in deeper sleep modes than the system (e.g., peripheral drivers, - * services or the application) allows at any given time. - * - * It is based on the use of lock counting for the individual sleep modes, and - * will put the device to sleep in the shallowest sleep mode that has a non-zero - * lock count. The drivers/services/application can change these counts by use - * of \ref sleepmgr_lock_mode and \ref sleepmgr_unlock_mode. - * Refer to \ref sleepmgr_mode for a list of the sleep modes available for - * locking, and the device datasheet for information on their effect. - * - * The application must supply the file \ref conf_sleepmgr.h. - * - * For the sleep manager to be enabled, the symbol \ref CONFIG_SLEEPMGR_ENABLE - * must be defined, e.g., in \ref conf_sleepmgr.h. If this symbol is not - * defined, the functions are replaced with dummy functions and no RAM is used. - * - * @{ - */ - -/** - * \def CONFIG_SLEEPMGR_ENABLE - * \brief Configuration symbol for enabling the sleep manager - * - * If this symbol is not defined, the functions of this service are replaced - * with dummy functions. This is useful for reducing code size and execution - * time if the sleep manager is not needed in the application. - * - * This symbol may be defined in \ref conf_sleepmgr.h. - */ -#if defined(__DOXYGEN__) && !defined(CONFIG_SLEEPMGR_ENABLE) -# define CONFIG_SLEEPMGR_ENABLE -#endif - -/** - * \enum sleepmgr_mode - * \brief Sleep mode locks - * - * Identifiers for the different sleep mode locks. - */ - -/** - * \brief Initialize the lock counts - * - * Sets all lock counts to 0, except the very last one, which is set to 1. This - * is done to simplify the algorithm for finding the deepest allowable sleep - * mode in \ref sleepmgr_enter_sleep. - */ -static inline void sleepmgr_init(void) -{ -#ifdef CONFIG_SLEEPMGR_ENABLE - uint8_t i; - - for (i = 0; i < SLEEPMGR_NR_OF_MODES - 1; i++) { - sleepmgr_locks[i] = 0; - } - sleepmgr_locks[SLEEPMGR_NR_OF_MODES - 1] = 1; -#endif /* CONFIG_SLEEPMGR_ENABLE */ -} - -/** - * \brief Increase lock count for a sleep mode - * - * Increases the lock count for \a mode to ensure that the sleep manager does - * not put the device to sleep in the deeper sleep modes. - * - * \param mode Sleep mode to lock. - */ -static inline void sleepmgr_lock_mode(enum sleepmgr_mode mode) -{ -#ifdef CONFIG_SLEEPMGR_ENABLE - irqflags_t flags; - - Assert(sleepmgr_locks[mode] < 0xff); - - // Enter a critical section - flags = cpu_irq_save(); - - ++sleepmgr_locks[mode]; - - // Leave the critical section - cpu_irq_restore(flags); -#endif /* CONFIG_SLEEPMGR_ENABLE */ -} - -/** - * \brief Decrease lock count for a sleep mode - * - * Decreases the lock count for \a mode. If the lock count reaches 0, the sleep - * manager can put the device to sleep in the deeper sleep modes. - * - * \param mode Sleep mode to unlock. - */ -static inline void sleepmgr_unlock_mode(enum sleepmgr_mode mode) -{ -#ifdef CONFIG_SLEEPMGR_ENABLE - irqflags_t flags; - - Assert(sleepmgr_locks[mode]); - - // Enter a critical section - flags = cpu_irq_save(); - - --sleepmgr_locks[mode]; - - // Leave the critical section - cpu_irq_restore(flags); -#endif /* CONFIG_SLEEPMGR_ENABLE */ -} - - /** - * \brief Retrieves the deepest allowable sleep mode - * - * Searches through the sleep mode lock counts, starting at the shallowest sleep - * mode, until the first non-zero lock count is found. The deepest allowable - * sleep mode is then returned. - */ -static inline enum sleepmgr_mode sleepmgr_get_sleep_mode(void) -{ - uint8_t sleep_mode = 0; - -#ifdef CONFIG_SLEEPMGR_ENABLE - uint8_t *lock_ptr = sleepmgr_locks; - - // Find first non-zero lock count, starting with the shallowest modes. - while (!(*lock_ptr)) { - lock_ptr++; - sleep_mode++; - - } - - // Catch the case where one too many sleepmgr_unlock_mode() call has been - // performed on the deepest sleep mode. - Assert((uintptr_t)(lock_ptr - sleepmgr_locks) < SLEEPMGR_NR_OF_MODES); - -#endif /* CONFIG_SLEEPMGR_ENABLE */ - - return (enum sleepmgr_mode)sleep_mode; -} - -/** - * \fn sleepmgr_enter_sleep - * \brief Go to sleep in the deepest allowed mode - * - * Searches through the sleep mode lock counts, starting at the shallowest sleep - * mode, until the first non-zero lock count is found. The device is then put to - * sleep in the sleep mode that corresponds to the lock. - * - * \note This function enables interrupts before going to sleep, and will leave - * them enabled upon return. This also applies if sleep is skipped due to ACTIVE - * mode being locked. - */ - -static inline void sleepmgr_enter_sleep(void) -{ -#ifdef CONFIG_SLEEPMGR_ENABLE - enum sleepmgr_mode sleep_mode; - - cpu_irq_disable(); - - // Find the deepest allowable sleep mode - sleep_mode = sleepmgr_get_sleep_mode(); - // Return right away if first mode (ACTIVE) is locked. - if (sleep_mode==SLEEPMGR_ACTIVE) { - cpu_irq_enable(); - return; - } - // Enter the deepest allowable sleep mode with interrupts enabled - sleepmgr_sleep(sleep_mode); -#else - cpu_irq_enable(); -#endif /* CONFIG_SLEEPMGR_ENABLE */ -} - - -//! @} - -#endif /* SLEEPMGR_H */ diff --git a/DSTAT1/src/asf/common/services/sleepmgr/xmega/sleepmgr.c b/DSTAT1/src/asf/common/services/sleepmgr/xmega/sleepmgr.c deleted file mode 100644 index 8e85c33..0000000 --- a/DSTAT1/src/asf/common/services/sleepmgr/xmega/sleepmgr.c +++ /dev/null @@ -1,61 +0,0 @@ -/** - * \file - * - * \brief Sleep manager - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include -#include - -#if defined(CONFIG_SLEEPMGR_ENABLE) || defined(__DOXYGEN__) - -uint8_t sleepmgr_locks[SLEEPMGR_NR_OF_MODES]; - -# ifndef __DOXYGEN__ -PROGMEM_DECLARE(enum SLEEP_SMODE_enum, - sleepmgr_configs[SLEEPMGR_NR_OF_MODES]) = { -# else -enum SLEEP_SMODE_enum sleepmgr_configs[SLEEPMGR_NR_OF_MODES] = { -# endif - SLEEP_SMODE_IDLE_gc, - SLEEP_SMODE_ESTDBY_gc, - SLEEP_SMODE_PSAVE_gc, - SLEEP_SMODE_STDBY_gc, - SLEEP_SMODE_PDOWN_gc, -}; - -#endif /* CONFIG_SLEEPMGR_ENABLE */ diff --git a/DSTAT1/src/asf/common/services/sleepmgr/xmega/sleepmgr.h b/DSTAT1/src/asf/common/services/sleepmgr/xmega/sleepmgr.h deleted file mode 100644 index 3c4d485..0000000 --- a/DSTAT1/src/asf/common/services/sleepmgr/xmega/sleepmgr.h +++ /dev/null @@ -1,116 +0,0 @@ -/** - * \file - * - * \brief AVR XMEGA Sleep manager implementation - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef XMEGA_SLEEPMGR_H -#define XMEGA_SLEEPMGR_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -/** - * \weakgroup sleepmgr_group - * @{ - */ - -enum sleepmgr_mode { - //! Active mode. - SLEEPMGR_ACTIVE = 0, - //! Idle mode. - SLEEPMGR_IDLE, - //! Extended Standby mode. - SLEEPMGR_ESTDBY, - //! Power Save mode. - SLEEPMGR_PSAVE, - //! Standby mode. - SLEEPMGR_STDBY, - //! Power Down mode. - SLEEPMGR_PDOWN, - SLEEPMGR_NR_OF_MODES, -}; - -/** - * \internal - * \name Internal arrays - * @{ - */ -#if defined(CONFIG_SLEEPMGR_ENABLE) || defined(__DOXYGEN__) -//! Sleep mode lock counters -extern uint8_t sleepmgr_locks[]; -# ifndef __DOXYGEN__ -PROGMEM_DECLARE(extern enum SLEEP_SMODE_enum, sleepmgr_configs[]); -# else -/** - * \brief Look-up table with sleep mode configurations - * \note This is located in program memory (Flash) as it is constant. - */ -extern enum SLEEP_SMODE_enum sleepmgr_configs[]; -# endif /* __DOXYGEN__ */ -#endif /* CONFIG_SLEEPMGR_ENABLE */ -//! @} - -static inline void sleepmgr_sleep(const enum sleepmgr_mode sleep_mode) -{ - Assert(sleep_mode != SLEEPMGR_ACTIVE); -#ifdef CONFIG_SLEEPMGR_ENABLE - sleep_set_mode((SLEEP_SMODE_t)PROGMEM_READ_BYTE(&sleepmgr_configs[sleep_mode-1])); - sleep_enable(); - - cpu_irq_enable(); - sleep_enter(); - - sleep_disable(); -#else - cpu_irq_enable(); -#endif /* CONFIG_SLEEPMGR_ENABLE */ - -} - -//! @} - -#ifdef __cplusplus -} -#endif - -#endif /* XMEGA_SLEEPMGR_H */ diff --git a/DSTAT1/src/asf/common/services/spi/spi_master.h b/DSTAT1/src/asf/common/services/spi/spi_master.h deleted file mode 100644 index bf089d7..0000000 --- a/DSTAT1/src/asf/common/services/spi/spi_master.h +++ /dev/null @@ -1,266 +0,0 @@ -/** - * \file - * - * \brief SPI Master Mode management - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef SPI_MASTER_H_INCLUDED -#define SPI_MASTER_H_INCLUDED - -#include - -#if XMEGA -# include "xmega_spi/spi_master.h" -#elif (defined(__GNUC__) && defined(__AVR32__)) || (defined(__ICCAVR32__) || defined(__AAVR32__)) -# include "uc3_spi/spi_master.h" -#elif SAM -# include "sam_spi/spi_master.h" -#else -# error Unsupported chip type -#endif - -/** - * - * \defgroup spi_group Serial Peripheral Interface (SPI) - * - * This is the common API for SPI interface. Additional features are available - * in the documentation of the specific modules. - * - * \section spi_group_platform Platform Dependencies - * - * The SPI API is partially chip- or platform-specific. While all - * platforms provide mostly the same functionality, there are some - * variations around how different bus types and clock tree structures - * are handled. - * - * The following functions are available on all platforms, but there may - * be variations in the function signature (i.e. parameters) and - * behavior. These functions are typically called by platform-specific - * parts of drivers, and applications that aren't intended to be - * portable: - * - spi_master_init() - * - spi_master_setup_device() - * - spi_select_device() - * - spi_deselect_device() - * - spi_write_single() - * - spi_write_packet() - * - spi_read_single() - * - spi_read_packet() - * - spi_is_tx_empty() - * - spi_is_tx_ready() - * - spi_is_rx_full() - * - spi_is_rx_ready() - * - spi_enable() - * - spi_disable() - * - spi_is_enabled() - * - * \section spi_master_qucikstart_section Quick Start Guide - * See \ref spi_master_quickstart - * @{ - */ - -//! @} - -/** - * \page spi_master_quickstart Quick Start Guide for the SPI Master Driver - * - * This is the quick start guide for the \ref spi_group "SPI Driver", with - * step-by-step instructions on how to configure and use the driver for a - * specific use case. - * - * The use case contain several code fragments. The code fragments in the - * steps for setup can be copied into a custom initialization function, while - * the steps for usage can be copied into, e.g., the main application function. - * - * The steps for setting up the SPI master for XMEGA and UC3 use exactly the - * same approach, but note that there are different names on the peripherals. So - * to use this Quick Start for UC3 please make sure that all the peripheral - * names are updated according to the UC3 datasheet. - * - \subpage spi_master_xmega - * - */ -/** - * \page spi_master_xmega Basic setup for SPI master on XMEGA devices - * - * \section spi_master_xmega_basic Basic setup for XMEGA devices - * The SPI module will be set up as master: - * - SPI on PORTD - * - 1MHz SPI clock speed - * - Slave Chip Select connected on PORTD pin 1 - * - SPI mode 0 (data on rising clock edge) - * - * \section spi_master_xmega_basic_setup Setup steps - * \subsection spi_master_xmega_basic_setup_code Example code - * Add to application C-file (e.g. main.c): - * \code - * void spi_init_pins(void) - * { - * ioport_configure_port_pin(&PORTD, PIN1_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - * - * ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_PULL_UP | IOPORT_DIR_INPUT); - * ioport_configure_port_pin(&PORTD, PIN5_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - * ioport_configure_port_pin(&PORTD, PIN6_bm, IOPORT_DIR_INPUT); - * ioport_configure_port_pin(&PORTD, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - * } - * - * void spi_init_module(void) - * { - * struct spi_device spi_device_conf = { - * .id = IOPORT_CREATE_PIN(PORTD, 1) - * }; - * - * spi_master_init(&SPID); - * spi_master_setup_device(&SPID, &spi_device_conf, SPI_MODE_0, 1000000, 0); - * spi_enable(&SPID); - * } - * \endcode - * - * \subsection spi_master_xmega_basic_setup Workflow - * -# Ensure that \ref conf_spi_master.h is present for the driver. - * - \note This file is only for the driver and should not be included by the - * user. In this example the file can be left empty. - * -# Initialize the pins used by the SPI interface (this initialization is for - * the ATxmega32A4U device). - * -# Set the pin used for slave select as output high: - * \code - * ioport_configure_port_pin(&PORTD, PIN1_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - * \endcode - * -# Enable pull-up on own chip select (SS): - * \code - * ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_PULL_UP | IOPORT_DIR_INPUT); - * \endcode - * \attention If this pin is pulled low the SPI module will go into slave mode. - * -# Set MOSI and SCL as output high, and set MISO as input: - * \code - * ioport_configure_port_pin(&PORTD, PIN5_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - * ioport_configure_port_pin(&PORTD, PIN6_bm, IOPORT_DIR_INPUT); - * ioport_configure_port_pin(&PORTD, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - * \endcode - * -# Define the SPI device configuration struct to describe which pin the - * slave select (slave chip select) is connected to, in this case the slave - * select pin has been connected to PORTD pin 1 (PD1): - * - \code - * struct spi_device spi_device_conf = { - * .id = IOPORT_CREATE_PIN(PORTD, 1) - * }; - * \endcode - * -# Initialize the SPI module, in this case SPI on PORTD has been chosen: - * - \code - * spi_master_init(&SPID); - * \endcode - * -# Setup the SPI master module for a specific device: - * - \code - * spi_master_setup_device(&SPID, &spi_device_conf, SPI_MODE_0, 1000000, 0); - * \endcode - * - \note The last argument, which is zero in this case, can be ignored and is - * only included for compability purposes. - * -# Then enable the SPI: - * - \code - * spi_enable(&SPID); - * \endcode - * - * \section spi_master_xmega_basic_usage Usage steps - * \subsection spi_master_xmega_basic_usage_code Example code - * Add to, e.g., the main loop in the application C-file: - * \code - * uint8_t data_buffer[1] = {0xAA}; - * - * struct spi_device spi_device_conf = { - * .id = IOPORT_CREATE_PIN(PORTD, 1) - * }; - * - * spi_select_device(&SPID, &spi_device_conf); - * - * spi_write_packet(&SPID, data_buffer, 1); - * spi_read_packet(&SPID, data_buffer, 1); - * - * spi_deselect_device(&SPID, &spi_device_conf); - * \endcode - * - * \subsection spi_master_xmega_basic_usage_flow Workflow - * -# Create a buffer for data to be sent/received on the SPI bus, in this case - * a single byte buffer is used. The buffer can be of arbitrary size as long as - * there is space left in SRAM: - * - \code - * uint8_t data_buffer[1] = {0xAA}; - * \endcode - * -# Define the SPI device configuration struct to describe which pin the - * slave select (slave chip select) is connected to, in this case the slave - * select pin has been connected to PORTD pin 1 (PD1): - * - \code - * struct spi_device spi_device_conf = { - * .id = IOPORT_CREATE_PIN(PORTD, 1) - * }; - * \endcode - * - \note As this struct is the same for both the initializing part and the usage - * part it could be a good idea to make the struct global, and hence accessible - * for both the initializing part and usage part. Another solution could be to - * create the struct in the main function and pass the address of the struct to - * the spi_init_module() function, e.g.: - * \code - * void spi_init_module(struct spi_device *spi_device_conf) - * { - * ... - * - * spi_master_setup_device(&SPID, spi_device_conf, SPI_MODE_0, 1000000, 0); - * - * ... - * } - * \endcode - * -# Write data to the SPI slave device, in this case write one byte from the - * data_buffer: - * - \code - * spi_write_packet(&SPID, data_buffer, 1); - * \endcode - * -# Read data from the SPI slave device, in this case read one byte and put it - * into the data_buffer: - * - \code - * spi_read_packet(&SPID, data_buffer, 1); - * \endcode - * - \attention As the SPI works as a shift register so that data is shifted in at - * the same time as data is shifted out a read operation will mean that a dummy - * byte \ref CONFIG_SPI_MASTER_DUMMY is written to the SPI bus. \ref CONFIG_SPI_MASTER_DUMMY - * defaults to 0xFF, but can be changed by defining it inside the \ref conf_spi_master.h - * file. - * -# When read and write operations is done de-select the slave: - * - \code - * spi_deselect_device(&SPID, &spi_device_conf); - * \endcode - * - */ - -#endif /* SPI_MASTER_H_INCLUDED */ diff --git a/DSTAT1/src/asf/common/services/spi/usart_spi.h b/DSTAT1/src/asf/common/services/spi/usart_spi.h deleted file mode 100644 index 6c006c0..0000000 --- a/DSTAT1/src/asf/common/services/spi/usart_spi.h +++ /dev/null @@ -1,97 +0,0 @@ -/** - * \file - * - * \brief USART in SPI mode driver functions. - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef USART_SPI_H_INCLUDED -#define USART_SPI_H_INCLUDED - -#include - -#if XMEGA -# include "xmega_usart_spi/usart_spi.h" -#elif (defined(__GNUC__) && defined(__AVR32__)) || (defined(__ICCAVR32__) || defined(__AAVR32__)) -# include "uc3_usart_spi/usart_spi.h" -#elif SAM -# include "sam_usart_spi/usart_spi.h" -#else -# error Unsupported chip type -#endif - -/** - * - * \defgroup usart_spi_group USART in SPI (Serial Peripheral Interface) mode - * - * This is the common API for USART in SPI mode. Additional features are available - * in the documentation of the specific modules. - * - * \section spi_group_platform Platform Dependencies - * - * The spi API is partially chip- or platform-specific. While all - * platforms provide mostly the same functionality, there are some - * variations around how different bus types and clock tree structures - * are handled. - * - * The following functions are available on all platforms, but there may - * be variations in the function signature (i.e. parameters) and - * behaviour. These functions are typically called by platform-specific - * parts of drivers, and applications that aren't intended to be - * portable: - * - usart_spi_init() - * - usart_spi_setup_device() - * - usart_spi_select_device() - * - usart_spi_deselect_device() - * - usart_spi_write_single() - * - usart_spi_write_packet() - * - usart_spi_read_single() - * - usart_spi_read_packet() - * - usart_spi_is_tx_empty() - * - usart_spi_is_tx_ready() - * - usart_spi_is_rx_full() - * - usart_spi_is_rx_ready() - * - usart_spi_enable() - * - usart_spi_disable() - * - usart_spi_is_enabled() - * - * - * @{ - */ - -//! @} - -#endif /* USART_SPI_H_INCLUDED */ diff --git a/DSTAT1/src/asf/common/services/spi/xmega_spi/spi_master.c b/DSTAT1/src/asf/common/services/spi/xmega_spi/spi_master.c deleted file mode 100644 index a690a22..0000000 --- a/DSTAT1/src/asf/common/services/spi/xmega_spi/spi_master.c +++ /dev/null @@ -1,187 +0,0 @@ -/***************************************************************************** - * - * \file - * - * \brief SPI software driver functions. - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - *****************************************************************************/ - -#include "spi_master.h" -#include "sysclk.h" - - -/*! \brief Initializes the SPI in master mode. - * - * \param spi Base address of the SPI instance. - * - */ -void spi_master_init(SPI_t *spi) -{ -#ifdef SPIA - if((uint16_t)spi == (uint16_t)&SPIA) { - sysclk_enable_module(SYSCLK_PORT_A,PR_SPI_bm); - } - -#endif -#ifdef SPIB - if((uint16_t)spi == (uint16_t)&SPIB) { - sysclk_enable_module(SYSCLK_PORT_B,PR_SPI_bm); - } -#endif -#ifdef SPIC - if((uint16_t)spi == (uint16_t)&SPIC) { - sysclk_enable_module(SYSCLK_PORT_C,PR_SPI_bm); - } -#endif -#ifdef SPID - if((uint16_t)spi == (uint16_t)&SPID) { - sysclk_enable_module(SYSCLK_PORT_D,PR_SPI_bm); - } -#endif -#ifdef SPIE - if((uint16_t)spi == (uint16_t)&SPIE) { - sysclk_enable_module(SYSCLK_PORT_E,PR_SPI_bm); - } -#endif -#ifdef SPIF - if((uint16_t)spi == (uint16_t)&SPIF) { - sysclk_enable_module(SYSCLK_PORT_F,PR_SPI_bm); - } -#endif - spi_enable_master_mode(spi); -} - -/** - * \brief Setup a SPI device. - * - * The returned device descriptor structure must be passed to the driver - * whenever that device should be used as current slave device. - * - * \param spi Base address of the SPI instance. - * \param device Pointer to SPI device struct that should be initialized. - * \param flags SPI configuration flags. Common flags for all - * implementations are the SPI modes SPI_MODE_0 ... - * SPI_MODE_3. - * \param baud_rate Baud rate for communication with slave device in Hz. - * \param sel_id Board specific seclet id - */ -void spi_master_setup_device(SPI_t *spi, struct spi_device *device, - spi_flags_t flags, uint32_t baud_rate, - board_spi_select_id_t sel_id) -{ - if(spi_xmega_set_baud_div(spi, baud_rate,sysclk_get_cpu_hz())<0) - { - //TODO Assert impossible baudrate - } - spi->CTRL|=(flags<id); -} - -/** - * \brief Deselect given device on the SPI bus - * - * Calls board chip deselect. - * - * \param spi Base address of the SPI instance. - * \param device SPI device - * - * \pre SPI device must be selected with spi_select_device() first - */ -void spi_deselect_device(SPI_t *spi, struct spi_device *device) -{ - ioport_set_pin_high(device->id); -} diff --git a/DSTAT1/src/asf/common/services/spi/xmega_spi/spi_master.h b/DSTAT1/src/asf/common/services/spi/xmega_spi/spi_master.h deleted file mode 100644 index a4d70fa..0000000 --- a/DSTAT1/src/asf/common/services/spi/xmega_spi/spi_master.h +++ /dev/null @@ -1,257 +0,0 @@ -/***************************************************************************** - * - * \file - * - * \brief SPI Master driver for AVR. - * - * This file defines a useful set of functions for the SPI interface on AVR - * devices. - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - ******************************************************************************/ - - -#ifndef _SPI_MASTER_H_ -#define _SPI_MASTER_H_ - -#include "compiler.h" -#include "status_codes.h" -#include "ioport.h" -#include "spi.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup xmega_spi_master_group XMEGA SPI master service. - * - * This is the API for SPI master service on XMEGA. - * - * @{ - * - * \section xmega_spi_master_qucikstart_section Quick Start Guide - * See \ref spi_master_quickstart - */ - -/*! \name Spi Master Management Configuration - */ -//! @{ -#include "conf_spi_master.h" - -//! Default Config Spi Master Dummy Field -#ifndef CONFIG_SPI_MASTER_DUMMY -#define CONFIG_SPI_MASTER_DUMMY 0xFF -#endif -//! @} - -/** - * \brief Clock phase - */ -#define SPI_CPHA (1 << 0) - -/** - * \brief Clock polarity - */ -#define SPI_CPOL (1 << 1) - -/** - * \brief SPI mode 0 - */ -#define SPI_MODE_0 0 -/** - * \brief SPI mode 1 - */ -#define SPI_MODE_1 (SPI_CPHA) -/** - * \brief SPI mode 2 - */ -#define SPI_MODE_2 (SPI_CPOL) -/** - * \brief SPI mode 3 - */ -#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA) - -typedef uint8_t spi_flags_t; -typedef uint32_t board_spi_select_id_t; - -//! \brief Polled SPI device defintion -struct spi_device { - //! Board specific select id - port_pin_t id; -}; - -/*! \brief Initializes the SPI in master mode. - * - * \param spi Base address of the SPI instance. - * - */ -extern void spi_master_init(SPI_t *spi); - -/** - * \brief Setup a SPI device. - * - * The returned device descriptor structure must be passed to the driver - * whenever that device should be used as current slave device. - * - * \param spi Base address of the SPI instance. - * \param device Pointer to SPI device struct that should be initialized. - * \param flags SPI configuration flags. Common flags for all - * implementations are the SPI modes SPI_MODE_0 ... - * SPI_MODE_3. - * \param baud_rate Baud rate for communication with slave device in Hz. - * \param sel_id Board specific seclet id - */ -extern void spi_master_setup_device(SPI_t *spi, struct spi_device *device, - spi_flags_t flags, unsigned long baud_rate, - board_spi_select_id_t sel_id); - -/*! \brief Enables the SPI. - * - * \param spi Base address of the SPI instance. - */ -extern void spi_enable(SPI_t *spi); - -/*! \brief Disables the SPI. - * - * Ensures that nothing is transferred while setting up buffers. - * - * \param spi Base address of the SPI instance. - * - * \warning This may cause data loss if used on a slave SPI. - */ -extern void spi_disable(SPI_t *spi); - - -/*! \brief Tests if the SPI is enabled. - * - * \param spi Base address of the SPI instance. - * - * \return \c 1 if the SPI is enabled, otherwise \c 0. - */ -extern bool spi_is_enabled(SPI_t *spi); - -/** - * \brief Select given device on the SPI bus - * - * Set device specific setting and calls board chip select. - * - * \param spi Base address of the SPI instance. - * \param device SPI device - * - */ -extern void spi_select_device(SPI_t *spi, struct spi_device *device); - -/** - * \brief Deselect given device on the SPI bus - * - * Calls board chip deselect. - * - * \param spi Base address of the SPI instance. - * \param device SPI device - * - * \pre SPI device must be selected with spi_select_device() first - */ -extern void spi_deselect_device(SPI_t *spi, struct spi_device *device); - -/*! \brief Write one byte to a SPI device. - * - * \param spi Base address of the SPI instance. - * \param data The data byte to be loaded - * - */ -static inline void spi_write_single(SPI_t *spi, uint8_t data) -{ - spi_put(spi,data); -} - -/** - * \brief Send a sequence of bytes to a SPI device - * - * Received bytes on the SPI bus are discarded. - * - * \param spi Base address of the SPI instance. - * \param data data buffer to write - * \param len Length of data - * - * \pre SPI device must be selected with spi_select_device() first - */ -extern status_code_t spi_write_packet(SPI_t *spi,const uint8_t *data, size_t len); - - -/*! \brief Receive one byte from a SPI device. - * - * \param spi Base address of the SPI instance. - * \param data Pointer to the data byte where to store the received data. - * - */ -inline static void spi_read_single(SPI_t *spi, uint8_t *data) -{ - *data=spi_get(spi); -} - -/** - * \brief Receive a sequence of bytes from a SPI device - * - * All bytes sent out on SPI bus are sent as value 0. - * - * \param spi Base address of the SPI instance. - * \param data data buffer to read - * \param len Length of data - * - * \pre SPI device must be selected with spi_select_device() first - */ -extern status_code_t spi_read_packet(SPI_t *spi, uint8_t *data, size_t len); - -/*! \brief Tests if the SPI contains a received character. - * - * \param spi Base address of the SPI instance. - * - * \return \c 1 if the SPI Receive Holding Register is full, otherwise \c 0. - */ -inline static bool spi_is_rx_full(SPI_t *spi) -{ - return spi_is_tx_ok(spi); -} - -//! @} - - - -#ifdef __cplusplus -} -#endif -#endif // _SPI_MASTER_H_ diff --git a/DSTAT1/src/asf/common/services/spi/xmega_usart_spi/usart_spi.c b/DSTAT1/src/asf/common/services/spi/xmega_usart_spi/usart_spi.c deleted file mode 100644 index f565f0b..0000000 --- a/DSTAT1/src/asf/common/services/spi/xmega_usart_spi/usart_spi.c +++ /dev/null @@ -1,135 +0,0 @@ -/** - * \file - * - * \brief AVR XMEGA USART in SPI mode driver functions. - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include "usart_spi.h" -#include "sysclk.h" - -void usart_spi_init(USART_t *usart) -{ -#ifdef USARTC0 - if((uint16_t)usart == (uint16_t)&USARTC0) { - sysclk_enable_module(SYSCLK_PORT_C,PR_USART0_bm); - } -#endif -#ifdef USARTC1 - else - if((uint16_t)usart == (uint16_t)&USARTC1) { - sysclk_enable_module(SYSCLK_PORT_C,PR_USART1_bm); - } -#endif -#ifdef USARTD0 - else - if((uint16_t)usart == (uint16_t)&USARTD0) { - sysclk_enable_module(SYSCLK_PORT_D,PR_USART0_bm); - } -#endif -#ifdef USARTD1 - else - if((uint16_t)usart == (uint16_t)&USARTD1) { - sysclk_enable_module(SYSCLK_PORT_D,PR_USART1_bm); - } -#endif -#ifdef USARTE0 - else - if((uint16_t)usart == (uint16_t)&USARTE0) { - sysclk_enable_module(SYSCLK_PORT_E,PR_USART0_bm); - } -#endif -#ifdef USARTE1 - else - if((uint16_t)usart == (uint16_t)&USARTE1) { - sysclk_enable_module(SYSCLK_PORT_E,PR_USART1_bm); - } -#endif -#ifdef USARTF0 - else - if((uint16_t)usart == (uint16_t)&USARTF0) { - sysclk_enable_module(SYSCLK_PORT_F,PR_USART0_bm); - } -#endif -#ifdef USARTF1 - else - if((uint16_t)usart == (uint16_t)&USARTF1) { - sysclk_enable_module(SYSCLK_PORT_F,PR_USART1_bm); - } -#endif -} - -void usart_spi_setup_device(USART_t *usart, struct usart_spi_device *device, - spi_flags_t flags, unsigned long baud_rate, - board_spi_select_id_t sel_id) -{ - usart_spi_options_t opt; - opt.baudrate=baud_rate; - opt.spimode=flags; - opt.data_order=false; - usart_init_spi(usart, &opt); -} - -status_code_t usart_spi_write_packet(USART_t *usart,const uint8_t *data, size_t len) -{ - size_t i=0; - while(len) { - usart_spi_transmit(usart,*(data+i)); - len--; - i++; - } - return STATUS_OK; -} - -status_code_t usart_spi_read_packet(USART_t *usart, uint8_t *data, size_t len) -{ - while(len) { - *data = usart_spi_transmit(usart, CONFIG_USART_SPI_DUMMY); - len--; - data++; - } - return STATUS_OK; -} - -void usart_spi_select_device(USART_t *usart, struct usart_spi_device *device) -{ - ioport_set_pin_low(device->id); -} - -void usart_spi_deselect_device(USART_t *usart, struct usart_spi_device *device) -{ - ioport_set_pin_high(device->id); -} diff --git a/DSTAT1/src/asf/common/services/spi/xmega_usart_spi/usart_spi.h b/DSTAT1/src/asf/common/services/spi/xmega_usart_spi/usart_spi.h deleted file mode 100644 index f7b1fe7..0000000 --- a/DSTAT1/src/asf/common/services/spi/xmega_usart_spi/usart_spi.h +++ /dev/null @@ -1,237 +0,0 @@ -/** - * \file - * - * \brief AVR XMEGA USART in SPI mode driver functions. - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _USART_SPI_H_ -#define _USART_SPI_H_ - -#include "compiler.h" -#include "status_codes.h" -#include "ioport.h" -#include "usart.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*! \name USART in SPI mode Management Configuration - */ -//! @{ -#include "conf_usart_spi.h" - -//! Default Config Spi Master Dummy Field -#ifndef CONFIG_USART_SPI_DUMMY - #define CONFIG_USART_SPI_DUMMY 0xFF -#endif -//! @} - -/** - * \brief Clock phase - */ -#define SPI_CPHA (1 << 0) - -/** - * \brief Clock polarity - */ -#define SPI_CPOL (1 << 1) - -/** - * \brief SPI mode 0 - */ -#define SPI_MODE_0 0 -/** - * \brief SPI mode 1 - */ -#define SPI_MODE_1 (SPI_CPHA) -/** - * \brief SPI mode 2 - */ -#define SPI_MODE_2 (SPI_CPOL) -/** - * \brief SPI mode 3 - */ -#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA) - -typedef uint8_t spi_flags_t; -typedef uint32_t board_spi_select_id_t; - -//! \brief Polled SPI device defintion -struct usart_spi_device { - //! Board specific select id - port_pin_t id; -}; - -/*! \brief Initializes the USART in SPI master mode. - * - * \param usart Base address of the USART instance. - * - */ -extern void usart_spi_init(USART_t *usart); - -/** - * \brief Setup a USART in SPI mdoe device. - * - * The returned device descriptor structure must be passed to the driver - * whenever that device should be used as current slave device. - * - * \param usart Base address of the USART instance. - * \param device Pointer to usart device struct that should be initialized. - * \param flags USART configuration flags. Common flags for all - * implementations are the usart modes SPI_MODE_0 ... - * SPI_MODE_3. - * \param baud_rate Baud rate for communication with slave device in Hz. - * \param sel_id Board specific seclet id - */ -extern void usart_spi_setup_device(USART_t *usart, struct usart_spi_device *device, - spi_flags_t flags, unsigned long baud_rate, - board_spi_select_id_t sel_id); - -/*! \brief Enables the USART for the specified USART in SPI mode. - * - * \param usart Base address of the USART instance. - */ -extern void usart_spi_enable(USART_t *usart); - -/*! \brief Disables the USART. - * - * Ensures that nothing is transferred while setting up buffers. - * - * \param usart Base address of the USART instance. - * - */ -extern void usart_spi_disable(USART_t *usart); - - -/*! \brief Tests if the USART in SPI mode is enabled. - * - * \param usart Base address of the usart instance. - * - * \return \c 1 if the usart is enabled, otherwise \c 0. - */ -extern bool usart_spi_is_enabled(USART_t *usart); - -/** - * \brief Select given device on the SPI bus - * - * Set device specific setting and calls board chip select. - * - * \param usart Base address of the USART instance. - * \param device SPI device - * - */ -extern void usart_spi_select_device(USART_t *usart, struct usart_spi_device *device); - -/** - * \brief Deselect given device on the SPI bus - * - * Calls board chip deselect. - * - * \param usart Base address of the USART instance. - * \param device SPI device - * - * \pre SPI device must be selected with spi_select_device() first - */ -extern void usart_spi_deselect_device(USART_t *usart, struct usart_spi_device *device); - -/*! \brief Write one byte to a SPI device using USART in SPI mode - * - * \param usart Base address of the usart instance. - * \param data The data byte to be loaded - * - */ -static inline void usart_spi_write_single(USART_t *usart, uint8_t data) -{ - usart_putchar(usart,data); -} - -/** - * \brief Send a sequence of bytes to a SPI device using USART in SPI mode - * - * Received bytes on the USART in SPI mode are discarded. - * - * \param usart Base address of the USART instance. - * \param data Data buffer to write - * \param len Length of data - * - * \pre usart device must be selected with spi_select_device() first - */ -extern status_code_t usart_spi_write_packet(USART_t *usart,const uint8_t *data, size_t len); - - -/*! \brief Receive one byte from a SPI device using USART in SPI mode - * - * \param usart Base address of the USART instance. - * \param data Pointer to the data byte where to store the received data. - * - */ -inline static void usart_spi_read_single(USART_t *usart, uint8_t *data) -{ - *data = usart_getchar(usart); -} - -/** - * \brief Receive a sequence of bytes from a USART in SPI mode device - * - * All bytes sent out on usart bus are sent as value 0. - * - * \param usart Base address of the usart instance. - * \param data data buffer to read - * \param len Length of data - * - * \pre usart device must be selected with spi_select_device() first - */ -extern status_code_t usart_spi_read_packet(USART_t *usart, uint8_t *data, size_t len); - -/*! \brief Tests if the USART in SPI mode contains a received character. - * - * \param usart Base address of the USART instance. - * - * \return \c 1 if the USART Receive Holding Register is full, otherwise \c 0. - */ -inline static bool usart_spi_is_rx_full(USART_t *usart) -{ - return usart_rx_is_complete(usart); -} - -#ifdef __cplusplus -} -#endif - -#endif // _USART_SPI_H_ diff --git a/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc.c b/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc.c deleted file mode 100644 index effbf1b..0000000 --- a/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc.c +++ /dev/null @@ -1,1232 +0,0 @@ -/** - * \file - * - * \brief USB Device Communication Device Class (CDC) interface. - * - * Copyright (c) 2009-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#include "conf_usb.h" -#include "usb_protocol.h" -#include "usb_protocol_cdc.h" -#include "udd.h" -#include "udc.h" -#include "udi_cdc.h" -#include - -#ifdef UDI_CDC_LOW_RATE -# define UDI_CDC_TX_BUFFERS (1*UDI_CDC_DATA_EPS_SIZE) -# define UDI_CDC_RX_BUFFERS (1*UDI_CDC_DATA_EPS_SIZE) -#else -# ifdef USB_DEVICE_HS_SUPPORT -# define UDI_CDC_TX_BUFFERS (8*UDI_CDC_DATA_EPS_SIZE) -# define UDI_CDC_RX_BUFFERS (8*UDI_CDC_DATA_EPS_SIZE) -# else -# define UDI_CDC_TX_BUFFERS (5*UDI_CDC_DATA_EPS_SIZE) -# define UDI_CDC_RX_BUFFERS (5*UDI_CDC_DATA_EPS_SIZE) -# endif -#endif - -#if UDI_CDC_PORT_NB == 1 -# define PORT 0 -#else -# define PORT port -#endif - -/** - * \addtogroup udi_cdc_group - * - * @{ - */ - -/** - * \name Interface for UDC - */ -//@{ - -bool udi_cdc_comm_enable(void); -void udi_cdc_comm_disable(void); -bool udi_cdc_comm_setup(void); -bool udi_cdc_data_enable(void); -void udi_cdc_data_disable(void); -bool udi_cdc_data_setup(void); -uint8_t udi_cdc_getsetting(void); -void udi_cdc_data_sof_notify(void); -UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm = { - .enable = udi_cdc_comm_enable, - .disable = udi_cdc_comm_disable, - .setup = udi_cdc_comm_setup, - .getsetting = udi_cdc_getsetting, -}; -UDC_DESC_STORAGE udi_api_t udi_api_cdc_data = { - .enable = udi_cdc_data_enable, - .disable = udi_cdc_data_disable, - .setup = udi_cdc_data_setup, - .getsetting = udi_cdc_getsetting, - .sof_notify = udi_cdc_data_sof_notify, -}; - -#if UDI_CDC_PORT_NB > 1 -bool udi_cdc_comm_enable_2(void); -void udi_cdc_comm_disable_2(void); -bool udi_cdc_comm_setup_2(void); -bool udi_cdc_data_enable_2(void); -void udi_cdc_data_sof_notify_2(void); -UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm_2 = { - .enable = udi_cdc_comm_enable_2, - .disable = udi_cdc_comm_disable_2, - .setup = udi_cdc_comm_setup_2, - .getsetting = udi_cdc_getsetting, -}; -UDC_DESC_STORAGE udi_api_t udi_api_cdc_data_2 = { - .enable = udi_cdc_data_enable_2, - .disable = udi_cdc_data_disable, - .setup = udi_cdc_data_setup, - .getsetting = udi_cdc_getsetting, - .sof_notify = udi_cdc_data_sof_notify_2, -}; -#endif - -#if UDI_CDC_PORT_NB > 2 -bool udi_cdc_comm_enable_3(void); -void udi_cdc_comm_disable_3(void); -bool udi_cdc_comm_setup_3(void); -bool udi_cdc_data_enable_3(void); -void udi_cdc_data_sof_notify_3(void); -UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm_3 = { - .enable = udi_cdc_comm_enable_3, - .disable = udi_cdc_comm_disable_3, - .setup = udi_cdc_comm_setup_3, - .getsetting = udi_cdc_getsetting, -}; -UDC_DESC_STORAGE udi_api_t udi_api_cdc_data_3 = { - .enable = udi_cdc_data_enable_3, - .disable = udi_cdc_data_disable, - .setup = udi_cdc_data_setup, - .getsetting = udi_cdc_getsetting, - .sof_notify = udi_cdc_data_sof_notify_3, -}; -#endif -//@} - - -/** - * \name Internal routines - */ -//@{ - -/** - * \name Routines to control serial line - */ -//@{ - -/** - * \brief Sends line coding port 1 to application - * - * Called after SETUP request when line coding data is received. - */ -static void udi_cdc_line_coding_received(void); -#if UDI_CDC_PORT_NB > 1 -/** - * \brief Sends line coding port 2 to application - * - * Called after SETUP request when line coding data is received. - */ -static void udi_cdc_line_coding_received_2(void); -#endif -#if UDI_CDC_PORT_NB > 2 -/** - * \brief Sends line coding port 3 to application - * - * Called after SETUP request when line coding data is received. - */ -static void udi_cdc_line_coding_received_3(void); -#endif -/** - * \brief Sends line coding port to application - * - * Called after SETUP request when line coding data is received. - * - * \param port Communication port number to manage - */ -static void udi_cdc_line_coding_received_common(uint8_t port); - -/** - * \brief Records new state - * - * \param port Communication port number to manage - * \param b_set State is enabled if true, else disabled - * \param bit_mask Field to process (see CDC_SERIAL_STATE_ defines) - */ -static void udi_cdc_ctrl_state_change(uint8_t port, bool b_set, le16_t bit_mask); - -/** - * \brief Check and eventually notify the USB host of new state - * - * \param port Communication port number to manage - */ -static void udi_cdc_ctrl_state_notify(uint8_t port); - -/** - * \brief Ack sent of serial state message on port 1 - * Callback called after serial state message sent - * - * \param status UDD_EP_TRANSFER_OK, if transfer finished - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data transfered - */ -static void udi_cdc_serial_state_msg_sent(udd_ep_status_t status, iram_size_t n); -#if UDI_CDC_PORT_NB > 1 -/** - * \brief Ack sent of serial state message on port 2 - * Callback called after serial state message sent - * - * \param status UDD_EP_TRANSFER_OK, if transfer finished - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data transfered - */ -static void udi_cdc_serial_state_msg_sent_2(udd_ep_status_t status, iram_size_t n); -#endif -#if UDI_CDC_PORT_NB > 2 -/** - * \brief Ack sent of serial state message on port 3 - * Callback called after serial state message sent - * - * \param status UDD_EP_TRANSFER_OK, if transfer finished - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data transfered - */ -static void udi_cdc_serial_state_msg_sent_3(udd_ep_status_t status, iram_size_t n); -#endif -/** - * \brief Ack sent of serial state message on a port - * Callback called after serial state message sent - * - * \param port Communication port number to manage - * \param status UDD_EP_TRANSFER_OK, if transfer finished - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data transfered - */ -static void udi_cdc_serial_state_msg_sent_common(uint8_t port, udd_ep_status_t status, iram_size_t n); - -//@} - -/** - * \name Routines to process data transfer - */ -//@{ - -/** - * \brief Enable the reception of data from the USB host - * - * The value udi_cdc_rx_trans_sel indicate the RX buffer to fill. - * - * \param port Communication port number to manage - * - * \return \c 1 if function was successfully done, otherwise \c 0. - */ -static bool udi_cdc_rx_start(uint8_t port); - -/** - * \brief Update rx buffer management with a new data for port 1 - * Callback called after data reception on USB line - * - * \param status UDD_EP_TRANSFER_OK, if transfer finish - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data received - */ -static void udi_cdc_data_received(udd_ep_status_t status, iram_size_t n); -#if UDI_CDC_PORT_NB > 1 -/** - * \brief Update rx buffer management with a new data for port 2 - * Callback called after data reception on USB line - * - * \param status UDD_EP_TRANSFER_OK, if transfer finish - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data received - */ -static void udi_cdc_data_received_2(udd_ep_status_t status, iram_size_t n); -#endif -#if UDI_CDC_PORT_NB > 2 -/** - * \brief Update rx buffer management with a new data for port 3 - * Callback called after data reception on USB line - * - * \param status UDD_EP_TRANSFER_OK, if transfer finish - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data received - */ -static void udi_cdc_data_received_3(udd_ep_status_t status, iram_size_t n); -#endif - -/** - * \brief Update rx buffer management with a new data for a port - * Callback called after data reception on USB line - * - * \param port Communication port number to manage - * \param status UDD_EP_TRANSFER_OK, if transfer finish - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data received - */ -static void udi_cdc_data_received_common(uint8_t port, udd_ep_status_t status, iram_size_t n); - -/** - * \brief Ack sent of tx buffer on port 1 - * Callback called after data transfer on USB line - * - * \param status UDD_EP_TRANSFER_OK, if transfer finished - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data transfered - */ -static void udi_cdc_data_sent(udd_ep_status_t status, iram_size_t n); -#if UDI_CDC_PORT_NB > 1 -/** - * \brief Ack sent of tx buffer on port 2 - * Callback called after data transfer on USB line - * - * \param status UDD_EP_TRANSFER_OK, if transfer finished - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data transfered - */ -static void udi_cdc_data_sent_2(udd_ep_status_t status, iram_size_t n); -#endif -#if UDI_CDC_PORT_NB > 2 -/** - * \brief Ack sent of tx buffer on port 3 - * Callback called after data transfer on USB line - * - * \param status UDD_EP_TRANSFER_OK, if transfer finished - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data transfered - */ -static void udi_cdc_data_sent_3(udd_ep_status_t status, iram_size_t n); -#endif - -/** - * \brief Ack sent of tx buffer on a port - * Callback called after data transfer on USB line - * - * \param port Communication port number to manage - * \param status UDD_EP_TRANSFER_OK, if transfer finished - * \param status UDD_EP_TRANSFER_ABORT, if transfer aborted - * \param n number of data transfered - */ -static void udi_cdc_data_sent_common(uint8_t port, udd_ep_status_t status, iram_size_t n); - -/** - * \brief Send buffer on line or wait a SOF event - * - * \param port Communication port number to manage - */ -static void udi_cdc_tx_send(uint8_t port); - -#if UDI_CDC_PORT_NB == 1 -bool udi_cdc_multi_is_rx_ready(uint8_t port); -#endif - -//@} - -//@} - -/** - * \name Information about configuration of communication line - */ -//@{ -static usb_cdc_line_coding_t udi_cdc_line_coding[UDI_CDC_PORT_NB]; -static bool udi_cdc_serial_state_msg_ongoing[UDI_CDC_PORT_NB]; -static volatile le16_t udi_cdc_state[UDI_CDC_PORT_NB]; -COMPILER_WORD_ALIGNED static usb_cdc_notify_serial_state_t uid_cdc_state_msg[UDI_CDC_PORT_NB]; -static const uint8_t UDI_CDC_COMM_EPS[]={ - UDI_CDC_COMM_EP, -#if UDI_CDC_PORT_NB > 1 - UDI_CDC_COMM_EP_2, -#endif -#if UDI_CDC_PORT_NB > 2 - UDI_CDC_COMM_EP_3, -#endif -}; -static const udd_callback_trans_t udi_cdc_serial_state_msg_sents[] = { - udi_cdc_serial_state_msg_sent, -#if UDI_CDC_PORT_NB > 1 - udi_cdc_serial_state_msg_sent_2, -#endif -#if UDI_CDC_PORT_NB > 2 - udi_cdc_serial_state_msg_sent_3, -#endif -}; -typedef void (*udi_cdc_callback_setup_t) (void); -static udi_cdc_callback_setup_t udi_cdc_line_coding_receiveds[] = { - udi_cdc_line_coding_received, -#if UDI_CDC_PORT_NB > 1 - udi_cdc_line_coding_received_2, -#endif -#if UDI_CDC_PORT_NB > 2 - udi_cdc_line_coding_receivedt_3, -#endif -}; - -//! Status of CDC interface -static volatile bool udi_cdc_running[UDI_CDC_PORT_NB]; -//@} - -/** - * \name Variables to manage RX/TX transfer requests - * Two buffers for each sense are used to optimize the speed. - */ -//@{ - -//! Buffer to receive data -COMPILER_WORD_ALIGNED static uint8_t udi_cdc_rx_buf[UDI_CDC_PORT_NB][2][UDI_CDC_RX_BUFFERS]; -//! Data available in RX buffers -static uint16_t udi_cdc_rx_buf_nb[UDI_CDC_PORT_NB][2]; -//! Give the current RX buffer used (rx0 if 0, rx1 if 1) -static volatile uint8_t udi_cdc_rx_buf_sel[UDI_CDC_PORT_NB]; -//! Read position in current RX buffer -static volatile uint16_t udi_cdc_rx_pos[UDI_CDC_PORT_NB]; -//! Signal a transfer on-going -static volatile bool udi_cdc_rx_trans_ongoing[UDI_CDC_PORT_NB]; -static const uint8_t UDI_CDC_DATA_EP_OUTS[]={ - UDI_CDC_DATA_EP_OUT, -#if UDI_CDC_PORT_NB > 1 - UDI_CDC_DATA_EP_OUT_2, -#endif -#if UDI_CDC_PORT_NB > 2 - UDI_CDC_DATA_EP_OUT_3, -#endif -}; -static const udd_callback_trans_t udi_cdc_data_received_callbacks[] = { - udi_cdc_data_received, -#if UDI_CDC_PORT_NB > 1 - udi_cdc_data_received_2, -#endif -#if UDI_CDC_PORT_NB > 2 - udi_cdc_data_received_3, -#endif -}; - -//! Define a transfer halted -#define UDI_CDC_TRANS_HALTED 2 - -//! Buffer to send data -COMPILER_WORD_ALIGNED static uint8_t udi_cdc_tx_buf[UDI_CDC_PORT_NB][2][UDI_CDC_TX_BUFFERS]; -//! Data available in TX buffers -static uint16_t udi_cdc_tx_buf_nb[UDI_CDC_PORT_NB][2]; -//! Give current TX buffer used (tx0 if 0, tx1 if 1) -static volatile uint8_t udi_cdc_tx_buf_sel[UDI_CDC_PORT_NB]; -//! Value of SOF during last TX transfer -static uint16_t udi_cdc_tx_sof_num[UDI_CDC_PORT_NB]; -//! Signal a transfer on-going -static volatile bool udi_cdc_tx_trans_ongoing[UDI_CDC_PORT_NB]; -//! Signal that both buffer content data to send -static volatile bool udi_cdc_tx_both_buf_to_send[UDI_CDC_PORT_NB]; -static const uint8_t UDI_CDC_DATA_EP_INS[]={ - UDI_CDC_DATA_EP_IN, -#if UDI_CDC_PORT_NB > 1 - UDI_CDC_DATA_EP_IN_2, -#endif -#if UDI_CDC_PORT_NB > 2 - UDI_CDC_DATA_EP_IN_3, -#endif -}; -static const udd_callback_trans_t udi_cdc_data_sents[] = { - udi_cdc_data_sent, -#if UDI_CDC_PORT_NB > 1 - udi_cdc_data_sent_2, -#endif -#if UDI_CDC_PORT_NB > 2 - udi_cdc_data_sent_3, -#endif -}; - -//@} - - - -static bool udi_cdc_comm_enable_common(uint8_t port) -{ - // Initialize control signal management - udi_cdc_state[PORT] = CPU_TO_LE16(0); - - uid_cdc_state_msg[PORT].header.bmRequestType = - USB_REQ_DIR_IN | USB_REQ_TYPE_CLASS | - USB_REQ_RECIP_INTERFACE, - uid_cdc_state_msg[PORT].header.bNotification = USB_REQ_CDC_NOTIFY_SERIAL_STATE, - uid_cdc_state_msg[PORT].header.wValue = LE16(0), - uid_cdc_state_msg[PORT].header.wIndex = LE16(UDI_CDC_COMM_IFACE_NUMBER), - uid_cdc_state_msg[PORT].header.wLength = LE16(2), - uid_cdc_state_msg[PORT].value = CPU_TO_LE16(0); - - udi_cdc_line_coding[PORT].dwDTERate = CPU_TO_LE32(UDI_CDC_DEFAULT_RATE); - udi_cdc_line_coding[PORT].bCharFormat = UDI_CDC_DEFAULT_STOPBITS; - udi_cdc_line_coding[PORT].bParityType = UDI_CDC_DEFAULT_PARITY; - udi_cdc_line_coding[PORT].bDataBits = UDI_CDC_DEFAULT_DATABITS; - // Call application callback - // to initialize memories or indicate that interface is enabled -#if UDI_CDC_PORT_NB == 1 - UDI_CDC_SET_CODING_EXT((&udi_cdc_line_coding[0])); - return UDI_CDC_ENABLE_EXT(); -#else - UDI_CDC_SET_CODING_EXT(port,(&udi_cdc_line_coding[port])); - return UDI_CDC_ENABLE_EXT(port); -#endif -} - -bool udi_cdc_comm_enable(void) -{ - return udi_cdc_comm_enable_common(0); -} -#if UDI_CDC_PORT_NB > 1 -bool udi_cdc_comm_enable_2(void) -{ - return udi_cdc_comm_enable_common(1); -} -#endif -#if UDI_CDC_PORT_NB > 2 -bool udi_cdc_comm_enable_3(void) -{ - return udi_cdc_comm_enable_common(2); - -} -#endif - -static bool udi_cdc_data_enable_common(uint8_t port) -{ - // Initialize TX management - udi_cdc_tx_trans_ongoing[PORT] = false; - udi_cdc_tx_both_buf_to_send[PORT] = false; - udi_cdc_tx_buf_sel[PORT] = 0; - udi_cdc_tx_buf_nb[PORT][0] = 0; - udi_cdc_tx_buf_nb[PORT][1] = 0; - udi_cdc_tx_sof_num[PORT] = 0; - udi_cdc_tx_send(PORT); - - // Initialize RX management - udi_cdc_rx_trans_ongoing[PORT] = false; - udi_cdc_rx_buf_sel[PORT] = 0; - udi_cdc_rx_buf_nb[PORT][0] = 0; - udi_cdc_rx_pos[PORT] = 0; - udi_cdc_running[PORT] = udi_cdc_rx_start(PORT); - return udi_cdc_running[PORT]; -} - -bool udi_cdc_data_enable(void) -{ - return udi_cdc_data_enable_common(0); -} -#if UDI_CDC_PORT_NB > 1 -bool udi_cdc_data_enable_2(void) -{ - return udi_cdc_data_enable_common(1); -} -#endif -#if UDI_CDC_PORT_NB > 2 -bool udi_cdc_data_enable_3(void) -{ - return udi_cdc_data_enable_common(2); -} -#endif - - -static void udi_cdc_comm_disable_common(uint8_t port) -{ -#if UDI_CDC_PORT_NB == 1 - udi_cdc_running[0] = false; - UDI_CDC_DISABLE_EXT(); -#else - udi_cdc_running[port] = false; - UDI_CDC_DISABLE_EXT(port); -#endif -} - -void udi_cdc_comm_disable(void) -{ - udi_cdc_comm_disable_common(0); -} -#if UDI_CDC_PORT_NB > 1 -void udi_cdc_comm_disable_2(void) -{ - udi_cdc_comm_disable_common(1); -} -#endif -#if UDI_CDC_PORT_NB > 2 -void udi_cdc_comm_disable_3(void) -{ - udi_cdc_comm_disable_common(2); -} -#endif - -void udi_cdc_data_disable(void) -{ -} - - - -static bool udi_cdc_comm_setup_common(uint8_t port) -{ - if (Udd_setup_is_in()) { - // GET Interface Requests - if (Udd_setup_type() == USB_REQ_TYPE_CLASS) { - // Requests Class Interface Get - switch (udd_g_ctrlreq.req.bRequest) { - case USB_REQ_CDC_GET_LINE_CODING: - // Get configuration of CDC line - if (sizeof(usb_cdc_line_coding_t) != - udd_g_ctrlreq.req.wLength) - return false; // Error for USB host - udd_g_ctrlreq.payload = - (uint8_t *) & - udi_cdc_line_coding[PORT]; - udd_g_ctrlreq.payload_size = - sizeof(udi_cdc_line_coding); - return true; - } - } - } - if (Udd_setup_is_out()) { - // SET Interface Requests - if (Udd_setup_type() == USB_REQ_TYPE_CLASS) { - // Requests Class Interface Set - switch (udd_g_ctrlreq.req.bRequest) { - case USB_REQ_CDC_SET_LINE_CODING: - // Change configuration of CDC line - if (sizeof(usb_cdc_line_coding_t) != - udd_g_ctrlreq.req.wLength) - return false; // Error for USB host - udd_g_ctrlreq.callback = - udi_cdc_line_coding_receiveds[PORT]; - udd_g_ctrlreq.payload = - (uint8_t *) & - udi_cdc_line_coding[PORT]; - udd_g_ctrlreq.payload_size = - sizeof(udi_cdc_line_coding); - return true; - case USB_REQ_CDC_SET_CONTROL_LINE_STATE: - // According cdc spec 1.1 chapter 6.2.14 -#if UDI_CDC_PORT_NB == 1 - UDI_CDC_SET_DTR_EXT((0 != - (udd_g_ctrlreq.req.wValue - & CDC_CTRL_SIGNAL_DTE_PRESENT))); - UDI_CDC_SET_RTS_EXT((0 != - (udd_g_ctrlreq.req.wValue - & CDC_CTRL_SIGNAL_ACTIVATE_CARRIER))); -#else - UDI_CDC_SET_DTR_EXT(PORT, (0 != - (udd_g_ctrlreq.req.wValue - & CDC_CTRL_SIGNAL_DTE_PRESENT))); - UDI_CDC_SET_RTS_EXT(PORT, (0 != - (udd_g_ctrlreq.req.wValue - & CDC_CTRL_SIGNAL_ACTIVATE_CARRIER))); -#endif - return true; - } - } - } - return false; // request Not supported -} - -bool udi_cdc_comm_setup(void) -{ - return udi_cdc_comm_setup_common(0); -} -#if UDI_CDC_PORT_NB > 1 -bool udi_cdc_comm_setup_2(void) -{ - return udi_cdc_comm_setup_common(1); -} -#endif -#if UDI_CDC_PORT_NB > 2 -bool udi_cdc_comm_setup_3(void) -{ - return udi_cdc_comm_setup_common(2); -} -#endif - -bool udi_cdc_data_setup(void) -{ - return false; // request Not supported -} - -uint8_t udi_cdc_getsetting(void) -{ - return 0; // CDC don't have multiple alternate setting -} - -void udi_cdc_data_sof_notify(void) -{ - udi_cdc_tx_send(0); -} -#if UDI_CDC_PORT_NB > 1 -void udi_cdc_data_sof_notify_2(void) -{ - udi_cdc_tx_send(1); -} -#endif -#if UDI_CDC_PORT_NB > 2 -void udi_cdc_data_sof_notify_3(void) -{ - udi_cdc_tx_send(2); -} -#endif - -//------------------------------------------------- -//------- Internal routines to control serial line - - -static void udi_cdc_line_coding_received(void) -{ - udi_cdc_line_coding_received_common(0); -} -#if UDI_CDC_PORT_NB > 1 -static void udi_cdc_line_coding_received_2(void) -{ - udi_cdc_line_coding_received_common(1); -} -#endif -#if UDI_CDC_PORT_NB > 2 -static void udi_cdc_line_coding_received_3(void) -{ - udi_cdc_line_coding_received_common(2); -} -#endif -static void udi_cdc_line_coding_received_common(uint8_t port) -{ - // Send line coding to component associated to CDC -#if UDI_CDC_PORT_NB == 1 - UDI_CDC_SET_CODING_EXT((&udi_cdc_line_coding[0])); -#else - UDI_CDC_SET_CODING_EXT(port, (&udi_cdc_line_coding[port])); -#endif -} - - -static void udi_cdc_ctrl_state_change(uint8_t port, bool b_set, le16_t bit_mask) -{ - irqflags_t flags; - - // Update state - flags = cpu_irq_save(); // Protect udi_cdc_state - if (b_set) { - udi_cdc_state[PORT] |= bit_mask; - } else { - udi_cdc_state[PORT] &= ~bit_mask; - } - cpu_irq_restore(flags); - - // Send it if possible and state changed - udi_cdc_ctrl_state_notify(PORT); -} - - -static void udi_cdc_ctrl_state_notify(uint8_t port) -{ - // Send it if possible and state changed - if ((!udi_cdc_serial_state_msg_ongoing[PORT]) - && (udi_cdc_state[PORT] != uid_cdc_state_msg[PORT].value)) { - // Fill notification message - uid_cdc_state_msg[PORT].value = udi_cdc_state[PORT]; - // Send notification message - udi_cdc_serial_state_msg_ongoing[PORT] = - udd_ep_run(UDI_CDC_COMM_EPS[PORT] , - false, - (uint8_t *) & uid_cdc_state_msg[PORT], - sizeof(uid_cdc_state_msg), - udi_cdc_serial_state_msg_sents[PORT]); - } -} - - -static void udi_cdc_serial_state_msg_sent(udd_ep_status_t status, iram_size_t n) -{ - udi_cdc_serial_state_msg_sent_common(0, status, n); -} -#if UDI_CDC_PORT_NB > 1 -static void udi_cdc_serial_state_msg_sent_2(udd_ep_status_t status, iram_size_t n) -{ - udi_cdc_serial_state_msg_sent_common(1, status, n); -} -#endif -#if UDI_CDC_PORT_NB > 2 -static void udi_cdc_serial_state_msg_sent_3(udd_ep_status_t status, iram_size_t n) -{ - udi_cdc_serial_state_msg_sent_common(2, status, n); -} -#endif - -static void udi_cdc_serial_state_msg_sent_common(uint8_t port, udd_ep_status_t status, iram_size_t n) -{ - udi_cdc_serial_state_msg_ongoing[PORT] = false; - - // For the irregular signals like break, the incoming ring signal, - // or the overrun error state, this will reset their values to zero - // and again will not send another notification until their state changes. - udi_cdc_state[PORT] &= ~(CDC_SERIAL_STATE_BREAK | - CDC_SERIAL_STATE_RING | - CDC_SERIAL_STATE_FRAMING | - CDC_SERIAL_STATE_PARITY | CDC_SERIAL_STATE_OVERRUN); - uid_cdc_state_msg[PORT].value &= ~(CDC_SERIAL_STATE_BREAK | - CDC_SERIAL_STATE_RING | - CDC_SERIAL_STATE_FRAMING | - CDC_SERIAL_STATE_PARITY | CDC_SERIAL_STATE_OVERRUN); - // Send it if possible and state changed - udi_cdc_ctrl_state_notify(PORT); -} - - -//------------------------------------------------- -//------- Internal routines to process data transfer - - -static bool udi_cdc_rx_start(uint8_t port) -{ - irqflags_t flags; - uint8_t buf_sel_trans; - - flags = cpu_irq_save(); - buf_sel_trans = udi_cdc_rx_buf_sel[PORT]; - if (udi_cdc_rx_trans_ongoing[PORT] || - (udi_cdc_rx_pos[PORT] < udi_cdc_rx_buf_nb[PORT][buf_sel_trans])) { - // Transfer already on-going or current buffer no empty - cpu_irq_restore(flags); - return false; - } - - // Change current buffer - udi_cdc_rx_pos[PORT] = 0; - udi_cdc_rx_buf_sel[PORT] = (buf_sel_trans==0)?1:0; - - // Start transfer on RX - udi_cdc_rx_trans_ongoing[PORT] = true; - cpu_irq_restore(flags); - - if (udi_cdc_multi_is_rx_ready(PORT)) { -#if UDI_CDC_PORT_NB == 1 - UDI_CDC_RX_NOTIFY(); -#else - UDI_CDC_RX_NOTIFY(port); -#endif - } - - return udd_ep_run( UDI_CDC_DATA_EP_OUTS[PORT], - true, - udi_cdc_rx_buf[PORT][buf_sel_trans], - UDI_CDC_RX_BUFFERS, - udi_cdc_data_received_callbacks[PORT]); -} - - -static void udi_cdc_data_received(udd_ep_status_t status, iram_size_t n) -{ - udi_cdc_data_received_common(0, status, n); -} -#if UDI_CDC_PORT_NB > 1 -static void udi_cdc_data_received_2(udd_ep_status_t status, iram_size_t n) -{ - udi_cdc_data_received_common(1, status, n); -} -#endif -#if UDI_CDC_PORT_NB > 2 -static void udi_cdc_data_received_3(udd_ep_status_t status, iram_size_t n) -{ - udi_cdc_data_received_common(2, status, n); -} -#endif - -static void udi_cdc_data_received_common(uint8_t port, udd_ep_status_t status, iram_size_t n) -{ - uint8_t buf_sel_trans; - - if (UDD_EP_TRANSFER_OK != status) { - // Abort reception - return; - } - buf_sel_trans = (udi_cdc_rx_buf_sel[PORT]==0)?1:0; - if (!n) { - udd_ep_run( UDI_CDC_DATA_EP_OUTS[PORT], - true, - udi_cdc_rx_buf[PORT][buf_sel_trans], - UDI_CDC_RX_BUFFERS, - udi_cdc_data_received_callbacks[PORT]); - return; - } - udi_cdc_rx_buf_nb[PORT][buf_sel_trans] = n; - udi_cdc_rx_trans_ongoing[PORT] = false; - udi_cdc_rx_start(PORT); -} - - -static void udi_cdc_data_sent(udd_ep_status_t status, iram_size_t n) -{ - udi_cdc_data_sent_common(0, status, n); -} -#if UDI_CDC_PORT_NB > 1 -static void udi_cdc_data_sent_2(udd_ep_status_t status, iram_size_t n) -{ - udi_cdc_data_sent_common(1, status, n); -} -#endif -#if UDI_CDC_PORT_NB > 2 -static void udi_cdc_data_sent_3(udd_ep_status_t status, iram_size_t n) -{ - udi_cdc_data_sent_common(2, status, n); -} -#endif - -static void udi_cdc_data_sent_common(uint8_t port, udd_ep_status_t status, iram_size_t n) -{ - if (UDD_EP_TRANSFER_OK != status) { - // Abort transfer - return; - } - udi_cdc_tx_buf_nb[PORT][(udi_cdc_tx_buf_sel[PORT]==0)?1:0] = 0; - udi_cdc_tx_both_buf_to_send[PORT] = false; - udi_cdc_tx_trans_ongoing[PORT] = false; - udi_cdc_tx_send(PORT); -} - - -static void udi_cdc_tx_send(uint8_t port) -{ - irqflags_t flags; - uint8_t buf_sel_trans; - bool b_short_packet; - - if (udi_cdc_tx_trans_ongoing[PORT]) { - return; // Already on going or wait next SOF to send next data - } - if (udd_is_high_speed()) { - if (udi_cdc_tx_sof_num[PORT] == udd_get_micro_frame_number()) { - return; // Wait next SOF to send next data - } - }else{ - if (udi_cdc_tx_sof_num[PORT] == udd_get_frame_number()) { - return; // Wait next SOF to send next data - } - } - - flags = cpu_irq_save(); // to protect udi_cdc_tx_buf_sel - buf_sel_trans = udi_cdc_tx_buf_sel[PORT]; - if (!udi_cdc_tx_both_buf_to_send[PORT]) { - // Send current Buffer - // and switch the current buffer - udi_cdc_tx_buf_sel[PORT] = (buf_sel_trans==0)?1:0; - }else{ - // Send the other Buffer - // and no switch the current buffer - buf_sel_trans = (buf_sel_trans==0)?1:0; - } - udi_cdc_tx_trans_ongoing[PORT] = true; - cpu_irq_restore(flags); - - b_short_packet = (udi_cdc_tx_buf_nb[PORT][buf_sel_trans] != UDI_CDC_TX_BUFFERS); - if (b_short_packet) { - if (udd_is_high_speed()) { - udi_cdc_tx_sof_num[PORT] = udd_get_micro_frame_number(); - }else{ - udi_cdc_tx_sof_num[PORT] = udd_get_frame_number(); - } - }else{ - udi_cdc_tx_sof_num[PORT] = 0; // Force next transfer without wait SOF - } - - // Send the buffer with enable of short packet - udd_ep_run( UDI_CDC_DATA_EP_INS[PORT], - b_short_packet, - udi_cdc_tx_buf[PORT][buf_sel_trans], - udi_cdc_tx_buf_nb[PORT][buf_sel_trans], - udi_cdc_data_sents[PORT]); -} - - -//--------------------------------------------- -//------- Application interface - - -//------- Application interface - -void udi_cdc_ctrl_signal_dcd(bool b_set) -{ - udi_cdc_ctrl_state_change(0, b_set, CDC_SERIAL_STATE_DCD); -} - -void udi_cdc_ctrl_signal_dsr(bool b_set) -{ - udi_cdc_ctrl_state_change(0, b_set, CDC_SERIAL_STATE_DSR); -} - -void udi_cdc_signal_framing_error(void) -{ - udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_FRAMING); -} - -void udi_cdc_signal_parity_error(void) -{ - udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_PARITY); -} - -void udi_cdc_signal_overrun(void) -{ - udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_OVERRUN); -} - -#if UDI_CDC_PORT_NB > 1 -void udi_cdc_multi_ctrl_signal_dcd(uint8_t port, bool b_set) -{ - udi_cdc_ctrl_state_change(port, b_set, CDC_SERIAL_STATE_DCD); -} - -void udi_cdc_multi_ctrl_signal_dsr(uint8_t port, bool b_set) -{ - udi_cdc_ctrl_state_change(port, b_set, CDC_SERIAL_STATE_DSR); -} - -void udi_cdc_multi_signal_framing_error(uint8_t port) -{ - udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_FRAMING); -} - -void udi_cdc_multi_signal_parity_error(uint8_t port) -{ - udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_PARITY); -} - -void udi_cdc_multi_signal_overrun(uint8_t port) -{ - udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_OVERRUN); -} -#endif - -bool udi_cdc_multi_is_rx_ready(uint8_t port) -{ - uint16_t pos = udi_cdc_rx_pos[PORT]; - return (pos < udi_cdc_rx_buf_nb[PORT][udi_cdc_rx_buf_sel[PORT]]); -} - -bool udi_cdc_is_rx_ready(void) -{ - return udi_cdc_multi_is_rx_ready(0); -} - -int udi_cdc_multi_getc(uint8_t port) -{ - int rx_data = 0; - bool b_databit_9; - uint16_t pos; - uint8_t buf_sel; - - b_databit_9 = (9 == udi_cdc_line_coding[PORT].bDataBits); - -udi_cdc_getc_process_one_byte: - // Check avaliable data - pos = udi_cdc_rx_pos[PORT]; - buf_sel = udi_cdc_rx_buf_sel[PORT]; - while (pos >= udi_cdc_rx_buf_nb[PORT][buf_sel]) { - if (!udi_cdc_running[PORT]) { - return 0; - } - goto udi_cdc_getc_process_one_byte; - } - - // Read data - rx_data |= udi_cdc_rx_buf[PORT][buf_sel][pos]; - udi_cdc_rx_pos[PORT] = pos+1; - - udi_cdc_rx_start(PORT); - - if (b_databit_9) { - // Receive MSB - b_databit_9 = false; - rx_data = rx_data << 8; - goto udi_cdc_getc_process_one_byte; - } - return rx_data; -} - -int udi_cdc_getc(void) -{ - return udi_cdc_multi_getc(0); -} - -iram_size_t udi_cdc_multi_read_buf(uint8_t port, int* buf, iram_size_t size) -{ - uint8_t *ptr_buf = (uint8_t *)buf; - iram_size_t copy_nb; - uint16_t pos; - uint8_t buf_sel; - -udi_cdc_read_buf_loop_wait: - // Check avaliable data - pos = udi_cdc_rx_pos[PORT]; - buf_sel = udi_cdc_rx_buf_sel[PORT]; - while (pos >= udi_cdc_rx_buf_nb[PORT][buf_sel]) { - if (!udi_cdc_running[PORT]) { - return size; - } - goto udi_cdc_read_buf_loop_wait; - } - - // Read data - copy_nb = udi_cdc_rx_buf_nb[PORT][buf_sel] - pos; - if (copy_nb>size) { - copy_nb = size; - } - memcpy(ptr_buf, &udi_cdc_rx_buf[PORT][buf_sel][pos], copy_nb); - udi_cdc_rx_pos[PORT] += copy_nb; - ptr_buf += copy_nb; - size -= copy_nb; - udi_cdc_rx_start(PORT); - - if (size) { - goto udi_cdc_read_buf_loop_wait; - } - return 0; -} - -iram_size_t udi_cdc_read_buf(int* buf, iram_size_t size) -{ - return udi_cdc_multi_read_buf(0, buf, size); -} - -bool udi_cdc_multi_is_tx_ready(uint8_t port) -{ - irqflags_t flags; - if (udi_cdc_tx_buf_nb[PORT][udi_cdc_tx_buf_sel[PORT]]!=UDI_CDC_TX_BUFFERS) { - return true; - } - if (!udi_cdc_tx_both_buf_to_send[PORT]) { - flags = cpu_irq_save(); // to protect udi_cdc_tx_buf_sel - if (!udi_cdc_tx_trans_ongoing[PORT]) { - // No transfer on-going - // then use the other buffer to store data - udi_cdc_tx_both_buf_to_send[PORT] = true; - udi_cdc_tx_buf_sel[PORT] = (udi_cdc_tx_buf_sel[PORT]==0)?1:0; - } - cpu_irq_restore(flags); - } - return (udi_cdc_tx_buf_nb[PORT][udi_cdc_tx_buf_sel[PORT]]!=UDI_CDC_TX_BUFFERS); -} - -bool udi_cdc_is_tx_ready(void) -{ - return udi_cdc_multi_is_tx_ready(0); -} - -int udi_cdc_multi_putc(uint8_t port, int value) -{ - irqflags_t flags; - bool b_databit_9; - uint8_t buf_sel; - - b_databit_9 = (9 == udi_cdc_line_coding[PORT].bDataBits); - -udi_cdc_putc_process_one_byte: - // Check avaliable space - if (!udi_cdc_multi_is_tx_ready(PORT)) { - if (!udi_cdc_running[PORT]) { - return false; - } - goto udi_cdc_putc_process_one_byte; - } - - // Write value - flags = cpu_irq_save(); - buf_sel = udi_cdc_tx_buf_sel[PORT]; - udi_cdc_tx_buf[PORT][buf_sel][udi_cdc_tx_buf_nb[PORT][buf_sel]++] = value; - cpu_irq_restore(flags); - - if (b_databit_9) { - // Send MSB - b_databit_9 = false; - value = value >> 8; - goto udi_cdc_putc_process_one_byte; - } - return true; -} - -int udi_cdc_putc(int value) -{ - return udi_cdc_multi_putc(0, value); -} - -iram_size_t udi_cdc_multi_write_buf(uint8_t port, const int* buf, iram_size_t size) -{ - irqflags_t flags; - uint8_t buf_sel; - uint16_t buf_nb; - iram_size_t copy_nb; - uint8_t *ptr_buf = (uint8_t *)buf; - - if (9 == udi_cdc_line_coding[PORT].bDataBits) { - size *=2; - } - -udi_cdc_write_buf_loop_wait: - // Check avaliable space - if (!udi_cdc_multi_is_tx_ready(PORT)) { - if (!udi_cdc_running[PORT]) { - return size; - } - goto udi_cdc_write_buf_loop_wait; - } - - // Write values - flags = cpu_irq_save(); - buf_sel = udi_cdc_tx_buf_sel[PORT]; - buf_nb = udi_cdc_tx_buf_nb[PORT][buf_sel]; - copy_nb = UDI_CDC_TX_BUFFERS - buf_nb; - if (copy_nb>size) { - copy_nb = size; - } - memcpy(&udi_cdc_tx_buf[PORT][buf_sel][buf_nb], ptr_buf, copy_nb); - udi_cdc_tx_buf_nb[PORT][buf_sel] = buf_nb + copy_nb; - cpu_irq_restore(flags); - - // Update buffer pointer - ptr_buf = ptr_buf + copy_nb; - size -= copy_nb; - - if (size) { - goto udi_cdc_write_buf_loop_wait; - } - - return 0; -} - -iram_size_t udi_cdc_write_buf(const int* buf, iram_size_t size) -{ - return udi_cdc_multi_write_buf(0, buf, size); -} - -//@} diff --git a/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc.h b/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc.h deleted file mode 100644 index 099f185..0000000 --- a/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc.h +++ /dev/null @@ -1,507 +0,0 @@ -/** - * \file - * - * \brief USB Device Communication Device Class (CDC) interface definitions. - * - * Copyright (c) 2009-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _UDI_CDC_H_ -#define _UDI_CDC_H_ - -#include "conf_usb.h" -#include "usb_protocol.h" -#include "usb_protocol_cdc.h" -#include "udd.h" -#include "udc_desc.h" -#include "udi.h" - -// Check the number of port -#ifndef UDI_CDC_PORT_NB -# define UDI_CDC_PORT_NB 1 -#endif -#if UDI_CDC_PORT_NB > 3 -# error UDI_CDC_PORT_NB must be inferior or equal to 3 -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \ingroup udi_group - * \defgroup udi_cdc_group UDI for Communication Device Class - * - * @{ - */ - -/** - * \name Interface Descriptor - * - * The following structures provide the interface descriptor. - * It must be implemented in USB configuration descriptor. - */ -//@{ - - -/** - * \brief Communication Class interface descriptor - * - * Interface descriptor with associated functional and endpoint - * descriptors for the CDC Communication Class interface. - */ -typedef struct { - //! Standard interface descriptor - usb_iface_desc_t iface; - //! CDC Header functional descriptor - usb_cdc_hdr_desc_t header; - //! CDC Abstract Control Model functional descriptor - usb_cdc_acm_desc_t acm; - //! CDC Union functional descriptor - usb_cdc_union_desc_t union_desc; - //! CDC Call Management functional descriptor - usb_cdc_call_mgmt_desc_t call_mgmt; - //! Notification endpoint descriptor - usb_ep_desc_t ep_notify; -} udi_cdc_comm_desc_t; - - -/** - * \brief Data Class interface descriptor - * - * Interface descriptor with associated endpoint descriptors for the - * CDC Data Class interface. - */ -typedef struct { - //! Standard interface descriptor - usb_iface_desc_t iface; - //! Data IN/OUT endpoint descriptors - usb_ep_desc_t ep_in; - usb_ep_desc_t ep_out; -} udi_cdc_data_desc_t; - - -//! CDC communication enpoints size for all speeds -#define UDI_CDC_COMM_EP_SIZE 64 -//! CDC data enpoints size for all speeds (no need to use 512B for HS) -#define UDI_CDC_DATA_EPS_SIZE 64 - -/** - * \name Content of interface descriptors for single or first com port - */ -//@{ -//! By default no string associated to these interfaces -#ifndef UDI_CDC_IAD_STRING_ID -#define UDI_CDC_IAD_STRING_ID 0 -#endif -#ifndef UDI_CDC_COMM_STRING_ID -#define UDI_CDC_COMM_STRING_ID 0 -#endif -#ifndef UDI_CDC_DATA_STRING_ID -#define UDI_CDC_DATA_STRING_ID 0 -#endif -# define UDI_CDC_IAD_DESC {\ - UDI_CDC_IAD_DESC_COMMON \ - .bFirstInterface = UDI_CDC_COMM_IFACE_NUMBER, \ - .iFunction = UDI_CDC_IAD_STRING_ID,\ - } -# define UDI_CDC_COMM_DESC {\ - UDI_CDC_COMM_DESC_COMMON \ - .ep_notify.bEndpointAddress = UDI_CDC_COMM_EP,\ - .iface.bInterfaceNumber = UDI_CDC_COMM_IFACE_NUMBER,\ - .call_mgmt.bDataInterface = UDI_CDC_DATA_IFACE_NUMBER,\ - .union_desc.bMasterInterface = UDI_CDC_COMM_IFACE_NUMBER,\ - .union_desc.bSlaveInterface0 = UDI_CDC_DATA_IFACE_NUMBER,\ - .iface.iInterface = UDI_CDC_COMM_STRING_ID,\ - } -# define UDI_CDC_DATA_DESC {\ - UDI_CDC_DATA_DESC_COMMON \ - .ep_in.bEndpointAddress = UDI_CDC_DATA_EP_IN,\ - .ep_out.bEndpointAddress = UDI_CDC_DATA_EP_OUT,\ - .iface.bInterfaceNumber = UDI_CDC_DATA_IFACE_NUMBER,\ - .iface.iInterface = UDI_CDC_DATA_STRING_ID,\ - } -//@} - -/** - * \name Content of interface descriptors for second com port - */ -//@{ -//! By default no string associated to these interfaces -#ifndef UDI_CDC_IAD_STRING_ID_2 -#define UDI_CDC_IAD_STRING_ID_2 0 -#endif -#ifndef UDI_CDC_COMM_STRING_ID_2 -#define UDI_CDC_COMM_STRING_ID_2 0 -#endif -#ifndef UDI_CDC_DATA_STRING_ID_2 -#define UDI_CDC_DATA_STRING_ID_2 0 -#endif -# define UDI_CDC_IAD_DESC_2 {\ - UDI_CDC_IAD_DESC_COMMON \ - .bFirstInterface = UDI_CDC_COMM_IFACE_NUMBER_2, \ - .iFunction = UDI_CDC_IAD_STRING_ID_2,\ - } -# define UDI_CDC_COMM_DESC_2 {\ - UDI_CDC_COMM_DESC_COMMON \ - .ep_notify.bEndpointAddress = UDI_CDC_COMM_EP_2,\ - .iface.bInterfaceNumber = UDI_CDC_COMM_IFACE_NUMBER_2,\ - .call_mgmt.bDataInterface = UDI_CDC_DATA_IFACE_NUMBER_2,\ - .union_desc.bMasterInterface = UDI_CDC_COMM_IFACE_NUMBER_2,\ - .union_desc.bSlaveInterface0 = UDI_CDC_DATA_IFACE_NUMBER_2,\ - .iface.iInterface = UDI_CDC_COMM_STRING_ID_2,\ - } -# define UDI_CDC_DATA_DESC_2 {\ - UDI_CDC_DATA_DESC_COMMON \ - .ep_in.bEndpointAddress = UDI_CDC_DATA_EP_IN_2,\ - .ep_out.bEndpointAddress = UDI_CDC_DATA_EP_OUT_2,\ - .iface.bInterfaceNumber = UDI_CDC_DATA_IFACE_NUMBER_2,\ - .iface.iInterface = UDI_CDC_DATA_STRING_ID_2,\ - } -//@} - -/** - * \name Content of interface descriptors for third com port - */ -//@{ -//! By default no string associated to these interfaces -#ifndef UDI_CDC_IAD_STRING_ID_3 -#define UDI_CDC_IAD_STRING_ID_3 0 -#endif -#ifndef UDI_CDC_COMM_STRING_ID_3 -#define UDI_CDC_COMM_STRING_ID_3 0 -#endif -#ifndef UDI_CDC_DATA_STRING_ID_3 -#define UDI_CDC_DATA_STRING_ID_3 0 -#endif -# define UDI_CDC_IAD_DESC_3 {\ - UDI_CDC_IAD_DESC_COMMON \ - .bFirstInterface = UDI_CDC_COMM_IFACE_NUMBER_3, \ - .iFunction = UDI_CDC_IAD_STRING_ID_3,\ - } -# define UDI_CDC_COMM_DESC_3 {\ - UDI_CDC_COMM_DESC_COMMON \ - .ep_notify.bEndpointAddress = UDI_CDC_COMM_EP_3,\ - .iface.bInterfaceNumber = UDI_CDC_COMM_IFACE_NUMBER_3,\ - .call_mgmt.bDataInterface = UDI_CDC_DATA_IFACE_NUMBER_3,\ - .union_desc.bMasterInterface = UDI_CDC_COMM_IFACE_NUMBER_3,\ - .union_desc.bSlaveInterface0 = UDI_CDC_DATA_IFACE_NUMBER_3,\ - .iface.iInterface = UDI_CDC_COMM_STRING_ID_3,\ - } -# define UDI_CDC_DATA_DESC_3 {\ - UDI_CDC_DATA_DESC_COMMON \ - .ep_in.bEndpointAddress = UDI_CDC_DATA_EP_IN_3,\ - .ep_out.bEndpointAddress = UDI_CDC_DATA_EP_OUT_3,\ - .iface.bInterfaceNumber = UDI_CDC_DATA_IFACE_NUMBER_3,\ - .iface.iInterface = UDI_CDC_DATA_STRING_ID_3,\ - } -//@} - - -//! Content of CDC IAD interface descriptor for all speeds -#define UDI_CDC_IAD_DESC_COMMON \ - .bLength = sizeof(usb_iad_desc_t),\ - .bDescriptorType = USB_DT_IAD,\ - .bInterfaceCount = 2,\ - .bFunctionClass = CDC_CLASS_COMM,\ - .bFunctionSubClass = CDC_SUBCLASS_ACM,\ - .bFunctionProtocol = CDC_PROTOCOL_V25TER, - -//! Content of CDC COMM interface descriptor for all speeds -#define UDI_CDC_COMM_DESC_COMMON \ - .iface.bLength = sizeof(usb_iface_desc_t),\ - .iface.bDescriptorType = USB_DT_INTERFACE,\ - .iface.bAlternateSetting = 0,\ - .iface.bNumEndpoints = 1,\ - .iface.bInterfaceClass = CDC_CLASS_COMM,\ - .iface.bInterfaceSubClass = CDC_SUBCLASS_ACM,\ - .iface.bInterfaceProtocol = CDC_PROTOCOL_V25TER,\ - .header.bFunctionLength = sizeof(usb_cdc_hdr_desc_t),\ - .header.bDescriptorType = CDC_CS_INTERFACE,\ - .header.bDescriptorSubtype = CDC_SCS_HEADER,\ - .header.bcdCDC = LE16(0x0110),\ - .call_mgmt.bFunctionLength = sizeof(usb_cdc_call_mgmt_desc_t),\ - .call_mgmt.bDescriptorType = CDC_CS_INTERFACE,\ - .call_mgmt.bDescriptorSubtype = CDC_SCS_CALL_MGMT,\ - .call_mgmt.bmCapabilities = \ - CDC_CALL_MGMT_SUPPORTED | CDC_CALL_MGMT_OVER_DCI,\ - .acm.bFunctionLength = sizeof(usb_cdc_acm_desc_t),\ - .acm.bDescriptorType = CDC_CS_INTERFACE,\ - .acm.bDescriptorSubtype = CDC_SCS_ACM,\ - .acm.bmCapabilities = CDC_ACM_SUPPORT_LINE_REQUESTS,\ - .union_desc.bFunctionLength = sizeof(usb_cdc_union_desc_t),\ - .union_desc.bDescriptorType = CDC_CS_INTERFACE,\ - .union_desc.bDescriptorSubtype= CDC_SCS_UNION,\ - .ep_notify.bLength = sizeof(usb_ep_desc_t),\ - .ep_notify.bDescriptorType = USB_DT_ENDPOINT,\ - .ep_notify.bmAttributes = USB_EP_TYPE_INTERRUPT,\ - .ep_notify.wMaxPacketSize = LE16(UDI_CDC_COMM_EP_SIZE),\ - .ep_notify.bInterval = 0xFF, - -//! Content of CDC DATA interface descriptor for all speeds -#define UDI_CDC_DATA_DESC_COMMON \ - .iface.bLength = sizeof(usb_iface_desc_t),\ - .iface.bDescriptorType = USB_DT_INTERFACE,\ - .iface.bAlternateSetting = 0,\ - .iface.bNumEndpoints = 2,\ - .iface.bInterfaceClass = CDC_CLASS_DATA,\ - .iface.bInterfaceSubClass = 0,\ - .iface.bInterfaceProtocol = 0,\ - .ep_in.bLength = sizeof(usb_ep_desc_t),\ - .ep_in.bDescriptorType = USB_DT_ENDPOINT,\ - .ep_in.wMaxPacketSize = LE16(UDI_CDC_DATA_EPS_SIZE),\ - .ep_in.bmAttributes = USB_EP_TYPE_BULK,\ - .ep_in.bInterval = 0,\ - .ep_out.bLength = sizeof(usb_ep_desc_t),\ - .ep_out.bDescriptorType = USB_DT_ENDPOINT,\ - .ep_out.wMaxPacketSize = LE16(UDI_CDC_DATA_EPS_SIZE),\ - .ep_out.bmAttributes = USB_EP_TYPE_BULK,\ - .ep_out.bInterval = 0, -//@} - - -//! Global struture which contains standard UDI API for UDC -extern UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm; -extern UDC_DESC_STORAGE udi_api_t udi_api_cdc_data; -extern UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm_2; -extern UDC_DESC_STORAGE udi_api_t udi_api_cdc_data_2; -extern UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm_3; -extern UDC_DESC_STORAGE udi_api_t udi_api_cdc_data_3; - -/** - * \name Interface for application - * - * These routines are used by memory to transfer its data - * to/from USB CDC endpoint. - */ -//@{ - -/** - * \brief Notify a state change of DCD signal - * - * \param b_set DCD is enabled if true, else disabled - */ -void udi_cdc_ctrl_signal_dcd(bool b_set); - -/** - * \brief Notify a state change of DSR signal - * - * \param b_set DSR is enabled if true, else disabled - */ -void udi_cdc_ctrl_signal_dsr(bool b_set); - -/** - * \brief Notify a framing error - */ -void udi_cdc_signal_framing_error(void); - -/** - * \brief Notify a parity error - */ -void udi_cdc_signal_parity_error(void); - -/** - * \brief Notify a overrun - */ -void udi_cdc_signal_overrun(void); - -/** - * \brief This function checks if a character has been received on the CDC line - * - * \return \c 1 if a byte is ready to be read. - */ -bool udi_cdc_is_rx_ready(void); - -/** - * \brief Waits and gets a value on CDC line - * - * \return value read on CDC line - */ -int udi_cdc_getc(void); - -/** - * \brief Reads a RAM buffer on CDC line - * - * \param buf Values readed - * \param size Number of value readed - * - * \return the number of data remaining - */ -iram_size_t udi_cdc_read_buf(int* buf, iram_size_t size); - -/** - * \brief This function checks if a new character sent is possible - * The type int is used to support scanf redirection from compiler LIB. - * - * \return \c 1 if a new chracter can be sent - */ -bool udi_cdc_is_tx_ready(void); - -/** - * \brief Puts a byte on CDC line - * The type int is used to support printf redirection from compiler LIB. - * - * \param value Value to put - * - * \return \c 1 if function was successfully done, otherwise \c 0. - */ -int udi_cdc_putc(int value); - -/** - * \brief Writes a RAM buffer on CDC line - * - * \param buf Values to write - * \param size Number of value to write - * - * \return the number of data remaining - */ -iram_size_t udi_cdc_write_buf(const int* buf, iram_size_t size); -//@} - - -/** - * \name Interface for application for all ports - * - * These routines are used by memory to transfer its data - * to/from USB CDC endpoint. - */ -//@{ - -/** - * \brief Notify a state change of DCD signal - * - * \param port Communication port number to manage - * \param b_set DCD is enabled if true, else disabled - */ -void udi_cdc_multi_ctrl_signal_dcd(uint8_t port, bool b_set); - -/** - * \brief Notify a state change of DSR signal - * - * \param port Communication port number to manage - * \param b_set DSR is enabled if true, else disabled - */ -void udi_cdc_multi_ctrl_signal_dsr(uint8_t port, bool b_set); - -/** - * \brief Notify a framing error - * - * \param port Communication port number to manage - */ -void udi_cdc_multi_signal_framing_error(uint8_t port); - -/** - * \brief Notify a parity error - * - * \param port Communication port number to manage - */ -void udi_cdc_multi_signal_parity_error(uint8_t port); - -/** - * \brief Notify a overrun - * - * \param port Communication port number to manage - */ -void udi_cdc_multi_signal_overrun(uint8_t port); - -/** - * \brief This function checks if a character has been received on the CDC line - * - * \param port Communication port number to manage - * - * \return \c 1 if a byte is ready to be read. - */ -bool udi_cdc_multi_is_rx_ready(uint8_t port); - -/** - * \brief Waits and gets a value on CDC line - * - * \param port Communication port number to manage - * - * \return value read on CDC line - */ -int udi_cdc_multi_getc(uint8_t port); - -/** - * \brief Reads a RAM buffer on CDC line - * - * \param port Communication port number to manage - * \param buf Values readed - * \param size Number of value readed - * - * \return the number of data remaining - */ -iram_size_t udi_cdc_multi_read_buf(uint8_t port, int* buf, iram_size_t size); - -/** - * \brief This function checks if a new character sent is possible - * The type int is used to support scanf redirection from compiler LIB. - * - * \param port Communication port number to manage - * - * \return \c 1 if a new chracter can be sent - */ -bool udi_cdc_multi_is_tx_ready(uint8_t port); - -/** - * \brief Puts a byte on CDC line - * The type int is used to support printf redirection from compiler LIB. - * - * \param port Communication port number to manage - * \param value Value to put - * - * \return \c 1 if function was successfully done, otherwise \c 0. - */ -int udi_cdc_multi_putc(uint8_t port, int value); - -/** - * \brief Writes a RAM buffer on CDC line - * - * \param port Communication port number to manage - * \param buf Values to write - * \param size Number of value to write - * - * \return the number of data remaining - */ -iram_size_t udi_cdc_multi_write_buf(uint8_t port, const int* buf, iram_size_t size); -//@} - -//@} - -#ifdef __cplusplus -} -#endif -#endif // _UDI_CDC_H_ diff --git a/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc_conf.h b/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc_conf.h deleted file mode 100644 index f65af68..0000000 --- a/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc_conf.h +++ /dev/null @@ -1,137 +0,0 @@ -/** - * \file - * - * \brief Default CDC configuration for a USB Device with a single interface - * - * Copyright (c) 2009-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _UDI_CDC_CONF_H_ -#define _UDI_CDC_CONF_H_ - -#include "usb_protocol_cdc.h" -#include "conf_usb.h" - -// Check the number of port -#ifndef UDI_CDC_PORT_NB -# define UDI_CDC_PORT_NB 1 -#endif -#if UDI_CDC_PORT_NB > 3 -# error UDI_CDC_PORT_NB must be inferior or equal at 3 -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \ingroup udi_cdc_group - * \defgroup udi_cdc_group_conf Default CDC configuration for a USB Device - * with a single interface CDC - * - * @{ - */ - -//! Control endpoint size (Endpoint 0) -#define USB_DEVICE_EP_CTRL_SIZE 64 - -#if XMEGA -/** - * \name Endpoint configuration on XMEGA - * The XMEGA supports a IN and OUT endpoint with the same number endpoint. - */ -//@{ -//! Endpoints' numbers used by single or first CDC port -#define UDI_CDC_DATA_EP_IN (1 | USB_EP_DIR_IN) // TX -#define UDI_CDC_DATA_EP_OUT (2 | USB_EP_DIR_OUT) // RX -#define UDI_CDC_COMM_EP (2 | USB_EP_DIR_IN) // Notify endpoint -//! Endpoints' numbers used by second CDC port (Optional) -#define UDI_CDC_DATA_EP_IN_2 (3 | USB_EP_DIR_IN) // TX -#define UDI_CDC_DATA_EP_OUT_2 (4 | USB_EP_DIR_OUT) // RX -#define UDI_CDC_COMM_EP_2 (4 | USB_EP_DIR_IN) // Notify endpoint -//! Endpoints' numbers used by third CDC port (Optional) -#define UDI_CDC_DATA_EP_IN_3 (5 | USB_EP_DIR_IN) // TX -#define UDI_CDC_DATA_EP_OUT_3 (6 | USB_EP_DIR_OUT) // RX -#define UDI_CDC_COMM_EP_3 (6 | USB_EP_DIR_IN) // Notify endpoint -//@} - -#else - -/** - * \name Default endpoint configuration - */ -//@{ -//! Endpoints' numbers used by single or first CDC port -#define UDI_CDC_DATA_EP_IN (1 | USB_EP_DIR_IN) // TX -#define UDI_CDC_DATA_EP_OUT (2 | USB_EP_DIR_OUT) // RX -#define UDI_CDC_COMM_EP (3 | USB_EP_DIR_IN) // Notify endpoint -//! Endpoints' numbers used by second CDC port (Optional) -#define UDI_CDC_DATA_EP_IN_2 (4 | USB_EP_DIR_IN) // TX -#define UDI_CDC_DATA_EP_OUT_2 (5 | USB_EP_DIR_OUT) // RX -#define UDI_CDC_COMM_EP_2 (6 | USB_EP_DIR_IN) // Notify endpoint -//! Endpoints' numbers used by third CDC port (Optional) -#define UDI_CDC_DATA_EP_IN_3 (7 | USB_EP_DIR_IN) // TX -#define UDI_CDC_DATA_EP_OUT_3 (8 | USB_EP_DIR_OUT) // RX -#define UDI_CDC_COMM_EP_3 (9 | USB_EP_DIR_IN) // Notify endpoint -//@} - -#endif - -//! Interface numbers used by single or first CDC port -#define UDI_CDC_COMM_IFACE_NUMBER 0 -#define UDI_CDC_DATA_IFACE_NUMBER 1 -//! Interface numbers used by second CDC port (Optional) -#define UDI_CDC_COMM_IFACE_NUMBER_2 2 -#define UDI_CDC_DATA_IFACE_NUMBER_2 3 -//! Interface numbers used by third CDC port (Optional) -#define UDI_CDC_COMM_IFACE_NUMBER_3 4 -#define UDI_CDC_DATA_IFACE_NUMBER_3 5 - -/** - * \name UDD Configuration - */ -//@{ -//! 3 endpoints used by single CDC interface -#define USB_DEVICE_MAX_EP (3*UDI_CDC_PORT_NB) -//@} - -//@} - -#ifdef __cplusplus -} -#endif -#endif // _UDI_CDC_CONF_H_ diff --git a/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc_desc.c b/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc_desc.c deleted file mode 100644 index 40dc678..0000000 --- a/DSTAT1/src/asf/common/services/usb/class/cdc/device/udi_cdc_desc.c +++ /dev/null @@ -1,212 +0,0 @@ -/** - * \file - * - * \brief Default descriptors for a USB Device with a single interface CDC - * - * Copyright (c) 2009-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#include "conf_usb.h" -#include "udd.h" -#include "udc_desc.h" -#include "udi_cdc.h" - - -/** - * \ingroup udi_cdc_group - * \defgroup udi_cdc_group_desc Default descriptors for a USB Device - * with a single interface CDC - * - * @{ - */ - -//! Two interfaces for a CDC device -#if UDI_CDC_PORT_NB == 1 -# define USB_DEVICE_NB_INTERFACE 2 -#elif UDI_CDC_PORT_NB == 2 -# define USB_DEVICE_NB_INTERFACE 4 -#elif UDI_CDC_PORT_NB == 3 -# define USB_DEVICE_NB_INTERFACE 6 -#endif - -/**INDENT-OFF**/ - -//! USB Device Descriptor -COMPILER_WORD_ALIGNED -UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = { - .bLength = sizeof(usb_dev_desc_t), - .bDescriptorType = USB_DT_DEVICE, - .bcdUSB = LE16(USB_V2_0), -#if UDI_CDC_PORT_NB > 1 - .bDeviceClass = 0, -#else - .bDeviceClass = CDC_CLASS_DEVICE, -#endif - .bDeviceSubClass = 0, - .bDeviceProtocol = 0, - .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE, - .idVendor = LE16(USB_DEVICE_VENDOR_ID), - .idProduct = LE16(USB_DEVICE_PRODUCT_ID), - .bcdDevice = LE16((USB_DEVICE_MAJOR_VERSION << 8) - | USB_DEVICE_MINOR_VERSION), -#ifdef USB_DEVICE_MANUFACTURE_NAME - .iManufacturer = 1, -#else - .iManufacturer = 0, // No manufacture string -#endif -#ifdef USB_DEVICE_PRODUCT_NAME - .iProduct = 2, -#else - .iProduct = 0, // No product string -#endif -#ifdef USB_DEVICE_SERIAL_NAME - .iSerialNumber = 3, -#else - .iSerialNumber = 0, // No serial string -#endif - .bNumConfigurations = 1 -}; - - -#ifdef USB_DEVICE_HS_SUPPORT -//! USB Device Qualifier Descriptor for HS -COMPILER_WORD_ALIGNED -UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = { - .bLength = sizeof(usb_dev_qual_desc_t), - .bDescriptorType = USB_DT_DEVICE_QUALIFIER, - .bcdUSB = LE16(USB_V2_0), -#if UDI_CDC_PORT_NB > 1 - .bDeviceClass = 0, -#else - .bDeviceClass = CDC_CLASS_DEVICE, -#endif - .bDeviceSubClass = 0, - .bDeviceProtocol = 0, - .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE, - .bNumConfigurations = 1 -}; -#endif - -//! Structure for USB Device Configuration Descriptor -COMPILER_PACK_SET(1); -typedef struct { - usb_conf_desc_t conf; -#if UDI_CDC_PORT_NB == 1 - udi_cdc_comm_desc_t udi_cdc_comm; - udi_cdc_data_desc_t udi_cdc_data; -#endif -#if UDI_CDC_PORT_NB > 1 - usb_iad_desc_t udi_cdc_iad; - udi_cdc_comm_desc_t udi_cdc_comm; - udi_cdc_data_desc_t udi_cdc_data; - usb_iad_desc_t udi_cdc_iad_2; - udi_cdc_comm_desc_t udi_cdc_comm_2; - udi_cdc_data_desc_t udi_cdc_data_2; -#endif -#if UDI_CDC_PORT_NB > 2 - usb_iad_desc_t udi_cdc_iad_3; - udi_cdc_comm_desc_t udi_cdc_comm_3; - udi_cdc_data_desc_t udi_cdc_data_3; -#endif -} udc_desc_t; -COMPILER_PACK_RESET(); - -//! USB Device Configuration Descriptor filled for full and high speed -COMPILER_WORD_ALIGNED -UDC_DESC_STORAGE udc_desc_t udc_desc = { - .conf.bLength = sizeof(usb_conf_desc_t), - .conf.bDescriptorType = USB_DT_CONFIGURATION, - .conf.wTotalLength = LE16(sizeof(udc_desc_t)), - .conf.bNumInterfaces = USB_DEVICE_NB_INTERFACE, - .conf.bConfigurationValue = 1, - .conf.iConfiguration = 0, - .conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR, - .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER), - .udi_cdc_comm = UDI_CDC_COMM_DESC, - .udi_cdc_data = UDI_CDC_DATA_DESC, -#if UDI_CDC_PORT_NB > 1 - .udi_cdc_iad = UDI_CDC_IAD_DESC, - .udi_cdc_iad_2 = UDI_CDC_IAD_DESC_2, - .udi_cdc_comm_2 = UDI_CDC_COMM_DESC_2, - .udi_cdc_data_2 = UDI_CDC_DATA_DESC_2, -#endif -#if UDI_CDC_PORT_NB > 2 - .udi_cdc_iad_3 = UDI_CDC_IAD_DESC_3, - .udi_cdc_comm_3 = UDI_CDC_COMM_DESC_3, - .udi_cdc_data_3 = UDI_CDC_DATA_DESC_3, -#endif -}; - - -/** - * \name UDC structures which content all USB Device definitions - */ -//@{ - -//! Associate an UDI for each USB interface -UDC_DESC_STORAGE udi_api_t *udi_apis[USB_DEVICE_NB_INTERFACE] = { - &udi_api_cdc_comm, - &udi_api_cdc_data, -#if UDI_CDC_PORT_NB > 1 - &udi_api_cdc_comm_2, - &udi_api_cdc_data_2, -#endif -#if UDI_CDC_PORT_NB > 2 - &udi_api_cdc_comm_3, - &udi_api_cdc_data_3, -#endif -}; - -//! Add UDI with USB Descriptors FS & HS -UDC_DESC_STORAGE udc_config_speed_t udc_config_fshs[1] = { { - .desc = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc, - .udi_apis = udi_apis, -}}; - -//! Add all information about USB Device in global structure for UDC -UDC_DESC_STORAGE udc_config_t udc_config = { - .confdev_lsfs = &udc_device_desc, - .conf_lsfs = udc_config_fshs, -#ifdef USB_DEVICE_HS_SUPPORT - .confdev_hs = &udc_device_desc, - .qualifier = &udc_device_qual, - .conf_hs = udc_config_fshs, -#endif -}; - -//@} -/**INDENT-ON**/ -//@} diff --git a/DSTAT1/src/asf/common/services/usb/class/cdc/usb_protocol_cdc.h b/DSTAT1/src/asf/common/services/usb/class/cdc/usb_protocol_cdc.h deleted file mode 100644 index 7f1dc84..0000000 --- a/DSTAT1/src/asf/common/services/usb/class/cdc/usb_protocol_cdc.h +++ /dev/null @@ -1,313 +0,0 @@ -/** - * \file - * - * \brief USB Communication Device Class (CDC) protocol definitions - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef _USB_PROTOCOL_CDC_H_ -#define _USB_PROTOCOL_CDC_H_ - -#include "compiler.h" - -/** - * \ingroup usb_protocol_group - * \defgroup cdc_protocol_group Communication Device Class Definitions - * @{ - */ - -/** - * \name Possible values of class - */ -//@{ -#define CDC_CLASS_DEVICE 0x02 //!< USB Communication Device Class -#define CDC_CLASS_COMM 0x02 //!< CDC Communication Class Interface -#define CDC_CLASS_DATA 0x0A //!< CDC Data Class Interface -//@} - -//! \name USB CDC Subclass IDs -//@{ -#define CDC_SUBCLASS_DLCM 0x01 //!< Direct Line Control Model -#define CDC_SUBCLASS_ACM 0x02 //!< Abstract Control Model -#define CDC_SUBCLASS_TCM 0x03 //!< Telephone Control Model -#define CDC_SUBCLASS_MCCM 0x04 //!< Multi-Channel Control Model -#define CDC_SUBCLASS_CCM 0x05 //!< CAPI Control Model -#define CDC_SUBCLASS_ETH 0x06 //!< Ethernet Networking Control Model -#define CDC_SUBCLASS_ATM 0x07 //!< ATM Networking Control Model -//@} - -//! \name USB CDC Communication Interface Protocol IDs -//@{ -#define CDC_PROTOCOL_V25TER 0x01 //!< Common AT commands -//@} - -//! \name USB CDC Data Interface Protocol IDs -//@{ -#define CDC_PROTOCOL_I430 0x30 //!< ISDN BRI -#define CDC_PROTOCOL_HDLC 0x31 //!< HDLC -#define CDC_PROTOCOL_TRANS 0x32 //!< Transparent -#define CDC_PROTOCOL_Q921M 0x50 //!< Q.921 management protocol -#define CDC_PROTOCOL_Q921 0x51 //!< Q.931 [sic] Data link protocol -#define CDC_PROTOCOL_Q921TM 0x52 //!< Q.921 TEI-multiplexor -#define CDC_PROTOCOL_V42BIS 0x90 //!< Data compression procedures -#define CDC_PROTOCOL_Q931 0x91 //!< Euro-ISDN protocol control -#define CDC_PROTOCOL_V120 0x92 //!< V.24 rate adaption to ISDN -#define CDC_PROTOCOL_CAPI20 0x93 //!< CAPI Commands -#define CDC_PROTOCOL_HOST 0xFD //!< Host based driver -/** - * \brief Describes the Protocol Unit Functional Descriptors [sic] - * on Communication Class Interface - */ -#define CDC_PROTOCOL_PUFD 0xFE -//@} - -//! \name USB CDC Functional Descriptor Types -//@{ -#define CDC_CS_INTERFACE 0x24 //!< Interface Functional Descriptor -#define CDC_CS_ENDPOINT 0x25 //!< Endpoint Functional Descriptor -//@} - -//! \name USB CDC Functional Descriptor Subtypes -//@{ -#define CDC_SCS_HEADER 0x00 //!< Header Functional Descriptor -#define CDC_SCS_CALL_MGMT 0x01 //!< Call Management -#define CDC_SCS_ACM 0x02 //!< Abstract Control Management -#define CDC_SCS_UNION 0x06 //!< Union Functional Descriptor -//@} - -//! \name USB CDC Request IDs -//@{ -#define USB_REQ_CDC_SEND_ENCAPSULATED_COMMAND 0x00 -#define USB_REQ_CDC_GET_ENCAPSULATED_RESPONSE 0x01 -#define USB_REQ_CDC_SET_COMM_FEATURE 0x02 -#define USB_REQ_CDC_GET_COMM_FEATURE 0x03 -#define USB_REQ_CDC_CLEAR_COMM_FEATURE 0x04 -#define USB_REQ_CDC_SET_AUX_LINE_STATE 0x10 -#define USB_REQ_CDC_SET_HOOK_STATE 0x11 -#define USB_REQ_CDC_PULSE_SETUP 0x12 -#define USB_REQ_CDC_SEND_PULSE 0x13 -#define USB_REQ_CDC_SET_PULSE_TIME 0x14 -#define USB_REQ_CDC_RING_AUX_JACK 0x15 -#define USB_REQ_CDC_SET_LINE_CODING 0x20 -#define USB_REQ_CDC_GET_LINE_CODING 0x21 -#define USB_REQ_CDC_SET_CONTROL_LINE_STATE 0x22 -#define USB_REQ_CDC_SEND_BREAK 0x23 -#define USB_REQ_CDC_SET_RINGER_PARMS 0x30 -#define USB_REQ_CDC_GET_RINGER_PARMS 0x31 -#define USB_REQ_CDC_SET_OPERATION_PARMS 0x32 -#define USB_REQ_CDC_GET_OPERATION_PARMS 0x33 -#define USB_REQ_CDC_SET_LINE_PARMS 0x34 -#define USB_REQ_CDC_GET_LINE_PARMS 0x35 -#define USB_REQ_CDC_DIAL_DIGITS 0x36 -#define USB_REQ_CDC_SET_UNIT_PARAMETER 0x37 -#define USB_REQ_CDC_GET_UNIT_PARAMETER 0x38 -#define USB_REQ_CDC_CLEAR_UNIT_PARAMETER 0x39 -#define USB_REQ_CDC_GET_PROFILE 0x3A -#define USB_REQ_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40 -#define USB_REQ_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x41 -#define USB_REQ_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x42 -#define USB_REQ_CDC_SET_ETHERNET_PACKET_FILTER 0x43 -#define USB_REQ_CDC_GET_ETHERNET_STATISTIC 0x44 -#define USB_REQ_CDC_SET_ATM_DATA_FORMAT 0x50 -#define USB_REQ_CDC_GET_ATM_DEVICE_STATISTICS 0x51 -#define USB_REQ_CDC_SET_ATM_DEFAULT_VC 0x52 -#define USB_REQ_CDC_GET_ATM_VC_STATISTICS 0x53 -// Added bNotification codes according cdc spec 1.1 chapter 6.3 -#define USB_REQ_CDC_NOTIFY_RING_DETECT 0x09 -#define USB_REQ_CDC_NOTIFY_SERIAL_STATE 0x20 -#define USB_REQ_CDC_NOTIFY_CALL_STATE_CHANGE 0x28 -#define USB_REQ_CDC_NOTIFY_LINE_STATE_CHANGE 0x29 -//@} - -/* - * Need to pack structures tightly, or the compiler might insert padding - * and violate the spec-mandated layout. - */ -COMPILER_PACK_SET(1); - -//! \name USB CDC Descriptors -//@{ - - -//! CDC Header Functional Descriptor -typedef struct { - uint8_t bFunctionLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - le16_t bcdCDC; -} usb_cdc_hdr_desc_t; - -//! CDC Call Management Functional Descriptor -typedef struct { - uint8_t bFunctionLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bmCapabilities; - uint8_t bDataInterface; -} usb_cdc_call_mgmt_desc_t; - -//! CDC ACM Functional Descriptor -typedef struct { - uint8_t bFunctionLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bmCapabilities; -} usb_cdc_acm_desc_t; - -//! CDC Union Functional Descriptor -typedef struct { - uint8_t bFunctionLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bMasterInterface; - uint8_t bSlaveInterface0; -} usb_cdc_union_desc_t; - - -//! \name USB CDC Call Management Capabilities -//@{ -//! Device handles call management itself -#define CDC_CALL_MGMT_SUPPORTED (1 << 0) -//! Device can send/receive call management info over a Data Class interface -#define CDC_CALL_MGMT_OVER_DCI (1 << 1) -//@} - -//! \name USB CDC ACM Capabilities -//@{ -//! Device supports the request combination of -//! Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature. -#define CDC_ACM_SUPPORT_FEATURE_REQUESTS (1 << 0) -//! Device supports the request combination of -//! Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, -//! and the notification Serial_State. -#define CDC_ACM_SUPPORT_LINE_REQUESTS (1 << 1) -//! Device supports the request Send_Break -#define CDC_ACM_SUPPORT_SENDBREAK_REQUESTS (1 << 2) -//! Device supports the notification Network_Connection. -#define CDC_ACM_SUPPORT_NOTIFY_REQUESTS (1 << 3) -//@} -//@} - -//! \name USB CDC line control -//@{ - -//! \name USB CDC line coding -//@{ -//! Line Coding structure -typedef struct { - le32_t dwDTERate; - uint8_t bCharFormat; - uint8_t bParityType; - uint8_t bDataBits; -} usb_cdc_line_coding_t; -//! Possible values of bCharFormat -enum cdc_char_format { - CDC_STOP_BITS_1 = 0, //!< 1 stop bit - CDC_STOP_BITS_1_5 = 1, //!< 1.5 stop bits - CDC_STOP_BITS_2 = 2, //!< 2 stop bits -}; -//! Possible values of bParityType -enum cdc_parity { - CDC_PAR_NONE = 0, //!< No parity - CDC_PAR_ODD = 1, //!< Odd parity - CDC_PAR_EVEN = 2, //!< Even parity - CDC_PAR_MARK = 3, //!< Parity forced to 0 (space) - CDC_PAR_SPACE = 4, //!< Parity forced to 1 (mark) -}; -//@} - -//! \name USB CDC control signals -//! spec 1.1 chapter 6.2.14 -//@{ - -//! Control signal structure -typedef struct { - uint16_t value; -} usb_cdc_control_signal_t; - -//! \name Possible values in usb_cdc_control_signal_t -//@{ -//! Carrier control for half duplex modems. -//! This signal corresponds to V.24 signal 105 and RS-232 signal RTS. -//! The device ignores the value of this bit -//! when operating in full duplex mode. -#define CDC_CTRL_SIGNAL_ACTIVATE_CARRIER (1 << 1) -//! Indicates to DCE if DTE is present or not. -//! This signal corresponds to V.24 signal 108/2 and RS-232 signal DTR. -#define CDC_CTRL_SIGNAL_DTE_PRESENT (1 << 0) -//@} -//@} - - -//! \name USB CDC notification message -//@{ - -typedef struct { - uint8_t bmRequestType; - uint8_t bNotification; - le16_t wValue; - le16_t wIndex; - le16_t wLength; -} usb_cdc_notify_msg_t; - -//! \name USB CDC serial state -//@{* - -//! Hardware handshake support (cdc spec 1.1 chapter 6.3.5) -typedef struct { - usb_cdc_notify_msg_t header; - le16_t value; -} usb_cdc_notify_serial_state_t; - -//! \name Possible values in usb_cdc_notify_serial_state_t -//@{ -#define CDC_SERIAL_STATE_DCD CPU_TO_LE16((1<<0)) -#define CDC_SERIAL_STATE_DSR CPU_TO_LE16((1<<1)) -#define CDC_SERIAL_STATE_BREAK CPU_TO_LE16((1<<2)) -#define CDC_SERIAL_STATE_RING CPU_TO_LE16((1<<3)) -#define CDC_SERIAL_STATE_FRAMING CPU_TO_LE16((1<<4)) -#define CDC_SERIAL_STATE_PARITY CPU_TO_LE16((1<<5)) -#define CDC_SERIAL_STATE_OVERRUN CPU_TO_LE16((1<<6)) -//@} -//! @} - -//! @} - -COMPILER_PACK_RESET(); - -//! @} - -#endif // _USB_PROTOCOL_CDC_H_ diff --git a/DSTAT1/src/asf/common/services/usb/udc/udc.c b/DSTAT1/src/asf/common/services/usb/udc/udc.c deleted file mode 100644 index 6daea9c..0000000 --- a/DSTAT1/src/asf/common/services/usb/udc/udc.c +++ /dev/null @@ -1,1084 +0,0 @@ -/** - * \file - * - * \brief USB Device Controller (UDC) - * - * Copyright (c) 2009 - 2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#include "conf_usb.h" -#include "usb_protocol.h" -#include "udd.h" -#include "udc_desc.h" -#include "udi.h" -#include "udc.h" - -/** - * \addtogroup udc_group - * @{ - */ - -//! \name Internal variables to manage the USB device -//! @{ - -//! Device status state (see enum usb_device_status in usb_protocol.h) -static le16_t udc_device_status; - -//! Device Configuration number selected by the USB host -static uint8_t udc_num_configuration = 0; - -//! Pointer on the selected speed device configuration -static udc_config_speed_t UDC_DESC_STORAGE *udc_ptr_conf; - -//! Pointer on interface descriptor used by SETUP request. -static usb_iface_desc_t UDC_DESC_STORAGE *udc_ptr_iface; - -//! @} - - -//! \name Internal structure to store the USB device main strings -//! @{ - -/** - * \brief Language ID of USB device (US ID by default) - */ -COMPILER_WORD_ALIGNED -static UDC_DESC_STORAGE usb_str_lgid_desc_t udc_string_desc_languageid = { - .desc.bLength = sizeof(usb_str_lgid_desc_t), - .desc.bDescriptorType = USB_DT_STRING, - .string = {LE16(USB_LANGID_EN_US)} -}; - -/** - * \brief USB device manufacture name storage - * String is allocated only if USB_DEVICE_MANUFACTURE_NAME is declared - * by usb application configuration - */ -#ifdef USB_DEVICE_MANUFACTURE_NAME -static uint8_t udc_string_manufacturer_name[] = USB_DEVICE_MANUFACTURE_NAME; -# define USB_DEVICE_MANUFACTURE_NAME_SIZE \ - (sizeof(udc_string_manufacturer_name)-1) -#else -# define USB_DEVICE_MANUFACTURE_NAME_SIZE 0 -#endif - -/** - * \brief USB device product name storage - * String is allocated only if USB_DEVICE_PRODUCT_NAME is declared - * by usb application configuration - */ -#ifdef USB_DEVICE_PRODUCT_NAME -static uint8_t udc_string_product_name[] = USB_DEVICE_PRODUCT_NAME; -# define USB_DEVICE_PRODUCT_NAME_SIZE (sizeof(udc_string_product_name)-1) -#else -# define USB_DEVICE_PRODUCT_NAME_SIZE 0 -#endif - -/** - * \brief Get USB device serial number - * - * Use the define USB_DEVICE_SERIAL_NAME to set static serial number. - * - * For dynamic serial number set the define USB_DEVICE_GET_SERIAL_NAME_POINTER - * to a suitable pointer. This will also require the serial number length - * define USB_DEVICE_GET_SERIAL_NAME_LENGTH. - */ -#if defined USB_DEVICE_GET_SERIAL_NAME_POINTER - static const uint8_t *udc_get_string_serial_name(void) - { - return (const uint8_t *)USB_DEVICE_GET_SERIAL_NAME_POINTER; - } -# define USB_DEVICE_SERIAL_NAME_SIZE \ - USB_DEVICE_GET_SERIAL_NAME_LENGTH -#elif defined USB_DEVICE_SERIAL_NAME - static const uint8_t *udc_get_string_serial_name(void) - { - return (const uint8_t *)USB_DEVICE_SERIAL_NAME; - } -# define USB_DEVICE_SERIAL_NAME_SIZE \ - (sizeof(USB_DEVICE_SERIAL_NAME)-1) -#else -# define USB_DEVICE_SERIAL_NAME_SIZE 0 -#endif - -/** - * \brief USB device string descriptor - * Structure used to transfer ASCII strings to USB String descriptor structure. - */ -struct udc_string_desc_t { - usb_str_desc_t header; - le16_t string[Max(Max(USB_DEVICE_MANUFACTURE_NAME_SIZE, \ - USB_DEVICE_PRODUCT_NAME_SIZE), USB_DEVICE_SERIAL_NAME_SIZE)]; -}; -COMPILER_WORD_ALIGNED -static UDC_DESC_STORAGE struct udc_string_desc_t udc_string_desc = { - .header.bDescriptorType = USB_DT_STRING -}; -//! @} - -usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void) -{ - return udc_ptr_iface; -} - -/** - * \brief Returns a value to check the end of USB Configuration descriptor - * - * \return address after the last byte of USB Configuration descriptor - */ -static usb_conf_desc_t UDC_DESC_STORAGE *udc_get_eof_conf(void) -{ - return (UDC_DESC_STORAGE usb_conf_desc_t *) ((uint8_t *) - udc_ptr_conf->desc + - le16_to_cpu(udc_ptr_conf->desc->wTotalLength)); -} - -#if (0!=USB_DEVICE_MAX_EP) -/** - * \brief Search specific descriptor in global interface descriptor - * - * \param desc Address of interface descriptor - * or previous specific descriptor found - * \param desc_id Descriptor ID to search - * - * \return address of specific descriptor found - * \return NULL if it is the end of global interface descriptor - */ -static usb_conf_desc_t UDC_DESC_STORAGE *udc_next_desc_in_iface(usb_conf_desc_t - UDC_DESC_STORAGE * desc, uint8_t desc_id) -{ - usb_conf_desc_t UDC_DESC_STORAGE *ptr_eof_desc; - - ptr_eof_desc = udc_get_eof_conf(); - // Go to next descriptor - desc = (UDC_DESC_STORAGE usb_conf_desc_t *) ((uint8_t *) desc + - desc->bLength); - // Check the end of configuration descriptor - while (ptr_eof_desc > desc) { - // If new interface descriptor is found, - // then it is the end of the current global interface descriptor - if (USB_DT_INTERFACE == desc->bDescriptorType) { - break; // End of global interface descriptor - } - if (desc_id == desc->bDescriptorType) { - return desc; // Specific descriptor found - } - // Go to next descriptor - desc = (UDC_DESC_STORAGE usb_conf_desc_t *) ((uint8_t *) desc + - desc->bLength); - } - return NULL; // No specific descriptor found -} -#endif - -/** - * \brief Search an interface descriptor - * This routine updates the internal pointer udc_ptr_iface. - * - * \param iface_num Interface number to find in Configuration Descriptor - * \param setting_num Setting number of interface to find - * - * \return 1 if found or 0 if not found - */ -static bool udc_update_iface_desc(uint8_t iface_num, uint8_t setting_num) -{ - usb_conf_desc_t UDC_DESC_STORAGE *ptr_end_desc; - - if (0 == udc_num_configuration) { - return false; - } - - if (iface_num >= udc_ptr_conf->desc->bNumInterfaces) { - return false; - } - - // Start at the beginning of configuration descriptor - udc_ptr_iface = (UDC_DESC_STORAGE usb_iface_desc_t *) - udc_ptr_conf->desc; - - // Check the end of configuration descriptor - ptr_end_desc = udc_get_eof_conf(); - while (ptr_end_desc > - (UDC_DESC_STORAGE usb_conf_desc_t *) udc_ptr_iface) { - if (USB_DT_INTERFACE == udc_ptr_iface->bDescriptorType) { - // A interface descriptor is found - // Check interface and alternate setting number - if ((iface_num == udc_ptr_iface->bInterfaceNumber) && - (setting_num == - udc_ptr_iface->bAlternateSetting)) { - return true; // Interface found - } - } - // Go to next descriptor - udc_ptr_iface = (UDC_DESC_STORAGE usb_iface_desc_t *) ( - (uint8_t *) udc_ptr_iface + - udc_ptr_iface->bLength); - } - return false; // Interface not found -} - -/** - * \brief Disables an usb device interface (UDI) - * This routine call the UDI corresponding to interface number - * - * \param iface_num Interface number to disable - * - * \return 1 if it is done or 0 if interface is not found - */ -static bool udc_iface_disable(uint8_t iface_num) -{ - udi_api_t UDC_DESC_STORAGE *udi_api; - - // Select first alternate setting of the interface - // to update udc_ptr_iface before call iface->getsetting() - if (!udc_update_iface_desc(iface_num, 0)) { - return false; - } - - // Select the interface with the current alternate setting - udi_api = udc_ptr_conf->udi_apis[iface_num]; - -#if (0!=USB_DEVICE_MAX_EP) - if (!udc_update_iface_desc(iface_num, udi_api->getsetting())) { - return false; - } - - // Start at the beginning of interface descriptor - { - usb_ep_desc_t UDC_DESC_STORAGE *ep_desc; - ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *) udc_ptr_iface; - while (1) { - // Search Endpoint descriptor included in global interface descriptor - ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *) - udc_next_desc_in_iface((UDC_DESC_STORAGE - usb_conf_desc_t *) - ep_desc, USB_DT_ENDPOINT); - if (NULL == ep_desc) { - break; - } - // Free the endpoint used by the interface - udd_ep_free(ep_desc->bEndpointAddress); - } - } -#endif - - // Disable interface - udi_api->disable(); - return true; -} - -/** - * \brief Enables an usb device interface (UDI) - * This routine calls the UDI corresponding - * to the interface and setting number. - * - * \param iface_num Interface number to enable - * \param setting_num Setting number to enable - * - * \return 1 if it is done or 0 if interface is not found - */ -static bool udc_iface_enable(uint8_t iface_num, uint8_t setting_num) -{ - // Select the interface descriptor - if (!udc_update_iface_desc(iface_num, setting_num)) { - return false; - } - -#if (0!=USB_DEVICE_MAX_EP) - usb_ep_desc_t UDC_DESC_STORAGE *ep_desc; - - // Start at the beginning of the global interface descriptor - ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *) udc_ptr_iface; - while (1) { - // Search Endpoint descriptor included in the global interface descriptor - ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *) - udc_next_desc_in_iface((UDC_DESC_STORAGE - usb_conf_desc_t *) ep_desc, - USB_DT_ENDPOINT); - if (NULL == ep_desc) - break; - // Alloc the endpoint used by the interface - if (!udd_ep_alloc(ep_desc->bEndpointAddress, - ep_desc->bmAttributes, - le16_to_cpu - (ep_desc->wMaxPacketSize))) { - return false; - } - } -#endif - // Enable the interface - return udc_ptr_conf->udi_apis[iface_num]->enable(); -} - -/*! \brief Start the USB Device stack - */ -void udc_start(void) -{ - udd_enable(); -} - -/*! \brief Stop the USB Device stack - */ -void udc_stop(void) -{ - udd_disable(); -} - -/** - * \brief Reset the current configuration of the USB device, - * This routines can be called by UDD when a RESET on the USB line occurs. - */ -void udc_reset(void) -{ - uint8_t iface_num; - - if (udc_num_configuration) { - for (iface_num = 0; - iface_num < udc_ptr_conf->desc->bNumInterfaces; - iface_num++) { - udc_iface_disable(iface_num); - } - } - udc_num_configuration = 0; -#if (USB_CONFIG_ATTR_REMOTE_WAKEUP \ - == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP)) - if (CPU_TO_LE16(USB_DEV_STATUS_REMOTEWAKEUP) & udc_device_status) { - // Remote wakeup is enabled then disable it - UDC_REMOTEWAKEUP_DISABLE(); - } -#endif - udc_device_status = -#if (USB_DEVICE_ATTR & USB_CONFIG_ATTR_SELF_POWERED) - CPU_TO_LE16(USB_DEV_STATUS_SELF_POWERED); -#else - CPU_TO_LE16(USB_DEV_STATUS_BUS_POWERED); -#endif -} - -void udc_sof_notify(void) -{ - uint8_t iface_num; - - if (udc_num_configuration) { - for (iface_num = 0; - iface_num < udc_ptr_conf->desc->bNumInterfaces; - iface_num++) { - if (udc_ptr_conf->udi_apis[iface_num]->sof_notify != NULL) { - udc_ptr_conf->udi_apis[iface_num]->sof_notify(); - } - } - } -} - -/** - * \brief Standard device request to get device status - * - * \return true if success - */ -static bool udc_req_std_dev_get_status(void) -{ - if (udd_g_ctrlreq.req.wLength != sizeof(udc_device_status)) { - return false; - } - - udd_set_setup_payload( (uint8_t *) & udc_device_status, - sizeof(udc_device_status)); - return true; -} - -#if (0!=USB_DEVICE_MAX_EP) -/** - * \brief Standard endpoint request to get endpoint status - * - * \return true if success - */ -static bool udc_req_std_ep_get_status(void) -{ - static le16_t udc_ep_status; - - if (udd_g_ctrlreq.req.wLength != sizeof(udc_ep_status)) { - return false; - } - - udc_ep_status = udd_ep_is_halted(udd_g_ctrlreq.req. - wIndex & 0xFF) ? CPU_TO_LE16(USB_EP_STATUS_HALTED) : 0; - - udd_set_setup_payload( (uint8_t *) & udc_ep_status, - sizeof(udc_ep_status)); - return true; -} -#endif - -/** - * \brief Standard device request to change device status - * - * \return true if success - */ -static bool udc_req_std_dev_clear_feature(void) -{ - if (udd_g_ctrlreq.req.wLength) { - return false; - } - - if (udd_g_ctrlreq.req.wValue == USB_DEV_FEATURE_REMOTE_WAKEUP) { - udc_device_status &= CPU_TO_LE16(~USB_DEV_STATUS_REMOTEWAKEUP); -#if (USB_CONFIG_ATTR_REMOTE_WAKEUP \ - == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP)) - UDC_REMOTEWAKEUP_DISABLE(); -#endif - return true; - } - return false; -} - -#if (0!=USB_DEVICE_MAX_EP) -/** - * \brief Standard endpoint request to clear endpoint feature - * - * \return true if success - */ -static bool udc_req_std_ep_clear_feature(void) -{ - if (udd_g_ctrlreq.req.wLength) { - return false; - } - - if (udd_g_ctrlreq.req.wValue == USB_EP_FEATURE_HALT) { - return udd_ep_clear_halt(udd_g_ctrlreq.req.wIndex & 0xFF); - } - return false; -} -#endif - -/** - * \brief Standard device request to set a feature - * - * \return true if success - */ -static bool udc_req_std_dev_set_feature(void) -{ - if (udd_g_ctrlreq.req.wLength) { - return false; - } - - switch (udd_g_ctrlreq.req.wValue) { - - case USB_DEV_FEATURE_REMOTE_WAKEUP: -#if (USB_CONFIG_ATTR_REMOTE_WAKEUP \ - == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP)) - udc_device_status |= CPU_TO_LE16(USB_DEV_STATUS_REMOTEWAKEUP); - UDC_REMOTEWAKEUP_ENABLE(); - return true; -#else - return false; -#endif - -#ifdef USB_DEVICE_HS_SUPPORT - case USB_DEV_FEATURE_TEST_MODE: - if (!udd_is_high_speed()) { - break; - } - if (udd_g_ctrlreq.req.wIndex & 0xff) { - break; - } - // Unconfigure the device, terminating all ongoing requests - udc_reset(); - switch ((udd_g_ctrlreq.req.wIndex >> 8) & 0xFF) { - case USB_DEV_TEST_MODE_J: - udd_g_ctrlreq.callback = udd_test_mode_j; - return true; - - case USB_DEV_TEST_MODE_K: - udd_g_ctrlreq.callback = udd_test_mode_k; - return true; - - case USB_DEV_TEST_MODE_SE0_NAK: - udd_g_ctrlreq.callback = udd_test_mode_se0_nak; - return true; - - case USB_DEV_TEST_MODE_PACKET: - udd_g_ctrlreq.callback = udd_test_mode_packet; - return true; - - case USB_DEV_TEST_MODE_FORCE_ENABLE: // Only for downstream facing hub ports - default: - break; - } - break; -#endif - default: - break; - } - return false; -} - -/** - * \brief Standard endpoint request to halt an endpoint - * - * \return true if success - */ -#if (0!=USB_DEVICE_MAX_EP) -static bool udc_req_std_epset_feature(void) -{ - if (udd_g_ctrlreq.req.wLength) { - return false; - } - if (udd_g_ctrlreq.req.wValue == USB_EP_FEATURE_HALT) { - return udd_ep_set_halt(udd_g_ctrlreq.req.wIndex & 0xFF); - } - return false; -} -#endif - -/** - * \brief Change the address of device - * Callback called at the end of request set address - */ -static void udc_valid_address(void) -{ - udd_set_address(udd_g_ctrlreq.req.wValue & 0x7F); -} - -/** - * \brief Standard device request to set device address - * - * \return true if success - */ -static bool udc_req_std_dev_set_address(void) -{ - if (udd_g_ctrlreq.req.wLength) { - return false; - } - - // The address must be changed at the end of setup request after the handshake - // then we use a callback to change address - udd_g_ctrlreq.callback = udc_valid_address; - return true; -} - -/** - * \brief Standard device request to get device string descriptor - * - * \return true if success - */ -static bool udc_req_std_dev_get_str_desc(void) -{ - uint8_t i; - const uint8_t *str; - uint8_t str_length = 0; - - // Link payload pointer to the string corresponding at request - switch (udd_g_ctrlreq.req.wValue & 0xff) { - case 0: - udd_set_setup_payload((uint8_t *) &udc_string_desc_languageid, - sizeof(udc_string_desc_languageid)); - break; - -#ifdef USB_DEVICE_MANUFACTURE_NAME - case 1: - str_length = USB_DEVICE_MANUFACTURE_NAME_SIZE; - str = udc_string_manufacturer_name; - break; -#endif -#ifdef USB_DEVICE_PRODUCT_NAME - case 2: - str_length = USB_DEVICE_PRODUCT_NAME_SIZE; - str = udc_string_product_name; - break; -#endif -#if defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER - case 3: - str_length = USB_DEVICE_SERIAL_NAME_SIZE; - str = udc_get_string_serial_name(); - break; -#endif - default: -#ifdef UDC_GET_EXTRA_STRING - if (UDC_GET_EXTRA_STRING()) { - break; - } -#endif - return false; - } - - if (str_length) { - for(i = 0; i < str_length; i++) { - udc_string_desc.string[i] = cpu_to_le16((le16_t)str[i]); - } - - udc_string_desc.header.bLength = 2 + (str_length) * 2; - udd_set_setup_payload( - (uint8_t *) &udc_string_desc, - udc_string_desc.header.bLength); - } - - return true; -} - -/** - * \brief Standard device request to get descriptors about USB device - * - * \return true if success - */ -static bool udc_req_std_dev_get_descriptor(void) -{ - uint8_t conf_num; - - conf_num = udd_g_ctrlreq.req.wValue & 0xff; - - // Check descriptor ID - switch ((uint8_t) (udd_g_ctrlreq.req.wValue >> 8)) { - case USB_DT_DEVICE: - // Device descriptor requested -#ifdef USB_DEVICE_HS_SUPPORT - if (!udd_is_high_speed()) { - udd_set_setup_payload( - (uint8_t *) udc_config.confdev_hs, - udc_config.confdev_hs->bLength); - } else -#endif - { - udd_set_setup_payload( - (uint8_t *) udc_config.confdev_lsfs, - udc_config.confdev_lsfs->bLength); - } - break; - - case USB_DT_CONFIGURATION: - // Configuration descriptor requested -#ifdef USB_DEVICE_HS_SUPPORT - if (udd_is_high_speed()) { - // HS descriptor - if (conf_num >= udc_config.confdev_hs-> - bNumConfigurations) { - return false; - } - udd_set_setup_payload( - (uint8_t *)udc_config.conf_hs[conf_num].desc, - le16_to_cpu(udc_config.conf_hs[conf_num].desc->wTotalLength)); - } else -#endif - { - // FS descriptor - if (conf_num >= udc_config.confdev_lsfs-> - bNumConfigurations) { - return false; - } - udd_set_setup_payload( - (uint8_t *)udc_config.conf_lsfs[conf_num].desc, - le16_to_cpu(udc_config.conf_lsfs[conf_num].desc->wTotalLength)); - } - ((usb_conf_desc_t *) udd_g_ctrlreq.payload)->bDescriptorType = - USB_DT_CONFIGURATION; - break; - -#ifdef USB_DEVICE_HS_SUPPORT - case USB_DT_DEVICE_QUALIFIER: - // Device qualifier descriptor requested - udd_set_setup_payload( (uint8_t *) udc_config.qualifier, - udc_config.qualifier->bLength); - break; - - case USB_DT_OTHER_SPEED_CONFIGURATION: - // Other configuration descriptor requested - if (!udd_is_high_speed()) { - // HS descriptor - if (conf_num >= udc_config.confdev_hs-> - bNumConfigurations) { - return false; - } - udd_set_setup_payload( - (uint8_t *)udc_config.conf_hs[conf_num].desc, - le16_to_cpu(udc_config.conf_hs[conf_num].desc->wTotalLength)); - } else { - // FS descriptor - if (conf_num >= udc_config.confdev_lsfs-> - bNumConfigurations) { - return false; - } - udd_set_setup_payload( - (uint8_t *)udc_config.conf_lsfs[conf_num].desc, - le16_to_cpu(udc_config.conf_lsfs[conf_num].desc->wTotalLength)); - } - ((usb_conf_desc_t *) udd_g_ctrlreq.payload)->bDescriptorType = - USB_DT_OTHER_SPEED_CONFIGURATION; - break; -#endif - - case USB_DT_STRING: - // String descriptor requested - if (!udc_req_std_dev_get_str_desc()) { - return false; - } - break; - - default: - // Unknown descriptor requested - return false; - } - // if the descriptor is larger than length requested, then reduce it - if (udd_g_ctrlreq.req.wLength < udd_g_ctrlreq.payload_size) { - udd_g_ctrlreq.payload_size = udd_g_ctrlreq.req.wLength; - } - return true; -} - -/** - * \brief Standard device request to get configuration number - * - * \return true if success - */ -static bool udc_req_std_dev_get_configuration(void) -{ - if (udd_g_ctrlreq.req.wLength != 1) { - return false; - } - - udd_set_setup_payload(&udc_num_configuration,1); - return true; -} - -/** - * \brief Standard device request to enable a configuration - * - * \return true if success - */ -static bool udc_req_std_dev_set_configuration(void) -{ - uint8_t iface_num; - - // Check request length - if (udd_g_ctrlreq.req.wLength) { - return false; - } - // Authorize configuration only if the address is valid - if (!udd_getaddress()) { - return false; - } - // Check the configuration number requested -#ifdef USB_DEVICE_HS_SUPPORT - if (udd_is_high_speed()) { - // HS descriptor - if ((udd_g_ctrlreq.req.wValue & 0xFF) > - udc_config.confdev_hs->bNumConfigurations) { - return false; - } - } else -#endif - { - // FS descriptor - if ((udd_g_ctrlreq.req.wValue & 0xFF) > - udc_config.confdev_lsfs->bNumConfigurations) { - return false; - } - } - - // Reset current configuration - udc_reset(); - - // Enable new configuration - udc_num_configuration = udd_g_ctrlreq.req.wValue & 0xFF; - if (udc_num_configuration == 0) { - return true; // Default empty configuration requested - } - // Update pointer of the configuration descriptor -#ifdef USB_DEVICE_HS_SUPPORT - if (udd_is_high_speed()) { - // HS descriptor - udc_ptr_conf = &udc_config.conf_hs[udc_num_configuration - 1]; - } else -#endif - { - // FS descriptor - udc_ptr_conf = &udc_config.conf_lsfs[udc_num_configuration - 1]; - } - // Enable all interfaces of the selected configuration - for (iface_num = 0; iface_num < udc_ptr_conf->desc->bNumInterfaces; - iface_num++) { - if (!udc_iface_enable(iface_num, 0)) { - return false; - } - } - return true; -} - -/** - * \brief Standard interface request - * to get the alternate setting number of an interface - * - * \return true if success - */ -static bool udc_req_std_iface_get_setting(void) -{ - static uint8_t udc_iface_setting; - uint8_t iface_num; - udi_api_t UDC_DESC_STORAGE *udi_api; - - if (udd_g_ctrlreq.req.wLength != 1) { - return false; // Error in request - } - if (!udc_num_configuration) { - return false; // The device is not is configured state yet - } - - // Check the interface number included in the request - iface_num = udd_g_ctrlreq.req.wIndex & 0xFF; - if (iface_num >= udc_ptr_conf->desc->bNumInterfaces) { - return false; - } - - // Select first alternate setting of the interface to update udc_ptr_iface - // before call iface->getsetting() - if (!udc_update_iface_desc(iface_num, 0)) { - return false; - } - // Get alternate setting from UDI - udi_api = udc_ptr_conf->udi_apis[iface_num]; - udc_iface_setting = udi_api->getsetting(); - - // Link value to payload pointer of request - udd_set_setup_payload(&udc_iface_setting,1); - return true; -} - -/** - * \brief Standard interface request - * to set an alternate setting of an interface - * - * \return true if success - */ -static bool udc_req_std_iface_set_setting(void) -{ - uint8_t iface_num, setting_num; - - if (udd_g_ctrlreq.req.wLength) { - return false; // Error in request - } - if (!udc_num_configuration) { - return false; // The device is not is configured state yet - } - - iface_num = udd_g_ctrlreq.req.wIndex & 0xFF; - setting_num = udd_g_ctrlreq.req.wValue & 0xFF; - - // Disable current setting - if (!udc_iface_disable(iface_num)) { - return false; - } - - // Enable new setting - return udc_iface_enable(iface_num, setting_num); -} - -/** - * \brief Main routine to manage the standard USB SETUP request - * - * \return true if the request is supported - */ -static bool udc_reqstd(void) -{ - if (Udd_setup_is_in()) { - // GET Standard Requests - if (udd_g_ctrlreq.req.wLength == 0) { - return false; // Error for USB host - } - - if (USB_REQ_RECIP_DEVICE == Udd_setup_recipient()) { - // Standard Get Device request - switch (udd_g_ctrlreq.req.bRequest) { - case USB_REQ_GET_STATUS: - return udc_req_std_dev_get_status(); - case USB_REQ_GET_DESCRIPTOR: - return udc_req_std_dev_get_descriptor(); - case USB_REQ_GET_CONFIGURATION: - return udc_req_std_dev_get_configuration(); - default: - break; - } - } - - if (USB_REQ_RECIP_INTERFACE == Udd_setup_recipient()) { - // Standard Get Interface request - switch (udd_g_ctrlreq.req.bRequest) { - case USB_REQ_GET_INTERFACE: - return udc_req_std_iface_get_setting(); - default: - break; - } - } -#if (0!=USB_DEVICE_MAX_EP) - if (USB_REQ_RECIP_ENDPOINT == Udd_setup_recipient()) { - // Standard Get Endpoint request - switch (udd_g_ctrlreq.req.bRequest) { - case USB_REQ_GET_STATUS: - return udc_req_std_ep_get_status(); - default: - break; - } - } -#endif - } else { - // SET Standard Requests - if (USB_REQ_RECIP_DEVICE == Udd_setup_recipient()) { - // Standard Set Device request - switch (udd_g_ctrlreq.req.bRequest) { - case USB_REQ_SET_ADDRESS: - return udc_req_std_dev_set_address(); - case USB_REQ_CLEAR_FEATURE: - return udc_req_std_dev_clear_feature(); - case USB_REQ_SET_FEATURE: - return udc_req_std_dev_set_feature(); - case USB_REQ_SET_CONFIGURATION: - return udc_req_std_dev_set_configuration(); - case USB_REQ_SET_DESCRIPTOR: - /* Not supported (defined as optional by the USB 2.0 spec) */ - break; - default: - break; - } - } - - if (USB_REQ_RECIP_INTERFACE == Udd_setup_recipient()) { - // Standard Set Interface request - switch (udd_g_ctrlreq.req.bRequest) { - case USB_REQ_SET_INTERFACE: - return udc_req_std_iface_set_setting(); - default: - break; - } - } -#if (0!=USB_DEVICE_MAX_EP) - if (USB_REQ_RECIP_ENDPOINT == Udd_setup_recipient()) { - // Standard Set Endpoint request - switch (udd_g_ctrlreq.req.bRequest) { - case USB_REQ_CLEAR_FEATURE: - return udc_req_std_ep_clear_feature(); - case USB_REQ_SET_FEATURE: - return udc_req_std_epset_feature(); - default: - break; - } - } -#endif - } - return false; -} - -/** - * \brief Send the SETUP interface request to UDI - * - * \return true if the request is supported - */ -static bool udc_req_iface(void) -{ - uint8_t iface_num; - udi_api_t UDC_DESC_STORAGE *udi_api; - - if (0 == udc_num_configuration) { - return false; // The device is not is configured state yet - } - // Check interface number - iface_num = udd_g_ctrlreq.req.wIndex & 0xFF; - if (iface_num >= udc_ptr_conf->desc->bNumInterfaces) { - return false; - } - - //* To update udc_ptr_iface with the selected interface in request - // Select first alternate setting of interface to update udc_ptr_iface - // before calling udi_api->getsetting() - if (!udc_update_iface_desc(iface_num, 0)) { - return false; - } - // Select the interface with the current alternate setting - udi_api = udc_ptr_conf->udi_apis[iface_num]; - if (!udc_update_iface_desc(iface_num, udi_api->getsetting())) { - return false; - } - - // Send the SETUP request to the UDI corresponding to the interface number - return udi_api->setup(); -} - -/** - * \brief Main routine to manage the USB SETUP request. - * - * This function parses a USB SETUP request and submits an appropriate - * response back to the host or, in the case of SETUP OUT requests - * with data, sets up a buffer for receiving the data payload. - * - * The main standard requests defined by the USB 2.0 standard are handled - * internally. The interface requests are sent to UDI, and the specific request - * sent to a specific application callback. - * - * \return true if the request is supported, else the request is stalled by UDD - */ -bool udc_process_setup(void) -{ - // By default no data (receive/send) and no callbacks registered - udd_g_ctrlreq.payload_size = 0; - udd_g_ctrlreq.callback = NULL; - udd_g_ctrlreq.over_under_run = NULL; - - if (Udd_setup_is_in()) { - if (udd_g_ctrlreq.req.wLength == 0) { - return false; // Error from USB host - } - } - - // If standard request then try to decode it in UDC - if (Udd_setup_type() == USB_REQ_TYPE_STANDARD) { - if (udc_reqstd()) { - return true; - } - } - - // If interface request then try to decode it in UDI - if (Udd_setup_recipient() == USB_REQ_RECIP_INTERFACE) { - if (udc_req_iface()) { - return true; - } - } - - // Here SETUP request unknown by UDC and UDIs -#ifdef USB_DEVICE_SPECIFIC_REQUEST - // Try to decode it in specific callback - return USB_DEVICE_SPECIFIC_REQUEST(); // Ex: Vendor request,... -#else - return false; -#endif -} - -//! @} diff --git a/DSTAT1/src/asf/common/services/usb/udc/udc.h b/DSTAT1/src/asf/common/services/usb/udc/udc.h deleted file mode 100644 index 488d1d2..0000000 --- a/DSTAT1/src/asf/common/services/usb/udc/udc.h +++ /dev/null @@ -1,242 +0,0 @@ -/** - * \file - * - * \brief Interface of the USB Device Controller (UDC) - * - * Copyright (c) 2009 - 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _UDC_H_ -#define _UDC_H_ - -#include "conf_usb.h" -#include "usb_protocol.h" -#include "udc_desc.h" -#include "udd.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \ingroup usb_device_group - * \defgroup udc_group USB Device Controller (UDC) - * - * The UDC provides a high-level abstraction of the usb device. - * You can use these functions to control the main device state - * (start/attach/wakeup). - * - * \section USB_DEVICE_CONF USB Device Custom configuration - * The following USB Device configuration must be included in the conf_usb.h - * file of the application. - * - * USB_DEVICE_VENDOR_ID (Word)
- * Vendor ID provided by USB org (ATMEL 0x03EB). - * - * USB_DEVICE_PRODUCT_ID (Word)
- * Product ID (Referenced in usb_atmel.h). - * - * USB_DEVICE_MAJOR_VERSION (Byte)
- * Major version of the device - * - * USB_DEVICE_MINOR_VERSION (Byte)
- * Minor version of the device - * - * USB_DEVICE_MANUFACTURE_NAME (string)
- * ASCII name for the manufacture - * - * USB_DEVICE_PRODUCT_NAME (string)
- * ASCII name for the product - * - * USB_DEVICE_SERIAL_NAME (string)
- * ASCII name to enable and set a serial number - * - * USB_DEVICE_POWER (Numeric)
- * (unit mA) Maximum device power - * - * USB_DEVICE_ATTR (Byte)
- * USB attributes available: - * - USB_CONFIG_ATTR_SELF_POWERED - * - USB_CONFIG_ATTR_REMOTE_WAKEUP - * Note: if remote wake enabled then defines remotewakeup callbacks, - * see Table 5-2. External API from UDC - Callback - * - * USB_DEVICE_LOW_SPEED (Only defined)
- * Force the USB Device to run in low speed - * - * USB_DEVICE_HS_SUPPORT (Only defined)
- * Authorize the USB Device to run in high speed - * - * USB_DEVICE_MAX_EP (Byte)
- * Define the maximum endpoint number used by the USB Device.
- * This one is already defined in UDI default configuration. - * Ex: - * - When endpoint control 0x00, endpoint 0x01 and - * endpoint 0x82 is used then USB_DEVICE_MAX_EP=2 - * - When only endpoint control 0x00 is used then USB_DEVICE_MAX_EP=0 - * - When endpoint 0x01 and endpoint 0x81 is used then USB_DEVICE_MAX_EP=1
- * (configuration not possible on USBB interface) - * @{ - */ - -/** - * \brief Authorizes the VBUS event - * - * \return true, if the VBUS monitoring is possible. - * - * \section udc_vbus_monitoring VBus monitoring used cases - * - * The VBus monitoring is used only for USB SELF Power application. - * - * - No custom implementation \n - * // Authorize VBUS monitoring \n - * if (!udc_include_vbus_monitoring()) { \n - * // VBUS monitoring is not available on this product \n - * // thereby VBUS has to be considered as present \n - * // Attach USB Device \n - * udc_attach(); \n - * } \n - * - * - Add custom VBUS monitoring \n - * // Authorize VBUS monitoring \n - * if (!udc_include_vbus_monitoring()) { \n - * // Implement custom VBUS monitoring via GPIO or other \n - * } \n - * Event_VBUS_present() // VBUS interrupt or GPIO interrupt or other \n - * { \n - * // Attach USB Device \n - * udc_attach(); \n - * } \n - * - * - Case of battery charging \n - * Event VBUS present() // VBUS interrupt or GPIO interrupt or .. \n - * { \n - * // Authorize battery charging, but wait key press to start USB. \n - * } \n - * Event Key press() \n - * { \n - * // Stop batteries charging \n - * // Start USB \n - * udc_attach(); \n - * } \n - */ -static inline bool udc_include_vbus_monitoring(void) -{ - return udd_include_vbus_monitoring(); -} - -/*! \brief Start the USB Device stack - */ -void udc_start(void); - -/*! \brief Stop the USB Device stack - */ -void udc_stop(void); - -/** - * \brief Attach device to the bus when possible - * - * \warning If a VBus control is included in driver, - * then it will attach device when an acceptable Vbus - * level from the host is detected. - */ -static inline void udc_attach(void) -{ - udd_attach(); -} - - -/** - * \brief Detaches the device from the bus - * - * The driver must remove pull-up on USB line D- or D+. - */ -static inline void udc_detach(void) -{ - udd_detach(); -} - - -/*! \brief The USB driver sends a resume signal called \e "Upstream Resume" - */ -static inline void udc_wakeup(void) -{ - udd_send_wake_up(); -} - - -/** - * \brief Returns a pointer on the current interface descriptor - * - * \return pointer on the current interface descriptor. - */ -usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void); - -//@} - -/** - * \ingroup usb_group - * \defgroup usb_device_group USB Stack Devices - * - * This module includes USB Stack Device implementation. - * The stack is divided in three parts: - * - USB Device Controller (UDC) provides USB chapter 9 compliance - * - USB Device Interface (UDI) provides USB Class compliance - * - USB Device Driver (UDD) provides USB Driver for each AVR product - - * Many USB Device applications can be implemented on Atmel MCU. - * Atmel provides many application notes for different applications: - * - AVR4900, provides general information about Device Stack - * - AVR4901, explains how to create a new class - * - AVR4902, explains how to create a composite device - * - AVR49xx, all device classes provided in ASF have an application note - * - * A basic USB knowledge is required to understand the USB Device - * Class application notes (HID,MS,CDC,PHDC,...). - * Then, to create an USB device with - * only one class provided by ASF, refer directly to the application note - * corresponding to this USB class. The USB Device application note for - * New Class and Composite is dedicated to advanced USB users. - * - * @{ - */ - -//! @} - -#ifdef __cplusplus -} -#endif -#endif // _UDC_H_ diff --git a/DSTAT1/src/asf/common/services/usb/udc/udc_desc.h b/DSTAT1/src/asf/common/services/usb/udc/udc_desc.h deleted file mode 100644 index 506401b..0000000 --- a/DSTAT1/src/asf/common/services/usb/udc/udc_desc.h +++ /dev/null @@ -1,129 +0,0 @@ -/** - * \file - * - * \brief Common API for USB Device Interface - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _UDC_DESC_H_ -#define _UDC_DESC_H_ - -#include "conf_usb.h" -#include "usb_protocol.h" -#include "udi.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \ingroup udc_group - * \defgroup udc_desc_group USB Device Descriptor - * - * @{ - */ - -/** - * \brief Defines the memory's location of USB descriptors - * - * By default the Descriptor is stored in RAM - * (UDC_DESC_STORAGE is defined empty). - * - * If you have need to free RAM space, - * it is possible to put descriptor in flash in following case: - * - USB driver authorize flash transfer (USBB on UC3 and USB on Mega) - * - USB Device is not high speed (UDC no need to change USB descriptors) - * - * For UC3 application used "const". - * - * For Mega application used "code". - */ -#define UDC_DESC_STORAGE - // Descriptor storage in internal RAM -#if (defined UDC_DATA_USE_HRAM_SUPPORT) -# if defined(__GNUC__) -# define UDC_DATA(x) COMPILER_WORD_ALIGNED __attribute__((__section__(".data_hram0"))) -# define UDC_BSS(x) COMPILER_ALIGNED(x) __attribute__((__section__(".bss_hram0"))) -# elif defined(__ICCAVR32__) -# define UDC_DATA(x) COMPILER_ALIGNED(x) __data32 -# define UDC_BSS(x) COMPILER_ALIGNED(x) __data32 -# endif -#else -# define UDC_DATA(x) COMPILER_ALIGNED(x) -# define UDC_BSS(x) COMPILER_ALIGNED(x) -#endif - - - -/** - * \brief Configuration descriptor and UDI link for one USB speed - */ -typedef struct { - //! USB configuration descriptor - usb_conf_desc_t UDC_DESC_STORAGE *desc; - //! Array of UDI API pointer - udi_api_t UDC_DESC_STORAGE *UDC_DESC_STORAGE * udi_apis; -} udc_config_speed_t; - - -/** - * \brief All information about the USB Device - */ -typedef struct { - //! USB device descriptor for low or full speed - usb_dev_desc_t UDC_DESC_STORAGE *confdev_lsfs; - //! USB configuration descriptor and UDI API pointers for low or full speed - udc_config_speed_t UDC_DESC_STORAGE *conf_lsfs; -#ifdef USB_DEVICE_HS_SUPPORT - //! USB device descriptor for high speed - usb_dev_desc_t UDC_DESC_STORAGE *confdev_hs; - //! USB device qualifier, only use in high speed mode - usb_dev_qual_desc_t UDC_DESC_STORAGE *qualifier; - //! USB configuration descriptor and UDI API pointers for high speed - udc_config_speed_t UDC_DESC_STORAGE *conf_hs; -#endif -} udc_config_t; - -//! Global variables of USB Device Descriptor and UDI links -extern UDC_DESC_STORAGE udc_config_t udc_config; - -//@} - -#ifdef __cplusplus -} -#endif -#endif // _UDC_DESC_H_ diff --git a/DSTAT1/src/asf/common/services/usb/udc/udd.h b/DSTAT1/src/asf/common/services/usb/udc/udd.h deleted file mode 100644 index 53d791a..0000000 --- a/DSTAT1/src/asf/common/services/usb/udc/udd.h +++ /dev/null @@ -1,390 +0,0 @@ -/** - * \file - * - * \brief Common API for USB Device Drivers (UDD) - * - * Copyright (c) 2009 - 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _UDD_H_ -#define _UDD_H_ - -#include "usb_protocol.h" -#include "udc_desc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \ingroup usb_device_group - * \defgroup udd_group USB Device Driver (UDD) - * - * The UDD driver provides a low-level abstraction of the device - * controller hardware. Most events coming from the hardware such as - * interrupts, which may cause the UDD to call into the UDC and UDI. - * - * @{ - */ - -//! \brief Endpoint identifier -typedef uint8_t udd_ep_id_t; - -//! \brief Endpoint transfer status -//! Returned in parameters of callback register via udd_ep_run routine. -typedef enum { - UDD_EP_TRANSFER_OK = 0, - UDD_EP_TRANSFER_ABORT = 1, -} udd_ep_status_t; - -/** - * \brief Global variable to give and record information of the setup request management - * - * This global variable allows to decode and response a setup request. - * It can be updated by udc_process_setup() from UDC or *setup() from UDIs. - */ -typedef struct { - //! Data received in USB SETUP packet - //! Note: The swap of "req.wValues" from uin16_t to le16_t is done by UDD. - usb_setup_req_t req; - - //! Point to buffer to send or fill with data following SETUP packet - uint8_t *payload; - - //! Size of buffer to send or fill, and content the number of byte transfered - uint16_t payload_size; - - //! Callback called after reception of ZLP from setup request - void (*callback) (void); - - //! Callback called when the buffer given (.payload) is full or empty. - //! This one return false to abort data transfer, or true with a new buffer in .payload. - bool(*over_under_run) (void); -} udd_ctrl_request_t; -extern udd_ctrl_request_t udd_g_ctrlreq; - -//! Return true if the setup request \a udd_g_ctrlreq indicates IN data transfer -#define Udd_setup_is_in() \ - (USB_REQ_DIR_IN == (udd_g_ctrlreq.req.bmRequestType & USB_REQ_DIR_MASK)) - -//! Return true if the setup request \a udd_g_ctrlreq indicates OUT data transfer -#define Udd_setup_is_out() \ - (USB_REQ_DIR_OUT == (udd_g_ctrlreq.req.bmRequestType & USB_REQ_DIR_MASK)) - -//! Return the type of the SETUP request \a udd_g_ctrlreq. \see usb_reqtype. -#define Udd_setup_type() \ - (udd_g_ctrlreq.req.bmRequestType & USB_REQ_TYPE_MASK) - -//! Return the recipient of the SETUP request \a udd_g_ctrlreq. \see usb_recipient -#define Udd_setup_recipient() \ - (udd_g_ctrlreq.req.bmRequestType & USB_REQ_RECIP_MASK) - -/** - * \brief End of halt callback function type. - * Registered by routine udd_ep_wait_stall_clear() - * Callback called when endpoint stall is cleared. - */ -typedef void (*udd_callback_halt_cleared_t) (void); - -/** - * \brief End of transfer callback function type. - * Registered by routine udd_ep_run() - * Callback called by USB interrupt after data transfer or abort (reset,...). - * - * \param status UDD_EP_TRANSFER_OK, if transfer is complete - * \param status UDD_EP_TRANSFER_ABORT, if transfer is aborted - * \param n number of data transfered - */ -typedef void (*udd_callback_trans_t) (udd_ep_status_t status, - iram_size_t nb_transfered); - -/** - * \brief Authorizes the VBUS event - * - * \return true, if the VBUS monitoring is possible. - */ -bool udd_include_vbus_monitoring(void); - -/** - * \brief Enables the USB Device mode - */ -void udd_enable(void); - -/** - * \brief Disables the USB Device mode - */ -void udd_disable(void); - -/** - * \brief Attach device to the bus when possible - * - * \warning If a VBus control is included in driver, - * then it will attach device when an acceptable Vbus - * level from the host is detected. - */ -void udd_attach(void); - -/** - * \brief Detaches the device from the bus - * - * The driver must remove pull-up on USB line D- or D+. - */ -void udd_detach(void); - -/** - * \brief Test whether the USB Device Controller is running at high - * speed or not. - * - * \return \c true if the Device is running at high speed mode, otherwise \c false. - */ -bool udd_is_high_speed(void); - -/** - * \brief Changes the USB address of device - * - * \param address New USB address - */ -void udd_set_address(uint8_t address); - -/** - * \brief Returns the USB address of device - * - * \return USB address - */ -uint8_t udd_getaddress(void); - -/** - * \brief Returns the current start of frame number - * - * \return current start of frame number. - */ -uint16_t udd_get_frame_number(void); - -/** - * \brief Returns the current micro start of frame number - * - * \return current micro start of frame number required in high speed mode. - */ -uint16_t udd_get_micro_frame_number(void); - -/*! \brief The USB driver sends a resume signal called Upstream Resume - */ -void udd_send_wake_up(void); - -/** - * \brief Load setup payload - * - * \param payload Pointer on payload - * \param payload_size Size of payload - */ -void udd_set_setup_payload( uint8_t *payload, uint16_t payload_size ); - - -/** - * \name Endpoint Management - * - * The following functions allow drivers to create and remove - * endpoints, as well as set, clear and query their "halted" and - * "wedged" states. - */ -//@{ - -#if (USB_DEVICE_MAX_EP != 0) - -/** - * \brief Configures and enables an endpoint - * - * \param ep Endpoint number including direction (USB_EP_DIR_IN/USB_EP_DIR_OUT). - * \param bmAttributes Attributes of endpoint declared in the descriptor. - * \param MaxEndpointSize Endpoint maximum size - * - * \return \c 1 if the endpoint is enabled, otherwise \c 0. - */ -bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes, - uint16_t MaxEndpointSize); - -/** - * \brief Disables an endpoint - * - * \param ep Endpoint number including direction (USB_EP_DIR_IN/USB_EP_DIR_OUT). - */ -void udd_ep_free(udd_ep_id_t ep); - -/** - * \brief Check if the endpoint \a ep is halted. - * - * \param ep The ID of the endpoint to check. - * - * \return \c 1 if \a ep is halted, otherwise \c 0. - */ -bool udd_ep_is_halted(udd_ep_id_t ep); - -/** - * \brief Set the halted state of the endpoint \a ep - * - * After calling this function, any transaction on \a ep will result - * in a STALL handshake being sent. Any pending transactions will be - * performed first, however. - * - * \param ep The ID of the endpoint to be halted - * - * \return \c 1 if \a ep is halted, otherwise \c 0. - */ -bool udd_ep_set_halt(udd_ep_id_t ep); - -/** - * \brief Clear the halted state of the endpoint \a ep - * - * After calling this function, any transaction on \a ep will - * be handled normally, i.e. a STALL handshake will not be sent, and - * the data toggle sequence will start at DATA0. - * - * \param ep The ID of the endpoint to be un-halted - * - * \return \c 1 if function was successfully done, otherwise \c 0. - */ -bool udd_ep_clear_halt(udd_ep_id_t ep); - -/** - * \brief Registers a callback to call when endpoint halt is cleared - * - * \param ep The ID of the endpoint to use - * \param callback NULL or function to call when endpoint halt is cleared - * - * \warning if the endpoint is not halted then the \a callback is called immediately. - * - * \return \c 1 if the register is accepted, otherwise \c 0. - */ -bool udd_ep_wait_stall_clear(udd_ep_id_t ep, - udd_callback_halt_cleared_t callback); - -/** - * \brief Allows to receive or send data on an endpoint - * - * The driver uses a specific DMA USB to transfer data - * from internal RAM to endpoint, if this one is available. - * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called. - * The \a callback returns the transfer status and eventually the number of byte transfered. - * Note: The control endpoint is not authorized. - * - * \param ep The ID of the endpoint to use - * \param b_shortpacket Enabled automatic short packet - * \param buf Buffer on Internal RAM to send or fill. - * It must be align, then use COMPILER_WORD_ALIGNED. - * \param buf_size Buffer size to send or fill - * \param callback NULL or function to call at the end of transfer - * - * \warning About \a b_shortpacket, for IN endpoint it means that a short packet - * (or a Zero Length Packet) will be sent to the USB line to properly close the usb - * transfer at the end of the data transfer. - * For Bulk and Interrupt OUT endpoint, it will automatically stop the transfer - * at the end of the data transfer (received short packet). - * - * \return \c 1 if function was successfully done, otherwise \c 0. - */ -bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, - uint8_t * buf, iram_size_t buf_size, - udd_callback_trans_t callback); -/** - * \brief Aborts transfer on going on endpoint - * - * If a transfer is on going, then it is stopped and - * the callback registered is called to signal the end of transfer. - * Note: The control endpoint is not authorized. - * - * \param ep Endpoint to abort - */ -void udd_ep_abort(udd_ep_id_t ep); - -#endif - -//@} - - -/** - * \name High speed test mode management - * - * The following functions allow the device to jump to a specific test mode required in high speed mode. - */ -//@{ -void udd_test_mode_j(void); -void udd_test_mode_k(void); -void udd_test_mode_se0_nak(void); -void udd_test_mode_packet(void); -//@} - - -/** - * \name UDC callbacks to provide for UDD - * - * The following callbacks are used by UDD. - */ -//@{ - -/** - * \brief Decodes and manages a setup request - * - * The driver call it when a SETUP packet is received. - * The \c udd_g_ctrlreq contains the data of SETUP packet. - * If this callback accepts the setup request then it must - * return \c 1 and eventually update \c udd_g_ctrlreq to send or receive data. - * - * \return \c 1 if the request is accepted, otherwise \c 0. - */ -extern bool udc_process_setup(void); - -/** - * \brief Reset the UDC - * - * The UDC must reset all configuration. - */ -extern void udc_reset(void); - -/** - * \brief To signal that a SOF is occured - * - * The UDC must send the signal to all UDIs enabled - */ -extern void udc_sof_notify(void); - -//@} - -//@} - -#ifdef __cplusplus -} -#endif -#endif // _UDD_H_ diff --git a/DSTAT1/src/asf/common/services/usb/udc/udi.h b/DSTAT1/src/asf/common/services/usb/udc/udi.h deleted file mode 100644 index 81f3870..0000000 --- a/DSTAT1/src/asf/common/services/usb/udc/udi.h +++ /dev/null @@ -1,128 +0,0 @@ -/** - * \file - * - * \brief Common API for USB Device Interface - * - * Copyright (c) 2009 - 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _UDI_H_ -#define _UDI_H_ - -#include "conf_usb.h" -#include "usb_protocol.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \ingroup usb_device_group - * \defgroup udi_group USB Device Interface (UDI) - * The UDI provides a common API for all classes, - * and this is used by UDC for the main control of USB Device interface. - * @{ - */ - -/** - * \brief UDI API. - * - * The callbacks within this structure are called only by - * USB Device Controller (UDC) - * - * The udc_get_interface_desc() can be use by UDI to know the interface descriptor - * selected by UDC. - */ -typedef struct { - /** - * \brief Enable the interface. - * - * This function is called when the host selects a configuration - * to which this interface belongs through a Set Configuration - * request, and when the host selects an alternate setting of - * this interface through a Set Interface request. - * - * \return \c 1 if function was successfully done, otherwise \c 0. - */ - bool(*enable) (void); - - /** - * \brief Disable the interface. - * - * This function is called when this interface is currently - * active, and - * - the host selects any configuration through a Set - * Configuration request, or - * - the host issues a USB reset, or - * - the device is detached from the host (i.e. Vbus is no - * longer present) - */ - void (*disable) (void); - - /** - * \brief Handle a control request directed at an interface. - * - * This function is called when this interface is currently - * active and the host sends a SETUP request - * with this interface as the recipient. - * - * Use udd_g_ctrlreq to decode and response to SETUP request. - * - * \return \c 1 if this interface supports the SETUP request, otherwise \c 0. - */ - bool(*setup) (void); - - /** - * \brief Returns the current setting of the selected interface. - * - * This function is called when UDC when know alternate setting of selected interface. - * - * \return alternate setting of selected interface - */ - uint8_t(*getsetting) (void); - - /** - * \brief To signal that a SOF is occured - */ - void(*sof_notify) (void); -} udi_api_t; - -//@} - -#ifdef __cplusplus -} -#endif -#endif // _UDI_H_ diff --git a/DSTAT1/src/asf/common/services/usb/usb_atmel.h b/DSTAT1/src/asf/common/services/usb/usb_atmel.h deleted file mode 100644 index e9db074..0000000 --- a/DSTAT1/src/asf/common/services/usb/usb_atmel.h +++ /dev/null @@ -1,180 +0,0 @@ -/** - * \file - * - * \brief All USB VIDs and PIDs from Atmel USB applications - * - * Copyright (c) 2009-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _USB_ATMEL_H_ -#define _USB_ATMEL_H_ - -/** - * \defgroup usb_group USB Stack - * - * This stack includes the USB Device Stack, USB Host Stack and common - * definitions. - * @{ - */ - -//! @} - -/** - * \ingroup usb_group - * \defgroup usb_atmel_ids_group Atmel USB Identifiers - * - * This module defines Atmel PID and VIDs constants. - * - * @{ - */ - -//! \name Vendor Identifier assigned by USB org to ATMEL -#define USB_VID_ATMEL 0x03EB - - -//! \name Product Identifier assigned by ATMEL to AVR applications -//! @{ - -//! \name The range from 2000h to 20FFh is reserved to the old PID for C51, MEGA, and others. -//! @{ -#define USB_PID_ATMEL_MEGA_HIDGENERIC 0x2013 -#define USB_PID_ATMEL_MEGA_HIDKEYBOARD 0x2017 -#define USB_PID_ATMEL_MEGA_CDC 0x2018 -#define USB_PID_ATMEL_MEGA_AUDIO_IN 0x2019 -#define USB_PID_ATMEL_MEGA_MS 0x201A -#define USB_PID_ATMEL_MEGA_AUDIO_IN_OUT 0x201B -#define USB_PID_ATMEL_MEGA_HIDMOUSE 0x201C -#define USB_PID_ATMEL_MEGA_HIDMOUSE_CERTIF_U4 0x201D -#define USB_PID_ATMEL_MEGA_CDC_MULTI 0x201E -#define USB_PID_ATMEL_MEGA_MS_HIDMS_HID_USBKEY 0x2022 -#define USB_PID_ATMEL_MEGA_MS_HIDMS_HID_STK525 0x2023 -#define USB_PID_ATMEL_MEGA_MS_2 0x2029 -#define USB_PID_ATMEL_MEGA_MS_HIDMS 0x202A -#define USB_PID_ATMEL_MEGA_MS_3 0x2032 -#define USB_PID_ATMEL_MEGA_LIBUSB 0x2050 -//! @} - -//! \name The range 2100h to 21FFh is reserved to PIDs for AVR Tools. -//! @{ -#define USB_PID_ATMEL_XPLAINED 0x2122 -//! @} - -//! \name The range 2300h to 23FFh is reserved to PIDs for demo from ASF1.7=> -//! @{ -#define USB_PID_ATMEL_UC3_ENUM 0x2300 -#define USB_PID_ATMEL_UC3_MS 0x2301 -#define USB_PID_ATMEL_UC3_MS_SDRAM_LOADER 0x2302 -#define USB_PID_ATMEL_UC3_EVK1100_CTRLPANEL 0x2303 -#define USB_PID_ATMEL_UC3_HID 0x2304 -#define USB_PID_ATMEL_UC3_EVK1101_CTRLPANEL_HID 0x2305 -#define USB_PID_ATMEL_UC3_EVK1101_CTRLPANEL_HID_MS 0x2306 -#define USB_PID_ATMEL_UC3_CDC 0x2307 -#define USB_PID_ATMEL_UC3_AUDIO_MICRO 0x2308 -#define USB_PID_ATMEL_UC3_CDC_DEBUG 0x2310 // Virtual Com (debug interface) on EVK11xx -#define USB_PID_ATMEL_UC3_AUDIO_SPEAKER_MICRO 0x2311 -#define USB_PID_ATMEL_UC3_CDC_MSC 0x2312 -//! @} - -//! \name The range 2400h to 24FFh is reserved to PIDs for ASF applications -//! @{ -#define USB_PID_ATMEL_AVR_HIDMOUSE 0x2400 -#define USB_PID_ATMEL_AVR_HIDKEYBOARD 0x2401 -#define USB_PID_ATMEL_AVR_HIDGENERIC 0x2402 -#define USB_PID_ATMEL_AVR_MSC 0x2403 -#define USB_PID_ATMEL_AVR_CDC 0x2404 -#define USB_PID_ATMEL_AVR_PHDC 0x2405 -#define USB_PID_ATMEL_AVR_MSC_HIDMOUSE 0x2420 -#define USB_PID_ATMEL_AVR_MSC_HIDS_CDC 0x2421 -#define USB_PID_ATMEL_AVR_MSC_HIDKEYBOARD 0x2422 -#define USB_PID_ATMEL_ASF_VENDOR_CLASS 0x2423 -#define USB_PID_ATMEL_AVR_MSC_CDC 0x2424 -#define USB_PID_ATMEL_AVR_TWO_CDC 0x2425 -#define USB_PID_ATMEL_AVR_XPLAIN_BC_POWERONLY 0x2430 -#define USB_PID_ATMEL_AVR_XPLAIN_BC_TERMINAL 0x2431 -#define USB_PID_ATMEL_AVR_XPLAIN_BC_TOUCH 0x2432 -#define USB_PID_ATMEL_AVR_AUDIO_SPEAKER 0x2433 -#define USB_PID_ATMEL_AVR_XMEGA_B1_XPLAINED 0x2434 -//! @} - -//! \name The range 2F00h to 2FFFh is reserved to official PIDs for AVR bootloaders -//! Note, !!!! don't use this range for demos or examples !!!! -//! @{ -#define USB_PID_ATMEL_DFU_ATXMEGA16C4 0x2FD8 -#define USB_PID_ATMEL_DFU_ATXMEGA32C4 0x2FD9 -#define USB_PID_ATMEL_DFU_ATXMEGA256C3 0x2FDA -#define USB_PID_ATMEL_DFU_ATXMEGA384C3 0x2FDB -#define USB_PID_ATMEL_DFU_ATUCL3_L4 0x2FDC -#define USB_PID_ATMEL_DFU_ATXMEGA64A4U 0x2FDD -#define USB_PID_ATMEL_DFU_ATXMEGA128A4U 0x2FDE - -#define USB_PID_ATMEL_DFU_ATXMEGA64B3 0x2FDF -#define USB_PID_ATMEL_DFU_ATXMEGA128B3 0x2FE0 -#define USB_PID_ATMEL_DFU_ATXMEGA64B1 0x2FE1 -#define USB_PID_ATMEL_DFU_ATXMEGA256A3BU 0x2FE2 -#define USB_PID_ATMEL_DFU_ATXMEGA16A4U 0x2FE3 -#define USB_PID_ATMEL_DFU_ATXMEGA32A4U 0x2FE4 -#define USB_PID_ATMEL_DFU_ATXMEGA64A3U 0x2FE5 -#define USB_PID_ATMEL_DFU_ATXMEGA128A3U 0x2FE6 -#define USB_PID_ATMEL_DFU_ATXMEGA192A3U 0x2FE7 -#define USB_PID_ATMEL_DFU_ATXMEGA64A1U 0x2FE8 -#define USB_PID_ATMEL_DFU_ATUC3D 0x2FE9 -#define USB_PID_ATMEL_DFU_ATXMEGA128B1 0x2FEA -#define USB_PID_ATMEL_DFU_AT32UC3C 0x2FEB -#define USB_PID_ATMEL_DFU_ATXMEGA256A3U 0x2FEC -#define USB_PID_ATMEL_DFU_ATXMEGA128A1U 0x2FED -#define USB_PID_ATMEL_DFU_ATMEGA8U2 0x2FEE -#define USB_PID_ATMEL_DFU_ATMEGA16U2 0x2FEF -#define USB_PID_ATMEL_DFU_ATMEGA32U2 0x2FF0 -#define USB_PID_ATMEL_DFU_AT32UC3A3 0x2FF1 -#define USB_PID_ATMEL_DFU_ATMEGA32U6 0x2FF2 -#define USB_PID_ATMEL_DFU_ATMEGA16U4 0x2FF3 -#define USB_PID_ATMEL_DFU_ATMEGA32U4 0x2FF4 -#define USB_PID_ATMEL_DFU_AT32AP7200 0x2FF5 -#define USB_PID_ATMEL_DFU_AT32UC3B 0x2FF6 -#define USB_PID_ATMEL_DFU_AT90USB82 0x2FF7 -#define USB_PID_ATMEL_DFU_AT32UC3A 0x2FF8 -#define USB_PID_ATMEL_DFU_AT90USB64 0x2FF9 -#define USB_PID_ATMEL_DFU_AT90USB162 0x2FFA -#define USB_PID_ATMEL_DFU_AT90USB128 0x2FFB -// 2FFCh to 2FFFh used by C51 family products -//! @} - -//! @} - -//! @} - - -#endif // _USB_ATMEL_H_ diff --git a/DSTAT1/src/asf/common/services/usb/usb_protocol.h b/DSTAT1/src/asf/common/services/usb/usb_protocol.h deleted file mode 100644 index 61140db..0000000 --- a/DSTAT1/src/asf/common/services/usb/usb_protocol.h +++ /dev/null @@ -1,408 +0,0 @@ -/** - * \file - * - * \brief USB protocol definitions. - * - * This file contains the USB definitions and data structures provided by the - * USB 2.0 specification. - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _USB_PROTOCOL_H_ -#define _USB_PROTOCOL_H_ - -#include "usb_atmel.h" - -/** - * \ingroup usb_group - * \defgroup usb_protocol_group USB Protocol Definitions - * - * This module defines constants and data structures provided by the USB - * 2.0 specification. - * - * @{ - */ - -//! Value for field bcdUSB -#define USB_V2_0 0x0200 //!< USB Specification version 2.00 - -/*! \name Generic definitions (Class, subclass and protocol) - */ -//! @{ -#define NO_CLASS 0x00 -#define CLASS_VENDOR_SPECIFIC 0xFF -#define NO_SUBCLASS 0x00 -#define NO_PROTOCOL 0x00 -//! @} - -//! \name IAD (Interface Association Descriptor) constants -//! @{ -#define CLASS_IAD 0xEF -#define SUB_CLASS_IAD 0x02 -#define PROTOCOL_IAD 0x01 -//! @} - -/** - * \brief USB request data transfer direction (bmRequestType) - */ -#define USB_REQ_DIR_OUT (0<<7) //!< Host to device -#define USB_REQ_DIR_IN (1<<7) //!< Device to host -#define USB_REQ_DIR_MASK (1<<7) //!< Mask - -/** - * \brief USB request types (bmRequestType) - */ -#define USB_REQ_TYPE_STANDARD (0<<5) //!< Standard request -#define USB_REQ_TYPE_CLASS (1<<5) //!< Class-specific request -#define USB_REQ_TYPE_VENDOR (2<<5) //!< Vendor-specific request -#define USB_REQ_TYPE_MASK (3<<5) //!< Mask - -/** - * \brief USB recipient codes (bmRequestType) - */ -#define USB_REQ_RECIP_DEVICE (0<<0) //!< Recipient device -#define USB_REQ_RECIP_INTERFACE (1<<0) //!< Recipient interface -#define USB_REQ_RECIP_ENDPOINT (2<<0) //!< Recipient endpoint -#define USB_REQ_RECIP_OTHER (3<<0) //!< Recipient other -#define USB_REQ_RECIP_MASK (0x1F) //!< Mask - -/** - * \brief Standard USB requests (bRequest) - */ -enum usb_reqid { - USB_REQ_GET_STATUS = 0, - USB_REQ_CLEAR_FEATURE = 1, - USB_REQ_SET_FEATURE = 3, - USB_REQ_SET_ADDRESS = 5, - USB_REQ_GET_DESCRIPTOR = 6, - USB_REQ_SET_DESCRIPTOR = 7, - USB_REQ_GET_CONFIGURATION = 8, - USB_REQ_SET_CONFIGURATION = 9, - USB_REQ_GET_INTERFACE = 10, - USB_REQ_SET_INTERFACE = 11, - USB_REQ_SYNCH_FRAME = 12, -}; - -/** - * \brief Standard USB device status flags - * - */ -enum usb_device_status { - USB_DEV_STATUS_BUS_POWERED = 0, - USB_DEV_STATUS_SELF_POWERED = 1, - USB_DEV_STATUS_REMOTEWAKEUP = 2 -}; - -/** - * \brief Standard USB Interface status flags - * - */ -enum usb_interface_status { - USB_IFACE_STATUS_RESERVED = 0 -}; - -/** - * \brief Standard USB endpoint status flags - * - */ -enum usb_endpoint_status { - USB_EP_STATUS_HALTED = 1, -}; - -/** - * \brief Standard USB device feature flags - * - * \note valid for SetFeature request. - */ -enum usb_device_feature { - USB_DEV_FEATURE_REMOTE_WAKEUP = 1, //!< Remote wakeup enabled - USB_DEV_FEATURE_TEST_MODE = 2, //!< USB test mode - USB_DEV_FEATURE_OTG_B_HNP_ENABLE = 3, - USB_DEV_FEATURE_OTG_A_HNP_SUPPORT = 4, - USB_DEV_FEATURE_OTG_A_ALT_HNP_SUPPORT = 5 -}; - -/** - * \brief Test Mode possible on HS USB device - * - * \note valid for USB_DEV_FEATURE_TEST_MODE request. - */ -enum usb_device_hs_test_mode { - USB_DEV_TEST_MODE_J = 1, - USB_DEV_TEST_MODE_K = 2, - USB_DEV_TEST_MODE_SE0_NAK = 3, - USB_DEV_TEST_MODE_PACKET = 4, - USB_DEV_TEST_MODE_FORCE_ENABLE = 5, -}; - -/** - * \brief Standard USB endpoint feature/status flags - */ -enum usb_endpoint_feature { - USB_EP_FEATURE_HALT = 0, -}; - -/** - * \brief Standard USB Test Mode Selectors - */ -enum usb_test_mode_selector { - USB_TEST_J = 0x01, - USB_TEST_K = 0x02, - USB_TEST_SE0_NAK = 0x03, - USB_TEST_PACKET = 0x04, - USB_TEST_FORCE_ENABLE = 0x05, -}; - -/** - * \brief Standard USB descriptor types - */ -enum usb_descriptor_type { - USB_DT_DEVICE = 1, - USB_DT_CONFIGURATION = 2, - USB_DT_STRING = 3, - USB_DT_INTERFACE = 4, - USB_DT_ENDPOINT = 5, - USB_DT_DEVICE_QUALIFIER = 6, - USB_DT_OTHER_SPEED_CONFIGURATION = 7, - USB_DT_INTERFACE_POWER = 8, - USB_DT_OTG = 9, - USB_DT_IAD = 0x0B, -}; - -/** - * \brief Standard USB endpoint transfer types - */ -enum usb_ep_type { - USB_EP_TYPE_CONTROL = 0x00, - USB_EP_TYPE_ISOCHRONOUS = 0x01, - USB_EP_TYPE_BULK = 0x02, - USB_EP_TYPE_INTERRUPT = 0x03, - USB_EP_TYPE_MASK = 0x03, -}; - -/** - * \brief Standard USB language IDs for string descriptors - */ -enum usb_langid { - USB_LANGID_EN_US = 0x0409, //!< English (United States) -}; - -/** - * \brief Mask selecting the index part of an endpoint address - */ -#define USB_EP_ADDR_MASK 0x0f - -//! \brief USB address identifier -typedef uint8_t usb_add_t; - -/** - * \brief Endpoint transfer direction is IN - */ -#define USB_EP_DIR_IN 0x80 - -/** - * \brief Endpoint transfer direction is OUT - */ -#define USB_EP_DIR_OUT 0x00 - -//! \brief Endpoint identifier -typedef uint8_t usb_ep_t; - -/** - * \brief Maximum length in bytes of a USB descriptor - * - * The maximum length of a USB descriptor is limited by the 8-bit - * bLength field. - */ -#define USB_MAX_DESC_LEN 255 - -/* - * 2-byte alignment requested for all USB structures. - */ -COMPILER_PACK_SET(1); - -/** - * \brief A USB Device SETUP request - * - * The data payload of SETUP packets always follows this structure. - */ -typedef struct { - uint8_t bmRequestType; - uint8_t bRequest; - le16_t wValue; - le16_t wIndex; - le16_t wLength; -} usb_setup_req_t; - -/** - * \brief Standard USB device descriptor stucture - */ -typedef struct { - uint8_t bLength; - uint8_t bDescriptorType; - le16_t bcdUSB; - uint8_t bDeviceClass; - uint8_t bDeviceSubClass; - uint8_t bDeviceProtocol; - uint8_t bMaxPacketSize0; - le16_t idVendor; - le16_t idProduct; - le16_t bcdDevice; - uint8_t iManufacturer; - uint8_t iProduct; - uint8_t iSerialNumber; - uint8_t bNumConfigurations; -} usb_dev_desc_t; - -/** - * \brief Standard USB device qualifier descriptor structure - * - * This descriptor contains information about the device when running at - * the "other" speed (i.e. if the device is currently operating at high - * speed, this descriptor can be used to determine what would change if - * the device was operating at full speed.) - */ -typedef struct { - uint8_t bLength; - uint8_t bDescriptorType; - le16_t bcdUSB; - uint8_t bDeviceClass; - uint8_t bDeviceSubClass; - uint8_t bDeviceProtocol; - uint8_t bMaxPacketSize0; - uint8_t bNumConfigurations; - uint8_t bReserved; -} usb_dev_qual_desc_t; - - -/** - * \brief Standard USB Interface Association Descriptor structure - */ -typedef struct { - uint8_t bLength; //!< size of this descriptor in bytes - uint8_t bDescriptorType; //!< INTERFACE descriptor type - uint8_t bFirstInterface; //!< Number of interface - uint8_t bInterfaceCount; //!< value to select alternate setting - uint8_t bFunctionClass; //!< Class code assigned by the USB - uint8_t bFunctionSubClass;//!< Sub-class code assigned by the USB - uint8_t bFunctionProtocol;//!< Protocol code assigned by the USB - uint8_t iFunction; //!< Index of string descriptor -} usb_association_desc_t; - - -/** - * \brief Standard USB configuration descriptor structure - */ -typedef struct { - uint8_t bLength; - uint8_t bDescriptorType; - le16_t wTotalLength; - uint8_t bNumInterfaces; - uint8_t bConfigurationValue; - uint8_t iConfiguration; - uint8_t bmAttributes; - uint8_t bMaxPower; -} usb_conf_desc_t; - - -#define USB_CONFIG_ATTR_MUST_SET (1 << 7) //!< Must always be set -#define USB_CONFIG_ATTR_BUS_POWERED (0 << 6) //!< Bus-powered -#define USB_CONFIG_ATTR_SELF_POWERED (1 << 6) //!< Self-powered -#define USB_CONFIG_ATTR_REMOTE_WAKEUP (1 << 5) //!< remote wakeup supported - -#define USB_CONFIG_MAX_POWER(ma) (((ma) + 1) / 2) //!< Max power in mA - -/** - * \brief Standard USB association descriptor structure - */ -typedef struct { - uint8_t bLength; //!< Size of this descriptor in bytes - uint8_t bDescriptorType; //!< Interface descriptor type - uint8_t bFirstInterface; //!< Number of interface - uint8_t bInterfaceCount; //!< value to select alternate setting - uint8_t bFunctionClass; //!< Class code assigned by the USB - uint8_t bFunctionSubClass; //!< Sub-class code assigned by the USB - uint8_t bFunctionProtocol; //!< Protocol code assigned by the USB - uint8_t iFunction; //!< Index of string descriptor -} usb_iad_desc_t; - -/** - * \brief Standard USB interface descriptor structure - */ -typedef struct { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bInterfaceNumber; - uint8_t bAlternateSetting; - uint8_t bNumEndpoints; - uint8_t bInterfaceClass; - uint8_t bInterfaceSubClass; - uint8_t bInterfaceProtocol; - uint8_t iInterface; -} usb_iface_desc_t; - -/** - * \brief Standard USB endpoint descriptor stcuture - */ -typedef struct { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bEndpointAddress; - uint8_t bmAttributes; - le16_t wMaxPacketSize; - uint8_t bInterval; -} usb_ep_desc_t; - - -/** - * \brief A standard USB string descriptor sructure - */ -typedef struct { - uint8_t bLength; - uint8_t bDescriptorType; -} usb_str_desc_t; - -typedef struct { - usb_str_desc_t desc; - le16_t string[1]; -} usb_str_lgid_desc_t; - -COMPILER_PACK_RESET(); - -//! @} - -#endif /* _USB_PROTOCOL_H_ */ diff --git a/DSTAT1/src/asf/common/utils/interrupt.h b/DSTAT1/src/asf/common/utils/interrupt.h deleted file mode 100644 index 2221e91..0000000 --- a/DSTAT1/src/asf/common/utils/interrupt.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * \file - * - * \brief Global interrupt management for 8- and 32-bit AVR - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef UTILS_INTERRUPT_H -#define UTILS_INTERRUPT_H - -#include - -#if XMEGA || MEGA -# include "interrupt/interrupt_avr8.h" -#elif UC3 -# include "interrupt/interrupt_avr32.h" -#else -# error Unsupported device. -#endif - -/** - * \defgroup interrupt_group Global interrupt management - * - * This is a driver for global enabling and disabling of interrupts. - * - * @{ - */ - -#if defined(__DOXYGEN__) -/** - * \def CONFIG_INTERRUPT_FORCE_INTC - * \brief Force usage of the ASF INTC driver - * - * Predefine this symbol when preprocessing to force the use of the ASF INTC driver. - * This is useful to ensure compatibilty accross compilers and shall be used only when required - * by the application needs. - */ -# define CONFIG_INTERRUPT_FORCE_INTC -#endif - -//! \name Global interrupt flags -//@{ -/** - * \typedef irqflags_t - * \brief Type used for holding state of interrupt flag - */ - -/** - * \def cpu_irq_enable - * \brief Enable interrupts globally - */ - -/** - * \def cpu_irq_disable - * \brief Disable interrupts globally - */ - -/** - * \fn irqflags_t cpu_irq_save(void) - * \brief Get and clear the global interrupt flags - * - * Use in conjunction with \ref cpu_irq_restore. - * - * \return Current state of interrupt flags. - * - * \note This function leaves interrupts disabled. - */ - -/** - * \fn void cpu_irq_restore(irqflags_t flags) - * \brief Restore global interrupt flags - * - * Use in conjunction with \ref cpu_irq_save. - * - * \param flags State to set interrupt flag to. - */ - -/** - * \fn bool cpu_irq_is_enabled_flags(irqflags_t flags) - * \brief Check if interrupts are globally enabled in supplied flags - * - * \param flags Currents state of interrupt flags. - * - * \return True if interrupts are enabled. - */ - -/** - * \def cpu_irq_is_enabled - * \brief Check if interrupts are globally enabled - * - * \return True if interrupts are enabled. - */ -//@} - -//! @} - -/** - * \ingroup interrupt_group - * \defgroup interrupt_deprecated_group Deprecated interrupt definitions - */ - -#endif /* UTILS_INTERRUPT_H */ diff --git a/DSTAT1/src/asf/common/utils/interrupt/interrupt_avr8.h b/DSTAT1/src/asf/common/utils/interrupt/interrupt_avr8.h deleted file mode 100644 index c557d0c..0000000 --- a/DSTAT1/src/asf/common/utils/interrupt/interrupt_avr8.h +++ /dev/null @@ -1,136 +0,0 @@ -/** - * \file - * - * \brief Global interrupt management for 8-bit AVR - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef UTILS_INTERRUPT_INTERRUPT_H -#define UTILS_INTERRUPT_INTERRUPT_H - -#include -#include - -/** - * \weakgroup interrupt_group - * - * @{ - */ - -/** - * \def ISR - * \brief Define service routine for specified interrupt vector - * - * Usage: - * \code - * ISR(FOO_vect) - * { - * ... - * } - * \endcode - * - * \param vect Interrupt vector name as found in the device header files. - */ -#if defined(__DOXYGEN__) -# define ISR(vect) -#elif defined(__GNUC__) -# include -#elif defined(__ICCAVR__) -# define __ISR(x) _Pragma(#x) -# define ISR(vect) __ISR(vector=vect) __interrupt void handler_##vect(void) -#endif - -#if XMEGA -/** - * \brief Initialize interrupt vectors - * Enables all interrupt levels, with vectors located in the application section - * and fixed priority scheduling. - */ -#define irq_initialize_vectors() \ - PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; -#endif - -#ifdef __GNUC__ -# define cpu_irq_enable() sei() -# define cpu_irq_disable() cli() -#else -# define cpu_irq_enable() __enable_interrupt() -# define cpu_irq_disable() __disable_interrupt() -#endif - -typedef uint8_t irqflags_t; - -static inline irqflags_t cpu_irq_save(void) -{ - irqflags_t flags = SREG; - cpu_irq_disable(); - return flags; -} - -static inline void cpu_irq_restore(irqflags_t flags) -{ - barrier(); - SREG = flags; -} - -static inline bool cpu_irq_is_enabled_flags(irqflags_t flags) -{ -#if XMEGA -# ifdef __GNUC__ - return flags & CPU_I_bm; -# else - return flags & I_bm; -# endif -#elif MEGA - return flags & (1 << SREG_I); -#endif -} - -#define cpu_irq_is_enabled() cpu_irq_is_enabled_flags(SREG) - -//! @} - -/** - * \weakgroup interrupt_deprecated_group - * @{ - */ -// Deprecated definitions. -#define Enable_global_interrupt() cpu_irq_enable() -#define Disable_global_interrupt() cpu_irq_disable() -#define Is_global_interrupt_enabled() cpu_irq_is_enabled() -//! @} - -#endif /* UTILS_INTERRUPT_INTERRUPT_H */ diff --git a/DSTAT1/src/asf/common/utils/parts.h b/DSTAT1/src/asf/common/utils/parts.h deleted file mode 100644 index 532e36b..0000000 --- a/DSTAT1/src/asf/common/utils/parts.h +++ /dev/null @@ -1,671 +0,0 @@ -/** - * \file - * - * \brief Atmel part identification macros - * - * Copyright (C) 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef ATMEL_PARTS_H -#define ATMEL_PARTS_H - -/** - * \defgroup part_macros_group Atmel part identification macros - * - * This collection of macros identify which series and families that the various - * Atmel parts belong to. These can be used to select part-dependent sections of - * code at compile time. - * - * @{ - */ - -/** - * \name Convenience macros for part checking - * @{ - */ -//! Check GCC and IAR part definition for 8-bit AVR -#define AVR8_PART_IS_DEFINED(part) \ - (defined(__ ## part ## __) || defined(__AVR_ ## part ## __)) - -//! Check GCC and IAR part definition for 32-bit AVR -#define AVR32_PART_IS_DEFINED(part) \ - (defined(__AT32 ## part ## __) || defined(__AVR32_ ## part ## __)) - -//! Check GCC and IAR part definition for SAM -#define SAM_PART_IS_DEFINED(part) (defined(__ ## part ## __)) -/** @} */ - -/** - * \defgroup uc3_part_macros_group AVR UC3 parts - * @{ - */ - -/** - * \name AVR UC3 A series - * @{ - */ -#define UC3A0 ( \ - AVR32_PART_IS_DEFINED(UC3A0128) || \ - AVR32_PART_IS_DEFINED(UC3A0256) || \ - AVR32_PART_IS_DEFINED(UC3A0512) \ - ) - -#define UC3A1 ( \ - AVR32_PART_IS_DEFINED(UC3A1128) || \ - AVR32_PART_IS_DEFINED(UC3A1256) || \ - AVR32_PART_IS_DEFINED(UC3A1512) \ - ) - -#define UC3A3 ( \ - AVR32_PART_IS_DEFINED(UC3A364) || \ - AVR32_PART_IS_DEFINED(UC3A364S) || \ - AVR32_PART_IS_DEFINED(UC3A3128) || \ - AVR32_PART_IS_DEFINED(UC3A3128S) || \ - AVR32_PART_IS_DEFINED(UC3A3256) || \ - AVR32_PART_IS_DEFINED(UC3A3256S) \ - ) - -#define UC3A4 ( \ - AVR32_PART_IS_DEFINED(UC3A464) || \ - AVR32_PART_IS_DEFINED(UC3A464S) || \ - AVR32_PART_IS_DEFINED(UC3A4128) || \ - AVR32_PART_IS_DEFINED(UC3A4128S) || \ - AVR32_PART_IS_DEFINED(UC3A4256) || \ - AVR32_PART_IS_DEFINED(UC3A4256S) \ - ) -/** @} */ - -/** - * \name AVR UC3 B series - * @{ - */ -#define UC3B0 ( \ - AVR32_PART_IS_DEFINED(UC3B064) || \ - AVR32_PART_IS_DEFINED(UC3B0128) || \ - AVR32_PART_IS_DEFINED(UC3B0256) || \ - AVR32_PART_IS_DEFINED(UC3B0512) \ - ) - -#define UC3B1 ( \ - AVR32_PART_IS_DEFINED(UC3B164) || \ - AVR32_PART_IS_DEFINED(UC3B1128) || \ - AVR32_PART_IS_DEFINED(UC3B1256) || \ - AVR32_PART_IS_DEFINED(UC3B1512) \ - ) -/** @} */ - -/** - * \name AVR UC3 C series - * @{ - */ -#define UC3C0 ( \ - AVR32_PART_IS_DEFINED(UC3C064C) || \ - AVR32_PART_IS_DEFINED(UC3C0128C) || \ - AVR32_PART_IS_DEFINED(UC3C0256C) || \ - AVR32_PART_IS_DEFINED(UC3C0512C) \ - ) - -#define UC3C1 ( \ - AVR32_PART_IS_DEFINED(UC3C164C) || \ - AVR32_PART_IS_DEFINED(UC3C1128C) || \ - AVR32_PART_IS_DEFINED(UC3C1256C) || \ - AVR32_PART_IS_DEFINED(UC3C1512C) \ - ) - -#define UC3C2 ( \ - AVR32_PART_IS_DEFINED(UC3C264C) || \ - AVR32_PART_IS_DEFINED(UC3C2128C) || \ - AVR32_PART_IS_DEFINED(UC3C2256C) || \ - AVR32_PART_IS_DEFINED(UC3C2512C) \ - ) -/** @} */ - -/** - * \name AVR UC3 D series - * @{ - */ -#define UC3D3 ( \ - AVR32_PART_IS_DEFINED(UC64D3) || \ - AVR32_PART_IS_DEFINED(UC128D3) \ - ) - -#define UC3D4 ( \ - AVR32_PART_IS_DEFINED(UC64D4) || \ - AVR32_PART_IS_DEFINED(UC128D4) \ - ) -/** @} */ - -/** - * \name AVR UC3 L series - * @{ - */ -#define UC3L0 ( \ - AVR32_PART_IS_DEFINED(UC3L016) || \ - AVR32_PART_IS_DEFINED(UC3L032) || \ - AVR32_PART_IS_DEFINED(UC3L064) \ - ) - -#define UC3L0128 ( \ - AVR32_PART_IS_DEFINED(UC3L0128) \ - ) - -#define UC3L0256 ( \ - AVR32_PART_IS_DEFINED(UC3L0256) \ - ) - -#define UC3L3 ( \ - AVR32_PART_IS_DEFINED(UC64L3U) || \ - AVR32_PART_IS_DEFINED(UC128L3U) || \ - AVR32_PART_IS_DEFINED(UC256L3U) \ - ) - -#define UC3L4 ( \ - AVR32_PART_IS_DEFINED(UC64L4U) || \ - AVR32_PART_IS_DEFINED(UC128L4U) || \ - AVR32_PART_IS_DEFINED(UC256L4U) \ - ) - -#define UC3L3_L4 (UC3L3 || UC3L4) -/** @} */ - -/** - * \name AVR UC3 families - * @{ - */ -/** AVR UC3 A family */ -#define UC3A (UC3A0 || UC3A1 || UC3A3 || UC3A4) - -/** AVR UC3 B family */ -#define UC3B (UC3B0 || UC3B1) - -/** AVR UC3 C family */ -#define UC3C (UC3C0 || UC3C1 || UC3C2) - -/** AVR UC3 D family */ -#define UC3D (UC3D3 || UC3D4) - -/** AVR UC3 L family */ -#define UC3L (UC3L0 || UC3L0128 || UC3L0256 || UC3L3_L4) -/** @} */ - -/** AVR UC3 product line */ -#define UC3 (UC3A || UC3B || UC3C || UC3D || UC3L) - -/** @} */ - -/** - * \defgroup xmega_part_macros_group AVR XMEGA parts - * @{ - */ - -/** - * \name AVR XMEGA A series - * @{ - */ -#define XMEGA_A1 ( \ - AVR8_PART_IS_DEFINED(ATxmega64A1) || \ - AVR8_PART_IS_DEFINED(ATxmega128A1) \ - ) - -#define XMEGA_A3 ( \ - AVR8_PART_IS_DEFINED(ATxmega64A3) || \ - AVR8_PART_IS_DEFINED(ATxmega128A3) || \ - AVR8_PART_IS_DEFINED(ATxmega192A3) || \ - AVR8_PART_IS_DEFINED(ATxmega256A3) \ - ) - -#define XMEGA_A3B ( \ - AVR8_PART_IS_DEFINED(ATxmega256A3B) \ - ) - -#define XMEGA_A4 ( \ - AVR8_PART_IS_DEFINED(ATxmega16A4) || \ - AVR8_PART_IS_DEFINED(ATxmega32A4) \ - ) -/** @} */ - -/** - * \name AVR XMEGA AU series - * @{ - */ -#define XMEGA_A1U ( \ - AVR8_PART_IS_DEFINED(ATxmega64A1U) || \ - AVR8_PART_IS_DEFINED(ATxmega128A1U) \ - ) - -#define XMEGA_A3U ( \ - AVR8_PART_IS_DEFINED(ATxmega64A3U) || \ - AVR8_PART_IS_DEFINED(ATxmega128A3U) || \ - AVR8_PART_IS_DEFINED(ATxmega192A3U) || \ - AVR8_PART_IS_DEFINED(ATxmega256A3U) \ - ) - -#define XMEGA_A3BU ( \ - AVR8_PART_IS_DEFINED(ATxmega256A3BU) \ - ) - -#define XMEGA_A4U ( \ - AVR8_PART_IS_DEFINED(ATxmega16A4U) || \ - AVR8_PART_IS_DEFINED(ATxmega32A4U) || \ - AVR8_PART_IS_DEFINED(ATxmega64A4U) || \ - AVR8_PART_IS_DEFINED(ATxmega128A4U) \ - ) -/** @} */ - -/** - * \name AVR XMEGA B series - * @{ - */ -#define XMEGA_B1 ( \ - AVR8_PART_IS_DEFINED(ATxmega64B1) || \ - AVR8_PART_IS_DEFINED(ATxmega128B1) \ - ) - -#define XMEGA_B3 ( \ - AVR8_PART_IS_DEFINED(ATxmega64B3) || \ - AVR8_PART_IS_DEFINED(ATxmega128B3) \ - ) -/** @} */ - -/** - * \name AVR XMEGA C series - * @{ - */ -#define XMEGA_C3 ( \ - AVR8_PART_IS_DEFINED(ATxmega384C3) || \ - AVR8_PART_IS_DEFINED(ATxmega256C3) || \ - AVR8_PART_IS_DEFINED(ATxmega128C3) || \ - AVR8_PART_IS_DEFINED(ATxmega64C3) \ - ) - -#define XMEGA_C4 ( \ - AVR8_PART_IS_DEFINED(ATxmega32C4) || \ - AVR8_PART_IS_DEFINED(ATxmega16C4) \ - ) -/** @} */ - -/** - * \name AVR XMEGA D series - * @{ - */ -#define XMEGA_D3 ( \ - AVR8_PART_IS_DEFINED(ATxmega64D3) || \ - AVR8_PART_IS_DEFINED(ATxmega128D3) || \ - AVR8_PART_IS_DEFINED(ATxmega192D3) || \ - AVR8_PART_IS_DEFINED(ATxmega256D3) || \ - AVR8_PART_IS_DEFINED(ATxmega384D3) \ - ) - -#define XMEGA_D4 ( \ - AVR8_PART_IS_DEFINED(ATxmega16D4) || \ - AVR8_PART_IS_DEFINED(ATxmega32D4) || \ - AVR8_PART_IS_DEFINED(ATxmega64D4) || \ - AVR8_PART_IS_DEFINED(ATxmega128D4) \ - ) -/** @} */ - -/** - * \name AVR XMEGA families - * @{ - */ -/** AVR XMEGA A family */ -#define XMEGA_A (XMEGA_A1 || XMEGA_A3 || XMEGA_A3B || XMEGA_A4) - -/** AVR XMEGA AU family */ -#define XMEGA_AU (XMEGA_A1U || XMEGA_A3U || XMEGA_A3BU || XMEGA_A4U) - -/** AVR XMEGA B family */ -#define XMEGA_B (XMEGA_B1 || XMEGA_B3) - -/** AVR XMEGA C family */ -#define XMEGA_C (XMEGA_C3 || XMEGA_C4) - -/** AVR XMEGA D family */ -#define XMEGA_D (XMEGA_D3 || XMEGA_D4) -/** @} */ - -/** AVR XMEGA product line */ -#define XMEGA (XMEGA_A || XMEGA_AU || XMEGA_B || XMEGA_C || XMEGA_D) - -/** @} */ - -/** - * \defgroup mega_part_macros_group megaAVR parts - * - * \note These megaAVR groupings are based on the groups in AVR Libc for the - * part header files. They are not names of official megaAVR device series or - * families. - * - * @{ - */ - -/** - * \name ATmegaxx0/xx1 subgroups - * @{ - */ -#define MEGA_XX0 ( \ - AVR8_PART_IS_DEFINED(ATmega640) || \ - AVR8_PART_IS_DEFINED(ATmega1280) || \ - AVR8_PART_IS_DEFINED(ATmega2560) \ - ) - -#define MEGA_XX1 ( \ - AVR8_PART_IS_DEFINED(ATmega1281) || \ - AVR8_PART_IS_DEFINED(ATmega2561) \ - ) -/** @} */ - -/** - * \name megaAVR groups - * @{ - */ -/** ATmegaxx0/xx1 group */ -#define MEGA_XX0_1 (MEGA_XX0 || MEGA_XX1) - -/** ATmegaxx4 group */ -#define MEGA_XX4 ( \ - AVR8_PART_IS_DEFINED(ATmega164A) || \ - AVR8_PART_IS_DEFINED(ATmega164PA) || \ - AVR8_PART_IS_DEFINED(ATmega324) || \ - AVR8_PART_IS_DEFINED(ATmega324A) || \ - AVR8_PART_IS_DEFINED(ATmega324PA) || \ - AVR8_PART_IS_DEFINED(ATmega644) || \ - AVR8_PART_IS_DEFINED(ATmega644A) || \ - AVR8_PART_IS_DEFINED(ATmega644PA) || \ - AVR8_PART_IS_DEFINED(ATmega1284P) || \ - AVR8_PART_IS_DEFINED(ATmega128RFA1) \ - ) - -/** ATmegaxx4 group */ -#define MEGA_XX4_A ( \ - AVR8_PART_IS_DEFINED(ATmega164A) || \ - AVR8_PART_IS_DEFINED(ATmega164PA) || \ - AVR8_PART_IS_DEFINED(ATmega324A) || \ - AVR8_PART_IS_DEFINED(ATmega324PA) || \ - AVR8_PART_IS_DEFINED(ATmega644A) || \ - AVR8_PART_IS_DEFINED(ATmega644PA) || \ - AVR8_PART_IS_DEFINED(ATmega1284P) \ - ) - -/** ATmegaxx8 group */ -#define MEGA_XX8 ( \ - AVR8_PART_IS_DEFINED(ATmega48) || \ - AVR8_PART_IS_DEFINED(ATmega48A) || \ - AVR8_PART_IS_DEFINED(ATmega48PA) || \ - AVR8_PART_IS_DEFINED(ATmega88) || \ - AVR8_PART_IS_DEFINED(ATmega88A) || \ - AVR8_PART_IS_DEFINED(ATmega88PA) || \ - AVR8_PART_IS_DEFINED(ATmega168) || \ - AVR8_PART_IS_DEFINED(ATmega168A) || \ - AVR8_PART_IS_DEFINED(ATmega168PA) || \ - AVR8_PART_IS_DEFINED(ATmega328) || \ - AVR8_PART_IS_DEFINED(ATmega328P) \ - ) - -/** ATmegaxx8A/P/PA group */ -#define MEGA_XX8_A ( \ - AVR8_PART_IS_DEFINED(ATmega48A) || \ - AVR8_PART_IS_DEFINED(ATmega48PA) || \ - AVR8_PART_IS_DEFINED(ATmega88A) || \ - AVR8_PART_IS_DEFINED(ATmega88PA) || \ - AVR8_PART_IS_DEFINED(ATmega168A) || \ - AVR8_PART_IS_DEFINED(ATmega168PA) || \ - AVR8_PART_IS_DEFINED(ATmega328P) \ - ) - -/** ATmegaxx group */ -#define MEGA_XX ( \ - AVR8_PART_IS_DEFINED(ATmega16) || \ - AVR8_PART_IS_DEFINED(ATmega16A) || \ - AVR8_PART_IS_DEFINED(ATmega32) || \ - AVR8_PART_IS_DEFINED(ATmega32A) || \ - AVR8_PART_IS_DEFINED(ATmega64) || \ - AVR8_PART_IS_DEFINED(ATmega64A) || \ - AVR8_PART_IS_DEFINED(ATmega128) || \ - AVR8_PART_IS_DEFINED(ATmega128A) \ - ) - -/** ATmegaxxA/P/PA group */ -#define MEGA_XX_A ( \ - AVR8_PART_IS_DEFINED(ATmega16A) || \ - AVR8_PART_IS_DEFINED(ATmega32A) || \ - AVR8_PART_IS_DEFINED(ATmega64A) || \ - AVR8_PART_IS_DEFINED(ATmega128A) \ - ) - -/** Unspecified group */ -#define MEGA_UNSPECIFIED ( \ - AVR8_PART_IS_DEFINED(ATmega16) || \ - AVR8_PART_IS_DEFINED(ATmega16A) || \ - AVR8_PART_IS_DEFINED(ATmega32) || \ - AVR8_PART_IS_DEFINED(ATmega32A) || \ - AVR8_PART_IS_DEFINED(ATmega64) || \ - AVR8_PART_IS_DEFINED(ATmega64A) || \ - AVR8_PART_IS_DEFINED(ATmega128) || \ - AVR8_PART_IS_DEFINED(ATmega128A) || \ - AVR8_PART_IS_DEFINED(ATmega169P) || \ - AVR8_PART_IS_DEFINED(ATmega169PA) || \ - AVR8_PART_IS_DEFINED(ATmega329P) || \ - AVR8_PART_IS_DEFINED(ATmega329PA) \ - ) -/** @} */ - -/** megaAVR product line */ -#define MEGA (MEGA_XX0_1 || MEGA_XX4 || MEGA_XX8 || MEGA_XX || MEGA_UNSPECIFIED) - -/** @} */ - -/** - * \defgroup sam_part_macros_group SAM parts - * @{ - */ - -/** - * \name SAM3S series - * @{ - */ -#define SAM3S1 ( \ - SAM_PART_IS_DEFINED(SAM3S1A) || \ - SAM_PART_IS_DEFINED(SAM3S1B) || \ - SAM_PART_IS_DEFINED(SAM3S1C) \ - ) - -#define SAM3S2 ( \ - SAM_PART_IS_DEFINED(SAM3S2A) || \ - SAM_PART_IS_DEFINED(SAM3S2B) || \ - SAM_PART_IS_DEFINED(SAM3S2C) \ - ) - -#define SAM3S4 ( \ - SAM_PART_IS_DEFINED(SAM3S4A) || \ - SAM_PART_IS_DEFINED(SAM3S4B) || \ - SAM_PART_IS_DEFINED(SAM3S4C) \ - ) - -#define SAM3S8 ( \ - SAM_PART_IS_DEFINED(SAM3S8B) || \ - SAM_PART_IS_DEFINED(SAM3S8C) \ - ) - -#define SAM3SD8 ( \ - SAM_PART_IS_DEFINED(SAM3SD8B) || \ - SAM_PART_IS_DEFINED(SAM3SD8C) \ - ) -/** @} */ - -/** - * \name SAM3U series - * @{ - */ -#define SAM3U1 ( \ - SAM_PART_IS_DEFINED(SAM3U1C) || \ - SAM_PART_IS_DEFINED(SAM3U1E) \ - ) - -#define SAM3U2 ( \ - SAM_PART_IS_DEFINED(SAM3U2C) || \ - SAM_PART_IS_DEFINED(SAM3U2E) \ - ) - -#define SAM3U4 ( \ - SAM_PART_IS_DEFINED(SAM3U4C) || \ - SAM_PART_IS_DEFINED(SAM3U4E) \ - ) -/** @} */ - -/** - * \name SAM3N series - * @{ - */ -#define SAM3N1 ( \ - SAM_PART_IS_DEFINED(SAM3N1A) || \ - SAM_PART_IS_DEFINED(SAM3N1B) || \ - SAM_PART_IS_DEFINED(SAM3N1C) \ - ) - -#define SAM3N2 ( \ - SAM_PART_IS_DEFINED(SAM3N2A) || \ - SAM_PART_IS_DEFINED(SAM3N2B) || \ - SAM_PART_IS_DEFINED(SAM3N2C) \ - ) - -#define SAM3N4 ( \ - SAM_PART_IS_DEFINED(SAM3N4A) || \ - SAM_PART_IS_DEFINED(SAM3N4B) || \ - SAM_PART_IS_DEFINED(SAM3N4C) \ - ) -/** @} */ - -/** - * \name SAM3X series - * @{ - */ -#define SAM3X4 ( \ - SAM_PART_IS_DEFINED(SAM3X4C) || \ - SAM_PART_IS_DEFINED(SAM3X4E) \ - ) - -#define SAM3X8 ( \ - SAM_PART_IS_DEFINED(SAM3X8C) || \ - SAM_PART_IS_DEFINED(SAM3X8E) || \ - SAM_PART_IS_DEFINED(SAM3X8H) \ - ) -/** @} */ - -/** - * \name SAM3A series - * @{ - */ -#define SAM3A4 ( \ - SAM_PART_IS_DEFINED(SAM3A4C) \ - ) - -#define SAM3A8 ( \ - SAM_PART_IS_DEFINED(SAM3A8C) \ - ) -/** @} */ - -/** - * \name SAM4S series - * @{ - */ -#define SAM4S8 ( \ - SAM_PART_IS_DEFINED(SAM4S8B) || \ - SAM_PART_IS_DEFINED(SAM4S8C) \ - ) - -#define SAM4S16 ( \ - SAM_PART_IS_DEFINED(SAM4S16B) || \ - SAM_PART_IS_DEFINED(SAM4S16C) \ - ) -/** @} */ - -/** - * \name SAM4L series - * @{ - */ -#define SAM4LS ( \ - SAM_PART_IS_DEFINED(ATSAM4LS2A) || \ - SAM_PART_IS_DEFINED(ATSAM4LS2B) || \ - SAM_PART_IS_DEFINED(ATSAM4LS2C) || \ - SAM_PART_IS_DEFINED(ATSAM4LS4A) || \ - SAM_PART_IS_DEFINED(ATSAM4LS4B) || \ - SAM_PART_IS_DEFINED(ATSAM4LS4C) \ - ) - -#define SAM4LC ( \ - SAM_PART_IS_DEFINED(ATSAM4LC2A) || \ - SAM_PART_IS_DEFINED(ATSAM4LC2B) || \ - SAM_PART_IS_DEFINED(ATSAM4LC2C) || \ - SAM_PART_IS_DEFINED(ATSAM4LC4A) || \ - SAM_PART_IS_DEFINED(ATSAM4LC4B) || \ - SAM_PART_IS_DEFINED(ATSAM4LC4C) \ - ) -/** @} */ - -/** - * \name SAM families - * @{ - */ -/** SAM3S Family */ -#define SAM3S (SAM3S1 || SAM3S2 || SAM3S4 || SAM3S8 || SAM3SD8) - -/** SAM3U Family */ -#define SAM3U (SAM3U1 || SAM3U2 || SAM3U4) - -/** SAM3N Family */ -#define SAM3N (SAM3N1 || SAM3N2 || SAM3N4) - -/** SAM3XA Family */ -#define SAM3XA (SAM3X4 || SAM3X8 || SAM3A4 || SAM3A8) - -/** SAM4S Family */ -#define SAM4S (SAM4S8 || SAM4S16) - -/** SAM4L Family */ -#define SAM4L (SAM4LS || SAM4LC) -/** @} */ - -/** SAM product line */ -#define SAM (SAM3S || SAM3U || SAM3N || SAM3XA || SAM4S || SAM4L) - -/** @} */ - -/** @} */ - -#endif /* ATMEL_PARTS_H */ diff --git a/DSTAT1/src/asf/common/utils/stdio/read.c b/DSTAT1/src/asf/common/utils/stdio/read.c deleted file mode 100644 index d8b0327..0000000 --- a/DSTAT1/src/asf/common/utils/stdio/read.c +++ /dev/null @@ -1,161 +0,0 @@ -/** - * \file - * - * \brief System-specific implementation of the \ref _read function used by - * the standard library. - * - * Copyright (c) 2009-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#include "compiler.h" - -/** - * \defgroup group_common_utils_stdio Standard I/O (stdio) - * - * Common standard I/O driver that implements the stdio - * read and write functions on AVR devices. - * - * \{ - */ - -extern volatile void *volatile stdio_base; -void (*ptr_get)(void volatile*,int*); - - -// IAR common implementation -#if ( defined(__ICCAVR32__) || defined(__ICCAVR__) || defined(__ICCARM__) ) - -#include - -_STD_BEGIN - -#pragma module_name = "?__read" - -/*! \brief Reads a number of bytes, at most \a size, into the memory area - * pointed to by \a buffer. - * - * \param handle File handle to read from. - * \param buffer Pointer to buffer to write read bytes to. - * \param size Number of bytes to read. - * - * \return The number of bytes read, \c 0 at the end of the file, or - * \c _LLIO_ERROR on failure. - */ -size_t __read(int handle, unsigned char *buffer, size_t size) -{ - int nChars = 0; - // This implementation only reads from stdin. - // For all other file handles, it returns failure. - if (handle != _LLIO_STDIN) { - return _LLIO_ERROR; - } - for (; size > 0; --size) { - int c; - ptr_get(stdio_base,&c); - if (c < 0) - break; - *buffer++ = c; - ++nChars; - } - return nChars; -} - -/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10 - * the implementation is empty to be compatible with old IAR version. - */ -int __close(int handle) -{ - return 0; -} - -/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10 - * the implementation is empty to be compatible with old IAR version. - */ -int remove(const char* val) -{ - return 0; -} - -/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10 - * the implementation is empty to be compatible with old IAR version. - */ -long __lseek(int handle, long val, int val2) -{ - return val; -} - -_STD_END - -// GCC AVR32 implementation -#elif (defined(__GNUC__) && !defined(XMEGA)) - - -int __attribute__((weak)) -_read (int file, char * ptr, int len) -{ - int nChars = 0; - - if (file != 0) - return -1; - - for (; len > 0; --len) { - int c; - ptr_get(stdio_base,&c); - if (c < 0) - break; - *ptr++ = c; - ++nChars; - } - return nChars; -} - -// GCC AVR implementation -#elif (defined(__GNUC__) && defined(XMEGA)) - -int _read (int *f); // Remove GCC compiler warning - -int _read (int *f) -{ - int c; - ptr_get(stdio_base,&c); - return c; -} - -/** - * \} - */ - -#endif diff --git a/DSTAT1/src/asf/common/utils/stdio/stdio_usb/stdio_usb.c b/DSTAT1/src/asf/common/utils/stdio/stdio_usb/stdio_usb.c deleted file mode 100644 index 07e8d68..0000000 --- a/DSTAT1/src/asf/common/utils/stdio/stdio_usb/stdio_usb.c +++ /dev/null @@ -1,120 +0,0 @@ -/** - * \file - * - * \brief USB CDC Standard I/O Serial Management. - * - * This module defines support routines for a stdio serial interface to the - * Atmel Software Framework (ASF) common USB CDC service. - * - * Copyright (c) 2011-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - - -#include "stdio_usb.h" - -static bool stdio_usb_interface_enable = false; - -int stdio_usb_putchar (volatile void * usart, int data) -{ - /* A negative return value should be used to indicate that data - * was not written, but this doesn't seem to work with GCC libc. - */ - if (!stdio_usb_interface_enable) { - return 0; // -1 - } - - return udi_cdc_putc (data) ? 0 : -1; -} - -void stdio_usb_getchar (void volatile * usart, int * data) -{ - /* A negative return value should be used to indicate that data - * was not read, but this doesn't seem to work with GCC libc. - */ - if (!stdio_usb_interface_enable) { - *data = 0; // -1 - return; - } - - *data = udi_cdc_getc (); -} - -void stdio_usb_vbus_event(bool b_high) -{ - if (b_high) { - // Attach USB Device - udc_attach (); - } else { - // VBUS not present - udc_detach (); - } -} - -bool stdio_usb_enable(void) -{ - stdio_usb_interface_enable = true; - return true; -} - -void stdio_usb_disable(void) -{ - stdio_usb_interface_enable = false; -} - -void stdio_usb_init (volatile void * usart) -{ - stdio_base = usart; - ptr_put = stdio_usb_putchar; - ptr_get = stdio_usb_getchar; - - /* - * Start and attach USB CDC device interface for devices with - * integrated USB interfaces. Assume the VBUS is present if - * VBUS monitoring is not available. - */ - udc_start (); - - if (! udc_include_vbus_monitoring ()) { - stdio_usb_vbus_event (true); - } - - // For AVR GCC libc print redirection uses fdevopen. - - #if defined(XMEGA) && defined(__GNUC__) - fdevopen((int (*)(char, FILE*))(_write),(int (*)(FILE*))(_read)); - #endif -} - diff --git a/DSTAT1/src/asf/common/utils/stdio/stdio_usb/stdio_usb.h b/DSTAT1/src/asf/common/utils/stdio/stdio_usb/stdio_usb.h deleted file mode 100644 index 6088530..0000000 --- a/DSTAT1/src/asf/common/utils/stdio/stdio_usb/stdio_usb.h +++ /dev/null @@ -1,126 +0,0 @@ -/** - * \file - * - * \brief USB Standard I/O Serial Management. - * - * This file defines a useful set of functions for the Stdio Serial - * interface on AVR devices. - * - * Copyright (c) 2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _stdio_usb_h_ -#define _stdio_usb_h_ - -/** - * \defgroup group_common_utils_stdio_stdio_usb USB/CDC Standard I/O (stdio) - * \ingroup group_common_utils_stdio - * - * Standard I/O (stdio) management component that implements a stdio - * USB CDC interface on AVR devices. - * - * \{ - */ - -#include - -#include - -#include -#include - -extern int _write (char c, int *f); -extern int _read (int *f); - - -//! Pointer to the base of the USART module instance to use for stdio. -extern volatile void *volatile stdio_base; -//! Pointer to the external low level write function. -extern int (*ptr_put)(void volatile*,int); -//! Pointer to the external low level read function. -extern void (*ptr_get)(void volatile*,int*); - -/*! \brief Sends a character with the USART. - * - * \param usart Base address of the USART instance. - * \param data Character to write. - * - * \return Status. - * \retval 0 The character was written. - * \retval -1 The function timed out before the transmitter became ready. - */ -int stdio_usb_putchar (volatile void * usart, int data); - -/*! \brief Waits until a character is received, and returns it. - * - * \param usart Base address of the USART instance. - * \param data Data to read - * - * \return Nothing. - */ -void stdio_usb_getchar (void volatile * usart, int * data); - -/*! \brief Callback for VBUS level change event. - * - * \param b_high 1 if VBus is present - * - * \return Nothing. - */ -void stdio_usb_vbus_event (bool b_high); - -/*! \brief Enables the stdio in USB Serial Mode. - * - * \return \c 1 if function was successfully done, otherwise \c 0. - */ -bool stdio_usb_enable(void); - -/*! \brief Disables the stdio in USB Serial Mode. - * - * \return Nothing. - */ -void stdio_usb_disable(void); - -/*! \brief Initializes the stdio in USB Serial Mode. - * - * \return Nothing. - */ -void stdio_usb_init (volatile void * usart); - -/** - * \} - */ - -#endif // _stdio_usb_h_ diff --git a/DSTAT1/src/asf/common/utils/stdio/write.c b/DSTAT1/src/asf/common/utils/stdio/write.c deleted file mode 100644 index b1e3fbf..0000000 --- a/DSTAT1/src/asf/common/utils/stdio/write.c +++ /dev/null @@ -1,141 +0,0 @@ -/** - * \file - * - * \brief System-specific implementation of the \ref _write function used by - * the standard library. - * - * Copyright (c) 2009-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#include "compiler.h" - -/** - * \addtogroup group_common_utils_stdio - * - * \{ - */ - -volatile void *volatile stdio_base; -int (*ptr_put)(void volatile*,int); - - -#if ( defined(__ICCAVR32__) || defined(__ICCAVR__)) - -#include - -_STD_BEGIN - -#pragma module_name = "?__write" - -/*! \brief Writes a number of bytes, at most \a size, from the memory area - * pointed to by \a buffer. - * - * If \a buffer is zero then \ref __write performs flushing of internal buffers, - * if any. In this case, \a handle can be \c -1 to indicate that all handles - * should be flushed. - * - * \param handle File handle to write to. - * \param buffer Pointer to buffer to read bytes to write from. - * \param size Number of bytes to write. - * - * \return The number of bytes written, or \c _LLIO_ERROR on failure. - */ -size_t __write(int handle, const unsigned char *buffer, size_t size) -{ - size_t nChars = 0; - - if (buffer == 0){ - // This means that we should flush internal buffers. - return 0; - } - - // This implementation only writes to stdout and stderr. - // For all other file handles, it returns failure. - if (handle != _LLIO_STDOUT && handle != _LLIO_STDERR) { - return _LLIO_ERROR; - } - - for (; size != 0; --size) { - if (ptr_put(stdio_base, *buffer++) < 0) { - return _LLIO_ERROR; - } - ++nChars; - } - - return nChars; -} - -_STD_END - - -#elif (defined(__GNUC__) && !defined(XMEGA)) - -int __attribute__((weak)) -_write (int file, char * ptr, int len) -{ - int nChars = 0; - - if ( (file != 1) - && (file != 2) && (file!=3)) - return -1; - - for (; len != 0; --len) { - if (ptr_put(stdio_base, *ptr++) < 0) { - return -1; - } - ++nChars; - } - return nChars; -} - -#elif (defined(__GNUC__) && defined(XMEGA)) - -int _write (char c, int *f); // Remove GCC compiler warning - -int _write (char c, int *f) -{ - if (ptr_put(stdio_base,c) < 0) - { - return -1; - } - return 1; -} - -/** - * \} - */ - -#endif diff --git a/DSTAT1/src/asf/xmega/drivers/cpu/ccp.h b/DSTAT1/src/asf/xmega/drivers/cpu/ccp.h deleted file mode 100644 index ed9f780..0000000 --- a/DSTAT1/src/asf/xmega/drivers/cpu/ccp.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * \file - * - * \brief Configuration Change Protection write functions - * - * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef CPU_CCP_H -#define CPU_CCP_H -#include - -/** - * \defgroup ccp_group Configuration Change Protection - * - * See \ref ccp_quickstart. - * - * Function for writing to protected IO registers. - * @{ - */ - -#if defined(__DOXYGEN__) -//! \name IAR Memory Model defines. -//@{ - -/** - * \def CONFIG_MEMORY_MODEL_TINY - * \brief Configuration symbol to enable 8 bit pointers. - * - */ -# define CONFIG_MEMORY_MODEL_TINY - -/** - * \def CONFIG_MEMORY_MODEL_SMALL - * \brief Configuration symbol to enable 16 bit pointers. - * \note If no memory model is defined, SMALL is default. - * - */ -# define CONFIG_MEMORY_MODEL_SMALL - - -/** - * \def CONFIG_MEMORY_MODEL_LARGE - * \brief Configuration symbol to enable 24 bit pointers. - * - */ -# define CONFIG_MEMORY_MODEL_LARGE - -//@} -#endif - - -/** - * \brief Write to a CCP-protected 8-bit I/O register - * - * \param addr Address of the I/O register - * \param value Value to be written - * - * \note Using IAR Embedded workbench, the choice of memory model has an impact - * on calling convention. The memory model is not visible to the - * preprocessor, so it must be defined in the Assembler preprocessor directives. - */ -extern void ccp_write_io(void *addr, uint8_t value); - -/** @} */ - -/** - * \page ccp_quickstart Quick start guide for CCP driver - * - * This is the quick start guide for the \ref ccp_group - * "Configuration Change Protection (CCP) driver", with step-by-step - * instructions on how to use the driver. - * - * The use case contains a code fragment, and this can be copied into, e.g., - * the main application function. - * - * \section ccp_basic_use_case Basic use case - * In this use case, the CCP is used to write to the protected XMEGA Clock - * Control register. - * - * \subsection ccp_basic_use_case_setup_flow Workflow - * -# call CCP write io to change system clock selection: - * - \code ccp_write_io((uint8_t *)&CLK.CTRL, CLK_SCLKSEL_RC32M_gc); \endcode - */ - -#endif /* CPU_CCP_H */ diff --git a/DSTAT1/src/asf/xmega/drivers/cpu/ccp.s b/DSTAT1/src/asf/xmega/drivers/cpu/ccp.s deleted file mode 100644 index b6ae4df..0000000 --- a/DSTAT1/src/asf/xmega/drivers/cpu/ccp.s +++ /dev/null @@ -1,98 +0,0 @@ -/** - * \file - * - * \brief Configuration Change Protection - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include - -//! Value to write to CCP for access to protected IO registers. -#define CCP_IOREG 0xd8 - - /* - * GNU and IAR use different calling conventions. Since this is - * a very small and simple function to begin with, it's easier - * to implement it twice than to deal with the differences - * within a single implementation. - * - * Interrupts are disabled by hardware during the timed - * sequence, so there's no need to save/restore interrupt state. - */ - - PUBLIC_FUNCTION(ccp_write_io) - -#if defined(__GNUC__) - - out RAMPZ, r1 // Reset bits 23:16 of Z - movw r30, r24 // Load addr into Z - ldi r18, CCP_IOREG // Load magic CCP value - out CCP, r18 // Start CCP handshake - st Z, r22 // Write value to I/O register - ret // Return to caller - -#elif defined(__IAR_SYSTEMS_ASM__) - -# if !defined(CONFIG_MEMORY_MODEL_TINY) && !defined(CONFIG_MEMORY_MODEL_SMALL) \ - && !defined(CONFIG_MEMORY_MODEL_LARGE) -# define CONFIG_MEMORY_MODEL_SMALL -# endif - ldi r20, 0 - out RAMPZ, r20 // Reset bits 23:16 of Z -# if defined(CONFIG_MEMORY_MODEL_TINY) - mov r31, r20 // Reset bits 8:15 of Z - mov r30, r16 // Load addr into Z -# else - movw r30, r16 // Load addr into Z -# endif - ldi r21, CCP_IOREG // Load magic CCP value - out CCP, r21 // Start CCP handshake -# if defined(CONFIG_MEMORY_MODEL_TINY) - st Z, r17 // Write value to I/O register -# elif defined(CONFIG_MEMORY_MODEL_SMALL) - st Z, r18 // Write value to I/O register -# elif defined(CONFIG_MEMORY_MODEL_LARGE) - st Z, r19 // Write value to I/O register -# else -# error Unknown memory model in use, no idea how registers should be accessed -# endif - ret -#else -# error Unknown assembler -#endif - - END_FUNC(ccp_write_io) - END_FILE() diff --git a/DSTAT1/src/asf/xmega/drivers/cpu/xmega_reset_cause.h b/DSTAT1/src/asf/xmega/drivers/cpu/xmega_reset_cause.h deleted file mode 100644 index f3c45dd..0000000 --- a/DSTAT1/src/asf/xmega/drivers/cpu/xmega_reset_cause.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * \file - * - * \brief Chip-specific reset cause functions - * - * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef XMEGA_DRIVERS_CPU_RESET_CAUSE_H -#define XMEGA_DRIVERS_CPU_RESET_CAUSE_H - -#include "compiler.h" -#include "ccp.h" - -/** - * \ingroup reset_cause_group - * \defgroup xmega_reset_cause_group XMEGA reset cause - * - * See \ref reset_cause_quickstart - * - * @{ - */ - -/** - * \brief Chip-specific reset cause type capable of holding all chip reset - * causes. Typically reflects the size of the reset cause register. - */ -typedef uint8_t reset_cause_t; - -//! \internal \name Chip-specific reset causes -//@{ -//! \internal External reset cause -#define CHIP_RESET_CAUSE_EXTRST RST_EXTRF_bm -//! \internal brown-out detected reset cause, same as for CPU -#define CHIP_RESET_CAUSE_BOD_IO RST_BORF_bm -//! \internal Brown-out detected reset cause, same as for I/O -#define CHIP_RESET_CAUSE_BOD_CPU RST_BORF_bm -//! \internal On-chip debug system reset cause -#define CHIP_RESET_CAUSE_OCD RST_PDIRF_bm -//! \internal Power-on-reset reset cause -#define CHIP_RESET_CAUSE_POR RST_PORF_bm -//! \internal Software reset reset cause -#define CHIP_RESET_CAUSE_SOFT RST_SRF_bm -//! \internal Spike detected reset cause -#define CHIP_RESET_CAUSE_SPIKE RST_SDRF_bm -//! \internal Watchdog timeout reset cause -#define CHIP_RESET_CAUSE_WDT RST_WDRF_bm -//@} - -static inline reset_cause_t reset_cause_get_causes(void) -{ - return (reset_cause_t)RST.STATUS; -} - -static inline void reset_cause_clear_causes(reset_cause_t causes) -{ - RST.STATUS = causes; -} - -static inline void reset_do_soft_reset(void) -{ - ccp_write_io((void *)&RST.CTRL, RST_SWRST_bm); - - while (1) { - /* Intentionally empty. */ - } -} - -//! @} - -#endif /* XMEGA_DRIVERS_CPU_RESET_CAUSE_H */ diff --git a/DSTAT1/src/asf/xmega/drivers/dma/dma.c b/DSTAT1/src/asf/xmega/drivers/dma/dma.c deleted file mode 100644 index 9e7bcc0..0000000 --- a/DSTAT1/src/asf/xmega/drivers/dma/dma.c +++ /dev/null @@ -1,280 +0,0 @@ -/** - * \file - * - * \brief AVR XMEGA Direct Memory Access Controller driver - * - * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include -#include -#include -#include -#include - -/** - * \private - * \brief DMA private data struct - */ -struct dma_data_struct { - /** Callback on complete */ - dma_callback_t callback; -}; - -/** - * \internal - * \brief DMA private data for each channel - */ -struct dma_data_struct dma_data[DMA_NUMBER_OF_CHANNELS]; - -/** - * \brief Enable DMA controller - * - * \note This function will do a soft reset of the DMA controller, clearing all - * previous configuration. - */ -void dma_enable(void) -{ - sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_DMA); - sleepmgr_lock_mode(SLEEPMGR_IDLE); - - /* Reset DMA controller just to make sure everything is from scratch */ - DMA.CTRL = DMA_RESET_bm; - DMA.CTRL = DMA_ENABLE_bm; -} - -/** - * \brief Disable DMA controller - */ -void dma_disable(void) -{ - DMA.CTRL = 0; - sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_DMA); - sleepmgr_unlock_mode(SLEEPMGR_IDLE); -} - -/** - * \brief Set callback for given DMA channel - * - * \param num \ref dma_channel_num_t - * \param callback \ref dma_callback_t - */ -void dma_set_callback(dma_channel_num_t num, dma_callback_t callback) -{ - dma_data[num].callback = callback; -} - -/** - * \internal - * \brief Common DMA channel interrupt handler - * - * Calls the channel callback with the channel status code. The following - * status codes are possible: - * - DMA_CH_TRANSFER_COMPLETED: Transfer completed successfully - * - DMA_CH_TRANSFER_ERROR: Fault in transfer - * - * The optional callback used by the interrupt handler is set by the - * dma_set_callback() function. - * - * \param num DMA channel number to handle interrupt for - */ -static void dma_interrupt(const dma_channel_num_t num) -{ - enum dma_channel_status status; - DMA_CH_t *channel; - - channel = dma_get_channel_address_from_num(num); - status = dma_get_channel_status(num); - - /* Clear all interrupt flags to be sure */ - channel->CTRLB |= DMA_CH_TRNIF_bm | DMA_CH_ERRIF_bm; - - if (dma_data[num].callback) { - dma_data[num].callback(status); - } -} - -/** - * \internal - * \brief DMA channel 0 interrupt handler - */ -ISR(DMA_CH0_vect) -{ - dma_interrupt(0); -} - -#if DMA_NUMBER_OF_CHANNELS > 1 -/** - * \internal - * \brief DMA channel 1 interrupt handler - */ -ISR(DMA_CH1_vect) -{ - dma_interrupt(1); -} -#endif - -#if DMA_NUMBER_OF_CHANNELS > 2 -/** - * \internal - * \brief DMA channel 2 interrupt handler - */ -ISR(DMA_CH2_vect) -{ - dma_interrupt(2); -} -#endif - -#if DMA_NUMBER_OF_CHANNELS > 3 -/** - * \internal - * \brief DMA channel 3 interrupt handler - */ -ISR(DMA_CH3_vect) -{ - dma_interrupt(3); -} -#endif - -/** - * \brief Write DMA channel configuration to hardware - * - * This function will write the DMA channel configuration, provided by a - * \ref dma_channel_config. - * - * \param num DMA channel number to write configuration to - * \param config Pointer to a DMA channel config, given by a - * \ref dma_channel_config - */ -void dma_channel_write_config(dma_channel_num_t num, - struct dma_channel_config *config) -{ - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - irqflags_t iflags = cpu_irq_save(); - -#ifdef CONFIG_HAVE_HUGEMEM - channel->DESTADDR0 = (uint32_t)config->destaddr; - channel->DESTADDR1 = (uint32_t)config->destaddr >> 8; - channel->DESTADDR2 = (uint32_t)config->destaddr >> 16; -#else - channel->DESTADDR0 = (uint32_t)config->destaddr16; - channel->DESTADDR1 = (uint32_t)config->destaddr16 >> 8; -# if XMEGA_A || XMEGA_AU - channel->DESTADDR2 = 0; -# endif -#endif - -#ifdef CONFIG_HAVE_HUGEMEM - channel->SRCADDR0 = (uint32_t)config->srcaddr; - channel->SRCADDR1 = (uint32_t)config->srcaddr >> 8; - channel->SRCADDR2 = (uint32_t)config->srcaddr >> 16; -#else - channel->SRCADDR0 = (uint32_t)config->srcaddr16; - channel->SRCADDR1 = (uint32_t)config->srcaddr16 >> 8; -# if XMEGA_A || XMEGA_AU - channel->SRCADDR2 = 0; -# endif -#endif - - channel->ADDRCTRL = config->addrctrl; - channel->TRIGSRC = config->trigsrc; - channel->TRFCNT = config->trfcnt; - channel->REPCNT = config->repcnt; - - channel->CTRLB = config->ctrlb; - - /* Make sure the DMA channel is not enabled before dma_channel_enable() - * is called. - */ -#if XMEGA_A || XMEGA_AU - channel->CTRLA = config->ctrla & ~DMA_CH_ENABLE_bm; -#else - channel->CTRLA = config->ctrla & ~DMA_CH_CHEN_bm; -#endif - - cpu_irq_restore(iflags); -} - -/** - * \brief Read DMA channel configuration from hardware - * - * This function will read the DMA channel configuration into a - * \ref dma_channel_config. - * - * \param num DMA channel number to read configuration from - * \param config Pointer to a DMA channel config, given by a - * \ref dma_channel_config - */ -void dma_channel_read_config(dma_channel_num_t num, - struct dma_channel_config *config) -{ - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - irqflags_t iflags = cpu_irq_save(); -#ifdef CONFIG_HAVE_HUGEMEM - uint32_t address; -#else - uint16_t address; -#endif - - address = channel->DESTADDR0; - address |= channel->DESTADDR1 << 8; -#ifdef CONFIG_HAVE_HUGEMEM - address |= (uint32_t)channel->DESTADDR2 << 16; - config->destaddr = (hugemem_ptr_t)address; -#else - config->destaddr16 = address; -#endif - - address = channel->SRCADDR0; - address |= channel->SRCADDR1 << 8; -#ifdef CONFIG_HAVE_HUGEMEM - address |= (uint32_t)channel->SRCADDR2 << 16; - config->srcaddr = (hugemem_ptr_t)address; -#else - config->srcaddr16 = address; -#endif - - config->addrctrl = channel->ADDRCTRL; - config->trigsrc = channel->TRIGSRC; - config->trfcnt = channel->TRFCNT; - config->repcnt = channel->REPCNT; - - config->ctrlb = channel->CTRLB; - config->ctrla = channel->CTRLA; - - cpu_irq_restore(iflags); -} diff --git a/DSTAT1/src/asf/xmega/drivers/dma/dma.h b/DSTAT1/src/asf/xmega/drivers/dma/dma.h deleted file mode 100644 index 4e871fd..0000000 --- a/DSTAT1/src/asf/xmega/drivers/dma/dma.h +++ /dev/null @@ -1,1394 +0,0 @@ -/** - * \file - * - * \brief AVR XMEGA Direct Memory Access Controller driver definitions - * - * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef DRIVERS_DMA_DMA_H -#define DRIVERS_DMA_DMA_H - -#include -#include -#include -#include - -/** - * \defgroup dma_group Direct Memory Access controller (DMA) - * - * See \ref xmega_dma_quickstart. - * - * This is a driver for configuration, enabling, disabling and use of the - * on-chip XMEGA Direct Memory Access (DMA) controller. - * - * \section dependencies Dependencies - * - * The direct memory access controller depends on the following modules: - * - \ref pmic_group for setting interrupt level. - * - \ref sysclk_group for peripheral clock control. - * - \ref sleepmgr_group for setting available sleep mode. - * - * @{ - */ - -#if XMEGA_A || XMEGA_AU -# define DMA_NUMBER_OF_CHANNELS 4 -#else -/** Number of available DMA channels, device dependent. */ -# define DMA_NUMBER_OF_CHANNELS 2 -#endif - -/** - * \private - * \brief Helper macro to get the channel offset given the channel number - * - * \param num DMA channel number - * - * \return DMA_CH_t pointer to the \a num DMA channel register struct - */ -#define dma_get_channel_address_from_num(num) \ - ((DMA_CH_t *)((uintptr_t)(&DMA.CH0) + (sizeof(DMA_CH_t) * num))) - -/** \brief DMA channel number type */ -typedef uint8_t dma_channel_num_t; - -/** \brief DMA channel status */ -enum dma_channel_status { - /** DMA channel is idling */ - DMA_CH_FREE = 0, - /** DMA channel has a block transfer pending */ - DMA_CH_PENDING, - /** DMA channel is busy doing a block transfer */ - DMA_CH_BUSY, - /** DMA channel has completed a block transfer */ - DMA_CH_TRANSFER_COMPLETED, - /** DMA channel failed to complete a block transfer */ - DMA_CH_TRANSFER_ERROR, -}; - -/** - * \brief DMA channel configuration struct - */ -struct dma_channel_config { - /** DMA channel control register A */ - uint8_t ctrla; - /** DMA channel control register B */ - uint8_t ctrlb; - /** DMA channel address control register */ - uint8_t addrctrl; - /** DMA channel trigger control register */ - uint8_t trigsrc; - /** DMA channel block transfer count register */ - uint16_t trfcnt; - /** DMA channel repeat counter register */ - uint8_t repcnt; - union { -#ifdef CONFIG_HAVE_HUGEMEM - /** DMA channel source hugemem address */ - hugemem_ptr_t srcaddr; -#endif - /** DMA channel source 16-bit address */ - uint16_t srcaddr16; - }; - union { -#ifdef CONFIG_HAVE_HUGEMEM - /** DMA channel destination hugemem address */ - hugemem_ptr_t destaddr; -#endif - /** DMA channel destaddr 16-bit address */ - uint16_t destaddr16; - }; -}; - -/** DMA interrupt levels */ -enum dma_int_level_t { - DMA_INT_LVL_OFF = 0x00, - DMA_INT_LVL_LO = 0x01, - DMA_INT_LVL_MED = 0x02, - DMA_INT_LVL_HI = 0x03, -}; - -void dma_enable(void); -void dma_disable(void); - -/** \name DMA Controller Management */ -/* @{ */ - -/** - * \brief Set DMA channel priority mode - * - * This functions sets the channel priority mode. Users can select between - * fixed priority, round-robin or a mix of both. - * - * The modes are defined in the toolchain header files in the form of \a - * DMA_PRIMODE_*_gc for devices with more than 2 channels, or DMA_PRIMODE_*_bm - * for dual channel devices. - * - * \param primode DMA channel priority mode given by a DMA_PRIMODE_t type - */ -static inline void dma_set_priority_mode(DMA_PRIMODE_t primode) -{ - irqflags_t iflags; - -#if XMEGA_A || XMEGA_AU - Assert(!(primode & ~DMA_PRIMODE_gm)); -#else - Assert(!(primode & ~DMA_PRIMODE_bm)); -#endif - - iflags = cpu_irq_save(); - -#if XMEGA_A || XMEGA_AU - DMA.CTRL = (DMA.CTRL & ~DMA_PRIMODE_gm) | primode; -#else - DMA.CTRL = (DMA.CTRL & ~DMA_PRIMODE_bm) | primode; -#endif - - cpu_irq_restore(iflags); -} - -/** - * \brief Set DMA channel double buffering mode - * - * This function modifies which channels should be in double buffer mode. The - * modes are defined in the toolchain header files in the form of \a - * DMA_DBUFMODE_*_gc for devices with more than 2 channels, or DMA_DBUFMODE_*_bm - * for dual channel devices. - * - * \param dbufmode Double buffer channel configuration given by a - * DMA_DBUFMODE_t type - */ -static inline void dma_set_double_buffer_mode(DMA_DBUFMODE_t dbufmode) -{ - irqflags_t iflags; - -#if XMEGA_A || XMEGA_AU - Assert(!(dbufmode & ~DMA_DBUFMODE_gm)); -#else - Assert(!(dbufmode & ~DMA_DBUFMODE_bm)); -#endif - - iflags = cpu_irq_save(); - -#if XMEGA_A || XMEGA_AU - DMA.CTRL = (DMA.CTRL & ~DMA_DBUFMODE_gm) | dbufmode; -#else - DMA.CTRL = (DMA.CTRL & ~DMA_DBUFMODE_bm) | dbufmode; -#endif - - cpu_irq_restore(iflags); -} - -/** @} */ - -/** \name DMA Channel Management */ -/** @{ */ - -void dma_channel_write_config(dma_channel_num_t num, - struct dma_channel_config *config); -void dma_channel_read_config(dma_channel_num_t num, - struct dma_channel_config *config); - -/** - * \brief Enable a DMA channel - * - * This function enables a DMA channel, depending on the configuration the DMA - * channel will start the block transfer upon a - * \ref dma_channel_trigger_block_transfer() or when other hardware modules trigger - * the DMA hardware. - * - * \pre The DMA channel configuration must be written to the channel before - * enabling the channel. - * - * \param num DMA channel to enable - */ -static inline void dma_channel_enable(dma_channel_num_t num) -{ - irqflags_t iflags = cpu_irq_save(); - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - -#if XMEGA_A || XMEGA_AU - channel->CTRLA |= DMA_CH_ENABLE_bm; -#else - channel->CTRLA |= DMA_CH_CHEN_bm; -#endif - - cpu_irq_restore(iflags); -} - -/** - * \brief Disable a DMA channel - * - * This function disables a DMA channel. If the DMA channel was already enabled - * the DMA channel is not disabled before the internal transfer buffer is empty - * and the DMA transfer is aborted. - * - * \param num DMA channel to disable - */ -static inline void dma_channel_disable(dma_channel_num_t num) -{ - irqflags_t iflags = cpu_irq_save(); - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - -#if XMEGA_A || XMEGA_AU - channel->CTRLA &= ~DMA_CH_ENABLE_bm; -#else - channel->CTRLA &= ~DMA_CH_CHEN_bm; -#endif - - cpu_irq_restore(iflags); -} - -/** - * \brief Check if DMA channel is enabled - * - * This function checks if a DMA channel is enabled. - * - * \param num DMA channel number to query - * - * \retval true DMA channel is enabled - * \retval false DMA channel is disabled - */ -static inline bool dma_channel_is_enabled(dma_channel_num_t num) -{ - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - bool channel_enabled; - -#if XMEGA_A || XMEGA_AU - channel_enabled = (channel->CTRLA & DMA_CH_ENABLE_bm); -#else - channel_enabled = (channel->CTRLA & DMA_CH_CHEN_bm); -#endif - - return channel_enabled; -} - -/** - * \brief Check if DMA channel is busy - * - * This function checks if a DMA channel is busy doing or going to do (pending) - * a block transfer. - * - * \param num DMA channel number to query - * - * \retval true DMA channel is busy or have a block transfer pending - * \retval false DMA channel is not busy or have a block transfer pending - */ -static inline bool dma_channel_is_busy(dma_channel_num_t num) -{ - uint8_t busy_pending = DMA.STATUS; - - busy_pending &= (1 << num) | (1 << (num + 4)); - if (busy_pending) { - return true; - } - - return false; -} - -/** - * \brief Get channel status - * - * This function returns the current channel status. - * - * \param num DMA channel number - * - * \return Channel status given by a \ref dma_channel_status - */ -static inline enum dma_channel_status dma_get_channel_status( - dma_channel_num_t num) -{ - uint8_t busy_pending = DMA.STATUS; - uint8_t error_completed = DMA.INTFLAGS; - - /* - * Check lower and upper nibble of INTFLAGS register to find possible - * error or transfer completed status. - */ - error_completed &= (1 << num) | (1 << (num + 4)); - if (error_completed & (1 << (num + 4))) { - return DMA_CH_TRANSFER_ERROR; - } else if (error_completed & (1 << num)) { - return DMA_CH_TRANSFER_COMPLETED; - } - - /* - * Check lower and upper nibble of STATUS register to find possible - * busy or pending completed status. - */ - busy_pending &= (1 << num) | (1 << (num + 4)); - if (busy_pending & (1 << (num + 4))) { - return DMA_CH_BUSY; - } else if (busy_pending & (1 << num)) { - return DMA_CH_PENDING; - } - - return DMA_CH_FREE; -} - -/** - * \brief DMA channel trigger block transfer - * - * This function triggers a start of a block transfer on a given DMA channel. - * - * \pre The DMA channel must be configured and enabled for this to have any - * affect. - * - * \param num DMA channel number to trigger block transfer for - */ -static inline void dma_channel_trigger_block_transfer(dma_channel_num_t num) -{ - irqflags_t iflags = cpu_irq_save(); - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - - channel->CTRLA |= DMA_CH_TRFREQ_bm; - - cpu_irq_restore(iflags); -} - -/** - * \brief Reset a DMA channel - * - * This function resets a given DMA channel. - * - * \param num DMA channel number to trigger block transfer for - */ -static inline void dma_channel_reset(dma_channel_num_t num) -{ - irqflags_t iflags = cpu_irq_save(); - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - -#if XMEGA_A || XMEGA_AU - channel->CTRLA |= DMA_CH_RESET_bm; -#else - channel->CTRLA |= DMA_CH_CHRST_bm; -#endif - - cpu_irq_restore(iflags); -} - -/** - * \brief Callback definition for DMA channel interrupts - * - * \param status Status of DMA channel block transfer - */ -typedef void (*dma_callback_t)(enum dma_channel_status status); - -void dma_set_callback(dma_channel_num_t num, dma_callback_t callback); - -/** @} */ - -/** - * \name DMA Channel Direct Configuration Functions - * - * These functions allows direct configuration on the DMA channels, not going - * through a \ref dma_channel_config struct. This allows update of the most - * commonly changed DMA channel properties. - * - * @{ - */ - -/** - * \brief Write DMA channel burst length to hardware - * - * This function writes the DMA channel burst length directly to hardware. The - * burst lengths are defined in the toolchain header files in the form of \a - * DMA_CH_BURSTLEN_*_gc, where * represents the various available burst - * lengths. - * - * \param num DMA channel number to write burst length for - * \param burst_length DMA channel burst length given by a DMA_CH_BURSTLEN_t - * type - */ -static inline void dma_channel_write_burst_length(dma_channel_num_t num, - DMA_CH_BURSTLEN_t burst_length) -{ - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - irqflags_t iflags = cpu_irq_save(); - - channel->CTRLA &= ~DMA_CH_BURSTLEN_gm; - channel->CTRLA |= burst_length; - - cpu_irq_restore(iflags); -} - -/** - * \brief Write DMA channel transfer count to hardware - * - * This function writes the DMA channel number of bytes in each block transfer - * to hardware. - * - * \param num DMA channel number to write transfer count for - * \param count Number of bytes in each block transfer - */ -static inline void dma_channel_write_transfer_count(dma_channel_num_t num, - uint16_t count) -{ - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - irqflags_t iflags = cpu_irq_save(); - - channel->TRFCNT = count; - - cpu_irq_restore(iflags); -} - -/** - * \brief Write DMA channel number of transfer repeats to hardware - * - * This function writes the DMA channel number of block transfer repeats to - * hardware. It will also enable the repeat feature. - * - * \param num DMA channel number to write transfer repeats for - * \param repeats Number of block transfer repeats - */ -static inline void dma_channel_write_repeats(dma_channel_num_t num, - uint8_t repeats) -{ - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - irqflags_t iflags = cpu_irq_save(); - - channel->REPCNT = repeats; - channel->CTRLA |= DMA_CH_REPEAT_bm; - - cpu_irq_restore(iflags); -} - -/** - * \brief Write DMA channel 16-bit destination address to hardware - * - * This function writes a DMA channel destination 16-bit LSB address to - *hardware. - * - * \param num DMA channel number to write 16-bit destination address for - * \param destination 16-bit LSB destination address - */ -static inline void dma_channel_write_destination(dma_channel_num_t num, - uint16_t destination) -{ - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - irqflags_t iflags = cpu_irq_save(); - - channel->DESTADDR0 = destination; - channel->DESTADDR1 = destination >> 8; - -#if XMEGA_A || XMEGA_AU - /* - * Make sure the third byte of the destination address is zero to avoid - * a runaway DMA transfer. - */ - channel->DESTADDR2 = 0; -#endif - - cpu_irq_restore(iflags); -} - -#ifdef CONFIG_HAVE_HUGEMEM - -/** - * \brief Write DMA channel hugemem destination address to hardware - * - * This function writes a DMA channel destination hugemem address to hardware. - * - * \param num DMA channel number to write hugemem destination address for - * \param destination hugemem destination address - */ -static inline void dma_channel_write_destination_hugemem(dma_channel_num_t num, - hugemem_ptr_t destination) -{ - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - irqflags_t iflags = cpu_irq_save(); - - channel->DESTADDR0 = (uint32_t)destination; - channel->DESTADDR1 = (uint32_t)destination >> 8; - channel->DESTADDR2 = (uint32_t)destination >> 16; - - cpu_irq_restore(iflags); -} - -#endif - -/** - * \brief Write DMA channel 16-bit source address to hardware - * - * This function writes a DMA channel source 16-bit LSB address to hardware. - * - * \param num DMA channel number to write 16-bit source address for - * \param source 16-bit LSB source address - */ -static inline void dma_channel_write_source(dma_channel_num_t num, - uint16_t source) -{ - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - irqflags_t iflags = cpu_irq_save(); - - channel->SRCADDR0 = source; - channel->SRCADDR1 = source >> 8; - -#if XMEGA_A || XMEGA_AU - /* - * Make sure the third byte of the source address is zero to avoid a - * runaway DMA transfer. - */ - channel->SRCADDR2 = 0; -#endif - - cpu_irq_restore(iflags); -} - -#ifdef CONFIG_HAVE_HUGEMEM - -/** - * \brief Write DMA channel hugemem source address to hardware - * - * This function writes a DMA channel source hugemem address to hardware. - * - * \param num DMA channel number to write hugemem source address for - * \param source hugemem source address - */ -static inline void dma_channel_write_source_hugemem(dma_channel_num_t num, - hugemem_ptr_t source) -{ - DMA_CH_t *channel = dma_get_channel_address_from_num(num); - irqflags_t iflags = cpu_irq_save(); - - channel->SRCADDR0 = (uint32_t)source; - channel->SRCADDR1 = (uint32_t)source >> 8; - channel->SRCADDR2 = (uint32_t)source >> 16; - - cpu_irq_restore(iflags); -} - -#endif - -/** @} */ - -/** \name DMA Channel Configuration Helper Functions */ -/** @{ */ - -/** - * \brief Set DMA channel burst length - * - * This function helps the caller setting the DMA channel burst length. The - * burst lengths are defined in the toolchain header files in the form of \a - * DMA_CH_BURSTLEN_*_gc, where * represents the various available burst - * lengths. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param burst_length DMA channel burst length given by a DMA_CH_BURSTLEN_t - * type - */ -static inline void dma_channel_set_burst_length( - struct dma_channel_config *config, - DMA_CH_BURSTLEN_t burst_length) -{ - config->ctrla &= ~DMA_CH_BURSTLEN_gm; - config->ctrla |= burst_length; -} - -/** - * \brief Set DMA channel in single shot transfer mode - * - * This function helps the caller setting the DMA channel in single shot - * transfer mode. - * - * \param config Pointer to a \ref dma_channel_config variable - */ -static inline void dma_channel_set_single_shot(struct dma_channel_config *config) -{ - config->ctrla |= DMA_CH_SINGLE_bm; -} - -/** - * \brief Unset DMA channel from single shot transfer mode - * - * This function helps the caller clear the DMA channel single shot transfer - * mode feature. - * - * \param config Pointer to a \ref dma_channel_config variable - */ -static inline void dma_channel_unset_single_shot( - struct dma_channel_config *config) -{ - config->ctrla &= ~DMA_CH_SINGLE_bm; -} - -/** - * \brief Set DMA channel interrupt level - * - * This function helps the caller setting the DMA channel interrupt level for - * transaction complete and channel error. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param level Interrupt level given by a \ref dma_int_level_t type - */ -static inline void dma_channel_set_interrupt_level(struct dma_channel_config - *config, enum dma_int_level_t level) -{ - config->ctrlb &= ~(DMA_CH_ERRINTLVL_gm | DMA_CH_TRNINTLVL_gm); - config->ctrlb |= (level << DMA_CH_ERRINTLVL_gp) - | (level << DMA_CH_TRNINTLVL_gp); -} - -/** - * \brief Set DMA channel source address reload mode - * - * This function helps the caller setting the DMA channel source address reload - * mode. The reload modes are defined in the toolchain header files in the form - * of \a DMA_CH_SRCRELOAD_*_gc, where * is NONE, BLOCK, BURST, TRANSACTION. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param mode DMA channel source address reload mode given by an - * DMA_CH_SRCRELOAD_t type - */ -static inline void dma_channel_set_src_reload_mode( - struct dma_channel_config *config, - DMA_CH_SRCRELOAD_t mode) -{ - config->addrctrl &= ~DMA_CH_SRCRELOAD_gm; - config->addrctrl |= mode; -} - -/** - * \brief Set DMA channel destination address reload mode - * - * This function helps the caller setting the DMA channel destination address - * reload mode. The reload modes are defined in the toolchain header files in - * the form of \a DMA_CH_DESTRELOAD_*_gc, where * is NONE, BLOCK, BURST, - * TRANSACTION. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param mode DMA channel destination address reload mode given by an - * DMA_CH_DESTRELOAD_t type - */ -static inline void dma_channel_set_dest_reload_mode( - struct dma_channel_config *config, - DMA_CH_DESTRELOAD_t mode) -{ - config->addrctrl &= ~DMA_CH_DESTRELOAD_gm; - config->addrctrl |= mode; -} - -/** - * \brief Set DMA channel source addressing mode - * - * This function helps the caller setting the DMA channel source addressing - * mode. The addressing modes are defined in the toolchain header files in the - * form of \a DMA_CH_SRCDIR_*_gc, where * is FIXED, INC, DEC. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param mode DMA channel source addressing mode given by an - * DMA_CH_SRCDIR_t type - */ -static inline void dma_channel_set_src_dir_mode( - struct dma_channel_config *config, - DMA_CH_SRCDIR_t mode) -{ - config->addrctrl &= ~DMA_CH_SRCDIR_gm; - config->addrctrl |= mode; -} - -/** - * \brief Set DMA channel destination addressing mode - * - * This function helps the caller setting the DMA channel destination - * addressing mode. The reload modes are defined in the toolchain header files - * in the form of \a DMA_CH_DESTDIR_*_gc, where * is FIXED, INC, DEC. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param mode DMA channel destination addressing mode given by an - * DMA_CH_DESTDIR_t type - */ -static inline void dma_channel_set_dest_dir_mode( - struct dma_channel_config *config, - DMA_CH_DESTDIR_t mode) -{ - config->addrctrl &= ~DMA_CH_DESTDIR_gm; - config->addrctrl |= mode; -} - -/** - * \brief Set DMA channel trigger source - * - * This function helps the caller setting the DMA channel trigger source. The - * trigger sources are defined in the toolchain header files in the form of \a - * DMA_CH_TRIGSRC_*_gc, where * represents the various sources. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param source DMA channel trigger source given by a DMA_CH_TRIGSRC_t type - */ -static inline void dma_channel_set_trigger_source( - struct dma_channel_config *config, - DMA_CH_TRIGSRC_t source) -{ - config->trigsrc = source; -} - -/** - * \brief Set DMA channel transfer count - * - * This function helps the caller setting the DMA channel number of bytes in - * each block transfer. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param count Number of bytes in each block transfer - */ -static inline void dma_channel_set_transfer_count( - struct dma_channel_config *config, - uint16_t count) -{ - config->trfcnt = count; -} - -/** - * \brief Set DMA channel number of transfer repeats - * - * This function helps the caller setting the DMA channel number of block - * transfer repeats. It will also enable the repeat feature. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param repeats Number of block transfer repeats - */ -static inline void dma_channel_set_repeats(struct dma_channel_config *config, - uint8_t repeats) -{ - config->ctrla |= DMA_CH_REPEAT_bm; - config->repcnt = repeats; -} - -/** - * \brief Set DMA channel 16-bit destination address - * - * This function helps the caller setting the DMA channel destination 16-bit - * LSB address. - * - * \note This function assumes the \a config was initialized with zeros (static - * or intentionally zeroed). If not zero filled, there might be garbage left in - * the upper byte of the destination address. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param destination 16-bit LSB destination address - */ -static inline void dma_channel_set_destination_address( - struct dma_channel_config *config, - uint16_t destination) -{ - config->destaddr16 = destination; -} - -#ifdef CONFIG_HAVE_HUGEMEM - -/** - * \brief Set DMA channel hugemem destination address - * - * This function helps the caller setting the DMA channel destination address. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param destination Destination address provided by a \ref hugemem_ptr_t type - */ -static inline void dma_channel_set_destination_hugemem( - struct dma_channel_config *config, - hugemem_ptr_t destination) -{ - config->destaddr = destination; -} - -#endif - -/** - * \brief Set DMA channel 16-bit source address - * - * This function helps the caller setting the DMA channel source 16-bit LSB - * address. - * - * \note This function assumes the \a config was initialized with zeros (static - * or intentionally zeroed). If not zero filled, there might be garbage left in - * the upper byte of the source address. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param source 16-bit LSB source address - */ -static inline void dma_channel_set_source_address( - struct dma_channel_config *config, - uint16_t source) -{ - config->srcaddr16 = source; -} - -#ifdef CONFIG_HAVE_HUGEMEM - -/** - * \brief Set DMA channel hugemem source address - * - * This function helps the caller setting the DMA channel source address. - * - * \param config Pointer to a \ref dma_channel_config variable - * \param source Source address provided by a \ref hugemem_ptr_t type - */ -static inline void dma_channel_set_source_hugemem( - struct dma_channel_config *config, - hugemem_ptr_t source) -{ - config->srcaddr = source; -} - -#endif -/** @} */ - -/** @} */ - -/** - * \page xmega_dma_quickstart Quick start guide for the XMEGA DMA driver - * - * This is the quick start guide for the \ref dma_group "DMA driver", with - * step-by-step instructions on how to configure and use the driver in a - * selection of use cases. - * - * The use cases contain several code fragments. The code fragments in the - * steps for setup can be copied into a custom initialization function, while - * the steps for usage can be copied into, e.g., the main application function. - * - * \section dma_use_cases Advanced use cases - * For more advanced use of the DMA driver, see the following use cases: - * - \subpage dma_use_case_1 - * - \subpage dma_use_case_2 - * - * \section dma_basic_use_case Basic use case - * In this basic use case, the DMA is configured for: - * - Burst length: 1 byte - * - Transfer count: 1024 - * - Source: Buffer located in RAM - * - Destination: Buffer located in RAM - * - Source and destination address reload mode: End of transaction - * - Source and destination address direction mode: Increment - * - * In this use case data is copied from the source buffer to the destination - * buffer in 1-byte bursts, until all data in the block is transferred. This - * example is analogus to a memcpy(destination, source, sizeof(source)) - * operation performed in hardware asynchronously to the CPU. - * - * \section dma_basic_use_case_setup Setup steps - * - * \subsection dma_basic_use_case_setup_prereq Prerequisites - * For the setup code of this use case to work, the following must - * be added to the project: - * -# \ref sysclk_group "System Clock Manager Service (sysclk)" - * - * \subsection dma_basic_use_case_setup_setup_code Example code - * Add to application C-file: - * \code - * #define DMA_CHANNEL 0 - * #define DMA_BUFFER_SIZE 1024 - * - * static uint8_t source[DMA_BUFFER_SIZE]; - * static uint8_t destination[DMA_BUFFER_SIZE]; - * - * static void dma_init(void) - * { - * struct dma_channel_config dmach_conf; - * memset(&dmach_conf, 0, sizeof(dmach_conf)); - * - * dma_channel_set_burst_length(&dmach_conf, DMA_CH_BURSTLEN_1BYTE_gc); - * dma_channel_set_transfer_count(&dmach_conf, DMA_BUFFER_SIZE); - * - * dma_channel_set_src_reload_mode(&dmach_conf, - * DMA_CH_SRCRELOAD_TRANSACTION_gc); - * dma_channel_set_dest_reload_mode(&dmach_conf, - * DMA_CH_DESTRELOAD_TRANSACTION_gc); - * - * dma_channel_set_src_dir_mode(&dmach_conf, DMA_CH_SRCDIR_INC_gc); - * dma_channel_set_source_address(&dmach_conf, - * (uint16_t)(uintptr_t)source); - * - * dma_channel_set_dest_dir_mode(&dmach_conf, DMA_CH_DESTDIR_INC_gc); - * dma_channel_set_destination_address(&dmach_conf, - * (uint16_t)(uintptr_t)destination); - * - * dma_enable(); - * - * dma_channel_write_config(DMA_CHANNEL, &dmach_conf); - * dma_channel_enable(DMA_CHANNEL); - * } - * \endcode - * - * Add to \c main(): - * \code - * sysclk_init(); - * dma_init(); - * \endcode - * - * \subsection dma_basic_use_case_setup_flow Workflow - * -# Define the DMA channel that will be used for the transfer for convenience: - * - \code #define DMA_CHANNEL 0 \endcode - * -# Define the array length that will be the used for the source and - * destination buffers located in RAM: - * - \code #define DMA_BUFFER_SIZE 1024 \endcode - * -# Create a pair of global arrays that will hold the source and destination - * data copied by the DMA controller channel when it is triggered: - * - \code - * static uint8_t source[DMA_BUFFER_SIZE]; - * static uint8_t destination[DMA_BUFFER_SIZE]; - * \endcode - * -# Create a function \c dma_init() to intialize the DMA: - * - \code - * static void dma_init(void) - * { - * // ... - * } - * \endcode - * -# Create config struct for DMA channel: - * - \code struct dma_channel_config dmach_conf; \endcode - * -# Make sure the configuration structure is zeroed out to ensure that all - * values are reset to their defaults before writing new values: - * - \code memset(&dmach_conf, 0, sizeof(dmach_conf)); \endcode - * -# Configure the DMA channel for single byte bursts, with a transfer length - * equal to the size of the source and destination buffers: - * - \code - * dma_channel_set_burst_length(&dmach_conf, DMA_CH_BURSTLEN_1BYTE_gc); - * dma_channel_set_transfer_count(&dmach_conf, DMA_BUFFER_SIZE); - * \endcode - * -# Configure the DMA channel to reset the source and destination addresses at - * the end of the complete transaction (i.e. after \c DMA_BUFFER_SIZE bytes - * copied): - * - \code - * dma_channel_set_src_reload_mode(&dmach_conf, DMA_CH_SRCRELOAD_TRANSACTION_gc); - * dma_channel_set_dest_reload_mode(&dmach_conf, DMA_CH_DESTRELOAD_TRANSACTION_gc); - * \endcode - * -# Configure the DMA channel to increment the source and destination - * addresses after each byte transferred: - * - \code - * dma_channel_set_src_dir_mode(&dmach_conf, DMA_CH_SRCDIR_INC_gc); - * dma_channel_set_dest_dir_mode(&dmach_conf, DMA_CH_DESTDIR_INC_gc); - * \endcode - * -# Configure the DMA channel source and destination addresses: - * - \code - * dma_channel_set_source_address(&dmach_conf, (uint16_t)(uintptr_t)source); - * dma_channel_set_destination_address(&dmach_conf, (uint16_t)(uintptr_t)destination); - * \endcode - * -# Enable the DMA module so that channels can be configured in it: - * - \code dma_enable(); \endcode - * \attention Calling dma_enable() will result in a soft-reset of the entire - * DMA module, clearing all channel configurations. If more than one - * DMA channel is to be configured, this function should be called - * only once in the application initialization procedure only. - * -# Write the DMA channel configuration to the DMA and enable it so that - * it can be triggered to start the transfer: - * - \code - * dma_channel_write_config(DMA_CHANNEL, &dmach_conf); - * dma_channel_enable(DMA_CHANNEL); - * \endcode - * -# Initialize the clock system: - * - \code sysclk_init(); \endcode - * -# Call our DMA init function: - * - \code dma_init(); \endcode - * - * \section dma_basic_use_case_usage Usage steps - * - * \subsection dma_basic_use_case_usage_code Example code - * Add to, e.g., main loop in application C-file: - * \code - * dma_channel_trigger_block_transfer(DMA_CHANNEL); - * do {} while (dma_get_channel_status(DMA_CHANNEL) != DMA_CH_TRANSFER_COMPLETED); - * \endcode - * - * \subsection dma_basic_use_case_usage_flow Workflow - * -# Start the DMA transfer: - * - \code dma_channel_trigger_block_transfer(DMA_CHANNEL); \endcode - * -# Wait for the transfer to complete: - * - \code do {} while (dma_get_channel_status(DMA_CHANNEL) != DMA_CH_TRANSFER_COMPLETED); - * \endcode - */ - -/** - * \page dma_use_case_1 Use case #1 - Interrupt for a completed DMA transfer. - * - * This use case shows how to set up an interrupt for when a DMA transfer is - * completed. - * - * In this use case, the DMA is configured for: - * - Interrupt level: Low - * - Burst length: 1 byte - * - Transfer count: 1024 - * - Source: Buffer located in RAM - * - Destination: Buffer located in RAM - * - Source and destination address reload mode: End of transaction - * - Source and destination address direction mode: Increment - * - * In this use case data is copied from the source buffer to the destination - * buffer in 1-byte bursts, until all data in the block is transferred. This - * example is analogus to a memcpy(destination, source, sizeof(source)) - * operation performed in hardware asynchronously to the CPU. - * - * Each time the DMA transfer completes, a user-specified callback function is - * run to notify the user application. - * - * \section dma_use_case_1_setup Setup steps - * - * \subsection dma_basic_use_case_setup_prereq Prerequisites - * For the setup code of this use case to work, the following must - * be added to the project: - * -# \ref sysclk_group "System Clock Manager Service (sysclk)" - * -# \ref sleepmgr_group "Sleep Manager Service" - * -# \ref pmic_group "PMIC Driver" - * - * A \ref dma_callback_t "callback" function, called \c dma_transfer_done, must - * also be provided by the user application: - * \code - * static void dma_transfer_done(enum dma_channel_status status) - * { - * // ... - * } - * \endcode - * - * \subsection dma_use_case_1_setup_code Example code - * Add to application C-file: - * \code - * #define DMA_CHANNEL 0 - * #define DMA_BUFFER_SIZE 1024 - * - * static uint8_t source[DMA_BUFFER_SIZE]; - * static uint8_t destination[DMA_BUFFER_SIZE]; - * - * static void dma_init(void) - * { - * struct dma_channel_config dmach_conf; - * memset(&dmach_conf, 0, sizeof(dmach_conf)); - * - * dma_channel_set_burst_length(&dmach_conf, DMA_CH_BURSTLEN_1BYTE_gc); - * dma_channel_set_transfer_count(&dmach_conf, DMA_BUFFER_SIZE); - * - * dma_channel_set_src_reload_mode(&dmach_conf, - * DMA_CH_SRCRELOAD_TRANSACTION_gc); - * dma_channel_set_dest_reload_mode(&dmach_conf, - * DMA_CH_DESTRELOAD_TRANSACTION_gc); - * - * dma_channel_set_src_dir_mode(&dmach_conf, DMA_CH_SRCDIR_INC_gc); - * dma_channel_set_source_address(&dmach_conf, - * (uint16_t)(uintptr_t)source); - * - * dma_channel_set_dest_dir_mode(&dmach_conf, DMA_CH_DESTDIR_INC_gc); - * dma_channel_set_destination_address(&dmach_conf, - * (uint16_t)(uintptr_t)destination); - * - * dma_enable(); - * - * dma_set_callback(DMA_CHANNEL, dma_transfer_done); - * dma_channel_set_interrupt_level(&config, DMA_INT_LVL_LO); - * - * dma_channel_write_config(DMA_CHANNEL, &dmach_conf); - * dma_channel_enable(DMA_CHANNEL); - * } - * \endcode - * - * Add to \c main(): - * \code - * sysclk_init(); - * pmic_init(); - * sleepmgr_init(); - * dma_init(); - * cpu_irq_enable(); - * \endcode - * - * \subsection dma_use_case_1_setup_flow Workflow - * -# Define the DMA channel that will be used for the transfer for convenience: - * - \code #define DMA_CHANNEL 0 \endcode - * -# Define the array length that will be the used for the source and - * destination buffers located in RAM: - * - \code #define DMA_BUFFER_SIZE 1024 \endcode - * -# Create a pair of global arrays that will hold the source and destination - * data copied by the DMA controller channel when it is triggered: - * - \code - * static uint8_t source[DMA_BUFFER_SIZE]; - * static uint8_t destination[DMA_BUFFER_SIZE]; - * \endcode - * -# Create a function \c dma_init() to intialize the DMA: - * - \code - * static void dma_init(void) - * { - * // ... - * } - * \endcode - * -# Create config struct for DMA channel: - * - \code struct dma_channel_config dmach_conf; \endcode - * -# Make sure the configuration structure is zeroed out to ensure that all - * values are reset to their defaults before writing new values: - * - \code memset(&dmach_conf, 0, sizeof(dmach_conf)); \endcode - * -# Configure the DMA channel for single byte bursts, with a transfer length - * equal to the size of the source and destination buffers: - * - \code - * dma_channel_set_burst_length(&dmach_conf, DMA_CH_BURSTLEN_1BYTE_gc); - * dma_channel_set_transfer_count(&dmach_conf, DMA_BUFFER_SIZE); - * \endcode - * -# Configure the DMA channel to reset the source and destination addresses at - * the end of the complete transaction (i.e. after \c DMA_BUFFER_SIZE bytes - * copied): - * - \code - * dma_channel_set_src_reload_mode(&dmach_conf, DMA_CH_SRCRELOAD_TRANSACTION_gc); - * dma_channel_set_dest_reload_mode(&dmach_conf, DMA_CH_DESTRELOAD_TRANSACTION_gc); - * \endcode - * -# Configure the DMA channel to increment the source and destination - * addresses after each byte transferred: - * - \code - * dma_channel_set_src_dir_mode(&dmach_conf, DMA_CH_SRCDIR_INC_gc); - * dma_channel_set_dest_dir_mode(&dmach_conf, DMA_CH_DESTDIR_INC_gc); - * \endcode - * -# Configure the DMA channel source and destination addresses: - * - \code - * dma_channel_set_source_address(&dmach_conf, (uint16_t)(uintptr_t)source); - * dma_channel_set_destination_address(&dmach_conf, - * (uint16_t)(uintptr_t)destination); - * \endcode - * -# Enable the DMA module so that channels can be configured in it: - * - \code dma_enable(); \endcode - * \attention Calling dma_enable() will result in a soft-reset of the entire - * DMA module, clearing all channel configurations. If more than one - * DMA channel is to be configured, this function should be called - * only once in the application initialization procedure only. - * -# Set up the DMA channel interrupt to run at low interrupt priority, and - * link it to the user created \c dma_transfer_done() function: - * - \code - * dma_set_callback(DMA_CHANNEL, dma_transfer_done); - * dma_channel_set_interrupt_level(&config, DMA_INT_LVL_LO); - * \endcode - * -# Write the DMA channel configuration to the DMA and enable it so that - * it can be triggered to start the transfer: - * - \code - * dma_channel_write_config(DMA_CHANNEL, &dmach_conf); - * dma_channel_enable(DMA_CHANNEL); - * \endcode - * -# Initialize the clock system, PMIC driver and Sleep Manager service: - * - \code - * sysclk_init(); - * pmic_init(); - * sleepmgr_init(); - * \endcode - * -# Call our DMA init function: - * - \code dma_init(); \endcode - * -# Enable global processing of interrupts: - * - \code cpu_irq_enable(); \endcode - * - * \section dma_use_case_1_usage Usage steps - * - * \subsection dma_use_case_1_usage_code Example code - * Add to, e.g., main loop in application C-file: - * \code - * dma_channel_trigger_block_transfer(DMA_CHANNEL); - * sleepmgr_enter_sleep(); - * \endcode - * - * \subsection dma_use_case_1_usage_flow Workflow - * -# Start the DMA transfer: - * - \code dma_channel_trigger_block_transfer(DMA_CHANNEL); \endcode - * -# Sleep while waiting for the transfer to complete: - * - \code sleepmgr_enter_sleep(); \endcode - */ - -/** - * \page dma_use_case_2 Use case #2 - Event driven DMA transfer from a peripheral. - * - * This use case shows how to set up a burst DMA transfer between a peripheral - * register set and the main system memory. - * - * In this use case, the DMA is configured for: - * - Burst length: 2 bytes (one 16-bit result from the ADC peripheral) - * - Transfer count: 1024 (512 16-bit samples) - * - Source: ADC channel 0 result register - * - Destination: Buffer located in RAM - * - Source address reload mode: End of burst - * - Destination address reload mode: End of transaction - * - Source and destination address direction mode: Increment - * - * In this use case data is copied from the 16-bit ADC channel 0 result register - * to a buffer in RAM, each time the ADC indicates that a new conversion has - * completed. - * - * \section dma_use_case_2_setup Setup steps - * - * \subsection dma_basic_use_case_setup_prereq Prerequisites - * For the setup code of this use case to work, the following must - * be added to the project: - * -# \ref sysclk_group "System Clock Manager Service (sysclk)" - * - * The ADC must be configured according to the XMEGA ADC driver Quick Start - * \ref adc_basic_use_case "basic use case". - * - * \subsection dma_use_case_2_setup_code Example code - * Add to application C-file: - * \code - * #define DMA_CHANNEL 0 - * #define DMA_BUFFER_SIZE 1024 - * - * static uint16_t adc_samples[DMA_BUFFER_SIZE / 2]; - * - * static void dma_init(void) - * { - * struct dma_channel_config dmach_conf; - * memset(&dmach_conf, 0, sizeof(dmach_conf)); - * - * dma_channel_set_burst_length(&dmach_conf, DMA_CH_BURSTLEN_2BYTE_gc); - * dma_channel_set_transfer_count(&dmach_conf, DMA_BUFFER_SIZE); - * - * dma_channel_set_src_reload_mode(&dmach_conf, - * DMA_CH_SRCRELOAD_BURST_gc); - * dma_channel_set_dest_reload_mode(&dmach_conf, - * DMA_CH_DESTRELOAD_TRANSACTION_gc); - * - * dma_channel_set_src_dir_mode(&dmach_conf, DMA_CH_SRCDIR_INC_gc); - * dma_channel_set_dest_dir_mode(&dmach_conf, DMA_CH_DESTDIR_INC_gc); - * - * dma_channel_set_source_address(&dmach_conf, - * (uint16_t)(uintptr_t)&ADCA.CH0RES); - * dma_channel_set_destination_address(&dmach_conf, - * (uint16_t)(uintptr_t)adc_samples); - * - * dma_channel_set_trigger_source(&dmach_conf, DMA_CH_TRIGSRC_ADCA_CH0_gc); - * dma_channel_set_single_shot(&dmach_conf); - * - * dma_enable(); - * - * dma_set_callback(DMA_CHANNEL, dma_transfer_done); - * dma_channel_set_interrupt_level(&config, DMA_INT_LVL_LO); - * - * dma_channel_write_config(DMA_CHANNEL, &dmach_conf); - * dma_channel_enable(DMA_CHANNEL); - * } - * \endcode - * - * Add to \c main(): - * \code - * sysclk_init(); - * dma_init(); - * \endcode - * - * \subsection dma_use_case_2_setup_flow Workflow - * -# Define the DMA channel that will be used for the transfer for convenience: - * - \code #define DMA_CHANNEL 0 \endcode - * -# Define the array length that will be the used for the source and - * destination buffers located in RAM: - * - \code #define DMA_BUFFER_SIZE 1024 \endcode - * -# Create a global array that will hold the ADC sample result data copied by - * the DMA controller channel when it is triggered (the buffer size is - * halved as each sample is two bytes long): - * - \code static uint16_t adc_samples[DMA_BUFFER_SIZE / 2]; \endcode - * -# Create a function \c dma_init() to intialize the DMA: - * - \code - * static void dma_init(void) - * { - * // ... - * } - * \endcode - * -# Create config struct for DMA channel: - * - \code struct dma_channel_config dmach_conf; \endcode - * -# Make sure the configuration structure is zeroed out to ensure that all - * values are reset to their defaults before writing new values: - * - \code memset(&dmach_conf, 0, sizeof(dmach_conf)); \endcode - * -# Configure the DMA channel for two byte bursts (the size of a single ADC - * conversion) with a transfer length equal to the size of the destination - * buffer: - * - \code - * dma_channel_set_burst_length(&dmach_conf, DMA_CH_BURSTLEN_2BYTE_gc); - * dma_channel_set_transfer_count(&dmach_conf, DMA_BUFFER_SIZE); - * \endcode - * -# Configure the DMA channel to reset the source address at the end of each - * burst transfer, and the destination addresses at the end of the complete - * transaction (i.e. after \c DMA_BUFFER_SIZE bytes copied): - * - \code - * dma_channel_set_src_reload_mode(&dmach_conf, DMA_CH_SRCRELOAD_BURST_gc); - * dma_channel_set_dest_reload_mode(&dmach_conf, DMA_CH_DESTRELOAD_TRANSACTION_gc); - * \endcode - * -# Configure the DMA channel to increment the source and destination - * addresses after each byte transferred: - * - \code - * dma_channel_set_src_dir_mode(&dmach_conf, DMA_CH_SRCDIR_INC_gc); - * dma_channel_set_dest_dir_mode(&dmach_conf, DMA_CH_DESTDIR_INC_gc); - * \endcode - * -# Configure the DMA channel source and destination addresses to the ADC - * module channel 0 result registers and RAM buffer respectively: - * - \code - * dma_channel_set_source_address(&dmach_conf, - * (uint16_t)(uintptr_t)&ADCA.CH0RES); - * dma_channel_set_destination_address(&dmach_conf, - * (uint16_t)(uintptr_t)adc_samples); - * \endcode - * -# Set the DMA channel trigger source to the ADC module channel 0 complete - * event: - * - \code dma_channel_set_trigger_source(&dmach_conf, DMA_CH_TRIGSRC_ADCA_CH0_gc); \endcode - * -# Configure the DMA channel in single shot mode, so that each time it is - * triggered it will perform one bust transfer only: - * - \code dma_channel_set_single_shot(&dmach_conf); \endcode - * -# Enable the DMA module so that channels can be configured in it: - * - \code dma_enable(); \endcode - * \attention Calling dma_enable() will result in a soft-reset of the entire - * DMA module, clearing all channel configurations. If more than one - * DMA channel is to be configured, this function should be called - * only once in the application initialization procedure only. - * -# Set up the DMA channel interrupt to run at low interrupt priority, and - * link it to the user created \c dma_transfer_done() function: - * - \code - * dma_set_callback(DMA_CHANNEL, dma_transfer_done); - * dma_channel_set_interrupt_level(&config, DMA_INT_LVL_LO); - * \endcode - * -# Write the DMA channel configuration to the DMA and enable it so that - * it can be triggered to start the transfer: - * - \code - * dma_channel_write_config(DMA_CHANNEL, &dmach_conf); - * dma_channel_enable(DMA_CHANNEL); - * \endcode - * -# Initialize the clock system: - * - \code sysclk_init(); \endcode - * -# Call our DMA init function: - * - \code dma_init(); \endcode - * - * \section dma_use_case_2_usage Usage steps - * - * \subsection dma_use_case_2_usage_code Example code - * Add to, e.g., main loop in application C-file: - * \code - * adc_start_conversion(&ADCA, ADC_CH0); - * adc_wait_for_interrupt_flag(&ADCA, ADC_CH0); - * \endcode - * - * \subsection dma_use_case_2_usage_flow Workflow - * -# Start an ADC conversion, result will be automatically copied to the - * global buffer when complete: - * - \code adc_start_conversion(&ADCA, ADC_CH0); \endcode - * -# Wait for the ADC to complete before triggering the next conversion by - * polling the ADC channel 0 complete interrupt flag: - * - \code adc_wait_for_interrupt_flag(&ADCA, ADC_CH0); \endcode - */ - -#endif /* DRIVERS_DMA_DMA_H */ diff --git a/DSTAT1/src/asf/xmega/drivers/ioport/ioport.c b/DSTAT1/src/asf/xmega/drivers/ioport/ioport.c deleted file mode 100644 index d769057..0000000 --- a/DSTAT1/src/asf/xmega/drivers/ioport/ioport.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * \file - * - * \brief I/O Ports software driver interface. - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include "ioport.h" - -void ioport_configure_port_pin(void *port, pin_mask_t pin_mask,port_pin_flags_t flags) -{ - uint8_t pin; - - for (pin = 0; pin < 8; pin++) { - if (pin_mask & (1 << pin)) { - *((uint8_t*)port+PORT_PIN0CTRL+pin)=flags; - } - } - /* Select direction and initial pin state */ - if (flags & IOPORT_DIR_OUTPUT) { - if (flags & IOPORT_INIT_HIGH) { - *((uint8_t*)port+PORT_OUTSET)=pin_mask; - } - else { - *((uint8_t*)port+PORT_OUTCLR)=pin_mask; - } - *((uint8_t*)port+PORT_DIRSET)=pin_mask; - } - else { - *((uint8_t*)port+PORT_DIRCLR)=pin_mask; - } -} diff --git a/DSTAT1/src/asf/xmega/drivers/ioport/ioport.h b/DSTAT1/src/asf/xmega/drivers/ioport/ioport.h deleted file mode 100644 index d1a7785..0000000 --- a/DSTAT1/src/asf/xmega/drivers/ioport/ioport.h +++ /dev/null @@ -1,421 +0,0 @@ -/** - * \file - * - * \brief I/O Ports software driver interface. - * - * Copyright (c) 2010-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef IOPORT_H -#define IOPORT_H - -#include - -// Some parts (XMEGAB3) do not have PORT A reference -#ifndef PORTA -# define PORTA (*(PORT_t *) 0x0600) -#endif - -/** - * \defgroup port_driver_group IO PORT Driver - * - * This is a driver implementation for the I/O ports peripheral. The I/O ports - * peripheral can be found on XMEGA devices and it controls and configures the - * I/O pins. - * @{ - */ - -/** - * \brief A bitmask representing a set of pins on a port - * - * Starting from pin 0 as the LSB, each bit in the mask corresponds to - * a pin on some port. Each '1' bit includes the corresponding pin in - * the set. - */ -typedef uint8_t pin_mask_t; - -/** - * \brief A PORT pin - * - * This type is used to describe the PORT pins on the part. - */ -typedef uint8_t port_pin_t; - -/** - * \brief Pin configuration flags - * - * This is a bitmask containing configuration flags for the pins that shall be - * configured. - */ -typedef uint16_t port_pin_flags_t; - -/** - * \brief A port id - * - * This type is used to describe the port id on the part (0 is PORTA). - */ -typedef uint8_t port_id_t; - -//! \name Input/Output Configuration Flags -//@{ -#define IOPORT_DIR_INPUT (0 << 8) //!< Pin is Input -#define IOPORT_DIR_OUTPUT (1 << 8) //!< Pin is Output -//@} - -//! \name Initial Output State Flags -//@{ -#define IOPORT_INIT_LOW (0 << 9) //!< Initial Ouptput State is Low -#define IOPORT_INIT_HIGH (1 << 9) //!< Initial Ouptput State is High -//@} - -//! \name Input/Sense Configuration Flags -//@{ -#define IOPORT_BOTHEDGES (0 << 0) //!< Sense Both Edges -#define IOPORT_RISING (1 << 0) //!< Sense Risign Edge -#define IOPORT_FALLING (2 << 0) //!< Sense Falling Edge -#define IOPORT_LEVEL (3 << 0) //!< Sense Low Level -#define IOPORT_INPUT_DISABLE (7 << 0) //!< Input Buffer Disabled -//@} - -//! \name Output and Pull Configuration Flags -//@{ -#define IOPORT_TOTEM (0 << 3) //!< Normal push/pull output -#define IOPORT_BUSKEEPER (1 << 3) //!< Bus Keeper -#define IOPORT_PULL_DOWN (2 << 3) //!< Pull-Down (when input) -#define IOPORT_PULL_UP (3 << 3) //!< Pull-Up (when input) -#define IOPORT_WIRED_OR (4 << 3) //!< Wired OR -#define IOPORT_WIRED_AND (5 << 3) //!< Wired AND -#define IOPORT_WIRED_OR_PULL_DOWN (6 << 3) //!< Wired OR and Pull-Down -#define IOPORT_WIRED_AND_PULL_UP (7 << 3) //!< Wired AND and Pull-Up -//@} - -//! \name Inverted I/O Configuration Flags -//@{ -#define IOPORT_INV_ENABLED (1 << 6) //!< I/O is Inverted -#define IOPORT_INV_DISABLE (0 << 6) //!< I/O is Not Inverted -//@} - -//! \name Slew Rate Limit Configuration Flags -//@{ -#define IOPORT_SRL_ENABLED (1 << 7) //!< Slew Rate Limit Enabled -#define IOPORT_SRL_DISABLED (0 << 7) //!< Slew Rate Limit Disabled -//@} - - -/** - * \brief Create a PORT pin number - * - * This macro creates a PORT pin number from a pin on a port. The PORT pin - * number can be used with the functions provided from this driver. - * - * \param port Port name e.g. PORTA. - * \param pin Pin number on the port, valid values are 0 to 7. - */ -#define IOPORT_CREATE_PIN(port, pin) ((PORT_##port) + (pin)) - -/** - * \brief Create a pointer to a port from a PORT pin number - * - * It is assumed that all ports are lined up after PORTA in the memory map like - * it is described in the XMEGA A manual. - * Otherwise we have to do a switch case here. - * - * \param pin PORT pin number. This number can be generated by the macro - * CREATE_PORT_PIN. - * \return Pointer to the port on which the pin is located. - */ -static inline PORT_t *ioport_pin_to_port(port_pin_t pin) -{ - // Each port has an offset of 0x20 - return (PORT_t *)((uintptr_t)&PORTA + (pin >> 3) * 0x20); -} - -/** - * \brief Create a pointer to a port from a PORT id number - * - * It is assumed that all ports are lined up after PORTA in the memory map like - * it is described in the XMEGA A manual. - * Otherwise we have to do a switch case here. - * - * \param port PORT id number. (PORTA is 0, PORTB is 1 ...) - * \return Pointer to the port on which the pin is located. - */ -static inline PORT_t *ioport_id_pin_to_port(port_id_t port) -{ - // Each port has an offset of 0x20 - return (PORT_t *)((uintptr_t)&PORTA + port * 0x20); -} - -/** - * \brief Generate port pin mask form PORT pin number - * - * \param pin PORT pin number. - * \return Pin mask. - */ -static inline pin_mask_t ioport_pin_to_mask(port_pin_t pin) -{ - return 1U << (pin & 0x7); -} - -/** - * \brief Configure the IO PORT pin function for a set of pins on a port - * - * \param port Pointer to the port - * \param pin_mask Mask containing the pins that should be configured - * \param flags Bitmask of flags specifying additional configuration - * parameters. - */ -extern void ioport_configure_port_pin(void *port, pin_mask_t pin_mask, - port_pin_flags_t flags); - -/** - * \brief Select the port function for a single pin - * - * \param pin The pin to configure - * \param flags Bitmask of flags specifying additional configuration - * parameters. - */ -static inline void ioport_configure_pin(port_pin_t pin, port_pin_flags_t flags) -{ - ioport_configure_port_pin(ioport_pin_to_port(pin), ioport_pin_to_mask(pin), flags); -} - - -/** - * \brief Configure a group of I/O pins on a specified port number - * - * \param port The port number - * \param pin_mask The pin mask to configure - * \param flags Bitmask of flags specifying additional configuration - * parameters. - */ -static inline void ioport_configure_group(port_id_t port, pin_mask_t pin_mask, port_pin_flags_t flags) -{ - ioport_configure_port_pin(ioport_id_pin_to_port(port), pin_mask, flags); -} - - -/** - * \internal - * \name PORT Pin Numbering - * - * These macros are used to generate PORT pin numbers for each port with the - * CREATE_PORT_PIN macro. Each port has 8 pins so e.g. the first pin on PORTB - * gets number 8, first pin on PORTC gets 16 ... - */ -//@{ -#define PORT_PORTA (0 * 8) -#define PORT_PORTB (1 * 8) -#define PORT_PORTC (2 * 8) -#define PORT_PORTD (3 * 8) -#define PORT_PORTE (4 * 8) -#define PORT_PORTF (5 * 8) -#define PORT_PORTG (6 * 8) -#define PORT_PORTH (7 * 8) -#define PORT_PORTJ (8 * 8) -#define PORT_PORTK (9 * 8) -#define PORT_PORTL (10 * 8) -#define PORT_PORTM (11 * 8) -#define PORT_PORTN (12 * 8) -#define PORT_PORTP (13 * 8) -#define PORT_PORTQ (14 * 8) -#define PORT_PORTR (15 * 8) -//@} - -/** - * \internal - * \name PORT fields struture offset - * - * These macros are used to compute the field offset nummber with the PORT_t struture. - */ -//@{ -#define PORT_DIR 0x00 //!< Data Direction -#define PORT_DIRSET 0x01 //!< Data Direction Set -#define PORT_DIRCLR 0x02 //!< Data Direction Clear -#define PORT_DIRTGL 0x03 //!< Data Direction Toggle -#define PORT_OUT 0x04 //!< Data Output Value -#define PORT_OUTSET 0x05 //!< Data Output Value Set -#define PORT_OUTCLR 0x06 //!< Data Output Value Clear -#define PORT_OUTTGL 0x07 //!< Data Output Value Toggle -#define PORT_IN 0x08 //!< Data Input Value -#define PORT_INTCTRL 0x09 //!< Interrupt Control -#define PORT_INT0MASK 0x0A //!< Interrupt 0 Mask -#define PORT_INT1MASK 0x0B //!< Interrupt 1 Mask -#define PORT_INTFLAGS 0x0C //!< Interrupt Flags -#define PORT_PIN0CTRL 0x10 //!< Pin 0 Configuration -#define PORT_PIN1CTRL 0x11 //!< Pin 1 Configuration -#define PORT_PIN2CTRL 0x12 //!< Pin 2 Configuration -#define PORT_PIN3CTRL 0x13 //!< Pin 3 Configuration -#define PORT_PIN4CTRL 0x14 //!< Pin 4 Configuration -#define PORT_PIN5CTRL 0x15 //!< Pin 5 Configuration -#define PORT_PIN6CTRL 0x16 //!< Pin 6 Configuration -#define PORT_PIN7CTRL 0x17 //!< Pin 7 Configuration -//@} - - -/** - * \brief Drive a PORT pin to a given state - * - * This function will only have an effect if \a pin is configured as - * an output. - * - * \param pin A number identifying the pin to act on. - * \param value The desired state of the pin. \a true means drive the - * pin high (towards Vdd), while \a false means drive the pin low - * (towards Vss). - */ -static inline void ioport_set_value(port_pin_t pin, bool value) -{ - PORT_t *port = ioport_pin_to_port(pin); - if (value) - port->OUTSET=ioport_pin_to_mask(pin); - else - port->OUTCLR=ioport_pin_to_mask(pin); -} - -/** - * \brief Drive a PORT pin to a low level - * - * This function will only have an effect if \a pin is configured as - * an output. - * - * \param pin A number identifying the pin to act on. - */ -static inline void ioport_set_pin_low(port_pin_t pin) -{ - PORT_t *port = ioport_pin_to_port(pin); - port->OUTCLR=ioport_pin_to_mask(pin); -} - -/** - * \brief Drive a PORT pin to a high level - * - * This function will only have an effect if \a pin is configured as - * an output. - * - * \param pin A number identifying the pin to act on. - */ -static inline void ioport_set_pin_high(port_pin_t pin) -{ - PORT_t *port = ioport_pin_to_port(pin); - port->OUTSET=ioport_pin_to_mask(pin); -} - -/** - * \brief Read the current state of a PORT pin - * - * \param pin A number identifying the pin to read. - * \retval true The pin is currently high (close to Vdd) - * \retval false The pin is currently low (close to Vss) - */ -static inline bool ioport_get_value(port_pin_t pin) -{ - PORT_t *port = ioport_pin_to_port(pin); - return port->IN&ioport_pin_to_mask(pin); -} - -/** - * \brief Read the current state of a PORT pin and test high level - * - * \param pin A number identifying the pin to read. - * \retval true The pin is currently high (close to Vdd) - * \retval false The pin is currently low (close to Vss) - */ -static inline bool ioport_pin_is_high(port_pin_t pin) -{ - PORT_t *port = ioport_pin_to_port(pin); - return port->IN&ioport_pin_to_mask(pin); -} - -/** - * \brief Read the current state of a PORT pin and test high level - * - * \param pin A number identifying the pin to read. - * \retval true The pin is currently high (close to Vdd) - * \retval false The pin is currently low (close to Vss) - */ -static inline bool ioport_pin_is_low(port_pin_t pin) -{ - PORT_t *port = ioport_pin_to_port(pin); - return (~port->IN&ioport_pin_to_mask(pin)); -} -/** - * \brief Toggle the current state of a PORT pin - * - * \param pin A number identifying the pin to act on. - */ -static inline void ioport_toggle_pin(port_pin_t pin) -{ - pin_mask_t pin_mask = ioport_pin_to_mask(pin); - PORT_t *port = ioport_pin_to_port(pin); - port->OUTTGL = pin_mask; -} - -/*! \brief Drives a group of I/O pin of a port to high level. - * - * \param port_id The port number. - * \param port_mask The mask. - */ -static inline void ioport_set_group_high(port_id_t port_id,pin_mask_t port_mask) -{ - PORT_t *port = ioport_id_pin_to_port(port_id); - port->OUTSET = port_mask; -} - -/*! \brief Drives a group of I/O pin of a port to low level. - * - * \param port_id The port number. - * \param port_mask The mask. - */ -static inline void ioport_set_group_low(port_id_t port_id,pin_mask_t port_mask) -{ - PORT_t *port = ioport_id_pin_to_port(port_id); - port->OUTCLR = port_mask; -} - -/*! \brief Toggles a group of I/O pin of a port. - * - * \param port_id The port number. - * \param port_mask The mask. - */ -static inline void ioport_tgl_group(port_id_t port_id,pin_mask_t port_mask) -{ - PORT_t *port = ioport_id_pin_to_port(port_id); - port->OUTTGL = port_mask; -} - -/*@}*/ - -#endif /* IOPORT_H */ diff --git a/DSTAT1/src/asf/xmega/drivers/nvm/nvm.c b/DSTAT1/src/asf/xmega/drivers/nvm/nvm.c deleted file mode 100644 index 7ca3713..0000000 --- a/DSTAT1/src/asf/xmega/drivers/nvm/nvm.c +++ /dev/null @@ -1,755 +0,0 @@ -/** - * \file - * - * \brief Non Volatile Memory controller driver - * - * Copyright (C) 2010-2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include "compiler.h" -#include "ccp.h" -#include "nvm.h" -#include - -/** - * \weakgroup nvm_signature_group - * @{ - */ - -/** - * \brief Read the device serial - * - * This function returns the device serial stored in the device. - * - * \note This function is modifying the NVM.CMD register. - * If the application are using program space access in interrupts - * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts - * needs to be disabled when running EEPROM access functions. If not - * the program space reads will be corrupted. - * - * \retval storage Pointer to the structure where to store the device serial - */ -void nvm_read_device_serial(struct nvm_device_serial *storage) -{ - storage->lotnum0 = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(LOTNUM0)); - storage->lotnum1 = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(LOTNUM1)); - storage->lotnum2 = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(LOTNUM2)); - storage->lotnum3 = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(LOTNUM3)); - storage->lotnum4 = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(LOTNUM4)); - storage->lotnum5 = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(LOTNUM5)); - - storage->wafnum = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(WAFNUM)); - - storage->coordx0 = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(COORDX0)); - storage->coordx1 = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(COORDX1)); - storage->coordy0 = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(COORDY0)); - storage->coordy1 = nvm_read_production_signature_row( - nvm_get_production_signature_row_offset(COORDY1)); -} - -//! @} - -/** - * \weakgroup nvm_eeprom_group - * @{ - */ - -/** - * \brief Read one byte from EEPROM using IO mapping. - * - * This function reads one byte from EEPROM using IO-mapped access. - * If memory mapped EEPROM is enabled, this function will not work. - * - * \param addr EEPROM address, between 0 and EEPROM_SIZE - * - * \return Byte value read from EEPROM. - */ -uint8_t nvm_eeprom_read_byte(eeprom_addr_t addr) -{ - Assert(addr <= EEPROM_SIZE); - - /* Wait until NVM is ready */ - nvm_wait_until_ready(); - - /* Set address to read from */ - NVM.ADDR2 = 0x00; - NVM.ADDR1 = (addr >> 8) & 0xFF; - NVM.ADDR0 = addr & 0xFF; - - /* Issue EEPROM Read command */ - nvm_issue_command(NVM_CMD_READ_EEPROM_gc); - - return NVM.DATA0; -} - -/** - * \brief Read buffer within the eeprom - * - * \param address the address to where to read - * \param buf pointer to the data - * \param len the number of bytes to read - */ -void nvm_eeprom_read_buffer(eeprom_addr_t address, void *buf, uint16_t len) -{ - nvm_wait_until_ready(); - eeprom_enable_mapping(); - memcpy( buf,(void*)(address+MAPPED_EEPROM_START), len ); - eeprom_disable_mapping(); -} - - -/** - * \brief Write one byte to EEPROM using IO mapping. - * - * This function writes one byte to EEPROM using IO-mapped access. - * If memory mapped EEPROM is enabled, this function will not work. - * This function will cancel all ongoing EEPROM page buffer loading - * operations, if any. - * - * \param address EEPROM address (max EEPROM_SIZE) - * \param value Byte value to write to EEPROM. - */ -void nvm_eeprom_write_byte(eeprom_addr_t address, uint8_t value) -{ - uint8_t old_cmd; - - /* Flush buffer to make sure no unintentional data is written and load - * the "Page Load" command into the command register. - */ - old_cmd = NVM.CMD; - nvm_eeprom_flush_buffer(); - // Wait until NVM is ready - nvm_wait_until_ready(); - - NVM.CMD = NVM_CMD_LOAD_EEPROM_BUFFER_gc; - - Assert(address <= EEPROM_SIZE); - - // Set address to write to - NVM.ADDR2 = 0x00; - NVM.ADDR1 = (address >> 8) & 0xFF; - NVM.ADDR0 = address & 0xFF; - - // Load data to write, which triggers the loading of EEPROM page buffer - NVM.DATA0 = value; - - /* Issue EEPROM Atomic Write (Erase&Write) command. Load command, write - * the protection signature and execute command. - */ - NVM.CMD = NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc; - nvm_exec(); - NVM.CMD = old_cmd; -} - -/** - * \brief Write buffer within the eeprom - * - * \param address the address to where to write - * \param buf pointer to the data - * \param len the number of bytes to write - */ -void nvm_eeprom_erase_and_write_buffer(eeprom_addr_t address, const void *buf, uint16_t len) -{ - while (len) { - if (((address%EEPROM_PAGE_SIZE)==0) && (len>=EEPROM_PAGE_SIZE)) { - // A full page can be written - nvm_eeprom_load_page_to_buffer((uint8_t*)buf); - nvm_eeprom_atomic_write_page(address/EEPROM_PAGE_SIZE); - address += EEPROM_PAGE_SIZE; - buf = (uint8_t*)buf + EEPROM_PAGE_SIZE; - len -= EEPROM_PAGE_SIZE; - } else { - nvm_eeprom_write_byte(address++, *(uint8_t*)buf); - buf = (uint8_t*)buf + 1; - len--; - } - } -} - - -/** - * \brief Flush temporary EEPROM page buffer. - * - * This function flushes the EEPROM page buffers. This function will cancel - * any ongoing EEPROM page buffer loading operations, if any. - * This function also works for memory mapped EEPROM access. - * - * \note An EEPROM write operations will automatically flush the buffer for you. - * \note The function does not preserve the value of the NVM.CMD register - */ -void nvm_eeprom_flush_buffer(void) -{ - // Wait until NVM is ready - nvm_wait_until_ready(); - - // Flush EEPROM page buffer if necessary - if ((NVM.STATUS & NVM_EELOAD_bm) != 0) { - NVM.CMD = NVM_CMD_ERASE_EEPROM_BUFFER_gc; - nvm_exec(); - } -} - -/** - * \brief Load single byte into temporary page buffer. - * - * This function loads one byte into the temporary EEPROM page buffers. - * If memory mapped EEPROM is enabled, this function will not work. - * Make sure that the buffer is flushed before starting to load bytes. - * Also, if multiple bytes are loaded into the same location, they will - * be ANDed together, thus 0x55 and 0xAA will result in 0x00 in the buffer. - * - * \note Only one page buffer exist, thus only one page can be loaded with - * data and programmed into one page. If data needs to be written to - * different pages, the loading and writing needs to be repeated. - * - * \param byte_addr EEPROM Byte address, between 0 and EEPROM_PAGE_SIZE. - * \param value Byte value to write to buffer. - */ -void nvm_eeprom_load_byte_to_buffer(uint8_t byte_addr, uint8_t value) -{ - uint8_t old_cmd; - old_cmd = NVM.CMD; - - // Wait until NVM is ready - nvm_wait_until_ready(); - - NVM.CMD = NVM_CMD_LOAD_EEPROM_BUFFER_gc; - - // Set address - NVM.ADDR2 = 0x00; - NVM.ADDR1 = 0x00; - NVM.ADDR0 = byte_addr & 0xFF; - - // Set data, which triggers loading of EEPROM page buffer - NVM.DATA0 = value; - - NVM.CMD = old_cmd; -} - - -/** - * \brief Load entire page into temporary EEPROM page buffer. - * - * This function loads an entire EEPROM page from an SRAM buffer to - * the EEPROM page buffers. If memory mapped EEPROM is enabled, this - * function will not work. Make sure that the buffer is flushed before - * starting to load bytes. - * - * \note Only the lower part of the address is used to address the buffer. - * Therefore, no address parameter is needed. In the end, the data - * is written to the EEPROM page given by the address parameter to the - * EEPROM write page operation. - * - * \param values Pointer to SRAM buffer containing an entire page. - */ -void nvm_eeprom_load_page_to_buffer(const uint8_t *values) -{ - uint8_t old_cmd; - old_cmd = NVM.CMD; - - // Wait until NVM is ready - nvm_wait_until_ready(); - - NVM.CMD = NVM_CMD_LOAD_EEPROM_BUFFER_gc; - - /* Set address to zero, as only the lower bits matters. ADDR0 is - * maintained inside the loop below. - */ - NVM.ADDR2 = 0x00; - NVM.ADDR1 = 0x00; - - // Load multible bytes into page buffer - uint8_t i; - for (i = 0; i < EEPROM_PAGE_SIZE; ++i) { - NVM.ADDR0 = i; - NVM.DATA0 = *values; - ++values; - } - NVM.CMD = old_cmd; -} - -/** - * \brief Erase and write bytes from page buffer into EEPROM. - * - * This function writes the contents of an already loaded EEPROM page - * buffer into EEPROM memory. - * - * As this is an atomic write, the page in EEPROM will be erased - * automatically before writing. Note that only the page buffer locations - * that have been loaded will be used when writing to EEPROM. Page buffer - * locations that have not been loaded will be left untouched in EEPROM. - * - * \param page_addr EEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGE_SIZE - */ -void nvm_eeprom_atomic_write_page(uint8_t page_addr) -{ - // Wait until NVM is ready - nvm_wait_until_ready(); - - // Calculate page address - uint16_t address = (uint16_t)(page_addr * EEPROM_PAGE_SIZE); - - Assert(address <= EEPROM_SIZE); - - // Set address - NVM.ADDR2 = 0x00; - NVM.ADDR1 = (address >> 8) & 0xFF; - NVM.ADDR0 = address & 0xFF; - - // Issue EEPROM Atomic Write (Erase&Write) command - nvm_issue_command(NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc); -} - -/** - * \brief Write (without erasing) EEPROM page. - * - * This function writes the contents of an already loaded EEPROM page - * buffer into EEPROM memory. - * - * As this is a split write, the page in EEPROM will _not_ be erased - * before writing. - * - * \param page_addr EEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGE_SIZE - */ -void nvm_eeprom_split_write_page(uint8_t page_addr) -{ - // Wait until NVM is ready - nvm_wait_until_ready(); - - // Calculate page address - uint16_t address = (uint16_t)(page_addr * EEPROM_PAGE_SIZE); - - Assert(address <= EEPROM_SIZE); - - // Set address - NVM.ADDR2 = 0x00; - NVM.ADDR1 = (address >> 8) & 0xFF; - NVM.ADDR0 = address & 0xFF; - - // Issue EEPROM Split Write command - nvm_issue_command(NVM_CMD_WRITE_EEPROM_PAGE_gc); -} - -/** - * \brief Fill temporary EEPROM page buffer with value. - * - * This fills the the EEPROM page buffers with a given value. - * If memory mapped EEPROM is enabled, this function will not work. - * - * \note Only the lower part of the address is used to address the buffer. - * Therefore, no address parameter is needed. In the end, the data - * is written to the EEPROM page given by the address parameter to the - * EEPROM write page operation. - * - * \param value Value to copy to the page buffer. - */ -void nvm_eeprom_fill_buffer_with_value(uint8_t value) -{ - uint8_t old_cmd; - old_cmd = NVM.CMD; - - nvm_eeprom_flush_buffer(); - // Wait until NVM is ready - nvm_wait_until_ready(); - - NVM.CMD = NVM_CMD_LOAD_EEPROM_BUFFER_gc; - - /* Set address to zero, as only the lower bits matters. ADDR0 is - * maintained inside the loop below. - */ - NVM.ADDR2 = 0x00; - NVM.ADDR1 = 0x00; - - // Load multible bytes into page buffer - uint8_t i; - for (i = 0; i < EEPROM_PAGE_SIZE; ++i) { - NVM.ADDR0 = i; - NVM.DATA0 = value; - } - NVM.CMD = old_cmd; -} - -/** - * \brief Erase bytes from EEPROM page. - * - * This function erases bytes from one EEPROM page, so that every location - * written to in the page buffer reads 0xFF. - * - * \param page_addr EEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGE_SIZE - */ -void nvm_eeprom_erase_bytes_in_page(uint8_t page_addr) -{ - // Wait until NVM is ready - nvm_wait_until_ready(); - - // Calculate page address - uint16_t address = (uint16_t)(page_addr * EEPROM_PAGE_SIZE); - - Assert(address <= EEPROM_SIZE); - - // Set address - NVM.ADDR2 = 0x00; - NVM.ADDR1 = (address >> 8) & 0xFF; - NVM.ADDR0 = address & 0xFF; - - // Issue EEPROM Erase command - nvm_issue_command(NVM_CMD_ERASE_EEPROM_PAGE_gc); -} - -/** - * \brief Erase EEPROM page. - * - * This function erases one EEPROM page, so that every location reads 0xFF. - * - * \param page_addr EEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGE_SIZE - */ -void nvm_eeprom_erase_page(uint8_t page_addr) -{ - // Mark all addresses to be deleted - nvm_eeprom_fill_buffer_with_value(0xff); - // Erase bytes - nvm_eeprom_erase_bytes_in_page(page_addr); -} - - -/** - * \brief Erase bytes from all EEPROM pages. - * - * This function erases bytes from all EEPROM pages, so that every location - * written to in the page buffer reads 0xFF. - */ -void nvm_eeprom_erase_bytes_in_all_pages(void) -{ - // Wait until NVM is ready - nvm_wait_until_ready(); - - // Issue EEPROM Erase All command - nvm_issue_command(NVM_CMD_ERASE_EEPROM_gc); -} - -/** - * \brief Erase entire EEPROM memory. - * - * This function erases the entire EEPROM memory block to 0xFF. - */ -void nvm_eeprom_erase_all(void) -{ - // Mark all addresses to be deleted - nvm_eeprom_fill_buffer_with_value(0xff); - // Erase all pages - nvm_eeprom_erase_bytes_in_all_pages(); -} - -//! @} - - -//! @} - - -/** - * \weakgroup nvm_flash_group - * @{ - */ - -/** - * \brief Issue flash range CRC command - * - * This function sets the FLASH range CRC command in the NVM.CMD register. - * It then loads the start and end byte address of the part of FLASH to - * generate a CRC-32 for into the ADDR and DATA registers and finally performs - * the execute command. - * - * \note Should only be called from the CRC module. The function saves and - * restores the NVM.CMD register, but if this - * function is called from an interrupt, interrupts must be disabled - * before this function is called. - * - * \param start_addr end byte address - * \param end_addr start byte address - */ -void nvm_issue_flash_range_crc(flash_addr_t start_addr, flash_addr_t end_addr) -{ - uint8_t old_cmd; - // Save current nvm command - old_cmd = NVM.CMD; - - // Load the NVM CMD register with the Flash Range CRC command - NVM.CMD = NVM_CMD_FLASH_RANGE_CRC_gc; - - // Load the start byte address in the NVM Address Register - NVM.ADDR0 = start_addr & 0xFF; - NVM.ADDR1 = (start_addr >> 8) & 0xFF; -#if (FLASH_SIZE >= 0x10000UL) - NVM.ADDR2 = (start_addr >> 16) & 0xFF; -#endif - - // Load the end byte address in NVM Data Register - NVM.DATA0 = end_addr & 0xFF; - NVM.DATA1 = (end_addr >> 8) & 0xFF; -#if (FLASH_SIZE >= 0x10000UL) - NVM.DATA2 = (end_addr >> 16) & 0xFF; -#endif - - // Execute command - ccp_write_io((uint8_t *)&NVM.CTRLA, NVM_CMDEX_bm); - - // Restore command register - NVM.CMD = old_cmd; -} - -/** - * \brief Read buffer within the application section - * - * \param address the address to where to read - * \param buf pointer to the data - * \param len the number of bytes to read - */ -void nvm_flash_read_buffer(flash_addr_t address, void *buf, uint16_t len) -{ -#if (FLASH_SIZE>0x10000) - uint32_t opt_address = address; -#else - uint16_t opt_address = (uint16_t)address; -#endif - nvm_wait_until_ready(); - while ( len ) { - *(uint8_t*)buf = nvm_flash_read_byte(opt_address); - buf=(uint8_t*)buf+1; - opt_address++; - len--; - } -} - -/** - * \brief Read buffer within the user section - * - * \param address the address to where to read - * \param buf pointer to the data - * \param len the number of bytes to read - */ -void nvm_user_sig_read_buffer(flash_addr_t address, void *buf, uint16_t len) -{ - uint16_t opt_address = (uint16_t)address&(FLASH_PAGE_SIZE-1); - while ( len ) { - *(uint8_t*)buf = nvm_read_user_signature_row(opt_address); - buf=(uint8_t*)buf+1; - opt_address++; - len--; - } -} - -/** - * \brief Write specific parts of user flash section - * - * \param address the address to where to write - * \param buf pointer to the data - * \param len the number of bytes to write - * \param b_blank_check if True then the page flash is checked before write - * to run or not the erase page command. - * - * Set b_blank_check to false if all application flash is erased before. - */ -void nvm_user_sig_write_buffer(flash_addr_t address, const void *buf, - uint16_t len, bool b_blank_check) -{ - uint16_t w_value; - uint16_t page_pos; - uint16_t opt_address = (uint16_t)address; - bool b_flag_erase = false; - - while ( len ) { - for (page_pos=0; page_pos0x10000) - uint32_t page_address; - uint32_t opt_address = address; -#else - uint16_t page_address; - uint16_t opt_address = (uint16_t)address; -#endif - - // Compute the start of the page to be modified - page_address = opt_address-(opt_address%FLASH_PAGE_SIZE); - - // For each page - while ( len ) { - b_flag_erase = false; - - nvm_wait_until_ready(); - for (page_pos=0; page_pos -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup nvm_group NVM driver - * - * See \ref xmega_nvm_quickstart - * - * \brief Low-level driver implementation for the AVR XMEGA Non Volatile - * Memory Controller (NVM). - * - * The XMEGA NVM controller interfaces the internal non-volatile memories - * in the XMEGA devices. Program memory, EEPROM and signature row is can be - * interfaced by the module. See the documentation of each sub-module for - * more information. - * - * \note If using GCC and the flash sub-module, remember to configure - * the boot section in the make file. More information in the sub-module - * documentation. - * - * \section xmega_nvm_quickstart_section Quick Start Guide - * See \ref xmega_nvm_quickstart - */ - -/** - * \defgroup nvm_generic_group NVM driver generic module handling - * \ingroup nvm_group - * \brief Support functions for the NVM driver. - * - * These functions are helper functions for the functions of the - * \ref nvm_group "NVM driver". - * - * @{ - */ - -/** - * \brief Wait for any NVM access to finish. - * - * This function is blocking and waits for any NVM access to finish. - * Use this function before any NVM accesses, if you are not certain that - * any previous operations are finished yet. - */ -static inline void nvm_wait_until_ready( void ) -{ - do { - // Block execution while waiting for the NVM to be ready - } while ((NVM.STATUS & NVM_NVMBUSY_bm) == NVM_NVMBUSY_bm); -} - -/** - * \brief Non-Volatile Memory Execute Command - * - * This function sets the CCP register before setting the CMDEX bit in the - * NVM.CTRLA register. - * - * \note The correct NVM command must be set in the NVM.CMD register before - * calling this function. - */ -static inline void nvm_exec(void) -{ - ccp_write_io((uint8_t *)&NVM.CTRLA, NVM_CMDEX_bm); -} - -/** - * \brief Non-Volatile Memory Execute Specific Command - * - * This function sets a command in the NVM.CMD register, then performs an - * execute command by writing the CMDEX bit to the NVM.CTRLA register. - * - * \note The function saves and restores the NVM.CMD register, but if this - * function is called from an interrupt, interrupts must be disabled - * before this function is called. - * - * \param nvm_command NVM Command to execute. - */ -static inline void nvm_issue_command(NVM_CMD_t nvm_command) -{ - uint8_t old_cmd; - - old_cmd = NVM.CMD; - NVM.CMD = nvm_command; - ccp_write_io((uint8_t *)&NVM.CTRLA, NVM_CMDEX_bm); - NVM.CMD = old_cmd; -} - -/** - * \brief Read one byte using the LDI instruction - * \internal - * - * This function sets the specified NVM_CMD, reads one byte using at the - * specified byte address with the LPM instruction. NVM_CMD is restored after - * use. - * - * \note Interrupts should be disabled before running this function - * if program memory/NVM controller is accessed from ISRs. - * - * \param nvm_cmd NVM commad to load before running LPM - * \param address Byte offset into the signature row - */ -uint8_t nvm_read_byte(uint8_t nvm_cmd, uint16_t address); - - -/** - * \brief Perform SPM write - * \internal - * - * This function sets the specified NVM_CMD, sets CCP and then runs the SPM - * instruction to write to flash. - * - * \note Interrupts should be disabled before running this function - * if program memory/NVM controller is accessed from ISRs. - * - * \param addr Address to perform the SPM on. - * \param nvm_cmd NVM command to use in the NVM_CMD register - */ -void nvm_common_spm(uint32_t addr, uint8_t nvm_cmd); - -//! @} - -/** - * \defgroup nvm_signature_group NVM driver signature handling - * \ingroup nvm_group - * \brief Handling of signature rows - * - * Functions for handling signature rows. The following is supported: - * - Reading values from production and user signature row - * - Reading device id - * - Reading device revision - * - Reading device serial - * - * \note Some of these functions are modifying the NVM.CMD register. - * If the application are using program space access in interrupts - * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts - * needs to be disabled when running EEPROM access functions. If not, - * the program space reads will be corrupted. See documentation for - * each individual function. - * \note Do not use the functions of this module in an interrupt service - * routine (ISR), since the functions can take several milliseconds to - * complete and hence block the interrupt for several milliseconds. - * In addition the functions of this module are modifying the page buffer - * which will corrupt any ongoing EEPROM handing used outside an ISR. - * @{ - */ - -/** - * \brief Structure containing the device ID - * - * This structure can be used to store the device ID of a device. - */ -struct nvm_device_id { - union { - struct { - uint8_t devid0; - uint8_t devid1; - uint8_t devid2; - }; - uint8_t byte[3]; - }; -}; - -/** - * \brief Structure containing the device serial - * - * This structure can be used to store the serial number of a device. - */ -struct nvm_device_serial { - union { - struct { - uint8_t lotnum0; - uint8_t lotnum1; - uint8_t lotnum2; - uint8_t lotnum3; - uint8_t lotnum4; - uint8_t lotnum5; - uint8_t wafnum; - uint8_t coordx0; - uint8_t coordx1; - uint8_t coordy0; - uint8_t coordy1; - }; - uint8_t byte[11]; - }; -}; - -/** - * \brief Get offset of calibration bytes in the production signature row - * - * \param regname Name of register within the production signature row - * \retval Offset of register into the production signature row - */ -#if defined(__GNUC__) -# define nvm_get_production_signature_row_offset(regname) \ - offsetof(NVM_PROD_SIGNATURES_t, regname) -#elif defined(__ICCAVR__) -# define nvm_get_production_signature_row_offset(regname) (regname##_offset) -#else -# error Unknown compiler -#endif - - -/** - * \brief Read one byte from the production signature row - * - * This function reads one byte from the production signature row of the device - * at the given address. - * - * \note This function is modifying the NVM.CMD register. - * If the application are using program space access in interrupts - * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts - * needs to be disabled when running EEPROM access functions. If not - * the program space reads will be corrupted. - * - * \param address Byte offset into the signature row - */ -static inline uint8_t nvm_read_production_signature_row(uint8_t address) -{ - return nvm_read_byte(NVM_CMD_READ_CALIB_ROW_gc, address); -} - -/** - * \brief Read one byte from the user signature row - * - * This function reads one byte from the user signature row of the device - * at the given address. - * - * \note This function is modifying the NVM.CMD register. - * If the application are using program space access in interrupts - * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts - * needs to be disabled when running EEPROM access functions. If not - * the program space reads will be corrupted. - * - * \param address Byte offset into the signature row - */ -static inline uint8_t nvm_read_user_signature_row(uint16_t address) -{ - return nvm_read_byte(NVM_CMD_READ_USER_SIG_ROW_gc, address); -} - -/** - * \brief Read the device id - * - * This function returns the device ID stored in the device. - * - * \retval storage Pointer to the structure where to store the device id - */ -static inline void nvm_read_device_id(struct nvm_device_id *storage) -{ - storage->devid0 = MCU.DEVID0; - storage->devid1 = MCU.DEVID1; - storage->devid2 = MCU.DEVID2; -} - -/** - * \brief Read the device revision - * - * This function returns the device revision stored in the device. - * - * \retval unsigned 8 bit value with the current device revision. - */ -static inline uint8_t nvm_read_device_rev(void) -{ - return MCU.REVID; -} - -void nvm_read_device_serial(struct nvm_device_serial *storage); - -//! @} - - -/** - * \defgroup nvm_eeprom_group NVM driver EEPROM handling - * \ingroup nvm_group - * \brief Functions for handling internal EEPROM memory. - * - * The internal EEPROM can be used to store data that will persist after - * power is removed. This can typically be used to store calibration data, - * application state, encryption keys or other data that need to be preserved - * when power is removed. - * - * The functions in this module uses IO register access to manipulate the - * EEPROM. - * - * \note The functions in this module are modifying the NVM.CMD register. - * If the application are using program space access in interrupts - * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts - * needs to be disabled when running EEPROM access functions. If not - * the program space reads will be corrupted. - * @{ - */ - -#ifndef EEPROM_PAGE_SIZE -# if XMEGA_A || XMEGA_AU || XMEGA_B || XMEGA_C || XMEGA_D -# define EEPROM_PAGE_SIZE 32 -# else -# error Unknown EEPROM page size -# endif -#endif - -#ifndef CONFIG_NVM_IGNORE_XMEGA_A3_D3_REVB_ERRATA -# if XMEGA_A3 || XMEGA_D3 -# error This NVM driver does not support rev B of XMEGA A3/D3 devices. \ - Set CONFIG_NVM_IGNORE_XMEGA_A3_D3_REVB_ERRATA to disable this message -# endif -#endif - -/** - * Data type for holding eeprom memory addresses. - */ -typedef uint16_t eeprom_addr_t; - - -/*! \brief Enable EEPROM mapping into data space. - * - * This macro enables mapping of EEPROM into data space. - * EEPROM starts at EEPROM_START in data memory. Read access - * can be done similar to ordinary SRAM access. - * - * \note This disables IO-mapped access to EEPROM, although page erase and - * write operations still needs to be done through IO register. - */ -static inline void eeprom_enable_mapping(void) -{ - NVM_CTRLB = NVM_CTRLB | NVM_EEMAPEN_bm; -} - - -/*! \brief Disable EEPROM mapping into data space. - * - * This macro disables mapping of EEPROM into data space. - * IO mapped access is now enabled. - */ -static inline void eeprom_disable_mapping(void) -{ - NVM_CTRLB = NVM_CTRLB & ~NVM_EEMAPEN_bm; -} - - -uint8_t nvm_eeprom_read_byte(eeprom_addr_t addr); -void nvm_eeprom_write_byte(eeprom_addr_t address, uint8_t value); -void nvm_eeprom_read_buffer(eeprom_addr_t address, void *buf, uint16_t len); -void nvm_eeprom_erase_and_write_buffer(eeprom_addr_t address, const void *buf, uint16_t len); - -void nvm_eeprom_flush_buffer(void); -void nvm_eeprom_load_byte_to_buffer(uint8_t byte_addr, uint8_t value); -void nvm_eeprom_load_page_to_buffer(const uint8_t *values); -void nvm_eeprom_atomic_write_page(uint8_t page_addr); -void nvm_eeprom_split_write_page(uint8_t page_addr); -void nvm_eeprom_fill_buffer_with_value(uint8_t value); -void nvm_eeprom_erase_bytes_in_page(uint8_t page_addr); -void nvm_eeprom_erase_page(uint8_t page_addr); -void nvm_eeprom_erase_bytes_in_all_pages(void); -void nvm_eeprom_erase_all(void); - -//! @} - -/** - * \defgroup nvm_flash_group NVM driver flash handling - * \ingroup nvm_group - * \brief Functions for handling internal flash memory. - * - * The internal flash memory on the XMEGA devices consists of the application - * section, the application table section and the bootloader section. - * All these sections can store program code for the MCU, but if there is - * available space, they can be used for storing other persistent data. - * - * Writing the flash memory can only be done one page at a time. It consists - * of loading the data to the internal page buffer and then running one of - * the write commands. If the page has not been erased before writing, the - * data will not be written correctly. - * - * In order to be able to write to flash memory the programming commands need - * to be run from the boot section. - * - When using IAR this is handled automatically by the linker script. - * - When using GCC this needs to be specified manually in the make files. For - * example the ATxmega128A1 has the boot section at the word address 0x10000 - * the corresponding byte address of 0x20000 needs to be added to the - * config.mk makefile: - * LDFLAGS += -Wl,--section-start=.BOOT=0x20000 - * See the device datasheet for the correct address for other devices. - * - * \note If using GCC and the flash sub-module, remember to configure - * the boot section in the make file. - * - * \note The functions in this module are modifying the NVM.CMD register. - * If the application are using program space access in interrupts - * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts - * needs to be disabled when running EEPROM access functions. If not - * the program space reads will be corrupted. - * @{ - */ - -/** - * \brief Size of a flash page in bytes - * - * The page size in bytes taken from the toolchain header files. - * - * \note Page size is currently missing from the IAR header files, so it needs - * to be defined in the driver until it is fixed. - */ -#ifdef __DOXYGEN__ -# define FLASH_SIZE -# define FLASH_PAGE_SIZE -#else - -// 16K devices -# if part_is_defined(ATxmega16A4) | \ - part_is_defined(ATxmega16A4U) | \ - part_is_defined(ATxmega16D4) | \ - part_is_defined(ATxmega16C4) -# define FLASH_SIZE (16*1024L) -# define FLASH_PAGE_SIZE (256) - -// 32K devices -# elif part_is_defined(ATxmega32A4) | \ - part_is_defined(ATxmega32A4U) | \ - part_is_defined(ATxmega32D4) | \ - part_is_defined(ATxmega32C4) -# define FLASH_SIZE (32*1024L) -# define FLASH_PAGE_SIZE (256) - -// 64K devices -# elif part_is_defined(ATxmega64A1) | \ - part_is_defined(ATxmega64A1U) | \ - part_is_defined(ATxmega64A3) | \ - part_is_defined(ATxmega64A3U) | \ - part_is_defined(ATxmega64A4U) | \ - part_is_defined(ATxmega64B1) | \ - part_is_defined(ATxmega64B3) | \ - part_is_defined(ATxmega64D3) | \ - part_is_defined(ATxmega64D4) -# define FLASH_SIZE (64*1024L) -# define FLASH_PAGE_SIZE (256) - -// 128K devices -# elif part_is_defined(ATxmega128A1) | \ - part_is_defined(ATxmega128A1U) | \ - part_is_defined(ATxmega128A3) | \ - part_is_defined(ATxmega128A3U) | \ - part_is_defined(ATxmega128A4U) | \ - part_is_defined(ATxmega128B1) | \ - part_is_defined(ATxmega128B3) | \ - part_is_defined(ATxmega128D3) | \ - part_is_defined(ATxmega128D4) -# define FLASH_SIZE (128*1024L) -# define FLASH_PAGE_SIZE (512) - -// 192K devices -# elif part_is_defined(ATxmega192A3U) | \ - part_is_defined(ATxmega192D3) -# define FLASH_SIZE (192*1024L) -# define FLASH_PAGE_SIZE (512) - -// 256K devices -# elif part_is_defined(ATxmega256A3) | \ - part_is_defined(ATxmega256A3U) | \ - part_is_defined(ATxmega256A3B) | \ - part_is_defined(ATxmega256A3BU) | \ - part_is_defined(ATxmega256C3) | \ - part_is_defined(ATxmega256D3) -# define FLASH_SIZE (256*1024L) -# define FLASH_PAGE_SIZE (512) - -// 384K devices -# elif part_is_defined(ATxmega384C3) -# define FLASH_SIZE (384*1024L) -# define FLASH_PAGE_SIZE (512) -# elif part_is_defined(ATxmega384D3) -# define FLASH_SIZE (384*1024L) -# define FLASH_PAGE_SIZE (512) -# else -# error Flash page size needs to be defined. -# endif -#endif - -/** - * Data type for holding flash memory addresses. - * - */ -#if (FLASH_SIZE >= 0x10000UL) // Note: Xmega with 64KB of flash have 4KB boot flash -typedef uint32_t flash_addr_t; -#else -typedef uint16_t flash_addr_t; -#endif - -/** - * Flash pointer type to use for accessing flash memory with IAR - */ -#if (FLASH_SIZE >= 0x10000UL) // Note: Xmega with 64KB of flash have 4KB boot flash -# define IAR_FLASH_PTR __farflash -#else -# define IAR_FLASH_PTR __flash -#endif - -/** - * \brief Load byte from flash memory - * - * Load one word of flash using byte addressing. IAR has __flash pointers - * and GCC have pgm_read_byte_xx functions which load data from flash memory. - * This function used for compatibility between the compilers. - * - * \param addr Byte address to load - * \return Byte from program memory - */ -static inline uint8_t nvm_flash_read_byte(flash_addr_t addr) -{ -#if defined(__GNUC__) - return pgm_read_byte_far(addr); -#elif defined(__ICCAVR__) - uint8_t IAR_FLASH_PTR *flashptr = (uint8_t IAR_FLASH_PTR *)addr; - return *flashptr; -#else -# error Unknown compiler -#endif -} - -/** - * \brief Load word from flash memory - * - * Load one word of flash using byte addressing. IAR has __flash pointers - * and GCC have pgm_read_byte_xx functions which load data from flash memory. - * This function used for compatibility between the compilers. - * - * \param addr Byte address to load (last bit is ignored) - * \return Word from program memory - */ -static inline uint16_t nvm_flash_read_word(flash_addr_t addr) -{ -#if defined(__GNUC__) - return pgm_read_word_far(addr); -#elif defined(__ICCAVR__) - uint16_t IAR_FLASH_PTR *flashptr = (uint16_t IAR_FLASH_PTR *)addr; - return *flashptr; -#endif -} - - -/** - * \brief Flush flash page buffer - * - * Clear the NVM controller page buffer for flash. This needs to be called - * before using \ref nvm_flash_load_word_to_buffer if it has not already been - * cleared. - * - */ -static inline void nvm_flash_flush_buffer(void) -{ - nvm_wait_until_ready(); - nvm_common_spm(0, NVM_CMD_ERASE_FLASH_BUFFER_gc); -} - - -/** - * \brief Load word into flash page buffer - * - * Clear the NVM controller page buffer for flash. This needs to be called - * before using \ref nvm_flash_load_word_to_buffer if it has not already been - * cleared. - * - * \param word_addr Address to store data. The upper bits beyond the page size - * is ignored. \ref FLASH_PAGE_SIZE - * \param data Data word to load into the page buffer - */ -void nvm_flash_load_word_to_buffer(uint32_t word_addr, uint16_t data); - - -/** - * \brief Erase entire application section - * - * Erase all of the application section. - */ -static inline void nvm_flash_erase_app(void) -{ - nvm_wait_until_ready(); - nvm_common_spm(0, NVM_CMD_ERASE_APP_gc); -} - -/** - * \brief Erase a page within the application section - * - * Erase one page within the application section - * - * \param page_addr Byte address to the page to delete - */ -static inline void nvm_flash_erase_app_page(flash_addr_t page_addr) -{ - nvm_wait_until_ready(); - nvm_common_spm(page_addr, NVM_CMD_ERASE_APP_PAGE_gc); -} - -/** - * \brief Write a page within the application section - * - * Write a page within the application section with the data stored in the - * page buffer. The page needs to be erased before the write to avoid - * corruption of the data written. - * - * \param page_addr Byte address to the page to delete - */ -static inline void nvm_flash_split_write_app_page(flash_addr_t page_addr) -{ - nvm_wait_until_ready(); - nvm_common_spm(page_addr, NVM_CMD_WRITE_APP_PAGE_gc); -} - -/** - * \brief Erase and write a page within the application section - * - * Erase and the write a page within the application section with the data - * stored in the page buffer. Erase and write is done in an atomic operation. - * - * \param page_addr Byte address to the page to delete - */ -static inline void nvm_flash_atomic_write_app_page(flash_addr_t page_addr) -{ - nvm_wait_until_ready(); - nvm_common_spm(page_addr, NVM_CMD_ERASE_WRITE_APP_PAGE_gc); -} - -void nvm_issue_flash_range_crc(flash_addr_t start_addr, flash_addr_t end_addr); - -void nvm_flash_read_buffer(flash_addr_t address, void *buf, uint16_t len); - -void nvm_flash_erase_and_write_buffer(flash_addr_t address, const void *buf, - uint16_t len, bool b_blank_check); - -/** - * \brief Erase a page within the boot section - * - * Erase one page within the boot section - * - * \param page_addr Byte address to the page to delete - */ -static inline void nvm_flash_erase_boot_page(flash_addr_t page_addr) -{ - nvm_wait_until_ready(); - nvm_common_spm(page_addr, NVM_CMD_ERASE_BOOT_PAGE_gc); -} - -/** - * \brief Write a page within the boot section - * - * Write a page within the boot section with the data stored in the - * page buffer. The page needs to be erased before the write to avoid - * corruption of the data written. - * - * \param page_addr Byte address to the page to delete - */ -static inline void nvm_flash_split_write_boot_page(flash_addr_t page_addr) -{ - nvm_wait_until_ready(); - nvm_common_spm(page_addr, NVM_CMD_WRITE_BOOT_PAGE_gc); -} - -/** - * \brief Erase and write a page within the boot section - * - * Erase and the write a page within the boot section with the data - * stored in the page buffer. Erase and write is done in an atomic operation. - * - * \param page_addr Byte address to the page to delete - */ -static inline void nvm_flash_atomic_write_boot_page(flash_addr_t page_addr) -{ - nvm_wait_until_ready(); - nvm_common_spm(page_addr, NVM_CMD_ERASE_WRITE_BOOT_PAGE_gc); -} - -void nvm_user_sig_read_buffer(flash_addr_t address, void *buf, uint16_t len); -void nvm_user_sig_write_buffer(flash_addr_t address, const void *buf, - uint16_t len, bool b_blank_check); - -/** - * \brief Erase the user calibration section page - * - * Erase the user calibration section page. There is only one page, so no - * paramaters are needed. - */ -static inline void nvm_flash_erase_user_section(void) -{ - nvm_wait_until_ready(); - nvm_common_spm(0, NVM_CMD_ERASE_USER_SIG_ROW_gc); -} - -/** - * \brief Write the user calibration section page - * - * Write a the user calibratino section page with the data stored in the - * page buffer. The page needs to be erased before the write to avoid - * corruption of the data written. There is only one page, so no - * paramaters are needed. - */ -static inline void nvm_flash_write_user_page(void) -{ - nvm_wait_until_ready(); - nvm_common_spm(0, NVM_CMD_WRITE_USER_SIG_ROW_gc); -} - -//! @} - -/** - * \defgroup nvm_fuse_lock_group NVM driver fuse and lock bits handling - * \ingroup nvm_group - * \brief Functions for reading fuses and writing lock bits. - * - * The Fuses are used to set important system functions and can only be written - * from an external programming interface. The application software can read - * the fuses. The fuses are used to configure reset sources such as Brown-out - * Detector and Watchdog, Start-up configuration, JTAG enable and JTAG user ID. - * - * The Lock bits are used to set protection level on the different flash - * sections. They are used to block read and/or write on the different flash - * sections. Lock bits can be written from en external programmer and from the - * application software to set a more strict protection level, but not to set a - * less strict protection level. Chip erase is the only way to erase the lock - * bits. The lock bits are erased after the rest of the flash memory is erased. - * An unprogrammed fuse or lock bit will have the value one, while a programmed - * fuse or lock bit will have the value zero. - * Both fuses and lock bits are reprogrammable like the Flash Program memory. - * - * \note The functions in this module are modifying the NVM.CMD register. - * If the application are using program space access in interrupts - * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts - * needs to be disabled when running EEPROM access functions. If not - * the program space reads will be corrupted. - * @{ - */ - -// The different fuse bytes -enum fuse_byte_t { - FUSEBYTE0 = 0, - FUSEBYTE1 = 1, - FUSEBYTE2 = 2, - FUSEBYTE3 = 3, // not used on current devices - FUSEBYTE4 = 4, - FUSEBYTE5 = 5, -}; - -uint8_t nvm_fuses_read(enum fuse_byte_t fuse); - -/** - * \brief Program the lock bits. - * - * Program the lock bits to the given values. Lock bits can only be programmed - * to a more secure setting than previously programmed. To clear lock bits, a - * flash erase has to be issued. - * - * \param blbb_lock Boot loader section lock bits to program - * \param blba_lock Application section lock bits to program - * \param blbat_lock Application table section lock bits to program - * \param lb_lock Flash/eeprom lock bits to program - */ -static inline void nvm_lock_bits_write(enum NVM_BLBB_enum blbb_lock, - enum NVM_BLBA_enum blba_lock, enum NVM_BLBAT_enum blbat_lock, - enum NVM_LB_enum lb_lock) -{ - nvm_wait_until_ready(); - NVM.DATA0 = (uint8_t)blbb_lock | (uint8_t)blba_lock | (uint8_t)blbat_lock | - (uint8_t)lb_lock; - nvm_issue_command(NVM_CMD_WRITE_LOCK_BITS_gc); -} - -/** - * \brief Program the BLBB lock bits. - * - * Program the lock bits for the boot loader section (BLBB). Other lock bits - * (BLBA, BLBAT and LB) are not altered (ie. programmed to NOLOCK). - * - * \param blbb_lock Boot loader section lock bits to program - */ -static inline void nvm_blbb_lock_bits_write(enum NVM_BLBB_enum blbb_lock) -{ - nvm_lock_bits_write(blbb_lock, NVM_BLBA_NOLOCK_gc, NVM_BLBAT_NOLOCK_gc, - NVM_LB_NOLOCK_gc); -} - -/** - * \brief Program the BLBA lock bits. - * - * Program the lock bits for the application section (BLBA). Other lock bits - * (BLBB, BLBAT and LB) are not altered (ie. programmed to NOLOCK). - * - * \param blba_lock Application section lock bits to program - */ -static inline void nvm_blba_lock_bits_write(enum NVM_BLBA_enum blba_lock) -{ - nvm_lock_bits_write(NVM_BLBB_NOLOCK_gc, blba_lock, NVM_BLBAT_NOLOCK_gc, - NVM_LB_NOLOCK_gc); -} - -/** - * \brief Program the BLBAT lock bits. - * - * Program the lock bits for the application table section (BLBAT). Other lock - * bits (BLBB, BLBA and LB) are not altered (ie. programmed to NOLOCK). - * - * \param blbat_lock Application table section lock bits to program - */ -static inline void nvm_blbat_lock_bits_write(enum NVM_BLBAT_enum blbat_lock) -{ - nvm_lock_bits_write(NVM_BLBB_NOLOCK_gc, NVM_BLBA_NOLOCK_gc, blbat_lock, - NVM_LB_NOLOCK_gc); -} - -/** - * \brief Program the LB lock bits. - * - * Program the lock bits for the flash and eeprom (LB). Other lock bits - * (BLBB, BLBA and BLBAT) are not altered (ie. programmed to NOLOCK). - * - * \param lb_lock Flash/eeprom lock bits to program - */ -static inline void nvm_lb_lock_bits_write(enum NVM_LB_enum lb_lock) -{ - nvm_lock_bits_write(NVM_BLBB_NOLOCK_gc, NVM_BLBA_NOLOCK_gc, - NVM_BLBAT_NOLOCK_gc, lb_lock); -} - -//! @} - -/** - * \page xmega_nvm_quickstart Quick Start Guide for the XMEGA NVM Driver - * - * This is the quick start guide for the \ref nvm_group "NVM Driver", with - * step-by-step instructions on how to configure and use the driver for - * specific use cases. - * - * The section described below can be compiled into e.g. the main application - * loop or any other function that will need to interface non-volatile memory. - * - * \section xmega_nvm_quickstart_basic Basic usage of the NVM driver - * This section will present three use cases of the NVM driver. The first will - * write a page to EEPROM and verify that it has been written, the second will - * access the BOD-level fuse to verify that the level is correctly set, and the - * third will read a chunk from the user signature row. - * - * \section xmega_nvm_quickstart_eeprom_case Use case 1: EEPROM - * - * The NVM driver has functions for interfacing many types of non-volatile - * memory, including flash, EEPROM, fuses and lock bits. The example code - * below will write a page to the internal EEPROM, and read it back to verify, - * using memory mapped I/O. - * - * \section xmega_nvm_quickstart_eeprom_case_setup_steps Setup steps - * There are no setup steps required for this use case. - * - * \subsection nvm_quickstart_eeprom_case_example_code Example code - * - * \code - * #define EXAMPLE_PAGE 2 - * #define EXAMPLE_ADDR EXAMPLE_PAGE * EEPROM_PAGE_SIZE - * - * uint8_t write_page[EEPROM_PAGE_SIZE]; - * uint8_t read_page[EEPROM_PAGE_SIZE]; - * - * fill_page_with_known_data(write_page); - * fill_page_with_zeroes(read_page); - * - * nvm_eeprom_load_page_to_buffer(write_page); - * nvm_eeprom_atomic_write_page(EXAMPLE_PAGE); - * - * nvm_eeprom_read_buffer(EXAMPLE_ADDR, - * read_page, EEPROM_PAGE_SIZE); - * - * check_if_pages_are_equal(write_page, read_page); - * \endcode - * - * \subsection nvm_quickstart_eeprom_case_workflow Workflow - * - * -# We define where we would like to store our data, and we arbitrarily - * choose page 2 of EEPROM: - * - \code - * #define EXAMPLE_PAGE 2 - * #define EXAMPLE_ADDR EXAMPLE_PAGE * EEPROM_PAGE_SIZE - * \endcode - * -# Define two tables, one which contains the data which we will write, - * and one which we will read the data into: - * - \code - * uint8_t write_page[EEPROM_PAGE_SIZE]; - * uint8_t read_page[EEPROM_PAGE_SIZE]; - * \endcode - * -# Fill the tables with our data, and zero out the read table: - * - \code - * fill_page_with_known_data(write_page); - * fill_page_with_zeroes(read_page); - * \endcode - * - \note These functions are undeclared, you should replace them with - * your own appropriate functions. - * -# We load our page into a temporary EEPROM page buffer: - * - \code - * nvm_eeprom_load_page_to_buffer(write_page); - * \endcode - * - \attention The function used above will not work if memory mapping - * is enabled. - * -# Do an atomic write of the page from buffer into the specified page: - * - \code - * nvm_eeprom_atomic_write_page(EXAMPLE_PAGE); - * \endcode - * - \note The function \ref nvm_eeprom_atomic_write_page() erases the - * page before writing the new one. For non-atomic (split) - * writing without deleting, see \ref nvm_eeprom_split_write_page() - * -# Read the page back into our read_page[] table: - * - \code - * nvm_eeprom_read_buffer(EXAMPLE_ADDR, - * read_page, EEPROM_PAGE_SIZE); - * \endcode - * -# Verify that the page is equal to the one that was written earlier: - * - \code - * check_if_pages_are_equal(write_page, read_page); - * \endcode - * - \note This function is not declared, you should replace it with your - * own appropriate function. - * - * \section xmega_nvm_quickstart_fuse_case Use case 2: Fuses - * - * The NVM driver has functions for reading fuses. - * See \ref nvm_fuse_lock_group. - * - * We would like to check whether the Brown-out Detection level is set to - * 2.1V. This is set by programming the fuses when the chip is connected - * to a suitable programmer. The fuse is a part of FUSEBYTE5. If the BODLVL - * is correct, we turn on LED0. - * - * \section xmega_nvm_quickstart_fuse_case_setup_steps Setup steps - * There are no setup steps required for this use case. - * - * \subsection nvm_quickstart_fuse_case_example_code Example code - * \code - * uint8_t fuse_value; - * fuse_value = nvm_fuses_read(FUSEBYTE5); - * - * if ((fuse_value & NVM_FUSES_BODLVL_gm) == BODLVL_2V1_gc) { - * gpio_set_pin_low(LED0_GPIO); - * } - * \endcode - * - * \subsection nvm_quickstart_fuse_case_workflow Workflow - * - * -# Create a variable to store the fuse contents: - * - \code - * uint8_t fuse_value; - * \endcode - * -# The fuse value we are interested in, BODLVL, is stored in FUSEBYTE5. - * We call the function \ref nvm_fuses_read() to read the fuse into our - * variable: - * - \code - * fuse_value = nvm_fuses_read(FUSEBYTE5); - * \endcode - * -# This ends the reading portion, but we would like to see whether the - * BOD-level is correct, and if it is, light up an LED: - * - \code - * if ((fuse_value & NVM_FUSES_BODLVL_gm) == BODLVL_2V1_gc) { - * gpio_set_pin_low(LED0_GPIO); - * } - * \endcode - * - * \section xmega_nvm_quickstart_signature_case Use case 3: Signature row - * - * The NVM driver has functions for reading the signature row of the device. - * Here we will simply read 16 bytes from the user signature row, assuming - * we need what is stored there. - * - * \section xmega_nvm_quickstart_signature_row_setup_steps Setup steps - * There are no setup steps required for this use case. - * - * \subsection xmega_nvm_quickstart_signature_row_example_code Example code - * - * \code - * #define START_ADDR 0x10 - * #define DATA_LENGTH 16 - * - * uint8_t values[LENGTH]; - * uint8_t i; - * - * for (i = 0; i < DATA_LENGTH; i++) { - * values[i] = nvm_read_user_signature_row(START_ADDR + i); - * } - * \endcode - * - * \subsection nvm_quickstart_signature_case_workflow Workflow - * - * -# Define starting address and length of data segment, and create - * variables needed to store and process the data: - * - \code - * #define START_ADDR 0x10 - * #define DATA_LENGTH 16 - * - * uint8_t values[LENGTH]; - * uint8_t i; - * \endcode - * -# Iterate through the user signature row, and store our desired data: - * - \code - * for (i = 0; i < DATA_LENGTH; i++) { - * values[i] = nvm_read_user_signature_row(START_ADDR + i); - * } - * \endcode - * - */ - -#ifdef __cplusplus -} -#endif - -#endif /* NVM_H */ diff --git a/DSTAT1/src/asf/xmega/drivers/nvm/nvm_asm.s b/DSTAT1/src/asf/xmega/drivers/nvm/nvm_asm.s deleted file mode 100644 index 328b55b..0000000 --- a/DSTAT1/src/asf/xmega/drivers/nvm/nvm_asm.s +++ /dev/null @@ -1,195 +0,0 @@ -/** - * \file - * - * \brief Non Volatile Memory controller driver - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include - -#if defined(__GNUC__) -//! Value to write to CCP for access to protected IO registers. -# define CCP_SPM_gc 0x9D - -//! NVM busy flag -# define NVM_NVMBUSY_bp 7 - -//! NVM command for loading flash buffer -# define NVM_CMD_LOAD_FLASH_BUFFER_gc 0x23 -#elif defined(__IAR_SYSTEMS_ASM__) -// All values are defined for IAR -#else -# error Unknown assembler -#endif - -#ifndef __DOXYGEN__ - PUBLIC_FUNCTION(nvm_read_byte) -#if defined(__GNUC__) - lds r20, NVM_CMD ; Store NVM command register - mov ZL, r22 ; Load byte index into low byte of Z. - mov ZH, r23 ; Load high byte into Z. - sts NVM_CMD, r24 ; Load prepared command into NVM Command register. - lpm r24, Z ; Perform an LPM to read out byte - sts NVM_CMD, r20 ; Restore NVM command register -#elif defined(__IAR_SYSTEMS_ASM__) - lds r20, NVM_CMD ; Store NVM command register - mov ZL, r18 ; Load byte index into low byte of Z. - mov ZH, r19 ; Load high byte into Z. - sts NVM_CMD, r16 ; Load prepared command into NVM Command register. - lpm r16, Z ; Perform an LPM to read out byte - sts NVM_CMD, r20 ; Restore NVM command register -#endif - - ret - - END_FUNC(nvm_read_byte) - -// IAR forgets about include files after each module, so need to include again -#if defined(__IAR_SYSTEMS_ASM__) -# include -#endif - - /** - * \brief Perform SPM command - */ - PUBLIC_FUNCTION_SEGMENT(nvm_common_spm, BOOT) - -#if defined(__GNUC__) - /** - * For GCC: - * \param address uint32_t r22:r25 - * \param nvm_cmd uint8_t r20 - */ - in r25, RAMPZ ; Store RAMPZ. Highest address byte is ignored, so using that - out RAMPZ, r24 ; Load R24 into RAMPZ - movw ZL, r22 ; Load R22:R23 into Z. - lds r24, NVM_CMD ; Store NVM command register (r24 is no longer needed) - sts NVM_CMD, r20 ; Load prepared command into NVM Command register. - ldi r23, CCP_SPM_gc ; Prepare Protect SPM signature (r23 is no longer needed) - sts CCP, r23 ; Enable SPM operation (this disables interrupts for 4 cycles). - spm ; Self-program. - sts NVM_CMD, r24 ; Restore NVM command register - out RAMPZ, r25 ; Restore RAMPZ register. -#elif defined(__IAR_SYSTEMS_ASM__) - /** - * For IAR: - * \param address uint32_t r16:r19 - * \param nvm_cmd uint8_t r20 - */ - in r19, RAMPZ ; Store RAMPZ. Highest address byte is ignored, so using that - out RAMPZ, r18 ; Load R18 into RAMPZ - movw ZL, r16 ; Load R16:R17 into Z. - lds r18, NVM_CMD ; Store NVM command register (r18 is no longer needed) - sts NVM_CMD, r20 ; Load prepared command into NVM Command register. - ldi r19, CCP_SPM_gc ; Prepare Protect SPM signature (r19 is no longer needed) - sts CCP, r19 ; Enable SPM operation (this disables interrupts for 4 cycles). - spm ; Self-program. - sts NVM_CMD, r18 ; Restore NVM command register - out RAMPZ, r19 ; Restore RAMPZ register. -#endif - - ret - - END_FUNC(nvm_common_spm) - -// IAR forgets about include files after each module, so need to include again -#if defined(__IAR_SYSTEMS_ASM__) -# include -#endif - - /** - * \brief Load byte to page buffer - * - */ - PUBLIC_FUNCTION_SEGMENT(nvm_flash_load_word_to_buffer, BOOT) - -#if defined(__GNUC__) - /** - * For GCC: - * \param word_addr uint32_t r22:r25 - * \param data uint16_t r20:r21 - */ -wait_nvm: - lds r18, NVM_STATUS - sbrc r18, NVM_NVMBUSY_bp - rjmp wait_nvm - - in r25, RAMPZ ; Store RAMPZ. Highest address byte is ignored, so using that - out RAMPZ, r24 ; Load R24 into RAMPZ - movw ZL, r22 ; Load R22:R23 into Z. - - lds r24, NVM_CMD ; Store NVM command register (r24 is no longer needed) - ldi r18, NVM_CMD_LOAD_FLASH_BUFFER_gc - sts NVM_CMD, r18 ; Load prepared command into NVM Command register. - - movw r0, r20 ; Load R20:R21 into R0:R1 - spm ; Self-program. - - clr r1 ; Clear R1 for GCC _zero_reg_ to function properly. - sts NVM_CMD, r24 ; Restore NVM command register - out RAMPZ, r25 ; Restore RAMPZ register. -#elif defined(__IAR_SYSTEMS_ASM__) - /** - * For IAR: - * \param word_addr uint32_t r16:r19 - * \param data uint16_t r20:r21 - */ -wait_nvm: - lds r19, NVM_STATUS - sbrc r19, NVM_NVMBUSY_bp - rjmp wait_nvm - - in r19, RAMPZ ; Store RAMPZ. Highest byte is ignored, so using that - out RAMPZ, r18 ; Load R18 into RAMPZ - movw ZL, r16 ; Load R16:R17 into Z. - - lds r18, NVM_CMD ; Store NVM command register (r18 is no longer needed) - ldi r17, NVM_CMD_LOAD_FLASH_BUFFER_gc - sts NVM_CMD, r17 ; Load prepared command into NVM Command register. - - movw r0, r20 ; Load R20:R21 into R0:R1 - spm ; Self-program. - - sts NVM_CMD, r18 ; Restore NVM command register - out RAMPZ, r19 ; Restore RAMPZ register. -#endif - - ret - - END_FUNC(nvm_flash_load_word_to_buffer) - - END_FILE() -#endif // __DOXYGEN__ diff --git a/DSTAT1/src/asf/xmega/drivers/pmic/pmic.h b/DSTAT1/src/asf/xmega/drivers/pmic/pmic.h deleted file mode 100644 index fd7d242..0000000 --- a/DSTAT1/src/asf/xmega/drivers/pmic/pmic.h +++ /dev/null @@ -1,347 +0,0 @@ -/** - * \file - * - * \brief Programmable Multilevel Interrupt Controller driver - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef PMIC_H -#define PMIC_H - -#include -#include - -/** - * \defgroup pmic_group Programmable Multilevel Interrupt Controller - * - * See \ref pmic_quickstart. - * - * This is a low-level driver implementation for the AVR XMEGA Programmable - * Multilevel Interrupt Controller. - * - * \note If these functions are used in interrupt service routines (ISRs), any - * non-ISR code or ISR code for lower level interrupts must ensure that the - * operations are atomic, i.e., by disabling interrupts during the function - * calls. - * @{ - */ - -/** - * \brief Interrupt level bitmasks - * - * \note These may be OR'ed, e.g., if multiple levels are to be enabled or - * disabled. - */ -enum pmic_level { - PMIC_LVL_LOW = PMIC_LOLVLEN_bm, //!< Low-level interrupts - PMIC_LVL_MEDIUM = PMIC_MEDLVLEN_bm, //!< Medium-level interrupts - PMIC_LVL_HIGH = PMIC_HILVLEN_bm, //!< High-level interrupts - /** - * \brief Non-maskable interrupts - * \note These cannot be enabled nor disabled. - */ - PMIC_LVL_NMI = PMIC_NMIEX_bp, -}; - -//! Interrupt vector locations -enum pmic_vector { - PMIC_VEC_APPLICATION, //!< Application section - PMIC_VEC_BOOT, //!< Boot section - PMIC_NR_OF_VECTORS, //!< Number of interrupt vector locations -}; - -//! Interrupt scheduling schemes -enum pmic_schedule { - PMIC_SCH_FIXED_PRIORITY, //!< Default, fixed priority scheduling - PMIC_SCH_ROUND_ROBIN, //!< Round-robin scheduling - PMIC_NR_OF_SCHEDULES, //!< Number of interrupt scheduling schemes -}; - -/** - * \brief Initialize the PMIC - * - * Enables all interrupt levels, with vectors located in the application section - * and fixed priority scheduling. - */ -static inline void pmic_init(void) -{ - PMIC.CTRL = PMIC_LVL_LOW | PMIC_LVL_MEDIUM | - PMIC_LVL_HIGH; -} - -/** - * \brief Enable interrupts with specified \a level(s). - * - * \param level Interrupt level(s) to enable. - */ -static inline void pmic_enable_level(enum pmic_level level) -{ - Assert((level & PMIC_LVL_NMI)); - - PMIC.CTRL |= level; -} - -/** - * \brief Disable interrupts with specified \a level(s). - * - * \param level Interrupt level(s) to disable. - */ -static inline void pmic_disable_level(enum pmic_level level) -{ - Assert((level & PMIC_LVL_NMI)); - - PMIC.CTRL &= ~level; -} - -/** - * \brief Check if specified interrupt \a level(s) is enabled. - * - * \param level Interrupt level(s) to check. - * - * \return True if interrupt level(s) is enabled. - */ -static inline bool pmic_level_is_enabled(enum pmic_level level) -{ - Assert((level & PMIC_LVL_NMI)); - - return PMIC.CTRL & level; -} - -/** - * \brief Get currently enabled level(s) - * - * \return Bitmask with currently enabled levels. - */ -static inline enum pmic_level pmic_get_enabled_levels(void) -{ - return (enum pmic_level)(PMIC.CTRL & (PMIC_LVL_LOW | PMIC_LVL_MEDIUM - | PMIC_LVL_HIGH)); -} - -/** - * \brief Check if an interrupt level(s) is currently executing. - * - * \param level Interrupt level(s) to check. - * - * \return True if interrupt level(s) is currently executing. - */ -static inline bool pmic_level_is_executing(enum pmic_level level) -{ - return PMIC.STATUS & level; -} - -/** - * \brief Set interrupt scheduling for low-level interrupts. - * - * \param schedule Interrupt scheduling method to set. - * - * \note The low-priority vector, INTPRI, must be set to 0 when round-robin - * scheduling is disabled to return to default interrupt priority order. - */ -static inline void pmic_set_scheduling(enum pmic_schedule schedule) -{ - Assert(schedule < PMIC_NR_OF_SCHEDULES); - - switch (schedule) { - case PMIC_SCH_FIXED_PRIORITY: - PMIC.CTRL &= ~PMIC_RREN_bm; - PMIC.INTPRI = 0; - break; - - case PMIC_SCH_ROUND_ROBIN: - PMIC.CTRL |= PMIC_RREN_bm; - break; - - default: - break; - }; -} - -/** - * \brief Set location of interrupt vectors. - * - * \param vector Location to use for interrupt vectors. - */ -static inline void pmic_set_vector_location(enum pmic_vector vector) -{ - uint8_t ctrl = PMIC.CTRL; - - Assert(vector < PMIC_NR_OF_VECTORS); - - switch (vector) { - case PMIC_VEC_APPLICATION: - ctrl &= ~PMIC_IVSEL_bm; - break; - - case PMIC_VEC_BOOT: - ctrl |= PMIC_IVSEL_bm; - break; - - default: - break; - } - - ccp_write_io((uint8_t*)&PMIC.CTRL, ctrl); -} - -//! @} - -/** - * \page pmic_quickstart Quick start guide for PMIC driver - * - * This is the quick start guide for the \ref pmic_group "PMIC driver" and - * the closely related \ref interrupt_group "global interrupt driver", with - * step-by-step instructions on how to configure and use the drivers in a - * selection of use cases. - * - * The use cases contain several code fragments. The code fragments in the - * steps for setup can be copied into a custom initialization function, while - * the steps for usage can be copied into, e.g., the main application function. - * - * \section pmic_basic_use_case Basic use case - * In this basic use case, the PMIC is configured for: - * - all interrupt levels enabled - * - round-robin scheduling - * - * This will allow for interrupts from other modules being used. - * - * \section pmic_basic_use_case_setup Setup steps - * - * \subsection pmic_basic_use_case_setup_prereq Prerequisites - * For the setup code of this use case to work, the following must - * be added to the project: - * -# Interrupts for the module requiering the PMIC module have to be - * enabled. - * -# An Interrupt Service Routine (ISR) for a given interrupt vector has to be - * defined, where the interrupt vectors available are defined by toolchain and - * listed in the subsection 'Interrupt Vector Summary' in the data sheet. - * \code - * ISR(interrupt_vector){ - * //Interrupt Service Routine - * } - * \endcode - * - * \subsection pmic_basic_use_case_setup_code Example code - * Add to the initialization code: - * \code - * pmic_init(); - * pmic_set_scheduling(PMIC_SCH_ROUND_ROBIN); - * cpu_irq_enable(); - * \endcode - * - * \subsection pmic_basic_use_case_setup_flow Workflow - * -# call the PMIC driver's own init function to enable all interrupt levels: - * - \code pmic_init(); \endcode - * -# enable round-robin instead of fixed priority interrupt scheduling: - * - \code pmic_set_scheduling(PMIC_SCH_ROUND_ROBIN); \endcode - * -# enable interrupts globally: - * - \code cpu_irq_enable(); \endcode - * - \attention Interrupts will not trigger without this step. - * - * \section pmic_use_cases Advanced use cases - * For more advanced use of the PMIC driver, see the following use cases: - * - \subpage pmic_use_case_1 : atomic operations - */ - -/** - * \page pmic_use_case_1 Use case #1 - * - * In this use case, the PMIC is configured for: - * - all interrupt levels enabled - * - * This will allow for interrupts from other modules being used. - * - * This use case shows how to make an operation which consists of multiple - * instructions uninterruptible, i.e., into an atomic operation. This is often - * necessary if there is a risk that data can be accessed by interrupt handlers - * while other code is accessing it, and at least one of them modifies it. - * - * \section pmic_use_case_1_setup Setup steps - * - * \subsection pmic_basic_use_case_setup_prereq Prerequisites - * For the setup code of this use case to work, the following must - * be added to the project: - * -# Interrupts for the module requiering the PMIC module have to be - * enabled. - * -# An Interrupt Service Routine (ISR) for a given interrupt vector has to be - * defined, where the interrupt vectors available are defined by toolchain and - * listed in the subsection 'Interrupt Vector Summary' in the data sheet. - * \code - * ISR(interrupt_vector){ - * //Interrupt Service Routine - * } - * \endcode - * - * \subsection pmic_use_case_1_setup_code Example code - * Add to application initialization: - * \code - * pmic_init(); - * cpu_irq_enable(); - * \endcode - * - * \subsection pmic_use_case_1_setup_flow Workflow - * -# call the PMIC driver's own init function to enable all interrupt levels: - * - \code pmic_init(); \endcode - * -# set global interrupt enable flag: - * - \code cpu_irq_enable(); \endcode - * - * \section pmic_use_case_1_usage Usage steps - * - * \subsection pmic_use_case_1_usage_code Example code - * \code - * Add to application: - * void atomic_operation(void) - * { - * irqflags_t flags; - * - * flags = cpu_irq_save(); - * - * // Uninterruptible block of code - * - * cpu_irq_restore(flags); - * } - * \endcode - * - * \subsection pmic_use_case_1_usage_flow Workflow - * -# allocate temporary storage for interrupt enable: - * - \code irqflags_t flags; \endcode - * -# clear global interrupt enable flag while saving its previous state: - * - \code flags = cpu_irq_save(); \endcode - * -# restore the previous state of global interrupt flag after operation: - * - \code cpu_irq_restore(flags); \endcode - */ - -#endif /* PMIC_H */ diff --git a/DSTAT1/src/asf/xmega/drivers/rtc/rtc.c b/DSTAT1/src/asf/xmega/drivers/rtc/rtc.c deleted file mode 100644 index 1f6a597..0000000 --- a/DSTAT1/src/asf/xmega/drivers/rtc/rtc.c +++ /dev/null @@ -1,226 +0,0 @@ -/** - * \file - * - * \brief AVR XMEGA Real Time Counter driver - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include -#include -#include -#include - -#ifdef CONFIG_RTC_OVERFLOW_INT_LEVEL -# define RTC_OVERFLOW_INT_LEVEL CONFIG_RTC_OVERFLOW_INT_LEVEL -#else -# define RTC_OVERFLOW_INT_LEVEL RTC_OVFINTLVL_LO_gc -#endif - -#ifdef CONFIG_RTC_COMPARE_INT_LEVEL -# define RTC_COMPARE_INT_LEVEL CONFIG_RTC_COMPARE_INT_LEVEL -#else -# define RTC_COMPARE_INT_LEVEL RTC_COMPINTLVL_LO_gc -#endif - -/** - * \internal - * \brief Driver private struct - */ -struct rtc_data_struct { - //! High value of counter - uint16_t counter_high; - //! High value of alarm time - uint16_t alarm_high; - //! Low value of alarm time - uint16_t alarm_low; - //! Callback function to use on alarm - rtc_callback_t callback; -}; - -/** - * \internal - * \brief Driver private data - */ -struct rtc_data_struct rtc_data; - -/** - * \internal - * \brief Check if RTC is busy synchronizing - */ -static __always_inline bool rtc_is_busy(void) -{ - return RTC.STATUS & RTC_SYNCBUSY_bm; -} - -/** - * \brief Check if pending alarm have triggered - * - * \retval true Alarm have triggered - * \retval false Alarm is pending - */ -__always_inline bool rtc_alarm_has_triggered(void) -{ - return !(RTC.INTCTRL & RTC_COMPARE_INT_LEVEL ); -} - -/** - * \brief Set current time - * - * \param time Time value to set - */ -void rtc_set_time(uint32_t time) -{ - RTC.CTRL = RTC_PRESCALER_OFF_gc; - - while (rtc_is_busy()); - - RTC.CNT = time; - rtc_data.counter_high = time >> 16; - RTC.CTRL = CONFIG_RTC_PRESCALER; -} - -/** - * \brief Get current time - * - * \return Current time value - * - * \note Due to errate, this can return old values shortly after waking up from - * sleep. - */ -uint32_t rtc_get_time(void) -{ - irqflags_t flags; - uint16_t count_high; - uint16_t count_low; - - flags = cpu_irq_save(); - count_high = rtc_data.counter_high; - count_low = RTC.CNT; - // Test for possible pending increase of high count value - if ((count_low == 0) && (RTC.INTFLAGS & RTC_OVFIF_bm)) - count_high++; - cpu_irq_restore(flags); - - return ((uint32_t)count_high << 16) | count_low; -} - -/** - * \brief Set alarm time - * - * Will set absolute alarm time that will call the callback specifed by \ref - * rtc_set_callback on completion. Or possibly use \ref - * rtc_alarm_has_triggered to check for it. - * - * Any pending alarm will be overwritten with this function. - * - * \param time Absolute time value. See also \ref rtc_min_alarm_time - * \pre Needs interrupts disabled if used from several contexts - */ -void rtc_set_alarm(uint32_t time) -{ - RTC.INTCTRL = RTC_OVERFLOW_INT_LEVEL; - RTC.COMP = time; - rtc_data.alarm_low = time; - rtc_data.alarm_high = time >> 16; - - while (rtc_is_busy()); - - RTC.INTFLAGS = RTC_COMPIF_bm; - RTC.INTCTRL = (uint8_t)RTC_COMPARE_INT_LEVEL - | (uint8_t)RTC_OVERFLOW_INT_LEVEL; -} - -/** - * \brief Set callback to call on alarm - * - * \param callback Callback function pointer - */ -void rtc_set_callback(rtc_callback_t callback) -{ - rtc_data.callback = callback; -} - -/** - * \brief Initialize the RTC - * - * Start up the RTC and start counting from 0 - */ -void rtc_init(void) -{ - sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_RTC); - CLK.RTCCTRL = CONFIG_RTC_CLOCK_SOURCE | CLK_RTCEN_bm; - RTC.PER = 0xffff; - RTC.CNT = 0; - /* Since overflow interrupt is needed all the time we limit sleep to - * power-save. - */ - sleepmgr_lock_mode(SLEEPMGR_PSAVE); - RTC.INTCTRL = RTC_OVERFLOW_INT_LEVEL; - RTC.CTRL = CONFIG_RTC_PRESCALER; -} - -/** - * \internal - * \brief Overflow interrupt handling high counter - */ -ISR(RTC_OVF_vect) -{ - rtc_data.counter_high++; -} - -/** - * \internal - * \brief Compare interrupt used for alarm - */ -ISR(RTC_COMP_vect) -{ - if (rtc_data.counter_high >= rtc_data.alarm_high) { - RTC.INTCTRL = RTC_OVERFLOW_INT_LEVEL; - if (rtc_data.callback) { - uint32_t count = ((uint32_t)rtc_data.counter_high << 16) - | RTC.CNT; - uint32_t alarm = ((uint32_t)rtc_data.alarm_high << 16) - | rtc_data.alarm_low; - /* Workaround for errata. Count might not be updated - * when waking up from sleep, so in this case use alarm - * time pluss one. - */ - if (alarm >= count) - count = alarm + 1; - rtc_data.callback(count); - } - } -} diff --git a/DSTAT1/src/asf/xmega/drivers/rtc/rtc.h b/DSTAT1/src/asf/xmega/drivers/rtc/rtc.h deleted file mode 100644 index befc464..0000000 --- a/DSTAT1/src/asf/xmega/drivers/rtc/rtc.h +++ /dev/null @@ -1,292 +0,0 @@ -/** - * \file - * - * \brief AVR XMEGA Real Time Counter driver definitions - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef DRIVERS_RTC_RTC_H -#define DRIVERS_RTC_RTC_H - -#include -#include - -/** - * \defgroup rtc_group Real Time Counter (RTC) - * - * See \ref rtc_quickstart. - * - * This is a driver implementation for the XMEGA RTC. - * - * \section rtc_min_alarm_time Minimum allowed alarm time - * - * If current time is close to a time unit roll over, there is a risk to miss - * this when using a value of 0. - * - * A safe use of this can be in an alarm callback. - * - * @{ - */ - -/** - * \def CONFIG_RTC_COMPARE_INT_LEVEL - * \brief Configuration symbol for interrupt level to use on alarm - * - * Possible values: - * - RTC_COMPINTLVL_LO_gc - * - RTC_COMPINTLVL_MED_gc - * - RTC_COMPINTLVL_HI_gc - */ -#ifdef __DOXYGEN__ -# define CONFIG_RTC_COMPARE_INT_LEVEL -#endif - -/** - * \def CONFIG_RTC_OVERFLOW_INT_LEVEL - * \brief Configuration symbol for interrupt level to use on overflow - * - * Possible values: - * - RTC_OVFINTLVL_LO_gc - * - RTC_OVFINTLVL_MED_gc - * - RTC_OVFINTLVL_HI_gc - */ -#ifdef __DOXYGEN__ -# define CONFIG_RTC_OVERFLOW_INT_LEVEL -#endif - -/** - * \def CONFIG_RTC_PRESCALER - * \brief Configuration symbol for prescaler to use - * - * Possible values: - * - RTC_PRESCALER_DIV1_gc - * - RTC_PRESCALER_DIV2_gc - * - RTC_PRESCALER_DIV8_gc - * - RTC_PRESCALER_DIV16_gc - * - RTC_PRESCALER_DIV64_gc - * - RTC_PRESCALER_DIV256_gc - * - RTC_PRESCALER_DIV1024_gc - */ -#ifdef __DOXYGEN__ -# define CONFIG_RTC_PRESCALER -#endif - -/** - * \def CONFIG_RTC_CLOCK_SOURCE - * \brief Configuration symbol for which clock source to use - * - * Possible values: - * - CLK_RTCSRC_ULP_gc - * - CLK_RTCSRC_TOSC_gc - * - CLK_RTCSRC_RCOSC_gc - * - CLK_RTCSRC_TOSC32_gc - */ -#ifdef __DOXYGEN__ -# define CONFIG_RTC_CLOCK_SOURCE -#endif - -/** - * \brief Callback definition for alarm callback - * - * \param time The time of the alarm - */ -typedef void (*rtc_callback_t)(uint32_t time); - -void rtc_set_callback(rtc_callback_t callback); -void rtc_set_time(uint32_t time); -uint32_t rtc_get_time(void); -void rtc_set_alarm(uint32_t time); -bool rtc_alarm_has_triggered(void); - -/** - * \brief Set alarm relative to current time - * - * \param offset Offset to current time. This is minimum value, so the alarm - * might happen at up to one time unit later. See also \ref - * rtc_min_alarm_time - * - * \note Due to errata, this can be unsafe to do shortly after waking up from - * sleep. - */ -static inline void rtc_set_alarm_relative(uint32_t offset) -{ - rtc_set_alarm(rtc_get_time() + offset); -} - -extern void rtc_init(void); - -//! @} - -/** - * \page rtc_quickstart Quick start guide for RTC driver - * - * This is the quick start guide for the \ref rtc_group "RTC driver", with - * step-by-step instructions on how to configure and use the drivers in a - * selection of use cases. - * - * The use cases contain several code fragments. The code fragments in the - * steps for setup can be copied into a custom initialization function, while - * the steps for usage can be copied into, e.g., the main application function. - * - * \section rtc_basic_use_case Basic use case - * In this basic use case, the RTC is configured for: - * - Clock source: 1 kHz from internal 32 kHz ULP - * - Prescaling: RTC clock/1024 - * - * \section rtc_basic_use_case_setup Setup steps - * - * \subsection rtc_basic_use_case_setup_code Example code - * Content of conf_rtc.h: - * \code - * #define CONFIG_RTC_PRESCALER RTC_PRESCALER_DIV1024_gc - * #define CONFIG_RTC_CLOCK_SOURCE CLK_RTCSRC_ULP_gc - * \endcode - * Add to the initialization code: - * \code - * sysclk_init(); - * rtc_init(); - * \endcode - * - * \subsection rtc_basic_use_case_setup_flow Workflow - * -# Ensure that conf_rtc.h is present for the driver. - * - \note This configuration file is used by the driver and - * should not be included by the user. - * -# Initialize system clock: - * - \code sysclk_init(); \endcode - * -# Call RTC driver's own init function to start up the RTC and start - * counting from zero: - * - \code rtc_init(); \endcode - * - * \section rtc_basic_use_case_usage Usage steps - * - * \subsection rtc_basic_use_case_usage_code Example code - * Add to, e.g., main loop in application C-file: - * \code - * rtc_get_time(); - * \endcode - * - * \subsection rtc_basic_use_case_usage_flow Workflow - * -# Get current time of the RTC: - * - \code rtc_get_time(); \endcode - * - * \section rtc_use_cases Advanced use cases - * For more advanced use of the RTC driver, see the following use cases: - * - \subpage rtc_use_case_1 : - */ - -/** - * \page rtc_use_case_1 Use case #1 - * - * In this use case, the RTC is configured for: - * - Clock source: 1 kHz from internal 32 kHz ULP - * - Prescaling: RTC clock/1024 - * - * This use case shows how to set an alarm for the RTC. - * - * \section rtc_use_case_1_setup Setup steps - * - * \subsection rtc_basic_use_case_setup_prereq Prerequisites - * For the setup code of this use case to work, the following must - * be added to the project: - * -# PMIC for interrupt handling. - * -# Sleep Managager. - * -# A \ref rtc_callback_t "callback" function, called alarm, that - * reschedules the alarm must be provided by the user: - * \code - * static void alarm(uint32_t time) - * { - * rtc_set_alarm(time); - * } - * \endcode - * - * \subsection rtc_use_case_1_setup_code Example code - * Content of conf_rtc.h: - * \code - * #define CONFIG_RTC_PRESCALER RTC_PRESCALER_DIV1024_gc - * #define CONFIG_RTC_CLOCK_SOURCE CLK_RTCSRC_ULP_gc - * \endcode - * Add to application initialization: - * \code - * pmic_init(); - * sysclk_init(); - * sleepmgr_init(); - * rtc_init(); - * rtc_set_callback(alarm); - * cpu_irq_enable(); - * \endcode - * - * \subsection rtc_use_case_1_setup_flow Workflow - * -# Ensure that conf_rtc.h is present for the driver. - * - \note This configuration file is used by the driver and - * should not be included by the user. - * -# Call the init function of the PMIC driver to enable all interrupt levels: - * - \code pmic_init(); \endcode - * -# Initialize system clock: - * - \code sysclk_init(); \endcode - * -# Call the init function of the sleep manager driver to be able to sleep - * waiting for alarm: - * - \code sleepmgr_init(); \endcode - * -# Call RTC driver's own init function to start up the RTC and start - * counting from zero: - * - \code rtc_init(); \endcode - * -# Set callback function to call on alarm: - * - \code rtc_set_callback(alarm); \endcode - * - \note The callback function alarm must be defined by the user. - * -# Enable interrupts globally: - * - \code cpu_irq_enable(); \endcode - * - * \section rtc_use_case_1_usage Usage steps - * - * \subsection rtc_use_case_1_usage_code Example code - * \code - * rtc_set_alarm_relative(0); - * while (true) { - * sleepmgr_enter_sleep(); - * } - * \endcode - * - * \subsection rtc_use_case_1_usage_flow Workflow - * -# Set the alarm to trigget on next time unit roll over: - * - \code rtc_set_alarm_relative(0); \endcode - * -# Sleep between each triggered alarm: - * - \code - * while (true) { - * sleepmgr_enter_sleep(); - * } - * \endcode - */ - -#endif /* RTC_H */ diff --git a/DSTAT1/src/asf/xmega/drivers/sleep/sleep.h b/DSTAT1/src/asf/xmega/drivers/sleep/sleep.h deleted file mode 100644 index 19ef9bb..0000000 --- a/DSTAT1/src/asf/xmega/drivers/sleep/sleep.h +++ /dev/null @@ -1,164 +0,0 @@ -/** - * \file - * - * \brief Sleep controller driver - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef SLEEP_H -#define SLEEP_H - -#include - -/** - * \defgroup sleep_group Sleep controller driver - * - * This is a low-level driver implementation for the AVR XMEGA sleep controller. - * - * \note To minimize the code overhead, these functions do not feature - * interrupt-protected access since they are likely to be called inside - * interrupt handlers or in applications where such protection is not - * necessary. If such protection is needed, it must be ensured by the calling - * code. - * - * \section xmega_sleep_quickstart_section Quick Start Guide - * See \ref xmega_sleep_quickstart - * @{ - */ - -#if defined(__ICCAVR__) || defined(__DOXYGEN__) -# include -//! Macro for issuing the sleep instruction. -# define sleep_enter() __sleep() - -/** - * \brief Enable sleep - */ -static inline void sleep_enable(void) -{ - SLEEP.CTRL |= SLEEP_SEN_bm; -} - -/** - * \brief Disable sleep - */ -static inline void sleep_disable(void) -{ - SLEEP.CTRL &= ~SLEEP_SEN_bm; -} - -#elif defined(__GNUC__) -# include -# define sleep_enter() sleep_cpu() - -#else -# error Unsupported compiler. -#endif - -/** - * \brief Set new sleep mode - * - * \param mode Sleep mode, from the device IO header file. - */ -static inline void sleep_set_mode(enum SLEEP_SMODE_enum mode) -{ - SLEEP.CTRL = mode | (SLEEP.CTRL & ~SLEEP_SMODE_gm); -} - -//! @} - -/** - * \page xmega_sleep_quickstart Quick Start Guide for the XMEGA Sleep Driver - * - * This is the quick start guide for the \ref sleep_group "Sleep Driver", with - * step-by-step instructions on how to configure and use the driver for a - * specific use case. - * - * The section described below can be copied into, e.g. the main application - * loop or any other function that will need to control and execute different - * sleep modes on the device. - * - * \section xmega_sleep_quickstart_basic Basic usage of the sleep driver - * This use case will prepare the device to enter the Power Down sleep mode and - * then enter the sleep mode. After waking up it will disable sleep. - * - * \section xmega_sleep_basic_usage Usage steps - * \subsection xmega_sleep_basic_usage_code Example code - * Add to, e.g., the main loop in the application C-file: - * \code - * sleep_set_mode(SLEEP_SMODE_PDOWN_gc); - * sleep_enable(); - * sleep_enter(); - * sleep_disable(); - * \endcode - * - * \subsection xmega_sleep_basic_usage Workflow - * -# Set what sleep mode to use, the different sleep modes can be found in the - * device header file under the enum definition SLEEP_SMODE_enum: - * - \code sleep_set_mode(SLEEP_SMODE_PDOWN_gc); \endcode - * -# Enable that the device are allowed to go to sleep: - * - \code sleep_enable(); \endcode - * - \note This function has to be called in order for the device to go to - * sleep. This is a safety feature to stop the device to go to sleep - * unintentionally, even though it is possible to have this enabled at all times - * it is recommended to enable sleep mode only when you intend to go to sleep - * within a few clock cycles. - * -# Enter sleep mode: - * - \code sleep_enter(); \endcode - * - \attention Make sure to enable global interrupt and the interrupt you - * plan to use as wake-up source for your device, do also pay special - * attention to what wake-up sources are available for the different sleep - * modes. Failing to enable interrupts may result in indefinite sleep until - * power is cycled! - * -# When the device is woken from sleep it will execute the interrupt handler - * related to the wakeup-source (interrupt source) and continue on the next line - * of code after the \ref sleep_enter() call. Make sure to disable sleep when - * waking up. - * - \code sleep_disable(); \endcode - * - * \subsection xmega_sleep_basic_sleep_modes Sleep Modes - * Possible sleep modes depend on the device that is used. Please refer to the - * device datasheet and header file to find these definitions. - * - * As an example the ATxmega32A4U device has the following sleep modes: - * - Idle sleep: SLEEP_SMODE_IDLE_gc - * - Power Down: SLEEP_SMODE_PDOWN_gc - * - Power Save: SLEEP_SMODE_PSAVE_gc - * - Standby: SLEEP_SMODE_STDBY_gc - * - Extended standby: SLEEP_SMODE_ESTDBY_gc - */ - -#endif /* SLEEP_H */ diff --git a/DSTAT1/src/asf/xmega/drivers/spi/spi.c b/DSTAT1/src/asf/xmega/drivers/spi/spi.c deleted file mode 100644 index 186e497..0000000 --- a/DSTAT1/src/asf/xmega/drivers/spi/spi.c +++ /dev/null @@ -1,114 +0,0 @@ -/***************************************************************************** - * - * \file - * - * \brief SPI software driver functions. - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - *****************************************************************************/ - -#include "spi.h" - -/*! \brief Calculates the SPI baudrate divider. - * - * \param baudrate The expected baudrate on the SPI. - * \param clkper_hz SPI module input clock frequency (Peripheral clock, Hz). - * \param spi The SPI module address - * - * \return Status of operation. - * \retval >=0 Success. - * \retval <0 Error. - */ -int8_t spi_xmega_set_baud_div(SPI_t *spi, uint32_t baudrate, uint32_t clkper_hz) -{ - uint32_t divisor; - uint8_t divisor_8bit; - uint8_t ctrl; - - // Sanity check, requested baudrate is lower than system clock - Assert(clkper_hz > baudrate); - - /* - * Get wanted divisor rounded up so we don't get speed higher than - * requested baudrate. - */ - divisor = (clkper_hz + baudrate - 1) / baudrate; - - if (divisor > 128) { - /* - * Highest possible divisor is 128 so fail since we can't get - * low enough baudrate. - */ - return -1; - } - - /* - * We now know that the divisor is 128 or lower so move it into a 8-bit - * variable to make sure the following comparison is more optimized. - */ - divisor_8bit = divisor; - - /* - * For divisor values between the possible ones round up to the closest - * higher one to avoid higher baudrate than requested. - */ - if (divisor_8bit > 64) { - ctrl = SPI_PRESCALER_DIV128_gc; - } - else if (divisor_8bit > 32) { - ctrl = SPI_PRESCALER_DIV64_gc; - } - else if (divisor_8bit > 16) { - ctrl = SPI_CLK2X_bm | SPI_PRESCALER_DIV64_gc; - } - else if (divisor_8bit > 8) { - ctrl = SPI_PRESCALER_DIV16_gc; - } - else if (divisor_8bit > 4) { - ctrl = SPI_CLK2X_bm | SPI_PRESCALER_DIV16_gc; - } - else if (divisor_8bit > 2) { - ctrl = SPI_PRESCALER_DIV4_gc; - } - else { - ctrl = SPI_CLK2X_bm | SPI_PRESCALER_DIV4_gc; - } - - // Update register and make sure to clear out any leftover bits - spi->CTRL = (spi->CTRL & ~(SPI_CLK2X_bm | SPI_PRESCALER_gm)) | ctrl; - - return 1; -} diff --git a/DSTAT1/src/asf/xmega/drivers/spi/spi.h b/DSTAT1/src/asf/xmega/drivers/spi/spi.h deleted file mode 100644 index 2fac103..0000000 --- a/DSTAT1/src/asf/xmega/drivers/spi/spi.h +++ /dev/null @@ -1,161 +0,0 @@ -/***************************************************************************** - * - * \file - * - * \brief SPI driver for AVR. - * - * This file defines a useful set of functions for the SPI interface on AVR - * devices. - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - ******************************************************************************/ - - -#ifndef _SPI_H_ -#define _SPI_H_ - -/** - * \defgroup group_xmega_drivers_spi SPI - Serial Peripheral Interface - * - * Driver for the Serial Peripheral Interface (SPI). - * Provides functions for configuring and using the SPI. - * - * \{ - */ - -#include "compiler.h" -#include "status_codes.h" -#include "ioport.h" - -/*! \brief Calculates the SPI baudrate divider. - * - * \param baudrate The expected baudrate on the SPI. - * \param clkper_hz SPI module input clock frequency (Peripheral clock, Hz). - * \param spi The SPI module address - * - * \return Divider or error code. - * \retval >=0 Success. - * \retval <0 Error. - */ -int8_t spi_xmega_set_baud_div(SPI_t *spi, uint32_t baudrate, uint32_t clkper_hz); - -/*! \brief Enables the SPI. - * - * \param spi Base address of the SPI instance. - */ -static inline void spi_enable(SPI_t *spi) -{ - spi->CTRL |= SPI_ENABLE_bm; -} - -/*! \brief Disables the SPI. - * - * Ensures that nothing is transferred while setting up buffers. - * - * \param spi Base address of the SPI instance. - * - * \warning This may cause data loss if used on a slave SPI. - */ -static inline void spi_disable(SPI_t *spi) -{ - spi->CTRL &= ~SPI_ENABLE_bm; -} - -/*! \brief Tests if the SPI is enabled. - * - * \param spi Base address of the SPI instance. - * - * \return \c 1 if the SPI is enabled, otherwise \c 0. - */ -static inline bool spi_is_enabled(SPI_t *spi) -{ - return spi->CTRL & SPI_ENABLE_bm ? true : false; -} - -/*! \brief Put one data byte to a SPI peripheral. - * - * \param spi Base address of the SPI instance. - * \param data The data byte to be loaded - * - */ -static inline void spi_put(SPI_t *spi, uint8_t data) -{ - spi->DATA = data; -} - -/*! \brief Get one data byte to a SPI peripheral. - * - * \param spi Base address of the SPI instance. - * \return The data byte - * - */ -static inline uint8_t spi_get(SPI_t *spi) -{ - return spi->DATA; -} - -/*! \brief Tests if the SPI contains a received character. - * - * \param spi Base address of the SPI instance. - * - * \return \c 1 if the SPI Receive Holding Register is full, otherwise \c 0. - */ -static inline bool spi_is_tx_ok(SPI_t *spi) -{ - return spi->STATUS & SPI_IF_bm ? true : false; -} - -/*! \brief Activate SPI master mode of a SPI peripheral - * - * \param spi Base address of the SPI instance. - * - * \warning This may cause data loss if used on a slave SPI. - */ -static inline void spi_enable_master_mode(SPI_t *spi) -{ - spi->CTRL |= SPI_MASTER_bm; -} - -/*! \name Part Specific SPI Driver - */ -//! @{ -//! @} - -/** - * \} - */ - -#endif // _SPI_H_ diff --git a/DSTAT1/src/asf/xmega/drivers/tc/tc.c b/DSTAT1/src/asf/xmega/drivers/tc/tc.c deleted file mode 100644 index 14e5823..0000000 --- a/DSTAT1/src/asf/xmega/drivers/tc/tc.c +++ /dev/null @@ -1,1076 +0,0 @@ -/** - * \file - * - * \brief AVR XMEGA TC Driver - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include - -#include "interrupt.h" -#include "compiler.h" -#include "parts.h" - -#include "tc.h" -#include "sysclk.h" -#include "sleepmgr.h" -#include "status_codes.h" - -#if defined(TCC0) || defined(__DOXYGEN__) -//! \internal Local storage of Timer Counter TCC0 interrupt callback function -static tc_callback_t tc_tcc0_ovf_callback; -static tc_callback_t tc_tcc0_err_callback; -static tc_callback_t tc_tcc0_cca_callback; -static tc_callback_t tc_tcc0_ccb_callback; -static tc_callback_t tc_tcc0_ccc_callback; -static tc_callback_t tc_tcc0_ccd_callback; - - -/** - * \internal - * \brief Interrupt handler for Timer Counter C0 overflow - * - * This function will handle interrupt on Timer Counter CO overflow and - * call the callback function. - */ -ISR(TCC0_OVF_vect) -{ - if (tc_tcc0_ovf_callback) { - tc_tcc0_ovf_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter C0 error - * - * This function will handle interrupt on Timer Counter CO error and - * call the callback function. - */ -ISR(TCC0_ERR_vect) -{ - if (tc_tcc0_err_callback) { - tc_tcc0_err_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter C0 Compare/CaptureA - * - * This function will handle interrupt on Timer Counter CO Compare/CaptureA and - * call the callback function. - */ -ISR(TCC0_CCA_vect) -{ - if (tc_tcc0_cca_callback) { - tc_tcc0_cca_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter C0 Compare/CaptureB - * - * This function will handle interrupt on Timer Counter CO Compare/CaptureB and - * call the callback function. - */ -ISR(TCC0_CCB_vect) -{ - if (tc_tcc0_ccb_callback) { - tc_tcc0_ccb_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter C0 Compare/CaptureC - * - * This function will handle interrupt on Timer Counter CO Compare/CaptureC and - * call the callback function. - */ -ISR(TCC0_CCC_vect) -{ - if (tc_tcc0_ccc_callback) { - tc_tcc0_ccc_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter C0 Compare/CaptureD - * - * This function will handle interrupt on Timer Counter CO Compare/CaptureD and - * call the callback function. - */ -ISR(TCC0_CCD_vect) -{ - if (tc_tcc0_ccd_callback) { - tc_tcc0_ccd_callback(); - } -} - -#endif - -#if defined(TCC1) || defined(__DOXYGEN__) -//! \internal Local storage of Timer Counter TCC1 interrupt callback function -static tc_callback_t tc_tcc1_ovf_callback; -static tc_callback_t tc_tcc1_err_callback; -static tc_callback_t tc_tcc1_cca_callback; -static tc_callback_t tc_tcc1_ccb_callback; - -/** - * \internal - * \brief Interrupt handler for Timer Counter C1 overflow - * - * This function will handle interrupt on Timer Counter C1 overflow and - * call the callback function. - */ -ISR(TCC1_OVF_vect) -{ - if (tc_tcc1_ovf_callback) { - tc_tcc1_ovf_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter C1 error - * - * This function will handle interrupt on Timer Counter C1 error and - * call the callback function. - */ -ISR(TCC1_ERR_vect) -{ - if (tc_tcc1_err_callback) { - tc_tcc1_err_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter C1 Compare/CaptureA - * - * This function will handle interrupt on Timer Counter C1 Compare/CaptureA and - * call the callback function. - */ -ISR(TCC1_CCA_vect) -{ - if (tc_tcc1_cca_callback) { - tc_tcc1_cca_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter C1 Compare/CaptureB - * - * This function will handle interrupt on Timer Counter C1 Compare/CaptureB and - * call the callback function. - */ -ISR(TCC1_CCB_vect) -{ - if (tc_tcc1_ccb_callback) { - tc_tcc1_ccb_callback(); - } -} - -#endif - -#if defined(TCD0) || defined(__DOXYGEN__) -//! \internal Local storage of Timer Counter TCD0 interrupt callback function -static tc_callback_t tc_tcd0_ovf_callback; -static tc_callback_t tc_tcd0_err_callback; -static tc_callback_t tc_tcd0_cca_callback; -static tc_callback_t tc_tcd0_ccb_callback; -static tc_callback_t tc_tcd0_ccc_callback; -static tc_callback_t tc_tcd0_ccd_callback; - - -/** - * \internal - * \brief Interrupt handler for Timer Counter D0 overflow - * - * This function will handle interrupt on Timer Counter D0 overflow and - * call the callback function. - */ -ISR(TCD0_OVF_vect) -{ - if (tc_tcd0_ovf_callback) { - tc_tcd0_ovf_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter D0 error - * - * This function will handle interrupt on Timer Counter D0 error and - * call the callback function. - */ -ISR(TCD0_ERR_vect) -{ - if (tc_tcd0_err_callback) { - tc_tcd0_err_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter D0 Compare/CaptureA - * - * This function will handle interrupt on Timer Counter D0 Compare/CaptureA and - * call the callback function. - */ -ISR(TCD0_CCA_vect) -{ - if (tc_tcd0_cca_callback) { - tc_tcd0_cca_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter D0 Compare/CaptureB - * - * This function will handle interrupt on Timer Counter D0 Compare/CaptureB and - * call the callback function. - */ -ISR(TCD0_CCB_vect) -{ - if (tc_tcd0_ccb_callback) { - tc_tcd0_ccb_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter D0 Compare/CaptureC - * - * This function will handle interrupt on Timer Counter D0 Compare/CaptureC and - * call the callback function. - */ -ISR(TCD0_CCC_vect) -{ - if (tc_tcd0_ccc_callback) { - tc_tcd0_ccc_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter D0 Compare/CaptureD - * - * This function will handle interrupt on Timer Counter D0 Compare/CaptureD and - * call the callback function. - */ -ISR(TCD0_CCD_vect) -{ - if (tc_tcd0_ccd_callback) { - tc_tcd0_ccd_callback(); - } -} - -#endif - -#if defined(TCD1) || defined(__DOXYGEN__) -//! \internal Local storage of Timer Counter TCD1 interrupt callback function -static tc_callback_t tc_tcd1_ovf_callback; -static tc_callback_t tc_tcd1_err_callback; -static tc_callback_t tc_tcd1_cca_callback; -static tc_callback_t tc_tcd1_ccb_callback; - -/** - * \internal - * \brief Interrupt handler for Timer Counter D1 overflow - * - * This function will handle interrupt on Timer Counter D1 overflow and - * call the callback function. - */ -ISR(TCD1_OVF_vect) -{ - if (tc_tcd1_ovf_callback) { - tc_tcd1_ovf_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter D1 error - * - * This function will handle interrupt on Timer Counter D1 error and - * call the callback function. - */ -ISR(TCD1_ERR_vect) -{ - if (tc_tcd1_err_callback) { - tc_tcd1_err_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter D1 Compare/CaptureA - * - * This function will handle interrupt on Timer Counter D1 Compare/CaptureA and - * call the callback function. - */ -ISR(TCD1_CCA_vect) -{ - if (tc_tcd1_cca_callback) { - tc_tcd1_cca_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter D1 Compare/CaptureB - * - * This function will handle interrupt on Timer Counter D1 Compare/CaptureB and - * call the callback function. - */ -ISR(TCD1_CCB_vect) -{ - if (tc_tcd1_ccb_callback) { - tc_tcd1_ccb_callback(); - } -} - -#endif - - -#if defined(TCE0) || defined(__DOXYGEN__) -//! \internal Local storage of Timer Counter TCE0 interrupt callback function -static tc_callback_t tc_tce0_ovf_callback; -static tc_callback_t tc_tce0_err_callback; -static tc_callback_t tc_tce0_cca_callback; -static tc_callback_t tc_tce0_ccb_callback; -static tc_callback_t tc_tce0_ccc_callback; -static tc_callback_t tc_tce0_ccd_callback; - - -/** - * \internal - * \brief Interrupt handler for Timer Counter E0 overflow - * - * This function will handle interrupt on Timer Counter E0 overflow and - * call the callback function. - */ -ISR(TCE0_OVF_vect) -{ - if (tc_tce0_ovf_callback) { - tc_tce0_ovf_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter E0 error - * - * This function will handle interrupt on Timer Counter E0 error and - * call the callback function. - */ -ISR(TCE0_ERR_vect) -{ - if (tc_tce0_err_callback) { - tc_tce0_err_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter E0 Compare/CaptureA - * - * This function will handle interrupt on Timer Counter E0 Compare/CaptureA and - * call the callback function. - */ -ISR(TCE0_CCA_vect) -{ - if (tc_tce0_cca_callback) { - tc_tce0_cca_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter E0 Compare/CaptureB - * - * This function will handle interrupt on Timer Counter E0 Compare/CaptureB and - * call the callback function. - */ -ISR(TCE0_CCB_vect) -{ - if (tc_tce0_ccb_callback) { - tc_tce0_ccb_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter E0 Compare/CaptureC - * - * This function will handle interrupt on Timer Counter E0 Compare/CaptureC and - * call the callback function. - */ -ISR(TCE0_CCC_vect) -{ - if (tc_tce0_ccc_callback) { - tc_tce0_ccc_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter E0 Compare/CaptureD - * - * This function will handle interrupt on Timer Counter E0 Compare/CaptureD and - * call the callback function. - */ -ISR(TCE0_CCD_vect) -{ - if (tc_tce0_ccd_callback) { - tc_tce0_ccd_callback(); - } -} - -#endif - -#if defined(TCE1) || defined(__DOXYGEN__) -//! \internal Local storage of Timer Counter TCE1 interrupt callback function -static tc_callback_t tc_tce1_ovf_callback; -static tc_callback_t tc_tce1_err_callback; -static tc_callback_t tc_tce1_cca_callback; -static tc_callback_t tc_tce1_ccb_callback; - -/** - * \internal - * \brief Interrupt handler for Timer Counter E1 overflow - * - * This function will handle interrupt on Timer Counter E1 overflow and - * call the callback function. - */ -ISR(TCE1_OVF_vect) -{ - if (tc_tce1_ovf_callback) { - tc_tce1_ovf_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter E1 error - * - * This function will handle interrupt on Timer Counter E1 error and - * call the callback function. - */ -ISR(TCE1_ERR_vect) -{ - if (tc_tce1_err_callback) { - tc_tce1_err_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter E1 Compare/CaptureA - * - * This function will handle interrupt on Timer Counter E1 Compare/CaptureA and - * call the callback function. - */ -ISR(TCE1_CCA_vect) -{ - if (tc_tce1_cca_callback) { - tc_tce1_cca_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter E1 Compare/CaptureB - * - * This function will handle interrupt on Timer Counter E1 Compare/CaptureB and - * call the callback function. - */ -ISR(TCE1_CCB_vect) -{ - if (tc_tce1_ccb_callback) { - tc_tce1_ccb_callback(); - } -} - -#endif - -#if defined(TCF0) || defined(__DOXYGEN__) -//! \internal Local storage of Timer Counter TCF0 interrupt callback function -static tc_callback_t tc_tcf0_ovf_callback; -static tc_callback_t tc_tcf0_err_callback; -static tc_callback_t tc_tcf0_cca_callback; -static tc_callback_t tc_tcf0_ccb_callback; -static tc_callback_t tc_tcf0_ccc_callback; -static tc_callback_t tc_tcf0_ccd_callback; - - -/** - * \internal - * \brief Interrupt handler for Timer Counter E0 overflow - * - * This function will handle interrupt on Timer Counter F0 overflow and - * call the callback function. - */ -ISR(TCF0_OVF_vect) -{ - if (tc_tcf0_ovf_callback) { - tc_tcf0_ovf_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter F0 error - * - * This function will handle interrupt on Timer Counter F0 error and - * call the callback function. - */ -ISR(TCF0_ERR_vect) -{ - if (tc_tcf0_err_callback) { - tc_tcf0_err_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter F0 Compare/CaptureA - * - * This function will handle interrupt on Timer Counter F0 Compare/CaptureA and - * call the callback function. - */ -ISR(TCF0_CCA_vect) -{ - if (tc_tcf0_cca_callback) { - tc_tcf0_cca_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter F0 Compare/CaptureB - * - * This function will handle interrupt on Timer Counter F0 Compare/CaptureB and - * call the callback function. - */ -ISR(TCF0_CCB_vect) -{ - if (tc_tcf0_ccb_callback) { - tc_tcf0_ccb_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter F0 Compare/CaptureC - * - * This function will handle interrupt on Timer Counter F0 Compare/CaptureC and - * call the callback function. - */ -ISR(TCF0_CCC_vect) -{ - if (tc_tcf0_ccc_callback) { - tc_tcf0_ccc_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter F0 Compare/CaptureD - * - * This function will handle interrupt on Timer Counter F0 Compare/CaptureD and - * call the callback function. - */ -ISR(TCF0_CCD_vect) -{ - if (tc_tcf0_ccd_callback) { - tc_tcf0_ccd_callback(); - } -} - -#endif - -#if defined(TCF1) || defined(__DOXYGEN__) -//! \internal Local storage of Timer Counter TCF1 interrupt callback function -static tc_callback_t tc_tcf1_ovf_callback; -static tc_callback_t tc_tcf1_err_callback; -static tc_callback_t tc_tcf1_cca_callback; -static tc_callback_t tc_tcf1_ccb_callback; - -/** - * \internal - * \brief Interrupt handler for Timer Counter F1 overflow - * - * This function will handle interrupt on Timer Counter F1 overflow and - * call the callback function. - */ -ISR(TCF1_OVF_vect) -{ - if (tc_tcf1_ovf_callback) { - tc_tcf1_ovf_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter F1 error - * - * This function will handle interrupt on Timer Counter F1 error and - * call the callback function. - */ -ISR(TCF1_ERR_vect) -{ - if (tc_tcf1_err_callback) { - tc_tcf1_err_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter F1 Compare/CaptureA - * - * This function will handle interrupt on Timer Counter F1 Compare/CaptureA and - * call the callback function. - */ -ISR(TCF1_CCA_vect) -{ - if (tc_tcf1_cca_callback) { - tc_tcf1_cca_callback(); - } -} - -/** - * \internal - * \brief Interrupt handler for Timer Counter F1 Compare/CaptureB - * - * This function will handle interrupt on Timer Counter F1 Compare/CaptureB and - * call the callback function. - */ -ISR(TCF1_CCB_vect) -{ - if (tc_tcf1_ccb_callback) { - tc_tcf1_ccb_callback(); - } -} - -#endif - -/** - * \brief Enable TC - * - * Enables the TC. - * - * \param tc Pointer to TC module - * - * \note - * unmask TC clock (sysclk), but does not configure the TC clock source. - */ -void tc_enable(volatile void *tc) -{ - irqflags_t iflags = cpu_irq_save(); - -#ifdef TCC0 - if ((uintptr_t) tc == (uintptr_t) & TCC0) { - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_TC0); - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_HIRES); - } else -#endif -#ifdef TCC1 - if ((uintptr_t) tc == (uintptr_t) & TCC1) { - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_TC1); - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_HIRES); - } else -#endif -#ifdef TCD0 - if ((uintptr_t) tc == (uintptr_t) & TCD0) { - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_TC0); - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_HIRES); - } else -#endif -#ifdef TCD1 - if ((uintptr_t) tc == (uintptr_t) & TCD1) { - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_TC1); - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_HIRES); - } else -#endif -#ifdef TCE0 - if ((uintptr_t) tc == (uintptr_t) & TCE0) { - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_TC0); - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_HIRES); - } else -#endif -#ifdef TCE1 - if ((uintptr_t) tc == (uintptr_t) & TCE1) { - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_TC1); - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_HIRES); - } else -#endif -#ifdef TCF0 - if ((uintptr_t) tc == (uintptr_t) & TCF0) { - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_TC0); - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_HIRES); - } else -#endif -#ifdef TCF1 - if ((uintptr_t) tc == (uintptr_t) & TCF1) { - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_TC1); - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_HIRES); - } else -#endif - { - cpu_irq_restore(iflags); - return; - } - sleepmgr_lock_mode(SLEEPMGR_IDLE); - cpu_irq_restore(iflags); -} - - -/** - * \brief Disable TC - * - * Disables the TC. - * - * \param tc Pointer to TC module - * - * \note - * mask TC clock (sysclk). - */ -void tc_disable(volatile void *tc) -{ - irqflags_t iflags = cpu_irq_save(); - - sleepmgr_unlock_mode(SLEEPMGR_IDLE); - -#ifdef TCC0 - if ((uintptr_t) tc == (uintptr_t) & TCC0) { - sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_TC0); - sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_HIRES); - } else -#endif -#ifdef TCC1 - if ((uintptr_t) tc == (uintptr_t) & TCC1) { - sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_TC1); - sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_HIRES); - } else -#endif -#ifdef TCD0 - if ((uintptr_t) tc == (uintptr_t) & TCD0) { - sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_TC0); - sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_HIRES); - } else -#endif -#ifdef TCD1 - if ((uintptr_t) tc == (uintptr_t) & TCD1) { - sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_TC1); - sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_HIRES); - } else -#endif -#ifdef TCE0 - if ((uintptr_t) tc == (uintptr_t) & TCE0) { - sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_TC0); - sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_HIRES); - } else -#endif -#ifdef TCE1 - if ((uintptr_t) tc == (uintptr_t) & TCE1) { - sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_TC1); - sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_HIRES); - } else -#endif -#ifdef TCF0 - if ((uintptr_t) tc == (uintptr_t) & TCF0) { - sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_TC0); - sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_HIRES); - } else -#endif -#ifdef TCF1 - if ((uintptr_t) tc == (uintptr_t) & TCF1) { - sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_TC1); - sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_HIRES); - } else -#endif - { - cpu_irq_restore(iflags); - return; - } - cpu_irq_restore(iflags); -} - -void tc_set_overflow_interrupt_callback(volatile void *tc, - tc_callback_t callback) -{ -#ifdef TCC0 - if ((uintptr_t) tc == (uintptr_t) & TCC0) { - tc_tcc0_ovf_callback = callback; - } else -#endif -#ifdef TCC1 - if ((uintptr_t) tc == (uintptr_t) & TCC1) { - tc_tcc1_ovf_callback = callback; - } else -#endif -#ifdef TCD0 - if ((uintptr_t) tc == (uintptr_t) & TCD0) { - tc_tcd0_ovf_callback = callback; - } else -#endif -#ifdef TCD1 - if ((uintptr_t) tc == (uintptr_t) & TCD1) { - tc_tcd1_ovf_callback = callback; - } else -#endif -#ifdef TCE0 - if ((uintptr_t) tc == (uintptr_t) & TCE0) { - tc_tce0_ovf_callback = callback; - } else -#endif -#ifdef TCE1 - if ((uintptr_t) tc == (uintptr_t) & TCE1) { - tc_tce1_ovf_callback = callback; - } else -#endif -#ifdef TCF0 - if ((uintptr_t) tc == (uintptr_t) & TCF0) { - tc_tcf0_ovf_callback = callback; - } else -#endif -#ifdef TCF1 - if ((uintptr_t) tc == (uintptr_t) & TCF1) { - tc_tcf1_ovf_callback = callback; - } else -#endif - {} -} - -void tc_set_error_interrupt_callback(volatile void *tc, tc_callback_t callback) -{ -#ifdef TCC0 - if ((uintptr_t) tc == (uintptr_t) & TCC0) { - tc_tcc0_err_callback = callback; - } else -#endif -#ifdef TCC1 - if ((uintptr_t) tc == (uintptr_t) & TCC1) { - tc_tcc1_err_callback = callback; - } else -#endif -#ifdef TCD0 - if ((uintptr_t) tc == (uintptr_t) & TCD0) { - tc_tcd0_err_callback = callback; - } else -#endif -#ifdef TCD1 - if ((uintptr_t) tc == (uintptr_t) & TCD1) { - tc_tcd1_err_callback = callback; - } else -#endif -#ifdef TCE0 - if ((uintptr_t) tc == (uintptr_t) & TCE0) { - tc_tce0_err_callback = callback; - } else -#endif -#ifdef TCE1 - if ((uintptr_t) tc == (uintptr_t) & TCE1) { - tc_tce1_err_callback = callback; - } else -#endif -#ifdef TCF0 - if ((uintptr_t) tc == (uintptr_t) & TCF0) { - tc_tcf0_err_callback = callback; - } else -#endif -#ifdef TCF1 - if ((uintptr_t) tc == (uintptr_t) & TCF1) { - tc_tcf1_err_callback = callback; - } else -#endif - {} -} - -void tc_set_cca_interrupt_callback(volatile void *tc, tc_callback_t callback) -{ -#ifdef TCC0 - if ((uintptr_t) tc == (uintptr_t) & TCC0) { - tc_tcc0_cca_callback = callback; - } else -#endif -#ifdef TCC1 - if ((uintptr_t) tc == (uintptr_t) & TCC1) { - tc_tcc1_cca_callback = callback; - } else -#endif -#ifdef TCD0 - if ((uintptr_t) tc == (uintptr_t) & TCD0) { - tc_tcd0_cca_callback = callback; - } else -#endif -#ifdef TCD1 - if ((uintptr_t) tc == (uintptr_t) & TCD1) { - tc_tcd1_cca_callback = callback; - } else -#endif -#ifdef TCE0 - if ((uintptr_t) tc == (uintptr_t) & TCE0) { - tc_tce0_cca_callback = callback; - } else -#endif -#ifdef TCE1 - if ((uintptr_t) tc == (uintptr_t) & TCE1) { - tc_tce1_cca_callback = callback; - } else -#endif -#ifdef TCF0 - if ((uintptr_t) tc == (uintptr_t) & TCF0) { - tc_tcf0_cca_callback = callback; - } else -#endif -#ifdef TCF1 - if ((uintptr_t) tc == (uintptr_t) & TCF1) { - tc_tcf1_cca_callback = callback; - } else -#endif - {} -} - -void tc_set_ccb_interrupt_callback(volatile void *tc, tc_callback_t callback) -{ -#ifdef TCC0 - if ((uintptr_t) tc == (uintptr_t) & TCC0) { - tc_tcc0_ccb_callback = callback; - } else -#endif -#ifdef TCC1 - if ((uintptr_t) tc == (uintptr_t) & TCC1) { - tc_tcc1_ccb_callback = callback; - } else -#endif -#ifdef TCD0 - if ((uintptr_t) tc == (uintptr_t) & TCD0) { - tc_tcd0_ccb_callback = callback; - } else -#endif -#ifdef TCD1 - if ((uintptr_t) tc == (uintptr_t) & TCD1) { - tc_tcd1_ccb_callback = callback; - } else -#endif -#ifdef TCE0 - if ((uintptr_t) tc == (uintptr_t) & TCE0) { - tc_tce0_ccb_callback = callback; - } else -#endif -#ifdef TCE1 - if ((uintptr_t) tc == (uintptr_t) & TCE1) { - tc_tce1_ccb_callback = callback; - } else -#endif -#ifdef TCF0 - if ((uintptr_t) tc == (uintptr_t) & TCF0) { - tc_tcf0_ccb_callback = callback; - } else -#endif -#ifdef TCF1 - if ((uintptr_t) tc == (uintptr_t) & TCF1) { - tc_tcf1_ccb_callback = callback; - } else -#endif - {} -} - -void tc_set_ccc_interrupt_callback(volatile void *tc, tc_callback_t callback) -{ -#ifdef TCC0 - if ((uintptr_t) tc == (uintptr_t) & TCC0) { - tc_tcc0_ccc_callback = callback; - } else -#endif - -#ifdef TCD0 - if ((uintptr_t) tc == (uintptr_t) & TCD0) { - tc_tcd0_ccc_callback = callback; - } else -#endif - -#ifdef TCE0 - if ((uintptr_t) tc == (uintptr_t) & TCE0) { - tc_tce0_ccc_callback = callback; - } else -#endif - -#ifdef TCF0 - if ((uintptr_t) tc == (uintptr_t) & TCF0) { - tc_tcf0_ccc_callback = callback; - } else -#endif - {} - -} - - -void tc_set_ccd_interrupt_callback(volatile void *tc, tc_callback_t callback) -{ -#ifdef TCC0 - if ((uintptr_t) tc == (uintptr_t) & TCC0) { - tc_tcc0_ccd_callback = callback; - } else -#endif - -#ifdef TCD0 - if ((uintptr_t) tc == (uintptr_t) & TCD0) { - tc_tcd0_ccd_callback = callback; - } else -#endif - -#ifdef TCE0 - if ((uintptr_t) tc == (uintptr_t) & TCE0) { - tc_tce0_ccd_callback = callback; - } else -#endif - -#ifdef TCF0 - if ((uintptr_t) tc == (uintptr_t) & TCF0) { - tc_tcf0_ccd_callback = callback; - } else -#endif - {} -} diff --git a/DSTAT1/src/asf/xmega/drivers/tc/tc.h b/DSTAT1/src/asf/xmega/drivers/tc/tc.h deleted file mode 100644 index 73cf96c..0000000 --- a/DSTAT1/src/asf/xmega/drivers/tc/tc.h +++ /dev/null @@ -1,1610 +0,0 @@ -/** - * \file - * - * \brief AVR XMEGA Timer Counter (TC) driver - * - * Copyright (c) 2010-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef TC_H -#define TC_H - -#include -#include -#include "status_codes.h" -#include "pmic.h" -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -/** - * \defgroup tc_group Timer Counter (TC) - * - * See \ref xmega_tc_quickstart - * - * This is a driver for the AVR XMEGA Timer Counter (TC). It provides functions - * for enabling, disabling and configuring the TC modules. - * - * \section dependencies Dependencies - * This driver depends on the following modules: - * - \ref sysclk_group for peripheral clock control. - * - \ref sleepmgr_group for setting allowed sleep mode. - * - \ref interrupt_group for ISR definition and disabling interrupts during - * critical code sections. - * @{ - */ - - - -/** - * \brief Interrupt event callback function type - * - * The interrupt handler can be configured to do a function callback, - * the callback function must match the tc_callback_t type. - * - */ -typedef void (*tc_callback_t)(void); - -//! Timer Counter Capture Compare Channel index -enum tc_cc_channel_t { - //! Channel A - TC_CCA = 1, - //! Channel B - TC_CCB = 2, - //! Channel C - TC_CCC = 3, - //! Channel D - TC_CCD = 4, -}; - -//! Timer Counter Capture Compare Channel index -enum tc_cc_channel_mask_enable_t { - //! Channel A Enable mask - TC_CCAEN = TC0_CCAEN_bm, - //! Channel B Enable mask - TC_CCBEN = TC0_CCBEN_bm, - //! Channel C Enable mask - TC_CCCEN = TC0_CCCEN_bm, - //! Channel D Enable mask - TC_CCDEN = TC0_CCDEN_bm, -}; - -//! Timer Counter Direction -enum tc_dir_t { - //! Counting up - TC_UP = 0, - //! Down Coutning B - TC_DOWN = 1 -}; -//! Timer Counter Waveform Generator mode -enum tc_wg_mode_t { - //! TC in normal Mode - TC_WG_NORMAL = TC_WGMODE_NORMAL_gc, - //! TC in Frequency Generator mode - TC_WG_FRQ = TC_WGMODE_FRQ_gc, - //! TC in single slope PWM mode - TC_WG_SS = TC_WGMODE_SS_gc, - //! TC in dual slope Top PWM mode - TC_WG_DS_T = TC_WGMODE_DS_T_gc, - //! TC in dual slope Top Bottom PWM mode - TC_WG_DS_TB = TC_WGMODE_DS_TB_gc, - //! TC in dual slope Bottom PWM mode - TC_WG_DS_B = TC_WGMODE_DS_B_gc -}; - -//! TC interrupt levels -enum TC_INT_LEVEL_t { - TC_INT_LVL_OFF = 0x00, - TC_INT_LVL_LO = 0x01, - TC_INT_LVL_MED = 0x02, - TC_INT_LVL_HI = 0x03, -}; - -//! Macro to check if type of passed TC is TC1_t -#define tc_is_tc1(void) ((uint16_t)tc&0x40 ? true : false) -//! Macro to check if type of passed TC is TC0_t -#define tc_is_tc0(void) ((uint16_t)tc&0x40 ? false : true) - -/** - * \brief Enable TC - * - * Enables the TC. - * - * \param tc Pointer to TC module - * - * \note - * unmask TC clock (sysclk), but does not configure the TC clock source. - */ -void tc_enable(volatile void *tc); - -/** - * \brief Disable TC - * - * Disables the TC. - * - * \param tc Pointer to TC module - * - * \note - * mask TC clock (sysclk). - */ -void tc_disable(volatile void *tc); - -/** - * \ingroup tc_group - * \defgroup tc_interrupt_group Timer Counter (TC) interrupt management - * This group provides functions to configure TC module interrupts - * - * - * @{ - */ -/** - * \brief Set TC overflow interrupt callback function - * - * This function allows the caller to set and change the interrupt callback - * function. Without setting a callback function the interrupt handler in the - * driver will only clear the interrupt flags. - * - * \param tc Pointer to the Timer Counter (TC) base address - * \param callback Reference to a callback function - */ -void tc_set_overflow_interrupt_callback(volatile void *tc, - tc_callback_t callback); - -/** - * \brief Set TC error interrupt callback function - * - * This function allows the caller to set and change the interrupt callback - * function. Without setting a callback function the interrupt handler in the - * driver will only clear the interrupt flags. - * - * \param tc Pointer to the Timer Counter (TC) base address - * \param callback Reference to a callback function - */ -void tc_set_error_interrupt_callback(volatile void *tc, tc_callback_t callback); - -/** - * \brief Set TC Capture Compare Channel A interrupt callback function - * - * This function allows the caller to set and change the interrupt callback - * function. Without setting a callback function the interrupt handler in the - * driver will only clear the interrupt flags. - * - * \param tc Pointer to the Timer Counter (TC) base address - * \param callback Reference to a callback function - */ -void tc_set_cca_interrupt_callback(volatile void *tc, tc_callback_t callback); - -/** - * \brief Set TC Capture Compare Channel B interrupt callback function - * - * This function allows the caller to set and change the interrupt callback - * function. Without setting a callback function the interrupt handler in the - * driver will only clear the interrupt flags. - * - * \param tc Pointer to the Timer Counter (TC) base address - * \param callback Reference to a callback function - */ -void tc_set_ccb_interrupt_callback(volatile void *tc, tc_callback_t callback); - -/** - * \brief Set TC Capture Compare Channel C interrupt callback function - * - * This function allows the caller to set and change the interrupt callback - * function. Without setting a callback function the interrupt handler in the - * driver will only clear the interrupt flags. - * - * \param tc Pointer to the Timer Counter (TC) base address - * \param callback Reference to a callback function - */ -void tc_set_ccc_interrupt_callback(volatile void *tc, tc_callback_t callback); - -/** - * \brief Set TC Capture Compare Channel D interrupt callback function - * - * This function allows the caller to set and change the interrupt callback - * function. Without setting a callback function the interrupt handler in the - * driver will only clear the interrupt flags. - * - * \param tc Pointer to the Timer Counter (TC) base address - * \param callback Reference to a callback function - */ -void tc_set_ccd_interrupt_callback(volatile void *tc, tc_callback_t callback); -/** - * \brief Configures TC overflow Interrupt level - * - * \param tc Pointer to TC module. - * \param level Overflow interrupt level - * \note Configures OVFINTLVL in INTCTRLA - */ -static inline void tc_set_overflow_interrupt_level(volatile void *tc, - enum TC_INT_LEVEL_t level) -{ - ((TC0_t *)tc)->INTCTRLA = ((TC0_t *)tc)->INTCTRLA & ~TC0_OVFINTLVL_gm; - ((TC0_t *)tc)->INTCTRLA = - ((TC0_t *)tc)->INTCTRLA | (level << TC0_OVFINTLVL_gp); -} - -/** - * \brief Configures TC error Interrupt level - * - * \param tc Pointer to TC module. - * \param level Error interrupt level - * \note Configures ERRINTLVL in INTCTRLA - */ -static inline void tc_set_error_interrupt_level(volatile void *tc, - enum TC_INT_LEVEL_t level) -{ - ((TC0_t *)tc)->INTCTRLA = ((TC0_t *)tc)->INTCTRLA & ~TC0_ERRINTLVL_gm; - ((TC0_t *)tc)->INTCTRLA = - ((TC0_t *)tc)->INTCTRLA | (level << TC0_ERRINTLVL_gp); -} - -/** - * \brief Configures TC Capture Compare A Interrupt level - * - * \param tc Pointer to TC module. - * \param level CCA interrupt level - * \note Configures CCAINTLVL in INTCTRLB - */ -static inline void tc_set_cca_interrupt_level(volatile void *tc, - enum TC_INT_LEVEL_t level) -{ - ((TC0_t *)tc)->INTCTRLB = ((TC0_t *)tc)->INTCTRLB & ~TC0_CCAINTLVL_gm; - ((TC0_t *)tc)->INTCTRLB = - ((TC0_t *)tc)->INTCTRLB | (level << TC0_CCAINTLVL_gp); -} - -/** - * \brief Configures TC Capture Compare B Interrupt level - * - * \param tc Pointer to TC module. - * \param level CCB interrupt level - * \note Configures CCBINTLVL in INTCTRLB - */ -static inline void tc_set_ccb_interrupt_level(volatile void *tc, - enum TC_INT_LEVEL_t level) -{ - ((TC0_t *)tc)->INTCTRLB = ((TC0_t *)tc)->INTCTRLB & ~TC0_CCBINTLVL_gm; - ((TC0_t *)tc)->INTCTRLB = - ((TC0_t *)tc)->INTCTRLB | (level << TC0_CCBINTLVL_gp); -} - -/** - * \brief Configures TC Capture Compare C Interrupt level - * - * \param tc Pointer to TC module. - * \param level CCC interrupt level - * \note Configures CCCINTLVL in INTCTRLB - */ -static inline void tc_set_ccc_interrupt_level(volatile void *tc, - enum TC_INT_LEVEL_t level) -{ - ((TC0_t *)tc)->INTCTRLB = ((TC0_t *)tc)->INTCTRLB & ~TC0_CCCINTLVL_gm; - ((TC0_t *)tc)->INTCTRLB = - ((TC0_t *)tc)->INTCTRLB | (level << TC0_CCCINTLVL_gp); -} - - /** - * \brief Configures TC Capture Compare D Interrupt level - * - * \param tc Pointer to TC module. - * \param level CCD interrupt level - * \note Configures CCDINTLVL in INTCTRLB - */ -static inline void tc_set_ccd_interrupt_level(volatile void *tc, - enum TC_INT_LEVEL_t level) -{ - ((TC0_t *)tc)->INTCTRLB = ((TC0_t *)tc)->INTCTRLB & ~TC0_CCDINTLVL_gm; - ((TC0_t *)tc)->INTCTRLB = - ((TC0_t *)tc)->INTCTRLB | (level << TC0_CCDINTLVL_gp); -} - -//@} - -/** - * \brief Configure Timer Clock Source - * - * \param tc Pointer to TC module. - * \param TC_CLKSEL_enum Clock source selection - * \note Configuring the clock starts alos the timer - */ -static inline void tc_write_clock_source(volatile void *tc, - TC_CLKSEL_t TC_CLKSEL_enum) -{ - ((TC0_t *)tc)->CTRLA = - (((TC0_t *)tc)->CTRLA & ~TC0_CLKSEL_gm) | - TC_CLKSEL_enum; -} - -/** - * \brief Read Timer Clock Source - * - * \param tc Pointer to TC module. - * \return TC_CLKSEL_enum Clock source selection - */ -static inline TC_CLKSEL_t tc_read_clock_source(volatile void *tc) -{ - return (TC_CLKSEL_t)(((TC0_t *)tc)->CTRLA & TC0_CLKSEL_gm); -} - -/** - * \brief Select clock for a specified TC and resolution. - * - * This function configures the clock selection, as prescaled CLKper, for a - * specified TC that gives a resolution at least as high as the one specified. - * The resolution of a TC is synonymous with its clock frequency. - * - * \note It is also possible to clock TCs with event channels. This is not - * handled by this implementation. - * - * \param tc ID of TC to get clock selection for. - * \param resolution Desired resolution for the TC in Hz. - */ -static inline void tc_set_resolution(void *tc, uint32_t resolution) -{ - uint32_t tc_clk_rate = sysclk_get_per_hz(); - - if (resolution <= (tc_clk_rate / 1024)) { - tc_write_clock_source(tc, TC_CLKSEL_DIV1024_gc); - } else if (resolution <= (tc_clk_rate / 256)) { - tc_write_clock_source(tc, TC_CLKSEL_DIV256_gc); - } else if (resolution <= (tc_clk_rate / 64)) { - tc_write_clock_source(tc, TC_CLKSEL_DIV64_gc); - } else if (resolution <= (tc_clk_rate / 8)) { - tc_write_clock_source(tc, TC_CLKSEL_DIV8_gc); - } else if (resolution <= (tc_clk_rate / 4)) { - tc_write_clock_source(tc, TC_CLKSEL_DIV4_gc); - } else if (resolution <= (tc_clk_rate / 2)) { - tc_write_clock_source(tc, TC_CLKSEL_DIV2_gc); - } else { - tc_write_clock_source(tc, TC_CLKSEL_DIV1_gc); - } -} - -/** - * \brief Get real resolution for a specified TC. - * - * This function returns the resolution which the specified clock selection - * of TC will result in. The resolution of a TC is synonymous with its clock - * frequency. - * - * \note This function does not handle event channel clock selections. - * - * \param tc Pointer of TC module to get resolution for. - * - * \return The resolution of \a tc. - */ -static inline uint32_t tc_get_resolution(void *tc) -{ - uint32_t tc_clk_rate = sysclk_get_per_hz(); - switch (tc_read_clock_source(tc)) { - case TC_CLKSEL_OFF_gc: - tc_clk_rate = 0; - break; - - case TC_CLKSEL_DIV1024_gc: - tc_clk_rate /= 1024; - break; - - case TC_CLKSEL_DIV256_gc: - tc_clk_rate /= 256; - break; - - case TC_CLKSEL_DIV64_gc: - tc_clk_rate /= 64; - break; - - case TC_CLKSEL_DIV8_gc: - tc_clk_rate /= 8; - break; - - case TC_CLKSEL_DIV4_gc: - tc_clk_rate /= 4; - break; - - case TC_CLKSEL_DIV2_gc: - tc_clk_rate /= 2; - break; - - case TC_CLKSEL_DIV1_gc: - break; - - default: - tc_clk_rate = 0; - break; - } - return (tc_clk_rate); -} - -/** - * \brief Configure Timer Direction - * - * \param tc Pointer to TC module. - * \param dir Timer direction : - */ -static inline void tc_set_direction(volatile void *tc, enum tc_dir_t dir) -{ - if (dir == TC_UP) { - ((TC0_t *)tc)->CTRLFCLR |= ~TC0_DIR_bm; - } else { - ((TC0_t *)tc)->CTRLFSET |= TC0_DIR_bm; - } -} - -/** - * \brief Write the Counter value of the Timer - * - * \param tc Pointer to TC module. - * \param cnt_value Counter value : - */ -static inline void tc_write_count(volatile void *tc, uint16_t cnt_value) -{ - ((TC0_t *)tc)->CNT = cnt_value; -} - -/** - * \brief Reads the Counter value of the Timer - * - * \param tc Pointer to TC module. - * \note Output the Counter value CNT - */ -static inline uint16_t tc_read_count(volatile void *tc) -{ - return (((TC0_t *)tc)->CNT); -} - -/** - * \brief Writes the Period value of the Timer - * - * \param tc Pointer to TC module. - * \param per_value Period value : PER - */ -static inline void tc_write_period(volatile void *tc, uint16_t per_value) -{ - ((TC0_t *)tc)->PER = per_value; -} - -/** - * \brief Reads the Period value of the Timer - * - * \param tc Pointer to TC module. - * \return Period value : PER - */ -static inline uint16_t tc_read_period(volatile void *tc) -{ - return (((TC0_t *)tc)->PER); -} - -/** - * \brief Writes the Period Buffer value of the Timer - * - * \param tc Pointer to TC module. - * \param per_buf Period Buffer value : PERH/PERL - */ -static inline void tc_write_period_buffer(volatile void *tc, uint16_t per_buf) -{ - ((TC0_t *)tc)->PERBUF = per_buf; -} - -/** - * \brief Reads the Period Buffer value of the Timer - * - * \param tc Pointer to TC module. - * \return Period Buffer value : PERH/PERL - */ -static inline uint16_t tc_read_period_buffer(volatile void *tc) -{ - return (((TC0_t *)tc)->PERBUF); -} - -/** - * \brief Tests if the Period Buffer is valid - * - * \param tc Pointer to TC module. - * \return period Buffer is valid or not:PERBV - */ -static inline bool tc_period_buffer_is_valid(volatile void *tc) -{ - return (((TC0_t *)tc)->CTRLGCLR & TC0_PERBV_bm); -} - -/** - * \brief Enables delay (used for 32bit timer mode) - * - * \param tc Pointer to TC module. - * \note enables Delay mode - */ -static inline void tc_enable_delay(volatile void *tc) -{ - ((TC0_t *)tc)->CTRLD = (((TC0_t *)tc)->CTRLD & - ~TC0_EVDLY_bm) | (1 << TC0_EVDLY_bp); -} - -/** - * \brief Disables delay - * - * \param tc Pointer to TC module. - * \note disables Delay mode - */ -static inline void tc_disable_delay(volatile void *tc) -{ - ((TC0_t *)tc)->CTRLD = ((TC0_t *)tc)->CTRLD & ~TC0_EVDLY_bm; -} - -/** - * \brief Tests if the Overflow flag is set - * - * \param tc Pointer to TC module. - * \return overflow has occured or not : OVFIF - */ -static inline bool tc_is_overflow(volatile void *tc) -{ - return (((TC0_t *)tc)->INTFLAGS & TC0_OVFIF_bm); -} - -/** - * \brief Clears the Overflow flag - * - * \param tc Pointer to TC module. - * \note OVFIF is cleared - */ -static inline void tc_clear_overflow(volatile void *tc) -{ - ((TC0_t *)tc)->INTFLAGS |= TC0_OVFIF_bm; -} - -/** - * \brief Tests if the Error flag is set - * - * \param tc Pointer to TC module. - * \return Error has occured or not : ERRIF - */ -static inline bool tc_read_error(volatile void *tc) -{ - return (((TC0_t *)tc)->INTFLAGS & TC0_ERRIF_bm); -} - -/** - * \brief Clears the Error flag - * - * \param tc Pointer to TC module. - * \note ERRIF is cleared - */ -static inline void tc_clear_error(volatile void *tc) -{ - ((TC0_t *)tc)->INTFLAGS |= TC0_ERRIF_bm; -} - -/** - * \brief Restart the Timer - * - * \param tc Pointer to TC module. - * \note CMD[3] in CTRLFSET is set to 1 and CMD[2] in CTRLFCLR is set - */ -static inline void tc_restart(volatile void *tc) -{ - ((TC0_t *)tc)->CTRLFSET = TC_CMD_RESTART_gc; -} - -/** - * \brief Reset the Timer - * - * \param tc Pointer to TC module. - * \note CMD[3:2] in CTRLFSET are set to 1 - */ -static inline void tc_reset(volatile void *tc) -{ - ((TC0_t *)tc)->CTRLFSET = TC_CMD_RESET_gc; -} - -/** - * \brief Update the Timer - * - * \param tc Pointer to TC module. - * \note CMD[2] in CTRLFSET is set to 1 and CMD[3] in CTRLFCLR is set - */ -static inline void tc_update(volatile void *tc) -{ - ((TC0_t *)tc)->CTRLFSET = TC_CMD_UPDATE_gc; -} - -/** - * \brief Configures the Timer in Byte mode - * - * \param tc Pointer to TC module. - * \note Configures BYTEM in CTRLE - */ -static inline void tc_set_8bits_mode(volatile void *tc) -{ -#ifdef TC0_BYTEM0_bm - ((TC0_t *)tc)->CTRLE |= TC0_BYTEM0_bm; -#else - ((TC0_t *)tc)->CTRLE |= TC0_BYTEM_bm; -#endif -} - -/** - * \brief Locks the Update of the Buffered registers - * - * \param tc Pointer to TC module. - * - * */ -static inline void tc_lock_update_buffers(volatile void *tc) -{ - ((TC0_t *)tc)->CTRLFSET |= TC0_LUPD_bm; -} - -/** - * \brief Unlocks the Update of the Buffered registers - * - * \param tc Pointer to TC module. - * \note Configures LUPD in CTRLFCLR - */ -static inline void tc_unlock_update_buffers(volatile void *tc) -{ - ((TC0_t *)tc)->CTRLFCLR |= TC0_LUPD_bm; -} - -/** - * \brief Enables Compare/Capture channel - * - * \param tc Pointer to TC module. - * \param enablemask CC channel - */ -static inline void tc_enable_cc_channels(volatile void *tc, - enum tc_cc_channel_mask_enable_t enablemask) -{ - if (tc_is_tc0(void *tc)) { - ((TC0_t *)tc)->CTRLB |= enablemask; - } else if (tc_is_tc1(void *tc)) { - ((TC1_t *)tc)->CTRLB |= - enablemask & (TC1_CCAEN_bm | TC1_CCBEN_bm); - } -} - -/** - * \brief Disables Compare/Capture channel - * - * \param tc Pointer to TC module. - * \param disablemask CC channel - */ -static inline void tc_disable_cc_channels(volatile void *tc, - enum tc_cc_channel_mask_enable_t disablemask) -{ - if (tc_is_tc0(void *tc)) { - ((TC0_t *)tc)->CTRLB &= ~disablemask; - } else if (tc_is_tc1(void *tc)) { - ((TC1_t *)tc)->CTRLB &= - ~(disablemask & TC0_CCAEN_bm & TC0_CCBEN_bm); - } -} - -/** - * \brief Enables Input capture mode - * - * \param tc Pointer to TC module. - * \param eventsource Source for the capture - * \param eventaction Event action capture type - */ -static inline void tc_set_input_capture(volatile void *tc, - TC_EVSEL_t eventsource, TC_EVACT_t eventaction) -{ - ((TC0_t *)tc)->CTRLD &= ~(TC0_EVSEL_gm | TC0_EVACT_gm); - ((TC0_t *)tc)->CTRLD |= (eventsource | eventaction); -} - -/** - * \brief Reads the Capture value - * - * \param tc Pointer to TC module. - * \param channel_index Channel x - * \return Read value of CCx - */ -static inline uint16_t tc_read_cc(volatile void *tc, - enum tc_cc_channel_t channel_index) -{ - if (tc_is_tc0(void *tc)) { - switch (channel_index) { - case TC_CCA: - return (((TC0_t *)tc)->CCA); - case TC_CCB: - return (((TC0_t *)tc)->CCB); - case TC_CCC: - return (((TC0_t *)tc)->CCC); - case TC_CCD: - return (((TC0_t *)tc)->CCD); - } - } else if (tc_is_tc1(void *tc)) { - switch (channel_index) { - case TC_CCA: - return (((TC1_t *)tc)->CCA); - case TC_CCB: - return (((TC1_t *)tc)->CCB); - default: - return (0); - } - } - return (0); -} - -/** - * \brief Writes the CC value - * - * \param tc Pointer to TC module. - * \param channel_index CC Channel - * \param value Counter value - */ -static inline void tc_write_cc(volatile void *tc, - enum tc_cc_channel_t channel_index, uint16_t value) -{ - if (tc_is_tc0(void *tc)) { - switch (channel_index) { - case TC_CCA: - ((TC0_t *)tc)->CCA = value; - break; - case TC_CCB: - ((TC0_t *)tc)->CCB = value; - break; - case TC_CCC: - ((TC0_t *)tc)->CCC = value; - break; - case TC_CCD: - ((TC0_t *)tc)->CCD = value; - break; - } - } else if (tc_is_tc1(void *tc)) { - switch (channel_index) { - case TC_CCA: - ((TC1_t *)tc)->CCA = value; - break; - case TC_CCB: - ((TC1_t *)tc)->CCB = value; - break; - default: - return ; - } - } -} - -/** - * \brief Writes the Capture/Compare Buffer value - * - * \param tc Pointer to TC module. - * \param channel_index CC Channel - * \param buffer_value Counter Buffer value - */ -static inline void tc_write_cc_buffer(volatile void *tc, - enum tc_cc_channel_t channel_index, uint16_t buffer_value) -{ - if (tc_is_tc0(void *tc)) { - switch (channel_index) { - case TC_CCA: - ((TC0_t *)tc)->CCABUF = buffer_value; - break; - case TC_CCB: - ((TC0_t *)tc)->CCBBUF = buffer_value; - break; - case TC_CCC: - ((TC0_t *)tc)->CCCBUF = buffer_value; - break; - case TC_CCD: - ((TC0_t *)tc)->CCDBUF = buffer_value; - break; - } - } else if (tc_is_tc1(void *tc)) { - switch (channel_index) { - case TC_CCA: - ((TC1_t *)tc)->CCABUF = buffer_value; - break; - case TC_CCB: - ((TC1_t *)tc)->CCBBUF = buffer_value; - break; - default: - return; - } - } -} - -/** - * \brief Reads the Capture/Compare Buffer value - * - * \param tc Pointer to TC module. - * \param channel_index CC Channel - * \return CCx Buffer value - */ -static inline uint16_t tc_read_cc_buffer(volatile void *tc, - enum tc_cc_channel_t channel_index) -{ - if (tc_is_tc0(void *tc)) { - switch (channel_index) { - case TC_CCA: - return (((TC0_t *)tc)->CCABUF); - case TC_CCB: - return (((TC0_t *)tc)->CCBBUF); - case TC_CCC: - return (((TC0_t *)tc)->CCCBUF); - case TC_CCD: - return (((TC0_t *)tc)->CCDBUF); - } - } else if (tc_is_tc1(void *tc)) { - switch (channel_index) { - case TC_CCA: - return (((TC1_t *)tc)->CCABUF); - case TC_CCB: - return (((TC1_t *)tc)->CCBBUF); - default: - return (0); - } - } - return (0); -} - -/** - * \brief Reports is Capture/Compare Buffer is valid - * - * \param tc Pointer to TC module. - * \param channel_index CC Channel - * \return CCx Buffer is valid or not - */ -static inline bool tc_cc_buffer_is_valid(volatile void *tc, - enum tc_cc_channel_t channel_index) -{ - if (tc_is_tc0(void *tc)) { - switch (channel_index) { - case TC_CCA: - return ((TC0_t *)tc)->CTRLGCLR & TC0_CCABV_bm; - case TC_CCB: - return ((TC0_t *)tc)->CTRLGCLR & TC0_CCBBV_bm; - case TC_CCC: - return ((TC0_t *)tc)->CTRLGCLR & TC0_CCCBV_bm; - case TC_CCD: - return ((TC0_t *)tc)->CTRLGCLR & TC0_CCDBV_bm; - } - } else if (tc_is_tc1(void *tc)) { - switch (channel_index) { - case TC_CCA: - return (((TC1_t *)tc)->CTRLGCLR & - TC1_CCABV_bm); - case TC_CCB: - return (((TC1_t *)tc)->CTRLGCLR & - TC1_CCBBV_bm); - default: - return (0); - } - } - return (0); -} - -/** - * \brief Reports if Capture/Compare interrupt has occured - * - * \param tc Pointer to TC module. - * \param channel_index CC Channel - * \return CCx Interrupt or not - */ -static inline bool tc_is_cc_interrupt(volatile void *tc, - enum tc_cc_channel_t channel_index) -{ - if (tc_is_tc0(void *tc)) { - switch (channel_index) { - case TC_CCA: - return (((TC0_t *)tc)->INTFLAGS & TC0_CCAIF_bm); - case TC_CCB: - return (((TC0_t *)tc)->INTFLAGS & TC0_CCBIF_bm); - case TC_CCC: - return (((TC0_t *)tc)->INTFLAGS & TC0_CCCIF_bm); - case TC_CCD: - return (((TC0_t *)tc)->INTFLAGS & TC0_CCDIF_bm); - } - } else if (tc_is_tc1(void *tc)) { - switch (channel_index) { - case TC_CCA: - return (((TC1_t *)tc)->INTFLAGS & - TC1_CCAIF_bm); - case TC_CCB: - return (((TC1_t *)tc)->INTFLAGS & - TC1_CCBIF_bm); - default: - return (0); - } - } - return (0); -} - -/** - * \brief Clears Capture/Compare interrupt - * - * \param tc Pointer to TC module. - * \param channel_index CC Channel - */ -static inline void tc_clear_cc_interrupt(volatile void *tc, - enum tc_cc_channel_t channel_index) -{ - if (tc_is_tc0(void *tc)) { - switch (channel_index) { - case TC_CCA: - ((TC0_t *)tc)->INTFLAGS = TC0_CCAIF_bm; - break; - case TC_CCB: - ((TC0_t *)tc)->INTFLAGS = TC0_CCBIF_bm; - break; - case TC_CCC: - ((TC0_t *)tc)->INTFLAGS = TC0_CCCIF_bm; - break; - case TC_CCD: - ((TC0_t *)tc)->INTFLAGS = TC0_CCDIF_bm; - break; - } - } else if (tc_is_tc1(void *tc)) { - switch (channel_index) { - case TC_CCA: - ((TC1_t *)tc)->INTFLAGS = TC1_CCAIF_bm; - break; - case TC_CCB: - ((TC1_t *)tc)->INTFLAGS = TC1_CCBIF_bm; - break; - default: - return; - } - } -} - -/** - * \brief Configures TC in the specified Waveform generator mode - * - * \param tc Pointer to TC module. - * \param wgm : waveform generator - */ -static inline void tc_set_wgm(volatile void *tc, enum tc_wg_mode_t wgm) -{ - ((TC0_t *)tc)->CTRLB = (((TC0_t *)tc)->CTRLB & ~TC0_WGMODE_gm) | wgm; -} - -/** - * \ingroup tc_group - * \defgroup tc_awex_group AWeX extension driver - * This group provides low level drivers to configure AWeX extension - * @{ - */ - -/** - * \brief AWeX extension enable - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_enable_cwcm(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL |= AWEX_CWCM_bm; -} - -/** - * \brief AWeX extension disable Common waveform mode - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_disable_cwcm(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL &= ~AWEX_CWCM_bm; -} - -/** - * \brief AWeX extension ensable pattern generator mode - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_enable_pgm(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL |= AWEX_PGM_bm; -} - -/** - * \brief AWeX extension dissable pattern generator mode - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_disable_pgm(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL &= ~AWEX_PGM_bm; -} - -/** - * \brief AWeX extension : enable Deadtime insertion on ccA - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_enable_cca_deadtime(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL |= AWEX_DTICCAEN_bm; -} - -/** - * \brief AWeX extension : disable Deadtime insertion on ccA - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_disable_cca_deadtime(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL &= ~AWEX_DTICCAEN_bm; -} - -/** - * \brief AWeX extension : enable Deadtime insertion on ccB - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_enable_ccb_deadtime(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL |= AWEX_DTICCBEN_bm; -} - -/** - * \brief AWeX extension : disable Deadtime insertion on ccB - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_disable_ccb_deadtime(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL &= ~AWEX_DTICCBEN_bm; -} - -/** - * \brief AWeX extension : enable Deadtime insertion on ccC - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_enable_ccc_deadtime(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL |= AWEX_DTICCCEN_bm; -} - -/** - * \brief AWeX extension : disable Deadtime insertion on ccD - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_disable_ccc_deadtime(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL &= ~AWEX_DTICCCEN_bm; -} - -/** - * \brief AWeX extension : enable Deadtime insertion on ccD - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_enable_ccd_deadtime(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL |= AWEX_DTICCDEN_bm; -} - -/** - * \brief AWeX extension : disable Deadtime insertion on ccD - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_disable_ccd_deadtime(AWEX_t *awex) -{ - ((AWEX_t *)awex)->CTRL &= ~AWEX_DTICCDEN_bm; -} -/** - * \brief AWeX extension : configures high side deadtime - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - * \param value : deadtime value - */ -static inline void tc_awex_set_dti_high(AWEX_t *awex, int16_t value) -{ - ((AWEX_t *)awex)->DTHS = value; -} -/** - * \brief AWeX extension : configures low side deadtime - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - * \param value : deadtime value - */ -static inline void tc_awex_set_dti_low(AWEX_t *awex, int16_t value) -{ - ((AWEX_t *)awex)->DTLS = value; -} -/** - * \brief AWeX extension : configures symetrical deadtime - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - * \param value : deadtime value - */ -static inline void tc_awex_set_dti_both(AWEX_t *awex, int16_t value) -{ - ((AWEX_t *)awex)->DTBOTH = value; -} - -/** - * \brief AWeX extension : configures symetrical deadtime buffer - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - * \param value : deadtime buffer value - */ -static inline void tc_awex_set_dti_both_buffer(AWEX_t *awex, - int16_t value) -{ - ((AWEX_t *)awex)->DTBOTHBUF = value; -} - -/** - * \brief AWeX extension : returns the deadtime buffer high nibble - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - * \return Dead Time High value - */ -static inline int8_t tc_awex_get_dti_high_buffer(AWEX_t *awex) -{ - return (((AWEX_t *)awex)->DTHSBUF); -} - -/** - * \brief AWeX extension : returns the deadtime buffer low nibble - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - * \return Dead Time High value - */ -static inline int8_t tc_awex_get_dti_low_buffer(AWEX_t *awex) -{ - return (((AWEX_t *)awex)->DTLSBUF); -} - -/** - * \brief AWeX extension : returns if DTI high buffer is valid - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - * \return Dead Time High Buffer valid or not - */ -static inline bool tc_awex_is_dti_high_buffer_valid(AWEX_t *awex) -{ - return (((AWEX_t *)awex)->STATUS & AWEX_DTHSBUFV_bm); -} - -/** - * \brief AWeX extension : returns if DTI low buffer is valid - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - * \return Dead Time Low Buffer is valid or not - */ -static inline bool tc_awex_is_dti_low_buffer_valid(AWEX_t *awex) -{ - return (((AWEX_t *)awex)->STATUS & AWEX_DTLSBUFV_bm); -} - -/** - * \brief AWeX extension : configures the Fault restart in latched mode - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_fdmode_restart_latched(AWEX_t *awex) -{ - ((AWEX_t *)awex)->FDCTRL &= ~AWEX_FDMODE_bm; -} - -/** - * \brief AWeX extension : configures the Fault restart in cycle to cycle mode - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_fdmode_restart_cycle(AWEX_t *awex) -{ - ((AWEX_t *)awex)->FDCTRL |= AWEX_FDMODE_bm; -} - -/** - * \brief AWeX extension : returns if fault is detected - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline bool tc_awex_fault_is_detected(AWEX_t *awex) -{ - return (((AWEX_t *)awex)->STATUS & AWEX_FDF_bm); -} - -/** - * \brief AWeX extension : clears the Fault detection - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_clear_fault(AWEX_t *awex) -{ - ((AWEX_t *)awex)->STATUS = AWEX_FDF_bm; -} - -/** - * \brief AWeX extension : configures fault action - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - * \param fd_act Fault action - */ -static inline void tc_awex_set_fault_detection_action(AWEX_t * - awex, AWEX_FDACT_t fd_act) -{ - ((AWEX_t *)awex)->FDCTRL = (((AWEX_t *)awex)->FDCTRL & ~AWEX_FDACT_gm) | - (fd_act & AWEX_FDACT_gm); - -} - -/** - * \brief AWeX extension : configures fault detection event - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - * \param eventmask Fault detection event - */ -static inline void tc_awex_set_fault_detection_event(AWEX_t *awex, - int8_t eventmask) -{ - ((AWEX_t *)awex)->FDEMASK = eventmask; -} - -/** - * \brief AWeX extension : configures the port overdrive - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - * \param value Output everride configuration - */ -static inline void tc_awex_set_output_override(AWEX_t * awex, - int8_t value) -{ - ((AWEX_t *)awex)->OUTOVEN = value; -} - -/** - * \brief AWeX extension : enable fault detection on debug break detection - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_enable_fault_debug_break(AWEX_t *awex) -{ - ((AWEX_t *)awex)->FDCTRL &= ~AWEX_FDDBD_bm; -} - -/** - * \brief AWeX extension : disable fault detection on debug break detection - * - * \param awex Pointer to AWeX module (AWEXC or AWEXE) - */ -static inline void tc_awex_disable_fault_debug_break(AWEX_t *awex) -{ - ((AWEX_t *)awex)->FDCTRL |= AWEX_FDDBD_bm; -} -//@} -/** - * \ingroup tc_group - * \defgroup tc_hires_group Hi-Res extension driver - * This group provides low level drivers to configure Hi-Res extension - * @{ - */ - -/** - * \brief Hi-Res Extension : configures the Hi-Res - * - * \param hires Pointer to AWeX module (AWEXC or AWEXE) - * \param hi_res_mode HIRES configuration - */ -static inline void tc_hires_set_mode(HIRES_t * hires, HIRES_HREN_t hi_res_mode) -{ - ((HIRES_t *)hires)->CTRLA = hi_res_mode; -} -//@} - -/** @} */ - - -#ifdef __cplusplus -} -#endif - -/** - * \page xmega_tc_quickstart Quick Start Guide for the XMEGA TC Driver - * - * This is the quick start guide for the \ref tc_group , with step-by-step - * instructions on how to configure and use the driver for a specific use case. - * The code examples can be copied into e.g the main application loop or any - * other function that will need to control the timer/counters. - * - * - * \section xmega_tc_qs_use_cases Use cases - * - \ref xmega_tc_qs_ovf - * - \ref xmega_tc_qs_cc - * - \ref xmega_tc_qs_pwm - * - * - * \section xmega_tc_qs_ovf Timer/counter overflow (interrupt based) - * - * This use case will prepare a timer to trigger a interrupt when the timer - * overflows. The interrupt is handled by a cutomizable call back function. - * - * We will setup the timer in this mode: - * - Normal WGM mode (incrementing timer) - * - Use the system clock as clock source - * - No prescaling (DIV = 1) - * - Overflow interrupt after 1000 counts. This will be done by setting the top - * value to 1000. - * - * - * \section xmega_tc_qs_ovf_setup Setup steps - * - * \subsection xmega_tc_qs_ovf_usage_prereq Prequisites - * - * For the setup code of this use case to work, the following must - * be added to the project: - * - \ref interrupt_group - * - \ref clk_group - * - * \subsection xmega_tc_qs_ovf_setup_code Example code - * - * Add a callback function that will be executed when the overflow interrupt - * trigger. - * \code - * static void my_callback(void) - * { - * ...Add your code here. This code will be executed when the overflow occur... - * } - * \endcode - * Add to, e.g., the main loop in the application C-file: - * \code - * pmic_init(); - * sysclk_init(); - * tc_enable(&TCC0); - * tc_set_overflow_interrupt_callback(&TCC0, my_callback); - * tc_set_wgm(&TCC0, TC_WG_NORMAL); - * tc_write_period(&TCC0, 1000); - * tc_set_overflow_interrupt_level(&TCC0, TC_INT_LVL_LO); - * cpu_irq_enable(); - * tc_write_clock_source(&TCC0, TC_CLKSEL_DIV1_gc); - * \endcode - * - * \subsection xmega_tc_qs_ovf_setup_code_workflow Workflow - * - * -# Enable the interrupt controller: - * - \code pmic_init(); \endcode - * -# Enable the clock system: - * - \code sysclk_init(); \endcode - * -# Enable timer/counter TCC0 - * - \code tc_enable(&TCC0); \endcode - * - \note This will enable the clock system for the module - * -# Set the callback function for overflow interrupt - * - \code tc_set_overflow_interrupt_callback(&TCC0, my_callback); \endcode - * - \warning This function requires that the my_callback function is defined - * -# Set the desired waveform mode - * - \code tc_set_wgm(&TCC0, TC_WG_NORMAL); \endcode - * - \note In this case, we use normal mode where the timer increments it - count value until the TOP value is reached. The timer then reset - its count value to 0. - * -# Set the period - * - \code tc_write_period(&TCC0, 1000); \endcode - * - \note This will specify the TOP value of the counter. The timer will - * overflow and reset when this value is reached. - * -# Set the overflow interrupt level - * - \code tc_set_overflow_interrupt_level(&TCC0, TC_INT_LVL_LO); \endcode - * -# Enable interrupts: - * - \code cpu_irq_enable(); \endcode - * -# Set the clock source - * - \code tc_write_clock_source(&TCC0, TC_CLKSEL_DIV1_gc); \endcode - * - \warning When the clock source is set, the timer will start counting - * - * \section xmega_tc_qs_ovf_usage Usage steps - * - * - None. The timer will run in the background, and the code written in the - * call back function will execute each time the timer overflows. - * - * - * \section xmega_tc_qs_cc Timer/counter compare match (interrupt based) - * - * This use case will prepare a timer to trigger two independent interrupts - * when it reaches two different compare values. The period of the timer - * is customizable and the two compare matches will be handled by two separate - * interrupts implemented in call back functions. - * - * We will setup the timer in this mode: - * - Normal WGM mode - incrementing timer - * - Use the system clock as clock source - * - No prescaling (DIV = 1) - * - Period of timer 10000 counts - * - Compare match A interrupt trigger after 100 counts - * - Compare match B interrupt trigger after 1000 counts - * - If compare A and compare B match occur simulatneously, compare B - * should have higher priority - * - * - * \section xmega_tc_qs_cc_setup Setup steps - * - * \subsection xmega_tc_qs_cc_usage_prereq Prequisites - * For the setup code of this use case to work, the following must - * be added to the project: - * - \ref interrupt_group - * - \ref clk_group - * - * \subsection xmega_tc_qs_cc_setup_code Example code - * - * Add two callback functions that will be executed when compare match A and - * compare match B occurs - * \code - * static void my_cca_callback(void) - * { - * ...Add your code here. This code will be executed when a compare match - * occur on channel A... - * } - * static void my_ccb_callback(void) - * { - * ...Add your code here. This code will be executed when a compare match - * occur on channel B... - * } - * \endcode - * Add to, e.g., the main loop in the application C-file: - * \code - * pmic_init(); - * sysclk_init(); - * cpu_irq_enable(); - * tc_enable(&TCC0); - * tc_set_cca_interrupt_callback(&TCC0, my_cca_callback); - * tc_set_ccb_interrupt_callback(&TCC0, my_ccb_callback); - * tc_set_wgm(&TCC0, TC_WG_NORMAL); - * tc_write_period(&TCC0, 10000); - * tc_write_cc(&TCC0, TC_CCA, 100); - * tc_write_cc(&TCC0, TC_CCB, 1000); - * tc_enable_cc_channels(&TCC0,(TC_CCAEN | TC_CCBEN)); - * tc_set_cca_interrupt_level(&TCC0, TC_INT_LVL_LO); - * tc_set_ccb_interrupt_level(&TCC0, TC_INT_LVL_MED); - * tc_write_clock_source(&TCC0, TC_CLKSEL_DIV1_gc); - * \endcode - * - * \subsection xmega_tc_qs_cc_setup_code_workflow Workflow - * - * -# Enable the interrupt controller: - * - \code pmic_init(); \endcode - * -# Enable the clock system: - * - \code sysclk_init(); \endcode - * -# Enable interrupts: - * - \code cpu_irq_enable(); \endcode - * -# Enable timer/counter TCC0 - * - \code tc_enable(&TCC0); \endcode - * - \note This will enable the clock system for the module - * -# Set call back function for CCA interrupt - * - \code tc_set_cca_interrupt_callback(&TCC0, my_cca_callback); \endcode - * - \warning This function requires that the call back function is defined - * -# Set call back function for CCB interrupt - * - \code tc_set_ccb_interrupt_callback(&TCC0, my_ccb_callback); \endcode - * - \warning This function requires that the call back function is defined - * -# Set the desired waveform mode - * - \code tc_set_wgm(&TCC0, TC_WG_NORMAL); \endcode - * - \note In this case, we use normal mode where the timer increments it - count value until the TOP value is reached. The timer then reset - its count value to 0. - * -# Set the period - * - \code tc_write_period(&TCC0, 10000); \endcode - * - \note This will specify the TOP value of the counter. The timer will - * overflow and reset when this value is reached. - * -# Set compare match value on CCA - * - \code tc_write_cc(&TCC0, TC_CCA, 100); \endcode - * -# Set compare match value on CCB - * - \code tc_write_cc(&TCC0, TC_CCB, 1000); \endcode - * -# Enable compare channel A and compare channel B - * -\code tc_enable_cc_channels(&TCC0, (TC_CCAEN | TC_CCBEN)); \endcode - * -# Set interrupt level on channel A (low priority, see \ref TC_INT_LEVEL_t) - * - \code tc_set_cca_interrupt_level(&TCC0, TC_INT_LVL_LO); \endcode - * -# Set interrupt level on channel B (medium priority \ref TC_INT_LEVEL_t) - * - \code tc_set_ccb_interrupt_level(&TCC0, TC_INT_LVL_MED); \endcode - * -# Set the clock source - * - \code tc_write_clock_source(&TCC0, TC_CLKSEL_DIV1_gc); \endcode - * - \warning When the clock source is set, the timer will start counting - * - * \section xmega_tc_qs_cc_usage Usage steps - * - * - None. The timer will run in the background, and the code written in the - * call back functions will execute each time a compare match occur. - * - * - * \section xmega_tc_qs_pwm Timer/counter PWM - * - * This use case will setup a timer in PWM mode. For more details you can - * also look at the XMEGA PWM service. - * - * We will setup the timer in this mode: - * - Normal WGM mode - incrementing timer - * - Use the 2MHz oscillator as clock source (default) - * - 1Hz PWM frequency (2MHz clock, 1024x prescale, TOP value 1950) - * - 10% duty cycle (1:10 ratio between PER and CC register) - * - Output the PWM signal to a I/O port - * - * \section xmega_tc_qs_pwm_setup Setup steps - * - * \subsection xmega_tc_qs_pwm_usage_prereq Prequisites - * For the setup code of this use case to work, the following must - * be added to the project: - * - \ref clk_group - * - * \subsection xmega_tc_qs_pwm_setup_code Example code - * - * Add to, e.g., the main loop in the application C-file: - * \code - * board_init(); - * sysclk_init(); - * tc_enable(&TCE0); - * tc_set_wgm(&TCE0, TC_WG_SS); - * tc_write_period(&TCE0, 1950); - * tc_write_cc(&TCE0, TC_CCA, 195); - * tc_enable_cc_channels(&TCE0,TC_CCAEN); - * tc_write_clock_source(&TCE0, TC_CLKSEL_DIV1024_gc); - * \endcode - * - * \subsection xmega_tc_qs_pwm_setup_code_workflow Workflow - * - * -# Ensure that PWM I/O pin is configured as output - * - \code board_init(); \endcode - * \note The board_init(); function configures the I/O pins. If this function - * is not executed, the I/O pin must be configured as output manually - * -# Enable the clock system: - * - \code sysclk_init(); \endcode - * -# Enable timer/counter TCE0 - * - \code tc_enable(&TCE0); \endcode - * - \note This will enable the clock system for the module - * -# Set the desired waveform mode - * - \code tc_set_wgm(&TCE0, TC_WG_NORMAL); \endcode - * - \note In this case, we use normal mode where the timer increments it - * count value until the TOP value is reached. The timer then reset - * its count value to 0. - * -# Set the period - * - \code tc_write_period(&TCE0, 1950); \endcode - * - \note This will specify the TOP value of the counter. The timer will - * overflow and reset when this value is reached. - * -# Set compare match value on CCA - * - \code tc_write_cc(&TCC0, TC_CCA, 195); \endcode - * - \note The PWM duty cycle will be the ratio between PER and CCA, which - * is set by the tc_write_period() and tc_write_cc() functions. Use - * tc_write_cc() to change duty cycle run time (e.g to dim a LED). - * When CCA = 0, the duty cycle will be 0%. When CCA = PER (top value) - * the duty cycle will be 100%. - * -# Enable compare channel A - * -\code tc_enable_cc_channels(&TCE0,TC_CCAEN); \endcode - * -# Set the clock source - * - \code tc_write_clock_source(&TCE0, TC_CLKSEL_DIV1024_gc); \endcode - * - \warning When the clock source is set, the timer will start counting - * - * \section xmega_tc_qs_pwm_usage Usage steps - * - Use tc_write_cc() to change the duty cycle of the PWM signal - * - Use tc_write_period() to change the PWM frequency - */ - -#endif /* TC_H */ diff --git a/DSTAT1/src/asf/xmega/drivers/usart/usart.c b/DSTAT1/src/asf/xmega/drivers/usart/usart.c deleted file mode 100644 index d428637..0000000 --- a/DSTAT1/src/asf/xmega/drivers/usart/usart.c +++ /dev/null @@ -1,458 +0,0 @@ -/** - * \file - * - * \brief USART driver for AVR XMEGA. - * - * Copyright (c) 2009-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#include - -#include "compiler.h" -#include "usart.h" -#include "sysclk.h" -#include "ioport.h" -#include "status_codes.h" - -/** - * \brief Enable the system clock to an USART module. - * - * This function will enable the system clock to the provided \arg usart - * module. - * - * \brief usart Pointer to an USART module. - */ -static inline void usart_enable_module_clock(USART_t *usart) -{ -#ifdef USARTC0 - if ((uintptr_t)usart == (uintptr_t)&USARTC0) { - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_USART0); - } -#endif -#ifdef USARTC1 - if ((uintptr_t)usart == (uintptr_t)&USARTC1) { - sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_USART1); - } -#endif -#ifdef USARTD0 - if ((uintptr_t)usart == (uintptr_t)&USARTD0) { - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_USART0); - } -#endif -#ifdef USARTD1 - if ((uintptr_t)usart == (uintptr_t)&USARTD1) { - sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_USART1); - } -#endif -#ifdef USARTE0 - if ((uintptr_t)usart == (uintptr_t)&USARTE0) { - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_USART0); - } -#endif -#ifdef USARTE1 - if ((uintptr_t)usart == (uintptr_t)&USARTE1) { - sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_USART1); - } -#endif -#ifdef USARTF0 - if ((uintptr_t)usart == (uintptr_t)&USARTF0) { - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_USART0); - } -#endif -#ifdef USARTF1 - if ((uintptr_t)usart == (uintptr_t)&USARTF1) { - sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_USART1); - } -#endif -} - -/** - * \brief Initialize USART in RS232 mode. - * - * This function initializes the USART module in RS232 mode using the - * usart_rs232_options_t configuration structure and CPU frequency. - * - * \param usart The USART module. - * \param opt The RS232 configuration option. - */ -void usart_init_rs232(USART_t *usart, const usart_rs232_options_t *opt) -{ - usart_enable_module_clock(usart); - usart_set_mode(usart, USART_CMODE_ASYNCHRONOUS_gc); - usart_format_set(usart, opt->charlength, opt->paritytype, - opt->stopbits); - usart_set_baudrate(usart, opt->baudrate, sysclk_get_per_hz()); - usart_tx_enable(usart); - usart_rx_enable(usart); -} - -/** - * \brief Initialize USART in SPI master mode. - * - * This function initializes the USART module in SPI master mode using the - * usart_spi_options_t configuration structure and CPU frequency. - * - * \param usart The USART module. - * \param opt The RS232 configuration option. - */ -void usart_init_spi(USART_t *usart, const usart_spi_options_t *opt) -{ - usart_enable_module_clock(usart); - usart_set_mode(usart, USART_CMODE_MSPI_gc); - port_pin_t sck_pin; - - if (opt->spimode == 1 || opt->spimode == 3) { - //! \todo Fix when UCPHA_bm is added to header file. - usart->CTRLC |= 0x02; - } else { - //! \todo Fix when UCPHA_bm is added to header file. - usart->CTRLC &= ~0x02; - } - - // configure Clock polarity using INVEN bit of the correct SCK I/O port - if (opt->spimode == 2 || opt->spimode == 3) { -#ifdef USARTC0 - if ((uint16_t)usart == (uint16_t)&USARTC0) { - sck_pin = IOPORT_CREATE_PIN(PORTC, 1); - ioport_configure_port_pin(ioport_pin_to_port(sck_pin), - ioport_pin_to_mask(sck_pin), - IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH | IOPORT_INV_ENABLED); - } -#endif -#ifdef USARTC1 - if ((uint16_t)usart == (uint16_t)&USARTC1) { - sck_pin = IOPORT_CREATE_PIN(PORTC, 5); - ioport_configure_port_pin(ioport_pin_to_port(sck_pin), - ioport_pin_to_mask(sck_pin), - IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH | IOPORT_INV_ENABLED); - } -#endif -#ifdef USARTD0 - if ((uint16_t)usart == (uint16_t)&USARTD0) { - sck_pin = IOPORT_CREATE_PIN(PORTD, 1); - ioport_configure_port_pin(ioport_pin_to_port(sck_pin), - ioport_pin_to_mask(sck_pin), - IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH | IOPORT_INV_ENABLED); - } -#endif -#ifdef USARTD1 - if ((uint16_t)usart == (uint16_t)&USARTD1) { - sck_pin = IOPORT_CREATE_PIN(PORTD, 5); - ioport_configure_port_pin(ioport_pin_to_port(sck_pin), - ioport_pin_to_mask(sck_pin), - IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH | IOPORT_INV_ENABLED); - } -#endif -#ifdef USARTE0 - if ((uint16_t)usart == (uint16_t)&USARTE0) { - sck_pin = IOPORT_CREATE_PIN(PORTE, 1); - ioport_configure_port_pin(ioport_pin_to_port(sck_pin), - ioport_pin_to_mask(sck_pin), - IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH | IOPORT_INV_ENABLED); - } -#endif -#ifdef USARTE1 - if ((uint16_t)usart == (uint16_t)&USARTE1) { - sck_pin = IOPORT_CREATE_PIN(PORTE, 5); - ioport_configure_port_pin(ioport_pin_to_port(sck_pin), - ioport_pin_to_mask(sck_pin), - IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH | IOPORT_INV_ENABLED); - } -#endif -#ifdef USARTF0 - if ((uint16_t)usart == (uint16_t)&USARTF0) { - sck_pin = IOPORT_CREATE_PIN(PORTF, 1); - ioport_configure_port_pin(ioport_pin_to_port(sck_pin), - ioport_pin_to_mask(sck_pin), - IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH | IOPORT_INV_ENABLED); - } -#endif -#ifdef USARTF1 - if ((uint16_t)usart == (uint16_t)&USARTF1) { - sck_pin = IOPORT_CREATE_PIN(PORTF, 5); - ioport_configure_port_pin(ioport_pin_to_port(sck_pin), - ioport_pin_to_mask(sck_pin), - IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH | IOPORT_INV_ENABLED); - } -#endif - } - - usart_spi_set_baudrate(usart, opt->baudrate, sysclk_get_per_hz()); - usart_tx_enable(usart); - usart_rx_enable(usart); -} - -/** - * \brief Send a data with the USART module - * - * This function outputs a data using the USART module. - * - * \param usart The USART module. - * \param c The data to send. - * - * \return STATUS_OK - */ -enum status_code usart_putchar(USART_t *usart, uint8_t c) -{ - while (usart_data_register_is_empty(usart) == false); - (usart)->DATA = c; - return STATUS_OK; -} - -/** - * \brief Receive a data with the USART module - * - * This function returns the received data from the USART module. - * - * \param usart The USART module. - * - * \return The received data. - */ -uint8_t usart_getchar(USART_t *usart) -{ - while (usart_rx_is_complete(usart) == false); - return ((uint8_t) (usart)->DATA); -} - -/** - * \brief Get the offset for lookup in the baudrate table - * - * \param baud The requested baudrate - * - * \return The baudrate offset in PROGMEM table - * \retval USART_BAUD_UNDEFINED for baudrates not in lookup table - */ -static uint8_t usart_get_baud_offset(uint32_t baud) -{ - switch(baud) { - case 1200: - return (uint8_t)USART_BAUD_1200; - case 2400: - return (uint8_t)USART_BAUD_2400; - case 4800: - return (uint8_t)USART_BAUD_4800; - case 9600: - return (uint8_t)USART_BAUD_9600; - case 19200: - return (uint8_t)USART_BAUD_19200; - case 38400: - return (uint8_t)USART_BAUD_38400; - case 57600: - return (uint8_t)USART_BAUD_57600; - default: - return (uint8_t)USART_BAUD_UNDEFINED; - } -} - -/** - * \brief Set the baudrate by setting the BSEL and BSCALE values in the USART - * - * This function sets the selected BSEL and BSCALE value in the BAUDCTRL - * registers with BSCALE 0. For calculation options, see table 21-1 in XMEGA A - * manual. - * - * \param usart The USART module. - * \param bsel Calculated BSEL value. - * \param bscale Calculated BSEL value. - * - */ -void usart_set_bsel_bscale_value(USART_t *usart, uint16_t bsel, uint8_t bscale) -{ - (usart)->BAUDCTRLA = (uint8_t) (bsel); - (usart)->BAUDCTRLB = (uint8_t)(((bsel >> 8) & 0X0F) | (bscale << 4)); -} - -/** - * \brief Set the baudrate using precalculated BAUDCTRL values from PROGMEM - * - * \note This function only works for cpu_hz 2Mhz or 32Mhz and baudrate values - * 1200, 2400, 4800, 9600, 19200, 38400 and 57600. - * - * \param usart The USART module. - * \param baud The baudrate. - * \param cpu_hz The CPU frequency. - * - */ -void usart_set_baudrate_precalculated(USART_t *usart, uint32_t baud, - uint32_t cpu_hz) -{ - uint8_t baud_offset; - uint16_t baudctrl = 0; - - baud_offset = usart_get_baud_offset(baud); - - if (cpu_hz == 2000000UL) { - baudctrl = PROGMEM_READ_WORD(baudctrl_2mhz + baud_offset); - } else if (cpu_hz == 32000000UL){ - baudctrl = PROGMEM_READ_WORD(baudctrl_32mhz + baud_offset); - } else { - /* Error, system clock speed or USART baud rate is not supported - by the look-up table */ - Assert(false); - } - if (baud_offset != USART_BAUD_UNDEFINED) { - (usart)->BAUDCTRLB = (uint8_t)((uint16_t)baudctrl); - (usart)->BAUDCTRLA = (uint8_t)((uint16_t)baudctrl >> 8); - } -} - -/** - * \brief Set the baudrate value in the USART module - * - * This function sets the baudrate register with scaling regarding the CPU - * frequency and makes sure the baud rate is supported by the hardware. - * The function can be used if you don't want to calculate the settings - * yourself or changes to baudrate at runtime is required. - * - * \param usart The USART module. - * \param baud The baudrate. - * \param cpu_hz The CPU frequency. - * - * \retval true if the hardware supports the baud rate - * \retval false if the hardware does not support the baud rate (i.e. it's - * either too high or too low.) - */ -bool usart_set_baudrate(USART_t *usart, uint32_t baud, uint32_t cpu_hz) -{ - int8_t exp; - uint32_t div; - uint32_t limit; - uint32_t ratio; - uint32_t min_rate; - uint32_t max_rate; - - /* - * Check if the hardware supports the given baud rate - */ - // 8 = (2^0) * 8 * (2^0) = (2^BSCALE_MIN) * 8 * (BSEL_MIN) - max_rate = cpu_hz / 8; - // 4194304 = (2^7) * 8 * (2^12) = (2^BSCALE_MAX) * 8 * (BSEL_MAX+1) - min_rate = cpu_hz / 4194304; - - if (!((usart)->CTRLB & USART_CLK2X_bm)) { - max_rate /= 2; - min_rate /= 2; - } - - if ((baud > max_rate) || (baud < min_rate)) { - return false; - } - - /* - * Check if double speed is enabled. - */ - if (!((usart)->CTRLB & USART_CLK2X_bm)) { - baud *= 2; - } - - /* - * Find the lowest possible exponent. - */ - limit = 0xfffU >> 4; - ratio = cpu_hz / baud; - - for (exp = -7; exp < 7; exp++) { - if (ratio < limit) { - break; - } - - limit <<= 1; - - if (exp < -3) { - limit |= 1; - } - } - - /* - * Depending on the value of exp, scale either the input frequency or - * the target baud rate. By always scaling upwards, we never introduce - * any additional inaccuracy. - * - * We are including the final divide-by-8 (aka. right-shift-by-3) in this - * operation as it ensures that we never exceeed 2**32 at any point. - * - * The formula for calculating BSEL is slightly different when exp is - * negative than it is when exp is positive. - */ - if (exp < 0) { - /* - * We are supposed to subtract 1, then apply BSCALE. We want to apply - * BSCALE first, so we need to turn everything inside the parenthesis - * into a single fractional expression. - */ - cpu_hz -= 8 * baud; - /* - * If we end up with a left-shift after taking the final divide-by-8 - * into account, do the shift before the divide. Otherwise, left-shift - * the denominator instead (effectively resulting in an overall right - * shift.) - */ - if (exp <= -3) { - div = ((cpu_hz << (-exp - 3)) + baud / 2) / baud; - } else { - baud <<= exp + 3; - div = (cpu_hz + baud / 2) / baud; - } - } else { - /* - * We will always do a right shift in this case, but we need to shift - * three extra positions because of the divide-by-8. - */ - baud <<= exp + 3; - div = (cpu_hz + baud / 2) / baud - 1; - } - - (usart)->BAUDCTRLB = (uint8_t)(((div >> 8) & 0X0F) | (exp << 4)); - (usart)->BAUDCTRLA = (uint8_t)div; - - return true; -} - -/** - * \brief Set the baudrate value in the USART_SPI module - * - * This function sets the baudrate register regarding the CPU frequency. - * - * \param usart The USART(SPI) module. - * \param baud The baudrate. - * \param cpu_hz The CPU frequency. - */ -void usart_spi_set_baudrate(USART_t *usart, uint32_t baud, uint32_t cpu_hz) -{ - uint16_t bsel_value = (uint16_t)((((((cpu_hz) << 1) - / (baud * 2)) + 1) >> 1) - 1); - (usart)->BAUDCTRLB = (uint8_t)((~USART_BSCALE_gm) & (bsel_value >> 8)); - (usart)->BAUDCTRLA = (uint8_t)(bsel_value); -} diff --git a/DSTAT1/src/asf/xmega/drivers/usart/usart.h b/DSTAT1/src/asf/xmega/drivers/usart/usart.h deleted file mode 100644 index 73481e9..0000000 --- a/DSTAT1/src/asf/xmega/drivers/usart/usart.h +++ /dev/null @@ -1,553 +0,0 @@ -/** - * \file - * - * \brief USART driver for AVR XMEGA. - * - * This file contains basic functions for the AVR XMEGA USART, with support for all - * modes, settings and clock speeds. - * - * Copyright (c) 2009-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef _USART_H_ -#define _USART_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "compiler.h" -#include "pmic.h" - -/** - * \defgroup usart_group USART module (USART) - * - * See \ref usart_quickstart. - * - * This is a driver for configuring, enablig, disabling and use of the on-chip - * USART. - * - * \section dependencies Dependencies - * - * The USART module depends on the following modules: - * - \ref sysclk_group for peripheral clock control. - * - \ref port_driver_group for peripheral io port control. - * - * @{ - */ - -//! Offset in lookup table for baudrate 1200 -#define USART_BAUD_1200 0x00 -//! Offset in lookup table for baudrate 2400 -#define USART_BAUD_2400 0x01 -//! Offset in lookup table for baudrate 4800 -#define USART_BAUD_4800 0x02 -//! Offset in lookup table for baudrate 9600 -#define USART_BAUD_9600 0x03 -//! Offset in lookup table for baudrate 19200 -#define USART_BAUD_19200 0x04 -//! Offset in lookup table for baudrate 38400 -#define USART_BAUD_38400 0x05 -//! Offset in lookup table for baudrate 57600 -#define USART_BAUD_57600 0x06 -//! Baudrate not in lookup table -#define USART_BAUD_UNDEFINED 0xFF - -//! Lookup table containing baudctrl values for CPU frequency 2 Mhz -static PROGMEM_DECLARE(uint16_t, baudctrl_2mhz[]) = { - 0xE5BC, // Baud: 1200 - 0xC5AC, // Baud: 2400 - 0x859C, // Baud: 4800 - 0x0396, // Baud: 9600 - 0xC192, // Baud: 19200 - 0x2191, // Baud: 38400 - 0x9690, // Baud: 57600 -}; - -//! Lookup table containing baudctrl values for CPU frequency 32 Mhz -static PROGMEM_DECLARE(uint16_t, baudctrl_32mhz[]) = { - 0x031D, // Baud: 1200 - 0x01ED, // Baud: 2400 - 0xFDDC, // Baud: 4800 - 0xF5CC, // Baud: 9600 - 0xE5BC, // Baud: 19200 - 0xC5AC, // Baud: 38400 - 0x6EA8, // Baud: 57600 -}; -//! @} - -//! Input parameters when initializing RS232 and similar modes. -typedef struct usart_rs232_options { - //! Set baud rate of the USART (unused in slave modes). - uint32_t baudrate; - - //! Number of bits to transmit as a character (5 to 9). - USART_CHSIZE_t charlength; - - //! Parity type: USART_PMODE_DISABLED_gc, USART_PMODE_EVEN_gc, - //! USART_PMODE_ODD_gc. - USART_PMODE_t paritytype; - - //! Number of stop bits between two characters: - //! true: 2 stop bits - //! false: 1 stop bit - bool stopbits; - -} usart_rs232_options_t; - -//! Input parameters when initializing SPI master mode. -typedef struct usart_spi_options { - //! Set baud rate of the USART in SPI mode. - uint32_t baudrate; - - //! SPI transmission mode. - uint8_t spimode; - - uint8_t data_order; -} usart_spi_options_t; - -//! USART interrupt levels -enum usart_int_level_t { - USART_INT_LVL_OFF = 0x00, - USART_INT_LVL_LO = 0x01, - USART_INT_LVL_MED = 0x02, - USART_INT_LVL_HI = 0x03, -}; - -/** - * \brief Enable USART receiver. - * - * \param usart Pointer to the USART module - */ -static inline void usart_rx_enable(USART_t *usart) -{ - (usart)->CTRLB |= USART_RXEN_bm; -} - -/** - * \brief Disable USART receiver. - * - * \param usart Pointer to the USART module. - */ -static inline void usart_rx_disable(USART_t *usart) -{ - (usart)->CTRLB &= ~USART_RXEN_bm; -} - -/** - * \brief Configure the USART frame format. - * - * Sets the frame format, Frame Size, parity mode and number of stop bits. - * - * \param usart Pointer to the USART module - * \param charSize The character size. Use USART_CHSIZE_t type. - * \param parityMode The parity Mode. Use USART_PMODE_t type. - * \param twoStopBits Enable two stop bit mode. Use bool type. - */ -static inline void usart_format_set(USART_t *usart, USART_CHSIZE_t charSize, - USART_PMODE_t parityMode, bool twoStopBits) -{ - (usart)->CTRLC = (uint8_t)charSize | parityMode - | (twoStopBits ? USART_SBMODE_bm : 0); -} - -/** - * \brief Enable USART transmitter. - * - * \param usart Pointer to the USART module. - */ -static inline void usart_tx_enable(USART_t *usart) -{ - (usart)->CTRLB |= USART_TXEN_bm; -} - -/** - * \brief Disable USART transmitter. - * - * \param usart Pointer to the USART module. - */ -static inline void usart_tx_disable(USART_t *usart) -{ - (usart)->CTRLB &= ~USART_TXEN_bm; -} - -/** - * \brief Set USART RXD interrupt level. - * - * Sets the interrupt level on RX Complete interrupt. - * - * \param usart Pointer to the USART module. - * \param level Interrupt level of the RXD interrupt. - */ -static inline void usart_set_rx_interrupt_level(USART_t *usart, - enum usart_int_level_t level) -{ - (usart)->CTRLA = ((usart)->CTRLA & ~USART_RXCINTLVL_gm) | - (level << USART_RXCINTLVL_gp); -} - -/** - * \brief Set USART TXD interrupt level. - * - * Sets the interrupt level on TX Complete interrupt. - * - * \param usart Pointer to the USART module. - * \param level Interrupt level of the TXD interrupt. - */ -static inline void usart_set_tx_interrupt_level(USART_t *usart, - enum usart_int_level_t level) -{ - (usart)->CTRLA = ((usart)->CTRLA & ~USART_TXCINTLVL_gm) | - (level << USART_TXCINTLVL_gp); -} - -/** - * \brief Set USART DRE interrupt level. - * - * Sets the interrupt level on Data Register interrupt. - * - * \param usart Pointer to the USART module. - * \param level Interrupt level of the DRE interrupt. - * Use USART_DREINTLVL_t type. - */ -static inline void usart_set_dre_interrupt_level(USART_t *usart, - enum usart_int_level_t level) -{ - (usart)->CTRLA = ((usart)->CTRLA & ~USART_DREINTLVL_gm) | - (level << USART_DREINTLVL_gp); -} - -/** - * \brief Set the mode the USART run in. - * - * Set the mode the USART run in. The default mode is asynchronous mode. - * - * \param usart Pointer to the USART module register section. - * \param usartmode Selects the USART mode. Use USART_CMODE_t type. - * - * USART modes: - * - 0x0 : Asynchronous mode. - * - 0x1 : Synchronous mode. - * - 0x2 : IrDA mode. - * - 0x3 : Master SPI mode. - */ -static inline void usart_set_mode(USART_t *usart, USART_CMODE_t usartmode) -{ - (usart)->CTRLC = ((usart)->CTRLC & (~USART_CMODE_gm)) | usartmode; -} - -/** - * \brief Check if data register empty flag is set. - * - * \param usart The USART module. - */ -static inline bool usart_data_register_is_empty(USART_t * usart) -{ - return (usart)->STATUS & USART_DREIF_bm; -} - -/** - * \brief Checks if the RX complete interrupt flag is set. - * - * Checks if the RX complete interrupt flag is set. - * - * \param usart The USART module. - */ -static inline bool usart_rx_is_complete(USART_t * usart) -{ - return (usart)->STATUS & USART_RXCIF_bm; -} - -/** - * \brief Checks if the TX complete interrupt flag is set. - * - * Checks if the TX complete interrupt flag is set. - * - * \param usart The USART module. - */ -static inline bool usart_tx_is_complete(USART_t * usart) -{ - return (usart)->STATUS & USART_TXCIF_bm; -} - -/** - * \brief Clear TX complete interrupt flag. - * - * \param usart The USART module. - */ -static inline void usart_clear_tx_complete(USART_t * usart) -{ - (usart)->STATUS = USART_TXCIF_bm; -} - -/** - * \brief Clear RX complete interrupt flag. - * - * \param usart The USART module. - */ -static inline void usart_clear_rx_complete(USART_t *usart) -{ - (usart)->STATUS = USART_RXCIF_bm; -} - -/** - * \brief Write a data to the USART data register. - * - * \param usart The USART module. - * \param txdata The data to be transmited. - */ -static inline void usart_put(USART_t * usart, uint8_t txdata) -{ - (usart)->DATA = txdata; -} - -/** - * \brief Read a data to the USART data register. - * - * \param usart The USART module. - * - * \return The received data - */ -static inline uint8_t usart_get(USART_t * usart) -{ - return (usart)->DATA; -} - -/** - * \brief Performs a data transfer on the USART in SPI mode. - * - * \param usart The USART module. - * \param txdata The data to be transmited. - * - * \return The received data - */ -static inline uint8_t usart_spi_transmit(USART_t * usart, - uint8_t txdata) -{ - while (usart_data_register_is_empty(usart) == false); - usart_put(usart, txdata); - while (!usart_tx_is_complete(usart)); - usart_clear_tx_complete(usart); - return usart_get(usart); -} - -void usart_init_rs232(USART_t *usart, const usart_rs232_options_t *opt); -void usart_init_spi(USART_t * usart, const usart_spi_options_t * opt); - -enum status_code usart_putchar(USART_t * usart, uint8_t c); -uint8_t usart_getchar(USART_t * usart); - -void usart_set_bsel_bscale_value(USART_t *usart, uint16_t bsel, uint8_t bscale); -void usart_set_baudrate_precalculated(USART_t *usart, uint32_t baud, - uint32_t cpu_hz); -bool usart_set_baudrate(USART_t *usart, uint32_t baud, uint32_t cpu_hz); -void usart_spi_set_baudrate(USART_t * usart, uint32_t baud, uint32_t cpu_hz); -//! @} - -#ifdef __cplusplus -} -#endif - -/** - * \page usart_quickstart Quick start guide for USART module - * - * This is the quick start guide for the \ref usart_group "USART module", with - * step-by-step instructions on how to configure and use the driver in a - * selection of use cases. - * - * The use cases contain several code fragments. The code fragments in the - * steps for setup can be copied into a custom initialization function, while - * the steps for usage can be copied into, e.g., the main application function. - * - * \section usart_basic_use_case Basic use case - * \section usart_use_cases USART use cases - * - \ref usart_basic_use_case - * - \subpage usart_use_case_1 - * - * \section usart_basic_use_case Basic use case - transmit a character - * In this use case, the USART module is configured for: - * - Using USARTD0 - * - Baudrate: 9600 - * - Character length: 8 bit - * - Parity mode: Disabled - * - Stop bit: None - * - RS232 mode - * - * \section usart_basic_use_case_setup Setup steps - * - * \subsection usart_basic_use_case_setup_prereq Prerequisites - * -# \ref sysclk_group - * \subsection usart_basic_use_case_setup_code Example code - * The following configuration must be added to the project (typically to a - * conf_usart.h file, but it can also be added to your main application file.) - * \code - * #define USART_SERIAL &USARTD0 - * #define USART_SERIAL_BAUDRATE 9600 - * #define USART_SERIAL_CHAR_LENGTH USART_CHSIZE_8BIT_gc - * #define USART_SERIAL_PARITY USART_PMODE_DISABLED_gc - * #define USART_SERIAL_STOP_BIT false - * \endcode - * - * Add to application initialization: - * \code - * sysclk_init(); - * static usart_rs232_options_t USART_SERIAL_OPTIONS = { - * .baudrate = USART_SERIAL_BAUDRATE, - * .charlength = USART_SERIAL_CHAR_LENGTH, - * .paritytype = USART_SERIAL_PARITY, - * .stopbits = USART_SERIAL_STOP_BIT - * }; - * sysclk_enable_module(SYSCLK_PORT_D, PR_USART0_bm); - * usart_init_rs232(USART_SERIAL, &USART_SERIAL_OPTIONS); - * \endcode - * - * \subsection usart_basic_use_case_setup_flow Workflow - * -# Initialize system clock: - * - \code sysclk_init(); \endcode - * - \note Not always required, but since the \ref usart_group driver is - * dependent on \ref sysclk_group it is good practise to initialize - * this module. - * -# Create USART options struct: - * - \code - * static usart_rs232_options_t USART_SERIAL_OPTIONS = { - * .baudrate = USART_SERIAL_BAUDRATE, - * .charlength = USART_SERIAL_CHAR_LENGTH, - * .paritytype = USART_SERIAL_PARITY, - * .stopbits = USART_SERIAL_STOP_BIT - * }; - * \endcode - * -# Enable the clock for the USART module: - * - \code sysclk_enable_module(SYSCLK_PORT_D, PR_USART0_bm); \endcode - * -# Initialize in RS232 mode: - * - \code usart_init_rs232(USART_SERIAL, &USART_SERIAL_OPTIONS); - * \endcode - * - * \section usart_basic_use_case_usage Usage steps - * - * \subsection usart_basic_use_case_usage_code Example code - * Add to application C-file: - * \code - * usart_putchar(USART_SERIAL, 'a'); - * \endcode - * - * \subsection usart_basic_use_case_usage_flow Workflow - * -# Send an 'a' character via USART - * - \code usart_putchar(USART_SERIAL, 'a'); \endcode - */ - -/** - * \page usart_use_case_1 USART receive character and echo back - * - * In this use case, the USART module is configured for: - * - Using USARTD0 - * - Baudrate: 9600 - * - Character length: 8 bit - * - Parity mode: Disabled - * - Stop bit: None - * - RS232 mode - * - * The use case waits for a received character on the configured USART and - * echoes the character back to the same USART. - * - * \section usart_use_case_1_setup Setup steps - * - * \subsection usart_use_case_1_setup_prereq Prerequisites - * -# \ref sysclk_group - * - * \subsection usart_use_case_1_setup_code Example code - * -# The following configuration must be added to the project (typically to a - * conf_usart.h file, but it can also be added to your main application file.): - * \code - * #define USART_SERIAL &USARTD0 - * #define USART_SERIAL_BAUDRATE 9600 - * #define USART_SERIAL_CHAR_LENGTH USART_CHSIZE_8BIT_gc - * #define USART_SERIAL_PARITY USART_PMODE_DISABLED_gc - * #define USART_SERIAL_STOP_BIT false - * \endcode - * - * A variable for the received byte must be added: - * \code uint8_t received_byte; \endcode - * - * Add to application initialization: - * \code - * sysclk_init(); - * static usart_rs232_options_t USART_SERIAL_OPTIONS = { - * .baudrate = USART_SERIAL_BAUDRATE, - * .charlength = USART_SERIAL_CHAR_LENGTH, - * .paritytype = USART_SERIAL_PARITY, - * .stopbits = USART_SERIAL_STOP_BIT - * }; - * sysclk_enable_module(SYSCLK_PORT_D, PR_USART0_bm); - * usart_init_rs232(USART_SERIAL, &USART_SERIAL_OPTIONS); - * \endcode - * - * \subsection usart_use_case_1_setup_flow Workflow - * -# Initialize system clock: - * - \code sysclk_init(); \endcode - * - \note Not always required, but since the \ref usart_group driver is - * dependent on \ref sysclk_group it is good practise to initialize - * this module. - * -# Create USART options struct: - * - \code - * static usart_rs232_options_t USART_SERIAL_OPTIONS = { - * .baudrate = USART_SERIAL_BAUDRATE, - * .charlength = USART_SERIAL_CHAR_LENGTH, - * .paritytype = USART_SERIAL_PARITY, - * .stopbits = USART_SERIAL_STOP_BIT - * }; - * \endcode - * -# Enable the clock for the USART module: - * - \code sysclk_enable_module(SYSCLK_PORT_D, PR_USART0_bm); \endcode - * -# Initialize in RS232 mode: - * - \code usart_init_rs232(USART_SERIAL, &USART_SERIAL_OPTIONS); - * \endcode - * - * \section usart_use_case_1_usage Usage steps - * - * \subsection usart_use_case_1_usage_code Example code - * Add to, e.g., main loop in application C-file: - * \code - * received_byte = usart_getchar(USART_SERIAL); - * usart_putchar(USART_SERIAL, received_byte); - * \endcode - * - * \subsection usart_use_case_1_usage_flow Workflow - * -# Wait for receival of a character: - * - \code received_byte = usart_getchar(USART_SERIAL); \endcode - * -# Echo the character back: - * - \code usart_putchar(USART_SERIAL, received_byte); \endcode - */ - -#endif // _USART_H_ diff --git a/DSTAT1/src/asf/xmega/drivers/usb/usb_device.c b/DSTAT1/src/asf/xmega/drivers/usb/usb_device.c deleted file mode 100644 index 0f96e56..0000000 --- a/DSTAT1/src/asf/xmega/drivers/usb/usb_device.c +++ /dev/null @@ -1,1448 +0,0 @@ -/** - * \file - * - * \brief USB Device driver - * Compliance with common driver UDD - * - * Copyright (c) 2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#include "conf_usb.h" - -// Read Modify Write opcode is implemented after IAR AVR 5.51 -#ifdef __ICCAVR__ -# if (__VER__ <= 551 || XMEGA_A1U) -# undef USB_WORKAROUND_DO_NOT_USE_RMW -# define USB_WORKAROUND_DO_NOT_USE_RMW -# endif -#endif - -#include "sysclk.h" -#include "udd.h" -#include "usb_device.h" -#include - -#ifndef UDD_NO_SLEEP_MGR -#include "sleepmgr.h" -#endif - -#ifndef UDD_USB_INT_LEVEL -// By default USB interrupt have low priority -# define UDD_USB_INT_LEVEL USB_INTLVL_LO_gc -#endif - - - -#ifdef USB_DEVICE_HS_SUPPORT -#error This product does not support high speed mode, please remove define USB_DEVICE_HS_SUPPORT in conf_usb.h -#endif - -//////////////////////////////////////////////////// -// USBB Device low-level driver (UDD) -//////////////////////////////////////////////////// -/** - * \ingroup usb_device_group - * \defgroup udd_group USB Device Driver (UDD) - * - * \section USBB_CONF USBB Custom configuration - * The following USBB driver configuration must be included in the conf_usb.h - * file of the application. - * - * UDD_USB_INT_LEVEL
- * Option to change the interrupt priority (USB_INTLVL_x_gc) - * by default USB_INTLVL_LO_gc (recommended). - * - * \section Callbacks management - * The USB driver is fully managed by interrupt and does not request periodique - * task. Thereby, the USB events use callbacks to transfer the information. - * The callbacks are declared in static during compilation or in variable during - * code execution. - * - * Static declarations defined in conf_usb.h: - * - UDC_VBUS_EVENT(bool b_present)
- * To signal Vbus level change - * - UDC_SUSPEND_EVENT()
- * Called when USB bus enter in suspend mode - * - UDC_RESUME_EVENT()
- * Called when USB bus is wakeup - * - UDC_SOF_EVENT()
- * Called for each received SOF, Note: Each 1ms in HS/FS mode only. - * - * Dynamic callbacks, called "endpoint job" , are registered - * in udd_ep_job_t structure via the following functions: - * - udd_ep_run()
- * To call it when a transfer is finish - * - udd_ep_wait_stall_clear()
- * To call it when a endpoint halt is disabled - * - * \section Power mode management - * The Sleep modes authorized : - * - in USB IDLE state, the USB needs of USB clock and authorizes up to IDLE mode - * - in USB SUSPEND state, the USB no needs USB clock but requests a minimum - * clock restart timing. Thus, it authorizes up to POWER_DOWN or STANDBY mode. - * - * The USB_SLEEP_MODE_USB_IDLE equals SLEEPMGR_IDLE. - * - * The USB_SLEEP_MODE_USB_SUSPEND depends on USB clock startup timing: - * | Clock Startup | Sleep mode authorized | - * | >10ms | SLEEPMGR_STDBY | - * | <=10ms | SLEEPMGR_PDOWN | - * - * @{ - */ - - -// Check USB Device configuration -#ifndef USB_DEVICE_EP_CTRL_SIZE -# error USB_DEVICE_EP_CTRL_SIZE not defined -#endif -#ifndef USB_DEVICE_MAX_EP -# error USB_DEVICE_MAX_EP not defined -#endif -#if (USB_DEVICE_MAX_EP!=0) -// Errata: FIFO Multipacket generates a TC interrupt for each USB packets -// For silicon version impacted by this errata, the TC FIFO is set at maximum -// Note: Remove it when all silicons are fixed -# define USB_DEVICE_MAX_EP_TEMP 15 -#else -# define USB_DEVICE_MAX_EP_TEMP 0 -#endif - -/** - * \name Power management routine. - */ -//@{ - - -#ifndef UDD_NO_SLEEP_MGR - -//! Definition of sleep levels -#if ((defined USB_DEVICE_HS_SUPPORT) && (USBCLK_STARTUP_TIMEOUT>3000)) \ - || ((!defined USB_DEVICE_HS_SUPPORT) && (USBCLK_STARTUP_TIMEOUT>10000)) -# define USBC_SLEEP_MODE_USB_SUSPEND SLEEPMGR_IDLE -#else -# define USBC_SLEEP_MODE_USB_SUSPEND SLEEPMGR_PDOWN -#endif -#define USBC_SLEEP_MODE_USB_IDLE SLEEPMGR_IDLE - -//! State of USB line -static bool udd_b_idle; - - -/*! \brief Authorize or not the CPU powerdown mode - * - * \param b_enable true to authorize powerdown mode - */ -static void udd_sleep_mode(bool b_idle) -{ - if (!b_idle && udd_b_idle) { - sleepmgr_unlock_mode(USBC_SLEEP_MODE_USB_IDLE); - } - if (b_idle && !udd_b_idle) { - sleepmgr_lock_mode(USBC_SLEEP_MODE_USB_IDLE); - } - udd_b_idle = b_idle; -} -#else - -static void udd_sleep_mode(bool b_idle) { -} -#endif // UDD_NO_SLEEP_MGR - -//@} - -/** - * \brief USB SRAM data about fifo, endpoint descriptor table and frame number - * - * The content of the USB SRAM can be: - * - modified by USB hardware by interface to signal endpoint status. - * Thereby, it is read by software. - * - modified by USB software to control endpoint. - * Thereby, it is read by hardware. - * This data section is volatile and the specific opcode read/modify/write must be used. - * - * @{ - */ -struct udd_sram_data { -#if XMEGA_A1U -# if (0!=((USB_DEVICE_MAX_EP_TEMP+1)%4)) - uint8_t padding_align[16 - ((USB_DEVICE_MAX_EP_TEMP + 1) * - sizeof(uint32_t)) % 16]; -# endif -#endif - uint32_t fifo[USB_DEVICE_MAX_EP_TEMP + 1]; - USB_EP_t ep_ctrl[2 * (USB_DEVICE_MAX_EP_TEMP + 1)]; - uint16_t frame_number; -}; -#if XMEGA_A1U -COMPILER_ALIGNED(16) -#else -COMPILER_ALIGNED(4) //! Caution seems GCC does not handle 2 alignement properly -#endif -static volatile struct udd_sram_data udd_sram; -#define UDD_EP_t USB_EP_t volatile - -// @} - -/** - * \name initialization of endpoint - */ -//@{ -/** - * \brief Configures and enables an endpoint - * - * \param ep Endpoint number including direction (USB_EP_DIR_IN/USB_EP_DIR_OUT). - * \param bmAttributes Attribut of endpoint declared in descriptor. - * \param MaxEndpointSize Endpoint size maximum - */ -static void udd_ep_init(udd_ep_id_t ep, uint8_t bmAttributes, - uint16_t MaxEndpointSize); - -/** - * \brief Returns a pointer on endpoint control SRAM corresponding at endpoint number - * - * \param ep Endpoint number including direction (USB_EP_DIR_IN/USB_EP_DIR_OUT). - * - * \return endpoint descriptor index - */ -static UDD_EP_t *udd_ep_get_ctrl(udd_ep_id_t ep); -//@} - - -/** - * \name Control endpoint low level management routine. - * - * This function performs control endpoint mangement. - * It handle the SETUP/DATA/HANDSHAKE phases of a control transaction. - */ -//@{ - -//! Global variable to give and record information about setup request management -udd_ctrl_request_t udd_g_ctrlreq; - -//! Bit definitions about endpoint control state machine for udd_ep_control_state -typedef enum { - UDD_EPCTRL_SETUP = 0, //!< Wait a SETUP packet - UDD_EPCTRL_DATA_OUT = 1, //!< Wait a OUT data packet - UDD_EPCTRL_DATA_IN = 2, //!< Wait a IN data packet - UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP = 3, //!< Wait a IN ZLP packet - UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP = 4, //!< Wait a OUT ZLP packet - UDD_EPCTRL_STALL_REQ = 5, //!< STALL enabled on IN & OUT packet -} udd_ctrl_ep_state_t; - -//! State of the endpoint control management -static udd_ctrl_ep_state_t udd_ep_control_state; -//! Total number of data received/sent during data packet phase with previous payload buffers -static uint16_t udd_ctrl_prev_payload_nb_trans; -//! Number of data received/sent to/from udd_g_ctrlreq.payload buffer -static uint16_t udd_ctrl_payload_nb_trans; -//! Signal if the data sent during IN DATA need of IN ZLP -static bool udd_ctrl_payload_need_in_zlp; - -/** - * \brief Buffer to store the data received on control endpoint (SETUP/OUT endpoint 0) - * - * Used to avoid a RAM buffer overflow in case of the payload buffer - * is smaller than control endpoint size - */ -static uint8_t udd_ctrl_buffer[USB_DEVICE_EP_CTRL_SIZE]; - -/** - * \brief Reset control endpoint management - * - * Called after a USB line reset or at the end of SETUP request (after ZLP) - */ -static void udd_ctrl_init(void); - -//! \brief Managed reception of SETUP packet on control enpoint -static void udd_ctrl_setup_received(void); - -//! \brief Managed reception of IN packet on control enpoint -static void udd_ctrl_in_sent(void); - -//! \brief Managed reception of OUT packet on control enpoint -static void udd_ctrl_out_received(void); - -//! \brief Managed underflow event of IN packet on control enpoint -//! It is used to detect a DATA phase stopped by the host via a ZLP request. -//! This is mandatory for chapter 8 compliance -static void udd_ctrl_underflow(void); - -//! \brief Managed overflow event of OUT packet on control enpoint -//! It is used to detect a DATA phase stopped by the host via a ZLP request. -//! This is mandatory for chapter 8 compliance -static void udd_ctrl_overflow(void); - -//! \brief Managed stall event of IN/OUT packet on control enpoint -static void udd_ctrl_stall_data(void); - -//! \brief Send a ZLP IN on control endpoint -static void udd_ctrl_send_zlp_in(void); - -//! \brief Send a ZLP OUT on control endpoint -static void udd_ctrl_send_zlp_out(void); - -//! \brief Call callback associated to setup request -static void udd_ctrl_endofrequest(void); - -/** - * \brief Sub interrupt routine to manage error on control endpoint - * - * \return \c 1 if an error about control endpoint is occured, otherwise \c 0. - */ -static bool udd_ctrl_interrupt_error(void); - -/** - * \brief Sub interrupt routine to manage a SETUP transfer complet on control endpoint - * - * \return \c 1 if an SETUP transfer complet about control endpoint is occured, - * otherwise \c 0. - */ -static bool udd_ctrl_interrupt_tc_setup(void); - -//@} - - -/** - * \name Management of bulk/interrupt/isochronous endpoints - * - * The UDD manages the data transfer on endpoints: - * - Start data tranfer on endpoint with USB Device DMA - * - Send a ZLP packet if requested - * - Call callback registered to signal end of transfer - * The transfer abort and stall feature are supported. - */ -//@{ -#if (0!=USB_DEVICE_MAX_EP) - -//! Structure definition about job registered on an endpoint -typedef struct { - //! A job is registered on this endpoint - uint8_t busy:1; - //! A short packet is requested for this job on endpoint IN - uint8_t b_shortpacket:1; - //! The cache buffer is currently used on endpoint OUT - uint8_t b_use_out_cache_buffer:1; - //! Buffer located in internal RAM to send or fill during job - uint8_t *buf; - //! Size of buffer to send or fill - iram_size_t buf_size; - //! Total number of data transfered on enpoint - iram_size_t nb_trans; - union { - //! Callback to call at the end of transfer - udd_callback_trans_t call_trans; - //! Callback to call when the endpoint halt is cleared - udd_callback_halt_cleared_t call_nohalt; - }; -} udd_ep_job_t; - -//! Array to register a job on bulk/interrupt/isochronous endpoint -static udd_ep_job_t udd_ep_job[USB_DEVICE_MAX_EP * 2]; - -/** - * \brief Buffer to store the data received on bulk/interrupt endpoints - * - * Used to avoid a RAM buffer overflow in case of the user buffer - * is smaller than endpoint size - * - * \warning The isochronous endpoint is not protected by this system - * and the user must always use a buffer corresponding at endpoint size - */ -#ifdef USB_DEVICE_LOW_SPEED -static uint8_t udd_ep_out_cache_buffer[USB_DEVICE_MAX_EP][8]; -#else -static uint8_t udd_ep_out_cache_buffer[USB_DEVICE_MAX_EP][64]; -#endif - - -/** - * \brief Checks endpoint number - * - * \param ep endpoint number - */ -bool udd_ep_is_valid(udd_ep_id_t ep); - -/** - * \brief Manages transfer complet on bulk/interrupt/isochronous endpoints - * - * \param ep endpoint number to manage - */ -static void udd_ep_trans_complet(udd_ep_id_t ep); - -/** - * \brief Returns the size of endpoint - * - * \return the size of current selected endpoint - */ -static uint16_t udd_ep_get_size(UDD_EP_t * ep_ctrl); - -/** - * \brief Returns a pointer on endpoint job corresponding at endpoint number - * - * \param ep Endpoint number including direction (USB_EP_DIR_IN/USB_EP_DIR_OUT). - */ -static udd_ep_job_t *udd_ep_get_job(udd_ep_id_t ep); - -#endif // (0!=USB_DEVICE_MAX_EP) -//@} - - -void udd_enable(void) -{ - uint8_t i; - irqflags_t flags; - - // Sanity check Silicon revision -#if part_is_defined(ATxmega128A1U) - // The part ATxmega128A1U Rev. J is not supported, please use new silicon revision. - Assert(!(MCU_REVID < 0x0A)); -#endif - -#ifdef CONFIG_OSC_AUTOCAL -# if CONFIG_OSC_AUTOCAL_REF_OSC == OSC_ID_USBSOF - // RC oscillator calibration via USB Start Of Frame is not available - // in low speed mode. - // Thus, the calibration is disabled - // when USB interface start in low speed mode - DFLLRC32M.CTRL = 0; -# endif -#endif - -#ifdef USB_DEVICE_LOW_SPEED - // The USB hardware need of 6MHz in low speed mode - sysclk_enable_usb(6); - udd_set_low_speed(); -#else - // The USB hardware need of 48MHz in full speed mode - sysclk_enable_usb(48); - udd_set_full_speed(); -# ifdef CONFIG_OSC_AUTOCAL -# if CONFIG_OSC_AUTOCAL_REF_OSC == OSC_ID_USBSOF - // Now the full mode is enabled and the SOF calibration can be enabled - DFLLRC32M.CTRL = DFLL_ENABLE_bm; -# endif -# endif -#endif - - flags = cpu_irq_save(); - - // Reset endpoints table - for (i = 0; i < ((USB_DEVICE_MAX_EP_TEMP + 1) * 2); i++) { - udd_sram.ep_ctrl[i].CTRL = 0; - } -#if (0!=USB_DEVICE_MAX_EP) - // Reset internal variables - for (i = 0; i < (USB_DEVICE_MAX_EP * 2); i++) { - udd_ep_job[i].busy = false; - } -#endif - - //** Enable USB hardware - usb_pad_init(); - udd_set_nb_max_ep(USB_DEVICE_MAX_EP_TEMP); - udd_enable_interface(); - udd_enable_store_frame_number(); - udd_set_ep_table_addr(udd_sram.ep_ctrl); - // Enable TC fifo management - udd_enable_fifo(); - udd_reset_fifo(); - // Enable Interrupt USB Device - udd_enable_interrupt(UDD_USB_INT_LEVEL); - -#ifndef UDD_NO_SLEEP_MGR - // Initialize the sleep mode authorized for the USB suspend mode - udd_b_idle = false; - sleepmgr_lock_mode(USBC_SLEEP_MODE_USB_SUSPEND); -#endif - - cpu_irq_restore(flags); -} - - -void udd_disable(void) -{ - irqflags_t flags; - flags = cpu_irq_save(); - udd_detach_device(); - // Disable interface - USB_INTCTRLA = 0; - USB_INTCTRLB = 0; - sysclk_disable_usb(); - udd_sleep_mode(false); -#ifndef UDD_NO_SLEEP_MGR - sleepmgr_unlock_mode(USBC_SLEEP_MODE_USB_SUSPEND); -#endif - cpu_irq_restore(flags); -} - -bool udd_include_vbus_monitoring(void) -{ - return false; // No Vbus monitoring -} - -void udd_attach(void) -{ - irqflags_t flags; - flags = cpu_irq_save(); - - // At startup the USB bus state is unknown, - // therefore the state is considered IDLE to not miss any USB event - udd_sleep_mode(true); - - udd_ack_suspend_event(); - udd_ack_resume_event(); - udd_attach_device(); - // Enable main USB interrupts - udd_enable_tc_interrupt(); - udd_enable_busevt_interrupt(); - udd_enable_setup_interrupt(); - udd_enable_start_of_frame_interrupt(); - - cpu_irq_restore(flags); -} - -void udd_detach(void) -{ - // Detach device from the bus - udd_detach_device(); -} - -bool udd_is_high_speed(void) -{ - return false; -} - -void udd_set_address(uint8_t address) -{ - udd_set_device_address(address); -} - -uint8_t udd_getaddress(void) -{ - return udd_get_device_address(); -} - -uint16_t udd_get_frame_number(void) -{ - return udd_sram.frame_number; -} - -uint16_t udd_get_micro_frame_number(void) -{ - return 0; -} - -void udd_send_wake_up(void) -{ -#ifndef UDD_NO_SLEEP_MGR - if (!udd_b_idle) -#endif - { - udd_sleep_mode(true); // Enter in IDLE mode - udd_send_remote_wake_up(); - } -} - -void udd_set_setup_payload( uint8_t *payload, uint16_t payload_size ) -{ - udd_g_ctrlreq.payload = payload; - udd_g_ctrlreq.payload_size = payload_size; -} - -#if (0!=USB_DEVICE_MAX_EP) -bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes, - uint16_t MaxEndpointSize) -{ - UDD_EP_t *ep_ctrl; - Assert(udd_ep_is_valid(ep)); - - ep_ctrl = udd_ep_get_ctrl(ep); - if (udd_endpoint_is_enable(ep_ctrl)) { - return false; // Already allocated - } - udd_ep_init(ep, bmAttributes, MaxEndpointSize); - - // Do not use multipacket mode with isochronous 1023 bytes endpoint - if (udd_endpoint_get_type(ep_ctrl)==USB_EP_TYPE_ISOCHRONOUS_gc - && (udd_endpoint_get_size_field(ep_ctrl) - ==USB_EP_BUFSIZE_1023_gc)) { - return true; - } - - udd_endpoint_set_multipacket(ep_ctrl); - return true; -} - -void udd_ep_free(udd_ep_id_t ep) -{ - UDD_EP_t *ep_ctrl; - Assert(udd_ep_is_valid(ep)); - - udd_ep_abort(ep); - ep_ctrl = udd_ep_get_ctrl(ep); - udd_endpoint_disable(ep_ctrl); -} - -bool udd_ep_is_halted(udd_ep_id_t ep) -{ - UDD_EP_t *ep_ctrl; - Assert(udd_ep_is_valid(ep)); - - ep_ctrl = udd_ep_get_ctrl(ep); - return (udd_endpoint_is_stall(ep_ctrl)); -} - -bool udd_ep_set_halt(udd_ep_id_t ep) -{ - UDD_EP_t *ep_ctrl; - Assert(udd_ep_is_valid(ep)); - - ep_ctrl = udd_ep_get_ctrl(ep); - udd_endpoint_enable_stall(ep_ctrl); - udd_endpoint_clear_dtgl(ep_ctrl); - - udd_ep_abort(ep); - return true; -} - -bool udd_ep_clear_halt(udd_ep_id_t ep) -{ - udd_ep_job_t *ptr_job; - UDD_EP_t *ep_ctrl; - Assert(udd_ep_is_valid(ep)); - - ep_ctrl = udd_ep_get_ctrl(ep); - udd_endpoint_disable_stall(ep_ctrl); - - // If a job is register on clear halt action - // then execute callback - ptr_job = udd_ep_get_job(ep); - if (ptr_job->busy == true) { - ptr_job->busy = false; - ptr_job->call_nohalt(); - } - return true; -} - -bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, uint8_t * buf, - iram_size_t buf_size, udd_callback_trans_t callback) -{ - udd_ep_job_t *ptr_job; - irqflags_t flags; - UDD_EP_t *ep_ctrl; - - Assert(udd_ep_is_valid(ep)); - - // Get control & job about this endpoint - ptr_job = udd_ep_get_job(ep); - ep_ctrl = udd_ep_get_ctrl(ep); - - if (!udd_endpoint_is_enable(ep_ctrl)) { - return false; // Endpoint not allocated - } - if (udd_endpoint_get_type(ep_ctrl)!=USB_EP_TYPE_ISOCHRONOUS_gc - && udd_endpoint_is_stall(ep_ctrl)) { - return false; // Endpoint is halted - } - flags = cpu_irq_save(); - if (ptr_job->busy == true) { - cpu_irq_restore(flags); - return false; // Job already on going - } - ptr_job->busy = true; - cpu_irq_restore(flags); - - - // Update Job information - ptr_job->buf = buf; - ptr_job->buf_size = buf_size; - ptr_job->nb_trans = 0; - ptr_job->call_trans = callback; - // Need to enable shortpacket to send a ZLP (buf_size==0) - ptr_job->b_shortpacket = b_shortpacket || (buf_size==0); - ptr_job->b_use_out_cache_buffer = false; - - // Initialize value to simulate a empty transfer - if (USB_EP_DIR_IN == (ep & USB_EP_DIR_IN)) { - udd_endpoint_in_reset_nb_sent(ep_ctrl); - } - else - { - if ((USB_EP_TYPE_ISOCHRONOUS_gc == udd_endpoint_get_type(ep_ctrl)) - && (0 != (buf_size % udd_ep_get_size(ep_ctrl)))) { - // The user must use a buffer size modulo endpoint size - ptr_job->busy = false; - return false; - } - udd_endpoint_out_reset_nb_received(ep_ctrl); - udd_endpoint_out_set_nbbyte(ep_ctrl, 0); - } - // Request next transfer - udd_ep_trans_complet(ep); - return true; -} - -void udd_ep_abort(udd_ep_id_t ep) -{ - UDD_EP_t *ep_ctrl; - udd_ep_job_t *ptr_job; - Assert(udd_ep_is_valid(ep)); - - ep_ctrl = udd_ep_get_ctrl(ep); - ptr_job = udd_ep_get_job(ep); - - // Stop transfer - udd_endpoint_set_NACK0(ep_ctrl); - if (ptr_job->busy == false) { - return; // No job on going - } - ptr_job->busy = false; - if (NULL != ptr_job->call_trans) { - ptr_job->call_trans(UDD_EP_TRANSFER_ABORT, - (ep & USB_EP_DIR_IN) ? - udd_endpoint_in_nb_sent(ep_ctrl) - : udd_endpoint_out_nb_receiv(ep_ctrl)); - } -} - -bool udd_ep_wait_stall_clear(udd_ep_id_t ep, - udd_callback_halt_cleared_t callback) -{ - udd_ep_job_t *ptr_job; - UDD_EP_t *ep_ctrl; - Assert(udd_ep_is_valid(ep)); - - ep_ctrl = udd_ep_get_ctrl(ep); - ptr_job = udd_ep_get_job(ep); - - if (udd_endpoint_is_stall(ep_ctrl)) { - // Wait clear halt endpoint - if (ptr_job->busy == true) { - return false; // Job already on going - } - ptr_job->busy = true; - ptr_job->call_nohalt = callback; - } else { - // Enpoint not halted then call directly callback - callback(); - } - return true; -} -#endif // (0!=USB_DEVICE_MAX_EP) - -//-------------------------------------------------------- -//--- INTERNAL ROUTINES TO MANAGED GLOBAL EVENTS - -/** - * \internal - * \brief Function called by USB bus event interrupt - * - * USB bus event interrupt includes : - * - USB line events SOF, reset, suspend, resume, wakeup - * - endpoint control errors underflow, overflow, stall - */ -ISR(USB_BUSEVENT_vect) -{ - if (udd_is_start_of_frame_event()) { - udd_ack_start_of_frame_event(); - udc_sof_notify(); -#ifdef UDC_SOF_EVENT - UDC_SOF_EVENT(); -#endif - goto udd_interrupt_bus_event_end; - } - - if (udd_ctrl_interrupt_error()) { - goto udd_interrupt_bus_event_end; - } - if (udd_is_reset_event()) { - udd_ack_reset_event(); -#if (0!=USB_DEVICE_MAX_EP) - // Abort all endpoint jobs on going - uint8_t i; - for (i = 1; i < USB_DEVICE_MAX_EP; i++) { - udd_ep_abort(i); - udd_ep_abort(i | USB_EP_DIR_IN); - } -#endif - udc_reset(); - - // Reset USB address to 0 - udd_set_device_address(0); - // Alloc and configure control endpoint - udd_ep_init(0, USB_EP_TYPE_CONTROL, USB_DEVICE_EP_CTRL_SIZE); - udd_ep_init(0 | USB_EP_DIR_IN, USB_EP_TYPE_CONTROL, - USB_DEVICE_EP_CTRL_SIZE); - udd_control_out_set_buf(&udd_ctrl_buffer); - // Reset endpoint control management - udd_ctrl_init(); - goto udd_interrupt_bus_event_end; - } - - if (udd_is_suspend_event()) { - udd_ack_suspend_event(); - udd_sleep_mode(false); // Enter in SUSPEND mode -#ifdef UDC_SUSPEND_EVENT - UDC_SUSPEND_EVENT(); -#endif - goto udd_interrupt_bus_event_end; - } - - if (udd_is_resume_event()) { - udd_ack_resume_event(); - udd_sleep_mode(true); // Enter in power reduction mode -#ifdef UDC_RESUME_EVENT - UDC_RESUME_EVENT(); -#endif - goto udd_interrupt_bus_event_end; - } - -udd_interrupt_bus_event_end: - return; -} - -/** - * \internal - * \brief Function called by USB transfer complet interrupt - * - * USB transfer complet interrupt includes events about endpoint transfer on all endpoints. - */ -ISR(USB_TRNCOMPL_vect) -{ -#if (0!=USB_DEVICE_MAX_EP) - uint8_t ep_index; - uint8_t i_fifo; - uint16_t ad; - uint16_t *p_ad; - int8_t rp; - UDD_EP_t *ep_ctrl; - udd_ep_id_t ep; -#endif - - // Check reception of SETUP packet on control endpoint - if (udd_ctrl_interrupt_tc_setup()) { - goto udd_interrupt_tc_end; // Interrupt acked by control endpoint managed - } - // Check IN/OUT transfer complet on all endpoints - Assert(udd_is_tc_event()); - udd_ack_tc_event(); - -#if (0!=USB_DEVICE_MAX_EP) - //** Decode TC FIFO - // Compute ep addr - rp = udd_get_fifo_rp(); - i_fifo = 2 * (1 + ~rp); - ad = ((uint16_t) udd_sram.ep_ctrl) - i_fifo; - p_ad = (uint16_t *) ad; - // Compute ep - ep_index = (((uint16_t) * p_ad - ((uint16_t) udd_sram.ep_ctrl)) >> 3); - ep = (ep_index / 2) + ((ep_index & 1) ? USB_EP_DIR_IN : 0); - Assert(USB_DEVICE_MAX_EP >= (ep & USB_EP_ADDR_MASK)); - - // Ack IT TC of endpoint - ep_ctrl = udd_ep_get_ctrl(ep); - if (!udd_endpoint_transfer_complete(ep_ctrl)) { - return; // Error, TC is generated by Multipacket transfer - } - udd_endpoint_ack_transfer_complete(ep_ctrl); - - // Check status on control endpoint - if (ep == 0) { - udd_ctrl_out_received(); - goto udd_interrupt_tc_end; // Interrupt acked by control endpoint managed - } - if (ep == (0 | USB_EP_DIR_IN)) { - udd_ctrl_in_sent(); - goto udd_interrupt_tc_end; // Interrupt acked by control endpoint managed - } - Assert(udd_ep_is_valid(ep)); - // Manage end of transfert on endpoint bulk/interrupt/isochronous - udd_ep_trans_complet(ep); - -#else - - udd_get_fifo_rp(); - if (udd_endpoint_transfer_complete(udd_ep_get_ctrl(0))) { - udd_endpoint_ack_transfer_complete(udd_ep_get_ctrl(0)); - udd_ctrl_out_received(); - }else{ - udd_endpoint_ack_transfer_complete(udd_ep_get_ctrl(0 | USB_EP_DIR_IN)); - udd_ctrl_in_sent(); - } -#endif - -udd_interrupt_tc_end: - return; -} - -//-------------------------------------------------------- -//--- INTERNAL ROUTINES TO INITIALIZE ENDPOINT - -static void udd_ep_init(udd_ep_id_t ep, uint8_t bmAttributes, - uint16_t MaxEndpointSize) -{ - USB_EP_TYPE_t type; - USB_EP_BUFSIZE_t size; - UDD_EP_t *ep_ctrl; - -#if (0!=USB_DEVICE_MAX_EP) - // Translate USB attribut to hardware defines - switch (bmAttributes & USB_EP_TYPE_MASK) { - case USB_EP_TYPE_CONTROL: - type = USB_EP_TYPE_CONTROL_gc; - break; - case USB_EP_TYPE_ISOCHRONOUS: - type = USB_EP_TYPE_ISOCHRONOUS_gc; - break; - case USB_EP_TYPE_BULK: - case USB_EP_TYPE_INTERRUPT: //interrupt behaves as bulk - type = USB_EP_TYPE_BULK_gc; - break; - default: - Assert(false); // Wrong value - break; - } -#else - type = USB_EP_TYPE_CONTROL_gc; -#endif - - // Translate USB endpoint size to hardware defines - switch (MaxEndpointSize) { - default: - Assert(false); // Wrong value - case 8: - size = USB_EP_BUFSIZE_8_gc; - break; - case 16: - size = USB_EP_BUFSIZE_16_gc; - break; - case 32: - size = USB_EP_BUFSIZE_32_gc; - break; - case 64: - size = USB_EP_BUFSIZE_64_gc; - break; -#if (0!=USB_DEVICE_MAX_EP) - case 128: - size = USB_EP_BUFSIZE_128_gc; - break; - case 256: - size = USB_EP_BUFSIZE_256_gc; - break; - case 512: - size = USB_EP_BUFSIZE_512_gc; - break; - case 1023: - size =USB_EP_BUFSIZE_1023_gc; - break; -#endif - } - - // Enable endpoint - ep_ctrl = udd_ep_get_ctrl(ep); - udd_endpoint_disable(ep_ctrl); - udd_endpoint_clear_status(ep_ctrl); - udd_endpoint_set_control(ep_ctrl, (uint8_t) type | (uint8_t) size); -} - -static UDD_EP_t *udd_ep_get_ctrl(udd_ep_id_t ep) -{ - return &udd_sram.ep_ctrl[(2 * (ep & USB_EP_ADDR_MASK) + - ((ep & USB_EP_DIR_IN) ? 1 : 0))]; -} - - -//-------------------------------------------------------- -//--- INTERNAL ROUTINES TO MANAGED THE CONTROL ENDPOINT - -static void udd_ctrl_init(void) -{ - udd_disable_overflow_interrupt(); - udd_disable_underflow_interrupt(); - - // Clear status flag from control endpointS - // Mandatory for ATxmega128A1 Rev. K - udd_control_in_set_NACK0(); - udd_control_in_set_bytecnt(0); - udd_control_in_ack_tc(); - udd_control_ack_in_underflow(); - udd_control_out_ack_tc(); - udd_control_ack_out_overflow(); - - udd_g_ctrlreq.callback = NULL; - udd_g_ctrlreq.over_under_run = NULL; - udd_g_ctrlreq.payload_size = 0; - udd_ep_control_state = UDD_EPCTRL_SETUP; -} - -static void udd_ctrl_setup_received(void) -{ - if (UDD_EPCTRL_SETUP != udd_ep_control_state) { - if ((UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP == udd_ep_control_state) - || (UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP == udd_ep_control_state)) { - // Accept that ZLP event can be hidden by setup packet event - // in case of setup packet sending quiclky after a ZLP - udd_ctrl_endofrequest(); - } - // Reinitializes control endpoint management - udd_ctrl_init(); - } - // Fill setup request structure - if (8 != udd_control_out_get_bytecnt()) - return; // Error data number don't correspond to SETUP packet - memcpy((uint8_t *) & udd_g_ctrlreq.req, udd_ctrl_buffer, 8); - - // To detect a protocol error on setup, enable nak interrupt on IN/OUT of control endpoint - udd_enable_overflow_interrupt(); - udd_enable_underflow_interrupt(); - - // Decode setup request - if (udc_process_setup() == false) { - // Setup request unknow then stall it - udd_ctrl_stall_data(); - return; - } - - if (Udd_setup_is_in()) { - // Compute if an IN ZLP must be send after IN data - udd_ctrl_payload_need_in_zlp = - ((udd_g_ctrlreq.payload_size % USB_DEVICE_EP_CTRL_SIZE) == 0); - udd_ctrl_prev_payload_nb_trans = 0; - udd_ctrl_payload_nb_trans = 0; - udd_ep_control_state = UDD_EPCTRL_DATA_IN; - udd_ctrl_in_sent(); // Send first data transfer - } else { - if (0 == udd_g_ctrlreq.req.wLength) { - // No data phase requested - // Send IN ZLP to ACK setup request - udd_ctrl_send_zlp_in(); - return; - } - // OUT data phase requested - udd_ctrl_prev_payload_nb_trans = 0; - udd_ctrl_payload_nb_trans = 0; - udd_ep_control_state = UDD_EPCTRL_DATA_OUT; - // Clear packet to receive first packet - udd_control_out_clear_NACK0(); - } -} - -static void udd_ctrl_in_sent(void) -{ - uint16_t nb_remain; - - if (UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP == udd_ep_control_state) { - // ZLP on IN is sent, then valid end of setup request - udd_ctrl_endofrequest(); - // Reinitializes control endpoint management - udd_ctrl_init(); - return; - } - Assert(udd_ep_control_state == UDD_EPCTRL_DATA_IN); - - nb_remain = udd_g_ctrlreq.payload_size - udd_ctrl_payload_nb_trans; - if (0 == nb_remain) { - // All content of current buffer payload are sent - if (!udd_ctrl_payload_need_in_zlp) { - // It is the end of data phase, because the last data packet is a short packet - // then generate an OUT ZLP for handshake phase. - udd_ctrl_send_zlp_out(); - return; - } - if ((udd_g_ctrlreq.req.wLength > (udd_ctrl_prev_payload_nb_trans - + udd_g_ctrlreq.payload_size)) - || (!udd_g_ctrlreq.over_under_run) - || (!udd_g_ctrlreq.over_under_run())) { - // Underrun or data packet complete - // than send zlp on IN (note don't change DataToggle) - udd_ctrl_payload_need_in_zlp = false; - udd_control_in_set_bytecnt(0); - goto udd_ctrl_in_sent_continue; - } - // A new payload buffer is given - // Update number of total data sending by previous payload buffer - udd_ctrl_prev_payload_nb_trans += udd_ctrl_payload_nb_trans; - // Update maangement of current playoad transfer - udd_ctrl_payload_nb_trans = 0; - nb_remain = udd_g_ctrlreq.payload_size; - // Compute if an IN ZLP must be send after IN data - udd_ctrl_payload_need_in_zlp = - ((udd_g_ctrlreq.payload_size % USB_DEVICE_EP_CTRL_SIZE) == 0); - } - // Continue transfer an send next data - if (nb_remain > USB_DEVICE_EP_CTRL_SIZE) { - nb_remain = USB_DEVICE_EP_CTRL_SIZE; - } - udd_control_in_set_bytecnt(nb_remain); - - // Link payload buffer directly on USB hardware - udd_control_in_set_buf(udd_g_ctrlreq.payload + udd_ctrl_payload_nb_trans); - udd_ctrl_payload_nb_trans += nb_remain; - -udd_ctrl_in_sent_continue: - // Valid and sent the data available in control endpoint buffer - udd_control_in_clear_NACK0(); -} - -static void udd_ctrl_out_received(void) -{ - uint16_t nb_data; - - if (UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP == udd_ep_control_state) { - // Valids end of setup request - udd_ctrl_endofrequest(); - // Reinitializes control endpoint management - udd_ctrl_init(); - return; - } - Assert(udd_ep_control_state == UDD_EPCTRL_DATA_OUT); - - // Read data received during OUT phase - nb_data = udd_control_out_get_bytecnt(); - - if (udd_g_ctrlreq.payload_size < (udd_ctrl_payload_nb_trans + nb_data)) { - // Payload buffer too small, ignore data remaining - nb_data = udd_g_ctrlreq.payload_size - udd_ctrl_payload_nb_trans; - } - - memcpy((uint8_t *) (udd_g_ctrlreq.payload + udd_ctrl_payload_nb_trans), - udd_ctrl_buffer, nb_data); - udd_ctrl_payload_nb_trans += nb_data; - - if ((USB_DEVICE_EP_CTRL_SIZE != nb_data) || (udd_g_ctrlreq.req.wLength - <= (udd_ctrl_prev_payload_nb_trans - + udd_ctrl_payload_nb_trans))) { - // End of reception because it is a short packet - // or all data are transfered - - // Before send ZLP, call intermediat calback - // in case of data receiv generate a stall - udd_g_ctrlreq.payload_size = udd_ctrl_payload_nb_trans; - if (NULL != udd_g_ctrlreq.over_under_run) { - if (!udd_g_ctrlreq.over_under_run()) { - // Stall ZLP - udd_ctrl_stall_data(); - return; - } - } - // Send IN ZLP to ACK setup request - udd_ctrl_send_zlp_in(); - return; - } - - if (udd_g_ctrlreq.payload_size == udd_ctrl_payload_nb_trans) { - // Overrun then request a new payload buffer - if (!udd_g_ctrlreq.over_under_run) { - // No callback availabled to request a new payload buffer - udd_ctrl_stall_data(); - return; - } - if (!udd_g_ctrlreq.over_under_run()) { - // No new payload buffer delivered - udd_ctrl_stall_data(); - return; - } - // New payload buffer available - // Update number of total data received - udd_ctrl_prev_payload_nb_trans += udd_ctrl_payload_nb_trans; - // Reinit reception on payload buffer - udd_ctrl_payload_nb_trans = 0; - } - // Free buffer of OUT control endpoint to authorize next reception - udd_control_out_clear_NACK0(); -} - -static void udd_ctrl_underflow(void) -{ - if (udd_control_out_tc()) { - return; // underflow ignored if OUT data is received - } - if (UDD_EPCTRL_DATA_OUT == udd_ep_control_state) { - // Host want to stop OUT transaction - // then stop to wait OUT data phase and wait IN ZLP handshake - udd_ctrl_send_zlp_in(); - } else if (UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP == udd_ep_control_state) { - // A OUT handshake is waiting by device, - // but host want extra IN data then stall extra IN data and following status stage - udd_control_in_enable_stall(); - udd_control_out_enable_stall(); - } -} - -static void udd_ctrl_overflow(void) -{ - if (udd_control_in_tc()) { - return; // overflow ignored if IN data is received - } - if (UDD_EPCTRL_DATA_IN == udd_ep_control_state) { - // Host want to stop IN transaction - // then stop to wait IN data phase and wait OUT ZLP handshake - udd_ctrl_send_zlp_out(); - } else if (UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP == udd_ep_control_state) { - // A IN handshake is waiting by device, - // but host want extra OUT data then stall extra OUT data and following status stage - udd_control_in_enable_stall(); - udd_control_out_enable_stall(); - } -} - -static void udd_ctrl_stall_data(void) -{ - // Stall all packets on IN & OUT control endpoint - udd_ep_control_state = UDD_EPCTRL_STALL_REQ; - udd_control_in_enable_stall(); - udd_control_out_enable_stall(); -} - -static void udd_ctrl_send_zlp_in(void) -{ - udd_ep_control_state = UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP; - // Valid and sent empty IN packet on control endpoint - udd_control_in_set_bytecnt(0); - udd_control_in_clear_NACK0(); -} - -static void udd_ctrl_send_zlp_out(void) -{ - udd_ep_control_state = UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP; - // Valid reception of OUT packet on control endpoint - udd_control_out_clear_NACK0(); -} - -static void udd_ctrl_endofrequest(void) -{ - // If a callback is registered then call it - if (udd_g_ctrlreq.callback) { - udd_g_ctrlreq.callback(); - } -} - -static bool udd_ctrl_interrupt_error(void) -{ - // Underflow only managed for control endpoint - if (udd_is_underflow_event()) { - udd_ack_underflow_event(); - if (udd_control_in_underflow()) { - udd_ctrl_underflow(); - } - return true; - } - // Overflow only managed for control endpoint - if (udd_is_overflow_event()) { - udd_ack_overflow_event(); - if (udd_control_out_overflow()) { - udd_ctrl_overflow(); - } - return true; - } - return false; -} - -static bool udd_ctrl_interrupt_tc_setup(void) -{ - if (!udd_is_setup_event()) { - return false; - } - udd_ack_setup_event(); - - // Clear eventually previous stall events - udd_control_out_ack_stall(); - udd_control_in_ack_stall(); - udd_ack_stall_event(); - - Assert(udd_control_setup()); // A setup must be received on control endpoint - - // Ack SETUP packet and decode request - udd_control_ack_setup(); - udd_ctrl_setup_received(); - return true; -} - - -//-------------------------------------------------------- -//--- INTERNAL ROUTINES TO MANAGED THE BULK/INTERRUPT/ISOCHRONOUS ENDPOINTS - -#if (0!=USB_DEVICE_MAX_EP) - -static uint16_t udd_ep_get_size(UDD_EP_t * ep_ctrl) -{ - // Translate hardware defines to USB endpoint size - switch (udd_endpoint_get_size_field(ep_ctrl)) { - default: - case USB_EP_BUFSIZE_8_gc: - return 8; - case USB_EP_BUFSIZE_16_gc: - return 16; - case USB_EP_BUFSIZE_32_gc: - return 32; - case USB_EP_BUFSIZE_64_gc: - return 64; - case USB_EP_BUFSIZE_128_gc: - return 128; - case USB_EP_BUFSIZE_256_gc: - return 256; - case USB_EP_BUFSIZE_512_gc: - return 512; - case USB_EP_BUFSIZE_1023_gc: - return 1023; - } -} - -static udd_ep_job_t *udd_ep_get_job(udd_ep_id_t ep) -{ - return &udd_ep_job[(2 * (ep & USB_EP_ADDR_MASK) + - ((ep & USB_EP_DIR_IN) ? 1 : 0)) - 2]; -} - -bool udd_ep_is_valid(udd_ep_id_t ep) -{ - ep &= USB_EP_ADDR_MASK; - if (ep == 0) { - return false; - } - return (USB_DEVICE_MAX_EP >= ep); -} - -static void udd_ep_trans_complet(udd_ep_id_t ep) -{ - UDD_EP_t *ep_ctrl; - udd_ep_job_t *ptr_job; - uint16_t ep_size, nb_trans; - iram_size_t next_trans; - - ptr_job = udd_ep_get_job(ep); - ep_ctrl = udd_ep_get_ctrl(ep); - ep_size = udd_ep_get_size(ep_ctrl); - - if (USB_EP_DIR_IN == (ep & USB_EP_DIR_IN)) { - // Transfer complet on IN - nb_trans = udd_endpoint_in_nb_sent(ep_ctrl); - - // Update number of data transfered - ptr_job->nb_trans += nb_trans; - - // Need to send other data - if (ptr_job->nb_trans != ptr_job->buf_size) { - next_trans = ptr_job->buf_size - ptr_job->nb_trans; - if (UDD_ENDPOINT_MAX_TRANS < next_trans) { - // The USB hardware support a maximum - // transfer size of UDD_ENDPOINT_MAX_TRANS Bytes - next_trans = UDD_ENDPOINT_MAX_TRANS - - (UDD_ENDPOINT_MAX_TRANS % ep_size); - } - // Need ZLP, if requested and last packet is not a short packet - ptr_job->b_shortpacket = ptr_job->b_shortpacket - && (0==(next_trans % ep_size)); - udd_endpoint_in_reset_nb_sent(ep_ctrl); - udd_endpoint_in_set_bytecnt(ep_ctrl, next_trans); - // Link the user buffer directly on USB hardware DMA - udd_endpoint_set_buf(ep_ctrl, &ptr_job->buf[ptr_job->nb_trans]); - udd_endpoint_clear_NACK0(ep_ctrl); - return; - } - - // Need to send a ZLP after all data transfer - if (ptr_job->b_shortpacket) { - ptr_job->b_shortpacket = false; - udd_endpoint_in_reset_nb_sent(ep_ctrl); - udd_endpoint_in_set_bytecnt(ep_ctrl, 0); - udd_endpoint_clear_NACK0(ep_ctrl); - return; - } - } - else - { - // Transfer complet on OUT - nb_trans = udd_endpoint_out_nb_receiv(ep_ctrl); - - // Can be necessary to copy data receiv from cache buffer to user buffer - if (ptr_job->b_use_out_cache_buffer) { - memcpy(&ptr_job->buf[ptr_job->nb_trans] - , udd_ep_out_cache_buffer[ep - 1] - , ptr_job->buf_size % ep_size); - } - - // Update number of data transfered - ptr_job->nb_trans += nb_trans; - if (ptr_job->nb_trans > ptr_job->buf_size) { - ptr_job->nb_trans = ptr_job->buf_size; - } - - // If all previous data requested are received and user buffer not full - // then need to receiv other data - if ((nb_trans == udd_endpoint_out_get_nbbyte_requested(ep_ctrl)) - && (ptr_job->nb_trans != ptr_job->buf_size)) { - next_trans = ptr_job->buf_size - ptr_job->nb_trans; - if (UDD_ENDPOINT_MAX_TRANS < next_trans) { - // The USB hardware support a maximum transfer size - // of UDD_ENDPOINT_MAX_TRANS Bytes - next_trans = UDD_ENDPOINT_MAX_TRANS - - (UDD_ENDPOINT_MAX_TRANS % ep_size); - } else { - next_trans -= next_trans % ep_size; - } - - udd_endpoint_out_reset_nb_received(ep_ctrl); - if (next_trans < ep_size) { - // Use the cache buffer for Bulk or Interrupt size endpoint - ptr_job->b_use_out_cache_buffer = true; - udd_endpoint_set_buf( ep_ctrl, - udd_ep_out_cache_buffer[((ep & USB_EP_ADDR_MASK) - 1)]); - udd_endpoint_out_set_nbbyte(ep_ctrl, ep_size); - } else { - // Link the user buffer directly on USB hardware DMA - udd_endpoint_set_buf(ep_ctrl, &ptr_job->buf[ptr_job->nb_trans]); - udd_endpoint_out_set_nbbyte(ep_ctrl, next_trans); - } - // Start transfer - udd_endpoint_clear_NACK0(ep_ctrl); - return; - } - } - - // Job complet then call callback - if (ptr_job->busy) { - ptr_job->busy = false; - if (NULL != ptr_job->call_trans) { - ptr_job->call_trans(UDD_EP_TRANSFER_OK, - ptr_job->nb_trans); - } - } - return; -} -#endif // (0!=USB_DEVICE_MAX_EP) -//@} diff --git a/DSTAT1/src/asf/xmega/drivers/usb/usb_device.h b/DSTAT1/src/asf/xmega/drivers/usb/usb_device.h deleted file mode 100644 index c15241c..0000000 --- a/DSTAT1/src/asf/xmega/drivers/usb/usb_device.h +++ /dev/null @@ -1,385 +0,0 @@ -/** - * \file - * - * \brief USB Driver header file for XMEGA products including USB interface. - * - * Copyright (c) 2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _USB_DEVICE_H_ -#define _USB_DEVICE_H_ - -#include - -/** - * \ingroup usb_device_group - * \defgroup udd_group USB Device Driver (UDD) - * USBC low-level driver for USB Device mode - * - * - * @{ - */ - -//! @name USB Device main management -//! @{ - -/** - * \brief Initializes the USB DP/DM buffers - * - * This functions initializes the USB buffer using the calibration value - * stored in production raw. - * If the calibration value is not found (0xFF) value, a default typical - * value is applied. - * Alternatively user can force calibration values using USB_PAD_USER_CAL0 - * and USB_PAD_USER_CAL1 - * - */ -static inline void usb_pad_init(void) -{ - uint8_t cal; - -#ifdef USB_PAD_USER_CAL0 - USB_CAL0 = USB_PAD_USER_CAL0; -#else - cal = nvm_read_production_signature_row - (nvm_get_production_signature_row_offset(USBCAL0)); - if (cal != 0xFF) { - USB_CAL0 = cal; - } else { - USB_CAL0 = 0x1F; - } -#endif - -#ifdef USB_PAD_USER_CAL1 - USB_CAL1 = USB_PAD_USER_CAL1; -#else - cal = nvm_read_production_signature_row - (nvm_get_production_signature_row_offset(USBCAL1)); - if (cal != 0xFF) { - USB_CAL1 = cal; - } else { - USB_CAL1 = 0x1F; - } -#endif -} - -#define udd_enable_interface() (USB_CTRLA |= USB_ENABLE_bm) -#define udd_disable_interface() (USB_CTRLA &= ~USB_ENABLE_bm) -#define udd_attach_device() (USB_CTRLB |= USB_ATTACH_bm) -#define udd_detach_device() (USB_CTRLB &= ~USB_ATTACH_bm) -#define udd_gnak_disable() (USB_CTRLB &= ~USB_GNACK_bm) -#define udd_gnak_enable() (USB_CTRLB |= USB_GNACK_bm) -#define udd_gnak_is_enable() (USB_CTRLB & USB_GNACK_bm) -#define udd_set_nb_max_ep(n) (USB_CTRLA |= n) -#define udd_enable_store_frame_number() (USB_CTRLA |= USB_STFRNUM_bm) -#define udd_disable_store_frame_number() (USB_CTRLA &= ~USB_STFRNUM_bm) -#define udd_set_full_speed() (USB_CTRLA |= USB_SPEED_bm) -#define udd_set_low_speed() (USB_CTRLA &= ~USB_SPEED_bm) -#define udd_set_ep_table_addr(n) (USB.EPPTR = (uint16_t)n) -#define udd_get_ep_table_addr() (USB.EPPTR) -#define udd_get_fifo_rp() (USB_FIFORP) -#define udd_reset_fifo() (USB_FIFORP=0xFF) -#define udd_enable_interrupt(level) (USB_INTCTRLA |= level&(USB_INTLVL1_bm|USB_INTLVL0_bm)) - -#define udd_set_device_address(n) (USB_ADDR=n) -#define udd_get_device_address() (USB_ADDR) -#define udd_enable_fifo() (USB_CTRLA |= USB_FIFOEN_bm) -#define udd_disable_fifo() (USB_CTRLA &= ~USB_FIFOEN_bm) - -#define udd_send_remote_wake_up() (USB_CTRLB &= ~USB_RWAKEUP_bm, USB_CTRLB |= USB_RWAKEUP_bm) -#define udd_set_global_nack() (USB_CTRLB |= USB_GNACK_bm) -#define udd_is_crc_event() (USB_INTFLAGSASET & USB_CRCIF_bm ? true : false) -#define udd_ack_crc_event() (USB_INTFLAGSACLR = USB_CRCIF_bm) -#define udd_set_crc_event() (USB_INTFLAGSASET = USB_CRCIF_bm) -#define udd_enable_crc_interrupt() (USB_INTCTRLA |= USB_CRCIE_bm) -#define udd_disable_crc_interrupt() (USB_INTCTRLA &= ~USB_CRCIE_bm) - -#define udd_is_start_of_frame_event() (USB_INTFLAGSASET & USB_SOFIF_bm ? true : false) -#define udd_ack_start_of_frame_event() (USB_INTFLAGSACLR = USB_SOFIF_bm) -#define udd_set_start_of_frame_event() (USB_INTFLAGSASET = USB_SOFIF_bm) -#define udd_enable_start_of_frame_interrupt() (USB_INTCTRLA |= USB_SOFIE_bm) -#define udd_disable_start_of_frame_interrupt() (USB_INTCTRLA &= ~USB_SOFIE_bm) -#define udd_is_enable_start_of_frame_interrupt() (0!=(USB_INTCTRLA|USB_SOFIE_bm)) - -#define udd_is_reset_event() (USB_INTFLAGSASET & USB_RSTIF_bm ? true : false) -#define udd_ack_reset_event() (USB_INTFLAGSACLR = USB_RSTIF_bm) -#define udd_set_reset_event() (USB_INTFLAGSASET = USB_RSTIF_bm) - -#define udd_is_suspend_event() (USB_INTFLAGSASET & USB_SUSPENDIF_bm ? true : false) -#define udd_ack_suspend_event() (USB_INTFLAGSACLR = USB_SUSPENDIF_bm) -#define udd_set_suspend_event() (USB_INTFLAGSASET = USB_SUSPENDIF_bm) - -#define udd_is_resume_event() (USB_INTFLAGSASET & USB_RESUMEIF_bm ? true : false) -#define udd_ack_resume_event() (USB_INTFLAGSACLR = USB_RESUMEIF_bm) -#define udd_set_resume_event() (USB_INTFLAGSASET = USB_RESUMEIF_bm) - -#define udd_enable_busevt_interrupt() (USB_INTCTRLA |= USB_BUSEVIE_bm) -#define udd_disable_busevt_interrupt() (USB_INTCTRLA &= ~USB_BUSEVIE_bm) - -#define udd_is_setup_event() (USB_INTFLAGSBCLR & USB_SETUPIF_bm ? true : false) -#define udd_ack_setup_event() (USB_INTFLAGSBCLR = USB_SETUPIF_bm) -#define udd_set_setup_event() (USB_INTFLAGSBSET = USB_SETUPIF_bm) -#define udd_enable_setup_interrupt() (USB_INTCTRLB |= USB_SETUPIE_bm) -#define udd_disable_setup_interrupt() (USB_INTCTRLB &= ~USB_SETUPIE_bm) - -#define udd_is_tc_event() (USB_INTFLAGSBCLR & USB_TRNIF_bm ? true : false) -#define udd_ack_tc_event() (USB_INTFLAGSBCLR = USB_TRNIF_bm) -#define udd_set_tc_event() (USB_INTFLAGSBSET = USB_TRNIF_bm) -#define udd_enable_tc_interrupt() (USB_INTCTRLB |= USB_TRNIE_bm) -#define udd_disable_tc_interrupt() (USB_INTCTRLB &= ~USB_TRNIE_bm) - -#define udd_is_overflow_event() (USB_INTFLAGSASET & USB_OVFIF_bm ? true : false) -#define udd_ack_overflow_event() (USB_INTFLAGSACLR = USB_OVFIF_bm) -#define udd_set_overflow_event() (USB_INTFLAGSASET = USB_OVFIF_bm) -#define udd_enable_overflow_interrupt() (USB_INTCTRLA |= USB_BUSERRIE_bm) -#define udd_disable_overflow_interrupt() (USB_INTCTRLA &= ~USB_BUSERRIE_bm) -#define udd_is_enable_overflow_interrupt() (USB_INTCTRLA&USB_BUSERRIE_bm ? true : false) - -#define udd_is_underflow_event() (USB_INTFLAGSASET & USB_UNFIF_bm ? true : false) -#define udd_ack_underflow_event() (USB_INTFLAGSACLR = USB_UNFIF_bm) -#define udd_set_underflow_event() (USB_INTFLAGSASET = USB_UNFIF_bm) -#define udd_enable_underflow_interrupt() (USB_INTCTRLA |= USB_BUSERRIE_bm) -#define udd_disable_underflow_interrupt() (USB_INTCTRLA &= ~USB_BUSERRIE_bm) -#define udd_is_enable_underflow_interrupt() (USB_INTCTRLA&USB_BUSERRIE_bm ? true : false) - -#define udd_is_stall_event() (USB_INTFLAGSASET & USB_STALLIF_bm ? true : false) -#define udd_ack_stall_event() (USB_INTFLAGSACLR = USB_STALLIF_bm) -#define udd_set_stall_event() (USB_INTFLAGSASET = USB_STALLIF_bm) -#define udd_enable_stall_interrupt() (USB_INTCTRLA |= USB_STALLIE_bm) -#define udd_disable_stall_interrupt() (USB_INTCTRLA &= ~USB_STALLIE_bm) -#define udd_is_enable_stall_interrupt() (USB_INTCTRLA&USB_STALLIE_bm ? true : false) -//! @} - -//! @name USB Device read/modify/write management -//! @{ -#ifndef USB_WORKAROUND_DO_NOT_USE_RMW -/* - * Read modify write new instructions for Xmega - * inline asm implementation with R16 register. - * This should be removed later on when the new instructions - * will be available whithin the compiler. - * - */ -// Load and Clear -#ifdef __GNUC__ -#define LACR16(addr,msk) \ - __asm__ __volatile__ ( \ - "ldi r16, %1" "\n\t" \ - ".dc.w 0x9306" "\n\t"\ - ::"z" (addr), "M" (msk):"r16") -#else -#define LACR16(addr,msk) __lac((unsigned char)msk,(unsigned char*)addr) -#endif - -// Load and Set -#ifdef __GNUC__ -#define LASR16(addr,msk) \ - __asm__ __volatile__ ( \ - "ldi r16, %1" "\n\t" \ - ".dc.w 0x9305" "\n\t"\ - ::"z" (addr), "M" (msk):"r16") -#else -#define LASR16(addr,msk) __las((unsigned char)msk,(unsigned char*)addr) -#endif - -// Exchange -#ifdef __GNUC__ -#define XCHR16(addr,msk) \ - __asm__ __volatile__ ( \ - "ldi r16, %1" "\n\t" \ - ".dc.w 0x9304" "\n\t"\ - ::"z" (addr), "M" (msk):"r16") -#else -#define XCHR16(addr,msk) __xch(msk,addr) -#endif - -// Load and toggle -#ifdef __GNUC__ -#define LATR16(addr,msk) \ - __asm__ __volatile__ ( \ - "ldi r16, %1" "\n\t" \ - ".dc.w 0x9307" "\n\t"\ - ::"z" (addr), "M" (msk):"r16") -#else -#define LATR16(addr,msk) __lat(msk,addr) -#endif - -#else - -// Load and Clear -#define LACR16(addr,msk) (*addr &= ~msk) -// Load and Set -#define LASR16(addr,msk)(*addr |= msk) - -#endif -//! @} - - -//! @name USB Device endpoints table management -//! @{ - -#define udd_endpoint_set_control(ep_ctrl,val) (ep_ctrl->CTRL=val) -#define udd_endpoint_get_control(ep_ctrl) (ep_ctrl->CTRL) - -#define udd_endpoint_disable(ep_ctrl) udd_endpoint_set_control(ep_ctrl,0) -#define udd_endpoint_is_enable(ep_ctrl) (USB_EP_TYPE_DISABLE_gc!=udd_endpoint_get_type(ep_ctrl)) - - -#define udd_endpoint_enable_stall(ep_ctrl) (ep_ctrl->CTRL |= USB_EP_STALL_bm) -#define udd_endpoint_disable_stall(ep_ctrl) (ep_ctrl->CTRL &= ~USB_EP_STALL_bm) -#define udd_endpoint_is_stall(ep_ctrl) (ep_ctrl->CTRL &USB_EP_STALL_bm ? true : false) -#define udd_endpoint_set_multipacket(ep_ctrl) (ep_ctrl->CTRL |= USB_EP_MULTIPKT_bm) -#define udd_endpoint_TC_int_disable(ep_ctrl) (ep_ctrl->CTRL |= USB_EP_INTDSBL_bm) -#define udd_endpoint_set_pingpong(ep_ctrl) (ep_ctrl->CTRL |= USB_EP_PINGPONG_bm) -#define udd_endpoint_get_size_field(ep_ctrl) (ep_ctrl->CTRL & USB_EP_BUFSIZE_gm) -#define udd_endpoint_get_type(ep_ctrl) (ep_ctrl->CTRL & USB_EP_TYPE_gm) - -#define udd_endpoint_get_status(ep_ctrl) (ep_ctrl->STATUS) -#define udd_endpoint_clear_status(ep_ctrl) (ep_ctrl->STATUS=USB_EP_BUSNACK0_bm|USB_EP_BUSNACK1_bm) - -#define udd_endpoint_setup_received(ep_ctrl) (ep_ctrl->STATUS&USB_EP_SETUP_bm ? true : false) -#define udd_endpoint_ack_setup_received(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_SETUP_bm) - -#define udd_endpoint_transfer_complete(ep_ctrl) (ep_ctrl->STATUS&USB_EP_TRNCOMPL0_bm ? true : false) -#define udd_endpoint_ack_transfer_complete(ep_ctrl) LACR16(&(ep_ctrl->STATUS), USB_EP_TRNCOMPL0_bm) -#define udd_endpoint_transfer_complete_bank0(ep_ctrl) (ep_ctrl->STATUS&USB_EP_TRNCOMPL0_bm ? true : false) -#define udd_endpoint_ack_transfer_complete_bankO(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_TRNCOMPL0_bm) -#define udd_endpoint_transfer_complete_bank1(ep_ctrl) (ep_ctrl->STATUS&USB_EP_SETUP_bm ? true : false) -#define udd_endpoint_ack_transfer_complete_bank1(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_SETUP_bm) - -#define udd_endpoint_get_bank(ep_ctrl) (ep_ctrl->STATUS & USB_EP_BANK_bm ? true : false) -#define udd_endpoint_set_bank(ep_ctrl) LASR16(&ep_ctrl->STATUS, USB_EP_BANK_bm) -#define udd_endpoint_clear_bank(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_BANK_bm) - -#define udd_endpoint_set_dtgl(ep_ctrl) LASR16(&ep_ctrl->STATUS,USB_EP_TOGGLE_bm) -#define udd_endpoint_clear_dtgl(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_TOGGLE_bm ) -#define udd_endpoint_get_dtgl(ep_ctrl) ((ep_ctrl->STATUS)&USB_EP_TOGGLE_bm ? true : false) -#define udd_endpoint_toggle_dtgl(ep_ctrl) LATR16(&ep_ctrl->STATUS, USB_EP_TOGGLE_bm) - -#define udd_endpoint_set_NACK0(ep_ctrl) LASR16(&ep_ctrl->STATUS,USB_EP_BUSNACK0_bm) -#define udd_endpoint_set_NACK1(ep_ctrl) LASR16(&ep_ctrl->STATUS,USB_EP_BUSNACK1_bm) -#define udd_endpoint_clear_NACK0(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_BUSNACK0_bm) -#define udd_endpoint_clear_NACK1(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_BUSNACK1_bm) -#define udd_endpoint_get_NACK1(ep_ctrl) ((ep_ctrl->STATUS&USB_EP_BUSNACK1_bm) ? true : false) -#define udd_endpoint_get_NACK0(ep_ctrl) ((ep_ctrl->STATUS&USB_EP_BUSNACK0_bm) ? true : false) -#define udd_endpoint_overflow(ep_ctrl) (ep_ctrl->STATUS&USB_EP_OVF_bm ? true : false) -#define udd_endpoint_underflow(ep_ctrl) (ep_ctrl->STATUS&USB_EP_UNF_bm ? true : false) - -#define UDD_ENDPOINT_MAX_TRANS (0x3FF) - -#define udd_endpoint_out_nb_receiv(ep_ctrl) (ep_ctrl->CNT) -#define udd_endpoint_out_reset_nb_received(ep_ctrl) (ep_ctrl->CNT = 0) -#define udd_endpoint_in_set_bytecnt(ep_ctrl,n) (ep_ctrl->CNT = n) -#define udd_endpoint_set_azlp(ep_ctrl) (ep_ctrl->CNT |= 0x8000) -#define udd_endpoint_clear_azlp(ep_ctrl) (ep_ctrl->CNT &= ~0x8000) - -#define udd_endpoint_set_buf(ep_ctrl,buf) (ep_ctrl->DATAPTR = (uint16_t) buf) - -#define udd_endpoint_in_nb_sent(ep_ctrl) (ep_ctrl->AUXDATA) -#define udd_endpoint_in_reset_nb_sent(ep_ctrl) (ep_ctrl->AUXDATA = 0) -#define udd_endpoint_out_set_nbbyte(ep_ctrl,nb) (ep_ctrl->AUXDATA = nb) -#define udd_endpoint_out_get_nbbyte_requested(ep_ctrl) (ep_ctrl->AUXDATA) -#define udd_endpoint_set_aux(ep_ctrl,buf) (ep_ctrl->AUXDATA = (uint16_t) buf) -//! @} - - -//! @name USB Device endpoint control field management -//! @{ - -//! @name USB Device endpoint control setup field management -//! @{ -#define udd_control_setup() (udd_sram.ep_ctrl[0].STATUS&USB_EP_SETUP_bm ? true : false) -#define udd_control_ack_setup() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_SETUP_bm) -//! @} - -//! @name USB Device endpoint control OUT field management -//! @{ -#define udd_control_out_is_enable_stall() (udd_sram.ep_ctrl[0].CTRL&USB_EP_STALL_bm ? true : false) -#define udd_control_out_enable_stall() LASR16(&udd_sram.ep_ctrl[0].CTRL,USB_EP_STALL_bm) -#define udd_control_out_disable_stall() LACR16(&udd_sram.ep_ctrl[0].CTRL,USB_EP_STALL_bm) -#define udd_control_out_is_stalled() (udd_sram.ep_ctrl[0].STATUS&USB_EP_STALLF_bm ? true : false) -#define udd_control_out_ack_stall() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_STALLF_bm) -#define udd_control_out_set_NACK0() LASR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_BUSNACK0_bm) -#define udd_control_out_clear_NACK0() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_BUSNACK0_bm) - -#define udd_control_out_overflow() (udd_sram.ep_ctrl[0].STATUS&USB_EP_OVF_bm ? true : false) -#define udd_control_ack_out_overflow() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_OVF_bm) - -#define udd_control_out_tc() (udd_sram.ep_ctrl[0].STATUS&USB_EP_TRNCOMPL0_bm ? true : false) -#define udd_control_out_ack_tc() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_TRNCOMPL0_bm) -#define udd_control_out_set_tc() LASR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_TRNCOMPL0_bm) - -#define udd_control_out_dt_get() (udd_sram.ep_ctrl[0].STATUS&USB_EP_TOGGLE_bm ? true : false) -#define udd_control_out_dt_set() LASR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_TOGGLE_bm ) -#define udd_control_out_dt_clear() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_TOGGLE_bm ) -#define udd_control_out_dt_toggle() LATR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_TOGGLE_bm) - -#define udd_control_out_set_buf(buf) (udd_sram.ep_ctrl[0].DATAPTR = (uint16_t) buf) - -#define udd_control_out_get_bytecnt() (udd_sram.ep_ctrl[0].CNT) -//! @} - -//! @name USB Device endpoint control IN field management -//! @{ -#define udd_control_in_is_enable_stall() (udd_sram.ep_ctrl[1].CTRL&USB_EP_STALL_bm ? true : false) -#define udd_control_in_enable_stall() LASR16(&udd_sram.ep_ctrl[1].CTRL,USB_EP_STALL_bm) -#define udd_control_in_disable_stall() LACR16(&udd_sram.ep_ctrl[1].CTRL,USB_EP_STALL_bm) -#define udd_control_in_is_stalled() (udd_sram.ep_ctrl[1].STATUS&USB_EP_STALLF_bm ? true : false) -#define udd_control_in_ack_stall() LACR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_STALLF_bm) -#define udd_control_in_set_NACK0() LASR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_BUSNACK0_bm) -#define udd_control_in_clear_NACK0() LACR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_BUSNACK0_bm) - -#define udd_control_in_underflow() (udd_sram.ep_ctrl[1].STATUS&USB_EP_UNF_bm ? true : false) -#define udd_control_ack_in_underflow() LACR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_UNF_bm) - -#define udd_control_in_tc() (udd_sram.ep_ctrl[1].STATUS&USB_EP_TRNCOMPL0_bm ? true : false) -#define udd_control_in_ack_tc() LACR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_TRNCOMPL0_bm) -#define udd_control_in_set_tc() LASR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_TRNCOMPL0_bm) - -#define udd_control_in_dt_get() (udd_sram.ep_ctrl[1].STATUS&USB_EP_TOGGLE_bm ? true : false) -#define udd_control_in_dt_set() LASR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_TOGGLE_bm ) -#define udd_control_in_dt_clear() LACR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_TOGGLE_bm ) -#define udd_control_in_dt_toggle() LATR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_TOGGLE_bm) - -#define udd_control_in_set_buf(buf) (udd_sram.ep_ctrl[1].DATAPTR = (uint16_t) buf) - -#define udd_control_in_set_bytecnt(n) (udd_sram.ep_ctrl[1].CNT = n) -//! @} -//! @} - -//! @} - -#endif // _USB_DEVICE_H_ diff --git a/DSTAT1/src/asf/xmega/utils/assembler.h b/DSTAT1/src/asf/xmega/utils/assembler.h deleted file mode 100644 index 31165a4..0000000 --- a/DSTAT1/src/asf/xmega/utils/assembler.h +++ /dev/null @@ -1,154 +0,0 @@ -/** - * \file - * - * \brief Assembler abstraction layer and utilities - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef ASSEMBLER_H_INCLUDED -#define ASSEMBLER_H_INCLUDED - -#if !defined(__ASSEMBLER__) && !defined(__IAR_SYSTEMS_ASM__) \ - && !defined(__DOXYGEN__) -# error This file may only be included from assembly files -#endif - -#if defined(__ASSEMBLER__) -# include "assembler/gas.h" -# include -#elif defined(__IAR_SYSTEMS_ASM__) -# include "assembler/iar.h" -# include -#endif - -/** - * \ingroup group_xmega_utils - * \defgroup assembler_group Assembler Support - * - * This group provides a good handful of macros intended to smooth out - * the differences between various assemblers, similar to what compiler.h does - * for compilers, except that assemblers tend to be much less standardized than - * compilers. - * - * @{ - */ - -//! \name Control Statements -//@{ -/** - * \def REPEAT(count) - * \brief Repeat the following statements \a count times - */ -/** - * \def END_REPEAT() - * \brief Mark the end of the statements to be repeated - */ -/** - * \def SET_LOC(offset) - * \brief Set the location counter to \a offset - */ -/** - * \def END_FILE() - * \brief Mark the end of the file - */ -//@} - -//! \name Data Objects -//@{ -/** - * \def FILL_BYTES(count) - * \brief Allocate space for \a count bytes - */ -//@} - -//! \name Symbol Definition -//@{ -/** - * \def L(name) - * \brief Turn \a name into a local symbol, if possible - */ -/** - * \def EXTERN_SYMBOL(name) - * \brief Declare \a name as an external symbol referenced by this file - */ -/** - * \def FUNCTION(name) - * \brief Define a file-local function called \a name - */ -/** - * \def PUBLIC_FUNCTION(name) - * \brief Define a globally visible function called \a name - */ -/** - * \def WEAK_FUNCTION(name) - * \brief Define a weak function called \a name - * - * Weak functions are only referenced if no strong definitions are found - */ -/** - * \def WEAK_FUNCTION_ALIAS(name, strong_name) - * \brief Define \a name as a weak alias for the function \a strong_name - * \sa WEAK_FUNCTION - */ -/** - * \def END_FUNC(name) - * \brief Mark the end of the function called \a name - */ -//@} - -//! \name Section Definition -//@{ -/** - * \def TEXT_SECTION(name) - * \brief Start a new section containing executable code - */ -/** - * \def RODATA_SECTION(name) - * \brief Start a new section containing read-only data - */ -/** - * \def DATA_SECTION(name) - * \brief Start a new section containing writeable initialized data - */ -/** - * \def BSS_SECTION(name) - * \brief Start a new section containing writeable zero-initialized data - */ -//@} - -//! @} - -#endif /* ASSEMBLER_H_INCLUDED */ diff --git a/DSTAT1/src/asf/xmega/utils/assembler/gas.h b/DSTAT1/src/asf/xmega/utils/assembler/gas.h deleted file mode 100644 index fa05050..0000000 --- a/DSTAT1/src/asf/xmega/utils/assembler/gas.h +++ /dev/null @@ -1,119 +0,0 @@ -/** - * \file - * - * \brief Assembler abstraction layer: GNU Assembler specifics - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef ASSEMBLER_GAS_H_INCLUDED -#define ASSEMBLER_GAS_H_INCLUDED - -#ifndef __DOXYGEN__ - - /* IAR doesn't accept dots in macro names */ - .macro ld_addr, reg, sym - lda.w \reg, \sym - .endm - - /* Define a function \a name that is either globally visible or only - * file-local. - */ - .macro gas_begin_func name, is_public - .if \is_public - .global \name - .endif - .section .text.\name, "ax", @progbits - .type \name, @function - \name : - .endm - - /* Define a function \a name that is either globally visible or only - * file-local in a given segment. - */ - .macro gas_begin_func_segm name, is_public, segment - .if \is_public - .global \name - .endif - .section .\segment, "ax", @progbits - .type \name, @function - \name : - .endm - - /* Define \a name as a weak alias for the function \a strong_name */ - .macro gas_weak_function_alias name, strong_name - .global \name - .weak \name - .type \name, @function - .set \name, \strong_name - .endm - - /* Define a weak function called \a name */ - .macro gas_weak_function name - .weak \name - gas_begin_func \name 1 - .endm - -#define REPEAT(count) .rept count -#define END_REPEAT() .endr -#define FILL_BYTES(count) .fill count -#define SET_LOC(offset) .org offset -#define L(name) .L##name -#define EXTERN_SYMBOL(name) - -#define TEXT_SECTION(name) \ - .section name, "ax", @progbits -#define RODATA_SECTION(name) \ - .section name, "a", @progbits -#define DATA_SECTION(name) \ - .section name, "aw", @progbits -#define BSS_SECTION(name) \ - .section name, "aw", @nobits - -#define FUNCTION(name) gas_begin_func name 0 -#define PUBLIC_FUNCTION(name) gas_begin_func name 1 -#define PUBLIC_FUNCTION_SEGMENT(name, segment) \ - gas_begin_func_segm name 1 segment -#define WEAK_FUNCTION(name) gas_weak_function name -#define WEAK_FUNCTION_ALIAS(name, strong_name) \ - gas_weak_function_alias name strong_name -#define END_FUNC(name) \ - .size name, . - name - -#define END_FILE() - -#endif /* __DOXYGEN__ */ - -#endif /* ASSEMBLER_GAS_H_INCLUDED */ diff --git a/DSTAT1/src/asf/xmega/utils/bit_handling/clz_ctz.h b/DSTAT1/src/asf/xmega/utils/bit_handling/clz_ctz.h deleted file mode 100644 index 90c5bfd..0000000 --- a/DSTAT1/src/asf/xmega/utils/bit_handling/clz_ctz.h +++ /dev/null @@ -1,210 +0,0 @@ -/** - * \file - * - * \brief CLZ/CTZ C implemetation. - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef CLZ_CTH_H -#define CLZ_CTH_H - -/** - * \brief Count leading zeros in unsigned integer - * - * This macro takes unsigned integers of any size, and evaluates to a call to - * the clz-function for its size. These functions count the number of zeros, - * starting with the MSB, before a one occurs in the integer. - * - * \param x Unsigned integer to count the leading zeros in. - * - * \return The number of leading zeros in \a x. - */ -#define clz(x) compiler_demux_size(sizeof(x), clz, (x)) - -/** - * \internal - * \brief Count leading zeros in unsigned, 8-bit integer - * - * \param x Unsigned byte to count the leading zeros in. - * - * \return The number of leading zeros in \a x. - */ -__always_inline static uint8_t clz8(uint8_t x) -{ - uint8_t bit = 0; - - if (x & 0xf0) { - x >>= 4; - } else { - bit += 4; - } - - if (x & 0x0c) { - x >>= 2; - } else { - bit += 2; - } - - if (!(x & 0x02)) { - bit++; - } - - return bit; - -} - -/** - * \internal - * \brief Count leading zeros in unsigned, 16-bit integer - * - * \param x Unsigned word to count the leading zeros in. - * - * \return The number of leading zeros in \a x. - */ -__always_inline static uint8_t clz16(uint16_t x) -{ - uint8_t bit = 0; - - if (x & 0xff00) { - x >>= 8; - } else { - bit += 8; - } - - return bit + clz8(x); -} - -/** - * \internal - * \brief Count leading zeros in unsigned, 32-bit integer - * - * \param x Unsigned double word to count the leading zeros in. - * - * \return The number of leading zeros in \a x. - */ -__always_inline static uint8_t clz32(uint32_t x) -{ - uint8_t bit = 0; - - if (x & 0xffff0000) { - x >>= 16; - } else { - bit += 16; - } - - return bit + clz16(x); -} - -/** - * \brief Count trailing zeros in unsigned integer - * - * This macro takes unsigned integers of any size, and evaluates to a call to - * the ctz-function for its size. These functions count the number of zeros, - * starting with the LSB, before a one occurs in the integer. - * - * \param x Unsigned integer to count the trailing zeros in. - * - * \return The number of trailing zeros in \a x. - */ -#define ctz(x) compiler_demux_size(sizeof(x), ctz, (x)) - -/** - * \internal - * \brief Count trailing zeros in unsigned, 8-bit integer - * - * \param x Unsigned byte to count the trailing zeros in. - * - * \return The number of leading zeros in \a x. - */ -__always_inline static uint8_t ctz8(uint8_t x) -{ - uint8_t bit = 0; - - if (!(x & 0x0f)) { - bit += 4; - x >>= 4; - } - if (!(x & 0x03)) { - bit += 2; - x >>= 2; - } - if (!(x & 0x01)) - bit++; - - return bit; -} - -/** - * \internal - * \brief Count trailing zeros in unsigned, 16-bit integer - * - * \param x Unsigned word to count the trailing zeros in. - * - * \return The number of trailing zeros in \a x. - */ -__always_inline static uint8_t ctz16(uint16_t x) -{ - uint8_t bit = 0; - - if (!(x & 0x00ff)) { - bit += 8; - x >>= 8; - } - - return bit + ctz8(x); -} - -/** - * \internal - * \brief Count trailing zeros in unsigned, 32-bit integer - * - * \param x Unsigned double word to count the trailing zeros in. - * - * \return The number of trailing zeros in \a x. - */ -__always_inline static uint8_t ctz32(uint32_t x) -{ - uint8_t bit = 0; - - if (!(x & 0x0000ffff)) { - bit += 16; - x >>= 16; - } - - return bit + ctz16(x); -} - -#endif /* CLZ_CTZ_H */ diff --git a/DSTAT1/src/asf/xmega/utils/compiler.h b/DSTAT1/src/asf/xmega/utils/compiler.h deleted file mode 100644 index c2dbb00..0000000 --- a/DSTAT1/src/asf/xmega/utils/compiler.h +++ /dev/null @@ -1,1023 +0,0 @@ -/** - * \file - * - * \brief Commonly used includes, types and macros. - * - * Copyright (c) 2010-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef UTILS_COMPILER_H -#define UTILS_COMPILER_H - -/** - * \defgroup group_xmega_utils XMEGA compiler driver - * - * Compiler abstraction layer and code utilities for 8-bit AVR. - * This module provides various abstraction layers and utilities to make code compatible between different compilers. - * - * \{ - */ - -#if defined(__GNUC__) -# include -# include -#elif defined(__ICCAVR__) -# include -# include -#else -# error Unsupported compiler. -#endif - -#include -#include -#include -#include - -#ifdef __ICCAVR__ -/*! \name Compiler Keywords - * - * Port of some keywords from GCC to IAR Embedded Workbench. - */ -//! @{ -#define __asm__ asm -#define __inline__ inline -#define __volatile__ -//! @} -#endif - -/** - * \def barrier - * \brief Memory barrier - */ -#ifdef __GNUC__ -# define barrier() asm volatile("" ::: "memory") -#else -# define barrier() asm ("") -#endif - -/** - * \brief Emit the compiler pragma \a arg. - * - * \param arg The pragma directive as it would appear after \e \#pragma - * (i.e. not stringified). - */ -#define COMPILER_PRAGMA(arg) _Pragma(#arg) - -/* - * AVR arch does not care about alignment anyway. - */ -#define COMPILER_PACK_RESET(alignment) -#define COMPILER_PACK_SET(alignment) - -/** - * \brief Set aligned boundary. - */ -#if (defined __GNUC__) -#define COMPILER_ALIGNED(a) __attribute__((__aligned__(a))) -#elif (defined __ICCAVR__) -#define COMPILER_ALIGNED(a) COMPILER_PRAGMA(data_alignment = a) -#endif - -/** - * \brief Set word-aligned boundary. - */ -#if (defined __GNUC__) -#define COMPILER_WORD_ALIGNED __attribute__((__aligned__(2))) -#elif (defined __ICCAVR__) -#define COMPILER_WORD_ALIGNED COMPILER_PRAGMA(data_alignment = 2) -#endif - -/** - * \name Tag functions as deprecated - * - * Tagging a function as deprecated will produce a warning when and only - * when the function is called. - * - * Usage is to add the __DEPRECATED__ symbol before the function definition. - * E.g.: - * __DEPRECATED__ uint8_t some_deprecated_function (void) - * { - * ... - * } - * - * \note Only supported by GCC 3.1 and above, no IAR support - * @{ - */ -#if ((defined __GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >=1))) -#define __DEPRECATED__ __attribute__((__deprecated__)) -#else -#define __DEPRECATED__ -#endif -//! @} - -/*! \name Usual Types - */ -//! @{ -typedef unsigned char Bool; //!< Boolean. -#ifndef __cplusplus -#if !defined(__bool_true_false_are_defined) -typedef unsigned char bool; //!< Boolean. -#endif -#endif -typedef signed char S8 ; //!< 8-bit signed integer. -typedef unsigned char U8 ; //!< 8-bit unsigned integer. -typedef signed short int S16; //!< 16-bit signed integer. -typedef unsigned short int U16; //!< 16-bit unsigned integer. -typedef unsigned short int le16_t; -typedef unsigned short int be16_t; -typedef signed long int S32; //!< 32-bit signed integer. -typedef unsigned long int U32; //!< 32-bit unsigned integer. -typedef uint32_t le32_t; -typedef uint32_t be32_t; -typedef signed long long int S64; //!< 64-bit signed integer. -typedef unsigned long long int U64; //!< 64-bit unsigned integer. -typedef float F32; //!< 32-bit floating-point number. -typedef double F64; //!< 64-bit floating-point number. -typedef uint16_t iram_size_t; -//! @} - - -/*! \name Status Types - */ -//! @{ -typedef Bool Status_bool_t; //!< Boolean status. -typedef U8 Status_t; //!< 8-bit-coded status. -//! @} - - -/*! \name Aliasing Aggregate Types - */ -//! @{ - -//! 16-bit union. -typedef union -{ - S16 s16 ; - U16 u16 ; - S8 s8 [2]; - U8 u8 [2]; -} Union16; - -//! 32-bit union. -typedef union -{ - S32 s32 ; - U32 u32 ; - S16 s16[2]; - U16 u16[2]; - S8 s8 [4]; - U8 u8 [4]; -} Union32; - -//! 64-bit union. -typedef union -{ - S64 s64 ; - U64 u64 ; - S32 s32[2]; - U32 u32[2]; - S16 s16[4]; - U16 u16[4]; - S8 s8 [8]; - U8 u8 [8]; -} Union64; - -//! Union of pointers to 64-, 32-, 16- and 8-bit unsigned integers. -typedef union -{ - S64 *s64ptr; - U64 *u64ptr; - S32 *s32ptr; - U32 *u32ptr; - S16 *s16ptr; - U16 *u16ptr; - S8 *s8ptr ; - U8 *u8ptr ; -} UnionPtr; - -//! Union of pointers to volatile 64-, 32-, 16- and 8-bit unsigned integers. -typedef union -{ - volatile S64 *s64ptr; - volatile U64 *u64ptr; - volatile S32 *s32ptr; - volatile U32 *u32ptr; - volatile S16 *s16ptr; - volatile U16 *u16ptr; - volatile S8 *s8ptr ; - volatile U8 *u8ptr ; -} UnionVPtr; - -//! Union of pointers to constant 64-, 32-, 16- and 8-bit unsigned integers. -typedef union -{ - const S64 *s64ptr; - const U64 *u64ptr; - const S32 *s32ptr; - const U32 *u32ptr; - const S16 *s16ptr; - const U16 *u16ptr; - const S8 *s8ptr ; - const U8 *u8ptr ; -} UnionCPtr; - -//! Union of pointers to constant volatile 64-, 32-, 16- and 8-bit unsigned integers. -typedef union -{ - const volatile S64 *s64ptr; - const volatile U64 *u64ptr; - const volatile S32 *s32ptr; - const volatile U32 *u32ptr; - const volatile S16 *s16ptr; - const volatile U16 *u16ptr; - const volatile S8 *s8ptr ; - const volatile U8 *u8ptr ; -} UnionCVPtr; - -//! Structure of pointers to 64-, 32-, 16- and 8-bit unsigned integers. -typedef struct -{ - S64 *s64ptr; - U64 *u64ptr; - S32 *s32ptr; - U32 *u32ptr; - S16 *s16ptr; - U16 *u16ptr; - S8 *s8ptr ; - U8 *u8ptr ; -} StructPtr; - -//! Structure of pointers to volatile 64-, 32-, 16- and 8-bit unsigned integers. -typedef struct -{ - volatile S64 *s64ptr; - volatile U64 *u64ptr; - volatile S32 *s32ptr; - volatile U32 *u32ptr; - volatile S16 *s16ptr; - volatile U16 *u16ptr; - volatile S8 *s8ptr ; - volatile U8 *u8ptr ; -} StructVPtr; - -//! Structure of pointers to constant 64-, 32-, 16- and 8-bit unsigned integers. -typedef struct -{ - const S64 *s64ptr; - const U64 *u64ptr; - const S32 *s32ptr; - const U32 *u32ptr; - const S16 *s16ptr; - const U16 *u16ptr; - const S8 *s8ptr ; - const U8 *u8ptr ; -} StructCPtr; - -//! Structure of pointers to constant volatile 64-, 32-, 16- and 8-bit unsigned integers. -typedef struct -{ - const volatile S64 *s64ptr; - const volatile U64 *u64ptr; - const volatile S32 *s32ptr; - const volatile U32 *u32ptr; - const volatile S16 *s16ptr; - const volatile U16 *u16ptr; - const volatile S8 *s8ptr ; - const volatile U8 *u8ptr ; -} StructCVPtr; - -//! @} - - -//_____ M A C R O S ________________________________________________________ - -/*! \name Usual Constants - */ -//! @{ -#define DISABLE 0 -#define ENABLE 1 -#ifndef __cplusplus -#if !defined(__bool_true_false_are_defined) -#define false 0 -#define true 1 -#endif -#endif -#define PASS 0 -#define FAIL 1 -#define LOW 0 -#define HIGH 1 -//! @} - - -//! \name Compile time error handling -//@{ - -/** - * \internal - * \def ERROR_FUNC(name, msg) - * \brief Fail compilation if function call isn't eliminated - * - * If the compiler fails to optimize away all calls to the function \a - * name, terminate compilation and display \a msg to the user. - * - * \note Not all compilers support this, so this is best-effort only. - * Sometimes, there may be a linker error instead, and when optimization - * is disabled, this mechanism will be completely disabled. - */ -#ifndef ERROR_FUNC -# define ERROR_FUNC(name, msg) \ - extern int name(void) -#endif - -//@} - -//! \name Function call demultiplexing -//@{ - -//! Error function for failed demultiplexing. -ERROR_FUNC(compiler_demux_bad_size, "Invalid parameter size"); - -/** - * \internal - * \brief Demultiplex function call based on size of datatype - * - * Evaluates to a function call to a function name with suffix 8, 16 or 32 - * depending on the size of the datatype. Any number of parameters can be - * passed to the function. - * - * Usage: - * \code - * void foo8(uint8_t a, void *b); - * void foo16(uint16_t a, void *b); - * void foo32(uint32_t a, void *b); - * - * #define foo(x, y) compiler_demux_size(sizeof(x), foo, x, y) - * \endcode - * - * \param size Size of the datatype. - * \param func Base function name. - * \param ... List of parameters to pass to the function. - */ -#define compiler_demux_size(size, func, ...) \ - (((size) == 1) ? func##8(__VA_ARGS__) : \ - ((size) == 2) ? func##16(__VA_ARGS__) : \ - ((size) == 4) ? func##32(__VA_ARGS__) : \ - compiler_demux_bad_size()) - -//@} - -/** - * \def __always_inline - * \brief The function should always be inlined. - * - * This annotation instructs the compiler to ignore its inlining - * heuristics and inline the function no matter how big it thinks it - * becomes. - */ -#if (defined __GNUC__) - #define __always_inline inline __attribute__((__always_inline__)) -#elif (defined __ICCAVR__) - #define __always_inline _Pragma("inline=forced") -#endif - -//! \name Optimization Control -//@{ - -/** - * \def __always_optimize - * \brief The function should always be optimized. - * - * This annotation instructs the compiler to ignore global optimization - * settings and always compile the function with a high level of - * optimization. - */ -#if (defined __GNUC__) - #define __always_optimize __attribute__((optimize(3))) -#elif (defined __ICCAVR__) - #define __always_optimize _Pragma("optimize=high") -#endif - -/** - * \def likely(exp) - * \brief The expression \a exp is likely to be true - */ -#ifndef likely -# define likely(exp) (exp) -#endif - -/** - * \def unlikely(exp) - * \brief The expression \a exp is unlikely to be true - */ -#ifndef unlikely -# define unlikely(exp) (exp) -#endif - -/** - * \def is_constant(exp) - * \brief Determine if an expression evaluates to a constant value. - * - * \param exp Any expression - * - * \return true if \a exp is constant, false otherwise. - */ -#ifdef __GNUC__ -# define is_constant(exp) __builtin_constant_p(exp) -#else -# define is_constant(exp) (0) -#endif - -//! @} - -/*! \name Bit-Field Handling - */ -#include "bit_handling/clz_ctz.h" -//! @{ - -/*! \brief Reads the bits of a value specified by a given bit-mask. - * - * \param value Value to read bits from. - * \param mask Bit-mask indicating bits to read. - * - * \return Read bits. - */ -#define Rd_bits( value, mask) ((value)&(mask)) - -/*! \brief Writes the bits of a C lvalue specified by a given bit-mask. - * - * \param lvalue C lvalue to write bits to. - * \param mask Bit-mask indicating bits to write. - * \param bits Bits to write. - * - * \return Resulting value with written bits. - */ -#define Wr_bits(lvalue, mask, bits) ((lvalue) = ((lvalue) & ~(mask)) |\ - ((bits ) & (mask))) - -/*! \brief Tests the bits of a value specified by a given bit-mask. - * - * \param value Value of which to test bits. - * \param mask Bit-mask indicating bits to test. - * - * \return \c 1 if at least one of the tested bits is set, else \c 0. - */ -#define Tst_bits( value, mask) (Rd_bits(value, mask) != 0) - -/*! \brief Clears the bits of a C lvalue specified by a given bit-mask. - * - * \param lvalue C lvalue of which to clear bits. - * \param mask Bit-mask indicating bits to clear. - * - * \return Resulting value with cleared bits. - */ -#define Clr_bits(lvalue, mask) ((lvalue) &= ~(mask)) - -/*! \brief Sets the bits of a C lvalue specified by a given bit-mask. - * - * \param lvalue C lvalue of which to set bits. - * \param mask Bit-mask indicating bits to set. - * - * \return Resulting value with set bits. - */ -#define Set_bits(lvalue, mask) ((lvalue) |= (mask)) - -/*! \brief Toggles the bits of a C lvalue specified by a given bit-mask. - * - * \param lvalue C lvalue of which to toggle bits. - * \param mask Bit-mask indicating bits to toggle. - * - * \return Resulting value with toggled bits. - */ -#define Tgl_bits(lvalue, mask) ((lvalue) ^= (mask)) - -/*! \brief Reads the bit-field of a value specified by a given bit-mask. - * - * \param value Value to read a bit-field from. - * \param mask Bit-mask indicating the bit-field to read. - * - * \return Read bit-field. - */ -#define Rd_bitfield( value,mask) (Rd_bits( value, (uint32_t)mask) >> ctz(mask)) - -/*! \brief Writes the bit-field of a C lvalue specified by a given bit-mask. - * - * \param lvalue C lvalue to write a bit-field to. - * \param mask Bit-mask indicating the bit-field to write. - * \param bitfield Bit-field to write. - * - * \return Resulting value with written bit-field. - */ -#define Wr_bitfield(lvalue, mask, bitfield) (Wr_bits(lvalue, mask, (uint32_t)(bitfield) << ctz(mask))) - -//! @} - - -/*! \brief This macro is used to test fatal errors. - * - * The macro tests if the expression is false. If it is, a fatal error is - * detected and the application hangs up. If TEST_SUITE_DEFINE_ASSERT_MACRO - * is defined, a unit test version of the macro is used, to allow execution - * of further tests after a false expression. - * - * \param expr Expression to evaluate and supposed to be nonzero. - */ -#if defined(_ASSERT_ENABLE_) -# if defined(TEST_SUITE_DEFINE_ASSERT_MACRO) - // Assert() is defined in unit_test/suite.h -# include "unit_test/suite.h" -# else -# define Assert(expr) \ - {\ - if (!(expr)) while (true);\ - } -# endif -#else -# define Assert(expr) ((void) 0) -#endif - -/*! \name Bit Reversing - */ -//! @{ - -/*! \brief Reverses the bits of \a u8. - * - * \param u8 U8 of which to reverse the bits. - * - * \return Value resulting from \a u8 with reversed bits. - */ -#define bit_reverse8(u8) ((U8)(bit_reverse32((U8)(u8)) >> 24)) - -/*! \brief Reverses the bits of \a u16. - * - * \param u16 U16 of which to reverse the bits. - * - * \return Value resulting from \a u16 with reversed bits. - */ -#define bit_reverse16(u16) ((U16)(bit_reverse32((U16)(u16)) >> 16)) - -/*! \brief Reverses the bits of \a u32. - * - * \param u32 U32 of which to reverse the bits. - * - * \return Value resulting from \a u32 with reversed bits. - */ -#if (defined __GNUC__) - #define bit_reverse32(u32) \ - (\ - {\ - unsigned int __value = (U32)(u32);\ - __asm__ ("brev\t%0" : "+r" (__value) : : "cc");\ - (U32)__value;\ - }\ - ) -#elif (defined __ICCAVR__) - #define bit_reverse32(u32) ((U32)__bit_reverse((U32)(u32))) -#endif - -/*! \brief Reverses the bits of \a u64. - * - * \param u64 U64 of which to reverse the bits. - * - * \return Value resulting from \a u64 with reversed bits. - */ -#define bit_reverse64(u64) ((U64)(((U64)bit_reverse32((U64)(u64) >> 32)) |\ - ((U64)bit_reverse32((U64)(u64)) << 32))) - -//! @} - -//! \name Logarithmic functions -//! @{ - -/** - * \internal - * Undefined function. Will cause a link failure if ilog2() is called - * with an invalid constant value. - */ -int_fast8_t ilog2_undefined(void); - -/** - * \brief Calculate the base-2 logarithm of a number rounded down to - * the nearest integer. - * - * \param x A 32-bit value - * \return The base-2 logarithm of \a x, or -1 if \a x is 0. - */ -static inline int_fast8_t ilog2(uint32_t x) -{ - if (is_constant(x)) - return ((x) & (1ULL << 31) ? 31 : - (x) & (1ULL << 30) ? 30 : - (x) & (1ULL << 29) ? 29 : - (x) & (1ULL << 28) ? 28 : - (x) & (1ULL << 27) ? 27 : - (x) & (1ULL << 26) ? 26 : - (x) & (1ULL << 25) ? 25 : - (x) & (1ULL << 24) ? 24 : - (x) & (1ULL << 23) ? 23 : - (x) & (1ULL << 22) ? 22 : - (x) & (1ULL << 21) ? 21 : - (x) & (1ULL << 20) ? 20 : - (x) & (1ULL << 19) ? 19 : - (x) & (1ULL << 18) ? 18 : - (x) & (1ULL << 17) ? 17 : - (x) & (1ULL << 16) ? 16 : - (x) & (1ULL << 15) ? 15 : - (x) & (1ULL << 14) ? 14 : - (x) & (1ULL << 13) ? 13 : - (x) & (1ULL << 12) ? 12 : - (x) & (1ULL << 11) ? 11 : - (x) & (1ULL << 10) ? 10 : - (x) & (1ULL << 9) ? 9 : - (x) & (1ULL << 8) ? 8 : - (x) & (1ULL << 7) ? 7 : - (x) & (1ULL << 6) ? 6 : - (x) & (1ULL << 5) ? 5 : - (x) & (1ULL << 4) ? 4 : - (x) & (1ULL << 3) ? 3 : - (x) & (1ULL << 2) ? 2 : - (x) & (1ULL << 1) ? 1 : - (x) & (1ULL << 0) ? 0 : - ilog2_undefined()); - - return 31 - clz(x); -} - -//! @} - -/*! \name Alignment - */ -//! @{ - -/*! \brief Tests alignment of the number \a val with the \a n boundary. - * - * \param val Input value. - * \param n Boundary. - * - * \return \c 1 if the number \a val is aligned with the \a n boundary, else \c 0. - */ -#define Test_align(val, n ) (!Tst_bits( val, (n) - 1 ) ) - -/*! \brief Gets alignment of the number \a val with respect to the \a n boundary. - * - * \param val Input value. - * \param n Boundary. - * - * \return Alignment of the number \a val with respect to the \a n boundary. - */ -#define Get_align( val, n ) ( Rd_bits( val, (n) - 1 ) ) - -/*! \brief Sets alignment of the lvalue number \a lval to \a alg with respect to the \a n boundary. - * - * \param lval Input/output lvalue. - * \param n Boundary. - * \param alg Alignment. - * - * \return New value of \a lval resulting from its alignment set to \a alg with respect to the \a n boundary. - */ -#define Set_align(lval, n, alg) ( Wr_bits(lval, (n) - 1, alg) ) - -/*! \brief Aligns the number \a val with the upper \a n boundary. - * - * \param val Input value. - * \param n Boundary. - * - * \return Value resulting from the number \a val aligned with the upper \a n boundary. - */ -#define Align_up( val, n ) (((val) + ((n) - 1)) & ~((n) - 1)) - -/*! \brief Aligns the number \a val with the lower \a n boundary. - * - * \param val Input value. - * \param n Boundary. - * - * \return Value resulting from the number \a val aligned with the lower \a n boundary. - */ -#define Align_down(val, n ) ( (val) & ~((n) - 1)) - -//! @} - - -/*! \name Mathematics - * - * Compiler optimization for non-constant expressions, only for abs under WinAVR - */ -//! @{ - -/*! \brief Takes the absolute value of \a a. - * - * \param a Input value. - * - * \return Absolute value of \a a. - * - * \note More optimized if only used with values known at compile time. - */ -#define Abs(a) (((a) < 0 ) ? -(a) : (a)) -#ifndef abs -#define abs(a) Abs(a) -#endif - -/*! \brief Takes the minimal value of \a a and \a b. - * - * \param a Input value. - * \param b Input value. - * - * \return Minimal value of \a a and \a b. - * - * \note More optimized if only used with values known at compile time. - */ -#define Min(a, b) (((a) < (b)) ? (a) : (b)) -#define min(a, b) Min(a, b) - -/*! \brief Takes the maximal value of \a a and \a b. - * - * \param a Input value. - * \param b Input value. - * - * \return Maximal value of \a a and \a b. - * - * \note More optimized if only used with values known at compile time. - */ -#define Max(a, b) (((a) > (b)) ? (a) : (b)) -#define max(a, b) Max(a, b) - -//! @} - - -/*! \brief Calls the routine at address \a addr. - * - * It generates a long call opcode. - * - * For example, `Long_call(0x80000000)' generates a software reset on a UC3 if - * it is invoked from the CPU supervisor mode. - * - * \param addr Address of the routine to call. - * - * \note It may be used as a long jump opcode in some special cases. - */ -#define Long_call(addr) ((*(void (*)(void))(addr))()) - -/*! \name System Register Access - */ -//! @{ - -/*! \brief Gets the value of the \a sysreg system register. - * - * \param sysreg Address of the system register of which to get the value. - * - * \return Value of the \a sysreg system register. - */ -#if (defined __GNUC__) - #define Get_system_register(sysreg) __builtin_mfsr(sysreg) -#elif (defined __ICCAVR__) - #define Get_system_register(sysreg) __get_system_register(sysreg) -#endif - -/*! \brief Sets the value of the \a sysreg system register to \a value. - * - * \param sysreg Address of the system register of which to set the value. - * \param value Value to set the \a sysreg system register to. - */ -#if (defined __GNUC__) - #define Set_system_register(sysreg, value) __builtin_mtsr(sysreg, value) -#elif (defined __ICCAVR__) - #define Set_system_register(sysreg, value) __set_system_register(sysreg, value) -#endif - -//! @} - -/*! \name Debug Register Access - */ -//! @{ - -/*! \brief Gets the value of the \a dbgreg debug register. - * - * \param dbgreg Address of the debug register of which to get the value. - * - * \return Value of the \a dbgreg debug register. - */ -#if (defined __GNUC__) - #define Get_debug_register(dbgreg) __builtin_mfdr(dbgreg) -#elif (defined __ICCAVR__) - #define Get_debug_register(dbgreg) __get_debug_register(dbgreg) -#endif - -/*! \brief Sets the value of the \a dbgreg debug register to \a value. - * - * \param dbgreg Address of the debug register of which to set the value. - * \param value Value to set the \a dbgreg debug register to. - */ -#if (defined __GNUC__) - #define Set_debug_register(dbgreg, value) __builtin_mtdr(dbgreg, value) -#elif (defined __ICCAVR__) - #define Set_debug_register(dbgreg, value) __set_debug_register(dbgreg, value) -#endif - -//! @} - - -/*! \name MCU Endianism Handling - * xmega is a MCU little endianism. - */ -//! @{ -#define MSB(u16) (((uint8_t* )&u16)[1]) -#define LSB(u16) (((uint8_t* )&u16)[0]) - -#define MSW(u32) (((uint16_t*)&u32)[1]) -#define LSW(u32) (((uint16_t*)&u32)[0]) -#define MSB0W(u32) (((uint8_t*)&(u32))[3]) //!< Most significant byte of 1st rank of \a u32. -#define MSB1W(u32) (((uint8_t*)&(u32))[2]) //!< Most significant byte of 2nd rank of \a u32. -#define MSB2W(u32) (((uint8_t*)&(u32))[1]) //!< Most significant byte of 3rd rank of \a u32. -#define MSB3W(u32) (((uint8_t*)&(u32))[0]) //!< Most significant byte of 4th rank of \a u32. -#define LSB3W(u32) MSB0W(u32) //!< Least significant byte of 4th rank of \a u32. -#define LSB2W(u32) MSB1W(u32) //!< Least significant byte of 3rd rank of \a u32. -#define LSB1W(u32) MSB2W(u32) //!< Least significant byte of 2nd rank of \a u32. -#define LSB0W(u32) MSB3W(u32) //!< Least significant byte of 1st rank of \a u32. - -#define MSB0(u32) (((uint8_t*)&u32)[3]) -#define MSB1(u32) (((uint8_t*)&u32)[2]) -#define MSB2(u32) (((uint8_t*)&u32)[1]) -#define MSB3(u32) (((uint8_t*)&u32)[0]) -#define LSB0(u32) MSB3(u32) -#define LSB1(u32) MSB2(u32) -#define LSB2(u32) MSB1(u32) -#define LSB3(u32) MSB0(u32) - -#define LE16(x) (x) -#define le16_to_cpu(x) (x) -#define cpu_to_le16(x) (x) -#define LE16_TO_CPU(x) (x) -#define CPU_TO_LE16(x) (x) - -#define BE16(x) Swap16(x) -#define be16_to_cpu(x) swap16(x) -#define cpu_to_be16(x) swap16(x) -#define BE16_TO_CPU(x) Swap16(x) -#define CPU_TO_BE16(x) Swap16(x) - -#define LE32(x) (x) -#define le32_to_cpu(x) (x) -#define cpu_to_le32(x) (x) -#define LE32_TO_CPU(x) (x) -#define CPU_TO_LE32(x) (x) - -#define BE32(x) Swap32(x) -#define be32_to_cpu(x) swap32(x) -#define cpu_to_be32(x) swap32(x) -#define BE32_TO_CPU(x) Swap32(x) -#define CPU_TO_BE32(x) Swap32(x) - - - -//! @} - - -/*! \name Endianism Conversion - * - * The same considerations as for clz and ctz apply here but AVR32-GCC's - * __builtin_bswap_16 and __builtin_bswap_32 do not behave like macros when - * applied to constant expressions, so two sets of macros are defined here: - * - Swap16, Swap32 and Swap64 to apply to constant expressions (values known - * at compile time); - * - swap16, swap32 and swap64 to apply to non-constant expressions (values - * unknown at compile time). - */ -//! @{ - -/*! \brief Toggles the endianism of \a u16 (by swapping its bytes). - * - * \param u16 U16 of which to toggle the endianism. - * - * \return Value resulting from \a u16 with toggled endianism. - * - * \note More optimized if only used with values known at compile time. - */ -#define Swap16(u16) ((U16)(((U16)(u16) >> 8) |\ - ((U16)(u16) << 8))) - -/*! \brief Toggles the endianism of \a u32 (by swapping its bytes). - * - * \param u32 U32 of which to toggle the endianism. - * - * \return Value resulting from \a u32 with toggled endianism. - * - * \note More optimized if only used with values known at compile time. - */ -#define Swap32(u32) ((U32)(((U32)Swap16((U32)(u32) >> 16)) |\ - ((U32)Swap16((U32)(u32)) << 16))) - -/*! \brief Toggles the endianism of \a u64 (by swapping its bytes). - * - * \param u64 U64 of which to toggle the endianism. - * - * \return Value resulting from \a u64 with toggled endianism. - * - * \note More optimized if only used with values known at compile time. - */ -#define Swap64(u64) ((U64)(((U64)Swap32((U64)(u64) >> 32)) |\ - ((U64)Swap32((U64)(u64)) << 32))) - -/*! \brief Toggles the endianism of \a u16 (by swapping its bytes). - * - * \param u16 U16 of which to toggle the endianism. - * - * \return Value resulting from \a u16 with toggled endianism. - * - * \note More optimized if only used with values unknown at compile time. - */ -#define swap16(u16) Swap16(u16) - -/*! \brief Toggles the endianism of \a u32 (by swapping its bytes). - * - * \param u32 U32 of which to toggle the endianism. - * - * \return Value resulting from \a u32 with toggled endianism. - * - * \note More optimized if only used with values unknown at compile time. - */ -#define swap32(u32) Swap32(u32) - -/*! \brief Toggles the endianism of \a u64 (by swapping its bytes). - * - * \param u64 U64 of which to toggle the endianism. - * - * \return Value resulting from \a u64 with toggled endianism. - * - * \note More optimized if only used with values unknown at compile time. - */ -#define swap64(u64) ((U64)(((U64)swap32((U64)(u64) >> 32)) |\ - ((U64)swap32((U64)(u64)) << 32))) - -//! @} - - -/*! \name Target Abstraction - */ -//! @{ - -#define _GLOBEXT_ extern //!< extern storage-class specifier. -#define _CONST_TYPE_ const //!< const type qualifier. -#define _MEM_TYPE_SLOW_ //!< Slow memory type. -#define _MEM_TYPE_MEDFAST_ //!< Fairly fast memory type. -#define _MEM_TYPE_FAST_ //!< Fast memory type. - -typedef U8 Byte; //!< 8-bit unsigned integer. - -#define memcmp_ram2ram memcmp //!< Target-specific memcmp of RAM to RAM. -#define memcmp_code2ram memcmp //!< Target-specific memcmp of RAM to NVRAM. -#define memcpy_ram2ram memcpy //!< Target-specific memcpy from RAM to RAM. -#define memcpy_code2ram memcpy //!< Target-specific memcpy from NVRAM to RAM. - -//! @} - -/** - * \brief Calculate \f$ \left\lceil \frac{a}{b} \right\rceil \f$ using - * integer arithmetic. - * - * \param a An integer - * \param b Another integer - * - * \return (\a a / \a b) rounded up to the nearest integer. - */ -#define div_ceil(a, b) (((a) + (b) - 1) / (b)) - -#include "preprocessor.h" -#include "progmem.h" -#include "interrupt.h" - -/** - * \} - */ - -#endif // UTILS_COMPILER_H diff --git a/DSTAT1/src/asf/xmega/utils/parts.h b/DSTAT1/src/asf/xmega/utils/parts.h deleted file mode 100644 index 90220fb..0000000 --- a/DSTAT1/src/asf/xmega/utils/parts.h +++ /dev/null @@ -1,175 +0,0 @@ -/** - * \file - * - * \brief XMEGA device family definitions - * - * Copyright (c) 2010-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef XMEGA_PARTS_H -#define XMEGA_PARTS_H - -/** - * \defgroup group_xmega_utils_parts Parts - * - * \ingroup group_xmega_utils - * - * \{ - */ - -//! Convenience macro for checking GCC and IAR part definitions -#define part_is_defined(part) \ - (defined(__ ## part ## __) || defined(__AVR_ ## part ## __)) - -// A1 Family -#define XMEGA_A1 ( \ - part_is_defined(ATxmega64A1) || \ - part_is_defined(ATxmega128A1) \ - ) - -// A3 Family -#define XMEGA_A3 ( \ - part_is_defined(ATxmega64A3) || \ - part_is_defined(ATxmega128A3) || \ - part_is_defined(ATxmega192A3) || \ - part_is_defined(ATxmega256A3) \ - ) - -// A3B Family -#define XMEGA_A3B ( \ - part_is_defined(ATxmega256A3B) \ - ) - -// A4 Family -#define XMEGA_A4 ( \ - part_is_defined(ATxmega16A4) || \ - part_is_defined(ATxmega32A4) \ - ) - -// Entire A Family -#define XMEGA_A (XMEGA_A1 || XMEGA_A3 || XMEGA_A3B || XMEGA_A4) - -// A1U Family -#define XMEGA_A1U ( \ - part_is_defined(ATxmega64A1U) || \ - part_is_defined(ATxmega128A1U) \ - ) - -// A3U Family -#define XMEGA_A3U ( \ - part_is_defined(ATxmega64A3U) || \ - part_is_defined(ATxmega128A3U) || \ - part_is_defined(ATxmega192A3U) || \ - part_is_defined(ATxmega256A3U) \ - ) - -// A3BU Family -#define XMEGA_A3BU ( \ - part_is_defined(ATxmega256A3BU) \ - ) - -// A4U Family -#define XMEGA_A4U ( \ - part_is_defined(ATxmega16A4U) || \ - part_is_defined(ATxmega32A4U) || \ - part_is_defined(ATxmega64A4U) || \ - part_is_defined(ATxmega128A4U) \ - ) - -// Entire AU Family -#define XMEGA_AU (XMEGA_A1U || XMEGA_A3U || XMEGA_A3BU || XMEGA_A4U) - -// B1 Family -#define XMEGA_B1 ( \ - part_is_defined(ATxmega64B1) || \ - part_is_defined(ATxmega128B1) \ - ) - -// B3 Family -#define XMEGA_B3 ( \ - part_is_defined(ATxmega64B3) || \ - part_is_defined(ATxmega128B3) \ - ) - -// Entire B Family -#define XMEGA_B (XMEGA_B1 || XMEGA_B3) - -// C3 Family -#define XMEGA_C3 ( \ - part_is_defined(ATxmega384C3) || \ - part_is_defined(ATxmega256C3) \ - ) - - -// C4 Family -#define XMEGA_C4 ( \ - part_is_defined(ATxmega32C4) || \ - part_is_defined(ATxmega16C4) \ - ) - - -// Entire C Family -#define XMEGA_C (XMEGA_C3 || XMEGA_C4) - - -// D3 Family -#define XMEGA_D3 ( \ - part_is_defined(ATxmega64D3) || \ - part_is_defined(ATxmega128D3) || \ - part_is_defined(ATxmega192D3) || \ - part_is_defined(ATxmega256D3) || \ - part_is_defined(ATxmega384D3) \ - ) - -// D4 Family -#define XMEGA_D4 ( \ - part_is_defined(ATxmega16D4) || \ - part_is_defined(ATxmega32D4) || \ - part_is_defined(ATxmega64D4) || \ - part_is_defined(ATxmega128D4) \ - ) - -// Entire D Family -#define XMEGA_D (XMEGA_D3 || XMEGA_D4) - -// Entire XMEGA Family -#define XMEGA (XMEGA_A || XMEGA_AU || XMEGA_B || XMEGA_C || XMEGA_D) - -/** - * \} - */ - -#endif /* XMEGA_PARTS_H */ diff --git a/DSTAT1/src/asf/xmega/utils/preprocessor/mrepeat.h b/DSTAT1/src/asf/xmega/utils/preprocessor/mrepeat.h deleted file mode 100644 index ece2d56..0000000 --- a/DSTAT1/src/asf/xmega/utils/preprocessor/mrepeat.h +++ /dev/null @@ -1,333 +0,0 @@ -/** - * \file - * - * \brief Preprocessor macro repeating utils. - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef _MREPEAT_H_ -#define _MREPEAT_H_ - -/** - * \defgroup group_xmega_utils_mrepeat Macro Repeat - * - * \ingroup group_xmega_utils - * - * \{ - */ - -#include "preprocessor.h" - - -//! Maximal number of repetitions supported by MREPEAT. -#define MREPEAT_LIMIT 256 - -/*! \brief Macro repeat. - * - * This macro represents a horizontal repetition construct. - * - * \param count The number of repetitious calls to macro. Valid values range from 0 to MREPEAT_LIMIT. - * \param macro A binary operation of the form macro(n, data). This macro is expanded by MREPEAT with - * the current repetition number and the auxiliary data argument. - * \param data Auxiliary data passed to macro. - * - * \return macro(0, data) macro(1, data) ... macro(count - 1, data) - */ -#define MREPEAT(count, macro, data) TPASTE2(MREPEAT, count)(macro, data) - -#define MREPEAT0( macro, data) -#define MREPEAT1( macro, data) MREPEAT0( macro, data) macro( 0, data) -#define MREPEAT2( macro, data) MREPEAT1( macro, data) macro( 1, data) -#define MREPEAT3( macro, data) MREPEAT2( macro, data) macro( 2, data) -#define MREPEAT4( macro, data) MREPEAT3( macro, data) macro( 3, data) -#define MREPEAT5( macro, data) MREPEAT4( macro, data) macro( 4, data) -#define MREPEAT6( macro, data) MREPEAT5( macro, data) macro( 5, data) -#define MREPEAT7( macro, data) MREPEAT6( macro, data) macro( 6, data) -#define MREPEAT8( macro, data) MREPEAT7( macro, data) macro( 7, data) -#define MREPEAT9( macro, data) MREPEAT8( macro, data) macro( 8, data) -#define MREPEAT10( macro, data) MREPEAT9( macro, data) macro( 9, data) -#define MREPEAT11( macro, data) MREPEAT10( macro, data) macro( 10, data) -#define MREPEAT12( macro, data) MREPEAT11( macro, data) macro( 11, data) -#define MREPEAT13( macro, data) MREPEAT12( macro, data) macro( 12, data) -#define MREPEAT14( macro, data) MREPEAT13( macro, data) macro( 13, data) -#define MREPEAT15( macro, data) MREPEAT14( macro, data) macro( 14, data) -#define MREPEAT16( macro, data) MREPEAT15( macro, data) macro( 15, data) -#define MREPEAT17( macro, data) MREPEAT16( macro, data) macro( 16, data) -#define MREPEAT18( macro, data) MREPEAT17( macro, data) macro( 17, data) -#define MREPEAT19( macro, data) MREPEAT18( macro, data) macro( 18, data) -#define MREPEAT20( macro, data) MREPEAT19( macro, data) macro( 19, data) -#define MREPEAT21( macro, data) MREPEAT20( macro, data) macro( 20, data) -#define MREPEAT22( macro, data) MREPEAT21( macro, data) macro( 21, data) -#define MREPEAT23( macro, data) MREPEAT22( macro, data) macro( 22, data) -#define MREPEAT24( macro, data) MREPEAT23( macro, data) macro( 23, data) -#define MREPEAT25( macro, data) MREPEAT24( macro, data) macro( 24, data) -#define MREPEAT26( macro, data) MREPEAT25( macro, data) macro( 25, data) -#define MREPEAT27( macro, data) MREPEAT26( macro, data) macro( 26, data) -#define MREPEAT28( macro, data) MREPEAT27( macro, data) macro( 27, data) -#define MREPEAT29( macro, data) MREPEAT28( macro, data) macro( 28, data) -#define MREPEAT30( macro, data) MREPEAT29( macro, data) macro( 29, data) -#define MREPEAT31( macro, data) MREPEAT30( macro, data) macro( 30, data) -#define MREPEAT32( macro, data) MREPEAT31( macro, data) macro( 31, data) -#define MREPEAT33( macro, data) MREPEAT32( macro, data) macro( 32, data) -#define MREPEAT34( macro, data) MREPEAT33( macro, data) macro( 33, data) -#define MREPEAT35( macro, data) MREPEAT34( macro, data) macro( 34, data) -#define MREPEAT36( macro, data) MREPEAT35( macro, data) macro( 35, data) -#define MREPEAT37( macro, data) MREPEAT36( macro, data) macro( 36, data) -#define MREPEAT38( macro, data) MREPEAT37( macro, data) macro( 37, data) -#define MREPEAT39( macro, data) MREPEAT38( macro, data) macro( 38, data) -#define MREPEAT40( macro, data) MREPEAT39( macro, data) macro( 39, data) -#define MREPEAT41( macro, data) MREPEAT40( macro, data) macro( 40, data) -#define MREPEAT42( macro, data) MREPEAT41( macro, data) macro( 41, data) -#define MREPEAT43( macro, data) MREPEAT42( macro, data) macro( 42, data) -#define MREPEAT44( macro, data) MREPEAT43( macro, data) macro( 43, data) -#define MREPEAT45( macro, data) MREPEAT44( macro, data) macro( 44, data) -#define MREPEAT46( macro, data) MREPEAT45( macro, data) macro( 45, data) -#define MREPEAT47( macro, data) MREPEAT46( macro, data) macro( 46, data) -#define MREPEAT48( macro, data) MREPEAT47( macro, data) macro( 47, data) -#define MREPEAT49( macro, data) MREPEAT48( macro, data) macro( 48, data) -#define MREPEAT50( macro, data) MREPEAT49( macro, data) macro( 49, data) -#define MREPEAT51( macro, data) MREPEAT50( macro, data) macro( 50, data) -#define MREPEAT52( macro, data) MREPEAT51( macro, data) macro( 51, data) -#define MREPEAT53( macro, data) MREPEAT52( macro, data) macro( 52, data) -#define MREPEAT54( macro, data) MREPEAT53( macro, data) macro( 53, data) -#define MREPEAT55( macro, data) MREPEAT54( macro, data) macro( 54, data) -#define MREPEAT56( macro, data) MREPEAT55( macro, data) macro( 55, data) -#define MREPEAT57( macro, data) MREPEAT56( macro, data) macro( 56, data) -#define MREPEAT58( macro, data) MREPEAT57( macro, data) macro( 57, data) -#define MREPEAT59( macro, data) MREPEAT58( macro, data) macro( 58, data) -#define MREPEAT60( macro, data) MREPEAT59( macro, data) macro( 59, data) -#define MREPEAT61( macro, data) MREPEAT60( macro, data) macro( 60, data) -#define MREPEAT62( macro, data) MREPEAT61( macro, data) macro( 61, data) -#define MREPEAT63( macro, data) MREPEAT62( macro, data) macro( 62, data) -#define MREPEAT64( macro, data) MREPEAT63( macro, data) macro( 63, data) -#define MREPEAT65( macro, data) MREPEAT64( macro, data) macro( 64, data) -#define MREPEAT66( macro, data) MREPEAT65( macro, data) macro( 65, data) -#define MREPEAT67( macro, data) MREPEAT66( macro, data) macro( 66, data) -#define MREPEAT68( macro, data) MREPEAT67( macro, data) macro( 67, data) -#define MREPEAT69( macro, data) MREPEAT68( macro, data) macro( 68, data) -#define MREPEAT70( macro, data) MREPEAT69( macro, data) macro( 69, data) -#define MREPEAT71( macro, data) MREPEAT70( macro, data) macro( 70, data) -#define MREPEAT72( macro, data) MREPEAT71( macro, data) macro( 71, data) -#define MREPEAT73( macro, data) MREPEAT72( macro, data) macro( 72, data) -#define MREPEAT74( macro, data) MREPEAT73( macro, data) macro( 73, data) -#define MREPEAT75( macro, data) MREPEAT74( macro, data) macro( 74, data) -#define MREPEAT76( macro, data) MREPEAT75( macro, data) macro( 75, data) -#define MREPEAT77( macro, data) MREPEAT76( macro, data) macro( 76, data) -#define MREPEAT78( macro, data) MREPEAT77( macro, data) macro( 77, data) -#define MREPEAT79( macro, data) MREPEAT78( macro, data) macro( 78, data) -#define MREPEAT80( macro, data) MREPEAT79( macro, data) macro( 79, data) -#define MREPEAT81( macro, data) MREPEAT80( macro, data) macro( 80, data) -#define MREPEAT82( macro, data) MREPEAT81( macro, data) macro( 81, data) -#define MREPEAT83( macro, data) MREPEAT82( macro, data) macro( 82, data) -#define MREPEAT84( macro, data) MREPEAT83( macro, data) macro( 83, data) -#define MREPEAT85( macro, data) MREPEAT84( macro, data) macro( 84, data) -#define MREPEAT86( macro, data) MREPEAT85( macro, data) macro( 85, data) -#define MREPEAT87( macro, data) MREPEAT86( macro, data) macro( 86, data) -#define MREPEAT88( macro, data) MREPEAT87( macro, data) macro( 87, data) -#define MREPEAT89( macro, data) MREPEAT88( macro, data) macro( 88, data) -#define MREPEAT90( macro, data) MREPEAT89( macro, data) macro( 89, data) -#define MREPEAT91( macro, data) MREPEAT90( macro, data) macro( 90, data) -#define MREPEAT92( macro, data) MREPEAT91( macro, data) macro( 91, data) -#define MREPEAT93( macro, data) MREPEAT92( macro, data) macro( 92, data) -#define MREPEAT94( macro, data) MREPEAT93( macro, data) macro( 93, data) -#define MREPEAT95( macro, data) MREPEAT94( macro, data) macro( 94, data) -#define MREPEAT96( macro, data) MREPEAT95( macro, data) macro( 95, data) -#define MREPEAT97( macro, data) MREPEAT96( macro, data) macro( 96, data) -#define MREPEAT98( macro, data) MREPEAT97( macro, data) macro( 97, data) -#define MREPEAT99( macro, data) MREPEAT98( macro, data) macro( 98, data) -#define MREPEAT100(macro, data) MREPEAT99( macro, data) macro( 99, data) -#define MREPEAT101(macro, data) MREPEAT100(macro, data) macro(100, data) -#define MREPEAT102(macro, data) MREPEAT101(macro, data) macro(101, data) -#define MREPEAT103(macro, data) MREPEAT102(macro, data) macro(102, data) -#define MREPEAT104(macro, data) MREPEAT103(macro, data) macro(103, data) -#define MREPEAT105(macro, data) MREPEAT104(macro, data) macro(104, data) -#define MREPEAT106(macro, data) MREPEAT105(macro, data) macro(105, data) -#define MREPEAT107(macro, data) MREPEAT106(macro, data) macro(106, data) -#define MREPEAT108(macro, data) MREPEAT107(macro, data) macro(107, data) -#define MREPEAT109(macro, data) MREPEAT108(macro, data) macro(108, data) -#define MREPEAT110(macro, data) MREPEAT109(macro, data) macro(109, data) -#define MREPEAT111(macro, data) MREPEAT110(macro, data) macro(110, data) -#define MREPEAT112(macro, data) MREPEAT111(macro, data) macro(111, data) -#define MREPEAT113(macro, data) MREPEAT112(macro, data) macro(112, data) -#define MREPEAT114(macro, data) MREPEAT113(macro, data) macro(113, data) -#define MREPEAT115(macro, data) MREPEAT114(macro, data) macro(114, data) -#define MREPEAT116(macro, data) MREPEAT115(macro, data) macro(115, data) -#define MREPEAT117(macro, data) MREPEAT116(macro, data) macro(116, data) -#define MREPEAT118(macro, data) MREPEAT117(macro, data) macro(117, data) -#define MREPEAT119(macro, data) MREPEAT118(macro, data) macro(118, data) -#define MREPEAT120(macro, data) MREPEAT119(macro, data) macro(119, data) -#define MREPEAT121(macro, data) MREPEAT120(macro, data) macro(120, data) -#define MREPEAT122(macro, data) MREPEAT121(macro, data) macro(121, data) -#define MREPEAT123(macro, data) MREPEAT122(macro, data) macro(122, data) -#define MREPEAT124(macro, data) MREPEAT123(macro, data) macro(123, data) -#define MREPEAT125(macro, data) MREPEAT124(macro, data) macro(124, data) -#define MREPEAT126(macro, data) MREPEAT125(macro, data) macro(125, data) -#define MREPEAT127(macro, data) MREPEAT126(macro, data) macro(126, data) -#define MREPEAT128(macro, data) MREPEAT127(macro, data) macro(127, data) -#define MREPEAT129(macro, data) MREPEAT128(macro, data) macro(128, data) -#define MREPEAT130(macro, data) MREPEAT129(macro, data) macro(129, data) -#define MREPEAT131(macro, data) MREPEAT130(macro, data) macro(130, data) -#define MREPEAT132(macro, data) MREPEAT131(macro, data) macro(131, data) -#define MREPEAT133(macro, data) MREPEAT132(macro, data) macro(132, data) -#define MREPEAT134(macro, data) MREPEAT133(macro, data) macro(133, data) -#define MREPEAT135(macro, data) MREPEAT134(macro, data) macro(134, data) -#define MREPEAT136(macro, data) MREPEAT135(macro, data) macro(135, data) -#define MREPEAT137(macro, data) MREPEAT136(macro, data) macro(136, data) -#define MREPEAT138(macro, data) MREPEAT137(macro, data) macro(137, data) -#define MREPEAT139(macro, data) MREPEAT138(macro, data) macro(138, data) -#define MREPEAT140(macro, data) MREPEAT139(macro, data) macro(139, data) -#define MREPEAT141(macro, data) MREPEAT140(macro, data) macro(140, data) -#define MREPEAT142(macro, data) MREPEAT141(macro, data) macro(141, data) -#define MREPEAT143(macro, data) MREPEAT142(macro, data) macro(142, data) -#define MREPEAT144(macro, data) MREPEAT143(macro, data) macro(143, data) -#define MREPEAT145(macro, data) MREPEAT144(macro, data) macro(144, data) -#define MREPEAT146(macro, data) MREPEAT145(macro, data) macro(145, data) -#define MREPEAT147(macro, data) MREPEAT146(macro, data) macro(146, data) -#define MREPEAT148(macro, data) MREPEAT147(macro, data) macro(147, data) -#define MREPEAT149(macro, data) MREPEAT148(macro, data) macro(148, data) -#define MREPEAT150(macro, data) MREPEAT149(macro, data) macro(149, data) -#define MREPEAT151(macro, data) MREPEAT150(macro, data) macro(150, data) -#define MREPEAT152(macro, data) MREPEAT151(macro, data) macro(151, data) -#define MREPEAT153(macro, data) MREPEAT152(macro, data) macro(152, data) -#define MREPEAT154(macro, data) MREPEAT153(macro, data) macro(153, data) -#define MREPEAT155(macro, data) MREPEAT154(macro, data) macro(154, data) -#define MREPEAT156(macro, data) MREPEAT155(macro, data) macro(155, data) -#define MREPEAT157(macro, data) MREPEAT156(macro, data) macro(156, data) -#define MREPEAT158(macro, data) MREPEAT157(macro, data) macro(157, data) -#define MREPEAT159(macro, data) MREPEAT158(macro, data) macro(158, data) -#define MREPEAT160(macro, data) MREPEAT159(macro, data) macro(159, data) -#define MREPEAT161(macro, data) MREPEAT160(macro, data) macro(160, data) -#define MREPEAT162(macro, data) MREPEAT161(macro, data) macro(161, data) -#define MREPEAT163(macro, data) MREPEAT162(macro, data) macro(162, data) -#define MREPEAT164(macro, data) MREPEAT163(macro, data) macro(163, data) -#define MREPEAT165(macro, data) MREPEAT164(macro, data) macro(164, data) -#define MREPEAT166(macro, data) MREPEAT165(macro, data) macro(165, data) -#define MREPEAT167(macro, data) MREPEAT166(macro, data) macro(166, data) -#define MREPEAT168(macro, data) MREPEAT167(macro, data) macro(167, data) -#define MREPEAT169(macro, data) MREPEAT168(macro, data) macro(168, data) -#define MREPEAT170(macro, data) MREPEAT169(macro, data) macro(169, data) -#define MREPEAT171(macro, data) MREPEAT170(macro, data) macro(170, data) -#define MREPEAT172(macro, data) MREPEAT171(macro, data) macro(171, data) -#define MREPEAT173(macro, data) MREPEAT172(macro, data) macro(172, data) -#define MREPEAT174(macro, data) MREPEAT173(macro, data) macro(173, data) -#define MREPEAT175(macro, data) MREPEAT174(macro, data) macro(174, data) -#define MREPEAT176(macro, data) MREPEAT175(macro, data) macro(175, data) -#define MREPEAT177(macro, data) MREPEAT176(macro, data) macro(176, data) -#define MREPEAT178(macro, data) MREPEAT177(macro, data) macro(177, data) -#define MREPEAT179(macro, data) MREPEAT178(macro, data) macro(178, data) -#define MREPEAT180(macro, data) MREPEAT179(macro, data) macro(179, data) -#define MREPEAT181(macro, data) MREPEAT180(macro, data) macro(180, data) -#define MREPEAT182(macro, data) MREPEAT181(macro, data) macro(181, data) -#define MREPEAT183(macro, data) MREPEAT182(macro, data) macro(182, data) -#define MREPEAT184(macro, data) MREPEAT183(macro, data) macro(183, data) -#define MREPEAT185(macro, data) MREPEAT184(macro, data) macro(184, data) -#define MREPEAT186(macro, data) MREPEAT185(macro, data) macro(185, data) -#define MREPEAT187(macro, data) MREPEAT186(macro, data) macro(186, data) -#define MREPEAT188(macro, data) MREPEAT187(macro, data) macro(187, data) -#define MREPEAT189(macro, data) MREPEAT188(macro, data) macro(188, data) -#define MREPEAT190(macro, data) MREPEAT189(macro, data) macro(189, data) -#define MREPEAT191(macro, data) MREPEAT190(macro, data) macro(190, data) -#define MREPEAT192(macro, data) MREPEAT191(macro, data) macro(191, data) -#define MREPEAT193(macro, data) MREPEAT192(macro, data) macro(192, data) -#define MREPEAT194(macro, data) MREPEAT193(macro, data) macro(193, data) -#define MREPEAT195(macro, data) MREPEAT194(macro, data) macro(194, data) -#define MREPEAT196(macro, data) MREPEAT195(macro, data) macro(195, data) -#define MREPEAT197(macro, data) MREPEAT196(macro, data) macro(196, data) -#define MREPEAT198(macro, data) MREPEAT197(macro, data) macro(197, data) -#define MREPEAT199(macro, data) MREPEAT198(macro, data) macro(198, data) -#define MREPEAT200(macro, data) MREPEAT199(macro, data) macro(199, data) -#define MREPEAT201(macro, data) MREPEAT200(macro, data) macro(200, data) -#define MREPEAT202(macro, data) MREPEAT201(macro, data) macro(201, data) -#define MREPEAT203(macro, data) MREPEAT202(macro, data) macro(202, data) -#define MREPEAT204(macro, data) MREPEAT203(macro, data) macro(203, data) -#define MREPEAT205(macro, data) MREPEAT204(macro, data) macro(204, data) -#define MREPEAT206(macro, data) MREPEAT205(macro, data) macro(205, data) -#define MREPEAT207(macro, data) MREPEAT206(macro, data) macro(206, data) -#define MREPEAT208(macro, data) MREPEAT207(macro, data) macro(207, data) -#define MREPEAT209(macro, data) MREPEAT208(macro, data) macro(208, data) -#define MREPEAT210(macro, data) MREPEAT209(macro, data) macro(209, data) -#define MREPEAT211(macro, data) MREPEAT210(macro, data) macro(210, data) -#define MREPEAT212(macro, data) MREPEAT211(macro, data) macro(211, data) -#define MREPEAT213(macro, data) MREPEAT212(macro, data) macro(212, data) -#define MREPEAT214(macro, data) MREPEAT213(macro, data) macro(213, data) -#define MREPEAT215(macro, data) MREPEAT214(macro, data) macro(214, data) -#define MREPEAT216(macro, data) MREPEAT215(macro, data) macro(215, data) -#define MREPEAT217(macro, data) MREPEAT216(macro, data) macro(216, data) -#define MREPEAT218(macro, data) MREPEAT217(macro, data) macro(217, data) -#define MREPEAT219(macro, data) MREPEAT218(macro, data) macro(218, data) -#define MREPEAT220(macro, data) MREPEAT219(macro, data) macro(219, data) -#define MREPEAT221(macro, data) MREPEAT220(macro, data) macro(220, data) -#define MREPEAT222(macro, data) MREPEAT221(macro, data) macro(221, data) -#define MREPEAT223(macro, data) MREPEAT222(macro, data) macro(222, data) -#define MREPEAT224(macro, data) MREPEAT223(macro, data) macro(223, data) -#define MREPEAT225(macro, data) MREPEAT224(macro, data) macro(224, data) -#define MREPEAT226(macro, data) MREPEAT225(macro, data) macro(225, data) -#define MREPEAT227(macro, data) MREPEAT226(macro, data) macro(226, data) -#define MREPEAT228(macro, data) MREPEAT227(macro, data) macro(227, data) -#define MREPEAT229(macro, data) MREPEAT228(macro, data) macro(228, data) -#define MREPEAT230(macro, data) MREPEAT229(macro, data) macro(229, data) -#define MREPEAT231(macro, data) MREPEAT230(macro, data) macro(230, data) -#define MREPEAT232(macro, data) MREPEAT231(macro, data) macro(231, data) -#define MREPEAT233(macro, data) MREPEAT232(macro, data) macro(232, data) -#define MREPEAT234(macro, data) MREPEAT233(macro, data) macro(233, data) -#define MREPEAT235(macro, data) MREPEAT234(macro, data) macro(234, data) -#define MREPEAT236(macro, data) MREPEAT235(macro, data) macro(235, data) -#define MREPEAT237(macro, data) MREPEAT236(macro, data) macro(236, data) -#define MREPEAT238(macro, data) MREPEAT237(macro, data) macro(237, data) -#define MREPEAT239(macro, data) MREPEAT238(macro, data) macro(238, data) -#define MREPEAT240(macro, data) MREPEAT239(macro, data) macro(239, data) -#define MREPEAT241(macro, data) MREPEAT240(macro, data) macro(240, data) -#define MREPEAT242(macro, data) MREPEAT241(macro, data) macro(241, data) -#define MREPEAT243(macro, data) MREPEAT242(macro, data) macro(242, data) -#define MREPEAT244(macro, data) MREPEAT243(macro, data) macro(243, data) -#define MREPEAT245(macro, data) MREPEAT244(macro, data) macro(244, data) -#define MREPEAT246(macro, data) MREPEAT245(macro, data) macro(245, data) -#define MREPEAT247(macro, data) MREPEAT246(macro, data) macro(246, data) -#define MREPEAT248(macro, data) MREPEAT247(macro, data) macro(247, data) -#define MREPEAT249(macro, data) MREPEAT248(macro, data) macro(248, data) -#define MREPEAT250(macro, data) MREPEAT249(macro, data) macro(249, data) -#define MREPEAT251(macro, data) MREPEAT250(macro, data) macro(250, data) -#define MREPEAT252(macro, data) MREPEAT251(macro, data) macro(251, data) -#define MREPEAT253(macro, data) MREPEAT252(macro, data) macro(252, data) -#define MREPEAT254(macro, data) MREPEAT253(macro, data) macro(253, data) -#define MREPEAT255(macro, data) MREPEAT254(macro, data) macro(254, data) -#define MREPEAT256(macro, data) MREPEAT255(macro, data) macro(255, data) - -/** - * \} - */ - -#endif // _MREPEAT_H_ diff --git a/DSTAT1/src/asf/xmega/utils/preprocessor/preprocessor.h b/DSTAT1/src/asf/xmega/utils/preprocessor/preprocessor.h deleted file mode 100644 index 5bb9340..0000000 --- a/DSTAT1/src/asf/xmega/utils/preprocessor/preprocessor.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * \file - * - * \brief Preprocessor utils. - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef _PREPROCESSOR_H_ -#define _PREPROCESSOR_H_ - -#include "tpaste.h" -#include "stringz.h" -#include "mrepeat.h" - - -#endif // _PREPROCESSOR_H_ diff --git a/DSTAT1/src/asf/xmega/utils/preprocessor/stringz.h b/DSTAT1/src/asf/xmega/utils/preprocessor/stringz.h deleted file mode 100644 index 824dfdd..0000000 --- a/DSTAT1/src/asf/xmega/utils/preprocessor/stringz.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * \file - * - * \brief Preprocessor stringizing utils. - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef _STRINGZ_H_ -#define _STRINGZ_H_ - -/** - * \defgroup group_xmega_utils_stringz Stringize - * - * \ingroup group_xmega_utils - * - * \{ - */ - -/*! \brief Stringize. - * - * Stringize a preprocessing token, this token being allowed to be \#defined. - * - * May be used only within macros with the token passed as an argument if the token is \#defined. - * - * For example, writing STRINGZ(PIN) within a macro \#defined by PIN_NAME(PIN) - * and invoked as PIN_NAME(PIN0) with PIN0 \#defined as A0 is equivalent to - * writing "A0". - */ -#define STRINGZ(x) #x - -/*! \brief Absolute stringize. - * - * Stringize a preprocessing token, this token being allowed to be \#defined. - * - * No restriction of use if the token is \#defined. - * - * For example, writing ASTRINGZ(PIN0) anywhere with PIN0 \#defined as A0 is - * equivalent to writing "A0". - */ -#define ASTRINGZ(x) STRINGZ(x) - -/** - * \} - */ - -#endif // _STRINGZ_H_ diff --git a/DSTAT1/src/asf/xmega/utils/preprocessor/tpaste.h b/DSTAT1/src/asf/xmega/utils/preprocessor/tpaste.h deleted file mode 100644 index d7a4e36..0000000 --- a/DSTAT1/src/asf/xmega/utils/preprocessor/tpaste.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * \file - * - * \brief Preprocessor token pasting utils. - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef _TPASTE_H_ -#define _TPASTE_H_ - -/** - * \defgroup group_xmega_utils_tpaste Token Paste - * - * \ingroup group_xmega_utils - * - * \{ - */ - -/*! \name Token Paste - * - * Paste N preprocessing tokens together, these tokens being allowed to be \#defined. - * - * May be used only within macros with the tokens passed as arguments if the tokens are \#defined. - * - * For example, writing TPASTE2(U, WIDTH) within a macro \#defined by - * UTYPE(WIDTH) and invoked as UTYPE(UL_WIDTH) with UL_WIDTH \#defined as 32 is - * equivalent to writing U32. - */ -//! @{ -#define TPASTE2( a, b) a##b -#define TPASTE3( a, b, c) a##b##c -#define TPASTE4( a, b, c, d) a##b##c##d -#define TPASTE5( a, b, c, d, e) a##b##c##d##e -#define TPASTE6( a, b, c, d, e, f) a##b##c##d##e##f -#define TPASTE7( a, b, c, d, e, f, g) a##b##c##d##e##f##g -#define TPASTE8( a, b, c, d, e, f, g, h) a##b##c##d##e##f##g##h -#define TPASTE9( a, b, c, d, e, f, g, h, i) a##b##c##d##e##f##g##h##i -#define TPASTE10(a, b, c, d, e, f, g, h, i, j) a##b##c##d##e##f##g##h##i##j -//! @} - -/*! \name Absolute Token Paste - * - * Paste N preprocessing tokens together, these tokens being allowed to be \#defined. - * - * No restriction of use if the tokens are \#defined. - * - * For example, writing ATPASTE2(U, UL_WIDTH) anywhere with UL_WIDTH \#defined - * as 32 is equivalent to writing U32. - */ -//! @{ -#define ATPASTE2( a, b) TPASTE2( a, b) -#define ATPASTE3( a, b, c) TPASTE3( a, b, c) -#define ATPASTE4( a, b, c, d) TPASTE4( a, b, c, d) -#define ATPASTE5( a, b, c, d, e) TPASTE5( a, b, c, d, e) -#define ATPASTE6( a, b, c, d, e, f) TPASTE6( a, b, c, d, e, f) -#define ATPASTE7( a, b, c, d, e, f, g) TPASTE7( a, b, c, d, e, f, g) -#define ATPASTE8( a, b, c, d, e, f, g, h) TPASTE8( a, b, c, d, e, f, g, h) -#define ATPASTE9( a, b, c, d, e, f, g, h, i) TPASTE9( a, b, c, d, e, f, g, h, i) -#define ATPASTE10(a, b, c, d, e, f, g, h, i, j) TPASTE10(a, b, c, d, e, f, g, h, i, j) -//! @} - -/** - * \} - */ - -#endif // _TPASTE_H_ diff --git a/DSTAT1/src/asf/xmega/utils/progmem.h b/DSTAT1/src/asf/xmega/utils/progmem.h deleted file mode 100644 index d8656cd..0000000 --- a/DSTAT1/src/asf/xmega/utils/progmem.h +++ /dev/null @@ -1,97 +0,0 @@ -/** - * \file - * - * \brief Program memory access - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef UTILS_PROGMEM_H -#define UTILS_PROGMEM_H - -/** - * \defgroup group_xmega_utils_progmem Program memory - * - * \ingroup group_xmega_utils - * - * \{ - */ - -/*! \name Program memory - * - * Macros for locating and accessing data in program memory. - * - * @{ - */ -#if defined(__GNUC__) || defined(__DOXYGEN__) -# include -# define PROGMEM_LOCATION(type, name, loc) \ - type name __attribute__((section (#loc))) -# define PROGMEM_DECLARE(type, name) const type name __attribute__((__progmem__)) -# define PROGMEM_STRING(x) PSTR(x) -# define PROGMEM_STRING_T PGM_P -# define PROGMEM_T -# define PROGMEM_PTR_T * -# define PROGMEM_BYTE_ARRAY_T uint8_t* -# define PROGMEM_WORD_ARRAY_T uint16_t* -# define PROGMEM_READ_BYTE(x) pgm_read_byte(x) -# define PROGMEM_READ_WORD(x) pgm_read_word(x) - -#elif defined(__ICCAVR__) -# include -# ifndef __HAS_ELPM__ -# define _MEMATTR_ASF __flash -# else /* __HAS_ELPM__ */ -# define _MEMATTR_ASF __hugeflash -# endif /* __HAS_ELPM__ */ -# define PROGMEM_LOCATION(type, name, loc) const _MEMATTR_ASF type name @ loc -# define PROGMEM_DECLARE(type, name) _MEMATTR_ASF type name -# define PROGMEM_STRING(x) ((_MEMATTR_ASF const char *)(x)) -# define PROGMEM_STRING_T char const _MEMATTR_ASF * -# define PROGMEM_T const _MEMATTR_ASF -# define PROGMEM_PTR_T const _MEMATTR_ASF * -# define PROGMEM_BYTE_ARRAY_T uint8_t const _MEMATTR_ASF * -# define PROGMEM_WORD_ARRAY_T uint16_t const _MEMATTR_ASF * -# define PROGMEM_READ_BYTE(x) *(x) -# define PROGMEM_READ_WORD(x) *(x) -#endif -//! @} - -/** - * \} - */ - -#endif /* UTILS_PROGMEM_H */ diff --git a/DSTAT1/src/asf/xmega/utils/status_codes.h b/DSTAT1/src/asf/xmega/utils/status_codes.h deleted file mode 100644 index 68873e5..0000000 --- a/DSTAT1/src/asf/xmega/utils/status_codes.h +++ /dev/null @@ -1,96 +0,0 @@ -/** - * \file - * - * \brief Status code definitions. - * - * This file defines various status codes returned by functions, - * indicating success or failure as well as what kind of failure. - * - * Copyright (c) 2009 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef STATUS_CODES_H_INCLUDED -#define STATUS_CODES_H_INCLUDED - -/** - * \defgroup group_xmega_utils_status_codes Status Codes - * - * \ingroup group_xmega_utils - * - * \{ - */ - -/** - * Status code that may be returned by shell commands and protocol - * implementations. - * - * \note Any change to these status codes and the corresponding - * message strings is strictly forbidden. New codes can be added, - * however, but make sure that any message string tables are updated - * at the same time. - */ -enum status_code { - STATUS_OK = 0, //!< Success - ERR_IO_ERROR = -1, //!< I/O error - ERR_FLUSHED = -2, //!< Request flushed from queue - ERR_TIMEOUT = -3, //!< Operation timed out - ERR_BAD_DATA = -4, //!< Data integrity check failed - ERR_PROTOCOL = -5, //!< Protocol error - ERR_UNSUPPORTED_DEV = -6, //!< Unsupported device - ERR_NO_MEMORY = -7, //!< Insufficient memory - ERR_INVALID_ARG = -8, //!< Invalid argument - ERR_BAD_ADDRESS = -9, //!< Bad address - ERR_BUSY = -10, //!< Resource is busy - ERR_BAD_FORMAT = -11, //!< Data format not recognized - - /** - * \brief Operation in progress - * - * This status code is for driver-internal use when an operation - * is currently being performed. - * - * \note Drivers should never return this status code to any - * callers. It is strictly for internal use. - */ - OPERATION_IN_PROGRESS = -128, -}; - -typedef enum status_code status_code_t; - -/** - * \} - */ - -#endif /* STATUS_CODES_H_INCLUDED */ diff --git a/DSTAT1/src/avr-stl/include/algorithm b/DSTAT1/src/avr-stl/include/algorithm deleted file mode 100644 index 1ba584f..0000000 --- a/DSTAT1/src/avr-stl/include/algorithm +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_ALGORITHM -#define __SGI_STL_ALGORITHM - -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_ALGORITHM */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/avr_config.h b/DSTAT1/src/avr-stl/include/avr_config.h deleted file mode 100644 index e5d8613..0000000 --- a/DSTAT1/src/avr-stl/include/avr_config.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * avr_config.h - * Contains values that you can change to customize the way that the library behaves - * - * Created on: 1 Jan 2011 - * Author: Andy Brown - */ - -#ifndef __C4BCBBDE_67BC_4bb4_A5E1_7745E49AF0B6 -#define __C4BCBBDE_67BC_4bb4_A5E1_7745E49AF0B6 - -#include - - -namespace avrstl { - -// default alloc-ahead for vectors. quoting from the SGI docs: -// -// "It is crucial that the amount of growth is proportional to the current capacity(), -// rather than a fixed constant: in the former case inserting a series of elements -// into a vector is a linear time operation, and in the latter case it is quadratic." -// -// If this advice pertains to you, then uncomment the first line and comment out the second. -// The default here in avr-land is to assume that memory is scarce. - -// template size_t AvrVectorAllocAhead(size_t oldSize_) { return 2*oldSize_; } - template size_t AvrVectorAllocAhead(size_t oldSize_) { return 20+oldSize_; } -// template<> size_t AvrVectorAllocAhead(size_t oldSize_) { return 20+oldSize_; } // sample specialization for char - -// minimum buffer size allocated ahead by a deque - - inline size_t AvrDequeBufferSize() { return 20; } - -// alloc-ahead additional memory increment for strings. The default SGI implementation will add -// the old size, doubling memory each time. We don't have memory to burn, so add 20 types each time - - template size_t AvrStringAllocAheadIncrement(size_t oldSize_) { return 20; } -} - - -#endif diff --git a/DSTAT1/src/avr-stl/include/basic_definitions b/DSTAT1/src/avr-stl/include/basic_definitions deleted file mode 100644 index 966cc7b..0000000 --- a/DSTAT1/src/avr-stl/include/basic_definitions +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - This file is part of the uClibc++ Library. - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __BASIC_DEFINITIONS -#define __BASIC_DEFINITIONS 1 - -#pragma GCC visibility push(default) - -//The following is used to support GCC symbol visibility patch - -#define _UCXXEXPORT __attribute__ ((visibility("default"))) -#define _UCXXLOCAL __attribute__ ((visibility("hidden"))) -#define __UCLIBCXX_NORETURN __attribute__ ((__noreturn__)) -#define __UCLIBCXX_TLS - - -//Testing purposes -#define __STRING_MAX_UNITS 65535 - -namespace std{ - typedef signed long int streamsize; -} - -#pragma GCC visibility pop - -#endif - - -#ifdef __DODEBUG__ - #define UCLIBCXX_DEBUG 1 -#else - #define UCLIBCXX_DEBUG 0 - -#endif diff --git a/DSTAT1/src/avr-stl/include/bitset b/DSTAT1/src/avr-stl/include/bitset deleted file mode 100644 index 130dc9e..0000000 --- a/DSTAT1/src/avr-stl/include/bitset +++ /dev/null @@ -1,1078 +0,0 @@ -/* - * Copyright (c) 1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_BITSET -#define __SGI_STL_BITSET - -// A bitset of size N has N % (sizeof(unsigned long) * CHAR_BIT) unused -// bits. (They are the high- order bits in the highest word.) It is -// a class invariant of class bitset<> that those unused bits are -// always zero. - -// Most of the actual code isn't contained in bitset<> itself, but in the -// base class _Base_bitset. The base class works with whole words, not with -// individual bits. This allows us to specialize _Base_bitset for the -// important special case where the bitset is only a single word. - -// The C++ standard does not define the precise semantics of operator[]. -// In this implementation the const version of operator[] is equivalent -// to test(), except that it does no range checking. The non-const version -// returns a reference to a bit, again without doing any range checking. - - -#include // for size_t -#include // for memset -#include - -#ifndef __AVR__ -#include // for invalid_argument, out_of_range, overflow_error -#endif - -#ifdef __STL_USE_NEW_IOSTREAMS -#include -#else -#include // for istream, ostream -#endif - -#define __BITS_PER_WORD (CHAR_BIT*sizeof(unsigned long)) -#define __BITSET_WORDS(__n) \ - ((__n) < 1 ? 1 : ((__n) + __BITS_PER_WORD - 1)/__BITS_PER_WORD) - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1209 -#endif - -// structure to aid in counting bits -template -struct _Bit_count { - static unsigned char _S_bit_count[256]; -}; - -// Mapping from 8 bit unsigned integers to the index of the first one -// bit: -template -struct _First_one { - static unsigned char _S_first_one[256]; -}; - -// -// Base class: general case. -// - -template -struct _Base_bitset { - typedef unsigned long _WordT; - - _WordT _M_w[_Nw]; // 0 is the least significant word. - - _Base_bitset( void ) { _M_do_reset(); } - _Base_bitset(unsigned long __val) { - _M_do_reset(); - _M_w[0] = __val; - } - - static size_t _S_whichword( size_t __pos ) - { return __pos / __BITS_PER_WORD; } - static size_t _S_whichbyte( size_t __pos ) - { return (__pos % __BITS_PER_WORD) / CHAR_BIT; } - static size_t _S_whichbit( size_t __pos ) - { return __pos % __BITS_PER_WORD; } - static _WordT _S_maskbit( size_t __pos ) - { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } - - _WordT& _M_getword(size_t __pos) { return _M_w[_S_whichword(__pos)]; } - _WordT _M_getword(size_t __pos) const { return _M_w[_S_whichword(__pos)]; } - - _WordT& _M_hiword() { return _M_w[_Nw - 1]; } - _WordT _M_hiword() const { return _M_w[_Nw - 1]; } - - void _M_do_and(const _Base_bitset<_Nw>& __x) { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _M_w[__i] &= __x._M_w[__i]; - } - } - - void _M_do_or(const _Base_bitset<_Nw>& __x) { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _M_w[__i] |= __x._M_w[__i]; - } - } - - void _M_do_xor(const _Base_bitset<_Nw>& __x) { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _M_w[__i] ^= __x._M_w[__i]; - } - } - - void _M_do_left_shift(size_t __shift); - void _M_do_right_shift(size_t __shift); - - void _M_do_flip() { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _M_w[__i] = ~_M_w[__i]; - } - } - - void _M_do_set() { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _M_w[__i] = ~static_cast<_WordT>(0); - } - } - - void _M_do_reset() { memset(_M_w, 0, _Nw * sizeof(_WordT)); } - - bool _M_is_equal(const _Base_bitset<_Nw>& __x) const { - for (size_t __i = 0; __i < _Nw; ++__i) { - if (_M_w[__i] != __x._M_w[__i]) - return false; - } - return true; - } - - bool _M_is_any() const { - for ( size_t __i = 0; __i < _Nw; __i++ ) { - if ( _M_w[__i] != static_cast<_WordT>(0) ) - return true; - } - return false; - } - - size_t _M_do_count() const { - size_t __result = 0; - const unsigned char* __byte_ptr = (const unsigned char*)_M_w; - const unsigned char* __end_ptr = (const unsigned char*)(_M_w+_Nw); - - while ( __byte_ptr < __end_ptr ) { - __result += _Bit_count::_S_bit_count[*__byte_ptr]; - __byte_ptr++; - } - return __result; - } - - unsigned long _M_do_to_ulong() const; - - // find first "on" bit - size_t _M_do_find_first(size_t __not_found) const; - - // find the next "on" bit that follows "prev" - size_t _M_do_find_next(size_t __prev, size_t __not_found) const; -}; - -// -// Definitions of non-inline functions from _Base_bitset. -// - -template -void _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) -{ - if (__shift != 0) { - const size_t __wshift = __shift / __BITS_PER_WORD; - const size_t __offset = __shift % __BITS_PER_WORD; - - if (__offset == 0) - for (size_t __n = _Nw - 1; __n >= __wshift; --__n) - _M_w[__n] = _M_w[__n - __wshift]; - - else { - const size_t __sub_offset = __BITS_PER_WORD - __offset; - for (size_t __n = _Nw - 1; __n > __wshift; --__n) - _M_w[__n] = (_M_w[__n - __wshift] << __offset) | - (_M_w[__n - __wshift - 1] >> __sub_offset); - _M_w[__wshift] = _M_w[0] << __offset; - } - - fill(_M_w + 0, _M_w + __wshift, static_cast<_WordT>(0)); - } -} - -template -void _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) -{ - if (__shift != 0) { - const size_t __wshift = __shift / __BITS_PER_WORD; - const size_t __offset = __shift % __BITS_PER_WORD; - const size_t __limit = _Nw - __wshift - 1; - - if (__offset == 0) - for (size_t __n = 0; __n <= __limit; ++__n) - _M_w[__n] = _M_w[__n + __wshift]; - - else { - const size_t __sub_offset = __BITS_PER_WORD - __offset; - for (size_t __n = 0; __n < __limit; ++__n) - _M_w[__n] = (_M_w[__n + __wshift] >> __offset) | - (_M_w[__n + __wshift + 1] << __sub_offset); - _M_w[__limit] = _M_w[_Nw-1] >> __offset; - } - - fill(_M_w + __limit + 1, _M_w + _Nw, static_cast<_WordT>(0)); - } -} - -template -unsigned long _Base_bitset<_Nw>::_M_do_to_ulong() const -{ - for (size_t __i = 1; __i < _Nw; ++__i) - if (_M_w[__i]) - __STL_THROW(overflow_error("bitset")); - - return _M_w[0]; -} - -template -size_t _Base_bitset<_Nw>::_M_do_find_first(size_t __not_found) const -{ - for ( size_t __i = 0; __i < _Nw; __i++ ) { - _WordT __thisword = _M_w[__i]; - if ( __thisword != static_cast<_WordT>(0) ) { - // find byte within word - for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) { - unsigned char __this_byte - = static_cast(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __i*__BITS_PER_WORD + __j*CHAR_BIT + - _First_one::_S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } - } - // not found, so return an indication of failure. - return __not_found; -} - -template -size_t -_Base_bitset<_Nw>::_M_do_find_next(size_t __prev, size_t __not_found) const -{ - // make bound inclusive - ++__prev; - - // check out of bounds - if ( __prev >= _Nw * __BITS_PER_WORD ) - return __not_found; - - // search first word - size_t __i = _S_whichword(__prev); - _WordT __thisword = _M_w[__i]; - - // mask off bits below bound - __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev); - - if ( __thisword != static_cast<_WordT>(0) ) { - // find byte within word - // get first byte into place - __thisword >>= _S_whichbyte(__prev) * CHAR_BIT; - for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); __j++ ) { - unsigned char __this_byte - = static_cast(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __i*__BITS_PER_WORD + __j*CHAR_BIT + - _First_one::_S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } - - // check subsequent words - __i++; - for ( ; __i < _Nw; __i++ ) { - _WordT __thisword = _M_w[__i]; - if ( __thisword != static_cast<_WordT>(0) ) { - // find byte within word - for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) { - unsigned char __this_byte - = static_cast(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __i*__BITS_PER_WORD + __j*CHAR_BIT + - _First_one::_S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } - } - - // not found, so return an indication of failure. - return __not_found; -} // end _M_do_find_next - - -// ------------------------------------------------------------ - -// -// Base class: specialization for a single word. -// - -__STL_TEMPLATE_NULL struct _Base_bitset<1> { - typedef unsigned long _WordT; - _WordT _M_w; - - _Base_bitset( void ) : _M_w(0) {} - _Base_bitset(unsigned long __val) : _M_w(__val) {} - - static size_t _S_whichword( size_t __pos ) - { return __pos / __BITS_PER_WORD; } - static size_t _S_whichbyte( size_t __pos ) - { return (__pos % __BITS_PER_WORD) / CHAR_BIT; } - static size_t _S_whichbit( size_t __pos ) - { return __pos % __BITS_PER_WORD; } - static _WordT _S_maskbit( size_t __pos ) - { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } - - _WordT& _M_getword(size_t) { return _M_w; } - _WordT _M_getword(size_t) const { return _M_w; } - - _WordT& _M_hiword() { return _M_w; } - _WordT _M_hiword() const { return _M_w; } - - void _M_do_and(const _Base_bitset<1>& __x) { _M_w &= __x._M_w; } - void _M_do_or(const _Base_bitset<1>& __x) { _M_w |= __x._M_w; } - void _M_do_xor(const _Base_bitset<1>& __x) { _M_w ^= __x._M_w; } - void _M_do_left_shift(size_t __shift) { _M_w <<= __shift; } - void _M_do_right_shift(size_t __shift) { _M_w >>= __shift; } - void _M_do_flip() { _M_w = ~_M_w; } - void _M_do_set() { _M_w = ~static_cast<_WordT>(0); } - void _M_do_reset() { _M_w = 0; } - - bool _M_is_equal(const _Base_bitset<1>& __x) const - { return _M_w == __x._M_w; } - bool _M_is_any() const - { return _M_w != 0; } - - size_t _M_do_count() const { - size_t __result = 0; - const unsigned char* __byte_ptr = (const unsigned char*)&_M_w; - const unsigned char* __end_ptr - = ((const unsigned char*)&_M_w)+sizeof(_M_w); - while ( __byte_ptr < __end_ptr ) { - __result += _Bit_count::_S_bit_count[*__byte_ptr]; - __byte_ptr++; - } - return __result; - } - - unsigned long _M_do_to_ulong() const { return _M_w; } - - size_t _M_do_find_first(size_t __not_found) const; - - // find the next "on" bit that follows "prev" - size_t _M_do_find_next(size_t __prev, size_t __not_found) const; - -}; - -// -// Definitions of non-inline functions from the single-word version of -// _Base_bitset. -// - -size_t _Base_bitset<1>::_M_do_find_first(size_t __not_found) const -{ - _WordT __thisword = _M_w; - - if ( __thisword != static_cast<_WordT>(0) ) { - // find byte within word - for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) { - unsigned char __this_byte - = static_cast(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __j*CHAR_BIT + _First_one::_S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } - // not found, so return a value that indicates failure. - return __not_found; -} - -size_t _Base_bitset<1>::_M_do_find_next(size_t __prev, size_t __not_found ) const -{ - // make bound inclusive - ++__prev; - - // check out of bounds - if ( __prev >= __BITS_PER_WORD ) - return __not_found; - - // search first (and only) word - _WordT __thisword = _M_w; - - // mask off bits below bound - __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev); - - if ( __thisword != static_cast<_WordT>(0) ) { - // find byte within word - // get first byte into place - __thisword >>= _S_whichbyte(__prev) * CHAR_BIT; - for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); __j++ ) { - unsigned char __this_byte - = static_cast(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __j*CHAR_BIT + _First_one::_S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } - - // not found, so return a value that indicates failure. - return __not_found; -} // end _M_do_find_next - - -// ------------------------------------------------------------ -// Helper class to zero out the unused high-order bits in the highest word. - -template struct _Sanitize { - static void _M_do_sanitize(unsigned long& __val) - { __val &= ~((~static_cast(0)) << _Extrabits); } -}; - -__STL_TEMPLATE_NULL struct _Sanitize<0> { - static void _M_do_sanitize(unsigned long) {} -}; - - - -// ------------------------------------------------------------ -// Class bitset. -// _Nb may be any nonzero number of type size_t. - -template -class bitset : private _Base_bitset<__BITSET_WORDS(_Nb)> -{ -private: - typedef _Base_bitset<__BITSET_WORDS(_Nb)> _Base; - typedef unsigned long _WordT; - -private: - void _M_do_sanitize() { - _Sanitize<_Nb%__BITS_PER_WORD>::_M_do_sanitize(this->_M_hiword()); - } - -public: - - // bit reference: - class reference; - friend class reference; - - class reference { - friend class bitset; - - _WordT *_M_wp; - size_t _M_bpos; - - // left undefined - reference(); - - public: - reference( bitset& __b, size_t __pos ) { - _M_wp = &__b._M_getword(__pos); - _M_bpos = _Base::_S_whichbit(__pos); - } - - ~reference() {} - - // for b[i] = __x; - reference& operator=(bool __x) { - if ( __x ) - *_M_wp |= _Base::_S_maskbit(_M_bpos); - else - *_M_wp &= ~_Base::_S_maskbit(_M_bpos); - - return *this; - } - - // for b[i] = b[__j]; - reference& operator=(const reference& __j) { - if ( (*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos)) ) - *_M_wp |= _Base::_S_maskbit(_M_bpos); - else - *_M_wp &= ~_Base::_S_maskbit(_M_bpos); - - return *this; - } - - // flips the bit - bool operator~() const - { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; } - - // for __x = b[i]; - operator bool() const - { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; } - - // for b[i].flip(); - reference& flip() { - *_M_wp ^= _Base::_S_maskbit(_M_bpos); - return *this; - } - }; - - // 23.3.5.1 constructors: - bitset() {} - bitset(unsigned long __val) : _Base_bitset<__BITSET_WORDS(_Nb)>(__val) - { _M_do_sanitize(); } - -#ifdef __STL_MEMBER_TEMPLATES - template - explicit bitset(const basic_string<_CharT, _Traits, _Alloc>& __s, - size_t __pos = 0) - : _Base() - { - if (__pos > __s.size()) - __STL_THROW(out_of_range("bitset")); - _M_copy_from_string(__s, __pos, - basic_string<_CharT, _Traits, _Alloc>::npos); - } - template - bitset(const basic_string<_CharT, _Traits, _Alloc>& __s, - size_t __pos, - size_t __n) - : _Base() - { - if (__pos > __s.size()) - __STL_THROW(out_of_range("bitset")); - _M_copy_from_string(__s, __pos, __n); - } -#else /* __STL_MEMBER_TEMPLATES */ - explicit bitset(const basic_string& __s, - size_t __pos = 0, - size_t __n = basic_string::npos) - : _Base() - { - if (__pos > __s.size()) - __STL_THROW(out_of_range("bitset")); - _M_copy_from_string(__s, __pos, __n); - } -#endif /* __STL_MEMBER_TEMPLATES */ - - // 23.3.5.2 bitset operations: - bitset<_Nb>& operator&=(const bitset<_Nb>& __rhs) { - this->_M_do_and(__rhs); - return *this; - } - - bitset<_Nb>& operator|=(const bitset<_Nb>& __rhs) { - this->_M_do_or(__rhs); - return *this; - } - - bitset<_Nb>& operator^=(const bitset<_Nb>& __rhs) { - this->_M_do_xor(__rhs); - return *this; - } - - bitset<_Nb>& operator<<=(size_t __pos) { - this->_M_do_left_shift(__pos); - this->_M_do_sanitize(); - return *this; - } - - bitset<_Nb>& operator>>=(size_t __pos) { - this->_M_do_right_shift(__pos); - this->_M_do_sanitize(); - return *this; - } - - // - // Extension: - // Versions of single-bit set, reset, flip, test with no range checking. - // - - bitset<_Nb>& _Unchecked_set(size_t __pos) { - this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); - return *this; - } - - bitset<_Nb>& _Unchecked_set(size_t __pos, int __val) { - if (__val) - this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); - else - this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos); - - return *this; - } - - bitset<_Nb>& _Unchecked_reset(size_t __pos) { - this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos); - return *this; - } - - bitset<_Nb>& _Unchecked_flip(size_t __pos) { - this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos); - return *this; - } - - bool _Unchecked_test(size_t __pos) const { - return (this->_M_getword(__pos) & _Base::_S_maskbit(__pos)) - != static_cast<_WordT>(0); - } - - // Set, reset, and flip. - - bitset<_Nb>& set() { - this->_M_do_set(); - this->_M_do_sanitize(); - return *this; - } - - bitset<_Nb>& set(size_t __pos) { - if (__pos >= _Nb) - __STL_THROW(out_of_range("bitset")); - - return _Unchecked_set(__pos); - } - - bitset<_Nb>& set(size_t __pos, int __val) { - if (__pos >= _Nb) - __STL_THROW(out_of_range("bitset")); - - return _Unchecked_set(__pos, __val); - } - - bitset<_Nb>& reset() { - this->_M_do_reset(); - return *this; - } - - bitset<_Nb>& reset(size_t __pos) { - if (__pos >= _Nb) - __STL_THROW(out_of_range("bitset")); - - return _Unchecked_reset(__pos); - } - - bitset<_Nb>& flip() { - this->_M_do_flip(); - this->_M_do_sanitize(); - return *this; - } - - bitset<_Nb>& flip(size_t __pos) { - if (__pos >= _Nb) - __STL_THROW(out_of_range("bitset")); - - return _Unchecked_flip(__pos); - } - - bitset<_Nb> operator~() const { - return bitset<_Nb>(*this).flip(); - } - - // element access: - //for b[i]; - reference operator[](size_t __pos) { return reference(*this,__pos); } - bool operator[](size_t __pos) const { return _Unchecked_test(__pos); } - - unsigned long to_ulong() const { return this->_M_do_to_ulong(); } - -#if defined(__STL_MEMBER_TEMPLATES) && \ - defined(__STL_EXPLICIT_FUNCTION_TMPL_ARGS) - template - basic_string<_CharT, _Traits, _Alloc> to_string() const { - basic_string<_CharT, _Traits, _Alloc> __result; - _M_copy_to_string(__result); - return __result; - } -#endif /* member templates and explicit function template args */ - - // Helper functions for string operations. -#ifdef __STL_MEMBER_TEMPLATES - template - void _M_copy_from_string(const basic_string<_CharT,_Traits,_Alloc>& __s, - size_t, - size_t); - - template - void _M_copy_to_string(basic_string<_CharT,_Traits,_Alloc>&) const; -#else /* __STL_MEMBER_TEMPLATES */ - void _M_copy_from_string(const basic_string&, size_t, size_t); - void _M_copy_to_string(basic_string&) const; -#endif /* __STL_MEMBER_TEMPLATES */ - - size_t count() const { return this->_M_do_count(); } - - size_t size() const { return _Nb; } - - bool operator==(const bitset<_Nb>& __rhs) const { - return this->_M_is_equal(__rhs); - } - bool operator!=(const bitset<_Nb>& __rhs) const { - return !this->_M_is_equal(__rhs); - } - - bool test(size_t __pos) const { - if (__pos > _Nb) - __STL_THROW(out_of_range("bitset")); - - return _Unchecked_test(__pos); - } - - bool any() const { return this->_M_is_any(); } - bool none() const { return !this->_M_is_any(); } - - bitset<_Nb> operator<<(size_t __pos) const - { return bitset<_Nb>(*this) <<= __pos; } - bitset<_Nb> operator>>(size_t __pos) const - { return bitset<_Nb>(*this) >>= __pos; } - - // - // EXTENSIONS: bit-find operations. These operations are - // experimental, and are subject to change or removal in future - // versions. - // - - // find the index of the first "on" bit - size_t _Find_first() const - { return this->_M_do_find_first(_Nb); } - - // find the index of the next "on" bit after prev - size_t _Find_next( size_t __prev ) const - { return this->_M_do_find_next(__prev, _Nb); } - -}; - -// -// Definitions of non-inline member functions. -// - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -void bitset<_Nb> - ::_M_copy_from_string(const basic_string<_CharT,_Traits,_Alloc>& __s, - size_t __pos, - size_t __n) -{ - reset(); - const size_t __nbits = min(_Nb, min(__n, __s.size() - __pos)); - for (size_t __i = 0; __i < __nbits; ++__i) { - switch(__s[__pos + __nbits - __i - 1]) { - case '0': - break; - case '1': - set(__i); - break; - default: - __STL_THROW(invalid_argument("bitset")); - } - } -} - -template -template -void bitset<_Nb> - ::_M_copy_to_string(basic_string<_CharT, _Traits, _Alloc>& __s) const -{ - __s.assign(_Nb, '0'); - - for (size_t __i = 0; __i < _Nb; ++__i) - if (_Unchecked_test(__i)) - __s[_Nb - 1 - __i] = '1'; -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -void bitset<_Nb>::_M_copy_from_string(const basic_string& __s, - size_t __pos, size_t __n) -{ - reset(); - size_t __tmp = _Nb; - const size_t __nbits = min(__tmp, min(__n, __s.size() - __pos)); - for (size_t __i = 0; __i < __nbits; ++__i) { - switch(__s[__pos + __nbits - __i - 1]) { - case '0': - break; - case '1': - set(__i); - break; - default: - __STL_THROW(invalid_argument("bitset")); - } - } -} - -template -void bitset<_Nb>::_M_copy_to_string(basic_string& __s) const -{ - __s.assign(_Nb, '0'); - - for (size_t __i = 0; __i < _Nb; ++__i) - if (_Unchecked_test(__i)) - __s[_Nb - 1 - __i] = '1'; -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -// ------------------------------------------------------------ - -// -// 23.3.5.3 bitset operations: -// - -template -inline bitset<_Nb> operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) { - bitset<_Nb> __result(__x); - __result &= __y; - return __result; -} - - -template -inline bitset<_Nb> operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) { - bitset<_Nb> __result(__x); - __result |= __y; - return __result; -} - -template -inline bitset<_Nb> operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) { - bitset<_Nb> __result(__x); - __result ^= __y; - return __result; -} - -#ifdef __STL_USE_NEW_IOSTREAMS - -template -basic_istream<_CharT, _Traits>& -operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) -{ - basic_string<_CharT, _Traits> __tmp; - __tmp.reserve(_Nb); - - // Skip whitespace - typename basic_istream<_CharT, _Traits>::sentry __sentry(__is); - if (__sentry) { - basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf(); - for (size_t __i = 0; __i < _Nb; ++__i) { - static typename _Traits::int_type __eof = _Traits::eof(); - - typename _Traits::int_type __c1 = __buf->sbumpc(); - if (_Traits::eq_int_type(__c1, __eof)) { - __is.setstate(ios_base::eofbit); - break; - } - else { - char __c2 = _Traits::to_char_type(__c1); - char __c = __is.narrow(__c2, '*'); - - if (__c == '0' || __c == '1') - __tmp.push_back(__c); - else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) { - __is.setstate(ios_base::failbit); - break; - } - } - } - - if (__tmp.empty()) - __is.setstate(ios_base::failbit); - else - __x._M_copy_from_string(__tmp, static_cast(0), _Nb); - } - - return __is; -} - -template -basic_ostream<_CharT, _Traits>& -operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x) -{ - basic_string<_CharT, _Traits> __tmp; - __x._M_copy_to_string(__tmp); - return __os << __tmp; -} - -#else /* __STL_USE_NEW_IOSTREAMS */ - -template -istream& operator>>(istream& __is, bitset<_Nb>& __x) { - string __tmp; - __tmp.reserve(_Nb); - - if (__is.flags() & ios::skipws) { - char __c; - do - __is.get(__c); - while (__is && isspace(__c)); - if (__is) - __is.putback(__c); - } - - for (size_t __i = 0; __i < _Nb; ++__i) { - char __c; - __is.get(__c); - - if (!__is) - break; - else if (__c != '0' && __c != '1') { - __is.putback(__c); - break; - } - else - __tmp.push_back(__c); - } - - if (__tmp.empty()) - __is.clear(__is.rdstate() | ios::failbit); - else - __x._M_copy_from_string(__tmp, static_cast(0), _Nb); - - return __is; -} - -template -ostream& operator<<(ostream& __os, const bitset<_Nb>& __x) { - string __tmp; - __x._M_copy_to_string(__tmp); - return __os << __tmp; -} - -#endif /* __STL_USE_NEW_IOSTREAMS */ - - -// ------------------------------------------------------------ -// Lookup tables for find and count operations. - -template -unsigned char _Bit_count<__dummy>::_S_bit_count[] = { - 0, /* 0 */ 1, /* 1 */ 1, /* 2 */ 2, /* 3 */ 1, /* 4 */ - 2, /* 5 */ 2, /* 6 */ 3, /* 7 */ 1, /* 8 */ 2, /* 9 */ - 2, /* 10 */ 3, /* 11 */ 2, /* 12 */ 3, /* 13 */ 3, /* 14 */ - 4, /* 15 */ 1, /* 16 */ 2, /* 17 */ 2, /* 18 */ 3, /* 19 */ - 2, /* 20 */ 3, /* 21 */ 3, /* 22 */ 4, /* 23 */ 2, /* 24 */ - 3, /* 25 */ 3, /* 26 */ 4, /* 27 */ 3, /* 28 */ 4, /* 29 */ - 4, /* 30 */ 5, /* 31 */ 1, /* 32 */ 2, /* 33 */ 2, /* 34 */ - 3, /* 35 */ 2, /* 36 */ 3, /* 37 */ 3, /* 38 */ 4, /* 39 */ - 2, /* 40 */ 3, /* 41 */ 3, /* 42 */ 4, /* 43 */ 3, /* 44 */ - 4, /* 45 */ 4, /* 46 */ 5, /* 47 */ 2, /* 48 */ 3, /* 49 */ - 3, /* 50 */ 4, /* 51 */ 3, /* 52 */ 4, /* 53 */ 4, /* 54 */ - 5, /* 55 */ 3, /* 56 */ 4, /* 57 */ 4, /* 58 */ 5, /* 59 */ - 4, /* 60 */ 5, /* 61 */ 5, /* 62 */ 6, /* 63 */ 1, /* 64 */ - 2, /* 65 */ 2, /* 66 */ 3, /* 67 */ 2, /* 68 */ 3, /* 69 */ - 3, /* 70 */ 4, /* 71 */ 2, /* 72 */ 3, /* 73 */ 3, /* 74 */ - 4, /* 75 */ 3, /* 76 */ 4, /* 77 */ 4, /* 78 */ 5, /* 79 */ - 2, /* 80 */ 3, /* 81 */ 3, /* 82 */ 4, /* 83 */ 3, /* 84 */ - 4, /* 85 */ 4, /* 86 */ 5, /* 87 */ 3, /* 88 */ 4, /* 89 */ - 4, /* 90 */ 5, /* 91 */ 4, /* 92 */ 5, /* 93 */ 5, /* 94 */ - 6, /* 95 */ 2, /* 96 */ 3, /* 97 */ 3, /* 98 */ 4, /* 99 */ - 3, /* 100 */ 4, /* 101 */ 4, /* 102 */ 5, /* 103 */ 3, /* 104 */ - 4, /* 105 */ 4, /* 106 */ 5, /* 107 */ 4, /* 108 */ 5, /* 109 */ - 5, /* 110 */ 6, /* 111 */ 3, /* 112 */ 4, /* 113 */ 4, /* 114 */ - 5, /* 115 */ 4, /* 116 */ 5, /* 117 */ 5, /* 118 */ 6, /* 119 */ - 4, /* 120 */ 5, /* 121 */ 5, /* 122 */ 6, /* 123 */ 5, /* 124 */ - 6, /* 125 */ 6, /* 126 */ 7, /* 127 */ 1, /* 128 */ 2, /* 129 */ - 2, /* 130 */ 3, /* 131 */ 2, /* 132 */ 3, /* 133 */ 3, /* 134 */ - 4, /* 135 */ 2, /* 136 */ 3, /* 137 */ 3, /* 138 */ 4, /* 139 */ - 3, /* 140 */ 4, /* 141 */ 4, /* 142 */ 5, /* 143 */ 2, /* 144 */ - 3, /* 145 */ 3, /* 146 */ 4, /* 147 */ 3, /* 148 */ 4, /* 149 */ - 4, /* 150 */ 5, /* 151 */ 3, /* 152 */ 4, /* 153 */ 4, /* 154 */ - 5, /* 155 */ 4, /* 156 */ 5, /* 157 */ 5, /* 158 */ 6, /* 159 */ - 2, /* 160 */ 3, /* 161 */ 3, /* 162 */ 4, /* 163 */ 3, /* 164 */ - 4, /* 165 */ 4, /* 166 */ 5, /* 167 */ 3, /* 168 */ 4, /* 169 */ - 4, /* 170 */ 5, /* 171 */ 4, /* 172 */ 5, /* 173 */ 5, /* 174 */ - 6, /* 175 */ 3, /* 176 */ 4, /* 177 */ 4, /* 178 */ 5, /* 179 */ - 4, /* 180 */ 5, /* 181 */ 5, /* 182 */ 6, /* 183 */ 4, /* 184 */ - 5, /* 185 */ 5, /* 186 */ 6, /* 187 */ 5, /* 188 */ 6, /* 189 */ - 6, /* 190 */ 7, /* 191 */ 2, /* 192 */ 3, /* 193 */ 3, /* 194 */ - 4, /* 195 */ 3, /* 196 */ 4, /* 197 */ 4, /* 198 */ 5, /* 199 */ - 3, /* 200 */ 4, /* 201 */ 4, /* 202 */ 5, /* 203 */ 4, /* 204 */ - 5, /* 205 */ 5, /* 206 */ 6, /* 207 */ 3, /* 208 */ 4, /* 209 */ - 4, /* 210 */ 5, /* 211 */ 4, /* 212 */ 5, /* 213 */ 5, /* 214 */ - 6, /* 215 */ 4, /* 216 */ 5, /* 217 */ 5, /* 218 */ 6, /* 219 */ - 5, /* 220 */ 6, /* 221 */ 6, /* 222 */ 7, /* 223 */ 3, /* 224 */ - 4, /* 225 */ 4, /* 226 */ 5, /* 227 */ 4, /* 228 */ 5, /* 229 */ - 5, /* 230 */ 6, /* 231 */ 4, /* 232 */ 5, /* 233 */ 5, /* 234 */ - 6, /* 235 */ 5, /* 236 */ 6, /* 237 */ 6, /* 238 */ 7, /* 239 */ - 4, /* 240 */ 5, /* 241 */ 5, /* 242 */ 6, /* 243 */ 5, /* 244 */ - 6, /* 245 */ 6, /* 246 */ 7, /* 247 */ 5, /* 248 */ 6, /* 249 */ - 6, /* 250 */ 7, /* 251 */ 6, /* 252 */ 7, /* 253 */ 7, /* 254 */ - 8 /* 255 */ -}; // end _Bit_count - -template -unsigned char _First_one<__dummy>::_S_first_one[] = { - 0, /* 0 */ 0, /* 1 */ 1, /* 2 */ 0, /* 3 */ 2, /* 4 */ - 0, /* 5 */ 1, /* 6 */ 0, /* 7 */ 3, /* 8 */ 0, /* 9 */ - 1, /* 10 */ 0, /* 11 */ 2, /* 12 */ 0, /* 13 */ 1, /* 14 */ - 0, /* 15 */ 4, /* 16 */ 0, /* 17 */ 1, /* 18 */ 0, /* 19 */ - 2, /* 20 */ 0, /* 21 */ 1, /* 22 */ 0, /* 23 */ 3, /* 24 */ - 0, /* 25 */ 1, /* 26 */ 0, /* 27 */ 2, /* 28 */ 0, /* 29 */ - 1, /* 30 */ 0, /* 31 */ 5, /* 32 */ 0, /* 33 */ 1, /* 34 */ - 0, /* 35 */ 2, /* 36 */ 0, /* 37 */ 1, /* 38 */ 0, /* 39 */ - 3, /* 40 */ 0, /* 41 */ 1, /* 42 */ 0, /* 43 */ 2, /* 44 */ - 0, /* 45 */ 1, /* 46 */ 0, /* 47 */ 4, /* 48 */ 0, /* 49 */ - 1, /* 50 */ 0, /* 51 */ 2, /* 52 */ 0, /* 53 */ 1, /* 54 */ - 0, /* 55 */ 3, /* 56 */ 0, /* 57 */ 1, /* 58 */ 0, /* 59 */ - 2, /* 60 */ 0, /* 61 */ 1, /* 62 */ 0, /* 63 */ 6, /* 64 */ - 0, /* 65 */ 1, /* 66 */ 0, /* 67 */ 2, /* 68 */ 0, /* 69 */ - 1, /* 70 */ 0, /* 71 */ 3, /* 72 */ 0, /* 73 */ 1, /* 74 */ - 0, /* 75 */ 2, /* 76 */ 0, /* 77 */ 1, /* 78 */ 0, /* 79 */ - 4, /* 80 */ 0, /* 81 */ 1, /* 82 */ 0, /* 83 */ 2, /* 84 */ - 0, /* 85 */ 1, /* 86 */ 0, /* 87 */ 3, /* 88 */ 0, /* 89 */ - 1, /* 90 */ 0, /* 91 */ 2, /* 92 */ 0, /* 93 */ 1, /* 94 */ - 0, /* 95 */ 5, /* 96 */ 0, /* 97 */ 1, /* 98 */ 0, /* 99 */ - 2, /* 100 */ 0, /* 101 */ 1, /* 102 */ 0, /* 103 */ 3, /* 104 */ - 0, /* 105 */ 1, /* 106 */ 0, /* 107 */ 2, /* 108 */ 0, /* 109 */ - 1, /* 110 */ 0, /* 111 */ 4, /* 112 */ 0, /* 113 */ 1, /* 114 */ - 0, /* 115 */ 2, /* 116 */ 0, /* 117 */ 1, /* 118 */ 0, /* 119 */ - 3, /* 120 */ 0, /* 121 */ 1, /* 122 */ 0, /* 123 */ 2, /* 124 */ - 0, /* 125 */ 1, /* 126 */ 0, /* 127 */ 7, /* 128 */ 0, /* 129 */ - 1, /* 130 */ 0, /* 131 */ 2, /* 132 */ 0, /* 133 */ 1, /* 134 */ - 0, /* 135 */ 3, /* 136 */ 0, /* 137 */ 1, /* 138 */ 0, /* 139 */ - 2, /* 140 */ 0, /* 141 */ 1, /* 142 */ 0, /* 143 */ 4, /* 144 */ - 0, /* 145 */ 1, /* 146 */ 0, /* 147 */ 2, /* 148 */ 0, /* 149 */ - 1, /* 150 */ 0, /* 151 */ 3, /* 152 */ 0, /* 153 */ 1, /* 154 */ - 0, /* 155 */ 2, /* 156 */ 0, /* 157 */ 1, /* 158 */ 0, /* 159 */ - 5, /* 160 */ 0, /* 161 */ 1, /* 162 */ 0, /* 163 */ 2, /* 164 */ - 0, /* 165 */ 1, /* 166 */ 0, /* 167 */ 3, /* 168 */ 0, /* 169 */ - 1, /* 170 */ 0, /* 171 */ 2, /* 172 */ 0, /* 173 */ 1, /* 174 */ - 0, /* 175 */ 4, /* 176 */ 0, /* 177 */ 1, /* 178 */ 0, /* 179 */ - 2, /* 180 */ 0, /* 181 */ 1, /* 182 */ 0, /* 183 */ 3, /* 184 */ - 0, /* 185 */ 1, /* 186 */ 0, /* 187 */ 2, /* 188 */ 0, /* 189 */ - 1, /* 190 */ 0, /* 191 */ 6, /* 192 */ 0, /* 193 */ 1, /* 194 */ - 0, /* 195 */ 2, /* 196 */ 0, /* 197 */ 1, /* 198 */ 0, /* 199 */ - 3, /* 200 */ 0, /* 201 */ 1, /* 202 */ 0, /* 203 */ 2, /* 204 */ - 0, /* 205 */ 1, /* 206 */ 0, /* 207 */ 4, /* 208 */ 0, /* 209 */ - 1, /* 210 */ 0, /* 211 */ 2, /* 212 */ 0, /* 213 */ 1, /* 214 */ - 0, /* 215 */ 3, /* 216 */ 0, /* 217 */ 1, /* 218 */ 0, /* 219 */ - 2, /* 220 */ 0, /* 221 */ 1, /* 222 */ 0, /* 223 */ 5, /* 224 */ - 0, /* 225 */ 1, /* 226 */ 0, /* 227 */ 2, /* 228 */ 0, /* 229 */ - 1, /* 230 */ 0, /* 231 */ 3, /* 232 */ 0, /* 233 */ 1, /* 234 */ - 0, /* 235 */ 2, /* 236 */ 0, /* 237 */ 1, /* 238 */ 0, /* 239 */ - 4, /* 240 */ 0, /* 241 */ 1, /* 242 */ 0, /* 243 */ 2, /* 244 */ - 0, /* 245 */ 1, /* 246 */ 0, /* 247 */ 3, /* 248 */ 0, /* 249 */ - 1, /* 250 */ 0, /* 251 */ 2, /* 252 */ 0, /* 253 */ 1, /* 254 */ - 0, /* 255 */ -}; // end _First_one - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1209 -#endif - -__STL_END_NAMESPACE - - -#undef __BITS_PER_WORD -#undef __BITSET_WORDS - -#endif /* __SGI_STL_BITSET */ - - -// Local Variables: -// mode:C++ -// End: - diff --git a/DSTAT1/src/avr-stl/include/cctype b/DSTAT1/src/avr-stl/include/cctype deleted file mode 100644 index ef12b1f..0000000 --- a/DSTAT1/src/avr-stl/include/cctype +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2006 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include - -namespace std{ - - using ::isalnum; - using ::isalpha; - using ::iscntrl; - using ::isdigit; - using ::isgraph; - using ::islower; - using ::isprint; - using ::ispunct; - using ::isspace; - using ::isupper; - using ::isxdigit; - using ::tolower; - using ::toupper; - -} diff --git a/DSTAT1/src/avr-stl/include/char_traits.h b/DSTAT1/src/avr-stl/include/char_traits.h deleted file mode 100644 index 7c21a72..0000000 --- a/DSTAT1/src/avr-stl/include/char_traits.h +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_CHAR_TRAITS_H -#define __SGI_STL_CHAR_TRAITS_H - -#include - -#ifndef __AVR__ -#include -#endif - -#ifndef __AVR__ -#if defined(__STL_USE_NEW_IOSTREAMS) && !defined(__SGI_STL_IOSFWD) -#include -#endif /* use new iostreams */ -#endif - -__STL_BEGIN_NAMESPACE - -// Class __char_traits_base. - -template class __char_traits_base { -public: - typedef _CharT char_type; - typedef _IntT int_type; - -#ifdef __AVR__ - typedef signed int char_traits_off_type; - typedef char state_type; - typedef char_traits_off_type off_type; - typedef char_traits_off_type pos_type; -#else -#ifdef __STL_USE_NEW_IOSTREAMS - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; -#endif /* __STL_USE_NEW_IOSTREAMS */ -#endif // __AVR__ - - static void assign(char_type& __c1, const char_type& __c2) { __c1 = __c2; } - static bool eq(const _CharT& __c1, const _CharT& __c2) - { return __c1 == __c2; } - static bool lt(const _CharT& __c1, const _CharT& __c2) - { return __c1 < __c2; } - - static int compare(const _CharT* __s1, const _CharT* __s2, size_t __n) { - for (size_t __i = 0; __i < __n; ++__i) - if (!eq(__s1[__i], __s2[__i])) - return __s1[__i] < __s2[__i] ? -1 : 1; - return 0; - } - - static size_t length(const _CharT* __s) { - const _CharT __nullchar = _CharT(); - size_t __i; - for (__i = 0; !eq(__s[__i], __nullchar); ++__i) - {} - return __i; - } - - static const _CharT* find(const _CharT* __s, size_t __n, const _CharT& __c) - { - for ( ; __n > 0 ; ++__s, --__n) - if (eq(*__s, __c)) - return __s; - return 0; - } - - static _CharT* move(_CharT* __s1, const _CharT* __s2, size_t __n) { - memmove(__s1, __s2, __n * sizeof(_CharT)); - return __s1; - } - - static _CharT* copy(_CharT* __s1, const _CharT* __s2, size_t __n) { - memcpy(__s1, __s2, __n * sizeof(_CharT)); - return __s1; - } - - static _CharT* assign(_CharT* __s, size_t __n, _CharT __c) { - for (size_t __i = 0; __i < __n; ++__i) - __s[__i] = __c; - return __s; - } - - static int_type not_eof(const int_type& __c) { - return !eq_int_type(__c, eof()) ? __c : 0; - } - - static char_type to_char_type(const int_type& __c) { - return static_cast(__c); - } - - static int_type to_int_type(const char_type& __c) { - return static_cast(__c); - } - - static bool eq_int_type(const int_type& __c1, const int_type& __c2) { - return __c1 == __c2; - } - - static int_type eof() { - return static_cast(-1); - } -}; - -// Generic char_traits class. Note that this class is provided only -// as a base for explicit specialization; it is unlikely to be useful -// as is for any particular user-defined type. In particular, it -// *will not work* for a non-POD type. - -template class char_traits - : public __char_traits_base<_CharT, _CharT> -{}; - -// Specialization for char. - -__STL_TEMPLATE_NULL class char_traits - : public __char_traits_base -{ -public: - static char_type to_char_type(const int_type& __c) { - return static_cast(static_cast(__c)); - } - - static int_type to_int_type(const char_type& __c) { - return static_cast(__c); - } - - static int compare(const char* __s1, const char* __s2, size_t __n) - { return memcmp(__s1, __s2, __n); } - - static size_t length(const char* __s) { return strlen(__s); } - - static void assign(char& __c1, const char& __c2) { __c1 = __c2; } - - static char* assign(char* __s, size_t __n, char __c) - { memset(__s, __c, __n); return __s; } -}; - -#ifndef __AVR__ -// Specialization for wchar_t. - -__STL_TEMPLATE_NULL class char_traits - : public __char_traits_base -{}; -#endif // ! __AVR__ - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_CHAR_TRAITS_H */ - -// Local Variables: -// mode:C++ -// End: - diff --git a/DSTAT1/src/avr-stl/include/concept_checks.h b/DSTAT1/src/avr-stl/include/concept_checks.h deleted file mode 100644 index 36df283..0000000 --- a/DSTAT1/src/avr-stl/include/concept_checks.h +++ /dev/null @@ -1,811 +0,0 @@ -/* - * Copyright (c) 1999 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __CONCEPT_CHECKS_H -#define __CONCEPT_CHECKS_H - -/* - Use these macro like assertions, but they assert properties - on types (usually template arguments). In technical terms they - verify whether a type "models" a "concept". - - This set of requirements and the terminology used here is derived - from the book "Generic Programming and the STL" by Matt Austern - (Addison Wesley). For further information please consult that - book. The requirements also are intended to match the ANSI/ISO C++ - standard. - - This file covers the basic concepts and the iterator concepts. - There are several other files that provide the requirements - for the STL containers: - container_concepts.h - sequence_concepts.h - assoc_container_concepts.h - - Jeremy Siek, 1999 - - TO DO: - - some issues with regards to concept classification and mutability - including AssociativeContianer -> ForwardContainer - and SortedAssociativeContainer -> ReversibleContainer - - HashedAssociativeContainer - - Allocator - - Function Object Concepts - - */ - -#ifndef __STL_USE_CONCEPT_CHECKS - -// Some compilers lack the features that are necessary for concept checks. -// On those compilers we define the concept check macros to do nothing. -#define __STL_REQUIRES(__type_var, __concept) do {} while(0) -#define __STL_CLASS_REQUIRES(__type_var, __concept) \ - static int __##__type_var##_##__concept -#define __STL_CONVERTIBLE(__type_x, __type_y) do {} while(0) -#define __STL_REQUIRES_SAME_TYPE(__type_x, __type_y) do {} while(0) -#define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \ - static int __##__type_x##__type_y##_require_same_type -#define __STL_GENERATOR_CHECK(__func, __ret) do {} while(0) -#define __STL_CLASS_GENERATOR_CHECK(__func, __ret) \ - static int __##__func##__ret##_generator_check -#define __STL_UNARY_FUNCTION_CHECK(__func, __ret, __arg) do {} while(0) -#define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ - static int __##__func##__ret##__arg##_unary_function_check -#define __STL_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ - do {} while(0) -#define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ - static int __##__func##__ret##__first##__second##_binary_function_check -#define __STL_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ - do {} while(0) -#define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ - static int __##__opname##__ret##__first##__second##_require_binary_op - -#else /* __STL_USE_CONCEPT_CHECKS */ - -// This macro tests whether the template argument "__type_var" -// satisfies the requirements of "__concept". Here is a list of concepts -// that we know how to check: -// _Allocator -// _Assignable -// _DefaultConstructible -// _EqualityComparable -// _LessThanComparable -// _TrivialIterator -// _InputIterator -// _OutputIterator -// _ForwardIterator -// _BidirectionalIterator -// _RandomAccessIterator -// _Mutable_TrivialIterator -// _Mutable_ForwardIterator -// _Mutable_BidirectionalIterator -// _Mutable_RandomAccessIterator - -#define __STL_REQUIRES(__type_var, __concept) \ -do { \ - void (*__x)( __type_var ) = __concept##_concept_specification< __type_var >\ - ::__concept##_requirement_violation; __x = __x; } while (0) - -// Use this to check whether type X is convertible to type Y -#define __STL_CONVERTIBLE(__type_x, __type_y) \ -do { \ - void (*__x)( __type_x , __type_y ) = _STL_CONVERT_ERROR< __type_x , \ - __type_y >::__type_X_is_not_convertible_to_type_Y; \ - __x = __x; } while (0) - -// Use this to test whether two template arguments are the same type -#define __STL_REQUIRES_SAME_TYPE(__type_x, __type_y) \ -do { \ - void (*__x)( __type_x , __type_y ) = _STL_SAME_TYPE_ERROR< __type_x, \ - __type_y >::__type_X_not_same_as_type_Y; \ - __x = __x; } while (0) - - -// function object checks -#define __STL_GENERATOR_CHECK(__func, __ret) \ -do { \ - __ret (*__x)( __func&) = \ - _STL_GENERATOR_ERROR< \ - __func, __ret>::__generator_requirement_violation; \ - __x = __x; } while (0) - - -#define __STL_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ -do { \ - __ret (*__x)( __func&, const __arg& ) = \ - _STL_UNARY_FUNCTION_ERROR< \ - __func, __ret, __arg>::__unary_function_requirement_violation; \ - __x = __x; } while (0) - - -#define __STL_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ -do { \ - __ret (*__x)( __func&, const __first&, const __second& ) = \ - _STL_BINARY_FUNCTION_ERROR< \ - __func, __ret, __first, __second>::__binary_function_requirement_violation; \ - __x = __x; } while (0) - - -#define __STL_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ - do { \ - __ret (*__x)( __first&, __second& ) = _STL_BINARY##__opname##_ERROR< \ - __ret, __first, __second>::__binary_operator_requirement_violation; \ - __ret (*__y)( const __first&, const __second& ) = \ - _STL_BINARY##__opname##_ERROR< __ret, __first, __second>:: \ - __const_binary_operator_requirement_violation; \ - __y = __y; __x = __x; } while (0) - - -#ifdef __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE - -#define __STL_CLASS_REQUIRES(__type_var, __concept) -#define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) -#define __STL_CLASS_GENERATOR_CHECK(__func, __ret) -#define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) -#define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) -#define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) - -#else - -// Use this macro inside of template classes, where you would -// like to place requirements on the template arguments to the class -// Warning: do not pass pointers and such (e.g. T*) in as the __type_var, -// since the type_var is used to construct identifiers. Instead typedef -// the pointer type, then use the typedef name for the __type_var. -#define __STL_CLASS_REQUIRES(__type_var, __concept) \ - typedef void (* __func##__type_var##__concept)( __type_var ); \ - template <__func##__type_var##__concept _Tp1> \ - struct __dummy_struct_##__type_var##__concept { }; \ - static __dummy_struct_##__type_var##__concept< \ - __concept##_concept_specification< \ - __type_var>::__concept##_requirement_violation> \ - __dummy_ptr_##__type_var##__concept - - -#define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \ - typedef void (* __func_##__type_x##__type_y##same_type)( __type_x, \ - __type_y ); \ - template < __func_##__type_x##__type_y##same_type _Tp1> \ - struct __dummy_struct_##__type_x##__type_y##_same_type { }; \ - static __dummy_struct_##__type_x##__type_y##_same_type< \ - _STL_SAME_TYPE_ERROR<__type_x, __type_y>::__type_X_not_same_as_type_Y> \ - __dummy_ptr_##__type_x##__type_y##_same_type - - -#define __STL_CLASS_GENERATOR_CHECK(__func, __ret) \ - typedef __ret (* __f_##__func##__ret##_generator)( __func& ); \ - template <__f_##__func##__ret##_generator _Tp1> \ - struct __dummy_struct_##__func##__ret##_generator { }; \ - static __dummy_struct_##__func##__ret##_generator< \ - _STL_GENERATOR_ERROR< \ - __func, __ret>::__generator_requirement_violation> \ - __dummy_ptr_##__func##__ret##_generator - - -#define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ - typedef __ret (* __f_##__func##__ret##__arg##_unary_check)( __func&, \ - const __arg& ); \ - template <__f_##__func##__ret##__arg##_unary_check _Tp1> \ - struct __dummy_struct_##__func##__ret##__arg##_unary_check { }; \ - static __dummy_struct_##__func##__ret##__arg##_unary_check< \ - _STL_UNARY_FUNCTION_ERROR< \ - __func, __ret, __arg>::__unary_function_requirement_violation> \ - __dummy_ptr_##__func##__ret##__arg##_unary_check - - -#define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ - typedef __ret (* __f_##__func##__ret##__first##__second##_binary_check)( __func&, const __first&,\ - const __second& ); \ - template <__f_##__func##__ret##__first##__second##_binary_check _Tp1> \ - struct __dummy_struct_##__func##__ret##__first##__second##_binary_check { }; \ - static __dummy_struct_##__func##__ret##__first##__second##_binary_check< \ - _STL_BINARY_FUNCTION_ERROR<__func, __ret, __first, __second>:: \ - __binary_function_requirement_violation> \ - __dummy_ptr_##__func##__ret##__first##__second##_binary_check - - -#define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ - typedef __ret (* __f_##__func##__ret##__first##__second##_binary_op)(const __first&, \ - const __second& ); \ - template <__f_##__func##__ret##__first##__second##_binary_op _Tp1> \ - struct __dummy_struct_##__func##__ret##__first##__second##_binary_op { }; \ - static __dummy_struct_##__func##__ret##__first##__second##_binary_op< \ - _STL_BINARY##__opname##_ERROR<__ret, __first, __second>:: \ - __binary_operator_requirement_violation> \ - __dummy_ptr_##__func##__ret##__first##__second##_binary_op - -#endif - -/* helper class for finding non-const version of a type. Need to have - something to assign to etc. when testing constant iterators. */ - -template -struct _Mutable_trait { - typedef _Tp _Type; -}; -template -struct _Mutable_trait { - typedef _Tp _Type; -}; - - -/* helper function for avoiding compiler warnings about unused variables */ -template -void __sink_unused_warning(_Type) { } - -template -struct _STL_CONVERT_ERROR { - static void - __type_X_is_not_convertible_to_type_Y(_TypeX __x, _TypeY) { - _TypeY __y = __x; - __sink_unused_warning(__y); - } -}; - - -template struct __check_equal { }; - -template -struct _STL_SAME_TYPE_ERROR { - static void - __type_X_not_same_as_type_Y(_TypeX , _TypeY ) { - __check_equal<_TypeX> t1 = __check_equal<_TypeY>(); - } -}; - - -// Some Functon Object Checks - -template -struct _STL_GENERATOR_ERROR { - static _Ret __generator_requirement_violation(_Func& __f) { - return __f(); - } -}; - -template -struct _STL_GENERATOR_ERROR<_Func, void> { - static void __generator_requirement_violation(_Func& __f) { - __f(); - } -}; - - -template -struct _STL_UNARY_FUNCTION_ERROR { - static _Ret - __unary_function_requirement_violation(_Func& __f, - const _Arg& __arg) { - return __f(__arg); - } -}; - -template -struct _STL_UNARY_FUNCTION_ERROR<_Func, void, _Arg> { - static void - __unary_function_requirement_violation(_Func& __f, - const _Arg& __arg) { - __f(__arg); - } -}; - -template -struct _STL_BINARY_FUNCTION_ERROR { - static _Ret - __binary_function_requirement_violation(_Func& __f, - const _First& __first, - const _Second& __second) { - return __f(__first, __second); - } -}; - -template -struct _STL_BINARY_FUNCTION_ERROR<_Func, void, _First, _Second> { - static void - __binary_function_requirement_violation(_Func& __f, - const _First& __first, - const _Second& __second) { - __f(__first, __second); - } -}; - - -#define __STL_DEFINE_BINARY_OP_CHECK(_OP, _NAME) \ -template \ -struct _STL_BINARY##_NAME##_ERROR { \ - static _Ret \ - __const_binary_operator_requirement_violation(const _First& __first, \ - const _Second& __second) { \ - return __first _OP __second; \ - } \ - static _Ret \ - __binary_operator_requirement_violation(_First& __first, \ - _Second& __second) { \ - return __first _OP __second; \ - } \ -} - -__STL_DEFINE_BINARY_OP_CHECK(==, _OP_EQUAL); -__STL_DEFINE_BINARY_OP_CHECK(!=, _OP_NOT_EQUAL); -__STL_DEFINE_BINARY_OP_CHECK(<, _OP_LESS_THAN); -__STL_DEFINE_BINARY_OP_CHECK(<=, _OP_LESS_EQUAL); -__STL_DEFINE_BINARY_OP_CHECK(>, _OP_GREATER_THAN); -__STL_DEFINE_BINARY_OP_CHECK(>=, _OP_GREATER_EQUAL); -__STL_DEFINE_BINARY_OP_CHECK(+, _OP_PLUS); -__STL_DEFINE_BINARY_OP_CHECK(*, _OP_TIMES); -__STL_DEFINE_BINARY_OP_CHECK(/, _OP_DIVIDE); -__STL_DEFINE_BINARY_OP_CHECK(-, _OP_SUBTRACT); -__STL_DEFINE_BINARY_OP_CHECK(%, _OP_MOD); -// ... - -// TODO, add unary operators (prefix and postfix) - -/* - The presence of this class is just to trick EDG into displaying - these error messages before any other errors. Without the - classes, the errors in the functions get reported after - other class errors deep inside the library. The name - choice just makes for an eye catching error message :) - */ -struct _STL_ERROR { - - template - static _Type - __default_constructor_requirement_violation(_Type) { - return _Type(); - } - template - static _Type - __assignment_operator_requirement_violation(_Type __a) { - __a = __a; - return __a; - } - template - static _Type - __copy_constructor_requirement_violation(_Type __a) { - _Type __c(__a); - return __c; - } - template - static _Type - __const_parameter_required_for_copy_constructor(_Type /* __a */, - const _Type& __b) { - _Type __c(__b); - return __c; - } - template - static _Type - __const_parameter_required_for_assignment_operator(_Type __a, - const _Type& __b) { - __a = __b; - return __a; - } - template - static _Type - __less_than_comparable_requirement_violation(_Type __a, _Type __b) { - if (__a < __b || __a > __b || __a <= __b || __a >= __b) return __a; - return __b; - } - template - static _Type - __equality_comparable_requirement_violation(_Type __a, _Type __b) { - if (__a == __b || __a != __b) return __a; - return __b; - } - template - static void - __dereference_operator_requirement_violation(_Iterator __i) { - __sink_unused_warning(*__i); - } - template - static void - __dereference_operator_and_assignment_requirement_violation(_Iterator __i) { - *__i = *__i; - } - template - static void - __preincrement_operator_requirement_violation(_Iterator __i) { - ++__i; - } - template - static void - __postincrement_operator_requirement_violation(_Iterator __i) { - __i++; - } - template - static void - __predecrement_operator_requirement_violation(_Iterator __i) { - --__i; - } - template - static void - __postdecrement_operator_requirement_violation(_Iterator __i) { - __i--; - } - template - static void - __postincrement_operator_and_assignment_requirement_violation(_Iterator __i, - _Type __t) { - *__i++ = __t; - } - template - static _Iterator - __iterator_addition_assignment_requirement_violation(_Iterator __i, - _Distance __n) { - __i += __n; - return __i; - } - template - static _Iterator - __iterator_addition_requirement_violation(_Iterator __i, _Distance __n) { - __i = __i + __n; - __i = __n + __i; - return __i; - } - template - static _Iterator - __iterator_subtraction_assignment_requirement_violation(_Iterator __i, - _Distance __n) { - __i -= __n; - return __i; - } - template - static _Iterator - __iterator_subtraction_requirement_violation(_Iterator __i, _Distance __n) { - __i = __i - __n; - return __i; - } - template - static _Distance - __difference_operator_requirement_violation(_Iterator __i, _Iterator __j, - _Distance __n) { - __n = __i - __j; - return __n; - } - template - static _Type - __element_access_operator_requirement_violation(_Exp __x, _Type*, - _Distance __n) { - return __x[__n]; - } - template - static void - __element_assignment_operator_requirement_violation(_Exp __x, - _Type* __t, - _Distance __n) { - __x[__n] = *__t; - } - -}; /* _STL_ERROR */ - -/* Associated Type Requirements */ - -__STL_BEGIN_NAMESPACE -template struct iterator_traits; -__STL_END_NAMESPACE - -template -struct __value_type_type_definition_requirement_violation { - typedef typename __STD::iterator_traits<_Iter>::value_type value_type; -}; - -template -struct __difference_type_type_definition_requirement_violation { - typedef typename __STD::iterator_traits<_Iter>::difference_type - difference_type; -}; - -template -struct __reference_type_definition_requirement_violation { - typedef typename __STD::iterator_traits<_Iter>::reference reference; -}; - -template -struct __pointer_type_definition_requirement_violation { - typedef typename __STD::iterator_traits<_Iter>::pointer pointer; -}; - -template -struct __iterator_category_type_definition_requirement_violation { - typedef typename __STD::iterator_traits<_Iter>::iterator_category - iterator_category; -}; - -/* Assignable Requirements */ - - -template -struct _Assignable_concept_specification { - static void _Assignable_requirement_violation(_Type __a) { - _STL_ERROR::__assignment_operator_requirement_violation(__a); - _STL_ERROR::__copy_constructor_requirement_violation(__a); - _STL_ERROR::__const_parameter_required_for_copy_constructor(__a,__a); - _STL_ERROR::__const_parameter_required_for_assignment_operator(__a,__a); - } -}; - -/* DefaultConstructible Requirements */ - - -template -struct _DefaultConstructible_concept_specification { - static void _DefaultConstructible_requirement_violation(_Type __a) { - _STL_ERROR::__default_constructor_requirement_violation(__a); - } -}; - -/* EqualityComparable Requirements */ - -template -struct _EqualityComparable_concept_specification { - static void _EqualityComparable_requirement_violation(_Type __a) { - _STL_ERROR::__equality_comparable_requirement_violation(__a, __a); - } -}; - -/* LessThanComparable Requirements */ -template -struct _LessThanComparable_concept_specification { - static void _LessThanComparable_requirement_violation(_Type __a) { - _STL_ERROR::__less_than_comparable_requirement_violation(__a, __a); - } -}; - -/* TrivialIterator Requirements */ - -template -struct _TrivialIterator_concept_specification { -static void -_TrivialIterator_requirement_violation(_TrivialIterator __i) { - typedef typename - __value_type_type_definition_requirement_violation<_TrivialIterator>:: - value_type __T; - // Refinement of Assignable - _Assignable_concept_specification<_TrivialIterator>:: - _Assignable_requirement_violation(__i); - // Refinement of DefaultConstructible - _DefaultConstructible_concept_specification<_TrivialIterator>:: - _DefaultConstructible_requirement_violation(__i); - // Refinement of EqualityComparable - _EqualityComparable_concept_specification<_TrivialIterator>:: - _EqualityComparable_requirement_violation(__i); - // Valid Expressions - _STL_ERROR::__dereference_operator_requirement_violation(__i); -} -}; - -template -struct _Mutable_TrivialIterator_concept_specification { -static void -_Mutable_TrivialIterator_requirement_violation(_TrivialIterator __i) { - _TrivialIterator_concept_specification<_TrivialIterator>:: - _TrivialIterator_requirement_violation(__i); - // Valid Expressions - _STL_ERROR::__dereference_operator_and_assignment_requirement_violation(__i); -} -}; - -/* InputIterator Requirements */ - -template -struct _InputIterator_concept_specification { -static void -_InputIterator_requirement_violation(_InputIterator __i) { - // Refinement of TrivialIterator - _TrivialIterator_concept_specification<_InputIterator>:: - _TrivialIterator_requirement_violation(__i); - // Associated Types - __difference_type_type_definition_requirement_violation<_InputIterator>(); - __reference_type_definition_requirement_violation<_InputIterator>(); - __pointer_type_definition_requirement_violation<_InputIterator>(); - __iterator_category_type_definition_requirement_violation<_InputIterator>(); - // Valid Expressions - _STL_ERROR::__preincrement_operator_requirement_violation(__i); - _STL_ERROR::__postincrement_operator_requirement_violation(__i); -} -}; - -/* OutputIterator Requirements */ - -template -struct _OutputIterator_concept_specification { -static void -_OutputIterator_requirement_violation(_OutputIterator __i) { - // Refinement of Assignable - _Assignable_concept_specification<_OutputIterator>:: - _Assignable_requirement_violation(__i); - // Associated Types - __iterator_category_type_definition_requirement_violation<_OutputIterator>(); - // Valid Expressions - _STL_ERROR::__dereference_operator_requirement_violation(__i); - _STL_ERROR::__preincrement_operator_requirement_violation(__i); - _STL_ERROR::__postincrement_operator_requirement_violation(__i); - _STL_ERROR:: - __postincrement_operator_and_assignment_requirement_violation(__i, *__i); -} -}; - -/* ForwardIterator Requirements */ - -template -struct _ForwardIterator_concept_specification { -static void -_ForwardIterator_requirement_violation(_ForwardIterator __i) { - // Refinement of InputIterator - _InputIterator_concept_specification<_ForwardIterator>:: - _InputIterator_requirement_violation(__i); -} -}; - -template -struct _Mutable_ForwardIterator_concept_specification { -static void -_Mutable_ForwardIterator_requirement_violation(_ForwardIterator __i) { - _ForwardIterator_concept_specification<_ForwardIterator>:: - _ForwardIterator_requirement_violation(__i); - // Refinement of OutputIterator - _OutputIterator_concept_specification<_ForwardIterator>:: - _OutputIterator_requirement_violation(__i); -} -}; - -/* BidirectionalIterator Requirements */ - -template -struct _BidirectionalIterator_concept_specification { -static void -_BidirectionalIterator_requirement_violation(_BidirectionalIterator __i) { - // Refinement of ForwardIterator - _ForwardIterator_concept_specification<_BidirectionalIterator>:: - _ForwardIterator_requirement_violation(__i); - // Valid Expressions - _STL_ERROR::__predecrement_operator_requirement_violation(__i); - _STL_ERROR::__postdecrement_operator_requirement_violation(__i); -} -}; - -template -struct _Mutable_BidirectionalIterator_concept_specification { -static void -_Mutable_BidirectionalIterator_requirement_violation( - _BidirectionalIterator __i) -{ - _BidirectionalIterator_concept_specification<_BidirectionalIterator>:: - _BidirectionalIterator_requirement_violation(__i); - // Refinement of mutable_ForwardIterator - _Mutable_ForwardIterator_concept_specification<_BidirectionalIterator>:: - _Mutable_ForwardIterator_requirement_violation(__i); - typedef typename - __value_type_type_definition_requirement_violation< - _BidirectionalIterator>::value_type __T; - typename _Mutable_trait<__T>::_Type* __tmp_ptr = 0; - // Valid Expressions - _STL_ERROR:: - __postincrement_operator_and_assignment_requirement_violation(__i, - *__tmp_ptr); -} -}; - -/* RandomAccessIterator Requirements */ - -template -struct _RandomAccessIterator_concept_specification { -static void -_RandomAccessIterator_requirement_violation(_RandAccIter __i) { - // Refinement of BidirectionalIterator - _BidirectionalIterator_concept_specification<_RandAccIter>:: - _BidirectionalIterator_requirement_violation(__i); - // Refinement of LessThanComparable - _LessThanComparable_concept_specification<_RandAccIter>:: - _LessThanComparable_requirement_violation(__i); - typedef typename - __value_type_type_definition_requirement_violation<_RandAccIter> - ::value_type - value_type; - typedef typename - __difference_type_type_definition_requirement_violation<_RandAccIter> - ::difference_type - _Dist; - typedef typename _Mutable_trait<_Dist>::_Type _MutDist; - - // Valid Expressions - _STL_ERROR::__iterator_addition_assignment_requirement_violation(__i, - _MutDist()); - _STL_ERROR::__iterator_addition_requirement_violation(__i, - _MutDist()); - _STL_ERROR:: - __iterator_subtraction_assignment_requirement_violation(__i, - _MutDist()); - _STL_ERROR::__iterator_subtraction_requirement_violation(__i, - _MutDist()); - _STL_ERROR::__difference_operator_requirement_violation(__i, __i, - _MutDist()); - typename _Mutable_trait::_Type* __dummy_ptr = 0; - _STL_ERROR::__element_access_operator_requirement_violation(__i, - __dummy_ptr, - _MutDist()); -} -}; - -template -struct _Mutable_RandomAccessIterator_concept_specification { -static void -_Mutable_RandomAccessIterator_requirement_violation(_RandAccIter __i) -{ - _RandomAccessIterator_concept_specification<_RandAccIter>:: - _RandomAccessIterator_requirement_violation(__i); - // Refinement of mutable_BidirectionalIterator - _Mutable_BidirectionalIterator_concept_specification<_RandAccIter>:: - _Mutable_BidirectionalIterator_requirement_violation(__i); - typedef typename - __value_type_type_definition_requirement_violation<_RandAccIter> - ::value_type - value_type; - typedef typename - __difference_type_type_definition_requirement_violation<_RandAccIter> - ::difference_type - _Dist; - - typename _Mutable_trait::_Type* __tmp_ptr = 0; - // Valid Expressions - _STL_ERROR::__element_assignment_operator_requirement_violation(__i, - __tmp_ptr, _Dist()); -} -}; - -#define __STL_TYPEDEF_REQUIREMENT(__REQUIREMENT) \ -template \ -struct __##__REQUIREMENT##__typedef_requirement_violation { \ - typedef typename Type::__REQUIREMENT __REQUIREMENT; \ -} - -__STL_TYPEDEF_REQUIREMENT(value_type); -__STL_TYPEDEF_REQUIREMENT(difference_type); -__STL_TYPEDEF_REQUIREMENT(size_type); -__STL_TYPEDEF_REQUIREMENT(reference); -__STL_TYPEDEF_REQUIREMENT(const_reference); -__STL_TYPEDEF_REQUIREMENT(pointer); -__STL_TYPEDEF_REQUIREMENT(const_pointer); - - -template -struct _Allocator_concept_specification { -static void -_Allocator_requirement_violation(_Alloc __a) { - // Refinement of DefaultConstructible - _DefaultConstructible_concept_specification<_Alloc>:: - _DefaultConstructible_requirement_violation(__a); - // Refinement of EqualityComparable - _EqualityComparable_concept_specification<_Alloc>:: - _EqualityComparable_requirement_violation(__a); - // Associated Types - __value_type__typedef_requirement_violation<_Alloc>(); - __difference_type__typedef_requirement_violation<_Alloc>(); - __size_type__typedef_requirement_violation<_Alloc>(); - __reference__typedef_requirement_violation<_Alloc>(); - __const_reference__typedef_requirement_violation<_Alloc>(); - __pointer__typedef_requirement_violation<_Alloc>(); - __const_pointer__typedef_requirement_violation<_Alloc>(); - typedef typename _Alloc::value_type _Tp; - //__STL_REQUIRES_SAME_TYPE(typename _Alloc::__STL_TEMPLATE rebind<_Tp>::other, - // _Alloc); -} -}; - -#endif /* __STL_USE_CONCEPT_CHECKS */ - -#endif /* __CONCEPT_CHECKS_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/container_concepts.h b/DSTAT1/src/avr-stl/include/container_concepts.h deleted file mode 100644 index da424db..0000000 --- a/DSTAT1/src/avr-stl/include/container_concepts.h +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (c) 1999 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __STL_CONTAINER_CONCEPTS_H -#define __STL_CONTAINER_CONCEPTS_H - - -#include - -#ifdef __STL_USE_CONCEPT_CHECKS - - -// This file covers the following concepts: -// _Container -// _ForwardContainer -// _ReversibleContainer -// _const_ReversibleContainer -// _RandomAccessContainer -// - -struct _ERROR_IN_STL_CONTAINER { - - /* Container expresssions */ - - template - static void - __begin_iterator_accessor_requirement_violation(_Container __c) { - __c.begin(); - } - template - static void - __const_begin_iterator_accessor_requirement_violation(const _Container& __c) { - __c.begin(); - } - template - static void - __end_iterator_accessor_requirement_violation(_Container __c) { - __c.end(); - } - template - static void - __const_end_iterator_accessor_requirement_violation(const _Container& __c) { - __c.end(); - } - - template - static void - __rbegin_iterator_accessor_requirement_violation(_Container __c) { - __c.rbegin(); - } - template - static void - __const_rbegin_iterator_accessor_requirement_violation(const _Container& __c) { - __c.rbegin(); - } - template - static void - __rend_iterator_accessor_requirement_violation(_Container __c) { - __c.rend(); - } - template - static void - __const_rend_iterator_accessor_requirement_violation(const _Container& __c) { - __c.rend(); - } - template - static void - __size_function_must_be_const(const _Container& __c) { - __c.size(); - } - template - static void - __size_function_requirement_violation(_Container& __c) { - __c.size(); - __size_function_must_be_const(__c); - } - template - static void - __max_size_function_must_be_const(const _Container& __c) { - __c.max_size(); - } - template - static void - __max_size_function_requirement_violation(_Container& __c) { - __c.max_size(); - __max_size_function_must_be_const(__c); - } - template - static void - __empty_function_must_be_const(const _Container& __c) { - __c.empty(); - } - template - static void - __empty_function_requirement_violation(_Container& __c) { - __c.empty(); - __empty_function_must_be_const(__c); - } - template - static void - __swap_function_requirement_violation(_Container& __c) { - __c.swap(__c); - } - -}; - - -__STL_TYPEDEF_REQUIREMENT(iterator); -__STL_TYPEDEF_REQUIREMENT(const_iterator); - -/* Containers */ - -template -struct _Container_concept_specification { -static void -_Container_requirement_violation(_Container __c) { - // Refinement of Assignable - _Assignable_concept_specification<_Container>::_Assignable_requirement_violation(__c); - // Associated Types - __value_type__typedef_requirement_violation<_Container>(); - __difference_type__typedef_requirement_violation<_Container>(); - __size_type__typedef_requirement_violation<_Container>(); - __reference__typedef_requirement_violation<_Container>(); - __const_reference__typedef_requirement_violation<_Container>(); - __pointer__typedef_requirement_violation<_Container>(); - __const_pointer__typedef_requirement_violation<_Container>(); - __iterator__typedef_requirement_violation<_Container>(); - __const_iterator__typedef_requirement_violation<_Container>(); - // Valid Expressions - _ERROR_IN_STL_CONTAINER::__const_begin_iterator_accessor_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__const_end_iterator_accessor_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__begin_iterator_accessor_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__end_iterator_accessor_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__size_function_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__max_size_function_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__empty_function_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__swap_function_requirement_violation(__c); - // Requirements on Iterators - typedef typename _Container::iterator iter; - typedef typename _Container::const_iterator const_iter; - _InputIterator_concept_specification::_InputIterator_requirement_violation(const_iter()); - _InputIterator_concept_specification::_InputIterator_requirement_violation(iter()); -} -}; - -template -struct _ForwardContainer_concept_specification { -static void -_ForwardContainer_requirement_violation(_ForwardContainer __c) { - // Refinement of Container - _Container_concept_specification<_ForwardContainer>::_Container_requirement_violation(__c); - // Requirements on Iterators - typedef typename _ForwardContainer::iterator iter; - typedef typename _ForwardContainer::const_iterator const_iter; - _ForwardIterator_concept_specification::_ForwardIterator_requirement_violation(const_iter()); - _Mutable_ForwardIterator_concept_specification::_Mutable_ForwardIterator_requirement_violation(iter()); -} -}; - - -__STL_TYPEDEF_REQUIREMENT(reverse_iterator); -__STL_TYPEDEF_REQUIREMENT(const_reverse_iterator); - -template -struct _ReversibleContainer_concept_specification { -static void -_ReversibleContainer_requirement_violation(_ReversibleContainer __c) { - // Refinement of ForwardContainer - _ForwardContainer_concept_specification<_ReversibleContainer>::_ForwardContainer_requirement_violation(__c); - // Associated types - __reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); - __const_reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); - // Valid Expressions - _ERROR_IN_STL_CONTAINER::__const_rbegin_iterator_accessor_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__const_rend_iterator_accessor_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__rbegin_iterator_accessor_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__rend_iterator_accessor_requirement_violation(__c); - // Requirements on Iterators - typedef typename _ReversibleContainer::iterator iter; - typedef typename _ReversibleContainer::const_iterator const_iter; - _BidirectionalIterator_concept_specification::_BidirectionalIterator_requirement_violation(const_iter()); - _Mutable_BidirectionalIterator_concept_specification::_Mutable_BidirectionalIterator_requirement_violation(iter()); -} -}; - -template -struct _const_ReversibleContainer_concept_specification { -static void -_const_ReversibleContainer_requirement_violation(_ReversibleContainer __c) { - // Refinement of Container (JGS, not ForwardContainer) - _Container_concept_specification<_ReversibleContainer>::_Container_requirement_violation(__c); - // Associated types - __reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); - __const_reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); - // Valid Expressions - _ERROR_IN_STL_CONTAINER::__const_rbegin_iterator_accessor_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__const_rend_iterator_accessor_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__rbegin_iterator_accessor_requirement_violation(__c); - _ERROR_IN_STL_CONTAINER::__rend_iterator_accessor_requirement_violation(__c); - // Requirements on Iterators - typedef typename _ReversibleContainer::iterator iter; - typedef typename _ReversibleContainer::const_iterator const_iter; - - // This line won't compile on gcc 2.91 due to a compiler bug - // Doesn't seem happy on avr-gcc 4.5.1 either - -#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 91) && !defined(__AVR__) - __BidirectionalIterator_concept_specification::_BidirectionalIterator_requirement_violation(const_iter()); -#endif -} -}; - - -template -struct _RandomAccessContainer_concept_specification { -static void -_RandomAccessContainer_requirement_violation(_RandomAccessContainer __c) { - // Refinement of ReversibleContainer - _ReversibleContainer_concept_specification<_RandomAccessContainer>::_ReversibleContainer_requirement_violation(__c); - // Valid Expressions - typedef typename _RandomAccessContainer::value_type __T; - typedef typename _RandomAccessContainer::difference_type _Dist; - typedef typename _Mutable_trait<__T>::_Type Type; - typedef Type* _TypePtr; - typedef typename _Mutable_trait<_Dist>::_Type Dist; - _STL_ERROR::__element_access_operator_requirement_violation(__c, - _TypePtr(), - Dist()); - // Requirements on Iterators - typedef typename _RandomAccessContainer::iterator iter; - typedef typename _RandomAccessContainer::const_iterator const_iter; - _RandomAccessIterator_concept_specification::_RandomAccessIterator_requirement_violation(const_iter()); - _Mutable_RandomAccessIterator_concept_specification::_Mutable_RandomAccessIterator_requirement_violation(iter()); -} -}; - -#endif /* if __STL_USE_CONCEPT_CHECKS */ - -#endif /* __STL_CONTAINER_CONCEPTS_H */ diff --git a/DSTAT1/src/avr-stl/include/cstddef b/DSTAT1/src/avr-stl/include/cstddef deleted file mode 100644 index d44834b..0000000 --- a/DSTAT1/src/avr-stl/include/cstddef +++ /dev/null @@ -1,58 +0,0 @@ -// -*- C++ -*- forwarding header. - -// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// -// ISO C++ 14882: 18.1 Types -// - -/** @file cstddef - * This is a Standard C++ Library file. You should @c #include this file - * in your programs, rather than any of the "*.h" implementation files. - * - * This is the C++ version of the Standard C Library header @c stddef.h, - * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. - */ - -#ifndef _CPP_CSTDDEF -#define _CPP_CSTDDEF 1 - -#ifdef __GCC__ -#pragma GCC system_header -#endif - -#include - -namespace std -{ - using ::ptrdiff_t; - using ::size_t; -} - -#endif diff --git a/DSTAT1/src/avr-stl/include/deque b/DSTAT1/src/avr-stl/include/deque deleted file mode 100644 index b823fa4..0000000 --- a/DSTAT1/src/avr-stl/include/deque +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_DEQUE -#define __SGI_STL_DEQUE - -#include -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_DEQUE */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/functional b/DSTAT1/src/avr-stl/include/functional deleted file mode 100644 index d046dbb..0000000 --- a/DSTAT1/src/avr-stl/include/functional +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef __SGI_STL_FUNCTIONAL -#define __SGI_STL_FUNCTIONAL - -#include -#include -#include - -#endif /* __SGI_STL_FUNCTIONAL */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/hash_map b/DSTAT1/src/avr-stl/include/hash_map deleted file mode 100644 index f7421e0..0000000 --- a/DSTAT1/src/avr-stl/include/hash_map +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef __SGI_STL_HASH_MAP -#define __SGI_STL_HASH_MAP - -#ifndef __SGI_STL_INTERNAL_HASHTABLE_H -#include -#endif - -#include - -#endif /* __SGI_STL_HASH_MAP */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/hash_set b/DSTAT1/src/avr-stl/include/hash_set deleted file mode 100644 index 2244f47..0000000 --- a/DSTAT1/src/avr-stl/include/hash_set +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef __SGI_STL_HASH_SET -#define __SGI_STL_HASH_SET - -#ifndef __SGI_STL_INTERNAL_HASHTABLE_H -#include -#endif - -#include - -#endif /* __SGI_STL_HASH_SET */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/iomanip b/DSTAT1/src/avr-stl/include/iomanip deleted file mode 100644 index a8dd6c1..0000000 --- a/DSTAT1/src/avr-stl/include/iomanip +++ /dev/null @@ -1,173 +0,0 @@ -/* Copyright (C) 2005 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __AVR__ -#include -#endif - -#include - -#ifndef __STD_IOMANIP -#define __STD_IOMANIP 1 - -#pragma GCC visibility push(default) - -namespace std{ - -// These are the helper classes which we are going to be using to -// hold the required data - -class _UCXXEXPORT __resetiosflags{ -public: - ios_base::fmtflags m; - _UCXXEXPORT __resetiosflags(ios_base::fmtflags mask) : m(mask){ } -}; - -class _UCXXEXPORT __setiosflags{ -public: - ios_base::fmtflags m; - _UCXXEXPORT __setiosflags(ios_base::fmtflags mask) : m(mask){ } -}; - -class _UCXXEXPORT __setbase{ -public: - int base; - _UCXXEXPORT __setbase(int b) : base(b){ } -}; - -class _UCXXEXPORT __setfill{ -public: - int character; - _UCXXEXPORT __setfill(int c): character(c){ } -}; - -class _UCXXEXPORT __setprecision{ -public: - int digits; - _UCXXEXPORT __setprecision(int n): digits(n) { } -}; - -class _UCXXEXPORT __setw{ -public: - int width; - _UCXXEXPORT __setw(int n): width(n) { } -}; - - -//Actual manipulator functions - -inline __resetiosflags resetiosflags(ios_base::fmtflags mask){ - return __resetiosflags(mask); -} - -inline __setiosflags setiosflags(ios_base::fmtflags mask){ - return __setiosflags(mask); -} - -inline __setbase setbase(int b){ - return __setbase(b); -} - -inline __setfill setfill(int c){ - return __setfill(c); -} - -inline __setprecision setprecision(int n){ - return __setprecision(n); -} - -inline __setw setw(int n){ - return __setw(n); -} - - -//How to handle interaction with [i|o]stream classes - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __resetiosflags s) -{ - os.setf(ios_base::fmtflags(0),s.m); - return os; -} - -template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, const __resetiosflags s) -{ - is.setf(ios_base::fmtflags(0),s.m); - return is; -} - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __setiosflags s) -{ - os.setf(s.m); - return os; -} - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __setbase s) -{ - ios_base::fmtflags f(0); - switch(s.base){ - case 8: - f = ios_base::oct; - break; - case 10: - f = ios_base::dec; - break; - case 16: - f = ios_base::hex; - break; - default: - break; - - } - os.setf(f, ios_base::basefield); - return os; -} - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __setfill s) -{ - os.fill(s.character); - return os; -} - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __setprecision s) -{ - os.precision(s.digits); - return os; -} - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __setw s) -{ - os.width(s.width); - return os; -} - - - -} - -#pragma GCC visibility pop - -#endif - diff --git a/DSTAT1/src/avr-stl/include/ios b/DSTAT1/src/avr-stl/include/ios deleted file mode 100644 index 5167231..0000000 --- a/DSTAT1/src/avr-stl/include/ios +++ /dev/null @@ -1,525 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include -#include -#include - -#ifndef __HEADER_STD_IOS -#define __HEADER_STD_IOS 1 - -#pragma GCC visibility push(default) - -namespace std{ - typedef signed long int streamoff; - - template class fpos; - - class _UCXXEXPORT ios_base { - public: - class failure; -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ - class failure : public exception { - public: - explicit failure(const std::string& msg) { } - explicit failure() { } - virtual const char* what() const throw() { - return "std::ios_base failure exception"; - } - }; -#endif -#ifdef __UCLIBCXX_SUPPORT_CDIR__ - class _UCXXLOCAL Init{ - public: - _UCXXEXPORT Init(); - _UCXXEXPORT ~Init(); - private: - static int init_cnt; - }; -#endif - - public: - - typedef unsigned short int fmtflags; - - static const fmtflags skipws = 0x0001; - - static const fmtflags left = 0x0002; - static const fmtflags right = 0x0004; - static const fmtflags internal = 0x0008; - - static const fmtflags boolalpha = 0x0010; - - static const fmtflags dec = 0x0020; - static const fmtflags oct = 0x0040; - static const fmtflags hex = 0x0080; - - static const fmtflags scientific = 0x0100; - static const fmtflags fixed = 0x0200; - - static const fmtflags showbase = 0x0400; - static const fmtflags showpoint = 0x0800; - static const fmtflags showpos = 0x1000; - static const fmtflags uppercase = 0x2000; - - static const fmtflags adjustfield = left | right | internal; - static const fmtflags basefield = dec | oct | hex; - static const fmtflags floatfield = fixed | scientific; - - static const fmtflags unitbuf = 0x4000; - - typedef unsigned char iostate; - static const iostate goodbit = 0x00; - static const iostate badbit = 0x01; - static const iostate eofbit = 0x02; - static const iostate failbit = 0x04; - - typedef unsigned char openmode; - static const openmode app = 0x01; - static const openmode ate = 0x02; - static const openmode binary = 0x04; - static const openmode in = 0x08; - static const openmode out = 0x10; - static const openmode trunc = 0x20; - - typedef unsigned char seekdir; - static const seekdir beg = 0x01; - static const seekdir cur = 0x02; - static const seekdir end = 0x04; - - _UCXXEXPORT fmtflags flags() const{ - return mformat; - } - - _UCXXEXPORT fmtflags flags(fmtflags fmtfl) { - fmtflags temp = mformat; - mformat = fmtfl; - return temp; - } - - - fmtflags setf(fmtflags fmtfl) { - return flags(flags() | fmtfl); - } - - fmtflags setf(fmtflags fmtfl, fmtflags mask ) { - return flags( (flags()& ~mask) | (fmtfl & mask)); - } - - _UCXXEXPORT void unsetf(fmtflags mask){ - mformat&= ~mask; - } - - _UCXXEXPORT streamsize precision() const{ - return mprecision; - } - - _UCXXEXPORT streamsize precision(streamsize prec) { - streamsize temp = mprecision; - mprecision = prec; - return temp; - } - - _UCXXEXPORT streamsize width() const{ - return mwidth; - } - - _UCXXEXPORT streamsize width(streamsize wide) { - streamsize temp = mwidth; - mwidth = wide; - return temp; - } - - _UCXXEXPORT locale imbue(const locale& loc) { - locale retval = mLocale; - mLocale = loc; - return retval; - } - - _UCXXEXPORT locale getloc() const{ - return mLocale; - } - -// FIXME - These need to be implemented -// static int xalloc(); -// long& iword(int index); -// void*& pword(int index); - - _UCXXEXPORT ~ios_base() { } - - enum event { erase_event, imbue_event, copyfmt_event }; - - typedef void (*event_callback)(event, ios_base&, int index); -// void register_callback(event_call_back fn, int index); - - //We are going to wrap stdio so we don't need implementation of the following: - inline static bool sync_with_stdio(bool = true) { return true; } - - protected: - _UCXXEXPORT ios_base() : mLocale(), mformat(dec | skipws ), mstate(goodbit), - mmode(), mdir(), mprecision(6), mwidth(0) -#ifdef __UCLIBCXX_SUPPORT_CDIR__ - ,mInit() -#endif - { - - } - locale mLocale; - fmtflags mformat; - iostate mstate; - openmode mmode; - seekdir mdir; - streamsize mprecision; - streamsize mwidth; -#ifdef __UCLIBCXX_SUPPORT_CDIR__ - Init mInit; -#endif - }; - - - //ios_base manipulators - - - inline ios_base& boolalpha (ios_base& str){ - str.setf(ios_base::boolalpha); - return str; - } - inline ios_base& noboolalpha(ios_base& str){ - str.unsetf(ios_base::boolalpha); - return str; - } - inline ios_base& showbase (ios_base& str){ - str.setf(ios_base::showbase); - return str; - } - inline ios_base& noshowbase (ios_base& str){ - str.unsetf(ios_base::showbase); - return str; - } - inline ios_base& showpoint (ios_base& str){ - str.setf(ios_base::showpoint); - return str; - } - inline ios_base& noshowpoint(ios_base& str){ - str.unsetf(ios_base::showpoint); - return str; - } - inline ios_base& showpos (ios_base& str){ - str.setf(ios_base::showpos); - return str; - } - inline ios_base& noshowpos (ios_base& str){ - str.unsetf(ios_base::showpos); - return str; - } - inline ios_base& skipws (ios_base& str){ - str.setf(ios_base::skipws); - return str; - } - inline ios_base& noskipws (ios_base& str){ - str.unsetf(ios_base::skipws); - return str; - } - inline ios_base& uppercase (ios_base& str){ - str.setf(ios_base::uppercase); - return str; - } - inline ios_base& nouppercase(ios_base& str){ - str.unsetf(ios_base::uppercase); - return str; - } - - inline ios_base& unitbuf (ios_base& str){ - str.setf(ios_base::unitbuf); - return str; - } - inline ios_base& nounitbuf (ios_base& str){ - str.unsetf(ios_base::unitbuf); - return str; - } - inline ios_base& internal (ios_base& str){ - str.setf(ios_base::internal, ios_base::adjustfield); - return str; - } - inline ios_base& left (ios_base& str){ - str.setf(ios_base::left, ios_base::adjustfield); - return str; - } - inline ios_base& right (ios_base& str){ - str.setf(ios_base::right, ios_base::adjustfield); - return str; - } - - inline ios_base& dec (ios_base& str){ - str.setf(ios_base::dec, ios_base::basefield); - return str; - } - inline ios_base& hex (ios_base& str){ - str.setf(ios_base::hex, ios_base::basefield); - return str; - } - inline ios_base& oct (ios_base& str){ - str.setf(ios_base::oct, ios_base::basefield); - return str; - } - - inline ios_base& fixed (ios_base& str){ - str.setf(ios_base::fixed, ios_base::floatfield); - return str; - } - inline ios_base& scientific (ios_base& str){ - str.setf(ios_base::scientific, ios_base::floatfield); - return str; - } - - - //basic_ios class definition - - - template class _UCXXEXPORT basic_ios - : public ios_base - { - public: - // Types: - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - typedef traits traits_type; - - _UCXXEXPORT operator void*() const{ - if(fail() ){ - return 0; - } - return (void *)(1); //Must return a non-NULL pointer (though it can be *any* pointer) - } - - _UCXXEXPORT bool operator!() const{ - return fail(); - } - _UCXXEXPORT iostate rdstate() const{ - return mstate; - } - _UCXXEXPORT void clear(iostate state = goodbit){ - if(rdbuf()!=0){ - mstate = state; - }else{ - mstate = state|ios_base::badbit; - } - } - _UCXXEXPORT void setstate(iostate state) { - clear(rdstate() | state); -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ - if(rdstate() & throw_mask){ - throw failure(); - } -#endif - } - - _UCXXEXPORT bool good() const{ - return (rdstate() == 0); - } - _UCXXEXPORT bool eof() const{ - if(rdstate() & eofbit){ - return true; - } - return false; - } - _UCXXEXPORT bool fail() const{ - if( mstate & (failbit | badbit) ){ - return true; - } - return false; - } - - _UCXXEXPORT bool bad() const{ - if(mstate & badbit){ - return true; - } - return false; - } - - _UCXXEXPORT iostate exceptions() const{ - return throw_mask; - } - _UCXXEXPORT void exceptions(iostate except){ - throw_mask = except; - } - - explicit _UCXXEXPORT basic_ios(basic_streambuf* sb) : fill_char(' '), mtied(0), mstreambuf(0){ - init(sb); - } - - basic_ios() : mtied(0), mstreambuf(0){ } - - virtual _UCXXEXPORT ~basic_ios(){ - } - - _UCXXEXPORT basic_ostream* tie() const{ - return mtied; - } - _UCXXEXPORT basic_ostream* tie(basic_ostream* tiestr){ - basic_ostream* retval= mtied; - mtied = tiestr; - return retval; - } - _UCXXEXPORT basic_streambuf* rdbuf() const{ - return mstreambuf; - } - _UCXXEXPORT basic_streambuf* rdbuf(basic_streambuf* sb){ - basic_streambuf* retval = mstreambuf; - mstreambuf = sb; - return retval; - } - _UCXXEXPORT basic_ios& copyfmt(const basic_ios& rhs); - _UCXXEXPORT char_type fill() const{ - return fill_char; - } - _UCXXEXPORT char_type fill(char_type ch){ - char_type temp = fill_char; - fill_char = ch; - return temp; - } - - _UCXXEXPORT locale imbue(const locale& loc){ - return ios_base::imbue(loc); - } - _UCXXEXPORT char narrow(char_type c, char dfault) const; - _UCXXEXPORT char_type widen(char c) const; - - protected: - char_type fill_char; - basic_ostream* mtied; - basic_streambuf* mstreambuf; - iostate throw_mask; - _UCXXEXPORT basic_ios(const basic_ios &){ } - _UCXXEXPORT basic_ios & operator=(const basic_ios &){ return *this; } - _UCXXEXPORT void init(basic_streambuf* sb){ - ios_base::mformat = skipws|dec; - mstreambuf = sb; - mstate = goodbit; - throw_mask = goodbit; - } - }; - -#ifdef __UCLIBCXX_EXPAND_IOS_CHAR__ -#ifndef __UCLIBCXX_COMPILE_IOS__ - - template <> _UCXXEXPORT void basic_ios >::clear(iostate state); - template <> _UCXXEXPORT void basic_ios >::setstate(iostate state); - -#endif -#endif - - - template - inline char basic_ios::narrow(char_type c, char dfault) const - { - return dfault; - } - - template <> - inline char basic_ios >::narrow(char_type c, char) const - { - return c; - } - -#ifdef __UCLIBCXX_HAS_WCHAR__ - - template <> - inline char basic_ios >::narrow(char_type c, char dfault) const - { - char retval = wctob (c); - if(retval == EOF){ - retval = dfault; - } - return retval; - } - -#endif //__UCLIBCXX_HAS_WCHAR__ - - template - inline typename basic_ios::char_type - basic_ios::widen(char c) const - { - return c; - } - - template <> - inline basic_ios >::char_type - basic_ios >::widen(char c) const - { - return c; - } - -#ifdef __UCLIBCXX_HAS_WCHAR__ - - template <> - inline basic_ios >::char_type - basic_ios >::widen(char c) const - { - return btowc(c); - } - -#endif //__UCLIBCXX_HAS_WCHAR__ - - - template class _UCXXEXPORT fpos{ - public: - _UCXXEXPORT fpos(stateT s){ - st = s; - } - _UCXXEXPORT stateT state() const{ - return st; - } - _UCXXEXPORT void state(stateT s){ - st = s; - } - _UCXXEXPORT bool operator==(const fpos &rhs){ - return st == rhs.st; - } - _UCXXEXPORT bool operator!=(const fpos &rhs){ - return st == rhs.st; - } - _UCXXEXPORT fpos & operator+(const streamoff & o){ - st += o; - return *this; - } - _UCXXEXPORT fpos & operator-(const streamoff & o){ - st -= o; - return *this; - } - _UCXXEXPORT streamoff operator-(const fpos & rhs){ - return st - rhs.st; - } - - - private: - stateT st; - }; - - -} - -#pragma GCC visibility pop - -#endif - diff --git a/DSTAT1/src/avr-stl/include/iosfwd b/DSTAT1/src/avr-stl/include/iosfwd deleted file mode 100644 index ea75a04..0000000 --- a/DSTAT1/src/avr-stl/include/iosfwd +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include - -#ifdef __AVR__ -class HardwareSerial; -class LiquidCrystal; -#endif - -#ifndef __HEADER_STD_IOSFWD -#define __HEADER_STD_IOSFWD 1 - -#pragma GCC visibility push(default) - -namespace std { - class ios_base; - template<> class char_traits; - - template > class basic_ios; - - template > class basic_streambuf; - template > class basic_istream; - template > class basic_ostream; - template > class basic_iostream; - - template , - class Allocator = allocator > class basic_stringbuf; - - template , - class Allocator = allocator > class basic_istringstream; - - template , - class Allocator = allocator > class basic_ostringstream; - - template , - class Allocator = allocator > class basic_stringstream; - - template > class basic_filebuf; - - template > class basic_ifstream; - - template > class basic_ofstream; - - template > class basic_fstream; - - template > class basic_istreambuf_iterator; - - template > class basic_ostreambuf_iterator; - - typedef basic_ios ios; - - typedef basic_streambuf streambuf; - typedef basic_istream istream; - typedef basic_ostream ostream; - typedef basic_iostream iostream; - - typedef basic_stringbuf stringbuf; - typedef basic_istringstream istringstream; - typedef basic_ostringstream ostringstream; - typedef basic_stringstream stringstream; - - typedef basic_filebuf filebuf; - typedef basic_ifstream ifstream; - typedef basic_ofstream ofstream; - typedef basic_fstream fstream; - -#ifdef __AVR__ -// specialisations for HardwareSerial - - template , class Tserial=HardwareSerial> class basic_serialbuf; - template , class Tserial=HardwareSerial> class basic_iserialstream; - template , class Tserial=HardwareSerial> class basic_oserialstream; - - typedef basic_iserialstream ihserialstream; - typedef basic_oserialstream ohserialstream; - -// specialisations for LiquidCrystal - - template > class basic_lcdbuf; - template > class basic_olcdstream; - - typedef basic_olcdstream olcdstream; -#endif - - template class fpos; - typedef fpos::state_type> streampos; -} - -#pragma GCC visibility pop - -#endif diff --git a/DSTAT1/src/avr-stl/include/iostream b/DSTAT1/src/avr-stl/include/iostream deleted file mode 100644 index bf06799..0000000 --- a/DSTAT1/src/avr-stl/include/iostream +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include - -#ifndef __HEADER_STD_IOSTREAM -#define __HEADER_STD_IOSTREAM 1 - -#include -#include -#include -#include - -#ifndef __AVR__ -#include -#include -#endif - - -#pragma GCC visibility push(default) - -namespace std{ -#ifdef __UCLIBCXX_SUPPORT_CIN__ - extern istream cin; -#endif -#ifdef __UCLIBCXX_SUPPORT_COUT__ - extern ostream cout; -#endif -#ifdef __UCLIBCXX_SUPPORT_CERR__ - extern ostream cerr; -#endif -#ifdef __UCLIBCXX_SUPPORT_CLOG__ - extern ostream clog; -#endif -#ifdef __UCLIBCXX_SUPPORT_WCIN__ - extern wistream wcin; -#endif -#ifdef __UCLIBCXX_SUPPORT_WCOUT__ - extern wostream wcout; -#endif -#ifdef __UCLIBCXX_SUPPORT_WCERR__ - extern wostream wcerr; -#endif -#ifdef __UCLIBCXX_SUPPORT_WCLOG__ - extern wostream wclog; -#endif - - - template class _UCXXEXPORT basic_iostream : - public basic_istream, public basic_ostream - { - public: - // constructor/destructor - explicit _UCXXEXPORT basic_iostream(basic_streambuf* sb); - virtual _UCXXEXPORT ~basic_iostream(); //Below - }; - - template _UCXXEXPORT - basic_iostream:: basic_iostream(basic_streambuf* sb) - : basic_ios(sb), basic_istream(sb), basic_ostream(sb) - { - return; - } - - - template _UCXXEXPORT basic_iostream::~basic_iostream(){ - return; - } - - -#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ -#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_IOSTREAM__ - - template <> _UCXXEXPORT basic_iostream >:: - basic_iostream(basic_streambuf >* sb); - template <> _UCXXEXPORT basic_iostream >::~basic_iostream(); - -#endif -#endif -#endif - - - -} - -#pragma GCC visibility pop - -#endif diff --git a/DSTAT1/src/avr-stl/include/istream b/DSTAT1/src/avr-stl/include/istream deleted file mode 100644 index caeda5d..0000000 --- a/DSTAT1/src/avr-stl/include/istream +++ /dev/null @@ -1,601 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc C++ Library. This library is free - software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) - any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this library; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. -*/ - -#include -#include -#include -#include -#include - -#ifndef __STD_HEADER_ISTREAM -#define __STD_HEADER_ISTREAM 1 - -#pragma GCC visibility push(default) - -namespace std{ - - typedef basic_istream istream; - -#ifdef __UCLIBCXX_HAS_WCHAR__ - typedef basic_istream wistream; -#endif - - template basic_istream& ws(basic_istream& is); - - template class _UCXXEXPORT basic_istream : - virtual public basic_ios - { - public: - - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - typedef basic_streambuf streambuf_type; - typedef traits traits_type; - - explicit basic_istream(basic_streambuf* sb) - : basic_ios(sb), count_last_ufmt_input(0) - { - basic_ios::init(sb); - } - virtual ~basic_istream() { } - - class sentry; - - basic_istream& operator>>(basic_istream& (*pf)(basic_istream&)); - basic_istream& operator>>(basic_ios& (*pf)(basic_ios&)); - basic_istream& operator>>(ios_base& (*pf)(ios_base&)); - basic_istream& operator>>(bool& n); - basic_istream& operator>>(short& n); - basic_istream& operator>>(unsigned short& n); - basic_istream& operator>>(int& n); - basic_istream& operator>>(unsigned int& n); - basic_istream& operator>>(long& n); - basic_istream& operator>>(unsigned long& n); - basic_istream& operator>>(void*& p); - basic_istream& operator>>(basic_streambuf* sb); - -#ifdef __UCLIBCXX_HAS_FLOATS__ - basic_istream& operator>>(float& f); - basic_istream& operator>>(double& f); - basic_istream& operator>>(long double& f); -#endif - - _UCXXEXPORT streamsize gcount() const{ - return count_last_ufmt_input; - } - - _UCXXEXPORT int_type get(); //below - _UCXXEXPORT basic_istream& get(char_type& c); //Below - - _UCXXEXPORT basic_istream& get(char_type* s, streamsize n){ - return get(s, n, basic_ios::widen('\n')); - } - - _UCXXEXPORT basic_istream& get(char_type* s, streamsize n, char_type delim){ - sentry(*this, true); - streamsize i = 0; - int_type c; - for(i=0;i::mstreambuf->sgetc(); - basic_ios::mstreambuf->sbumpc(); - if(c == traits::eof() ){ - if(i==0){ - basic_ios::setstate(ios_base::failbit); - }else{ - basic_ios::setstate(ios_base::eofbit); - } - break; - } - if(c == delim){ - if(i==0){ - basic_ios::setstate(ios_base::failbit); - } - basic_ios::mstreambuf->sputbackc(c); - break; - } - s[i] = c; - } - s[i] = traits::eos(); - count_last_ufmt_input = i; - return *this; - } - - _UCXXEXPORT basic_istream& get(basic_streambuf& sb){ - return get(sb, basic_ios::widen('\n')); - } - - _UCXXEXPORT basic_istream& get(basic_streambuf& sb, char_type delim){ - sentry(*this, true); - streamsize i = 0; - int_type c; - while(1){ //We will exit internally based upon error conditions - c = basic_ios::mstreambuf->sgetc(); - if(c == traits::eof()){ - if(i==0){ - basic_ios::setstate(ios_base::failbit); - }else{ - basic_ios::setstate(ios_base::eofbit); - } - count_last_ufmt_input = i; - return *this; - } - if(c == delim){ - if(i==0){ - basic_ios::setstate(ios_base::failbit); - } - count_last_ufmt_input = i; - return *this; - } - if(sb.sputc(c) != c){ //Error doing output - count_last_ufmt_input = i; - return *this; - } - ++i; - basic_ios::mstreambuf->sbumpc(); - } - } - - _UCXXEXPORT basic_istream& getline(char_type* s, streamsize n){ - return getline(s, n, basic_ios::widen('\n')); - } - - _UCXXEXPORT basic_istream& getline(char_type* s, streamsize n, char_type delim){ - sentry(*this, true); - streamsize i = 0; - int_type c; - for(i=0;i::mstreambuf->sgetc(); - if(c == traits::eof() ){ - if( basic_ios::eof() ){ - basic_ios::setstate(ios_base::failbit); - }else{ - basic_ios::setstate(ios_base::eofbit); - } - count_last_ufmt_input = i; - s[i] = traits::eos(); - return *this; - } - if(basic_ios::mstreambuf->sbumpc()==traits::eof() ){ - basic_ios::setstate(ios_base::eofbit); - } - if(c == delim){ - count_last_ufmt_input = i+1; - s[i] = traits::eos(); - return *this; - } - s[i] = c; - } - s[n-1] = traits::eos(); - return *this; - } - - _UCXXEXPORT basic_istream& ignore (streamsize n = 1, int_type delim = traits::eof()){ - sentry(*this, true); - streamsize i; - int_type c; - for(i=0;i::mstreambuf->sgetc(); - if(c == traits::eof()){ - basic_ios::setstate(ios_base::eofbit); - return *this; - } - basic_ios::mstreambuf->sbumpc(); - if(c == delim){ - return *this; - } - } - return *this; - } - - _UCXXEXPORT int_type peek(){ - if(basic_ios::good() == false){ - return traits::eof(); - }else{ - int_type c = basic_ios::mstreambuf->sgetc(); - if(c == traits::eof()){ - basic_ios::setstate(ios_base::eofbit); - } - return basic_ios::mstreambuf->sgetc(); - } - } - - _UCXXEXPORT basic_istream& read (char_type* s, streamsize n){ - sentry(*this, true); - streamsize i; - int_type c; - for(i=0;i::mstreambuf->sgetc(); - - if(c == traits::eof()){ - basic_ios::setstate(ios_base::failbit); - basic_ios::setstate(ios_base::eofbit); - count_last_ufmt_input = i; - return *this; - } - basic_ios::mstreambuf->sbumpc(); - s[i] = c; - } - count_last_ufmt_input = n; - return *this; - } - - _UCXXEXPORT streamsize readsome(char_type* s, streamsize n){ - sentry(*this, true); - if(!basic_ios::good()){ - count_last_ufmt_input = 0; - basic_ios::setstate(ios_base::failbit); - return 0; - } - - if( basic_ios::mstreambuf->in_avail() == -1){ - count_last_ufmt_input=0; - basic_ios::setstate(ios_base::eofbit); - return 0; - } - - if(n > basic_ios::mstreambuf->in_avail() ){ - n = basic_ios::mstreambuf->in_avail(); - } - - streamsize i; - int_type c; - - for(i=0;i::mstreambuf->sgetc(); - basic_ios::mstreambuf->sbumpc(); - s[i] = c; - } - count_last_ufmt_input = n; - return n; - } - - _UCXXEXPORT basic_istream& putback(char_type c){ - sentry(*this, true); - if(!basic_ios::good()){ - basic_ios::setstate(ios_base::failbit); - return *this; - } - if(basic_ios::mstreambuf == 0){ - basic_ios::setstate(ios_base::badbit); - return *this; - } - if(basic_ios::mstreambuf->sputbackc(c) == traits::eof()){ - basic_ios::setstate(ios_base::badbit); - return *this; - } - return *this; - } - - _UCXXEXPORT basic_istream& unget(){ - sentry(*this, true); - if(!basic_ios::good()){ - basic_ios::setstate(ios_base::failbit); - return *this; - } - if(basic_ios::mstreambuf == 0){ - basic_ios::setstate(ios_base::failbit); - return *this; - } - if(basic_ios::mstreambuf->sungetc() == traits::eof()){ - basic_ios::setstate(ios_base::failbit); - } - return *this; - } - - _UCXXEXPORT int sync(){ - sentry(*this, true); - if(basic_ios::mstreambuf == 0){ - return -1; - } - if(basic_ios::mstreambuf->pubsync() == -1){ - basic_ios::setstate(ios_base::badbit); - return traits::eof(); - } - return 0; - } - - _UCXXEXPORT pos_type tellg(){ - if(basic_ios::fail() !=false){ - return pos_type(-1); - } - return basic_ios::mstreambuf->pubseekoff(0, ios_base::cur, ios_base::in); - } - - _UCXXEXPORT basic_istream& seekg(pos_type pos){ - if(basic_ios::fail() !=true){ - basic_ios::mstreambuf->pubseekpos(pos); - } - return *this; - } - - _UCXXEXPORT basic_istream& seekg(off_type off, ios_base::seekdir dir){ - if(basic_ios::fail() !=true){ - basic_ios::mstreambuf->pubseekoff(off, dir); - } - return *this; - } - - protected: - _UCXXEXPORT basic_istream(const basic_istream &): basic_ios() { } - _UCXXEXPORT basic_istream & operator=(const basic_istream &){ return *this; } - streamsize count_last_ufmt_input; - - }; - - template > class _UCXXEXPORT basic_istream::sentry { - bool ok; - public: - explicit _UCXXEXPORT sentry(basic_istream& os, bool noskipws = false){ - if(os.good() !=0){ //Prepare for output - } - - //Flush any tied buffer - if(os.tie() != 0){ - os.tie()->flush(); - } - if(!noskipws){ - __skipws(os); - } - - ok = true; - } - _UCXXEXPORT ~sentry() { } - _UCXXEXPORT operator bool() { - return ok; - } - }; - - //Template implementations of basic_istream functions which may be partially specialized - //For code reduction - - template - _UCXXEXPORT typename basic_istream::int_type basic_istream::get(){ - sentry(*this, true); - int_type retval = basic_ios::mstreambuf->sgetc(); - if(retval == traits::eof()){ - count_last_ufmt_input = 0; - basic_ios::setstate(ios_base::eofbit); - }else{ - count_last_ufmt_input = 1; - basic_ios::mstreambuf->sbumpc(); - } - return retval; - } - - template - _UCXXEXPORT basic_istream& basic_istream::get(char_type& c){ - sentry(*this, true); - int_type retval = basic_ios::mstreambuf->sgetc(); - if(retval == traits::eof()){ - count_last_ufmt_input = 0; - basic_ios::setstate(ios_base::eofbit); - basic_ios::setstate(ios_base::failbit); - }else{ - count_last_ufmt_input = 1; - c = traits::to_char_type(retval); - basic_ios::mstreambuf->sbumpc(); - } - return *this; - } - - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(bool& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(short& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(unsigned short& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& basic_istream::operator>>(int& n){ - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& basic_istream::operator>>(unsigned int& n){ - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& basic_istream::operator>>(long int& n){ - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(unsigned long int& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - -#ifdef __UCLIBCXX_HAS_FLOATS__ - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(float& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(double& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(long double& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } -#endif - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(void *& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, charT& c) - { - typename basic_istream::sentry s(is); - is.get(c); - return is; - } - - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, unsigned char& c) - { - typename basic_istream::sentry s(is); - char b; - is.get(b); - c = b; - return is; - } - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, signed char& c) - { - typename basic_istream::sentry s(is); - is.get(c); - return is; - } - - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, charT* c) - { - typename basic_istream::sentry s(is); - int n = is.width(); - if(n == 0){ - n = __STRING_MAX_UNITS; - } - is.get(c, n); - return is; - - } - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, unsigned char* c) - { - typename basic_istream::sentry s(is); - int n = is.width(); - if(n == 0){ - n = __STRING_MAX_UNITS; - } - is.get(c, n); - return is; - } - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, signed char* c) - { - typename basic_istream::sentry s(is); - int n = is.width(); - if(n == 0){ - n = __STRING_MAX_UNITS; - } - is.get(c, n); - return is; - } - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(basic_istream& (*pf)(basic_istream&)) - { - sentry(*this); - pf(*this); - return *this; - } - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(basic_ios& (*pf)(basic_ios&)) - { - sentry(*this); - pf(*this); - return *this; - } - - template _UCXXEXPORT basic_istream& - ws(basic_istream& is) - { - __skipws(is); - return is; - } - - -#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_ISTREAM__ - - - template <> _UCXXEXPORT istream & basic_istream >::get(char & c); - template <> _UCXXEXPORT istream::int_type basic_istream >::get(); - - template <> _UCXXEXPORT istream & istream::operator>>(bool &n); - template <> _UCXXEXPORT istream & istream::operator>>(short &n); - template <> _UCXXEXPORT istream & istream::operator>>(unsigned short &n); - template <> _UCXXEXPORT istream & istream::operator>>(int &n); - template <> _UCXXEXPORT istream & istream::operator>>(unsigned int &n); - template <> _UCXXEXPORT istream & istream::operator>>(long unsigned &n); - template <> _UCXXEXPORT istream & istream::operator>>(long int &n); - template <> _UCXXEXPORT istream & istream::operator>>(void *& p); - -#ifdef __UCLIBCXX_HAS_FLOATS__ - template <> _UCXXEXPORT istream & istream::operator>>(float &f); - template <> _UCXXEXPORT istream & istream::operator>>(double &f); - template <> _UCXXEXPORT istream & istream::operator>>(long double &f); -#endif - - template <> _UCXXEXPORT istream & operator>>(istream & is, char & c); - - template <> _UCXXEXPORT void __skipws(basic_istream >& is); - -#endif -#endif - - - -} - -#pragma GCC visibility pop - -#endif - diff --git a/DSTAT1/src/avr-stl/include/istream_helpers b/DSTAT1/src/avr-stl/include/istream_helpers deleted file mode 100644 index a92dc0a..0000000 --- a/DSTAT1/src/avr-stl/include/istream_helpers +++ /dev/null @@ -1,344 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include - -#include - -#ifndef __STD_HEADER_ISTREAM_HELPERS -#define __STD_HEADER_ISTREAM_HELPERS 1 - -#pragma GCC visibility push(default) - -namespace std{ - - - /* We are making the following template class for serveral reasons. Firstly, - * we want to keep the main istream code neat and tidy. Secondly, we want it - * to be easy to do partial specialization of the istream code so that it can - * be expanded and put into the library. This will allow us to make application - * code smaller at the expense of increased library size. This is a fair - * trade-off when there are multiple applications being compiled. Also, this - * feature will be used optionally via configuration options. It will also - * allow us to keep the code bases in sync, dramatically simplifying the - * maintenance required. We specialized for char because wchar and others - * require different scanf functions - */ - - template _UCXXEXPORT - basic_string _readToken(basic_istream& stream) - { - basic_string temp; - typename traits::int_type c; - while(true){ - c = stream.rdbuf()->sgetc(); - if(c != traits::eof() && isspace(c) == false){ - stream.rdbuf()->sbumpc(); - temp.append(1, traits::to_char_type(c)); - }else{ - break; - } - } - if (temp.size() == 0) - stream.setstate(ios_base::eofbit|ios_base::failbit); - - return temp; - } - - template _UCXXEXPORT - basic_string _readTokenDecimal(basic_istream& stream) - { - basic_string temp; - typename traits::int_type c; - while(true){ - c = stream.rdbuf()->sgetc(); - if(c != traits::eof() && isspace(c) == false && (isdigit(c) || c == '.' || c == ',' )){ - stream.rdbuf()->sbumpc(); - temp.append(1, traits::to_char_type(c)); - }else{ - break; - } - } - if (temp.size() == 0) - stream.setstate(ios_base::eofbit|ios_base::failbit); - - return temp; - } - -#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ - - template <> _UCXXEXPORT string _readToken >(istream & stream); - -#endif - - - template class _UCXXEXPORT __istream_readin{ - public: - static void readin(basic_istream& stream, dataType & var); - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, bool & var) - { - basic_string temp; - temp = _readToken( stream); - if(temp == "true" || temp == "True" || temp == "TRUE" || temp == "1"){ - var = true; - }else{ - var = false; - } - } - }; - - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, short & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%hd", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%ho", (unsigned short int *)(&var) ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%hX", (unsigned short int *)(&var) ); - }else{ - sscanf(temp.c_str(), "%hx", (unsigned short int *)(&var) ); - } - }else{ - sscanf(temp.c_str(), "%hi", &var); - - } - } - } - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, unsigned short & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%hu", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%ho", &var); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%hX", &var ); - }else{ - sscanf(temp.c_str(), "%hx", &var); - } - }else{ - sscanf(temp.c_str(), "%hi", (signed short int*)(&var) ); - } - } - } - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, int & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%d", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%o", (unsigned int *)(&var) ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%X", (unsigned int *)(&var) ); - }else{ - sscanf(temp.c_str(), "%x", (unsigned int *)(&var) ); - } - }else{ - sscanf(temp.c_str(), "%i", &var); - } - } - } - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, unsigned int & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%u", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%o", (unsigned int *)(&var) ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%X", (unsigned int *)(&var) ); - }else{ - sscanf(temp.c_str(), "%x", (unsigned int *)(&var) ); - } - }else{ - sscanf(temp.c_str(), "%i", (int *)(&var) ); - } - } - - } - }; - - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, long int & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%ld", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%lo", (unsigned long int *)(&var) ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%lX", (unsigned long int *)(&var) ); - }else{ - sscanf(temp.c_str(), "%lx", (unsigned long int *)(&var) ); - } - }else{ - sscanf(temp.c_str(), "%li", (long int *)(&var) ); - } - } - - } - }; - - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, unsigned long int & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%lu", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%lo", &var ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%lX", &var ); - }else{ - sscanf(temp.c_str(), "%lx", &var); - } - }else{ - sscanf(temp.c_str(), "%li", (long int *)(&var) ); - } - } - } - }; - - -#ifdef __UCLIBCXX_HAS_FLOATS__ - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, float & var) - { - basic_string temp; - temp = _readTokenDecimal( stream); - - sscanf(temp.c_str(), "%g", &var); - } - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, double & var) - { - basic_string temp; - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%lg", &var); - } - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, long double & var) - { - basic_string temp; - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%Lg", &var); - } - }; - -#endif // ifdef __UCLIBCXX_HAS_FLOATS__ - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, void* & var) - { - basic_string temp; - temp = _readToken( stream); - sscanf(temp.c_str(), "%p", &var); - } - }; - - - template void __skipws(basic_istream& is){ - const typename basic_istream::int_type eof = traits::eof(); - typename basic_istream::int_type c; - //While the next character normally read doesn't equal eof - //and that character is a space, advance to the next read position - //Thus itterating through all whitespace until we get to the meaty stuff - while ( - !traits::eq_int_type((c = is.rdbuf()->sgetc()), eof) - && isspace(c) - ) - { - is.rdbuf()->sbumpc(); - } - if(traits::eq_int_type(c, eof)){ - is.setstate(ios_base::eofbit); - } - } -} - -#pragma GCC visibility pop - -#endif - - - diff --git a/DSTAT1/src/avr-stl/include/iterator b/DSTAT1/src/avr-stl/include/iterator deleted file mode 100644 index fe2b8e8..0000000 --- a/DSTAT1/src/avr-stl/include/iterator +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_ITERATOR -#define __SGI_STL_ITERATOR - -#include -#include -#include - -#ifdef __STL_USE_NEW_IOSTREAMS -#include -#else /* __STL_USE_NEW_IOSTREAMS */ -#include -#endif /* __STL_USE_NEW_IOSTREAMS */ - -#include -#include - -#endif /* __SGI_STL_ITERATOR */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/lcdostream b/DSTAT1/src/avr-stl/include/lcdostream deleted file mode 100644 index 126e96a..0000000 --- a/DSTAT1/src/avr-stl/include/lcdostream +++ /dev/null @@ -1,192 +0,0 @@ -/* - * lcdostream - * Implementation of output stream for the Arduino LiquidCrystal library - * - * Created on: 6 Jan 2011 - * Author: Andy Brown - * - * http://andybrown.me.uk/ws/terms-and-conditions - */ - - -#ifndef __65B857C4_2BD5_4044_8D08C067F4A032DC -#define __65B857C4_2BD5_4044_8D08C067F4A032DC - -#include - -#include -#include -#include -#include -#include - - -namespace std -{ -/* - * basic_lcdbuf implements an unbuffered basic_streambuf as a backing buffer - * for the output class. - */ - - template - class basic_lcdbuf : public basic_streambuf - { - public: - - /* - * Types used here - */ - - typedef charT char_type; - typedef typename traits::int_type int_type; - - /* - * constructor - wraps an existing LiquidCrystal class instance - */ - - explicit basic_lcdbuf(LiquidCrystal& lcd_) - : _lcd(lcd_) - { - basic_streambuf::openedFor = ios_base::out; - } - - /* - * Required to maintain the chain - */ - - virtual ~basic_lcdbuf() { } - - /* - * Get a reference to the wrapped object - */ - - LiquidCrystal& lcd() { return _lcd; } - - protected: - - /* - * Write up to n chars - */ - - virtual streamsize xsputn(const char_type* s, streamsize n){ - - for(streamsize i=0;i class basic_olcdstream - : public basic_ostream - { - public: - - /* - * Types used here - */ - - typedef charT char_type; - - - /* - * Constructor - */ - - explicit basic_olcdstream(LiquidCrystal& lcd_) - : basic_ios(&sb), basic_ostream(&sb), sb(lcd_) - { - } - - /* - * Required to maintain the chain - */ - - virtual ~basic_olcdstream() { } - - - /* - * Move the LCD cursor - */ - - void moveCursor(int x_,int y_) { - sb.lcd().setCursor(x_,y_); - } - - void clear() { - sb.lcd().clear(); - } - - /* - * The wrapped object - */ - - private: - basic_lcdbuf sb; - }; - - -/* - * Move the cursor - */ - - struct __move{ - int _x,_y; - __move(int x,int y): _x(x),_y(y) { } - }; - - inline __move move(int x,int y) { - return __move(x,y); - } - - template basic_olcdstream& - operator<<(basic_olcdstream& os, const __move m) - { - os.moveCursor(m._x,m._y); - return os; - } - - -/* - * Clear screen - */ - - struct __clear{ - }; - - inline __clear clear() { - return __clear(); - } - - template basic_olcdstream& - operator<<(basic_olcdstream& os, const __clear c) - { - os.clear(); - return os; - } -} - - -#endif diff --git a/DSTAT1/src/avr-stl/include/limits b/DSTAT1/src/avr-stl/include/limits deleted file mode 100644 index f1a9a09..0000000 --- a/DSTAT1/src/avr-stl/include/limits +++ /dev/null @@ -1,537 +0,0 @@ -/* - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is not portable code. Parts of numeric_limits<> are - * inherently machine-dependent. At present this file is suitable - * for the MIPS and ia32 architectures. - */ - -#ifndef __SGI_CPP_LIMITS -#define __SGI_CPP_LIMITS - -#include -#include -#include - -__STL_BEGIN_NAMESPACE - -enum float_round_style { - round_indeterminate = -1, - round_toward_zero = 0, - round_to_nearest = 1, - round_toward_infinity = 2, - round_toward_neg_infinity = 3 -}; - -enum float_denorm_style { - denorm_indeterminate = -1, - denorm_absent = 0, - denorm_present = 1 -}; - -// The C++ standard (section 18.2.1) requires that some of the members of -// numeric_limits be static const data members that are given constant- -// initializers within the class declaration. On compilers where the -// __STL_STATIC_CONST_INIT_BUG macro is defined, it is impossible to write -// a standard-conforming numeric_limits class. -// -// There are two possible workarounds: either initialize the data -// members outside the class, or change them from data members to -// enums. Neither workaround is satisfactory: the former makes it -// impossible to use the data members in constant-expressions, and the -// latter means they have the wrong type and that it is impossible to -// take their addresses. We choose the former workaround. - -#ifdef __STL_STATIC_CONST_INIT_BUG -# define __STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \ - enum { __mem_name = __mem_value } -#else /* __STL_STATIC_CONST_INIT_BUG */ -# define __STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \ - static const __mem_type __mem_name = __mem_value -#endif /* __STL_STATIC_CONST_INIT_BUG */ - -// Base class for all specializations of numeric_limits. - -template -class _Numeric_limits_base { -public: - __STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, false); - - static __number min() __STL_NOTHROW { return __number(); } - static __number max() __STL_NOTHROW { return __number(); } - - __STL_DECLARE_LIMITS_MEMBER(int, digits, 0); - __STL_DECLARE_LIMITS_MEMBER(int, digits10, 0); - - __STL_DECLARE_LIMITS_MEMBER(bool, is_signed, false); - __STL_DECLARE_LIMITS_MEMBER(bool, is_integer, false); - __STL_DECLARE_LIMITS_MEMBER(bool, is_exact, false); - - __STL_DECLARE_LIMITS_MEMBER(int, radix, 0); - - static __number epsilon() __STL_NOTHROW { return __number(); } - static __number round_error() __STL_NOTHROW { return __number(); } - - __STL_DECLARE_LIMITS_MEMBER(int, min_exponent, 0); - __STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, 0); - __STL_DECLARE_LIMITS_MEMBER(int, max_exponent, 0); - __STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, 0); - - __STL_DECLARE_LIMITS_MEMBER(bool, has_infinity, false); - __STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN, false); - __STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, false); - __STL_DECLARE_LIMITS_MEMBER(float_denorm_style, - has_denorm, - denorm_absent); - __STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss, false); - - static __number infinity() __STL_NOTHROW { return __number(); } - static __number quiet_NaN() __STL_NOTHROW { return __number(); } - static __number signaling_NaN() __STL_NOTHROW { return __number(); } - static __number denorm_min() __STL_NOTHROW { return __number(); } - - __STL_DECLARE_LIMITS_MEMBER(bool, is_iec559, false); - __STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, false); - __STL_DECLARE_LIMITS_MEMBER(bool, is_modulo, false); - - __STL_DECLARE_LIMITS_MEMBER(bool, traps, false); - __STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before, false); - __STL_DECLARE_LIMITS_MEMBER(float_round_style, - round_style, - round_toward_zero); -}; - -#ifdef __STL_STATIC_CONST_INIT_BUG -# define __STL_DEFINE_NUMERIC_BASE_MEMBER(__type, __mem) -#else /* __STL_STATIC_CONST_INIT_BUG */ -# define __STL_DEFINE_NUMERIC_BASE_MEMBER(__type, __mem) \ - template \ - const __type _Numeric_limits_base<__number>:: __mem -#endif /* __STL_STATIC_CONST_INIT_BUG */ - -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_specialized); -__STL_DEFINE_NUMERIC_BASE_MEMBER(int, digits); -__STL_DEFINE_NUMERIC_BASE_MEMBER(int, digits10); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_signed); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_integer); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_exact); -__STL_DEFINE_NUMERIC_BASE_MEMBER(int, radix); -__STL_DEFINE_NUMERIC_BASE_MEMBER(int, min_exponent); -__STL_DEFINE_NUMERIC_BASE_MEMBER(int, max_exponent); -__STL_DEFINE_NUMERIC_BASE_MEMBER(int, min_exponent10); -__STL_DEFINE_NUMERIC_BASE_MEMBER(int, max_exponent10); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_infinity); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_quiet_NaN); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_signaling_NaN); -__STL_DEFINE_NUMERIC_BASE_MEMBER(float_denorm_style, has_denorm); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_denorm_loss); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_iec559); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_bounded); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_modulo); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, traps); -__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, tinyness_before); -__STL_DEFINE_NUMERIC_BASE_MEMBER(float_round_style, round_style); - - -// Base class for integers. - -template -class _Integer_limits : public _Numeric_limits_base<_Int> -{ -public: - __STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true); - - static _Int min() __STL_NOTHROW { return __imin; } - static _Int max() __STL_NOTHROW { return __imax; } - - __STL_DECLARE_LIMITS_MEMBER(int, - digits, - (__idigits < 0) ? (int)(sizeof(_Int) * CHAR_BIT) - - (__imin == 0 ? 0 : 1) - : __idigits); - __STL_DECLARE_LIMITS_MEMBER(int, digits10, (digits * 301) / 1000); - // log 2 = 0.301029995664... - - __STL_DECLARE_LIMITS_MEMBER(bool, is_signed, __imin != 0); - __STL_DECLARE_LIMITS_MEMBER(bool, is_integer, true); - __STL_DECLARE_LIMITS_MEMBER(bool, is_exact, true); - __STL_DECLARE_LIMITS_MEMBER(int, radix, 2); - - __STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, true); - __STL_DECLARE_LIMITS_MEMBER(bool, is_modulo, __ismod); -}; - -#ifdef __STL_STATIC_CONST_INIT_BUG -# define __STL_DEFINE_INTEGER_LIMITS_MEMBER(__type, __mem) -#else /* __STL_STATIC_CONST_INIT_BUG */ -# define __STL_DEFINE_INTEGER_LIMITS_MEMBER(__type, __mem) \ - template \ - const __type _Integer_limits<_Int, __imin, __imax, __idig, __ismod>::__mem -#endif /* __STL_STATIC_CONST_INIT_BUG */ - -__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_specialized); -__STL_DEFINE_INTEGER_LIMITS_MEMBER(int, digits); -__STL_DEFINE_INTEGER_LIMITS_MEMBER(int, digits10); -__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_signed); -__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_integer); -__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_exact); -__STL_DEFINE_INTEGER_LIMITS_MEMBER(int, radix); -__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_bounded); -__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_modulo); - - -// Base class for floating-point numbers. -template -class _Floating_limits : public _Numeric_limits_base<__number> -{ -public: - __STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true); - - __STL_DECLARE_LIMITS_MEMBER(int, digits, __Digits); - __STL_DECLARE_LIMITS_MEMBER(int, digits10, __Digits10); - - __STL_DECLARE_LIMITS_MEMBER(bool, is_signed, true); - - __STL_DECLARE_LIMITS_MEMBER(int, radix, 2); - - __STL_DECLARE_LIMITS_MEMBER(int, min_exponent, __MinExp); - __STL_DECLARE_LIMITS_MEMBER(int, max_exponent, __MaxExp); - __STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, __MinExp10); - __STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, __MaxExp10); - - __STL_DECLARE_LIMITS_MEMBER(bool, has_infinity, true); - __STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN, true); - __STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, true); - __STL_DECLARE_LIMITS_MEMBER(float_denorm_style, - has_denorm, - denorm_indeterminate); - __STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss, false); - - __STL_DECLARE_LIMITS_MEMBER(bool, is_iec559, __IsIEC559); - __STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, true); - __STL_DECLARE_LIMITS_MEMBER(bool, traps, true); - __STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before, false); - - __STL_DECLARE_LIMITS_MEMBER(float_round_style, round_style, __RoundStyle); -}; - -#ifdef __STL_STATIC_CONST_INIT_BUG -# define __STL_DEFINE_FLOAT_LIMITS_MEMBER(__type, __mem) -#else /* __STL_STATIC_CONST_INIT_BUG */ -# define __STL_DEFINE_FLOAT_LIMITS_MEMBER(__type, __mem) \ - template \ - const __type _Floating_limits<__Num, __Dig, __Dig10, \ - __MnX, __MxX, __MnX10, __MxX10, \ - __IsIEEE, __Sty>:: __mem -#endif /* __STL_STATIC_CONST_INIT_BUG */ - -__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_specialized); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, digits); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, digits10); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_signed); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, radix); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, min_exponent); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, max_exponent); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, min_exponent10); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, max_exponent10); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_infinity); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_quiet_NaN); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_signaling_NaN); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(float_denorm_style, has_denorm); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_denorm_loss); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_iec559); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_bounded); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, traps); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, tinyness_before); -__STL_DEFINE_FLOAT_LIMITS_MEMBER(float_round_style, round_style); - - -#undef __STL_DECLARE_NUMERIC_LIMITS_MEMBER -#undef __STL_DEFINE_NUMERIC_BASE_MEMBER -#undef __STL_DEFINE_INTEGER_LIMITS_MEMBER -#undef __STL_DEFINE_FLOAT_LIMITS_MEMBER - -// Class numeric_limits - -// The unspecialized class. - -template -class numeric_limits : public _Numeric_limits_base<_Tp> {}; - -// Specializations for all built-in integral types. - -#ifndef __STL_NO_BOOL - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -#endif /* __STL_NO_BOOL */ - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -#ifdef __STL_HAS_WCHAR_T - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -#endif - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -#ifdef __STL_LONG_LONG - -// Some compilers have long long, but don't define the -// LONGLONG_MIN and LONGLONG_MAX macros in limits.h. This -// assumes that long long is 64 bits. -#if !defined(LONGLONG_MIN) && !defined(LONGLONG_MAX) \ - && !defined(ULONGLONG_MAX) - -#define ULONGLONG_MAX 0xffffffffffffffffLLU -#define LONGLONG_MAX 0x7fffffffffffffffLL -#define LONGLONG_MIN (-LONGLONG_MAX - 1LL) - -#endif - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -__STL_TEMPLATE_NULL -class numeric_limits - : public _Integer_limits -{}; - -#endif /* __STL_LONG_LONG */ - -// Specializations for all built-in floating-point type. - -__STL_TEMPLATE_NULL class numeric_limits - : public _Floating_limits -{ -public: - static float min() __STL_NOTHROW { return FLT_MIN; } - static float denorm_min() __STL_NOTHROW { return FLT_MIN; } - static float max() __STL_NOTHROW { return FLT_MAX; } - static float epsilon() __STL_NOTHROW { return FLT_EPSILON; } - static float round_error() __STL_NOTHROW { return 0.5f; } // Units: ulps. - static float infinity() __STL_NOTHROW; - static float quiet_NaN() __STL_NOTHROW; - static float signaling_NaN() __STL_NOTHROW; -}; - -__STL_TEMPLATE_NULL class numeric_limits - : public _Floating_limits -{ -public: - static double min() __STL_NOTHROW { return DBL_MIN; } - static double denorm_min() __STL_NOTHROW { return DBL_MIN; } - static double max() __STL_NOTHROW { return DBL_MAX; } - static double epsilon() __STL_NOTHROW { return DBL_EPSILON; } - static double round_error() __STL_NOTHROW { return 0.5; } // Units: ulps. - static double infinity() __STL_NOTHROW; - static double quiet_NaN() __STL_NOTHROW; - static double signaling_NaN() __STL_NOTHROW; -}; - -__STL_TEMPLATE_NULL class numeric_limits - : public _Floating_limits -{ -public: - static long double min() __STL_NOTHROW { return LDBL_MIN; } - static long double denorm_min() __STL_NOTHROW { return LDBL_MIN; } - static long double max() __STL_NOTHROW { return LDBL_MAX; } - static long double epsilon() __STL_NOTHROW { return LDBL_EPSILON; } - static long double round_error() __STL_NOTHROW { return 4; } // Units: ulps. - static long double infinity() __STL_NOTHROW; - static long double quiet_NaN() __STL_NOTHROW; - static long double signaling_NaN() __STL_NOTHROW; -}; - -// We write special values (Inf and NaN) as bit patterns and -// cast the the appropriate floating-point types. - -#if defined(_MIPSEB) -// Big-endian MIPS. float is 32 bits, double 64, long double 128. - -#define _Define_float(__f, __h, __l) \ - inline float numeric_limits::__f() __STL_NOTHROW { \ - static const unsigned short __x[2] = { __h, __l }; \ - return *reinterpret_cast(__x); } -#define _Define_double(__f, __h, __l) \ - inline double numeric_limits::__f() __STL_NOTHROW { \ - static const unsigned short __x[4] = { __h, __l }; \ - return *reinterpret_cast(__x); } -#define _Define_ldouble(__f, __h, __l) \ - inline long double numeric_limits::__f() __STL_NOTHROW { \ - static const unsigned short __x[8] = { __h, __l }; \ - return *reinterpret_cast(__x); } - -_Define_float(infinity, 0x7f80, 0) -_Define_float(quiet_NaN, 0x7f81, 0) -_Define_float(signaling_NaN, 0x7fc1, 0) - -_Define_double(infinity, 0x7ff0, 0) -_Define_double(quiet_NaN, 0x7ff1, 0) -_Define_double(signaling_NaN, 0x7ff9, 0) - -_Define_ldouble(infinity, 0x7ff0, 0) -_Define_ldouble(quiet_NaN, 0x7ff1, 0) -_Define_ldouble(signaling_NaN, 0x7ff9, 0) - -#elif defined(__i386) || defined(_M_IX86) -// Little-endian ia32. float is 32 bits, double 64, long double 80. - -#define _Define_float(__f, __h, __l) \ - inline float numeric_limits::__f() __STL_NOTHROW { \ - static const unsigned short __x[2] = { __l, __h }; \ - return *reinterpret_cast(__x); } -#define _Define_double(__f, __h, __l) \ - inline double numeric_limits::__f() __STL_NOTHROW { \ - static const unsigned short __x[4] = { 0, 0, __l, __h }; \ - return *reinterpret_cast(__x); } -#define _Define_ldouble(__f, __h, __l) \ - inline long double numeric_limits::__f() __STL_NOTHROW { \ - static const unsigned short __x[5] = { 0, 0, 0, __l, __h }; \ - return *reinterpret_cast(__x); } - -_Define_float(infinity, 0x7f80, 0) -_Define_float(quiet_NaN, 0x7fa0, 0) -_Define_float(signaling_NaN, 0x7fc0, 0) - -_Define_double(infinity, 0x7ff0, 0) -_Define_double(quiet_NaN, 0x7ff4, 0) -_Define_double(signaling_NaN, 0x7ff8, 0) - -_Define_ldouble(infinity, 0x7fff, 0x8000) -_Define_ldouble(quiet_NaN, 0x7fff, 0xa000) -_Define_ldouble(signaling_NaN, 0x7fff, 0xc000) - -#else - -/* This is an architecture we don't know how to handle. Return some - obviously wrong values. */ - -#define _Define_float(__f) \ - inline float numeric_limits::__f() __STL_NOTHROW { \ - return 0; } -#define _Define_double(__f) \ - inline double numeric_limits::__f() __STL_NOTHROW { \ - return 0; } -#define _Define_ldouble(__f) \ - inline long double numeric_limits::__f() __STL_NOTHROW { \ - return 0; } - -_Define_float(infinity) -_Define_float(quiet_NaN) -_Define_float(signaling_NaN) - -_Define_double(infinity) -_Define_double(quiet_NaN) -_Define_double(signaling_NaN) - -_Define_ldouble(infinity) -_Define_ldouble(quiet_NaN) -_Define_ldouble(signaling_NaN) - -#endif - -#undef _Define_float -#undef _Define_double -#undef _Define_ldouble - -__STL_END_NAMESPACE - -#endif /* __SGI_CPP_LIMITS */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/list b/DSTAT1/src/avr-stl/include/list deleted file mode 100644 index 5294f39..0000000 --- a/DSTAT1/src/avr-stl/include/list +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_LIST -#define __SGI_STL_LIST - -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_LIST */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/locale b/DSTAT1/src/avr-stl/include/locale deleted file mode 100644 index 29f972e..0000000 --- a/DSTAT1/src/avr-stl/include/locale +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include - -#ifndef __AVR__ -#include -#endif - -#ifndef __HEADER_STD_LOCALE -#define __HEADER_STD_LOCALE 1 - -#pragma GCC visibility push(default) - -namespace std{ - class _UCXXEXPORT locale { - public: - // types: - class facet; - class id; - typedef unsigned char category; - - static const category - none = 0, - collate = 0x01, ctype = 0x02, - monetary = 0x04, numeric = 0x08, - time = 0x10, messages = 0x20, - all = collate | ctype | monetary | numeric | time | messages; - - // construct/copy/destroy: - locale() throw(){ - return; - } - locale(const locale& other) throw(){ - (void)other; - return; - } - locale(const char *) throw(){ - return; - } - ~locale() throw(){ - return; - } - - const locale& operator=(const locale&) throw(){ - return *this; - } -#ifndef __AVR__ - std::string name() const { return "C"; } -#endif - }; - - class _UCXXEXPORT locale::facet { - friend class locale; - explicit facet(size_t = 0){ - return; - } - virtual ~facet(){ - return; - } - }; - - class _UCXXEXPORT locale::id { - id(){ } - }; - -} - -#pragma GCC visibility pop - -#endif diff --git a/DSTAT1/src/avr-stl/include/map b/DSTAT1/src/avr-stl/include/map deleted file mode 100644 index 4cfb765..0000000 --- a/DSTAT1/src/avr-stl/include/map +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_MAP -#define __SGI_STL_MAP - -#ifndef __SGI_STL_INTERNAL_TREE_H -#include -#endif -#include -#include - -#endif /* __SGI_STL_MAP */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/memory b/DSTAT1/src/avr-stl/include/memory deleted file mode 100644 index a1b096c..0000000 --- a/DSTAT1/src/avr-stl/include/memory +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 1997-1999 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef __SGI_STL_MEMORY -#define __SGI_STL_MEMORY - -#include -#include -#include -#include -#include -#include - - -__STL_BEGIN_NAMESPACE - -#if defined(__SGI_STL_USE_AUTO_PTR_CONVERSIONS) && \ - defined(__STL_MEMBER_TEMPLATES) - -template struct auto_ptr_ref { - _Tp1* _M_ptr; - auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {} -}; - -#endif - -template class auto_ptr { -private: - _Tp* _M_ptr; - -public: - typedef _Tp element_type; - - explicit auto_ptr(_Tp* __p = 0) __STL_NOTHROW : _M_ptr(__p) {} - auto_ptr(auto_ptr& __a) __STL_NOTHROW : _M_ptr(__a.release()) {} - -#ifdef __STL_MEMBER_TEMPLATES - template auto_ptr(auto_ptr<_Tp1>& __a) __STL_NOTHROW - : _M_ptr(__a.release()) {} -#endif /* __STL_MEMBER_TEMPLATES */ - - auto_ptr& operator=(auto_ptr& __a) __STL_NOTHROW { - if (&__a != this) { - delete _M_ptr; - _M_ptr = __a.release(); - } - return *this; - } - -#ifdef __STL_MEMBER_TEMPLATES - template - auto_ptr& operator=(auto_ptr<_Tp1>& __a) __STL_NOTHROW { - if (__a.get() != this->get()) { - delete _M_ptr; - _M_ptr = __a.release(); - } - return *this; - } -#endif /* __STL_MEMBER_TEMPLATES */ - - // Note: The C++ standard says there is supposed to be an empty throw - // specification here, but omitting it is standard conforming. Its - // presence can be detected only if _Tp::~_Tp() throws, but (17.4.3.6/2) - // this is prohibited. - ~auto_ptr() { delete _M_ptr; } - - _Tp& operator*() const __STL_NOTHROW { - return *_M_ptr; - } - _Tp* operator->() const __STL_NOTHROW { - return _M_ptr; - } - _Tp* get() const __STL_NOTHROW { - return _M_ptr; - } - _Tp* release() __STL_NOTHROW { - _Tp* __tmp = _M_ptr; - _M_ptr = 0; - return __tmp; - } - void reset(_Tp* __p = 0) __STL_NOTHROW { - if (__p != _M_ptr) { - delete _M_ptr; - _M_ptr = __p; - } - } - - // According to the C++ standard, these conversions are required. Most - // present-day compilers, however, do not enforce that requirement---and, - // in fact, most present-day compilers do not support the language - // features that these conversions rely on. - -#if defined(__SGI_STL_USE_AUTO_PTR_CONVERSIONS) && \ - defined(__STL_MEMBER_TEMPLATES) - -public: - auto_ptr(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW - : _M_ptr(__ref._M_ptr) {} - - auto_ptr& operator=(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW { - if (__ref._M_ptr != this->get()) { - delete _M_ptr; - _M_ptr = __ref._M_ptr; - } - return *this; - } - - template operator auto_ptr_ref<_Tp1>() __STL_NOTHROW - { return auto_ptr_ref<_Tp1>(this->release()); } - template operator auto_ptr<_Tp1>() __STL_NOTHROW - { return auto_ptr<_Tp1>(this->release()); } - -#endif /* auto ptr conversions && member templates */ -}; - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_MEMORY */ - - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/new b/DSTAT1/src/avr-stl/include/new deleted file mode 100644 index 6472f29..0000000 --- a/DSTAT1/src/avr-stl/include/new +++ /dev/null @@ -1,17 +0,0 @@ -/* - * new - * - * Created on: 1 Jan 2011 - * Author: Andy Brown - */ - -#ifndef __1F3E89E5_F35D_4f8d_A849_9A3416814905 -#define __1F3E89E5_F35D_4f8d_A849_9A3416814905 - - -// void *operator new(size_t size_); -// void* operator new(size_t size_,void *ptr_); -// void operator delete(void *ptr_); - - -#endif diff --git a/DSTAT1/src/avr-stl/include/new.cpp b/DSTAT1/src/avr-stl/include/new.cpp deleted file mode 100644 index b3a4e07..0000000 --- a/DSTAT1/src/avr-stl/include/new.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * new - * - * Created on: 1 Jan 2011 - * Author: Andy Brown - */ - -#include - -extern "C"{ - #include -} - -/** - * Global operator new - */ - -void *operator new(size_t size_) -{ - return malloc(size_); -} - - -/** - * Global placement operator new - */ - -void* operator new(size_t size_,void *ptr_) -{ - return ptr_; -} - - -/** - * Global operator delete - */ - -void operator delete(void *ptr_) -{ - free(ptr_); -} diff --git a/DSTAT1/src/avr-stl/include/numeric b/DSTAT1/src/avr-stl/include/numeric deleted file mode 100644 index 50bf199..0000000 --- a/DSTAT1/src/avr-stl/include/numeric +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_NUMERIC -#define __SGI_STL_NUMERIC - -#include -#include -#include - -#ifndef __AVR__ -#ifdef __STL_USE_NEW_IOSTREAMS -#include -#else /* __STL_USE_NEW_IOSTREAMS */ -#include -#endif /* __STL_USE_NEW_IOSTREAMS */ -#endif - -#include -#include -#include -#include - -#endif /* __SGI_STL_NUMERIC */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/ostream b/DSTAT1/src/avr-stl/include/ostream deleted file mode 100644 index 68a2d74..0000000 --- a/DSTAT1/src/avr-stl/include/ostream +++ /dev/null @@ -1,497 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include - -#ifndef STD_HEADER_OSTREAM -#define STD_HEADER_OSTREAM 1 - -#include -#include -#ifndef __AVR__ -#include -#endif -#include - -#pragma GCC visibility push(default) - -namespace std { - template class basic_ostream; - typedef basic_ostream ostream; - -#ifdef __UCLIBCXX_HAS_WCHAR__ - typedef basic_ostream wostream; -#endif - - template basic_ostream& endl(basic_ostream& os); - template basic_ostream& ends(basic_ostream& os); - template basic_ostream& flush(basic_ostream& os); - - template class _UCXXEXPORT basic_ostream - : virtual public basic_ios - { - public: - - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - typedef traits traits_type; - - - _UCXXEXPORT basic_ostream(basic_streambuf* sb) - : basic_ios(sb) - { - basic_ios::init(sb); - } - virtual _UCXXEXPORT ~basic_ostream(); - - class sentry; - - _UCXXEXPORT basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&)){ - return pf(*this); - } - _UCXXEXPORT basic_ostream& operator<<(basic_ios& (*pf)(basic_ios&)){ - pf(*this); - return *this; - } - _UCXXEXPORT basic_ostream& operator<<(ios_base& (*pf)(ios_base&)){ - pf(*this); - return *this; - } - basic_ostream& operator<<(bool n); - basic_ostream& operator<<(short n); - basic_ostream& operator<<(unsigned short n); - basic_ostream& operator<<(int n); - basic_ostream& operator<<(unsigned int n); - basic_ostream& operator<<(long n); - basic_ostream& operator<<(unsigned long n); - basic_ostream& operator<<(float f); - basic_ostream& operator<<(double f); - basic_ostream& operator<<(long double f); - basic_ostream& operator<<(void* p); - basic_ostream& operator<<(basic_streambuf* sb); - - _UCXXEXPORT basic_ostream& put(char_type c){ - if(basic_ostream::traits_type::eq_int_type( - basic_ios::mstreambuf->sputc(c), - basic_ostream::traits_type::eof())) - { - basic_ios::setstate(ios_base::eofbit); - } - return *this; - } - _UCXXEXPORT basic_ostream& write(const char_type* s, streamsize n){ - if(basic_ostream::traits_type::eq_int_type( - basic_ios::mstreambuf->sputn(s, n), - basic_ostream::traits_type::eof()) - ){ - basic_ios::setstate(ios_base::eofbit); - } - return *this; - } - _UCXXEXPORT basic_ostream& flush(){ - if(basic_ios::mstreambuf->pubsync() == -1){ - basic_ios::setstate(ios_base::badbit); - } - return *this; - } - _UCXXEXPORT pos_type tellp(){ - if(basic_ios::fail() != false){ - return pos_type(-1); - } - return basic_ios::rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); - } - _UCXXEXPORT basic_ostream& seekp(pos_type pos){ - if( basic_ios::fail() != true ){ - basic_ios::rdbuf()->pubseekpos(pos); - } - return *this; - } - _UCXXEXPORT basic_ostream& seekp(off_type off, ios_base::seekdir dir){ - if( basic_ios::fail() != true){ - basic_ios::rdbuf()->pubseekoff(off, dir); - } - return *this; - } - - protected: - basic_ostream(const basic_ostream &){ } - basic_ostream & operator=(const basic_ostream &){ return *this; } - }; - - //Implementations of template functions. To allow for partial specialization - - template _UCXXEXPORT basic_ostream::~basic_ostream(){ } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(bool n){ - sentry s(*this); - if( basic_ios::flags() & ios_base::boolalpha){ - if(n){ - write("true", 4); - }else{ - write("false", 5); - } - }else{ - if(n){ - write("1", 1); - }else{ - write("0", 1); - } - } - if(basic_ios::flags() & ios_base::unitbuf){ - flush(); - } - return *this; - } - - template _UCXXEXPORT basic_ostream& - basic_ostream::operator<<(unsigned short n){ - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(short n){ - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(int n){ - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(unsigned int n){ - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(long n){ - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& - basic_ostream::operator<<(unsigned long n) - { - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(float f){ - sentry s(*this); - __ostream_printout::printout(*this, f); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(double f){ - sentry s(*this); - __ostream_printout::printout(*this, f); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(long double f){ - sentry s(*this); - __ostream_printout::printout(*this, f); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(void* p){ - sentry s(*this); - char buffer[20]; - write(buffer, snprintf(buffer, 20, "%p", p) ); - if(basic_ios::flags() & ios_base::unitbuf){ - flush(); - } - return *this; - } - - template _UCXXEXPORT basic_ostream& - basic_ostream::operator<<(basic_streambuf* sb) - { - sentry s(*this); - if(sb == 0){ - basic_ios::setstate(ios_base::badbit); - return *this; - } - - typename traits::int_type c; - - while(basic_ios::good() && (c = sb->sbumpc()) != traits::eof() ){ - put(c); - } - - if(basic_ios::flags() & ios_base::unitbuf){ - flush(); - } - return *this; - } - - /*Template Specializations*/ - -#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_OSTREAM__ - -#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT ostream::~basic_ostream(); - -#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT ostream & ostream::flush(); - - template <> _UCXXEXPORT ostream & ostream::operator<<(bool n); - template <> _UCXXEXPORT ostream & ostream::operator<<(short int n); - template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned short int n); - template <> _UCXXEXPORT ostream & ostream::operator<<(int n); - template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned int n); - template <> _UCXXEXPORT ostream & ostream::operator<<(long n); - template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned long n); - template <> _UCXXEXPORT ostream & ostream::operator<<(float f); - template <> _UCXXEXPORT ostream & ostream::operator<<(double f); - template <> _UCXXEXPORT ostream & ostream::operator<<(long double f); - template <> _UCXXEXPORT ostream & ostream::operator<<(void* p); - template <> _UCXXEXPORT ostream & ostream::operator<<(basic_streambuf >* sb); -#endif -#endif - - template > - class _UCXXEXPORT basic_ostream::sentry - { - bool ok; - public: - explicit _UCXXEXPORT sentry(basic_ostream& os): ok(true){ - if(os.good() !=0){ //Prepare for output - } - - //Flush any tied buffer - if(os.tie() !=0 ){ - os.tie()->flush(); - } - } - _UCXXEXPORT ~sentry() { } - _UCXXEXPORT operator bool() { - return ok; - } - }; - - -#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_OSTREAM__ -#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT ostream::sentry::sentry(ostream & os); - template <> _UCXXEXPORT ostream::sentry::~sentry(); - -#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ -#endif -#endif - - - //Non - class functions - - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, charT c) - { - typename basic_ostream::sentry s(out); - out.put(c); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, char c) - { - typename basic_ostream::sentry s(out); - out.put(c); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, char c) - { - typename basic_ostream::sentry s(out); - out.put(c); - return out; - } - - // signed and unsigned - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, signed char c) - { - typename basic_ostream::sentry s(out); - out.put(c); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, unsigned char c) - { - typename basic_ostream::sentry s(out); - out.put(c); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const charT* c) - { - typename basic_ostream::sentry s(out); - out.write(c, traits::length(c) ); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const char* c) - { - typename basic_ostream::sentry s(out); - out.write(c, char_traits::length(c) ); - return out; - } - - // partial specializations - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const char* c) - { - typename basic_ostream::sentry s(out); - out.write(c, traits::length(c)); - return out; - } - -#ifdef __UCLIBCXX_HAS_WCHAR__ - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const char* c) - { - typename basic_ostream::sentry s(out); - size_t numChars = char_traits::length(c); - wchar_t * temp = new wchar_t[numChars]; - - for(size_t i=0; i < numChars; ++i){ - temp[i] = out.widen(c[i]); - } - - out.write(temp, numChars); - return out; - } -#endif - - // signed and unsigned - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const signed char* c) - { - typename basic_ostream::sentry s(out); - out.write(reinterpret_cast(c), traits::length( reinterpret_cast(c))); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const unsigned char* c) - { - typename basic_ostream::sentry s(out); - out.write(reinterpret_cast(c), traits::length( reinterpret_cast(c))); - return out; - } - - template _UCXXEXPORT basic_ostream& - endl(basic_ostream& os) - { - typename basic_ostream::sentry s(os); - os.put('\n'); - os.flush(); - return os; - } - -#ifdef __AVR__ - template _UCXXEXPORT basic_ostream& - crlf(basic_ostream& os) - { - typename basic_ostream::sentry s(os); - os.put('\r'); - os.put('\n'); - os.flush(); - return os; - } -#endif - - template _UCXXEXPORT basic_ostream& - ends(basic_ostream& os) - { - typename basic_ostream::sentry s(os); - os.put(traits::eos()); - return os; - } - - template _UCXXEXPORT basic_ostream& flush(basic_ostream& os){ - typename basic_ostream::sentry s(os); - os.flush(); - return os; - } - - -#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_OSTREAM__ - template <> _UCXXEXPORT ostream & endl(ostream & os); - template <> _UCXXEXPORT ostream & flush(ostream & os); - template <> _UCXXEXPORT ostream & operator<<(ostream & out, char c); - template <> _UCXXEXPORT ostream & operator<<(ostream & out, const char* c); - template <> _UCXXEXPORT ostream & operator<<(ostream & out, unsigned char c); - template <> _UCXXEXPORT ostream & operator<<(ostream & out, unsigned const char* c); - -#endif -#endif - - -#ifndef __STRICT_ANSI__ - -//Support for output of long long data types - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, signed long long int i) -{ - typename basic_ostream::sentry s(os); - __ostream_printout::printout(os, i); - return os; -} - - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, unsigned long long int i) -{ - typename basic_ostream::sentry s(os); - __ostream_printout::printout(os, i); - return os; -} - - -#endif //__STRICT_ANSI__ - - - - -} - -#pragma GCC visibility pop - -#endif - diff --git a/DSTAT1/src/avr-stl/include/ostream_helpers b/DSTAT1/src/avr-stl/include/ostream_helpers deleted file mode 100644 index 9f86708..0000000 --- a/DSTAT1/src/avr-stl/include/ostream_helpers +++ /dev/null @@ -1,537 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include -#include -#include -#include - -#ifndef __STD_HEADER_OSTREAM_HELPERS -#define __STD_HEADER_OSTREAM_HELPERS 1 - -#pragma GCC visibility push(default) - -namespace std{ - - /* We are making the following template class for serveral reasons. Firstly, - * we want to keep the main ostream code neat and tidy. Secondly, we want it - * to be easy to do partial specialization of the ostream code so that it can - * be expanded and put into the library. This will allow us to make application - * code smaller at the expense of increased library size. This is a fair - * trade-off when there are multiple applications being compiled. Also, this - * feature will be used optionally via configuration options. It will also - * allow us to keep the code bases in sync, dramatically simplifying the - * maintenance required. We specialized for char because wchar and others - * require different scanf functions - */ - - - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const dataType n); - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const signed long int n) - { - char buffer[20]; - const char * c_ld = "%ld"; - const char * c_lo = "%lo"; - const char * c_lX = "%lX"; - const char * c_lx = "%lx"; - const char * c_hashlo = "%#lo"; - const char * c_hashlX = "%#lX"; - const char * c_hashlx = "%#lx"; - - const char * formatString=0; - - if( stream.flags() & ios_base::dec){ - formatString = c_ld; - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - formatString = c_hashlo; - }else{ - formatString = c_lo; - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - formatString = c_hashlX; - }else{ - formatString = c_hashlx; - } - }else{ - if(stream.flags() & ios_base::uppercase){ - formatString = c_lX; - }else{ - formatString = c_lx; - } - } - } - - stream.write(buffer, snprintf(buffer, 20, formatString, n) ); - - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const unsigned long int n) - { - char buffer[20]; - const char * c_lo = "%lo"; - const char * c_lu = "%lu"; - const char * c_lX = "%lX"; - const char * c_lx = "%lx"; - const char * c_hashlo = "%#lo"; - const char * c_hashlX = "%#lX"; - const char * c_hashlx = "%#lx"; - const char * formatString=0; - - if( stream.flags() & ios_base::dec){ - formatString = c_lu; - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - formatString = c_hashlo; - }else{ - formatString = c_lo; - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - formatString = c_hashlX; - }else{ - formatString = c_hashlx; - } - }else{ - if(stream.flags() & ios_base::uppercase){ - formatString = c_lX; - }else{ - formatString = c_lx; - } - } - } - - stream.write(buffer, snprintf(buffer, 20, formatString, n)); - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - -#ifndef __STRICT_ANSI__ - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const signed long long int n) - { - char buffer[28]; - const char * lld = "%lld"; - const char * llo = "%llo"; - const char * llX = "%llX"; - const char * llx = "%llx"; - const char * hashllo = "%#llo"; - const char * hashllX = "%#llX"; - const char * hashllx = "%#llx"; - const char * formatString=0; - - if( stream.flags() & ios_base::dec){ - formatString = lld; - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - formatString = hashllo; - }else{ - formatString = llo; - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - formatString = hashllX; - }else{ - formatString = hashllx; - } - }else{ - if(stream.flags() & ios_base::uppercase){ - formatString = llX; - }else{ - formatString = llx; - } - } - } - - stream.write(buffer, snprintf(buffer, 27, formatString, n) ); - - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const unsigned long long int n) - { - char buffer[28]; - const char * llo = "%llo"; - const char * llu = "%llu"; - const char * llX = "%llX"; - const char * llx = "%llx"; - const char * hashllo = "%#llo"; - const char * hashllX = "%#llX"; - const char * hashllx = "%#llx"; - const char * formatString=0; - - if( stream.flags() & ios_base::dec){ - formatString = llu; - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - formatString = hashllo; - }else{ - formatString = llo; - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - formatString = hashllX; - }else{ - formatString = hashllx; - } - }else{ - if(stream.flags() & ios_base::uppercase){ - formatString = llX; - }else{ - formatString = llx; - } - } - } - - stream.write(buffer, snprintf(buffer, 27, formatString, n) ); - - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - -#endif //__STRICT_ANSI__ - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, double f) - { - char buffer[32]; - int length; - -#ifdef __AVR__ - // this is lifted from the Arduino Print class - char *ptr=buffer; - - // Handle negative numbers - if (f < 0.0) - { - *ptr++='-'; - f = -f; - } - - int digits=stream.precision(); - - // Round correctly so that print(1.999, 2) prints as "2.00" - double rounding = 0.5; - for (uint8_t i=0; i 0) - *ptr++='.'; - - // Extract digits from the remainder one at a time - while (digits-- > 0) - { - remainder *= 10.0; - int toPrint = int(remainder); - itoa(toPrint,ptr,10); - while(*ptr) ptr++; - remainder -= toPrint; - } - - length=ptr-buffer; - -#else - if(stream.flags() & ios_base::scientific){ - if(stream.flags() & ios_base::uppercase){ - length = snprintf(buffer, 32, "%*.*E", static_cast(stream.width()),static_cast(stream.precision()), f); - }else{ - length = snprintf(buffer, 32, "%*.*e", static_cast(stream.width()),static_cast(stream.precision()), f); - } - } else if(stream.flags() & ios_base::fixed){ - length = snprintf(buffer, 32, "%*.*f",static_cast(stream.width()),static_cast(stream.precision()), f); - } else { - length = snprintf(buffer, 32, "%*.*g",static_cast(stream.width()),static_cast(stream.precision()), f); - } -#endif - stream.write(buffer, length); - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const long double f) - { - char buffer[32]; - int length; - if(stream.flags() & ios_base::scientific){ - if(stream.flags() & ios_base::uppercase){ - length = snprintf(buffer, 32, "%*.*LE", static_cast(stream.width()), static_cast(stream.precision()), f); - }else{ - length = snprintf(buffer, 32, "%*.*Le", static_cast(stream.width()), static_cast(stream.precision()), f); - } - } else if(stream.flags() & ios_base::fixed){ - length = snprintf(buffer, 32, "%*.*Lf", static_cast(stream.width()), static_cast(stream.precision()), f); - } else { - length = snprintf(buffer, 32, "%*.*Lg", static_cast(stream.width()), static_cast(stream.precision()), f); - } - stream.write(buffer, length); - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - - } - }; - -#ifdef __UCLIBCXX_HAS_WCHAR__ - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const signed long int n) - { - wchar_t buffer[20]; - if( stream.flags() & ios_base::dec){ - stream.write(buffer, swprintf(buffer, 20, L"%ld", n)); - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - stream.write(buffer, swprintf(buffer, 20, L"%#lo", n)); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%lo", n) ); - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 20, L"%#lX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%#lx", n) ); - } - }else{ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 20, L"%lX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%lx", n) ); - } - } - } - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const unsigned long int n) - { - wchar_t buffer[20]; - if( stream.flags() & ios_base::dec){ - stream.write(buffer, swprintf(buffer, 20, L"%lu", n)); - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - stream.write(buffer, swprintf(buffer, 20, L"%#lo", n)); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%lo", n) ); - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 20, L"%#lX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%#lx", n) ); - } - }else{ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 20, L"%lX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%lx", n) ); - } - } - } - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - -#ifndef __STRICT_ANSI__ - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const signed long long int n) - { - wchar_t buffer[28]; - if( stream.flags() & ios_base::dec){ - stream.write(buffer, swprintf(buffer, 27, L"%lld", n)); - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - stream.write(buffer, swprintf(buffer, 27, L"%#llo", n)); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%llo", n) ); - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 27, L"%#llX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%#llx", n) ); - } - }else{ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 27, L"%llX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%llx", n) ); - } - } - } - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const unsigned long long int n) - { - wchar_t buffer[28]; - if( stream.flags() & ios_base::dec){ - stream.write(buffer, swprintf(buffer, 27, L"%llu", n)); - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - stream.write(buffer, swprintf(buffer, 27, L"%#llo", n)); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%llo", n) ); - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 27, L"%#llX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%#llx", n) ); - } - }else{ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 27, L"%llX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%llx", n) ); - } - } - } - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - -#endif //__STRICT_ANSI__ - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const double f) - { - wchar_t buffer[32]; - wchar_t format_string[32]; - if(stream.flags() & ios_base::scientific){ - if(stream.flags() & ios_base::uppercase){ - swprintf(format_string, 32, L"%%%u.%uE", static_cast(stream.width()), static_cast(stream.precision())); - }else{ - swprintf(format_string, 32, L"%%%u.%ue", static_cast(stream.width()), static_cast(stream.precision())); - } - } else if(stream.flags() & ios_base::fixed){ - swprintf(format_string, 32, L"%%%u.%uf", static_cast(stream.width()), static_cast(stream.precision())); - } else { - swprintf(format_string, 32, L"%%%u.%ug", static_cast(stream.width()), static_cast(stream.precision())); - } - stream.write(buffer, swprintf(buffer, 32, format_string, f) ); - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const long double f) - { - wchar_t buffer[32]; - wchar_t format_string[32]; - if(stream.flags() & ios_base::scientific){ - if(stream.flags() & ios_base::uppercase){ - swprintf(format_string, 32, L"%%%u.%uLE", static_cast(stream.width()), static_cast(stream.precision())); - }else{ - swprintf(format_string, 32, L"%%%u.%uLe", static_cast(stream.width()), static_cast(stream.precision())); - } - } else if(stream.flags() & ios_base::fixed){ - swprintf(format_string, 32, L"%%%u.%uLf", static_cast(stream.width()), static_cast(stream.precision())); - } else { - swprintf(format_string, 32, L"%%%u.%uLg", static_cast(stream.width()), static_cast(stream.precision())); - } - stream.write(buffer, swprintf(buffer, 32, format_string, f) ); - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - -#endif //__UCLIBCXX_HAS_WCHAR__ - -} - -#pragma GCC visibility pop - -#endif - - - diff --git a/DSTAT1/src/avr-stl/include/queue b/DSTAT1/src/avr-stl/include/queue deleted file mode 100644 index f9417fb..0000000 --- a/DSTAT1/src/avr-stl/include/queue +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_QUEUE -#define __SGI_STL_QUEUE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_QUEUE */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/sequence_concepts.h b/DSTAT1/src/avr-stl/include/sequence_concepts.h deleted file mode 100644 index bf8f373..0000000 --- a/DSTAT1/src/avr-stl/include/sequence_concepts.h +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 1999 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef STL_SEQUENCE_CONCEPTS_H -#define STL_SEQUENCE_CONCEPTS_H - -#include - -#ifdef __STL_USE_CONCEPT_CHECKS - -// This file covers the following concepts: -// _Sequence -// _FrontInsertionSequence -// _BackInsertionSequence - -struct _ERROR_IN_STL_SEQ { - - template - static void - __fill_constructor_requirement_violation(_XX& __s) { - typename _XX::value_type __t = typename _XX::value_type(); - typename _XX::difference_type __n = typename _XX::difference_type(); - _XX __x(__n, __t); - __sink_unused_warning(__x); - } - template - static void - __fill_default_constructor_requirement_violation(_XX& __s) { - _STL_ERROR::__default_constructor_requirement_violation(*__s.begin()); - typename _XX::difference_type __n = typename _XX::difference_type(); - _XX __x(__n); - __sink_unused_warning(__x); - } - template - static void - __range_constructor_requirement_violation(_XX& __s) { - _XX __x(__s.begin(), __s.end()); - __sink_unused_warning(__x); - } - template - static void - __insert_function_requirement_violation(_XX& __s) { - typename _XX::value_type __t = typename _XX::value_type(); - typename _XX::iterator __p = typename _XX::iterator(); - __p = __s.insert(__p, __t); - } - template - static void - __fill_insert_function_requirement_violation(_XX& __s) { - typename _XX::value_type __t = typename _XX::value_type(); - typename _XX::iterator __p = typename _XX::iterator(); - typename _XX::difference_type __n = typename _XX::difference_type(); - __s.insert(__p, __n, __t); - } - template - static void - __range_insert_function_requirement_violation(_XX& __s) { - typename _XX::iterator __p = typename _XX::iterator(); - typename _XX::iterator __i = typename _XX::iterator(); - typename _XX::iterator __j = typename _XX::iterator(); - __s.insert(__p, __i, __j); - } - template - static void - __insert_element_function_requirement_violation(_XX& __s) { - typename _XX::value_type __t = typename _XX::value_type(); - std::pair __r; - __r = __s.insert(__t); - __sink_unused_warning(__r); - } - template - static void - __unconditional_insert_element_function_requirement_violation(_XX& __s) { - typename _XX::value_type __t = typename _XX::value_type(); - typename _XX::iterator __p; - __p = __s.insert(__t); - __sink_unused_warning(__p); - } - template - static void - __erase_function_requirement_violation(_XX& __s) { - typename _XX::iterator __p = typename _XX::iterator(); - __p = __s.erase(__p); - } - template - static void - __range_erase_function_requirement_violation(_XX& __s) { - typename _XX::iterator __p = typename _XX::iterator(); - typename _XX::iterator __q = typename _XX::iterator(); - __p = __s.erase(__p, __q); - } - template - static void - __const_front_function_requirement_violation(const _XX& __s) { - typename _XX::const_reference __t = __s.front(); - __sink_unused_warning(__t); - } - template - static void - __front_function_requirement_violation(_XX& __s) { - typename _XX::reference __t = __s.front(); - __const_front_function_requirement_violation(__s); - __sink_unused_warning(__t); - } - template - static void - __const_back_function_requirement_violation(const _XX& __s) { - typename _XX::const_reference __t = __s.back(); - __sink_unused_warning(__t); - } - template - static void - __back_function_requirement_violation(_XX& __s) { - typename _XX::reference __t = __s.back(); - __const_back_function_requirement_violation(__s); - __sink_unused_warning(__t); - } - template - static void - __push_front_function_requirement_violation(_XX& __s) { - typename _XX::value_type __t = typename _XX::value_type(); - __s.push_front(__t); - } - template - static void - __pop_front_function_requirement_violation(_XX& __s) { - __s.pop_front(); - } - template - static void - __push_back_function_requirement_violation(_XX& __s) { - typename _XX::value_type __t = typename _XX::value_type(); - __s.push_back(__t); - } - template - static void - __pop_back_function_requirement_violation(_XX& __s) { - __s.pop_back(); - } - -}; - -/* Sequence Containers */ - -template -struct _Sequence_concept_specification { -static void -_Sequence_requirement_violation(_Sequence __s) { - // Refinement of ForwardContainer - _ForwardContainer_concept_specification<_Sequence>::_ForwardContainer_requirement_violation(__s); - // Refinement of DefaultConstructible - _DefaultConstructible_concept_specification<_Sequence>::_DefaultConstructible_requirement_violation(__s); - // Valid Expressions - _ERROR_IN_STL_SEQ::__fill_constructor_requirement_violation(__s); - _ERROR_IN_STL_SEQ::__fill_default_constructor_requirement_violation(__s); - _ERROR_IN_STL_SEQ::__range_constructor_requirement_violation(__s); - _ERROR_IN_STL_SEQ::__insert_function_requirement_violation(__s); - _ERROR_IN_STL_SEQ::__fill_insert_function_requirement_violation(__s); - _ERROR_IN_STL_SEQ::__range_insert_function_requirement_violation(__s); - _ERROR_IN_STL_SEQ::__erase_function_requirement_violation(__s); - _ERROR_IN_STL_SEQ::__range_erase_function_requirement_violation(__s); - _ERROR_IN_STL_SEQ::__front_function_requirement_violation(__s); -} -}; - -template -struct _FrontInsertionSequence_concept_specification { -static void -_FrontInsertionSequence_requirement_violation(_FrontInsertionSequence __s) { - // Refinement of Sequence - _Sequence_concept_specification<_FrontInsertionSequence>::_Sequence_requirement_violation(__s); - // Valid Expressions - _ERROR_IN_STL_SEQ::__push_front_function_requirement_violation(__s); - _ERROR_IN_STL_SEQ::__pop_front_function_requirement_violation(__s); -} -}; - -template -struct _BackInsertionSequence_concept_specification { -static void -_BackInsertionSequence_requirement_violation(_BackInsertionSequence __s) { - // Refinement of Sequence - _Sequence_concept_specification<_BackInsertionSequence>::_Sequence_requirement_violation(__s); - // Valid Expressions - _ERROR_IN_STL_SEQ::__back_function_requirement_violation(__s); - _ERROR_IN_STL_SEQ::__push_back_function_requirement_violation(__s); - _ERROR_IN_STL_SEQ::__pop_back_function_requirement_violation(__s); -} -}; - -#endif /* if __STL_USE_CONCEPT_CHECKS */ - - -#endif /* STL_SEQUENCE_CONCEPTS_H */ diff --git a/DSTAT1/src/avr-stl/include/serstream b/DSTAT1/src/avr-stl/include/serstream deleted file mode 100644 index 07d868b..0000000 --- a/DSTAT1/src/avr-stl/include/serstream +++ /dev/null @@ -1,293 +0,0 @@ -/* - * serstream - * Implementation of input/output streams for the Arduino serial classes - * - * Created on: 2 Jan 2011 - * Author: Andy Brown - * - * http://andybrown.me.uk/ws/terms-and-conditions - */ - -#ifndef __810370EC_AD69_4ef7_91F5_B1AA16F14712 -#define __810370EC_AD69_4ef7_91F5_B1AA16F14712 - -#include - -#include -#include -#include -#include -#include -#include - - -namespace std -{ -/* - * basic_serialbuf implements an unbuffered basic_streambuf as a backing buffer - * for the IO classes - */ - - template - class basic_serialbuf : public basic_streambuf - { - public: - - /* - * Types used here - */ - - typedef charT char_type; - typedef typename traits::int_type int_type; - - /* - * constructor - wraps an existing Tserial class instance - */ - - explicit basic_serialbuf(Tserial& serial_,ios_base::openmode which_ = ios_base::in | ios_base::out) - : _serial(serial_) - { - basic_streambuf::openedFor = which_; - } - - /* - * Required to maintain the chain - */ - - virtual ~basic_serialbuf() { } - - /* - * Get a reference to the wrapped object - */ - - Tserial& serial() { return _serial; } - - protected: - - /* - * Get how many bytes available - */ - - virtual int showmanyc(){ - return _serial.available(); - } - - /* - * Read up to n chars - */ - - virtual streamsize xsgetn(char_type* c, streamsize n) { - - streamsize i = 0; - char_type data; - - while((data=_serial.read())!=-1 && i < n ) { - c[i] = data; - ++i; - } - return i; - } - - /* - * Write up to n chars - */ - - virtual streamsize xsputn(const char_type* s, streamsize n){ - - for(streamsize i=0;i class basic_iserialstream - : public basic_istream - { - public: - - /* - * Types used here - */ - - typedef charT char_type; - - /* - * Constructor - default the serial object to #1 - * Mega users can explicity initialise with one of - * the others - */ - - explicit basic_iserialstream(Tserial& serial_) - : basic_ios(&sb), basic_istream(&sb), sb(serial_,ios_base::in) - { - } - - /* - * Required to maintain the chain - */ - - virtual ~basic_iserialstream() { } - - /* - * Initialise the baud rate - */ - - void begin(long speed_) { - sb.serial().begin(speed_); - } - - /* - * The wrapped object - */ - - private: - basic_serialbuf sb; - }; - - -/* - * Output stream - */ - - template class basic_oserialstream - : public basic_ostream - { - public: - - /* - * Types used here - */ - - typedef charT char_type; - - /* - * Constructor - default the serial object to #1 - * Mega users can explicity initialise with one of - * the others - */ - - explicit basic_oserialstream(Tserial& serial_) - : basic_ios(&sb), basic_ostream(&sb), sb(serial_,ios_base::out) - { - } - - /* - * Required to maintain the chain - */ - - virtual ~basic_oserialstream() { } - - /* - * Initialise the baud rate - */ - - void begin(long speed_) { - sb.serial().begin(speed_); - } - - /* - * The wrapped object - */ - - private: - basic_serialbuf sb; - }; - - -/* - * Input/output stream - */ - - template class basic_ioserialstream - : public basic_iostream - { - public: - - /* - * Types used here - */ - - typedef charT char_type; - - /* - * Constructor - default the serial object to #1 - * Mega users can explicity initialise with one of - * the others - */ - - explicit basic_ioserialstream(Tserial& serial_) - : basic_ios(&sb), basic_iostream(&sb), sb(serial_,ios_base::in | ios_base::out) - { - } - - /* - * Required to maintain the chain - */ - - virtual ~basic_ioserialstream(){ } - - /* - * Initialise the baud rate - */ - - void begin(long speed_) { - sb.serial().begin(speed_); - } - - /* - * The wrapped object - */ - - private: - basic_serialbuf sb; - }; -} - - -#endif diff --git a/DSTAT1/src/avr-stl/include/set b/DSTAT1/src/avr-stl/include/set deleted file mode 100644 index c836c45..0000000 --- a/DSTAT1/src/avr-stl/include/set +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_SET -#define __SGI_STL_SET - -#ifndef __SGI_STL_INTERNAL_TREE_H -#include -#endif -#include -#include - -#endif /* __SGI_STL_SET */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/slist b/DSTAT1/src/avr-stl/include/slist deleted file mode 100644 index c3ec742..0000000 --- a/DSTAT1/src/avr-stl/include/slist +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef __SGI_STL_SLIST -#define __SGI_STL_SLIST - -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_SLIST */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/sstream b/DSTAT1/src/avr-stl/include/sstream deleted file mode 100644 index 2969853..0000000 --- a/DSTAT1/src/avr-stl/include/sstream +++ /dev/null @@ -1,384 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include - -#ifndef HEADER_STD_SSTREAM -#define HEADER_STD_SSTREAM 1 - -#include -#include -#include -#include -#include -#include - -#pragma GCC visibility push(default) - -namespace std{ - - template - class _UCXXEXPORT basic_stringbuf : public basic_streambuf - { - public: - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - typedef typename Allocator::size_type size_type; - - explicit _UCXXEXPORT basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out) - : data(), ielement(0), oelement(0) - { - basic_streambuf::openedFor = which; - } - - explicit _UCXXEXPORT basic_stringbuf(const basic_string& str, - ios_base::openmode which = ios_base::in | ios_base::out) - : data(str), ielement(0), oelement(0) - { - if(which & ios_base::ate){ - oelement = data.length(); - } - basic_streambuf::openedFor = which; - } - - virtual _UCXXEXPORT ~basic_stringbuf() { } - - _UCXXEXPORT basic_string str() const{ - return data; - } - - _UCXXEXPORT void str(const basic_string& s){ - data = s; - ielement = 0; - if(basic_streambuf::openedFor & ios_base::ate){ - oelement = data.length(); - }else{ - oelement = 0; - } - } - - protected: - virtual _UCXXEXPORT int sync(){ - return 0; - } - virtual _UCXXEXPORT int_type underflow(){ - if(ielement >= data.length()){ - return traits::eof(); - } - return traits::to_int_type(data[ielement]); - } - - virtual _UCXXEXPORT int_type uflow(){ - int_type retval = underflow(); - if(retval != traits::eof()){ - ++ielement; - } - return retval; - } - - virtual _UCXXEXPORT int_type pbackfail(int_type c = traits::eof()){ - //Error possibilities - if(ielement == 0){ - return traits::eof(); - } - if(ielement > data.length()){ - ielement = data.length(); - return traits::eof(); - } - //eof passed in - if(traits::eq_int_type(c,traits::eof())==true){ - --ielement; - return traits::not_eof(c); - } - if(traits::eq(traits::to_char_type(c),data[ielement-1]) == true){ - --ielement; - return c; - } - if(basic_streambuf::openedFor & ios_base::out){ - --ielement; - data[ielement] = c; - return c; - } - return traits::eof(); - } - - virtual _UCXXEXPORT int showmanyc(){ - return data.length() - ielement; - } - virtual _UCXXEXPORT streamsize xsgetn(char_type* c, streamsize n){ - streamsize i = 0; - while(ielement < data.length() && i < n ){ - c[i] = data[ielement]; - ++i; - ++ielement; - } - return i; - } - - virtual _UCXXEXPORT int_type overflow (int_type c = traits::eof()){ - //Nothing to do - if(traits::eq_int_type(c,traits::eof())){ - return traits::not_eof(c); - } - - //Actually add character, if possible - if(basic_streambuf::openedFor & ios_base::out){ - if(oelement >= data.length()){ - data.push_back(c); - }else{ - data[oelement] = c; - } - ++oelement; - return c; - } - //Not possible - return traits::eof(); - } - - virtual _UCXXEXPORT basic_streambuf* setbuf(charT*, streamsize){ - //This function does nothing - return this; - } - - virtual _UCXXEXPORT streamsize xsputn(const char_type* s, streamsize n){ - data.replace(oelement, n, s, n); - oelement += n; - return n; - } - - virtual _UCXXEXPORT pos_type seekoff(off_type off, ios_base::seekdir way, - ios_base::openmode which = ios_base::in | ios_base::out) - { - //Test for invalid option - if( (which & ios_base::in) && (which & ios_base::out) && (way == ios_base::cur)){ - return -1; - } - - //Calculate new location - size_type newpos = 0; - - if(way == ios_base::beg){ - newpos = off; - }else if(way == ios_base::cur){ - if(which & ios_base::out){ - newpos = data.length() + off; - } - if(which & ios_base::in){ - newpos = ielement + off; - } - - }else{ - newpos = data.length() + off; - } - - //Test for error conditions - if(newpos > data.length()){ - return -1; - } - - //Shuffle pointers - - if(which & ios_base::in){ - ielement = newpos; - } - if(which & ios_base::out){ - data.resize(newpos); - if(ielement > data.length()){ - ielement = data.length(); - } - } - - return newpos; - } - - virtual _UCXXEXPORT pos_type seekpos(pos_type sp, - ios_base::openmode which = ios_base::in | ios_base::out) - { - return seekoff(sp, ios_base::beg, which); - } - - basic_string data; - size_type ielement; - size_type oelement; - }; - - - template class _UCXXEXPORT basic_istringstream - : public basic_istream - { - public: - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - - - explicit _UCXXEXPORT basic_istringstream(ios_base::openmode m = ios_base::in) - : basic_ios(&sb), basic_istream(&sb), sb(m) - { - } - explicit _UCXXEXPORT basic_istringstream( const basic_string& str, - ios_base::openmode which = ios_base::in) - : basic_ios(&sb), basic_istream(&sb), sb(str, which) - { - } - virtual _UCXXEXPORT ~basic_istringstream() { } - _UCXXEXPORT basic_stringbuf* rdbuf() const{ - return &sb; - } - _UCXXEXPORT basic_string str() const{ - return sb.str(); - } - _UCXXEXPORT void str(const basic_string& s){ - sb.str(s); - basic_istream::clear(); - } - private: - basic_stringbuf sb; - }; - - - template class _UCXXEXPORT basic_ostringstream - : public basic_ostream - { - public: - - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - - explicit _UCXXEXPORT basic_ostringstream(ios_base::openmode m = ios_base::out) - : basic_ios(&sb), basic_ostream(&sb), sb(m) - { - } - explicit _UCXXEXPORT basic_ostringstream(const basic_string& str, - ios_base::openmode which = ios_base::out) - : basic_ios(&sb), basic_ostream(&sb), sb(str, which) - { - } - virtual _UCXXEXPORT ~basic_ostringstream() { } - - _UCXXEXPORT basic_stringbuf* rdbuf() const{ - return &sb; - } - _UCXXEXPORT basic_string str() const{ - return sb.str(); - } - _UCXXEXPORT void str(const basic_string& s){ - sb.str(s); - basic_ostream::clear(); - } - private: - basic_stringbuf sb; - }; - - - template class _UCXXEXPORT basic_stringstream - : public basic_iostream - { - public: - - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - - explicit _UCXXEXPORT basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in) - : basic_ios(&sb), basic_iostream(&sb), sb(which) - { - } - - explicit _UCXXEXPORT basic_stringstream(const basic_string& str, - ios_base::openmode which = ios_base::out|ios_base::in) - : basic_ios(&sb), basic_iostream(&sb), sb(str, which) - { - } - virtual _UCXXEXPORT ~basic_stringstream(){ } - - _UCXXEXPORT basic_stringbuf* rdbuf(){ - return &sb; - } - _UCXXEXPORT basic_string str() const{ - return sb.str(); - } - _UCXXEXPORT void str(const basic_string& s){ - sb.str(s); - basic_iostream::clear(); - } - private: - basic_stringbuf sb; - }; - -#ifdef __UCLIBCXX_EXPAND_SSTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_SSTREAM__ - -#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT basic_stringbuf, allocator >:: - basic_stringbuf(ios_base::openmode which); - template <> _UCXXEXPORT basic_stringbuf, allocator >::~basic_stringbuf(); - -#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT basic_string, allocator > - basic_stringbuf, allocator >::str() const; - - template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type - basic_stringbuf, allocator >:: - pbackfail(basic_stringbuf, allocator >::int_type c); - - template <> _UCXXEXPORT basic_stringbuf, allocator >::pos_type - basic_stringbuf, allocator >:: - seekoff (basic_stringbuf, allocator >::off_type off, - ios_base::seekdir way, - ios_base::openmode which - ); - - template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type - basic_stringbuf, allocator >:: - overflow (basic_stringbuf, allocator >::int_type c); - - template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type - basic_stringbuf, allocator >::underflow (); - - template <> _UCXXEXPORT streamsize basic_stringbuf, allocator >:: - xsputn(const char* s, streamsize n); - -#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT basic_stringstream, allocator >:: - basic_stringstream(ios_base::openmode which); - template <> _UCXXEXPORT basic_stringstream, allocator >::~basic_stringstream(); - template <> _UCXXEXPORT basic_istringstream, allocator >::~basic_istringstream(); - template <> _UCXXEXPORT basic_ostringstream, allocator >::~basic_ostringstream(); - -#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - -#endif -#endif - -#pragma GCC visibility pop - -} - - -#endif diff --git a/DSTAT1/src/avr-stl/include/stack b/DSTAT1/src/avr-stl/include/stack deleted file mode 100644 index 36461d9..0000000 --- a/DSTAT1/src/avr-stl/include/stack +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_STACK -#define __SGI_STL_STACK - -#include -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_STACK */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_algo.h b/DSTAT1/src/avr-stl/include/stl_algo.h deleted file mode 100644 index 37dbf4a..0000000 --- a/DSTAT1/src/avr-stl/include/stl_algo.h +++ /dev/null @@ -1,3297 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_ALGO_H -#define __SGI_STL_INTERNAL_ALGO_H - -#include - -// See concept_checks.h for the concept-checking macros -// __STL_REQUIRES, __STL_CONVERTIBLE, etc. - - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1209 -#endif - -// __median (an extension, not present in the C++ standard). - -template -inline const _Tp& __median(const _Tp& __a, const _Tp& __b, const _Tp& __c) { - __STL_REQUIRES(_Tp, _LessThanComparable); - if (__a < __b) - if (__b < __c) - return __b; - else if (__a < __c) - return __c; - else - return __a; - else if (__a < __c) - return __a; - else if (__b < __c) - return __c; - else - return __b; -} - -template -inline const _Tp& -__median(const _Tp& __a, const _Tp& __b, const _Tp& __c, _Compare __comp) { - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp); - if (__comp(__a, __b)) - if (__comp(__b, __c)) - return __b; - else if (__comp(__a, __c)) - return __c; - else - return __a; - else if (__comp(__a, __c)) - return __a; - else if (__comp(__b, __c)) - return __c; - else - return __b; -} - -// for_each. Apply a function to every element of a range. -template -_Function for_each(_InputIter __first, _InputIter __last, _Function __f) { - __STL_REQUIRES(_InputIter, _InputIterator); - for ( ; __first != __last; ++__first) - __f(*__first); - return __f; -} - -// find and find_if. - -template -inline _InputIter find(_InputIter __first, _InputIter __last, - const _Tp& __val, - input_iterator_tag) -{ - while (__first != __last && !(*__first == __val)) - ++__first; - return __first; -} - -template -inline _InputIter find_if(_InputIter __first, _InputIter __last, - _Predicate __pred, - input_iterator_tag) -{ - while (__first != __last && !__pred(*__first)) - ++__first; - return __first; -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -_RandomAccessIter find(_RandomAccessIter __first, _RandomAccessIter __last, - const _Tp& __val, - random_access_iterator_tag) -{ - typename iterator_traits<_RandomAccessIter>::difference_type __trip_count - = (__last - __first) >> 2; - - for ( ; __trip_count > 0 ; --__trip_count) { - if (*__first == __val) return __first; - ++__first; - - if (*__first == __val) return __first; - ++__first; - - if (*__first == __val) return __first; - ++__first; - - if (*__first == __val) return __first; - ++__first; - } - - switch(__last - __first) { - case 3: - if (*__first == __val) return __first; - ++__first; - case 2: - if (*__first == __val) return __first; - ++__first; - case 1: - if (*__first == __val) return __first; - ++__first; - case 0: - default: - return __last; - } -} - -template -_RandomAccessIter find_if(_RandomAccessIter __first, _RandomAccessIter __last, - _Predicate __pred, - random_access_iterator_tag) -{ - typename iterator_traits<_RandomAccessIter>::difference_type __trip_count - = (__last - __first) >> 2; - - for ( ; __trip_count > 0 ; --__trip_count) { - if (__pred(*__first)) return __first; - ++__first; - - if (__pred(*__first)) return __first; - ++__first; - - if (__pred(*__first)) return __first; - ++__first; - - if (__pred(*__first)) return __first; - ++__first; - } - - switch(__last - __first) { - case 3: - if (__pred(*__first)) return __first; - ++__first; - case 2: - if (__pred(*__first)) return __first; - ++__first; - case 1: - if (__pred(*__first)) return __first; - ++__first; - case 0: - default: - return __last; - } -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline _InputIter find(_InputIter __first, _InputIter __last, - const _Tp& __val) -{ - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool, - typename iterator_traits<_InputIter>::value_type, _Tp); - return find(__first, __last, __val, __ITERATOR_CATEGORY(__first)); -} - -template -inline _InputIter find_if(_InputIter __first, _InputIter __last, - _Predicate __pred) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, - typename iterator_traits<_InputIter>::value_type); - return find_if(__first, __last, __pred, __ITERATOR_CATEGORY(__first)); -} - -// adjacent_find. - -template -_ForwardIter adjacent_find(_ForwardIter __first, _ForwardIter __last) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type, - _EqualityComparable); - if (__first == __last) - return __last; - _ForwardIter __next = __first; - while(++__next != __last) { - if (*__first == *__next) - return __first; - __first = __next; - } - return __last; -} - -template -_ForwardIter adjacent_find(_ForwardIter __first, _ForwardIter __last, - _BinaryPredicate __binary_pred) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool, - typename iterator_traits<_ForwardIter>::value_type, - typename iterator_traits<_ForwardIter>::value_type); - if (__first == __last) - return __last; - _ForwardIter __next = __first; - while(++__next != __last) { - if (__binary_pred(*__first, *__next)) - return __first; - __first = __next; - } - return __last; -} - -// count and count_if. There are two version of each, one whose return type -// type is void and one (present only if we have partial specialization) -// whose return type is iterator_traits<_InputIter>::difference_type. The -// C++ standard only has the latter version, but the former, which was present -// in the HP STL, is retained for backward compatibility. - -template -void count(_InputIter __first, _InputIter __last, const _Tp& __value, - _Size& __n) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(typename iterator_traits<_InputIter>::value_type, - _EqualityComparable); - __STL_REQUIRES(_Tp, _EqualityComparable); - for ( ; __first != __last; ++__first) - if (*__first == __value) - ++__n; -} - -template -void count_if(_InputIter __first, _InputIter __last, _Predicate __pred, - _Size& __n) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, - typename iterator_traits<_InputIter>::value_type); - for ( ; __first != __last; ++__first) - if (__pred(*__first)) - ++__n; -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -typename iterator_traits<_InputIter>::difference_type -count(_InputIter __first, _InputIter __last, const _Tp& __value) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(typename iterator_traits<_InputIter>::value_type, - _EqualityComparable); - __STL_REQUIRES(_Tp, _EqualityComparable); - typename iterator_traits<_InputIter>::difference_type __n = 0; - for ( ; __first != __last; ++__first) - if (*__first == __value) - ++__n; - return __n; -} - -template -typename iterator_traits<_InputIter>::difference_type -count_if(_InputIter __first, _InputIter __last, _Predicate __pred) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, - typename iterator_traits<_InputIter>::value_type); - typename iterator_traits<_InputIter>::difference_type __n = 0; - for ( ; __first != __last; ++__first) - if (__pred(*__first)) - ++__n; - return __n; -} - - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// search. - -template -_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2) -{ - __STL_REQUIRES(_ForwardIter1, _ForwardIterator); - __STL_REQUIRES(_ForwardIter2, _ForwardIterator); - __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool, - typename iterator_traits<_ForwardIter1>::value_type, - typename iterator_traits<_ForwardIter2>::value_type); - - // Test for empty ranges - if (__first1 == __last1 || __first2 == __last2) - return __first1; - - // Test for a pattern of length 1. - _ForwardIter2 __tmp(__first2); - ++__tmp; - if (__tmp == __last2) - return find(__first1, __last1, *__first2); - - // General case. - - _ForwardIter2 __p1, __p; - - __p1 = __first2; ++__p1; - - _ForwardIter1 __current = __first1; - - while (__first1 != __last1) { - __first1 = find(__first1, __last1, *__first2); - if (__first1 == __last1) - return __last1; - - __p = __p1; - __current = __first1; - if (++__current == __last1) - return __last1; - - while (*__current == *__p) { - if (++__p == __last2) - return __first1; - if (++__current == __last1) - return __last1; - } - - ++__first1; - } - return __first1; -} - -template -_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2, - _BinaryPred __predicate) -{ - __STL_REQUIRES(_ForwardIter1, _ForwardIterator); - __STL_REQUIRES(_ForwardIter2, _ForwardIterator); - __STL_BINARY_FUNCTION_CHECK(_BinaryPred, bool, - typename iterator_traits<_ForwardIter1>::value_type, - typename iterator_traits<_ForwardIter2>::value_type); - - // Test for empty ranges - if (__first1 == __last1 || __first2 == __last2) - return __first1; - - // Test for a pattern of length 1. - _ForwardIter2 __tmp(__first2); - ++__tmp; - if (__tmp == __last2) { - while (__first1 != __last1 && !__predicate(*__first1, *__first2)) - ++__first1; - return __first1; - } - - // General case. - - _ForwardIter2 __p1, __p; - - __p1 = __first2; ++__p1; - - _ForwardIter1 __current = __first1; - - while (__first1 != __last1) { - while (__first1 != __last1) { - if (__predicate(*__first1, *__first2)) - break; - ++__first1; - } - while (__first1 != __last1 && !__predicate(*__first1, *__first2)) - ++__first1; - if (__first1 == __last1) - return __last1; - - __p = __p1; - __current = __first1; - if (++__current == __last1) return __last1; - - while (__predicate(*__current, *__p)) { - if (++__p == __last2) - return __first1; - if (++__current == __last1) - return __last1; - } - - ++__first1; - } - return __first1; -} - -// search_n. Search for __count consecutive copies of __val. - -template -_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last, - _Integer __count, const _Tp& __val) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type, - _EqualityComparable); - __STL_REQUIRES(_Tp, _EqualityComparable); - - if (__count <= 0) - return __first; - else { - __first = find(__first, __last, __val); - while (__first != __last) { - _Integer __n = __count - 1; - _ForwardIter __i = __first; - ++__i; - while (__i != __last && __n != 0 && *__i == __val) { - ++__i; - --__n; - } - if (__n == 0) - return __first; - else - __first = find(__i, __last, __val); - } - return __last; - } -} - -template -_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last, - _Integer __count, const _Tp& __val, - _BinaryPred __binary_pred) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_BINARY_FUNCTION_CHECK(_BinaryPred, bool, - typename iterator_traits<_ForwardIter>::value_type, _Tp); - if (__count <= 0) - return __first; - else { - while (__first != __last) { - if (__binary_pred(*__first, __val)) - break; - ++__first; - } - while (__first != __last) { - _Integer __n = __count - 1; - _ForwardIter __i = __first; - ++__i; - while (__i != __last && __n != 0 && __binary_pred(*__i, __val)) { - ++__i; - --__n; - } - if (__n == 0) - return __first; - else { - while (__i != __last) { - if (__binary_pred(*__i, __val)) - break; - ++__i; - } - __first = __i; - } - } - return __last; - } -} - -// swap_ranges - -template -_ForwardIter2 swap_ranges(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2) { - __STL_REQUIRES(_ForwardIter1, _Mutable_ForwardIterator); - __STL_REQUIRES(_ForwardIter2, _Mutable_ForwardIterator); - __STL_CONVERTIBLE(typename iterator_traits<_ForwardIter1>::value_type, - typename iterator_traits<_ForwardIter2>::value_type); - __STL_CONVERTIBLE(typename iterator_traits<_ForwardIter2>::value_type, - typename iterator_traits<_ForwardIter1>::value_type); - for ( ; __first1 != __last1; ++__first1, ++__first2) - iter_swap(__first1, __first2); - return __first2; -} - -// transform - -template -_OutputIter transform(_InputIter __first, _InputIter __last, - _OutputIter __result, _UnaryOperation __opr) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - - for ( ; __first != __last; ++__first, ++__result) - *__result = __opr(*__first); - return __result; -} - -template -_OutputIter transform(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _OutputIter __result, - _BinaryOperation __binary_op) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - for ( ; __first1 != __last1; ++__first1, ++__first2, ++__result) - *__result = __binary_op(*__first1, *__first2); - return __result; -} - -// replace, replace_if, replace_copy, replace_copy_if - -template -void replace(_ForwardIter __first, _ForwardIter __last, - const _Tp& __old_value, const _Tp& __new_value) { - __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); - __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool, - typename iterator_traits<_ForwardIter>::value_type, _Tp); - __STL_CONVERTIBLE(_Tp, typename iterator_traits<_ForwardIter>::value_type); - for ( ; __first != __last; ++__first) - if (*__first == __old_value) - *__first = __new_value; -} - -template -void replace_if(_ForwardIter __first, _ForwardIter __last, - _Predicate __pred, const _Tp& __new_value) { - __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); - __STL_CONVERTIBLE(_Tp, typename iterator_traits<_ForwardIter>::value_type); - __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, - typename iterator_traits<_ForwardIter>::value_type); - for ( ; __first != __last; ++__first) - if (__pred(*__first)) - *__first = __new_value; -} - -template -_OutputIter replace_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - const _Tp& __old_value, const _Tp& __new_value) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool, - typename iterator_traits<_InputIter>::value_type, _Tp); - for ( ; __first != __last; ++__first, ++__result) - *__result = *__first == __old_value ? __new_value : *__first; - return __result; -} - -template -_OutputIter replace_copy_if(_InputIter __first, _InputIter __last, - _OutputIter __result, - _Predicate __pred, const _Tp& __new_value) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, - typename iterator_traits<_InputIter>::value_type); - for ( ; __first != __last; ++__first, ++__result) - *__result = __pred(*__first) ? __new_value : *__first; - return __result; -} - -// generate and generate_n - -template -void generate(_ForwardIter __first, _ForwardIter __last, _Generator __gen) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_GENERATOR_CHECK(_Generator, - typename iterator_traits<_ForwardIter>::value_type); - for ( ; __first != __last; ++__first) - *__first = __gen(); -} - -template -_OutputIter generate_n(_OutputIter __first, _Size __n, _Generator __gen) { - __STL_REQUIRES(_OutputIter, _OutputIterator); - for ( ; __n > 0; --__n, ++__first) - *__first = __gen(); - return __first; -} - -// remove, remove_if, remove_copy, remove_copy_if - -template -_OutputIter remove_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, const _Tp& __value) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool, - typename iterator_traits<_InputIter>::value_type, _Tp); - for ( ; __first != __last; ++__first) - if (!(*__first == __value)) { - *__result = *__first; - ++__result; - } - return __result; -} - -template -_OutputIter remove_copy_if(_InputIter __first, _InputIter __last, - _OutputIter __result, _Predicate __pred) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, - typename iterator_traits<_InputIter>::value_type); - for ( ; __first != __last; ++__first) - if (!__pred(*__first)) { - *__result = *__first; - ++__result; - } - return __result; -} - -template -_ForwardIter remove(_ForwardIter __first, _ForwardIter __last, - const _Tp& __value) { - __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); - __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool, - typename iterator_traits<_ForwardIter>::value_type, _Tp); - __STL_CONVERTIBLE(_Tp, typename iterator_traits<_ForwardIter>::value_type); - __first = find(__first, __last, __value); - _ForwardIter __i = __first; - return __first == __last ? __first - : remove_copy(++__i, __last, __first, __value); -} - -template -_ForwardIter remove_if(_ForwardIter __first, _ForwardIter __last, - _Predicate __pred) { - __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); - __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, - typename iterator_traits<_ForwardIter>::value_type); - __first = find_if(__first, __last, __pred); - _ForwardIter __i = __first; - return __first == __last ? __first - : remove_copy_if(++__i, __last, __first, __pred); -} - -// unique and unique_copy - -template -_OutputIter __unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, _Tp*) { - _Tp __value = *__first; - *__result = __value; - while (++__first != __last) - if (!(__value == *__first)) { - __value = *__first; - *++__result = __value; - } - return ++__result; -} - -template -inline _OutputIter __unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - output_iterator_tag) { - return __unique_copy(__first, __last, __result, __VALUE_TYPE(__first)); -} - -template -_ForwardIter __unique_copy(_InputIter __first, _InputIter __last, - _ForwardIter __result, forward_iterator_tag) { - *__result = *__first; - while (++__first != __last) - if (!(*__result == *__first)) - *++__result = *__first; - return ++__result; -} - -template -inline _OutputIter unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES(typename iterator_traits<_InputIter>::value_type, - _EqualityComparable); - if (__first == __last) return __result; - return __unique_copy(__first, __last, __result, - __ITERATOR_CATEGORY(__result)); -} - -template -_OutputIter __unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - _BinaryPredicate __binary_pred, _Tp*) { - __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool, _Tp, _Tp); - _Tp __value = *__first; - *__result = __value; - while (++__first != __last) - if (!__binary_pred(__value, *__first)) { - __value = *__first; - *++__result = __value; - } - return ++__result; -} - -template -inline _OutputIter __unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - _BinaryPredicate __binary_pred, - output_iterator_tag) { - return __unique_copy(__first, __last, __result, __binary_pred, - __VALUE_TYPE(__first)); -} - -template -_ForwardIter __unique_copy(_InputIter __first, _InputIter __last, - _ForwardIter __result, - _BinaryPredicate __binary_pred, - forward_iterator_tag) { - __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool, - typename iterator_traits<_ForwardIter>::value_type, - typename iterator_traits<_InputIter>::value_type); - *__result = *__first; - while (++__first != __last) - if (!__binary_pred(*__result, *__first)) *++__result = *__first; - return ++__result; -} - -template -inline _OutputIter unique_copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - _BinaryPredicate __binary_pred) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - if (__first == __last) return __result; - return __unique_copy(__first, __last, __result, __binary_pred, - __ITERATOR_CATEGORY(__result)); -} - -template -_ForwardIter unique(_ForwardIter __first, _ForwardIter __last) { - __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); - __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type, - _EqualityComparable); - __first = adjacent_find(__first, __last); - return unique_copy(__first, __last, __first); -} - -template -_ForwardIter unique(_ForwardIter __first, _ForwardIter __last, - _BinaryPredicate __binary_pred) { - __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); - __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool, - typename iterator_traits<_ForwardIter>::value_type, - typename iterator_traits<_ForwardIter>::value_type); - __first = adjacent_find(__first, __last, __binary_pred); - return unique_copy(__first, __last, __first, __binary_pred); -} - -// reverse and reverse_copy, and their auxiliary functions - -template -void __reverse(_BidirectionalIter __first, _BidirectionalIter __last, - bidirectional_iterator_tag) { - while (true) - if (__first == __last || __first == --__last) - return; - else - iter_swap(__first++, __last); -} - -template -void __reverse(_RandomAccessIter __first, _RandomAccessIter __last, - random_access_iterator_tag) { - while (__first < __last) - iter_swap(__first++, --__last); -} - -template -inline void reverse(_BidirectionalIter __first, _BidirectionalIter __last) { - __STL_REQUIRES(_BidirectionalIter, _Mutable_BidirectionalIterator); - __reverse(__first, __last, __ITERATOR_CATEGORY(__first)); -} - -template -_OutputIter reverse_copy(_BidirectionalIter __first, - _BidirectionalIter __last, - _OutputIter __result) { - __STL_REQUIRES(_BidirectionalIter, _BidirectionalIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - while (__first != __last) { - --__last; - *__result = *__last; - ++__result; - } - return __result; -} - -// rotate and rotate_copy, and their auxiliary functions - -template -_EuclideanRingElement __gcd(_EuclideanRingElement __m, - _EuclideanRingElement __n) -{ - while (__n != 0) { - _EuclideanRingElement __t = __m % __n; - __m = __n; - __n = __t; - } - return __m; -} - -template -_ForwardIter __rotate(_ForwardIter __first, - _ForwardIter __middle, - _ForwardIter __last, - _Distance*, - forward_iterator_tag) { - if (__first == __middle) - return __last; - if (__last == __middle) - return __first; - - _ForwardIter __first2 = __middle; - do { - swap(*__first++, *__first2++); - if (__first == __middle) - __middle = __first2; - } while (__first2 != __last); - - _ForwardIter __new_middle = __first; - - __first2 = __middle; - - while (__first2 != __last) { - swap (*__first++, *__first2++); - if (__first == __middle) - __middle = __first2; - else if (__first2 == __last) - __first2 = __middle; - } - - return __new_middle; -} - - -template -_BidirectionalIter __rotate(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, - _Distance*, - bidirectional_iterator_tag) { - __STL_REQUIRES(_BidirectionalIter, _Mutable_BidirectionalIterator); - if (__first == __middle) - return __last; - if (__last == __middle) - return __first; - - __reverse(__first, __middle, bidirectional_iterator_tag()); - __reverse(__middle, __last, bidirectional_iterator_tag()); - - while (__first != __middle && __middle != __last) - swap (*__first++, *--__last); - - if (__first == __middle) { - __reverse(__middle, __last, bidirectional_iterator_tag()); - return __last; - } - else { - __reverse(__first, __middle, bidirectional_iterator_tag()); - return __first; - } -} - -template -_RandomAccessIter __rotate(_RandomAccessIter __first, - _RandomAccessIter __middle, - _RandomAccessIter __last, - _Distance *, _Tp *) { - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - _Distance __n = __last - __first; - _Distance __k = __middle - __first; - _Distance __l = __n - __k; - _RandomAccessIter __result = __first + (__last - __middle); - - if (__k == 0) - return __last; - - else if (__k == __l) { - swap_ranges(__first, __middle, __middle); - return __result; - } - - _Distance __d = __gcd(__n, __k); - - for (_Distance __i = 0; __i < __d; __i++) { - _Tp __tmp = *__first; - _RandomAccessIter __p = __first; - - if (__k < __l) { - for (_Distance __j = 0; __j < __l/__d; __j++) { - if (__p > __first + __l) { - *__p = *(__p - __l); - __p -= __l; - } - - *__p = *(__p + __k); - __p += __k; - } - } - - else { - for (_Distance __j = 0; __j < __k/__d - 1; __j ++) { - if (__p < __last - __k) { - *__p = *(__p + __k); - __p += __k; - } - - *__p = * (__p - __l); - __p -= __l; - } - } - - *__p = __tmp; - ++__first; - } - - return __result; -} - -template -inline _ForwardIter rotate(_ForwardIter __first, _ForwardIter __middle, - _ForwardIter __last) { - __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); - return __rotate(__first, __middle, __last, - __DISTANCE_TYPE(__first), - __ITERATOR_CATEGORY(__first)); -} - -template -_OutputIter rotate_copy(_ForwardIter __first, _ForwardIter __middle, - _ForwardIter __last, _OutputIter __result) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - return copy(__first, __middle, copy(__middle, __last, __result)); -} - -// Return a random number in the range [0, __n). This function encapsulates -// whether we're using rand (part of the standard C library) or lrand48 -// (not standard, but a much better choice whenever it's available). - -template -inline _Distance __random_number(_Distance __n) { -#ifdef __STL_NO_DRAND48 - return rand() % __n; -#else - return lrand48() % __n; -#endif -} - -// random_shuffle - -template -inline void random_shuffle(_RandomAccessIter __first, - _RandomAccessIter __last) { - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - if (__first == __last) return; - for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) - iter_swap(__i, __first + __random_number((__i - __first) + 1)); -} - -template -void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last, - _RandomNumberGenerator& __rand) { - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - if (__first == __last) return; - for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) - iter_swap(__i, __first + __rand((__i - __first) + 1)); -} - -// random_sample and random_sample_n (extensions, not part of the standard). - -template -_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last, - _OutputIter __out, const _Distance __n) -{ - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - _Distance __remaining = 0; - distance(__first, __last, __remaining); - _Distance __m = min(__n, __remaining); - - while (__m > 0) { - if (__random_number(__remaining) < __m) { - *__out = *__first; - ++__out; - --__m; - } - - --__remaining; - ++__first; - } - return __out; -} - -template -_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last, - _OutputIter __out, const _Distance __n, - _RandomNumberGenerator& __rand) -{ - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_UNARY_FUNCTION_CHECK(_RandomNumberGenerator, _Distance, _Distance); - _Distance __remaining = 0; - distance(__first, __last, __remaining); - _Distance __m = min(__n, __remaining); - - while (__m > 0) { - if (__rand(__remaining) < __m) { - *__out = *__first; - ++__out; - --__m; - } - - --__remaining; - ++__first; - } - return __out; -} - -template -_RandomAccessIter __random_sample(_InputIter __first, _InputIter __last, - _RandomAccessIter __out, - const _Distance __n) -{ - _Distance __m = 0; - _Distance __t = __n; - for ( ; __first != __last && __m < __n; ++__m, ++__first) - __out[__m] = *__first; - - while (__first != __last) { - ++__t; - _Distance __M = __random_number(__t); - if (__M < __n) - __out[__M] = *__first; - ++__first; - } - - return __out + __m; -} - -template -_RandomAccessIter __random_sample(_InputIter __first, _InputIter __last, - _RandomAccessIter __out, - _RandomNumberGenerator& __rand, - const _Distance __n) -{ - __STL_UNARY_FUNCTION_CHECK(_RandomNumberGenerator, _Distance, _Distance); - _Distance __m = 0; - _Distance __t = __n; - for ( ; __first != __last && __m < __n; ++__m, ++__first) - __out[__m] = *__first; - - while (__first != __last) { - ++__t; - _Distance __M = __rand(__t); - if (__M < __n) - __out[__M] = *__first; - ++__first; - } - - return __out + __m; -} - -template -inline _RandomAccessIter -random_sample(_InputIter __first, _InputIter __last, - _RandomAccessIter __out_first, _RandomAccessIter __out_last) -{ - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - return __random_sample(__first, __last, - __out_first, __out_last - __out_first); -} - - -template -inline _RandomAccessIter -random_sample(_InputIter __first, _InputIter __last, - _RandomAccessIter __out_first, _RandomAccessIter __out_last, - _RandomNumberGenerator& __rand) -{ - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - return __random_sample(__first, __last, - __out_first, __rand, - __out_last - __out_first); -} - -// partition, stable_partition, and their auxiliary functions - -template -_ForwardIter __partition(_ForwardIter __first, - _ForwardIter __last, - _Predicate __pred, - forward_iterator_tag) { - if (__first == __last) return __first; - - while (__pred(*__first)) - if (++__first == __last) return __first; - - _ForwardIter __next = __first; - - while (++__next != __last) - if (__pred(*__next)) { - swap(*__first, *__next); - ++__first; - } - - return __first; -} - -template -_BidirectionalIter __partition(_BidirectionalIter __first, - _BidirectionalIter __last, - _Predicate __pred, - bidirectional_iterator_tag) { - while (true) { - while (true) - if (__first == __last) - return __first; - else if (__pred(*__first)) - ++__first; - else - break; - --__last; - while (true) - if (__first == __last) - return __first; - else if (!__pred(*__last)) - --__last; - else - break; - iter_swap(__first, __last); - ++__first; - } -} - -template -inline _ForwardIter partition(_ForwardIter __first, - _ForwardIter __last, - _Predicate __pred) { - __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); - __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, - typename iterator_traits<_ForwardIter>::value_type); - return __partition(__first, __last, __pred, __ITERATOR_CATEGORY(__first)); -} - - -template -_ForwardIter __inplace_stable_partition(_ForwardIter __first, - _ForwardIter __last, - _Predicate __pred, _Distance __len) { - if (__len == 1) - return __pred(*__first) ? __last : __first; - _ForwardIter __middle = __first; - advance(__middle, __len / 2); - return rotate(__inplace_stable_partition(__first, __middle, __pred, - __len / 2), - __middle, - __inplace_stable_partition(__middle, __last, __pred, - __len - __len / 2)); -} - -template -_ForwardIter __stable_partition_adaptive(_ForwardIter __first, - _ForwardIter __last, - _Predicate __pred, _Distance __len, - _Pointer __buffer, - _Distance __buffer_size) -{ - if (__len <= __buffer_size) { - _ForwardIter __result1 = __first; - _Pointer __result2 = __buffer; - for ( ; __first != __last ; ++__first) - if (__pred(*__first)) { - *__result1 = *__first; - ++__result1; - } - else { - *__result2 = *__first; - ++__result2; - } - copy(__buffer, __result2, __result1); - return __result1; - } - else { - _ForwardIter __middle = __first; - advance(__middle, __len / 2); - return rotate(__stable_partition_adaptive( - __first, __middle, __pred, - __len / 2, __buffer, __buffer_size), - __middle, - __stable_partition_adaptive( - __middle, __last, __pred, - __len - __len / 2, __buffer, __buffer_size)); - } -} - -template -inline _ForwardIter -__stable_partition_aux(_ForwardIter __first, _ForwardIter __last, - _Predicate __pred, _Tp*, _Distance*) -{ - _Temporary_buffer<_ForwardIter, _Tp> __buf(__first, __last); - if (__buf.size() > 0) - return __stable_partition_adaptive(__first, __last, __pred, - _Distance(__buf.requested_size()), - __buf.begin(), __buf.size()); - else - return __inplace_stable_partition(__first, __last, __pred, - _Distance(__buf.requested_size())); -} - -template -inline _ForwardIter stable_partition(_ForwardIter __first, - _ForwardIter __last, - _Predicate __pred) { - __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); - __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, - typename iterator_traits<_ForwardIter>::value_type); - if (__first == __last) - return __first; - else - return __stable_partition_aux(__first, __last, __pred, - __VALUE_TYPE(__first), - __DISTANCE_TYPE(__first)); -} - -template -_RandomAccessIter __unguarded_partition(_RandomAccessIter __first, - _RandomAccessIter __last, - _Tp __pivot) -{ - while (true) { - while (*__first < __pivot) - ++__first; - --__last; - while (__pivot < *__last) - --__last; - if (!(__first < __last)) - return __first; - iter_swap(__first, __last); - ++__first; - } -} - -template -_RandomAccessIter __unguarded_partition(_RandomAccessIter __first, - _RandomAccessIter __last, - _Tp __pivot, _Compare __comp) -{ - while (true) { - while (__comp(*__first, __pivot)) - ++__first; - --__last; - while (__comp(__pivot, *__last)) - --__last; - if (!(__first < __last)) - return __first; - iter_swap(__first, __last); - ++__first; - } -} - -const int __stl_threshold = 16; - -// sort() and its auxiliary functions. - -template -void __unguarded_linear_insert(_RandomAccessIter __last, _Tp __val) { - _RandomAccessIter __next = __last; - --__next; - while (__val < *__next) { - *__last = *__next; - __last = __next; - --__next; - } - *__last = __val; -} - -template -void __unguarded_linear_insert(_RandomAccessIter __last, _Tp __val, - _Compare __comp) { - _RandomAccessIter __next = __last; - --__next; - while (__comp(__val, *__next)) { - *__last = *__next; - __last = __next; - --__next; - } - *__last = __val; -} - -template -inline void __linear_insert(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*) { - _Tp __val = *__last; - if (__val < *__first) { - copy_backward(__first, __last, __last + 1); - *__first = __val; - } - else - __unguarded_linear_insert(__last, __val); -} - -template -inline void __linear_insert(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*, _Compare __comp) { - _Tp __val = *__last; - if (__comp(__val, *__first)) { - copy_backward(__first, __last, __last + 1); - *__first = __val; - } - else - __unguarded_linear_insert(__last, __val, __comp); -} - -template -void __insertion_sort(_RandomAccessIter __first, _RandomAccessIter __last) { - if (__first == __last) return; - for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) - __linear_insert(__first, __i, __VALUE_TYPE(__first)); -} - -template -void __insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last, _Compare __comp) { - if (__first == __last) return; - for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) - __linear_insert(__first, __i, __VALUE_TYPE(__first), __comp); -} - -template -void __unguarded_insertion_sort_aux(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*) { - for (_RandomAccessIter __i = __first; __i != __last; ++__i) - __unguarded_linear_insert(__i, _Tp(*__i)); -} - -template -inline void __unguarded_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last) { - __unguarded_insertion_sort_aux(__first, __last, __VALUE_TYPE(__first)); -} - -template -void __unguarded_insertion_sort_aux(_RandomAccessIter __first, - _RandomAccessIter __last, - _Tp*, _Compare __comp) { - for (_RandomAccessIter __i = __first; __i != __last; ++__i) - __unguarded_linear_insert(__i, _Tp(*__i), __comp); -} - -template -inline void __unguarded_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last, - _Compare __comp) { - __unguarded_insertion_sort_aux(__first, __last, __VALUE_TYPE(__first), - __comp); -} - -template -void __final_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last) { - if (__last - __first > __stl_threshold) { - __insertion_sort(__first, __first + __stl_threshold); - __unguarded_insertion_sort(__first + __stl_threshold, __last); - } - else - __insertion_sort(__first, __last); -} - -template -void __final_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last, _Compare __comp) { - if (__last - __first > __stl_threshold) { - __insertion_sort(__first, __first + __stl_threshold, __comp); - __unguarded_insertion_sort(__first + __stl_threshold, __last, __comp); - } - else - __insertion_sort(__first, __last, __comp); -} - -template -inline _Size __lg(_Size __n) { - _Size __k; - for (__k = 0; __n != 1; __n >>= 1) ++__k; - return __k; -} - -template -void __introsort_loop(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*, - _Size __depth_limit) -{ - while (__last - __first > __stl_threshold) { - if (__depth_limit == 0) { - partial_sort(__first, __last, __last); - return; - } - --__depth_limit; - _RandomAccessIter __cut = - __unguarded_partition(__first, __last, - _Tp(__median(*__first, - *(__first + (__last - __first)/2), - *(__last - 1)))); - __introsort_loop(__cut, __last, (_Tp*) 0, __depth_limit); - __last = __cut; - } -} - -template -void __introsort_loop(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*, - _Size __depth_limit, _Compare __comp) -{ - while (__last - __first > __stl_threshold) { - if (__depth_limit == 0) { - partial_sort(__first, __last, __last, __comp); - return; - } - --__depth_limit; - _RandomAccessIter __cut = - __unguarded_partition(__first, __last, - _Tp(__median(*__first, - *(__first + (__last - __first)/2), - *(__last - 1), __comp)), - __comp); - __introsort_loop(__cut, __last, (_Tp*) 0, __depth_limit, __comp); - __last = __cut; - } -} - -template -inline void sort(_RandomAccessIter __first, _RandomAccessIter __last) { - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type, - _LessThanComparable); - if (__first != __last) { - __introsort_loop(__first, __last, - __VALUE_TYPE(__first), - __lg(__last - __first) * 2); - __final_insertion_sort(__first, __last); - } -} - -template -inline void sort(_RandomAccessIter __first, _RandomAccessIter __last, - _Compare __comp) { - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_RandomAccessIter>::value_type, - typename iterator_traits<_RandomAccessIter>::value_type); - if (__first != __last) { - __introsort_loop(__first, __last, - __VALUE_TYPE(__first), - __lg(__last - __first) * 2, - __comp); - __final_insertion_sort(__first, __last, __comp); - } -} - -// stable_sort() and its auxiliary functions. - -template -void __inplace_stable_sort(_RandomAccessIter __first, - _RandomAccessIter __last) { - if (__last - __first < 15) { - __insertion_sort(__first, __last); - return; - } - _RandomAccessIter __middle = __first + (__last - __first) / 2; - __inplace_stable_sort(__first, __middle); - __inplace_stable_sort(__middle, __last); - __merge_without_buffer(__first, __middle, __last, - __middle - __first, - __last - __middle); -} - -template -void __inplace_stable_sort(_RandomAccessIter __first, - _RandomAccessIter __last, _Compare __comp) { - if (__last - __first < 15) { - __insertion_sort(__first, __last, __comp); - return; - } - _RandomAccessIter __middle = __first + (__last - __first) / 2; - __inplace_stable_sort(__first, __middle, __comp); - __inplace_stable_sort(__middle, __last, __comp); - __merge_without_buffer(__first, __middle, __last, - __middle - __first, - __last - __middle, - __comp); -} - -template -void __merge_sort_loop(_RandomAccessIter1 __first, - _RandomAccessIter1 __last, - _RandomAccessIter2 __result, _Distance __step_size) { - _Distance __two_step = 2 * __step_size; - - while (__last - __first >= __two_step) { - __result = merge(__first, __first + __step_size, - __first + __step_size, __first + __two_step, - __result); - __first += __two_step; - } - - __step_size = min(_Distance(__last - __first), __step_size); - merge(__first, __first + __step_size, __first + __step_size, __last, - __result); -} - -template -void __merge_sort_loop(_RandomAccessIter1 __first, - _RandomAccessIter1 __last, - _RandomAccessIter2 __result, _Distance __step_size, - _Compare __comp) { - _Distance __two_step = 2 * __step_size; - - while (__last - __first >= __two_step) { - __result = merge(__first, __first + __step_size, - __first + __step_size, __first + __two_step, - __result, - __comp); - __first += __two_step; - } - __step_size = min(_Distance(__last - __first), __step_size); - - merge(__first, __first + __step_size, - __first + __step_size, __last, - __result, - __comp); -} - -const int __stl_chunk_size = 7; - -template -void __chunk_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last, _Distance __chunk_size) -{ - while (__last - __first >= __chunk_size) { - __insertion_sort(__first, __first + __chunk_size); - __first += __chunk_size; - } - __insertion_sort(__first, __last); -} - -template -void __chunk_insertion_sort(_RandomAccessIter __first, - _RandomAccessIter __last, - _Distance __chunk_size, _Compare __comp) -{ - while (__last - __first >= __chunk_size) { - __insertion_sort(__first, __first + __chunk_size, __comp); - __first += __chunk_size; - } - __insertion_sort(__first, __last, __comp); -} - -template -void __merge_sort_with_buffer(_RandomAccessIter __first, - _RandomAccessIter __last, - _Pointer __buffer, _Distance*) { - _Distance __len = __last - __first; - _Pointer __buffer_last = __buffer + __len; - - _Distance __step_size = __stl_chunk_size; - __chunk_insertion_sort(__first, __last, __step_size); - - while (__step_size < __len) { - __merge_sort_loop(__first, __last, __buffer, __step_size); - __step_size *= 2; - __merge_sort_loop(__buffer, __buffer_last, __first, __step_size); - __step_size *= 2; - } -} - -template -void __merge_sort_with_buffer(_RandomAccessIter __first, - _RandomAccessIter __last, _Pointer __buffer, - _Distance*, _Compare __comp) { - _Distance __len = __last - __first; - _Pointer __buffer_last = __buffer + __len; - - _Distance __step_size = __stl_chunk_size; - __chunk_insertion_sort(__first, __last, __step_size, __comp); - - while (__step_size < __len) { - __merge_sort_loop(__first, __last, __buffer, __step_size, __comp); - __step_size *= 2; - __merge_sort_loop(__buffer, __buffer_last, __first, __step_size, __comp); - __step_size *= 2; - } -} - -template -void __stable_sort_adaptive(_RandomAccessIter __first, - _RandomAccessIter __last, _Pointer __buffer, - _Distance __buffer_size) { - _Distance __len = (__last - __first + 1) / 2; - _RandomAccessIter __middle = __first + __len; - if (__len > __buffer_size) { - __stable_sort_adaptive(__first, __middle, __buffer, __buffer_size); - __stable_sort_adaptive(__middle, __last, __buffer, __buffer_size); - } - else { - __merge_sort_with_buffer(__first, __middle, __buffer, (_Distance*)0); - __merge_sort_with_buffer(__middle, __last, __buffer, (_Distance*)0); - } - __merge_adaptive(__first, __middle, __last, _Distance(__middle - __first), - _Distance(__last - __middle), __buffer, __buffer_size); -} - -template -void __stable_sort_adaptive(_RandomAccessIter __first, - _RandomAccessIter __last, _Pointer __buffer, - _Distance __buffer_size, _Compare __comp) { - _Distance __len = (__last - __first + 1) / 2; - _RandomAccessIter __middle = __first + __len; - if (__len > __buffer_size) { - __stable_sort_adaptive(__first, __middle, __buffer, __buffer_size, - __comp); - __stable_sort_adaptive(__middle, __last, __buffer, __buffer_size, - __comp); - } - else { - __merge_sort_with_buffer(__first, __middle, __buffer, (_Distance*)0, - __comp); - __merge_sort_with_buffer(__middle, __last, __buffer, (_Distance*)0, - __comp); - } - __merge_adaptive(__first, __middle, __last, _Distance(__middle - __first), - _Distance(__last - __middle), __buffer, __buffer_size, - __comp); -} - -template -inline void __stable_sort_aux(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*, _Distance*) { - _Temporary_buffer<_RandomAccessIter, _Tp> buf(__first, __last); - if (buf.begin() == 0) - __inplace_stable_sort(__first, __last); - else - __stable_sort_adaptive(__first, __last, buf.begin(), - _Distance(buf.size())); -} - -template -inline void __stable_sort_aux(_RandomAccessIter __first, - _RandomAccessIter __last, _Tp*, _Distance*, - _Compare __comp) { - _Temporary_buffer<_RandomAccessIter, _Tp> buf(__first, __last); - if (buf.begin() == 0) - __inplace_stable_sort(__first, __last, __comp); - else - __stable_sort_adaptive(__first, __last, buf.begin(), - _Distance(buf.size()), - __comp); -} - -template -inline void stable_sort(_RandomAccessIter __first, - _RandomAccessIter __last) { - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type, - _LessThanComparable); - __stable_sort_aux(__first, __last, - __VALUE_TYPE(__first), - __DISTANCE_TYPE(__first)); -} - -template -inline void stable_sort(_RandomAccessIter __first, - _RandomAccessIter __last, _Compare __comp) { - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_RandomAccessIter>::value_type, - typename iterator_traits<_RandomAccessIter>::value_type); - __stable_sort_aux(__first, __last, - __VALUE_TYPE(__first), - __DISTANCE_TYPE(__first), - __comp); -} - -// partial_sort, partial_sort_copy, and auxiliary functions. - -template -void __partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle, - _RandomAccessIter __last, _Tp*) { - make_heap(__first, __middle); - for (_RandomAccessIter __i = __middle; __i < __last; ++__i) - if (*__i < *__first) - __pop_heap(__first, __middle, __i, _Tp(*__i), - __DISTANCE_TYPE(__first)); - sort_heap(__first, __middle); -} - -template -inline void partial_sort(_RandomAccessIter __first, - _RandomAccessIter __middle, - _RandomAccessIter __last) { - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type, - _LessThanComparable); - __partial_sort(__first, __middle, __last, __VALUE_TYPE(__first)); -} - -template -void __partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle, - _RandomAccessIter __last, _Tp*, _Compare __comp) { - make_heap(__first, __middle, __comp); - for (_RandomAccessIter __i = __middle; __i < __last; ++__i) - if (__comp(*__i, *__first)) - __pop_heap(__first, __middle, __i, _Tp(*__i), __comp, - __DISTANCE_TYPE(__first)); - sort_heap(__first, __middle, __comp); -} - -template -inline void partial_sort(_RandomAccessIter __first, - _RandomAccessIter __middle, - _RandomAccessIter __last, _Compare __comp) { - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_RandomAccessIter>::value_type, - typename iterator_traits<_RandomAccessIter>::value_type); - __partial_sort(__first, __middle, __last, __VALUE_TYPE(__first), __comp); -} - -template -_RandomAccessIter __partial_sort_copy(_InputIter __first, - _InputIter __last, - _RandomAccessIter __result_first, - _RandomAccessIter __result_last, - _Distance*, _Tp*) { - if (__result_first == __result_last) return __result_last; - _RandomAccessIter __result_real_last = __result_first; - while(__first != __last && __result_real_last != __result_last) { - *__result_real_last = *__first; - ++__result_real_last; - ++__first; - } - make_heap(__result_first, __result_real_last); - while (__first != __last) { - if (*__first < *__result_first) - __adjust_heap(__result_first, _Distance(0), - _Distance(__result_real_last - __result_first), - _Tp(*__first)); - ++__first; - } - sort_heap(__result_first, __result_real_last); - return __result_real_last; -} - -template -inline _RandomAccessIter -partial_sort_copy(_InputIter __first, _InputIter __last, - _RandomAccessIter __result_first, - _RandomAccessIter __result_last) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - __STL_CONVERTIBLE(typename iterator_traits<_InputIter>::value_type, - typename iterator_traits<_RandomAccessIter>::value_type); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type, - _LessThanComparable); - __STL_REQUIRES(typename iterator_traits<_InputIter>::value_type, - _LessThanComparable); - return __partial_sort_copy(__first, __last, __result_first, __result_last, - __DISTANCE_TYPE(__result_first), - __VALUE_TYPE(__first)); -} - -template -_RandomAccessIter __partial_sort_copy(_InputIter __first, - _InputIter __last, - _RandomAccessIter __result_first, - _RandomAccessIter __result_last, - _Compare __comp, _Distance*, _Tp*) { - if (__result_first == __result_last) return __result_last; - _RandomAccessIter __result_real_last = __result_first; - while(__first != __last && __result_real_last != __result_last) { - *__result_real_last = *__first; - ++__result_real_last; - ++__first; - } - make_heap(__result_first, __result_real_last, __comp); - while (__first != __last) { - if (__comp(*__first, *__result_first)) - __adjust_heap(__result_first, _Distance(0), - _Distance(__result_real_last - __result_first), - _Tp(*__first), - __comp); - ++__first; - } - sort_heap(__result_first, __result_real_last, __comp); - return __result_real_last; -} - -template -inline _RandomAccessIter -partial_sort_copy(_InputIter __first, _InputIter __last, - _RandomAccessIter __result_first, - _RandomAccessIter __result_last, _Compare __comp) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - __STL_CONVERTIBLE(typename iterator_traits<_InputIter>::value_type, - typename iterator_traits<_RandomAccessIter>::value_type); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_RandomAccessIter>::value_type, - typename iterator_traits<_RandomAccessIter>::value_type); - return __partial_sort_copy(__first, __last, __result_first, __result_last, - __comp, - __DISTANCE_TYPE(__result_first), - __VALUE_TYPE(__first)); -} - -// nth_element() and its auxiliary functions. - -template -void __nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, - _RandomAccessIter __last, _Tp*) { - while (__last - __first > 3) { - _RandomAccessIter __cut = - __unguarded_partition(__first, __last, - _Tp(__median(*__first, - *(__first + (__last - __first)/2), - *(__last - 1)))); - if (__cut <= __nth) - __first = __cut; - else - __last = __cut; - } - __insertion_sort(__first, __last); -} - -template -inline void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, - _RandomAccessIter __last) { - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type, - _LessThanComparable); - __nth_element(__first, __nth, __last, __VALUE_TYPE(__first)); -} - -template -void __nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, - _RandomAccessIter __last, _Tp*, _Compare __comp) { - while (__last - __first > 3) { - _RandomAccessIter __cut = - __unguarded_partition(__first, __last, - _Tp(__median(*__first, - *(__first + (__last - __first)/2), - *(__last - 1), - __comp)), - __comp); - if (__cut <= __nth) - __first = __cut; - else - __last = __cut; - } - __insertion_sort(__first, __last, __comp); -} - -template -inline void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, - _RandomAccessIter __last, _Compare __comp) { - __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_RandomAccessIter>::value_type, - typename iterator_traits<_RandomAccessIter>::value_type); - __nth_element(__first, __nth, __last, __VALUE_TYPE(__first), __comp); -} - - -// Binary search (lower_bound, upper_bound, equal_range, binary_search). - -template -_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (*__middle < __val) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else - __len = __half; - } - return __first; -} - -template -inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES_SAME_TYPE(_Tp, - typename iterator_traits<_ForwardIter>::value_type); - __STL_REQUIRES(_Tp, _LessThanComparable); - return __lower_bound(__first, __last, __val, - __DISTANCE_TYPE(__first)); -} - -template -_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Compare __comp, _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (__comp(*__middle, __val)) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else - __len = __half; - } - return __first; -} - -template -inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Compare __comp) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES_SAME_TYPE(_Tp, - typename iterator_traits<_ForwardIter>::value_type); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp); - return __lower_bound(__first, __last, __val, __comp, - __DISTANCE_TYPE(__first)); -} - -template -_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (__val < *__middle) - __len = __half; - else { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - } - return __first; -} - -template -inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES_SAME_TYPE(_Tp, - typename iterator_traits<_ForwardIter>::value_type); - __STL_REQUIRES(_Tp, _LessThanComparable); - return __upper_bound(__first, __last, __val, - __DISTANCE_TYPE(__first)); -} - -template -_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Compare __comp, _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (__comp(__val, *__middle)) - __len = __half; - else { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - } - return __first; -} - -template -inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, _Compare __comp) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES_SAME_TYPE(_Tp, - typename iterator_traits<_ForwardIter>::value_type); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp); - return __upper_bound(__first, __last, __val, __comp, - __DISTANCE_TYPE(__first)); -} - -template -pair<_ForwardIter, _ForwardIter> -__equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, - _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle, __left, __right; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (*__middle < __val) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else if (__val < *__middle) - __len = __half; - else { - __left = lower_bound(__first, __middle, __val); - advance(__first, __len); - __right = upper_bound(++__middle, __first, __val); - return pair<_ForwardIter, _ForwardIter>(__left, __right); - } - } - return pair<_ForwardIter, _ForwardIter>(__first, __first); -} - -template -inline pair<_ForwardIter, _ForwardIter> -equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES_SAME_TYPE(_Tp, - typename iterator_traits<_ForwardIter>::value_type); - __STL_REQUIRES(_Tp, _LessThanComparable); - return __equal_range(__first, __last, __val, - __DISTANCE_TYPE(__first)); -} - -template -pair<_ForwardIter, _ForwardIter> -__equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, - _Compare __comp, _Distance*) -{ - _Distance __len = 0; - distance(__first, __last, __len); - _Distance __half; - _ForwardIter __middle, __left, __right; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - advance(__middle, __half); - if (__comp(*__middle, __val)) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else if (__comp(__val, *__middle)) - __len = __half; - else { - __left = lower_bound(__first, __middle, __val, __comp); - advance(__first, __len); - __right = upper_bound(++__middle, __first, __val, __comp); - return pair<_ForwardIter, _ForwardIter>(__left, __right); - } - } - return pair<_ForwardIter, _ForwardIter>(__first, __first); -} - -template -inline pair<_ForwardIter, _ForwardIter> -equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, - _Compare __comp) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES_SAME_TYPE(_Tp, - typename iterator_traits<_ForwardIter>::value_type); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp); - return __equal_range(__first, __last, __val, __comp, - __DISTANCE_TYPE(__first)); -} - -template -bool binary_search(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES_SAME_TYPE(_Tp, - typename iterator_traits<_ForwardIter>::value_type); - __STL_REQUIRES(_Tp, _LessThanComparable); - _ForwardIter __i = lower_bound(__first, __last, __val); - return __i != __last && !(__val < *__i); -} - -template -bool binary_search(_ForwardIter __first, _ForwardIter __last, - const _Tp& __val, - _Compare __comp) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES_SAME_TYPE(_Tp, - typename iterator_traits<_ForwardIter>::value_type); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp); - _ForwardIter __i = lower_bound(__first, __last, __val, __comp); - return __i != __last && !__comp(__val, *__i); -} - -// merge, with and without an explicitly supplied comparison function. - -template -_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type, - _LessThanComparable); - while (__first1 != __last1 && __first2 != __last2) { - if (*__first2 < *__first1) { - *__result = *__first2; - ++__first2; - } - else { - *__result = *__first1; - ++__first1; - } - ++__result; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -template -_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result, _Compare __comp) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter1>::value_type); - while (__first1 != __last1 && __first2 != __last2) { - if (__comp(*__first2, *__first1)) { - *__result = *__first2; - ++__first2; - } - else { - *__result = *__first1; - ++__first1; - } - ++__result; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -// inplace_merge and its auxiliary functions. - -template -void __merge_without_buffer(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, - _Distance __len1, _Distance __len2) { - if (__len1 == 0 || __len2 == 0) - return; - if (__len1 + __len2 == 2) { - if (*__middle < *__first) - iter_swap(__first, __middle); - return; - } - _BidirectionalIter __first_cut = __first; - _BidirectionalIter __second_cut = __middle; - _Distance __len11 = 0; - _Distance __len22 = 0; - if (__len1 > __len2) { - __len11 = __len1 / 2; - advance(__first_cut, __len11); - __second_cut = lower_bound(__middle, __last, *__first_cut); - distance(__middle, __second_cut, __len22); - } - else { - __len22 = __len2 / 2; - advance(__second_cut, __len22); - __first_cut = upper_bound(__first, __middle, *__second_cut); - distance(__first, __first_cut, __len11); - } - _BidirectionalIter __new_middle - = rotate(__first_cut, __middle, __second_cut); - __merge_without_buffer(__first, __first_cut, __new_middle, - __len11, __len22); - __merge_without_buffer(__new_middle, __second_cut, __last, __len1 - __len11, - __len2 - __len22); -} - -template -void __merge_without_buffer(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, - _Distance __len1, _Distance __len2, - _Compare __comp) { - if (__len1 == 0 || __len2 == 0) - return; - if (__len1 + __len2 == 2) { - if (__comp(*__middle, *__first)) - iter_swap(__first, __middle); - return; - } - _BidirectionalIter __first_cut = __first; - _BidirectionalIter __second_cut = __middle; - _Distance __len11 = 0; - _Distance __len22 = 0; - if (__len1 > __len2) { - __len11 = __len1 / 2; - advance(__first_cut, __len11); - __second_cut = lower_bound(__middle, __last, *__first_cut, __comp); - distance(__middle, __second_cut, __len22); - } - else { - __len22 = __len2 / 2; - advance(__second_cut, __len22); - __first_cut = upper_bound(__first, __middle, *__second_cut, __comp); - distance(__first, __first_cut, __len11); - } - _BidirectionalIter __new_middle - = rotate(__first_cut, __middle, __second_cut); - __merge_without_buffer(__first, __first_cut, __new_middle, __len11, __len22, - __comp); - __merge_without_buffer(__new_middle, __second_cut, __last, __len1 - __len11, - __len2 - __len22, __comp); -} - -template -_BidirectionalIter1 __rotate_adaptive(_BidirectionalIter1 __first, - _BidirectionalIter1 __middle, - _BidirectionalIter1 __last, - _Distance __len1, _Distance __len2, - _BidirectionalIter2 __buffer, - _Distance __buffer_size) { - _BidirectionalIter2 __buffer_end; - if (__len1 > __len2 && __len2 <= __buffer_size) { - __buffer_end = copy(__middle, __last, __buffer); - copy_backward(__first, __middle, __last); - return copy(__buffer, __buffer_end, __first); - } - else if (__len1 <= __buffer_size) { - __buffer_end = copy(__first, __middle, __buffer); - copy(__middle, __last, __first); - return copy_backward(__buffer, __buffer_end, __last); - } - else - return rotate(__first, __middle, __last); -} - -template -_BidirectionalIter3 __merge_backward(_BidirectionalIter1 __first1, - _BidirectionalIter1 __last1, - _BidirectionalIter2 __first2, - _BidirectionalIter2 __last2, - _BidirectionalIter3 __result) { - if (__first1 == __last1) - return copy_backward(__first2, __last2, __result); - if (__first2 == __last2) - return copy_backward(__first1, __last1, __result); - --__last1; - --__last2; - while (true) { - if (*__last2 < *__last1) { - *--__result = *__last1; - if (__first1 == __last1) - return copy_backward(__first2, ++__last2, __result); - --__last1; - } - else { - *--__result = *__last2; - if (__first2 == __last2) - return copy_backward(__first1, ++__last1, __result); - --__last2; - } - } -} - -template -_BidirectionalIter3 __merge_backward(_BidirectionalIter1 __first1, - _BidirectionalIter1 __last1, - _BidirectionalIter2 __first2, - _BidirectionalIter2 __last2, - _BidirectionalIter3 __result, - _Compare __comp) { - if (__first1 == __last1) - return copy_backward(__first2, __last2, __result); - if (__first2 == __last2) - return copy_backward(__first1, __last1, __result); - --__last1; - --__last2; - while (true) { - if (__comp(*__last2, *__last1)) { - *--__result = *__last1; - if (__first1 == __last1) - return copy_backward(__first2, ++__last2, __result); - --__last1; - } - else { - *--__result = *__last2; - if (__first2 == __last2) - return copy_backward(__first1, ++__last1, __result); - --__last2; - } - } -} - -template -void __merge_adaptive(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, - _Distance __len1, _Distance __len2, - _Pointer __buffer, _Distance __buffer_size) { - if (__len1 <= __len2 && __len1 <= __buffer_size) { - _Pointer __buffer_end = copy(__first, __middle, __buffer); - merge(__buffer, __buffer_end, __middle, __last, __first); - } - else if (__len2 <= __buffer_size) { - _Pointer __buffer_end = copy(__middle, __last, __buffer); - __merge_backward(__first, __middle, __buffer, __buffer_end, __last); - } - else { - _BidirectionalIter __first_cut = __first; - _BidirectionalIter __second_cut = __middle; - _Distance __len11 = 0; - _Distance __len22 = 0; - if (__len1 > __len2) { - __len11 = __len1 / 2; - advance(__first_cut, __len11); - __second_cut = lower_bound(__middle, __last, *__first_cut); - distance(__middle, __second_cut, __len22); - } - else { - __len22 = __len2 / 2; - advance(__second_cut, __len22); - __first_cut = upper_bound(__first, __middle, *__second_cut); - distance(__first, __first_cut, __len11); - } - _BidirectionalIter __new_middle = - __rotate_adaptive(__first_cut, __middle, __second_cut, __len1 - __len11, - __len22, __buffer, __buffer_size); - __merge_adaptive(__first, __first_cut, __new_middle, __len11, - __len22, __buffer, __buffer_size); - __merge_adaptive(__new_middle, __second_cut, __last, __len1 - __len11, - __len2 - __len22, __buffer, __buffer_size); - } -} - -template -void __merge_adaptive(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, - _Distance __len1, _Distance __len2, - _Pointer __buffer, _Distance __buffer_size, - _Compare __comp) { - if (__len1 <= __len2 && __len1 <= __buffer_size) { - _Pointer __buffer_end = copy(__first, __middle, __buffer); - merge(__buffer, __buffer_end, __middle, __last, __first, __comp); - } - else if (__len2 <= __buffer_size) { - _Pointer __buffer_end = copy(__middle, __last, __buffer); - __merge_backward(__first, __middle, __buffer, __buffer_end, __last, - __comp); - } - else { - _BidirectionalIter __first_cut = __first; - _BidirectionalIter __second_cut = __middle; - _Distance __len11 = 0; - _Distance __len22 = 0; - if (__len1 > __len2) { - __len11 = __len1 / 2; - advance(__first_cut, __len11); - __second_cut = lower_bound(__middle, __last, *__first_cut, __comp); - distance(__middle, __second_cut, __len22); - } - else { - __len22 = __len2 / 2; - advance(__second_cut, __len22); - __first_cut = upper_bound(__first, __middle, *__second_cut, __comp); - distance(__first, __first_cut, __len11); - } - _BidirectionalIter __new_middle = - __rotate_adaptive(__first_cut, __middle, __second_cut, __len1 - __len11, - __len22, __buffer, __buffer_size); - __merge_adaptive(__first, __first_cut, __new_middle, __len11, - __len22, __buffer, __buffer_size, __comp); - __merge_adaptive(__new_middle, __second_cut, __last, __len1 - __len11, - __len2 - __len22, __buffer, __buffer_size, __comp); - } -} - -template -inline void __inplace_merge_aux(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, _Tp*, _Distance*) { - _Distance __len1 = 0; - distance(__first, __middle, __len1); - _Distance __len2 = 0; - distance(__middle, __last, __len2); - - _Temporary_buffer<_BidirectionalIter, _Tp> __buf(__first, __last); - if (__buf.begin() == 0) - __merge_without_buffer(__first, __middle, __last, __len1, __len2); - else - __merge_adaptive(__first, __middle, __last, __len1, __len2, - __buf.begin(), _Distance(__buf.size())); -} - -template -inline void __inplace_merge_aux(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, _Tp*, _Distance*, - _Compare __comp) { - _Distance __len1 = 0; - distance(__first, __middle, __len1); - _Distance __len2 = 0; - distance(__middle, __last, __len2); - - _Temporary_buffer<_BidirectionalIter, _Tp> __buf(__first, __last); - if (__buf.begin() == 0) - __merge_without_buffer(__first, __middle, __last, __len1, __len2, __comp); - else - __merge_adaptive(__first, __middle, __last, __len1, __len2, - __buf.begin(), _Distance(__buf.size()), - __comp); -} - -template -inline void inplace_merge(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last) { - __STL_REQUIRES(_BidirectionalIter, _Mutable_BidirectionalIterator); - __STL_REQUIRES(typename iterator_traits<_BidirectionalIter>::value_type, - _LessThanComparable); - if (__first == __middle || __middle == __last) - return; - __inplace_merge_aux(__first, __middle, __last, - __VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); -} - -template -inline void inplace_merge(_BidirectionalIter __first, - _BidirectionalIter __middle, - _BidirectionalIter __last, _Compare __comp) { - __STL_REQUIRES(_BidirectionalIter, _Mutable_BidirectionalIterator); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_BidirectionalIter>::value_type, - typename iterator_traits<_BidirectionalIter>::value_type); - if (__first == __middle || __middle == __last) - return; - __inplace_merge_aux(__first, __middle, __last, - __VALUE_TYPE(__first), __DISTANCE_TYPE(__first), - __comp); -} - -// Set algorithms: includes, set_union, set_intersection, set_difference, -// set_symmetric_difference. All of these algorithms have the precondition -// that their input ranges are sorted and the postcondition that their output -// ranges are sorted. - -template -bool includes(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type, - _LessThanComparable); - while (__first1 != __last1 && __first2 != __last2) - if (*__first2 < *__first1) - return false; - else if(*__first1 < *__first2) - ++__first1; - else - ++__first1, ++__first2; - - return __first2 == __last2; -} - -template -bool includes(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, _Compare __comp) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - while (__first1 != __last1 && __first2 != __last2) - if (__comp(*__first2, *__first1)) - return false; - else if(__comp(*__first1, *__first2)) - ++__first1; - else - ++__first1, ++__first2; - - return __first2 == __last2; -} - -template -_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type, - _LessThanComparable); - while (__first1 != __last1 && __first2 != __last2) { - if (*__first1 < *__first2) { - *__result = *__first1; - ++__first1; - } - else if (*__first2 < *__first1) { - *__result = *__first2; - ++__first2; - } - else { - *__result = *__first1; - ++__first1; - ++__first2; - } - ++__result; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -template -_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result, _Compare __comp) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - while (__first1 != __last1 && __first2 != __last2) { - if (__comp(*__first1, *__first2)) { - *__result = *__first1; - ++__first1; - } - else if (__comp(*__first2, *__first1)) { - *__result = *__first2; - ++__first2; - } - else { - *__result = *__first1; - ++__first1; - ++__first2; - } - ++__result; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -template -_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type, - _LessThanComparable); - while (__first1 != __last1 && __first2 != __last2) - if (*__first1 < *__first2) - ++__first1; - else if (*__first2 < *__first1) - ++__first2; - else { - *__result = *__first1; - ++__first1; - ++__first2; - ++__result; - } - return __result; -} - -template -_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result, _Compare __comp) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - - while (__first1 != __last1 && __first2 != __last2) - if (__comp(*__first1, *__first2)) - ++__first1; - else if (__comp(*__first2, *__first1)) - ++__first2; - else { - *__result = *__first1; - ++__first1; - ++__first2; - ++__result; - } - return __result; -} - -template -_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type, - _LessThanComparable); - while (__first1 != __last1 && __first2 != __last2) - if (*__first1 < *__first2) { - *__result = *__first1; - ++__first1; - ++__result; - } - else if (*__first2 < *__first1) - ++__first2; - else { - ++__first1; - ++__first2; - } - return copy(__first1, __last1, __result); -} - -template -_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result, _Compare __comp) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - - while (__first1 != __last1 && __first2 != __last2) - if (__comp(*__first1, *__first2)) { - *__result = *__first1; - ++__first1; - ++__result; - } - else if (__comp(*__first2, *__first1)) - ++__first2; - else { - ++__first1; - ++__first2; - } - return copy(__first1, __last1, __result); -} - -template -_OutputIter -set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type, - _LessThanComparable); - while (__first1 != __last1 && __first2 != __last2) - if (*__first1 < *__first2) { - *__result = *__first1; - ++__first1; - ++__result; - } - else if (*__first2 < *__first1) { - *__result = *__first2; - ++__first2; - ++__result; - } - else { - ++__first1; - ++__first2; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -template -_OutputIter -set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _OutputIter __result, - _Compare __comp) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - __STL_REQUIRES_SAME_TYPE( - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_InputIter1>::value_type, - typename iterator_traits<_InputIter2>::value_type); - while (__first1 != __last1 && __first2 != __last2) - if (__comp(*__first1, *__first2)) { - *__result = *__first1; - ++__first1; - ++__result; - } - else if (__comp(*__first2, *__first1)) { - *__result = *__first2; - ++__first2; - ++__result; - } - else { - ++__first1; - ++__first2; - } - return copy(__first2, __last2, copy(__first1, __last1, __result)); -} - -// min_element and max_element, with and without an explicitly supplied -// comparison function. - -template -_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type, - _LessThanComparable); - if (__first == __last) return __first; - _ForwardIter __result = __first; - while (++__first != __last) - if (*__result < *__first) - __result = __first; - return __result; -} - -template -_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last, - _Compare __comp) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_ForwardIter>::value_type, - typename iterator_traits<_ForwardIter>::value_type); - if (__first == __last) return __first; - _ForwardIter __result = __first; - while (++__first != __last) - if (__comp(*__result, *__first)) __result = __first; - return __result; -} - -template -_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type, - _LessThanComparable); - if (__first == __last) return __first; - _ForwardIter __result = __first; - while (++__first != __last) - if (*__first < *__result) - __result = __first; - return __result; -} - -template -_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last, - _Compare __comp) { - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_ForwardIter>::value_type, - typename iterator_traits<_ForwardIter>::value_type); - if (__first == __last) return __first; - _ForwardIter __result = __first; - while (++__first != __last) - if (__comp(*__first, *__result)) - __result = __first; - return __result; -} - -// next_permutation and prev_permutation, with and without an explicitly -// supplied comparison function. - -template -bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last) { - __STL_REQUIRES(_BidirectionalIter, _BidirectionalIterator); - __STL_REQUIRES(typename iterator_traits<_BidirectionalIter>::value_type, - _LessThanComparable); - if (__first == __last) - return false; - _BidirectionalIter __i = __first; - ++__i; - if (__i == __last) - return false; - __i = __last; - --__i; - - for(;;) { - _BidirectionalIter __ii = __i; - --__i; - if (*__i < *__ii) { - _BidirectionalIter __j = __last; - while (!(*__i < *--__j)) - {} - iter_swap(__i, __j); - reverse(__ii, __last); - return true; - } - if (__i == __first) { - reverse(__first, __last); - return false; - } - } -} - -template -bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last, - _Compare __comp) { - __STL_REQUIRES(_BidirectionalIter, _BidirectionalIterator); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_BidirectionalIter>::value_type, - typename iterator_traits<_BidirectionalIter>::value_type); - if (__first == __last) - return false; - _BidirectionalIter __i = __first; - ++__i; - if (__i == __last) - return false; - __i = __last; - --__i; - - for(;;) { - _BidirectionalIter __ii = __i; - --__i; - if (__comp(*__i, *__ii)) { - _BidirectionalIter __j = __last; - while (!__comp(*__i, *--__j)) - {} - iter_swap(__i, __j); - reverse(__ii, __last); - return true; - } - if (__i == __first) { - reverse(__first, __last); - return false; - } - } -} - -template -bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last) { - __STL_REQUIRES(_BidirectionalIter, _BidirectionalIterator); - __STL_REQUIRES(typename iterator_traits<_BidirectionalIter>::value_type, - _LessThanComparable); - if (__first == __last) - return false; - _BidirectionalIter __i = __first; - ++__i; - if (__i == __last) - return false; - __i = __last; - --__i; - - for(;;) { - _BidirectionalIter __ii = __i; - --__i; - if (*__ii < *__i) { - _BidirectionalIter __j = __last; - while (!(*--__j < *__i)) - {} - iter_swap(__i, __j); - reverse(__ii, __last); - return true; - } - if (__i == __first) { - reverse(__first, __last); - return false; - } - } -} - -template -bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last, - _Compare __comp) { - __STL_REQUIRES(_BidirectionalIter, _BidirectionalIterator); - __STL_BINARY_FUNCTION_CHECK(_Compare, bool, - typename iterator_traits<_BidirectionalIter>::value_type, - typename iterator_traits<_BidirectionalIter>::value_type); - if (__first == __last) - return false; - _BidirectionalIter __i = __first; - ++__i; - if (__i == __last) - return false; - __i = __last; - --__i; - - for(;;) { - _BidirectionalIter __ii = __i; - --__i; - if (__comp(*__ii, *__i)) { - _BidirectionalIter __j = __last; - while (!__comp(*--__j, *__i)) - {} - iter_swap(__i, __j); - reverse(__ii, __last); - return true; - } - if (__i == __first) { - reverse(__first, __last); - return false; - } - } -} - -// find_first_of, with and without an explicitly supplied comparison function. - -template -_InputIter find_first_of(_InputIter __first1, _InputIter __last1, - _ForwardIter __first2, _ForwardIter __last2) -{ - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool, - typename iterator_traits<_InputIter>::value_type, - typename iterator_traits<_ForwardIter>::value_type); - - for ( ; __first1 != __last1; ++__first1) - for (_ForwardIter __iter = __first2; __iter != __last2; ++__iter) - if (*__first1 == *__iter) - return __first1; - return __last1; -} - -template -_InputIter find_first_of(_InputIter __first1, _InputIter __last1, - _ForwardIter __first2, _ForwardIter __last2, - _BinaryPredicate __comp) -{ - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool, - typename iterator_traits<_InputIter>::value_type, - typename iterator_traits<_ForwardIter>::value_type); - - for ( ; __first1 != __last1; ++__first1) - for (_ForwardIter __iter = __first2; __iter != __last2; ++__iter) - if (__comp(*__first1, *__iter)) - return __first1; - return __last1; -} - - -// find_end, with and without an explicitly supplied comparison function. -// Search [first2, last2) as a subsequence in [first1, last1), and return -// the *last* possible match. Note that find_end for bidirectional iterators -// is much faster than for forward iterators. - -// find_end for forward iterators. -template -_ForwardIter1 __find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2, - forward_iterator_tag, forward_iterator_tag) -{ - if (__first2 == __last2) - return __last1; - else { - _ForwardIter1 __result = __last1; - while (1) { - _ForwardIter1 __new_result - = search(__first1, __last1, __first2, __last2); - if (__new_result == __last1) - return __result; - else { - __result = __new_result; - __first1 = __new_result; - ++__first1; - } - } - } -} - -template -_ForwardIter1 __find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2, - forward_iterator_tag, forward_iterator_tag, - _BinaryPredicate __comp) -{ - if (__first2 == __last2) - return __last1; - else { - _ForwardIter1 __result = __last1; - while (1) { - _ForwardIter1 __new_result - = search(__first1, __last1, __first2, __last2, __comp); - if (__new_result == __last1) - return __result; - else { - __result = __new_result; - __first1 = __new_result; - ++__first1; - } - } - } -} - -// find_end for bidirectional iterators. Requires partial specialization. -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -_BidirectionalIter1 -__find_end(_BidirectionalIter1 __first1, _BidirectionalIter1 __last1, - _BidirectionalIter2 __first2, _BidirectionalIter2 __last2, - bidirectional_iterator_tag, bidirectional_iterator_tag) -{ - __STL_REQUIRES(_BidirectionalIter1, _BidirectionalIterator); - __STL_REQUIRES(_BidirectionalIter2, _BidirectionalIterator); - typedef reverse_iterator<_BidirectionalIter1> _RevIter1; - typedef reverse_iterator<_BidirectionalIter2> _RevIter2; - - _RevIter1 __rlast1(__first1); - _RevIter2 __rlast2(__first2); - _RevIter1 __rresult = search(_RevIter1(__last1), __rlast1, - _RevIter2(__last2), __rlast2); - - if (__rresult == __rlast1) - return __last1; - else { - _BidirectionalIter1 __result = __rresult.base(); - advance(__result, -distance(__first2, __last2)); - return __result; - } -} - -template -_BidirectionalIter1 -__find_end(_BidirectionalIter1 __first1, _BidirectionalIter1 __last1, - _BidirectionalIter2 __first2, _BidirectionalIter2 __last2, - bidirectional_iterator_tag, bidirectional_iterator_tag, - _BinaryPredicate __comp) -{ - __STL_REQUIRES(_BidirectionalIter1, _BidirectionalIterator); - __STL_REQUIRES(_BidirectionalIter2, _BidirectionalIterator); - typedef reverse_iterator<_BidirectionalIter1> _RevIter1; - typedef reverse_iterator<_BidirectionalIter2> _RevIter2; - - _RevIter1 __rlast1(__first1); - _RevIter2 __rlast2(__first2); - _RevIter1 __rresult = search(_RevIter1(__last1), __rlast1, - _RevIter2(__last2), __rlast2, - __comp); - - if (__rresult == __rlast1) - return __last1; - else { - _BidirectionalIter1 __result = __rresult.base(); - advance(__result, -distance(__first2, __last2)); - return __result; - } -} -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// Dispatching functions for find_end. - -template -inline _ForwardIter1 -find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2) -{ - __STL_REQUIRES(_ForwardIter1, _ForwardIterator); - __STL_REQUIRES(_ForwardIter2, _ForwardIterator); - __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool, - typename iterator_traits<_ForwardIter1>::value_type, - typename iterator_traits<_ForwardIter2>::value_type); - return __find_end(__first1, __last1, __first2, __last2, - __ITERATOR_CATEGORY(__first1), - __ITERATOR_CATEGORY(__first2)); -} - -template -inline _ForwardIter1 -find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, - _ForwardIter2 __first2, _ForwardIter2 __last2, - _BinaryPredicate __comp) -{ - __STL_REQUIRES(_ForwardIter1, _ForwardIterator); - __STL_REQUIRES(_ForwardIter2, _ForwardIterator); - __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool, - typename iterator_traits<_ForwardIter1>::value_type, - typename iterator_traits<_ForwardIter2>::value_type); - - return __find_end(__first1, __last1, __first2, __last2, - __ITERATOR_CATEGORY(__first1), - __ITERATOR_CATEGORY(__first2), - __comp); -} - -// is_heap, a predicate testing whether or not a range is -// a heap. This function is an extension, not part of the C++ -// standard. - -template -bool __is_heap(_RandomAccessIter __first, _Distance __n) -{ - _Distance __parent = 0; - for (_Distance __child = 1; __child < __n; ++__child) { - if (__first[__parent] < __first[__child]) - return false; - if ((__child & 1) == 0) - ++__parent; - } - return true; -} - -template -bool __is_heap(_RandomAccessIter __first, _StrictWeakOrdering __comp, - _Distance __n) -{ - _Distance __parent = 0; - for (_Distance __child = 1; __child < __n; ++__child) { - if (__comp(__first[__parent], __first[__child])) - return false; - if ((__child & 1) == 0) - ++__parent; - } - return true; -} - -template -inline bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last) -{ - __STL_REQUIRES(_RandomAccessIter, _RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type, - _LessThanComparable); - return __is_heap(__first, __last - __first); -} - - -template -inline bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last, - _StrictWeakOrdering __comp) -{ - __STL_REQUIRES(_RandomAccessIter, _RandomAccessIterator); - __STL_BINARY_FUNCTION_CHECK(_StrictWeakOrdering, bool, - typename iterator_traits<_RandomAccessIter>::value_type, - typename iterator_traits<_RandomAccessIter>::value_type); - return __is_heap(__first, __comp, __last - __first); -} - -// is_sorted, a predicated testing whether a range is sorted in -// nondescending order. This is an extension, not part of the C++ -// standard. - -template -bool is_sorted(_ForwardIter __first, _ForwardIter __last) -{ - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type, - _LessThanComparable); - if (__first == __last) - return true; - - _ForwardIter __next = __first; - for (++__next; __next != __last; __first = __next, ++__next) { - if (*__next < *__first) - return false; - } - - return true; -} - -template -bool is_sorted(_ForwardIter __first, _ForwardIter __last, - _StrictWeakOrdering __comp) -{ - __STL_REQUIRES(_ForwardIter, _ForwardIterator); - __STL_BINARY_FUNCTION_CHECK(_StrictWeakOrdering, bool, - typename iterator_traits<_ForwardIter>::value_type, - typename iterator_traits<_ForwardIter>::value_type); - if (__first == __last) - return true; - - _ForwardIter __next = __first; - for (++__next; __next != __last; __first = __next, ++__next) { - if (__comp(*__next, *__first)) - return false; - } - - return true; -} - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1209 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_ALGO_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_algobase.h b/DSTAT1/src/avr-stl/include/stl_algobase.h deleted file mode 100644 index a190859..0000000 --- a/DSTAT1/src/avr-stl/include/stl_algobase.h +++ /dev/null @@ -1,698 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - - -#ifndef __SGI_STL_INTERNAL_ALGOBASE_H -#define __SGI_STL_INTERNAL_ALGOBASE_H - -#ifndef __STL_CONFIG_H -#include -#endif -#ifndef __SGI_STL_INTERNAL_RELOPS -#include -#endif -#ifndef __SGI_STL_INTERNAL_PAIR_H -#include -#endif -#ifndef __TYPE_TRAITS_H -#include -#endif - -#include -#include -#include -#include -#include - -#ifndef __AVR__ -#ifdef __STL_USE_NEW_IOSTREAMS -#include -#else /* __STL_USE_NEW_IOSTREAMS */ -#include -#endif /* __STL_USE_NEW_IOSTREAMS */ -#endif - -#ifndef __SGI_STL_INTERNAL_ITERATOR_H -#include -#include -#endif - -// We pick up concept_checks.h from stl_iterator_base.h. - -__STL_BEGIN_NAMESPACE - -// swap and iter_swap - -template -inline void __iter_swap(_ForwardIter1 __a, _ForwardIter2 __b, _Tp*) { - _Tp __tmp = *__a; - *__a = *__b; - *__b = __tmp; -} - -template -inline void iter_swap(_ForwardIter1 __a, _ForwardIter2 __b) { - __STL_REQUIRES(_ForwardIter1, _Mutable_ForwardIterator); - __STL_REQUIRES(_ForwardIter2, _Mutable_ForwardIterator); - __STL_CONVERTIBLE(typename iterator_traits<_ForwardIter1>::value_type, - typename iterator_traits<_ForwardIter2>::value_type); - __STL_CONVERTIBLE(typename iterator_traits<_ForwardIter2>::value_type, - typename iterator_traits<_ForwardIter1>::value_type); - __iter_swap(__a, __b, __VALUE_TYPE(__a)); -} - -template -inline void swap(_Tp& __a, _Tp& __b) { - __STL_REQUIRES(_Tp, _Assignable); - _Tp __tmp = __a; - __a = __b; - __b = __tmp; -} - -//-------------------------------------------------- -// min and max - -#if !defined(__BORLANDC__) || __BORLANDC__ >= 0x540 /* C++ Builder 4.0 */ - -#undef min -#undef max - -template -inline const _Tp& min(const _Tp& __a, const _Tp& __b) { - __STL_REQUIRES(_Tp, _LessThanComparable); - return __b < __a ? __b : __a; -} - -template -inline const _Tp& max(const _Tp& __a, const _Tp& __b) { - __STL_REQUIRES(_Tp, _LessThanComparable); - return __a < __b ? __b : __a; -} - -#endif /* __BORLANDC__ */ - -template -inline const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) { - return __comp(__b, __a) ? __b : __a; -} - -template -inline const _Tp& max(const _Tp& __a, const _Tp& __b, _Compare __comp) { - return __comp(__a, __b) ? __b : __a; -} - -//-------------------------------------------------- -// copy - -// All of these auxiliary functions serve two purposes. (1) Replace -// calls to copy with memmove whenever possible. (Memmove, not memcpy, -// because the input and output ranges are permitted to overlap.) -// (2) If we're using random access iterators, then write the loop as -// a for loop with an explicit count. - -template -inline _OutputIter __copy(_InputIter __first, _InputIter __last, - _OutputIter __result, - input_iterator_tag, _Distance*) -{ - for ( ; __first != __last; ++__result, ++__first) - *__result = *__first; - return __result; -} - -template -inline _OutputIter -__copy(_RandomAccessIter __first, _RandomAccessIter __last, - _OutputIter __result, random_access_iterator_tag, _Distance*) -{ - for (_Distance __n = __last - __first; __n > 0; --__n) { - *__result = *__first; - ++__first; - ++__result; - } - return __result; -} - -template -inline _Tp* -__copy_trivial(const _Tp* __first, const _Tp* __last, _Tp* __result) { - memmove(__result, __first, sizeof(_Tp) * (__last - __first)); - return __result + (__last - __first); -} - -#if defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER) - -template -inline _OutputIter __copy_aux2(_InputIter __first, _InputIter __last, - _OutputIter __result, __false_type) { - return __copy(__first, __last, __result, - __ITERATOR_CATEGORY(__first), - __DISTANCE_TYPE(__first)); -} - -template -inline _OutputIter __copy_aux2(_InputIter __first, _InputIter __last, - _OutputIter __result, __true_type) { - return __copy(__first, __last, __result, - __ITERATOR_CATEGORY(__first), - __DISTANCE_TYPE(__first)); -} - -#ifndef __USLC__ - -template -inline _Tp* __copy_aux2(_Tp* __first, _Tp* __last, _Tp* __result, - __true_type) { - return __copy_trivial(__first, __last, __result); -} - -#endif /* __USLC__ */ - -template -inline _Tp* __copy_aux2(const _Tp* __first, const _Tp* __last, _Tp* __result, - __true_type) { - return __copy_trivial(__first, __last, __result); -} - - -template -inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, - _OutputIter __result, _Tp*) { - typedef typename __type_traits<_Tp>::has_trivial_assignment_operator - _Trivial; - return __copy_aux2(__first, __last, __result, _Trivial()); -} - -template -inline _OutputIter copy(_InputIter __first, _InputIter __last, - _OutputIter __result) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - return __copy_aux(__first, __last, __result, __VALUE_TYPE(__first)); -} - -// Hack for compilers that don't have partial ordering of function templates -// but do have partial specialization of class templates. -#elif defined(__STL_CLASS_PARTIAL_SPECIALIZATION) - -template -struct __copy_dispatch { - static _OutputIter copy(_InputIter __first, _InputIter __last, - _OutputIter __result) { - typedef typename iterator_traits<_InputIter>::iterator_category _Category; - typedef typename iterator_traits<_InputIter>::difference_type _Distance; - return __copy(__first, __last, __result, _Category(), (_Distance*) 0); - } -}; - -template -struct __copy_dispatch<_Tp*, _Tp*, __true_type> -{ - static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) { - return __copy_trivial(__first, __last, __result); - } -}; - -template -struct __copy_dispatch -{ - static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) { - return __copy_trivial(__first, __last, __result); - } -}; - -template -inline _OutputIter copy(_InputIter __first, _InputIter __last, - _OutputIter __result) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - typedef typename iterator_traits<_InputIter>::value_type _Tp; - typedef typename __type_traits<_Tp>::has_trivial_assignment_operator - _Trivial; - return __copy_dispatch<_InputIter, _OutputIter, _Trivial> - ::copy(__first, __last, __result); -} - -// Fallback for compilers with neither partial ordering nor partial -// specialization. Define the faster version for the basic builtin -// types. -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline _OutputIter copy(_InputIter __first, _InputIter __last, - _OutputIter __result) -{ - return __copy(__first, __last, __result, - __ITERATOR_CATEGORY(__first), - __DISTANCE_TYPE(__first)); -} - -#define __SGI_STL_DECLARE_COPY_TRIVIAL(_Tp) \ - inline _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) { \ - memmove(__result, __first, sizeof(_Tp) * (__last - __first)); \ - return __result + (__last - __first); \ - } - -__SGI_STL_DECLARE_COPY_TRIVIAL(char) -__SGI_STL_DECLARE_COPY_TRIVIAL(signed char) -__SGI_STL_DECLARE_COPY_TRIVIAL(unsigned char) -__SGI_STL_DECLARE_COPY_TRIVIAL(short) -__SGI_STL_DECLARE_COPY_TRIVIAL(unsigned short) -__SGI_STL_DECLARE_COPY_TRIVIAL(int) -__SGI_STL_DECLARE_COPY_TRIVIAL(unsigned int) -__SGI_STL_DECLARE_COPY_TRIVIAL(long) -__SGI_STL_DECLARE_COPY_TRIVIAL(unsigned long) -#ifdef __STL_HAS_WCHAR_T -__SGI_STL_DECLARE_COPY_TRIVIAL(wchar_t) -#endif -#ifdef _STL_LONG_LONG -__SGI_STL_DECLARE_COPY_TRIVIAL(long long) -__SGI_STL_DECLARE_COPY_TRIVIAL(unsigned long long) -#endif -__SGI_STL_DECLARE_COPY_TRIVIAL(float) -__SGI_STL_DECLARE_COPY_TRIVIAL(double) -__SGI_STL_DECLARE_COPY_TRIVIAL(long double) - -#undef __SGI_STL_DECLARE_COPY_TRIVIAL -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -//-------------------------------------------------- -// copy_backward - -template -inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first, - _BidirectionalIter1 __last, - _BidirectionalIter2 __result, - bidirectional_iterator_tag, - _Distance*) -{ - while (__first != __last) - *--__result = *--__last; - return __result; -} - -template -inline _BidirectionalIter __copy_backward(_RandomAccessIter __first, - _RandomAccessIter __last, - _BidirectionalIter __result, - random_access_iterator_tag, - _Distance*) -{ - for (_Distance __n = __last - __first; __n > 0; --__n) - *--__result = *--__last; - return __result; -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -// This dispatch class is a workaround for compilers that do not -// have partial ordering of function templates. All we're doing is -// creating a specialization so that we can turn a call to copy_backward -// into a memmove whenever possible. - -template -struct __copy_backward_dispatch -{ - typedef typename iterator_traits<_BidirectionalIter1>::iterator_category - _Cat; - typedef typename iterator_traits<_BidirectionalIter1>::difference_type - _Distance; - - static _BidirectionalIter2 copy(_BidirectionalIter1 __first, - _BidirectionalIter1 __last, - _BidirectionalIter2 __result) { - return __copy_backward(__first, __last, __result, _Cat(), (_Distance*) 0); - } -}; - -template -struct __copy_backward_dispatch<_Tp*, _Tp*, __true_type> -{ - static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) { - const ptrdiff_t _Num = __last - __first; - memmove(__result - _Num, __first, sizeof(_Tp) * _Num); - return __result - _Num; - } -}; - -template -struct __copy_backward_dispatch -{ - static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) { - return __copy_backward_dispatch<_Tp*, _Tp*, __true_type> - ::copy(__first, __last, __result); - } -}; - -template -inline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) { - __STL_REQUIRES(_BI1, _BidirectionalIterator); - __STL_REQUIRES(_BI2, _Mutable_BidirectionalIterator); - __STL_CONVERTIBLE(typename iterator_traits<_BI1>::value_type, - typename iterator_traits<_BI2>::value_type); - typedef typename __type_traits::value_type> - ::has_trivial_assignment_operator - _Trivial; - return __copy_backward_dispatch<_BI1, _BI2, _Trivial> - ::copy(__first, __last, __result); -} - -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) { - return __copy_backward(__first, __last, __result, - __ITERATOR_CATEGORY(__first), - __DISTANCE_TYPE(__first)); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -//-------------------------------------------------- -// copy_n (not part of the C++ standard) - -template -pair<_InputIter, _OutputIter> __copy_n(_InputIter __first, _Size __count, - _OutputIter __result, - input_iterator_tag) { - for ( ; __count > 0; --__count) { - *__result = *__first; - ++__first; - ++__result; - } - return pair<_InputIter, _OutputIter>(__first, __result); -} - -template -inline pair<_RAIter, _OutputIter> -__copy_n(_RAIter __first, _Size __count, - _OutputIter __result, - random_access_iterator_tag) { - _RAIter __last = __first + __count; - return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result)); -} - -template -inline pair<_InputIter, _OutputIter> -__copy_n(_InputIter __first, _Size __count, _OutputIter __result) { - return __copy_n(__first, __count, __result, - __ITERATOR_CATEGORY(__first)); -} - -template -inline pair<_InputIter, _OutputIter> -copy_n(_InputIter __first, _Size __count, _OutputIter __result) { - __STL_REQUIRES(_InputIter, _InputIterator); - __STL_REQUIRES(_OutputIter, _OutputIterator); - return __copy_n(__first, __count, __result); -} - -//-------------------------------------------------- -// fill and fill_n - - -template -void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __value) { - __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); - for ( ; __first != __last; ++__first) - *__first = __value; -} - -template -_OutputIter fill_n(_OutputIter __first, _Size __n, const _Tp& __value) { - __STL_REQUIRES(_OutputIter, _OutputIterator); - for ( ; __n > 0; --__n, ++__first) - *__first = __value; - return __first; -} - -// Specialization: for one-byte types we can use memset. - -inline void fill(unsigned char* __first, unsigned char* __last, - const unsigned char& __c) { - unsigned char __tmp = __c; - memset(__first, __tmp, __last - __first); -} - -inline void fill(signed char* __first, signed char* __last, - const signed char& __c) { - signed char __tmp = __c; - memset(__first, static_cast(__tmp), __last - __first); -} - -inline void fill(char* __first, char* __last, const char& __c) { - char __tmp = __c; - memset(__first, static_cast(__tmp), __last - __first); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline unsigned char* fill_n(unsigned char* __first, _Size __n, - const unsigned char& __c) { - fill(__first, __first + __n, __c); - return __first + __n; -} - -template -inline signed char* fill_n(char* __first, _Size __n, - const signed char& __c) { - fill(__first, __first + __n, __c); - return __first + __n; -} - -template -inline char* fill_n(char* __first, _Size __n, const char& __c) { - fill(__first, __first + __n, __c); - return __first + __n; -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -//-------------------------------------------------- -// equal and mismatch - -template -pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1, - _InputIter1 __last1, - _InputIter2 __first2) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type, - _EqualityComparable); - __STL_REQUIRES(typename iterator_traits<_InputIter2>::value_type, - _EqualityComparable); - while (__first1 != __last1 && *__first1 == *__first2) { - ++__first1; - ++__first2; - } - return pair<_InputIter1, _InputIter2>(__first1, __first2); -} - -template -pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1, - _InputIter1 __last1, - _InputIter2 __first2, - _BinaryPredicate __binary_pred) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) { - ++__first1; - ++__first2; - } - return pair<_InputIter1, _InputIter2>(__first1, __first2); -} - -template -inline bool equal(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type, - _EqualityComparable); - __STL_REQUIRES(typename iterator_traits<_InputIter2>::value_type, - _EqualityComparable); - for ( ; __first1 != __last1; ++__first1, ++__first2) - if (*__first1 != *__first2) - return false; - return true; -} - -template -inline bool equal(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _BinaryPredicate __binary_pred) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - for ( ; __first1 != __last1; ++__first1, ++__first2) - if (!__binary_pred(*__first1, *__first2)) - return false; - return true; -} - -//-------------------------------------------------- -// lexicographical_compare and lexicographical_compare_3way. -// (the latter is not part of the C++ standard.) - -template -bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type, - _LessThanComparable); - __STL_REQUIRES(typename iterator_traits<_InputIter2>::value_type, - _LessThanComparable); - for ( ; __first1 != __last1 && __first2 != __last2 - ; ++__first1, ++__first2) { - if (*__first1 < *__first2) - return true; - if (*__first2 < *__first1) - return false; - } - return __first1 == __last1 && __first2 != __last2; -} - -template -bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _Compare __comp) { - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - for ( ; __first1 != __last1 && __first2 != __last2 - ; ++__first1, ++__first2) { - if (__comp(*__first1, *__first2)) - return true; - if (__comp(*__first2, *__first1)) - return false; - } - return __first1 == __last1 && __first2 != __last2; -} - -inline bool -lexicographical_compare(const unsigned char* __first1, - const unsigned char* __last1, - const unsigned char* __first2, - const unsigned char* __last2) -{ - const size_t __len1 = __last1 - __first1; - const size_t __len2 = __last2 - __first2; - const int __result = memcmp(__first1, __first2, min(__len1, __len2)); - return __result != 0 ? __result < 0 : __len1 < __len2; -} - -inline bool lexicographical_compare(const char* __first1, const char* __last1, - const char* __first2, const char* __last2) -{ -#if CHAR_MAX == SCHAR_MAX - return lexicographical_compare((const signed char*) __first1, - (const signed char*) __last1, - (const signed char*) __first2, - (const signed char*) __last2); -#else /* CHAR_MAX == SCHAR_MAX */ - return lexicographical_compare((const unsigned char*) __first1, - (const unsigned char*) __last1, - (const unsigned char*) __first2, - (const unsigned char*) __last2); -#endif /* CHAR_MAX == SCHAR_MAX */ -} - -template -int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2) -{ - while (__first1 != __last1 && __first2 != __last2) { - if (*__first1 < *__first2) - return -1; - if (*__first2 < *__first1) - return 1; - ++__first1; - ++__first2; - } - if (__first2 == __last2) { - return !(__first1 == __last1); - } - else { - return -1; - } -} - -inline int -__lexicographical_compare_3way(const unsigned char* __first1, - const unsigned char* __last1, - const unsigned char* __first2, - const unsigned char* __last2) -{ - const ptrdiff_t __len1 = __last1 - __first1; - const ptrdiff_t __len2 = __last2 - __first2; - const int __result = memcmp(__first1, __first2, min(__len1, __len2)); - return __result != 0 ? __result - : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1)); -} - -inline int -__lexicographical_compare_3way(const char* __first1, const char* __last1, - const char* __first2, const char* __last2) -{ -#if CHAR_MAX == SCHAR_MAX - return __lexicographical_compare_3way( - (const signed char*) __first1, - (const signed char*) __last1, - (const signed char*) __first2, - (const signed char*) __last2); -#else - return __lexicographical_compare_3way((const unsigned char*) __first1, - (const unsigned char*) __last1, - (const unsigned char*) __first2, - (const unsigned char*) __last2); -#endif -} - -template -int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2) -{ - __STL_REQUIRES(_InputIter1, _InputIterator); - __STL_REQUIRES(_InputIter2, _InputIterator); - __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type, - _LessThanComparable); - __STL_REQUIRES(typename iterator_traits<_InputIter2>::value_type, - _LessThanComparable); - return __lexicographical_compare_3way(__first1, __last1, __first2, __last2); -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_ALGOBASE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_alloc.h b/DSTAT1/src/avr-stl/include/stl_alloc.h deleted file mode 100644 index 98277eb..0000000 --- a/DSTAT1/src/avr-stl/include/stl_alloc.h +++ /dev/null @@ -1,945 +0,0 @@ -/* - * Copyright (c) 1996-1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_ALLOC_H -#define __SGI_STL_INTERNAL_ALLOC_H - -#ifdef __SUNPRO_CC -# define __PRIVATE public - // Extra access restrictions prevent us from really making some things - // private. -#else -# define __PRIVATE private -#endif - -#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG -# define __USE_MALLOC -#endif - - -// This implements some standard node allocators. These are -// NOT the same as the allocators in the C++ draft standard or in -// in the original STL. They do not encapsulate different pointer -// types; indeed we assume that there is only one pointer type. -// The allocation primitives are intended to allocate individual objects, -// not larger arenas as with the original STL allocators. - -#ifdef __AVR__ -#define __THROW_BAD_ALLOC { exit(0); } // this will intentionally hang the MCU -#else -#ifndef __THROW_BAD_ALLOC -# if defined(__STL_NO_BAD_ALLOC) || !defined(__STL_USE_EXCEPTIONS) -# include -# include -# define __THROW_BAD_ALLOC fprintf(stderr, "out of memory\n"); exit(1) -# else /* Standard conforming out-of-memory handling */ -# include -# define __THROW_BAD_ALLOC throw std::bad_alloc() -# endif -#endif -#endif - -#include -#include -#include -#include -#ifndef __RESTRICT -# define __RESTRICT -#endif - -#ifdef __STL_THREADS -# include -# define __NODE_ALLOCATOR_THREADS true -# ifdef __STL_SGI_THREADS - // We test whether threads are in use before locking. - // Perhaps this should be moved into stl_threads.h, but that - // probably makes it harder to avoid the procedure call when - // it isn't needed. - extern "C" { - extern int __us_rsthread_malloc; - } - // The above is copied from malloc.h. Including - // would be cleaner but fails with certain levels of standard - // conformance. -# define __NODE_ALLOCATOR_LOCK if (threads && __us_rsthread_malloc) \ - { _S_node_allocator_lock._M_acquire_lock(); } -# define __NODE_ALLOCATOR_UNLOCK if (threads && __us_rsthread_malloc) \ - { _S_node_allocator_lock._M_release_lock(); } -# else /* !__STL_SGI_THREADS */ -# define __NODE_ALLOCATOR_LOCK \ - { if (threads) _S_node_allocator_lock._M_acquire_lock(); } -# define __NODE_ALLOCATOR_UNLOCK \ - { if (threads) _S_node_allocator_lock._M_release_lock(); } -# endif -#else -// Thread-unsafe -# define __NODE_ALLOCATOR_LOCK -# define __NODE_ALLOCATOR_UNLOCK -# define __NODE_ALLOCATOR_THREADS false -#endif - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#endif - - -#ifdef __AVR__ -#define avr_malloc malloc -#define avr_free free -#define avr_realloc realloc -#endif - -#if 0 -static void *avr_malloc(size_t size_) -{ - void *ptr; - Serial.print("malloc for "); - Serial.print(size_); - Serial.print(" ptr "); - ptr=malloc(size_); - Serial.println((long)ptr); - return ptr; -} -static void *avr_realloc(void *ptr_,size_t size_) -{ - void *newptr; - Serial.print("realloc for "); - Serial.print(size_); - Serial.print(" old ptr "); - Serial.print((long)ptr_); - Serial.print(" newptr "); - newptr=malloc(size_); - Serial.println((long)newptr); - return newptr; -} -static void avr_free(void *ptr) -{ - Serial.print("free for "); - Serial.println((long)ptr); - free(ptr); -} -#endif - - -// Malloc-based allocator. Typically slower than default below. -// Typically thread-safe and more storage efficient. -#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG -# ifdef __DECLARE_GLOBALS_HERE - void (* __malloc_alloc_oom_handler)() = 0; - // g++ 2.7.2 does not handle static template data members. -# else - extern void (* __malloc_alloc_oom_handler)(); -# endif -#endif - -template -class __malloc_alloc_template { - -private: - - static void* _S_oom_malloc(size_t); - static void* _S_oom_realloc(void*, size_t); - -#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG - static void (* __malloc_alloc_oom_handler)(); -#endif - -public: - - static void* allocate(size_t __n) - { - void* __result = avr_malloc(__n); - if (0 == __result) __result = _S_oom_malloc(__n); - return __result; - } - - static void deallocate(void* __p, size_t /* __n */) - { - avr_free(__p); - } - - static void* reallocate(void* __p, size_t /* old_sz */, size_t __new_sz) - { - void* __result = avr_realloc(__p, __new_sz); - if (0 == __result) __result = _S_oom_realloc(__p, __new_sz); - return __result; - } - - static void (* __set_malloc_handler(void (*__f)()))() - { - void (* __old)() = __malloc_alloc_oom_handler; - __malloc_alloc_oom_handler = __f; - return(__old); - } - -}; - - -// malloc_alloc out-of-memory handling - -#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG -template -void (* __malloc_alloc_template<__inst>::__malloc_alloc_oom_handler)() = 0; -#endif - -template -void* -__malloc_alloc_template<__inst>::_S_oom_malloc(size_t __n) -{ - void (* __my_malloc_handler)(); - void* __result; - - for (;;) { - __my_malloc_handler = __malloc_alloc_oom_handler; - if (0 == __my_malloc_handler) { __THROW_BAD_ALLOC; } - (*__my_malloc_handler)(); - __result = malloc(__n); - if (__result) return(__result); - } -} - -template -void* __malloc_alloc_template<__inst>::_S_oom_realloc(void* __p, size_t __n) -{ - void (* __my_malloc_handler)(); - void* __result; - - for (;;) { - __my_malloc_handler = __malloc_alloc_oom_handler; - if (0 == __my_malloc_handler) { __THROW_BAD_ALLOC; } - (*__my_malloc_handler)(); - __result = realloc(__p, __n); - if (__result) return(__result); - } -} - -typedef __malloc_alloc_template<0> malloc_alloc; - -template -class simple_alloc { - -public: - static _Tp* allocate(size_t __n) - { return 0 == __n ? 0 : (_Tp*) _Alloc::allocate(__n * sizeof (_Tp)); } - static _Tp* allocate(void) - { return (_Tp*) _Alloc::allocate(sizeof (_Tp)); } - static void deallocate(_Tp* __p, size_t __n) - { if (0 != __n) _Alloc::deallocate(__p, __n * sizeof (_Tp)); } - static void deallocate(_Tp* __p) - { _Alloc::deallocate(__p, sizeof (_Tp)); } -}; - -// Allocator adaptor to check size arguments for debugging. -// Reports errors using assert. Checking can be disabled with -// NDEBUG, but it's far better to just use the underlying allocator -// instead when no checking is desired. -// There is some evidence that this can confuse Purify. -template -class debug_alloc { - -private: - - enum {_S_extra = 8}; // Size of space used to store size. Note - // that this must be large enough to preserve - // alignment. - -public: - - static void* allocate(size_t __n) - { - char* __result = (char*)_Alloc::allocate(__n + (int) _S_extra); - *(size_t*)__result = __n; - return __result + (int) _S_extra; - } - - static void deallocate(void* __p, size_t __n) - { - char* __real_p = (char*)__p - (int) _S_extra; - assert(*(size_t*)__real_p == __n); - _Alloc::deallocate(__real_p, __n + (int) _S_extra); - } - - static void* reallocate(void* __p, size_t __old_sz, size_t __new_sz) - { - char* __real_p = (char*)__p - (int) _S_extra; - assert(*(size_t*)__real_p == __old_sz); - char* __result = (char*) - _Alloc::reallocate(__real_p, __old_sz + (int) _S_extra, - __new_sz + (int) _S_extra); - *(size_t*)__result = __new_sz; - return __result + (int) _S_extra; - } - -}; - - -# ifdef __USE_MALLOC - -typedef malloc_alloc alloc; -typedef malloc_alloc single_client_alloc; - -# else - - -// Default node allocator. -// With a reasonable compiler, this should be roughly as fast as the -// original STL class-specific allocators, but with less fragmentation. -// Default_alloc_template parameters are experimental and MAY -// DISAPPEAR in the future. Clients should just use alloc for now. -// -// Important implementation properties: -// 1. If the client request an object of size > _MAX_BYTES, the resulting -// object will be obtained directly from malloc. -// 2. In all other cases, we allocate an object of size exactly -// _S_round_up(requested_size). Thus the client has enough size -// information that we can return the object to the proper free list -// without permanently losing part of the object. -// - -// The first template parameter specifies whether more than one thread -// may use this allocator. It is safe to allocate an object from -// one instance of a default_alloc and deallocate it with another -// one. This effectively transfers its ownership to the second one. -// This may have undesirable effects on reference locality. -// The second parameter is unreferenced and serves only to allow the -// creation of multiple default_alloc instances. -// Node that containers built on different allocator instances have -// different types, limiting the utility of this approach. - -#if defined(__SUNPRO_CC) || defined(__GNUC__) -// breaks if we make these template class members: - enum {_ALIGN = 8}; - enum {_MAX_BYTES = 128}; - enum {_NFREELISTS = 16}; // _MAX_BYTES/_ALIGN -#endif - -template -class __default_alloc_template { - -private: - // Really we should use static const int x = N - // instead of enum { x = N }, but few compilers accept the former. -#if ! (defined(__SUNPRO_CC) || defined(__GNUC__)) - enum {_ALIGN = 8}; - enum {_MAX_BYTES = 128}; - enum {_NFREELISTS = 16}; // _MAX_BYTES/_ALIGN -# endif - static size_t - _S_round_up(size_t __bytes) - { return (((__bytes) + (size_t) _ALIGN-1) & ~((size_t) _ALIGN - 1)); } - -__PRIVATE: - union _Obj { - union _Obj* _M_free_list_link; - char _M_client_data[1]; /* The client sees this. */ - }; -private: -# if defined(__SUNPRO_CC) || defined(__GNUC__) || defined(__HP_aCC) - static _Obj* __STL_VOLATILE _S_free_list[]; - // Specifying a size results in duplicate def for 4.1 -# else - static _Obj* __STL_VOLATILE _S_free_list[_NFREELISTS]; -# endif - static size_t _S_freelist_index(size_t __bytes) { - return (((__bytes) + (size_t)_ALIGN-1)/(size_t)_ALIGN - 1); - } - - // Returns an object of size __n, and optionally adds to size __n free list. - static void* _S_refill(size_t __n); - // Allocates a chunk for nobjs of size size. nobjs may be reduced - // if it is inconvenient to allocate the requested number. - static char* _S_chunk_alloc(size_t __size, int& __nobjs); - - // Chunk allocation state. - static char* _S_start_free; - static char* _S_end_free; - static size_t _S_heap_size; - -# ifdef __STL_THREADS - static _STL_mutex_lock _S_node_allocator_lock; -# endif - - // It would be nice to use _STL_auto_lock here. But we - // don't need the NULL check. And we do need a test whether - // threads have actually been started. - class _Lock; - friend class _Lock; - class _Lock { - public: - _Lock() { __NODE_ALLOCATOR_LOCK; } - ~_Lock() { __NODE_ALLOCATOR_UNLOCK; } - }; - -public: - - /* __n must be > 0 */ - static void* allocate(size_t __n) - { - void* __ret = 0; - - if (__n > (size_t) _MAX_BYTES) { - __ret = malloc_alloc::allocate(__n); - } - else { - _Obj* __STL_VOLATILE* __my_free_list - = _S_free_list + _S_freelist_index(__n); - // Acquire the lock here with a constructor call. - // This ensures that it is released in exit or during stack - // unwinding. -# ifndef _NOTHREADS - /*REFERENCED*/ - _Lock __lock_instance; -# endif - _Obj* __RESTRICT __result = *__my_free_list; - if (__result == 0) - __ret = _S_refill(_S_round_up(__n)); - else { - *__my_free_list = __result -> _M_free_list_link; - __ret = __result; - } - } - - return __ret; - }; - - /* __p may not be 0 */ - static void deallocate(void* __p, size_t __n) - { - if (__n > (size_t) _MAX_BYTES) - malloc_alloc::deallocate(__p, __n); - else { - _Obj* __STL_VOLATILE* __my_free_list - = _S_free_list + _S_freelist_index(__n); - _Obj* __q = (_Obj*)__p; - - // acquire lock -# ifndef _NOTHREADS - /*REFERENCED*/ - _Lock __lock_instance; -# endif /* _NOTHREADS */ - __q -> _M_free_list_link = *__my_free_list; - *__my_free_list = __q; - // lock is released here - } - } - - static void* reallocate(void* __p, size_t __old_sz, size_t __new_sz); - -} ; - -typedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc; -typedef __default_alloc_template single_client_alloc; - -template -inline bool operator==(const __default_alloc_template<__threads, __inst>&, - const __default_alloc_template<__threads, __inst>&) -{ - return true; -} - -# ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER -template -inline bool operator!=(const __default_alloc_template<__threads, __inst>&, - const __default_alloc_template<__threads, __inst>&) -{ - return false; -} -# endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - - -/* We allocate memory in large chunks in order to avoid fragmenting */ -/* the malloc heap too much. */ -/* We assume that size is properly aligned. */ -/* We hold the allocation lock. */ -template -char* -__default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size, - int& __nobjs) -{ - char* __result; - size_t __total_bytes = __size * __nobjs; - size_t __bytes_left = _S_end_free - _S_start_free; - - if (__bytes_left >= __total_bytes) { - __result = _S_start_free; - _S_start_free += __total_bytes; - return(__result); - } else if (__bytes_left >= __size) { - __nobjs = (int)(__bytes_left/__size); - __total_bytes = __size * __nobjs; - __result = _S_start_free; - _S_start_free += __total_bytes; - return(__result); - } else { - size_t __bytes_to_get = - 2 * __total_bytes + _S_round_up(_S_heap_size >> 4); - // Try to make use of the left-over piece. - if (__bytes_left > 0) { - _Obj* __STL_VOLATILE* __my_free_list = - _S_free_list + _S_freelist_index(__bytes_left); - - ((_Obj*)_S_start_free) -> _M_free_list_link = *__my_free_list; - *__my_free_list = (_Obj*)_S_start_free; - } - _S_start_free = (char*)malloc(__bytes_to_get); - if (0 == _S_start_free) { - size_t __i; - _Obj* __STL_VOLATILE* __my_free_list; - _Obj* __p; - // Try to make do with what we have. That can't - // hurt. We do not try smaller requests, since that tends - // to result in disaster on multi-process machines. - for (__i = __size; - __i <= (size_t) _MAX_BYTES; - __i += (size_t) _ALIGN) { - __my_free_list = _S_free_list + _S_freelist_index(__i); - __p = *__my_free_list; - if (0 != __p) { - *__my_free_list = __p -> _M_free_list_link; - _S_start_free = (char*)__p; - _S_end_free = _S_start_free + __i; - return(_S_chunk_alloc(__size, __nobjs)); - // Any leftover piece will eventually make it to the - // right free list. - } - } - _S_end_free = 0; // In case of exception. - _S_start_free = (char*)malloc_alloc::allocate(__bytes_to_get); - // This should either throw an - // exception or remedy the situation. Thus we assume it - // succeeded. - } - _S_heap_size += __bytes_to_get; - _S_end_free = _S_start_free + __bytes_to_get; - return(_S_chunk_alloc(__size, __nobjs)); - } -} - - -/* Returns an object of size __n, and optionally adds to size __n free list.*/ -/* We assume that __n is properly aligned. */ -/* We hold the allocation lock. */ -template -void* -__default_alloc_template<__threads, __inst>::_S_refill(size_t __n) -{ - int __nobjs = 20; - char* __chunk = _S_chunk_alloc(__n, __nobjs); - _Obj* __STL_VOLATILE* __my_free_list; - _Obj* __result; - _Obj* __current_obj; - _Obj* __next_obj; - int __i; - - if (1 == __nobjs) return(__chunk); - __my_free_list = _S_free_list + _S_freelist_index(__n); - - /* Build free list in chunk */ - __result = (_Obj*)__chunk; - *__my_free_list = __next_obj = (_Obj*)(__chunk + __n); - for (__i = 1; ; __i++) { - __current_obj = __next_obj; - __next_obj = (_Obj*)((char*)__next_obj + __n); - if (__nobjs - 1 == __i) { - __current_obj -> _M_free_list_link = 0; - break; - } else { - __current_obj -> _M_free_list_link = __next_obj; - } - } - return(__result); -} - -template -void* -__default_alloc_template::reallocate(void* __p, - size_t __old_sz, - size_t __new_sz) -{ - void* __result; - size_t __copy_sz; - - if (__old_sz > (size_t) _MAX_BYTES && __new_sz > (size_t) _MAX_BYTES) { - return(realloc(__p, __new_sz)); - } - if (_S_round_up(__old_sz) == _S_round_up(__new_sz)) return(__p); - __result = allocate(__new_sz); - __copy_sz = __new_sz > __old_sz? __old_sz : __new_sz; - memcpy(__result, __p, __copy_sz); - deallocate(__p, __old_sz); - return(__result); -} - -#ifdef __STL_THREADS - template - _STL_mutex_lock - __default_alloc_template<__threads, __inst>::_S_node_allocator_lock - __STL_MUTEX_INITIALIZER; -#endif - - -template -char* __default_alloc_template<__threads, __inst>::_S_start_free = 0; - -template -char* __default_alloc_template<__threads, __inst>::_S_end_free = 0; - -template -size_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0; - -template -typename __default_alloc_template<__threads, __inst>::_Obj* __STL_VOLATILE -__default_alloc_template<__threads, __inst> ::_S_free_list[ -# if defined(__SUNPRO_CC) || defined(__GNUC__) || defined(__HP_aCC) - _NFREELISTS -# else - __default_alloc_template<__threads, __inst>::_NFREELISTS -# endif -] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -// The 16 zeros are necessary to make version 4.1 of the SunPro -// compiler happy. Otherwise it appears to allocate too little -// space for the array. - -#endif /* ! __USE_MALLOC */ - -// This implements allocators as specified in the C++ standard. -// -// Note that standard-conforming allocators use many language features -// that are not yet widely implemented. In particular, they rely on -// member templates, partial specialization, partial ordering of function -// templates, the typename keyword, and the use of the template keyword -// to refer to a template member of a dependent type. - -#ifdef __STL_USE_STD_ALLOCATORS - -template -class allocator { - typedef alloc _Alloc; // The underlying allocator. -public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Tp* pointer; - typedef const _Tp* const_pointer; - typedef _Tp& reference; - typedef const _Tp& const_reference; - typedef _Tp value_type; - - template struct rebind { - typedef allocator<_Tp1> other; - }; - - allocator() __STL_NOTHROW {} - allocator(const allocator&) __STL_NOTHROW {} - template allocator(const allocator<_Tp1>&) __STL_NOTHROW {} - ~allocator() __STL_NOTHROW {} - - pointer address(reference __x) const { return &__x; } - const_pointer address(const_reference __x) const { return &__x; } - - // __n is permitted to be 0. The C++ standard says nothing about what - // the return value is when __n == 0. - _Tp* allocate(size_type __n, const void* = 0) { - return __n != 0 ? static_cast<_Tp*>(_Alloc::allocate(__n * sizeof(_Tp))) - : 0; - } - - // __p is not permitted to be a null pointer. - void deallocate(pointer __p, size_type __n) - { _Alloc::deallocate(__p, __n * sizeof(_Tp)); } - - size_type max_size() const __STL_NOTHROW - { return size_t(-1) / sizeof(_Tp); } - - void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); } - void destroy(pointer __p) { __p->~_Tp(); } -}; - -template<> -class allocator { -public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef void* pointer; - typedef const void* const_pointer; - typedef void value_type; - - template struct rebind { - typedef allocator<_Tp1> other; - }; -}; - - -template -inline bool operator==(const allocator<_T1>&, const allocator<_T2>&) -{ - return true; -} - -template -inline bool operator!=(const allocator<_T1>&, const allocator<_T2>&) -{ - return false; -} - -// Allocator adaptor to turn an SGI-style allocator (e.g. alloc, malloc_alloc) -// into a standard-conforming allocator. Note that this adaptor does -// *not* assume that all objects of the underlying alloc class are -// identical, nor does it assume that all of the underlying alloc's -// member functions are static member functions. Note, also, that -// __allocator<_Tp, alloc> is essentially the same thing as allocator<_Tp>. - -template -struct __allocator { - _Alloc __underlying_alloc; - - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Tp* pointer; - typedef const _Tp* const_pointer; - typedef _Tp& reference; - typedef const _Tp& const_reference; - typedef _Tp value_type; - - template struct rebind { - typedef __allocator<_Tp1, _Alloc> other; - }; - - __allocator() __STL_NOTHROW {} - __allocator(const __allocator& __a) __STL_NOTHROW - : __underlying_alloc(__a.__underlying_alloc) {} - template - __allocator(const __allocator<_Tp1, _Alloc>& __a) __STL_NOTHROW - : __underlying_alloc(__a.__underlying_alloc) {} - ~__allocator() __STL_NOTHROW {} - - pointer address(reference __x) const { return &__x; } - const_pointer address(const_reference __x) const { return &__x; } - - // __n is permitted to be 0. - _Tp* allocate(size_type __n, const void* = 0) { - return __n != 0 - ? static_cast<_Tp*>(__underlying_alloc.allocate(__n * sizeof(_Tp))) - : 0; - } - - // __p is not permitted to be a null pointer. - void deallocate(pointer __p, size_type __n) - { __underlying_alloc.deallocate(__p, __n * sizeof(_Tp)); } - - size_type max_size() const __STL_NOTHROW - { return size_t(-1) / sizeof(_Tp); } - - void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); } - void destroy(pointer __p) { __p->~_Tp(); } -}; - -template -class __allocator { - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef void* pointer; - typedef const void* const_pointer; - typedef void value_type; - - template struct rebind { - typedef __allocator<_Tp1, _Alloc> other; - }; -}; - -template -inline bool operator==(const __allocator<_Tp, _Alloc>& __a1, - const __allocator<_Tp, _Alloc>& __a2) -{ - return __a1.__underlying_alloc == __a2.__underlying_alloc; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER -template -inline bool operator!=(const __allocator<_Tp, _Alloc>& __a1, - const __allocator<_Tp, _Alloc>& __a2) -{ - return __a1.__underlying_alloc != __a2.__underlying_alloc; -} -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -// Comparison operators for all of the predifined SGI-style allocators. -// This ensures that __allocator (for example) will -// work correctly. - -template -inline bool operator==(const __malloc_alloc_template&, - const __malloc_alloc_template&) -{ - return true; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER -template -inline bool operator!=(const __malloc_alloc_template<__inst>&, - const __malloc_alloc_template<__inst>&) -{ - return false; -} -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - -template -inline bool operator==(const debug_alloc<_Alloc>&, - const debug_alloc<_Alloc>&) { - return true; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER -template -inline bool operator!=(const debug_alloc<_Alloc>&, - const debug_alloc<_Alloc>&) { - return false; -} -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -// Another allocator adaptor: _Alloc_traits. This serves two -// purposes. First, make it possible to write containers that can use -// either SGI-style allocators or standard-conforming allocator. -// Second, provide a mechanism so that containers can query whether or -// not the allocator has distinct instances. If not, the container -// can avoid wasting a word of memory to store an empty object. - -// This adaptor uses partial specialization. The general case of -// _Alloc_traits<_Tp, _Alloc> assumes that _Alloc is a -// standard-conforming allocator, possibly with non-equal instances -// and non-static members. (It still behaves correctly even if _Alloc -// has static member and if all instances are equal. Refinements -// affect performance, not correctness.) - -// There are always two members: allocator_type, which is a standard- -// conforming allocator type for allocating objects of type _Tp, and -// _S_instanceless, a static const member of type bool. If -// _S_instanceless is true, this means that there is no difference -// between any two instances of type allocator_type. Furthermore, if -// _S_instanceless is true, then _Alloc_traits has one additional -// member: _Alloc_type. This type encapsulates allocation and -// deallocation of objects of type _Tp through a static interface; it -// has two member functions, whose signatures are -// static _Tp* allocate(size_t) -// static void deallocate(_Tp*, size_t) - -// The fully general version. - -template -struct _Alloc_traits -{ - static const bool _S_instanceless = false; - typedef typename _Allocator::__STL_TEMPLATE rebind<_Tp>::other - allocator_type; -}; - -template -const bool _Alloc_traits<_Tp, _Allocator>::_S_instanceless; - -// The version for the default allocator. - -template -struct _Alloc_traits<_Tp, allocator<_Tp1> > -{ - static const bool _S_instanceless = true; -#ifdef __AVR__ - typedef simple_alloc<_Tp, malloc_alloc> _Alloc_type; -#else - typedef simple_alloc<_Tp, alloc> _Alloc_type; -#endif - typedef allocator<_Tp> allocator_type; -}; - -// Versions for the predefined SGI-style allocators. - -template -struct _Alloc_traits<_Tp, __malloc_alloc_template<__inst> > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type; - typedef __allocator<_Tp, __malloc_alloc_template<__inst> > allocator_type; -}; - -template -struct _Alloc_traits<_Tp, __default_alloc_template<__threads, __inst> > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, __default_alloc_template<__threads, __inst> > - _Alloc_type; - typedef __allocator<_Tp, __default_alloc_template<__threads, __inst> > - allocator_type; -}; - -template -struct _Alloc_traits<_Tp, debug_alloc<_Alloc> > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, debug_alloc<_Alloc> > _Alloc_type; - typedef __allocator<_Tp, debug_alloc<_Alloc> > allocator_type; -}; - -// Versions for the __allocator adaptor used with the predefined -// SGI-style allocators. - -template -struct _Alloc_traits<_Tp, - __allocator<_Tp1, __malloc_alloc_template<__inst> > > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type; - typedef __allocator<_Tp, __malloc_alloc_template<__inst> > allocator_type; -}; - -template -struct _Alloc_traits<_Tp, - __allocator<_Tp1, - __default_alloc_template<__thr, __inst> > > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, __default_alloc_template<__thr,__inst> > - _Alloc_type; - typedef __allocator<_Tp, __default_alloc_template<__thr,__inst> > - allocator_type; -}; - -template -struct _Alloc_traits<_Tp, __allocator<_Tp1, debug_alloc<_Alloc> > > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, debug_alloc<_Alloc> > _Alloc_type; - typedef __allocator<_Tp, debug_alloc<_Alloc> > allocator_type; -}; - - -#endif /* __STL_USE_STD_ALLOCATORS */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#endif - -__STL_END_NAMESPACE - -#undef __PRIVATE - -#endif /* __SGI_STL_INTERNAL_ALLOC_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_bvector.h b/DSTAT1/src/avr-stl/include/stl_bvector.h deleted file mode 100644 index 128065b..0000000 --- a/DSTAT1/src/avr-stl/include/stl_bvector.h +++ /dev/null @@ -1,897 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1999 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_BVECTOR_H -#define __SGI_STL_INTERNAL_BVECTOR_H - -__STL_BEGIN_NAMESPACE - -static const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int)); - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -struct _Bit_reference { - unsigned int* _M_p; - unsigned int _M_mask; - _Bit_reference(unsigned int* __x, unsigned int __y) - : _M_p(__x), _M_mask(__y) {} - -public: - _Bit_reference() : _M_p(0), _M_mask(0) {} - operator bool() const { return !(!(*_M_p & _M_mask)); } - _Bit_reference& operator=(bool __x) - { - if (__x) *_M_p |= _M_mask; - else *_M_p &= ~_M_mask; - return *this; - } - _Bit_reference& operator=(const _Bit_reference& __x) - { return *this = bool(__x); } - bool operator==(const _Bit_reference& __x) const - { return bool(*this) == bool(__x); } - bool operator<(const _Bit_reference& __x) const { - return !bool(*this) && bool(__x); - } - void flip() { *_M_p ^= _M_mask; } -}; - -inline void swap(_Bit_reference __x, _Bit_reference __y) -{ - bool __tmp = __x; - __x = __y; - __y = __tmp; -} - -struct _Bit_iterator_base : public random_access_iterator -{ - unsigned int* _M_p; - unsigned int _M_offset; - - _Bit_iterator_base(unsigned int* __x, unsigned int __y) - : _M_p(__x), _M_offset(__y) {} - - void _M_bump_up() { - if (_M_offset++ == __WORD_BIT - 1) { - _M_offset = 0; - ++_M_p; - } - } - void _M_bump_down() { - if (_M_offset-- == 0) { - _M_offset = __WORD_BIT - 1; - --_M_p; - } - } - - void _M_incr(ptrdiff_t __i) { - difference_type __n = __i + _M_offset; - _M_p += __n / __WORD_BIT; - __n = __n % __WORD_BIT; - if (__n < 0) { - _M_offset = (unsigned int) __n + __WORD_BIT; - --_M_p; - } else - _M_offset = (unsigned int) __n; - } - - bool operator==(const _Bit_iterator_base& __i) const { - return _M_p == __i._M_p && _M_offset == __i._M_offset; - } - bool operator<(const _Bit_iterator_base& __i) const { - return _M_p < __i._M_p || (_M_p == __i._M_p && _M_offset < __i._M_offset); - } - bool operator!=(const _Bit_iterator_base& __i) const { - return !(*this == __i); - } - bool operator>(const _Bit_iterator_base& __i) const { - return __i < *this; - } - bool operator<=(const _Bit_iterator_base& __i) const { - return !(__i < *this); - } - bool operator>=(const _Bit_iterator_base& __i) const { - return !(*this < __i); - } -}; - -inline ptrdiff_t -operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { - return __WORD_BIT * (__x._M_p - __y._M_p) + __x._M_offset - __y._M_offset; -} - - -struct _Bit_iterator : public _Bit_iterator_base -{ - typedef _Bit_reference reference; - typedef _Bit_reference* pointer; - typedef _Bit_iterator iterator; - - _Bit_iterator() : _Bit_iterator_base(0, 0) {} - _Bit_iterator(unsigned int* __x, unsigned int __y) - : _Bit_iterator_base(__x, __y) {} - - reference operator*() const { return reference(_M_p, 1U << _M_offset); } - iterator& operator++() { - _M_bump_up(); - return *this; - } - iterator operator++(int) { - iterator __tmp = *this; - _M_bump_up(); - return __tmp; - } - iterator& operator--() { - _M_bump_down(); - return *this; - } - iterator operator--(int) { - iterator __tmp = *this; - _M_bump_down(); - return __tmp; - } - iterator& operator+=(difference_type __i) { - _M_incr(__i); - return *this; - } - iterator& operator-=(difference_type __i) { - *this += -__i; - return *this; - } - iterator operator+(difference_type __i) const { - iterator __tmp = *this; - return __tmp += __i; - } - iterator operator-(difference_type __i) const { - iterator __tmp = *this; - return __tmp -= __i; - } - - reference operator[](difference_type __i) { return *(*this + __i); } -}; - -inline _Bit_iterator -operator+(ptrdiff_t __n, const _Bit_iterator& __x) { return __x + __n; } - - -struct _Bit_const_iterator : public _Bit_iterator_base -{ - typedef bool reference; - typedef bool const_reference; - typedef const bool* pointer; - typedef _Bit_const_iterator const_iterator; - - _Bit_const_iterator() : _Bit_iterator_base(0, 0) {} - _Bit_const_iterator(unsigned int* __x, unsigned int __y) - : _Bit_iterator_base(__x, __y) {} - _Bit_const_iterator(const _Bit_iterator& __x) - : _Bit_iterator_base(__x._M_p, __x._M_offset) {} - - const_reference operator*() const { - return _Bit_reference(_M_p, 1U << _M_offset); - } - const_iterator& operator++() { - _M_bump_up(); - return *this; - } - const_iterator operator++(int) { - const_iterator __tmp = *this; - _M_bump_up(); - return __tmp; - } - const_iterator& operator--() { - _M_bump_down(); - return *this; - } - const_iterator operator--(int) { - const_iterator __tmp = *this; - _M_bump_down(); - return __tmp; - } - const_iterator& operator+=(difference_type __i) { - _M_incr(__i); - return *this; - } - const_iterator& operator-=(difference_type __i) { - *this += -__i; - return *this; - } - const_iterator operator+(difference_type __i) const { - const_iterator __tmp = *this; - return __tmp += __i; - } - const_iterator operator-(difference_type __i) const { - const_iterator __tmp = *this; - return __tmp -= __i; - } - const_reference operator[](difference_type __i) { - return *(*this + __i); - } -}; - -inline _Bit_const_iterator -operator+(ptrdiff_t __n, const _Bit_const_iterator& __x) { return __x + __n; } - - -// Bit-vector base class, which encapsulates the difference between -// old SGI-style allocators and standard-conforming allocators. - -#ifdef __STL_USE_STD_ALLOCATORS - -// Base class for ordinary allocators. -template -class _Bvector_alloc_base { -public: - typedef typename _Alloc_traits::allocator_type - allocator_type; - allocator_type get_allocator() const { return _M_data_allocator; } - - _Bvector_alloc_base(const allocator_type& __a) - : _M_data_allocator(__a), _M_start(), _M_finish(), _M_end_of_storage(0) {} - -protected: - unsigned int* _M_bit_alloc(size_t __n) - { return _M_data_allocator.allocate((__n + __WORD_BIT - 1)/__WORD_BIT); } - void _M_deallocate() { - if (_M_start._M_p) - _M_data_allocator.deallocate(_M_start._M_p, - _M_end_of_storage - _M_start._M_p); - } - - typename _Alloc_traits::allocator_type - _M_data_allocator; - _Bit_iterator _M_start; - _Bit_iterator _M_finish; - unsigned int* _M_end_of_storage; -}; - -// Specialization for instanceless allocators. -template -class _Bvector_alloc_base<_Allocator, true> { -public: - typedef typename _Alloc_traits::allocator_type - allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Bvector_alloc_base(const allocator_type&) - : _M_start(), _M_finish(), _M_end_of_storage(0) {} - -protected: - typedef typename _Alloc_traits::_Alloc_type - _Alloc_type; - - unsigned int* _M_bit_alloc(size_t __n) - { return _Alloc_type::allocate((__n + __WORD_BIT - 1)/__WORD_BIT); } - void _M_deallocate() { - if (_M_start._M_p) - _Alloc_type::deallocate(_M_start._M_p, - _M_end_of_storage - _M_start._M_p); - } - - _Bit_iterator _M_start; - _Bit_iterator _M_finish; - unsigned int* _M_end_of_storage; -}; - -template -class _Bvector_base - : public _Bvector_alloc_base<_Alloc, - _Alloc_traits::_S_instanceless> -{ - typedef _Bvector_alloc_base<_Alloc, - _Alloc_traits::_S_instanceless> - _Base; -public: - typedef typename _Base::allocator_type allocator_type; - - _Bvector_base(const allocator_type& __a) : _Base(__a) {} - ~_Bvector_base() { _Base::_M_deallocate(); } -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -class _Bvector_base -{ -public: - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Bvector_base(const allocator_type&) - : _M_start(), _M_finish(), _M_end_of_storage(0) {} - ~_Bvector_base() { _M_deallocate(); } - -protected: - typedef simple_alloc _Alloc_type; - - unsigned int* _M_bit_alloc(size_t __n) - { return _Alloc_type::allocate((__n + __WORD_BIT - 1)/__WORD_BIT); } - void _M_deallocate() { - if (_M_start._M_p) - _Alloc_type::deallocate(_M_start._M_p, - _M_end_of_storage - _M_start._M_p); - } - - _Bit_iterator _M_start; - _Bit_iterator _M_finish; - unsigned int* _M_end_of_storage; -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -// The next few lines are confusing. What we're doing is declaring a -// partial specialization of vector if we have the necessary -// compiler support. Otherwise, we define a class bit_vector which uses -// the default allocator. - -#if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && !defined(__STL_NO_BOOL) -# define __SGI_STL_VECBOOL_TEMPLATE -# define __BVECTOR vector -# define __VECTOR vector -# define __BVECTOR_BASE _Bvector_base<_Alloc> -# define __BVECTOR_TMPL_LIST template - __STL_END_NAMESPACE -# include - __STL_BEGIN_NAMESPACE -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION && !__STL_NO_BOOL */ -# undef __SGI_STL_VECBOOL_TEMPLATE -# define __BVECTOR bit_vector -# define __VECTOR bit_vector -# define __BVECTOR_BASE _Bvector_base<__STL_DEFAULT_ALLOCATOR(bool) > -# define __BVECTOR_TMPL_LIST -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION && !__STL_NO_BOOL */ - - -__BVECTOR_TMPL_LIST -class __BVECTOR : public __BVECTOR_BASE -{ -public: - typedef bool value_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Bit_reference reference; - typedef bool const_reference; - typedef _Bit_reference* pointer; - typedef const bool* const_pointer; - - typedef _Bit_iterator iterator; - typedef _Bit_const_iterator const_iterator; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator - reverse_iterator; -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - - typedef typename __BVECTOR_BASE::allocator_type allocator_type; - allocator_type get_allocator() const { - return __BVECTOR_BASE::get_allocator(); - } - -protected: -#ifdef __STL_USE_NAMESPACES - using __BVECTOR_BASE::_M_bit_alloc; - using __BVECTOR_BASE::_M_deallocate; - using __BVECTOR_BASE::_M_start; - using __BVECTOR_BASE::_M_finish; - using __BVECTOR_BASE::_M_end_of_storage; -#endif /* __STL_USE_NAMESPACES */ - -protected: - void _M_initialize(size_type __n) { - unsigned int* __q = _M_bit_alloc(__n); - _M_end_of_storage = __q + (__n + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - _M_finish = _M_start + difference_type(__n); - } - void _M_insert_aux(iterator __position, bool __x) { - if (_M_finish._M_p != _M_end_of_storage) { - copy_backward(__position, _M_finish, _M_finish + 1); - *__position = __x; - ++_M_finish; - } - else { - size_type __len = size() ? 2 * size() : __WORD_BIT; - - unsigned int* __q = _M_bit_alloc(__len); - iterator __i = copy(begin(), __position, iterator(__q, 0)); - *__i++ = __x; - _M_finish = copy(__position, end(), __i); - _M_deallocate(); - _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - } - } - -#ifdef __STL_MEMBER_TEMPLATES - template - void _M_initialize_range(_InputIterator __first, _InputIterator __last, - input_iterator_tag) { - _M_start = iterator(); - _M_finish = iterator(); - _M_end_of_storage = 0; - for ( ; __first != __last; ++__first) - push_back(*__first); - } - - template - void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) { - size_type __n = 0; - distance(__first, __last, __n); - _M_initialize(__n); - copy(__first, __last, _M_start); - } - - template - void _M_insert_range(iterator __pos, - _InputIterator __first, _InputIterator __last, - input_iterator_tag) { - for ( ; __first != __last; ++__first) { - __pos = insert(__pos, *__first); - ++__pos; - } - } - - template - void _M_insert_range(iterator __position, - _ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) { - if (__first != __last) { - size_type __n = 0; - distance(__first, __last, __n); - if (capacity() - size() >= __n) { - copy_backward(__position, end(), _M_finish + difference_type(__n)); - copy(__first, __last, __position); - _M_finish += difference_type(__n); - } - else { - size_type __len = size() + max(size(), __n); - unsigned int* __q = _M_bit_alloc(__len); - iterator __i = copy(begin(), __position, iterator(__q, 0)); - __i = copy(__first, __last, __i); - _M_finish = copy(__position, end(), __i); - _M_deallocate(); - _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - } - } - } - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: - iterator begin() { return _M_start; } - const_iterator begin() const { return _M_start; } - iterator end() { return _M_finish; } - const_iterator end() const { return _M_finish; } - - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - - size_type size() const { return size_type(end() - begin()); } - size_type max_size() const { return size_type(-1); } - size_type capacity() const { - return size_type(const_iterator(_M_end_of_storage, 0) - begin()); - } - bool empty() const { return begin() == end(); } - - reference operator[](size_type __n) - { return *(begin() + difference_type(__n)); } - const_reference operator[](size_type __n) const - { return *(begin() + difference_type(__n)); } - -#ifdef __STL_THROW_RANGE_ERRORS - void _M_range_check(size_type __n) const { - if (__n >= this->size()) - __stl_throw_range_error("vector"); - } - - reference at(size_type __n) - { _M_range_check(__n); return (*this)[__n]; } - const_reference at(size_type __n) const - { _M_range_check(__n); return (*this)[__n]; } -#endif /* __STL_THROW_RANGE_ERRORS */ - - explicit __VECTOR(const allocator_type& __a = allocator_type()) - : __BVECTOR_BASE(__a) {} - - __VECTOR(size_type __n, bool __value, - const allocator_type& __a = allocator_type()) - : __BVECTOR_BASE(__a) - { - _M_initialize(__n); - fill(_M_start._M_p, _M_end_of_storage, __value ? ~0 : 0); - } - - explicit __VECTOR(size_type __n) - : __BVECTOR_BASE(allocator_type()) - { - _M_initialize(__n); - fill(_M_start._M_p, _M_end_of_storage, 0); - } - - __VECTOR(const __VECTOR& __x) : __BVECTOR_BASE(__x.get_allocator()) { - _M_initialize(__x.size()); - copy(__x.begin(), __x.end(), _M_start); - } - -#ifdef __STL_MEMBER_TEMPLATES - - // Check whether it's an integral type. If so, it's not an iterator. - - template - void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) { - _M_initialize(__n); - fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0); - } - - template - void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, - __false_type) { - _M_initialize_range(__first, __last, __ITERATOR_CATEGORY(__first)); - } - - template - __VECTOR(_InputIterator __first, _InputIterator __last, - const allocator_type& __a = allocator_type()) - : __BVECTOR_BASE(__a) - { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_initialize_dispatch(__first, __last, _Integral()); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - __VECTOR(const_iterator __first, const_iterator __last, - const allocator_type& __a = allocator_type()) - : __BVECTOR_BASE(__a) - { - size_type __n = 0; - distance(__first, __last, __n); - _M_initialize(__n); - copy(__first, __last, _M_start); - } - __VECTOR(const bool* __first, const bool* __last, - const allocator_type& __a = allocator_type()) - : __BVECTOR_BASE(__a) - { - size_type __n = 0; - distance(__first, __last, __n); - _M_initialize(__n); - copy(__first, __last, _M_start); - } - -#endif /* __STL_MEMBER_TEMPLATES */ - - ~__VECTOR() { } - - __VECTOR& operator=(const __VECTOR& __x) { - if (&__x == this) return *this; - if (__x.size() > capacity()) { - _M_deallocate(); - _M_initialize(__x.size()); - } - copy(__x.begin(), __x.end(), begin()); - _M_finish = begin() + difference_type(__x.size()); - return *this; - } - - // assign(), a generalized assignment member function. Two - // versions: one that takes a count, and one that takes a range. - // The range version is a member template, so we dispatch on whether - // or not the type is an integer. - - void _M_fill_assign(size_t __n, bool __x) { - if (__n > size()) { - fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0); - insert(end(), __n - size(), __x); - } - else { - erase(begin() + __n, end()); - fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0); - } - } - - void assign(size_t __n, bool __x) { _M_fill_assign(__n, __x); } - -#ifdef __STL_MEMBER_TEMPLATES - - template - void assign(_InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_assign_dispatch(__first, __last, _Integral()); - } - - template - void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { _M_fill_assign((size_t) __n, (bool) __val); } - - template - void _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type) - { _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first)); } - - template - void _M_assign_aux(_InputIterator __first, _InputIterator __last, - input_iterator_tag) { - iterator __cur = begin(); - for ( ; __first != __last && __cur != end(); ++__cur, ++__first) - *__cur = *__first; - if (__first == __last) - erase(__cur, end()); - else - insert(end(), __first, __last); - } - - template - void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) { - size_type __len = 0; - distance(__first, __last, __len); - if (__len < size()) - erase(copy(__first, __last, begin()), end()); - else { - _ForwardIterator __mid = __first; - advance(__mid, size()); - copy(__first, __mid, begin()); - insert(end(), __mid, __last); - } - } - -#endif /* __STL_MEMBER_TEMPLATES */ - - void reserve(size_type __n) { - if (capacity() < __n) { - unsigned int* __q = _M_bit_alloc(__n); - _M_finish = copy(begin(), end(), iterator(__q, 0)); - _M_deallocate(); - _M_start = iterator(__q, 0); - _M_end_of_storage = __q + (__n + __WORD_BIT - 1)/__WORD_BIT; - } - } - - reference front() { return *begin(); } - const_reference front() const { return *begin(); } - reference back() { return *(end() - 1); } - const_reference back() const { return *(end() - 1); } - void push_back(bool __x) { - if (_M_finish._M_p != _M_end_of_storage) - *_M_finish++ = __x; - else - _M_insert_aux(end(), __x); - } - void swap(__BVECTOR& __x) { - __STD::swap(_M_start, __x._M_start); - __STD::swap(_M_finish, __x._M_finish); - __STD::swap(_M_end_of_storage, __x._M_end_of_storage); - } - iterator insert(iterator __position, bool __x = bool()) { - difference_type __n = __position - begin(); - if (_M_finish._M_p != _M_end_of_storage && __position == end()) - *_M_finish++ = __x; - else - _M_insert_aux(__position, __x); - return begin() + __n; - } - -#ifdef __STL_MEMBER_TEMPLATES - // Check whether it's an integral type. If so, it's not an iterator. - - template - void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, - __true_type) { - _M_fill_insert(__pos, __n, __x); - } - - template - void _M_insert_dispatch(iterator __pos, - _InputIterator __first, _InputIterator __last, - __false_type) { - _M_insert_range(__pos, __first, __last, __ITERATOR_CATEGORY(__first)); - } - - template - void insert(iterator __position, - _InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_insert_dispatch(__position, __first, __last, _Integral()); - } - -#else /* __STL_MEMBER_TEMPLATES */ - void insert(iterator __position, - const_iterator __first, const_iterator __last) { - if (__first == __last) return; - size_type __n = 0; - distance(__first, __last, __n); - if (capacity() - size() >= __n) { - copy_backward(__position, end(), _M_finish + __n); - copy(__first, __last, __position); - _M_finish += __n; - } - else { - size_type __len = size() + max(size(), __n); - unsigned int* __q = _M_bit_alloc(__len); - iterator __i = copy(begin(), __position, iterator(__q, 0)); - __i = copy(__first, __last, __i); - _M_finish = copy(__position, end(), __i); - _M_deallocate(); - _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - } - } - - void insert(iterator __position, const bool* __first, const bool* __last) { - if (__first == __last) return; - size_type __n = 0; - distance(__first, __last, __n); - if (capacity() - size() >= __n) { - copy_backward(__position, end(), _M_finish + __n); - copy(__first, __last, __position); - _M_finish += __n; - } - else { - size_type __len = size() + max(size(), __n); - unsigned int* __q = _M_bit_alloc(__len); - iterator __i = copy(begin(), __position, iterator(__q, 0)); - __i = copy(__first, __last, __i); - _M_finish = copy(__position, end(), __i); - _M_deallocate(); - _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - } - } -#endif /* __STL_MEMBER_TEMPLATES */ - - void _M_fill_insert(iterator __position, size_type __n, bool __x) { - if (__n == 0) return; - if (capacity() - size() >= __n) { - copy_backward(__position, end(), _M_finish + difference_type(__n)); - fill(__position, __position + difference_type(__n), __x); - _M_finish += difference_type(__n); - } - else { - size_type __len = size() + max(size(), __n); - unsigned int* __q = _M_bit_alloc(__len); - iterator __i = copy(begin(), __position, iterator(__q, 0)); - fill_n(__i, __n, __x); - _M_finish = copy(__position, end(), __i + difference_type(__n)); - _M_deallocate(); - _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT; - _M_start = iterator(__q, 0); - } - } - - void insert(iterator __position, size_type __n, bool __x) { - _M_fill_insert(__position, __n, __x); - } - - void pop_back() { --_M_finish; } - iterator erase(iterator __position) { - if (__position + 1 != end()) - copy(__position + 1, end(), __position); - --_M_finish; - return __position; - } - iterator erase(iterator __first, iterator __last) { - _M_finish = copy(__last, end(), __first); - return __first; - } - void resize(size_type __new_size, bool __x = bool()) { - if (__new_size < size()) - erase(begin() + difference_type(__new_size), end()); - else - insert(end(), __new_size - size(), __x); - } - void flip() { - for (unsigned int* __p = _M_start._M_p; __p != _M_end_of_storage; ++__p) - *__p = ~*__p; - } - - void clear() { erase(begin(), end()); } -}; - -#ifdef __SGI_STL_VECBOOL_TEMPLATE - -// This typedef is non-standard. It is provided for backward compatibility. -typedef vector bit_vector; - -#else /* __SGI_STL_VECBOOL_TEMPLATE */ - -inline void swap(bit_vector& __x, bit_vector& __y) { - __x.swap(__y); -} - -inline bool -operator==(const bit_vector& __x, const bit_vector& __y) -{ - return (__x.size() == __y.size() && - equal(__x.begin(), __x.end(), __y.begin())); -} - -inline bool -operator!=(const bit_vector& __x, const bit_vector& __y) -{ - return !(__x == __y); -} - -inline bool -operator<(const bit_vector& __x, const bit_vector& __y) -{ - return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); -} - -inline bool operator>(const bit_vector& __x, const bit_vector& __y) -{ - return __y < __x; -} - -inline bool operator<=(const bit_vector& __x, const bit_vector& __y) -{ - return !(__y < __x); -} - -inline bool operator>=(const bit_vector& __x, const bit_vector& __y) -{ - return !(__x < __y); -} - -#endif /* __SGI_STL_VECBOOL_TEMPLATE */ - -#undef __SGI_STL_VECBOOL_TEMPLATE -#undef __BVECTOR -#undef __VECTOR -#undef __BVECTOR_BASE -#undef __BVECTOR_TMPL_LIST - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_BVECTOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_config.h b/DSTAT1/src/avr-stl/include/stl_config.h deleted file mode 100644 index 7456b56..0000000 --- a/DSTAT1/src/avr-stl/include/stl_config.h +++ /dev/null @@ -1,601 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * Copyright (c) 1997 - * Silicon Graphics - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef __STL_CONFIG_H -# define __STL_CONFIG_H - -// Flags: -// * __STL_NO_BOOL: defined if the compiler doesn't have bool as a builtin -// type. -// * __STL_HAS_WCHAR_T: defined if the compier has wchar_t as a builtin type. -// * __STL_NO_DRAND48: defined if the compiler doesn't have the drand48 -// function. -// * __STL_STATIC_TEMPLATE_MEMBER_BUG: defined if the compiler can't handle -// static members of template classes. -// * __STL_STATIC_CONST_INIT_BUG: defined if the compiler can't handle a -// constant-initializer in the declaration of a static const data member -// of integer type. (See section 9.4.2, paragraph 4, of the C++ standard.) -// * __STL_CLASS_PARTIAL_SPECIALIZATION: defined if the compiler supports -// partial specialization of template classes. -// * __STL_PARTIAL_SPECIALIZATION_SYNTAX: defined if the compiler -// supports partial specialization syntax for full specialization of -// class templates. (Even if it doesn't actually support partial -// specialization itself.) -// * __STL_FUNCTION_TMPL_PARTIAL_ORDER: defined if the compiler supports -// partial ordering of function templates. (a.k.a partial specialization -// of function templates.) -// * __STL_MEMBER_TEMPLATES: defined if the compiler supports template -// member functions of classes. -// * __STL_MEMBER_TEMPLATE_CLASSES: defined if the compiler supports -// nested classes that are member templates of other classes. -// * __STL_TEMPLATE_FRIENDS: defined if the compiler supports templatized -// friend declarations. -// * __STL_EXPLICIT_FUNCTION_TMPL_ARGS: defined if the compiler -// supports calling a function template by providing its template -// arguments explicitly. -// * __STL_LIMITED_DEFAULT_TEMPLATES: defined if the compiler is unable -// to handle default template parameters that depend on previous template -// parameters. -// * __STL_NON_TYPE_TMPL_PARAM_BUG: defined if the compiler has trouble with -// function template argument deduction for non-type template parameters. -// * __SGI_STL_NO_ARROW_OPERATOR: defined if the compiler is unable -// to support the -> operator for iterators. -// * __STL_DEFAULT_CONSTRUCTOR_BUG: defined if T() does not work properly -// when T is a builtin type. -// * __STL_USE_EXCEPTIONS: defined if the compiler (in the current compilation -// mode) supports exceptions. -// * __STL_USE_NAMESPACES: defined if the compiler has the necessary -// support for namespaces. -// * __STL_NO_EXCEPTION_HEADER: defined if the compiler does not have a -// standard-conforming header . -// * __STL_NO_BAD_ALLOC: defined if the compiler does not have a -// header, or if does not contain a bad_alloc class. If a bad_alloc -// class exists, it is assumed to be in namespace std. -// * __STL_SGI_THREADS: defined if this is being compiled for an SGI IRIX -// system in multithreaded mode, using native SGI threads instead of -// pthreads. -// * __STL_WIN32THREADS: defined if this is being compiled on a WIN32 -// compiler in multithreaded mode. -// * __STL_PTHREADS: defined if we should use portable pthreads -// synchronization. -// * __STL_UITHREADS: defined if we should use UI / solaris / UnixWare threads -// synchronization. UIthreads are similar to pthreads, but are based -// on an earlier version of the Posix threads standard. -// * __STL_LONG_LONG if the compiler has long long and unsigned long long -// types. (They're not in the C++ standard, but they are expected to be -// included in the forthcoming C9X standard.) -// * __STL_THREADS is defined if thread safety is needed. -// * __STL_VOLATILE is defined to be "volatile" if threads are being -// used, and the empty string otherwise. -// * __STL_USE_CONCEPT_CHECKS enables some extra compile-time error -// checking to make sure that user-defined template arguments satisfy -// all of the appropriate requirements. This may result in more -// comprehensible error messages. It incurs no runtime overhead. This -// feature requires member templates and partial specialization. -// * __STL_NO_USING_CLAUSE_IN_CLASS: The compiler does not handle "using" -// clauses inside of class definitions. -// * __STL_NO_FRIEND_TEMPLATE_CLASS: The compiler does not handle friend -// declaractions where the friend is a template class. -// * __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE: The compiler does not -// support the use of a function pointer type as the argument -// for a template. -// * __STL_MEMBER_TEMPLATE_KEYWORD: standard C++ requires the template -// keyword in a few new places (14.2.4). This flag is set for -// compilers that support (and require) this usage. - - -// User-settable macros that control compilation: -// * __STL_USE_SGI_ALLOCATORS: if defined, then the STL will use older -// SGI-style allocators, instead of standard-conforming allocators, -// even if the compiler supports all of the language features needed -// for standard-conforming allocators. -// * __STL_NO_NAMESPACES: if defined, don't put the library in namespace -// std, even if the compiler supports namespaces. -// * __STL_NO_RELOPS_NAMESPACE: if defined, don't put the relational -// operator templates (>, <=. >=, !=) in namespace std::rel_ops, even -// if the compiler supports namespaces and partial ordering of -// function templates. -// * __STL_ASSERTIONS: if defined, then enable runtime checking through the -// __stl_assert macro. -// * _PTHREADS: if defined, use Posix threads for multithreading support. -// * _UITHREADS:if defined, use SCO/Solaris/UI threads for multithreading -// support -// * _NOTHREADS: if defined, don't use any multithreading support. -// * _STL_NO_CONCEPT_CHECKS: if defined, disables the error checking that -// we get from __STL_USE_CONCEPT_CHECKS. -// * __STL_USE_NEW_IOSTREAMS: if defined, then the STL will use new, -// standard-conforming iostreams (e.g. the header). If not -// defined, the STL will use old cfront-style iostreams (e.g. the -// header). - -// Other macros defined by this file: - -// * bool, true, and false, if __STL_NO_BOOL is defined. -// * typename, as a null macro if it's not already a keyword. -// * explicit, as a null macro if it's not already a keyword. -// * namespace-related macros (__STD, __STL_BEGIN_NAMESPACE, etc.) -// * exception-related macros (__STL_TRY, __STL_UNWIND, etc.) -// * __stl_assert, either as a test or as a null macro, depending on -// whether or not __STL_ASSERTIONS is defined. - -#if defined(__AVR__) - -#include - -// don't change these - -#define __STL_NO_DRAND48 -#define __STL_NO_BAD_ALLOC -#define __STL_PARTIAL_SPECIALIZATION_SYNTAX -#define __STL_CLASS_PARTIAL_SPECIALIZATION -#define __STL_USE_NEW_IOSTREAMS // not really :-/ -#define __STL_FUNCTION_TMPL_PARTIAL_ORDER -#define __STL_EXPLICIT_FUNCTION_TMPL_ARGS -#define __STL_MEMBER_TEMPLATES -#define __STL_MEMBER_TEMPLATE_CLASSES -#define __STL_TEMPLATE_FRIENDS -#define __SGI_STL_USE_AUTO_PTR_CONVERSIONS -#define __STL_HAS_NAMESPACES -#define __STL_USE_NAMESPACES -#define __STL_MEMBER_TEMPLATE_KEYWORD -#define _NOTHREADS - -#endif - - -# if defined(_PTHREADS) && !defined(_NOTHREADS) -# define __STL_PTHREADS -# endif - -# if defined(_UITHREADS) && !defined(_PTHREADS) && !defined(_NOTHREADS) -# define __STL_UITHREADS -# endif - -# if defined(__sgi) && !defined(__GNUC__) -# include -# if !defined(_BOOL) -# define __STL_NO_BOOL -# endif -# if defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32 -# define __STL_STATIC_CONST_INIT_BUG -# endif -# if defined(_WCHAR_T_IS_KEYWORD) -# define __STL_HAS_WCHAR_T -# endif -# if !defined(_TYPENAME_IS_KEYWORD) -# define __STL_NEED_TYPENAME -# endif -# ifdef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# endif -# if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32 -# define __STL_FUNCTION_TMPL_PARTIAL_ORDER -# endif -# ifdef _MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATES -# define __STL_TEMPLATE_FRIENDS -# define __STL_MEMBER_TEMPLATE_CLASSES -# endif -# if defined(_MEMBER_TEMPLATE_KEYWORD) -# define __STL_MEMBER_TEMPLATE_KEYWORD -# endif -# if defined(_STANDARD_C_PLUS_PLUS) -# define __STL_EXPLICIT_FUNCTION_TMPL_ARGS -# endif -# if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32 -# define __STL_MEMBER_TEMPLATE_KEYWORD -# endif -# if COMPILER_VERSION < 720 || (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) -# define __STL_DEFAULT_CONSTRUCTOR_BUG -# endif -# if !defined(_EXPLICIT_IS_KEYWORD) -# define __STL_NEED_EXPLICIT -# endif -# ifdef __EXCEPTIONS -# define __STL_USE_EXCEPTIONS -# endif -# if (_COMPILER_VERSION >= 721) && defined(_NAMESPACES) -# define __STL_HAS_NAMESPACES -# endif -# if (_COMPILER_VERSION < 721) || \ - !defined(__STL_HAS_NAMESPACES) || defined(__STL_NO_NAMESPACES) -# define __STL_NO_EXCEPTION_HEADER -# endif -# if _COMPILER_VERSION < 730 || !defined(_STANDARD_C_PLUS_PLUS) || \ - !defined(_NAMESPACES) -# define __STL_NO_BAD_ALLOC -# endif -# if !defined(_NOTHREADS) && !defined(__STL_PTHREADS) -# define __STL_SGI_THREADS -# endif -# if defined(_LONGLONG) && defined(_SGIAPI) && _SGIAPI -# define __STL_LONG_LONG -# endif -# if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS) -# define __STL_USE_NEW_IOSTREAMS -# endif -# if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS) -# define __STL_CAN_THROW_RANGE_ERRORS -# endif -# if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS) -# define __SGI_STL_USE_AUTO_PTR_CONVERSIONS -# endif -# endif - - -/* - * Jochen Schlick '1999 - added new #defines (__STL)_UITHREADS (for - * providing SCO / Solaris / UI thread support) - * - added the necessary defines for the SCO UDK 7 - * compiler (and its template friend behavior) - * - all UDK7 specific STL changes are based on the - * macro __USLC__ being defined - */ -// SCO UDK 7 compiler (UnixWare 7x, OSR 5, UnixWare 2x) -# if defined(__USLC__) -# define __STL_HAS_WCHAR_T -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_PARTIAL_SPECIALIZATION_SYNTAX -# define __STL_FUNCTION_TMPL_PARTIAL_ORDER -# define __STL_MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATE_CLASSES -# define __STL_USE_EXCEPTIONS -# define __STL_HAS_NAMESPACES -# define __STL_USE_NAMESPACES -# define __STL_LONG_LONG -# if defined(_REENTRANT) -# define _UITHREADS /* if UnixWare < 7.0.1 */ -# define __STL_UITHREADS -// use the following defines instead of the UI threads defines when -// you want to use POSIX threads -//# define _PTHREADS /* only if UnixWare >=7.0.1 */ -//# define __STL_PTHREADS -# endif -# endif - - - -# ifdef __GNUC__ -# if __GNUC__ == 2 && __GNUC_MINOR__ <= 7 -# define __STL_STATIC_TEMPLATE_MEMBER_BUG -# endif -# if __GNUC__ < 2 -# define __STL_NEED_TYPENAME -# define __STL_NEED_EXPLICIT -# endif -# if __GNUC__ == 2 && __GNUC_MINOR__ <= 8 -# define __STL_NO_EXCEPTION_HEADER -# define __STL_NO_BAD_ALLOC -# endif -# if __GNUC__ == 2 && __GNUC_MINOR__ >= 8 -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_FUNCTION_TMPL_PARTIAL_ORDER -# define __STL_EXPLICIT_FUNCTION_TMPL_ARGS -# define __STL_MEMBER_TEMPLATES -# define __STL_CAN_THROW_RANGE_ERRORS - // g++ 2.8.1 supports member template functions, but not member - // template nested classes. -# if __GNUC_MINOR__ >= 9 -# define __STL_MEMBER_TEMPLATE_CLASSES -# define __STL_TEMPLATE_FRIENDS -# define __SGI_STL_USE_AUTO_PTR_CONVERSIONS -# define __STL_HAS_NAMESPACES -//# define __STL_USE_NEW_IOSTREAMS -# endif -# endif -# define __STL_DEFAULT_CONSTRUCTOR_BUG -# ifdef __EXCEPTIONS -# define __STL_USE_EXCEPTIONS -# endif -# ifdef _REENTRANT -# define __STL_PTHREADS -# endif -# if (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 95) -# define __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE -# endif -# endif - -# if defined(__SUNPRO_CC) -# define __STL_NO_BOOL -# define __STL_NEED_TYPENAME -# define __STL_NEED_EXPLICIT -# define __STL_USE_EXCEPTIONS -# ifdef _REENTRANT -# define __STL_PTHREADS -# endif -# define __SGI_STL_NO_ARROW_OPERATOR -# define __STL_PARTIAL_SPECIALIZATION_SYNTAX -# define __STL_NO_EXCEPTION_HEADER -# define __STL_NO_BAD_ALLOC -# endif - -# if defined(__COMO__) -# define __STL_MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATE_CLASSES -# define __STL_TEMPLATE_FRIENDS -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_USE_EXCEPTIONS -# define __STL_HAS_NAMESPACES -# endif - -// Intel compiler, which uses the EDG front end. -# if defined(__ICL) -# define __STL_LONG_LONG -# define __STL_MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATE_CLASSES -# define __STL_TEMPLATE_FRIENDS -# define __STL_FUNCTION_TMPL_PARTIAL_ORDER -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_NO_DRAND48 -# define __STL_HAS_NAMESPACES -# define __STL_USE_EXCEPTIONS -# define __STL_MEMBER_TEMPLATE_KEYWORD -# ifdef _CPPUNWIND -# define __STL_USE_EXCEPTIONS -# endif -# ifdef _MT -# define __STL_WIN32THREADS -# endif -# endif - -// Mingw32, egcs compiler using the Microsoft C runtime -# if defined(__MINGW32__) -# define __STL_NO_DRAND48 -# ifdef _MT -# define __STL_WIN32THREADS -# endif -# endif - -// Cygwin32, egcs compiler on MS Windows -# if defined(__CYGWIN__) -# define __STL_NO_DRAND48 -# endif - - - -// Microsoft compiler. -# if defined(_MSC_VER) && !defined(__ICL) && !defined(__MWERKS__) -# define __STL_NO_DRAND48 -# define __STL_STATIC_CONST_INIT_BUG -# define __STL_NEED_TYPENAME -# define __STL_NO_USING_CLAUSE_IN_CLASS -# define __STL_NO_FRIEND_TEMPLATE_CLASS -# if _MSC_VER < 1100 /* 1000 is version 4.0, 1100 is 5.0, 1200 is 6.0. */ -# define __STL_NEED_EXPLICIT -# define __STL_NO_BOOL -# define __STL_NO_BAD_ALLOC -# endif -# if _MSC_VER > 1000 -# include -# define __STL_DONT_USE_BOOL_TYPEDEF -# endif -# define __STL_NON_TYPE_TMPL_PARAM_BUG -# define __SGI_STL_NO_ARROW_OPERATOR -# define __STL_DEFAULT_CONSTRUCTOR_BUG -# ifdef _CPPUNWIND -# define __STL_USE_EXCEPTIONS -# endif -# ifdef _MT -# define __STL_WIN32THREADS -# endif -# if _MSC_VER >= 1200 -# define __STL_PARTIAL_SPECIALIZATION_SYNTAX -# define __STL_HAS_NAMESPACES -# define __STL_CAN_THROW_RANGE_ERRORS -# define NOMINMAX -# undef min -# undef max -// disable warning 'initializers put in unrecognized initialization area' -# pragma warning ( disable : 4075 ) -// disable warning 'empty controlled statement found' -# pragma warning ( disable : 4390 ) -// disable warning 'debug symbol greater than 255 chars' -# pragma warning ( disable : 4786 ) -# endif -# if _MSC_VER < 1100 -# define __STL_NO_EXCEPTION_HEADER -# define __STL_NO_BAD_ALLOC -# endif - // Because of a Microsoft front end bug, we must not provide a - // namespace qualifier when declaring a friend function. -# define __STD_QUALIFIER -# endif - -# if defined(__BORLANDC__) -# define __STL_NO_BAD_ALLOC -# define __STL_NO_DRAND48 -# define __STL_DEFAULT_CONSTRUCTOR_BUG -# if __BORLANDC__ >= 0x540 /* C++ Builder 4.0 */ -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_FUNCTION_TMPL_PARTIAL_ORDER -# define __STL_EXPLICIT_FUNCTION_TMPL_ARGS -# define __STL_MEMBER_TEMPLATES -# define __STL_TEMPLATE_FRIENDS -# else -# define __STL_NEED_TYPENAME -# define __STL_LIMITED_DEFAULT_TEMPLATES -# define __SGI_STL_NO_ARROW_OPERATOR -# define __STL_NON_TYPE_TMPL_PARAM_BUG -# endif -# ifdef _CPPUNWIND -# define __STL_USE_EXCEPTIONS -# endif -# ifdef __MT__ -# define __STL_WIN32THREADS -# endif -# endif - -# if defined(__STL_NO_BOOL) && !defined(__STL_DONT_USE_BOOL_TYPEDEF) - typedef int bool; -# define true 1 -# define false 0 -# endif - -# ifdef __STL_NEED_TYPENAME -# define typename -# endif - -# ifdef __STL_LIMITED_DEFAULT_TEMPLATES -# define __STL_DEPENDENT_DEFAULT_TMPL(_Tp) -# else -# define __STL_DEPENDENT_DEFAULT_TMPL(_Tp) = _Tp -# endif - -# ifdef __STL_MEMBER_TEMPLATE_KEYWORD -# define __STL_TEMPLATE template -# else -# define __STL_TEMPLATE -# endif - -# ifdef __STL_NEED_EXPLICIT -# define explicit -# endif - -# ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS -# define __STL_NULL_TMPL_ARGS <> -# else -# define __STL_NULL_TMPL_ARGS -# endif - -# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \ - || defined (__STL_PARTIAL_SPECIALIZATION_SYNTAX) -# define __STL_TEMPLATE_NULL template<> -# else -# define __STL_TEMPLATE_NULL -# endif - -// Use standard-conforming allocators if we have the necessary language -// features. __STL_USE_SGI_ALLOCATORS is a hook so that users can -// disable new-style allocators, and continue to use the same kind of -// allocators as before, without having to edit library headers. -# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && \ - defined(__STL_MEMBER_TEMPLATES) && \ - defined(__STL_MEMBER_TEMPLATE_CLASSES) && \ - !defined(__STL_NO_BOOL) && \ - !defined(__STL_NON_TYPE_TMPL_PARAM_BUG) && \ - !defined(__STL_LIMITED_DEFAULT_TEMPLATES) && \ - !defined(__STL_USE_SGI_ALLOCATORS) -# define __STL_USE_STD_ALLOCATORS -# endif - -# ifndef __STL_DEFAULT_ALLOCATOR -# ifdef __STL_USE_STD_ALLOCATORS -# define __STL_DEFAULT_ALLOCATOR(T) allocator< T > -# else -# define __STL_DEFAULT_ALLOCATOR(T) alloc -# endif -# endif - -// __STL_NO_NAMESPACES is a hook so that users can disable namespaces -// without having to edit library headers. __STL_NO_RELOPS_NAMESPACE is -// a hook so that users can disable the std::rel_ops namespace, keeping -// the relational operator template in namespace std, without having to -// edit library headers. -# if defined(__STL_HAS_NAMESPACES) && !defined(__STL_NO_NAMESPACES) -# define __STL_USE_NAMESPACES -# define __STD std -# define __STL_BEGIN_NAMESPACE namespace std { -# define __STL_END_NAMESPACE } -# if defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER) && \ - !defined(__STL_NO_RELOPS_NAMESPACE) -# define __STL_USE_NAMESPACE_FOR_RELOPS -# define __STL_BEGIN_RELOPS_NAMESPACE namespace std { namespace rel_ops { -# define __STL_END_RELOPS_NAMESPACE } } -# define __STD_RELOPS std::rel_ops -# else /* Use std::rel_ops namespace */ -# define __STL_USE_NAMESPACE_FOR_RELOPS -# define __STL_BEGIN_RELOPS_NAMESPACE namespace std { -# define __STL_END_RELOPS_NAMESPACE } -# define __STD_RELOPS std -# endif /* Use std::rel_ops namespace */ -# else -# define __STD -# define __STL_BEGIN_NAMESPACE -# define __STL_END_NAMESPACE -# undef __STL_USE_NAMESPACE_FOR_RELOPS -# define __STL_BEGIN_RELOPS_NAMESPACE -# define __STL_END_RELOPS_NAMESPACE -# define __STD_RELOPS -# undef __STL_USE_NAMESPACES -# endif - -// Some versions of the EDG front end sometimes require an explicit -// namespace spec where they shouldn't. This macro facilitates that. -// If the bug becomes irrelevant, then all uses of __STD_QUALIFIER -// should be removed. The 7.3 beta SGI compiler has this bug, but the -// MR version is not expected to have it. - -# if defined(__STL_USE_NAMESPACES) && !defined(__STD_QUALIFIER) -# define __STD_QUALIFIER std:: -# else -# define __STD_QUALIFIER -# endif - -# ifdef __STL_USE_EXCEPTIONS -# define __STL_TRY try -# define __STL_CATCH_ALL catch(...) -# define __STL_THROW(x) throw x -# define __STL_RETHROW throw -# define __STL_NOTHROW throw() -# define __STL_UNWIND(action) catch(...) { action; throw; } -# else -# define __STL_TRY -# define __STL_CATCH_ALL if (false) -# define __STL_THROW(x) -# define __STL_RETHROW -# define __STL_NOTHROW -# define __STL_UNWIND(action) -# endif - -#ifdef __STL_ASSERTIONS -# include -# define __stl_assert(expr) \ - if (!(expr)) { fprintf(stderr, "%s:%d STL assertion failure: %s\n", \ - __FILE__, __LINE__, # expr); abort(); } -#else -# define __stl_assert(expr) -#endif - -#if defined(__STL_WIN32THREADS) || defined(__STL_SGI_THREADS) \ - || defined(__STL_PTHREADS) || defined(__STL_UITHREADS) -# define __STL_THREADS -# define __STL_VOLATILE volatile -#else -# define __STL_VOLATILE -#endif - -#if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \ - && defined(__STL_MEMBER_TEMPLATES) \ - && !defined(_STL_NO_CONCEPT_CHECKS) -# define __STL_USE_CONCEPT_CHECKS -#endif - - -#endif /* __STL_CONFIG_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_construct.h b/DSTAT1/src/avr-stl/include/stl_construct.h deleted file mode 100644 index cb27e76..0000000 --- a/DSTAT1/src/avr-stl/include/stl_construct.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H -#define __SGI_STL_INTERNAL_CONSTRUCT_H - -#include - -__STL_BEGIN_NAMESPACE - -// construct and destroy. These functions are not part of the C++ standard, -// and are provided for backward compatibility with the HP STL. We also -// provide internal names _Construct and _Destroy that can be used within -// the library, so that standard-conforming pieces don't have to rely on -// non-standard extensions. - -// Internal names - -template -inline void _Construct(_T1* __p, const _T2& __value) { - new ((void*) __p) _T1(__value); -} - -template -inline void _Construct(_T1* __p) { - new ((void*) __p) _T1(); -} - -template -inline void _Destroy(_Tp* __pointer) { - __pointer->~_Tp(); -} - -template -void -__destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type) -{ - for ( ; __first != __last; ++__first) - destroy(&*__first); -} - -template -inline void __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type) {} - -template -inline void -__destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*) -{ - typedef typename __type_traits<_Tp>::has_trivial_destructor - _Trivial_destructor; - __destroy_aux(__first, __last, _Trivial_destructor()); -} - -template -inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) { - __destroy(__first, __last, __VALUE_TYPE(__first)); -} - -inline void _Destroy(char*, char*) {} -inline void _Destroy(int*, int*) {} -inline void _Destroy(long*, long*) {} -inline void _Destroy(float*, float*) {} -inline void _Destroy(double*, double*) {} -#ifdef __STL_HAS_WCHAR_T -inline void _Destroy(wchar_t*, wchar_t*) {} -#endif /* __STL_HAS_WCHAR_T */ - -// -------------------------------------------------- -// Old names from the HP STL. - -template -inline void construct(_T1* __p, const _T2& __value) { - _Construct(__p, __value); -} - -template -inline void construct(_T1* __p) { - _Construct(__p); -} - -template -inline void destroy(_Tp* __pointer) { - _Destroy(__pointer); -} - -template -inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { - _Destroy(__first, __last); -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_CONSTRUCT_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_ctraits_fns.h b/DSTAT1/src/avr-stl/include/stl_ctraits_fns.h deleted file mode 100644 index 5577f4d..0000000 --- a/DSTAT1/src/avr-stl/include/stl_ctraits_fns.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1999 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -// WARNING: This is an internal header file, included by other C++ -// standard library headers. You should not attempt to use this header -// file directly. - -#ifndef __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H -#define __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H - -// This file contains a few small adapters that allow a character -// traits class to be used as a function object. - -__STL_BEGIN_NAMESPACE - -template -struct _Eq_traits - : public binary_function -{ - bool operator()(const typename _Traits::char_type& __x, - const typename _Traits::char_type& __y) const - { return _Traits::eq(__x, __y); } -}; - -template -struct _Eq_int_traits - : public binary_function -{ - bool operator()(const typename _Traits::char_type& __x, - const typename _Traits::int_type& __y) const - { return _Traits::eq_int_type(_Traits::to_int_type(__x), __y); } -}; - -template -struct _Lt_traits - : public binary_function -{ - bool operator()(const typename _Traits::char_type& __x, - const typename _Traits::char_type& __y) const - { return _Traits::lt(__x, __y); } -}; - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H */ - -// Local Variables: -// mode:C++ -// End: - - - - diff --git a/DSTAT1/src/avr-stl/include/stl_deque.h b/DSTAT1/src/avr-stl/include/stl_deque.h deleted file mode 100644 index ea9aa67..0000000 --- a/DSTAT1/src/avr-stl/include/stl_deque.h +++ /dev/null @@ -1,1664 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#include - -#ifndef __SGI_STL_INTERNAL_DEQUE_H -#define __SGI_STL_INTERNAL_DEQUE_H - -/* Class invariants: - * For any nonsingular iterator i: - * i.node is the address of an element in the map array. The - * contents of i.node is a pointer to the beginning of a node. - * i.first == *(i.node) - * i.last == i.first + node_size - * i.cur is a pointer in the range [i.first, i.last). NOTE: - * the implication of this is that i.cur is always a dereferenceable - * pointer, even if i is a past-the-end iterator. - * Start and Finish are always nonsingular iterators. NOTE: this means - * that an empty deque must have one node, and that a deque - * with N elements, where N is the buffer size, must have two nodes. - * For every node other than start.node and finish.node, every element - * in the node is an initialized object. If start.node == finish.node, - * then [start.cur, finish.cur) are initialized objects, and - * the elements outside that range are uninitialized storage. Otherwise, - * [start.cur, start.last) and [finish.first, finish.cur) are initialized - * objects, and [start.first, start.cur) and [finish.cur, finish.last) - * are uninitialized storage. - * [map, map + map_size) is a valid, non-empty range. - * [start.node, finish.node] is a valid range contained within - * [map, map + map_size). - * A pointer in the range [map, map + map_size) points to an allocated node - * if and only if the pointer is in the range [start.node, finish.node]. - */ - - -/* - * In previous versions of deque, there was an extra template - * parameter so users could control the node size. This extension - * turns out to violate the C++ standard (it can be detected using - * template template parameters), and it has been removed. - */ - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -// Note: this function is simply a kludge to work around several compilers' -// bugs in handling constant expressions. - -#ifdef __AVR__ -inline size_t __deque_buf_size(size_t __size) { - return __size < avrstl::AvrDequeBufferSize() ? size_t(avrstl::AvrDequeBufferSize() / __size) : size_t(1); -} -#else -inline size_t __deque_buf_size(size_t __size) { - return __size < 512 ? size_t(512 / __size) : size_t(1); -} -#endif - -template -struct _Deque_iterator { - typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator; - typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator; - static size_t _S_buffer_size() { return __deque_buf_size(sizeof(_Tp)); } - - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Ptr pointer; - typedef _Ref reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Tp** _Map_pointer; - - typedef _Deque_iterator _Self; - - _Tp* _M_cur; - _Tp* _M_first; - _Tp* _M_last; - _Map_pointer _M_node; - - _Deque_iterator(_Tp* __x, _Map_pointer __y) - : _M_cur(__x), _M_first(*__y), - _M_last(*__y + _S_buffer_size()), _M_node(__y) {} - _Deque_iterator() : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) {} - _Deque_iterator(const iterator& __x) - : _M_cur(__x._M_cur), _M_first(__x._M_first), - _M_last(__x._M_last), _M_node(__x._M_node) {} - - reference operator*() const { return *_M_cur; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return _M_cur; } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - - difference_type operator-(const _Self& __x) const { - return difference_type(_S_buffer_size()) * (_M_node - __x._M_node - 1) + - (_M_cur - _M_first) + (__x._M_last - __x._M_cur); - } - - _Self& operator++() { - ++_M_cur; - if (_M_cur == _M_last) { - _M_set_node(_M_node + 1); - _M_cur = _M_first; - } - return *this; - } - _Self operator++(int) { - _Self __tmp = *this; - ++*this; - return __tmp; - } - - _Self& operator--() { - if (_M_cur == _M_first) { - _M_set_node(_M_node - 1); - _M_cur = _M_last; - } - --_M_cur; - return *this; - } - _Self operator--(int) { - _Self __tmp = *this; - --*this; - return __tmp; - } - - _Self& operator+=(difference_type __n) - { - difference_type __offset = __n + (_M_cur - _M_first); - if (__offset >= 0 && __offset < difference_type(_S_buffer_size())) - _M_cur += __n; - else { - difference_type __node_offset = - __offset > 0 ? __offset / difference_type(_S_buffer_size()) - : -difference_type((-__offset - 1) / _S_buffer_size()) - 1; - _M_set_node(_M_node + __node_offset); - _M_cur = _M_first + - (__offset - __node_offset * difference_type(_S_buffer_size())); - } - return *this; - } - - _Self operator+(difference_type __n) const - { - _Self __tmp = *this; - return __tmp += __n; - } - - _Self& operator-=(difference_type __n) { return *this += -__n; } - - _Self operator-(difference_type __n) const { - _Self __tmp = *this; - return __tmp -= __n; - } - - reference operator[](difference_type __n) const { return *(*this + __n); } - - bool operator==(const _Self& __x) const { return _M_cur == __x._M_cur; } - bool operator!=(const _Self& __x) const { return !(*this == __x); } - bool operator<(const _Self& __x) const { - return (_M_node == __x._M_node) ? - (_M_cur < __x._M_cur) : (_M_node < __x._M_node); - } - bool operator>(const _Self& __x) const { return __x < *this; } - bool operator<=(const _Self& __x) const { return !(__x < *this); } - bool operator>=(const _Self& __x) const { return !(*this < __x); } - - void _M_set_node(_Map_pointer __new_node) { - _M_node = __new_node; - _M_first = *__new_node; - _M_last = _M_first + difference_type(_S_buffer_size()); - } -}; - -template -inline _Deque_iterator<_Tp, _Ref, _Ptr> -operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x) -{ - return __x + __n; -} - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline random_access_iterator_tag -iterator_category(const _Deque_iterator<_Tp,_Ref,_Ptr>&) -{ - return random_access_iterator_tag(); -} - -template -inline _Tp* value_type(const _Deque_iterator<_Tp,_Ref,_Ptr>&) { return 0; } - -template -inline ptrdiff_t* distance_type(const _Deque_iterator<_Tp,_Ref,_Ptr>&) { - return 0; -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// Deque base class. It has two purposes. First, its constructor -// and destructor allocate (but don't initialize) storage. This makes -// exception safety easier. Second, the base class encapsulates all of -// the differences between SGI-style allocators and standard-conforming -// allocators. - -#ifdef __STL_USE_STD_ALLOCATORS - -// Base class for ordinary allocators. -template -class _Deque_alloc_base { -public: - typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type; - allocator_type get_allocator() const { return _M_node_allocator; } - - _Deque_alloc_base(const allocator_type& __a) - : _M_node_allocator(__a), _M_map_allocator(__a), - _M_map(0), _M_map_size(0) - {} - -protected: - typedef typename _Alloc_traits<_Tp*, _Alloc>::allocator_type - _Map_allocator_type; - - allocator_type _M_node_allocator; - _Map_allocator_type _M_map_allocator; - - _Tp* _M_allocate_node() { - return _M_node_allocator.allocate(__deque_buf_size(sizeof(_Tp))); - } - void _M_deallocate_node(_Tp* __p) { - _M_node_allocator.deallocate(__p, __deque_buf_size(sizeof(_Tp))); - } - _Tp** _M_allocate_map(size_t __n) - { return _M_map_allocator.allocate(__n); } - void _M_deallocate_map(_Tp** __p, size_t __n) - { _M_map_allocator.deallocate(__p, __n); } - - _Tp** _M_map; - size_t _M_map_size; -}; - -// Specialization for instanceless allocators. -template -class _Deque_alloc_base<_Tp, _Alloc, true> -{ -public: - typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Deque_alloc_base(const allocator_type&) : _M_map(0), _M_map_size(0) {} - -protected: - typedef typename _Alloc_traits<_Tp, _Alloc>::_Alloc_type _Node_alloc_type; - typedef typename _Alloc_traits<_Tp*, _Alloc>::_Alloc_type _Map_alloc_type; - - _Tp* _M_allocate_node() { - return _Node_alloc_type::allocate(__deque_buf_size(sizeof(_Tp))); - } - void _M_deallocate_node(_Tp* __p) { - _Node_alloc_type::deallocate(__p, __deque_buf_size(sizeof(_Tp))); - } - _Tp** _M_allocate_map(size_t __n) - { return _Map_alloc_type::allocate(__n); } - void _M_deallocate_map(_Tp** __p, size_t __n) - { _Map_alloc_type::deallocate(__p, __n); } - - _Tp** _M_map; - size_t _M_map_size; -}; - -template -class _Deque_base - : public _Deque_alloc_base<_Tp,_Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> -{ -public: - typedef _Deque_alloc_base<_Tp,_Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> - _Base; - typedef typename _Base::allocator_type allocator_type; - typedef _Deque_iterator<_Tp,_Tp&,_Tp*> iterator; - typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator; - - _Deque_base(const allocator_type& __a, size_t __num_elements) - : _Base(__a), _M_start(), _M_finish() - { _M_initialize_map(__num_elements); } - _Deque_base(const allocator_type& __a) - : _Base(__a), _M_start(), _M_finish() {} - ~_Deque_base(); - -protected: - void _M_initialize_map(size_t); - void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish); - void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish); - enum { _S_initial_map_size = 8 }; - -protected: - iterator _M_start; - iterator _M_finish; -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -class _Deque_base { -public: - typedef _Deque_iterator<_Tp,_Tp&,_Tp*> iterator; - typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator; - - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Deque_base(const allocator_type&, size_t __num_elements) - : _M_map(0), _M_map_size(0), _M_start(), _M_finish() { - _M_initialize_map(__num_elements); - } - _Deque_base(const allocator_type&) - : _M_map(0), _M_map_size(0), _M_start(), _M_finish() {} - ~_Deque_base(); - -protected: - void _M_initialize_map(size_t); - void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish); - void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish); - enum { _S_initial_map_size = 8 }; - -protected: - _Tp** _M_map; - size_t _M_map_size; - iterator _M_start; - iterator _M_finish; - - typedef simple_alloc<_Tp, _Alloc> _Node_alloc_type; - typedef simple_alloc<_Tp*, _Alloc> _Map_alloc_type; - - _Tp* _M_allocate_node() - { return _Node_alloc_type::allocate(__deque_buf_size(sizeof(_Tp))); } - void _M_deallocate_node(_Tp* __p) - { _Node_alloc_type::deallocate(__p, __deque_buf_size(sizeof(_Tp))); } - _Tp** _M_allocate_map(size_t __n) - { return _Map_alloc_type::allocate(__n); } - void _M_deallocate_map(_Tp** __p, size_t __n) - { _Map_alloc_type::deallocate(__p, __n); } -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -// Non-inline member functions from _Deque_base. - -template -_Deque_base<_Tp,_Alloc>::~_Deque_base() { - if (_Base::_M_map) { - _M_destroy_nodes(_M_start._M_node, _M_finish._M_node + 1); - _M_deallocate_map(_Base::_M_map, _Base::_M_map_size); - } -} - -template -void -_Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements) -{ - size_t __num_nodes = - __num_elements / __deque_buf_size(sizeof(_Tp)) + 1; - - _Base::_M_map_size = max((size_t) _S_initial_map_size, __num_nodes + 2); - _Base::_M_map = _M_allocate_map(_Base::_M_map_size); - - _Tp** __nstart = _Base::_M_map + (_Base::_M_map_size - __num_nodes) / 2; - _Tp** __nfinish = __nstart + __num_nodes; - - __STL_TRY { - _M_create_nodes(__nstart, __nfinish); - } - __STL_UNWIND((_M_deallocate_map(_M_map, _M_map_size), - _M_map = 0, _M_map_size = 0)); - _M_start._M_set_node(__nstart); - _M_finish._M_set_node(__nfinish - 1); - _M_start._M_cur = _M_start._M_first; - _M_finish._M_cur = _M_finish._M_first + - __num_elements % __deque_buf_size(sizeof(_Tp)); -} - -template -void _Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart, _Tp** __nfinish) -{ - _Tp** __cur; - __STL_TRY { - for (__cur = __nstart; __cur < __nfinish; ++__cur) - *__cur = _Base::_M_allocate_node(); - } - __STL_UNWIND(_M_destroy_nodes(__nstart, __cur)); -} - -template -void -_Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish) -{ - for (_Tp** __n = __nstart; __n < __nfinish; ++__n) - _M_deallocate_node(*__n); -} - -template -class deque : protected _Deque_base<_Tp, _Alloc> { - - // requirements: - - __STL_CLASS_REQUIRES(_Tp, _Assignable); - - typedef _Deque_base<_Tp, _Alloc> _Base; -public: // Basic types - typedef _Tp value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - typedef typename _Base::allocator_type allocator_type; - allocator_type get_allocator() const { return _Base::get_allocator(); } - -public: // Iterators - typedef typename _Base::iterator iterator; - typedef typename _Base::const_iterator const_iterator; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef reverse_iterator - const_reverse_iterator; - typedef reverse_iterator - reverse_iterator; -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -protected: // Internal typedefs - typedef pointer* _Map_pointer; - static size_t _S_buffer_size() { return __deque_buf_size(sizeof(_Tp)); } - -protected: -#ifdef __STL_USE_NAMESPACES - using _Base::_M_initialize_map; - using _Base::_M_create_nodes; - using _Base::_M_destroy_nodes; - using _Base::_M_allocate_node; - using _Base::_M_deallocate_node; - using _Base::_M_allocate_map; - using _Base::_M_deallocate_map; - - using _Base::_M_map; - using _Base::_M_map_size; - using _Base::_M_start; - using _Base::_M_finish; -#endif /* __STL_USE_NAMESPACES */ - -public: // Basic accessors - iterator begin() { return _M_start; } - iterator end() { return _M_finish; } - const_iterator begin() const { return _M_start; } - const_iterator end() const { return _M_finish; } - - reverse_iterator rbegin() { return reverse_iterator(_M_finish); } - reverse_iterator rend() { return reverse_iterator(_M_start); } - const_reverse_iterator rbegin() const - { return const_reverse_iterator(_M_finish); } - const_reverse_iterator rend() const - { return const_reverse_iterator(_M_start); } - - reference operator[](size_type __n) - { return _M_start[difference_type(__n)]; } - const_reference operator[](size_type __n) const - { return _M_start[difference_type(__n)]; } - -#ifdef __STL_THROW_RANGE_ERRORS - void _M_range_check(size_type __n) const { - if (__n >= this->size()) - __stl_throw_range_error("deque"); - } - - reference at(size_type __n) - { _M_range_check(__n); return (*this)[__n]; } - const_reference at(size_type __n) const - { _M_range_check(__n); return (*this)[__n]; } -#endif /* __STL_THROW_RANGE_ERRORS */ - - reference front() { return *_M_start; } - reference back() { - iterator __tmp = _M_finish; - --__tmp; - return *__tmp; - } - const_reference front() const { return *_M_start; } - const_reference back() const { - const_iterator __tmp = _M_finish; - --__tmp; - return *__tmp; - } - - size_type size() const { return _M_finish - _M_start; } - size_type max_size() const { return size_type(-1); } - bool empty() const { return _M_finish == _M_start; } - -public: // Constructor, destructor. - explicit deque(const allocator_type& __a = allocator_type()) - : _Base(__a, 0) {} - deque(const deque& __x) : _Base(__x.get_allocator(), __x.size()) - { uninitialized_copy(__x.begin(), __x.end(), _M_start); } - deque(size_type __n, const value_type& __value, - const allocator_type& __a = allocator_type()) : _Base(__a, __n) - { _M_fill_initialize(__value); } - explicit deque(size_type __n) : _Base(allocator_type(), __n) - { _M_fill_initialize(value_type()); } - -#ifdef __STL_MEMBER_TEMPLATES - - // Check whether it's an integral type. If so, it's not an iterator. - template - deque(_InputIterator __first, _InputIterator __last, - const allocator_type& __a = allocator_type()) : _Base(__a) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_initialize_dispatch(__first, __last, _Integral()); - } - - template - void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) { - _M_initialize_map(__n); - _M_fill_initialize(__x); - } - - template - void _M_initialize_dispatch(_InputIter __first, _InputIter __last, - __false_type) { - _M_range_initialize(__first, __last, __ITERATOR_CATEGORY(__first)); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - deque(const value_type* __first, const value_type* __last, - const allocator_type& __a = allocator_type()) - : _Base(__a, __last - __first) - { uninitialized_copy(__first, __last, _M_start); } - deque(const_iterator __first, const_iterator __last, - const allocator_type& __a = allocator_type()) - : _Base(__a, __last - __first) - { uninitialized_copy(__first, __last, _M_start); } - -#endif /* __STL_MEMBER_TEMPLATES */ - - ~deque() { destroy(_M_start, _M_finish); } - - deque& operator= (const deque& __x) { - const size_type __len = size(); - if (&__x != this) { - if (__len >= __x.size()) - erase(copy(__x.begin(), __x.end(), _M_start), _M_finish); - else { - const_iterator __mid = __x.begin() + difference_type(__len); - copy(__x.begin(), __mid, _M_start); - insert(_M_finish, __mid, __x.end()); - } - } - return *this; - } - - void swap(deque& __x) { - __STD::swap(_M_start, __x._M_start); - __STD::swap(_M_finish, __x._M_finish); - __STD::swap(_M_map, __x._M_map); - __STD::swap(_M_map_size, __x._M_map_size); - } - -public: - // assign(), a generalized assignment member function. Two - // versions: one that takes a count, and one that takes a range. - // The range version is a member template, so we dispatch on whether - // or not the type is an integer. - - void _M_fill_assign(size_type __n, const _Tp& __val) { - if (__n > size()) { - fill(begin(), end(), __val); - insert(end(), __n - size(), __val); - } - else { - erase(begin() + __n, end()); - fill(begin(), end(), __val); - } - } - - void assign(size_type __n, const _Tp& __val) { - _M_fill_assign(__n, __val); - } - -#ifdef __STL_MEMBER_TEMPLATES - - template - void assign(_InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_assign_dispatch(__first, __last, _Integral()); - } - -private: // helper functions for assign() - - template - void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { _M_fill_assign((size_type) __n, (_Tp) __val); } - - template - void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, - __false_type) { - _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first)); - } - - template - void _M_assign_aux(_InputIterator __first, _InputIterator __last, - input_iterator_tag); - - template - void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) { - size_type __len = 0; - distance(__first, __last, __len); - if (__len > size()) { - _ForwardIterator __mid = __first; - advance(__mid, size()); - copy(__first, __mid, begin()); - insert(end(), __mid, __last); - } - else - erase(copy(__first, __last, begin()), end()); - } - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: // push_* and pop_* - - void push_back(const value_type& __t) { - if (_M_finish._M_cur != _M_finish._M_last - 1) { - construct(_M_finish._M_cur, __t); - ++_M_finish._M_cur; - } - else - _M_push_back_aux(__t); - } - - void push_back() { - if (_M_finish._M_cur != _M_finish._M_last - 1) { - construct(_M_finish._M_cur); - ++_M_finish._M_cur; - } - else - _M_push_back_aux(); - } - - void push_front(const value_type& __t) { - if (_M_start._M_cur != _M_start._M_first) { - construct(_M_start._M_cur - 1, __t); - --_M_start._M_cur; - } - else - _M_push_front_aux(__t); - } - - void push_front() { - if (_M_start._M_cur != _M_start._M_first) { - construct(_M_start._M_cur - 1); - --_M_start._M_cur; - } - else - _M_push_front_aux(); - } - - - void pop_back() { - if (_M_finish._M_cur != _M_finish._M_first) { - --_M_finish._M_cur; - destroy(_M_finish._M_cur); - } - else - _M_pop_back_aux(); - } - - void pop_front() { - if (_M_start._M_cur != _M_start._M_last - 1) { - destroy(_M_start._M_cur); - ++_M_start._M_cur; - } - else - _M_pop_front_aux(); - } - -public: // Insert - - iterator insert(iterator position, const value_type& __x) { - if (position._M_cur == _M_start._M_cur) { - push_front(__x); - return _M_start; - } - else if (position._M_cur == _M_finish._M_cur) { - push_back(__x); - iterator __tmp = _M_finish; - --__tmp; - return __tmp; - } - else { - return _M_insert_aux(position, __x); - } - } - - iterator insert(iterator __position) - { return insert(__position, value_type()); } - - void insert(iterator __pos, size_type __n, const value_type& __x) - { _M_fill_insert(__pos, __n, __x); } - - void _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); - -#ifdef __STL_MEMBER_TEMPLATES - - // Check whether it's an integral type. If so, it's not an iterator. - template - void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_insert_dispatch(__pos, __first, __last, _Integral()); - } - - template - void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, - __true_type) { - _M_fill_insert(__pos, (size_type) __n, (value_type) __x); - } - - template - void _M_insert_dispatch(iterator __pos, - _InputIterator __first, _InputIterator __last, - __false_type) { - insert(__pos, __first, __last, __ITERATOR_CATEGORY(__first)); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - void insert(iterator __pos, - const value_type* __first, const value_type* __last); - void insert(iterator __pos, - const_iterator __first, const_iterator __last); - -#endif /* __STL_MEMBER_TEMPLATES */ - - void resize(size_type __new_size, const value_type& __x) { - const size_type __len = size(); - if (__new_size < __len) - erase(_M_start + __new_size, _M_finish); - else - insert(_M_finish, __new_size - __len, __x); - } - - void resize(size_type new_size) { resize(new_size, value_type()); } - -public: // Erase - iterator erase(iterator __pos) { - iterator __next = __pos; - ++__next; - difference_type __index = __pos - _M_start; - if (size_type(__index) < (this->size() >> 1)) { - copy_backward(_M_start, __pos, __next); - pop_front(); - } - else { - copy(__next, _M_finish, __pos); - pop_back(); - } - return _M_start + __index; - } - - iterator erase(iterator __first, iterator __last); - void clear(); - -protected: // Internal construction/destruction - - void _M_fill_initialize(const value_type& __value); - -#ifdef __STL_MEMBER_TEMPLATES - - template - void _M_range_initialize(_InputIterator __first, _InputIterator __last, - input_iterator_tag); - - template - void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag); - -#endif /* __STL_MEMBER_TEMPLATES */ - -protected: // Internal push_* and pop_* - - void _M_push_back_aux(const value_type&); - void _M_push_back_aux(); - void _M_push_front_aux(const value_type&); - void _M_push_front_aux(); - void _M_pop_back_aux(); - void _M_pop_front_aux(); - -protected: // Internal insert functions - -#ifdef __STL_MEMBER_TEMPLATES - - template - void insert(iterator __pos, _InputIterator __first, _InputIterator __last, - input_iterator_tag); - - template - void insert(iterator __pos, - _ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag); - -#endif /* __STL_MEMBER_TEMPLATES */ - - iterator _M_insert_aux(iterator __pos, const value_type& __x); - iterator _M_insert_aux(iterator __pos); - void _M_insert_aux(iterator __pos, size_type __n, const value_type& __x); - -#ifdef __STL_MEMBER_TEMPLATES - - template - void _M_insert_aux(iterator __pos, - _ForwardIterator __first, _ForwardIterator __last, - size_type __n); - -#else /* __STL_MEMBER_TEMPLATES */ - - void _M_insert_aux(iterator __pos, - const value_type* __first, const value_type* __last, - size_type __n); - - void _M_insert_aux(iterator __pos, - const_iterator __first, const_iterator __last, - size_type __n); - -#endif /* __STL_MEMBER_TEMPLATES */ - - iterator _M_reserve_elements_at_front(size_type __n) { - size_type __vacancies = _M_start._M_cur - _M_start._M_first; - if (__n > __vacancies) - _M_new_elements_at_front(__n - __vacancies); - return _M_start - difference_type(__n); - } - - iterator _M_reserve_elements_at_back(size_type __n) { - size_type __vacancies = (_M_finish._M_last - _M_finish._M_cur) - 1; - if (__n > __vacancies) - _M_new_elements_at_back(__n - __vacancies); - return _M_finish + difference_type(__n); - } - - void _M_new_elements_at_front(size_type __new_elements); - void _M_new_elements_at_back(size_type __new_elements); - -protected: // Allocation of _M_map and nodes - - // Makes sure the _M_map has space for new nodes. Does not actually - // add the nodes. Can invalidate _M_map pointers. (And consequently, - // deque iterators.) - - void _M_reserve_map_at_back (size_type __nodes_to_add = 1) { - if (__nodes_to_add + 1 > _M_map_size - (_M_finish._M_node - _M_map)) - _M_reallocate_map(__nodes_to_add, false); - } - - void _M_reserve_map_at_front (size_type __nodes_to_add = 1) { - if (__nodes_to_add > size_type(_M_start._M_node - _M_map)) - _M_reallocate_map(__nodes_to_add, true); - } - - void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front); -}; - -// Non-inline member functions - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -void deque<_Tp, _Alloc> - ::_M_assign_aux(_InputIter __first, _InputIter __last, input_iterator_tag) -{ - iterator __cur = begin(); - for ( ; __first != __last && __cur != end(); ++__cur, ++__first) - *__cur = *__first; - if (__first == __last) - erase(__cur, end()); - else - insert(end(), __first, __last); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -void deque<_Tp, _Alloc>::_M_fill_insert(iterator __pos, - size_type __n, const value_type& __x) -{ - if (__pos._M_cur == _M_start._M_cur) { - iterator __new_start = _M_reserve_elements_at_front(__n); - __STL_TRY { - uninitialized_fill(__new_start, _M_start, __x); - _M_start = __new_start; - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else if (__pos._M_cur == _M_finish._M_cur) { - iterator __new_finish = _M_reserve_elements_at_back(__n); - __STL_TRY { - uninitialized_fill(_M_finish, __new_finish, __x); - _M_finish = __new_finish; - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } - else - _M_insert_aux(__pos, __n, __x); -} - -#ifndef __STL_MEMBER_TEMPLATES - -template -void deque<_Tp, _Alloc>::insert(iterator __pos, - const value_type* __first, - const value_type* __last) { - size_type __n = __last - __first; - if (__pos._M_cur == _M_start._M_cur) { - iterator __new_start = _M_reserve_elements_at_front(__n); - __STL_TRY { - uninitialized_copy(__first, __last, __new_start); - _M_start = __new_start; - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else if (__pos._M_cur == _M_finish._M_cur) { - iterator __new_finish = _M_reserve_elements_at_back(__n); - __STL_TRY { - uninitialized_copy(__first, __last, _M_finish); - _M_finish = __new_finish; - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } - else - _M_insert_aux(__pos, __first, __last, __n); -} - -template -void deque<_Tp,_Alloc>::insert(iterator __pos, - const_iterator __first, const_iterator __last) -{ - size_type __n = __last - __first; - if (__pos._M_cur == _M_start._M_cur) { - iterator __new_start = _M_reserve_elements_at_front(__n); - __STL_TRY { - uninitialized_copy(__first, __last, __new_start); - _M_start = __new_start; - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else if (__pos._M_cur == _M_finish._M_cur) { - iterator __new_finish = _M_reserve_elements_at_back(__n); - __STL_TRY { - uninitialized_copy(__first, __last, _M_finish); - _M_finish = __new_finish; - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } - else - _M_insert_aux(__pos, __first, __last, __n); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -typename deque<_Tp,_Alloc>::iterator -deque<_Tp,_Alloc>::erase(iterator __first, iterator __last) -{ - if (__first == _M_start && __last == _M_finish) { - clear(); - return _M_finish; - } - else { - difference_type __n = __last - __first; - difference_type __elems_before = __first - _M_start; - if (__elems_before < difference_type((this->size() - __n) / 2)) { - copy_backward(_M_start, __first, __last); - iterator __new_start = _M_start + __n; - destroy(_M_start, __new_start); - _M_destroy_nodes(__new_start._M_node, _M_start._M_node); - _M_start = __new_start; - } - else { - copy(__last, _M_finish, __first); - iterator __new_finish = _M_finish - __n; - destroy(__new_finish, _M_finish); - _M_destroy_nodes(__new_finish._M_node + 1, _M_finish._M_node + 1); - _M_finish = __new_finish; - } - return _M_start + __elems_before; - } -} - -template -void deque<_Tp,_Alloc>::clear() -{ - for (_Map_pointer __node = _M_start._M_node + 1; - __node < _M_finish._M_node; - ++__node) { - destroy(*__node, *__node + _S_buffer_size()); - _M_deallocate_node(*__node); - } - - if (_M_start._M_node != _M_finish._M_node) { - destroy(_M_start._M_cur, _M_start._M_last); - destroy(_M_finish._M_first, _M_finish._M_cur); - _M_deallocate_node(_M_finish._M_first); - } - else - destroy(_M_start._M_cur, _M_finish._M_cur); - - _M_finish = _M_start; -} - -// Precondition: _M_start and _M_finish have already been initialized, -// but none of the deque's elements have yet been constructed. -template -void deque<_Tp,_Alloc>::_M_fill_initialize(const value_type& __value) { - _Map_pointer __cur; - __STL_TRY { - for (__cur = _M_start._M_node; __cur < _M_finish._M_node; ++__cur) - uninitialized_fill(*__cur, *__cur + _S_buffer_size(), __value); - uninitialized_fill(_M_finish._M_first, _M_finish._M_cur, __value); - } - __STL_UNWIND(destroy(_M_start, iterator(*__cur, __cur))); -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -void deque<_Tp,_Alloc>::_M_range_initialize(_InputIterator __first, - _InputIterator __last, - input_iterator_tag) -{ - _M_initialize_map(0); - __STL_TRY { - for ( ; __first != __last; ++__first) - push_back(*__first); - } - __STL_UNWIND(clear()); -} - -template template -void deque<_Tp,_Alloc>::_M_range_initialize(_ForwardIterator __first, - _ForwardIterator __last, - forward_iterator_tag) -{ - size_type __n = 0; - distance(__first, __last, __n); - _M_initialize_map(__n); - - _Map_pointer __cur_node; - __STL_TRY { - for (__cur_node = _M_start._M_node; - __cur_node < _M_finish._M_node; - ++__cur_node) { - _ForwardIterator __mid = __first; - advance(__mid, _S_buffer_size()); - uninitialized_copy(__first, __mid, *__cur_node); - __first = __mid; - } - uninitialized_copy(__first, __last, _M_finish._M_first); - } - __STL_UNWIND(destroy(_M_start, iterator(*__cur_node, __cur_node))); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -// Called only if _M_finish._M_cur == _M_finish._M_last - 1. -template -void deque<_Tp,_Alloc>::_M_push_back_aux(const value_type& __t) -{ - value_type __t_copy = __t; - _M_reserve_map_at_back(); - *(_M_finish._M_node + 1) = _M_allocate_node(); - __STL_TRY { - construct(_M_finish._M_cur, __t_copy); - _M_finish._M_set_node(_M_finish._M_node + 1); - _M_finish._M_cur = _M_finish._M_first; - } - __STL_UNWIND(_M_deallocate_node(*(_M_finish._M_node + 1))); -} - -// Called only if _M_finish._M_cur == _M_finish._M_last - 1. -template -void deque<_Tp,_Alloc>::_M_push_back_aux() -{ - _M_reserve_map_at_back(); - *(_M_finish._M_node + 1) = _M_allocate_node(); - __STL_TRY { - construct(_M_finish._M_cur); - _M_finish._M_set_node(_M_finish._M_node + 1); - _M_finish._M_cur = _M_finish._M_first; - } - __STL_UNWIND(_M_deallocate_node(*(_M_finish._M_node + 1))); -} - -// Called only if _M_start._M_cur == _M_start._M_first. -template -void deque<_Tp,_Alloc>::_M_push_front_aux(const value_type& __t) -{ - value_type __t_copy = __t; - _M_reserve_map_at_front(); - *(_M_start._M_node - 1) = _M_allocate_node(); - __STL_TRY { - _M_start._M_set_node(_M_start._M_node - 1); - _M_start._M_cur = _M_start._M_last - 1; - construct(_M_start._M_cur, __t_copy); - } - __STL_UNWIND((++_M_start, _M_deallocate_node(*(_M_start._M_node - 1)))); -} - -// Called only if _M_start._M_cur == _M_start._M_first. -template -void deque<_Tp,_Alloc>::_M_push_front_aux() -{ - _M_reserve_map_at_front(); - *(_M_start._M_node - 1) = _M_allocate_node(); - __STL_TRY { - _M_start._M_set_node(_M_start._M_node - 1); - _M_start._M_cur = _M_start._M_last - 1; - construct(_M_start._M_cur); - } - __STL_UNWIND((++_M_start, _M_deallocate_node(*(_M_start._M_node - 1)))); -} - -// Called only if _M_finish._M_cur == _M_finish._M_first. -template -void deque<_Tp,_Alloc>::_M_pop_back_aux() -{ - _M_deallocate_node(_M_finish._M_first); - _M_finish._M_set_node(_M_finish._M_node - 1); - _M_finish._M_cur = _M_finish._M_last - 1; - destroy(_M_finish._M_cur); -} - -// Called only if _M_start._M_cur == _M_start._M_last - 1. Note that -// if the deque has at least one element (a precondition for this member -// function), and if _M_start._M_cur == _M_start._M_last, then the deque -// must have at least two nodes. -template -void deque<_Tp,_Alloc>::_M_pop_front_aux() -{ - destroy(_M_start._M_cur); - _M_deallocate_node(_M_start._M_first); - _M_start._M_set_node(_M_start._M_node + 1); - _M_start._M_cur = _M_start._M_first; -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -void deque<_Tp,_Alloc>::insert(iterator __pos, - _InputIterator __first, _InputIterator __last, - input_iterator_tag) -{ - copy(__first, __last, inserter(*this, __pos)); -} - -template template -void -deque<_Tp,_Alloc>::insert(iterator __pos, - _ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) { - size_type __n = 0; - distance(__first, __last, __n); - if (__pos._M_cur == _M_start._M_cur) { - iterator __new_start = _M_reserve_elements_at_front(__n); - __STL_TRY { - uninitialized_copy(__first, __last, __new_start); - _M_start = __new_start; - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else if (__pos._M_cur == _M_finish._M_cur) { - iterator __new_finish = _M_reserve_elements_at_back(__n); - __STL_TRY { - uninitialized_copy(__first, __last, _M_finish); - _M_finish = __new_finish; - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } - else - _M_insert_aux(__pos, __first, __last, __n); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -typename deque<_Tp, _Alloc>::iterator -deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos, const value_type& __x) -{ - difference_type __index = __pos - _M_start; - value_type __x_copy = __x; - if (size_type(__index) < this->size() / 2) { - push_front(front()); - iterator __front1 = _M_start; - ++__front1; - iterator __front2 = __front1; - ++__front2; - __pos = _M_start + __index; - iterator __pos1 = __pos; - ++__pos1; - copy(__front2, __pos1, __front1); - } - else { - push_back(back()); - iterator __back1 = _M_finish; - --__back1; - iterator __back2 = __back1; - --__back2; - __pos = _M_start + __index; - copy_backward(__pos, __back2, __back1); - } - *__pos = __x_copy; - return __pos; -} - -template -typename deque<_Tp,_Alloc>::iterator -deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos) -{ - difference_type __index = __pos - _M_start; - if (__index < size() / 2) { - push_front(front()); - iterator __front1 = _M_start; - ++__front1; - iterator __front2 = __front1; - ++__front2; - __pos = _M_start + __index; - iterator __pos1 = __pos; - ++__pos1; - copy(__front2, __pos1, __front1); - } - else { - push_back(back()); - iterator __back1 = _M_finish; - --__back1; - iterator __back2 = __back1; - --__back2; - __pos = _M_start + __index; - copy_backward(__pos, __back2, __back1); - } - *__pos = value_type(); - return __pos; -} - -template -void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos, - size_type __n, - const value_type& __x) -{ - const difference_type __elems_before = __pos - _M_start; - size_type __length = this->size(); - value_type __x_copy = __x; - if (__elems_before < difference_type(__length / 2)) { - iterator __new_start = _M_reserve_elements_at_front(__n); - iterator __old_start = _M_start; - __pos = _M_start + __elems_before; - __STL_TRY { - if (__elems_before >= difference_type(__n)) { - iterator __start_n = _M_start + difference_type(__n); - uninitialized_copy(_M_start, __start_n, __new_start); - _M_start = __new_start; - copy(__start_n, __pos, __old_start); - fill(__pos - difference_type(__n), __pos, __x_copy); - } - else { - __uninitialized_copy_fill(_M_start, __pos, __new_start, - _M_start, __x_copy); - _M_start = __new_start; - fill(__old_start, __pos, __x_copy); - } - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else { - iterator __new_finish = _M_reserve_elements_at_back(__n); - iterator __old_finish = _M_finish; - const difference_type __elems_after = - difference_type(__length) - __elems_before; - __pos = _M_finish - __elems_after; - __STL_TRY { - if (__elems_after > difference_type(__n)) { - iterator __finish_n = _M_finish - difference_type(__n); - uninitialized_copy(__finish_n, _M_finish, _M_finish); - _M_finish = __new_finish; - copy_backward(__pos, __finish_n, __old_finish); - fill(__pos, __pos + difference_type(__n), __x_copy); - } - else { - __uninitialized_fill_copy(_M_finish, __pos + difference_type(__n), - __x_copy, __pos, _M_finish); - _M_finish = __new_finish; - fill(__pos, __old_finish, __x_copy); - } - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos, - _ForwardIterator __first, - _ForwardIterator __last, - size_type __n) -{ - const difference_type __elemsbefore = __pos - _M_start; - size_type __length = size(); - -#ifdef __AVR__ - if ((unsigned long)__elemsbefore < __length / 2) { // ptrdiff_t = signed on AVR (long int) -#else - if (__elemsbefore < __length / 2) { -#endif - iterator __new_start = _M_reserve_elements_at_front(__n); - iterator __old_start = _M_start; - __pos = _M_start + __elemsbefore; - __STL_TRY { - if (__elemsbefore >= difference_type(__n)) { - iterator __start_n = _M_start + difference_type(__n); - uninitialized_copy(_M_start, __start_n, __new_start); - _M_start = __new_start; - copy(__start_n, __pos, __old_start); - copy(__first, __last, __pos - difference_type(__n)); - } - else { - _ForwardIterator __mid = __first; - advance(__mid, difference_type(__n) - __elemsbefore); - __uninitialized_copy_copy(_M_start, __pos, __first, __mid, - __new_start); - _M_start = __new_start; - copy(__mid, __last, __old_start); - } - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else { - iterator __new_finish = _M_reserve_elements_at_back(__n); - iterator __old_finish = _M_finish; - const difference_type __elemsafter = - difference_type(__length) - __elemsbefore; - __pos = _M_finish - __elemsafter; - __STL_TRY { - if (__elemsafter > difference_type(__n)) { - iterator __finish_n = _M_finish - difference_type(__n); - uninitialized_copy(__finish_n, _M_finish, _M_finish); - _M_finish = __new_finish; - copy_backward(__pos, __finish_n, __old_finish); - copy(__first, __last, __pos); - } - else { - _ForwardIterator __mid = __first; - advance(__mid, __elemsafter); - __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish); - _M_finish = __new_finish; - copy(__first, __mid, __pos); - } - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos, - const value_type* __first, - const value_type* __last, - size_type __n) -{ - const difference_type __elemsbefore = __pos - _M_start; - size_type __length = size(); - if (__elemsbefore < __length / 2) { - iterator __new_start = _M_reserve_elements_at_front(__n); - iterator __old_start = _M_start; - __pos = _M_start + __elemsbefore; - __STL_TRY { - if (__elemsbefore >= difference_type(__n)) { - iterator __start_n = _M_start + difference_type(__n); - uninitialized_copy(_M_start, __start_n, __new_start); - _M_start = __new_start; - copy(__start_n, __pos, __old_start); - copy(__first, __last, __pos - difference_type(__n)); - } - else { - const value_type* __mid = - __first + (difference_type(__n) - __elemsbefore); - __uninitialized_copy_copy(_M_start, __pos, __first, __mid, - __new_start); - _M_start = __new_start; - copy(__mid, __last, __old_start); - } - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else { - iterator __new_finish = _M_reserve_elements_at_back(__n); - iterator __old_finish = _M_finish; - const difference_type __elemsafter = - difference_type(__length) - __elemsbefore; - __pos = _M_finish - __elemsafter; - __STL_TRY { - if (__elemsafter > difference_type(__n)) { - iterator __finish_n = _M_finish - difference_type(__n); - uninitialized_copy(__finish_n, _M_finish, _M_finish); - _M_finish = __new_finish; - copy_backward(__pos, __finish_n, __old_finish); - copy(__first, __last, __pos); - } - else { - const value_type* __mid = __first + __elemsafter; - __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish); - _M_finish = __new_finish; - copy(__first, __mid, __pos); - } - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } -} - -template -void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos, - const_iterator __first, - const_iterator __last, - size_type __n) -{ - const difference_type __elemsbefore = __pos - _M_start; - size_type __length = size(); - if (__elemsbefore < __length / 2) { - iterator __new_start = _M_reserve_elements_at_front(__n); - iterator __old_start = _M_start; - __pos = _M_start + __elemsbefore; - __STL_TRY { - if (__elemsbefore >= __n) { - iterator __start_n = _M_start + __n; - uninitialized_copy(_M_start, __start_n, __new_start); - _M_start = __new_start; - copy(__start_n, __pos, __old_start); - copy(__first, __last, __pos - difference_type(__n)); - } - else { - const_iterator __mid = __first + (__n - __elemsbefore); - __uninitialized_copy_copy(_M_start, __pos, __first, __mid, - __new_start); - _M_start = __new_start; - copy(__mid, __last, __old_start); - } - } - __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node)); - } - else { - iterator __new_finish = _M_reserve_elements_at_back(__n); - iterator __old_finish = _M_finish; - const difference_type __elemsafter = __length - __elemsbefore; - __pos = _M_finish - __elemsafter; - __STL_TRY { - if (__elemsafter > __n) { - iterator __finish_n = _M_finish - difference_type(__n); - uninitialized_copy(__finish_n, _M_finish, _M_finish); - _M_finish = __new_finish; - copy_backward(__pos, __finish_n, __old_finish); - copy(__first, __last, __pos); - } - else { - const_iterator __mid = __first + __elemsafter; - __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish); - _M_finish = __new_finish; - copy(__first, __mid, __pos); - } - } - __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, - __new_finish._M_node + 1)); - } -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -void deque<_Tp,_Alloc>::_M_new_elements_at_front(size_type __new_elems) -{ - size_type __new_nodes - = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size(); - _M_reserve_map_at_front(__new_nodes); - size_type __i; - __STL_TRY { - for (__i = 1; __i <= __new_nodes; ++__i) - *(_M_start._M_node - __i) = _M_allocate_node(); - } -# ifdef __STL_USE_EXCEPTIONS - catch(...) { - for (size_type __j = 1; __j < __i; ++__j) - _M_deallocate_node(*(_M_start._M_node - __j)); - throw; - } -# endif /* __STL_USE_EXCEPTIONS */ -} - -template -void deque<_Tp,_Alloc>::_M_new_elements_at_back(size_type __new_elems) -{ - size_type __new_nodes - = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size(); - _M_reserve_map_at_back(__new_nodes); - size_type __i; - __STL_TRY { - for (__i = 1; __i <= __new_nodes; ++__i) - *(_M_finish._M_node + __i) = _M_allocate_node(); - } -# ifdef __STL_USE_EXCEPTIONS - catch(...) { - for (size_type __j = 1; __j < __i; ++__j) - _M_deallocate_node(*(_M_finish._M_node + __j)); - throw; - } -# endif /* __STL_USE_EXCEPTIONS */ -} - -template -void deque<_Tp,_Alloc>::_M_reallocate_map(size_type __nodes_to_add, - bool __add_at_front) -{ - size_type __old_num_nodes = _M_finish._M_node - _M_start._M_node + 1; - size_type __new_num_nodes = __old_num_nodes + __nodes_to_add; - - _Map_pointer __new_nstart; - if (_M_map_size > 2 * __new_num_nodes) { - __new_nstart = _M_map + (_M_map_size - __new_num_nodes) / 2 - + (__add_at_front ? __nodes_to_add : 0); - if (__new_nstart < _M_start._M_node) - copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart); - else - copy_backward(_M_start._M_node, _M_finish._M_node + 1, - __new_nstart + __old_num_nodes); - } - else { - size_type __new_map_size = - _M_map_size + max(_M_map_size, __nodes_to_add) + 2; - - _Map_pointer __new_map = _M_allocate_map(__new_map_size); - __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2 - + (__add_at_front ? __nodes_to_add : 0); - copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart); - _M_deallocate_map(_M_map, _M_map_size); - - _M_map = __new_map; - _M_map_size = __new_map_size; - } - - _M_start._M_set_node(__new_nstart); - _M_finish._M_set_node(__new_nstart + __old_num_nodes - 1); -} - - -// Nonmember functions. - -template -inline bool operator==(const deque<_Tp, _Alloc>& __x, - const deque<_Tp, _Alloc>& __y) { - return __x.size() == __y.size() && - equal(__x.begin(), __x.end(), __y.begin()); -} - -template -inline bool operator<(const deque<_Tp, _Alloc>& __x, - const deque<_Tp, _Alloc>& __y) { - return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=(const deque<_Tp, _Alloc>& __x, - const deque<_Tp, _Alloc>& __y) { - return !(__x == __y); -} - -template -inline bool operator>(const deque<_Tp, _Alloc>& __x, - const deque<_Tp, _Alloc>& __y) { - return __y < __x; -} - -template -inline bool operator<=(const deque<_Tp, _Alloc>& __x, - const deque<_Tp, _Alloc>& __y) { - return !(__y < __x); -} -template -inline bool operator>=(const deque<_Tp, _Alloc>& __x, - const deque<_Tp, _Alloc>& __y) { - return !(__x < __y); -} - -template -inline void swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_DEQUE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_function.h b/DSTAT1/src/avr-stl/include/stl_function.h deleted file mode 100644 index 15fc4c8..0000000 --- a/DSTAT1/src/avr-stl/include/stl_function.h +++ /dev/null @@ -1,729 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_FUNCTION_H -#define __SGI_STL_INTERNAL_FUNCTION_H - -__STL_BEGIN_NAMESPACE - -template -struct unary_function { - typedef _Arg argument_type; - typedef _Result result_type; -}; - -template -struct binary_function { - typedef _Arg1 first_argument_type; - typedef _Arg2 second_argument_type; - typedef _Result result_type; -}; - -template -struct plus : public binary_function<_Tp,_Tp,_Tp> { - _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; } -}; - -template -struct minus : public binary_function<_Tp,_Tp,_Tp> { - _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; } -}; - -template -struct multiplies : public binary_function<_Tp,_Tp,_Tp> { - _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; } -}; - -template -struct divides : public binary_function<_Tp,_Tp,_Tp> { - _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; } -}; - -// identity_element (not part of the C++ standard). - -template inline _Tp identity_element(plus<_Tp>) { - return _Tp(0); -} -template inline _Tp identity_element(multiplies<_Tp>) { - return _Tp(1); -} - -template -struct modulus : public binary_function<_Tp,_Tp,_Tp> -{ - _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; } -}; - -template -struct negate : public unary_function<_Tp,_Tp> -{ - _Tp operator()(const _Tp& __x) const { return -__x; } -}; - -template -struct equal_to : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; } -}; - -template -struct not_equal_to : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x != __y; } -}; - -template -struct greater : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x > __y; } -}; - -template -struct less : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; } -}; - -template -struct greater_equal : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x >= __y; } -}; - -template -struct less_equal : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x <= __y; } -}; - -template -struct logical_and : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x && __y; } -}; - -template -struct logical_or : public binary_function<_Tp,_Tp,bool> -{ - bool operator()(const _Tp& __x, const _Tp& __y) const { return __x || __y; } -}; - -template -struct logical_not : public unary_function<_Tp,bool> -{ - bool operator()(const _Tp& __x) const { return !__x; } -}; - -template -class unary_negate - : public unary_function { -protected: - _Predicate _M_pred; -public: - explicit unary_negate(const _Predicate& __x) : _M_pred(__x) {} - bool operator()(const typename _Predicate::argument_type& __x) const { - return !_M_pred(__x); - } -}; - -template -inline unary_negate<_Predicate> -not1(const _Predicate& __pred) -{ - return unary_negate<_Predicate>(__pred); -} - -template -class binary_negate - : public binary_function { -protected: - _Predicate _M_pred; -public: - explicit binary_negate(const _Predicate& __x) : _M_pred(__x) {} - bool operator()(const typename _Predicate::first_argument_type& __x, - const typename _Predicate::second_argument_type& __y) const - { - return !_M_pred(__x, __y); - } -}; - -template -inline binary_negate<_Predicate> -not2(const _Predicate& __pred) -{ - return binary_negate<_Predicate>(__pred); -} - -template -class binder1st - : public unary_function { -protected: - _Operation op; - typename _Operation::first_argument_type value; -public: - binder1st(const _Operation& __x, - const typename _Operation::first_argument_type& __y) - : op(__x), value(__y) {} - typename _Operation::result_type - operator()(const typename _Operation::second_argument_type& __x) const { - return op(value, __x); - } -}; - -template -inline binder1st<_Operation> -bind1st(const _Operation& __fn, const _Tp& __x) -{ - typedef typename _Operation::first_argument_type _Arg1_type; - return binder1st<_Operation>(__fn, _Arg1_type(__x)); -} - -template -class binder2nd - : public unary_function { -protected: - _Operation op; - typename _Operation::second_argument_type value; -public: - binder2nd(const _Operation& __x, - const typename _Operation::second_argument_type& __y) - : op(__x), value(__y) {} - typename _Operation::result_type - operator()(const typename _Operation::first_argument_type& __x) const { - return op(__x, value); - } -}; - -template -inline binder2nd<_Operation> -bind2nd(const _Operation& __fn, const _Tp& __x) -{ - typedef typename _Operation::second_argument_type _Arg2_type; - return binder2nd<_Operation>(__fn, _Arg2_type(__x)); -} - -// unary_compose and binary_compose (extensions, not part of the standard). - -template -class unary_compose - : public unary_function -{ -protected: - _Operation1 _M_fn1; - _Operation2 _M_fn2; -public: - unary_compose(const _Operation1& __x, const _Operation2& __y) - : _M_fn1(__x), _M_fn2(__y) {} - typename _Operation1::result_type - operator()(const typename _Operation2::argument_type& __x) const { - return _M_fn1(_M_fn2(__x)); - } -}; - -template -inline unary_compose<_Operation1,_Operation2> -compose1(const _Operation1& __fn1, const _Operation2& __fn2) -{ - return unary_compose<_Operation1,_Operation2>(__fn1, __fn2); -} - -template -class binary_compose - : public unary_function { -protected: - _Operation1 _M_fn1; - _Operation2 _M_fn2; - _Operation3 _M_fn3; -public: - binary_compose(const _Operation1& __x, const _Operation2& __y, - const _Operation3& __z) - : _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { } - typename _Operation1::result_type - operator()(const typename _Operation2::argument_type& __x) const { - return _M_fn1(_M_fn2(__x), _M_fn3(__x)); - } -}; - -template -inline binary_compose<_Operation1, _Operation2, _Operation3> -compose2(const _Operation1& __fn1, const _Operation2& __fn2, - const _Operation3& __fn3) -{ - return binary_compose<_Operation1,_Operation2,_Operation3> - (__fn1, __fn2, __fn3); -} - -template -class pointer_to_unary_function : public unary_function<_Arg, _Result> { -protected: - _Result (*_M_ptr)(_Arg); -public: - pointer_to_unary_function() {} - explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) {} - _Result operator()(_Arg __x) const { return _M_ptr(__x); } -}; - -template -inline pointer_to_unary_function<_Arg, _Result> ptr_fun(_Result (*__x)(_Arg)) -{ - return pointer_to_unary_function<_Arg, _Result>(__x); -} - -template -class pointer_to_binary_function : - public binary_function<_Arg1,_Arg2,_Result> { -protected: - _Result (*_M_ptr)(_Arg1, _Arg2); -public: - pointer_to_binary_function() {} - explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) - : _M_ptr(__x) {} - _Result operator()(_Arg1 __x, _Arg2 __y) const { - return _M_ptr(__x, __y); - } -}; - -template -inline pointer_to_binary_function<_Arg1,_Arg2,_Result> -ptr_fun(_Result (*__x)(_Arg1, _Arg2)) { - return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__x); -} - -// identity is an extensions: it is not part of the standard. -template -struct _Identity : public unary_function<_Tp,_Tp> { - const _Tp& operator()(const _Tp& __x) const { return __x; } -}; - -template struct identity : public _Identity<_Tp> {}; - -// select1st and select2nd are extensions: they are not part of the standard. -template -struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> { - const typename _Pair::first_type& operator()(const _Pair& __x) const { - return __x.first; - } -}; - -template -struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type> -{ - const typename _Pair::second_type& operator()(const _Pair& __x) const { - return __x.second; - } -}; - -template struct select1st : public _Select1st<_Pair> {}; -template struct select2nd : public _Select2nd<_Pair> {}; - -// project1st and project2nd are extensions: they are not part of the standard -template -struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> { - _Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; } -}; - -template -struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> { - _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; } -}; - -template -struct project1st : public _Project1st<_Arg1, _Arg2> {}; - -template -struct project2nd : public _Project2nd<_Arg1, _Arg2> {}; - -// constant_void_fun, constant_unary_fun, and constant_binary_fun are -// extensions: they are not part of the standard. (The same, of course, -// is true of the helper functions constant0, constant1, and constant2.) - -template -struct _Constant_void_fun { - typedef _Result result_type; - result_type _M_val; - - _Constant_void_fun(const result_type& __v) : _M_val(__v) {} - const result_type& operator()() const { return _M_val; } -}; - -template -struct _Constant_unary_fun { - typedef _Argument argument_type; - typedef _Result result_type; - result_type _M_val; - - _Constant_unary_fun(const result_type& __v) : _M_val(__v) {} - const result_type& operator()(const _Argument&) const { return _M_val; } -}; - -template -struct _Constant_binary_fun { - typedef _Arg1 first_argument_type; - typedef _Arg2 second_argument_type; - typedef _Result result_type; - _Result _M_val; - - _Constant_binary_fun(const _Result& __v) : _M_val(__v) {} - const result_type& operator()(const _Arg1&, const _Arg2&) const { - return _M_val; - } -}; - -template -struct constant_void_fun : public _Constant_void_fun<_Result> { - constant_void_fun(const _Result& __v) : _Constant_void_fun<_Result>(__v) {} -}; - - -template -struct constant_unary_fun : public _Constant_unary_fun<_Result, _Argument> -{ - constant_unary_fun(const _Result& __v) - : _Constant_unary_fun<_Result, _Argument>(__v) {} -}; - - -template -struct constant_binary_fun - : public _Constant_binary_fun<_Result, _Arg1, _Arg2> -{ - constant_binary_fun(const _Result& __v) - : _Constant_binary_fun<_Result, _Arg1, _Arg2>(__v) {} -}; - -template -inline constant_void_fun<_Result> constant0(const _Result& __val) -{ - return constant_void_fun<_Result>(__val); -} - -template -inline constant_unary_fun<_Result,_Result> constant1(const _Result& __val) -{ - return constant_unary_fun<_Result,_Result>(__val); -} - -template -inline constant_binary_fun<_Result,_Result,_Result> -constant2(const _Result& __val) -{ - return constant_binary_fun<_Result,_Result,_Result>(__val); -} - -// subtractive_rng is an extension: it is not part of the standard. -// Note: this code assumes that int is 32 bits. -class subtractive_rng : public unary_function { -private: - unsigned int _M_table[55]; - size_t _M_index1; - size_t _M_index2; -public: - unsigned int operator()(unsigned int __limit) { - _M_index1 = (_M_index1 + 1) % 55; - _M_index2 = (_M_index2 + 1) % 55; - _M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2]; - return _M_table[_M_index1] % __limit; - } - - void _M_initialize(unsigned int __seed) - { - unsigned int __k = 1; - _M_table[54] = __seed; - size_t __i; - for (__i = 0; __i < 54; __i++) { - size_t __ii = (21 * (__i + 1) % 55) - 1; - _M_table[__ii] = __k; - __k = __seed - __k; - __seed = _M_table[__ii]; - } - for (int __loop = 0; __loop < 4; __loop++) { - for (__i = 0; __i < 55; __i++) - _M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55]; - } - _M_index1 = 0; - _M_index2 = 31; - } - - subtractive_rng(unsigned int __seed) { _M_initialize(__seed); } -#ifdef __AVR__ - subtractive_rng() { _M_initialize(16180u); } -#else - subtractive_rng() { _M_initialize(161803398u); } -#endif -}; - - -// Adaptor function objects: pointers to member functions. - -// There are a total of 16 = 2^4 function objects in this family. -// (1) Member functions taking no arguments vs member functions taking -// one argument. -// (2) Call through pointer vs call through reference. -// (3) Member function with void return type vs member function with -// non-void return type. -// (4) Const vs non-const member function. - -// Note that choice (3) is nothing more than a workaround: according -// to the draft, compilers should handle void and non-void the same way. -// This feature is not yet widely implemented, though. You can only use -// member functions returning void if your compiler supports partial -// specialization. - -// All of this complexity is in the function objects themselves. You can -// ignore it by using the helper function mem_fun and mem_fun_ref, -// which create whichever type of adaptor is appropriate. -// (mem_fun1 and mem_fun1_ref are no longer part of the C++ standard, -// but they are provided for backward compatibility.) - - -template -class mem_fun_t : public unary_function<_Tp*,_Ret> { -public: - explicit mem_fun_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) {} - _Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); } -private: - _Ret (_Tp::*_M_f)(); -}; - -template -class const_mem_fun_t : public unary_function { -public: - explicit const_mem_fun_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {} - _Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); } -private: - _Ret (_Tp::*_M_f)() const; -}; - - -template -class mem_fun_ref_t : public unary_function<_Tp,_Ret> { -public: - explicit mem_fun_ref_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) {} - _Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); } -private: - _Ret (_Tp::*_M_f)(); -}; - -template -class const_mem_fun_ref_t : public unary_function<_Tp,_Ret> { -public: - explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {} - _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); } -private: - _Ret (_Tp::*_M_f)() const; -}; - -template -class mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> { -public: - explicit mem_fun1_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) {} - _Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); } -private: - _Ret (_Tp::*_M_f)(_Arg); -}; - -template -class const_mem_fun1_t : public binary_function { -public: - explicit const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {} - _Ret operator()(const _Tp* __p, _Arg __x) const - { return (__p->*_M_f)(__x); } -private: - _Ret (_Tp::*_M_f)(_Arg) const; -}; - -template -class mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> { -public: - explicit mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) {} - _Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } -private: - _Ret (_Tp::*_M_f)(_Arg); -}; - -template -class const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> { -public: - explicit const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {} - _Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } -private: - _Ret (_Tp::*_M_f)(_Arg) const; -}; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -class mem_fun_t : public unary_function<_Tp*,void> { -public: - explicit mem_fun_t(void (_Tp::*__pf)()) : _M_f(__pf) {} - void operator()(_Tp* __p) const { (__p->*_M_f)(); } -private: - void (_Tp::*_M_f)(); -}; - -template -class const_mem_fun_t : public unary_function { -public: - explicit const_mem_fun_t(void (_Tp::*__pf)() const) : _M_f(__pf) {} - void operator()(const _Tp* __p) const { (__p->*_M_f)(); } -private: - void (_Tp::*_M_f)() const; -}; - -template -class mem_fun_ref_t : public unary_function<_Tp,void> { -public: - explicit mem_fun_ref_t(void (_Tp::*__pf)()) : _M_f(__pf) {} - void operator()(_Tp& __r) const { (__r.*_M_f)(); } -private: - void (_Tp::*_M_f)(); -}; - -template -class const_mem_fun_ref_t : public unary_function<_Tp,void> { -public: - explicit const_mem_fun_ref_t(void (_Tp::*__pf)() const) : _M_f(__pf) {} - void operator()(const _Tp& __r) const { (__r.*_M_f)(); } -private: - void (_Tp::*_M_f)() const; -}; - -template -class mem_fun1_t : public binary_function<_Tp*,_Arg,void> { -public: - explicit mem_fun1_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {} - void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } -private: - void (_Tp::*_M_f)(_Arg); -}; - -template -class const_mem_fun1_t - : public binary_function { -public: - explicit const_mem_fun1_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {} - void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } -private: - void (_Tp::*_M_f)(_Arg) const; -}; - -template -class mem_fun1_ref_t - : public binary_function<_Tp,_Arg,void> { -public: - explicit mem_fun1_ref_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {} - void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } -private: - void (_Tp::*_M_f)(_Arg); -}; - -template -class const_mem_fun1_ref_t - : public binary_function<_Tp,_Arg,void> { -public: - explicit const_mem_fun1_ref_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {} - void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } -private: - void (_Tp::*_M_f)(_Arg) const; -}; - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// Mem_fun adaptor helper functions. There are only two: -// mem_fun and mem_fun_ref. (mem_fun1 and mem_fun1_ref -// are provided for backward compatibility, but they are no longer -// part of the C++ standard.) - -template -inline mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)()) - { return mem_fun_t<_Ret,_Tp>(__f); } - -template -inline const_mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)() const) - { return const_mem_fun_t<_Ret,_Tp>(__f); } - -template -inline mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)()) - { return mem_fun_ref_t<_Ret,_Tp>(__f); } - -template -inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const) - { return const_mem_fun_ref_t<_Ret,_Tp>(__f); } - -template -inline mem_fun1_t<_Ret,_Tp,_Arg> mem_fun(_Ret (_Tp::*__f)(_Arg)) - { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); } - -template -inline const_mem_fun1_t<_Ret,_Tp,_Arg> mem_fun(_Ret (_Tp::*__f)(_Arg) const) - { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); } - -template -inline mem_fun1_ref_t<_Ret,_Tp,_Arg> mem_fun_ref(_Ret (_Tp::*__f)(_Arg)) - { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); } - -template -inline const_mem_fun1_ref_t<_Ret,_Tp,_Arg> -mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const) - { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); } - -template -inline mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg)) - { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); } - -template -inline const_mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg) const) - { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); } - -template -inline mem_fun1_ref_t<_Ret,_Tp,_Arg> mem_fun1_ref(_Ret (_Tp::*__f)(_Arg)) - { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); } - -template -inline const_mem_fun1_ref_t<_Ret,_Tp,_Arg> -mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const) - { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); } - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_FUNCTION_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_hash_fun.h b/DSTAT1/src/avr-stl/include/stl_hash_fun.h deleted file mode 100644 index 44ab9bb..0000000 --- a/DSTAT1/src/avr-stl/include/stl_hash_fun.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_HASH_FUN_H -#define __SGI_STL_HASH_FUN_H - -#include - -__STL_BEGIN_NAMESPACE - -template struct hash { }; - -inline size_t __stl_hash_string(const char* __s) -{ - unsigned long __h = 0; - for ( ; *__s; ++__s) - __h = 5*__h + *__s; - - return size_t(__h); -} - -__STL_TEMPLATE_NULL struct hash -{ - size_t operator()(const char* __s) const { return __stl_hash_string(__s); } -}; - -__STL_TEMPLATE_NULL struct hash -{ - size_t operator()(const char* __s) const { return __stl_hash_string(__s); } -}; - -__STL_TEMPLATE_NULL struct hash { - size_t operator()(char __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(unsigned char __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(unsigned char __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(short __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(unsigned short __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(int __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(unsigned int __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(long __x) const { return __x; } -}; -__STL_TEMPLATE_NULL struct hash { - size_t operator()(unsigned long __x) const { return __x; } -}; - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_HASH_FUN_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_hash_map.h b/DSTAT1/src/avr-stl/include/stl_hash_map.h deleted file mode 100644 index 0d5bc8a..0000000 --- a/DSTAT1/src/avr-stl/include/stl_hash_map.h +++ /dev/null @@ -1,532 +0,0 @@ -/* - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_HASH_MAP_H -#define __SGI_STL_INTERNAL_HASH_MAP_H - -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -// Forward declaration of equality operator; needed for friend declaration. - -template ), - class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Key>), - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) > -class hash_map; - -template -inline bool operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&, - const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&); - -template -class hash_map -{ - // requirements: - - __STL_CLASS_REQUIRES(_Key, _Assignable); - __STL_CLASS_REQUIRES(_Tp, _Assignable); - __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Key); - __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Key, _Key); - -private: - typedef hashtable,_Key,_HashFcn, - _Select1st >,_EqualKey,_Alloc> _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_map(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_map(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - hash_map(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_map(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_map(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_map(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } - -#else - hash_map(const value_type* __f, const value_type* __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const value_type* __f, const value_type* __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } - - hash_map(const_iterator __f, const_iterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const_iterator __f, const_iterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_map(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); } - -#ifdef __STL_MEMBER_TEMPLATES - template - friend bool operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&, - const hash_map<_K1, _T1, _HF, _EqK, _Al>&); -#else /* __STL_MEMBER_TEMPLATES */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const hash_map&, const hash_map&); -#endif /* __STL_MEMBER_TEMPLATES */ - - - iterator begin() { return _M_ht.begin(); } - iterator end() { return _M_ht.end(); } - const_iterator begin() const { return _M_ht.begin(); } - const_iterator end() const { return _M_ht.end(); } - -public: - pair insert(const value_type& __obj) - { return _M_ht.insert_unique(__obj); } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_unique(__f,__l); } -#else - void insert(const value_type* __f, const value_type* __l) { - _M_ht.insert_unique(__f,__l); - } - void insert(const_iterator __f, const_iterator __l) - { _M_ht.insert_unique(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - pair insert_noresize(const value_type& __obj) - { return _M_ht.insert_unique_noresize(__obj); } - - iterator find(const key_type& __key) { return _M_ht.find(__key); } - const_iterator find(const key_type& __key) const - { return _M_ht.find(__key); } - - _Tp& operator[](const key_type& __key) { - return _M_ht.find_or_insert(value_type(__key, _Tp())).second; - } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) - { return _M_ht.equal_range(__key); } - pair - equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, - const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) -{ - return __hm1._M_ht == __hm2._M_ht; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool -operator!=(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, - const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) { - return !(__hm1 == __hm2); -} - -template -inline void -swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, - hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) -{ - __hm1.swap(__hm2); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -// Forward declaration of equality operator; needed for friend declaration. - -template ), - class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Key>), - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) > -class hash_multimap; - -template -inline bool -operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, - const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2); - -template -class hash_multimap -{ - // requirements: - - __STL_CLASS_REQUIRES(_Key, _Assignable); - __STL_CLASS_REQUIRES(_Tp, _Assignable); - __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Key); - __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Key, _Key); - -private: - typedef hashtable, _Key, _HashFcn, - _Select1st >, _EqualKey, _Alloc> - _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_multimap(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_multimap(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - hash_multimap(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } - -#else - hash_multimap(const value_type* __f, const value_type* __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const value_type* __f, const value_type* __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } - - hash_multimap(const_iterator __f, const_iterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const_iterator __f, const_iterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multimap(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); } - -#ifdef __STL_MEMBER_TEMPLATES - template - friend bool operator== (const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&, - const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&); -#else /* __STL_MEMBER_TEMPLATES */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const hash_multimap&,const hash_multimap&); -#endif /* __STL_MEMBER_TEMPLATES */ - - iterator begin() { return _M_ht.begin(); } - iterator end() { return _M_ht.end(); } - const_iterator begin() const { return _M_ht.begin(); } - const_iterator end() const { return _M_ht.end(); } - -public: - iterator insert(const value_type& __obj) - { return _M_ht.insert_equal(__obj); } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_equal(__f,__l); } -#else - void insert(const value_type* __f, const value_type* __l) { - _M_ht.insert_equal(__f,__l); - } - void insert(const_iterator __f, const_iterator __l) - { _M_ht.insert_equal(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - iterator insert_noresize(const value_type& __obj) - { return _M_ht.insert_equal_noresize(__obj); } - - iterator find(const key_type& __key) { return _M_ht.find(__key); } - const_iterator find(const key_type& __key) const - { return _M_ht.find(__key); } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) - { return _M_ht.equal_range(__key); } - pair - equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - -public: - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, - const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) -{ - return __hm1._M_ht == __hm2._M_ht; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool -operator!=(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, - const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) { - return !(__hm1 == __hm2); -} - -template -inline void -swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, - hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) -{ - __hm1.swap(__hm2); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -// Specialization of insert_iterator so that it will work for hash_map -// and hash_multimap. - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -class insert_iterator > { -protected: - typedef hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; - _Container* container; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x) : container(&__x) {} - insert_iterator(_Container& __x, typename _Container::iterator) - : container(&__x) {} - insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->insert(__value); - return *this; - } - insert_iterator<_Container>& operator*() { return *this; } - insert_iterator<_Container>& operator++() { return *this; } - insert_iterator<_Container>& operator++(int) { return *this; } -}; - -template -class insert_iterator > { -protected: - typedef hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; - _Container* container; - typename _Container::iterator iter; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x) : container(&__x) {} - insert_iterator(_Container& __x, typename _Container::iterator) - : container(&__x) {} - insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->insert(__value); - return *this; - } - insert_iterator<_Container>& operator*() { return *this; } - insert_iterator<_Container>& operator++() { return *this; } - insert_iterator<_Container>& operator++(int) { return *this; } -}; - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_HASH_MAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_hash_set.h b/DSTAT1/src/avr-stl/include/stl_hash_set.h deleted file mode 100644 index a4b845b..0000000 --- a/DSTAT1/src/avr-stl/include/stl_hash_set.h +++ /dev/null @@ -1,514 +0,0 @@ -/* - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_HASH_SET_H -#define __SGI_STL_INTERNAL_HASH_SET_H - -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -// Forward declaration of equality operator; needed for friend declaration. - -template ), - class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Value>), - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) > -class hash_set; - -template -inline bool -operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2); - -template -class hash_set -{ - // requirements: - - __STL_CLASS_REQUIRES(_Value, _Assignable); - __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Value); - __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Value, _Value); - -private: - typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, - _EqualKey, _Alloc> _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::const_pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::const_reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::const_iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_set() - : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_set(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_set(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_set(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - hash_set(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_set(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_set(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_set(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } -#else - - hash_set(const value_type* __f, const value_type* __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const value_type* __f, const value_type* __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } - - hash_set(const_iterator __f, const_iterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const_iterator __f, const_iterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - hash_set(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_set& __hs) { _M_ht.swap(__hs._M_ht); } - -#ifdef __STL_MEMBER_TEMPLATES - template - friend bool operator== (const hash_set<_Val, _HF, _EqK, _Al>&, - const hash_set<_Val, _HF, _EqK, _Al>&); -#else /* __STL_MEMBER_TEMPLATES */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const hash_set&, const hash_set&); -#endif /* __STL_MEMBER_TEMPLATES */ - - iterator begin() const { return _M_ht.begin(); } - iterator end() const { return _M_ht.end(); } - -public: - pair insert(const value_type& __obj) - { - pair __p = _M_ht.insert_unique(__obj); - return pair(__p.first, __p.second); - } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_unique(__f,__l); } -#else - void insert(const value_type* __f, const value_type* __l) { - _M_ht.insert_unique(__f,__l); - } - void insert(const_iterator __f, const_iterator __l) - {_M_ht.insert_unique(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - pair insert_noresize(const value_type& __obj) - { - pair __p = - _M_ht.insert_unique_noresize(__obj); - return pair(__p.first, __p.second); - } - - iterator find(const key_type& __key) const { return _M_ht.find(__key); } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - -public: - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) -{ - return __hs1._M_ht == __hs2._M_ht; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool -operator!=(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) { - return !(__hs1 == __hs2); -} - -template -inline void -swap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) -{ - __hs1.swap(__hs2); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - -template ), - class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Value>), - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) > -class hash_multiset; - -template -inline bool -operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2); - - -template -class hash_multiset -{ - // requirements: - - __STL_CLASS_REQUIRES(_Value, _Assignable); - __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Value); - __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Value, _Value); - -private: - typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, - _EqualKey, _Alloc> _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::const_pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::const_reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::const_iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_multiset() - : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_multiset(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_multiset(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - hash_multiset(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } -#else - - hash_multiset(const value_type* __f, const value_type* __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const value_type* __f, const value_type* __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const value_type* __f, const value_type* __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } - - hash_multiset(const_iterator __f, const_iterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const_iterator __f, const_iterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - hash_multiset(const_iterator __f, const_iterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_multiset& hs) { _M_ht.swap(hs._M_ht); } - -#ifdef __STL_MEMBER_TEMPLATES - template - friend bool operator== (const hash_multiset<_Val, _HF, _EqK, _Al>&, - const hash_multiset<_Val, _HF, _EqK, _Al>&); -#else /* __STL_MEMBER_TEMPLATES */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const hash_multiset&,const hash_multiset&); -#endif /* __STL_MEMBER_TEMPLATES */ - - iterator begin() const { return _M_ht.begin(); } - iterator end() const { return _M_ht.end(); } - -public: - iterator insert(const value_type& __obj) - { return _M_ht.insert_equal(__obj); } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_equal(__f,__l); } -#else - void insert(const value_type* __f, const value_type* __l) { - _M_ht.insert_equal(__f,__l); - } - void insert(const_iterator __f, const_iterator __l) - { _M_ht.insert_equal(__f, __l); } -#endif /*__STL_MEMBER_TEMPLATES */ - iterator insert_noresize(const value_type& __obj) - { return _M_ht.insert_equal_noresize(__obj); } - - iterator find(const key_type& __key) const { return _M_ht.find(__key); } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - -public: - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) -{ - return __hs1._M_ht == __hs2._M_ht; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool -operator!=(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) { - return !(__hs1 == __hs2); -} - -template -inline void -swap(hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) { - __hs1.swap(__hs2); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -// Specialization of insert_iterator so that it will work for hash_set -// and hash_multiset. - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -class insert_iterator > { -protected: - typedef hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Container; - _Container* container; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x) : container(&__x) {} - insert_iterator(_Container& __x, typename _Container::iterator) - : container(&__x) {} - insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->insert(__value); - return *this; - } - insert_iterator<_Container>& operator*() { return *this; } - insert_iterator<_Container>& operator++() { return *this; } - insert_iterator<_Container>& operator++(int) { return *this; } -}; - -template -class insert_iterator > { -protected: - typedef hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container; - _Container* container; - typename _Container::iterator iter; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x) : container(&__x) {} - insert_iterator(_Container& __x, typename _Container::iterator) - : container(&__x) {} - insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->insert(__value); - return *this; - } - insert_iterator<_Container>& operator*() { return *this; } - insert_iterator<_Container>& operator++() { return *this; } - insert_iterator<_Container>& operator++(int) { return *this; } -}; - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_HASH_SET_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_hashtable.h b/DSTAT1/src/avr-stl/include/stl_hashtable.h deleted file mode 100644 index f52d2dc..0000000 --- a/DSTAT1/src/avr-stl/include/stl_hashtable.h +++ /dev/null @@ -1,1080 +0,0 @@ -/* - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_HASHTABLE_H -#define __SGI_STL_INTERNAL_HASHTABLE_H - -// Hashtable class, used to implement the hashed associative containers -// hash_set, hash_map, hash_multiset, and hash_multimap. - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -__STL_BEGIN_NAMESPACE - -template -struct _Hashtable_node -{ - _Hashtable_node* _M_next; - _Val _M_val; -}; - -template -class hashtable; - -template -struct _Hashtable_iterator; - -template -struct _Hashtable_const_iterator; - -template -struct _Hashtable_iterator { - typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> - _Hashtable; - typedef _Hashtable_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - const_iterator; - typedef _Hashtable_node<_Val> _Node; - - typedef forward_iterator_tag iterator_category; - typedef _Val value_type; - typedef ptrdiff_t difference_type; - typedef size_t size_type; - typedef _Val& reference; - typedef _Val* pointer; - - _Node* _M_cur; - _Hashtable* _M_ht; - - _Hashtable_iterator(_Node* __n, _Hashtable* __tab) - : _M_cur(__n), _M_ht(__tab) {} - _Hashtable_iterator() {} - reference operator*() const { return _M_cur->_M_val; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - iterator& operator++(); - iterator operator++(int); - bool operator==(const iterator& __it) const - { return _M_cur == __it._M_cur; } - bool operator!=(const iterator& __it) const - { return _M_cur != __it._M_cur; } -}; - - -template -struct _Hashtable_const_iterator { - typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> - _Hashtable; - typedef _Hashtable_iterator<_Val,_Key,_HashFcn, - _ExtractKey,_EqualKey,_Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - const_iterator; - typedef _Hashtable_node<_Val> _Node; - - typedef forward_iterator_tag iterator_category; - typedef _Val value_type; - typedef ptrdiff_t difference_type; - typedef size_t size_type; - typedef const _Val& reference; - typedef const _Val* pointer; - - const _Node* _M_cur; - const _Hashtable* _M_ht; - - _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab) - : _M_cur(__n), _M_ht(__tab) {} - _Hashtable_const_iterator() {} - _Hashtable_const_iterator(const iterator& __it) - : _M_cur(__it._M_cur), _M_ht(__it._M_ht) {} - reference operator*() const { return _M_cur->_M_val; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - const_iterator& operator++(); - const_iterator operator++(int); - bool operator==(const const_iterator& __it) const - { return _M_cur == __it._M_cur; } - bool operator!=(const const_iterator& __it) const - { return _M_cur != __it._M_cur; } -}; - -#ifdef __AVR__ - -enum { __stl_num_primes = 30 }; - -// downsize the prime set to be more appropriate for a -// device with low RAM and store this table in flash - -static const unsigned char __stl_prime_list[__stl_num_primes] = -{ - 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, - 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, - 79, 83, 89, 97, 101, 103, 107, 109, 113, 127 -}; - -inline unsigned long __stl_next_prime(unsigned long __n) -{ - const unsigned char * __first = __stl_prime_list; - const unsigned char * __last = __stl_prime_list + (int)__stl_num_primes; - const unsigned char * pos = lower_bound(__first, __last, (unsigned char)__n); - - return pos == __last ? *(__last - 1) : *pos; -} - -#else - -// Note: assumes long is at least 32 bits. -enum { __stl_num_primes = 28 }; - -static const unsigned long __stl_prime_list[__stl_num_primes] = -{ - 53ul, 97ul, 193ul, 389ul, 769ul, - 1543ul, 3079ul, 6151ul, 12289ul, 24593ul, - 49157ul, 98317ul, 196613ul, 393241ul, 786433ul, - 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul, - 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul, - 1610612741ul, 3221225473ul, 4294967291ul -}; - -inline unsigned long __stl_next_prime(unsigned long __n) -{ - const unsigned long* __first = __stl_prime_list; - const unsigned long* __last = __stl_prime_list + (int)__stl_num_primes; - const unsigned long* pos = lower_bound(__first, __last, __n); - return pos == __last ? *(__last - 1) : *pos; -} -#endif - -// Forward declaration of operator==. - -template -class hashtable; - -template -bool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, - const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2); - - -// Hashtables handle allocators a bit differently than other containers -// do. If we're using standard-conforming allocators, then a hashtable -// unconditionally has a member variable to hold its allocator, even if -// it so happens that all instances of the allocator type are identical. -// This is because, for hashtables, this extra storage is negligible. -// Additionally, a base class wouldn't serve any other purposes; it -// wouldn't, for example, simplify the exception-handling code. - -template -class hashtable { -public: - typedef _Key key_type; - typedef _Val value_type; - typedef _HashFcn hasher; - typedef _EqualKey key_equal; - - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - - hasher hash_funct() const { return _M_hash; } - key_equal key_eq() const { return _M_equals; } - -private: - typedef _Hashtable_node<_Val> _Node; - -#ifdef __STL_USE_STD_ALLOCATORS -public: - typedef typename _Alloc_traits<_Val,_Alloc>::allocator_type allocator_type; - allocator_type get_allocator() const { return _M_node_allocator; } -private: - typename _Alloc_traits<_Node, _Alloc>::allocator_type _M_node_allocator; - _Node* _M_get_node() { return _M_node_allocator.allocate(1); } - void _M_put_node(_Node* __p) { _M_node_allocator.deallocate(__p, 1); } -# define __HASH_ALLOC_INIT(__a) _M_node_allocator(__a), -#else /* __STL_USE_STD_ALLOCATORS */ -public: - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } -private: - typedef simple_alloc<_Node, _Alloc> _M_node_allocator_type; - _Node* _M_get_node() { return _M_node_allocator_type::allocate(1); } - void _M_put_node(_Node* __p) { _M_node_allocator_type::deallocate(__p, 1); } -# define __HASH_ALLOC_INIT(__a) -#endif /* __STL_USE_STD_ALLOCATORS */ - -private: - hasher _M_hash; - key_equal _M_equals; - _ExtractKey _M_get_key; - vector<_Node*,_Alloc> _M_buckets; - size_type _M_num_elements; - -public: - typedef _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey, - _Alloc> - const_iterator; - - friend struct - _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>; - friend struct - _Hashtable_const_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>; - -public: - hashtable(size_type __n, - const _HashFcn& __hf, - const _EqualKey& __eql, - const _ExtractKey& __ext, - const allocator_type& __a = allocator_type()) - : __HASH_ALLOC_INIT(__a) - _M_hash(__hf), - _M_equals(__eql), - _M_get_key(__ext), - _M_buckets(__a), - _M_num_elements(0) - { - _M_initialize_buckets(__n); - } - - hashtable(size_type __n, - const _HashFcn& __hf, - const _EqualKey& __eql, - const allocator_type& __a = allocator_type()) - : __HASH_ALLOC_INIT(__a) - _M_hash(__hf), - _M_equals(__eql), - _M_get_key(_ExtractKey()), - _M_buckets(__a), - _M_num_elements(0) - { - _M_initialize_buckets(__n); - } - - hashtable(const hashtable& __ht) - : __HASH_ALLOC_INIT(__ht.get_allocator()) - _M_hash(__ht._M_hash), - _M_equals(__ht._M_equals), - _M_get_key(__ht._M_get_key), - _M_buckets(__ht.get_allocator()), - _M_num_elements(0) - { - _M_copy_from(__ht); - } - -#undef __HASH_ALLOC_INIT - - hashtable& operator= (const hashtable& __ht) - { - if (&__ht != this) { - clear(); - _M_hash = __ht._M_hash; - _M_equals = __ht._M_equals; - _M_get_key = __ht._M_get_key; - _M_copy_from(__ht); - } - return *this; - } - - ~hashtable() { clear(); } - - size_type size() const { return _M_num_elements; } - size_type max_size() const { return size_type(-1); } - bool empty() const { return size() == 0; } - - void swap(hashtable& __ht) - { - __STD::swap(_M_hash, __ht._M_hash); - __STD::swap(_M_equals, __ht._M_equals); - __STD::swap(_M_get_key, __ht._M_get_key); - _M_buckets.swap(__ht._M_buckets); - __STD::swap(_M_num_elements, __ht._M_num_elements); - } - - iterator begin() - { - for (size_type __n = 0; __n < _M_buckets.size(); ++__n) - if (_M_buckets[__n]) - return iterator(_M_buckets[__n], this); - return end(); - } - - iterator end() { return iterator(0, this); } - - const_iterator begin() const - { - for (size_type __n = 0; __n < _M_buckets.size(); ++__n) - if (_M_buckets[__n]) - return const_iterator(_M_buckets[__n], this); - return end(); - } - - const_iterator end() const { return const_iterator(0, this); } - -#ifdef __STL_MEMBER_TEMPLATES - template - friend bool operator== (const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&, - const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&); -#else /* __STL_MEMBER_TEMPLATES */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const hashtable&, const hashtable&); -#endif /* __STL_MEMBER_TEMPLATES */ - -public: - - size_type bucket_count() const { return _M_buckets.size(); } - - size_type max_bucket_count() const - { return __stl_prime_list[(int)__stl_num_primes - 1]; } - - size_type elems_in_bucket(size_type __bucket) const - { - size_type __result = 0; - for (_Node* __cur = _M_buckets[__bucket]; __cur; __cur = __cur->_M_next) - __result += 1; - return __result; - } - - pair insert_unique(const value_type& __obj) - { - resize(_M_num_elements + 1); - return insert_unique_noresize(__obj); - } - - iterator insert_equal(const value_type& __obj) - { - resize(_M_num_elements + 1); - return insert_equal_noresize(__obj); - } - - pair insert_unique_noresize(const value_type& __obj); - iterator insert_equal_noresize(const value_type& __obj); - -#ifdef __STL_MEMBER_TEMPLATES - template - void insert_unique(_InputIterator __f, _InputIterator __l) - { - insert_unique(__f, __l, __ITERATOR_CATEGORY(__f)); - } - - template - void insert_equal(_InputIterator __f, _InputIterator __l) - { - insert_equal(__f, __l, __ITERATOR_CATEGORY(__f)); - } - - template - void insert_unique(_InputIterator __f, _InputIterator __l, - input_iterator_tag) - { - for ( ; __f != __l; ++__f) - insert_unique(*__f); - } - - template - void insert_equal(_InputIterator __f, _InputIterator __l, - input_iterator_tag) - { - for ( ; __f != __l; ++__f) - insert_equal(*__f); - } - - template - void insert_unique(_ForwardIterator __f, _ForwardIterator __l, - forward_iterator_tag) - { - size_type __n = 0; - distance(__f, __l, __n); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_unique_noresize(*__f); - } - - template - void insert_equal(_ForwardIterator __f, _ForwardIterator __l, - forward_iterator_tag) - { - size_type __n = 0; - distance(__f, __l, __n); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_equal_noresize(*__f); - } - -#else /* __STL_MEMBER_TEMPLATES */ - void insert_unique(const value_type* __f, const value_type* __l) - { - size_type __n = __l - __f; - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_unique_noresize(*__f); - } - - void insert_equal(const value_type* __f, const value_type* __l) - { - size_type __n = __l - __f; - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_equal_noresize(*__f); - } - - void insert_unique(const_iterator __f, const_iterator __l) - { - size_type __n = 0; - distance(__f, __l, __n); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_unique_noresize(*__f); - } - - void insert_equal(const_iterator __f, const_iterator __l) - { - size_type __n = 0; - distance(__f, __l, __n); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_equal_noresize(*__f); - } -#endif /*__STL_MEMBER_TEMPLATES */ - - reference find_or_insert(const value_type& __obj); - - iterator find(const key_type& __key) - { - size_type __n = _M_bkt_num_key(__key); - _Node* __first; - for ( __first = _M_buckets[__n]; - __first && !_M_equals(_M_get_key(__first->_M_val), __key); - __first = __first->_M_next) - {} - return iterator(__first, this); - } - - const_iterator find(const key_type& __key) const - { - size_type __n = _M_bkt_num_key(__key); - const _Node* __first; - for ( __first = _M_buckets[__n]; - __first && !_M_equals(_M_get_key(__first->_M_val), __key); - __first = __first->_M_next) - {} - return const_iterator(__first, this); - } - - size_type count(const key_type& __key) const - { - const size_type __n = _M_bkt_num_key(__key); - size_type __result = 0; - - for (const _Node* __cur = _M_buckets[__n]; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), __key)) - ++__result; - return __result; - } - - pair - equal_range(const key_type& __key); - - pair - equal_range(const key_type& __key) const; - - size_type erase(const key_type& __key); - void erase(const iterator& __it); - void erase(iterator __first, iterator __last); - - void erase(const const_iterator& __it); - void erase(const_iterator __first, const_iterator __last); - - void resize(size_type __num_elements_hint); - void clear(); - -private: - size_type _M_next_size(size_type __n) const - { return __stl_next_prime(__n); } - - void _M_initialize_buckets(size_type __n) - { - const size_type __n_buckets = _M_next_size(__n); - _M_buckets.reserve(__n_buckets); - _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*) 0); - _M_num_elements = 0; - } - - size_type _M_bkt_num_key(const key_type& __key) const - { - return _M_bkt_num_key(__key, _M_buckets.size()); - } - - size_type _M_bkt_num(const value_type& __obj) const - { - return _M_bkt_num_key(_M_get_key(__obj)); - } - - size_type _M_bkt_num_key(const key_type& __key, size_t __n) const - { - return _M_hash(__key) % __n; - } - - size_type _M_bkt_num(const value_type& __obj, size_t __n) const - { - return _M_bkt_num_key(_M_get_key(__obj), __n); - } - - _Node* _M_new_node(const value_type& __obj) - { - _Node* __n = _M_get_node(); - __n->_M_next = 0; - __STL_TRY { - construct(&__n->_M_val, __obj); - return __n; - } - __STL_UNWIND(_M_put_node(__n)); - } - - void _M_delete_node(_Node* __n) - { - destroy(&__n->_M_val); - _M_put_node(__n); - } - - void _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last); - void _M_erase_bucket(const size_type __n, _Node* __last); - - void _M_copy_from(const hashtable& __ht); - -}; - -template -_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>& -_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++() -{ - const _Node* __old = _M_cur; - _M_cur = _M_cur->_M_next; - if (!_M_cur) { - size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); - while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) - _M_cur = _M_ht->_M_buckets[__bucket]; - } - return *this; -} - -template -inline _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All> -_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++(int) -{ - iterator __tmp = *this; - ++*this; - return __tmp; -} - -template -_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>& -_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++() -{ - const _Node* __old = _M_cur; - _M_cur = _M_cur->_M_next; - if (!_M_cur) { - size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); - while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) - _M_cur = _M_ht->_M_buckets[__bucket]; - } - return *this; -} - -template -inline _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All> -_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++(int) -{ - const_iterator __tmp = *this; - ++*this; - return __tmp; -} - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline forward_iterator_tag -iterator_category(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&) -{ - return forward_iterator_tag(); -} - -template -inline _Val* -value_type(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&) -{ - return (_Val*) 0; -} - -template -inline hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type* -distance_type(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&) -{ - return (hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type*) 0; -} - -template -inline forward_iterator_tag -iterator_category(const _Hashtable_const_iterator<_Val,_Key,_HF, - _ExK,_EqK,_All>&) -{ - return forward_iterator_tag(); -} - -template -inline _Val* -value_type(const _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&) -{ - return (_Val*) 0; -} - -template -inline hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type* -distance_type(const _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&) -{ - return (hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type*) 0; -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -bool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, - const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2) -{ - typedef typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::_Node _Node; - if (__ht1._M_buckets.size() != __ht2._M_buckets.size()) - return false; - for (int __n = 0; __n < __ht1._M_buckets.size(); ++__n) { - _Node* __cur1 = __ht1._M_buckets[__n]; - _Node* __cur2 = __ht2._M_buckets[__n]; - for ( ; __cur1 && __cur2 && __cur1->_M_val == __cur2->_M_val; - __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next) - {} - if (__cur1 || __cur2) - return false; - } - return true; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, - const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2) { - return !(__ht1 == __ht2); -} - -template -inline void swap(hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht1, - hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht2) { - __ht1.swap(__ht2); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - -template -pair::iterator, bool> -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::insert_unique_noresize(const value_type& __obj) -{ - const size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) - return pair(iterator(__cur, this), false); - - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return pair(iterator(__tmp, this), true); -} - -template -typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::insert_equal_noresize(const value_type& __obj) -{ - const size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) { - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __cur->_M_next; - __cur->_M_next = __tmp; - ++_M_num_elements; - return iterator(__tmp, this); - } - - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return iterator(__tmp, this); -} - -template -typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::reference -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::find_or_insert(const value_type& __obj) -{ - resize(_M_num_elements + 1); - - size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) - return __cur->_M_val; - - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return __tmp->_M_val; -} - -template -pair::iterator, - typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator> -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::equal_range(const key_type& __key) -{ - typedef pair _Pii; - const size_type __n = _M_bkt_num_key(__key); - - for (_Node* __first = _M_buckets[__n]; __first; __first = __first->_M_next) - if (_M_equals(_M_get_key(__first->_M_val), __key)) { - for (_Node* __cur = __first->_M_next; __cur; __cur = __cur->_M_next) - if (!_M_equals(_M_get_key(__cur->_M_val), __key)) - return _Pii(iterator(__first, this), iterator(__cur, this)); - for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) - if (_M_buckets[__m]) - return _Pii(iterator(__first, this), - iterator(_M_buckets[__m], this)); - return _Pii(iterator(__first, this), end()); - } - return _Pii(end(), end()); -} - -template -pair::const_iterator, - typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::const_iterator> -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::equal_range(const key_type& __key) const -{ - typedef pair _Pii; - const size_type __n = _M_bkt_num_key(__key); - - for (const _Node* __first = _M_buckets[__n] ; - __first; - __first = __first->_M_next) { - if (_M_equals(_M_get_key(__first->_M_val), __key)) { - for (const _Node* __cur = __first->_M_next; - __cur; - __cur = __cur->_M_next) - if (!_M_equals(_M_get_key(__cur->_M_val), __key)) - return _Pii(const_iterator(__first, this), - const_iterator(__cur, this)); - for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) - if (_M_buckets[__m]) - return _Pii(const_iterator(__first, this), - const_iterator(_M_buckets[__m], this)); - return _Pii(const_iterator(__first, this), end()); - } - } - return _Pii(end(), end()); -} - -template -typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::size_type -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const key_type& __key) -{ - const size_type __n = _M_bkt_num_key(__key); - _Node* __first = _M_buckets[__n]; - size_type __erased = 0; - - if (__first) { - _Node* __cur = __first; - _Node* __next = __cur->_M_next; - while (__next) { - if (_M_equals(_M_get_key(__next->_M_val), __key)) { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - __next = __cur->_M_next; - ++__erased; - --_M_num_elements; - } - else { - __cur = __next; - __next = __cur->_M_next; - } - } - if (_M_equals(_M_get_key(__first->_M_val), __key)) { - _M_buckets[__n] = __first->_M_next; - _M_delete_node(__first); - ++__erased; - --_M_num_elements; - } - } - return __erased; -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const iterator& __it) -{ - _Node* __p = __it._M_cur; - if (__p) { - const size_type __n = _M_bkt_num(__p->_M_val); - _Node* __cur = _M_buckets[__n]; - - if (__cur == __p) { - _M_buckets[__n] = __cur->_M_next; - _M_delete_node(__cur); - --_M_num_elements; - } - else { - _Node* __next = __cur->_M_next; - while (__next) { - if (__next == __p) { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - --_M_num_elements; - break; - } - else { - __cur = __next; - __next = __cur->_M_next; - } - } - } - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::erase(iterator __first, iterator __last) -{ - size_type __f_bucket = __first._M_cur ? - _M_bkt_num(__first._M_cur->_M_val) : _M_buckets.size(); - size_type __l_bucket = __last._M_cur ? - _M_bkt_num(__last._M_cur->_M_val) : _M_buckets.size(); - - if (__first._M_cur == __last._M_cur) - return; - else if (__f_bucket == __l_bucket) - _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur); - else { - _M_erase_bucket(__f_bucket, __first._M_cur, 0); - for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n) - _M_erase_bucket(__n, 0); - if (__l_bucket != _M_buckets.size()) - _M_erase_bucket(__l_bucket, __last._M_cur); - } -} - -template -inline void -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const_iterator __first, - const_iterator __last) -{ - erase(iterator(const_cast<_Node*>(__first._M_cur), - const_cast(__first._M_ht)), - iterator(const_cast<_Node*>(__last._M_cur), - const_cast(__last._M_ht))); -} - -template -inline void -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const const_iterator& __it) -{ - erase(iterator(const_cast<_Node*>(__it._M_cur), - const_cast(__it._M_ht))); -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::resize(size_type __num_elements_hint) -{ - const size_type __old_n = _M_buckets.size(); - if (__num_elements_hint > __old_n) { - const size_type __n = _M_next_size(__num_elements_hint); - if (__n > __old_n) { - vector<_Node*, _All> __tmp(__n, (_Node*)(0), - _M_buckets.get_allocator()); - __STL_TRY { - for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) { - _Node* __first = _M_buckets[__bucket]; - while (__first) { - size_type __new_bucket = _M_bkt_num(__first->_M_val, __n); - _M_buckets[__bucket] = __first->_M_next; - __first->_M_next = __tmp[__new_bucket]; - __tmp[__new_bucket] = __first; - __first = _M_buckets[__bucket]; - } - } - _M_buckets.swap(__tmp); - } -# ifdef __STL_USE_EXCEPTIONS - catch(...) { - for (size_type __bucket = 0; __bucket < __tmp.size(); ++__bucket) { - while (__tmp[__bucket]) { - _Node* __next = __tmp[__bucket]->_M_next; - _M_delete_node(__tmp[__bucket]); - __tmp[__bucket] = __next; - } - } - throw; - } -# endif /* __STL_USE_EXCEPTIONS */ - } - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::_M_erase_bucket(const size_type __n, _Node* __first, _Node* __last) -{ - _Node* __cur = _M_buckets[__n]; - if (__cur == __first) - _M_erase_bucket(__n, __last); - else { - _Node* __next; - for (__next = __cur->_M_next; - __next != __first; - __cur = __next, __next = __cur->_M_next) - ; - while (__next != __last) { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - __next = __cur->_M_next; - --_M_num_elements; - } - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::_M_erase_bucket(const size_type __n, _Node* __last) -{ - _Node* __cur = _M_buckets[__n]; - while (__cur != __last) { - _Node* __next = __cur->_M_next; - _M_delete_node(__cur); - __cur = __next; - _M_buckets[__n] = __cur; - --_M_num_elements; - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::clear() -{ - for (size_type __i = 0; __i < _M_buckets.size(); ++__i) { - _Node* __cur = _M_buckets[__i]; - while (__cur != 0) { - _Node* __next = __cur->_M_next; - _M_delete_node(__cur); - __cur = __next; - } - _M_buckets[__i] = 0; - } - _M_num_elements = 0; -} - - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::_M_copy_from(const hashtable& __ht) -{ - _M_buckets.clear(); - _M_buckets.reserve(__ht._M_buckets.size()); - _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0); - __STL_TRY { - for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) { - const _Node* __cur = __ht._M_buckets[__i]; - if (__cur) { - _Node* __copy = _M_new_node(__cur->_M_val); - _M_buckets[__i] = __copy; - - for (_Node* __next = __cur->_M_next; - __next; - __cur = __next, __next = __cur->_M_next) { - __copy->_M_next = _M_new_node(__next->_M_val); - __copy = __copy->_M_next; - } - } - } - _M_num_elements = __ht._M_num_elements; - } - __STL_UNWIND(clear()); -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_HASHTABLE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_heap.h b/DSTAT1/src/avr-stl/include/stl_heap.h deleted file mode 100644 index 651d21a..0000000 --- a/DSTAT1/src/avr-stl/include/stl_heap.h +++ /dev/null @@ -1,297 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_HEAP_H -#define __SGI_STL_INTERNAL_HEAP_H - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1209 -#endif - -// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap. - -template -void -__push_heap(_RandomAccessIterator __first, - _Distance __holeIndex, _Distance __topIndex, _Tp __value) -{ - _Distance __parent = (__holeIndex - 1) / 2; - while (__holeIndex > __topIndex && *(__first + __parent) < __value) { - *(__first + __holeIndex) = *(__first + __parent); - __holeIndex = __parent; - __parent = (__holeIndex - 1) / 2; - } - *(__first + __holeIndex) = __value; -} - -template -inline void -__push_heap_aux(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Distance*, _Tp*) -{ - __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), - _Tp(*(__last - 1))); -} - -template -inline void -push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, - _LessThanComparable); - __push_heap_aux(__first, __last, - __DISTANCE_TYPE(__first), __VALUE_TYPE(__first)); -} - -template -void -__push_heap(_RandomAccessIterator __first, _Distance __holeIndex, - _Distance __topIndex, _Tp __value, _Compare __comp) -{ - _Distance __parent = (__holeIndex - 1) / 2; - while (__holeIndex > __topIndex && __comp(*(__first + __parent), __value)) { - *(__first + __holeIndex) = *(__first + __parent); - __holeIndex = __parent; - __parent = (__holeIndex - 1) / 2; - } - *(__first + __holeIndex) = __value; -} - -template -inline void -__push_heap_aux(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp, - _Distance*, _Tp*) -{ - __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), - _Tp(*(__last - 1)), __comp); -} - -template -inline void -push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Compare __comp) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __push_heap_aux(__first, __last, __comp, - __DISTANCE_TYPE(__first), __VALUE_TYPE(__first)); -} - -template -void -__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, - _Distance __len, _Tp __value) -{ - _Distance __topIndex = __holeIndex; - _Distance __secondChild = 2 * __holeIndex + 2; - while (__secondChild < __len) { - if (*(__first + __secondChild) < *(__first + (__secondChild - 1))) - __secondChild--; - *(__first + __holeIndex) = *(__first + __secondChild); - __holeIndex = __secondChild; - __secondChild = 2 * (__secondChild + 1); - } - if (__secondChild == __len) { - *(__first + __holeIndex) = *(__first + (__secondChild - 1)); - __holeIndex = __secondChild - 1; - } - __push_heap(__first, __holeIndex, __topIndex, __value); -} - -template -inline void -__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _RandomAccessIterator __result, _Tp __value, _Distance*) -{ - *__result = *__first; - __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value); -} - -template -inline void -__pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Tp*) -{ - __pop_heap(__first, __last - 1, __last - 1, - _Tp(*(__last - 1)), __DISTANCE_TYPE(__first)); -} - -template -inline void pop_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, - _LessThanComparable); - __pop_heap_aux(__first, __last, __VALUE_TYPE(__first)); -} - -template -void -__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, - _Distance __len, _Tp __value, _Compare __comp) -{ - _Distance __topIndex = __holeIndex; - _Distance __secondChild = 2 * __holeIndex + 2; - while (__secondChild < __len) { - if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1)))) - __secondChild--; - *(__first + __holeIndex) = *(__first + __secondChild); - __holeIndex = __secondChild; - __secondChild = 2 * (__secondChild + 1); - } - if (__secondChild == __len) { - *(__first + __holeIndex) = *(__first + (__secondChild - 1)); - __holeIndex = __secondChild - 1; - } - __push_heap(__first, __holeIndex, __topIndex, __value, __comp); -} - -template -inline void -__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _RandomAccessIterator __result, _Tp __value, _Compare __comp, - _Distance*) -{ - *__result = *__first; - __adjust_heap(__first, _Distance(0), _Distance(__last - __first), - __value, __comp); -} - -template -inline void -__pop_heap_aux(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Tp*, _Compare __comp) -{ - __pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), __comp, - __DISTANCE_TYPE(__first)); -} - -template -inline void -pop_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __pop_heap_aux(__first, __last, __VALUE_TYPE(__first), __comp); -} - -template -void -__make_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Tp*, _Distance*) -{ - if (__last - __first < 2) return; - _Distance __len = __last - __first; - _Distance __parent = (__len - 2)/2; - - while (true) { - __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent))); - if (__parent == 0) return; - __parent--; - } -} - -template -inline void -make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, - _LessThanComparable); - __make_heap(__first, __last, - __VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); -} - -template -void -__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Compare __comp, _Tp*, _Distance*) -{ - if (__last - __first < 2) return; - _Distance __len = __last - __first; - _Distance __parent = (__len - 2)/2; - - while (true) { - __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)), - __comp); - if (__parent == 0) return; - __parent--; - } -} - -template -inline void -make_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __make_heap(__first, __last, __comp, - __VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); -} - -template -void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, - _LessThanComparable); - while (__last - __first > 1) - pop_heap(__first, __last--); -} - -template -void -sort_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - while (__last - __first > 1) - pop_heap(__first, __last--, __comp); -} - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1209 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_HEAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_iterator.h b/DSTAT1/src/avr-stl/include/stl_iterator.h deleted file mode 100644 index f84a8c4..0000000 --- a/DSTAT1/src/avr-stl/include/stl_iterator.h +++ /dev/null @@ -1,965 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_ITERATOR_H -#define __SGI_STL_INTERNAL_ITERATOR_H - -__STL_BEGIN_NAMESPACE - - -template -class back_insert_iterator { -protected: - _Container* container; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - explicit back_insert_iterator(_Container& __x) : container(&__x) {} - back_insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->push_back(__value); - return *this; - } - back_insert_iterator<_Container>& operator*() { return *this; } - back_insert_iterator<_Container>& operator++() { return *this; } - back_insert_iterator<_Container>& operator++(int) { return *this; } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline output_iterator_tag -iterator_category(const back_insert_iterator<_Container>&) -{ - return output_iterator_tag(); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline back_insert_iterator<_Container> back_inserter(_Container& __x) { - return back_insert_iterator<_Container>(__x); -} - -template -class front_insert_iterator { -protected: - _Container* container; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - explicit front_insert_iterator(_Container& __x) : container(&__x) {} - front_insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->push_front(__value); - return *this; - } - front_insert_iterator<_Container>& operator*() { return *this; } - front_insert_iterator<_Container>& operator++() { return *this; } - front_insert_iterator<_Container>& operator++(int) { return *this; } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline output_iterator_tag -iterator_category(const front_insert_iterator<_Container>&) -{ - return output_iterator_tag(); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline front_insert_iterator<_Container> front_inserter(_Container& __x) { - return front_insert_iterator<_Container>(__x); -} - -template -class insert_iterator { -protected: - _Container* container; - typename _Container::iterator iter; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x, typename _Container::iterator __i) - : container(&__x), iter(__i) {} - insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - iter = container->insert(iter, __value); - ++iter; - return *this; - } - insert_iterator<_Container>& operator*() { return *this; } - insert_iterator<_Container>& operator++() { return *this; } - insert_iterator<_Container>& operator++(int) { return *this; } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline output_iterator_tag -iterator_category(const insert_iterator<_Container>&) -{ - return output_iterator_tag(); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline -insert_iterator<_Container> inserter(_Container& __x, _Iterator __i) -{ - typedef typename _Container::iterator __iter; - return insert_iterator<_Container>(__x, __iter(__i)); -} - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template -#else -template -#endif -class reverse_bidirectional_iterator { - typedef reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, - _Reference, _Distance> _Self; -protected: - _BidirectionalIterator current; -public: - typedef bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Reference reference; - - reverse_bidirectional_iterator() {} - explicit reverse_bidirectional_iterator(_BidirectionalIterator __x) - : current(__x) {} - _BidirectionalIterator base() const { return current; } - _Reference operator*() const { - _BidirectionalIterator __tmp = current; - return *--__tmp; - } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - _Self& operator++() { - --current; - return *this; - } - _Self operator++(int) { - _Self __tmp = *this; - --current; - return __tmp; - } - _Self& operator--() { - ++current; - return *this; - } - _Self operator--(int) { - _Self __tmp = *this; - ++current; - return __tmp; - } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline bidirectional_iterator_tag -iterator_category(const reverse_bidirectional_iterator<_BidirectionalIterator, - _Tp, _Reference, - _Distance>&) -{ - return bidirectional_iterator_tag(); -} - -template -inline _Tp* -value_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, - _Reference, _Distance>&) -{ - return (_Tp*) 0; -} - -template -inline _Distance* -distance_type(const reverse_bidirectional_iterator<_BidirectionalIterator, - _Tp, - _Reference, _Distance>&) -{ - return (_Distance*) 0; -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline bool operator==( - const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __x, - const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __y) -{ - return __x.base() == __y.base(); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=( - const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __x, - const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __y) -{ - return !(__x == __y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -// This is the new version of reverse_iterator, as defined in the -// draft C++ standard. It relies on the iterator_traits template, -// which in turn relies on partial specialization. The class -// reverse_bidirectional_iterator is no longer part of the draft -// standard, but it is retained for backward compatibility. - -template -class reverse_iterator -{ -protected: - _Iterator current; -public: - typedef typename iterator_traits<_Iterator>::iterator_category - iterator_category; - typedef typename iterator_traits<_Iterator>::value_type - value_type; - typedef typename iterator_traits<_Iterator>::difference_type - difference_type; - typedef typename iterator_traits<_Iterator>::pointer - pointer; - typedef typename iterator_traits<_Iterator>::reference - reference; - - typedef _Iterator iterator_type; - typedef reverse_iterator<_Iterator> _Self; - -public: - reverse_iterator() {} - explicit reverse_iterator(iterator_type __x) : current(__x) {} - - reverse_iterator(const _Self& __x) : current(__x.current) {} -#ifdef __STL_MEMBER_TEMPLATES - template - reverse_iterator(const reverse_iterator<_Iter>& __x) - : current(__x.base()) {} -#endif /* __STL_MEMBER_TEMPLATES */ - - iterator_type base() const { return current; } - reference operator*() const { - _Iterator __tmp = current; - return *--__tmp; - } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - - _Self& operator++() { - --current; - return *this; - } - _Self operator++(int) { - _Self __tmp = *this; - --current; - return __tmp; - } - _Self& operator--() { - ++current; - return *this; - } - _Self operator--(int) { - _Self __tmp = *this; - ++current; - return __tmp; - } - - _Self operator+(difference_type __n) const { - return _Self(current - __n); - } - _Self& operator+=(difference_type __n) { - current -= __n; - return *this; - } - _Self operator-(difference_type __n) const { - return _Self(current + __n); - } - _Self& operator-=(difference_type __n) { - current += __n; - return *this; - } - reference operator[](difference_type __n) const { return *(*this + __n); } -}; - -template -inline bool operator==(const reverse_iterator<_Iterator>& __x, - const reverse_iterator<_Iterator>& __y) { - return __x.base() == __y.base(); -} - -template -inline bool operator<(const reverse_iterator<_Iterator>& __x, - const reverse_iterator<_Iterator>& __y) { - return __y.base() < __x.base(); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=(const reverse_iterator<_Iterator>& __x, - const reverse_iterator<_Iterator>& __y) { - return !(__x == __y); -} - -template -inline bool operator>(const reverse_iterator<_Iterator>& __x, - const reverse_iterator<_Iterator>& __y) { - return __y < __x; -} - -template -inline bool operator<=(const reverse_iterator<_Iterator>& __x, - const reverse_iterator<_Iterator>& __y) { - return !(__y < __x); -} - -template -inline bool operator>=(const reverse_iterator<_Iterator>& __x, - const reverse_iterator<_Iterator>& __y) { - return !(__x < __y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -template -inline typename reverse_iterator<_Iterator>::difference_type -operator-(const reverse_iterator<_Iterator>& __x, - const reverse_iterator<_Iterator>& __y) { - return __y.base() - __x.base(); -} - -template -inline reverse_iterator<_Iterator> -operator+(typename reverse_iterator<_Iterator>::difference_type __n, - const reverse_iterator<_Iterator>& __x) { - return reverse_iterator<_Iterator>(__x.base() - __n); -} - -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// This is the old version of reverse_iterator, as found in the original -// HP STL. It does not use partial specialization. - -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template -#else -template -#endif -class reverse_iterator { - typedef reverse_iterator<_RandomAccessIterator, _Tp, _Reference, _Distance> - _Self; -protected: - _RandomAccessIterator current; -public: - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Reference reference; - - reverse_iterator() {} - explicit reverse_iterator(_RandomAccessIterator __x) : current(__x) {} - _RandomAccessIterator base() const { return current; } - _Reference operator*() const { return *(current - 1); } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - _Self& operator++() { - --current; - return *this; - } - _Self operator++(int) { - _Self __tmp = *this; - --current; - return __tmp; - } - _Self& operator--() { - ++current; - return *this; - } - _Self operator--(int) { - _Self __tmp = *this; - ++current; - return __tmp; - } - _Self operator+(_Distance __n) const { - return _Self(current - __n); - } - _Self& operator+=(_Distance __n) { - current -= __n; - return *this; - } - _Self operator-(_Distance __n) const { - return _Self(current + __n); - } - _Self& operator-=(_Distance __n) { - current += __n; - return *this; - } - _Reference operator[](_Distance __n) const { return *(*this + __n); } -}; - -template -inline random_access_iterator_tag -iterator_category(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>&) -{ - return random_access_iterator_tag(); -} - -template -inline _Tp* value_type(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>&) -{ - return (_Tp*) 0; -} - -template -inline _Distance* -distance_type(const reverse_iterator<_RandomAccessIterator, - _Tp, _Reference, _Distance>&) -{ - return (_Distance*) 0; -} - - -template -inline bool -operator==(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __x, - const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __y) -{ - return __x.base() == __y.base(); -} - -template -inline bool -operator<(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __x, - const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __y) -{ - return __y.base() < __x.base(); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool -operator!=(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __x, - const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __y) { - return !(__x == __y); -} - -template -inline bool -operator>(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __x, - const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __y) { - return __y < __x; -} - -template -inline bool -operator<=(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __x, - const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __y) { - return !(__y < __x); -} - -template -inline bool -operator>=(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __x, - const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __y) { - return !(__x < __y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -template -inline _Distance -operator-(const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __x, - const reverse_iterator<_RandomAccessIterator, _Tp, - _Reference, _Distance>& __y) -{ - return __y.base() - __x.base(); -} - -template -inline reverse_iterator<_RandAccIter, _Tp, _Ref, _Dist> -operator+(_Dist __n, - const reverse_iterator<_RandAccIter, _Tp, _Ref, _Dist>& __x) -{ - return reverse_iterator<_RandAccIter, _Tp, _Ref, _Dist>(__x.base() - __n); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// istream_iterator and ostream_iterator look very different if we're -// using new, templatized iostreams than if we're using the old cfront -// version. - -#ifdef __STL_USE_NEW_IOSTREAMS - -template , - class _Dist = ptrdiff_t> -class istream_iterator { -public: - typedef _CharT char_type; - typedef _Traits traits_type; - typedef basic_istream<_CharT, _Traits> istream_type; - - typedef input_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Dist difference_type; - typedef const _Tp* pointer; - typedef const _Tp& reference; - - istream_iterator() : _M_stream(0), _M_ok(false) {} - istream_iterator(istream_type& __s) : _M_stream(&__s) { _M_read(); } - - reference operator*() const { return _M_value; } - pointer operator->() const { return &(operator*()); } - - istream_iterator& operator++() { - _M_read(); - return *this; - } - istream_iterator operator++(int) { - istream_iterator __tmp = *this; - _M_read(); - return __tmp; - } - - bool _M_equal(const istream_iterator& __x) const - { return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); } - -private: - istream_type* _M_stream; - _Tp _M_value; - bool _M_ok; - - void _M_read() { - _M_ok = (_M_stream && *_M_stream) ? true : false; - if (_M_ok) { - *_M_stream >> _M_value; - _M_ok = *_M_stream ? true : false; - } - } -}; - -template -inline bool -operator==(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x, - const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y) { - return __x._M_equal(__y); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool -operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x, - const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y) { - return !__x._M_equal(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -template > -class ostream_iterator { -public: - typedef _CharT char_type; - typedef _Traits traits_type; - typedef basic_ostream<_CharT, _Traits> ostream_type; - - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - ostream_iterator(ostream_type& __s) : _M_stream(&__s), _M_string(0) {} - ostream_iterator(ostream_type& __s, const _CharT* __c) - : _M_stream(&__s), _M_string(__c) {} - ostream_iterator<_Tp>& operator=(const _Tp& __value) { - *_M_stream << __value; - if (_M_string) *_M_stream << _M_string; - return *this; - } - ostream_iterator<_Tp>& operator*() { return *this; } - ostream_iterator<_Tp>& operator++() { return *this; } - ostream_iterator<_Tp>& operator++(int) { return *this; } -private: - ostream_type* _M_stream; - const _CharT* _M_string; -}; - -// The default template argument is declared in iosfwd - -// We do not read any characters until operator* is called. The first -// time operator* is called, it calls getc. Subsequent calls to getc -// return a cached character, and calls to operator++ use snextc. Before -// operator* or operator++ has been called, _M_is_initialized is false. -template -class istreambuf_iterator - : public iterator -{ -public: - typedef _CharT char_type; - typedef _Traits traits_type; - typedef typename _Traits::int_type int_type; - typedef basic_streambuf<_CharT, _Traits> streambuf_type; - typedef basic_istream<_CharT, _Traits> istream_type; - -public: - istreambuf_iterator(streambuf_type* __p = 0) { this->_M_init(__p); } - istreambuf_iterator(istream_type& __is) { this->_M_init(__is.rdbuf()); } - - char_type operator*() const - { return _M_is_initialized ? _M_c : _M_dereference_aux(); } - - istreambuf_iterator& operator++() { this->_M_nextc(); return *this; } - istreambuf_iterator operator++(int) { - if (!_M_is_initialized) - _M_postincr_aux(); - istreambuf_iterator __tmp = *this; - this->_M_nextc(); - return __tmp; - } - - bool equal(const istreambuf_iterator& __i) const { - return this->_M_is_initialized && __i._M_is_initialized - ? this->_M_eof == __i._M_eof - : this->_M_equal_aux(__i); - } - -private: - void _M_init(streambuf_type* __p) { - _M_buf = __p; - _M_eof = !__p; - _M_is_initialized = _M_eof; - } - - char_type _M_dereference_aux() const; - bool _M_equal_aux(const istreambuf_iterator&) const; - void _M_postincr_aux(); - - void _M_nextc() { - int_type __c = _M_buf->snextc(); - _M_c = traits_type::to_char_type(__c); - _M_eof = traits_type::eq_int_type(__c, traits_type::eof()); - _M_is_initialized = true; - } - - void _M_getc() const { - int_type __c = _M_buf->sgetc(); - _M_c = traits_type::to_char_type(__c); - _M_eof = traits_type::eq_int_type(__c, traits_type::eof()); - _M_is_initialized = true; - } - -private: - streambuf_type* _M_buf; - mutable _CharT _M_c; - mutable bool _M_eof : 1; - mutable bool _M_is_initialized : 1; -}; - -template -_CharT istreambuf_iterator<_CharT, _Traits>::_M_dereference_aux() const -{ - this->_M_getc(); - return _M_c; -} - -template -bool istreambuf_iterator<_CharT, _Traits> - ::_M_equal_aux(const istreambuf_iterator& __i) const -{ - if (!this->_M_is_initialized) - this->_M_getc(); - if (!__i._M_is_initialized) - __i._M_getc(); - - return this->_M_eof == __i._M_eof; -} - -template -void istreambuf_iterator<_CharT, _Traits>::_M_postincr_aux() -{ - this->_M_getc(); -} - -template -inline bool operator==(const istreambuf_iterator<_CharT, _Traits>& __x, - const istreambuf_iterator<_CharT, _Traits>& __y) { - return __x.equal(__y); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=(const istreambuf_iterator<_CharT, _Traits>& __x, - const istreambuf_iterator<_CharT, _Traits>& __y) { - return !__x.equal(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -// The default template argument is declared in iosfwd -template -class ostreambuf_iterator - : public iterator -{ -public: - typedef _CharT char_type; - typedef _Traits traits_type; - typedef typename _Traits::int_type int_type; - typedef basic_streambuf<_CharT, _Traits> streambuf_type; - typedef basic_ostream<_CharT, _Traits> ostream_type; - -public: - ostreambuf_iterator(streambuf_type* __buf) : _M_buf(__buf), _M_ok(__buf) {} - ostreambuf_iterator(ostream_type& __o) - : _M_buf(__o.rdbuf()), _M_ok(__o.rdbuf() != 0) {} - - ostreambuf_iterator& operator=(char_type __c) { - _M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c), - traits_type::eof()); - return *this; - } - - ostreambuf_iterator& operator*() { return *this; } - ostreambuf_iterator& operator++() { return *this; } - ostreambuf_iterator& operator++(int) { return *this; } - - bool failed() const { return !_M_ok; } - -private: - streambuf_type* _M_buf; - bool _M_ok; -}; - -#else /* __STL_USE_NEW_IOSTREAMS */ - -template class istream_iterator; - -template -inline bool operator==(const istream_iterator<_Tp, _Dist>&, - const istream_iterator<_Tp, _Dist>&); - -template -class istream_iterator { -#ifdef __STL_TEMPLATE_FRIENDS - template - friend bool operator==(const istream_iterator<_T1, _D1>&, - const istream_iterator<_T1, _D1>&); -#else /* __STL_TEMPLATE_FRIENDS */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const istream_iterator&, - const istream_iterator&); -#endif /* __STL_TEMPLATE_FRIENDS */ - -protected: - istream* _M_stream; - _Tp _M_value; - bool _M_end_marker; - void _M_read() { - _M_end_marker = (*_M_stream) ? true : false; - if (_M_end_marker) *_M_stream >> _M_value; - _M_end_marker = (*_M_stream) ? true : false; - } -public: - typedef input_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Dist difference_type; - typedef const _Tp* pointer; - typedef const _Tp& reference; - - istream_iterator() : _M_stream(&cin), _M_end_marker(false) {} - istream_iterator(istream& __s) : _M_stream(&__s) { _M_read(); } - reference operator*() const { return _M_value; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - istream_iterator<_Tp, _Dist>& operator++() { - _M_read(); - return *this; - } - istream_iterator<_Tp, _Dist> operator++(int) { - istream_iterator<_Tp, _Dist> __tmp = *this; - _M_read(); - return __tmp; - } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline input_iterator_tag -iterator_category(const istream_iterator<_Tp, _Dist>&) -{ - return input_iterator_tag(); -} - -template -inline _Tp* -value_type(const istream_iterator<_Tp, _Dist>&) { return (_Tp*) 0; } - -template -inline _Dist* -distance_type(const istream_iterator<_Tp, _Dist>&) { return (_Dist*)0; } - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline bool operator==(const istream_iterator<_Tp, _Distance>& __x, - const istream_iterator<_Tp, _Distance>& __y) { - return (__x._M_stream == __y._M_stream && - __x._M_end_marker == __y._M_end_marker) || - __x._M_end_marker == false && __y._M_end_marker == false; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=(const istream_iterator<_Tp, _Distance>& __x, - const istream_iterator<_Tp, _Distance>& __y) { - return !(__x == __y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -template -class ostream_iterator { -protected: - ostream* _M_stream; - const char* _M_string; -public: - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - ostream_iterator(ostream& __s) : _M_stream(&__s), _M_string(0) {} - ostream_iterator(ostream& __s, const char* __c) - : _M_stream(&__s), _M_string(__c) {} - ostream_iterator<_Tp>& operator=(const _Tp& __value) { - *_M_stream << __value; - if (_M_string) *_M_stream << _M_string; - return *this; - } - ostream_iterator<_Tp>& operator*() { return *this; } - ostream_iterator<_Tp>& operator++() { return *this; } - ostream_iterator<_Tp>& operator++(int) { return *this; } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline output_iterator_tag -iterator_category(const ostream_iterator<_Tp>&) { - return output_iterator_tag(); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -#endif /* __STL_USE_NEW_IOSTREAMS */ - - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_ITERATOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_iterator_base.h b/DSTAT1/src/avr-stl/include/stl_iterator_base.h deleted file mode 100644 index 9c54225..0000000 --- a/DSTAT1/src/avr-stl/include/stl_iterator_base.h +++ /dev/null @@ -1,367 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_ITERATOR_BASE_H -#define __SGI_STL_INTERNAL_ITERATOR_BASE_H - -// This file contains all of the general iterator-related utilities. -// The internal file stl_iterator.h contains predefined iterators, -// such as front_insert_iterator and istream_iterator. - -#include - -__STL_BEGIN_NAMESPACE - -struct input_iterator_tag {}; -struct output_iterator_tag {}; -struct forward_iterator_tag : public input_iterator_tag {}; -struct bidirectional_iterator_tag : public forward_iterator_tag {}; -struct random_access_iterator_tag : public bidirectional_iterator_tag {}; - -// The base classes input_iterator, output_iterator, forward_iterator, -// bidirectional_iterator, and random_access_iterator are not part of -// the C++ standard. (They have been replaced by struct iterator.) -// They are included for backward compatibility with the HP STL. - -template struct input_iterator { - typedef input_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -struct output_iterator { - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; -}; - -template struct forward_iterator { - typedef forward_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - - -template struct bidirectional_iterator { - typedef bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -template struct random_access_iterator { - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -#ifdef __STL_USE_NAMESPACES -template -struct iterator { - typedef _Category iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Pointer pointer; - typedef _Reference reference; -}; -#endif /* __STL_USE_NAMESPACES */ - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -struct iterator_traits { - typedef typename _Iterator::iterator_category iterator_category; - typedef typename _Iterator::value_type value_type; - typedef typename _Iterator::difference_type difference_type; - typedef typename _Iterator::pointer pointer; - typedef typename _Iterator::reference reference; -}; - -template -struct iterator_traits<_Tp*> { - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef ptrdiff_t difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -template -struct iterator_traits { - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef ptrdiff_t difference_type; - typedef const _Tp* pointer; - typedef const _Tp& reference; -}; - -// The overloaded functions iterator_category, distance_type, and -// value_type are not part of the C++ standard. (They have been -// replaced by struct iterator_traits.) They are included for -// backward compatibility with the HP STL. - -// We introduce internal names for these functions. - -template -inline typename iterator_traits<_Iter>::iterator_category -__iterator_category(const _Iter&) -{ - typedef typename iterator_traits<_Iter>::iterator_category _Category; - return _Category(); -} - -template -inline typename iterator_traits<_Iter>::difference_type* -__distance_type(const _Iter&) -{ - return static_cast::difference_type*>(0); -} - -template -inline typename iterator_traits<_Iter>::value_type* -__value_type(const _Iter&) -{ - return static_cast::value_type*>(0); -} - -template -inline typename iterator_traits<_Iter>::iterator_category -iterator_category(const _Iter& __i) { return __iterator_category(__i); } - - -template -inline typename iterator_traits<_Iter>::difference_type* -distance_type(const _Iter& __i) { return __distance_type(__i); } - -template -inline typename iterator_traits<_Iter>::value_type* -value_type(const _Iter& __i) { return __value_type(__i); } - -#define __ITERATOR_CATEGORY(__i) __iterator_category(__i) -#define __DISTANCE_TYPE(__i) __distance_type(__i) -#define __VALUE_TYPE(__i) __value_type(__i) - -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline input_iterator_tag -iterator_category(const input_iterator<_Tp, _Distance>&) - { return input_iterator_tag(); } - -inline output_iterator_tag iterator_category(const output_iterator&) - { return output_iterator_tag(); } - -template -inline forward_iterator_tag -iterator_category(const forward_iterator<_Tp, _Distance>&) - { return forward_iterator_tag(); } - -template -inline bidirectional_iterator_tag -iterator_category(const bidirectional_iterator<_Tp, _Distance>&) - { return bidirectional_iterator_tag(); } - -template -inline random_access_iterator_tag -iterator_category(const random_access_iterator<_Tp, _Distance>&) - { return random_access_iterator_tag(); } - -template -inline random_access_iterator_tag iterator_category(const _Tp*) - { return random_access_iterator_tag(); } - -template -inline _Tp* value_type(const input_iterator<_Tp, _Distance>&) - { return (_Tp*)(0); } - -template -inline _Tp* value_type(const forward_iterator<_Tp, _Distance>&) - { return (_Tp*)(0); } - -template -inline _Tp* value_type(const bidirectional_iterator<_Tp, _Distance>&) - { return (_Tp*)(0); } - -template -inline _Tp* value_type(const random_access_iterator<_Tp, _Distance>&) - { return (_Tp*)(0); } - -template -inline _Tp* value_type(const _Tp*) { return (_Tp*)(0); } - -template -inline _Distance* distance_type(const input_iterator<_Tp, _Distance>&) -{ - return (_Distance*)(0); -} - -template -inline _Distance* distance_type(const forward_iterator<_Tp, _Distance>&) -{ - return (_Distance*)(0); -} - -template -inline _Distance* -distance_type(const bidirectional_iterator<_Tp, _Distance>&) -{ - return (_Distance*)(0); -} - -template -inline _Distance* -distance_type(const random_access_iterator<_Tp, _Distance>&) -{ - return (_Distance*)(0); -} - -template -inline ptrdiff_t* distance_type(const _Tp*) { return (ptrdiff_t*)(0); } - -// Without partial specialization we can't use iterator_traits, so -// we must keep the old iterator query functions around. - -#define __ITERATOR_CATEGORY(__i) iterator_category(__i) -#define __DISTANCE_TYPE(__i) distance_type(__i) -#define __VALUE_TYPE(__i) value_type(__i) - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline void __distance(_InputIterator __first, _InputIterator __last, - _Distance& __n, input_iterator_tag) -{ - while (__first != __last) { ++__first; ++__n; } -} - -template -inline void __distance(_RandomAccessIterator __first, - _RandomAccessIterator __last, - _Distance& __n, random_access_iterator_tag) -{ - __STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator); - __n += __last - __first; -} - -template -inline void distance(_InputIterator __first, - _InputIterator __last, _Distance& __n) -{ - __STL_REQUIRES(_InputIterator, _InputIterator); - __distance(__first, __last, __n, iterator_category(__first)); -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline typename iterator_traits<_InputIterator>::difference_type -__distance(_InputIterator __first, _InputIterator __last, input_iterator_tag) -{ - typename iterator_traits<_InputIterator>::difference_type __n = 0; - while (__first != __last) { - ++__first; ++__n; - } - return __n; -} - -template -inline typename iterator_traits<_RandomAccessIterator>::difference_type -__distance(_RandomAccessIterator __first, _RandomAccessIterator __last, - random_access_iterator_tag) { - __STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator); - return __last - __first; -} - -template -inline typename iterator_traits<_InputIterator>::difference_type -distance(_InputIterator __first, _InputIterator __last) { - typedef typename iterator_traits<_InputIterator>::iterator_category - _Category; - __STL_REQUIRES(_InputIterator, _InputIterator); - return __distance(__first, __last, _Category()); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template -inline void __advance(_InputIter& __i, _Distance __n, input_iterator_tag) { - while (__n--) ++__i; -} - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1183 -#endif - -template -inline void __advance(_BidirectionalIterator& __i, _Distance __n, - bidirectional_iterator_tag) { - __STL_REQUIRES(_BidirectionalIterator, _BidirectionalIterator); - if (__n >= 0) - while (__n--) ++__i; - else - while (__n++) --__i; -} - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1183 -#endif - -template -inline void __advance(_RandomAccessIterator& __i, _Distance __n, - random_access_iterator_tag) { - __STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator); - __i += __n; -} - -template -inline void advance(_InputIterator& __i, _Distance __n) { - __STL_REQUIRES(_InputIterator, _InputIterator); - __advance(__i, __n, iterator_category(__i)); -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_ITERATOR_BASE_H */ - - - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_list.h b/DSTAT1/src/avr-stl/include/stl_list.h deleted file mode 100644 index 99a8ddc..0000000 --- a/DSTAT1/src/avr-stl/include/stl_list.h +++ /dev/null @@ -1,885 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_LIST_H -#define __SGI_STL_INTERNAL_LIST_H - -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -struct _List_node_base { - _List_node_base* _M_next; - _List_node_base* _M_prev; -}; - -template -struct _List_node : public _List_node_base { - _Tp _M_data; -}; - -struct _List_iterator_base { - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef bidirectional_iterator_tag iterator_category; - - _List_node_base* _M_node; - - _List_iterator_base(_List_node_base* __x) : _M_node(__x) {} - _List_iterator_base() {} - - void _M_incr() { _M_node = _M_node->_M_next; } - void _M_decr() { _M_node = _M_node->_M_prev; } - - bool operator==(const _List_iterator_base& __x) const { - return _M_node == __x._M_node; - } - bool operator!=(const _List_iterator_base& __x) const { - return _M_node != __x._M_node; - } -}; - -template -struct _List_iterator : public _List_iterator_base { - typedef _List_iterator<_Tp,_Tp&,_Tp*> iterator; - typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator; - typedef _List_iterator<_Tp,_Ref,_Ptr> _Self; - - typedef _Tp value_type; - typedef _Ptr pointer; - typedef _Ref reference; - typedef _List_node<_Tp> _Node; - - _List_iterator(_Node* __x) : _List_iterator_base(__x) {} - _List_iterator() {} - _List_iterator(const iterator& __x) : _List_iterator_base(__x._M_node) {} - - reference operator*() const { return ((_Node*) _M_node)->_M_data; } - -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - - _Self& operator++() { - this->_M_incr(); - return *this; - } - _Self operator++(int) { - _Self __tmp = *this; - this->_M_incr(); - return __tmp; - } - _Self& operator--() { - this->_M_decr(); - return *this; - } - _Self operator--(int) { - _Self __tmp = *this; - this->_M_decr(); - return __tmp; - } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -inline bidirectional_iterator_tag -iterator_category(const _List_iterator_base&) -{ - return bidirectional_iterator_tag(); -} - -template -inline _Tp* -value_type(const _List_iterator<_Tp, _Ref, _Ptr>&) -{ - return 0; -} - -inline ptrdiff_t* -distance_type(const _List_iterator_base&) -{ - return 0; -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - - -// Base class that encapsulates details of allocators. Three cases: -// an ordinary standard-conforming allocator, a standard-conforming -// allocator with no non-static data, and an SGI-style allocator. -// This complexity is necessary only because we're worrying about backward -// compatibility and because we want to avoid wasting storage on an -// allocator instance if it isn't necessary. - -#ifdef __STL_USE_STD_ALLOCATORS - -// Base for general standard-conforming allocators. -template -class _List_alloc_base { -public: - typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return _Node_allocator; } - - _List_alloc_base(const allocator_type& __a) : _Node_allocator(__a) {} - -protected: - _List_node<_Tp>* _M_get_node() - { return _Node_allocator.allocate(1); } - void _M_put_node(_List_node<_Tp>* __p) - { _Node_allocator.deallocate(__p, 1); } - -protected: - typename _Alloc_traits<_List_node<_Tp>, _Allocator>::allocator_type - _Node_allocator; - _List_node<_Tp>* _M_node; -}; - -// Specialization for instanceless allocators. - -template -class _List_alloc_base<_Tp, _Allocator, true> { -public: - typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _List_alloc_base(const allocator_type&) {} - -protected: - typedef typename _Alloc_traits<_List_node<_Tp>, _Allocator>::_Alloc_type - _Alloc_type; - _List_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); } - void _M_put_node(_List_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); } - -protected: - _List_node<_Tp>* _M_node; -}; - -template -class _List_base - : public _List_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> -{ -public: - typedef _List_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> - _Base; - typedef typename _Base::allocator_type allocator_type; - - _List_base(const allocator_type& __a) : _Base(__a) { - _Base::_M_node = _Base::_M_get_node(); - _Base::_M_node->_M_next = _Base::_M_node; - _Base::_M_node->_M_prev = _Base::_M_node; - } - ~_List_base() { - clear(); - _M_put_node(_Base::_M_node); - } - - void clear(); -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -class _List_base -{ -public: - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _List_base(const allocator_type&) { - _M_node = _M_get_node(); - _M_node->_M_next = _M_node; - _M_node->_M_prev = _M_node; - } - ~_List_base() { - clear(); - _M_put_node(_M_node); - } - - void clear(); - -protected: - typedef simple_alloc<_List_node<_Tp>, _Alloc> _Alloc_type; - _List_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); } - void _M_put_node(_List_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); } - -protected: - _List_node<_Tp>* _M_node; -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -template -void -_List_base<_Tp,_Alloc>::clear() -{ - _List_node<_Tp>* __cur = (_List_node<_Tp>*) _Base::_M_node->_M_next; - while (__cur != _Base::_M_node) { - _List_node<_Tp>* __tmp = __cur; - __cur = (_List_node<_Tp>*) __cur->_M_next; - _Destroy(&__tmp->_M_data); - _M_put_node(__tmp); - } - _Base::_M_node->_M_next = _Base::_M_node; - _Base::_M_node->_M_prev = _Base::_M_node; -} - -template -class list : protected _List_base<_Tp, _Alloc> { - // requirements: - - __STL_CLASS_REQUIRES(_Tp, _Assignable); - - typedef _List_base<_Tp, _Alloc> _Base; -protected: - typedef void* _Void_pointer; - -public: - typedef _Tp value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef _List_node<_Tp> _Node; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - typedef typename _Base::allocator_type allocator_type; - allocator_type get_allocator() const { return _Base::get_allocator(); } - -public: - typedef _List_iterator<_Tp,_Tp&,_Tp*> iterator; - typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef std::reverse_bidirectional_iterator - const_reverse_iterator; - typedef std::reverse_bidirectional_iterator - reverse_iterator; -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -protected: -#ifdef __STL_HAS_NAMESPACES - using _Base::_M_node; - using _Base::_M_put_node; - using _Base::_M_get_node; -#endif /* __STL_HAS_NAMESPACES */ - -protected: - _Node* _M_create_node(const _Tp& __x) - { - _Node* __p = _M_get_node(); - __STL_TRY { - _Construct(&__p->_M_data, __x); - } - __STL_UNWIND(_M_put_node(__p)); - return __p; - } - - _Node* _M_create_node() - { - _Node* __p = _M_get_node(); - __STL_TRY { - _Construct(&__p->_M_data); - } - __STL_UNWIND(_M_put_node(__p)); - return __p; - } - -public: - explicit list(const allocator_type& __a = allocator_type()) : _Base(__a) {} - - iterator begin() { return (_Node*)(_M_node->_M_next); } - const_iterator begin() const { return (_Node*)(_M_node->_M_next); } - - iterator end() { return _M_node; } - const_iterator end() const { return _M_node; } - - reverse_iterator rbegin() - { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const - { return const_reverse_iterator(end()); } - - reverse_iterator rend() - { return reverse_iterator(begin()); } - const_reverse_iterator rend() const - { return const_reverse_iterator(begin()); } - - bool empty() const { return _M_node->_M_next == _M_node; } - size_type size() const { - size_type __result = 0; - distance(begin(), end(), __result); - return __result; - } - size_type max_size() const { return size_type(-1); } - - reference front() { return *begin(); } - const_reference front() const { return *begin(); } - reference back() { return *(--end()); } - const_reference back() const { return *(--end()); } - - void swap(list<_Tp, _Alloc>& __x) { __STD::swap(_M_node, __x._M_node); } - - iterator insert(iterator __position, const _Tp& __x) { - _Node* __tmp = _M_create_node(__x); - __tmp->_M_next = __position._M_node; - __tmp->_M_prev = __position._M_node->_M_prev; - __position._M_node->_M_prev->_M_next = __tmp; - __position._M_node->_M_prev = __tmp; - return __tmp; - } - iterator insert(iterator __position) { return insert(__position, _Tp()); } -#ifdef __STL_MEMBER_TEMPLATES - // Check whether it's an integral type. If so, it's not an iterator. - - template - void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, - __true_type) { - _M_fill_insert(__pos, (size_type) __n, (_Tp) __x); - } - - template - void _M_insert_dispatch(iterator __pos, - _InputIterator __first, _InputIterator __last, - __false_type); - - template - void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_insert_dispatch(__pos, __first, __last, _Integral()); - } - -#else /* __STL_MEMBER_TEMPLATES */ - void insert(iterator __position, const _Tp* __first, const _Tp* __last); - void insert(iterator __position, - const_iterator __first, const_iterator __last); -#endif /* __STL_MEMBER_TEMPLATES */ - void insert(iterator __pos, size_type __n, const _Tp& __x) - { _M_fill_insert(__pos, __n, __x); } - void _M_fill_insert(iterator __pos, size_type __n, const _Tp& __x); - - void push_front(const _Tp& __x) { insert(begin(), __x); } - void push_front() {insert(begin());} - void push_back(const _Tp& __x) { insert(end(), __x); } - void push_back() {insert(end());} - - iterator erase(iterator __position) { - _List_node_base* __next_node = __position._M_node->_M_next; - _List_node_base* __prev_node = __position._M_node->_M_prev; - _Node* __n = (_Node*) __position._M_node; - __prev_node->_M_next = __next_node; - __next_node->_M_prev = __prev_node; - _Destroy(&__n->_M_data); - _M_put_node(__n); - return iterator((_Node*) __next_node); - } - iterator erase(iterator __first, iterator __last); - void clear() { _Base::clear(); } - - void resize(size_type __new_size, const _Tp& __x); - void resize(size_type __new_size) { this->resize(__new_size, _Tp()); } - - void pop_front() { erase(begin()); } - void pop_back() { - iterator __tmp = end(); - erase(--__tmp); - } - list(size_type __n, const _Tp& __value, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { insert(begin(), __n, __value); } - explicit list(size_type __n) - : _Base(allocator_type()) - { insert(begin(), __n, _Tp()); } - -#ifdef __STL_MEMBER_TEMPLATES - - // We don't need any dispatching tricks here, because insert does all of - // that anyway. - template - list(_InputIterator __first, _InputIterator __last, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { insert(begin(), __first, __last); } - -#else /* __STL_MEMBER_TEMPLATES */ - - list(const _Tp* __first, const _Tp* __last, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { this->insert(begin(), __first, __last); } - list(const_iterator __first, const_iterator __last, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { this->insert(begin(), __first, __last); } - -#endif /* __STL_MEMBER_TEMPLATES */ - list(const list<_Tp, _Alloc>& __x) : _Base(__x.get_allocator()) - { insert(begin(), __x.begin(), __x.end()); } - - ~list() { } - - list<_Tp, _Alloc>& operator=(const list<_Tp, _Alloc>& __x); - -public: - // assign(), a generalized assignment member function. Two - // versions: one that takes a count, and one that takes a range. - // The range version is a member template, so we dispatch on whether - // or not the type is an integer. - - void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); } - - void _M_fill_assign(size_type __n, const _Tp& __val); - -#ifdef __STL_MEMBER_TEMPLATES - - template - void assign(_InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_assign_dispatch(__first, __last, _Integral()); - } - - template - void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { _M_fill_assign((size_type) __n, (_Tp) __val); } - - template - void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, - __false_type); - -#endif /* __STL_MEMBER_TEMPLATES */ - -protected: - void transfer(iterator __position, iterator __first, iterator __last) { - if (__position != __last) { - // Remove [first, last) from its old position. - __last._M_node->_M_prev->_M_next = __position._M_node; - __first._M_node->_M_prev->_M_next = __last._M_node; - __position._M_node->_M_prev->_M_next = __first._M_node; - - // Splice [first, last) into its new position. - _List_node_base* __tmp = __position._M_node->_M_prev; - __position._M_node->_M_prev = __last._M_node->_M_prev; - __last._M_node->_M_prev = __first._M_node->_M_prev; - __first._M_node->_M_prev = __tmp; - } - } - -public: - void splice(iterator __position, list& __x) { - if (!__x.empty()) - this->transfer(__position, __x.begin(), __x.end()); - } - void splice(iterator __position, list&, iterator __i) { - iterator __j = __i; - ++__j; - if (__position == __i || __position == __j) return; - this->transfer(__position, __i, __j); - } - void splice(iterator __position, list&, iterator __first, iterator __last) { - if (__first != __last) - this->transfer(__position, __first, __last); - } - void remove(const _Tp& __value); - void unique(); - void merge(list& __x); - void reverse(); - void sort(); - -#ifdef __STL_MEMBER_TEMPLATES - template void remove_if(_Predicate); - template void unique(_BinaryPredicate); - template void merge(list&, _StrictWeakOrdering); - template void sort(_StrictWeakOrdering); -#endif /* __STL_MEMBER_TEMPLATES */ -}; - -template -inline bool -operator==(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y) -{ - typedef typename list<_Tp,_Alloc>::const_iterator const_iterator; - const_iterator __end1 = __x.end(); - const_iterator __end2 = __y.end(); - - const_iterator __i1 = __x.begin(); - const_iterator __i2 = __y.begin(); - while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) { - ++__i1; - ++__i2; - } - return __i1 == __end1 && __i2 == __end2; -} - -template -inline bool operator<(const list<_Tp,_Alloc>& __x, - const list<_Tp,_Alloc>& __y) -{ - return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=(const list<_Tp,_Alloc>& __x, - const list<_Tp,_Alloc>& __y) { - return !(__x == __y); -} - -template -inline bool operator>(const list<_Tp,_Alloc>& __x, - const list<_Tp,_Alloc>& __y) { - return __y < __x; -} - -template -inline bool operator<=(const list<_Tp,_Alloc>& __x, - const list<_Tp,_Alloc>& __y) { - return !(__y < __x); -} - -template -inline bool operator>=(const list<_Tp,_Alloc>& __x, - const list<_Tp,_Alloc>& __y) { - return !(__x < __y); -} - -template -inline void -swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) -{ - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#ifdef __STL_MEMBER_TEMPLATES - -template template -void -list<_Tp, _Alloc>::_M_insert_dispatch(iterator __position, - _InputIter __first, _InputIter __last, - __false_type) -{ - for ( ; __first != __last; ++__first) - insert(__position, *__first); -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -void -list<_Tp, _Alloc>::insert(iterator __position, - const _Tp* __first, const _Tp* __last) -{ - for ( ; __first != __last; ++__first) - insert(__position, *__first); -} - -template -void -list<_Tp, _Alloc>::insert(iterator __position, - const_iterator __first, const_iterator __last) -{ - for ( ; __first != __last; ++__first) - insert(__position, *__first); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -void -list<_Tp, _Alloc>::_M_fill_insert(iterator __position, - size_type __n, const _Tp& __x) -{ - for ( ; __n > 0; --__n) - insert(__position, __x); -} - -template -typename list<_Tp,_Alloc>::iterator list<_Tp, _Alloc>::erase(iterator __first, - iterator __last) -{ - while (__first != __last) - erase(__first++); - return __last; -} - -template -void list<_Tp, _Alloc>::resize(size_type __new_size, const _Tp& __x) -{ - iterator __i = begin(); - size_type __len = 0; - for ( ; __i != end() && __len < __new_size; ++__i, ++__len) - ; - if (__len == __new_size) - erase(__i, end()); - else // __i == end() - insert(end(), __new_size - __len, __x); -} - -template -list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list<_Tp, _Alloc>& __x) -{ - if (this != &__x) { - iterator __first1 = begin(); - iterator __last1 = end(); - const_iterator __first2 = __x.begin(); - const_iterator __last2 = __x.end(); - while (__first1 != __last1 && __first2 != __last2) - *__first1++ = *__first2++; - if (__first2 == __last2) - erase(__first1, __last1); - else - insert(__last1, __first2, __last2); - } - return *this; -} - -template -void list<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val) { - iterator __i = begin(); - for ( ; __i != end() && __n > 0; ++__i, --__n) - *__i = __val; - if (__n > 0) - insert(end(), __n, __val); - else - erase(__i, end()); -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -void -list<_Tp, _Alloc>::_M_assign_dispatch(_InputIter __first2, _InputIter __last2, - __false_type) -{ - iterator __first1 = begin(); - iterator __last1 = end(); - for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) - *__first1 = *__first2; - if (__first2 == __last2) - erase(__first1, __last1); - else - insert(__last1, __first2, __last2); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -void list<_Tp, _Alloc>::remove(const _Tp& __value) -{ - iterator __first = begin(); - iterator __last = end(); - while (__first != __last) { - iterator __next = __first; - ++__next; - if (*__first == __value) erase(__first); - __first = __next; - } -} - -template -void list<_Tp, _Alloc>::unique() -{ - iterator __first = begin(); - iterator __last = end(); - if (__first == __last) return; - iterator __next = __first; - while (++__next != __last) { - if (*__first == *__next) - erase(__next); - else - __first = __next; - __next = __first; - } -} - -template -void list<_Tp, _Alloc>::merge(list<_Tp, _Alloc>& __x) -{ - iterator __first1 = begin(); - iterator __last1 = end(); - iterator __first2 = __x.begin(); - iterator __last2 = __x.end(); - while (__first1 != __last1 && __first2 != __last2) - if (*__first2 < *__first1) { - iterator __next = __first2; - transfer(__first1, __first2, ++__next); - __first2 = __next; - } - else - ++__first1; - if (__first2 != __last2) transfer(__last1, __first2, __last2); -} - -inline void __List_base_reverse(_List_node_base* __p) -{ - _List_node_base* __tmp = __p; - do { - __STD::swap(__tmp->_M_next, __tmp->_M_prev); - __tmp = __tmp->_M_prev; // Old next node is now prev. - } while (__tmp != __p); -} - -template -inline void list<_Tp, _Alloc>::reverse() -{ - __List_base_reverse(this->_M_node); -} - -template -void list<_Tp, _Alloc>::sort() -{ - // Do nothing if the list has length 0 or 1. - if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node) { - list<_Tp, _Alloc> __carry; - list<_Tp, _Alloc> __counter[64]; - int __fill = 0; - while (!empty()) { - __carry.splice(__carry.begin(), *this, begin()); - int __i = 0; - while(__i < __fill && !__counter[__i].empty()) { - __counter[__i].merge(__carry); - __carry.swap(__counter[__i++]); - } - __carry.swap(__counter[__i]); - if (__i == __fill) ++__fill; - } - - for (int __i = 1; __i < __fill; ++__i) - __counter[__i].merge(__counter[__i-1]); - swap(__counter[__fill-1]); - } -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -void list<_Tp, _Alloc>::remove_if(_Predicate __pred) -{ - iterator __first = begin(); - iterator __last = end(); - while (__first != __last) { - iterator __next = __first; - ++__next; - if (__pred(*__first)) erase(__first); - __first = __next; - } -} - -template template -void list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) -{ - iterator __first = begin(); - iterator __last = end(); - if (__first == __last) return; - iterator __next = __first; - while (++__next != __last) { - if (__binary_pred(*__first, *__next)) - erase(__next); - else - __first = __next; - __next = __first; - } -} - -template template -void list<_Tp, _Alloc>::merge(list<_Tp, _Alloc>& __x, - _StrictWeakOrdering __comp) -{ - iterator __first1 = begin(); - iterator __last1 = end(); - iterator __first2 = __x.begin(); - iterator __last2 = __x.end(); - while (__first1 != __last1 && __first2 != __last2) - if (__comp(*__first2, *__first1)) { - iterator __next = __first2; - transfer(__first1, __first2, ++__next); - __first2 = __next; - } - else - ++__first1; - if (__first2 != __last2) transfer(__last1, __first2, __last2); -} - -template template -void list<_Tp, _Alloc>::sort(_StrictWeakOrdering __comp) -{ - // Do nothing if the list has length 0 or 1. - if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node) { - list<_Tp, _Alloc> __carry; - list<_Tp, _Alloc> __counter[64]; - int __fill = 0; - while (!empty()) { - __carry.splice(__carry.begin(), *this, begin()); - int __i = 0; - while(__i < __fill && !__counter[__i].empty()) { - __counter[__i].merge(__carry, __comp); - __carry.swap(__counter[__i++]); - } - __carry.swap(__counter[__i]); - if (__i == __fill) ++__fill; - } - - for (int __i = 1; __i < __fill; ++__i) - __counter[__i].merge(__counter[__i-1], __comp); - swap(__counter[__fill-1]); - } -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_LIST_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_map.h b/DSTAT1/src/avr-stl/include/stl_map.h deleted file mode 100644 index a2ea66c..0000000 --- a/DSTAT1/src/avr-stl/include/stl_map.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_MAP_H -#define __SGI_STL_INTERNAL_MAP_H - -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -// Forward declarations of operators == and <, needed for friend declarations. -template ), - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) > -class map; - -template -inline bool operator==(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y); - -template -inline bool operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y); - -template -class map { -public: - -// requirements: - - __STL_CLASS_REQUIRES(_Tp, _Assignable); - __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key); - -// typedefs: - - typedef _Key key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef pair value_type; - typedef _Compare key_compare; - - class value_compare - : public binary_function { - friend class map<_Key,_Tp,_Compare,_Alloc>; - protected : - _Compare comp; - value_compare(_Compare __c) : comp(__c) {} - public: - bool operator()(const value_type& __x, const value_type& __y) const { - return comp(__x.first, __y.first); - } - }; - -private: - typedef _Rb_tree, key_compare, _Alloc> _Rep_type; - _Rep_type _M_t; // red-black tree representing map -public: - typedef typename _Rep_type::pointer pointer; - typedef typename _Rep_type::const_pointer const_pointer; - typedef typename _Rep_type::reference reference; - typedef typename _Rep_type::const_reference const_reference; - typedef typename _Rep_type::iterator iterator; - typedef typename _Rep_type::const_iterator const_iterator; - typedef typename _Rep_type::reverse_iterator reverse_iterator; - typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; - typedef typename _Rep_type::size_type size_type; - typedef typename _Rep_type::difference_type difference_type; - typedef typename _Rep_type::allocator_type allocator_type; - - // allocation/deallocation - - map() : _M_t(_Compare(), allocator_type()) {} - explicit map(const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - map(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - template - map(_InputIterator __first, _InputIterator __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } -#else - map(const value_type* __first, const value_type* __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - map(const value_type* __first, - const value_type* __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } - - map(const_iterator __first, const_iterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - map(const_iterator __first, const_iterator __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } - -#endif /* __STL_MEMBER_TEMPLATES */ - - map(const map<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {} - map<_Key,_Tp,_Compare,_Alloc>& - operator=(const map<_Key, _Tp, _Compare, _Alloc>& __x) - { - _M_t = __x._M_t; - return *this; - } - - // accessors: - - key_compare key_comp() const { return _M_t.key_comp(); } - value_compare value_comp() const { return value_compare(_M_t.key_comp()); } - allocator_type get_allocator() const { return _M_t.get_allocator(); } - - iterator begin() { return _M_t.begin(); } - const_iterator begin() const { return _M_t.begin(); } - iterator end() { return _M_t.end(); } - const_iterator end() const { return _M_t.end(); } - reverse_iterator rbegin() { return _M_t.rbegin(); } - const_reverse_iterator rbegin() const { return _M_t.rbegin(); } - reverse_iterator rend() { return _M_t.rend(); } - const_reverse_iterator rend() const { return _M_t.rend(); } - bool empty() const { return _M_t.empty(); } - size_type size() const { return _M_t.size(); } - size_type max_size() const { return _M_t.max_size(); } - _Tp& operator[](const key_type& __k) { - iterator __i = lower_bound(__k); - // __i->first is greater than or equivalent to __k. - if (__i == end() || key_comp()(__k, (*__i).first)) - __i = insert(__i, value_type(__k, _Tp())); - return (*__i).second; - } - void swap(map<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); } - - // insert/erase - - pair insert(const value_type& __x) - { return _M_t.insert_unique(__x); } - iterator insert(iterator position, const value_type& __x) - { return _M_t.insert_unique(position, __x); } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __first, _InputIterator __last) { - _M_t.insert_unique(__first, __last); - } -#else - void insert(const value_type* __first, const value_type* __last) { - _M_t.insert_unique(__first, __last); - } - void insert(const_iterator __first, const_iterator __last) { - _M_t.insert_unique(__first, __last); - } -#endif /* __STL_MEMBER_TEMPLATES */ - - void erase(iterator __position) { _M_t.erase(__position); } - size_type erase(const key_type& __x) { return _M_t.erase(__x); } - void erase(iterator __first, iterator __last) - { _M_t.erase(__first, __last); } - void clear() { _M_t.clear(); } - - // map operations: - - iterator find(const key_type& __x) { return _M_t.find(__x); } - const_iterator find(const key_type& __x) const { return _M_t.find(__x); } - size_type count(const key_type& __x) const { - return _M_t.find(__x) == _M_t.end() ? 0 : 1; - } - iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); } - const_iterator lower_bound(const key_type& __x) const { - return _M_t.lower_bound(__x); - } - iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); } - const_iterator upper_bound(const key_type& __x) const { - return _M_t.upper_bound(__x); - } - - pair equal_range(const key_type& __x) { - return _M_t.equal_range(__x); - } - pair equal_range(const key_type& __x) const { - return _M_t.equal_range(__x); - } - -#ifdef __STL_TEMPLATE_FRIENDS - template - friend bool operator== (const map<_K1, _T1, _C1, _A1>&, - const map<_K1, _T1, _C1, _A1>&); - template - friend bool operator< (const map<_K1, _T1, _C1, _A1>&, - const map<_K1, _T1, _C1, _A1>&); -#else /* __STL_TEMPLATE_FRIENDS */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const map&, const map&); - friend bool __STD_QUALIFIER - operator< __STL_NULL_TMPL_ARGS (const map&, const map&); -#endif /* __STL_TEMPLATE_FRIENDS */ -}; - -template -inline bool operator==(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) { - return __x._M_t == __y._M_t; -} - -template -inline bool operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) { - return __x._M_t < __y._M_t; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) { - return !(__x == __y); -} - -template -inline bool operator>(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) { - return __y < __x; -} - -template -inline bool operator<=(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) { - return !(__y < __x); -} - -template -inline bool operator>=(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) { - return !(__x < __y); -} - -template -inline void swap(map<_Key,_Tp,_Compare,_Alloc>& __x, - map<_Key,_Tp,_Compare,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_MAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_multimap.h b/DSTAT1/src/avr-stl/include/stl_multimap.h deleted file mode 100644 index ecd959c..0000000 --- a/DSTAT1/src/avr-stl/include/stl_multimap.h +++ /dev/null @@ -1,282 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_MULTIMAP_H -#define __SGI_STL_INTERNAL_MULTIMAP_H - -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -// Forward declaration of operators < and ==, needed for friend declaration. - -template ), - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) > -class multimap; - -template -inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y); - -template -inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y); - -template -class multimap { - // requirements: - - __STL_CLASS_REQUIRES(_Tp, _Assignable); - __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key); - -public: - -// typedefs: - - typedef _Key key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef pair value_type; - typedef _Compare key_compare; - - class value_compare : public binary_function { - friend class multimap<_Key,_Tp,_Compare,_Alloc>; - protected: - _Compare comp; - value_compare(_Compare __c) : comp(__c) {} - public: - bool operator()(const value_type& __x, const value_type& __y) const { - return comp(__x.first, __y.first); - } - }; - -private: - typedef _Rb_tree, key_compare, _Alloc> _Rep_type; - _Rep_type _M_t; // red-black tree representing multimap -public: - typedef typename _Rep_type::pointer pointer; - typedef typename _Rep_type::const_pointer const_pointer; - typedef typename _Rep_type::reference reference; - typedef typename _Rep_type::const_reference const_reference; - typedef typename _Rep_type::iterator iterator; - typedef typename _Rep_type::const_iterator const_iterator; - typedef typename _Rep_type::reverse_iterator reverse_iterator; - typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; - typedef typename _Rep_type::size_type size_type; - typedef typename _Rep_type::difference_type difference_type; - typedef typename _Rep_type::allocator_type allocator_type; - -// allocation/deallocation - - multimap() : _M_t(_Compare(), allocator_type()) { } - explicit multimap(const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { } - -#ifdef __STL_MEMBER_TEMPLATES - template - multimap(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - - template - multimap(_InputIterator __first, _InputIterator __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } -#else - multimap(const value_type* __first, const value_type* __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - multimap(const value_type* __first, const value_type* __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } - - multimap(const_iterator __first, const_iterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - multimap(const_iterator __first, const_iterator __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } -#endif /* __STL_MEMBER_TEMPLATES */ - - multimap(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) { } - multimap<_Key,_Tp,_Compare,_Alloc>& - operator=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) { - _M_t = __x._M_t; - return *this; - } - - // accessors: - - key_compare key_comp() const { return _M_t.key_comp(); } - value_compare value_comp() const { return value_compare(_M_t.key_comp()); } - allocator_type get_allocator() const { return _M_t.get_allocator(); } - - iterator begin() { return _M_t.begin(); } - const_iterator begin() const { return _M_t.begin(); } - iterator end() { return _M_t.end(); } - const_iterator end() const { return _M_t.end(); } - reverse_iterator rbegin() { return _M_t.rbegin(); } - const_reverse_iterator rbegin() const { return _M_t.rbegin(); } - reverse_iterator rend() { return _M_t.rend(); } - const_reverse_iterator rend() const { return _M_t.rend(); } - bool empty() const { return _M_t.empty(); } - size_type size() const { return _M_t.size(); } - size_type max_size() const { return _M_t.max_size(); } - void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); } - - // insert/erase - - iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); } - iterator insert(iterator __position, const value_type& __x) { - return _M_t.insert_equal(__position, __x); - } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __first, _InputIterator __last) { - _M_t.insert_equal(__first, __last); - } -#else - void insert(const value_type* __first, const value_type* __last) { - _M_t.insert_equal(__first, __last); - } - void insert(const_iterator __first, const_iterator __last) { - _M_t.insert_equal(__first, __last); - } -#endif /* __STL_MEMBER_TEMPLATES */ - void erase(iterator __position) { _M_t.erase(__position); } - size_type erase(const key_type& __x) { return _M_t.erase(__x); } - void erase(iterator __first, iterator __last) - { _M_t.erase(__first, __last); } - void clear() { _M_t.clear(); } - - // multimap operations: - - iterator find(const key_type& __x) { return _M_t.find(__x); } - const_iterator find(const key_type& __x) const { return _M_t.find(__x); } - size_type count(const key_type& __x) const { return _M_t.count(__x); } - iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); } - const_iterator lower_bound(const key_type& __x) const { - return _M_t.lower_bound(__x); - } - iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); } - const_iterator upper_bound(const key_type& __x) const { - return _M_t.upper_bound(__x); - } - pair equal_range(const key_type& __x) { - return _M_t.equal_range(__x); - } - pair equal_range(const key_type& __x) const { - return _M_t.equal_range(__x); - } - -#ifdef __STL_TEMPLATE_FRIENDS - template - friend bool operator== (const multimap<_K1, _T1, _C1, _A1>&, - const multimap<_K1, _T1, _C1, _A1>&); - template - friend bool operator< (const multimap<_K1, _T1, _C1, _A1>&, - const multimap<_K1, _T1, _C1, _A1>&); -#else /* __STL_TEMPLATE_FRIENDS */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const multimap&, const multimap&); - friend bool __STD_QUALIFIER - operator< __STL_NULL_TMPL_ARGS (const multimap&, const multimap&); -#endif /* __STL_TEMPLATE_FRIENDS */ -}; - -template -inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { - return __x._M_t == __y._M_t; -} - -template -inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { - return __x._M_t < __y._M_t; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { - return !(__x == __y); -} - -template -inline bool operator>(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { - return __y < __x; -} - -template -inline bool operator<=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { - return !(__y < __x); -} - -template -inline bool operator>=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { - return !(__x < __y); -} - -template -inline void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x, - multimap<_Key,_Tp,_Compare,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_MULTIMAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_multiset.h b/DSTAT1/src/avr-stl/include/stl_multiset.h deleted file mode 100644 index 5365ffb..0000000 --- a/DSTAT1/src/avr-stl/include/stl_multiset.h +++ /dev/null @@ -1,274 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_MULTISET_H -#define __SGI_STL_INTERNAL_MULTISET_H - -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -// Forward declaration of operators < and ==, needed for friend declaration. - -template ), - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) > -class multiset; - -template -inline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y); - -template -inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y); - -template -class multiset { - // requirements: - - __STL_CLASS_REQUIRES(_Key, _Assignable); - __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key); - -public: - - // typedefs: - - typedef _Key key_type; - typedef _Key value_type; - typedef _Compare key_compare; - typedef _Compare value_compare; -private: - typedef _Rb_tree, key_compare, _Alloc> _Rep_type; - _Rep_type _M_t; // red-black tree representing multiset -public: - typedef typename _Rep_type::const_pointer pointer; - typedef typename _Rep_type::const_pointer const_pointer; - typedef typename _Rep_type::const_reference reference; - typedef typename _Rep_type::const_reference const_reference; - typedef typename _Rep_type::const_iterator iterator; - typedef typename _Rep_type::const_iterator const_iterator; - typedef typename _Rep_type::const_reverse_iterator reverse_iterator; - typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; - typedef typename _Rep_type::size_type size_type; - typedef typename _Rep_type::difference_type difference_type; - typedef typename _Rep_type::allocator_type allocator_type; - - // allocation/deallocation - - multiset() : _M_t(_Compare(), allocator_type()) {} - explicit multiset(const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - - template - multiset(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - - template - multiset(_InputIterator __first, _InputIterator __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } - -#else - - multiset(const value_type* __first, const value_type* __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - - multiset(const value_type* __first, const value_type* __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } - - multiset(const_iterator __first, const_iterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } - - multiset(const_iterator __first, const_iterator __last, - const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } - -#endif /* __STL_MEMBER_TEMPLATES */ - - multiset(const multiset<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {} - multiset<_Key,_Compare,_Alloc>& - operator=(const multiset<_Key,_Compare,_Alloc>& __x) { - _M_t = __x._M_t; - return *this; - } - - // accessors: - - key_compare key_comp() const { return _M_t.key_comp(); } - value_compare value_comp() const { return _M_t.key_comp(); } - allocator_type get_allocator() const { return _M_t.get_allocator(); } - - iterator begin() const { return _M_t.begin(); } - iterator end() const { return _M_t.end(); } - reverse_iterator rbegin() const { return _M_t.rbegin(); } - reverse_iterator rend() const { return _M_t.rend(); } - bool empty() const { return _M_t.empty(); } - size_type size() const { return _M_t.size(); } - size_type max_size() const { return _M_t.max_size(); } - void swap(multiset<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); } - - // insert/erase - iterator insert(const value_type& __x) { - return _M_t.insert_equal(__x); - } - iterator insert(iterator __position, const value_type& __x) { - typedef typename _Rep_type::iterator _Rep_iterator; - return _M_t.insert_equal((_Rep_iterator&)__position, __x); - } - -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __first, _InputIterator __last) { - _M_t.insert_equal(__first, __last); - } -#else - void insert(const value_type* __first, const value_type* __last) { - _M_t.insert_equal(__first, __last); - } - void insert(const_iterator __first, const_iterator __last) { - _M_t.insert_equal(__first, __last); - } -#endif /* __STL_MEMBER_TEMPLATES */ - void erase(iterator __position) { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__position); - } - size_type erase(const key_type& __x) { - return _M_t.erase(__x); - } - void erase(iterator __first, iterator __last) { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last); - } - void clear() { _M_t.clear(); } - - // multiset operations: - - iterator find(const key_type& __x) const { return _M_t.find(__x); } - size_type count(const key_type& __x) const { return _M_t.count(__x); } - iterator lower_bound(const key_type& __x) const { - return _M_t.lower_bound(__x); - } - iterator upper_bound(const key_type& __x) const { - return _M_t.upper_bound(__x); - } - pair equal_range(const key_type& __x) const { - return _M_t.equal_range(__x); - } - -#ifdef __STL_TEMPLATE_FRIENDS - template - friend bool operator== (const multiset<_K1,_C1,_A1>&, - const multiset<_K1,_C1,_A1>&); - template - friend bool operator< (const multiset<_K1,_C1,_A1>&, - const multiset<_K1,_C1,_A1>&); -#else /* __STL_TEMPLATE_FRIENDS */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const multiset&, const multiset&); - friend bool __STD_QUALIFIER - operator< __STL_NULL_TMPL_ARGS (const multiset&, const multiset&); -#endif /* __STL_TEMPLATE_FRIENDS */ -}; - -template -inline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) { - return __x._M_t == __y._M_t; -} - -template -inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) { - return __x._M_t < __y._M_t; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) { - return !(__x == __y); -} - -template -inline bool operator>(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) { - return __y < __x; -} - -template -inline bool operator<=(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) { - return !(__y < __x); -} - -template -inline bool operator>=(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) { - return !(__x < __y); -} - -template -inline void swap(multiset<_Key,_Compare,_Alloc>& __x, - multiset<_Key,_Compare,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_MULTISET_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_numeric.h b/DSTAT1/src/avr-stl/include/stl_numeric.h deleted file mode 100644 index f8e9594..0000000 --- a/DSTAT1/src/avr-stl/include/stl_numeric.h +++ /dev/null @@ -1,255 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - - -#ifndef __SGI_STL_INTERNAL_NUMERIC_H -#define __SGI_STL_INTERNAL_NUMERIC_H - -__STL_BEGIN_NAMESPACE - -template -_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) -{ - __STL_REQUIRES(_InputIterator, _InputIterator); - for ( ; __first != __last; ++__first) - __init = __init + *__first; - return __init; -} - -template -_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, - _BinaryOperation __binary_op) -{ - __STL_REQUIRES(_InputIterator, _InputIterator); - for ( ; __first != __last; ++__first) - __init = __binary_op(__init, *__first); - return __init; -} - -template -_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, - _InputIterator2 __first2, _Tp __init) -{ - __STL_REQUIRES(_InputIterator2, _InputIterator); - __STL_REQUIRES(_InputIterator2, _InputIterator); - for ( ; __first1 != __last1; ++__first1, ++__first2) - __init = __init + (*__first1 * *__first2); - return __init; -} - -template -_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, - _InputIterator2 __first2, _Tp __init, - _BinaryOperation1 __binary_op1, - _BinaryOperation2 __binary_op2) -{ - __STL_REQUIRES(_InputIterator2, _InputIterator); - __STL_REQUIRES(_InputIterator2, _InputIterator); - for ( ; __first1 != __last1; ++__first1, ++__first2) - __init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); - return __init; -} - -template -_OutputIterator -__partial_sum(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _Tp*) -{ - _Tp __value = *__first; - while (++__first != __last) { - __value = __value + *__first; - *++__result = __value; - } - return ++__result; -} - -template -_OutputIterator -partial_sum(_InputIterator __first, _InputIterator __last, - _OutputIterator __result) -{ - __STL_REQUIRES(_InputIterator, _InputIterator); - __STL_REQUIRES(_OutputIterator, _OutputIterator); - if (__first == __last) return __result; - *__result = *__first; - return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first)); -} - -template -_OutputIterator -__partial_sum(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _Tp*, _BinaryOperation __binary_op) -{ - _Tp __value = *__first; - while (++__first != __last) { - __value = __binary_op(__value, *__first); - *++__result = __value; - } - return ++__result; -} - -template -_OutputIterator -partial_sum(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _BinaryOperation __binary_op) -{ - __STL_REQUIRES(_InputIterator, _InputIterator); - __STL_REQUIRES(_OutputIterator, _OutputIterator); - if (__first == __last) return __result; - *__result = *__first; - return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first), - __binary_op); -} - -template -_OutputIterator -__adjacent_difference(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _Tp*) -{ - _Tp __value = *__first; - while (++__first != __last) { - _Tp __tmp = *__first; - *++__result = __tmp - __value; - __value = __tmp; - } - return ++__result; -} - -template -_OutputIterator -adjacent_difference(_InputIterator __first, - _InputIterator __last, _OutputIterator __result) -{ - __STL_REQUIRES(_InputIterator, _InputIterator); - __STL_REQUIRES(_OutputIterator, _OutputIterator); - if (__first == __last) return __result; - *__result = *__first; - return __adjacent_difference(__first, __last, __result, - __VALUE_TYPE(__first)); -} - -template -_OutputIterator -__adjacent_difference(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _Tp*, - _BinaryOperation __binary_op) { - _Tp __value = *__first; - while (++__first != __last) { - _Tp __tmp = *__first; - *++__result = __binary_op(__tmp, __value); - __value = __tmp; - } - return ++__result; -} - -template -_OutputIterator -adjacent_difference(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, _BinaryOperation __binary_op) -{ - __STL_REQUIRES(_InputIterator, _InputIterator); - __STL_REQUIRES(_OutputIterator, _OutputIterator); - if (__first == __last) return __result; - *__result = *__first; - return __adjacent_difference(__first, __last, __result, - __VALUE_TYPE(__first), - __binary_op); -} - -// Returns __x ** __n, where __n >= 0. _Note that "multiplication" -// is required to be associative, but not necessarily commutative. - - -template -_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr) -{ - if (__n == 0) - return identity_element(__opr); - else { - while ((__n & 1) == 0) { - __n >>= 1; - __x = __opr(__x, __x); - } - - _Tp __result = __x; - __n >>= 1; - while (__n != 0) { - __x = __opr(__x, __x); - if ((__n & 1) != 0) - __result = __opr(__result, __x); - __n >>= 1; - } - return __result; - } -} - -template -inline _Tp __power(_Tp __x, _Integer __n) -{ - return __power(__x, __n, multiplies<_Tp>()); -} - -// Alias for the internal name __power. Note that power is an extension, -// not part of the C++ standard. - -template -inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __opr) -{ - return __power(__x, __n, __opr); -} - -template -inline _Tp power(_Tp __x, _Integer __n) -{ - return __power(__x, __n); -} - -// iota is not part of the C++ standard. It is an extension. - -template -void -iota(_ForwardIter __first, _ForwardIter __last, _Tp __value) -{ - __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); - __STL_CONVERTIBLE(_Tp, typename iterator_traits<_ForwardIter>::value_type); - while (__first != __last) - *__first++ = __value++; -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_NUMERIC_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_pair.h b/DSTAT1/src/avr-stl/include/stl_pair.h deleted file mode 100644 index a6155a6..0000000 --- a/DSTAT1/src/avr-stl/include/stl_pair.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_PAIR_H -#define __SGI_STL_INTERNAL_PAIR_H - -__STL_BEGIN_NAMESPACE - -template -struct pair { - typedef _T1 first_type; - typedef _T2 second_type; - - _T1 first; - _T2 second; - pair() : first(_T1()), second(_T2()) {} - pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} -#endif -}; - -template -inline bool operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) -{ - return __x.first == __y.first && __x.second == __y.second; -} - -template -inline bool operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) -{ - return __x.first < __y.first || - (!(__y.first < __x.first) && __x.second < __y.second); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { - return !(__x == __y); -} - -template -inline bool operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { - return __y < __x; -} - -template -inline bool operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { - return !(__y < __x); -} - -template -inline bool operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { - return !(__x < __y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -template -inline pair<_T1, _T2> make_pair(const _T1& __x, const _T2& __y) -{ - return pair<_T1, _T2>(__x, __y); -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_PAIR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_queue.h b/DSTAT1/src/avr-stl/include/stl_queue.h deleted file mode 100644 index 833e45f..0000000 --- a/DSTAT1/src/avr-stl/include/stl_queue.h +++ /dev/null @@ -1,243 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_QUEUE_H -#define __SGI_STL_INTERNAL_QUEUE_H - -#include - -__STL_BEGIN_NAMESPACE - -// Forward declarations of operators < and ==, needed for friend declaration. - -template ) > -class queue; - -template -inline bool operator==(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&); - -template -inline bool operator<(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&); - - -template -class queue { - - // requirements: - - __STL_CLASS_REQUIRES(_Tp, _Assignable); - __STL_CLASS_REQUIRES(_Sequence, _FrontInsertionSequence); - __STL_CLASS_REQUIRES(_Sequence, _BackInsertionSequence); - typedef typename _Sequence::value_type _Sequence_value_type; - __STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type); - - -#ifdef __STL_MEMBER_TEMPLATES - template - friend bool operator== (const queue<_Tp1, _Seq1>&, - const queue<_Tp1, _Seq1>&); - template - friend bool operator< (const queue<_Tp1, _Seq1>&, - const queue<_Tp1, _Seq1>&); -#else /* __STL_MEMBER_TEMPLATES */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const queue&, const queue&); - friend bool __STD_QUALIFIER - operator< __STL_NULL_TMPL_ARGS (const queue&, const queue&); -#endif /* __STL_MEMBER_TEMPLATES */ - -public: - typedef typename _Sequence::value_type value_type; - typedef typename _Sequence::size_type size_type; - typedef _Sequence container_type; - - typedef typename _Sequence::reference reference; - typedef typename _Sequence::const_reference const_reference; -protected: - _Sequence c; -public: - queue() : c() {} - explicit queue(const _Sequence& __c) : c(__c) {} - - bool empty() const { return c.empty(); } - size_type size() const { return c.size(); } - reference front() { return c.front(); } - const_reference front() const { return c.front(); } - reference back() { return c.back(); } - const_reference back() const { return c.back(); } - void push(const value_type& __x) { c.push_back(__x); } - void pop() { c.pop_front(); } -}; - -template -bool -operator==(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return __x.c == __y.c; -} - -template -bool -operator<(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return __x.c < __y.c; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -bool -operator!=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return !(__x == __y); -} - -template -bool -operator>(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return __y < __x; -} - -template -bool -operator<=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return !(__y < __x); -} - -template -bool -operator>=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) -{ - return !(__x < __y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -template ), - class _Compare - __STL_DEPENDENT_DEFAULT_TMPL(less) > -class priority_queue { - - // requirements: - - __STL_CLASS_REQUIRES(_Tp, _Assignable); - __STL_CLASS_REQUIRES(_Sequence, _Sequence); - __STL_CLASS_REQUIRES(_Sequence, _RandomAccessContainer); - typedef typename _Sequence::value_type _Sequence_value_type; - __STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type); - __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp); - -public: - typedef typename _Sequence::value_type value_type; - typedef typename _Sequence::size_type size_type; - typedef _Sequence container_type; - - typedef typename _Sequence::reference reference; - typedef typename _Sequence::const_reference const_reference; -protected: - _Sequence c; - _Compare comp; -public: - priority_queue() : c() {} - explicit priority_queue(const _Compare& __x) : c(), comp(__x) {} - priority_queue(const _Compare& __x, const _Sequence& __s) - : c(__s), comp(__x) - { make_heap(c.begin(), c.end(), comp); } - -#ifdef __STL_MEMBER_TEMPLATES - template - priority_queue(_InputIterator __first, _InputIterator __last) - : c(__first, __last) { make_heap(c.begin(), c.end(), comp); } - - template - priority_queue(_InputIterator __first, - _InputIterator __last, const _Compare& __x) - : c(__first, __last), comp(__x) - { make_heap(c.begin(), c.end(), comp); } - - template - priority_queue(_InputIterator __first, _InputIterator __last, - const _Compare& __x, const _Sequence& __s) - : c(__s), comp(__x) - { - c.insert(c.end(), __first, __last); - make_heap(c.begin(), c.end(), comp); - } - -#else /* __STL_MEMBER_TEMPLATES */ - priority_queue(const value_type* __first, const value_type* __last) - : c(__first, __last) { make_heap(c.begin(), c.end(), comp); } - - priority_queue(const value_type* __first, const value_type* __last, - const _Compare& __x) - : c(__first, __last), comp(__x) - { make_heap(c.begin(), c.end(), comp); } - - priority_queue(const value_type* __first, const value_type* __last, - const _Compare& __x, const _Sequence& __c) - : c(__c), comp(__x) - { - c.insert(c.end(), __first, __last); - make_heap(c.begin(), c.end(), comp); - } -#endif /* __STL_MEMBER_TEMPLATES */ - - bool empty() const { return c.empty(); } - size_type size() const { return c.size(); } - const_reference top() const { return c.front(); } - void push(const value_type& __x) { - __STL_TRY { - c.push_back(__x); - push_heap(c.begin(), c.end(), comp); - } - __STL_UNWIND(c.clear()); - } - void pop() { - __STL_TRY { - pop_heap(c.begin(), c.end(), comp); - c.pop_back(); - } - __STL_UNWIND(c.clear()); - } -}; - -// no equality is provided - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_QUEUE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_range_errors.h b/DSTAT1/src/avr-stl/include/stl_range_errors.h deleted file mode 100644 index 3ddde6d..0000000 --- a/DSTAT1/src/avr-stl/include/stl_range_errors.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 1999 - * Silicon Graphics - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef __STL_RANGE_ERRORS_H -#define __STL_RANGE_ERRORS_H - -// A few places in the STL throw range errors, using standard exception -// classes defined in . This header file provides functions -// to throw those exception objects. - -// __STL_DONT_THROW_RANGE_ERRORS is a hook so that users can disable -// this exception throwing. - -#include - -#if defined(__STL_CAN_THROW_RANGE_ERRORS) && \ - defined(__STL_USE_EXCEPTIONS) && \ - !defined(__STL_DONT_THROW_RANGE_ERRORS) -# define __STL_THROW_RANGE_ERRORS -#endif - -// For the SGI 7.3 compiler, declare these functions here and define them -// elsewhere. -#if defined(__STL_THROW_RANGE_ERRORS) && \ - defined(__sgi) && !defined(__GNUC__) && \ - _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS) - -__STL_BEGIN_NAMESPACE -void __stl_throw_range_error(const char* __msg); -void __stl_throw_length_error(const char* __msg); -__STL_END_NAMESPACE - -// For other compilers where we're throwing range errors, include the -// stdexcept header and throw the appropriate exceptions directly. -#elif defined(__STL_THROW_RANGE_ERRORS) - -#include - -__STL_BEGIN_NAMESPACE -inline void __stl_throw_range_error(const char* __msg) - { throw range_error(__msg); } -inline void __stl_throw_length_error(const char* __msg) - { throw length_error(__msg); } -__STL_END_NAMESPACE - -// Otherwise, define inline functions that do nothing. -#else - -__STL_BEGIN_NAMESPACE -inline void __stl_throw_range_error(const char*) {} -inline void __stl_throw_length_error(const char*) {} -__STL_END_NAMESPACE - -#endif - -#endif /* __STL_RANGE_ERRORS_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_raw_storage_iter.h b/DSTAT1/src/avr-stl/include/stl_raw_storage_iter.h deleted file mode 100644 index 6f3951c..0000000 --- a/DSTAT1/src/avr-stl/include/stl_raw_storage_iter.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H -#define __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H - -__STL_BEGIN_NAMESPACE - -template -class raw_storage_iterator { -protected: - _ForwardIterator _M_iter; -public: - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - explicit raw_storage_iterator(_ForwardIterator __x) : _M_iter(__x) {} - raw_storage_iterator& operator*() { return *this; } - raw_storage_iterator& operator=(const _Tp& __element) { - construct(&*_M_iter, __element); - return *this; - } - raw_storage_iterator<_ForwardIterator, _Tp>& operator++() { - ++_M_iter; - return *this; - } - raw_storage_iterator<_ForwardIterator, _Tp> operator++(int) { - raw_storage_iterator<_ForwardIterator, _Tp> __tmp = *this; - ++_M_iter; - return __tmp; - } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -inline output_iterator_tag -iterator_category(const raw_storage_iterator<_ForwardIterator, _Tp>&) -{ - return output_iterator_tag(); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_relops.h b/DSTAT1/src/avr-stl/include/stl_relops.h deleted file mode 100644 index 16cad1b..0000000 --- a/DSTAT1/src/avr-stl/include/stl_relops.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * Copyright (c) 1996,1997 - * Silicon Graphics - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_RELOPS -#define __SGI_STL_INTERNAL_RELOPS - -__STL_BEGIN_RELOPS_NAMESPACE - -template -inline bool operator!=(const _Tp& __x, const _Tp& __y) { - return !(__x == __y); -} - -template -inline bool operator>(const _Tp& __x, const _Tp& __y) { - return __y < __x; -} - -template -inline bool operator<=(const _Tp& __x, const _Tp& __y) { - return !(__y < __x); -} - -template -inline bool operator>=(const _Tp& __x, const _Tp& __y) { - return !(__x < __y); -} - -__STL_END_RELOPS_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_RELOPS */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_set.h b/DSTAT1/src/avr-stl/include/stl_set.h deleted file mode 100644 index 1916d21..0000000 --- a/DSTAT1/src/avr-stl/include/stl_set.h +++ /dev/null @@ -1,268 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_SET_H -#define __SGI_STL_INTERNAL_SET_H - -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -// Forward declarations of operators < and ==, needed for friend declaration. - -template ), - class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) > -class set; - -template -inline bool operator==(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y); - -template -inline bool operator<(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y); - - -template -class set { - // requirements: - - __STL_CLASS_REQUIRES(_Key, _Assignable); - __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key); - -public: - // typedefs: - - typedef _Key key_type; - typedef _Key value_type; - typedef _Compare key_compare; - typedef _Compare value_compare; -private: - typedef _Rb_tree, key_compare, _Alloc> _Rep_type; - _Rep_type _M_t; // red-black tree representing set -public: - typedef typename _Rep_type::const_pointer pointer; - typedef typename _Rep_type::const_pointer const_pointer; - typedef typename _Rep_type::const_reference reference; - typedef typename _Rep_type::const_reference const_reference; - typedef typename _Rep_type::const_iterator iterator; - typedef typename _Rep_type::const_iterator const_iterator; - typedef typename _Rep_type::const_reverse_iterator reverse_iterator; - typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; - typedef typename _Rep_type::size_type size_type; - typedef typename _Rep_type::difference_type difference_type; - typedef typename _Rep_type::allocator_type allocator_type; - - // allocation/deallocation - - set() : _M_t(_Compare(), allocator_type()) {} - explicit set(const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) {} - -#ifdef __STL_MEMBER_TEMPLATES - template - set(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - template - set(_InputIterator __first, _InputIterator __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } -#else - set(const value_type* __first, const value_type* __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - set(const value_type* __first, - const value_type* __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } - - set(const_iterator __first, const_iterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } - - set(const_iterator __first, const_iterator __last, const _Compare& __comp, - const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } -#endif /* __STL_MEMBER_TEMPLATES */ - - set(const set<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {} - set<_Key,_Compare,_Alloc>& operator=(const set<_Key, _Compare, _Alloc>& __x) - { - _M_t = __x._M_t; - return *this; - } - - // accessors: - - key_compare key_comp() const { return _M_t.key_comp(); } - value_compare value_comp() const { return _M_t.key_comp(); } - allocator_type get_allocator() const { return _M_t.get_allocator(); } - - iterator begin() const { return _M_t.begin(); } - iterator end() const { return _M_t.end(); } - reverse_iterator rbegin() const { return _M_t.rbegin(); } - reverse_iterator rend() const { return _M_t.rend(); } - bool empty() const { return _M_t.empty(); } - size_type size() const { return _M_t.size(); } - size_type max_size() const { return _M_t.max_size(); } - void swap(set<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); } - - // insert/erase - pair insert(const value_type& __x) { - pair __p = _M_t.insert_unique(__x); - return pair(__p.first, __p.second); - } - iterator insert(iterator __position, const value_type& __x) { - typedef typename _Rep_type::iterator _Rep_iterator; - return _M_t.insert_unique((_Rep_iterator&)__position, __x); - } -#ifdef __STL_MEMBER_TEMPLATES - template - void insert(_InputIterator __first, _InputIterator __last) { - _M_t.insert_unique(__first, __last); - } -#else - void insert(const_iterator __first, const_iterator __last) { - _M_t.insert_unique(__first, __last); - } - void insert(const value_type* __first, const value_type* __last) { - _M_t.insert_unique(__first, __last); - } -#endif /* __STL_MEMBER_TEMPLATES */ - void erase(iterator __position) { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__position); - } - size_type erase(const key_type& __x) { - return _M_t.erase(__x); - } - void erase(iterator __first, iterator __last) { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last); - } - void clear() { _M_t.clear(); } - - // set operations: - - iterator find(const key_type& __x) const { return _M_t.find(__x); } - size_type count(const key_type& __x) const { - return _M_t.find(__x) == _M_t.end() ? 0 : 1; - } - iterator lower_bound(const key_type& __x) const { - return _M_t.lower_bound(__x); - } - iterator upper_bound(const key_type& __x) const { - return _M_t.upper_bound(__x); - } - pair equal_range(const key_type& __x) const { - return _M_t.equal_range(__x); - } - -#ifdef __STL_TEMPLATE_FRIENDS - template - friend bool operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); - template - friend bool operator< (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); -#else /* __STL_TEMPLATE_FRIENDS */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const set&, const set&); - friend bool __STD_QUALIFIER - operator< __STL_NULL_TMPL_ARGS (const set&, const set&); -#endif /* __STL_TEMPLATE_FRIENDS */ -}; - -template -inline bool operator==(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) { - return __x._M_t == __y._M_t; -} - -template -inline bool operator<(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) { - return __x._M_t < __y._M_t; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool operator!=(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) { - return !(__x == __y); -} - -template -inline bool operator>(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) { - return __y < __x; -} - -template -inline bool operator<=(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) { - return !(__y < __x); -} - -template -inline bool operator>=(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) { - return !(__x < __y); -} - -template -inline void swap(set<_Key,_Compare,_Alloc>& __x, - set<_Key,_Compare,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_SET_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_slist.h b/DSTAT1/src/avr-stl/include/stl_slist.h deleted file mode 100644 index a748d1a..0000000 --- a/DSTAT1/src/avr-stl/include/stl_slist.h +++ /dev/null @@ -1,1048 +0,0 @@ -/* - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_SLIST_H -#define __SGI_STL_INTERNAL_SLIST_H - -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -struct _Slist_node_base -{ - _Slist_node_base* _M_next; -}; - -inline _Slist_node_base* -__slist_make_link(_Slist_node_base* __prev_node, - _Slist_node_base* __new_node) -{ - __new_node->_M_next = __prev_node->_M_next; - __prev_node->_M_next = __new_node; - return __new_node; -} - -inline _Slist_node_base* -__slist_previous(_Slist_node_base* __head, - const _Slist_node_base* __node) -{ - while (__head && __head->_M_next != __node) - __head = __head->_M_next; - return __head; -} - -inline const _Slist_node_base* -__slist_previous(const _Slist_node_base* __head, - const _Slist_node_base* __node) -{ - while (__head && __head->_M_next != __node) - __head = __head->_M_next; - return __head; -} - -inline void __slist_splice_after(_Slist_node_base* __pos, - _Slist_node_base* __before_first, - _Slist_node_base* __before_last) -{ - if (__pos != __before_first && __pos != __before_last) { - _Slist_node_base* __first = __before_first->_M_next; - _Slist_node_base* __after = __pos->_M_next; - __before_first->_M_next = __before_last->_M_next; - __pos->_M_next = __first; - __before_last->_M_next = __after; - } -} - -inline void -__slist_splice_after(_Slist_node_base* __pos, _Slist_node_base* __head) -{ - _Slist_node_base* __before_last = __slist_previous(__head, 0); - if (__before_last != __head) { - _Slist_node_base* __after = __pos->_M_next; - __pos->_M_next = __head->_M_next; - __head->_M_next = 0; - __before_last->_M_next = __after; - } -} - -inline _Slist_node_base* __slist_reverse(_Slist_node_base* __node) -{ - _Slist_node_base* __result = __node; - __node = __node->_M_next; - __result->_M_next = 0; - while(__node) { - _Slist_node_base* __next = __node->_M_next; - __node->_M_next = __result; - __result = __node; - __node = __next; - } - return __result; -} - -inline size_t __slist_size(_Slist_node_base* __node) -{ - size_t __result = 0; - for ( ; __node != 0; __node = __node->_M_next) - ++__result; - return __result; -} - -template -struct _Slist_node : public _Slist_node_base -{ - _Tp _M_data; -}; - -struct _Slist_iterator_base -{ - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef forward_iterator_tag iterator_category; - - _Slist_node_base* _M_node; - - _Slist_iterator_base(_Slist_node_base* __x) : _M_node(__x) {} - void _M_incr() { _M_node = _M_node->_M_next; } - - bool operator==(const _Slist_iterator_base& __x) const { - return _M_node == __x._M_node; - } - bool operator!=(const _Slist_iterator_base& __x) const { - return _M_node != __x._M_node; - } -}; - -template -struct _Slist_iterator : public _Slist_iterator_base -{ - typedef _Slist_iterator<_Tp, _Tp&, _Tp*> iterator; - typedef _Slist_iterator<_Tp, const _Tp&, const _Tp*> const_iterator; - typedef _Slist_iterator<_Tp, _Ref, _Ptr> _Self; - - typedef _Tp value_type; - typedef _Ptr pointer; - typedef _Ref reference; - typedef _Slist_node<_Tp> _Node; - - _Slist_iterator(_Node* __x) : _Slist_iterator_base(__x) {} - _Slist_iterator() : _Slist_iterator_base(0) {} - _Slist_iterator(const iterator& __x) : _Slist_iterator_base(__x._M_node) {} - - reference operator*() const { return ((_Node*) _M_node)->_M_data; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - - _Self& operator++() - { - _M_incr(); - return *this; - } - _Self operator++(int) - { - _Self __tmp = *this; - _M_incr(); - return __tmp; - } -}; - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -inline ptrdiff_t* distance_type(const _Slist_iterator_base&) { - return 0; -} - -inline forward_iterator_tag iterator_category(const _Slist_iterator_base&) { - return forward_iterator_tag(); -} - -template -inline _Tp* value_type(const _Slist_iterator<_Tp, _Ref, _Ptr>&) { - return 0; -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -// Base class that encapsulates details of allocators. Three cases: -// an ordinary standard-conforming allocator, a standard-conforming -// allocator with no non-static data, and an SGI-style allocator. -// This complexity is necessary only because we're worrying about backward -// compatibility and because we want to avoid wasting storage on an -// allocator instance if it isn't necessary. - -#ifdef __STL_USE_STD_ALLOCATORS - -// Base for general standard-conforming allocators. -template -class _Slist_alloc_base { -public: - typedef typename _Alloc_traits<_Tp,_Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return _M_node_allocator; } - - _Slist_alloc_base(const allocator_type& __a) : _M_node_allocator(__a) {} - -protected: - _Slist_node<_Tp>* _M_get_node() - { return _M_node_allocator.allocate(1); } - void _M_put_node(_Slist_node<_Tp>* __p) - { _M_node_allocator.deallocate(__p, 1); } - -protected: - typename _Alloc_traits<_Slist_node<_Tp>,_Allocator>::allocator_type - _M_node_allocator; - _Slist_node_base _M_head; -}; - -// Specialization for instanceless allocators. -template -class _Slist_alloc_base<_Tp,_Allocator, true> { -public: - typedef typename _Alloc_traits<_Tp,_Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Slist_alloc_base(const allocator_type&) {} - -protected: - typedef typename _Alloc_traits<_Slist_node<_Tp>, _Allocator>::_Alloc_type - _Alloc_type; - _Slist_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); } - void _M_put_node(_Slist_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); } - -protected: - _Slist_node_base _M_head; -}; - - -template -struct _Slist_base - : public _Slist_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> -{ - typedef _Slist_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> - _Base; - typedef typename _Base::allocator_type allocator_type; - - _Slist_base(const allocator_type& __a) - : _Base(__a) { this->_M_head._M_next = 0; } - ~_Slist_base() { _M_erase_after(&this->_M_head, 0); } - -protected: - - _Slist_node_base* _M_erase_after(_Slist_node_base* __pos) - { - _Slist_node<_Tp>* __next = (_Slist_node<_Tp>*) (__pos->_M_next); - _Slist_node_base* __next_next = __next->_M_next; - __pos->_M_next = __next_next; - destroy(&__next->_M_data); - _M_put_node(__next); - return __next_next; - } - _Slist_node_base* _M_erase_after(_Slist_node_base*, _Slist_node_base*); -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -struct _Slist_base { - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Slist_base(const allocator_type&) { _M_head._M_next = 0; } - ~_Slist_base() { _M_erase_after(&_M_head, 0); } - -protected: - typedef simple_alloc<_Slist_node<_Tp>, _Alloc> _Alloc_type; - _Slist_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); } - void _M_put_node(_Slist_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); } - - _Slist_node_base* _M_erase_after(_Slist_node_base* __pos) - { - _Slist_node<_Tp>* __next = (_Slist_node<_Tp>*) (__pos->_M_next); - _Slist_node_base* __next_next = __next->_M_next; - __pos->_M_next = __next_next; - destroy(&__next->_M_data); - _M_put_node(__next); - return __next_next; - } - _Slist_node_base* _M_erase_after(_Slist_node_base*, _Slist_node_base*); - -protected: - _Slist_node_base _M_head; -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -template -_Slist_node_base* -_Slist_base<_Tp,_Alloc>::_M_erase_after(_Slist_node_base* __before_first, - _Slist_node_base* __last_node) { - _Slist_node<_Tp>* __cur = (_Slist_node<_Tp>*) (__before_first->_M_next); - while (__cur != __last_node) { - _Slist_node<_Tp>* __tmp = __cur; - __cur = (_Slist_node<_Tp>*) __cur->_M_next; - destroy(&__tmp->_M_data); - _M_put_node(__tmp); - } - __before_first->_M_next = __last_node; - return __last_node; -} - -template -class slist : private _Slist_base<_Tp,_Alloc> -{ - // requirements: - - __STL_CLASS_REQUIRES(_Tp, _Assignable); - -private: - typedef _Slist_base<_Tp,_Alloc> _Base; -public: - typedef _Tp value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - typedef _Slist_iterator<_Tp, _Tp&, _Tp*> iterator; - typedef _Slist_iterator<_Tp, const _Tp&, const _Tp*> const_iterator; - - typedef typename _Base::allocator_type allocator_type; - allocator_type get_allocator() const { return _Base::get_allocator(); } - -private: - typedef _Slist_node<_Tp> _Node; - typedef _Slist_node_base _Node_base; - typedef _Slist_iterator_base _Iterator_base; - - _Node* _M_create_node(const value_type& __x) { - _Node* __node = this->_M_get_node(); - __STL_TRY { - construct(&__node->_M_data, __x); - __node->_M_next = 0; - } - __STL_UNWIND(this->_M_put_node(__node)); - return __node; - } - - _Node* _M_create_node() { - _Node* __node = this->_M_get_node(); - __STL_TRY { - construct(&__node->_M_data); - __node->_M_next = 0; - } - __STL_UNWIND(this->_M_put_node(__node)); - return __node; - } - -public: - explicit slist(const allocator_type& __a = allocator_type()) : _Base(__a) {} - - slist(size_type __n, const value_type& __x, - const allocator_type& __a = allocator_type()) : _Base(__a) - { _M_insert_after_fill(&this->_M_head, __n, __x); } - - explicit slist(size_type __n) : _Base(allocator_type()) - { _M_insert_after_fill(&this->_M_head, __n, value_type()); } - -#ifdef __STL_MEMBER_TEMPLATES - // We don't need any dispatching tricks here, because _M_insert_after_range - // already does them. - template - slist(_InputIterator __first, _InputIterator __last, - const allocator_type& __a = allocator_type()) : _Base(__a) - { _M_insert_after_range(&this->_M_head, __first, __last); } - -#else /* __STL_MEMBER_TEMPLATES */ - slist(const_iterator __first, const_iterator __last, - const allocator_type& __a = allocator_type()) : _Base(__a) - { _M_insert_after_range(&this->_M_head, __first, __last); } - slist(const value_type* __first, const value_type* __last, - const allocator_type& __a = allocator_type()) : _Base(__a) - { _M_insert_after_range(&this->_M_head, __first, __last); } -#endif /* __STL_MEMBER_TEMPLATES */ - - slist(const slist& __x) : _Base(__x.get_allocator()) - { _M_insert_after_range(&this->_M_head, __x.begin(), __x.end()); } - - slist& operator= (const slist& __x); - - ~slist() {} - -public: - // assign(), a generalized assignment member function. Two - // versions: one that takes a count, and one that takes a range. - // The range version is a member template, so we dispatch on whether - // or not the type is an integer. - - void assign(size_type __n, const _Tp& __val) - { _M_fill_assign(__n, __val); } - - void _M_fill_assign(size_type __n, const _Tp& __val); - - -#ifdef __STL_MEMBER_TEMPLATES - - template - void assign(_InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_assign_dispatch(__first, __last, _Integral()); - } - - template - void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { _M_fill_assign((size_type) __n, (_Tp) __val); } - - template - void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, - __false_type); - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: - - iterator begin() { return iterator((_Node*)this->_M_head._M_next); } - const_iterator begin() const - { return const_iterator((_Node*)this->_M_head._M_next);} - - iterator end() { return iterator(0); } - const_iterator end() const { return const_iterator(0); } - - // Experimental new feature: before_begin() returns a - // non-dereferenceable iterator that, when incremented, yields - // begin(). This iterator may be used as the argument to - // insert_after, erase_after, etc. Note that even for an empty - // slist, before_begin() is not the same iterator as end(). It - // is always necessary to increment before_begin() at least once to - // obtain end(). - iterator before_begin() { return iterator((_Node*) &this->_M_head); } - const_iterator before_begin() const - { return const_iterator((_Node*) &this->_M_head); } - - size_type size() const { return __slist_size(this->_M_head._M_next); } - - size_type max_size() const { return size_type(-1); } - - bool empty() const { return this->_M_head._M_next == 0; } - - void swap(slist& __x) - { __STD::swap(this->_M_head._M_next, __x._M_head._M_next); } - -public: - - reference front() { return ((_Node*) this->_M_head._M_next)->_M_data; } - const_reference front() const - { return ((_Node*) this->_M_head._M_next)->_M_data; } - void push_front(const value_type& __x) { - __slist_make_link(&this->_M_head, _M_create_node(__x)); - } - void push_front() { __slist_make_link(&this->_M_head, _M_create_node()); } - void pop_front() { - _Node* __node = (_Node*) this->_M_head._M_next; - this->_M_head._M_next = __node->_M_next; - destroy(&__node->_M_data); - this->_M_put_node(__node); - } - - iterator previous(const_iterator __pos) { - return iterator((_Node*) __slist_previous(&this->_M_head, __pos._M_node)); - } - const_iterator previous(const_iterator __pos) const { - return const_iterator((_Node*) __slist_previous(&this->_M_head, - __pos._M_node)); - } - -private: - _Node* _M_insert_after(_Node_base* __pos, const value_type& __x) { - return (_Node*) (__slist_make_link(__pos, _M_create_node(__x))); - } - - _Node* _M_insert_after(_Node_base* __pos) { - return (_Node*) (__slist_make_link(__pos, _M_create_node())); - } - - void _M_insert_after_fill(_Node_base* __pos, - size_type __n, const value_type& __x) { - for (size_type __i = 0; __i < __n; ++__i) - __pos = __slist_make_link(__pos, _M_create_node(__x)); - } - -#ifdef __STL_MEMBER_TEMPLATES - - // Check whether it's an integral type. If so, it's not an iterator. - template - void _M_insert_after_range(_Node_base* __pos, - _InIter __first, _InIter __last) { - typedef typename _Is_integer<_InIter>::_Integral _Integral; - _M_insert_after_range(__pos, __first, __last, _Integral()); - } - - template - void _M_insert_after_range(_Node_base* __pos, _Integer __n, _Integer __x, - __true_type) { - _M_insert_after_fill(__pos, __n, __x); - } - - template - void _M_insert_after_range(_Node_base* __pos, - _InIter __first, _InIter __last, - __false_type) { - while (__first != __last) { - __pos = __slist_make_link(__pos, _M_create_node(*__first)); - ++__first; - } - } - -#else /* __STL_MEMBER_TEMPLATES */ - - void _M_insert_after_range(_Node_base* __pos, - const_iterator __first, const_iterator __last) { - while (__first != __last) { - __pos = __slist_make_link(__pos, _M_create_node(*__first)); - ++__first; - } - } - void _M_insert_after_range(_Node_base* __pos, - const value_type* __first, - const value_type* __last) { - while (__first != __last) { - __pos = __slist_make_link(__pos, _M_create_node(*__first)); - ++__first; - } - } - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: - - iterator insert_after(iterator __pos, const value_type& __x) { - return iterator(_M_insert_after(__pos._M_node, __x)); - } - - iterator insert_after(iterator __pos) { - return insert_after(__pos, value_type()); - } - - void insert_after(iterator __pos, size_type __n, const value_type& __x) { - _M_insert_after_fill(__pos._M_node, __n, __x); - } - -#ifdef __STL_MEMBER_TEMPLATES - - // We don't need any dispatching tricks here, because _M_insert_after_range - // already does them. - template - void insert_after(iterator __pos, _InIter __first, _InIter __last) { - _M_insert_after_range(__pos._M_node, __first, __last); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - void insert_after(iterator __pos, - const_iterator __first, const_iterator __last) { - _M_insert_after_range(__pos._M_node, __first, __last); - } - void insert_after(iterator __pos, - const value_type* __first, const value_type* __last) { - _M_insert_after_range(__pos._M_node, __first, __last); - } - -#endif /* __STL_MEMBER_TEMPLATES */ - - iterator insert(iterator __pos, const value_type& __x) { - return iterator(_M_insert_after(__slist_previous(&this->_M_head, - __pos._M_node), - __x)); - } - - iterator insert(iterator __pos) { - return iterator(_M_insert_after(__slist_previous(&this->_M_head, - __pos._M_node), - value_type())); - } - - void insert(iterator __pos, size_type __n, const value_type& __x) { - _M_insert_after_fill(__slist_previous(&this->_M_head, __pos._M_node), - __n, __x); - } - -#ifdef __STL_MEMBER_TEMPLATES - - // We don't need any dispatching tricks here, because _M_insert_after_range - // already does them. - template - void insert(iterator __pos, _InIter __first, _InIter __last) { - _M_insert_after_range(__slist_previous(&this->_M_head, __pos._M_node), - __first, __last); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - void insert(iterator __pos, const_iterator __first, const_iterator __last) { - _M_insert_after_range(__slist_previous(&this->_M_head, __pos._M_node), - __first, __last); - } - void insert(iterator __pos, const value_type* __first, - const value_type* __last) { - _M_insert_after_range(__slist_previous(&this->_M_head, __pos._M_node), - __first, __last); - } - -#endif /* __STL_MEMBER_TEMPLATES */ - - -public: - iterator erase_after(iterator __pos) { - return iterator((_Node*) this->_M_erase_after(__pos._M_node)); - } - iterator erase_after(iterator __before_first, iterator __last) { - return iterator((_Node*) this->_M_erase_after(__before_first._M_node, - __last._M_node)); - } - - iterator erase(iterator __pos) { - return (_Node*) this->_M_erase_after(__slist_previous(&this->_M_head, - __pos._M_node)); - } - iterator erase(iterator __first, iterator __last) { - return (_Node*) this->_M_erase_after( - __slist_previous(&this->_M_head, __first._M_node), __last._M_node); - } - - void resize(size_type new_size, const _Tp& __x); - void resize(size_type new_size) { resize(new_size, _Tp()); } - void clear() { this->_M_erase_after(&this->_M_head, 0); } - -public: - // Moves the range [__before_first + 1, __before_last + 1) to *this, - // inserting it immediately after __pos. This is constant time. - void splice_after(iterator __pos, - iterator __before_first, iterator __before_last) - { - if (__before_first != __before_last) - __slist_splice_after(__pos._M_node, __before_first._M_node, - __before_last._M_node); - } - - // Moves the element that follows __prev to *this, inserting it immediately - // after __pos. This is constant time. - void splice_after(iterator __pos, iterator __prev) - { - __slist_splice_after(__pos._M_node, - __prev._M_node, __prev._M_node->_M_next); - } - - - // Removes all of the elements from the list __x to *this, inserting - // them immediately after __pos. __x must not be *this. Complexity: - // linear in __x.size(). - void splice_after(iterator __pos, slist& __x) - { - __slist_splice_after(__pos._M_node, &__x._M_head); - } - - // Linear in distance(begin(), __pos), and linear in __x.size(). - void splice(iterator __pos, slist& __x) { - if (__x._M_head._M_next) - __slist_splice_after(__slist_previous(&this->_M_head, __pos._M_node), - &__x._M_head, __slist_previous(&__x._M_head, 0)); - } - - // Linear in distance(begin(), __pos), and in distance(__x.begin(), __i). - void splice(iterator __pos, slist& __x, iterator __i) { - __slist_splice_after(__slist_previous(&this->_M_head, __pos._M_node), - __slist_previous(&__x._M_head, __i._M_node), - __i._M_node); - } - - // Linear in distance(begin(), __pos), in distance(__x.begin(), __first), - // and in distance(__first, __last). - void splice(iterator __pos, slist& __x, iterator __first, iterator __last) - { - if (__first != __last) - __slist_splice_after(__slist_previous(&this->_M_head, __pos._M_node), - __slist_previous(&__x._M_head, __first._M_node), - __slist_previous(__first._M_node, __last._M_node)); - } - -public: - void reverse() { - if (this->_M_head._M_next) - this->_M_head._M_next = __slist_reverse(this->_M_head._M_next); - } - - void remove(const _Tp& __val); - void unique(); - void merge(slist& __x); - void sort(); - -#ifdef __STL_MEMBER_TEMPLATES - template - void remove_if(_Predicate __pred); - - template - void unique(_BinaryPredicate __pred); - - template - void merge(slist&, _StrictWeakOrdering); - - template - void sort(_StrictWeakOrdering __comp); -#endif /* __STL_MEMBER_TEMPLATES */ -}; - -template -slist<_Tp,_Alloc>& slist<_Tp,_Alloc>::operator=(const slist<_Tp,_Alloc>& __x) -{ - if (&__x != this) { - _Node_base* __p1 = &this->_M_head; - _Node* __n1 = (_Node*) this->_M_head._M_next; - const _Node* __n2 = (const _Node*) __x._M_head._M_next; - while (__n1 && __n2) { - __n1->_M_data = __n2->_M_data; - __p1 = __n1; - __n1 = (_Node*) __n1->_M_next; - __n2 = (const _Node*) __n2->_M_next; - } - if (__n2 == 0) - this->_M_erase_after(__p1, 0); - else - _M_insert_after_range(__p1, const_iterator((_Node*)__n2), - const_iterator(0)); - } - return *this; -} - -template -void slist<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val) { - _Node_base* __prev = &this->_M_head; - _Node* __node = (_Node*) this->_M_head._M_next; - for ( ; __node != 0 && __n > 0 ; --__n) { - __node->_M_data = __val; - __prev = __node; - __node = (_Node*) __node->_M_next; - } - if (__n > 0) - _M_insert_after_fill(__prev, __n, __val); - else - this->_M_erase_after(__prev, 0); -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -void -slist<_Tp, _Alloc>::_M_assign_dispatch(_InputIter __first, _InputIter __last, - __false_type) -{ - _Node_base* __prev = &this->_M_head; - _Node* __node = (_Node*) this->_M_head._M_next; - while (__node != 0 && __first != __last) { - __node->_M_data = *__first; - __prev = __node; - __node = (_Node*) __node->_M_next; - ++__first; - } - if (__first != __last) - _M_insert_after_range(__prev, __first, __last); - else - this->_M_erase_after(__prev, 0); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -inline bool -operator==(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) -{ - typedef typename slist<_Tp,_Alloc>::const_iterator const_iterator; - const_iterator __end1 = _SL1.end(); - const_iterator __end2 = _SL2.end(); - - const_iterator __i1 = _SL1.begin(); - const_iterator __i2 = _SL2.begin(); - while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) { - ++__i1; - ++__i2; - } - return __i1 == __end1 && __i2 == __end2; -} - - -template -inline bool -operator<(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) -{ - return lexicographical_compare(_SL1.begin(), _SL1.end(), - _SL2.begin(), _SL2.end()); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool -operator!=(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) { - return !(_SL1 == _SL2); -} - -template -inline bool -operator>(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) { - return _SL2 < _SL1; -} - -template -inline bool -operator<=(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) { - return !(_SL2 < _SL1); -} - -template -inline bool -operator>=(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) { - return !(_SL1 < _SL2); -} - -template -inline void swap(slist<_Tp,_Alloc>& __x, slist<_Tp,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - -template -void slist<_Tp,_Alloc>::resize(size_type __len, const _Tp& __x) -{ - _Node_base* __cur = &this->_M_head; - while (__cur->_M_next != 0 && __len > 0) { - --__len; - __cur = __cur->_M_next; - } - if (__cur->_M_next) - this->_M_erase_after(__cur, 0); - else - _M_insert_after_fill(__cur, __len, __x); -} - -template -void slist<_Tp,_Alloc>::remove(const _Tp& __val) -{ - _Node_base* __cur = &this->_M_head; - while (__cur && __cur->_M_next) { - if (((_Node*) __cur->_M_next)->_M_data == __val) - this->_M_erase_after(__cur); - else - __cur = __cur->_M_next; - } -} - -template -void slist<_Tp,_Alloc>::unique() -{ - _Node_base* __cur = this->_M_head._M_next; - if (__cur) { - while (__cur->_M_next) { - if (((_Node*)__cur)->_M_data == - ((_Node*)(__cur->_M_next))->_M_data) - this->_M_erase_after(__cur); - else - __cur = __cur->_M_next; - } - } -} - -template -void slist<_Tp,_Alloc>::merge(slist<_Tp,_Alloc>& __x) -{ - _Node_base* __n1 = &this->_M_head; - while (__n1->_M_next && __x._M_head._M_next) { - if (((_Node*) __x._M_head._M_next)->_M_data < - ((_Node*) __n1->_M_next)->_M_data) - __slist_splice_after(__n1, &__x._M_head, __x._M_head._M_next); - __n1 = __n1->_M_next; - } - if (__x._M_head._M_next) { - __n1->_M_next = __x._M_head._M_next; - __x._M_head._M_next = 0; - } -} - -template -void slist<_Tp,_Alloc>::sort() -{ - if (this->_M_head._M_next && this->_M_head._M_next->_M_next) { - slist __carry; - slist __counter[64]; - int __fill = 0; - while (!empty()) { - __slist_splice_after(&__carry._M_head, - &this->_M_head, this->_M_head._M_next); - int __i = 0; - while (__i < __fill && !__counter[__i].empty()) { - __counter[__i].merge(__carry); - __carry.swap(__counter[__i]); - ++__i; - } - __carry.swap(__counter[__i]); - if (__i == __fill) - ++__fill; - } - - for (int __i = 1; __i < __fill; ++__i) - __counter[__i].merge(__counter[__i-1]); - this->swap(__counter[__fill-1]); - } -} - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -void slist<_Tp,_Alloc>::remove_if(_Predicate __pred) -{ - _Node_base* __cur = &this->_M_head; - while (__cur->_M_next) { - if (__pred(((_Node*) __cur->_M_next)->_M_data)) - this->_M_erase_after(__cur); - else - __cur = __cur->_M_next; - } -} - -template template -void slist<_Tp,_Alloc>::unique(_BinaryPredicate __pred) -{ - _Node* __cur = (_Node*) this->_M_head._M_next; - if (__cur) { - while (__cur->_M_next) { - if (__pred(((_Node*)__cur)->_M_data, - ((_Node*)(__cur->_M_next))->_M_data)) - this->_M_erase_after(__cur); - else - __cur = (_Node*) __cur->_M_next; - } - } -} - -template template -void slist<_Tp,_Alloc>::merge(slist<_Tp,_Alloc>& __x, - _StrictWeakOrdering __comp) -{ - _Node_base* __n1 = &this->_M_head; - while (__n1->_M_next && __x._M_head._M_next) { - if (__comp(((_Node*) __x._M_head._M_next)->_M_data, - ((_Node*) __n1->_M_next)->_M_data)) - __slist_splice_after(__n1, &__x._M_head, __x._M_head._M_next); - __n1 = __n1->_M_next; - } - if (__x._M_head._M_next) { - __n1->_M_next = __x._M_head._M_next; - __x._M_head._M_next = 0; - } -} - -template template -void slist<_Tp,_Alloc>::sort(_StrictWeakOrdering __comp) -{ - if (this->_M_head._M_next && this->_M_head._M_next->_M_next) { - slist __carry; - slist __counter[64]; - int __fill = 0; - while (!empty()) { - __slist_splice_after(&__carry._M_head, - &this->_M_head, this->_M_head._M_next); - int __i = 0; - while (__i < __fill && !__counter[__i].empty()) { - __counter[__i].merge(__carry, __comp); - __carry.swap(__counter[__i]); - ++__i; - } - __carry.swap(__counter[__i]); - if (__i == __fill) - ++__fill; - } - - for (int __i = 1; __i < __fill; ++__i) - __counter[__i].merge(__counter[__i-1], __comp); - this->swap(__counter[__fill-1]); - } -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -// Specialization of insert_iterator so that insertions will be constant -// time rather than linear time. - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -class insert_iterator > { -protected: - typedef slist<_Tp, _Alloc> _Container; - _Container* container; - typename _Container::iterator iter; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x, typename _Container::iterator __i) - : container(&__x) { - if (__i == __x.begin()) - iter = __x.before_begin(); - else - iter = __x.previous(__i); - } - - insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - iter = container->insert_after(iter, __value); - return *this; - } - insert_iterator<_Container>& operator*() { return *this; } - insert_iterator<_Container>& operator++() { return *this; } - insert_iterator<_Container>& operator++(int) { return *this; } -}; - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_SLIST_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_stack.h b/DSTAT1/src/avr-stl/include/stl_stack.h deleted file mode 100644 index 0693e57..0000000 --- a/DSTAT1/src/avr-stl/include/stl_stack.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_STACK_H -#define __SGI_STL_INTERNAL_STACK_H - -#include - -__STL_BEGIN_NAMESPACE - -// Forward declarations of operators == and <, needed for friend declaration. - -template ) > -class stack; - -template -bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y); - -template -bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y); - - -template -class stack { - - // requirements: - - __STL_CLASS_REQUIRES(_Tp, _Assignable); - __STL_CLASS_REQUIRES(_Sequence, _BackInsertionSequence); - typedef typename _Sequence::value_type _Sequence_value_type; - __STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type); - - -#ifdef __STL_MEMBER_TEMPLATES - template - friend bool operator== (const stack<_Tp1, _Seq1>&, - const stack<_Tp1, _Seq1>&); - template - friend bool operator< (const stack<_Tp1, _Seq1>&, - const stack<_Tp1, _Seq1>&); -#else /* __STL_MEMBER_TEMPLATES */ - friend bool __STD_QUALIFIER - operator== __STL_NULL_TMPL_ARGS (const stack&, const stack&); - friend bool __STD_QUALIFIER - operator< __STL_NULL_TMPL_ARGS (const stack&, const stack&); -#endif /* __STL_MEMBER_TEMPLATES */ - -public: - typedef typename _Sequence::value_type value_type; - typedef typename _Sequence::size_type size_type; - typedef _Sequence container_type; - - typedef typename _Sequence::reference reference; - typedef typename _Sequence::const_reference const_reference; -protected: - _Sequence c; -public: - stack() : c() {} - explicit stack(const _Sequence& __s) : c(__s) {} - - bool empty() const { return c.empty(); } - size_type size() const { return c.size(); } - reference top() { return c.back(); } - const_reference top() const { return c.back(); } - void push(const value_type& __x) { c.push_back(__x); } - void pop() { c.pop_back(); } -}; - -template -bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return __x.c == __y.c; -} - -template -bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return __x.c < __y.c; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -bool operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return !(__x == __y); -} - -template -bool operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return __y < __x; -} - -template -bool operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return !(__y < __x); -} - -template -bool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) -{ - return !(__x < __y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_STACK_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_string_fwd.h b/DSTAT1/src/avr-stl/include/stl_string_fwd.h deleted file mode 100644 index 8e59de7..0000000 --- a/DSTAT1/src/avr-stl/include/stl_string_fwd.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_STRING_FWD_H -#define __SGI_STL_STRING_FWD_H - -#include -#include -#include -#include - -__STL_BEGIN_NAMESPACE - -template , - class _Alloc = __STL_DEFAULT_ALLOCATOR(_CharT) > -class basic_string; - -typedef basic_string string; -typedef basic_string wstring; - -static const char* __get_c_string(const string&); - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_STRING_FWD_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_tempbuf.h b/DSTAT1/src/avr-stl/include/stl_tempbuf.h deleted file mode 100644 index 0fc68d6..0000000 --- a/DSTAT1/src/avr-stl/include/stl_tempbuf.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_TEMPBUF_H -#define __SGI_STL_INTERNAL_TEMPBUF_H - - -__STL_BEGIN_NAMESPACE - -template -pair<_Tp*, ptrdiff_t> -__get_temporary_buffer(ptrdiff_t __len, _Tp*) -{ - if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp))) - __len = INT_MAX / sizeof(_Tp); - - while (__len > 0) { - _Tp* __tmp = (_Tp*) malloc((size_t)__len * sizeof(_Tp)); - if (__tmp != 0) - return pair<_Tp*, ptrdiff_t>(__tmp, __len); - __len /= 2; - } - - return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0); -} - -#ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS - -template -inline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) { - return __get_temporary_buffer(__len, (_Tp*) 0); -} - -#endif /* __STL_EXPLICIT_FUNCTION_TMPL_ARGS */ - -// This overload is not required by the standard; it is an extension. -// It is supported for backward compatibility with the HP STL, and -// because not all compilers support the language feature (explicit -// function template arguments) that is required for the standard -// version of get_temporary_buffer. -template -inline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len, _Tp*) { - return __get_temporary_buffer(__len, (_Tp*) 0); -} - -template -void return_temporary_buffer(_Tp* __p) { - free(__p); -} - -template -class _Temporary_buffer { -private: - ptrdiff_t _M_original_len; - ptrdiff_t _M_len; - _Tp* _M_buffer; - - void _M_allocate_buffer() { - _M_original_len = _M_len; - _M_buffer = 0; - - if (_M_len > (ptrdiff_t)(INT_MAX / sizeof(_Tp))) - _M_len = INT_MAX / sizeof(_Tp); - - while (_M_len > 0) { - _M_buffer = (_Tp*) malloc(_M_len * sizeof(_Tp)); - if (_M_buffer) - break; - _M_len /= 2; - } - } - - void _M_initialize_buffer(const _Tp&, __true_type) {} - void _M_initialize_buffer(const _Tp& val, __false_type) { - uninitialized_fill_n(_M_buffer, _M_len, val); - } - -public: - ptrdiff_t size() const { return _M_len; } - ptrdiff_t requested_size() const { return _M_original_len; } - _Tp* begin() { return _M_buffer; } - _Tp* end() { return _M_buffer + _M_len; } - - _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) { - // Workaround for a __type_traits bug in the pre-7.3 compiler. -# if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION < 730 - typedef typename __type_traits<_Tp>::is_POD_type _Trivial; -# else - typedef typename __type_traits<_Tp>::has_trivial_default_constructor - _Trivial; -# endif - - __STL_TRY { - _M_len = 0; - distance(__first, __last, _M_len); - _M_allocate_buffer(); - if (_M_len > 0) - _M_initialize_buffer(*__first, _Trivial()); - } - __STL_UNWIND(free(_M_buffer); _M_buffer = 0; _M_len = 0); - } - - ~_Temporary_buffer() { - destroy(_M_buffer, _M_buffer + _M_len); - free(_M_buffer); - } - -private: - // Disable copy constructor and assignment operator. - _Temporary_buffer(const _Temporary_buffer&) {} - void operator=(const _Temporary_buffer&) {} -}; - -// Class temporary_buffer is not part of the standard. It is an extension. - -template ::value_type -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - > -struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp> -{ - temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) - : _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) {} - ~temporary_buffer() {} -}; - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_TEMPBUF_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_tree.h b/DSTAT1/src/avr-stl/include/stl_tree.h deleted file mode 100644 index 5f388b2..0000000 --- a/DSTAT1/src/avr-stl/include/stl_tree.h +++ /dev/null @@ -1,1369 +0,0 @@ -/* - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_TREE_H -#define __SGI_STL_INTERNAL_TREE_H - -/* - -Red-black tree class, designed for use in implementing STL -associative containers (set, multiset, map, and multimap). The -insertion and deletion algorithms are based on those in Cormen, -Leiserson, and Rivest, Introduction to Algorithms (MIT Press, 1990), -except that - -(1) the header cell is maintained with links not only to the root -but also to the leftmost node of the tree, to enable constant time -begin(), and to the rightmost node of the tree, to enable linear time -performance when used with the generic set algorithms (set_union, -etc.); - -(2) when a node being deleted has two children its successor node is -relinked into its place, rather than copied, so that the only -iterators invalidated are those referring to the deleted node. - -*/ - -#include -#include -#include -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1375 -#endif - -typedef bool _Rb_tree_Color_type; -const _Rb_tree_Color_type _S_rb_tree_red = false; -const _Rb_tree_Color_type _S_rb_tree_black = true; - -struct _Rb_tree_node_base -{ - typedef _Rb_tree_Color_type _Color_type; - typedef _Rb_tree_node_base* _Base_ptr; - - _Color_type _M_color; - _Base_ptr _M_parent; - _Base_ptr _M_left; - _Base_ptr _M_right; - - static _Base_ptr _S_minimum(_Base_ptr __x) - { - while (__x->_M_left != 0) __x = __x->_M_left; - return __x; - } - - static _Base_ptr _S_maximum(_Base_ptr __x) - { - while (__x->_M_right != 0) __x = __x->_M_right; - return __x; - } -}; - -template -struct _Rb_tree_node : public _Rb_tree_node_base -{ - typedef _Rb_tree_node<_Value>* _Link_type; - _Value _M_value_field; -}; - - -struct _Rb_tree_base_iterator -{ - typedef _Rb_tree_node_base::_Base_ptr _Base_ptr; - typedef bidirectional_iterator_tag iterator_category; - typedef ptrdiff_t difference_type; - _Base_ptr _M_node; - - void _M_increment() - { - if (_M_node->_M_right != 0) { - _M_node = _M_node->_M_right; - while (_M_node->_M_left != 0) - _M_node = _M_node->_M_left; - } - else { - _Base_ptr __y = _M_node->_M_parent; - while (_M_node == __y->_M_right) { - _M_node = __y; - __y = __y->_M_parent; - } - if (_M_node->_M_right != __y) - _M_node = __y; - } - } - - void _M_decrement() - { - if (_M_node->_M_color == _S_rb_tree_red && - _M_node->_M_parent->_M_parent == _M_node) - _M_node = _M_node->_M_right; - else if (_M_node->_M_left != 0) { - _Base_ptr __y = _M_node->_M_left; - while (__y->_M_right != 0) - __y = __y->_M_right; - _M_node = __y; - } - else { - _Base_ptr __y = _M_node->_M_parent; - while (_M_node == __y->_M_left) { - _M_node = __y; - __y = __y->_M_parent; - } - _M_node = __y; - } - } -}; - -template -struct _Rb_tree_iterator : public _Rb_tree_base_iterator -{ - typedef _Value value_type; - typedef _Ref reference; - typedef _Ptr pointer; - typedef _Rb_tree_iterator<_Value, _Value&, _Value*> - iterator; - typedef _Rb_tree_iterator<_Value, const _Value&, const _Value*> - const_iterator; - typedef _Rb_tree_iterator<_Value, _Ref, _Ptr> - _Self; - typedef _Rb_tree_node<_Value>* _Link_type; - - _Rb_tree_iterator() {} - _Rb_tree_iterator(_Link_type __x) { _M_node = __x; } - _Rb_tree_iterator(const iterator& __it) { _M_node = __it._M_node; } - - reference operator*() const { return _Link_type(_M_node)->_M_value_field; } -#ifndef __SGI_STL_NO_ARROW_OPERATOR - pointer operator->() const { return &(operator*()); } -#endif /* __SGI_STL_NO_ARROW_OPERATOR */ - - _Self& operator++() { _M_increment(); return *this; } - _Self operator++(int) { - _Self __tmp = *this; - _M_increment(); - return __tmp; - } - - _Self& operator--() { _M_decrement(); return *this; } - _Self operator--(int) { - _Self __tmp = *this; - _M_decrement(); - return __tmp; - } -}; - -inline bool operator==(const _Rb_tree_base_iterator& __x, - const _Rb_tree_base_iterator& __y) { - return __x._M_node == __y._M_node; -} - -inline bool operator!=(const _Rb_tree_base_iterator& __x, - const _Rb_tree_base_iterator& __y) { - return __x._M_node != __y._M_node; -} - -#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION - -inline bidirectional_iterator_tag -iterator_category(const _Rb_tree_base_iterator&) { - return bidirectional_iterator_tag(); -} - -inline _Rb_tree_base_iterator::difference_type* -distance_type(const _Rb_tree_base_iterator&) { - return (_Rb_tree_base_iterator::difference_type*) 0; -} - -template -inline _Value* value_type(const _Rb_tree_iterator<_Value, _Ref, _Ptr>&) { - return (_Value*) 0; -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -inline void -_Rb_tree_rotate_left(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root) -{ - _Rb_tree_node_base* __y = __x->_M_right; - __x->_M_right = __y->_M_left; - if (__y->_M_left !=0) - __y->_M_left->_M_parent = __x; - __y->_M_parent = __x->_M_parent; - - if (__x == __root) - __root = __y; - else if (__x == __x->_M_parent->_M_left) - __x->_M_parent->_M_left = __y; - else - __x->_M_parent->_M_right = __y; - __y->_M_left = __x; - __x->_M_parent = __y; -} - -inline void -_Rb_tree_rotate_right(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root) -{ - _Rb_tree_node_base* __y = __x->_M_left; - __x->_M_left = __y->_M_right; - if (__y->_M_right != 0) - __y->_M_right->_M_parent = __x; - __y->_M_parent = __x->_M_parent; - - if (__x == __root) - __root = __y; - else if (__x == __x->_M_parent->_M_right) - __x->_M_parent->_M_right = __y; - else - __x->_M_parent->_M_left = __y; - __y->_M_right = __x; - __x->_M_parent = __y; -} - -inline void -_Rb_tree_rebalance(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root) -{ - __x->_M_color = _S_rb_tree_red; - while (__x != __root && __x->_M_parent->_M_color == _S_rb_tree_red) { - if (__x->_M_parent == __x->_M_parent->_M_parent->_M_left) { - _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_right; - if (__y && __y->_M_color == _S_rb_tree_red) { - __x->_M_parent->_M_color = _S_rb_tree_black; - __y->_M_color = _S_rb_tree_black; - __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; - __x = __x->_M_parent->_M_parent; - } - else { - if (__x == __x->_M_parent->_M_right) { - __x = __x->_M_parent; - _Rb_tree_rotate_left(__x, __root); - } - __x->_M_parent->_M_color = _S_rb_tree_black; - __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_right(__x->_M_parent->_M_parent, __root); - } - } - else { - _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_left; - if (__y && __y->_M_color == _S_rb_tree_red) { - __x->_M_parent->_M_color = _S_rb_tree_black; - __y->_M_color = _S_rb_tree_black; - __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; - __x = __x->_M_parent->_M_parent; - } - else { - if (__x == __x->_M_parent->_M_left) { - __x = __x->_M_parent; - _Rb_tree_rotate_right(__x, __root); - } - __x->_M_parent->_M_color = _S_rb_tree_black; - __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_left(__x->_M_parent->_M_parent, __root); - } - } - } - __root->_M_color = _S_rb_tree_black; -} - -inline _Rb_tree_node_base* -_Rb_tree_rebalance_for_erase(_Rb_tree_node_base* __z, - _Rb_tree_node_base*& __root, - _Rb_tree_node_base*& __leftmost, - _Rb_tree_node_base*& __rightmost) -{ - _Rb_tree_node_base* __y = __z; - _Rb_tree_node_base* __x = 0; - _Rb_tree_node_base* __x_parent = 0; - if (__y->_M_left == 0) // __z has at most one non-null child. y == z. - __x = __y->_M_right; // __x might be null. - else - if (__y->_M_right == 0) // __z has exactly one non-null child. y == z. - __x = __y->_M_left; // __x is not null. - else { // __z has two non-null children. Set __y to - __y = __y->_M_right; // __z's successor. __x might be null. - while (__y->_M_left != 0) - __y = __y->_M_left; - __x = __y->_M_right; - } - if (__y != __z) { // relink y in place of z. y is z's successor - __z->_M_left->_M_parent = __y; - __y->_M_left = __z->_M_left; - if (__y != __z->_M_right) { - __x_parent = __y->_M_parent; - if (__x) __x->_M_parent = __y->_M_parent; - __y->_M_parent->_M_left = __x; // __y must be a child of _M_left - __y->_M_right = __z->_M_right; - __z->_M_right->_M_parent = __y; - } - else - __x_parent = __y; - if (__root == __z) - __root = __y; - else if (__z->_M_parent->_M_left == __z) - __z->_M_parent->_M_left = __y; - else - __z->_M_parent->_M_right = __y; - __y->_M_parent = __z->_M_parent; - __STD::swap(__y->_M_color, __z->_M_color); - __y = __z; - // __y now points to node to be actually deleted - } - else { // __y == __z - __x_parent = __y->_M_parent; - if (__x) __x->_M_parent = __y->_M_parent; - if (__root == __z) - __root = __x; - else - if (__z->_M_parent->_M_left == __z) - __z->_M_parent->_M_left = __x; - else - __z->_M_parent->_M_right = __x; - if (__leftmost == __z) { - if (__z->_M_right == 0) // __z->_M_left must be null also - __leftmost = __z->_M_parent; - // makes __leftmost == _M_header if __z == __root - else - __leftmost = _Rb_tree_node_base::_S_minimum(__x); - } - if (__rightmost == __z) { - if (__z->_M_left == 0) // __z->_M_right must be null also - __rightmost = __z->_M_parent; - // makes __rightmost == _M_header if __z == __root - else // __x == __z->_M_left - __rightmost = _Rb_tree_node_base::_S_maximum(__x); - } - } - if (__y->_M_color != _S_rb_tree_red) { - while (__x != __root && (__x == 0 || __x->_M_color == _S_rb_tree_black)) - if (__x == __x_parent->_M_left) { - _Rb_tree_node_base* __w = __x_parent->_M_right; - if (__w->_M_color == _S_rb_tree_red) { - __w->_M_color = _S_rb_tree_black; - __x_parent->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_left(__x_parent, __root); - __w = __x_parent->_M_right; - } - if ((__w->_M_left == 0 || - __w->_M_left->_M_color == _S_rb_tree_black) && - (__w->_M_right == 0 || - __w->_M_right->_M_color == _S_rb_tree_black)) { - __w->_M_color = _S_rb_tree_red; - __x = __x_parent; - __x_parent = __x_parent->_M_parent; - } else { - if (__w->_M_right == 0 || - __w->_M_right->_M_color == _S_rb_tree_black) { - if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black; - __w->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_right(__w, __root); - __w = __x_parent->_M_right; - } - __w->_M_color = __x_parent->_M_color; - __x_parent->_M_color = _S_rb_tree_black; - if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black; - _Rb_tree_rotate_left(__x_parent, __root); - break; - } - } else { // same as above, with _M_right <-> _M_left. - _Rb_tree_node_base* __w = __x_parent->_M_left; - if (__w->_M_color == _S_rb_tree_red) { - __w->_M_color = _S_rb_tree_black; - __x_parent->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_right(__x_parent, __root); - __w = __x_parent->_M_left; - } - if ((__w->_M_right == 0 || - __w->_M_right->_M_color == _S_rb_tree_black) && - (__w->_M_left == 0 || - __w->_M_left->_M_color == _S_rb_tree_black)) { - __w->_M_color = _S_rb_tree_red; - __x = __x_parent; - __x_parent = __x_parent->_M_parent; - } else { - if (__w->_M_left == 0 || - __w->_M_left->_M_color == _S_rb_tree_black) { - if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black; - __w->_M_color = _S_rb_tree_red; - _Rb_tree_rotate_left(__w, __root); - __w = __x_parent->_M_left; - } - __w->_M_color = __x_parent->_M_color; - __x_parent->_M_color = _S_rb_tree_black; - if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black; - _Rb_tree_rotate_right(__x_parent, __root); - break; - } - } - if (__x) __x->_M_color = _S_rb_tree_black; - } - return __y; -} - -// Base class to encapsulate the differences between old SGI-style -// allocators and standard-conforming allocators. In order to avoid -// having an empty base class, we arbitrarily move one of rb_tree's -// data members into the base class. - -#ifdef __STL_USE_STD_ALLOCATORS - -// _Base for general standard-conforming allocators. -template -class _Rb_tree_alloc_base { -public: - typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type; - allocator_type get_allocator() const { return _M_node_allocator; } - - _Rb_tree_alloc_base(const allocator_type& __a) - : _M_node_allocator(__a), _M_header(0) {} - -protected: - typename _Alloc_traits<_Rb_tree_node<_Tp>, _Alloc>::allocator_type - _M_node_allocator; - _Rb_tree_node<_Tp>* _M_header; - - _Rb_tree_node<_Tp>* _M_get_node() - { return _M_node_allocator.allocate(1); } - void _M_put_node(_Rb_tree_node<_Tp>* __p) - { _M_node_allocator.deallocate(__p, 1); } -}; - -// Specialization for instanceless allocators. -template -class _Rb_tree_alloc_base<_Tp, _Alloc, true> { -public: - typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Rb_tree_alloc_base(const allocator_type&) : _M_header(0) {} - -protected: - _Rb_tree_node<_Tp>* _M_header; - - typedef typename _Alloc_traits<_Rb_tree_node<_Tp>, _Alloc>::_Alloc_type - _Alloc_type; - - _Rb_tree_node<_Tp>* _M_get_node() - { return _Alloc_type::allocate(1); } - void _M_put_node(_Rb_tree_node<_Tp>* __p) - { _Alloc_type::deallocate(__p, 1); } -}; - -template -struct _Rb_tree_base - : public _Rb_tree_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> -{ - typedef _Rb_tree_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> - _Base; - typedef typename _Base::allocator_type allocator_type; - - _Rb_tree_base(const allocator_type& __a) - : _Base(__a) { _Base::_M_header = _Base::_M_get_node(); } - ~_Rb_tree_base() { _M_put_node(_Base::_M_header); } - -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -struct _Rb_tree_base -{ - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Rb_tree_base(const allocator_type&) - : _M_header(0) { _M_header = _M_get_node(); } - ~_Rb_tree_base() { _M_put_node(_M_header); } - -protected: - _Rb_tree_node<_Tp>* _M_header; - - typedef simple_alloc<_Rb_tree_node<_Tp>, _Alloc> _Alloc_type; - - _Rb_tree_node<_Tp>* _M_get_node() - { return _Alloc_type::allocate(1); } - void _M_put_node(_Rb_tree_node<_Tp>* __p) - { _Alloc_type::deallocate(__p, 1); } -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -template -class _Rb_tree : protected _Rb_tree_base<_Value, _Alloc> { - typedef _Rb_tree_base<_Value, _Alloc> _Base; -protected: - typedef _Rb_tree_node_base* _Base_ptr; - typedef std::_Rb_tree_node<_Value> _Rb_tree_node; - typedef std::_Rb_tree_Color_type _Color_type; -public: - typedef _Key key_type; - typedef _Value value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef _Rb_tree_node* _Link_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - typedef typename _Base::allocator_type allocator_type; - allocator_type get_allocator() const { return _Base::get_allocator(); } - -protected: -#ifdef __STL_USE_NAMESPACES - using _Base::_M_get_node; - using _Base::_M_put_node; - using _Base::_M_header; -#endif /* __STL_USE_NAMESPACES */ - -protected: - - _Link_type _M_create_node(const value_type& __x) - { - _Link_type __tmp = _M_get_node(); - __STL_TRY { - construct(&__tmp->_M_value_field, __x); - } - __STL_UNWIND(_M_put_node(__tmp)); - return __tmp; - } - - _Link_type _M_clone_node(_Link_type __x) - { - _Link_type __tmp = _M_create_node(__x->_M_value_field); - __tmp->_M_color = __x->_M_color; - __tmp->_M_left = 0; - __tmp->_M_right = 0; - return __tmp; - } - - void destroy_node(_Link_type __p) - { - destroy(&__p->_M_value_field); - _M_put_node(__p); - } - -protected: - size_type _M_node_count; // keeps track of size of tree - _Compare _M_key_compare; - - _Link_type& _M_root() const - { return (_Link_type&) _M_header->_M_parent; } - _Link_type& _M_leftmost() const - { return (_Link_type&) _M_header->_M_left; } - _Link_type& _M_rightmost() const - { return (_Link_type&) _M_header->_M_right; } - - static _Link_type& _S_left(_Link_type __x) - { return (_Link_type&)(__x->_M_left); } - static _Link_type& _S_right(_Link_type __x) - { return (_Link_type&)(__x->_M_right); } - static _Link_type& _S_parent(_Link_type __x) - { return (_Link_type&)(__x->_M_parent); } - static reference _S_value(_Link_type __x) - { return __x->_M_value_field; } - static const _Key& _S_key(_Link_type __x) - { return _KeyOfValue()(_S_value(__x)); } - static _Color_type& _S_color(_Link_type __x) - { return (_Color_type&)(__x->_M_color); } - - static _Link_type& _S_left(_Base_ptr __x) - { return (_Link_type&)(__x->_M_left); } - static _Link_type& _S_right(_Base_ptr __x) - { return (_Link_type&)(__x->_M_right); } - static _Link_type& _S_parent(_Base_ptr __x) - { return (_Link_type&)(__x->_M_parent); } - static reference _S_value(_Base_ptr __x) - { return ((_Link_type)__x)->_M_value_field; } - static const _Key& _S_key(_Base_ptr __x) - { return _KeyOfValue()(_S_value(_Link_type(__x)));} - static _Color_type& _S_color(_Base_ptr __x) - { return (_Color_type&)(_Link_type(__x)->_M_color); } - - static _Link_type _S_minimum(_Link_type __x) - { return (_Link_type) _Rb_tree_node_base::_S_minimum(__x); } - - static _Link_type _S_maximum(_Link_type __x) - { return (_Link_type) _Rb_tree_node_base::_S_maximum(__x); } - -public: - typedef _Rb_tree_iterator iterator; - typedef _Rb_tree_iterator - const_iterator; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef reverse_bidirectional_iterator - reverse_iterator; - typedef reverse_bidirectional_iterator - const_reverse_iterator; -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -private: - iterator _M_insert(_Base_ptr __x, _Base_ptr __y, const value_type& __v); - _Link_type _M_copy(_Link_type __x, _Link_type __p); - void _M_erase(_Link_type __x); - -public: - // allocation/deallocation - _Rb_tree() - : _Base(allocator_type()), _M_node_count(0), _M_key_compare() - { _M_empty_initialize(); } - - _Rb_tree(const _Compare& __comp) - : _Base(allocator_type()), _M_node_count(0), _M_key_compare(__comp) - { _M_empty_initialize(); } - - _Rb_tree(const _Compare& __comp, const allocator_type& __a) - : _Base(__a), _M_node_count(0), _M_key_compare(__comp) - { _M_empty_initialize(); } - - _Rb_tree(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x) - : _Base(__x.get_allocator()), - _M_node_count(0), _M_key_compare(__x._M_key_compare) - { - if (__x._M_root() == 0) - _M_empty_initialize(); - else { - _S_color(_M_header) = _S_rb_tree_red; - _M_root() = _M_copy(__x._M_root(), _M_header); - _M_leftmost() = _S_minimum(_M_root()); - _M_rightmost() = _S_maximum(_M_root()); - } - _M_node_count = __x._M_node_count; - } - ~_Rb_tree() { clear(); } - _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& - operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x); - -private: - void _M_empty_initialize() { - _S_color(_M_header) = _S_rb_tree_red; // used to distinguish header from - // __root, in iterator.operator++ - _M_root() = 0; - _M_leftmost() = _M_header; - _M_rightmost() = _M_header; - } - -public: - // accessors: - _Compare key_comp() const { return _M_key_compare; } - iterator begin() { return _M_leftmost(); } - const_iterator begin() const { return _M_leftmost(); } - iterator end() { return _M_header; } - const_iterator end() const { return _M_header; } - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - bool empty() const { return _M_node_count == 0; } - size_type size() const { return _M_node_count; } - size_type max_size() const { return size_type(-1); } - - void swap(_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __t) { - __STD::swap(_M_header, __t._M_header); - __STD::swap(_M_node_count, __t._M_node_count); - __STD::swap(_M_key_compare, __t._M_key_compare); - } - -public: - // insert/erase - pair insert_unique(const value_type& __x); - iterator insert_equal(const value_type& __x); - - iterator insert_unique(iterator __position, const value_type& __x); - iterator insert_equal(iterator __position, const value_type& __x); - -#ifdef __STL_MEMBER_TEMPLATES - template - void insert_unique(_InputIterator __first, _InputIterator __last); - template - void insert_equal(_InputIterator __first, _InputIterator __last); -#else /* __STL_MEMBER_TEMPLATES */ - void insert_unique(const_iterator __first, const_iterator __last); - void insert_unique(const value_type* __first, const value_type* __last); - void insert_equal(const_iterator __first, const_iterator __last); - void insert_equal(const value_type* __first, const value_type* __last); -#endif /* __STL_MEMBER_TEMPLATES */ - - void erase(iterator __position); - size_type erase(const key_type& __x); - void erase(iterator __first, iterator __last); - void erase(const key_type* __first, const key_type* __last); - void clear() { - if (_M_node_count != 0) { - _M_erase(_M_root()); - _M_leftmost() = _M_header; - _M_root() = 0; - _M_rightmost() = _M_header; - _M_node_count = 0; - } - } - -public: - // set operations: - iterator find(const key_type& __x); - const_iterator find(const key_type& __x) const; - size_type count(const key_type& __x) const; - iterator lower_bound(const key_type& __x); - const_iterator lower_bound(const key_type& __x) const; - iterator upper_bound(const key_type& __x); - const_iterator upper_bound(const key_type& __x) const; - pair equal_range(const key_type& __x); - pair equal_range(const key_type& __x) const; - -public: - // Debugging. - bool __rb_verify() const; -}; - -template -inline bool -operator==(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) -{ - return __x.size() == __y.size() && - equal(__x.begin(), __x.end(), __y.begin()); -} - -template -inline bool -operator<(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) -{ - return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool -operator!=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) { - return !(__x == __y); -} - -template -inline bool -operator>(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) { - return __y < __x; -} - -template -inline bool -operator<=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) { - return !(__y < __x); -} - -template -inline bool -operator>=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) { - return !(__x < __y); -} - - -template -inline void -swap(_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, - _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) -{ - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - -template -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x) -{ - if (this != &__x) { - // Note that _Key may be a constant type. - clear(); - _M_node_count = 0; - _M_key_compare = __x._M_key_compare; - if (__x._M_root() == 0) { - _M_root() = 0; - _M_leftmost() = _M_header; - _M_rightmost() = _M_header; - } - else { - _M_root() = _M_copy(__x._M_root(), _M_header); - _M_leftmost() = _S_minimum(_M_root()); - _M_rightmost() = _S_maximum(_M_root()); - _M_node_count = __x._M_node_count; - } - } - return *this; -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::_M_insert(_Base_ptr __x_, _Base_ptr __y_, const _Value& __v) -{ - _Link_type __x = (_Link_type) __x_; - _Link_type __y = (_Link_type) __y_; - _Link_type __z; - - if (__y == _M_header || __x != 0 || - _M_key_compare(_KeyOfValue()(__v), _S_key(__y))) { - __z = _M_create_node(__v); - _S_left(__y) = __z; // also makes _M_leftmost() = __z - // when __y == _M_header - if (__y == _M_header) { - _M_root() = __z; - _M_rightmost() = __z; - } - else if (__y == _M_leftmost()) - _M_leftmost() = __z; // maintain _M_leftmost() pointing to min node - } - else { - __z = _M_create_node(__v); - _S_right(__y) = __z; - if (__y == _M_rightmost()) - _M_rightmost() = __z; // maintain _M_rightmost() pointing to max node - } - _S_parent(__z) = __y; - _S_left(__z) = 0; - _S_right(__z) = 0; - _Rb_tree_rebalance(__z, _M_header->_M_parent); - ++_M_node_count; - return iterator(__z); -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::insert_equal(const _Value& __v) -{ - _Link_type __y = _M_header; - _Link_type __x = _M_root(); - while (__x != 0) { - __y = __x; - __x = _M_key_compare(_KeyOfValue()(__v), _S_key(__x)) ? - _S_left(__x) : _S_right(__x); - } - return _M_insert(__x, __y, __v); -} - - -template -pair::iterator, - bool> -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::insert_unique(const _Value& __v) -{ - _Link_type __y = _M_header; - _Link_type __x = _M_root(); - bool __comp = true; - while (__x != 0) { - __y = __x; - __comp = _M_key_compare(_KeyOfValue()(__v), _S_key(__x)); - __x = __comp ? _S_left(__x) : _S_right(__x); - } - iterator __j = iterator(__y); - if (__comp) { - if (__j == begin()) - return pair(_M_insert(__x, __y, __v), true); - else - --__j; - } - if (_M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__v))) - return pair(_M_insert(__x, __y, __v), true); - return pair(__j, false); -} - - -template -typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator -_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc> - ::insert_unique(iterator __position, const _Val& __v) -{ - if (__position._M_node == _M_header->_M_left) { // begin() - if (size() > 0 && - _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node))) - return _M_insert(__position._M_node, __position._M_node, __v); - // first argument just needs to be non-null - else - return insert_unique(__v).first; - } else if (__position._M_node == _M_header) { // end() - if (_M_key_compare(_S_key(_M_rightmost()), _KeyOfValue()(__v))) - return _M_insert(0, _M_rightmost(), __v); - else - return insert_unique(__v).first; - } else { - iterator __before = __position; - --__before; - if (_M_key_compare(_S_key(__before._M_node), _KeyOfValue()(__v)) - && _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node))) { - if (_S_right(__before._M_node) == 0) - return _M_insert(0, __before._M_node, __v); - else - return _M_insert(__position._M_node, __position._M_node, __v); - // first argument just needs to be non-null - } else - return insert_unique(__v).first; - } -} - -template -typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc> - ::insert_equal(iterator __position, const _Val& __v) -{ - if (__position._M_node == _M_header->_M_left) { // begin() - if (size() > 0 && - !_M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__v))) - return _M_insert(__position._M_node, __position._M_node, __v); - // first argument just needs to be non-null - else - return insert_equal(__v); - } else if (__position._M_node == _M_header) {// end() - if (!_M_key_compare(_KeyOfValue()(__v), _S_key(_M_rightmost()))) - return _M_insert(0, _M_rightmost(), __v); - else - return insert_equal(__v); - } else { - iterator __before = __position; - --__before; - if (!_M_key_compare(_KeyOfValue()(__v), _S_key(__before._M_node)) - && !_M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__v))) { - if (_S_right(__before._M_node) == 0) - return _M_insert(0, __before._M_node, __v); - else - return _M_insert(__position._M_node, __position._M_node, __v); - // first argument just needs to be non-null - } else - return insert_equal(__v); - } -} - -#ifdef __STL_MEMBER_TEMPLATES - -template - template -void _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_equal(_II __first, _II __last) -{ - for ( ; __first != __last; ++__first) - insert_equal(*__first); -} - -template - template -void _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_unique(_II __first, _II __last) { - for ( ; __first != __last; ++__first) - insert_unique(*__first); -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -void -_Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_equal(const _Val* __first, const _Val* __last) -{ - for ( ; __first != __last; ++__first) - insert_equal(*__first); -} - -template -void -_Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_equal(const_iterator __first, const_iterator __last) -{ - for ( ; __first != __last; ++__first) - insert_equal(*__first); -} - -template -void -_Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_unique(const _Val* __first, const _Val* __last) -{ - for ( ; __first != __last; ++__first) - insert_unique(*__first); -} - -template -void _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc> - ::insert_unique(const_iterator __first, const_iterator __last) -{ - for ( ; __first != __last; ++__first) - insert_unique(*__first); -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -inline void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::erase(iterator __position) -{ - _Link_type __y = - (_Link_type) _Rb_tree_rebalance_for_erase(__position._M_node, - _M_header->_M_parent, - _M_header->_M_left, - _M_header->_M_right); - destroy_node(__y); - --_M_node_count; -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::size_type -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::erase(const _Key& __x) -{ - pair __p = equal_range(__x); - size_type __n = 0; - distance(__p.first, __p.second, __n); - erase(__p.first, __p.second); - return __n; -} - -template -typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type -_Rb_tree<_Key,_Val,_KoV,_Compare,_Alloc> - ::_M_copy(_Link_type __x, _Link_type __p) -{ - // structural copy. __x and __p must be non-null. - _Link_type __top = _M_clone_node(__x); - __top->_M_parent = __p; - - __STL_TRY { - if (__x->_M_right) - __top->_M_right = _M_copy(_S_right(__x), __top); - __p = __top; - __x = _S_left(__x); - - while (__x != 0) { - _Link_type __y = _M_clone_node(__x); - __p->_M_left = __y; - __y->_M_parent = __p; - if (__x->_M_right) - __y->_M_right = _M_copy(_S_right(__x), __y); - __p = __y; - __x = _S_left(__x); - } - } - __STL_UNWIND(_M_erase(__top)); - - return __top; -} - -template -void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::_M_erase(_Link_type __x) -{ - // erase without rebalancing - while (__x != 0) { - _M_erase(_S_right(__x)); - _Link_type __y = _S_left(__x); - destroy_node(__x); - __x = __y; - } -} - -template -void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::erase(iterator __first, iterator __last) -{ - if (__first == begin() && __last == end()) - clear(); - else - while (__first != __last) erase(__first++); -} - -template -void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::erase(const _Key* __first, const _Key* __last) -{ - while (__first != __last) erase(*__first++); -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::find(const _Key& __k) -{ - _Link_type __y = _M_header; // Last node which is not less than __k. - _Link_type __x = _M_root(); // Current node. - - while (__x != 0) - if (!_M_key_compare(_S_key(__x), __k)) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - - iterator __j = iterator(__y); - return (__j == end() || _M_key_compare(__k, _S_key(__j._M_node))) ? - end() : __j; -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::find(const _Key& __k) const -{ - _Link_type __y = _M_header; /* Last node which is not less than __k. */ - _Link_type __x = _M_root(); /* Current node. */ - - while (__x != 0) { - if (!_M_key_compare(_S_key(__x), __k)) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - } - const_iterator __j = const_iterator(__y); - return (__j == end() || _M_key_compare(__k, _S_key(__j._M_node))) ? - end() : __j; -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::size_type -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::count(const _Key& __k) const -{ - pair __p = equal_range(__k); - size_type __n = 0; - distance(__p.first, __p.second, __n); - return __n; -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::lower_bound(const _Key& __k) -{ - _Link_type __y = _M_header; /* Last node which is not less than __k. */ - _Link_type __x = _M_root(); /* Current node. */ - - while (__x != 0) - if (!_M_key_compare(_S_key(__x), __k)) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - - return iterator(__y); -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::lower_bound(const _Key& __k) const -{ - _Link_type __y = _M_header; /* Last node which is not less than __k. */ - _Link_type __x = _M_root(); /* Current node. */ - - while (__x != 0) - if (!_M_key_compare(_S_key(__x), __k)) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - - return const_iterator(__y); -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::upper_bound(const _Key& __k) -{ - _Link_type __y = _M_header; /* Last node which is greater than __k. */ - _Link_type __x = _M_root(); /* Current node. */ - - while (__x != 0) - if (_M_key_compare(__k, _S_key(__x))) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - - return iterator(__y); -} - -template -typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::upper_bound(const _Key& __k) const -{ - _Link_type __y = _M_header; /* Last node which is greater than __k. */ - _Link_type __x = _M_root(); /* Current node. */ - - while (__x != 0) - if (_M_key_compare(__k, _S_key(__x))) - __y = __x, __x = _S_left(__x); - else - __x = _S_right(__x); - - return const_iterator(__y); -} - -template -inline -pair::iterator, - typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator> -_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> - ::equal_range(const _Key& __k) -{ - return pair(lower_bound(__k), upper_bound(__k)); -} - -template -inline -pair::const_iterator, - typename _Rb_tree<_Key, _Value, _KoV, _Compare, _Alloc>::const_iterator> -_Rb_tree<_Key, _Value, _KoV, _Compare, _Alloc> - ::equal_range(const _Key& __k) const -{ - return pair(lower_bound(__k), - upper_bound(__k)); -} - -inline int -__black_count(_Rb_tree_node_base* __node, _Rb_tree_node_base* __root) -{ - if (__node == 0) - return 0; - else { - int __bc = __node->_M_color == _S_rb_tree_black ? 1 : 0; - if (__node == __root) - return __bc; - else - return __bc + __black_count(__node->_M_parent, __root); - } -} - -template -bool _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const -{ - if (_M_node_count == 0 || begin() == end()) - return _M_node_count == 0 && begin() == end() && - _M_header->_M_left == _M_header && _M_header->_M_right == _M_header; - - int __len = __black_count(_M_leftmost(), _M_root()); - for (const_iterator __it = begin(); __it != end(); ++__it) { - _Link_type __x = (_Link_type) __it._M_node; - _Link_type __L = _S_left(__x); - _Link_type __R = _S_right(__x); - - if (__x->_M_color == _S_rb_tree_red) - if ((__L && __L->_M_color == _S_rb_tree_red) || - (__R && __R->_M_color == _S_rb_tree_red)) - return false; - - if (__L && _M_key_compare(_S_key(__x), _S_key(__L))) - return false; - if (__R && _M_key_compare(_S_key(__R), _S_key(__x))) - return false; - - if (!__L && !__R && __black_count(__x, _M_root()) != __len) - return false; - } - - if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root())) - return false; - if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root())) - return false; - - return true; -} - -// Class rb_tree is not part of the C++ standard. It is provided for -// compatibility with the HP STL. - -template -struct rb_tree : public _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> -{ - typedef _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> _Base; - typedef typename _Base::allocator_type allocator_type; - - rb_tree(const _Compare& __comp = _Compare(), - const allocator_type& __a = allocator_type()) - : _Base(__comp, __a) {} - - ~rb_tree() {} -}; - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_TREE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_uninitialized.h b/DSTAT1/src/avr-stl/include/stl_uninitialized.h deleted file mode 100644 index d367fbe..0000000 --- a/DSTAT1/src/avr-stl/include/stl_uninitialized.h +++ /dev/null @@ -1,279 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H -#define __SGI_STL_INTERNAL_UNINITIALIZED_H - -__STL_BEGIN_NAMESPACE - -// uninitialized_copy - -// Valid if copy construction is equivalent to assignment, and if the -// destructor is trivial. -template -inline _ForwardIter -__uninitialized_copy_aux(_InputIter __first, _InputIter __last, - _ForwardIter __result, - __true_type) -{ - return copy(__first, __last, __result); -} - -template -_ForwardIter -__uninitialized_copy_aux(_InputIter __first, _InputIter __last, - _ForwardIter __result, - __false_type) -{ - _ForwardIter __cur = __result; - __STL_TRY { - for ( ; __first != __last; ++__first, ++__cur) - _Construct(&*__cur, *__first); - return __cur; - } - __STL_UNWIND(_Destroy(__result, __cur)); -} - - -template -inline _ForwardIter -__uninitialized_copy(_InputIter __first, _InputIter __last, - _ForwardIter __result, _Tp*) -{ - typedef typename __type_traits<_Tp>::is_POD_type _Is_POD; - return __uninitialized_copy_aux(__first, __last, __result, _Is_POD()); -} - -template -inline _ForwardIter - uninitialized_copy(_InputIter __first, _InputIter __last, - _ForwardIter __result) -{ - return __uninitialized_copy(__first, __last, __result, - __VALUE_TYPE(__result)); -} - -inline char* uninitialized_copy(const char* __first, const char* __last, - char* __result) { - memmove(__result, __first, __last - __first); - return __result + (__last - __first); -} - -inline wchar_t* -uninitialized_copy(const wchar_t* __first, const wchar_t* __last, - wchar_t* __result) -{ - memmove(__result, __first, sizeof(wchar_t) * (__last - __first)); - return __result + (__last - __first); -} - -// uninitialized_copy_n (not part of the C++ standard) - -template -pair<_InputIter, _ForwardIter> -__uninitialized_copy_n(_InputIter __first, _Size __count, - _ForwardIter __result, - input_iterator_tag) -{ - _ForwardIter __cur = __result; - __STL_TRY { - for ( ; __count > 0 ; --__count, ++__first, ++__cur) - _Construct(&*__cur, *__first); - return pair<_InputIter, _ForwardIter>(__first, __cur); - } - __STL_UNWIND(_Destroy(__result, __cur)); -} - -template -inline pair<_RandomAccessIter, _ForwardIter> -__uninitialized_copy_n(_RandomAccessIter __first, _Size __count, - _ForwardIter __result, - random_access_iterator_tag) { - _RandomAccessIter __last = __first + __count; - return pair<_RandomAccessIter, _ForwardIter>( - __last, - uninitialized_copy(__first, __last, __result)); -} - -template -inline pair<_InputIter, _ForwardIter> -__uninitialized_copy_n(_InputIter __first, _Size __count, - _ForwardIter __result) { - return __uninitialized_copy_n(__first, __count, __result, - __ITERATOR_CATEGORY(__first)); -} - -template -inline pair<_InputIter, _ForwardIter> -uninitialized_copy_n(_InputIter __first, _Size __count, - _ForwardIter __result) { - return __uninitialized_copy_n(__first, __count, __result, - __ITERATOR_CATEGORY(__first)); -} - -// Valid if copy construction is equivalent to assignment, and if the -// destructor is trivial. -template -inline void -__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last, - const _Tp& __x, __true_type) -{ - fill(__first, __last, __x); -} - -template -void -__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last, - const _Tp& __x, __false_type) -{ - _ForwardIter __cur = __first; - __STL_TRY { - for ( ; __cur != __last; ++__cur) - _Construct(&*__cur, __x); - } - __STL_UNWIND(_Destroy(__first, __cur)); -} - -template -inline void __uninitialized_fill(_ForwardIter __first, - _ForwardIter __last, const _Tp& __x, _Tp1*) -{ - typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD; - __uninitialized_fill_aux(__first, __last, __x, _Is_POD()); - -} - -template -inline void uninitialized_fill(_ForwardIter __first, - _ForwardIter __last, - const _Tp& __x) -{ - __uninitialized_fill(__first, __last, __x, __VALUE_TYPE(__first)); -} - -// Valid if copy construction is equivalent to assignment, and if the -// destructor is trivial. -template -inline _ForwardIter -__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n, - const _Tp& __x, __true_type) -{ - return fill_n(__first, __n, __x); -} - -template -_ForwardIter -__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n, - const _Tp& __x, __false_type) -{ - _ForwardIter __cur = __first; - __STL_TRY { - for ( ; __n > 0; --__n, ++__cur) - _Construct(&*__cur, __x); - return __cur; - } - __STL_UNWIND(_Destroy(__first, __cur)); -} - -template -inline _ForwardIter -__uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x, _Tp1*) -{ - typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD; - return __uninitialized_fill_n_aux(__first, __n, __x, _Is_POD()); -} - -template -inline _ForwardIter -uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) -{ - return __uninitialized_fill_n(__first, __n, __x, __VALUE_TYPE(__first)); -} - -// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill, -// __uninitialized_fill_copy. - -// __uninitialized_copy_copy -// Copies [first1, last1) into [result, result + (last1 - first1)), and -// copies [first2, last2) into -// [result, result + (last1 - first1) + (last2 - first2)). - -template -inline _ForwardIter -__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1, - _InputIter2 __first2, _InputIter2 __last2, - _ForwardIter __result) -{ - _ForwardIter __mid = uninitialized_copy(__first1, __last1, __result); - __STL_TRY { - return uninitialized_copy(__first2, __last2, __mid); - } - __STL_UNWIND(_Destroy(__result, __mid)); -} - -// __uninitialized_fill_copy -// Fills [result, mid) with x, and copies [first, last) into -// [mid, mid + (last - first)). -template -inline _ForwardIter -__uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid, - const _Tp& __x, - _InputIter __first, _InputIter __last) -{ - uninitialized_fill(__result, __mid, __x); - __STL_TRY { - return uninitialized_copy(__first, __last, __mid); - } - __STL_UNWIND(_Destroy(__result, __mid)); -} - -// __uninitialized_copy_fill -// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and -// fills [first2 + (last1 - first1), last2) with x. -template -inline void -__uninitialized_copy_fill(_InputIter __first1, _InputIter __last1, - _ForwardIter __first2, _ForwardIter __last2, - const _Tp& __x) -{ - _ForwardIter __mid2 = uninitialized_copy(__first1, __last1, __first2); - __STL_TRY { - uninitialized_fill(__mid2, __last2, __x); - } - __STL_UNWIND(_Destroy(__first2, __mid2)); -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_UNINITIALIZED_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/stl_vector.h b/DSTAT1/src/avr-stl/include/stl_vector.h deleted file mode 100644 index 18e1bc4..0000000 --- a/DSTAT1/src/avr-stl/include/stl_vector.h +++ /dev/null @@ -1,879 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_VECTOR_H -#define __SGI_STL_INTERNAL_VECTOR_H - -#include - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -// The vector base class serves two purposes. First, its constructor -// and destructor allocate (but don't initialize) storage. This makes -// exception safety easier. Second, the base class encapsulates all of -// the differences between SGI-style allocators and standard-conforming -// allocators. - -#ifdef __STL_USE_STD_ALLOCATORS - -// Base class for ordinary allocators. -template -class _Vector_alloc_base { -public: - typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return _M_data_allocator; } - - _Vector_alloc_base(const allocator_type& __a) - : _M_data_allocator(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0) - {} - -protected: - allocator_type _M_data_allocator; - _Tp* _M_start; - _Tp* _M_finish; - _Tp* _M_end_of_storage; - - _Tp* _M_allocate(size_t __n) - { return _M_data_allocator.allocate(__n); } - void _M_deallocate(_Tp* __p, size_t __n) - { if (__p) _M_data_allocator.deallocate(__p, __n); } -}; - -// Specialization for allocators that have the property that we don't -// actually have to store an allocator object. -template -class _Vector_alloc_base<_Tp, _Allocator, true> { -public: - typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type - allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Vector_alloc_base(const allocator_type&) - : _M_start(0), _M_finish(0), _M_end_of_storage(0) - {} - -protected: - _Tp* _M_start; - _Tp* _M_finish; - _Tp* _M_end_of_storage; - - typedef typename _Alloc_traits<_Tp, _Allocator>::_Alloc_type _Alloc_type; - _Tp* _M_allocate(size_t __n) - { return _Alloc_type::allocate(__n); } - void _M_deallocate(_Tp* __p, size_t __n) - { _Alloc_type::deallocate(__p, __n);} -}; - -template -struct _Vector_base - : public _Vector_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> -{ - typedef _Vector_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> - _Base; - typedef typename _Base::allocator_type allocator_type; - - _Vector_base(const allocator_type& __a) : _Base(__a) {} - _Vector_base(size_t __n, const allocator_type& __a) : _Base(__a) { - _Base::_M_start = _Base::_M_allocate(__n); - _Base::_M_finish = _Base::_M_start; - _Base::_M_end_of_storage = _Base::_M_start + __n; - } - - ~_Vector_base() { _M_deallocate(_Base::_M_start, _Base::_M_end_of_storage - _Base::_M_start); } -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template -class _Vector_base { -public: - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _Vector_base(const _Alloc&) - : _M_start(0), _M_finish(0), _M_end_of_storage(0) {} - _Vector_base(size_t __n, const _Alloc&) - : _M_start(0), _M_finish(0), _M_end_of_storage(0) - { - _M_start = _M_allocate(__n); - _M_finish = _M_start; - _M_end_of_storage = _M_start + __n; - } - - ~_Vector_base() { _M_deallocate(_M_start, _M_end_of_storage - _M_start); } - -protected: - _Tp* _M_start; - _Tp* _M_finish; - _Tp* _M_end_of_storage; - - typedef simple_alloc<_Tp, _Alloc> _M_data_allocator; - _Tp* _M_allocate(size_t __n) - { return _M_data_allocator::allocate(__n); } - void _M_deallocate(_Tp* __p, size_t __n) - { _M_data_allocator::deallocate(__p, __n); } -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -template -class vector : protected _Vector_base<_Tp, _Alloc> -{ - // requirements: - - __STL_CLASS_REQUIRES(_Tp, _Assignable); - -private: - typedef _Vector_base<_Tp, _Alloc> _Base; -public: - typedef _Tp value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type* iterator; - typedef const value_type* const_iterator; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - typedef typename _Base::allocator_type allocator_type; - allocator_type get_allocator() const { return _Base::get_allocator(); } - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator - reverse_iterator; -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -protected: -#ifdef __STL_HAS_NAMESPACES - using _Base::_M_allocate; - using _Base::_M_deallocate; - using _Base::_M_start; - using _Base::_M_finish; - using _Base::_M_end_of_storage; -#endif /* __STL_HAS_NAMESPACES */ - -protected: - void _M_insert_aux(iterator __position, const _Tp& __x); - void _M_insert_aux(iterator __position); - -public: - iterator begin() { return _M_start; } - const_iterator begin() const { return _M_start; } - iterator end() { return _M_finish; } - const_iterator end() const { return _M_finish; } - - reverse_iterator rbegin() - { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const - { return const_reverse_iterator(end()); } - reverse_iterator rend() - { return reverse_iterator(begin()); } - const_reverse_iterator rend() const - { return const_reverse_iterator(begin()); } - - size_type size() const - { return size_type(end() - begin()); } - size_type max_size() const - { return size_type(-1) / sizeof(_Tp); } - size_type capacity() const - { return size_type(_M_end_of_storage - begin()); } - bool empty() const - { return begin() == end(); } - - reference operator[](size_type __n) { return *(begin() + __n); } - const_reference operator[](size_type __n) const { return *(begin() + __n); } - -#ifdef __STL_THROW_RANGE_ERRORS - void _M_range_check(size_type __n) const { - if (__n >= this->size()) - __stl_throw_range_error("vector"); - } - - reference at(size_type __n) - { _M_range_check(__n); return (*this)[__n]; } - const_reference at(size_type __n) const - { _M_range_check(__n); return (*this)[__n]; } -#endif /* __STL_THROW_RANGE_ERRORS */ - - explicit vector(const allocator_type& __a = allocator_type()) - : _Base(__a) {} - - vector(size_type __n, const _Tp& __value, - const allocator_type& __a = allocator_type()) - : _Base(__n, __a) - { _M_finish = uninitialized_fill_n(_M_start, __n, __value); } - - explicit vector(size_type __n) - : _Base(__n, allocator_type()) - { _M_finish = uninitialized_fill_n(_M_start, __n, _Tp()); } - - vector(const vector<_Tp, _Alloc>& __x) - : _Base(__x.size(), __x.get_allocator()) - { _M_finish = uninitialized_copy(__x.begin(), __x.end(), _M_start); } - -#ifdef __STL_MEMBER_TEMPLATES - // Check whether it's an integral type. If so, it's not an iterator. - template - vector(_InputIterator __first, _InputIterator __last, - const allocator_type& __a = allocator_type()) : _Base(__a) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_initialize_aux(__first, __last, _Integral()); - } - - template - void _M_initialize_aux(_Integer __n, _Integer __value, __true_type) { - _M_start = _M_allocate(__n); - _M_end_of_storage = _M_start + __n; - _M_finish = uninitialized_fill_n(_M_start, __n, __value); - } - - template - void _M_initialize_aux(_InputIterator __first, _InputIterator __last, - __false_type) { - _M_range_initialize(__first, __last, __ITERATOR_CATEGORY(__first)); - } - -#else - vector(const _Tp* __first, const _Tp* __last, - const allocator_type& __a = allocator_type()) - : _Base(__last - __first, __a) - { _M_finish = uninitialized_copy(__first, __last, _M_start); } -#endif /* __STL_MEMBER_TEMPLATES */ - - ~vector() { destroy(_M_start, _M_finish); } - - vector<_Tp, _Alloc>& operator=(const vector<_Tp, _Alloc>& __x); - void reserve(size_type __n) { - if (capacity() < __n) { - const size_type __old_size = size(); - iterator __tmp = _M_allocate_and_copy(__n, _M_start, _M_finish); - destroy(_M_start, _M_finish); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __tmp; - _M_finish = __tmp + __old_size; - _M_end_of_storage = _M_start + __n; - } - } - - // assign(), a generalized assignment member function. Two - // versions: one that takes a count, and one that takes a range. - // The range version is a member template, so we dispatch on whether - // or not the type is an integer. - - void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); } - void _M_fill_assign(size_type __n, const _Tp& __val); - -#ifdef __STL_MEMBER_TEMPLATES - - template - void assign(_InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_assign_dispatch(__first, __last, _Integral()); - } - - template - void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { _M_fill_assign((size_type) __n, (_Tp) __val); } - - template - void _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type) - { _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first)); } - - template - void _M_assign_aux(_InputIterator __first, _InputIterator __last, - input_iterator_tag); - - template - void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag); - -#endif /* __STL_MEMBER_TEMPLATES */ - - reference front() { return *begin(); } - const_reference front() const { return *begin(); } - reference back() { return *(end() - 1); } - const_reference back() const { return *(end() - 1); } - - void push_back(const _Tp& __x) { - if (_M_finish != _M_end_of_storage) { - construct(_M_finish, __x); - ++_M_finish; - } - else - _M_insert_aux(end(), __x); - } - void push_back() { - if (_M_finish != _M_end_of_storage) { - construct(_M_finish); - ++_M_finish; - } - else - _M_insert_aux(end()); - } - void swap(vector<_Tp, _Alloc>& __x) { - __STD::swap(_M_start, __x._M_start); - __STD::swap(_M_finish, __x._M_finish); - __STD::swap(_M_end_of_storage, __x._M_end_of_storage); - } - - iterator insert(iterator __position, const _Tp& __x) { - size_type __n = __position - begin(); - if (_M_finish != _M_end_of_storage && __position == end()) { - construct(_M_finish, __x); - ++_M_finish; - } - else - _M_insert_aux(__position, __x); - return begin() + __n; - } - iterator insert(iterator __position) { - size_type __n = __position - begin(); - if (_M_finish != _M_end_of_storage && __position == end()) { - construct(_M_finish); - ++_M_finish; - } - else - _M_insert_aux(__position); - return begin() + __n; - } -#ifdef __STL_MEMBER_TEMPLATES - // Check whether it's an integral type. If so, it's not an iterator. - template - void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_insert_dispatch(__pos, __first, __last, _Integral()); - } - - template - void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, - __true_type) - { _M_fill_insert(__pos, (size_type) __n, (_Tp) __val); } - - template - void _M_insert_dispatch(iterator __pos, - _InputIterator __first, _InputIterator __last, - __false_type) { - _M_range_insert(__pos, __first, __last, __ITERATOR_CATEGORY(__first)); - } -#else /* __STL_MEMBER_TEMPLATES */ - void insert(iterator __position, - const_iterator __first, const_iterator __last); -#endif /* __STL_MEMBER_TEMPLATES */ - - void insert (iterator __pos, size_type __n, const _Tp& __x) - { _M_fill_insert(__pos, __n, __x); } - - void _M_fill_insert (iterator __pos, size_type __n, const _Tp& __x); - - void pop_back() { - --_M_finish; - destroy(_M_finish); - } - iterator erase(iterator __position) { - if (__position + 1 != end()) - copy(__position + 1, _M_finish, __position); - --_M_finish; - destroy(_M_finish); - return __position; - } - iterator erase(iterator __first, iterator __last) { - iterator __i = copy(__last, _M_finish, __first); - destroy(__i, _M_finish); - _M_finish = _M_finish - (__last - __first); - return __first; - } - - void resize(size_type __new_size, const _Tp& __x) { - if (__new_size < size()) - erase(begin() + __new_size, end()); - else - insert(end(), __new_size - size(), __x); - } - void resize(size_type __new_size) { resize(__new_size, _Tp()); } - void clear() { erase(begin(), end()); } - -protected: - -#ifdef __STL_MEMBER_TEMPLATES - template - iterator _M_allocate_and_copy(size_type __n, _ForwardIterator __first, - _ForwardIterator __last) -{ - iterator __result = _M_allocate(__n); - __STL_TRY { - uninitialized_copy(__first, __last, __result); - return __result; - } - __STL_UNWIND(_M_deallocate(__result, __n)); - } -#else /* __STL_MEMBER_TEMPLATES */ - iterator _M_allocate_and_copy(size_type __n, const_iterator __first, - const_iterator __last) - { - iterator __result = _M_allocate(__n); - __STL_TRY { - uninitialized_copy(__first, __last, __result); - return __result; - } - __STL_UNWIND(_M_deallocate(__result, __n)); - } -#endif /* __STL_MEMBER_TEMPLATES */ - - -#ifdef __STL_MEMBER_TEMPLATES - template - void _M_range_initialize(_InputIterator __first, - _InputIterator __last, input_iterator_tag) - { - for ( ; __first != __last; ++__first) - push_back(*__first); - } - - // This function is only called by the constructor. - template - void _M_range_initialize(_ForwardIterator __first, - _ForwardIterator __last, forward_iterator_tag) - { - size_type __n = 0; - distance(__first, __last, __n); - _M_start = _M_allocate(__n); - _M_end_of_storage = _M_start + __n; - _M_finish = uninitialized_copy(__first, __last, _M_start); - } - - template - void _M_range_insert(iterator __pos, - _InputIterator __first, _InputIterator __last, - input_iterator_tag); - - template - void _M_range_insert(iterator __pos, - _ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag); - -#endif /* __STL_MEMBER_TEMPLATES */ -}; - -template -inline bool -operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) -{ - return __x.size() == __y.size() && - equal(__x.begin(), __x.end(), __y.begin()); -} - -template -inline bool -operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) -{ - return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) -{ - __x.swap(__y); -} - -template -inline bool -operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { - return !(__x == __y); -} - -template -inline bool -operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { - return __y < __x; -} - -template -inline bool -operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { - return !(__y < __x); -} - -template -inline bool -operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { - return !(__x < __y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -template -vector<_Tp,_Alloc>& -vector<_Tp,_Alloc>::operator=(const vector<_Tp, _Alloc>& __x) -{ - if (&__x != this) { - const size_type __xlen = __x.size(); - if (__xlen > capacity()) { - iterator __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end()); - destroy(_M_start, _M_finish); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __tmp; - _M_end_of_storage = _M_start + __xlen; - } - else if (size() >= __xlen) { - iterator __i = copy(__x.begin(), __x.end(), begin()); - destroy(__i, _M_finish); - } - else { - copy(__x.begin(), __x.begin() + size(), _M_start); - uninitialized_copy(__x.begin() + size(), __x.end(), _M_finish); - } - _M_finish = _M_start + __xlen; - } - return *this; -} - -template -void vector<_Tp, _Alloc>::_M_fill_assign(size_t __n, const value_type& __val) -{ - if (__n > capacity()) { - vector<_Tp, _Alloc> __tmp(__n, __val, get_allocator()); - __tmp.swap(*this); - } - else if (__n > size()) { - fill(begin(), end(), __val); - _M_finish = uninitialized_fill_n(_M_finish, __n - size(), __val); - } - else - erase(fill_n(begin(), __n, __val), end()); -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -void vector<_Tp, _Alloc>::_M_assign_aux(_InputIter __first, _InputIter __last, - input_iterator_tag) { - iterator __cur = begin(); - for ( ; __first != __last && __cur != end(); ++__cur, ++__first) - *__cur = *__first; - if (__first == __last) - erase(__cur, end()); - else - insert(end(), __first, __last); -} - -template template -void -vector<_Tp, _Alloc>::_M_assign_aux(_ForwardIter __first, _ForwardIter __last, - forward_iterator_tag) { - size_type __len = 0; - distance(__first, __last, __len); - - if (__len > capacity()) { - iterator __tmp = _M_allocate_and_copy(__len, __first, __last); - destroy(_M_start, _M_finish); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __tmp; - _M_end_of_storage = _M_finish = _M_start + __len; - } - else if (size() >= __len) { - iterator __new_finish = copy(__first, __last, _M_start); - destroy(__new_finish, _M_finish); - _M_finish = __new_finish; - } - else { - _ForwardIter __mid = __first; - advance(__mid, size()); - copy(__first, __mid, _M_start); - _M_finish = uninitialized_copy(__mid, __last, _M_finish); - } -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -void -vector<_Tp, _Alloc>::_M_insert_aux(iterator __position, const _Tp& __x) -{ - if (_M_finish != _M_end_of_storage) { - construct(_M_finish, *(_M_finish - 1)); - ++_M_finish; - _Tp __x_copy = __x; - copy_backward(__position, _M_finish - 2, _M_finish - 1); - *__position = __x_copy; - } - else { - const size_type __old_size = size(); - -#ifdef __AVR__ - const size_type __len = __old_size != 0 ? avrstl::AvrVectorAllocAhead<_Tp>(__old_size) : 1; -#else - const size_type __len = __old_size != 0 ? 2 * __old_size : 1; -#endif - iterator __new_start = _M_allocate(__len); - iterator __new_finish = __new_start; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - construct(__new_finish, __x); - ++__new_finish; - __new_finish = uninitialized_copy(__position, _M_finish, __new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(begin(), end()); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __len; - } -} - -template -void -vector<_Tp, _Alloc>::_M_insert_aux(iterator __position) -{ - if (_M_finish != _M_end_of_storage) { - construct(_M_finish, *(_M_finish - 1)); - ++_M_finish; - copy_backward(__position, _M_finish - 2, _M_finish - 1); - *__position = _Tp(); - } - else { - const size_type __old_size = size(); - -#ifdef __AVR__ - const size_type __len = __old_size != 0 ? avrstl::AvrVectorAllocAhead<_Tp>(__old_size) : 1; -#else - const size_type __len = __old_size != 0 ? 2 * __old_size : 1; -#endif - iterator __new_start = _M_allocate(__len); - iterator __new_finish = __new_start; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - construct(__new_finish); - ++__new_finish; - __new_finish = uninitialized_copy(__position, _M_finish, __new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(begin(), end()); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __len; - } -} - -template -void vector<_Tp, _Alloc>::_M_fill_insert(iterator __position, size_type __n, - const _Tp& __x) -{ - if (__n != 0) { - if (size_type(_M_end_of_storage - _M_finish) >= __n) { - _Tp __x_copy = __x; - const size_type __elems_after = _M_finish - __position; - iterator __old_finish = _M_finish; - if (__elems_after > __n) { - uninitialized_copy(_M_finish - __n, _M_finish, _M_finish); - _M_finish += __n; - copy_backward(__position, __old_finish - __n, __old_finish); - fill(__position, __position + __n, __x_copy); - } - else { - uninitialized_fill_n(_M_finish, __n - __elems_after, __x_copy); - _M_finish += __n - __elems_after; - uninitialized_copy(__position, __old_finish, _M_finish); - _M_finish += __elems_after; - fill(__position, __old_finish, __x_copy); - } - } - else { - const size_type __old_size = size(); - const size_type __len = __old_size + max(__old_size, __n); - iterator __new_start = _M_allocate(__len); - iterator __new_finish = __new_start; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - __new_finish = uninitialized_fill_n(__new_finish, __n, __x); - __new_finish - = uninitialized_copy(__position, _M_finish, __new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __len; - } - } -} - -#ifdef __STL_MEMBER_TEMPLATES - -template template -void -vector<_Tp, _Alloc>::_M_range_insert(iterator __pos, - _InputIterator __first, - _InputIterator __last, - input_iterator_tag) -{ - for ( ; __first != __last; ++__first) { - __pos = insert(__pos, *__first); - ++__pos; - } -} - -template template -void -vector<_Tp, _Alloc>::_M_range_insert(iterator __position, - _ForwardIterator __first, - _ForwardIterator __last, - forward_iterator_tag) -{ - if (__first != __last) { - size_type __n = 0; - distance(__first, __last, __n); - if (size_type(_M_end_of_storage - _M_finish) >= __n) { - const size_type __elems_after = _M_finish - __position; - iterator __old_finish = _M_finish; - if (__elems_after > __n) { - uninitialized_copy(_M_finish - __n, _M_finish, _M_finish); - _M_finish += __n; - copy_backward(__position, __old_finish - __n, __old_finish); - copy(__first, __last, __position); - } - else { - _ForwardIterator __mid = __first; - advance(__mid, __elems_after); - uninitialized_copy(__mid, __last, _M_finish); - _M_finish += __n - __elems_after; - uninitialized_copy(__position, __old_finish, _M_finish); - _M_finish += __elems_after; - copy(__first, __mid, __position); - } - } - else { - const size_type __old_size = size(); - const size_type __len = __old_size + max(__old_size, __n); - iterator __new_start = _M_allocate(__len); - iterator __new_finish = __new_start; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - __new_finish = uninitialized_copy(__first, __last, __new_finish); - __new_finish - = uninitialized_copy(__position, _M_finish, __new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __len; - } - } -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -void -vector<_Tp, _Alloc>::insert(iterator __position, - const_iterator __first, - const_iterator __last) -{ - if (__first != __last) { - size_type __n = 0; - distance(__first, __last, __n); - if (size_type(_M_end_of_storage - _M_finish) >= __n) { - const size_type __elems_after = _M_finish - __position; - iterator __old_finish = _M_finish; - if (__elems_after > __n) { - uninitialized_copy(_M_finish - __n, _M_finish, _M_finish); - _M_finish += __n; - copy_backward(__position, __old_finish - __n, __old_finish); - copy(__first, __last, __position); - } - else { - uninitialized_copy(__first + __elems_after, __last, _M_finish); - _M_finish += __n - __elems_after; - uninitialized_copy(__position, __old_finish, _M_finish); - _M_finish += __elems_after; - copy(__first, __first + __elems_after, __position); - } - } - else { - const size_type __old_size = size(); - const size_type __len = __old_size + max(__old_size, __n); - iterator __new_start = _M_allocate(__len); - iterator __new_finish = __new_start; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - __new_finish = uninitialized_copy(__first, __last, __new_finish); - __new_finish - = uninitialized_copy(__position, _M_finish, __new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __len; - } - } -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_VECTOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/streambuf b/DSTAT1/src/avr-stl/include/streambuf deleted file mode 100644 index 0daa388..0000000 --- a/DSTAT1/src/avr-stl/include/streambuf +++ /dev/null @@ -1,329 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include -#include - -#ifndef HEADER_STD_STREAMBUF -#define HEADER_STD_STREAMBUF 1 - -#include - -#pragma GCC visibility push(default) - -namespace std{ - - template class _UCXXEXPORT basic_streambuf{ - public: -#ifdef __UCLIBCXX_SUPPORT_CDIR__ - friend ios_base::Init::Init(); -#endif - // Types: - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - typedef traits traits_type; - - virtual ~basic_streambuf(); - - locale pubimbue(const locale &loc); - - locale getloc() const{ - return myLocale; - } - - basic_streambuf* pubsetbuf(char_type* s, streamsize n){ - return setbuf(s,n); - } - pos_type pubseekoff(off_type off, - typename ios_base::seekdir way, - ios_base::openmode which = ios_base::in | - ios_base::out - ) - { - return seekoff(off,way,which); - } - pos_type pubseekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out){ - return seekpos(sp,which); - } - int pubsync(){ - return sync(); - } - - streamsize in_avail(); - - int_type snextc(); - - int_type sbumpc(); - - int_type sgetc(); - - streamsize sgetn(char_type* s, streamsize n){ - return xsgetn(s,n); - } - - int_type sputbackc(char_type c); - - int_type sungetc(); - - int_type sputc(char_type c); - - streamsize sputn(const char_type* s, streamsize n){ - if(openedFor & ios_base::app){ - seekoff(0, ios_base::end, ios_base::out); - } - return xsputn(s, n); - } - - protected: - locale myLocale; - //Pointers for the "get" buffers - charT * mgbeg; - charT * mgnext; - charT * mgend; - - //Pointers for the "put" buffers - charT * mpbeg; - charT * mpnext; - charT * mpend; - - //In the event of null buffers Lets us know what the buffer is opened for - ios_base::openmode openedFor; - - basic_streambuf(); - - basic_streambuf(const basic_streambuf > &) - : myLocale(), - mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0), - openedFor(0) - { } - basic_streambuf > & operator=(const basic_streambuf > &){ - return *this; - } - - char_type* eback() const{ - return mgbeg; - } - char_type* gptr() const{ - return mgnext; - } - char_type* egptr() const{ - return mgend; - } - void gbump(int n){ - mgnext+=n; - } - void setg(char_type* gbeg, char_type* gnext, char_type* gend){ - mgbeg = gbeg; - mgnext = gnext; - mgend = gend; - } - - char_type* pbase() const{ - return mpbeg; - } - char_type* pptr() const{ - return mpnext; - } - char_type* epptr() const{ - return mpend; - } - void pbump(int n){ - mpnext+=n; - } - void setp(char_type* pbeg, char_type* pend){ - mpbeg = pbeg; - mpnext = pbeg; - mpend = pend; - } - - virtual void imbue(const locale &loc){ - myLocale = loc; - } - - //Virtual functions which we will not implement - - virtual basic_streambuf* setbuf(char_type* , streamsize){ - return 0; - } - virtual pos_type seekoff(off_type , ios_base::seekdir, - ios_base::openmode = ios_base::in | ios_base::out) - { - return 0; - } - virtual pos_type seekpos(pos_type , ios_base::openmode = ios_base::in | ios_base::out){ - return 0; - } - virtual int sync(){ - return 0; - } - - virtual int showmanyc(){ - return 0; - } - virtual streamsize xsgetn(char_type* , streamsize ){ - return 0; - } - virtual int_type underflow(){ - return traits_type::eof(); - } - virtual int_type uflow(){ - int_type ret = underflow(); - if (!traits_type::eq_int_type(ret, traits_type::eof())) - gbump(1); - return ret; - } - - virtual int_type pbackfail(int_type c = traits::eof()){ - return c; - } - virtual streamsize xsputn(const char_type* c, streamsize n){ - //This function is designed to be replaced by subclasses - for(streamsize i = 0; i< n; ++i){ - if(sputc(c[i]) == traits::eof()){ - return i; - } - } - return n; - } - virtual int_type overflow (int_type c = traits::eof()){ - return c; - } - }; - - typedef basic_streambuf streambuf; -#ifdef __UCLIBCXX_HAS_WCHAR__ - typedef basic_streambuf wstreambuf; -#endif - - -//Definitions put below to allow for easy expansion of code - - template basic_streambuf::~basic_streambuf(){ } - - template locale basic_streambuf::pubimbue(const locale &loc){ - locale temp = myLocale; - myLocale = loc; - return temp; - } - - template streamsize basic_streambuf::in_avail(){ - if(mgend !=0 && mgnext !=0){ - return mgend - mgnext; - } - return showmanyc(); - } - - template typename basic_streambuf::int_type basic_streambuf::sbumpc(){ - if(mgbeg == 0 || mgnext == mgend){ - return uflow(); - } - int_type retval = T::to_int_type(*gptr()); - gbump(1); - return retval; - } - - template typename basic_streambuf::int_type basic_streambuf::snextc(){ - if(sbumpc() == T::eof() ){ - return T::eof() ; - } - return sgetc(); - } - - template typename basic_streambuf::int_type basic_streambuf::sgetc(){ - if(mgbeg == 0 || mgnext == mgend){ - return underflow(); - } - return T::to_int_type(*gptr()); - } - - template typename basic_streambuf::int_type basic_streambuf::sputbackc(char_type c){ - if(mgbeg == 0 || mgnext == mgbeg || !T::eq(c, gptr()[-1] )){ - return pbackfail(T::to_int_type(c)); - } - gbump(-1); - return T::to_int_type(*gptr()); - } - - template typename basic_streambuf::int_type basic_streambuf::sungetc(){ - if(mgbeg == 0 || mgnext == mgbeg){ - return ios_base::failbit; - } - gbump(-1); - return T::to_int_type(*gptr()); - } - - template typename basic_streambuf::int_type basic_streambuf::sputc(char_type c){ - if(openedFor & ios_base::app){ - seekoff(0, ios_base::end, ios_base::out); - } - if(mpnext < mpend){ - *mpnext = c; - ++mpnext; - }else{ - return overflow( T::to_int_type(c) ); - } - return T::to_int_type(c); - } - - template basic_streambuf::basic_streambuf() - : myLocale(), - mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0), - openedFor(0) - { } - - - - - - -#ifdef __UCLIBCXX_EXPAND_STREAMBUF_CHAR__ -#ifndef __UCLIBCXX_COMPILE_STREAMBUF__ - -#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT streambuf::basic_streambuf(); - template <> _UCXXEXPORT streambuf::~basic_streambuf(); - -#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT locale streambuf::pubimbue(const locale &loc); - template <> _UCXXEXPORT streamsize streambuf::in_avail(); - template <> _UCXXEXPORT streambuf::int_type streambuf::sbumpc(); - template <> _UCXXEXPORT streambuf::int_type streambuf::snextc(); - template <> _UCXXEXPORT streambuf::int_type streambuf::sgetc(); - template <> _UCXXEXPORT streambuf::int_type streambuf::sputbackc(char_type c); - template <> _UCXXEXPORT streambuf::int_type streambuf::sungetc(); - template <> _UCXXEXPORT streambuf::int_type streambuf::sputc(char_type c); - -#endif -#endif - - - - - -} - -#pragma GCC visibility pop - -#endif diff --git a/DSTAT1/src/avr-stl/include/string b/DSTAT1/src/avr-stl/include/string deleted file mode 100644 index 32f920a..0000000 --- a/DSTAT1/src/avr-stl/include/string +++ /dev/null @@ -1,2453 +0,0 @@ -/* - * Copyright (c) 1997-1999 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_STRING -#define __SGI_STL_STRING - -#include -#include -#include -#include -#include - -#ifndef __AVR__ -#include -#endif - -#include -#include -#include - -#ifdef __STL_USE_NEW_IOSTREAMS -#include -#include -#else /* __STL_USE_NEW_IOSTREAMS */ -#include -#endif /* __STL_USE_NEW_IOSTREAMS */ - -// Standard C++ string class. This class has performance -// characteristics very much like vector<>, meaning, for example, that -// it does not perform reference-count or copy-on-write, and that -// concatenation of two strings is an O(N) operation. - -// There are three reasons why basic_string is not identical to -// vector. First, basic_string always stores a null character at the -// end; this makes it possible for c_str to be a fast operation. -// Second, the C++ standard requires basic_string to copy elements -// using char_traits<>::assign, char_traits<>::copy, and -// char_traits<>::move. This means that all of vector<>'s low-level -// operations must be rewritten. Third, basic_string<> has a lot of -// extra functions in its interface that are convenient but, strictly -// speaking, redundant. - -// Additionally, the C++ standard imposes a major restriction: according -// to the standard, the character type _CharT must be a POD type. This -// implementation weakens that restriction, and allows _CharT to be a -// a user-defined non-POD type. However, _CharT must still have a -// default constructor. - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1174 -#pragma set woff 1375 -#endif - -// A helper class to use a char_traits as a function object. - -template -struct _Not_within_traits - : public unary_function -{ - typedef const typename _Traits::char_type* _Pointer; - const _Pointer _M_first; - const _Pointer _M_last; - - _Not_within_traits(_Pointer __f, _Pointer __l) - : _M_first(__f), _M_last(__l) {} - - bool operator()(const typename _Traits::char_type& __x) const { - return find_if(_M_first, _M_last, - bind1st(_Eq_traits<_Traits>(), __x)) == _M_last; - } -}; - -// ------------------------------------------------------------ -// Class _String_base. - -// _String_base is a helper class that makes it it easier to write an -// exception-safe version of basic_string. The constructor allocates, -// but does not initialize, a block of memory. The destructor -// deallocates, but does not destroy elements within, a block of -// memory. The destructor assumes that _M_start either is null, or else -// points to a block of memory that was allocated using _String_base's -// allocator and whose size is _M_end_of_storage - _M_start. - -// Additionally, _String_base encapsulates the difference between -// old SGI-style allocators and standard-conforming allocators. - -#ifdef __STL_USE_STD_ALLOCATORS - -// General base class. -template -class _String_alloc_base { -public: - typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type; - allocator_type get_allocator() const { return _M_data_allocator; } - - _String_alloc_base(const allocator_type& __a) - : _M_data_allocator(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0) - {} - -protected: - _Tp* _M_allocate(size_t __n) - { return _M_data_allocator.allocate(__n); } - void _M_deallocate(_Tp* __p, size_t __n) { - if (__p) - _M_data_allocator.deallocate(__p, __n); - } - -protected: - allocator_type _M_data_allocator; - - _Tp* _M_start; - _Tp* _M_finish; - _Tp* _M_end_of_storage; -}; - -// Specialization for instanceless allocators. -template -class _String_alloc_base<_Tp,_Alloc,true> { -public: - typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - - _String_alloc_base(const allocator_type&) - : _M_start(0), _M_finish(0), _M_end_of_storage(0) {} - -protected: - typedef typename _Alloc_traits<_Tp, _Alloc>::_Alloc_type _Alloc_type; - _Tp* _M_allocate(size_t __n) - { return _Alloc_type::allocate(__n); } - void _M_deallocate(_Tp* __p, size_t __n) - { _Alloc_type::deallocate(__p, __n); } - -protected: - _Tp* _M_start; - _Tp* _M_finish; - _Tp* _M_end_of_storage; -}; - -template -class _String_base - : public _String_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> -{ -protected: - typedef _String_alloc_base<_Tp, _Alloc, - _Alloc_traits<_Tp, _Alloc>::_S_instanceless> - _Base; - typedef typename _Base::allocator_type allocator_type; - - void _M_allocate_block(size_t __n) { - if (__n <= max_size()) { - _Base::_M_start = _Base::_M_allocate(__n); - _Base::_M_finish = _Base::_M_start; - _Base::_M_end_of_storage = _Base::_M_start + __n; - } - else - _M_throw_length_error(); - } - - void _M_deallocate_block() - { _M_deallocate(_Base::_M_start, _Base::_M_end_of_storage - _Base::_M_start); } - - size_t max_size() const { return (size_t(-1) / sizeof(_Tp)) - 1; } - - _String_base(const allocator_type& __a) : _Base(__a) { } - - _String_base(const allocator_type& __a, size_t __n) : _Base(__a) - { _M_allocate_block(__n); } - - ~_String_base() { _M_deallocate_block(); } - - void _M_throw_length_error() const; - void _M_throw_out_of_range() const; -}; - -#else /* __STL_USE_STD_ALLOCATORS */ - -template class _String_base { -public: - typedef _Alloc allocator_type; - allocator_type get_allocator() const { return allocator_type(); } - -protected: - typedef simple_alloc<_Tp, _Alloc> _Alloc_type; - - _Tp* _M_start; - _Tp* _M_finish; - _Tp* _M_end_of_storage; - // Precondition: 0 < __n <= max_size(). - - _Tp* _M_allocate(size_t __n) { return _Alloc_type::allocate(__n); } - void _M_deallocate(_Tp* __p, size_t __n) { - if (__p) - _Alloc_type::deallocate(__p, __n); - } - - void _M_allocate_block(size_t __n) { - if (__n <= max_size()) { - _M_start = _M_allocate(__n); - _M_finish = _M_start; - _M_end_of_storage = _M_start + __n; - } - else - _M_throw_length_error(); - } - - void _M_deallocate_block() - { _M_deallocate(_M_start, _M_end_of_storage - _M_start); } - - size_t max_size() const { return (size_t(-1) / sizeof(_Tp)) - 1; } - - _String_base(const allocator_type&) - : _M_start(0), _M_finish(0), _M_end_of_storage(0) { } - - _String_base(const allocator_type&, size_t __n) - : _M_start(0), _M_finish(0), _M_end_of_storage(0) - { _M_allocate_block(__n); } - - ~_String_base() { _M_deallocate_block(); } - - void _M_throw_length_error() const; - void _M_throw_out_of_range() const; -}; - -#endif /* __STL_USE_STD_ALLOCATORS */ - -// Helper functions for exception handling. -template -void _String_base<_Tp,_Alloc>::_M_throw_length_error() const { - __STL_THROW(length_error("basic_string")); -} - -template -void _String_base<_Tp, _Alloc>::_M_throw_out_of_range() const { - __STL_THROW(out_of_range("basic_string")); -} - - -// ------------------------------------------------------------ -// Class basic_string. - -// Class invariants: -// (1) [start, finish) is a valid range. -// (2) Each iterator in [start, finish) points to a valid object -// of type value_type. -// (3) *finish is a valid object of type value_type; in particular, -// it is value_type(). -// (4) [finish + 1, end_of_storage) is a valid range. -// (5) Each iterator in [finish + 1, end_of_storage) points to -// unininitialized memory. - -// Note one important consequence: a string of length n must manage -// a block of memory whose size is at least n + 1. - - -template -class basic_string : private _String_base<_CharT,_Alloc> { -public: - typedef _CharT value_type; - typedef _Traits traits_type; - - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - typedef const value_type* const_iterator; - typedef value_type* iterator; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - typedef reverse_iterator - const_reverse_iterator; - typedef reverse_iterator - reverse_iterator; -#endif /* __STL_PARTIAL_SPECIALIZATION */ - - static const size_type npos; - - typedef _String_base<_CharT,_Alloc> _Base; - -public: // Constructor, destructor, assignment. - typedef typename _Base::allocator_type allocator_type; - allocator_type get_allocator() const { return _Base::get_allocator(); } - - explicit basic_string(const allocator_type& __a = allocator_type()) - : _Base(__a, 8) { _M_terminate_string(); } - - struct _Reserve_t {}; - basic_string(_Reserve_t, size_t __n, - const allocator_type& __a = allocator_type()) - : _Base(__a, __n + 1) { _M_terminate_string(); } - - basic_string(const basic_string& __s) : _Base(__s.get_allocator()) - { _M_range_initialize(__s.begin(), __s.end()); } - - basic_string(const basic_string& __s, size_type __pos, size_type __n = npos, - const allocator_type& __a = allocator_type()) - : _Base(__a) { - if (__pos > __s.size()) - _M_throw_out_of_range(); - else - _M_range_initialize(__s.begin() + __pos, - __s.begin() + __pos + min(__n, __s.size() - __pos)); - } - - basic_string(const _CharT* __s, size_type __n, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { _M_range_initialize(__s, __s + __n); } - - basic_string(const _CharT* __s, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { _M_range_initialize(__s, __s + _Traits::length(__s)); } - - basic_string(size_type __n, _CharT __c, - const allocator_type& __a = allocator_type()) - : _Base(__a, __n + 1) - { - _M_finish = uninitialized_fill_n(_M_start, __n, __c); - _M_terminate_string(); - } - - // Check to see if _InputIterator is an integer type. If so, then - // it can't be an iterator. -#ifdef __STL_MEMBER_TEMPLATES - template - basic_string(_InputIterator __f, _InputIterator __l, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_initialize_dispatch(__f, __l, _Integral()); - } -#else /* __STL_MEMBER_TEMPLATES */ - basic_string(const _CharT* __f, const _CharT* __l, - const allocator_type& __a = allocator_type()) - : _Base(__a) - { - _M_range_initialize(__f, __l); - } -#endif - - ~basic_string() { destroy(_M_start, _M_finish + 1); } - - basic_string& operator=(const basic_string& __s) { - if (&__s != this) - assign(__s.begin(), __s.end()); - return *this; - } - - basic_string& operator=(const _CharT* __s) - { return assign(__s, __s + _Traits::length(__s)); } - - basic_string& operator=(_CharT __c) - { return assign(static_cast(1), __c); } - -protected: // Protected members inherited from base. -#ifdef __STL_HAS_NAMESPACES - using _Base::_M_allocate; - using _Base::_M_deallocate; - using _Base::_M_allocate_block; - using _Base::_M_deallocate_block; - using _Base::_M_throw_length_error; - using _Base::_M_throw_out_of_range; - - using _Base::_M_start; - using _Base::_M_finish; - using _Base::_M_end_of_storage; -#endif /* __STL_HAS_NAMESPACES */ - -private: // Helper functions used by constructors - // and elsewhere. - void _M_construct_null(_CharT* __p) { - construct(__p); -# ifdef __STL_DEFAULT_CONSTRUCTOR_BUG - __STL_TRY { - *__p = (_CharT) 0; - } - __STL_UNWIND(destroy(__p)); -# endif - } - - static _CharT _M_null() { -# ifndef __STL_DEFAULT_CONSTRUCTOR_BUG - return _CharT(); -# else - return (_CharT) 0; -# endif - } - -private: - // Helper functions used by constructors. It is a severe error for - // any of them to be called anywhere except from within constructors. - - void _M_terminate_string() { - __STL_TRY { - _M_construct_null(_M_finish); - } - __STL_UNWIND(destroy(_M_start, _M_finish)); - } - -#ifdef __STL_MEMBER_TEMPLATES - - template - void _M_range_initialize(_InputIter __f, _InputIter __l, - input_iterator_tag) { - _M_allocate_block(8); - _M_construct_null(_M_finish); - __STL_TRY { - append(__f, __l); - } - __STL_UNWIND(destroy(_M_start, _M_finish + 1)); - } - - template - void _M_range_initialize(_ForwardIter __f, _ForwardIter __l, - forward_iterator_tag) { - difference_type __n = 0; - distance(__f, __l, __n); - _M_allocate_block(__n + 1); - _M_finish = uninitialized_copy(__f, __l, _M_start); - _M_terminate_string(); - } - - template - void _M_range_initialize(_InputIter __f, _InputIter __l) { - typedef typename iterator_traits<_InputIter>::iterator_category _Category; - _M_range_initialize(__f, __l, _Category()); - } - - template - void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) { - _M_allocate_block(__n + 1); - _M_finish = uninitialized_fill_n(_M_start, __n, __x); - _M_terminate_string(); - } - - template - void _M_initialize_dispatch(_InputIter __f, _InputIter __l, __false_type) { - _M_range_initialize(__f, __l); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - void _M_range_initialize(const _CharT* __f, const _CharT* __l) { - ptrdiff_t __n = __l - __f; - _M_allocate_block(__n + 1); - _M_finish = uninitialized_copy(__f, __l, _M_start); - _M_terminate_string(); - } - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: // Iterators. - iterator begin() { return _M_start; } - iterator end() { return _M_finish; } - const_iterator begin() const { return _M_start; } - const_iterator end() const { return _M_finish; } - - reverse_iterator rbegin() - { return reverse_iterator(_M_finish); } - reverse_iterator rend() - { return reverse_iterator(_M_start); } - const_reverse_iterator rbegin() const - { return const_reverse_iterator(_M_finish); } - const_reverse_iterator rend() const - { return const_reverse_iterator(_M_start); } - -public: // Size, capacity, etc. - size_type size() const { return _M_finish - _M_start; } - size_type length() const { return size(); } - - size_t max_size() const { return _Base::max_size(); } - - - void resize(size_type __n, _CharT __c) { - if (__n <= size()) - erase(begin() + __n, end()); - else - append(__n - size(), __c); - } - - void resize(size_type __n) { resize(__n, _M_null()); } - - void reserve(size_type = 0); - - size_type capacity() const { return (_M_end_of_storage - _M_start) - 1; } - - void clear() { - if (!empty()) { - _Traits::assign(*_M_start, _M_null()); - destroy(_M_start+1, _M_finish+1); - _M_finish = _M_start; - } - } - - bool empty() const { return _M_start == _M_finish; } - -public: // Element access. - - const_reference operator[](size_type __n) const - { return *(_M_start + __n); } - reference operator[](size_type __n) - { return *(_M_start + __n); } - - const_reference at(size_type __n) const { - if (__n >= size()) - _M_throw_out_of_range(); - return *(_M_start + __n); - } - - reference at(size_type __n) { - if (__n >= size()) - _M_throw_out_of_range(); - return *(_M_start + __n); - } - -public: // Append, operator+=, push_back. - - basic_string& operator+=(const basic_string& __s) { return append(__s); } - basic_string& operator+=(const _CharT* __s) { return append(__s); } - basic_string& operator+=(_CharT __c) { push_back(__c); return *this; } - - basic_string& append(const basic_string& __s) - { return append(__s.begin(), __s.end()); } - - basic_string& append(const basic_string& __s, - size_type __pos, size_type __n) - { - if (__pos > __s.size()) - _M_throw_out_of_range(); - return append(__s.begin() + __pos, - __s.begin() + __pos + min(__n, __s.size() - __pos)); - } - - basic_string& append(const _CharT* __s, size_type __n) - { return append(__s, __s+__n); } - - basic_string& append(const _CharT* __s) - { return append(__s, __s + _Traits::length(__s)); } - - basic_string& append(size_type __n, _CharT __c); - -#ifdef __STL_MEMBER_TEMPLATES - - // Check to see if _InputIterator is an integer type. If so, then - // it can't be an iterator. - template - basic_string& append(_InputIter __first, _InputIter __last) { - typedef typename _Is_integer<_InputIter>::_Integral _Integral; - return _M_append_dispatch(__first, __last, _Integral()); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - basic_string& append(const _CharT* __first, const _CharT* __last); - -#endif /* __STL_MEMBER_TEMPLATES */ - - void push_back(_CharT __c) { - if (_M_finish + 1 == _M_end_of_storage) - reserve(size() + max(size(), static_cast(1))); - _M_construct_null(_M_finish + 1); - _Traits::assign(*_M_finish, __c); - ++_M_finish; - } - - void pop_back() { - _Traits::assign(*(_M_finish - 1), _M_null()); - destroy(_M_finish); - --_M_finish; - } - -private: // Helper functions for append. - -#ifdef __STL_MEMBER_TEMPLATES - - template - basic_string& append(_InputIter __f, _InputIter __l, input_iterator_tag); - - template - basic_string& append(_ForwardIter __f, _ForwardIter __l, - forward_iterator_tag); - - template - basic_string& _M_append_dispatch(_Integer __n, _Integer __x, __true_type) { - return append((size_type) __n, (_CharT) __x); - } - - template - basic_string& _M_append_dispatch(_InputIter __f, _InputIter __l, - __false_type) { - typedef typename iterator_traits<_InputIter>::iterator_category _Category; - return append(__f, __l, _Category()); - } - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: // Assign - - basic_string& assign(const basic_string& __s) - { return assign(__s.begin(), __s.end()); } - - basic_string& assign(const basic_string& __s, - size_type __pos, size_type __n) { - if (__pos > __s.size()) - _M_throw_out_of_range(); - return assign(__s.begin() + __pos, - __s.begin() + __pos + min(__n, __s.size() - __pos)); - } - - basic_string& assign(const _CharT* __s, size_type __n) - { return assign(__s, __s + __n); } - - basic_string& assign(const _CharT* __s) - { return assign(__s, __s + _Traits::length(__s)); } - - basic_string& assign(size_type __n, _CharT __c); - -#ifdef __STL_MEMBER_TEMPLATES - - // Check to see if _InputIterator is an integer type. If so, then - // it can't be an iterator. - template - basic_string& assign(_InputIter __first, _InputIter __last) { - typedef typename _Is_integer<_InputIter>::_Integral _Integral; - return _M_assign_dispatch(__first, __last, _Integral()); - } - -#endif /* __STL_MEMBER_TEMPLATES */ - - basic_string& assign(const _CharT* __f, const _CharT* __l); - -private: // Helper functions for assign. - -#ifdef __STL_MEMBER_TEMPLATES - - template - basic_string& _M_assign_dispatch(_Integer __n, _Integer __x, __true_type) { - return assign((size_type) __n, (_CharT) __x); - } - - template - basic_string& _M_assign_dispatch(_InputIter __f, _InputIter __l, - __false_type); - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: // Insert - - basic_string& insert(size_type __pos, const basic_string& __s) { - if (__pos > size()) - _M_throw_out_of_range(); - if (size() > max_size() - __s.size()) - _M_throw_length_error(); - insert(_M_start + __pos, __s.begin(), __s.end()); - return *this; - } - - basic_string& insert(size_type __pos, const basic_string& __s, - size_type __beg, size_type __n) { - if (__pos > size() || __beg > __s.size()) - _M_throw_out_of_range(); - size_type __len = min(__n, __s.size() - __beg); - if (size() > max_size() - __len) - _M_throw_length_error(); - insert(_M_start + __pos, - __s.begin() + __beg, __s.begin() + __beg + __len); - return *this; - } - - basic_string& insert(size_type __pos, const _CharT* __s, size_type __n) { - if (__pos > size()) - _M_throw_out_of_range(); - if (size() > max_size() - __n) - _M_throw_length_error(); - insert(_M_start + __pos, __s, __s + __n); - return *this; - } - - basic_string& insert(size_type __pos, const _CharT* __s) { - if (__pos > size()) - _M_throw_out_of_range(); - size_type __len = _Traits::length(__s); - if (size() > max_size() - __len) - _M_throw_length_error(); - insert(_M_start + __pos, __s, __s + __len); - return *this; - } - - basic_string& insert(size_type __pos, size_type __n, _CharT __c) { - if (__pos > size()) - _M_throw_out_of_range(); - if (size() > max_size() - __n) - _M_throw_length_error(); - insert(_M_start + __pos, __n, __c); - return *this; - } - - iterator insert(iterator __p, _CharT __c) { - if (__p == _M_finish) { - push_back(__c); - return _M_finish - 1; - } - else - return _M_insert_aux(__p, __c); - } - - void insert(iterator __p, size_t __n, _CharT __c); - -#ifdef __STL_MEMBER_TEMPLATES - - // Check to see if _InputIterator is an integer type. If so, then - // it can't be an iterator. - template - void insert(iterator __p, _InputIter __first, _InputIter __last) { - typedef typename _Is_integer<_InputIter>::_Integral _Integral; - _M_insert_dispatch(__p, __first, __last, _Integral()); - } - -#else /* __STL_MEMBER_TEMPLATES */ - - void insert(iterator __p, const _CharT* __first, const _CharT* __last); - -#endif /* __STL_MEMBER_TEMPLATES */ - -private: // Helper functions for insert. - -#ifdef __STL_MEMBER_TEMPLATES - - template - void insert(iterator __p, _InputIter, _InputIter, input_iterator_tag); - - template - void insert(iterator __p, _ForwardIter, _ForwardIter, forward_iterator_tag); - - - template - void _M_insert_dispatch(iterator __p, _Integer __n, _Integer __x, - __true_type) { - insert(__p, (size_type) __n, (_CharT) __x); - } - - template - void _M_insert_dispatch(iterator __p, _InputIter __first, _InputIter __last, - __false_type) { - typedef typename iterator_traits<_InputIter>::iterator_category _Category; - insert(__p, __first, __last, _Category()); - } - - template - void - _M_copy(_InputIterator __first, _InputIterator __last, iterator __result) { - for ( ; __first != __last; ++__first, ++__result) - _Traits::assign(*__result, *__first); - } - -#endif /* __STL_MEMBER_TEMPLATES */ - - iterator _M_insert_aux(iterator, _CharT); - - void - _M_copy(const _CharT* __first, const _CharT* __last, _CharT* __result) { - _Traits::copy(__result, __first, __last - __first); - } - -public: // Erase. - - basic_string& erase(size_type __pos = 0, size_type __n = npos) { - if (__pos > size()) - _M_throw_out_of_range(); - erase(_M_start + __pos, _M_start + __pos + min(__n, size() - __pos)); - return *this; - } - - iterator erase(iterator __position) { - // The move includes the terminating null. - _Traits::move(__position, __position + 1, _M_finish - __position); - destroy(_M_finish); - --_M_finish; - return __position; - } - - iterator erase(iterator __first, iterator __last) { - if (__first != __last) { - // The move includes the terminating null. - _Traits::move(__first, __last, (_M_finish - __last) + 1); - const iterator __new_finish = _M_finish - (__last - __first); - destroy(__new_finish + 1, _M_finish + 1); - _M_finish = __new_finish; - } - return __first; - } - -public: // Replace. (Conceptually equivalent - // to erase followed by insert.) - basic_string& replace(size_type __pos, size_type __n, - const basic_string& __s) { - if (__pos > size()) - _M_throw_out_of_range(); - const size_type __len = min(__n, size() - __pos); - if (size() - __len >= max_size() - __s.size()) - _M_throw_length_error(); - return replace(_M_start + __pos, _M_start + __pos + __len, - __s.begin(), __s.end()); - } - - basic_string& replace(size_type __pos1, size_type __n1, - const basic_string& __s, - size_type __pos2, size_type __n2) { - if (__pos1 > size() || __pos2 > __s.size()) - _M_throw_out_of_range(); - const size_type __len1 = min(__n1, size() - __pos1); - const size_type __len2 = min(__n2, __s.size() - __pos2); - if (size() - __len1 >= max_size() - __len2) - _M_throw_length_error(); - return replace(_M_start + __pos1, _M_start + __pos1 + __len1, - __s._M_start + __pos2, __s._M_start + __pos2 + __len2); - } - - basic_string& replace(size_type __pos, size_type __n1, - const _CharT* __s, size_type __n2) { - if (__pos > size()) - _M_throw_out_of_range(); - const size_type __len = min(__n1, size() - __pos); - if (__n2 > max_size() || size() - __len >= max_size() - __n2) - _M_throw_length_error(); - return replace(_M_start + __pos, _M_start + __pos + __len, - __s, __s + __n2); - } - - basic_string& replace(size_type __pos, size_type __n1, - const _CharT* __s) { - if (__pos > size()) - _M_throw_out_of_range(); - const size_type __len = min(__n1, size() - __pos); - const size_type __n2 = _Traits::length(__s); - if (__n2 > max_size() || size() - __len >= max_size() - __n2) - _M_throw_length_error(); - return replace(_M_start + __pos, _M_start + __pos + __len, - __s, __s + _Traits::length(__s)); - } - - basic_string& replace(size_type __pos, size_type __n1, - size_type __n2, _CharT __c) { - if (__pos > size()) - _M_throw_out_of_range(); - const size_type __len = min(__n1, size() - __pos); - if (__n2 > max_size() || size() - __len >= max_size() - __n2) - _M_throw_length_error(); - return replace(_M_start + __pos, _M_start + __pos + __len, __n2, __c); - } - - basic_string& replace(iterator __first, iterator __last, - const basic_string& __s) - { return replace(__first, __last, __s.begin(), __s.end()); } - - basic_string& replace(iterator __first, iterator __last, - const _CharT* __s, size_type __n) - { return replace(__first, __last, __s, __s + __n); } - - basic_string& replace(iterator __first, iterator __last, - const _CharT* __s) { - return replace(__first, __last, __s, __s + _Traits::length(__s)); - } - - basic_string& replace(iterator __first, iterator __last, - size_type __n, _CharT __c); - - // Check to see if _InputIterator is an integer type. If so, then - // it can't be an iterator. -#ifdef __STL_MEMBER_TEMPLATES - template - basic_string& replace(iterator __first, iterator __last, - _InputIter __f, _InputIter __l) { - typedef typename _Is_integer<_InputIter>::_Integral _Integral; - return _M_replace_dispatch(__first, __last, __f, __l, _Integral()); - } -#else /* __STL_MEMBER_TEMPLATES */ - basic_string& replace(iterator __first, iterator __last, - const _CharT* __f, const _CharT* __l); -#endif /* __STL_MEMBER_TEMPLATES */ - -private: // Helper functions for replace. - -#ifdef __STL_MEMBER_TEMPLATES - - template - basic_string& _M_replace_dispatch(iterator __first, iterator __last, - _Integer __n, _Integer __x, - __true_type) { - return replace(__first, __last, (size_type) __n, (_CharT) __x); - } - - template - basic_string& _M_replace_dispatch(iterator __first, iterator __last, - _InputIter __f, _InputIter __l, - __false_type) { - typedef typename iterator_traits<_InputIter>::iterator_category _Category; - return replace(__first, __last, __f, __l, _Category()); - } - - template - basic_string& replace(iterator __first, iterator __last, - _InputIter __f, _InputIter __l, input_iterator_tag); - - template - basic_string& replace(iterator __first, iterator __last, - _ForwardIter __f, _ForwardIter __l, - forward_iterator_tag); - -#endif /* __STL_MEMBER_TEMPLATES */ - -public: // Other modifier member functions. - - size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const { - if (__pos > size()) - _M_throw_out_of_range(); - const size_type __len = min(__n, size() - __pos); - _Traits::copy(__s, _M_start + __pos, __len); - return __len; - } - - void swap(basic_string& __s) { - __STD::swap(_M_start, __s._M_start); - __STD::swap(_M_finish, __s._M_finish); - __STD::swap(_M_end_of_storage, __s._M_end_of_storage); - } - -public: // Conversion to C string. - - const _CharT* c_str() const { return _M_start; } - const _CharT* data() const { return _M_start; } - -public: // find. - - size_type find(const basic_string& __s, size_type __pos = 0) const - { return find(__s.begin(), __pos, __s.size()); } - - size_type find(const _CharT* __s, size_type __pos = 0) const - { return find(__s, __pos, _Traits::length(__s)); } - - size_type find(const _CharT* __s, size_type __pos, size_type __n) const; - size_type find(_CharT __c, size_type __pos = 0) const; - -public: // rfind. - - size_type rfind(const basic_string& __s, size_type __pos = npos) const - { return rfind(__s.begin(), __pos, __s.size()); } - - size_type rfind(const _CharT* __s, size_type __pos = npos) const - { return rfind(__s, __pos, _Traits::length(__s)); } - - size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const; - size_type rfind(_CharT __c, size_type __pos = npos) const; - -public: // find_first_of - - size_type find_first_of(const basic_string& __s, size_type __pos = 0) const - { return find_first_of(__s.begin(), __pos, __s.size()); } - - size_type find_first_of(const _CharT* __s, size_type __pos = 0) const - { return find_first_of(__s, __pos, _Traits::length(__s)); } - - size_type find_first_of(const _CharT* __s, size_type __pos, - size_type __n) const; - - size_type find_first_of(_CharT __c, size_type __pos = 0) const - { return find(__c, __pos); } - -public: // find_last_of - - size_type find_last_of(const basic_string& __s, - size_type __pos = npos) const - { return find_last_of(__s.begin(), __pos, __s.size()); } - - size_type find_last_of(const _CharT* __s, size_type __pos = npos) const - { return find_last_of(__s, __pos, _Traits::length(__s)); } - - size_type find_last_of(const _CharT* __s, size_type __pos, - size_type __n) const; - - size_type find_last_of(_CharT __c, size_type __pos = npos) const { - return rfind(__c, __pos); - } - -public: // find_first_not_of - - size_type find_first_not_of(const basic_string& __s, - size_type __pos = 0) const - { return find_first_not_of(__s.begin(), __pos, __s.size()); } - - size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const - { return find_first_not_of(__s, __pos, _Traits::length(__s)); } - - size_type find_first_not_of(const _CharT* __s, size_type __pos, - size_type __n) const; - - size_type find_first_not_of(_CharT __c, size_type __pos = 0) const; - -public: // find_last_not_of - - size_type find_last_not_of(const basic_string& __s, - size_type __pos = npos) const - { return find_last_not_of(__s.begin(), __pos, __s.size()); } - - size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const - { return find_last_not_of(__s, __pos, _Traits::length(__s)); } - - size_type find_last_not_of(const _CharT* __s, size_type __pos, - size_type __n) const; - - size_type find_last_not_of(_CharT __c, size_type __pos = npos) const; - -public: // Substring. - - basic_string substr(size_type __pos = 0, size_type __n = npos) const { - if (__pos > size()) - _M_throw_out_of_range(); - return basic_string(_M_start + __pos, - _M_start + __pos + min(__n, size() - __pos)); - } - -public: // Compare - - int compare(const basic_string& __s) const - { return _M_compare(_M_start, _M_finish, __s._M_start, __s._M_finish); } - - int compare(size_type __pos1, size_type __n1, - const basic_string& __s) const { - if (__pos1 > size()) - _M_throw_out_of_range(); - return _M_compare(_M_start + __pos1, - _M_start + __pos1 + min(__n1, size() - __pos1), - __s._M_start, __s._M_finish); - } - - int compare(size_type __pos1, size_type __n1, - const basic_string& __s, - size_type __pos2, size_type __n2) const { - if (__pos1 > size() || __pos2 > __s.size()) - _M_throw_out_of_range(); - return _M_compare(_M_start + __pos1, - _M_start + __pos1 + min(__n1, size() - __pos1), - __s._M_start + __pos2, - __s._M_start + __pos2 + min(__n2, size() - __pos2)); - } - - int compare(const _CharT* __s) const { - return _M_compare(_M_start, _M_finish, __s, __s + _Traits::length(__s)); - } - - int compare(size_type __pos1, size_type __n1, const _CharT* __s) const { - if (__pos1 > size()) - _M_throw_out_of_range(); - return _M_compare(_M_start + __pos1, - _M_start + __pos1 + min(__n1, size() - __pos1), - __s, __s + _Traits::length(__s)); - } - - int compare(size_type __pos1, size_type __n1, const _CharT* __s, - size_type __n2) const { - if (__pos1 > size()) - _M_throw_out_of_range(); - return _M_compare(_M_start + __pos1, - _M_start + __pos1 + min(__n1, size() - __pos1), - __s, __s + __n2); - } - -public: // Helper function for compare. - static int _M_compare(const _CharT* __f1, const _CharT* __l1, - const _CharT* __f2, const _CharT* __l2) { - const ptrdiff_t __n1 = __l1 - __f1; - const ptrdiff_t __n2 = __l2 - __f2; - const int cmp = _Traits::compare(__f1, __f2, min(__n1, __n2)); - return cmp != 0 ? cmp : (__n1 < __n2 ? -1 : (__n1 > __n2 ? 1 : 0)); - } -}; - - - -// ------------------------------------------------------------ -// Non-inline declarations. - -template -const typename basic_string<_CharT,_Traits,_Alloc>::size_type -basic_string<_CharT,_Traits,_Alloc>::npos - = (typename basic_string<_CharT,_Traits,_Alloc>::size_type) -1; - -// Change the string's capacity so that it is large enough to hold -// at least __res_arg elements, plus the terminating null. Note that, -// if __res_arg < capacity(), this member function may actually decrease -// the string's capacity. -template -void basic_string<_CharT,_Traits,_Alloc>::reserve(size_type __res_arg) { - if (__res_arg > max_size()) - _M_throw_length_error(); - - size_type __n = max(__res_arg, size()) + 1; - pointer __new_start = _M_allocate(__n); - pointer __new_finish = __new_start; - - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, _M_finish, __new_start); - _M_construct_null(__new_finish); - } - __STL_UNWIND((destroy(__new_start, __new_finish), - _M_deallocate(__new_start, __n))); - - destroy(_M_start, _M_finish + 1); - _M_deallocate_block(); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __n; -} - -template -basic_string<_CharT,_Traits,_Alloc>& -basic_string<_CharT,_Traits,_Alloc>::append(size_type __n, _CharT __c) { - if (__n > max_size() || size() > max_size() - __n) - _M_throw_length_error(); - if (size() + __n > capacity()) - reserve(size() + max(size(), __n)); - if (__n > 0) { - uninitialized_fill_n(_M_finish + 1, __n - 1, __c); - __STL_TRY { - _M_construct_null(_M_finish + __n); - } - __STL_UNWIND(destroy(_M_finish + 1, _M_finish + __n)); - _Traits::assign(*_M_finish, __c); - _M_finish += __n; - } - return *this; -} - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -basic_string<_Tp, _Traits, _Alloc>& -basic_string<_Tp, _Traits, _Alloc>::append(_InputIterator __first, - _InputIterator __last, - input_iterator_tag) { - for ( ; __first != __last ; ++__first) - push_back(*__first); - return *this; -} - -template -template -basic_string<_Tp, _Traits, _Alloc>& -basic_string<_Tp, _Traits, _Alloc>::append(_ForwardIter __first, - _ForwardIter __last, - forward_iterator_tag) { - if (__first != __last) { - const size_type __old_size = size(); - difference_type __n = 0; - - distance(__first, __last, __n); - - if (static_cast(__n) > max_size() || - __old_size > max_size() - static_cast(__n)) - _M_throw_length_error(); - if (__old_size + static_cast(__n) > capacity()) { - -#ifdef __AVR__ - const size_type __len = __old_size + - max(avrstl::AvrStringAllocAheadIncrement<_Tp>(__old_size), - static_cast(__n)) + 1; -#else - const size_type __len = __old_size + - max(__old_size, static_cast(__n)) + 1; -#endif - pointer __new_start = _M_allocate(__len); - pointer __new_finish = __new_start; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, _M_finish, __new_start); - __new_finish = uninitialized_copy(__first, __last, __new_finish); - _M_construct_null(__new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish + 1); - _M_deallocate_block(); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __len; - } - else { - _ForwardIter __f1 = __first; - ++__f1; - uninitialized_copy(__f1, __last, _M_finish + 1); - __STL_TRY { - _M_construct_null(_M_finish + __n); - } - __STL_UNWIND(destroy(_M_finish + 1, _M_finish + __n)); - _Traits::assign(*_M_finish, *__first); - _M_finish += __n; - } - } - return *this; -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -basic_string<_Tp, _Traits, _Alloc>& -basic_string<_Tp, _Traits, _Alloc>::append(const _Tp* __first, - const _Tp* __last) -{ - if (__first != __last) { - const size_type __old_size = size(); - ptrdiff_t __n = __last - __first; - if (__n > max_size() || __old_size > max_size() - __n) - _M_throw_length_error(); - if (__old_size + __n > capacity()) { - const size_type __len = __old_size + max(__old_size, (size_t) __n) + 1; - pointer __new_start = _M_allocate(__len); - pointer __new_finish = __new_start; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, _M_finish, __new_start); - __new_finish = uninitialized_copy(__first, __last, __new_finish); - _M_construct_null(__new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish + 1); - _M_deallocate_block(); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __len; - } - else { - const _Tp* __f1 = __first; - ++__f1; - uninitialized_copy(__f1, __last, _M_finish + 1); - __STL_TRY { - _M_construct_null(_M_finish + __n); - } - __STL_UNWIND(destroy(_M_finish + 1, _M_finish + __n)); - _Traits::assign(*_M_finish, *__first); - _M_finish += __n; - } - } - return *this; -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -basic_string<_CharT,_Traits,_Alloc>& -basic_string<_CharT,_Traits,_Alloc>::assign(size_type __n, _CharT __c) { - if (__n <= size()) { - _Traits::assign(_M_start, __n, __c); - erase(_M_start + __n, _M_finish); - } - else { - _Traits::assign(_M_start, size(), __c); - append(__n - size(), __c); - } - return *this; -} - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -basic_string<_CharT,_Traits,_Alloc>& basic_string<_CharT,_Traits,_Alloc> - ::_M_assign_dispatch(_InputIter __f, _InputIter __l, __false_type) -{ - pointer __cur = _M_start; - while (__f != __l && __cur != _M_finish) { - _Traits::assign(*__cur, *__f); - ++__f; - ++__cur; - } - if (__f == __l) - erase(__cur, _M_finish); - else - append(__f, __l); - return *this; -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -basic_string<_CharT,_Traits,_Alloc>& -basic_string<_CharT,_Traits,_Alloc>::assign(const _CharT* __f, - const _CharT* __l) -{ - const ptrdiff_t __n = __l - __f; - if (static_cast(__n) <= size()) { - _Traits::copy(_M_start, __f, __n); - erase(_M_start + __n, _M_finish); - } - else { - _Traits::copy(_M_start, __f, size()); - append(__f + size(), __l); - } - return *this; -} - -template -typename basic_string<_CharT,_Traits,_Alloc>::iterator -basic_string<_CharT,_Traits,_Alloc> - ::_M_insert_aux(basic_string<_CharT,_Traits,_Alloc>::iterator __p, - _CharT __c) -{ - iterator __new_pos = __p; - if (_M_finish + 1 < _M_end_of_storage) { - _M_construct_null(_M_finish + 1); - _Traits::move(__p + 1, __p, _M_finish - __p); - _Traits::assign(*__p, __c); - ++_M_finish; - } - else { - const size_type __old_len = size(); -#ifdef __AVR__ - const size_type __len = __old_len + - max(avrstl::AvrStringAllocAheadIncrement<_CharT>(__old_len), static_cast(1)) + 1; -#else - const size_type __len = __old_len + - max(__old_len, static_cast(1)) + 1; -#endif - iterator __new_start = _M_allocate(__len); - iterator __new_finish = __new_start; - __STL_TRY { - __new_pos = uninitialized_copy(_M_start, __p, __new_start); - construct(__new_pos, __c); - __new_finish = __new_pos + 1; - __new_finish = uninitialized_copy(__p, _M_finish, __new_finish); - _M_construct_null(__new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish + 1); - _M_deallocate_block(); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __len; - } - return __new_pos; -} - -template -void basic_string<_CharT,_Traits,_Alloc> - ::insert(basic_string<_CharT,_Traits,_Alloc>::iterator __position, - size_t __n, _CharT __c) -{ - if (__n != 0) { - if (size_type(_M_end_of_storage - _M_finish) >= __n + 1) { - const size_type __elems_after = _M_finish - __position; - iterator __old_finish = _M_finish; - if (__elems_after >= __n) { - uninitialized_copy((_M_finish - __n) + 1, _M_finish + 1, - _M_finish + 1); - _M_finish += __n; - _Traits::move(__position + __n, - __position, (__elems_after - __n) + 1); - _Traits::assign(__position, __n, __c); - } - else { - uninitialized_fill_n(_M_finish + 1, __n - __elems_after - 1, __c); - _M_finish += __n - __elems_after; - __STL_TRY { - uninitialized_copy(__position, __old_finish + 1, _M_finish); - _M_finish += __elems_after; - } - __STL_UNWIND((destroy(__old_finish + 1, _M_finish), - _M_finish = __old_finish)); - _Traits::assign(__position, __elems_after + 1, __c); - } - } - else { - const size_type __old_size = size(); - -#ifdef __AVR__ - const size_type __len = __old_size + max(avrstl::AvrStringAllocAheadIncrement<_CharT>(__old_size), __n) + 1; -#else - const size_type __len = __old_size + max(__old_size, __n) + 1; -#endif - iterator __new_start = _M_allocate(__len); - iterator __new_finish = __new_start; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - __new_finish = uninitialized_fill_n(__new_finish, __n, __c); - __new_finish = uninitialized_copy(__position, _M_finish, - __new_finish); - _M_construct_null(__new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish + 1); - _M_deallocate_block(); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __len; - } - } -} - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -void basic_string<_Tp, _Traits, _Alloc>::insert(iterator __p, - _InputIter __first, - _InputIter __last, - input_iterator_tag) -{ - for ( ; __first != __last; ++__first) { - __p = insert(__p, *__first); - ++__p; - } -} - -template -template -void -basic_string<_CharT,_Traits,_Alloc>::insert(iterator __position, - _ForwardIter __first, - _ForwardIter __last, - forward_iterator_tag) -{ - if (__first != __last) { - difference_type __n = 0; - - distance(__first, __last, __n); - - if (_M_end_of_storage - _M_finish >= __n + 1) { - const difference_type __elems_after = _M_finish - __position; - iterator __old_finish = _M_finish; - if (__elems_after >= __n) { - uninitialized_copy((_M_finish - __n) + 1, _M_finish + 1, - _M_finish + 1); - _M_finish += __n; - _Traits::move(__position + __n, - __position, (__elems_after - __n) + 1); - _M_copy(__first, __last, __position); - } - else { - _ForwardIter __mid = __first; - advance(__mid, __elems_after + 1); - uninitialized_copy(__mid, __last, _M_finish + 1); - _M_finish += __n - __elems_after; - __STL_TRY { - uninitialized_copy(__position, __old_finish + 1, _M_finish); - _M_finish += __elems_after; - } - __STL_UNWIND((destroy(__old_finish + 1, _M_finish), - _M_finish = __old_finish)); - _M_copy(__first, __mid, __position); - } - } - else { - const size_type __old_size = size(); - -#ifdef __AVR__ - const size_type __len - = __old_size + max(avrstl::AvrStringAllocAheadIncrement<_CharT>(__old_size), static_cast(__n)) + 1; -#else - const size_type __len - = __old_size + max(__old_size, static_cast(__n)) + 1; -#endif - - pointer __new_start = _M_allocate(__len); - pointer __new_finish = __new_start; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - __new_finish = uninitialized_copy(__first, __last, __new_finish); - __new_finish - = uninitialized_copy(__position, _M_finish, __new_finish); - _M_construct_null(__new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish + 1); - _M_deallocate_block(); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __len; - } - } -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -void -basic_string<_CharT,_Traits,_Alloc>::insert(iterator __position, - const _CharT* __first, - const _CharT* __last) -{ - if (__first != __last) { - const ptrdiff_t __n = __last - __first; - if (_M_end_of_storage - _M_finish >= __n + 1) { - const ptrdiff_t __elems_after = _M_finish - __position; - iterator __old_finish = _M_finish; - if (__elems_after >= __n) { - uninitialized_copy((_M_finish - __n) + 1, _M_finish + 1, - _M_finish + 1); - _M_finish += __n; - _Traits::move(__position + __n, - __position, (__elems_after - __n) + 1); - _M_copy(__first, __last, __position); - } - else { - const _CharT* __mid = __first; - advance(__mid, __elems_after + 1); - uninitialized_copy(__mid, __last, _M_finish + 1); - _M_finish += __n - __elems_after; - __STL_TRY { - uninitialized_copy(__position, __old_finish + 1, _M_finish); - _M_finish += __elems_after; - } - __STL_UNWIND((destroy(__old_finish + 1, _M_finish), - _M_finish = __old_finish)); - _M_copy(__first, __mid, __position); - } - } - else { - const size_type __old_size = size(); - const size_type __len - = __old_size + max(__old_size, static_cast(__n)) + 1; - pointer __new_start = _M_allocate(__len); - pointer __new_finish = __new_start; - __STL_TRY { - __new_finish = uninitialized_copy(_M_start, __position, __new_start); - __new_finish = uninitialized_copy(__first, __last, __new_finish); - __new_finish - = uninitialized_copy(__position, _M_finish, __new_finish); - _M_construct_null(__new_finish); - } - __STL_UNWIND((destroy(__new_start,__new_finish), - _M_deallocate(__new_start,__len))); - destroy(_M_start, _M_finish + 1); - _M_deallocate_block(); - _M_start = __new_start; - _M_finish = __new_finish; - _M_end_of_storage = __new_start + __len; - } - } -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -basic_string<_CharT,_Traits,_Alloc>& -basic_string<_CharT,_Traits,_Alloc> - ::replace(iterator __first, iterator __last, size_type __n, _CharT __c) -{ - const size_type __len = static_cast(__last - __first); - if (__len >= __n) { - _Traits::assign(__first, __n, __c); - erase(__first + __n, __last); - } - else { - _Traits::assign(__first, __len, __c); - insert(__last, __n - __len, __c); - } - return *this; -} - -#ifdef __STL_MEMBER_TEMPLATES - -template -template -basic_string<_CharT,_Traits,_Alloc>& -basic_string<_CharT,_Traits,_Alloc> - ::replace(iterator __first, iterator __last, _InputIter __f, _InputIter __l, - input_iterator_tag) -{ - for ( ; __first != __last && __f != __l; ++__first, ++__f) - _Traits::assign(*__first, *__f); - - if (__f == __l) - erase(__first, __last); - else - insert(__last, __f, __l); - return *this; -} - -template -template -basic_string<_CharT,_Traits,_Alloc>& -basic_string<_CharT,_Traits,_Alloc> - ::replace(iterator __first, iterator __last, - _ForwardIter __f, _ForwardIter __l, - forward_iterator_tag) -{ - difference_type __n = 0; - distance(__f, __l, __n); - const difference_type __len = __last - __first; - if (__len >= __n) { - _M_copy(__f, __l, __first); - erase(__first + __n, __last); - } - else { - _ForwardIter __m = __f; - advance(__m, __len); - _M_copy(__f, __m, __first); - insert(__last, __m, __l); - } - return *this; -} - -#else /* __STL_MEMBER_TEMPLATES */ - -template -basic_string<_CharT,_Traits,_Alloc>& -basic_string<_CharT,_Traits,_Alloc> - ::replace(iterator __first, iterator __last, - const _CharT* __f, const _CharT* __l) -{ - const ptrdiff_t __n = __l - __f; - const difference_type __len = __last - __first; - if (__len >= __n) { - _M_copy(__f, __l, __first); - erase(__first + __n, __last); - } - else { - const _CharT* __m = __f + __len; - _M_copy(__f, __m, __first); - insert(__last, __m, __l); - } - return *this; -} - -#endif /* __STL_MEMBER_TEMPLATES */ - -template -typename basic_string<_CharT,_Traits,_Alloc>::size_type -basic_string<_CharT,_Traits,_Alloc> - ::find(const _CharT* __s, size_type __pos, size_type __n) const -{ - if (__pos + __n > size()) - return npos; - else { - const const_iterator __result = - search(_M_start + __pos, _M_finish, - __s, __s + __n, _Eq_traits<_Traits>()); - return __result != _M_finish ? __result - begin() : npos; - } -} - -template -typename basic_string<_CharT,_Traits,_Alloc>::size_type -basic_string<_CharT,_Traits,_Alloc> - ::find(_CharT __c, size_type __pos) const -{ - if (__pos >= size()) - return npos; - else { - const const_iterator __result = - find_if(_M_start + __pos, _M_finish, - bind2nd(_Eq_traits<_Traits>(), __c)); - return __result != _M_finish ? __result - begin() : npos; - } -} - -template -typename basic_string<_CharT,_Traits,_Alloc>::size_type -basic_string<_CharT,_Traits,_Alloc> - ::rfind(const _CharT* __s, size_type __pos, size_type __n) const -{ - const size_t __len = size(); - - if (__n > __len) - return npos; - else if (__n == 0) - return min(__len, __pos); - else { - const const_iterator __last = begin() + min(__len - __n, __pos) + __n; - const const_iterator __result = find_end(begin(), __last, - __s, __s + __n, - _Eq_traits<_Traits>()); - return __result != __last ? __result - begin() : npos; - } -} - -template -typename basic_string<_CharT,_Traits,_Alloc>::size_type -basic_string<_CharT,_Traits,_Alloc> - ::rfind(_CharT __c, size_type __pos) const -{ - const size_type __len = size(); - - if (__len < 1) - return npos; - else { - const const_iterator __last = begin() + min(__len - 1, __pos) + 1; - const_reverse_iterator __rresult = - find_if(const_reverse_iterator(__last), rend(), - bind2nd(_Eq_traits<_Traits>(), __c)); - return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos; - } -} - -template -typename basic_string<_CharT,_Traits,_Alloc>::size_type -basic_string<_CharT,_Traits,_Alloc> - ::find_first_of(const _CharT* __s, size_type __pos, size_type __n) const -{ - if (__pos >= size()) - return npos; - else { - const_iterator __result = __STD::find_first_of(begin() + __pos, end(), - __s, __s + __n, - _Eq_traits<_Traits>()); - return __result != _M_finish ? __result - begin() : npos; - } -} - - -template -typename basic_string<_CharT,_Traits,_Alloc>::size_type -basic_string<_CharT,_Traits,_Alloc> - ::find_last_of(const _CharT* __s, size_type __pos, size_type __n) const -{ - const size_type __len = size(); - - if (__len < 1) - return npos; - else { - const const_iterator __last = _M_start + min(__len - 1, __pos) + 1; - const const_reverse_iterator __rresult = - __STD::find_first_of(const_reverse_iterator(__last), rend(), - __s, __s + __n, - _Eq_traits<_Traits>()); - return __rresult != rend() ? (__rresult.base() - 1) - _M_start : npos; - } -} - - -template -typename basic_string<_CharT,_Traits,_Alloc>::size_type -basic_string<_CharT,_Traits,_Alloc> - ::find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const -{ - if (__pos > size()) - return npos; - else { - const_iterator __result = find_if(_M_start + __pos, _M_finish, - _Not_within_traits<_Traits>(__s, __s + __n)); - return __result != _M_finish ? __result - _M_start : npos; - } -} - -template -typename basic_string<_CharT,_Traits,_Alloc>::size_type -basic_string<_CharT,_Traits,_Alloc> - ::find_first_not_of(_CharT __c, size_type __pos) const -{ - if (__pos > size()) - return npos; - else { - const_iterator __result - = find_if(begin() + __pos, end(), - not1(bind2nd(_Eq_traits<_Traits>(), __c))); - return __result != _M_finish ? __result - begin() : npos; - } -} - -template -typename basic_string<_CharT,_Traits,_Alloc>::size_type -basic_string<_CharT,_Traits,_Alloc> - ::find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const -{ - - const size_type __len = size(); - - if (__len < 1) - return npos; - else { - const const_iterator __last = begin() + min(__len - 1, __pos) + 1; - const const_reverse_iterator __rresult = - find_if(const_reverse_iterator(__last), rend(), - _Not_within_traits<_Traits>(__s, __s + __n)); - return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos; - } -} - -template -typename basic_string<_Tp, _Traits, _Alloc>::size_type -basic_string<_Tp, _Traits, _Alloc> - ::find_last_not_of(_Tp __c, size_type __pos) const -{ - const size_type __len = size(); - - if (__len < 1) - return npos; - else { - const const_iterator __last = begin() + min(__len - 1, __pos) + 1; - const_reverse_iterator __rresult = - find_if(const_reverse_iterator(__last), rend(), - not1(bind2nd(_Eq_traits<_Traits>(), __c))); - return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos; - } -} - -// ------------------------------------------------------------ -// Non-member functions. - -// Operator+ - -template -inline basic_string<_CharT,_Traits,_Alloc> -operator+(const basic_string<_CharT,_Traits,_Alloc>& __x, - const basic_string<_CharT,_Traits,_Alloc>& __y) -{ - typedef basic_string<_CharT,_Traits,_Alloc> _Str; - typedef typename _Str::_Reserve_t _Reserve_t; - _Reserve_t __reserve; - _Str __result(__reserve, __x.size() + __y.size(), __x.get_allocator()); - __result.append(__x); - __result.append(__y); - return __result; -} - -template -inline basic_string<_CharT,_Traits,_Alloc> -operator+(const _CharT* __s, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - typedef basic_string<_CharT,_Traits,_Alloc> _Str; - typedef typename _Str::_Reserve_t _Reserve_t; - _Reserve_t __reserve; - const size_t __n = _Traits::length(__s); - _Str __result(__reserve, __n + __y.size()); - __result.append(__s, __s + __n); - __result.append(__y); - return __result; -} - -template -inline basic_string<_CharT,_Traits,_Alloc> -operator+(_CharT __c, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - typedef basic_string<_CharT,_Traits,_Alloc> _Str; - typedef typename _Str::_Reserve_t _Reserve_t; - _Reserve_t __reserve; - _Str __result(__reserve, 1 + __y.size()); - __result.push_back(__c); - __result.append(__y); - return __result; -} - -template -inline basic_string<_CharT,_Traits,_Alloc> -operator+(const basic_string<_CharT,_Traits,_Alloc>& __x, - const _CharT* __s) { - typedef basic_string<_CharT,_Traits,_Alloc> _Str; - typedef typename _Str::_Reserve_t _Reserve_t; - _Reserve_t __reserve; - const size_t __n = _Traits::length(__s); - _Str __result(__reserve, __x.size() + __n, __x.get_allocator()); - __result.append(__x); - __result.append(__s, __s + __n); - return __result; -} - -template -inline basic_string<_CharT,_Traits,_Alloc> -operator+(const basic_string<_CharT,_Traits,_Alloc>& __x, - const _CharT __c) { - typedef basic_string<_CharT,_Traits,_Alloc> _Str; - typedef typename _Str::_Reserve_t _Reserve_t; - _Reserve_t __reserve; - _Str __result(__reserve, __x.size() + 1, __x.get_allocator()); - __result.append(__x); - __result.push_back(__c); - return __result; -} - -// Operator== and operator!= - -template -inline bool -operator==(const basic_string<_CharT,_Traits,_Alloc>& __x, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - return __x.size() == __y.size() && - _Traits::compare(__x.data(), __y.data(), __x.size()) == 0; -} - -template -inline bool -operator==(const _CharT* __s, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - size_t __n = _Traits::length(__s); - return __n == __y.size() && _Traits::compare(__s, __y.data(), __n) == 0; -} - -template -inline bool -operator==(const basic_string<_CharT,_Traits,_Alloc>& __x, - const _CharT* __s) { - size_t __n = _Traits::length(__s); - return __x.size() == __n && _Traits::compare(__x.data(), __s, __n) == 0; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool -operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - return !(__x == __y); -} - -template -inline bool -operator!=(const _CharT* __s, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - return !(__s == __y); -} - -template -inline bool -operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x, - const _CharT* __s) { - return !(__x == __s); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -// Operator< (and also >, <=, and >=). - -template -inline bool -operator<(const basic_string<_CharT,_Traits,_Alloc>& __x, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - return basic_string<_CharT,_Traits,_Alloc> - ::_M_compare(__x.begin(), __x.end(), __y.begin(), __y.end()) < 0; -} - -template -inline bool -operator<(const _CharT* __s, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - size_t __n = _Traits::length(__s); - return basic_string<_CharT,_Traits,_Alloc> - ::_M_compare(__s, __s + __n, __y.begin(), __y.end()) < 0; -} - -template -inline bool -operator<(const basic_string<_CharT,_Traits,_Alloc>& __x, - const _CharT* __s) { - size_t __n = _Traits::length(__s); - return basic_string<_CharT,_Traits,_Alloc> - ::_M_compare(__x.begin(), __x.end(), __s, __s + __n) < 0; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline bool -operator>(const basic_string<_CharT,_Traits,_Alloc>& __x, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - return __y < __x; -} - -template -inline bool -operator>(const _CharT* __s, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - return __y < __s; -} - -template -inline bool -operator>(const basic_string<_CharT,_Traits,_Alloc>& __x, - const _CharT* __s) { - return __s < __x; -} - -template -inline bool -operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - return !(__y < __x); -} - -template -inline bool -operator<=(const _CharT* __s, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - return !(__y < __s); -} - -template -inline bool -operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x, - const _CharT* __s) { - return !(__s < __x); -} - -template -inline bool -operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - return !(__x < __y); -} - -template -inline bool -operator>=(const _CharT* __s, - const basic_string<_CharT,_Traits,_Alloc>& __y) { - return !(__s < __y); -} - -template -inline bool -operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x, - const _CharT* __s) { - return !(__x < __s); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -// Swap. - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline void swap(basic_string<_CharT,_Traits,_Alloc>& __x, - basic_string<_CharT,_Traits,_Alloc>& __y) { - __x.swap(__y); -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - - -// I/O. - -#ifndef __STL_USE_NEW_IOSTREAMS -__STL_END_NAMESPACE -#include -__STL_BEGIN_NAMESPACE -#endif /* __STL_USE_NEW_IOSTREAMS */ - -#ifdef __STL_USE_NEW_IOSTREAMS - -template -inline bool -__sgi_string_fill(basic_ostream<_CharT, _Traits>& __os, - basic_streambuf<_CharT, _Traits>* __buf, - size_t __n) -{ - _CharT __f = __os.fill(); - size_t __i; - bool __ok = true; - - for (__i = 0; __i < __n; __i++) - __ok = __ok && !_Traits::eq_int_type(__buf->sputc(__f), _Traits::eof()); - return __ok; -} - -template -basic_ostream<_CharT, _Traits>& -operator<<(basic_ostream<_CharT, _Traits>& __os, - const basic_string<_CharT,_Traits,_Alloc>& __s) -{ - typename basic_ostream<_CharT, _Traits>::sentry __sentry(__os); - bool __ok = false; - - if (__sentry) { - __ok = true; - size_t __n = __s.size(); - size_t __pad_len = 0; - const bool __left = (__os.flags() & ios::left) != 0; - const size_t __w = __os.width(0); - basic_streambuf<_CharT, _Traits>* __buf = __os.rdbuf(); - - if (__w != 0 && __n < __w) - __pad_len = __w - __n; - - if (!__left) - __ok = __sgi_string_fill(__os, __buf, __pad_len); - - __ok = __ok && - __buf->sputn(__s.data(), streamsize(__n)) == streamsize(__n); - - if (__left) - __ok = __ok && __sgi_string_fill(__os, __buf, __pad_len); - } - - if (!__ok) - __os.setstate(ios_base::failbit); - - return __os; -} - -template -basic_istream<_CharT, _Traits>& -operator>>(basic_istream<_CharT, _Traits>& __is, - basic_string<_CharT,_Traits,_Alloc>& __s) -{ - typename basic_istream<_CharT, _Traits>::sentry __sentry(__is); - - if (__sentry) { - basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf(); -#ifndef __AVR__ - const ctype<_CharT>& __ctype = use_facet >(__is.getloc()); -#endif - __s.clear(); - size_t __n = __is.width(0); - if (__n == 0) - __n = static_cast(-1); - else - __s.reserve(__n); - - - while (__n-- > 0) { - typename _Traits::int_type __c1 = __buf->sbumpc(); - if (_Traits::eq_int_type(__c1, _Traits::eof())) { - __is.setstate(ios_base::eofbit); - break; - } - else { - _CharT __c = _Traits::to_char_type(__c1); - -#ifdef __AVR__ - if(isspace(__c)) { -#else - if (__ctype.is(ctype<_CharT>::space, __c)) { -#endif - if (_Traits::eq_int_type(__buf->sputbackc(__c), _Traits::eof())) - __is.setstate(ios_base::failbit); - break; - } - else - __s.push_back(__c); - } - } - - // If we have read no characters, then set failbit. - if (__s.size() == 0) - __is.setstate(ios_base::failbit); - } - else - __is.setstate(ios_base::failbit); - - return __is; -} - -template -basic_istream<_CharT, _Traits>& -getline(istream& __is, - basic_string<_CharT,_Traits,_Alloc>& __s, - _CharT __delim) -{ - size_t __nread = 0; - typename basic_istream<_CharT, _Traits>::sentry __sentry(__is, true); - if (__sentry) { - basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf(); - __s.clear(); - - int __c1; - while (__nread < __s.max_size()) { - int __c1 = __buf->sbumpc(); - if (_Traits::eq_int_type(__c1, _Traits::eof())) { - __is.setstate(ios_base::eofbit); - break; - } - else { - ++__nread; - _CharT __c = _Traits::to_char_type(__c1); - if (!_Traits::eq(__c, __delim)) - __s.push_back(__c); - else - break; // Character is extracted but not appended. - } - } - } - if (__nread == 0 || __nread >= __s.max_size()) - __is.setstate(ios_base::failbit); - - return __is; -} - -template -inline basic_istream<_CharT, _Traits>& -getline(basic_istream<_CharT, _Traits>& __is, - basic_string<_CharT,_Traits,_Alloc>& __s) -{ - return getline(__is, __s, '\n'); -} - -#else /* __STL_USE_NEW_IOSTREAMS */ - -inline void __sgi_string_fill(ostream& __os, streambuf* __buf, size_t __n) -{ - char __f = __os.fill(); - size_t __i; - - for (__i = 0; __i < __n; __i++) __buf->sputc(__f); -} - -template -ostream& operator<<(ostream& __os, - const basic_string<_CharT,_Traits,_Alloc>& __s) -{ - streambuf* __buf = __os.rdbuf(); - if (__buf) { - size_t __n = __s.size(); - size_t __pad_len = 0; - const bool __left = (__os.flags() & ios::left) != 0; - const size_t __w = __os.width(); - - if (__w > 0) { - __n = min(__w, __n); - __pad_len = __w - __n; - } - - if (!__left) - __sgi_string_fill(__os, __buf, __pad_len); - - const size_t __nwritten = __buf->sputn(__s.data(), __n); - - if (__left) - __sgi_string_fill(__os, __buf, __pad_len); - - if (__nwritten != __n) - __os.clear(__os.rdstate() | ios::failbit); - - __os.width(0); - } - else - __os.clear(__os.rdstate() | ios::badbit); - - return __os; -} - -template -istream& operator>>(istream& __is, basic_string<_CharT,_Traits,_Alloc>& __s) -{ - if (!__is) - return __is; - - streambuf* __buf = __is.rdbuf(); - if (__buf) { - -#ifdef __USLC__ -/* Jochen Schlick '1999 - operator >> modified. Work-around to get the - * output buffer flushed (necessary when using - * "cout" (without endl or flushing) followed by - * "cin >>" ...) - */ - if (__is.flags() & ios::skipws) { - _CharT __c; - do - __is.get(__c); - while (__is && isspace(__c)); - if (__is) - __is.putback(__c); - } -#else - if (__is.flags() & ios::skipws) { - int __c; - do { - __c = __buf->sbumpc(); - } - while (__c != EOF && isspace((unsigned char)__c)); - - if (__c == EOF) { - __is.clear(__is.rdstate() | ios::eofbit | ios::failbit); - } - else { - if (__buf->sputbackc(__c) == EOF) - __is.clear(__is.rdstate() | ios::failbit); - } - } -#endif - - // If we arrive at end of file (or fail for some other reason) while - // still discarding whitespace, then we don't try to read the string. - if (__is) { - __s.clear(); - - size_t __n = __is.width(); - if (__n == 0) - __n = static_cast(-1); - else - __s.reserve(__n); - - while (__n-- > 0) { - int __c1 = __buf->sbumpc(); - if (__c1 == EOF) { - __is.clear(__is.rdstate() | ios::eofbit); - break; - } - else { - _CharT __c = _Traits::to_char_type(__c1); - - if (isspace((unsigned char) __c)) { - if (__buf->sputbackc(__c) == EOF) - __is.clear(__is.rdstate() | ios::failbit); - break; - } - else - __s.push_back(__c); - } - } - - // If we have read no characters, then set failbit. - if (__s.size() == 0) - __is.clear(__is.rdstate() | ios::failbit); - } - - __is.width(0); - } - else // We have no streambuf. - __is.clear(__is.rdstate() | ios::badbit); - - return __is; -} - -template -istream& getline(istream& __is, - basic_string<_CharT,_Traits,_Alloc>& __s, - _CharT __delim) -{ - streambuf* __buf = __is.rdbuf(); - if (__buf) { - size_t __nread = 0; - if (__is) { - __s.clear(); - - while (__nread < __s.max_size()) { - int __c1 = __buf->sbumpc(); - if (__c1 == EOF) { - __is.clear(__is.rdstate() | ios::eofbit); - break; - } - else { - ++__nread; - _CharT __c = _Traits::to_char_type(__c1); - if (!_Traits::eq(__c, __delim)) - __s.push_back(__c); - else - break; // Character is extracted but not appended. - } - } - } - - if (__nread == 0 || __nread >= __s.max_size()) - __is.clear(__is.rdstate() | ios::failbit); - } - else - __is.clear(__is.rdstate() | ios::badbit); - - return __is; -} - -template -inline istream& -getline(istream& __is, basic_string<_CharT,_Traits,_Alloc>& __s) -{ - return getline(__is, __s, '\n'); -} - -#endif /* __STL_USE_NEW_IOSTREAMS */ - - -template -void _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s, - _CharT* __buf, - size_t __n) -{ - if (__n > 0) { - __n = min(__n - 1, __s.size()); - copy(__s.begin(), __s.begin() + __n, __buf); - _Traits::assign(__buf[__n], - basic_string<_CharT,_Traits,_Alloc>::_M_null()); - } -} - -inline const char* __get_c_string(const string& __s) { return __s.c_str(); } - -// ------------------------------------------------------------ -// Typedefs - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1174 -#pragma reset woff 1375 -#endif - -__STL_END_NAMESPACE - -#include - -__STL_BEGIN_NAMESPACE - -template -size_t __stl_string_hash(const basic_string<_CharT,_Traits,_Alloc>& __s) { - unsigned long __h = 0; - for (typename basic_string<_CharT,_Traits,_Alloc>::const_iterator __i = __s.begin(); - __i != __s.end(); - ++__i) - __h = 5*__h + *__i; - return size_t(__h); -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -struct hash > { - size_t operator()(const basic_string<_CharT,_Traits,_Alloc>& __s) const - { return __stl_string_hash(__s); } -}; - -#else - -__STL_TEMPLATE_NULL struct hash { - size_t operator()(const string& __s) const - { return __stl_string_hash(__s); } -}; - -__STL_TEMPLATE_NULL struct hash { - size_t operator()(const wstring& __s) const - { return __stl_string_hash(__s); } -}; - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_STRING */ - - -// Local Variables: -// mode:C++ -// End: - diff --git a/DSTAT1/src/avr-stl/include/type_traits.h b/DSTAT1/src/avr-stl/include/type_traits.h deleted file mode 100644 index b6a7dfc..0000000 --- a/DSTAT1/src/avr-stl/include/type_traits.h +++ /dev/null @@ -1,373 +0,0 @@ -/* - * - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __TYPE_TRAITS_H -#define __TYPE_TRAITS_H - -#ifndef __STL_CONFIG_H -#include -#endif - -/* -This header file provides a framework for allowing compile time dispatch -based on type attributes. This is useful when writing template code. -For example, when making a copy of an array of an unknown type, it helps -to know if the type has a trivial copy constructor or not, to help decide -if a memcpy can be used. - -The class template __type_traits provides a series of typedefs each of -which is either __true_type or __false_type. The argument to -__type_traits can be any type. The typedefs within this template will -attain their correct values by one of these means: - 1. The general instantiation contain conservative values which work - for all types. - 2. Specializations may be declared to make distinctions between types. - 3. Some compilers (such as the Silicon Graphics N32 and N64 compilers) - will automatically provide the appropriate specializations for all - types. - -EXAMPLE: - -//Copy an array of elements which have non-trivial copy constructors -template void copy(T* source, T* destination, int n, __false_type); -//Copy an array of elements which have trivial copy constructors. Use memcpy. -template void copy(T* source, T* destination, int n, __true_type); - -//Copy an array of any type by using the most efficient copy mechanism -template inline void copy(T* source,T* destination,int n) { - copy(source, destination, n, - typename __type_traits::has_trivial_copy_constructor()); -} -*/ - - -struct __true_type { -}; - -struct __false_type { -}; - -template -struct __type_traits { - typedef __true_type this_dummy_member_must_be_first; - /* Do not remove this member. It informs a compiler which - automatically specializes __type_traits that this - __type_traits template is special. It just makes sure that - things work if an implementation is using a template - called __type_traits for something unrelated. */ - - /* The following restrictions should be observed for the sake of - compilers which automatically produce type specific specializations - of this class: - - You may reorder the members below if you wish - - You may remove any of the members below if you wish - - You must not rename members without making the corresponding - name change in the compiler - - Members you add will be treated like regular members unless - you add the appropriate support in the compiler. */ - - - typedef __false_type has_trivial_default_constructor; - typedef __false_type has_trivial_copy_constructor; - typedef __false_type has_trivial_assignment_operator; - typedef __false_type has_trivial_destructor; - typedef __false_type is_POD_type; -}; - - - -// Provide some specializations. This is harmless for compilers that -// have built-in __types_traits support, and essential for compilers -// that don't. - -#ifndef __STL_NO_BOOL - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#endif /* __STL_NO_BOOL */ - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#ifdef __STL_HAS_WCHAR_T - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#endif /* __STL_HAS_WCHAR_T */ - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#ifdef __STL_LONG_LONG - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#endif /* __STL_LONG_LONG */ - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template -struct __type_traits<_Tp*> { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -__STL_TEMPLATE_NULL struct __type_traits { - typedef __true_type has_trivial_default_constructor; - typedef __true_type has_trivial_copy_constructor; - typedef __true_type has_trivial_assignment_operator; - typedef __true_type has_trivial_destructor; - typedef __true_type is_POD_type; -}; - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - - -// The following could be written in terms of numeric_limits. -// We're doing it separately to reduce the number of dependencies. - -template struct _Is_integer { - typedef __false_type _Integral; -}; - -#ifndef __STL_NO_BOOL - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -#endif /* __STL_NO_BOOL */ - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -#ifdef __STL_HAS_WCHAR_T - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -#endif /* __STL_HAS_WCHAR_T */ - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -#ifdef __STL_LONG_LONG - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -__STL_TEMPLATE_NULL struct _Is_integer { - typedef __true_type _Integral; -}; - -#endif /* __STL_LONG_LONG */ - -#endif /* __TYPE_TRAITS_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/utility b/DSTAT1/src/avr-stl/include/utility deleted file mode 100644 index df8c224..0000000 --- a/DSTAT1/src/avr-stl/include/utility +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_UTILITY -#define __SGI_STL_UTILITY - -#include -#include -#include - -#endif /* __SGI_STL_UTILITY */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/valarray b/DSTAT1/src/avr-stl/include/valarray deleted file mode 100644 index 750e8a3..0000000 --- a/DSTAT1/src/avr-stl/include/valarray +++ /dev/null @@ -1,1780 +0,0 @@ -/* - * Copyright (c) 1999 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_VALARRAY -#define __SGI_STL_VALARRAY - -#ifdef __AVR__ -#include -#undef round -#undef abs -#else -#include -#endif - -#include -#include -#include -#include -#include - - -__STL_BEGIN_NAMESPACE - -class slice; -class gslice; - -template class valarray; -template class slice_array; -template class gslice_array; -template class mask_array; -template class indirect_array; - -//---------------------------------------------------------------------- -// class valarray - -// Base class to handle memory allocation and deallocation. We can't just -// use vector<>, because vector would be unsuitable as an internal -// representation for valarray. - -template -struct _Valarray_base -{ - _Tp* _M_first; - size_t _M_size; - - _Valarray_base() : _M_first(0), _M_size(0) {} - _Valarray_base(size_t __n) : _M_first(0), _M_size(0) { _M_allocate(__n); } - ~_Valarray_base() { _M_deallocate(); } - - void _M_allocate(size_t __n) { - if (__n != 0) { - _M_first = static_cast<_Tp*>(malloc(__n * sizeof(_Tp))); - _M_size = __n; -# if !defined(__STL_NO_BAD_ALLOC) && defined(__STL_USE_EXCEPTIONS) - if (_M_first == 0) { - _M_size = 0; - throw std::bad_alloc(); - } -# endif - } - else { - _M_first = 0; - _M_size = 0; - } - } - - void _M_deallocate() { - free(_M_first); - _M_first = 0; - _M_size = 0; - } -}; - -template -class valarray : private _Valarray_base<_Tp> -{ - friend class gslice; - -public: - typedef _Tp value_type; - - // Basic constructors - valarray() : _Valarray_base<_Tp>() {} - valarray(size_t __n) : _Valarray_base<_Tp>(__n) - { uninitialized_fill_n(this->_M_first, this->_M_size, value_type()); } - valarray(const value_type& __x, size_t __n) : _Valarray_base<_Tp>(__n) - { uninitialized_fill_n(this->_M_first, this->_M_size, __x); } - valarray(const value_type* __p, size_t __n) : _Valarray_base<_Tp>(__n) - { uninitialized_copy(__p, __p + __n, this->_M_first); } - valarray(const valarray& __x) : _Valarray_base<_Tp>(__x._M_size) { - uninitialized_copy(__x._M_first, __x._M_first + __x._M_size, - this->_M_first); - } - - // Constructors from auxiliary array types - valarray(const slice_array<_Tp>&); - valarray(const gslice_array<_Tp>&); - valarray(const mask_array<_Tp>&); - valarray(const indirect_array<_Tp>&); - - // Destructor - ~valarray() { destroy(this->_M_first, this->_M_first + this->_M_size); } - - // Extension: constructor that doesn't initialize valarray elements to a - // specific value. This is faster for types such as int and double. -private: - void _M_initialize(__true_type) {} - void _M_initialize(__false_type) - { uninitialized_fill_n(this->_M_first, this->_M_size, value_type()); } - -public: - struct _NoInit {}; - valarray(size_t __n, _NoInit) : _Valarray_base<_Tp>(__n) { - typedef typename __type_traits<_Tp>::has_trivial_default_constructor - _Is_Trivial; - _M_initialize(_Is_Trivial()); - } - -public: // Assignment - // Basic assignment. Note that 'x = y' is undefined if x.size() != y.size() - valarray& operator=(const valarray& __x) { - if (this != &__x) - copy(__x._M_first, __x._M_first + __x._M_size, this->_M_first); - return *this; - } - - // Scalar assignment - valarray& operator=(const value_type& __x) { - fill_n(this->_M_first, this->_M_size, __x); - return *this; - } - - // Assignment of auxiliary array types - valarray& operator=(const slice_array<_Tp>&); - valarray& operator=(const gslice_array<_Tp>&); - valarray& operator=(const mask_array<_Tp>&); - valarray& operator=(const indirect_array<_Tp>&); - -public: // Element access - value_type operator[](size_t __n) const { return this->_M_first[__n]; } - value_type& operator[](size_t __n) { return this->_M_first[__n]; } - size_t size() const { return this->_M_size; } - -public: // Subsetting operations with auxiliary type - valarray operator[](slice) const; - slice_array<_Tp> operator[](slice); - valarray operator[](gslice) const; - gslice_array<_Tp> operator[](gslice); - valarray operator[](const valarray&) const; - mask_array<_Tp> operator[](const valarray&); - valarray operator[](const valarray&) const; - indirect_array<_Tp> operator[](const valarray&); - -public: // Unary operators. - valarray operator+() const { return *this; } - - valarray operator-() const { - valarray __tmp(this->size(), _NoInit()); - for (size_t __i = 0; __i < this->size(); ++__i) - __tmp[__i] = -(*this)[__i]; - return __tmp; - } - - valarray operator~() const { - valarray __tmp(this->size(), _NoInit()); - for (size_t __i = 0; __i < this->size(); ++__i) - __tmp[__i] = ~(*this)[__i]; - return __tmp; - } - - valarray operator!() const { - valarray __tmp(this->size(), valarray::_NoInit()); - for (size_t __i = 0; __i < this->size(); ++__i) - __tmp[__i] = !(*this)[__i]; - return __tmp; - } - -public: // Scalar computed assignment. - valarray& operator*= (const value_type& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] *= __x; - return *this; - } - - valarray& operator/= (const value_type& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] /= __x; - return *this; - } - - valarray& operator%= (const value_type& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] %= __x; - return *this; - } - - valarray& operator+= (const value_type& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] += __x; - return *this; - } - - valarray& operator-= (const value_type& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] -= __x; - return *this; - } - - valarray& operator^= (const value_type& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] ^= __x; - return *this; - } - - valarray& operator&= (const value_type& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] &= __x; - return *this; - } - - valarray& operator|= (const value_type& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] |= __x; - return *this; - } - - valarray& operator<<= (const value_type& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] <<= __x; - return *this; - } - - valarray& operator>>= (const value_type& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] >>= __x; - return *this; - } - -public: // Array computed assignment. - valarray& operator*= (const valarray& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] *= __x[__i]; - return *this; - } - - valarray& operator/= (const valarray& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] /= __x[__i]; - return *this; - } - - valarray& operator%= (const valarray& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] %= __x[__i]; - return *this; - } - - valarray& operator+= (const valarray& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] += __x[__i]; - return *this; - } - - valarray& operator-= (const valarray& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] -= __x[__i]; - return *this; - } - - valarray& operator^= (const valarray& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] ^= __x[__i]; - return *this; - } - - valarray& operator&= (const valarray& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] &= __x[__i]; - return *this; - } - - valarray& operator|= (const valarray& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] |= __x[__i]; - return *this; - } - - valarray& operator<<= (const valarray& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] <<= __x[__i]; - return *this; - } - - valarray& operator>>= (const valarray& __x) { - for (size_t __i = 0; __i < this->size(); ++__i) - (*this)[__i] >>= __x[__i]; - return *this; - } - -public: // Other member functions. - - // The result is undefined for zero-length arrays - value_type sum() const { - return accumulate(this->_M_first + 1, this->_M_first + this->_M_size, - (*this)[0]); - } - - // The result is undefined for zero-length arrays - value_type min() const { - return *min_element(this->_M_first + 0, this->_M_first + this->_M_size); - } - - value_type max() const { - return *max_element(this->_M_first + 0, this->_M_first + this->_M_size); - } - - valarray shift(int __n) const; - valarray cshift(int __n) const; - - valarray apply(value_type __f(value_type)) const { - valarray __tmp(this->size()); - transform(this->_M_first, this->_M_first + this->_M_size, __tmp._M_first, - __f); - return __tmp; - } - valarray apply(value_type __f(const value_type&)) const { - valarray __tmp(this->size()); - transform(this->_M_first, this->_M_first + this->_M_size, __tmp._M_first, - __f); - return __tmp; - } - - void resize(size_t __n, value_type __x = value_type()) { - destroy(this->_M_first, this->_M_first + this->_M_size); - this->_Valarray_base<_Tp>::_M_deallocate(); - this->_Valarray_base<_Tp>::_M_allocate(__n); - uninitialized_fill_n(this->_M_first, this->_M_size, __x); - } -}; - -//---------------------------------------------------------------------- -// valarray non-member functions. - -// Binary arithmetic operations between two arrays. Behavior is -// undefined if the two arrays do not have the same length. - -template -inline valarray<_Tp> operator*(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] * __y[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator/(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] / __y[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator%(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] % __y[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator+(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] + __y[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator-(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] - __y[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator^(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] ^ __y[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator&(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] & __y[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator|(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] | __y[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator<<(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] << __y[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator>>(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] >> __y[__i]; - return __tmp; -} - -// Binary arithmetic operations between an array and a scalar. - -template -inline valarray<_Tp> operator*(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] * __c; - return __tmp; -} - -template -inline valarray<_Tp> operator*(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c * __x[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator/(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] / __c; - return __tmp; -} - -template -inline valarray<_Tp> operator/(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c / __x[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator%(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] % __c; - return __tmp; -} - -template -inline valarray<_Tp> operator%(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c % __x[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator+(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] + __c; - return __tmp; -} - -template -inline valarray<_Tp> operator+(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c + __x[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator-(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] - __c; - return __tmp; -} - -template -inline valarray<_Tp> operator-(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c - __x[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator^(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] ^ __c; - return __tmp; -} - -template -inline valarray<_Tp> operator^(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c ^ __x[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator&(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] & __c; - return __tmp; -} - -template -inline valarray<_Tp> operator&(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c & __x[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator|(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] | __c; - return __tmp; -} - -template -inline valarray<_Tp> operator|(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c | __x[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator<<(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] << __c; - return __tmp; -} - -template -inline valarray<_Tp> operator<<(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c << __x[__i]; - return __tmp; -} - -template -inline valarray<_Tp> operator>>(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] >> __c; - return __tmp; -} - -template -inline valarray<_Tp> operator>>(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c >> __x[__i]; - return __tmp; -} - -// Binary logical operations between two arrays. Behavior is undefined -// if the two arrays have different lengths. Note that operator== does -// not do what you might at first expect. - -template -inline valarray operator==(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] == __y[__i]; - return __tmp; -} - -template -inline valarray operator<(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] < __y[__i]; - return __tmp; -} - -#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER - -template -inline valarray operator!=(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] != __y[__i]; - return __tmp; -} - -template -inline valarray operator>(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] > __y[__i]; - return __tmp; -} - -template -inline valarray operator<=(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] <= __y[__i]; - return __tmp; -} - -template -inline valarray operator>=(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] >= __y[__i]; - return __tmp; -} - -#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ - -template -inline valarray operator&&(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] && __y[__i]; - return __tmp; -} - -template -inline valarray operator||(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] || __y[__i]; - return __tmp; -} - -// Logical operations between an array and a scalar. - -template -inline valarray operator==(const valarray<_Tp>& __x, const _Tp& __c) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] == __c; - return __tmp; -} - -template -inline valarray operator==(const _Tp& __c, const valarray<_Tp>& __x) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c == __x[__i]; - return __tmp; -} - -template -inline valarray operator!=(const valarray<_Tp>& __x, const _Tp& __c) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] != __c; - return __tmp; -} - -template -inline valarray operator!=(const _Tp& __c, const valarray<_Tp>& __x) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c != __x[__i]; - return __tmp; -} - -template -inline valarray operator<(const valarray<_Tp>& __x, const _Tp& __c) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] < __c; - return __tmp; -} - -template -inline valarray operator<(const _Tp& __c, const valarray<_Tp>& __x) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c < __x[__i]; - return __tmp; -} - -template -inline valarray operator>(const valarray<_Tp>& __x, const _Tp& __c) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] > __c; - return __tmp; -} - -template -inline valarray operator>(const _Tp& __c, const valarray<_Tp>& __x) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c > __x[__i]; - return __tmp; -} - -template -inline valarray operator<=(const valarray<_Tp>& __x, const _Tp& __c) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] <= __c; - return __tmp; -} - -template -inline valarray operator<=(const _Tp& __c, const valarray<_Tp>& __x) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c <= __x[__i]; - return __tmp; -} - -template -inline valarray operator>=(const valarray<_Tp>& __x, const _Tp& __c) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] >= __c; - return __tmp; -} - -template -inline valarray operator>=(const _Tp& __c, const valarray<_Tp>& __x) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c >= __x[__i]; - return __tmp; -} - -template -inline valarray operator&&(const valarray<_Tp>& __x, const _Tp& __c) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] && __c; - return __tmp; -} - -template -inline valarray operator&&(const _Tp& __c, const valarray<_Tp>& __x) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c && __x[__i]; - return __tmp; -} - -template -inline valarray operator||(const valarray<_Tp>& __x, const _Tp& __c) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __x[__i] || __c; - return __tmp; -} - -template -inline valarray operator||(const _Tp& __c, const valarray<_Tp>& __x) -{ - valarray __tmp(__x.size(), valarray::_NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = __c || __x[__i]; - return __tmp; -} - -// valarray "transcendentals" (the list includes abs and sqrt, which, -// of course, are not transcendental). - -template -inline valarray<_Tp> abs(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = abs(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> acos(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = acos(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> asin(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = asin(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> atan(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = atan(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> atan2(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = atan2(__x[__i], __y[__i]); - return __tmp; -} - -template -inline valarray<_Tp> atan2(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = atan2(__x[__i], __c); - return __tmp; -} - -template -inline valarray<_Tp> atan2(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = atan2(__c, __x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> cos(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = cos(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> cosh(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = cosh(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> exp(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = exp(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> log(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = log(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> log10(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = log10(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> pow(const valarray<_Tp>& __x, - const valarray<_Tp>& __y) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = pow(__x[__i], __y[__i]); - return __tmp; -} - -template -inline valarray<_Tp> pow(const valarray<_Tp>& __x, const _Tp& __c) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = pow(__x[__i], __c); - return __tmp; -} - -template -inline valarray<_Tp> pow(const _Tp& __c, const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = pow(__c, __x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> sin(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = sin(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> sinh(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = sinh(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> sqrt(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = sqrt(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> tan(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = tan(__x[__i]); - return __tmp; -} - -template -inline valarray<_Tp> tanh(const valarray<_Tp>& __x) { - typedef typename valarray<_Tp>::_NoInit _NoInit; - valarray<_Tp> __tmp(__x.size(), _NoInit()); - for (size_t __i = 0; __i < __x.size(); ++__i) - __tmp[__i] = tanh(__x[__i]); - return __tmp; -} - -//---------------------------------------------------------------------- -// slice and slice_array - -class slice { -public: - slice() : _M_start(0), _M_length(0), _M_stride(0) {} - slice(size_t __start, size_t __length, size_t __stride) - : _M_start(__start), _M_length(__length), _M_stride(__stride) - {} - - size_t start() const { return _M_start; } - size_t size() const { return _M_length; } - size_t stride() const { return _M_stride; } - - -private: - size_t _M_start; - size_t _M_length; - size_t _M_stride; -}; - -template -class slice_array { - friend class valarray<_Tp>; -public: - typedef _Tp value_type; - - void operator=(const valarray& __x) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] = __x[__i]; - } - - void operator*=(const valarray& __x) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] *= __x[__i]; - } - - void operator/=(const valarray& __x) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] /= __x[__i]; - } - - void operator%=(const valarray& __x) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] %= __x[__i]; - } - - void operator+=(const valarray& __x) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] += __x[__i]; - } - - void operator-=(const valarray& __x) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] -= __x[__i]; - } - - void operator^=(const valarray& __x) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] ^= __x[__i]; - } - - void operator&=(const valarray& __x) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] &= __x[__i]; - } - - void operator|=(const valarray& __x) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] |= __x[__i]; - } - - void operator<<=(const valarray& __x) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] <<= __x[__i]; - } - - void operator>>=(const valarray& __x) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] >>= __x[__i]; - } - - void operator=(const value_type& __c) const { - size_t __index = _M_slice.start(); - for (size_t __i = 0; - __i < _M_slice.size(); - ++__i, __index += _M_slice.stride()) - _M_array[__index] = __c; - } - - ~slice_array() {} - -private: - slice_array(const slice& __slice, valarray<_Tp>& __array) - : _M_slice(__slice), _M_array(__array) - {} - - slice _M_slice; - valarray<_Tp>& _M_array; - -private: // Disable assignment and default constructor - slice_array(); -}; - -// valarray member functions dealing with slice and slice_array - -template -inline valarray<_Tp>::valarray(const slice_array<_Tp>& __x) - : _Valarray_base<_Tp>(__x._M_slice.size()) -{ - typedef typename __type_traits<_Tp>::has_trivial_default_constructor - _Is_Trivial; - _M_initialize(_Is_Trivial()); - *this = __x; -} - -// Behavior is undefined if __x and *this have different sizes -template -valarray<_Tp>& valarray<_Tp>::operator=(const slice_array<_Tp>& __x) -{ - size_t __index = __x._M_slice.start(); - for (size_t __i = 0; - __i < __x._M_slice.size(); - ++__i, __index += __x._M_slice.stride()) - (*this)[__i] = __x._M_array[__index]; - return *this; -} - -template -valarray<_Tp> valarray<_Tp>::operator[](slice __slice) const { - valarray<_Tp> __tmp(__slice.size(), _NoInit()); - size_t __index = __slice.start(); - for (size_t __i = 0; - __i < __slice.size(); - ++__i, __index += __slice.stride()) - __tmp[__i] = (*this)[__index]; - return __tmp; -} - -template -inline slice_array<_Tp> valarray<_Tp>::operator[](slice __slice) { - return slice_array<_Tp>(__slice, *this); -} - -//---------------------------------------------------------------------- -// gslice and gslice_array - -struct _Gslice_Iter; - -class gslice { - friend struct _Gslice_Iter; -public: - gslice() : _M_start(0), _M_lengths(0), _M_strides(0) {} - gslice(size_t __start, - const valarray& __lengths, const valarray& __strides) - : _M_start(__start), _M_lengths(__lengths), _M_strides(__strides) - {} - - size_t start() const { return _M_start; } - valarray size() const { return _M_lengths; } - valarray stride() const { return _M_strides; } - - // Extension: check for an empty gslice. - bool _M_empty() const { return _M_lengths.size() == 0; } - - // Extension: number of indices this gslice represents. (For a degenerate - // gslice, they're not necessarily all distinct.) - size_t _M_size() const { - return !this->_M_empty() - ? accumulate(_M_lengths._M_first + 1, - _M_lengths._M_first + _M_lengths._M_size, - _M_lengths[0], - multiplies()) - : 0; - } - -private: - size_t _M_start; - valarray _M_lengths; - valarray _M_strides; -}; - -// This is not an STL iterator. It is constructed from a gslice, and it -// steps through the gslice indices in sequence. See 23.3.6 of the C++ -// standard, paragraphs 2-3, for an explanation of the sequence. At -// each step we get two things: the ordinal (i.e. number of steps taken), -// and the one-dimensional index. - -struct _Gslice_Iter { - _Gslice_Iter(const gslice& __gslice) - : _M_step(0), _M_1d_idx(__gslice.start()), - _M_indices(size_t(0), __gslice._M_lengths.size()), - _M_gslice(__gslice) - {} - - bool _M_done() const { return _M_indices[0] == _M_gslice._M_lengths[0]; } - - bool _M_incr() { - size_t __dim = _M_indices.size() - 1; - ++_M_step; - while (true) { - _M_1d_idx += _M_gslice._M_strides[__dim]; - if (++_M_indices[__dim] != _M_gslice._M_lengths[__dim]) - return true; - else if (__dim != 0) { - _M_1d_idx -= - _M_gslice._M_strides[__dim] * _M_gslice._M_lengths[__dim]; - _M_indices[__dim] = 0; - --__dim; - } - else - return false; - } - } - - size_t _M_step; - size_t _M_1d_idx; - - valarray _M_indices; - const gslice& _M_gslice; -}; - -template -class gslice_array { - friend class valarray<_Tp>; -public: - typedef _Tp value_type; - - void operator= (const valarray& __x) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] = __x[__i._M_step]; while(__i._M_incr()); - } - } - - void operator*= (const valarray& __x) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] *= __x[__i._M_step]; while(__i._M_incr()); - } - } - - void operator/= (const valarray& __x) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] /= __x[__i._M_step]; while(__i._M_incr()); - } - } - - void operator%= (const valarray& __x) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] %= __x[__i._M_step]; while(__i._M_incr()); - } - } - - void operator+= (const valarray& __x) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] += __x[__i._M_step]; while(__i._M_incr()); - } - } - - void operator-= (const valarray& __x) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] -= __x[__i._M_step]; while(__i._M_incr()); - } - } - - void operator^= (const valarray& __x) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] ^= __x[__i._M_step]; while(__i._M_incr()); - } - } - - void operator&= (const valarray& __x) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] &= __x[__i._M_step]; while(__i._M_incr()); - } - } - - void operator|= (const valarray& __x) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] |= __x[__i._M_step]; while(__i._M_incr()); - } - } - - void operator<<= (const valarray& __x) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] <<= __x[__i._M_step]; while(__i._M_incr()); - } - } - - void operator>>= (const valarray& __x) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] >>= __x[__i._M_step]; while(__i._M_incr()); - } - } - - void operator= (const value_type& __c) const { - if (!_M_gslice._M_empty()) { - _Gslice_Iter __i(_M_gslice); - do _M_array[__i._M_1d_idx] = __c; while(__i._M_incr()); - } - } - - ~gslice_array() {} - -private: - gslice_array(gslice __gslice, valarray<_Tp>& __array) - : _M_gslice(__gslice), _M_array(__array) - {} - - gslice _M_gslice; - valarray& _M_array; - -private: // Disable assignment - void operator=(const gslice_array&); -}; - -// valarray member functions dealing with gslice and gslice_array. Note -// that it is illegal (behavior is undefined) to construct a gslice_array -// from a degenerate gslice. - -template -inline valarray<_Tp>::valarray(const gslice_array<_Tp>& __x) - : _Valarray_base<_Tp>(__x._M_gslice._M_size()) -{ - typedef typename __type_traits<_Tp>::has_trivial_default_constructor - _Is_Trivial; - _M_initialize(_Is_Trivial()); - *this = __x; -} - -// Behavior is undefined if __x and *this have different sizes, or if -// __x was constructed from a degenerate gslice. -template -valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<_Tp>& __x) -{ - if (this->size() != 0) { - _Gslice_Iter __i(__x._M_gslice); - do - (*this)[__i._M_step] = __x._M_array[__i._M_1d_idx]; - while(__i._M_incr()); - } - return *this; -} - -template -inline gslice_array<_Tp> valarray<_Tp>::operator[](gslice __slice) { - return gslice_array<_Tp>(__slice, *this); -} - -template -valarray<_Tp> valarray<_Tp>::operator[](gslice __slice) const -{ - valarray __tmp(__slice._M_size(), _NoInit()); - if (__tmp.size() != 0) { - _Gslice_Iter __i(__slice); - do __tmp[__i._M_step] = (*this)[__i._M_1d_idx]; while(__i._M_incr()); - } - return __tmp; -} - -//---------------------------------------------------------------------- -// mask_array - -template -class mask_array { - friend class valarray<_Tp>; -public: - typedef _Tp value_type; - - void operator=(const valarray& __x) const { - size_t __idx = 0; - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] = __x[__idx++]; - } - - void operator*=(const valarray& __x) const { - size_t __idx = 0; - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] *= __x[__idx++]; - } - - void operator/=(const valarray& __x) const { - size_t __idx = 0; - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] /= __x[__idx++]; - } - - void operator%=(const valarray& __x) const { - size_t __idx = 0; - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] %= __x[__idx++]; - } - - void operator+=(const valarray& __x) const { - size_t __idx = 0; - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] += __x[__idx++]; - } - - void operator-=(const valarray& __x) const { - size_t __idx = 0; - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] -= __x[__idx++]; - } - - void operator^=(const valarray& __x) const { - size_t __idx = 0; - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] ^= __x[__idx++]; - } - - void operator&=(const valarray& __x) const { - size_t __idx = 0; - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] &= __x[__idx++]; - } - - void operator|=(const valarray& __x) const { - size_t __idx = 0; - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] |= __x[__idx++]; - } - - void operator<<=(const valarray& __x) const { - size_t __idx = 0; - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] <<= __x[__idx++]; - } - - void operator>>=(const valarray& __x) const { - size_t __idx = 0; - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] >>= __x[__idx++]; - } - - void operator=(const value_type& __c) const { - for (size_t __i = 0; __i < _M_array.size(); ++__i) - if (_M_mask[__i]) _M_array[__i] = __c; - } - - ~mask_array() {} - - // Extension: number of true values in the mask - size_t _M_num_true() const { - size_t __result = 0; - for (size_t __i = 0; __i < _M_mask.size(); ++__i) - if (_M_mask[__i]) ++__result; - return __result; - } - -private: - mask_array(const valarray& __mask, valarray<_Tp>& __array) - : _M_mask(__mask), _M_array(__array) - {} - - valarray _M_mask; - valarray<_Tp>& _M_array; - -private: // Disable assignment - void operator=(const mask_array&); -}; - -// valarray member functions dealing with mask_array - -template -inline valarray<_Tp>::valarray(const mask_array<_Tp>& __x) - : _Valarray_base<_Tp>(__x._M_num_true()) -{ - typedef typename __type_traits<_Tp>::has_trivial_default_constructor - _Is_Trivial; - _M_initialize(_Is_Trivial()); - *this = __x; -} - -// Behavior is undefined if __x._M_num_true() != this->size() -template -inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<_Tp>& __x) { - size_t __idx = 0; - for (size_t __i = 0; __i < __x._M_array.size(); ++__i) - if (__x._M_mask[__i]) (*this)[__idx++] = __x._M_array[__i]; - return *this; -} - -template -inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray& __mask) -{ - return mask_array<_Tp>(__mask, *this); -} - -template -valarray<_Tp> valarray<_Tp>::operator[](const valarray& __mask) const -{ - size_t __size = 0; - { - for (size_t __i = 0; __i < __mask.size(); ++__i) - if (__mask[__i]) ++__size; - } - - valarray __tmp(__size, _NoInit()); - size_t __idx = 0; - { - for (size_t __i = 0; __i < __mask.size(); ++__i) - if (__mask[__i]) __tmp[__idx++] = (*this)[__i]; - } - - return __tmp; -} - -//---------------------------------------------------------------------- -// indirect_array - -template -class indirect_array { - friend class valarray<_Tp>; -public: - typedef _Tp value_type; - - void operator=(const valarray& __x) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] = __x[__i]; - } - - void operator*=(const valarray& __x) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] *= __x[__i]; - } - - void operator/=(const valarray& __x) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] /= __x[__i]; - } - - void operator%=(const valarray& __x) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] %= __x[__i]; - } - - void operator+=(const valarray& __x) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] += __x[__i]; - } - - void operator-=(const valarray& __x) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] -= __x[__i]; - } - - void operator^=(const valarray& __x) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] ^= __x[__i]; - } - - void operator&=(const valarray& __x) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] &= __x[__i]; - } - - void operator|=(const valarray& __x) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] |= __x[__i]; - } - - void operator<<=(const valarray& __x) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] <<= __x[__i]; - } - - void operator>>=(const valarray& __x) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] >>= __x[__i]; - } - - void operator=(const value_type& __c) const { - for (size_t __i = 0; __i < _M_addr.size(); ++__i) - _M_array[_M_addr[__i]] = __c; - } - - ~indirect_array() {} - -private: - indirect_array(const valarray& __addr, valarray<_Tp>& __array) - : _M_addr(__addr), _M_array(__array) - {} - - valarray _M_addr; - valarray<_Tp>& _M_array; - -private: // Disable assignment - void operator=(const indirect_array&); -}; - -// valarray member functions dealing with indirect_array - -template -inline valarray<_Tp>::valarray(const indirect_array<_Tp>& __x) - : _Valarray_base<_Tp>(__x._M_addr.size()) -{ - typedef typename __type_traits<_Tp>::has_trivial_default_constructor - _Is_Trivial; - _M_initialize(_Is_Trivial()); - *this = __x; -} - -template -valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array<_Tp>& __x) { - for (size_t __i = 0; __i < __x._M_addr.size(); ++__i) - (*this)[__i] = __x._M_array[__x._M_addr[__i]]; - return *this; -} - -template -inline indirect_array<_Tp> -valarray<_Tp>::operator[](const valarray& __addr) -{ - return indirect_array<_Tp>(__addr, *this); -} - -template -valarray<_Tp> -valarray<_Tp>::operator[](const valarray& __addr) const -{ - valarray<_Tp> __tmp(__addr.size(), _NoInit()); - for (size_t __i = 0; __i < __addr.size(); ++__i) - __tmp[__i] = (*this)[__addr[__i]]; - return __tmp; -} - -//---------------------------------------------------------------------- -// Other valarray noninline member functions - -// Shift and cshift - -template -valarray<_Tp> valarray<_Tp>::shift(int __n) const -{ - valarray<_Tp> __tmp(this->size()); - - if (__n >= 0) { - if (__n < this->size()) - copy(this->_M_first + __n, this->_M_first + this->size(), - __tmp._M_first); - } - else { - if (-__n < this->size()) - copy(this->_M_first, this->_M_first + this->size() + __n, - __tmp._M_first - __n); - } - return __tmp; -} - -template -valarray<_Tp> valarray<_Tp>::cshift(int __m) const -{ - valarray<_Tp> __tmp(this->size()); - - // Reduce __m to an equivalent number in the range [0, size()). We - // have to be careful with negative numbers, since the sign of a % b - // is unspecified when a < 0. - long __n = __m; - if (this->size() < numeric_limits::max()) - __n %= long(this->size()); - if (__n < 0) - __n += this->size(); - - copy(this->_M_first, this->_M_first + __n, - __tmp._M_first + (this->size() - __n)); - copy(this->_M_first + __n, this->_M_first + this->size(), - __tmp._M_first); - - return __tmp; -} - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_VALARRAY */ - - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/avr-stl/include/vector b/DSTAT1/src/avr-stl/include/vector deleted file mode 100644 index 272f60f..0000000 --- a/DSTAT1/src/avr-stl/include/vector +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_VECTOR -#define __SGI_STL_VECTOR - -#include -#include -#include -#include -#include -#include -#include - -#endif /* __SGI_STL_VECTOR */ - -// Local Variables: -// mode:C++ -// End: diff --git a/DSTAT1/src/config/conf_board.h b/DSTAT1/src/config/conf_board.h deleted file mode 100644 index dc022fa..0000000 --- a/DSTAT1/src/config/conf_board.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * \file - * - * \brief User board configuration template - * - */ - -#ifndef CONF_BOARD_H -#define CONF_BOARD_H - -// External oscillator settings. -// Uncomment and set correct values if external oscillator is used. - -// External oscillator frequency -#define BOARD_XOSC_HZ 3570000 - -// External oscillator type. -//!< External clock signal -//#define BOARD_XOSC_TYPE XOSC_TYPE_EXTERNAL -//!< 32.768 kHz resonator on TOSC -//#define BOARD_XOSC_TYPE XOSC_TYPE_32KHZ -//!< 0.4 to 16 MHz resonator on XTALS -#define BOARD_XOSC_TYPE XOSC_TYPE_XTAL - -// External oscillator startup time -#define BOARD_XOSC_STARTUP_US 5000 - -#endif // CONF_BOARD_H diff --git a/DSTAT1/src/config/conf_clock.h b/DSTAT1/src/config/conf_clock.h deleted file mode 100644 index 8261093..0000000 --- a/DSTAT1/src/config/conf_clock.h +++ /dev/null @@ -1,93 +0,0 @@ -/** - * \file - * - * \brief Chip-specific system clock manager configuration - * - * Copyright (c) 2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef CONF_CLOCK_H_INCLUDED -#define CONF_CLOCK_H_INCLUDED - -//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC2MHZ -//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC32MHZ -//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC32KHZ -//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_XOSC -//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLL - -/* Fbus = Fsys / (2 ^ BUS_div) */ -//#define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_1 -//#define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_1 - -//#define CONFIG_PLL0_SOURCE PLL_SRC_XOSC -//#define CONFIG_PLL0_SOURCE PLL_SRC_RC2MHZ -//#define CONFIG_PLL0_SOURCE PLL_SRC_RC32MHZ -#define CONFIG_PLL0_SOURCE PLL_SRC_XOSC - -/* Fpll = (Fclk * PLL_mul) / PLL_div */ -#define CONFIG_PLL0_MUL 7 -#define CONFIG_PLL0_DIV 1 - -/* External oscillator frequency range */ -//! 0.4 to 2 MHz frequency range -//#define CONFIG_XOSC_RANGE XOSC_RANGE_04TO2 -// 2 to 9 MHz frequency range -#define CONFIG_XOSC_RANGE XOSC_RANGE_2TO9 -//! 9 to 12 MHz frequency range -//define CONFIG_XOSC_RANGE XOSC_RANGE_9TO12 -//! 12 to 16 MHz frequency range -//define CONFIG_XOSC_RANGE XOSC_RANGE_12TO16 - -// *************************************************************** -// ** CONFIGURATION WITH USB ** -// *************************************************************** -//! The following clock configuraiton can be used for USB operation -//! It allows to operate USB using On-Chip RC oscillator at 48MHz -//! The RC oscillator is calibrated via USB Start Of Frame -//! Clk USB = 48MHz (used by USB) -//! Clk sys = 48MHz -//! Clk cpu/per = 24MHz -#define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC -#define CONFIG_OSC_RC32_CAL 48000000UL -#define CONFIG_OSC_AUTOCAL OSC_ID_RC32MHZ -#define CONFIG_OSC_AUTOCAL_REF_OSC OSC_ID_USBSOF -#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC32MHZ -#define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_1 -#define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_1 - -// ********** END OF USB CLOCK CONFIGURATION ********************** - - -#endif /* CONF_CLOCK_H_INCLUDED */ diff --git a/DSTAT1/src/config/conf_rtc.h b/DSTAT1/src/config/conf_rtc.h deleted file mode 100644 index ee43e88..0000000 --- a/DSTAT1/src/config/conf_rtc.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * \file - * - * \brief RTC configuration - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef CONF_RTC_H -#define CONF_RTC_H - -#define CONFIG_RTC_PRESCALER RTC_PRESCALER_DIV1024_gc -#define CONFIG_RTC_CLOCK_SOURCE CLK_RTCSRC_RCOSC_gc -#define CONFIG_RTC_COMPARE_INT_LEVEL RTC_COMPINTLVL_OFF_gc -#define CONFIG_RTC_OVERFLOW_INT_LEVEL RTC_OVFINTLVL_OFF_gc - -#endif /* CONF_RTC_H */ diff --git a/DSTAT1/src/config/conf_sleepmgr.h b/DSTAT1/src/config/conf_sleepmgr.h deleted file mode 100644 index 2ed302f..0000000 --- a/DSTAT1/src/config/conf_sleepmgr.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * \file - * - * \brief Chip-specific sleep manager configuration - * - * Copyright (c) 2010 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef CONF_SLEEPMGR_H -#define CONF_SLEEPMGR_H - -// Sleep manager options -#define CONFIG_SLEEPMGR_ENABLE - -#endif /* CONF_SLEEPMGR_H */ diff --git a/DSTAT1/src/config/conf_spi_master.h b/DSTAT1/src/config/conf_spi_master.h deleted file mode 100644 index d7e3cf0..0000000 --- a/DSTAT1/src/config/conf_spi_master.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * \file ********************************************************************* - * - * \brief Spi Master configuration for spi example - * - * Copyright (c) 2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef CONF_SPI_MASTER_H_INCLUDED -#define CONF_SPI_MASTER_H_INCLUDED - -//! Default Config Spi Master Dummy Field -#define CONFIG_SPI_MASTER_DUMMY 0xAA - -#endif /* CONF_SPI_MASTER_H_INCLUDED */ diff --git a/DSTAT1/src/config/conf_usart_spi.h b/DSTAT1/src/config/conf_usart_spi.h deleted file mode 100644 index 390f3cd..0000000 --- a/DSTAT1/src/config/conf_usart_spi.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * \file ********************************************************************* - * - * \brief Spi Master configuration for spi example - * - * Copyright (c) 2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -#ifndef CONF_USART_SPI_H_INCLUDED -#define CONF_USART_SPI_H_INCLUDED - - -#endif /* CONF_USART_SPI_H_INCLUDED */ diff --git a/DSTAT1/src/config/conf_usb.h b/DSTAT1/src/config/conf_usb.h deleted file mode 100644 index e5aa444..0000000 --- a/DSTAT1/src/config/conf_usb.h +++ /dev/null @@ -1,143 +0,0 @@ -/** - * \file - * - * \brief USB configuration file for CDC application - * - * Copyright (c) 2009-2011 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _CONF_USB_H_ -#define _CONF_USB_H_ - -#include "compiler.h" - -/** - * USB Device Configuration - * @{ - */ - -//! Device definition (mandatory) -#define USB_DEVICE_VENDOR_ID 0x0092 -#define USB_DEVICE_PRODUCT_ID 0x0092 -#define USB_DEVICE_MAJOR_VERSION 1 -#define USB_DEVICE_MINOR_VERSION 0 -#define USB_DEVICE_POWER 100 // Consumption on Vbus line (mA) -#define USB_DEVICE_ATTR \ -(USB_CONFIG_ATTR_SELF_POWERED) - //(USB_CONFIG_ATTR_BUS_POWERED) -// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED) -// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED) - -//! USB Device string definitions (Optional) -#define USB_DEVICE_MANUFACTURE_NAME "Wheeler Lab" -#define USB_DEVICE_PRODUCT_NAME "DStat" -// #define USB_DEVICE_SERIAL_NAME "12...EF" - - -/** - * Device speeds support - * Low speed not supported by CDC - * @{ - */ -//! To authorize the High speed -#if (UC3A3||UC3A4) -//#define USB_DEVICE_HS_SUPPORT -#endif -//@} - - -/** - * USB Device Callbacks definitions (Optional) - * @{ - */ -#define UDC_VBUS_EVENT(b_vbus_high) stdio_usb_vbus_event(b_vbus_high) -// #define UDC_SOF_EVENT() user_callback_sof_action() -// #define UDC_SUSPEND_EVENT() user_callback_suspend_action() -// #define UDC_RESUME_EVENT() user_callback_resume_action() -//! Mandatory when USB_DEVICE_ATTR authorizes remote wakeup feature -// #define UDC_REMOTEWAKEUP_ENABLE() user_callback_remotewakeup_enable() -// #define UDC_REMOTEWAKEUP_DISABLE() user_callback_remotewakeup_disable() -//! When a extra string descriptor must be supported -//! other than manufacturer, product and serial string -// #define UDC_GET_EXTRA_STRING() -//@} - -//@} - - -/** - * USB Interface Configuration - * @{ - */ -/** - * Configuration of CDC interface - * @{ - */ - -//! Number of communication port used (1 to 3) -#define UDI_CDC_PORT_NB 1 - -//! Interface callback definition -#define UDI_CDC_ENABLE_EXT() true -#define UDI_CDC_DISABLE_EXT() -#define UDI_CDC_RX_NOTIFY() -#define UDI_CDC_SET_CODING_EXT(cfg) -#define UDI_CDC_SET_DTR_EXT(set) -#define UDI_CDC_SET_RTS_EXT(set) - -//! Define it when the transfer CDC Device to Host is a low rate (<512000 bauds) -//! to reduce CDC buffers size -//#define UDI_CDC_LOW_RATE - -//! Default configuration of communication port -#define UDI_CDC_DEFAULT_RATE 10240000 -#define UDI_CDC_DEFAULT_STOPBITS CDC_STOP_BITS_1 -#define UDI_CDC_DEFAULT_PARITY CDC_PAR_NONE -#define UDI_CDC_DEFAULT_DATABITS 8 -//@} -//@} - - -/** - * USB Device Driver Configuration - * @{ - */ -//@} - -//! The includes of classes and other headers must be done at the end of this file to avoid compile error -#include "udi_cdc_conf.h" - -#endif // _CONF_USB_H_ diff --git a/DSTAT1/src/main.cpp b/DSTAT1/src/main.cpp deleted file mode 100644 index 1cc1da8..0000000 --- a/DSTAT1/src/main.cpp +++ /dev/null @@ -1,1416 +0,0 @@ -/** - * \file - * - * \brief Empty user application template - * - */ - -/* - * Include header files for all drivers that have been imported from - * Atmel Software Framework (ASF). - */ - -#define __STDC_LIMIT_MACROS -#define __STDC_CONSTANT_MACROS - -extern "C"{ -#include -#include -#include -#include -#include "ads1255.h" -#include "max5443.h" -} - -//#include "new.cpp" -#include "cstddef" -#include "main.h" -#include "iterator" -#include "vector" -#include "queue" - -//volatile uint8_t gain = POT_GAIN_30k; -volatile int32_t voltage = 0; -volatile uint16_t dacindex = 0; -uint16_t dacindex_stop = 0; -volatile int8_t up = 1; -volatile uint16_t iter = 0; -uint16_t* eis_ptr = 0; -volatile uint16_t cycles = 0; -volatile uint16_t samples = 0; -volatile uint16_t tcf0period = 0; -uint32_t skip_samples = 0; - -uint8_t ads_buff = ADS_BUFF_ON; -uint8_t ads_datarate = ADS_DR_60; -uint8_t ads_pga = ADS_PGA_2; - -int16_t eis_data[500]; - -typedef void (*port_callback_t) (void); - -static port_callback_t portd_int0_callback; -static port_callback_t portd_int1_callback; - -static void tcf0_ovf_callback(void); -static void tcf0_ovf_callback_eis(void); -static void tce0_ovf_callback_eis(void); -static void tcd0_ovf_callback_eis(void); -static void porte_int0_lsv(void); -static void tce1_ovf_callback_lsv(void); -static void lsv_cca_callback(void); -static void porte_int0_ca(void); -static void ca_cca_callback(void); - -enum potgain_t {POT_GAIN_100, POT_GAIN_300, POT_GAIN_3k, POT_GAIN_30k, POT_GAIN_300k, POT_GAIN_3M, POT_GAIN_30M, POT_GAIN_500M}; - -void pot_set_gain(/*uint8_t*/ potgain_t gain); - -potgain_t gain = POT_GAIN_3k; - -inline potgain_t& operator++(potgain_t& x){ - const int i = static_cast(x); - x = static_cast(i + 1); - return x; - } - - inline potgain_t& operator--(potgain_t& x){ - const int i = static_cast(x); - x = static_cast(i - 1); - return x; - } - -/*static void tce1_ovf_callback(void);*/ - -int8_t autogainswitch(void){ - extern int8_t over_under[ADS_OVER_UNDER_SAMPLES]; - int8_t overcurrent = 0; - static uint8_t hysteresis = 0; - static uint8_t last_return = 0; - - if (last_return==1) - { - last_return=0; - return 1; - } - - if (gain == POT_GAIN_500M) - return 0; - - if (hysteresis < ADS_OVER_UNDER_SAMPLES-1){ - ++hysteresis; - return 0; - } - - - for (uint16_t i = 0; i < ADS_OVER_UNDER_SAMPLES; ++i) - { - overcurrent += over_under[i]; - } - /*printf("OC: %i\n\r", overcurrent);*/ - - if (overcurrent == ADS_OVER_UNDER_SAMPLES && gain > POT_GAIN_300) - { - pot_set_gain(--gain); - last_return=1; - hysteresis = 0; - for (uint16_t i = 0; i < ADS_OVER_UNDER_SAMPLES; ++i) - over_under[i]=0; - - return 1; - } - - if ((overcurrent*-1) == (ADS_OVER_UNDER_SAMPLES) && gain < POT_GAIN_30M) - { - if (hysteresis < ADS_OVER_UNDER_SAMPLES+3){ - ++hysteresis; - return 0; - - } - pot_set_gain(++gain); - last_return=1; - hysteresis = 0; - for (uint16_t i = 0; i < ADS_OVER_UNDER_SAMPLES; ++i) - over_under[i]=0; - - return 1; - } - - hysteresis = 0; - return 0; -} - -void pot_set_gain(/*uint8_t*/ potgain_t gain){ - switch (gain){ -// case POT_GAIN_30k: -// ioport_configure_port_pin(&PORTD, PIN3_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); -// ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); -// printf("INFO: 30k\n\r"); -// break; -// case POT_GAIN_300k: -// ioport_configure_port_pin(&PORTD, PIN3_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); -// ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); -// printf("INFO: 300k\n\r"); -// break; -// case POT_GAIN_3M: -// ioport_configure_port_pin(&PORTD, PIN3_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); -// ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); -// printf("INFO: 3M\n\r"); -// break; -// case POT_GAIN_500M: -// ioport_configure_port_pin(&PORTD, PIN3_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); -// ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); -// printf("INFO: 500M\n\r");; -// break; - case POT_GAIN_500M: - ioport_configure_port_pin(&PORTB, PIN6_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); //A - ioport_configure_port_pin(&PORTB, PIN7_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); //B - ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); //C - printf("INFO: 500M\n\r"); - break; - case POT_GAIN_30M: - ioport_configure_port_pin(&PORTB, PIN6_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTB, PIN7_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - printf("INFO: 30M\n\r"); - break; - case POT_GAIN_3M: - ioport_configure_port_pin(&PORTB, PIN6_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTB, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - printf("INFO: 3M\n\r"); - break; - case POT_GAIN_300k: - ioport_configure_port_pin(&PORTB, PIN6_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTB, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - printf("INFO: 300k\n\r"); - break; - case POT_GAIN_30k: - ioport_configure_port_pin(&PORTB, PIN6_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTB, PIN7_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - printf("INFO: 30k\n\r"); - break; - case POT_GAIN_3k: - ioport_configure_port_pin(&PORTB, PIN6_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTB, PIN7_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - printf("INFO: 3k\n\r"); - break; - case POT_GAIN_300: - ioport_configure_port_pin(&PORTB, PIN6_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTB, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - printf("INFO: 300\n\r"); - break; - case POT_GAIN_100: - ioport_configure_port_pin(&PORTB, PIN6_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTB, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - printf("INFO: 100\n\r"); - break; - - default: - printf("WAR: Invalid pot gain.\n\r"); - break; - - return; - } -} - -inline void pot_exp_start(void){ - ioport_configure_port_pin(&PORTB, PIN4_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTB, PIN5_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTB, PIN3_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); -} - -inline void pot_exp_stop(void){ - ioport_configure_port_pin(&PORTB, PIN4_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTB, PIN5_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTB, PIN3_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); -} - -void cv_experiment(int16_t v1, int16_t v2, int16_t start, uint8_t scans, uint16_t slope){ - // check if start is [v1,v2] - int8_t firstrun = 1; - - if((start < v1 && start < v2) || (start > v1 && start > v2)) - { - printf("ERR: Start must be within [v1, v2]\n\r"); - return; - } - - RTC.CTRL = RTC_PRESCALER_OFF_gc; - while (RTC.STATUS & RTC_SYNCBUSY_bm); - RTC.CNT = 0; - RTC.PER = 0xffff; - RTC.CTRL = RTC_PRESCALER_DIV1024_gc; // 1 s tick - - - while(scans > 0){ - if (start != v1){ - lsv_experiment(start,v1,slope,firstrun); - firstrun = 0; - } - if (start == v2 && scans == 1) - firstrun = -1; - lsv_experiment(v1,v2,slope, firstrun); - if (scans == 1) - firstrun = -1; - if (start != v2) - lsv_experiment(v2,start,slope, firstrun); - scans--; - firstrun = 0; - } - - printf("Time: %lu s \n\r", rtc_get_time()); - - return; -} - -void lsv_experiment(int16_t start, int16_t stop, uint16_t slope, int8_t first_run){ - //check experiment limits - if(start<-1500 || start>1500 ||start==stop|| stop<-1500 || stop>1500 || slope>7000) - { - printf("ERR: Experiment parameters outside limits\n\r"); - return; - } - - uint16_t dacindex_start = ceil(start*(65535/(double)3000)+32767); - dacindex_stop = ceil(stop*(65535/(double)3000)+32767); -// uint16_t period; - uint32_t timer_period; - uint16_t temp_div; - - - printf("Firstrun:%i\n\r", first_run); - - max5443_set_voltage1(dacindex_start); - - if (first_run == 1 || first_run == 2){ - - pot_exp_start(); - ads1255_rdatac(); - tc_enable(&TCC1); - - ads1255_sync(); - -// voltage = TCE1.CNT; - tc_enable(&TCC0); - tc_set_overflow_interrupt_callback(&TCC0, tcf0_ovf_callback); - tc_set_overflow_interrupt_callback(&TCC1, tce1_ovf_callback_lsv); - tc_set_cca_interrupt_callback(&TCC1, lsv_cca_callback); - portd_int0_callback = porte_int0_lsv; - - //set EVCH0 event - EVSYS.CH0MUX = EVSYS_CHMUX_TCC0_OVF_gc; - EVSYS.CH0CTRL = 0; - - timer_period = ceil(1/((double)slope/(3000./65535))*(F_CPU)); - temp_div = ceil(timer_period/65535.); - - if (temp_div <= 1){ - tc_write_clock_source(&TCC0,TC_CLKSEL_DIV1_gc); - } - else if (temp_div == 2){ - tc_write_clock_source(&TCC0,TC_CLKSEL_DIV2_gc); - timer_period /= 2; - } - else if (temp_div <= 4){ - tc_write_clock_source(&TCC0,TC_CLKSEL_DIV4_gc); - timer_period /= 4; - } - else if (temp_div <= 8){ - tc_write_clock_source(&TCC0,TC_CLKSEL_DIV8_gc); - timer_period /= 8; - } - else if (temp_div <= 64){ - tc_write_clock_source(&TCC0,TC_CLKSEL_DIV64_gc); - timer_period /= 64; - } - else if (temp_div <= 256){ - tc_write_clock_source(&TCC0,TC_CLKSEL_DIV256_gc); - timer_period /= 256; - } - else if (temp_div <= 1024){ - tc_write_clock_source(&TCC0,TC_CLKSEL_DIV1024_gc); - timer_period /= 1024; - } - else{ - printf("ERR: Frequency/ADC rate is too low\n\r"); - return; - } - - printf("Period:%lu\n\r", timer_period); - ads1255_wakeup(); - tc_write_period(&TCC1, 0xffff); - tc_write_period(&TCC0, (uint16_t)timer_period); - } - - TCC1.CNT = dacindex_start; - - if (stop > start) - { - up = 1; - tc_set_direction(&TCC1, TC_UP); - } - else - { - up = -1; - tc_set_direction(&TCC1, TC_DOWN); - } - - tc_write_cc(&TCC1, TC_CCA, dacindex_stop); - tc_enable_cc_channels(&TCC1, TC_CCAEN); - TCC0.CNT = 0; - - tc_set_cca_interrupt_level(&TCC1, TC_INT_LVL_HI); - tc_set_overflow_interrupt_level(&TCC0, (TC_INT_LEVEL_t) TC_OVFINTLVL_MED_gc); -// PORTE.INTCTRL = PORT_INT0LVL_LO_gc; - PORTD.INTCTRL = PORT_INT0LVL_LO_gc; - - tc_write_clock_source(&TCC1, TC_CLKSEL_EVCH0_gc); - - - while (up != 0) - { - } - - if (first_run == -1 || first_run == 2) - { - tc_disable(&TCC0); - TCC0.CNT = 0x0; - tc_disable(&TCC1); - pot_exp_stop(); - ads1255_standby(); - } - - return; -} - -static void porte_int0_lsv(void){ - if (autogainswitch()==0){ -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - if (gain == POT_GAIN_300) - printf("%u, %ld00000\n\r", TCC1.CNT, ads1255_read()); - else if (gain == POT_GAIN_3k) - printf("%u, %ld0000\n\r", TCC1.CNT, ads1255_read()); - else if (gain == POT_GAIN_30k) - printf("%u, %ld000\n\r", TCC1.CNT, ads1255_read()); - else if (gain == POT_GAIN_300k) - printf("%u, %ld00\n\r", TCC1.CNT, ads1255_read()); - else if (gain == POT_GAIN_3M) - printf("%u, %ld0\n\r", TCC1.CNT, ads1255_read()); - else if (gain == POT_GAIN_30M) - printf("%u, %ld\n\r", TCC1.CNT, ads1255_read()); - else - printf("%u, %lu\n\r", TCC1.CNT, ads1255_read()); - } - else{ -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - ads1255_read(); - } -} - -static void tcf0_ovf_callback(void){ - max5443_set_voltage1(TCC1.CNT); -} - -static void tce1_ovf_callback_lsv(void){ -// printf("TCE1_OVF\n\r"); -// PORTE.INTCTRL = PORT_INT0LVL_OFF_gc; - PORTD.INTCTRL = PORT_INT0LVL_OFF_gc; - tc_set_overflow_interrupt_level(&TCC0, (TC_INT_LEVEL_t)TC_OVFINTLVL_OFF_gc); - tc_set_overflow_interrupt_level(&TCC1, (TC_INT_LEVEL_t)TC_OVFINTLVL_OFF_gc); - up = 0; - return; -} - -static void lsv_cca_callback(void) - { -// printf("CCA\n\r"); -// PORTE.INTCTRL = PORT_INT0LVL_OFF_gc; - PORTD.INTCTRL = PORT_INT0LVL_OFF_gc; - tc_set_overflow_interrupt_level(&TCC0, (TC_INT_LEVEL_t)TC_OVFINTLVL_OFF_gc); - tc_set_cca_interrupt_level(&TCC1, TC_INT_LVL_OFF); - up = 0; - return; - } - - -void chronoamp(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[]){ - - while (RTC.STATUS & RTC_SYNCBUSY_bm); - RTC.PER = 999; - while (RTC.STATUS & RTC_SYNCBUSY_bm); - RTC.CTRL = RTC_PRESCALER_DIV1_gc; - - EVSYS.CH0MUX = EVSYS_CHMUX_RTC_OVF_gc; - - portd_int0_callback = porte_int0_ca; - - tc_enable(&TCC0); - tc_set_cca_interrupt_callback(&TCC0, ca_cca_callback); - - ads1255_rdatac(); - ads1255_wakeup(); - - tc_write_period(&TCC0,0xffff); - tc_write_clock_source(&TCC0, TC_CLKSEL_EVCH0_gc); - tc_set_direction(&TCC0, TC_UP); - tc_enable_cc_channels(&TCC0, TC_CCAEN); - tc_set_cca_interrupt_level(&TCC0, TC_INT_LVL_HI); - TCC0.CNT = 0; - - pot_exp_start(); - - for (uint8_t i = 0; i < steps; ++i) - { - up = 1; - tc_write_cc(&TCC0, TC_CCA, TCC0.CNT+step_seconds[i]-1); - RTC.CNT=0; - max5443_set_voltage1(step_dac[i]); - //PORTE.INTCTRL = PORT_INT0LVL_LO_gc; - PORTD.INTCTRL = PORT_INT0LVL_LO_gc; - while (up !=0); - } - - tc_set_cca_interrupt_level(&TCC0, TC_INT_LVL_OFF); - tc_write_clock_source(&TCC0, TC_CLKSEL_OFF_gc); - tc_disable(&TCC0); - pot_exp_stop(); - ads1255_standby(); - - return; -} - -static void porte_int0_ca(void){ - if (autogainswitch()==0){ - //while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - if (gain == POT_GAIN_300) - printf("%u, %ld00000\n\r", TCC1.CNT, ads1255_read()); - else if (gain == POT_GAIN_3k) - printf("%u, %ld0000\n\r", TCC1.CNT, ads1255_read()); - else if (gain == POT_GAIN_30k) - printf("%u, %ld000\n\r", TCC1.CNT, ads1255_read()); - else if (gain == POT_GAIN_300k) - printf("%u, %ld00\n\r", TCC1.CNT, ads1255_read()); - else if (gain == POT_GAIN_3M) - printf("%u, %ld0\n\r", TCC1.CNT, ads1255_read()); - else if (gain == POT_GAIN_30M) - printf("%u, %ld\n\r", TCC1.CNT, ads1255_read()); - else - printf("%u, %lu\n\r", TCC1.CNT, ads1255_read()); - } - else{ - //while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - ads1255_read(); - } -} - -static void ca_cca_callback(void) - { - //PORTE.INTCTRL = PORT_INT0LVL_OFF_gc; - PORTD.INTCTRL = PORT_INT0LVL_OFF_gc; - up = 0; - return; - } - -void swv_experiment(int16_t start, int16_t stop, uint16_t step, uint16_t pulse_height, uint16_t frequency){ - //check experiment limits -// if((start-pulse_height)<-1500 || (start+pulse_height)>(1500)|| start == stop || stop<-1500 || (stop+pulse_height)>1500 || step<1 || step>1500 || pulse_height > 1500 || pulse_height < 1) -// { -// printf("ERR: Experiment parameters outside limits\n\r"); -// //return; -// } - - int32_t forward = 0; - int32_t reverse = 0; - int32_t data_buffer; - uint8_t direction; - uint16_t dacindex_start = ceil((start)*(65535/(double)3000))+32767; - uint16_t dacindex_stop = ceil(stop*(65535/(double)3000))+32767; - uint16_t dacindex_step = ceil(step*(65535/(double)3000)); - uint16_t dacindex_pulse_height = ceil(pulse_height*(65535/(double)3000)); - uint16_t dacindex = dacindex_start; - uint32_t period; - int16_t fgain = -1; - int16_t rgain = -1; - - - if (start < stop) - direction = 1; - else - direction = 0; - - tc_enable(&TCF0); - - frequency *= 2; //compensate for half-period triggers - - //calculate time to ADC trigger - period = ceil((1/(double)frequency)*F_CPU); - uint8_t temp_div = ceil((double)period/UINT16_MAX); - - if (temp_div == 1) - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV1_gc); - else if (temp_div == 2){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV2_gc); - period /= 2; - } - else if (temp_div <= 4){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV4_gc); - period /= 4; - } - else if (temp_div <= 8){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV8_gc); - period /= 8; - } - else if (temp_div <= 64){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV64_gc); - period /= 64; - } - else if (temp_div <= 256){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV256_gc); - period /= 256; - } - else if (temp_div <= 1024){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV1024_gc); - period /= 1024; - } - else{ - printf("Frequency/ADC rate is too low\n\r"); - return; - } - - tc_write_period(&TCF0, (uint16_t)period); - - if (direction == 1) - max5443_set_voltage1(dacindex+dacindex_pulse_height); - else - max5443_set_voltage1(dacindex-dacindex_pulse_height); - - ads1255_wakeup(); - ads1255_rdatac(); - ads1255_sync(); - - pot_exp_start(); - TCF0.CNT = 0; - while (!tc_is_overflow(&TCF0)); - ads1255_wakeup(); - TCF0.CNT = 0; - - while ((dacindex <= dacindex_stop && direction == 1) || (dacindex >= dacindex_stop && direction == 0)){ - tc_clear_overflow(&TCF0); - - if (fgain > -1) - //printf("%u, %li, %li\n\r", dacindex, forward*fgain, reverse*rgain); - printf("%u, %li%0*lu, %li%0*lu\n\r", dacindex, fgain, 0, forward, rgain, 0, reverse); - - forward = 0; - reverse = 0; - - while (!tc_is_overflow(&TCF0)){ - autogainswitch(); - if (gain <= POT_GAIN_30M) - fgain = 0; - else - fgain = gain-1; - - - while (ioport_pin_is_low(IOPORT_CREATE_PIN(PORTD, 5))); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - -// while (ioport_pin_is_low(IOPORT_CREATE_PIN(PORTE, 3))); -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); -// forward = ads1255_read_fast24(); - forward = ads1255_read(); - } - - - if (direction == 1) - max5443_set_voltage1(dacindex-dacindex_pulse_height); - else - max5443_set_voltage1(dacindex+dacindex_pulse_height); - - - tc_clear_overflow(&TCF0); - if (direction == 1) - dacindex += dacindex_step; - else - dacindex -= dacindex_step; - - while (!tc_is_overflow(&TCF0)){ - autogainswitch(); - if (gain <= POT_GAIN_30M) - rgain = 0; - else - rgain = gain-1; - - while (ioport_pin_is_low(IOPORT_CREATE_PIN(PORTD, 5))); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - -// while (ioport_pin_is_low(IOPORT_CREATE_PIN(PORTE, 3))); -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); -// reverse = ads1255_read_fast24(); - reverse = ads1255_read(); - } - - if (direction == 1) - max5443_set_voltage1(dacindex+dacindex_pulse_height); - else - max5443_set_voltage1(dacindex-dacindex_pulse_height); - - } - - pot_exp_stop(); - tc_write_clock_source(&TCF0, TC_CLKSEL_OFF_gc); - tc_disable(&TCF0); - tc_write_count(&TCF0,0); - ads1255_standby(); - - return; -} - -void eis_waveform(int16_t offset, int16_t amplitude, uint32_t freq, uint16_t cycle){ - - cycles = cycle; - uint16_t dacindex = ceil(offset*(65535/(double)3000)+32767); - - max5443_set_voltage1(dacindex); - - tc_enable(&TCF0); - tc_set_overflow_interrupt_callback(&TCF0, tcf0_ovf_callback_eis); - tc_enable(&TCE1); - tc_enable(&TCE0); - tc_enable(&TCD0); - - tc_set_overflow_interrupt_callback(&TCE0, tce0_ovf_callback_eis); - tc_set_overflow_interrupt_callback(&TCD0, tcd0_ovf_callback_eis); - - if (freq > 10000) - { - skip_samples = 300000UL/freq; - } - - ////// - - for (int i = 0; i<500; i++) - eis_data[i]=0; - - ////// - -// if (freq > 1000) -// samples=ceil(400000/freq); -// else -// samples = 500; - samples = 500; - - uint32_t timer_period; - uint8_t temp_div; - uint16_t V[samples]; - eis_ptr = (uint16_t*)&V; - up = 1; - - for (int i = 0; i < samples; i++) - { - V[i] = dacindex + floor((cos(2*M_PI*i/(samples-1))*amplitude)*(65536/(double)3000)); -// printf("%u\n\r", V[i]); - } - - pot_exp_start(); - - timer_period = round(F_CPU/((freq)/10.*(double)samples)); - printf("timer_period %lu\n\r", timer_period); - temp_div = ceil(timer_period/65535.); - printf("temp_div %u\n\r", temp_div); - EVSYS.CH0MUX = EVSYS_CHMUX_TCF0_OVF_gc; //TCF0: DAC timer, TCE1: cos iterator, TCE0: cycle counter - EVSYS.CH1MUX = EVSYS_CHMUX_TCE1_OVF_gc; -// EVSYS.CH2MUX = EVSYS_CHMUX_PORTE_PIN3_gc; - EVSYS.CH2MUX = EVSYS_CHMUX_PORTD_PIN5_gc; - - - if (temp_div <= 1){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV1_gc); - printf("DIV1_gc\n\r"); - } - else if (temp_div == 2){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV2_gc); - timer_period /= 2; - } - else if (temp_div <= 4){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV4_gc); - timer_period /= 4; - } - else if (temp_div <= 8){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV8_gc); - timer_period /= 8; - } - else if (temp_div <= 64){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV64_gc); - timer_period /= 64; - } - else if (temp_div <= 256){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV256_gc); - timer_period /= 256; - } - else if (temp_div <= 1024){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV1024_gc); - timer_period /= 1024; - } - else{ - printf("ERR: Frequency/ADC rate is too low\n\r"); - return; - } - - tcf0period = (uint16_t)timer_period; - printf("tcf0max = %lu\n\r", tcf0period*(uint32_t)samples); - - tc_write_period(&TCF0, (uint16_t)timer_period); - tc_write_period(&TCE1, samples-1); - tc_write_period(&TCE0, cycles); - tc_write_period(&TCD0, skip_samples); - - ads1255_wakeup(); - ads1255_rdatac(); - TCF0.CNT = 0; - TCE1.CNT = 0; - TCE0.CNT = 1; - TCD0.CNT = 1; - - tc_write_clock_source(&TCE1, TC_CLKSEL_EVCH0_gc); - tc_write_clock_source(&TCE0, TC_CLKSEL_EVCH1_gc); - tc_write_clock_source(&TCD0, TC_CLKSEL_EVCH2_gc); - - if (freq > 10000) - tc_set_overflow_interrupt_level(&TCD0, (TC_INT_LEVEL_t)TC_OVFINTLVL_MED_gc); - else -// PORTE.INTCTRL = PORT_INT1LVL_MED_gc; - PORTD.INTCTRL = PORT_INT1LVL_MED_gc; - - tc_set_overflow_interrupt_level(&TCF0, (TC_INT_LEVEL_t)TC_OVFINTLVL_LO_gc); - tc_set_overflow_interrupt_level(&TCE0, (TC_INT_LEVEL_t)TC_OVFINTLVL_HI_gc); - - while (up != 0) - { - } - - tc_write_clock_source(&TCF0, TC_CLKSEL_OFF_gc); - tc_write_clock_source(&TCE1, TC_CLKSEL_OFF_gc); - tc_write_clock_source(&TCE0, TC_CLKSEL_OFF_gc); - tc_write_clock_source(&TCD0, TC_CLKSEL_OFF_gc); - tc_disable(&TCF0); - TCF0.CNT = 0x0; - - ads1255_standby(); - - for (uint16_t i=0; i<500; i++){ - if (eis_data[i] !=0) - printf("%i, %i\n\r", i, eis_data[i]); - } -// tc_disable(&TCE1); -// TCE1.CNT = 0x0; - return; -} - -static void tcf0_ovf_callback_eis(void){ - max5443_set_voltage1(*(eis_ptr+TCE1.CNT)); - return; -} - -static void tce0_ovf_callback_eis(void){ -// printf("TCC0_OVF\n\r"); - tc_set_overflow_interrupt_level(&TCF0, (TC_INT_LEVEL_t)TC_OVFINTLVL_OFF_gc); - tc_set_overflow_interrupt_level(&TCD0, (TC_INT_LEVEL_t)TC_OVFINTLVL_OFF_gc); -// PORTE.INTCTRL = PORT_INT1LVL_OFF_gc; - PORTD.INTCTRL = PORT_INT1LVL_OFF_gc; - - up = 0; - tc_set_overflow_interrupt_level(&TCE0, (TC_INT_LEVEL_t)TC_OVFINTLVL_OFF_gc); - return; -} - -static void tcd0_ovf_callback_eis(void){ - uint16_t position = TCE1.CNT; - int16_t data_buff = ads1255_read_fast(); - - if (eis_data[position] == 0) - eis_data[position] = data_buff; - else - eis_data[position] = (eis_data[position] & data_buff)+((eis_data[position]^data_buff)>>1); - - return; -} - -void sw_test(uint16_t frequency){ - uint16_t dacindex_start = round((-1400)*(65536/(double)3000))+32768; - uint16_t dacindex_stop = round(1400*(65536/(double)3000))+32768; - uint32_t period; - - tc_enable(&TCF0); - - //calculate time to ADC trigger - period = round(((1/(double)frequency)*F_CPU)); - uint8_t temp_div = ceil(period/UINT16_MAX); - - if (temp_div == 1) - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV1_gc); - else if (temp_div == 2){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV2_gc); - period /= 2; - } - else if (temp_div <= 4){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV4_gc); - period /= 4; - } - else if (temp_div <= 8){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV8_gc); - period /= 8; - } - else if (temp_div <= 64){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV64_gc); - period /= 64; - } - else if (temp_div <= 256){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV256_gc); - period /= 256; - } - else if (temp_div <= 1024){ - tc_write_clock_source(&TCF0,TC_CLKSEL_DIV1024_gc); - period /= 1024; - } - else{ - printf("ERR: Frequency/ADC rate is too low\n\r"); - return; - } - - tc_write_period(&TCF0, (uint16_t)period/2); - pot_exp_start(); - tc_write_count(&TCF0,0); - - while (1){ - tc_clear_overflow(&TCF0); - while (!tc_is_overflow(&TCF0)); - max5443_set_voltage1(dacindex_start); - tc_clear_overflow(&TCF0); - while (!tc_is_overflow(&TCF0)); - max5443_set_voltage1(dacindex_stop); - } - pot_exp_stop(); - tc_disable(&TCF0); - tc_write_count(&TCF0,0); - return; -} - -void menu(uint8_t selection){ - int16_t start = 2000; - int16_t stop = 2000; - uint16_t slope = 0; - uint16_t height = 0; - short unsigned int scans = 0; - int16_t v1 = 2000; - int16_t v2 = 2000; - uint32_t freq = 120000; - uint16_t periods = 0; - uint16_t amp_dac[20]; - uint16_t amp_seconds[20]; - - char input = 'x'; - - switch (selection) - { - case MENU_OPS: - printf("Options:\n\r"); - - do { - printf("ADS Buffer (Y/N): "); - scanf("%c", &input); - printf("%c\n\r", input); - - if (input == 'y' || input == 'Y') - ads_buff = ADS_BUFF_ON; - else if (input == 'n' || input == 'N') - ads_buff = ADS_BUFF_OFF; - }while (!(input == 'y'||input == 'Y'||input == 'n'||input == 'N')); - - do { - printf("ADS sample rate: \n\r"); - printf("1 2.5 Hz\n\r"); - printf("2 5 Hz\n\r"); - printf("3 10 Hz\n\r"); - printf("4 15 Hz\n\r"); - printf("5 25 Hz\n\r"); - printf("6 30 Hz\n\r"); - printf("7 50 Hz\n\r"); - printf("8 60 Hz\n\r"); - printf("9 100 Hz\n\r"); - printf("10 500 Hz\n\r"); - printf("11 1 kHz\n\r"); - printf("12 2 kHz\n\r"); - printf("13 3.75 kHz\n\r"); - printf("14 7.5 kHz\n\r"); - printf("15 15 kHz\n\r"); - printf("16 30 kHz\n\r"); - - scanf("%u", &periods); - printf("%u\n\r", periods); - - if (periods == 1) - ads_datarate = ADS_DR_2_5; - else if (periods == 2) - ads_datarate = ADS_DR_5; - else if (periods == 3) - ads_datarate = ADS_DR_10; - else if (periods == 4) - ads_datarate = ADS_DR_15; - else if (periods == 5) - ads_datarate = ADS_DR_25; - else if (periods == 6) - ads_datarate = ADS_DR_30; - else if (periods == 7) - ads_datarate = ADS_DR_50; - else if (periods == 8) - ads_datarate = ADS_DR_60; - else if (periods == 9) - ads_datarate = ADS_DR_100; - else if (periods == 10) - ads_datarate = ADS_DR_500; - else if (periods == 11) - ads_datarate = ADS_DR_1000; - else if (periods == 12) - ads_datarate = ADS_DR_2000; - else if (periods == 13) - ads_datarate = ADS_DR_3750; - else if (periods == 14) - ads_datarate = ADS_DR_7500; - else if (periods == 15) - ads_datarate = ADS_DR_15000; - else if (periods == 16) - ads_datarate = ADS_DR_30000; - }while (periods == 0 || periods > 16); - - do { - printf("ADS PGA (1,2,4,8,16,32,64): \n\r"); - - scanf("%u", &periods); - printf("%u\n\r", periods); - - if (periods == 1) - ads_pga = ADS_PGA_1; - else if (periods == 2) - ads_pga = ADS_PGA_2; - else if (periods == 4) - ads_pga = ADS_PGA_4; - else if (periods == 8) - ads_pga = ADS_PGA_8; - else if (periods == 16) - ads_pga = ADS_PGA_16; - else if (periods == 32) - ads_pga = ADS_PGA_32; - else if (periods == 64) - ads_pga = ADS_PGA_64; - else - periods = 0; - }while (periods == 0 || periods > 64); - - ads1255_setup(ads_buff,ads_datarate,ads_pga); - - break; - case MENU_LSV: - printf("LSV:\n\r"); - - do { - printf("Start (-1500 - 1500 mV): "); - scanf("%d", &start); - printf("%d\n\r", start); - - if (start > 1500 && start < -1500) - { - printf("Invalid selection.\n\r"); - } - }while (start > 1500 && start < -1500); - - do { - printf("Stop (-1500 - 1500 mV): "); - scanf("%d", &stop); - printf("%d\n\r", stop); - - if (stop > 1500 && stop < -1500) - { - printf("Invalid selection.\n\r"); - } - }while (stop > 1500 && stop < -1500); - - do { - printf("Slope (1 - 7000 mV/s): "); - scanf("%u", &slope); - printf("%u\n\r", slope); - - if (slope > 7000 && slope < 1) - { - printf("Invalid selection.\n\r"); - } - }while (slope > 7000 && slope < 1); - - lsv_experiment(start,stop,slope,2); - break; - - case MENU_CV: - printf("CV:\n\r"); - - do { - printf("v1 (-1500 - 1500 mV): "); - scanf("%d", &v1); - printf("%d\n\r", v1); - - if (v1 > 1500 && v1 < -1500) - { - printf("Invalid selection.\n\r"); - } - }while (v1 > 1500 && v1 < -1500); - - do { - printf("v2 (-1500 - 1500 mV): "); - scanf("%d", &v2); - printf("%d\n\r", v2); - - if (v2 > 1500 && v2 < -1500) - { - printf("Invalid selection.\n\r"); - } - }while (v2 > 1500 && v2 < -1500); - - do { - printf("Start (-1500 - 1500 mV): "); - scanf("%d", &start); - printf("%d\n\r", start); - - if (start > 1500 && start < -1500) - { - printf("Invalid selection.\n\r"); - } - }while (start > 1500 && start < -1500); - - do { - printf("Slope (1 - 7000 mV/s): "); - scanf("%u", &slope); - printf("%u\n\r", slope); - - if (slope > 7000 && slope < 1) - { - printf("Invalid selection.\n\r"); - } - }while (slope > 7000 && slope < 1); - - do { - printf("Scans (1-255): "); - scanf("%hu", &scans); - printf("%hu\n\r", scans); - - if (scans < 1) - { - printf("Invalid selection.\n\r"); - } - }while (scans < 1); - - cv_experiment(v1,v2,start,scans,slope); - break; - case MENU_EIS: - printf("EIS:\n\r"); - - do { - printf("freq (1-100000 dHz): \n\r"); - scanf("%lu", &freq); - - if (freq > 100000 || freq == 0) - { - printf("Invalid selection.\n\r"); - } - }while (freq > 100000 || freq == 0); - - do { - printf("offset (-1500-1500 mV): \n\r"); - scanf("%d", &start); - - if (start > 1500 || start < -1500) - { - printf("Invalid selection.\n\r"); - } - }while (start > 1500 || start < -1500); - - do { - printf("amplitude (1-500 mV): \n\r"); - scanf("%u", &slope); - - if (slope > 500) - { - printf("Invalid selection.\n\r"); - } - }while (slope > 500); - - do { - printf("cycles: \n\r"); - scanf("%u", &periods); - - if (periods > 10000 || periods == 0) - { - printf("Invalid selection.\n\r"); - } - }while (periods > 10000 || periods == 0); - ads1255_setup(ADS_BUFF_ON,ADS_DR_30000,ADS_PGA_2); - eis_waveform(start, slope, freq, periods); - break; - case MENU_SWV: - printf("SWV:\n\r"); - - do { - printf("Start (-1500-1500 mV): "); - scanf("%d", &start); - printf("%d \n\r",start); - - if (start > 1500 || start < -1500) - { - printf("Invalid selection.\n\r"); - } - }while (start > 1500 || start < -1500); - - do { - printf("Stop (-1500-1500 mV): "); - scanf("%d", &stop); - printf("%d \n\r", stop); - - if (stop > 1500 || stop < -1500) - { - printf("Invalid selection.\n\r"); - } - }while (stop > 1500 || stop < -1500); - - do { - printf("Step (1-400 mV): "); - scanf("%u", &slope); - printf("%u \n\r", slope); - - if (slope > 400 || slope < 1) - { - printf("Invalid selection.\n\r"); - } - }while (slope > 400 || slope < 1); - - do { - printf("Pulse height (1-500 mV): "); - scanf("%u", &height); - printf("%u \n\r", height); - - if (height > 500) - { - printf("Invalid selection.\n\r"); - } - }while (height > 500); - - do { - printf("freq (1-10000 Hz): "); - scanf("%lu", &freq); - printf("%lu\n\r", freq); - - if (freq > 10000 || freq == 0) - { - printf("Invalid selection.\n\r"); - } - }while (freq > 10000 || freq == 0); - - do { - printf("Scans: "); - scanf("%u", &periods); - printf("%u\n\r", periods); - - if (periods == 0) - printf("Invalid selection.\n\r"); - }while (periods == 0); - - for (uint16_t i = 0; i < periods; ++i) - swv_experiment(start, stop, slope, height, freq); - break; - - case MENU_AMP: - printf("Chronoamperometry:\n\r"); - - do { - printf("Steps (1-20): "); - scanf("%u", &slope); - printf("%u\n\r", slope); - - if (slope > 20 || slope == 0) - { - printf("Invalid selection.\n\r"); - } - }while (slope > 20 || slope == 0); - - for (uint16_t i = 0; i 1500 || start < -1500) - printf("Invalid selection.\n\r"); - }while (start > 1500 || start < -1500); - - amp_dac[i] = ceil(start*(65535/(double)3000)+32767); - } - chronoamp(slope, amp_dac, amp_seconds); - - break; - default: - printf("Invalid selection.\n\r"); - return; - return; - } -} - -int main (void) -{ - board_init(); - pmic_init(); - - irq_initialize_vectors(); - cpu_irq_enable(); - sleepmgr_init(); - sysclk_init(); //Disables ALL peripheral clocks D: - rtc_init(); - sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_EVSYS); - - pmic_set_scheduling(PMIC_SCH_ROUND_ROBIN); - - stdio_usb_init(&USARTD1); - stdio_usb_enable(); -// printf("DStat v1 25 Jun 2012\n\r"); - - ads1255_init_pins(); - ads1255_init_module(); - ads1255_setup(ADS_BUFF_ON,ADS_DR_60,ADS_PGA_2); -// // PORTE.INT0MASK = PIN3_bm; -// // PORTE.INT1MASK = PIN3_bm; -// // PORTE.INTCTRL = PORT_INT0LVL_OFF_gc; -// // PORTE.INTCTRL = PORT_INT1LVL_OFF_gc; - PORTD.INT0MASK = PIN5_bm; - PORTD.INT1MASK = PIN5_bm; - PORTD.INTCTRL = PORT_INT0LVL_OFF_gc | PORT_INT1LVL_OFF_gc; - - pot_exp_stop(); - max5443_init_pins(); - max5443_init_module(); - delay_ms(300); - - uint16_t input; - - gain = POT_GAIN_3k; - pot_set_gain(gain); - -// RTC.CTRL = RTC_PRESCALER_OFF_gc; -// while (RTC.STATUS & RTC_SYNCBUSY_bm); -// RTC.CNT = 0; -// RTC.PER = 0xffff; -// RTC.CTRL = RTC_PRESCALER_DIV1_gc; - - ads1255_wakeup(); - ads1255_rdatac(); - int32_t data1 = 0; - -// max5443_set_voltage1(21845); //1V -// pot_exp_start(); - - while (1){ - ads1255_standby(); - - printf("Choose Experiment type:\n\r"); - printf("Options:0, LSV:1, CV:2, SWV:3, AMP:4, EIS:5\n\r"); - printf("DStat v1.1 27 Aug 2012\n\r"); - - scanf("%u", &input); - - if (input < 6) - menu(input); - else - printf("Invalid selection.\n\r"); - - getchar(); - - } - -} - - -ISR(PORTD_INT0_vect){ - if (portd_int0_callback) { - portd_int0_callback(); - } -// if (autogainswitch()==0){ -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); -// if (gain == POT_GAIN_30k) -// { -// printf("%u, %ld\n\r", TCC1.CNT, ads1255_read()*100); -// } -// else if (gain == POT_GAIN_300k) -// { -// printf("%u, %ld\n\r", TCC1.CNT, ads1255_read()*10); -// } -// else if (gain == POT_GAIN_3M) -// { -// printf("%u, %ld\n\r", TCC1.CNT, ads1255_read()); -// } -// else -// { -// printf("%u, %lu\n\r", TCC1.CNT, ads1255_read()); -// } -// /*printf("%li, %li\n\r", voltage, ads1255_read());*/ -// } -// else{ -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); -// ads1255_read(); -// } -} - -ISR(PORTD_INT1_vect){ -// if (autogainswitch()==0){ -// printf("INT1\n\r"); -// static uint16_t skip = 0; -// if (++skip <= skip_samples) -// return; -// skip = 0; -// -// if (samples == 500){ -// printf("%u, %d\n\r", TCE1.CNT, ads1255_read_fast()); -// return; -// } -// -// uint32_t iter1 = TCE1.CNT*(uint32_t)tcf0period + TCF0.CNT; -// -// printf("%lu, %d\n\r", iter1, ads1255_read_fast()/**(3./65535/30000.)*/); - - uint16_t position = TCE1.CNT; - int16_t data_buff = ads1255_read_fast(); - - if (eis_data[position] == 0) - eis_data[position] = data_buff; - else - eis_data[position] = (eis_data[position] & data_buff)+((eis_data[position]^data_buff)>>1); - - - return; - -} \ No newline at end of file diff --git a/DSTAT1/src/main.h b/DSTAT1/src/main.h deleted file mode 100644 index c347318..0000000 --- a/DSTAT1/src/main.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * main.h - * - * Created: 06/04/2012 1:19:58 AM - * Author: mdryden - */ - - -int8_t autogainswitch(void); -void menu(uint8_t selection); -//void pot_set_gain(/*uint8_t*/ potgain_t gain); -//void pot_LP(uint8_t lponoff); -void pot_exp_start(void); -void pot_exp_stop(void); -void sw_test(uint16_t frequency); -void lsv_experiment(int16_t start, int16_t stop, uint16_t slope, int8_t first_run); -void cv_experiment(int16_t v1, int16_t v2, int16_t start, uint8_t scans, uint16_t slope); -void chronoamp(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[]); -void swv_experiment(int16_t start, int16_t stop, uint16_t step, uint16_t pulse_height, uint16_t frequency); -void eis_waveform(int16_t offset, int16_t amplitude, uint32_t freq, uint16_t cycles); - - -#define MENU_LSV 1 -#define MENU_CV 2 -#define MENU_SWV 3 -#define MENU_AMP 4 -#define MENU_EIS 5 -#define MENU_OPS 0 - -// #define POT_GAIN_30k 0 -// #define POT_GAIN_300k 1 -// #define POT_GAIN_3M 2 -// #define POT_GAIN_500M 3 -// #define POT_LP_OFF 0 -// #define POT_LP_ON 1 - -#define ADS_F_2_5 0 -#define ADS_F_5 1 -#define ADS_F_10 2 -#define ADS_F_15 3 -#define ADS_F_25 4 -#define ADS_F_30 5 -#define ADS_F_50 6 -#define ADS_F_60 7 -#define ADS_F_100 8 -#define ADS_F_500 9 -#define ADS_F_1000 10 -#define ADS_F_2000 11 -#define ADS_F_3750 12 -#define ADS_F_7500 13 -#define ADS_F_15000 14 -#define ADS_F_30000 15 - -#define SIN_IMP_CYCLEPTS 50 diff --git a/DSTAT1/src/main1.c b/DSTAT1/src/main1.c deleted file mode 100644 index 15a5564..0000000 --- a/DSTAT1/src/main1.c +++ /dev/null @@ -1,206 +0,0 @@ -/** - * \file - * - * \brief Empty user application template - * - */ - -/* - * Include header files for all drivers that have been imported from - * Atmel Software Framework (ASF). - */ -#include -#include -#include - -static bool main_b_vbus_event = false; -static bool main_b_resume_event = false; -static bool main_b_suspend_event = false; -static bool main_b_sof_event = false; -static bool main_b_cdc_configurated = false; -static bool main_b_cdc_enumerated = false; - - -void usblog(char logdata[], int length){ - for (int i = 0; i -// #include -// #include -// #include - -// struct spi_device spi_device_conf_c = { -// .id = IOPORT_CREATE_PIN(PORTC, 4) -// }; - -struct usart_spi_device spi_device_conf_c = { - .id = IOPORT_CREATE_PIN(PORTC, 4) - }; - -void max5443_init_pins(void){ - ioport_configure_port_pin(&PORTC, PIN4_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTC, PIN5_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - ioport_configure_port_pin(&PORTC, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); -// ioport_configure_port_pin(&PORTC, PIN3_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); //CLR -// delay_us(1); -// ioport_configure_port_pin(&PORTC, PIN3_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); -} - -void max5443_init_module(void){ -// spi_master_init(&SPIC); -// spi_master_setup_device(&SPIC, &spi_device_conf_c, SPI_MODE_0, 24000000UL, 0); -// spi_enable(&SPIC); - - usart_spi_init(&USARTC1); - usart_spi_setup_device(&USARTC1, &spi_device_conf_c, SPI_MODE_0, 24000000UL, 0); -// usart_spi_enable(&USARTC1); -} - -void max5443_set_voltage1(uint16_t dacindex){ -/* char logstr[10];*/ - - static union{ - uint8_t ui8[2]; - uint16_t ui16; - } buffer; - - if (buffer.ui16 == dacindex) - return; - - buffer.ui16 = dacindex; - - irqflags_t flags; - flags = cpu_irq_save(); - -// spi_select_device(&SPIC, &spi_device_conf_c); -// spi_write_single(&SPIC, buffer.ui8[1]); -// delay_cycles(40); -// spi_write_single(&SPIC, buffer.ui8[0]); -// spi_deselect_device(&SPIC, &spi_device_conf_c); - - usart_spi_select_device(&USARTC1, &spi_device_conf_c); - usart_spi_write_single(&USARTC1, buffer.ui8[1]); - delay_cycles(40); - usart_spi_write_single(&USARTC1, buffer.ui8[0]); - usart_spi_deselect_device(&USARTC1, &spi_device_conf_c); - - cpu_irq_restore(flags); - return; -} - -// void max5443_set_voltage_8bit(uint8_t dacindex){ -// spi_select_device(&SPIC, &spi_device_conf_c); -// spi_write_single(&SPIC, dacindex); -// spi_deselect_device(&SPIC, &spi_device_conf_c); -// return; -// } - -/*void max5443_set_voltage(uint8_t msb, uint8_t lsb){ - irqflags_t flags; - flags = cpu_irq_save(); - - spi_select_device(&SPIC, &spi_device_conf_c); - spi_write_single(&SPIC, msb); - spi_write_single(&SPIC, lsb); - spi_deselect_device(&SPIC, &spi_device_conf_c); - - cpu_irq_restore(flags); -}*/ \ No newline at end of file diff --git a/DSTAT1/src/max5443.h b/DSTAT1/src/max5443.h deleted file mode 100644 index cf4070c..0000000 --- a/DSTAT1/src/max5443.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * max5443.h - * - * Created: 06/04/2012 7:30:13 PM - * Author: mdryden - */ - - -#ifndef MAX5443_H_ -#define MAX5443_H_ -#include - -void max5443_init_pins(void); -void max5443_init_module(void); -void max5443_set_voltage1(uint16_t dacindex); -//void max5443_set_voltage_8bit(uint8_t dacindex); - -#endif /* MAX5443_H_ */ \ No newline at end of file -- GitLab