diff options
author | px4dev <px4@purgatory.org> | 2012-09-14 21:33:19 -0700 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2012-09-14 21:33:19 -0700 |
commit | a3f21d914038f249e5e141b31410cc8554d94623 (patch) | |
tree | 59e60563503a42fce283149f0ca265c21faa19e2 /nuttx | |
parent | 53fe61a6211a86597834d5d8d7e90187f84717b0 (diff) | |
parent | cfa24e37d6f153dbb5c7e2e0de6484719ea4a9b0 (diff) | |
download | px4-firmware-a3f21d914038f249e5e141b31410cc8554d94623.tar.gz px4-firmware-a3f21d914038f249e5e141b31410cc8554d94623.tar.bz2 px4-firmware-a3f21d914038f249e5e141b31410cc8554d94623.zip |
Merge branch 'NuttX/master'
Diffstat (limited to 'nuttx')
352 files changed, 6337 insertions, 2893 deletions
diff --git a/nuttx/COPYING b/nuttx/COPYING index 82d3a8a58..863b81a2f 100644 --- a/nuttx/COPYING +++ b/nuttx/COPYING @@ -71,7 +71,12 @@ FAT Long File Names FAT implementations that include support for long filenames, and that removable solid state media and consumer devices only using short names would be unaffected. ..." - + + This Wikipedia entry has been updated with recent legal decisions in favor + of Microsoft. Refer to: + + http://en.wikipedia.org/wiki/File_Allocation_Table#Legal_issues + So you have been forewarned: Use the long filename at your own risk! uIP diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index b67c066bc..b6817eab2 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3250,3 +3250,102 @@ * sched/work_cancel.c: Fix a bad assertion (reported by Mike Smith) * configs/stm3210e-eval/src/up_idle.c: Correct some power management compilation errors (reported by Diego Sanchez). + * include/nuttx/wqueue.h, sched/work*, and others: Added logic to support + a second, lower priority work queue (CONFIG_SCHED_LPWORK). + * arch/arm/src/stm32/stm32_dma.c, chip/stm32*_memorymap.h: FSMC SRAM is + only 16-bits wide and the SDIO DMA must be set up differently. + * arch/arm/src/stm32/stm32_dma.c: Back out the 16-bit DMA change. It + is incorrect. + * configs/: Make use of UART4/5 vs USART4/5 consistent in all places. + * Kconfig: Serial 2STOP setting must be integer 0/1, not a boolean. + * lib/misc/sendfile.c and include/sys/sendfile.h: Add a Linux style + sendfile() (non-standard!) + * Kconfig: Refactor serial settings (moved from chip to drivers/serial). + AVR "teensy" now builds with Kconfig (contributed by Richard Cochran). + * Kconfig: Add configuration settings for the LPC17xx + * Kconfig: Add configuration settings for the LM3S (from Richard Cochran). + * Kconfig: Verify configuration settings for the STM32. This includes + changes in the way that the external SRAM is configured: Define + CONFIG_HEAP2_SIZE (decimal) instead of CONFIG_HEAP2_END (hex). + * tools/configure.sh: Don't append the apps directory path setting + if the correct setting is already in defined in the defconfig file. + * fs/fat/fs_utils.c: Improper constructed bool expression. This + would cause many unnecessary writes to FLASH (Thanks Ronen Vainish). + * Kconfig: Verify configuration settings for the LPC43xx. This includes + some corrections to configuration variable names and defconfig settings. + * Kconfig: Add and verify configuration settings for the LPC31xx. + * arch/arm/src/stm32/stm32_uart.h and stm32_serial.c: Add logic to + re-initialize the console UART as needed to enable DMA on the + console UART (contributed by Mike Smith). + * net/recvfrom.c, net/Kconfig, include/nuttx/net/uipopt.h: Remove delay + after receiving data. That has historical reasons to be there (it + was needed before read-ahead buffering was added), but kills performance. + (Noted by Max Holtzberg). + * configs/shenzhou: Add beginnings of a board configuration for the + Shenzhou STM32107 board (see www.armjishu.com). Very little is in + place as of this initial check-in. + * QEMU: Fixes from Richard Cochran to build QEMU with Kconfig files. + * arch/*/src/Makefile: Remove some old logic that was kicked off + when CONFIG_BOOT_RUNFROMFLASH=y. The old logic used to use + objcopy to move sections. Newer logic changes the load position + of sections in the the linker script. As far as I can tell, there + is nothing in the source tree now that depends on the old way of + doing things (if I am wrong, they will need a change to the linker + script). + * configs/fire-stm32v2: Configuration for the M3 Wildfire board. I + don't know very much about this board other than is has an + STM32F103VET6 chip, LCD, touchscreen, and ENC28J60 network. Very + little is in place on the initial check-in. + * configs/shenzhou: Coding for the Shenzhou board port is complete, + but tested has been deferred until I get the right tools. + * arch/arc/include/stm32/chip.h and arch/arm/src/stm32/chip.h: + Add support for the STM32F103VET6. + * fs/fs_fdopen.c: Bad check for failure to allocate memory. (Noted + by Ronen Vainish). + * drivers/mmcsd/mmcsd_sdio.c: If the MMC/SD driver were ever + uninitialized then there would be a double release of memory + (Noted by Ronen Vainish). + * fs/mmap/fs_rammap.c: Fix logic error and errno check (contributed + by Kate). + * arch/avr/src: Fixes from AVR32 build errors that have crept in + over the time; incorporated Kconfig for AVR3 (Richard Cochran). + * fs/fat and include/nuttx/fs/fat.h: The FAT file system allocates + memory for sector I/O buffers used to exchange data with the + configured block driver. In some contexts, the block driver may + require DMA-capable memory. If CONFIG_FAT_DMAMEMORY is defined, + then the FAT FS will use platform-provided DMA memory allocators + to allocate the block driver I/O buffers. + * CONFIG_NET_ENC28J60 renamed CONFIG_ENC28J60 to be consistent + in all places. + * drivers/enc28j60.c, include/nuttx/net/enc28j60.h, and + olimex-strp711/src/up_enc28j60.c: No longer passes IRQ number + as a parameters. Instead now passes a call table to manage + ENC28J60 GPIO interrupts. That is because GPIO interrupts are + handled in different ways by different MCUs and some do not + support IRQ numbers for GPIO interrupts. + * mm/mm_gran* and include/nuttx/gran.h: Add a simple granule- + based allocator. The intent of this allocator is to support + simple allocation of DMA I/O buffers. The initiali check-in + is code complete but untested (not event built into the + mm/Makefile yet. + * confgs/fire-stm32v2: The board port is basically functional. + Not all features have been verified. The ENC28J60 network + is not yet functional. + * configs/stm3240g-eval/discover: A configuration for testing + the UDP discovery utility. Contributed by Max Holtzberg. + * mm/README.txt: Add a new README file. + * include/nuttx/usb/usb.h, arch/*/src/*usb.c, and arch/*/src/*otg*.c: + Add hooks to to use common, external DMA buffer allocation + implementation. + * net/recvfrom.c: Don't block in recvfrom if (1) read-ahead buffering + is enabled and (2) some data was obtained from read-ahead buffers. + Blocking is a bad idea in that case because there is no timeout! + (submitted by Max Holtzberg). + * configs/stm3240g-eval/xmlrpc: An example configuration for the + Embeddable Lightweight XML-RPC Server at apps/examples/xmlrpc. + See http://www.drdobbs.com/web-development/\ + an-embeddable-lightweight-xml-rpc-server/184405364 for more info. + Contributed by Max Holtzberg. + * configs/*/nxwm/defconfig and sched/task_exithook.c: Fixes for + bugs that crept in during recent changes. (Submitted by Max + Holtzberg). diff --git a/nuttx/Kconfig b/nuttx/Kconfig index 7a8ba9bf2..f920e4984 100644 --- a/nuttx/Kconfig +++ b/nuttx/Kconfig @@ -16,7 +16,7 @@ config NUTTX_NEWCONFIG bool default y -menu "General Setup" +menu "Build Setup" config EXPERIMENTAL bool "Prompt for development and/or incomplete code/drivers" @@ -152,26 +152,91 @@ config RAW_BINARY should not be selected if you are not using the GNU toolchain. endmenu +menu "Customize Header Files" + +config ARCH_STDBOOL_H + bool "stdbool.h" + default n + ---help--- + The stdbool.h header file can be found at nuttx/include/stdbool.h. + However, that header includes logic to redirect the inclusion of an + architecture specific header file like: + + #ifdef CONFIG_ARCH_STDBOOL_H + # include <arch/stdbool.h> + #else + ... + #endif + + Recall that that include path, include/arch, is a symbolic link and + will refer to a version of stdbool.h at nuttx/arch/<architecture>/include/stdbool.h. + +config ARCH_MATH_H + bool "math.h" + default n + ---help--- + There is also a re-directing version of math.h in the source tree. + However, it resides out-of-the-way at include/nuttx/math.h because it + conflicts too often with the system math.h. If ARCH_MATH_H=y is + defined, however, the top-level makefile will copy the redirecting + math.h header file from include/nuttx/math.h to include/math.h. math.h + will then include the architecture-specific version of math.h that you + must provide at nuttx/arch/>architecture</include/math.h. + + #ifdef CONFIG_ARCH_MATH_H + # include <arch/math.h> + #endif + + So for the architectures that define ARCH_MATH_H=y, include/math.h + will be the redirecting math.h header file; for the architectures + that don't select ARCH_MATH_H, the redirecting math.h header file + will stay out-of-the-way in include/nuttx/. + +config ARCH_STDARG_H + bool "stdarg.h" + default n + ---help--- + There is also a redirecting version of stdarg.h in the source tree + as well. It also resides out-of-the-way at include/nuttx/stdarg.h. + This is because you should normally use your toolchain's stdarg.h + file. But sometimes, your toolchain's stdarg.h file may have other + header file dependencies and so may not be usable in the NuttX build + environment. In those cases, you may have to create a architecture- + specific stdarg.h header file at nuttx/arch/<architecture>/include/stdarg.h + + If ARCH_STDARG_H=y is defined, the top-level makefile will copy the + re-directing stdarg.h header file from include/nuttx/stdarg.h to + include/stdarg.h. So for the architectures that cannot use their + toolchain's stdarg.h file, they can use this alternative by defining + ARCH_STDARG_H=y and providing. If ARCH_STDARG_H, is not defined, then + the stdarg.h header file will stay out-of-the-way in include/nuttx/. + +endmenu + menu "Debug Options" config DEBUG - bool "Enable debug output" + bool "Enable debug features" default n ---help--- - enables built-in debug options + Enables built-in debug features. Selecting this option will (1) Enable + debug assertions in the code, (2) enable extended parameter testing in + many functions, and (3) enable support for debug output. Note that enabling + this option by itself does not produce debug output. Debug output must + also be selected on a subsystem-by-subsystem basis. if DEBUG config DEBUG_VERBOSE bool "Enable debug verbose output" default n ---help--- - enables verbose debug output + Enables verbose debug output (assuming debug output is enabled) config DEBUG_ENABLE bool "Enable debug controls" default n ---help--- - Support an interface to enable or disable debug output. + Support an interface to dynamically enable or disable debug output. config DEBUG_SCHED bool "Enable scheduler debug output" @@ -258,7 +323,7 @@ menu "Board Selection" source "configs/Kconfig" endmenu -menu "Kernel Features" +menu "RTOS Features" source sched/Kconfig endmenu @@ -266,24 +331,24 @@ menu "Device Drivers" source drivers/Kconfig endmenu -menu "Networking support" +menu "Networking Support" source net/Kconfig endmenu -menu "File systems" +menu "File Systems" source fs/Kconfig endmenu -menu "Memory management" +menu "Memory Management" source mm/Kconfig endmenu -menu "Library routines" +menu "Library Routines" source lib/Kconfig source libxx/Kconfig endmenu -menu "Application configuration" +menu "Application Configuration" source "$APPSDIR/Kconfig" endmenu diff --git a/nuttx/Makefile b/nuttx/Makefile index 1a51ca09b..375538919 100644 --- a/nuttx/Makefile +++ b/nuttx/Makefile @@ -603,7 +603,7 @@ distclean: clean subdir_distclean clean_context ifeq ($(CONFIG_BUILD_2PASS),y) @$(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" distclean endif - @rm -f Make.defs setenv.sh .config + @rm -f Make.defs setenv.sh .config .config.old # Application housekeeping targets. The APPDIR variable refers to the user # application directory. A sample apps/ directory is included with NuttX, @@ -616,9 +616,10 @@ endif # apps_clean: Perform the clean operation only in the user application # directory # apps_distclean: Perform the distclean operation only in the user application -# directory. Note that the apps/.config file is preserved -# so that this is not a "full" distclean but more of a -# configuration "reset." +# directory. Note that the apps/.config file (inf any) is +# preserved so that this is not a "full" distclean but more of a +# configuration "reset." (There willnot be an apps/.config +# file if the configuration was generated via make menuconfig). apps_clean: ifneq ($(APPDIR),) @@ -627,10 +628,16 @@ endif apps_distclean: ifneq ($(APPDIR),) - @cp "$(TOPDIR)/$(APPDIR)/.config" _SAVED_APPS_config || \ - { echo "Copy of $(APPDIR)/.config failed" ; exit 1 ; } + @if [ -r "$(TOPDIR)/$(APPDIR)/.config" ]; then \ + cp "$(TOPDIR)/$(APPDIR)/.config" _SAVED_APPS_config || \ + { echo "Copy of $(APPDIR)/.config failed" ; exit 1 ; } \ + else \ + rm -f _SAVED_APPS_config; \ + fi @$(MAKE) -C "$(TOPDIR)/$(APPDIR)" TOPDIR="$(TOPDIR)" distclean - @mv _SAVED_APPS_config "$(TOPDIR)/$(APPDIR)/.config" || \ - { echo "Copy of _SAVED_APPS_config failed" ; exit 1 ; } + @if [ -r _SAVED_APPS_config ]; then \ + @mv _SAVED_APPS_config "$(TOPDIR)/$(APPDIR)/.config" || \ + { echo "Copy of _SAVED_APPS_config failed" ; exit 1 ; } \ + fi endif diff --git a/nuttx/README.txt b/nuttx/README.txt index 28b4fba03..afea4d2e3 100644 --- a/nuttx/README.txt +++ b/nuttx/README.txt @@ -654,6 +654,8 @@ nuttx | | |- ostest/README.txt | | |- poll/README.txt | | `- README.txt + | |- fire-stm32v2/ + | | `- README.txt | |- hymini-stm32v/ | | |- include/README.txt | | |- src/README.txt @@ -735,6 +737,8 @@ nuttx | | |- include/README.txt | | |- src/README.txt | | `- README.txt + | |- shenzhou/ + | | `- README.txt | |- skp16c26/ | | |- include/README.txt | | |- src/README.txt @@ -802,6 +806,8 @@ nuttx | `- README.txt |- libxx/ | `- README.txt + |- mm/ + | `- README.txt |- syscall/ | `- README.txt `- tools/ @@ -820,6 +826,8 @@ apps |- modbus/ | `- README.txt |- netutils/ + | |- discover + | | `- README.txt | |- ftpc | | `- README.txt | |- telnetd diff --git a/nuttx/arch/Kconfig b/nuttx/arch/Kconfig index fea56b739..b445e5620 100644 --- a/nuttx/arch/Kconfig +++ b/nuttx/arch/Kconfig @@ -14,23 +14,27 @@ config ARCH_8051 config ARCH_ARM bool "ARM" + select ARCH_HAVE_INTERRUPTSTACK ---help--- The ARM architectures config ARCH_AVR bool "AVR" select ARCH_NOINTC + select ARCH_HAVE_INTERRUPTSTACK ---help--- Atmel 8-bit bit AVR and 32-bit AVR32 architectures config ARCH_HC bool "Freescale HC" select ARCH_NOINTC + select ARCH_HAVE_INTERRUPTSTACK ---help--- Freescale HC architectures (M9S12) config ARCH_MIPS bool "MIPS" + select ARCH_HAVE_INTERRUPTSTACK ---help--- MIPS architectures (PIC32) @@ -43,6 +47,7 @@ config ARCH_RGMP config ARCH_SH bool "Renesas" select ARCH_NOINTC + select ARCH_HAVE_INTERRUPTSTACK ---help--- Renesas architectures (SH and M16C). @@ -58,11 +63,13 @@ config ARCH_X86 config ARCH_Z16 bool "ZNEO" + select ARCH_HAVE_HEAP2 ---help--- ZiLOG ZNEO 16-bit architectures (z16f). config ARCH_Z80 bool "z80" + select ARCH_HAVE_HEAP2 ---help--- ZiLOG 8-bit architectures (z80, ez80, z8). @@ -100,6 +107,10 @@ config ARCH_NOINTC bool default n +config ARCH_DMA + bool + default n + config ARCH_STACKDUMP bool "Dump stack on assertions" default n @@ -117,11 +128,70 @@ config BOARD_LOOPSPERMSEC is 100 seconds. config DRAM_START - hex "DRAM start address" + hex "DRAM start physical address" help - The physical start address of installed RAM. + The physical start address of installed RAM. Despite the naming, + this may be SDRAM or SRAM or any other RAM technology that support + program execution. + +config DRAM_VSTART + hex "DRAM start virtual address" + depends on ARCH_HAVE_MMU + help + The virtual start address of installed RAM. Despite the naming, + this may be SDRAM or SRAM or any other RAM technology that support + program execution. config DRAM_SIZE int "DRAM size" help - The size in bytes of the installed RAM. + The size in bytes of the installed RAM. Despite the naming, + this may be SDRAM or SRAM or any other RAM technology that support + program execution. + +config ARCH_HAVE_INTERRUPTSTACK + bool + +config ARCH_INTERRUPTSTACK + bool "Use interrupt stack" + depends on ARCH_HAVE_INTERRUPTSTACK + default y + ---help--- + This architecture supports an interrupt stack. If defined, this symbol + is the size of the interrupt stack in bytes. If not defined, the user + task stacks will be used during interrupt handling. + +comment "Boot options" + +choice + prompt "Boot Mode" + default BOOT_RUNFROMFLASH + +config BOOT_RUNFROMEXTSRAM + bool "Run from external SRAM" + ---help--- + Some configuration support booting and running from external SRAM. + +config BOOT_RUNFROMFLASH + bool "Boot and run from flash" + ---help--- + Most configurations support XIP operation from FLASH but must copy + initialized .data sections to RAM. (This is the default). + +config BOOT_RUNFROMISRAM + bool "Boot and run from internal SRAM" + ---help--- + Some configuration support booting and running from internal SRAM. + +config BOOT_RUNFROMSDRAM + bool "Boot and run from external SDRAM" + ---help--- + Some configuration support booting and running from external SDRAM. + +config BOOT_COPYTORAM + bool "Boot from FLASH but copy to ram" + ---help--- + Some configurations boot in FLASH but copy themselves entirely into + RAM for better performance. + +endchoice diff --git a/nuttx/arch/arm/Kconfig b/nuttx/arch/arm/Kconfig index f587cc274..3bd531232 100644 --- a/nuttx/arch/arm/Kconfig +++ b/nuttx/arch/arm/Kconfig @@ -10,71 +10,106 @@ choice config ARCH_CHIP_C5471 bool "TMS320 C5471" + select ARCH_ARM7TDMI + select ARCH_HAVE_LOWVECTORS ---help--- TI TMS320 C5471, A180, or DA180 (ARM7TDMI) config ARCH_CHIP_CALYPSO bool "Calypso" + select ARCH_ARM7TDMI + select ARCH_HAVE_HEAP2 + select ARCH_HAVE_LOWVECTORS ---help--- TI Calypso-based cell phones (ARM7TDMI) config ARCH_CHIP_DM320 bool "TMS320 DM320" + select ARCH_ARM926EJS + select ARCH_HAVE_LOWVECTORS + select ARCH_HAVE_MMU ---help--- TI DMS320 DM320 (ARM926EJS) config ARCH_CHIP_IMX bool "Freescale iMX" + select ARCH_ARM920T + select ARCH_HAVE_HEAP2 + select ARCH_HAVE_LOWVECTORS + select ARCH_HAVE_MMU ---help--- Freescale iMX architectures (ARM920T) config ARCH_CHIP_KINETIS bool "Freescale Kinetis" + select ARCH_CORTEXM4 + select ARCH_HAVE_MPU ---help--- Freescale Kinetis Architectures (ARM Cortex-M4) config ARCH_CHIP_LM3S bool "TI Stellaris" + select ARCH_CORTEXM3 + select ARCH_HAVE_MPU ---help--- TI Stellaris LMS3 architecutres (ARM Cortex-M3) config ARCH_CHIP_LPC17XX bool "NXP LPC17xx" + select ARCH_CORTEXM3 + select ARCH_HAVE_MPU ---help--- NXP LPC17xx architectures (ARM Cortex-M3) config ARCH_CHIP_LPC214X bool "NXP LPC214x" + select ARCH_ARM7TDMI + select ARCH_HAVE_LOWVECTORS ---help--- NXP LPC2145x architectures (ARM7TDMI) config ARCH_CHIP_LPC2378 bool "NXP LPC2378" + select ARCH_ARM7TDMI + select ARCH_HAVE_LOWVECTORS ---help--- NXP LPC2145x architectures (ARM7TDMI) config ARCH_CHIP_LPC31XX bool "NXP LPC31XX" + select ARCH_ARM926EJS + select ARCH_HAVE_LOWVECTORS + select ARCH_HAVE_MMU ---help--- NPX LPC31XX architectures (ARM926EJS). config ARCH_CHIP_LPC43XX bool "NXP LPC43XX" + select ARCH_CORTEXM4 + select ARCH_HAVE_CMNVECTOR + select ARMV7M_CMNVECTOR + select ARCH_HAVE_MPU ---help--- NPX LPC43XX architectures (ARM Cortex-M4). config ARCH_CHIP_SAM3U bool "Atmel AT91SAM3U" + select ARCH_CORTEXM3 + select ARCH_HAVE_MPU ---help--- Atmel AT91SAM3U architectures (ARM Cortex-M3) config ARCH_CHIP_STM32 bool "STMicro STM32" + select ARCH_HAVE_CMNVECTOR + select ARCH_HAVE_MPU ---help--- STMicro STM32 architectures (ARM Cortex-M3/4). config ARCH_CHIP_STR71X bool "STMicro STR71x" + select ARCH_ARM7TDMI + select ARCH_HAVE_LOWVECTORS ---help--- STMicro STR71x architectures (ARM7TDMI). @@ -82,24 +117,23 @@ endchoice config ARCH_ARM7TDMI bool - default y if ARCH_CHIP_C5471 || ARCH_CHIP_CALYPSO || ARCH_CHIP_LPC214X || ARCH_CHIP_LPC2378 || ARCH_CHIP_STR71X config ARCH_ARM926EJS bool - default y if ARCH_CHIP_DM320 || ARCH_CHIP_LPC31XX config ARCH_ARM920T bool - default y if ARCH_CHIP_IMX -config ARCH_CORTEXM +config ARCH_CORTEXM3 + bool + +config ARCH_CORTEXM4 bool - default y if ARCH_CHIP_KINETIS || ARCH_CHIP_LM3S || ARCH_CHIP_LPC17XX || ARCH_CHIP_LPC43XX || ARCH_CHIP_SAM3U || ARCH_CHIP_STM32 config ARCH_FAMILY string default "arm" if ARCH_ARM7TDMI || ARCH_ARM926EJS || ARCH_ARM920T - default "armv7-m" if ARCH_CORTEXM + default "armv7-m" if ARCH_CORTEXM3 || ARCH_CORTEXM4 config ARCH_CHIP string @@ -109,7 +143,7 @@ config ARCH_CHIP default "imx" if ARCH_CHIP_IMX default "kinetis" if ARCH_CHIP_KINETIS default "lm3s" if ARCH_CHIP_LM3S - default "lpc17x" if ARCH_CHIP_LPC17XX + default "lpc17xx" if ARCH_CHIP_LPC17XX default "lpc214x" if ARCH_CHIP_LPC214X default "lpc2378" if ARCH_CHIP_LPC2378 default "lpc31xx" if ARCH_CHIP_LPC31XX @@ -118,27 +152,77 @@ config ARCH_CHIP default "stm32" if ARCH_CHIP_STM32 default "str71x" if ARCH_CHIP_STR71X -config ARCH_LEDS - bool "Use board LEDs to show state" - default y +config ARMV7M_CMNVECTOR + bool "Use common ARMv7-M vectors" + default n + depends on ARCH_HAVE_CMNVECTOR ---help--- - Use LEDs to show state. Unique to boards that have LEDs + Some architectures use their own, built-in vector logic. Some use only + the common vector logic. Some can use either their own built-in vector + logic or the common vector logic. This applies only to ARMv7-M + architectures. -config ARCH_INTERRUPTSTACK - bool "Use interrupt stack" +config ARCH_FPU + bool "FPU support" default y + depends on ARCH_CORTEXM4 + ---help--- + Build in support for the ARM Cortex-M4 Floating Point Unit (FPU). + Check your chip specifications first; not all Cortex-M4 chips support the FPU. + +config ARCH_HAVE_MPU + bool + +config ARMV7M_MPU + bool "MPU support" + default n + depends on ARCH_HAVE_MPU + ---help--- + Build in support for the ARM Cortex-M3/4 Memory Protection Unit (MPU). + Check your chip specifications first; not all Cortex-M3/4 chips support the MPU. + +config ARCH_HAVE_LOWVECTORS + bool + +config ARCH_LOWVECTORS + bool "Vectors in low memory" + default n + depends on ARCH_HAVE_LOWVECTORS + ---help--- + Support ARM vectors in low memory. + +config ARCH_HAVE_MMU + bool + +config PGTABLE_VADDR + hex "Page table virtual address" + depends on ARCH_HAVE_MMU + ---help--- + Page table virtual address (might be defined in the board.h file). Not + applicable to all architectures. + +config ARCH_ROMPGTABLE + bool "ROM page table" + default n + depends on ARCH_HAVE_MMU + ---help--- + Support a fixed memory mapping use a (read-only) page table in ROM/FLASH. + +config PAGING + bool "On-demand paging" + default n + depends on ARCH_HAVE_MMU && !ARCH_ROMPGTABLE ---help--- - This architecture supports an interrupt stack. If defined, this symbol - is the size of the interrupt stack in bytes. If not defined, the user - task stacks will be used during interrupt handling. + If set =y in your configation file, this setting will enable the on-demand + paging feature as described in http://www.nuttx.org/NuttXDemandPaging.html. config ARCH_IRQPRIO bool "Interrupt priority" - default y if ARCH_CORTEXM + default y if ARCH_CORTEXM3 || ARCH_CORTEXM4 ---help--- Select if your board supports interrupt prioritization. -config ARCH_LOOPSPERMSEC +config BOARD_LOOPSPERMSEC int "Delay loops per millisecond" default 5000 ---help--- @@ -150,8 +234,8 @@ config ARCH_CALIBRATION ---help--- Enables some built in instrumentation that causes a 100 second delay during boot-up. This 100 second delay serves no purpose other than it - allows you to calibratre ARCH_LOOPSPERMSEC. You simply use a stop - watch to measure the 100 second delay then adjust ARCH_LOOPSPERMSEC until + allows you to calibratre BOARD_LOOPSPERMSEC. You simply use a stop + watch to measure the 100 second delay then adjust BOARD_LOOPSPERMSEC until the delay actually is 100 seconds. if ARCH_CHIP_C5471 diff --git a/nuttx/arch/arm/include/arch.h b/nuttx/arch/arm/include/arch.h index dd750ad77..d0b2602eb 100644 --- a/nuttx/arch/arm/include/arch.h +++ b/nuttx/arch/arm/include/arch.h @@ -2,7 +2,7 @@ * arch/arm/include/arch.h * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/include/arm/irq.h b/nuttx/arch/arm/include/arm/irq.h index 6b4f05539..a06abe888 100644 --- a/nuttx/arch/arm/include/arm/irq.h +++ b/nuttx/arch/arm/include/arm/irq.h @@ -2,7 +2,7 @@ * arch/arm/include/arm/irq.h * * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/include/arm/syscall.h b/nuttx/arch/arm/include/arm/syscall.h index e06de1a3c..3fc36c3db 100644 --- a/nuttx/arch/arm/include/arm/syscall.h +++ b/nuttx/arch/arm/include/arm/syscall.h @@ -2,7 +2,7 @@ * arch/arm/include/arm/syscall.h * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/include/armv7-m/syscall.h b/nuttx/arch/arm/include/armv7-m/syscall.h index 4c7b84302..4278c3a36 100644 --- a/nuttx/arch/arm/include/armv7-m/syscall.h +++ b/nuttx/arch/arm/include/armv7-m/syscall.h @@ -2,7 +2,7 @@ * arch/arm/include/armv7-m/syscall.h * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/include/irq.h b/nuttx/arch/arm/include/irq.h index 71493a9fe..bde751b99 100644 --- a/nuttx/arch/arm/include/irq.h +++ b/nuttx/arch/arm/include/irq.h @@ -2,7 +2,7 @@ * arch/arm/include/irq.h * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/include/serial.h b/nuttx/arch/arm/include/serial.h index 80eefb2b4..844f78a2b 100644 --- a/nuttx/arch/arm/include/serial.h +++ b/nuttx/arch/arm/include/serial.h @@ -2,7 +2,7 @@ * arch/arm/include/serial.h * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/include/stm32/chip.h b/nuttx/arch/arm/include/stm32/chip.h index 2bf1d79b4..d01929e1c 100644 --- a/nuttx/arch/arm/include/stm32/chip.h +++ b/nuttx/arch/arm/include/stm32/chip.h @@ -56,6 +56,8 @@ * the chip datasheet. */ +/* STM32 F100 Value Line ************************************************************/ + #if defined(CONFIG_ARCH_CHIP_STM32F100C8) || defined(CONFIG_ARCH_CHIP_STM32F100CB) \ || defined(CONFIG_ARCH_CHIP_STM32F100R8) || defined(CONFIG_ARCH_CHIP_STM32F100RB) \ || defined(CONFIG_ARCH_CHIP_STM32F100V8) || defined(CONFIG_ARCH_CHIP_STM32F100VB) @@ -87,34 +89,10 @@ # define STM32_NRNG 0 /* No random number generator (RNG) */ # define STM32_NDCMI 0 /* No digital camera interface (DCMI) */ -#elif defined(CONFIG_ARCH_CHIP_STM32F103ZET6) -# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */ -# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */ -# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */ -# define CONFIG_STM32_HIGHDENSITY 1 /* STM32F101x and STM32F103x w/ 256/512 Kbytes */ -# undef CONFIG_STM32_VALUELINE /* STM32F100x */ -# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */ -# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ -# define STM32_NFSMC 1 /* FSMC */ -# define STM32_NATIM 1 /* One advanced timer TIM1 */ -# define STM32_NGTIM 4 /* 16-bit generall timers TIM2,3,4,5 with DMA */ -# define STM32_NBTIM 0 /* No basic timers */ -# define STM32_NDMA 2 /* DMA1-2 */ -# define STM32_NSPI 2 /* SPI1-2 */ -# define STM32_NI2S 0 /* No I2S (?) */ -# define STM32_NUSART 3 /* USART1-3 */ -# define STM32_NI2C 2 /* I2C1-2 */ -# define STM32_NCAN 1 /* CAN1 */ -# define STM32_NSDIO 1 /* SDIO */ -# define STM32_NUSBOTG 0 /* No USB OTG FS/HS */ -# define STM32_NGPIO 112 /* GPIOA-G */ -# define STM32_NADC 1 /* ADC1 */ -# define STM32_NDAC 0 /* No DAC */ -# define STM32_NCRC 0 /* No CRC */ -# define STM32_NETHERNET 0 /* No ethernet */ -# define STM32_NRNG 0 /* No random number generator (RNG) */ -# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */ +/* STM32 F103 High Density Family ***************************************************/ +/* STM32F103RC, STM32F103RD, and STM32F103RE are all provided in 64 pin packages and differ + * only in the available FLASH and SRAM. + */ #elif defined(CONFIG_ARCH_CHIP_STM32F103RET6) # define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */ @@ -145,7 +123,11 @@ # define STM32_NRNG 0 /* No random number generator (RNG) */ # define STM32_NDCMI 0 /* No digital camera interface (DCMI) */ -#elif defined(CONFIG_ARCH_CHIP_STM32F103VCT6) +/* STM32F103VC, STM32F103VD, and STM32F103VE are all provided in 100 pin packages and differ + * only in the available FLASH and SRAM. + */ + +#elif defined(CONFIG_ARCH_CHIP_STM32F103VCT6) || defined(CONFIG_ARCH_CHIP_STM32F103VET6) # define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */ # undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */ # undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */ @@ -174,6 +156,40 @@ # define STM32_NRNG 0 /* No random number generator (RNG) */ # define STM32_NDCMI 0 /* No digital camera interface (DCMI) */ +/* STM32F103ZC, STM32F103ZD, and STM32F103ZE are all provided in 144 pin packages and differ + * only in the available FLASH and SRAM. + */ + +#elif defined(CONFIG_ARCH_CHIP_STM32F103ZET6) +# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */ +# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */ +# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */ +# define CONFIG_STM32_HIGHDENSITY 1 /* STM32F101x and STM32F103x w/ 256/512 Kbytes */ +# undef CONFIG_STM32_VALUELINE /* STM32F100x */ +# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */ +# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */ +# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# define STM32_NFSMC 1 /* FSMC */ +# define STM32_NATIM 1 /* One advanced timer TIM1 */ +# define STM32_NGTIM 4 /* 16-bit generall timers TIM2,3,4,5 with DMA */ +# define STM32_NBTIM 0 /* No basic timers */ +# define STM32_NDMA 2 /* DMA1-2 */ +# define STM32_NSPI 2 /* SPI1-2 */ +# define STM32_NI2S 0 /* No I2S (?) */ +# define STM32_NUSART 3 /* USART1-3 */ +# define STM32_NI2C 2 /* I2C1-2 */ +# define STM32_NCAN 1 /* CAN1 */ +# define STM32_NSDIO 1 /* SDIO */ +# define STM32_NUSBOTG 0 /* No USB OTG FS/HS */ +# define STM32_NGPIO 112 /* GPIOA-G */ +# define STM32_NADC 1 /* ADC1 */ +# define STM32_NDAC 0 /* No DAC */ +# define STM32_NCRC 0 /* No CRC */ +# define STM32_NETHERNET 0 /* No ethernet */ +# define STM32_NRNG 0 /* No random number generator (RNG) */ +# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */ + +/* STM32 F105/F107 Connectivity Line *******************************************************/ #elif defined(CONFIG_ARCH_CHIP_STM32F105VBT7) # define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */ # undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */ @@ -232,6 +248,7 @@ # define STM32_NRNG 0 /* No random number generator (RNG) */ # define STM32_NDCMI 0 /* No digital camera interface (DCMI) */ +/* STM32 F2 Family ******************************************************************/ #elif defined(CONFIG_ARCH_CHIP_STM32F207IG) /* UFBGA-176 1024Kb FLASH 128Kb SRAM */ # undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */ # undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */ @@ -263,6 +280,7 @@ # define STM32_NRNG 1 /* Random number generator (RNG) */ # define STM32_NDCMI 1 /* Digital camera interface (DCMI) */ +/* STM23 F4 Family ******************************************************************/ #elif defined(CONFIG_ARCH_CHIP_STM32F405RG) /* LQFP 64 10x10x1.4 1024Kb FLASH 192Kb SRAM */ # undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */ # undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */ diff --git a/nuttx/arch/arm/include/syscall.h b/nuttx/arch/arm/include/syscall.h index 4c9eee63e..8b438200a 100644 --- a/nuttx/arch/arm/include/syscall.h +++ b/nuttx/arch/arm/include/syscall.h @@ -2,7 +2,7 @@ * arch/arm/include/syscall.h * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/include/types.h b/nuttx/arch/arm/include/types.h index c3471ca59..c06b28950 100644 --- a/nuttx/arch/arm/include/types.h +++ b/nuttx/arch/arm/include/types.h @@ -2,7 +2,7 @@ * arch/arm/include/types.h * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/include/watchdog.h b/nuttx/arch/arm/include/watchdog.h index f70b8d2e9..43fbac2be 100644 --- a/nuttx/arch/arm/include/watchdog.h +++ b/nuttx/arch/arm/include/watchdog.h @@ -2,7 +2,7 @@ * arch/arm/include/watchdog.h * * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/Makefile b/nuttx/arch/arm/src/Makefile index ef0415375..74be6c18d 100644 --- a/nuttx/arch/arm/src/Makefile +++ b/nuttx/arch/arm/src/Makefile @@ -111,11 +111,6 @@ nuttx: $(HEAD_OBJ) board/libboard$(LIBEXT) @echo "LD: nuttx" @$(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX)$(EXEEXT) $(HEAD_OBJ) $(EXTRA_OBJS) \ --start-group $(LDLIBS) -lboard $(EXTRA_LIBS) $(LIBGCC) --end-group -ifeq ($(CONFIG_BOOT_RUNFROMFLASH),y) - @export flashloc=`$(OBJDUMP) --all-headers $(NUTTX)$(EXEEXT) | grep _eronly | cut -d' ' -f1`; \ - $(OBJCOPY) $(OBJCOPYARGS) --adjust-section-vma=.data=0x$$flashloc $(NUTTX)$(EXEEXT) $(NUTTX).flashimage - @mv $(NUTTX).flashimage $(NUTTX)$(EXEEXT) -endif @$(NM) $(NUTTX)$(EXEEXT) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ sort > $(TOPDIR)/System.map diff --git a/nuttx/arch/arm/src/armv7-m/psr.h b/nuttx/arch/arm/src/armv7-m/psr.h index 30913f7c9..b8b33c80f 100644 --- a/nuttx/arch/arm/src/armv7-m/psr.h +++ b/nuttx/arch/arm/src/armv7-m/psr.h @@ -2,7 +2,7 @@ * arch/arm/src/armv7-m/psr.h * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/armv7-m/svcall.h b/nuttx/arch/arm/src/armv7-m/svcall.h index 51b5b9111..9a4db89b1 100644 --- a/nuttx/arch/arm/src/armv7-m/svcall.h +++ b/nuttx/arch/arm/src/armv7-m/svcall.h @@ -2,7 +2,7 @@ * arch/arm/src/armv7-m/svcall.h * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/armv7-m/up_assert.c b/nuttx/arch/arm/src/armv7-m/up_assert.c index 77fd0b596..2662cbe37 100644 --- a/nuttx/arch/arm/src/armv7-m/up_assert.c +++ b/nuttx/arch/arm/src/armv7-m/up_assert.c @@ -2,7 +2,7 @@ * arch/arm/src/armv7-m/up_assert.c * * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/armv7-m/up_blocktask.c b/nuttx/arch/arm/src/armv7-m/up_blocktask.c index 896476ed2..896476ed2 100755..100644 --- a/nuttx/arch/arm/src/armv7-m/up_blocktask.c +++ b/nuttx/arch/arm/src/armv7-m/up_blocktask.c diff --git a/nuttx/arch/arm/src/armv7-m/up_copystate.c b/nuttx/arch/arm/src/armv7-m/up_copystate.c index a5ad312f5..e9eede8f9 100644 --- a/nuttx/arch/arm/src/armv7-m/up_copystate.c +++ b/nuttx/arch/arm/src/armv7-m/up_copystate.c @@ -2,7 +2,7 @@ * arch/arm/src/armv7-m/up_copystate.c * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/armv7-m/up_doirq.c b/nuttx/arch/arm/src/armv7-m/up_doirq.c index 7ac1ec34d..375054fba 100644 --- a/nuttx/arch/arm/src/armv7-m/up_doirq.c +++ b/nuttx/arch/arm/src/armv7-m/up_doirq.c @@ -2,7 +2,7 @@ * arch/arm/src/armv7-m/up_doirq.c * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/armv7-m/up_hardfault.c b/nuttx/arch/arm/src/armv7-m/up_hardfault.c index a9eea8103..cb3ce9e8a 100644 --- a/nuttx/arch/arm/src/armv7-m/up_hardfault.c +++ b/nuttx/arch/arm/src/armv7-m/up_hardfault.c @@ -2,7 +2,7 @@ * arch/arm/src/armv7-m/up_hardfault.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/armv7-m/up_memfault.c b/nuttx/arch/arm/src/armv7-m/up_memfault.c index bbe3f6573..ab93c7697 100644 --- a/nuttx/arch/arm/src/armv7-m/up_memfault.c +++ b/nuttx/arch/arm/src/armv7-m/up_memfault.c @@ -2,7 +2,7 @@ * arch/arm/src/armv7-m/up_memfault.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/armv7-m/up_mpu.c b/nuttx/arch/arm/src/armv7-m/up_mpu.c index 27936562c..4bb3f21d9 100644 --- a/nuttx/arch/arm/src/armv7-m/up_mpu.c +++ b/nuttx/arch/arm/src/armv7-m/up_mpu.c @@ -2,7 +2,7 @@ * arch/arm/src/armv7-m/up_mpu.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/armv7-m/up_releasepending.c b/nuttx/arch/arm/src/armv7-m/up_releasepending.c index 2f0d4dc39..2f0d4dc39 100755..100644 --- a/nuttx/arch/arm/src/armv7-m/up_releasepending.c +++ b/nuttx/arch/arm/src/armv7-m/up_releasepending.c diff --git a/nuttx/arch/arm/src/armv7-m/up_reprioritizertr.c b/nuttx/arch/arm/src/armv7-m/up_reprioritizertr.c index f1c961b15..f1c961b15 100755..100644 --- a/nuttx/arch/arm/src/armv7-m/up_reprioritizertr.c +++ b/nuttx/arch/arm/src/armv7-m/up_reprioritizertr.c diff --git a/nuttx/arch/arm/src/armv7-m/up_saveusercontext.S b/nuttx/arch/arm/src/armv7-m/up_saveusercontext.S index c8da07430..06eb183d2 100755 --- a/nuttx/arch/arm/src/armv7-m/up_saveusercontext.S +++ b/nuttx/arch/arm/src/armv7-m/up_saveusercontext.S @@ -2,7 +2,7 @@ * arch/arm/src/armv7-m/up_saveusercontext.S * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/armv7-m/up_sigdeliver.c b/nuttx/arch/arm/src/armv7-m/up_sigdeliver.c index 3c340b8d3..38673c41d 100644 --- a/nuttx/arch/arm/src/armv7-m/up_sigdeliver.c +++ b/nuttx/arch/arm/src/armv7-m/up_sigdeliver.c @@ -2,7 +2,7 @@ * arch/arm/src/armv7-m/up_sigdeliver.c * * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/armv7-m/up_switchcontext.S b/nuttx/arch/arm/src/armv7-m/up_switchcontext.S index 854f6fa16..762e2066e 100755 --- a/nuttx/arch/arm/src/armv7-m/up_switchcontext.S +++ b/nuttx/arch/arm/src/armv7-m/up_switchcontext.S @@ -2,7 +2,7 @@ * arch/arm/src/armv7-m/up_switchcontext.S * * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/armv7-m/up_unblocktask.c b/nuttx/arch/arm/src/armv7-m/up_unblocktask.c index da10f0376..da10f0376 100755..100644 --- a/nuttx/arch/arm/src/armv7-m/up_unblocktask.c +++ b/nuttx/arch/arm/src/armv7-m/up_unblocktask.c diff --git a/nuttx/arch/arm/src/common/up_allocateheap.c b/nuttx/arch/arm/src/common/up_allocateheap.c index fbd1421a7..d4b763196 100644 --- a/nuttx/arch/arm/src/common/up_allocateheap.c +++ b/nuttx/arch/arm/src/common/up_allocateheap.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_allocateheap.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_arch.h b/nuttx/arch/arm/src/common/up_arch.h index b612f6af2..af29bbf65 100644 --- a/nuttx/arch/arm/src/common/up_arch.h +++ b/nuttx/arch/arm/src/common/up_arch.h @@ -2,7 +2,7 @@ * arch/arm/src/common/up_arch.h * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_checkstack.c b/nuttx/arch/arm/src/common/up_checkstack.c index 6c13f63d1..ac8d9e7b9 100644 --- a/nuttx/arch/arm/src/common/up_checkstack.c +++ b/nuttx/arch/arm/src/common/up_checkstack.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_checkstack.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_etherstub.c b/nuttx/arch/arm/src/common/up_etherstub.c index 1c4a71ce6..407e7b45b 100755..100644 --- a/nuttx/arch/arm/src/common/up_etherstub.c +++ b/nuttx/arch/arm/src/common/up_etherstub.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_etherstub.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_idle.c b/nuttx/arch/arm/src/common/up_idle.c index 62557c3a8..187af76e7 100644 --- a/nuttx/arch/arm/src/common/up_idle.c +++ b/nuttx/arch/arm/src/common/up_idle.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_idle.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_interruptcontext.c b/nuttx/arch/arm/src/common/up_interruptcontext.c index b67ad523a..0039692bc 100644 --- a/nuttx/arch/arm/src/common/up_interruptcontext.c +++ b/nuttx/arch/arm/src/common/up_interruptcontext.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_interruptcontext.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_lowputs.c b/nuttx/arch/arm/src/common/up_lowputs.c index 8b2919a05..890167e0e 100644 --- a/nuttx/arch/arm/src/common/up_lowputs.c +++ b/nuttx/arch/arm/src/common/up_lowputs.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_lowputs.c * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_mdelay.c b/nuttx/arch/arm/src/common/up_mdelay.c index b9b9ffc0e..2c0447620 100644 --- a/nuttx/arch/arm/src/common/up_mdelay.c +++ b/nuttx/arch/arm/src/common/up_mdelay.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_mdelay.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_modifyreg16.c b/nuttx/arch/arm/src/common/up_modifyreg16.c index e488a6eee..32ebd6f96 100644 --- a/nuttx/arch/arm/src/common/up_modifyreg16.c +++ b/nuttx/arch/arm/src/common/up_modifyreg16.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_modifyreg16.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_modifyreg32.c b/nuttx/arch/arm/src/common/up_modifyreg32.c index 8b93f6b84..a87873284 100644 --- a/nuttx/arch/arm/src/common/up_modifyreg32.c +++ b/nuttx/arch/arm/src/common/up_modifyreg32.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_modifyreg32.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_modifyreg8.c b/nuttx/arch/arm/src/common/up_modifyreg8.c index 2c9dbac25..92ed48eff 100644 --- a/nuttx/arch/arm/src/common/up_modifyreg8.c +++ b/nuttx/arch/arm/src/common/up_modifyreg8.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_modifyreg8.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_puts.c b/nuttx/arch/arm/src/common/up_puts.c index 4e74f0cdc..f56dbf07e 100644 --- a/nuttx/arch/arm/src/common/up_puts.c +++ b/nuttx/arch/arm/src/common/up_puts.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_puts.c * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_releasestack.c b/nuttx/arch/arm/src/common/up_releasestack.c index 407bd1b54..82f5db88f 100644 --- a/nuttx/arch/arm/src/common/up_releasestack.c +++ b/nuttx/arch/arm/src/common/up_releasestack.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_releasestack.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_udelay.c b/nuttx/arch/arm/src/common/up_udelay.c index d2d5b74d9..8fcb93522 100644 --- a/nuttx/arch/arm/src/common/up_udelay.c +++ b/nuttx/arch/arm/src/common/up_udelay.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_udelay.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/common/up_usestack.c b/nuttx/arch/arm/src/common/up_usestack.c index f46be0cc9..a3f4f4816 100644 --- a/nuttx/arch/arm/src/common/up_usestack.c +++ b/nuttx/arch/arm/src/common/up_usestack.c @@ -2,7 +2,7 @@ * arch/arm/src/common/up_usestack.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/Kconfig b/nuttx/arch/arm/src/stm32/Kconfig index bf7c59c11..b5d0306da 100644 --- a/nuttx/arch/arm/src/stm32/Kconfig +++ b/nuttx/arch/arm/src/stm32/Kconfig @@ -3,81 +3,188 @@ # see misc/tools/kconfig-language.txt. # +comment "STM32 Configuration Options" + choice prompt "STM32 Chip Selection" default ARCH_CHIP_STM32F103ZET6 depends on ARCH_CHIP_STM32 -config ARCH_CHIP_STM32F103ZET6 - bool "STM32F103ZET6" +config ARCH_CHIP_STM32F100C8 + bool "STM32F100C8" + select ARCH_CORTEXM3 + select STM32_STM32F10XX + select STM32_VALUELINE + +config ARCH_CHIP_STM32F100CB + bool "STM32F100CB" + select ARCH_CORTEXM3 + select STM32_STM32F10XX + select STM32_VALUELINE + +config ARCH_CHIP_STM32F100R8 + bool "STM32F100R8" + select ARCH_CORTEXM3 + select STM32_STM32F10XX + select STM32_VALUELINE + +config ARCH_CHIP_STM32F100RB + bool "STM32F100RB" + select ARCH_CORTEXM3 + select STM32_STM32F10XX + select STM32_VALUELINE + +config ARCH_CHIP_STM32F100V8 + bool "STM32F100V8" + select ARCH_CORTEXM3 + select STM32_STM32F10XX + select STM32_VALUELINE + +config ARCH_CHIP_STM32F100VB + bool "STM32F100VB" + select ARCH_CORTEXM3 + select STM32_STM32F10XX + select STM32_VALUELINE config ARCH_CHIP_STM32F103RET6 bool "STM32F103RET6" + select ARCH_CORTEXM3 + select STM32_STM32F10XX + select STM32_HIGHDENSITY config ARCH_CHIP_STM32F103VCT6 bool "STM32F103VCT6" + select ARCH_CORTEXM3 + select STM32_STM32F10XX + select STM32_HIGHDENSITY + +config ARCH_CHIP_STM32F103VET6 + bool "STM32F103VET6" + select ARCH_CORTEXM3 + select STM32_STM32F10XX + select STM32_HIGHDENSITY + +config ARCH_CHIP_STM32F103ZET6 + bool "STM32F103ZET6" + select ARCH_CORTEXM3 + select STM32_STM32F10XX config ARCH_CHIP_STM32F105VBT7 bool "STM32F105VBT7" + select ARCH_CORTEXM3 + select STM32_STM32F10XX + select STM32_CONNECTIVITYLINE config ARCH_CHIP_STM32F107VC bool "STM32F107VC" + select ARCH_CORTEXM3 + select STM32_STM32F10XX + select STM32_CONNECTIVITYLINE config ARCH_CHIP_STM32F207IG bool "STM32F207IG" + select ARCH_CORTEXM3 + select STM32_STM32F20XX config ARCH_CHIP_STM32F405RG bool "STM32F405RG" + select ARCH_CORTEXM4 + select STM32_STM32F40XX config ARCH_CHIP_STM32F405VG bool "STM32F405VG" + select ARCH_CORTEXM4 + select STM32_STM32F40XX config ARCH_CHIP_STM32F405ZG bool "STM32F405ZG" + select ARCH_CORTEXM4 + select STM32_STM32F40XX config ARCH_CHIP_STM32F407VE bool "STM32F407VE" + select ARCH_CORTEXM4 + select STM32_STM32F40XX config ARCH_CHIP_STM32F407VG bool "STM32F407VG" + select ARCH_CORTEXM3 + select STM32_STM32F40XX config ARCH_CHIP_STM32F407ZE bool "STM32F407ZE" + select ARCH_CORTEXM4 + select STM32_STM32F40XX config ARCH_CHIP_STM32F407ZG bool "STM32F407ZG" + select ARCH_CORTEXM4 + select STM32_STM32F40XX config ARCH_CHIP_STM32F407IE bool "STM32F407IE" + select ARCH_CORTEXM4 + select STM32_STM32F40XX config ARCH_CHIP_STM32F407IG bool "STM32F407IG" + select ARCH_CORTEXM4 + select STM32_STM32F40XX endchoice config STM32_STM32F10XX bool - default y if ARCH_CHIP_STM32F103ZET6 || ARCH_CHIP_STM32F103RET6 || ARCH_CHIP_STM32F103VCT6 || ARCH_CHIP_STM32F105VBT7 || ARCH_CHIP_STM32F107VC + +config STM32_VALUELINE + bool + +config STM32_HIGHDENSITY + bool config STM32_CONNECTIVITYLINE bool - default y if ARCH_CHIP_STM32F105VBT7 || ARCH_CHIP_STM32F107VC config STM32_STM32F20XX bool - default y if ARCH_CHIP_STM32F207IG config STM32_STM32F40XX bool - default y if ARCH_CHIP_STM32F405RG || ARCH_CHIP_STM32F405VG || ARCH_CHIP_STM32F405ZG || ARCH_CHIP_STM32F407VE || ARCH_CHIP_STM32F407VG || ARCH_CHIP_STM32F407ZE || ARCH_CHIP_STM32F407ZG || ARCH_CHIP_STM32F407IE || ARCH_CHIP_STM32F407IE -config ARCH_CORTEXM3 - bool - default y if !STM32_STM32F40XX +choice + prompt "Toolchain Selection" + default STM32_CODESOURCERYW + depends on ARCH_CHIP_STM32 -config ARCH_CORTEXM4 - bool - default y if STM32_STM32F40XX +config STM32_CODESOURCERYW + bool "CodeSourcery for Windows" + +config STM32_CODESOURCERYL + bool "CodeSourcery for Linux" + +config STM32_ATOLLIC_LITE + bool "Atollic Lite for Windows" + +config STM32_ATOLLIC_PRO + bool "Atollic Pro for Windows" + +config STM32_DEVKITARM + bool "DevkitARM (Windows)" + +config STM32_RAISONANCE + bool "STMicro Raisonance for Windows" + +config STM32_BUILDROOT + bool "NuttX buildroot (Cygwin or Linux)" + +endchoice + +config STM32_DFU + bool "DFU bootloader" + default n + ---help--- + Configure and position code for use with the STMicro DFU bootloader. Do + not select this option if you will load code using JTAG/SWM. menu "STM32 Peripheral Support" @@ -100,10 +207,12 @@ config STM32_CRC config STM32_DMA1 bool "DMA1" default n + select ARCH_DMA config STM32_DMA2 bool "DMA2" default n + select ARCH_DMA config STM32_BKP bool "BKP" @@ -118,11 +227,13 @@ config STM32_BKPSRAM config STM32_CAN1 bool "CAN1" default n + select CAN config STM32_CAN2 bool "CAN2" default n depends on STM32_STM32F20XX || STM32_STM32F40XX + select CAN config STM32_CCMDATARAM bool "CMD/DATA RAM" @@ -150,11 +261,12 @@ config STM32_DCMI config STM32_ETHMAC bool "Ethernet MAC" default n - depends on STM32_STM32F20XX || STM32_STM32F40XX + depends on STM32_CONNECTIVITYLINE || STM32_STM32F20XX || STM32_STM32F40XX config STM32_FSMC bool "FSMC" default n + depends on !STM32_CONNECTIVITYLINE config STM32_HASH bool "HASH" @@ -177,6 +289,7 @@ config STM32_I2C3 config STM32_IWDG bool "IWDG" default n + select WATCHDOG config STM32_OTGFS bool "OTG FS" @@ -200,28 +313,33 @@ config STM32_RNG config STM32_SDIO bool "SDIO" default n + depends on !STM32_CONNECTIVITYLINE config STM32_SPI1 bool "SPI1" default n + select SPI config STM32_SPI2 bool "SPI2" default n + select SPI config STM32_SPI3 bool "SPI3" default n depends on STM32_STM32F20XX || STM32_STM32F40XX + select SPI config STM32_SPI4 bool "SPI4" default n depends on STM32_STM32F10XX + select SPI config STM32_SYSCFG bool "SYSCFG" - default n + default y depends on STM32_STM32F20XX || STM32_STM32F40XX config STM32_TIM1 @@ -289,36 +407,44 @@ config STM32_TIM14 config STM32_USART1 bool "USART1" default n + select ARCH_HAVE_USART1 config STM32_USART2 bool "USART2" default n + select ARCH_HAVE_USART2 config STM32_USART3 bool "USART3" default n + select ARCH_HAVE_USART3 config STM32_UART4 bool "UART4" default n + select ARCH_HAVE_UART4 config STM32_UART5 bool "UART5" default n + select ARCH_HAVE_UART5 config STM32_USART6 bool "USART6" default n depends on STM32_STM32F20XX || STM32_STM32F40XX + select ARCH_HAVE_USART6 config STM32_USB bool "USB Device" default n depends on STM32_STM32F10XX + select USBDEV config STM32_WWDG bool "WWDG" default n + select WATCHDOG endmenu @@ -334,14 +460,12 @@ config STM32_SPI bool default y if STM32_SPI1 || STM32_SPI2 || STM32_SPI3 || STM32_SPI4 -config STM32_DMA - bool - default y if STM32_DMA1 || STM32_DMA2 - config STM32_CAN bool default y if STM32_CAN1 || STM32_CAN2 +menu "Alternate Pin Mapping" + choice prompt "TIM1 Alternate Pin Mappings" depends on STM32_STM32F10XX && STM32_TIM1 @@ -447,18 +571,25 @@ choice config STM32_CAN1_NO_REMAP bool "No pin remapping" -config STM32_CAN1_FULL_REMAP - bool "Full pin remapping" +config CONFIG_STM32_CAN1_REMAP1 + bool "CAN1 alternate pin remapping #1" -config STM32_CAN1_PARTIAL_REMAP - bool "Partial pin remapping" +config CONFIG_STM32_CAN1_REMAP2 + bool "CAN1 alternate pin remapping #2" endchoice config STM32_CAN2_REMAP bool "CAN2 Alternate Pin Mapping" default n - depends on STM32_STM32F10XX && STM32_CAN2 + depends on STM32_CONNECTIVITYLINE && STM32_CAN2 + +config STM32_ETH_REMAP + bool "Ethernet Alternate Pin Mapping" + default n + depends on STM32_CONNECTIVITYLINE && STM32_ETHMAC + +endmenu choice prompt "JTAG Configuration" @@ -497,39 +628,18 @@ config ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG config STM32_CCMEXCLUDE bool "Exclude CCM SRAM from the heap" depends on STM32_STM32F20XX || STM32_STM32F40XX - default y if STM32_DMA1 || STM32_DMA2 + default y if ARCH_DMA ---help--- Exclude CCM SRAM from the HEAP because it cannot be used for DMA. config STM32_FSMC_SRAM bool "External SRAM on FSMC" default n - depends on FSMC + depends on STM32_FSMC + select ARCH_HAVE_HEAP2 ---help--- In addition to internal SRAM, SRAM may also be available through the FSMC. -config HEAP2_BASE - hex "FSMC SRAM base address" - default 0x00000000 - depends on STM32_FSMC_SRAM - ---help--- - The base address of the SRAM in the FSMC address space. - -config HEAP2_END - hex "FSMC SRAM end+1 address" - default 0x00000000 - depends on STM32_FSMC_SRAM - ---help--- - The end (+1) of the SRAM in the FSMC address space - -config ARCH_FPU - bool "FPU support" - default y - depends on ARCH_CORTEXM4 - ---help--- - Build in support for the ARM Cortex-M4 FPU. Only the STM3240xxx supports - a floating point unit (FPU) - config STM32_TIM1_PWM bool "TIM1 PWM" default n @@ -1420,342 +1530,48 @@ config STM32_TIM14_DAC2 endchoice -menu "USART1 Configuration" - depends on STM32_USART1 - -config USART1_SERIAL_CONSOLE - bool "USART1 serial console" - default y - ---help--- - Selects the USART1 for the console and ttys0 (default is the USART1). - -config USART1_RXBUFSIZE - int "USART1 Rx buffer size" - default 256 - ---help--- - Characters are buffered as received. This specific the size of the receive - buffer. - -config USART1_TXBUFSIZE - int "USART1 Tx buffer size" - default 256 - ---help--- - Characters are buffered before being sent. This specific the size of the - transmit buffer - -config USART1_BAUD - int "USART1 BAUD" - default 11520 - ---help--- - The configured BAUD of the UART - -config USART1_BITS - int "USART1 number of bits" - default 8 - ---help--- - The number of bits. Must be either 7 or 8. - -config USART1_PARITY - int "USART1 parity" - default 0 - ---help--- - 0=no parity, 1=odd parity, 2=even parity - -config USART1_2STOP - bool "USART1 two stop bits" - default n - ---help--- - Two stop bits - config USART1_RXDMA bool "USART1 Rx DMA" default n - depends on STM32_STM32F40XX && ARCH_DMA && STM32_DMA2 + depends on STM32_STM32F40XX && STM32_DMA2 ---help--- In high data rate usage, Rx DMA may eliminate Rx overrun errors -endmenu - -menu "USART2 Configuration" - depends on STM32_USART2 - -config USART2_SERIAL_CONSOLE - bool "USART2 serial console" - default y if !STM32_USART1 - ---help--- - Selects the USART2 for the console and ttys0 (default is the USART2). - -config USART2_RXBUFSIZE - int "USART2 Rx buffer size" - default 256 - ---help--- - Characters are buffered as received. This specific the size of the receive - buffer. - -config USART2_TXBUFSIZE - int "USART2 Tx buffer size" - default 256 - ---help--- - Characters are buffered before being sent. This specific the size of the - transmit buffer - -config USART2_BAUD - int "USART2 BAUD" - default 11520 - ---help--- - The configured BAUD of the UART - -config USART2_BITS - int "USART2 number of bits" - default 8 - ---help--- - The number of bits. Must be either 7 or 8. - -config USART2_PARITY - int "USART2 parity" - default 0 - ---help--- - 0=no parity, 1=odd parity, 2=even parity - -config USART2_2STOP - bool "USART2 two stop bits" - default n - ---help--- - Two stop bits - config USART2_RXDMA bool "USART2 Rx DMA" default n - depends on STM32_STM32F40XX && ARCH_DMA && STM32_DMA1 + depends on STM32_STM32F40XX && STM32_DMA1 ---help--- In high data rate usage, Rx DMA may eliminate Rx overrun errors -endmenu - -menu "USART3 Configuration" - depends on STM32_USART3 - -config USART3_SERIAL_CONSOLE - bool "USART3 serial console" - default y if !STM32_USART1 && !STM32_USART2 - ---help--- - Selects the USART3 for the console and ttys0 (default is the USART3). - -config USART3_RXBUFSIZE - int "USART3 Rx buffer size" - default 256 - ---help--- - Characters are buffered as received. This specific the size of the receive - buffer. - -config USART3_TXBUFSIZE - int "USART3 Tx buffer size" - default 256 - ---help--- - Characters are buffered before being sent. This specific the size of the - transmit buffer - -config USART3_BAUD - int "USART3 BAUD" - default 11520 - ---help--- - The configured BAUD of the UART - -config USART3_BITS - int "USART3 number of bits" - default 8 - ---help--- - The number of bits. Must be either 7 or 8. - -config USART3_PARITY - int "USART3 parity" - default 0 - ---help--- - 0=no parity, 1=odd parity, 2=even parity - -config USART3_2STOP - bool "USART3 two stop bits" - default n - ---help--- - Two stop bits - config USART3_RXDMA bool "USART3 Rx DMA" default n - depends on STM32_STM32F40XX && ARCH_DMA && STM32_DMA1 + depends on STM32_STM32F40XX && STM32_DMA1 ---help--- In high data rate usage, Rx DMA may eliminate Rx overrun errors -endmenu - -menu "UART4 Configuration" - depends on STM32_UART4 - -config USART4_SERIAL_CONSOLE - bool "UART4 serial console" - default y if !STM32_USART1 && !STM32_USART2 && !STM32_USART3 - ---help--- - Selects the UART4 for the console and ttys0 (default is the USART1). - -config USART4_RXBUFSIZE - int "UART4 Rx buffer size" - default 256 - ---help--- - Characters are buffered as received. This specific the size of the receive - buffer. - -config USART4_TXBUFSIZE - int "UART4 Tx buffer size" - default 256 - ---help--- - Characters are buffered before being sent. This specific the size of the - transmit buffer - -config USART4_BAUD - int "UART4 BAUD" - default 11520 - ---help--- - The configured BAUD of the UART - -config USART4_BITS - int "UART4 number of bits" - default 8 - ---help--- - The number of bits. Must be either 7 or 8. - -config USART4_PARITY - int "UART4 parity" - default 0 - ---help--- - 0=no parity, 1=odd parity, 2=even parity - -config USART4_2STOP - bool "UART4 two stop bits" - default n - ---help--- - Two stop bits - -config USART4_RXDMA - bool "USART4 Rx DMA" +config UART4_RXDMA + bool "UART4 Rx DMA" default n - depends on STM32_STM32F40XX && ARCH_DMA && STM32_DMA1 + depends on STM32_STM32F40XX && STM32_DMA1 ---help--- In high data rate usage, Rx DMA may eliminate Rx overrun errors -endmenu - -menu "UART5 Configuration" - depends on STM32_UART5 - -config USART5_SERIAL_CONSOLE - bool "UART5 serial console" - default y if !STM32_USART1 && !STM32_USART2 && !STM32_USART3 && !STM32_UART4 - ---help--- - Selects the UART5 for the console and ttys0 (default is the USART1). - -config USART5_RXBUFSIZE - int "USART5 Rx buffer size" - default 256 - ---help--- - Characters are buffered as received. This specific the size of the receive - buffer. - -config USART5_TXBUFSIZE - int "UART5 Tx buffer size" - default 256 - ---help--- - Characters are buffered before being sent. This specific the size of the - transmit buffer - -config USART5_BAUD - int "UART5 BAUD" - default 11520 - ---help--- - The configured BAUD of the UART - -config USART5_BITS - int "UART5 number of bits" - default 8 - ---help--- - The number of bits. Must be either 7 or 8. - -config USART5_PARITY - int "UART5 parity" - default 0 - ---help--- - 0=no parity, 1=odd parity, 2=even parity - -config USART5_2STOP - bool "UART5 two stop bits" - default n - ---help--- - Two stop bits - -config USART5_RXDMA - bool "USART5 Rx DMA" +config UART5_RXDMA + bool "UART5 Rx DMA" default n - depends on STM32_STM32F40XX && ARCH_DMA && STM32_DMA1 + depends on STM32_STM32F40XX && STM32_DMA1 ---help--- In high data rate usage, Rx DMA may eliminate Rx overrun errors -endmenu - -menu "USART6 Configuration" - depends on STM32_USART6 - -config USART6_SERIAL_CONSOLE - bool "USART6 serial console" - default y if !STM32_USART1 && !STM32_USART2 && !STM32_USART3 && !STM32_UART4 && !STM32_UART5 - ---help--- - Selects the USART6 for the console and ttys0 (default is the USART6). - -config USART6_RXBUFSIZE - int "USART6 Rx buffer size" - default 256 - ---help--- - Characters are buffered as received. This specific the size of the receive - buffer. - -config USART6_TXBUFSIZE - int "USART6 Tx buffer size" - default 256 - ---help--- - Characters are buffered before being sent. This specific the size of the - transmit buffer - -config USART6_BAUD - int "USART6 BAUD" - default 11520 - ---help--- - The configured BAUD of the UART - -config USART6_BITS - int "USART6 number of bits" - default 8 - ---help--- - The number of bits. Must be either 7 or 8. - -config USART6_PARITY - int "USART6 parity" - default 0 - ---help--- - 0=no parity, 1=odd parity, 2=even parity - -config USART6_2STOP - bool "USART6 two stop bits" - default n - ---help--- - Two stop bits - config USART6_RXDMA bool "USART6 Rx DMA" default n - depends on STM32_STM32F40XX && ARCH_DMA && STM32_DMA2 + depends on STM32_STM32F40XX && STM32_DMA2 ---help--- In high data rate usage, Rx DMA may eliminate Rx overrun errors -endmenu - config SERIAL_TERMIOS bool "Serial driver TERMIOS supported" depends on STM32_USART1 || STM32_USART2 || STM32_USART3 || STM32_UART4 || STM32_UART5 || STM32_USART6 @@ -1819,32 +1635,60 @@ menu "Ethernet MAC configuration" config STM32_PHYADDR int "PHY address" + default 1 ---help--- - The 5-bit address of the PHY on the board + The 5-bit address of the PHY on the board. Default: 1 config STM32_MII bool "Use MII interface" default n + depends on STM32_ETHMAC ---help--- Support Ethernet MII interface. +choice + prompt "MII clock configuration" + default STM32_MII_MCO if STM32_STM32F10XX + default STM32_MII_MCO1 if STM32_STM32F20XX || STM32_STM32F40XX + depends on STM32_MII + +config STM32_MII_MCO + bool "Use MC0 as MII clock" + depends on STM32_STM32F10XX + ---help--- + Use MCO to clock the MII interface. Default: Use MC0 + +config STM32_MII_MCO1 + bool "Use MC01 as MII clock" + depends on (STM32_STM32F20XX || STM32_STM32F40XX) + ---help--- + Use MCO1 to clock the MII interface. Default: Use MC01 + config STM32_MII_MCO2 bool "Use MC02 as MII clock" - default n - depends on STM32_MII + depends on (STM32_STM32F20XX || STM32_STM32F40XX) ---help--- Use MCO2 to clock the MII interface. Default: Use MC01 +config STM32_MII_EXTCLK + bool "External MII clock" + ---help--- + Clocking is provided by external logic. Don't use MCO for MII + clock. Default: Use MC0[1] + +endchoice + config STM32_AUTONEG bool "Use autonegtiation" default y + depends on STM32_ETHMAC ---help--- Use PHY autonegotion to determine speed and mode config STM32_ETHFD bool "Full duplex" default n - depends on !STM32_AUTONEG + depends on STM32_ETHMAC && !STM32_AUTONEG ---help--- If STM32_AUTONEG is not defined, then this may be defined to select full duplex mode. Default: half-duplex @@ -1852,7 +1696,7 @@ config STM32_ETHFD config STM32_ETH100MBPS bool "100 Mbps" default n - depends on !STM32_AUTONEG + depends on STM32_ETHMAC && !STM32_AUTONEG ---help--- If STM32_AUTONEG is not defined, then this may be defined to select 100 MBps speed. Default: 10 Mbps @@ -1896,6 +1740,7 @@ config STM32_PHYSR_FULLDUPLEX config STM32_ETH_PTP bool "Precision Time Protocol (PTP)" default n + depends on STM32_ETHMAC ---help--- Precision Time Protocol (PTP). Not supported but some hooks are indicated with this condition. @@ -1905,11 +1750,39 @@ endmenu config STM32_RMII bool default y if !STM32_MII + depends on STM32_ETHMAC -config STM32_MII_MCO1 - bool - default y if !STM32_MII_MCO2 - depends on STM32_MII +choice + prompt "RMII clock configuration" + default STM32_RMII_MCO if STM32_STM32F10XX + default STM32_RMII_MCO1 if STM32_STM32F20XX || STM32_STM32F40XX + depends on STM32_RMII + +config STM32_RMII_MCO + bool "Use MC0 as RMII clock" + depends on STM32_STM32F10XX + ---help--- + Use MCO to clock the RMII interface. Default: Use MC0 + +config STM32_RMII_MCO1 + bool "Use MC01 as RMII clock" + depends on (STM32_STM32F20XX || STM32_STM32F40XX) + ---help--- + Use MCO1 to clock the RMII interface. Default: Use MC01 + +config STM32_RMII_MCO2 + bool "Use MC02 as RMII clock" + depends on (STM32_STM32F20XX || STM32_STM32F40XX) + ---help--- + Use MCO2 to clock the RMII interface. Default: Use MC01 + +config STM32_RMII_EXTCLK + bool "External RMII clock" + ---help--- + Clocking is provided by external logic. Don't use MCO for RMII + clock. Default: Use MC0[1] + +endchoice menu "USB Host Configuration" diff --git a/nuttx/arch/arm/src/stm32/chip.h b/nuttx/arch/arm/src/stm32/chip.h index cc3ee1f96..3fac597ef 100644 --- a/nuttx/arch/arm/src/stm32/chip.h +++ b/nuttx/arch/arm/src/stm32/chip.h @@ -48,24 +48,51 @@ /* Include the chip pin configuration file */ +/* STM32 F1 Family ******************************************************************/ #if defined(CONFIG_STM32_STM32F10XX) + +/* STM32F100 Value Line */ + # if defined(CONFIG_STM32_VALUELINE) # include "chip/stm32f100_pinmap.h" -# elif defined(CONFIG_ARCH_CHIP_STM32F103ZET6) -# include "chip/stm32f103ze_pinmap.h" + +/* STM32 F103 High Density Family */ +/* STM32F103RC, STM32F103RD, and STM32F103RE are all provided in 64 pin packages and differ + * only in the available FLASH and SRAM. + */ + # elif defined(CONFIG_ARCH_CHIP_STM32F103RET6) # include "chip/stm32f103re_pinmap.h" -# elif defined(CONFIG_ARCH_CHIP_STM32F103VCT6) + +/* STM32F103VC, STM32F103VD, and STM32F103VE are all provided in 100 pin packages and differ + * only in the available FLASH and SRAM. + */ + +# elif defined(CONFIG_ARCH_CHIP_STM32F103VCT6) || defined(CONFIG_ARCH_CHIP_STM32F103VET6) # include "chip/stm32f103vc_pinmap.h" + +/* STM32F103ZC, STM32F103ZD, and STM32F103ZE are all provided in 144 pin packages and differ + * only in the available FLASH and SRAM. + */ +# elif defined(CONFIG_ARCH_CHIP_STM32F103ZET6) +# include "chip/stm32f103ze_pinmap.h" + +/* STM32 F105/F107 Connectivity Line */ + # elif defined(CONFIG_ARCH_CHIP_STM32F105VBT7) # include "chip/stm32f105vb_pinmap.h" + # elif defined(CONFIG_ARCH_CHIP_STM32F107VC) # include "chip/stm32f107vc_pinmap.h" # else # error "Unsupported STM32F10XXX chip" # endif + +/* STM32 F2 Family ******************************************************************/ #elif defined(CONFIG_STM32_STM32F20XX) # include "chip/stm32f20xxx_pinmap.h" + +/* STM32 F4 Family ******************************************************************/ #elif defined(CONFIG_STM32_STM32F40XX) # include "chip/stm32f40xxx_pinmap.h" #else diff --git a/nuttx/arch/arm/src/stm32/chip/stm32_bkp.h b/nuttx/arch/arm/src/stm32/chip/stm32_bkp.h index 1788bdee0..5bda839a8 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32_bkp.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32_bkp.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/chip/stm32_bkp.h * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/chip/stm32_exti.h b/nuttx/arch/arm/src/stm32/chip/stm32_exti.h index 82477db54..5386a260f 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32_exti.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32_exti.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/chip/stm32_exti.h * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/chip/stm32_memorymap.h b/nuttx/arch/arm/src/stm32/chip/stm32_memorymap.h index a53c7441c..36813b565 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32_memorymap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32_memorymap.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/chip/stm32_memorymap.h * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f100_pinmap.h b/nuttx/arch/arm/src/stm32/chip/stm32f100_pinmap.h index 18e8435f7..01d6e1ce0 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f100_pinmap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f100_pinmap.h @@ -4,7 +4,7 @@ * Copyright (C) 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2011 Uros Platise. All rights reserved. * Copyright (C) 2012 Michael Smith. All Rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * Uros Platise <uros.platise@isotel.eu> * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f103re_pinmap.h b/nuttx/arch/arm/src/stm32/chip/stm32f103re_pinmap.h index d0b5a6386..042f57f74 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f103re_pinmap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f103re_pinmap.h @@ -3,7 +3,7 @@ * * Copyright (C) 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2011 Uros Platise. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * Uros Platise <uros.platise@isotel.eu> * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f105vb_pinmap.h b/nuttx/arch/arm/src/stm32/chip/stm32f105vb_pinmap.h index fde8dd935..7a5ec3381 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f105vb_pinmap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f105vb_pinmap.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/chip/stm32f105vb_pinmap.h * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h b/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h index 82f1fa5e7..9bbc21479 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/chip/stm32f107vc_pinmap.h * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -93,41 +93,41 @@ #define GPIO_ETH_MDC (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN1) #define GPIO_ETH_MDIO (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN2) -#define GPIO_ETH_MIICOL (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN3) -#define GPIO_ETH_MIICRSWKUP (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN0) -#define GPIO_ETH_MIIRXCLK (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN1) +#define GPIO_ETH_MII_COL (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN3) +#define GPIO_ETH_MII_CRS (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN0) +#define GPIO_ETH_MII_RX_CLK (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN1) #if defined(CONFIG_STM32_ETH_REMAP) -# define GPIO_ETH_MIIRXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN9) -# define GPIO_ETH_MIIRXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN10) -# define GPIO_ETH_MIIRXD2 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN11) -# define GPIO_ETH_MIIRXD3 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN12) -# define GPIO_ETH_MIIRXDV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN8) +# define GPIO_ETH_MII_RXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN9) +# define GPIO_ETH_MII_RXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN10) +# define GPIO_ETH_MII_RXD2 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN11) +# define GPIO_ETH_MII_RXD3 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN12) +# define GPIO_ETH_MII_RX_DV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN8) #else -# define GPIO_ETH_MIIRXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN4) -# define GPIO_ETH_MIIRXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN5) -# define GPIO_ETH_MIIRXD2 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN0) -# define GPIO_ETH_MIIRXD3 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN1) -# define GPIO_ETH_MIIRXDV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN7) +# define GPIO_ETH_MII_RXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN4) +# define GPIO_ETH_MII_RXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN5) +# define GPIO_ETH_MII_RXD2 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN0) +# define GPIO_ETH_MII_RXD3 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN1) +# define GPIO_ETH_MII_RX_DV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN7) #endif -#define GPIO_ETH_MIIRXER (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN10) -#define GPIO_ETH_MIITXCLK (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN3) -#define GPIO_ETH_MIITXD0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12) -#define GPIO_ETH_MIITXD1 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN13) -#define GPIO_ETH_MIITXD2 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN2) -#define GPIO_ETH_MIITXD3 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8) -#define GPIO_ETH_MIITXEN (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN11) +#define GPIO_ETH_MII_RX_ER (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN10) +#define GPIO_ETH_MII_TX_CLK (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN3) +#define GPIO_ETH_MII_TXD0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12) +#define GPIO_ETH_MII_TXD1 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN13) +#define GPIO_ETH_MII_TXD2 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN2) +#define GPIO_ETH_MII_TXD3 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8) +#define GPIO_ETH_MII_TX_EN (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN11) #define GPIO_ETH_PPS_OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN5) #define GPIO_ETH_RMII_REF_CLK (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN1) #if defined(CONFIG_STM32_ETH_REMAP) -# define GPIO_ETH_RMII_CRS_DV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN8) -# define GPIO_ETH_RMII_RXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN9) -# define GPIO_ETH_RMII_RXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN10) +# define GPIO_ETH_RMII_CRS_DV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN8) +# define GPIO_ETH_RMII_RXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN9) +# define GPIO_ETH_RMII_RXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN10) #else -# define GPIO_ETH_RMII_CRS_DV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN7) -# define GPIO_ETH_RMII_RXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN4) -# define GPIO_ETH_RMII_RXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN5) +# define GPIO_ETH_RMII_CRS_DV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN7) +# define GPIO_ETH_RMII_RXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN4) +# define GPIO_ETH_RMII_RXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN5) #endif #define GPIO_ETH_RMII_TXD0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12) #define GPIO_ETH_RMII_TXD1 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN13) diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_memorymap.h b/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_memorymap.h index 80b38a89f..ed1bc2625 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_memorymap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_memorymap.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/chip/stm32f10xxx_memorymap.h * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -47,6 +47,9 @@ #define STM32_SRAMBB_BASE 0x22000000 #define STM32_PERIPH_BASE 0x40000000 +#define STM32_REGION_MASK 0xf0000000 +#define STM32_IS_SRAM(a) ((((uint32_t)(a)) & STM32_REGION_MASK) == STM32_SRAM_BASE) + /* Register Base Address ************************************************************/ /* APB1 bus */ @@ -123,7 +126,13 @@ /* Flexible SRAM controller (FSMC) */ -#define STM32_FSMC_BASE 0xa0000000 +#define STM32_FSMC_BANK1 0x60000000 /* 0x60000000-0x6fffffff: 256Mb NOR/SRAM */ +#define STM32_FSMC_BANK2 0x70000000 /* 0x70000000-0x7fffffff: 256Mb NAND FLASH */ +#define STM32_FSMC_BANK3 0x80000000 /* 0x80000000-0x8fffffff: 256Mb NAND FLASH */ +#define STM32_FSMC_BANK4 0x90000000 /* 0x90000000-0x9fffffff: 256Mb PC CARD*/ +#define STM32_IS_EXTSRAM(a) ((((uint32_t)(a)) & STM32_REGION_MASK) == STM32_FSMC_BANK1) + +#define STM32_FSMC_BASE 0xa0000000 /* 0xa0000000-0xbfffffff: 512Mb FSMC register block */ /* Other registers -- see armv7-m/nvic.h for standard Cortex-M3 registers in this * address range diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f20xxx_memorymap.h b/nuttx/arch/arm/src/stm32/chip/stm32f20xxx_memorymap.h index 2fa705607..777b9595f 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f20xxx_memorymap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f20xxx_memorymap.h @@ -46,11 +46,19 @@ #define STM32_SRAM_BASE 0x20000000 /* 0x20000000-0x3fffffff: 512Mb sram block */ #define STM32_PERIPH_BASE 0x40000000 /* 0x40000000-0x5fffffff: 512Mb peripheral block */ #define STM32_FSMC_BASE12 0x60000000 /* 0x60000000-0x7fffffff: 512Mb FSMC bank1&2 block */ +# define STM32_FSMC_BANK1 0x60000000 /* 0x60000000-0x6fffffff: 256Mb NOR/SRAM */ +# define STM32_FSMC_BANK2 0x70000000 /* 0x70000000-0x7fffffff: 256Mb NAND FLASH */ #define STM32_FSMC_BASE34 0x80000000 /* 0x80000000-0x8fffffff: 512Mb FSMC bank3&4 block */ +# define STM32_FSMC_BANK3 0x80000000 /* 0x80000000-0x8fffffff: 256Mb NAND FLASH */ +# define STM32_FSMC_BANK4 0x90000000 /* 0x90000000-0x9fffffff: 256Mb PC CARD*/ #define STM32_FSMC_BASE 0xa0000000 /* 0xa0000000-0xbfffffff: 512Mb FSMC register block */ /* 0xc0000000-0xdfffffff: 512Mb (not used) */ #define STM32_CORTEX_BASE 0xe0000000 /* 0xe0000000-0xffffffff: 512Mb Cortex-M4 block */ +#define STM32_REGION_MASK 0xf0000000 +#define STM32_IS_SRAM(a) ((((uint32_t)(a)) & STM32_REGION_MASK) == STM32_SRAM_BASE) +#define STM32_IS_EXTSRAM(a) ((((uint32_t)(a)) & STM32_REGION_MASK) == STM32_FSMC_BANK1) + /* Code Base Addresses **************************************************************/ #define STM32_BOOT_BASE 0x00000000 /* 0x00000000-0x000fffff: Aliased boot memory */ @@ -185,7 +193,7 @@ #define STM32_HASH_BASE 0x50060400 /* 0x50060400-0x500607ff: HASH */ #define STM32_RNG_BASE 0x50060800 /* 0x50060800-0x50060bff: RNG */ -/* Cortex-M4 Base Addresses *********************************************************/ +/* Cortex-M3 Base Addresses *********************************************************/ /* Other registers -- see armv7-m/nvic.h for standard Cortex-M3 registers in this * address range */ diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f20xxx_pinmap.h b/nuttx/arch/arm/src/stm32/chip/stm32f20xxx_pinmap.h index c59cd565a..817e747f7 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f20xxx_pinmap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f20xxx_pinmap.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/chip/stm32f20xxx_pinmap.h * * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_gpio.h b/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_gpio.h index aa7353ed9..3a5f8bc6a 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_gpio.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_gpio.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/chip/stm32f40xxx_gpio.h * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_memorymap.h b/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_memorymap.h index c7f7ff2ec..6b9912121 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_memorymap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_memorymap.h @@ -46,11 +46,19 @@ #define STM32_SRAM_BASE 0x20000000 /* 0x20000000-0x3fffffff: 512Mb sram block */ #define STM32_PERIPH_BASE 0x40000000 /* 0x40000000-0x5fffffff: 512Mb peripheral block */ #define STM32_FSMC_BASE12 0x60000000 /* 0x60000000-0x7fffffff: 512Mb FSMC bank1&2 block */ +# define STM32_FSMC_BANK1 0x60000000 /* 0x60000000-0x6fffffff: 256Mb NOR/SRAM */ +# define STM32_FSMC_BANK2 0x70000000 /* 0x70000000-0x7fffffff: 256Mb NAND FLASH */ #define STM32_FSMC_BASE34 0x80000000 /* 0x80000000-0x8fffffff: 512Mb FSMC bank3&4 block */ +# define STM32_FSMC_BANK3 0x80000000 /* 0x80000000-0x8fffffff: 256Mb NAND FLASH */ +# define STM32_FSMC_BANK4 0x90000000 /* 0x90000000-0x9fffffff: 256Mb PC CARD*/ #define STM32_FSMC_BASE 0xa0000000 /* 0xa0000000-0xbfffffff: 512Mb FSMC register block */ /* 0xc0000000-0xdfffffff: 512Mb (not used) */ #define STM32_CORTEX_BASE 0xe0000000 /* 0xe0000000-0xffffffff: 512Mb Cortex-M4 block */ +#define STM32_REGION_MASK 0xf0000000 +#define STM32_IS_SRAM(a) ((((uint32_t)(a)) & STM32_REGION_MASK) == STM32_SRAM_BASE) +#define STM32_IS_EXTSRAM(a) ((((uint32_t)(a)) & STM32_REGION_MASK) == STM32_FSMC_BANK1) + /* Code Base Addresses **************************************************************/ #define STM32_BOOT_BASE 0x00000000 /* 0x00000000-0x000fffff: Aliased boot memory */ diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_rtc.h b/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_rtc.h index fdfa9b323..a656cfda0 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_rtc.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_rtc.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/chip/stm32f40xxx_rtc.h * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/stm32_allocateheap.c b/nuttx/arch/arm/src/stm32/stm32_allocateheap.c index 4c186a852..4b8707a2b 100644 --- a/nuttx/arch/arm/src/stm32/stm32_allocateheap.c +++ b/nuttx/arch/arm/src/stm32/stm32_allocateheap.c @@ -73,13 +73,14 @@ * * CONFIG_STM32_FSMC=y : Enables the FSMC * CONFIG_STM32_FSMC_SRAM=y : Indicates that SRAM is available via the - * FSMC (as opposed to an LCD or FLASH). + * FSMC (as opposed to an LCD or FLASH). * CONFIG_HEAP2_BASE : The base address of the SRAM in the FSMC - * address space - * CONFIG_HEAP2_END : The end (+1) of the SRAM in the FSMC - * address space + * address space + * CONFIG_HEAP2_SIZE : The size of the SRAM in the FSMC + * address space * CONFIG_MM_REGIONS : Must be set to a large enough value to - * include the FSMC SRAM (as determined by the rules provided below) + * include the FSMC SRAM (as determined by + * the rules provided below) */ #ifndef CONFIG_STM32_FSMC @@ -211,7 +212,7 @@ * should be 3. */ -# ifdef CONFIG_STM32_DMA +# ifdef CONFIG_ARCH_DMA # warning "CCM SRAM is included in the heap AND DMA is enabled" # endif # if CONFIG_MM_REGIONS != 3 @@ -237,7 +238,7 @@ * should be disabled and CONFIG_MM_REGIONS should be 2. */ -# ifdef CONFIG_STM32_DMA +# ifdef CONFIG_ARCH_DMA # warning "CCM SRAM is included in the heap AND DMA is enabled" # endif # if CONFIG_MM_REGIONS < 2 @@ -256,12 +257,12 @@ /* If FSMC SRAM is going to be used as heap, then verify that the starting * address and size of the external SRAM region has been provided in the - * configuration (as CONFIG_HEAP2_BASE and CONFIG_HEAP2_END). + * configuration (as CONFIG_HEAP2_BASE and CONFIG_HEAP2_SIZE). */ #ifdef CONFIG_STM32_FSMC_SRAM -# if !defined(CONFIG_HEAP2_BASE) || !defined(CONFIG_HEAP2_END) -# error "CONFIG_HEAP2_BASE and CONFIG_HEAP2_END must be provided" +# if !defined(CONFIG_HEAP2_BASE) || !defined(CONFIG_HEAP2_SIZE) +# error "CONFIG_HEAP2_BASE and CONFIG_HEAP2_SIZE must be provided" # undef CONFIG_STM32_FSMC_SRAM # endif #endif @@ -317,7 +318,7 @@ void up_addregion(void) /* Add the external FSMC SRAM heap region. */ #ifdef CONFIG_STM32_FSMC_SRAM - mm_addregion((FAR void*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_END - CONFIG_HEAP2_BASE); + mm_addregion((FAR void*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE); #endif } #endif diff --git a/nuttx/arch/arm/src/stm32/stm32_dbgmcu.h b/nuttx/arch/arm/src/stm32/stm32_dbgmcu.h index 080f4bec5..5fb192186 100644 --- a/nuttx/arch/arm/src/stm32/stm32_dbgmcu.h +++ b/nuttx/arch/arm/src/stm32/stm32_dbgmcu.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/stm32_dbgmcu.h * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.c b/nuttx/arch/arm/src/stm32/stm32_eth.c index 57d4cc2d3..59f3def7f 100644 --- a/nuttx/arch/arm/src/stm32/stm32_eth.c +++ b/nuttx/arch/arm/src/stm32/stm32_eth.c @@ -102,11 +102,32 @@ #endif #ifdef CONFIG_STM32_MII -# if !defined(CONFIG_STM32_MII_MCO1) && !defined(CONFIG_STM32_MII_MCO2) -# warning "Neither CONFIG_STM32_MII_MCO1 nor CONFIG_STM32_MII_MCO2 defined" +# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if !defined(CONFIG_STM32_MII_MCO1) && !defined(CONFIG_STM32_MII_MCO2) && !defined(CONFIG_STM32_MII_EXTCLK) +# warning "Neither CONFIG_STM32_MII_MCO1, CONFIG_STM32_MII_MCO2, nor CONFIG_STM32_MII_EXTCLK defined" +# endif +# if defined(CONFIG_STM32_MII_MCO1) && defined(CONFIG_STM32_MII_MCO2) +# error "Both CONFIG_STM32_MII_MCO1 and CONFIG_STM32_MII_MCO2 defined" +# endif +# elif defined(CONFIG_STM32_CONNECTIVITYLINE) +# if !defined(CONFIG_STM32_MII_MCO) && !defined(CONFIG_STM32_MII_EXTCLK) +# warning "Neither CONFIG_STM32_MII_MCO nor CONFIG_STM32_MII_EXTCLK defined" +# endif # endif -# if defined(CONFIG_STM32_MII_MCO1) && defined(CONFIG_STM32_MII_MCO2) -# error "Both CONFIG_STM32_MII_MCO1 and CONFIG_STM32_MII_MCO2 defined" +#endif + +#ifdef CONFIG_STM32_RMII +# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if !defined(CONFIG_STM32_RMII_MCO1) && !defined(CONFIG_STM32_RMII_MCO2) && !defined(CONFIG_STM32_RMII_EXTCLK) +# warning "Neither CONFIG_STM32_RMII_MCO1, CONFIG_STM32_RMII_MCO2, nor CONFIG_STM32_RMII_EXTCLK defined" +# endif +# if defined(CONFIG_STM32_RMII_MCO1) && defined(CONFIG_STM32_RMII_MCO2) +# error "Both CONFIG_STM32_RMII_MCO1 and CONFIG_STM32_RMII_MCO2 defined" +# endif +# elif defined(CONFIG_STM32_CONNECTIVITYLINE) +# if !defined(CONFIG_STM32_RMII_MCO) && !defined(CONFIG_STM32_RMII_EXTCLK) +# warning "Neither CONFIG_STM32_RMII_MCO nor CONFIG_STM32_RMII_EXTCLK defined" +# endif # endif #endif @@ -608,6 +629,12 @@ static int stm32_phyinit(FAR struct stm32_ethmac_s *priv); /* MAC/DMA Initialization */ +#ifdef CONFIG_STM32_MII +static inline void stm32_selectmii(void); +#endif +#ifdef CONFIG_STM32_RMII +static inline void stm32_selectrmii(void); +#endif static inline void stm32_ethgpioconfig(FAR struct stm32_ethmac_s *priv); static void stm32_ethreset(FAR struct stm32_ethmac_s *priv); static int stm32_macconfig(FAR struct stm32_ethmac_s *priv); @@ -2570,6 +2597,66 @@ static int stm32_phyinit(FAR struct stm32_ethmac_s *priv) return OK; } +/************************************************************************************ + * Name: stm32_selectmii + * + * Description: + * Selects the MII inteface. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ************************************************************************************/ + +#ifdef CONFIG_STM32_MII +static inline void stm32_selectmii(void) +{ + uint32_t regval; + +#ifdef CONFIG_STM32_CONNECTIVITYLINE + regval = getreg32(STM32_AFIO_MAPR); + regval &= ~AFIO_MAPR_MII_RMII_SEL; + putreg32(regval, STM32_AFIO_MAPR); +#else + regval = getreg32(STM32_SYSCFG_PMC); + regval &= ~SYSCFG_PMC_MII_RMII_SEL; + putreg32(regval, STM32_SYSCFG_PMC); +#endif +} +#endif + +/************************************************************************************ + * Name: stm32_selectrmii + * + * Description: + * Selects the RMII inteface. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ************************************************************************************/ + +static inline void stm32_selectrmii(void) +{ + uint32_t regval; + +#ifdef CONFIG_STM32_CONNECTIVITYLINE + regval = getreg32(STM32_AFIO_MAPR); + regval |= AFIO_MAPR_MII_RMII_SEL; + putreg32(regval, STM32_AFIO_MAPR); +#else + regval = getreg32(STM32_SYSCFG_PMC); + regval |= SYSCFG_PMC_MII_RMII_SEL; + putreg32(regval, STM32_SYSCFG_PMC); +#endif +} + /**************************************************************************** * Function: stm32_ethgpioconfig * @@ -2605,7 +2692,7 @@ static inline void stm32_ethgpioconfig(FAR struct stm32_ethmac_s *priv) stm32_selectmii(); - /* Provide clocking via MCO1 or MCO2: + /* Provide clocking via MCO, MCO1 or MCO2: * * "MCO1 (microcontroller clock output), used to output HSI, LSE, HSE or PLL * clock (through a configurable prescaler) on PA8 pin." @@ -2614,7 +2701,7 @@ static inline void stm32_ethgpioconfig(FAR struct stm32_ethmac_s *priv) * PLLI2S clock (through a configurable prescaler) on PC9 pin." */ -# if defined(CONFIG_STM32_MII_MCO1) +# if defined(CONFIG_STM32_MII_MCO1) /* Configure MC01 to drive the PHY. Board logic must provide MC01 clocking * info. */ @@ -2622,14 +2709,20 @@ static inline void stm32_ethgpioconfig(FAR struct stm32_ethmac_s *priv) stm32_configgpio(GPIO_MCO1); stm32_mco1config(BOARD_CFGR_MC01_SOURCE, BOARD_CFGR_MC01_DIVIDER); -# elif defined(CONFIG_STM32_MII_MCO2) +# elif defined(CONFIG_STM32_MII_MCO2) /* Configure MC02 to drive the PHY. Board logic must provide MC02 clocking * info. */ stm32_configgpio(GPIO_MCO2); stm32_mco2config(BOARD_CFGR_MC02_SOURCE, BOARD_CFGR_MC02_DIVIDER); -# endif + +# elif defined(CONFIG_STM32_MII_MCO) + /* Setup MCO pin for alternative usage */ + + stm32_configgpio(GPIO_MCO); + stm32_mcoconfig(BOARD_CFGR_MCO_SOURCE); +# endif /* MII interface pins (17): * @@ -2657,16 +2750,41 @@ static inline void stm32_ethgpioconfig(FAR struct stm32_ethmac_s *priv) #elif defined(CONFIG_STM32_RMII) + /* Select the RMII interface */ + + stm32_selectrmii(); + + /* Provide clocking via MCO, MCO1 or MCO2: + * + * "MCO1 (microcontroller clock output), used to output HSI, LSE, HSE or PLL + * clock (through a configurable prescaler) on PA8 pin." + * + * "MCO2 (microcontroller clock output), used to output HSE, PLL, SYSCLK or + * PLLI2S clock (through a configurable prescaler) on PC9 pin." + */ + +# if defined(CONFIG_STM32_RMII_MCO1) + /* Configure MC01 to drive the PHY. Board logic must provide MC01 clocking + * info. + */ + + stm32_configgpio(GPIO_MCO1); + stm32_mco1config(BOARD_CFGR_MC01_SOURCE, BOARD_CFGR_MC01_DIVIDER); + +# elif defined(CONFIG_STM32_RMII_MCO2) + /* Configure MC02 to drive the PHY. Board logic must provide MC02 clocking + * info. + */ + + stm32_configgpio(GPIO_MCO2); + stm32_mco2config(BOARD_CFGR_MC02_SOURCE, BOARD_CFGR_MC02_DIVIDER); + +# elif defined(CONFIG_STM32_RMII_MCO) /* Setup MCO pin for alternative usage */ -#if defined(CONFIG_STM32_RMII_MCO) stm32_configgpio(GPIO_MCO); stm32_mcoconfig(BOARD_CFGR_MCO_SOURCE); -#endif - - /* Select the RMII interface */ - - stm32_selectrmii(); +# endif /* RMII interface pins (7): * diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.h b/nuttx/arch/arm/src/stm32/stm32_eth.h index 188dc10d3..f0c14b5b1 100644 --- a/nuttx/arch/arm/src/stm32/stm32_eth.h +++ b/nuttx/arch/arm/src/stm32/stm32_eth.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/stm32_eth.h * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/stm32_gpio.h b/nuttx/arch/arm/src/stm32/stm32_gpio.h index 34623c525..fde564cbb 100644 --- a/nuttx/arch/arm/src/stm32/stm32_gpio.h +++ b/nuttx/arch/arm/src/stm32/stm32_gpio.h @@ -3,7 +3,7 @@ * * Copyright (C) 2009, 2011-2012 Gregory Nutt. All rights reserved. * Copyright (C) 2011 Uros Platise. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * Uros Platise <uros.platise@isotel.eu> * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/arch/arm/src/stm32/stm32_i2c.h b/nuttx/arch/arm/src/stm32/stm32_i2c.h index 23a06bc05..b914c4247 100644 --- a/nuttx/arch/arm/src/stm32/stm32_i2c.h +++ b/nuttx/arch/arm/src/stm32/stm32_i2c.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/stm32_i2c.h * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/stm32_lowputc.c b/nuttx/arch/arm/src/stm32/stm32_lowputc.c index 14f4efae4..7f7205672 100644 --- a/nuttx/arch/arm/src/stm32/stm32_lowputc.c +++ b/nuttx/arch/arm/src/stm32/stm32_lowputc.c @@ -85,22 +85,22 @@ # define STM32_CONSOLE_2STOP CONFIG_USART3_2STOP # define STM32_CONSOLE_TX GPIO_USART3_TX # define STM32_CONSOLE_RX GPIO_USART3_RX -#elif defined(CONFIG_USART4_SERIAL_CONSOLE) +#elif defined(CONFIG_UART4_SERIAL_CONSOLE) # define STM32_CONSOLE_BASE STM32_UART4_BASE # define STM32_APBCLOCK STM32_PCLK1_FREQUENCY -# define STM32_CONSOLE_BAUD CONFIG_USART4_BAUD -# define STM32_CONSOLE_BITS CONFIG_USART4_BITS -# define STM32_CONSOLE_PARITY CONFIG_USART4_PARITY -# define STM32_CONSOLE_2STOP CONFIG_USART4_2STOP +# define STM32_CONSOLE_BAUD CONFIG_UART4_BAUD +# define STM32_CONSOLE_BITS CONFIG_UART4_BITS +# define STM32_CONSOLE_PARITY CONFIG_UART4_PARITY +# define STM32_CONSOLE_2STOP CONFIG_UART4_2STOP # define STM32_CONSOLE_TX GPIO_UART4_TX # define STM32_CONSOLE_RX GPIO_UART4_RX -#elif defined(CONFIG_USART5_SERIAL_CONSOLE) +#elif defined(CONFIG_UART5_SERIAL_CONSOLE) # define STM32_CONSOLE_BASE STM32_UART5_BASE # define STM32_APBCLOCK STM32_PCLK1_FREQUENCY -# define STM32_CONSOLE_BAUD CONFIG_USART5_BAUD -# define STM32_CONSOLE_BITS CONFIG_USART5_BITS -# define STM32_CONSOLE_PARITY CONFIG_USART5_PARITY -# define STM32_CONSOLE_2STOP CONFIG_USART5_2STOP +# define STM32_CONSOLE_BAUD CONFIG_UART5_BAUD +# define STM32_CONSOLE_BITS CONFIG_UART5_BITS +# define STM32_CONSOLE_PARITY CONFIG_UART5_PARITY +# define STM32_CONSOLE_2STOP CONFIG_UART5_2STOP # define STM32_CONSOLE_TX GPIO_UART5_TX # define STM32_CONSOLE_RX GPIO_UART5_RX #elif defined(CONFIG_USART6_SERIAL_CONSOLE) diff --git a/nuttx/arch/arm/src/stm32/stm32_lowputc.h b/nuttx/arch/arm/src/stm32/stm32_lowputc.h index edcc78d8f..659de7b1c 100644 --- a/nuttx/arch/arm/src/stm32/stm32_lowputc.h +++ b/nuttx/arch/arm/src/stm32/stm32_lowputc.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/stm32_lowputc.h * * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c index 81c919cdf..461d500ad 100644 --- a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c +++ b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c @@ -607,7 +607,7 @@ static void stm32_ep_freereq(FAR struct usbdev_ep_s *ep, /* Endpoint buffer management */ -#ifdef CONFIG_ARCH_USBDEV_DMA +#ifdef CONFIG_USBDEV_DMA static void *stm32_ep_allocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes); static void stm32_ep_freebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf); #endif @@ -669,7 +669,7 @@ static const struct usbdev_epops_s g_epops = .disable = stm32_ep_disable, .allocreq = stm32_ep_allocreq, .freereq = stm32_ep_freereq, -#ifdef CONFIG_ARCH_USBDEV_DMA +#ifdef CONFIG_USBDEV_DMA .allocbuffer = stm32_ep_allocbuffer, .freebuffer = stm32_ep_freebuffer, #endif @@ -4070,11 +4070,16 @@ static void stm32_ep_freereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s * *******************************************************************************/ -#ifdef CONFIG_ARCH_USBDEV_DMA +#ifdef CONFIG_USBDEV_DMA static void *stm32_ep_allocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes) { usbtrace(TRACE_EPALLOCBUFFER, privep->epphy); - return malloc(bytes) + +#ifdef CONFIG_USBDEV_DMAMEMORY + return usbdev_dma_alloc(bytes); +#else + return malloc(bytes); +#endif } #endif @@ -4086,11 +4091,16 @@ static void *stm32_ep_allocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes) * *******************************************************************************/ -#ifdef CONFIG_STM32_USBDEV_DMA +#ifdef CONFIG_USBDEV_DMA static void stm32_ep_freebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf) { usbtrace(TRACE_EPFREEBUFFER, privep->epphy); + +#ifdef CONFIG_USBDEV_DMAMEMORY + usbdev_dma_free(buf); +#else free(buf); +#endif } #endif diff --git a/nuttx/arch/arm/src/stm32/stm32_pwr.c b/nuttx/arch/arm/src/stm32/stm32_pwr.c index bada048e3..14149922f 100644 --- a/nuttx/arch/arm/src/stm32/stm32_pwr.c +++ b/nuttx/arch/arm/src/stm32/stm32_pwr.c @@ -95,4 +95,4 @@ void stm32_pwr_enablebkp(void) stm32_pwr_modifyreg(STM32_PWR_CR_OFFSET, 0, PWR_CR_DBP); } -#endif // defined(CONFIG_STM32_PWR) +#endif /* CONFIG_STM32_PWR */ diff --git a/nuttx/arch/arm/src/stm32/stm32_pwr.h b/nuttx/arch/arm/src/stm32/stm32_pwr.h index 56aee49b6..7a2751677 100644 --- a/nuttx/arch/arm/src/stm32/stm32_pwr.h +++ b/nuttx/arch/arm/src/stm32/stm32_pwr.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/stm32_pwr.h * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/stm32_sdio.c b/nuttx/arch/arm/src/stm32/stm32_sdio.c index 57d5f80d9..a8bcae307 100644 --- a/nuttx/arch/arm/src/stm32/stm32_sdio.c +++ b/nuttx/arch/arm/src/stm32/stm32_sdio.c @@ -2512,6 +2512,7 @@ static int stm32_dmarecvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer, stm32_sample(priv, SAMPLENDX_AFTER_SETUP); ret = OK; } + return ret; } #endif @@ -2587,6 +2588,7 @@ static int stm32_dmasendsetup(FAR struct sdio_dev_s *dev, ret = OK; } + return ret; } #endif @@ -2660,7 +2662,7 @@ static void stm32_callback(void *arg) /* Yes.. queue it */ fvdbg("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - (void)work_queue(&priv->cbwork, (worker_t)priv->callback, priv->cbarg, 0); + (void)work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, priv->cbarg, 0); } else { diff --git a/nuttx/arch/arm/src/stm32/stm32_serial.c b/nuttx/arch/arm/src/stm32/stm32_serial.c index 80cf5d61e..ff18d208b 100644 --- a/nuttx/arch/arm/src/stm32/stm32_serial.c +++ b/nuttx/arch/arm/src/stm32/stm32_serial.c @@ -90,7 +90,7 @@ # endif # if defined(CONFIG_USART2_RXDMA) || defined(CONFIG_USART3_RXDMA) || \ - defined(CONFIG_USART4_RXDMA) || defined(CONFIG_USART5_RXDMA) + defined(CONFIG_UART4_RXDMA) || defined(CONFIG_UART5_RXDMA) # ifndef CONFIG_STM32_DMA1 # error STM32 USART2/3/4/5 receive DMA requires CONFIG_STM32_DMA1 # endif @@ -113,11 +113,11 @@ # error "USART3 DMA channel not defined (DMAMAP_USART3_RX)" # endif -# if defined(CONFIG_USART4_RXDMA) && !defined(DMAMAP_UART4_RX) +# if defined(CONFIG_UART4_RXDMA) && !defined(DMAMAP_UART4_RX) # error "UART4 DMA channel not defined (DMAMAP_UART4_RX)" # endif -# if defined(CONFIG_USART5_RXDMA) && !defined(DMAMAP_UART5_RX) +# if defined(CONFIG_UART5_RXDMA) && !defined(DMAMAP_UART5_RX) # error "UART5 DMA channel not defined (DMAMAP_UART5_RX)" # endif @@ -338,17 +338,17 @@ static char g_usart3rxfifo[RXDMA_BUFFER_SIZE]; #endif #ifdef CONFIG_STM32_UART4 -static char g_uart4rxbuffer[CONFIG_USART4_RXBUFSIZE]; -static char g_uart4txbuffer[CONFIG_USART4_TXBUFSIZE]; -# ifdef CONFIG_USART4_RXDMA +static char g_uart4rxbuffer[CONFIG_UART4_RXBUFSIZE]; +static char g_uart4txbuffer[CONFIG_UART4_TXBUFSIZE]; +# ifdef CONFIG_UART4_RXDMA static char g_uart4rxfifo[RXDMA_BUFFER_SIZE]; # endif #endif #ifdef CONFIG_STM32_UART5 -static char g_uart5rxbuffer[CONFIG_USART5_RXBUFSIZE]; -static char g_uart5txbuffer[CONFIG_USART5_TXBUFSIZE]; -# ifdef CONFIG_USART5_RXDMA +static char g_uart5rxbuffer[CONFIG_UART5_RXBUFSIZE]; +static char g_uart5txbuffer[CONFIG_UART5_TXBUFSIZE]; +# ifdef CONFIG_UART5_RXDMA static char g_uart5rxfifo[RXDMA_BUFFER_SIZE]; # endif #endif @@ -526,15 +526,15 @@ static struct up_dev_s g_uart4priv = #endif .recv = { - .size = CONFIG_USART4_RXBUFSIZE, + .size = CONFIG_UART4_RXBUFSIZE, .buffer = g_uart4rxbuffer, }, .xmit = { - .size = CONFIG_USART4_TXBUFSIZE, + .size = CONFIG_UART4_TXBUFSIZE, .buffer = g_uart4txbuffer, }, -#ifdef CONFIG_USART4_RXDMA +#ifdef CONFIG_UART4_RXDMA .ops = &g_uart_dma_ops, #else .ops = &g_uart_ops, @@ -543,21 +543,21 @@ static struct up_dev_s g_uart4priv = }, .irq = STM32_IRQ_UART4, - .parity = CONFIG_USART4_PARITY, - .bits = CONFIG_USART4_BITS, - .stopbits2 = CONFIG_USART4_2STOP, - .baud = CONFIG_USART4_BAUD, + .parity = CONFIG_UART4_PARITY, + .bits = CONFIG_UART4_BITS, + .stopbits2 = CONFIG_UART4_2STOP, + .baud = CONFIG_UART4_BAUD, .apbclock = STM32_PCLK1_FREQUENCY, .usartbase = STM32_UART4_BASE, .tx_gpio = GPIO_UART4_TX, .rx_gpio = GPIO_UART4_RX, -#ifdef GPIO_USART4_CTS +#ifdef GPIO_UART4_CTS .cts_gpio = GPIO_UART4_CTS, #endif -#ifdef GPIO_USART4_RTS +#ifdef GPIO_UART4_RTS .rts_gpio = GPIO_UART4_RTS, #endif -#ifdef CONFIG_USART4_RXDMA +#ifdef CONFIG_UART4_RXDMA .rxdma_channel = DMAMAP_UART4_RX, .rxfifo = g_uart4rxfifo, #endif @@ -577,15 +577,15 @@ static struct up_dev_s g_uart5priv = #endif .recv = { - .size = CONFIG_USART5_RXBUFSIZE, + .size = CONFIG_UART5_RXBUFSIZE, .buffer = g_uart5rxbuffer, }, .xmit = { - .size = CONFIG_USART5_TXBUFSIZE, + .size = CONFIG_UART5_TXBUFSIZE, .buffer = g_uart5txbuffer, }, -#ifdef CONFIG_USART5_RXDMA +#ifdef CONFIG_UART5_RXDMA .ops = &g_uart_dma_ops, #else .ops = &g_uart_ops, @@ -594,21 +594,21 @@ static struct up_dev_s g_uart5priv = }, .irq = STM32_IRQ_UART5, - .parity = CONFIG_USART5_PARITY, - .bits = CONFIG_USART5_BITS, - .stopbits2 = CONFIG_USART5_2STOP, - .baud = CONFIG_USART5_BAUD, + .parity = CONFIG_UART5_PARITY, + .bits = CONFIG_UART5_BITS, + .stopbits2 = CONFIG_UART5_2STOP, + .baud = CONFIG_UART5_BAUD, .apbclock = STM32_PCLK1_FREQUENCY, .usartbase = STM32_UART5_BASE, .tx_gpio = GPIO_UART5_TX, .rx_gpio = GPIO_UART5_RX, -#ifdef GPIO_USART5_CTS +#ifdef GPIO_UART5_CTS .cts_gpio = GPIO_UART5_CTS, #endif -#ifdef GPIO_USART5_RTS +#ifdef GPIO_UART5_RTS .rts_gpio = GPIO_UART5_RTS, #endif -#ifdef CONFIG_USART5_RXDMA +#ifdef CONFIG_UART5_RXDMA .rxdma_channel = DMAMAP_UART5_RX, .rxfifo = g_uart5rxfifo, #endif @@ -1840,13 +1840,13 @@ void up_serialinit(void) (void)uart_register("/dev/console", &uart_devs[CONSOLE_UART - 1]->dev); (void)uart_register("/dev/ttyS0", &uart_devs[CONSOLE_UART - 1]->dev); - /* If we need to re-initialise the console (e.g. to enable DMA) do that here. */ + /* If we need to re-initialise the console to enable DMA do that here. */ -# if CONFIG_SERIAL_CONSOLE_REINIT - uart_devs[CONSOLE_UART - 1]->dev.ops->setup(&uart_devs[CONSOLE_UART - 1]->dev); +# ifdef SERIAL_HAVE_CONSOLE_DMA + up_dma_setup(&uart_devs[CONSOLE_UART - 1]->dev); # endif -#endif +#endif /* CONSOLE_UART > 0 */ /* Register all remaining USARTs */ @@ -1909,14 +1909,14 @@ void stm32_serial_dma_poll(void) } #endif -#ifdef CONFIG_USART4_RXDMA +#ifdef CONFIG_UART4_RXDMA if (g_uart4priv.rxdma != NULL) { up_dma_rxcallback(g_uart4priv.rxdma, 0, &g_uart4priv); } #endif -#ifdef CONFIG_USART5_RXDMA +#ifdef CONFIG_UART5_RXDMA if (g_uart5priv.rxdma != NULL) { up_dma_rxcallback(g_uart5priv.rxdma, 0, &g_uart5priv); diff --git a/nuttx/arch/arm/src/stm32/stm32_spi.h b/nuttx/arch/arm/src/stm32/stm32_spi.h index 268589bf3..6030ddfdd 100644 --- a/nuttx/arch/arm/src/stm32/stm32_spi.h +++ b/nuttx/arch/arm/src/stm32/stm32_spi.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/stm32_spi.h * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/stm32_syscfg.h b/nuttx/arch/arm/src/stm32/stm32_syscfg.h index 8a57a2c58..d1487da40 100644 --- a/nuttx/arch/arm/src/stm32/stm32_syscfg.h +++ b/nuttx/arch/arm/src/stm32/stm32_syscfg.h @@ -45,60 +45,10 @@ #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) # include "chip/stm32_syscfg.h" +#endif /* CONFIG_STM32_STM32F20XX || CONFIG_STM32_STM32F40XX */ /**************************************************************************************************** * Pre-processor Definitions ****************************************************************************************************/ -/**************************************************************************************************** - * Inline Functions - ****************************************************************************************************/ - -/************************************************************************************ - * Name: stm32_selectmii - * - * Description: - * Selects the MII inteface. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ************************************************************************************/ - -static inline void stm32_selectmii(void) -{ - uint32_t regval; - - regval = getreg32(STM32_SYSCFG_PMC); - regval &= ~SYSCFG_PMC_MII_RMII_SEL; - putreg32(regval, STM32_SYSCFG_PMC); -} - -/************************************************************************************ - * Name: stm32_selectrmii - * - * Description: - * Selects the RMII inteface. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ************************************************************************************/ - -static inline void stm32_selectrmii(void) -{ - uint32_t regval; - - regval = getreg32(STM32_SYSCFG_PMC); - regval |= SYSCFG_PMC_MII_RMII_SEL; - putreg32(regval, STM32_SYSCFG_PMC); -} - -#endif /* CONFIG_STM32_STM32F20XX || CONFIG_STM32_STM32F40XX */ #endif /* __ARCH_ARM_SRC_STM32_STM32_SYSCFG_H */ diff --git a/nuttx/arch/arm/src/stm32/stm32_timerisr.c b/nuttx/arch/arm/src/stm32/stm32_timerisr.c index 93cca02ac..ff6499415 100644 --- a/nuttx/arch/arm/src/stm32/stm32_timerisr.c +++ b/nuttx/arch/arm/src/stm32/stm32_timerisr.c @@ -2,7 +2,7 @@ * arch/arm/src/stm32/stm32_timerisr.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/stm32_uart.h b/nuttx/arch/arm/src/stm32/stm32_uart.h index 42fe9e346..a70923cbf 100644 --- a/nuttx/arch/arm/src/stm32/stm32_uart.h +++ b/nuttx/arch/arm/src/stm32/stm32_uart.h @@ -84,40 +84,40 @@ #if defined(CONFIG_USART1_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART1) # undef CONFIG_USART2_SERIAL_CONSOLE # undef CONFIG_USART3_SERIAL_CONSOLE -# undef CONFIG_USART4_SERIAL_CONSOLE -# undef CONFIG_USART5_SERIAL_CONSOLE +# undef CONFIG_UART4_SERIAL_CONSOLE +# undef CONFIG_UART5_SERIAL_CONSOLE # undef CONFIG_USART6_SERIAL_CONSOLE # define CONSOLE_UART 1 # define HAVE_CONSOLE 1 #elif defined(CONFIG_USART2_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART2) # undef CONFIG_USART1_SERIAL_CONSOLE # undef CONFIG_USART3_SERIAL_CONSOLE -# undef CONFIG_USART4_SERIAL_CONSOLE -# undef CONFIG_USART5_SERIAL_CONSOLE +# undef CONFIG_UART4_SERIAL_CONSOLE +# undef CONFIG_UART5_SERIAL_CONSOLE # undef CONFIG_USART6_SERIAL_CONSOLE # define CONSOLE_UART 2 # define HAVE_CONSOLE 1 #elif defined(CONFIG_USART3_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART3) # undef CONFIG_USART1_SERIAL_CONSOLE # undef CONFIG_USART2_SERIAL_CONSOLE -# undef CONFIG_USART4_SERIAL_CONSOLE -# undef CONFIG_USART5_SERIAL_CONSOLE +# undef CONFIG_UART4_SERIAL_CONSOLE +# undef CONFIG_UART5_SERIAL_CONSOLE # undef CONFIG_USART6_SERIAL_CONSOLE # define CONSOLE_UART 3 # define HAVE_CONSOLE 1 -#elif defined(CONFIG_USART4_SERIAL_CONSOLE) && defined(CONFIG_STM32_UART4) +#elif defined(CONFIG_UART4_SERIAL_CONSOLE) && defined(CONFIG_STM32_UART4) # undef CONFIG_USART1_SERIAL_CONSOLE # undef CONFIG_USART2_SERIAL_CONSOLE # undef CONFIG_USART3_SERIAL_CONSOLE -# undef CONFIG_USART5_SERIAL_CONSOLE +# undef CONFIG_UART5_SERIAL_CONSOLE # undef CONFIG_USART6_SERIAL_CONSOLE # define CONSOLE_UART 4 # define HAVE_CONSOLE 1 -#elif defined(CONFIG_USART5_SERIAL_CONSOLE) && defined(CONFIG_STM32_UART5) +#elif defined(CONFIG_UART5_SERIAL_CONSOLE) && defined(CONFIG_STM32_UART5) # undef CONFIG_USART1_SERIAL_CONSOLE # undef CONFIG_USART2_SERIAL_CONSOLE # undef CONFIG_USART3_SERIAL_CONSOLE -# undef CONFIG_USART4_SERIAL_CONSOLE +# undef CONFIG_UART4_SERIAL_CONSOLE # undef CONFIG_USART6_SERIAL_CONSOLE # define CONSOLE_UART 5 # define HAVE_CONSOLE 1 @@ -125,16 +125,16 @@ # undef CONFIG_USART1_SERIAL_CONSOLE # undef CONFIG_USART2_SERIAL_CONSOLE # undef CONFIG_USART3_SERIAL_CONSOLE -# undef CONFIG_USART4_SERIAL_CONSOLE -# undef CONFIG_USART5_SERIAL_CONSOLE +# undef CONFIG_UART4_SERIAL_CONSOLE +# undef CONFIG_UART5_SERIAL_CONSOLE # define CONSOLE_UART 6 # define HAVE_CONSOLE 1 #else # undef CONFIG_USART1_SERIAL_CONSOLE # undef CONFIG_USART2_SERIAL_CONSOLE # undef CONFIG_USART3_SERIAL_CONSOLE -# undef CONFIG_USART4_SERIAL_CONSOLE -# undef CONFIG_USART5_SERIAL_CONSOLE +# undef CONFIG_UART4_SERIAL_CONSOLE +# undef CONFIG_UART5_SERIAL_CONSOLE # undef CONFIG_USART6_SERIAL_CONSOLE # define CONSOLE_UART 0 # undef HAVE_CONSOLE @@ -149,8 +149,8 @@ # undef CONFIG_USART1_RXDMA # undef CONFIG_USART2_RXDMA # undef CONFIG_USART3_RXDMA -# undef CONFIG_USART4_RXDMA -# undef CONFIG_USART5_RXDMA +# undef CONFIG_UART4_RXDMA +# undef CONFIG_UART5_RXDMA # undef CONFIG_USART6_RXDMA #endif @@ -169,11 +169,11 @@ #endif #ifndef CONFIG_STM32_UART4 -# undef CONFIG_USART4_RXDMA +# undef CONFIG_UART4_RXDMA #endif #ifndef CONFIG_STM32_UART5 -# undef CONFIG_USART5_RXDMA +# undef CONFIG_UART5_RXDMA #endif #ifndef CONFIG_STM32_USART6 @@ -184,11 +184,28 @@ #undef SERIAL_HAVE_DMA #if defined(CONFIG_USART1_RXDMA) || defined(CONFIG_USART2_RXDMA) || \ - defined(CONFIG_USART3_RXDMA) || defined(CONFIG_USART4_RXDMA) || \ - defined(CONFIG_USART5_RXDMA) || defined(CONFIG_USART6_RXDMA) + defined(CONFIG_USART3_RXDMA) || defined(CONFIG_UART4_RXDMA) || \ + defined(CONFIG_UART5_RXDMA) || defined(CONFIG_USART6_RXDMA) # define SERIAL_HAVE_DMA 1 #endif +/* Is DMA used on the console UART? */ + +#undef SERIAL_HAVE_CONSOLE_DMA +#if defined(CONFIG_USART1_SERIAL_CONSOLE) && defined(CONFIG_USART1_RXDMA) +# define SERIAL_HAVE_CONSOLE_DMA 1 +#elif defined(CONFIG_USART2_SERIAL_CONSOLE) && defined(CONFIG_USART2_RXDMA) +# define SERIAL_HAVE_CONSOLE_DMA 1 +#elif defined(CONFIG_USART3_SERIAL_CONSOLE) && defined(CONFIG_USART3_RXDMA) +# define SERIAL_HAVE_CONSOLE_DMA 1 +#elif defined(CONFIG_UART4_SERIAL_CONSOLE) && defined(CONFIG_UART4_RXDMA) +# define SERIAL_HAVE_CONSOLE_DMA 1 +#elif defined(CONFIG_UART5_SERIAL_CONSOLE) && defined(CONFIG_UART5_RXDMA) +# define SERIAL_HAVE_CONSOLE_DMA 1 +#elif defined(CONFIG_USART6_SERIAL_CONSOLE) && defined(CONFIG_USART6_RXDMA) +# define SERIAL_HAVE_CONSOLE_DMA 1 +#endif + /* Is DMA used on all (enabled) USARTs */ #define SERIAL_HAVE_ONLY_DMA 1 @@ -198,9 +215,9 @@ # undef SERIAL_HAVE_ONLY_DMA #elif defined(CONFIG_STM32_USART3) && !defined(CONFIG_USART3_RXDMA) # undef SERIAL_HAVE_ONLY_DMA -#elif defined(CONFIG_STM32_UART4) && !defined(CONFIG_USART4_RXDMA) +#elif defined(CONFIG_STM32_UART4) && !defined(CONFIG_UART4_RXDMA) # undef SERIAL_HAVE_ONLY_DMA -#elif defined(CONFIG_STM32_UART5) && !defined(CONFIG_USART5_RXDMA) +#elif defined(CONFIG_STM32_UART5) && !defined(CONFIG_UART5_RXDMA) # undef SERIAL_HAVE_ONLY_DMA #elif defined(CONFIG_STM32_USART6) && !defined(CONFIG_USART6_RXDMA) # undef SERIAL_HAVE_ONLY_DMA diff --git a/nuttx/arch/arm/src/stm32/stm32_usbdev.h b/nuttx/arch/arm/src/stm32/stm32_usbdev.h index a1af471b2..587107dc8 100644 --- a/nuttx/arch/arm/src/stm32/stm32_usbdev.h +++ b/nuttx/arch/arm/src/stm32/stm32_usbdev.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/stm32_usbdev.h * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/stm32_wdg.h b/nuttx/arch/arm/src/stm32/stm32_wdg.h index 38af388f9..fbb8128b5 100644 --- a/nuttx/arch/arm/src/stm32/stm32_wdg.h +++ b/nuttx/arch/arm/src/stm32/stm32_wdg.h @@ -2,7 +2,7 @@ * arch/arm/src/stm32/stm32_wdg.h * * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/stm32/stm32f10xxx_rtc.c b/nuttx/arch/arm/src/stm32/stm32f10xxx_rtc.c index df8ad9dd5..e1d52ac09 100644 --- a/nuttx/arch/arm/src/stm32/stm32f10xxx_rtc.c +++ b/nuttx/arch/arm/src/stm32/stm32f10xxx_rtc.c @@ -113,6 +113,10 @@ # error "CONFIG_STM32_BKP is required for CONFIG_RTC" #endif +#ifndef CONFIG_STM32_PWR +# error "CONFIG_STM32_PWR is required for CONFIG_RTC" +#endif + /* RTC/BKP Definitions *************************************************************/ /* STM32_RTC_PRESCALAR_VALUE * RTC pre-scalar value. The RTC is driven by a 32,768Hz input clock. This input diff --git a/nuttx/binfmt/Makefile b/nuttx/binfmt/Makefile index dd9e459ce..b3a9269b3 100644 --- a/nuttx/binfmt/Makefile +++ b/nuttx/binfmt/Makefile @@ -2,7 +2,7 @@ # nxflat/Makefile # # Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/binfmt_dumpmodule.c b/nuttx/binfmt/binfmt_dumpmodule.c index 945dcb3ac..32a3fef3e 100644 --- a/nuttx/binfmt/binfmt_dumpmodule.c +++ b/nuttx/binfmt/binfmt_dumpmodule.c @@ -2,7 +2,7 @@ * binfmt/binfmt_dumpmodule.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/binfmt_exec.c b/nuttx/binfmt/binfmt_exec.c index cefd3aa5c..c070324c3 100644 --- a/nuttx/binfmt/binfmt_exec.c +++ b/nuttx/binfmt/binfmt_exec.c @@ -2,7 +2,7 @@ * binfmt/binfmt_exec.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/binfmt_execmodule.c b/nuttx/binfmt/binfmt_execmodule.c index 1965f6fa0..1b511b0cb 100644 --- a/nuttx/binfmt/binfmt_execmodule.c +++ b/nuttx/binfmt/binfmt_execmodule.c @@ -2,7 +2,7 @@ * binfmt/binfmt_execmodule.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/binfmt_globals.c b/nuttx/binfmt/binfmt_globals.c index 0d0b2dbb4..069d3a2aa 100644 --- a/nuttx/binfmt/binfmt_globals.c +++ b/nuttx/binfmt/binfmt_globals.c @@ -2,7 +2,7 @@ * binfmt/binfmt_globals.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/binfmt_internal.h b/nuttx/binfmt/binfmt_internal.h index 22fadcd21..da67f5350 100644 --- a/nuttx/binfmt/binfmt_internal.h +++ b/nuttx/binfmt/binfmt_internal.h @@ -2,7 +2,7 @@ * binfmt/binfmt_internal.h * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/binfmt_loadmodule.c b/nuttx/binfmt/binfmt_loadmodule.c index d4ef7cde2..01ab8cc88 100644 --- a/nuttx/binfmt/binfmt_loadmodule.c +++ b/nuttx/binfmt/binfmt_loadmodule.c @@ -2,7 +2,7 @@ * binfmt/binfmt_loadmodule.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/binfmt_register.c b/nuttx/binfmt/binfmt_register.c index e41c7a0d9..7f6eef671 100644 --- a/nuttx/binfmt/binfmt_register.c +++ b/nuttx/binfmt/binfmt_register.c @@ -2,7 +2,7 @@ * binfmt/binfmt_register.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/binfmt_unloadmodule.c b/nuttx/binfmt/binfmt_unloadmodule.c index c6fa90c39..04859a291 100644 --- a/nuttx/binfmt/binfmt_unloadmodule.c +++ b/nuttx/binfmt/binfmt_unloadmodule.c @@ -2,7 +2,7 @@ * binfmt/binfmt_loadmodule.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/binfmt_unregister.c b/nuttx/binfmt/binfmt_unregister.c index 1b50b2c58..b97b9b67d 100644 --- a/nuttx/binfmt/binfmt_unregister.c +++ b/nuttx/binfmt/binfmt_unregister.c @@ -2,7 +2,7 @@ * binfmt/binfmt_unregister.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/libnxflat/Make.defs b/nuttx/binfmt/libnxflat/Make.defs index 9e9593651..f979741e5 100644 --- a/nuttx/binfmt/libnxflat/Make.defs +++ b/nuttx/binfmt/libnxflat/Make.defs @@ -2,7 +2,7 @@ # nxflat/lib/Make.defs # # Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/libnxflat/gnu-nxflat.ld b/nuttx/binfmt/libnxflat/gnu-nxflat.ld index 9a59c0ec0..e66b1dff5 100644 --- a/nuttx/binfmt/libnxflat/gnu-nxflat.ld +++ b/nuttx/binfmt/libnxflat/gnu-nxflat.ld @@ -2,7 +2,7 @@ * examples/nxflat/nxflat.ld * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/libnxflat/libnxflat_bind.c b/nuttx/binfmt/libnxflat/libnxflat_bind.c index eb65a7e63..ca348178d 100644 --- a/nuttx/binfmt/libnxflat/libnxflat_bind.c +++ b/nuttx/binfmt/libnxflat/libnxflat_bind.c @@ -2,7 +2,7 @@ * binfmt/libnxflat/libnxflat_bind.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/libnxflat/libnxflat_init.c b/nuttx/binfmt/libnxflat/libnxflat_init.c index 45f016e27..5b6375ff1 100644 --- a/nuttx/binfmt/libnxflat/libnxflat_init.c +++ b/nuttx/binfmt/libnxflat/libnxflat_init.c @@ -2,7 +2,7 @@ * binfmt/libnxflat/libnxflat_init.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/libnxflat/libnxflat_load.c b/nuttx/binfmt/libnxflat/libnxflat_load.c index 25be05621..0991d0c2d 100644 --- a/nuttx/binfmt/libnxflat/libnxflat_load.c +++ b/nuttx/binfmt/libnxflat/libnxflat_load.c @@ -2,7 +2,7 @@ * binfmt/libnxflat/libnxflat_load.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/libnxflat/libnxflat_read.c b/nuttx/binfmt/libnxflat/libnxflat_read.c index 8f1650e87..dbcd54279 100644 --- a/nuttx/binfmt/libnxflat/libnxflat_read.c +++ b/nuttx/binfmt/libnxflat/libnxflat_read.c @@ -2,7 +2,7 @@ * binfmt/libnxflat/libnxflat_read.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/libnxflat/libnxflat_uninit.c b/nuttx/binfmt/libnxflat/libnxflat_uninit.c index 72be6c7ae..5d06296c7 100644 --- a/nuttx/binfmt/libnxflat/libnxflat_uninit.c +++ b/nuttx/binfmt/libnxflat/libnxflat_uninit.c @@ -2,7 +2,7 @@ * binfmt/libnxflat/libnxflat_uninit.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/libnxflat/libnxflat_unload.c b/nuttx/binfmt/libnxflat/libnxflat_unload.c index 7dc3e87a7..55a2e45e6 100644 --- a/nuttx/binfmt/libnxflat/libnxflat_unload.c +++ b/nuttx/binfmt/libnxflat/libnxflat_unload.c @@ -2,7 +2,7 @@ * binfmt/libnxflat/libnxflat_unload.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/libnxflat/libnxflat_verify.c b/nuttx/binfmt/libnxflat/libnxflat_verify.c index de952774f..f799aca4f 100644 --- a/nuttx/binfmt/libnxflat/libnxflat_verify.c +++ b/nuttx/binfmt/libnxflat/libnxflat_verify.c @@ -2,7 +2,7 @@ * binfmt/libnxflat/nxflat_verify.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/nxflat.c b/nuttx/binfmt/nxflat.c index 99b99249a..4f5869bd9 100644 --- a/nuttx/binfmt/nxflat.c +++ b/nuttx/binfmt/nxflat.c @@ -2,7 +2,7 @@ * binfmt/nxflat.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/symtab_findbyname.c b/nuttx/binfmt/symtab_findbyname.c index 02b2ac22b..201d7ba07 100644 --- a/nuttx/binfmt/symtab_findbyname.c +++ b/nuttx/binfmt/symtab_findbyname.c @@ -2,7 +2,7 @@ * binfmt/symtab_findbyname.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/symtab_findbyvalue.c b/nuttx/binfmt/symtab_findbyvalue.c index 80df74668..4382ed5d8 100644 --- a/nuttx/binfmt/symtab_findbyvalue.c +++ b/nuttx/binfmt/symtab_findbyvalue.c @@ -2,7 +2,7 @@ * binfmt/symtab_findbyvalue.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/symtab_findorderedbyname.c b/nuttx/binfmt/symtab_findorderedbyname.c index 82d68bfea..61decf49a 100644 --- a/nuttx/binfmt/symtab_findorderedbyname.c +++ b/nuttx/binfmt/symtab_findorderedbyname.c @@ -2,7 +2,7 @@ * binfmt/symtab_findorderedbyname.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/binfmt/symtab_findorderedbyvalue.c b/nuttx/binfmt/symtab_findorderedbyvalue.c index a995595da..92b107856 100644 --- a/nuttx/binfmt/symtab_findorderedbyvalue.c +++ b/nuttx/binfmt/symtab_findorderedbyvalue.c @@ -2,7 +2,7 @@ * binfmt/symtab_findorderedbyvalue.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index 1b405b3e4..1c14e8388 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -270,8 +270,6 @@ defconfig -- This is a configuration file similar to the Linux CONFIG_DEBUG_GRAPHICS - enable NX graphics debug output (disabled by default) - CONFIG_ARCH_LOWPUTC - architecture supports low-level, boot - time console output CONFIG_MM_REGIONS - If the architecture includes multiple regions of memory to allocate from, this specifies the number of memory regions that the memory manager must @@ -285,6 +283,33 @@ defconfig -- This is a configuration file similar to the Linux of size less than or equal to 64Kb. In this case, CONFIG_MM_SMALL can be defined so that those MCUs will also benefit from the smaller, 16-bit-based allocation overhead. + CONFIG_HEAP2_BASE and CONFIG_HEAP2_SIZE + Some architectures use these settings to specify the size of + a second heap region. + CONFIG_GRAN + Enable granual allocator support. Allocations will be aligned to the + granule size; allocations will be in units of the granule size. + Larger granules will give better performance and less overhead but + more losses of memory due to alignment and quantization waste. + NOTE: The current implementation also restricts the maximum + allocation size to 32 granaules. That restriction could be + eliminated with some additional coding effort. + CONFIG_GRAN_SINGLE + Select if there is only one instance of the granule allocator (i.e., + gran_initialize will be called only once. In this case, (1) there + are a few optimizations that can can be done and (2) the GRAN_HANDLE + is not needed. + CONFIG_GRAN_INTR - Normally mutual exclusive access to granule allocator + data is assured using a semaphore. If this option is set then, instead, + mutual exclusion logic will disable interrupts. While this options is + more invasive to system performance, it will also support use of the + granule allocator from interrupt level logic. + CONFIG_DEBUG_GRAM + Just like CONFIG_DEBUG_MM, but only generates ouput from the gran + allocation logic. + + CONFIG_ARCH_LOWPUTC - architecture supports low-level, boot + time console output CONFIG_MSEC_PER_TICK - The default system timer is 100Hz or MSEC_PER_TICK=10. This setting may be defined to inform NuttX that the processor hardware is providing @@ -361,13 +386,24 @@ defconfig -- This is a configuration file similar to the Linux if memory reclamation is of high priority). If CONFIG_SCHED_WORKQUEUE is enabled, then the following options can also be used: CONFIG_SCHED_WORKPRIORITY - The execution priority of the worker - thread. Default: 50 + thread. Default: 192 CONFIG_SCHED_WORKPERIOD - How often the worker thread checks for work in units of microseconds. Default: 50*1000 (50 MS). CONFIG_SCHED_WORKSTACKSIZE - The stack size allocated for the worker thread. Default: CONFIG_IDLETHREAD_STACKSIZE. CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up the worker thread. Default: 4 + CONFIG_SCHED_LPWORK. If CONFIG_SCHED_WORKQUEUE is defined, then a single + work queue is created by default. If CONFIG_SCHED_LPWORK is also defined + then an additional, lower-priority work queue will also be created. This + lower priority work queue is better suited for more extended processing + (such as file system clean-up operations) + CONFIG_SCHED_LPWORKPRIORITY - The execution priority of the lower priority + worker thread. Default: 50 + CONFIG_SCHED_LPWORKPERIOD - How often the lower priority worker thread + checks for work in units of microseconds. Default: 50*1000 (50 MS). + CONFIG_SCHED_LPWORKSTACKSIZE - The stack size allocated for the lower + priority worker thread. Default: CONFIG_IDLETHREAD_STACKSIZE. CONFIG_SCHED_WAITPID - Enables the waitpid() API CONFIG_SCHED_ATEXIT - Enables the atexit() API CONFIG_SCHED_ATEXIT_MAX - By default if CONFIG_SCHED_ATEXIT is @@ -710,7 +746,6 @@ defconfig -- This is a configuration file similar to the Linux Filesystem configuration CONFIG_FS_FAT - Enable FAT filesystem support - CONFIG_FAT_SECTORSIZE - Max supported sector size CONFIG_FAT_LCNAMES - Enable use of the NT-style upper/lower case 8.3 file name support. CONFIG_FAT_LFN - Enable FAT long file names. NOTE: Microsoft claims @@ -940,7 +975,7 @@ defconfig -- This is a configuration file similar to the Linux ENC28J60 Ethernet Driver Configuration Settings: - CONFIG_NET_ENC28J60 - Enabled ENC28J60 support + CONFIG_ENC28J60 - Enabled ENC28J60 support CONFIG_ENC28J60_SPIMODE - Controls the SPI mode CONFIG_ENC28J60_FREQUENCY - Define to use a different bus frequency CONFIG_ENC28J60_NINTERFACES - Specifies the number of physical ENC28J60 @@ -979,7 +1014,10 @@ defconfig -- This is a configuration file similar to the Linux CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks) CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers - (may be zero) + (may be zero to disable TCP/IP read-ahead buffering) + CONFIG_NET_TCP_RECVDELAY - Delay (in deciseconds) after a TCP/IP packet + is received. This delay may allow catching of additional packets + when TCP/IP read-ahead is disabled. Default: 0 CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until accept() is called. The size of the backlog is selected when listen() is called. @@ -1005,8 +1043,6 @@ defconfig -- This is a configuration file similar to the Linux from incoming IP packets. CONFIG_NET_BROADCAST - Incoming UDP broadcast support CONFIG_NET_MULTICAST - Outgoing multi-cast address support - CONFIG_NET_FWCACHE_SIZE - number of packets to remember when - looking for duplicates SLIP Driver. SLIP supports point-to-point IP communications over a serial port. The default data link layer for uIP is Ethernet. If CONFIG_NET_SLIP @@ -1443,8 +1479,6 @@ defconfig -- This is a configuration file similar to the Linux but copy themselves entirely into RAM for better performance. CONFIG_BOOT_RAMFUNCS - Other configurations may copy just some functions into RAM, either for better performance or for errata workarounds. - CONFIG_STACK_POINTER - The initial stack pointer (may not be supported - in all architectures). CONFIG_STACK_ALIGNMENT - Set if the your application has specific stack alignment requirements (may not be supported in all architectures). @@ -1534,6 +1568,10 @@ configs/ez80f0910200zco development kit, eZ80F091 part, and the Zilog ZDS-II Windows command line tools. The development environment is Cygwin under WinXP. +configs/fire-stm32v2 + A configuration for the M3 Wildfire STM32 board. This board is based on the + STM32F103VET6 chip. See http://firestm32.taobao.com + configs/hymini-stm32v A configuration for the HY-Mini STM32v board. This board is based on the STM32F103VCT chip. @@ -1695,6 +1733,10 @@ configs/sim This port does not support interrupts or a real timer (and hence no round robin scheduler) Otherwise, it is complete. +configs/shenzhou + This is the port of NuttX to the Shenzhou development board from + www.armjishu.com. This board features the STMicro STM32F107VCT MCU. + configs/skp16c26 Renesas M16C processor on the Renesas SKP16C26 StarterKit. This port uses the GNU m32c toolchain. STATUS: The port is complete but untested diff --git a/nuttx/configs/px4io/common/setenv.sh b/nuttx/configs/px4io/common/setenv.sh index d83685192..ee33a8d21 100755 --- a/nuttx/configs/px4io/common/setenv.sh +++ b/nuttx/configs/px4io/common/setenv.sh @@ -2,7 +2,7 @@ # configs/stm3210e-eval/dfu/setenv.sh # # Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/configs/px4io/io/setenv.sh b/nuttx/configs/px4io/io/setenv.sh index d83685192..ee33a8d21 100755 --- a/nuttx/configs/px4io/io/setenv.sh +++ b/nuttx/configs/px4io/io/setenv.sh @@ -2,7 +2,7 @@ # configs/stm3210e-eval/dfu/setenv.sh # # Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/Kconfig b/nuttx/drivers/Kconfig index f89862650..294566d01 100644 --- a/nuttx/drivers/Kconfig +++ b/nuttx/drivers/Kconfig @@ -3,15 +3,13 @@ # see misc/tools/kconfig-language.txt. # -comment "Device Driver Configuration" - config DEV_NULL bool "Enable /dev/null" default y config DEV_ZERO bool "Enable /dev/zero" - default y + default n config LOOP bool "Enable loop device" @@ -22,15 +20,15 @@ config LOOP loteardown() in include/nuttx/fs/fs.h. config RAMDISK - bool "RAM disk support" + bool "RAM Disk Support" default n ---help--- Can be used to set up a block of memory or (read-only) FLASH as a block driver that can be mounted as a files system. See include/nuttx/ramdisk.h. -config CAN - bool "CAN support" +menuconfig CAN + bool "CAN Driver Support" default n ---help--- This selection enables building of the "upper-half" CAN driver. @@ -65,8 +63,8 @@ config CAN_LOOPBACK endif -config PWM - bool "PWM support" +menuconfig PWM + bool "PWM Driver Support" default n ---help--- This selection enables building of the "upper-half" PWM driver. @@ -74,7 +72,7 @@ config PWM if PWM config PWM_PULSECOUNT - bool "PWM pulse count support" + bool "PWM Pulse Count Support" default n ---help--- Some hardware will support generation of a fixed number of pulses. This @@ -84,19 +82,46 @@ config PWM_PULSECOUNT endif -config I2C - bool "I2C support" - default y +menuconfig I2C + bool "I2C Driver Support" + default n ---help--- This selection enables building of the "upper-half" I2C driver. See include/nuttx/i2c.h for further I2C driver information. -if I2C -endif +config I2C_SLAVE + bool "I2C Slave" + default n + depends on I2C -config SPI - bool "SPI support" - default y +config I2C_TRANSFER + bool "Support the I2C transfer() method" + default n + depends on I2C + +config I2C_WRITEREAD + bool "Support the I2C writeread() method" + default n + depends on I2C + +config I2C_POLLED + bool "Polled I2C (no interrupts)" + default n + depends on I2C + +config I2C_TRACE + bool "Enable I2C trace debug" + default n + depends on I2C + +config I2C_NTRACE + bool "Enable I2C trace debug" + default n + depends on I2C_TRACE + +menuconfig SPI + bool "SPI Driver Support" + default n ---help--- This selection enables building of the "upper-half" SPI driver. See include/nuttx/spi.h for further SPI driver information. @@ -104,7 +129,7 @@ config SPI if SPI config SPI_OWNBUS bool "SPI single device" - default y + default n ---help--- Set if there is only one active device on the SPI bus. No locking or SPI configuration will be performed. It is not necessary for clients to lock, @@ -126,9 +151,62 @@ config SPI_CMDDATA endif -config WATCHDOG - bool "Watchdog timer support" - default y +menuconfig RTC + bool "RTC Driver Support" + default n + ---help--- + This selection enables configuration of a real time clock (RTCdriver. + See include/nuttx/rtc.h for further watchdog timer driver information. + Most RTC drivers are MCU specific and may require other specific settings. + +config RTC_DATETIME + bool "Date/Time RTC Support" + default n + depends on RTC + ---help--- + There are two general types of RTC: (1) A simple battery backed counter + that keeps the time when power is down, and (2) a full date / time RTC the + provides the date and time information, often in BCD format. If + RTC_DATETIME is selected, it specifies this second kind of RTC. In this + case, the RTC is used to "seed" the normal NuttX timer and the NuttX system + timer provides for higher resolution time. + +config RTC_HIRES + bool "Hi-Res RTC Support" + default n + depends on RTC && !RTC_DATETIME + ---help--- + If RTC_DATETIME not selected, then the simple, battery backed counter is + used. There are two different implementations of such simple counters + based on the time resolution of the counter: The typical RTC keeps time + to resolution of 1 second, usually supporting a 32-bit time_t value. In + this case, the RTC is used to "seed" the normal NuttX timer and the NuttX + timer provides for higherresoution time. + + If RTC_HIRES is enabled in the NuttX configuration, then the RTC provides + higher resolution time and completely replaces the system timer for purpose + of date and time. + +config RTC_FREQUENCY + int "Hi-Res RTC frequency" + default 1 + depends on RTC && !RTC_DATETIME && RTC_HIRES + ---help--- + If RTC_HIRES is defined, then the frequency of the high resolution RTC + must be provided. If RTC_HIRES is not defined, RTC_FREQUENCY is assumed + to be one Hz. + +config RTC_ALARM + bool "RTC Alarm Support" + default n + depends on RTC + ---help--- + Enable if the RTC hardware supports setting of an alarm. A callback + function will be executed when the alarm goes off. + +menuconfig WATCHDOG + bool "Watchdog Timer Support" + default n ---help--- This selection enables building of the "upper-half" watchdog timer driver. See include/nuttx/watchdog.h for further watchdog timer driver information. @@ -137,7 +215,7 @@ if WATCHDOG endif menuconfig ANALOG - bool "Analog Device(ADC/DAC) support" + bool "Analog Device(ADC/DAC) Support" default n ---help--- This directory holds implementations of analog device drivers. @@ -149,8 +227,8 @@ if ANALOG source drivers/analog/Kconfig endif -config BCH - bool "BCH support" +menuconfig BCH + bool "Block-to-Character (BCH) Support" default n ---help--- Contains logic that may be used to convert a block driver into @@ -163,8 +241,8 @@ source drivers/bch/Kconfig endif menuconfig INPUT - bool "Input device support" - default y + bool "Input Device Support" + default n ---help--- This directory holds implementations of input device drivers. This includes such things as touchscreen and keypad drivers. @@ -175,7 +253,7 @@ source drivers/input/Kconfig endif menuconfig LCD - bool "LCD support" + bool "LCD Driver Support" default n select NX_LCDDRIVER ---help--- @@ -191,7 +269,7 @@ source drivers/lcd/Kconfig endif menuconfig MMCSD - bool "MMC/SD support" + bool "MMC/SD Driver Support" default n ---help--- Support for MMC/SD block drivers. MMC/SD block drivers based on @@ -201,9 +279,9 @@ menuconfig MMCSD if MMCSD source drivers/mmcsd/Kconfig endif - + menuconfig MTD - bool "Memory Technology Device (MTD) support" + bool "Memory Technology Device (MTD) Support" default n ---help--- Memory Technology Device (MTD) drivers. Some simple drivers for @@ -220,8 +298,9 @@ source drivers/mtd/Kconfig endif menuconfig NETDEVICES - bool "Network Device support" + bool "Network Device Support" default n + depends on NET ---help--- Network interface drivers. See also include/nuttx/net/net.h @@ -250,7 +329,7 @@ config PM drivers are not active. menuconfig POWER - bool "Power management device support" + bool "Power Management Support" default n ---help--- Enable building of power-related devices (battery monitors, chargers, etc). @@ -260,7 +339,7 @@ source drivers/power/Kconfig endif menuconfig SENSORS - bool "Sensors support" + bool "Sensor Device Support" default n ---help--- Drivers for various sensors @@ -270,7 +349,7 @@ source drivers/sensors/Kconfig endif menuconfig SERCOMM_CONSOLE - bool "Osmocom-bb serial console" + bool "Osmocom-bb Sercomm Driver Support" default n ---help--- Sercomm is the transport used by osmocom-bb that runs on top of serial. @@ -287,7 +366,7 @@ source drivers/sercomm/Kconfig endif menuconfig SERIAL - bool "Serial support" + bool "Serial Driver Support" default y ---help--- Front-end character drivers for chip-specific UARTs. This provide @@ -299,7 +378,7 @@ source drivers/serial/Kconfig endif menuconfig USBDEV - bool "USB device support" + bool "USB Device Driver Support" default n ---help--- USB device drivers. See also include/nuttx/usb/usbdev.h @@ -309,7 +388,7 @@ source drivers/usbdev/Kconfig endif menuconfig USBHOST - bool "USB Host support" + bool "USB Host Driver Support" default n ---help--- USB host drivers. See also include/nuttx/usb/usbhost.h @@ -319,7 +398,7 @@ source drivers/usbhost/Kconfig endif menuconfig WIRELESS - bool "Wireless support" + bool "Wireless Device Support" default n ---help--- Drivers for various wireless devices. @@ -328,6 +407,8 @@ if WIRELESS source drivers/wireless/Kconfig endif +comment "System Logging Device Options" + source drivers/syslog/Kconfig diff --git a/nuttx/drivers/analog/Make.defs b/nuttx/drivers/analog/Make.defs index 10b0db478..d94e39758 100644 --- a/nuttx/drivers/analog/Make.defs +++ b/nuttx/drivers/analog/Make.defs @@ -2,7 +2,7 @@ # drivers/analog/Make.defs # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/analog/dac.c b/nuttx/drivers/analog/dac.c index 9371e3414..e1fc3049f 100644 --- a/nuttx/drivers/analog/dac.c +++ b/nuttx/drivers/analog/dac.c @@ -8,7 +8,7 @@ * Derived from drivers/can.c * * Copyright (C) 2008-2009Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/input/Make.defs b/nuttx/drivers/input/Make.defs index aaf08b827..6dbae268e 100644 --- a/nuttx/drivers/input/Make.defs +++ b/nuttx/drivers/input/Make.defs @@ -2,7 +2,7 @@ # drivers/input/Make.defs # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/input/ads7843e.c b/nuttx/drivers/input/ads7843e.c index 750b91ff2..e08a7a728 100644 --- a/nuttx/drivers/input/ads7843e.c +++ b/nuttx/drivers/input/ads7843e.c @@ -521,7 +521,7 @@ static int ads7843e_schedule(FAR struct ads7843e_dev_s *priv) */ DEBUGASSERT(priv->work.worker == NULL); - ret = work_queue(&priv->work, ads7843e_worker, priv, 0); + ret = work_queue(HPWORK, &priv->work, ads7843e_worker, priv, 0); if (ret != 0) { illdbg("Failed to queue work: %d\n", ret); @@ -1179,7 +1179,7 @@ int ads7843e_register(FAR struct spi_dev_s *dev, * availability conditions. */ - ret = work_queue(&priv->work, ads7843e_worker, priv, 0); + ret = work_queue(HPWORK, &priv->work, ads7843e_worker, priv, 0); if (ret != 0) { idbg("Failed to queue work: %d\n", ret); diff --git a/nuttx/drivers/input/stmpe811_base.c b/nuttx/drivers/input/stmpe811_base.c index 72af1575a..f37c24622 100644 --- a/nuttx/drivers/input/stmpe811_base.c +++ b/nuttx/drivers/input/stmpe811_base.c @@ -195,7 +195,7 @@ static int stmpe811_interrupt(int irq, FAR void *context) * action should be required to protect the work queue. */ - ret = work_queue(&priv->work, stmpe811_worker, priv, 0); + ret = work_queue(HPWORK, &priv->work, stmpe811_worker, priv, 0); if (ret != 0) { illdbg("Failed to queue work: %d\n", ret); diff --git a/nuttx/drivers/input/stmpe811_tsc.c b/nuttx/drivers/input/stmpe811_tsc.c index e2ab2827d..c7f8b473b 100644 --- a/nuttx/drivers/input/stmpe811_tsc.c +++ b/nuttx/drivers/input/stmpe811_tsc.c @@ -783,7 +783,7 @@ static void stmpe811_timeout(int argc, uint32_t arg1, ...) * action should be required to protect the work queue. */ - ret = work_queue(&priv->timeout, stmpe811_timeoutworker, priv, 0); + ret = work_queue(HPWORK, &priv->timeout, stmpe811_timeoutworker, priv, 0); if (ret != 0) { illdbg("Failed to queue work: %d\n", ret); diff --git a/nuttx/drivers/input/tsc2007.c b/nuttx/drivers/input/tsc2007.c index 07acb5371..163118b95 100644 --- a/nuttx/drivers/input/tsc2007.c +++ b/nuttx/drivers/input/tsc2007.c @@ -775,7 +775,7 @@ static int tsc2007_interrupt(int irq, FAR void *context) */ DEBUGASSERT(priv->work.worker == NULL); - ret = work_queue(&priv->work, tsc2007_worker, priv, 0); + ret = work_queue(HPWORK, &priv->work, tsc2007_worker, priv, 0); if (ret != 0) { illdbg("Failed to queue work: %d\n", ret); @@ -1316,7 +1316,7 @@ int tsc2007_register(FAR struct i2c_dev_s *dev, * availability conditions. */ - ret = work_queue(&priv->work, tsc2007_worker, priv, 0); + ret = work_queue(HPWORK, &priv->work, tsc2007_worker, priv, 0); if (ret != 0) { idbg("Failed to queue work: %d\n", ret); diff --git a/nuttx/drivers/lcd/nokia6100.c b/nuttx/drivers/lcd/nokia6100.c index d450e05db..7354b8a91 100644 --- a/nuttx/drivers/lcd/nokia6100.c +++ b/nuttx/drivers/lcd/nokia6100.c @@ -3,7 +3,7 @@ * Nokia 6100 LCD Display Driver * * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: * "Nokia 6100 LCD Display Driver," Revision 1, James P. Lynch ("Nokia 6100 LCD diff --git a/nuttx/drivers/lcd/pcf8833.h b/nuttx/drivers/lcd/pcf8833.h index b0a7e14d4..36dc65ac3 100644 --- a/nuttx/drivers/lcd/pcf8833.h +++ b/nuttx/drivers/lcd/pcf8833.h @@ -1,152 +1,152 @@ -/**************************************************************************************
- * drivers/lcd/pcf8833.h
- * Definitions for the Phillips PCF8833 LCD controller
- *
- * Copyright (C) 2010 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * References: "Data Sheet, PCF8833 STN RGB 132x132x3 driver," Phillips, 2003 Feb 14.
- *
- * 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. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS 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.
- *
- **************************************************************************************/
-
-#ifndef __DRIVERS_LCD_PCF8833_H
-#define __DRIVERS_LCD_PCF8833_H
-
-/**************************************************************************************
- * Included Files
- **************************************************************************************/
-
-/**************************************************************************************
- * Pre-processor Definitions
- **************************************************************************************/
-/* Pixel format codes */
-
-#define PCF8833_FMT_8BPS (2)
-#define PCF8833_FMT_12BPS (3)
-#define PCF8833_FMT_16BPS (5)
-
-/* LCD Commands */
-
-#define PCF8833_NOP 0x00 /* No operation; Data: none */
-#define PCF8833_SWRESET 0x01 /* Software reset ; Data: none */
-#define PCF8833_BSTROFF 0x02 /* Booster voltage off; Data: none */
-#define PCF8833_BSTRON 0x03 /* Booster voltage on; Data: none */
-#define PCF8833_RDDIDIF 0x04 /* Read display identification; Data: none */
-#define PCF8833_RDDST 0x09 /* Read display status; Data: none */
-#define PCF8833_SLEEPIN 0x10 /* Sleep_IN; Data: none */
-#define PCF8833_SLEEPOUT 0x11 /* Sleep_OUT; Data: none */
-#define PCF8833_PTLON 0x12 /* Partial mode on; Data: none */
-#define PCF8833_NORON 0x13 /* Normal Display mode on; Data: none */
-#define PCF8833_INVOFF 0x20 /* Display inversion off; Data: none */
-#define PCF8833_INVON 0x21 /* Display inversion on; Data: none */
-#define PCF8833_DALO 0x22 /* All pixel off; Data: none */
-#define PCF8833_DAL 0x23 /* All pixel on; Data: none */
-#define PCF8833_SETCON 0x25 /* Set contrast; Data: (1) contrast */
-#define PCF8833_DISPOFF 0x28 /* Display off; Data: none */
-#define PCF8833_DISPON 0x29 /* Display on; Data: none */
-#define PCF8833_CASET 0x2a /* Column address set; Data: (1) X start (2) X end */
-#define PCF8833_PASET 0x2b /* Page address set Data: (1) Y start (2) Y end */
-#define PCF8833_RAMWR 0x2c /* Memory write; Data: (1) write data */
-#define PCF8833_RGBSET 0x2d /* Colour set; Data: (1-8) red tones, (9-16) green tones, (17-20) blue tones */
-#define PCF8833_PTLAR 0x30 /* Partial area; Data: (1) start address (2) end address */
-#define PCF8833_VSCRDEF 0x33 /* Vertical scroll definition; Data: (1) top fixed, (2) scrol area, (3) bottom fixed */
-#define PCF8833_TEOFF 0x34 /* Tearing line off; Data: none */
-#define PCF8833_TEON 0x35 /* Tearing line on; Data: (1) don't care */
-#define PCF8833_MADCTL 0x36 /* Memory data access control; Data: (1) access control settings */
-#define PCF8833_SEP 0x37 /* Set Scroll Entry Point; Data: (1) scroll entry point */
-#define PCF8833_IDMOFF 0x38 /* Idle mode off; Data: none */
-#define PCF8833_IDMON 0x39 /* Idle mode on; Data: none */
-#define PCF8833_COLMOD 0x3a /* Interface pixel format; Data: (1) color interface format */
-#define PCF8833_SETVOP 0xb0 /* Set VOP; Data: (1) VOP5-8 (2) VOP0-4 */
-#define PCF8833_BRS 0xb4 /* Bottom Row Swap; Data: none */
-#define PCF8833_TRS 0xb6 /* Top Row Swap; Data: none */
-#define PCF8833_FINV 0xb9 /* Super Frame INVersion; Data: none */
-#define PCF8833_DOR 0xba /* Data ORder; Data: none */
-#define PCF8833_TCDFE 0xbd /* Enable/disable DF temp comp; Data: none */
-#define PCF8833_TCVOPE 0xbf /* Enable or disable VOP temp comp; Data: none */
-#define PCF8833_EC 0xc0 /* Internal or external oscillator; Data: none */
-#define PCF8833_SETMUL 0xc2 /* Set multiplication factor; Data: (1) Multiplication factor */
-#define PCF8833_TCVOPAB 0xc3 /* Set TCVOP slopes A and B; Data: (1) SLB and SLA */
-#define PCF8833_TCVOPCD 0xc4 /* Set TCVOP slopes C and D; Data: (1) SLD and SLC */
-#define PCF8833_TCDF 0xc5 /* Set divider frequency; Data: Divider factor in region (1) A (2) B (3) C (4) D */
-#define PCF8833_DF8COLOR 0xc6 /* Set divider frequency 8-colour mode; Data: (1) DF80-6 */
-#define PCF8833_SETBS 0xc7 /* Set bias system; Data: (1) Bias systems */
-#define PCF8833_RDTEMP 0xc8 /* Temperature read back; Data: none */
-#define PCF8833_NLI 0xc9 /* N-Line Inversion; Data: (1) NLI time slots invervsion */
-#define PCF8833_RDID1 0xda /* Read ID1; Data: none */
-#define PCF8833_RDID2 0xdb /* Read ID2; Data: none */
-#define PCF8833_RDID3 0xdc /* Read ID3; Data: none */
-#define PCF8833_SFD 0xef /* Select factory defaults; Data: none */
-#define PCF8833_ECM 0xf0 /* Enter Calibration mode; Data: (1) Calibration control settings */
-#define PCF8833_OTPSHTIN 0xf1 /* Shift data in OTP shift registers; Data: Any number of bytes */
-
-/* Memory data access control (MADCTL) bit definitions */
-
-#define MADCTL_RGB (1 << 3) /* Bit 3: BGR */
-#define MADCTL_LAO (1 << 4) /* Bit 4: Line address order bottom to top */
-#define MADCTL_V (1 << 5) /* Bit 5: Vertical RAM write; in Y direction */
-#define MADCTL_MX (1 << 6) /* Bit 6: Mirror X */
-#define MADCTL_MY (1 << 7) /* Bit 7: Mirror Y */
-
-/* PCF8833 status register bit definitions */
-/* CMD format: RDDST command followed by four status bytes: */
-/* Byte 1: D31 d30 D29 D28 D27 D26 --- --- */
-
-#define PCF8833_ST_RGB (1 << 2) /* Bit 2: D26 - RGB/BGR order */
-#define PCF8833_ST_LINEADDR (1 << 3) /* Bit 3: D27 - Line address order */
-#define PCF8833_ST_ADDRMODE (1 << 4) /* Bit 4: D28 - Vertical/horizontal addressing mode */
-#define PCF8833_ST_XADDR (1 << 5) /* Bit 5: D29 - X address order */
-#define PCF8833_ST_YADDR (1 << 6) /* Bit 6: D30 - Y address order */
-#define PCF8833_ST_BOOSTER (1 << 7) /* Bit 7: D31 - Booster voltage status */
-
-/* Byte 2: --- D22 D21 D20 D19 D18 D17 D16 */
-
-#define PCF8833_ST_NORMAL (1 << 0) /* Bit 0: D16 - Normal display mode */
-#define PCF8833_ST_SLEEPIN (1 << 1) /* Bit 1: D17 - Sleep in selected */
-#define PCF8833_ST_PARTIAL (1 << 2) /* Bit 2: D18 - Partial mode on */
-#define PCF8833_ST_IDLE (1 << 3) /* Bit 3: D19 - Idle mode selected */
-#define PCF8833_ST_PIXELFMT_SHIFT (4) /* Bits 4-6: D20-D22 - Interface pixel format */
-#define PCF8833_ST_PIXELFMT_MASK (7 << PCF8833_ST_PIXELFMT_SHIFT)
-# define PCF8833_ST_PIXELFMT_8BPS (PCF8833_FMT_8BPS << PCF8833_ST_PIXELFMT_SHIFT)
-# define PCF8833_ST_PIXELFMT_12BPS (PCF8833_FMT_12BPS << PCF8833_ST_PIXELFMT_SHIFT)
-# define PCF8833_ST_PIXELFMT_16BPS (PCF8833_FMT_16BPS << PCF8833_ST_PIXELFMT_SHIFT)
-
-/* Byte 3: D15 -- D13 D12 D11 D10 D9 --- */
-
-#define PCF8833_ST_TEARING (1 << 1) /* Bit 1: D9 - Tearing effect on */
-#define PCF8833_ST_DISPLAYON (1 << 2) /* Bit 2: D10 - Display on */
-#define PCF8833_ST_PIXELSOFF (1 << 3) /* Bit 3: D11 - All pixels off */
-#define PCF8833_ST_PIXELSON (1 << 4) /* Bit 4: D12 - All pixels on */
-#define PCF8833_ST_INV (1 << 5) /* Bit 5: D13 - Display inversion */
-#define PCF8833_ST_VSCROLL (1 << 7) /* Bit 6: D15 - Vertical scroll mode */
-
-/* Byte 4: All zero */
-
+/************************************************************************************** + * drivers/lcd/pcf8833.h + * Definitions for the Phillips PCF8833 LCD controller + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * References: "Data Sheet, PCF8833 STN RGB 132x132x3 driver," Phillips, 2003 Feb 14. + * + * 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. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS 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. + * + **************************************************************************************/ + +#ifndef __DRIVERS_LCD_PCF8833_H +#define __DRIVERS_LCD_PCF8833_H + +/************************************************************************************** + * Included Files + **************************************************************************************/ + +/************************************************************************************** + * Pre-processor Definitions + **************************************************************************************/ +/* Pixel format codes */ + +#define PCF8833_FMT_8BPS (2) +#define PCF8833_FMT_12BPS (3) +#define PCF8833_FMT_16BPS (5) + +/* LCD Commands */ + +#define PCF8833_NOP 0x00 /* No operation; Data: none */ +#define PCF8833_SWRESET 0x01 /* Software reset ; Data: none */ +#define PCF8833_BSTROFF 0x02 /* Booster voltage off; Data: none */ +#define PCF8833_BSTRON 0x03 /* Booster voltage on; Data: none */ +#define PCF8833_RDDIDIF 0x04 /* Read display identification; Data: none */ +#define PCF8833_RDDST 0x09 /* Read display status; Data: none */ +#define PCF8833_SLEEPIN 0x10 /* Sleep_IN; Data: none */ +#define PCF8833_SLEEPOUT 0x11 /* Sleep_OUT; Data: none */ +#define PCF8833_PTLON 0x12 /* Partial mode on; Data: none */ +#define PCF8833_NORON 0x13 /* Normal Display mode on; Data: none */ +#define PCF8833_INVOFF 0x20 /* Display inversion off; Data: none */ +#define PCF8833_INVON 0x21 /* Display inversion on; Data: none */ +#define PCF8833_DALO 0x22 /* All pixel off; Data: none */ +#define PCF8833_DAL 0x23 /* All pixel on; Data: none */ +#define PCF8833_SETCON 0x25 /* Set contrast; Data: (1) contrast */ +#define PCF8833_DISPOFF 0x28 /* Display off; Data: none */ +#define PCF8833_DISPON 0x29 /* Display on; Data: none */ +#define PCF8833_CASET 0x2a /* Column address set; Data: (1) X start (2) X end */ +#define PCF8833_PASET 0x2b /* Page address set Data: (1) Y start (2) Y end */ +#define PCF8833_RAMWR 0x2c /* Memory write; Data: (1) write data */ +#define PCF8833_RGBSET 0x2d /* Colour set; Data: (1-8) red tones, (9-16) green tones, (17-20) blue tones */ +#define PCF8833_PTLAR 0x30 /* Partial area; Data: (1) start address (2) end address */ +#define PCF8833_VSCRDEF 0x33 /* Vertical scroll definition; Data: (1) top fixed, (2) scrol area, (3) bottom fixed */ +#define PCF8833_TEOFF 0x34 /* Tearing line off; Data: none */ +#define PCF8833_TEON 0x35 /* Tearing line on; Data: (1) don't care */ +#define PCF8833_MADCTL 0x36 /* Memory data access control; Data: (1) access control settings */ +#define PCF8833_SEP 0x37 /* Set Scroll Entry Point; Data: (1) scroll entry point */ +#define PCF8833_IDMOFF 0x38 /* Idle mode off; Data: none */ +#define PCF8833_IDMON 0x39 /* Idle mode on; Data: none */ +#define PCF8833_COLMOD 0x3a /* Interface pixel format; Data: (1) color interface format */ +#define PCF8833_SETVOP 0xb0 /* Set VOP; Data: (1) VOP5-8 (2) VOP0-4 */ +#define PCF8833_BRS 0xb4 /* Bottom Row Swap; Data: none */ +#define PCF8833_TRS 0xb6 /* Top Row Swap; Data: none */ +#define PCF8833_FINV 0xb9 /* Super Frame INVersion; Data: none */ +#define PCF8833_DOR 0xba /* Data ORder; Data: none */ +#define PCF8833_TCDFE 0xbd /* Enable/disable DF temp comp; Data: none */ +#define PCF8833_TCVOPE 0xbf /* Enable or disable VOP temp comp; Data: none */ +#define PCF8833_EC 0xc0 /* Internal or external oscillator; Data: none */ +#define PCF8833_SETMUL 0xc2 /* Set multiplication factor; Data: (1) Multiplication factor */ +#define PCF8833_TCVOPAB 0xc3 /* Set TCVOP slopes A and B; Data: (1) SLB and SLA */ +#define PCF8833_TCVOPCD 0xc4 /* Set TCVOP slopes C and D; Data: (1) SLD and SLC */ +#define PCF8833_TCDF 0xc5 /* Set divider frequency; Data: Divider factor in region (1) A (2) B (3) C (4) D */ +#define PCF8833_DF8COLOR 0xc6 /* Set divider frequency 8-colour mode; Data: (1) DF80-6 */ +#define PCF8833_SETBS 0xc7 /* Set bias system; Data: (1) Bias systems */ +#define PCF8833_RDTEMP 0xc8 /* Temperature read back; Data: none */ +#define PCF8833_NLI 0xc9 /* N-Line Inversion; Data: (1) NLI time slots invervsion */ +#define PCF8833_RDID1 0xda /* Read ID1; Data: none */ +#define PCF8833_RDID2 0xdb /* Read ID2; Data: none */ +#define PCF8833_RDID3 0xdc /* Read ID3; Data: none */ +#define PCF8833_SFD 0xef /* Select factory defaults; Data: none */ +#define PCF8833_ECM 0xf0 /* Enter Calibration mode; Data: (1) Calibration control settings */ +#define PCF8833_OTPSHTIN 0xf1 /* Shift data in OTP shift registers; Data: Any number of bytes */ + +/* Memory data access control (MADCTL) bit definitions */ + +#define MADCTL_RGB (1 << 3) /* Bit 3: BGR */ +#define MADCTL_LAO (1 << 4) /* Bit 4: Line address order bottom to top */ +#define MADCTL_V (1 << 5) /* Bit 5: Vertical RAM write; in Y direction */ +#define MADCTL_MX (1 << 6) /* Bit 6: Mirror X */ +#define MADCTL_MY (1 << 7) /* Bit 7: Mirror Y */ + +/* PCF8833 status register bit definitions */ +/* CMD format: RDDST command followed by four status bytes: */ +/* Byte 1: D31 d30 D29 D28 D27 D26 --- --- */ + +#define PCF8833_ST_RGB (1 << 2) /* Bit 2: D26 - RGB/BGR order */ +#define PCF8833_ST_LINEADDR (1 << 3) /* Bit 3: D27 - Line address order */ +#define PCF8833_ST_ADDRMODE (1 << 4) /* Bit 4: D28 - Vertical/horizontal addressing mode */ +#define PCF8833_ST_XADDR (1 << 5) /* Bit 5: D29 - X address order */ +#define PCF8833_ST_YADDR (1 << 6) /* Bit 6: D30 - Y address order */ +#define PCF8833_ST_BOOSTER (1 << 7) /* Bit 7: D31 - Booster voltage status */ + +/* Byte 2: --- D22 D21 D20 D19 D18 D17 D16 */ + +#define PCF8833_ST_NORMAL (1 << 0) /* Bit 0: D16 - Normal display mode */ +#define PCF8833_ST_SLEEPIN (1 << 1) /* Bit 1: D17 - Sleep in selected */ +#define PCF8833_ST_PARTIAL (1 << 2) /* Bit 2: D18 - Partial mode on */ +#define PCF8833_ST_IDLE (1 << 3) /* Bit 3: D19 - Idle mode selected */ +#define PCF8833_ST_PIXELFMT_SHIFT (4) /* Bits 4-6: D20-D22 - Interface pixel format */ +#define PCF8833_ST_PIXELFMT_MASK (7 << PCF8833_ST_PIXELFMT_SHIFT) +# define PCF8833_ST_PIXELFMT_8BPS (PCF8833_FMT_8BPS << PCF8833_ST_PIXELFMT_SHIFT) +# define PCF8833_ST_PIXELFMT_12BPS (PCF8833_FMT_12BPS << PCF8833_ST_PIXELFMT_SHIFT) +# define PCF8833_ST_PIXELFMT_16BPS (PCF8833_FMT_16BPS << PCF8833_ST_PIXELFMT_SHIFT) + +/* Byte 3: D15 -- D13 D12 D11 D10 D9 --- */ + +#define PCF8833_ST_TEARING (1 << 1) /* Bit 1: D9 - Tearing effect on */ +#define PCF8833_ST_DISPLAYON (1 << 2) /* Bit 2: D10 - Display on */ +#define PCF8833_ST_PIXELSOFF (1 << 3) /* Bit 3: D11 - All pixels off */ +#define PCF8833_ST_PIXELSON (1 << 4) /* Bit 4: D12 - All pixels on */ +#define PCF8833_ST_INV (1 << 5) /* Bit 5: D13 - Display inversion */ +#define PCF8833_ST_VSCROLL (1 << 7) /* Bit 6: D15 - Vertical scroll mode */ + +/* Byte 4: All zero */ + #endif /* __DRIVERS_LCD_PCF8833_H */
\ No newline at end of file diff --git a/nuttx/drivers/lcd/s1d15g10.h b/nuttx/drivers/lcd/s1d15g10.h index df2dd8be2..9b5f7738f 100644 --- a/nuttx/drivers/lcd/s1d15g10.h +++ b/nuttx/drivers/lcd/s1d15g10.h @@ -1,141 +1,141 @@ -/**************************************************************************************
- * drivers/lcd/s1d15g10.h
- * Definitions for the Epson S1D15G0 LCD controller
- *
- * Copyright (C) 2010 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * References: S1D15G0D08B000, Seiko Epson Corportation, 2002.
- *
- * 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. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS 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.
- *
- **************************************************************************************/
-
-#ifndef __DRIVERS_LCD_S1D15G10_H
-#define __DRIVERS_LCD_S1D15G10_H
-
-/**************************************************************************************
- * Included Files
- **************************************************************************************/
-
-/**************************************************************************************
- * Pre-processor Definitions
- **************************************************************************************/
-
-/* Epson S1D15G10 Command Set */
-
-#define S1D15G10_DISON 0xaf /* Display on; Data: none */
-#define S1D15G10_DISOFF 0xae /* Display off; Data: none */
-#define S1D15G10_DISNOR 0xa6 /* Normal display; Data: none */
-#define S1D15G10_DISINV 0xa7 /* Inverse display; Data: none */
-#define S1D15G10_COMSCN 0xbb /* Common scan direction; Data: (1) common scan direction */
-#define S1D15G10_DISCTL 0xca /* Display control; Data: Data: (1) CL div, F1/2 pat, (2) duty, (3) FR inverse (4) dispersion */
-#define S1D15G10_SLPIN 0x95 /* Sleep in; Data: none */
-#define S1D15G10_SLPOUT 0x94 /* Sleep out; Data: none */
-#define S1D15G10_PASET 0x75 /* Page address set; Data: (1) start page, (2) end page */
-#define S1D15G10_CASET 0x15 /* Column address set; Data: (1) start addr, (2) end addr */
-#define S1D15G10_DATCTL 0xbc /* Data scan direction, etc.; Data: (1) inverse, scan dir (2) RGB, (3) gray-scale */
-#define S1D15G10_RGBSET8 0xce /* 256-color position set; Data: (1-8) red tones, (9-16) green tones, (17-20) blue tones */
-#define S1D15G10_RAMWR 0x5c /* Writing to memory; Data: (1) write data */
-#define S1D15G10_RAMRD 0x5d /* Reading from memory; Data: (1) read data */
-#define S1D15G10_PTLIN 0xa8 /* Partial display in; Data: (1) start addr, (2) end addr */
-#define S1D15G10_PTLOUT 0xa9 /* Partial display out; Data: none */
-#define S1D15G10_RMWIN 0xe0 /* Read and modify write; Data: none */
-#define S1D15G10_RMWOUT 0xee /* End; Data: none */
-#define S1D15G10_ASCSET 0xaa /* Area scroll set; Data: (1) top addr, (2) bottom addr, (3) Num blocks, (4) scroll mode */
-#define S1D15G10_SCSTART 0xab /* Scroll start set; Data: (1) start block addr */
-#define S1D15G10_OSCON 0xd1 /* Internal oscillation on; Data: none */
-#define S1D15G10_OSCOFF 0xd2 /* Internal oscillation off; Data: none */
-#define S1D15G10_PWRCTR 0x20 /* Power control; Data: (1) LCD drive power */
-#define S1D15G10_VOLCTR 0x81 /* Electronic volume control; Data: (1) volume value, (2) resistance ratio */
-#define S1D15G10_VOLUP 0xd6 /* Increment electronic control by 1; Data: none */
-#define S1D15G10_VOLDOWN 0xd7 /* Decrement electronic control by 1; Data: none */
-#define S1D15G10_TMPGRD 0x82 /* Temperature gradient set; Data: (1-14) temperature gradient */
-#define S1D15G10_EPCTIN 0xcd /* Control EEPROM; Data: (1) read/write */
-#define S1D15G10_EPCOUT 0xcc /* Cancel EEPROM control; Data: none */
-#define S1D15G10_EPMWR 0xfc /* Write into EEPROM; Data: none */
-#define S1D15G10_EPMRD 0xfd /* Read from EEPROM; Data: none */
-#define S1D15G10_EPSRRD1 0x7c /* Read register 1; Data: none */
-#define S1D15G10_EPSRRD2 0x7d /* Read regiser 2; Data: none */
-#define S1D15G10_NOP 0x25 /* NOP intruction (0x45?); Data: none */
-#define S1D15G10_STREAD 0x20 /* Status read; Data: none */
-
-/* Display control (DISCTL) bit definitions */
-
-#define DISCTL_PERIOD_SHIFT (0) /* P1: Bits 0-1, F1 and F2 drive-pattern switching period */
-#define DISCTL_PERIOD_MASK (3 << DISCTL_PERIOD_SHIFT)
-# define DISCTL_PERIOD_8 (0 << DISCTL_PERIOD_SHIFT)
-# define DISCTL_PERIOD_4 (1 << DISCTL_PERIOD_SHIFT)
-# define DISCTL_PERIOD_16 (2 << DISCTL_PERIOD_SHIFT)
-# define DISCTL_PERIOD_FLD (3 << DISCTL_PERIOD_SHIFT)
-#define DISCTL_CLDIV_SHIFT (2) /* P1: Bits 2-4, Clock divider */
-#define DISCTL_CLDIV_MASK (7 << DISCTL_CLDIV_SHIFT)
-# define DISCTL_CLDIV_2 (0 << DISCTL_CLDIV_SHIFT)
-# define DISCTL_CLDIV_4 (1 << DISCTL_CLDIV_SHIFT)
-# define DISCTL_CLDIV_8 (2 << DISCTL_CLDIV_SHIFT)
-# define DISCTL_CLDIV_NONE (3 << DISCTL_CLDIV_SHIFT)
-
-/* Power control (PWRCTR) bit definitions */
-
-#define PWCTR_REFVOLTAGE (1 << 0) /* P1: Bit 0, Turn on reference voltage generation circuit. */
-#define PWCTR_REGULATOR (1 << 1) /* P1: Bit 1, Turn on voltage regulator and circuit voltage follower. */
-#define PWCTR_BOOSTER2 (1 << 2) /* P1: Bit 2, Turn on secondary booster/step-down circuit. */
-#define PWCTR_BOOSTER1 (1 << 3) /* P1: Bit 3, Turn on primary booster circuit. */
-#define PWCTR_EXTR (1 << 4) /* P1: Bit 4, Use external resistance to adjust voltage. */
-
-/* Data control (DATCTL) bit definitions */
-
-#define DATCTL_PGADDR_INV (1 << 0) /* P1: Bit 0, Inverse display of the page address. */
-#define DATCTL_COLADDR_REV (1 << 1) /* P1: Bit 1, Reverse turn of column address. */
-#define DATCTL_ADDR_PGDIR (1 << 2) /* P1: Bit 2, Address-scan direction in page (vs column) direction. */
-
-#define DATCTL_BGR (1 << 0) /* P2: Bit0, RGB->BGR */
-
-#define DATCTL_8GRAY (1) /* P3: Bits 0-2 = 001, 8 gray-scale */
-#define DATCTL_16GRAY_A (2) /* P3: Bits 0-2 = 010, 16 gray-scale display type A */
-#define DATCTL_16GRAY_B (4) /* P3: Bits 0-2 = 100, 16 gray-scale display type B */
-
-/* Status register bit definions (after reset or NOP) */
-
-#define S1D15G10_SR_PARTIAL (1 << 0) /* Bit 0: Partial display */
-#define S1D15G10_SR_NORMAL (1 << 1) /* Bit 1: Normal (vs. inverse) display */
-#define S1D15G10_SR_EEPROM (1 << 2) /* Bit 2: EEPROM access */
-#define S1D15G10_SR_DISPON (1 << 3) /* Bit 3: Display on */
-#define S1D15G10_SR_COLSCAN (1 << 4) /* Bit 4: Column (vs. page) scan direction */
-#define S1D15G10_SR_RMW (1 << 5) /* Bit 5: Read modify write */
-#define S1D15G10_SR_SCROLL (3 << 6) /* Bits 6-7: Area scroll mode */
-
-/* Status register bit definions (after EPSRRD1) */
-
-#define S1D15G10_SR_VOLUME 0x3f /* Bits 0-5: Electronic volume control values */
-
-/* Status register bit definions (after EPSRRD2) */
-
-#define S1D15G10_SR_RRATIO 0x07 /* Bits 0-2: Built-in resistance ratio */
-
+/************************************************************************************** + * drivers/lcd/s1d15g10.h + * Definitions for the Epson S1D15G0 LCD controller + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * References: S1D15G0D08B000, Seiko Epson Corportation, 2002. + * + * 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. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS 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. + * + **************************************************************************************/ + +#ifndef __DRIVERS_LCD_S1D15G10_H +#define __DRIVERS_LCD_S1D15G10_H + +/************************************************************************************** + * Included Files + **************************************************************************************/ + +/************************************************************************************** + * Pre-processor Definitions + **************************************************************************************/ + +/* Epson S1D15G10 Command Set */ + +#define S1D15G10_DISON 0xaf /* Display on; Data: none */ +#define S1D15G10_DISOFF 0xae /* Display off; Data: none */ +#define S1D15G10_DISNOR 0xa6 /* Normal display; Data: none */ +#define S1D15G10_DISINV 0xa7 /* Inverse display; Data: none */ +#define S1D15G10_COMSCN 0xbb /* Common scan direction; Data: (1) common scan direction */ +#define S1D15G10_DISCTL 0xca /* Display control; Data: Data: (1) CL div, F1/2 pat, (2) duty, (3) FR inverse (4) dispersion */ +#define S1D15G10_SLPIN 0x95 /* Sleep in; Data: none */ +#define S1D15G10_SLPOUT 0x94 /* Sleep out; Data: none */ +#define S1D15G10_PASET 0x75 /* Page address set; Data: (1) start page, (2) end page */ +#define S1D15G10_CASET 0x15 /* Column address set; Data: (1) start addr, (2) end addr */ +#define S1D15G10_DATCTL 0xbc /* Data scan direction, etc.; Data: (1) inverse, scan dir (2) RGB, (3) gray-scale */ +#define S1D15G10_RGBSET8 0xce /* 256-color position set; Data: (1-8) red tones, (9-16) green tones, (17-20) blue tones */ +#define S1D15G10_RAMWR 0x5c /* Writing to memory; Data: (1) write data */ +#define S1D15G10_RAMRD 0x5d /* Reading from memory; Data: (1) read data */ +#define S1D15G10_PTLIN 0xa8 /* Partial display in; Data: (1) start addr, (2) end addr */ +#define S1D15G10_PTLOUT 0xa9 /* Partial display out; Data: none */ +#define S1D15G10_RMWIN 0xe0 /* Read and modify write; Data: none */ +#define S1D15G10_RMWOUT 0xee /* End; Data: none */ +#define S1D15G10_ASCSET 0xaa /* Area scroll set; Data: (1) top addr, (2) bottom addr, (3) Num blocks, (4) scroll mode */ +#define S1D15G10_SCSTART 0xab /* Scroll start set; Data: (1) start block addr */ +#define S1D15G10_OSCON 0xd1 /* Internal oscillation on; Data: none */ +#define S1D15G10_OSCOFF 0xd2 /* Internal oscillation off; Data: none */ +#define S1D15G10_PWRCTR 0x20 /* Power control; Data: (1) LCD drive power */ +#define S1D15G10_VOLCTR 0x81 /* Electronic volume control; Data: (1) volume value, (2) resistance ratio */ +#define S1D15G10_VOLUP 0xd6 /* Increment electronic control by 1; Data: none */ +#define S1D15G10_VOLDOWN 0xd7 /* Decrement electronic control by 1; Data: none */ +#define S1D15G10_TMPGRD 0x82 /* Temperature gradient set; Data: (1-14) temperature gradient */ +#define S1D15G10_EPCTIN 0xcd /* Control EEPROM; Data: (1) read/write */ +#define S1D15G10_EPCOUT 0xcc /* Cancel EEPROM control; Data: none */ +#define S1D15G10_EPMWR 0xfc /* Write into EEPROM; Data: none */ +#define S1D15G10_EPMRD 0xfd /* Read from EEPROM; Data: none */ +#define S1D15G10_EPSRRD1 0x7c /* Read register 1; Data: none */ +#define S1D15G10_EPSRRD2 0x7d /* Read regiser 2; Data: none */ +#define S1D15G10_NOP 0x25 /* NOP intruction (0x45?); Data: none */ +#define S1D15G10_STREAD 0x20 /* Status read; Data: none */ + +/* Display control (DISCTL) bit definitions */ + +#define DISCTL_PERIOD_SHIFT (0) /* P1: Bits 0-1, F1 and F2 drive-pattern switching period */ +#define DISCTL_PERIOD_MASK (3 << DISCTL_PERIOD_SHIFT) +# define DISCTL_PERIOD_8 (0 << DISCTL_PERIOD_SHIFT) +# define DISCTL_PERIOD_4 (1 << DISCTL_PERIOD_SHIFT) +# define DISCTL_PERIOD_16 (2 << DISCTL_PERIOD_SHIFT) +# define DISCTL_PERIOD_FLD (3 << DISCTL_PERIOD_SHIFT) +#define DISCTL_CLDIV_SHIFT (2) /* P1: Bits 2-4, Clock divider */ +#define DISCTL_CLDIV_MASK (7 << DISCTL_CLDIV_SHIFT) +# define DISCTL_CLDIV_2 (0 << DISCTL_CLDIV_SHIFT) +# define DISCTL_CLDIV_4 (1 << DISCTL_CLDIV_SHIFT) +# define DISCTL_CLDIV_8 (2 << DISCTL_CLDIV_SHIFT) +# define DISCTL_CLDIV_NONE (3 << DISCTL_CLDIV_SHIFT) + +/* Power control (PWRCTR) bit definitions */ + +#define PWCTR_REFVOLTAGE (1 << 0) /* P1: Bit 0, Turn on reference voltage generation circuit. */ +#define PWCTR_REGULATOR (1 << 1) /* P1: Bit 1, Turn on voltage regulator and circuit voltage follower. */ +#define PWCTR_BOOSTER2 (1 << 2) /* P1: Bit 2, Turn on secondary booster/step-down circuit. */ +#define PWCTR_BOOSTER1 (1 << 3) /* P1: Bit 3, Turn on primary booster circuit. */ +#define PWCTR_EXTR (1 << 4) /* P1: Bit 4, Use external resistance to adjust voltage. */ + +/* Data control (DATCTL) bit definitions */ + +#define DATCTL_PGADDR_INV (1 << 0) /* P1: Bit 0, Inverse display of the page address. */ +#define DATCTL_COLADDR_REV (1 << 1) /* P1: Bit 1, Reverse turn of column address. */ +#define DATCTL_ADDR_PGDIR (1 << 2) /* P1: Bit 2, Address-scan direction in page (vs column) direction. */ + +#define DATCTL_BGR (1 << 0) /* P2: Bit0, RGB->BGR */ + +#define DATCTL_8GRAY (1) /* P3: Bits 0-2 = 001, 8 gray-scale */ +#define DATCTL_16GRAY_A (2) /* P3: Bits 0-2 = 010, 16 gray-scale display type A */ +#define DATCTL_16GRAY_B (4) /* P3: Bits 0-2 = 100, 16 gray-scale display type B */ + +/* Status register bit definions (after reset or NOP) */ + +#define S1D15G10_SR_PARTIAL (1 << 0) /* Bit 0: Partial display */ +#define S1D15G10_SR_NORMAL (1 << 1) /* Bit 1: Normal (vs. inverse) display */ +#define S1D15G10_SR_EEPROM (1 << 2) /* Bit 2: EEPROM access */ +#define S1D15G10_SR_DISPON (1 << 3) /* Bit 3: Display on */ +#define S1D15G10_SR_COLSCAN (1 << 4) /* Bit 4: Column (vs. page) scan direction */ +#define S1D15G10_SR_RMW (1 << 5) /* Bit 5: Read modify write */ +#define S1D15G10_SR_SCROLL (3 << 6) /* Bits 6-7: Area scroll mode */ + +/* Status register bit definions (after EPSRRD1) */ + +#define S1D15G10_SR_VOLUME 0x3f /* Bits 0-5: Electronic volume control values */ + +/* Status register bit definions (after EPSRRD2) */ + +#define S1D15G10_SR_RRATIO 0x07 /* Bits 0-2: Built-in resistance ratio */ + #endif /* __DRIVERS_LCD_S1D15G10_H */
\ No newline at end of file diff --git a/nuttx/drivers/lcd/skeleton.c b/nuttx/drivers/lcd/skeleton.c index 1cb8b5955..83aa92018 100644 --- a/nuttx/drivers/lcd/skeleton.c +++ b/nuttx/drivers/lcd/skeleton.c @@ -2,7 +2,7 @@ * drivers/lcd/skeleton.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/lcd/ssd1305.h b/nuttx/drivers/lcd/ssd1305.h index 87c955de4..34678fa80 100644 --- a/nuttx/drivers/lcd/ssd1305.h +++ b/nuttx/drivers/lcd/ssd1305.h @@ -1,211 +1,211 @@ -/**************************************************************************************
- * drivers/lcd/ssd1305.h
- * Definitions for the Solomon Systech SSD1305 132x64 Dot Matrix OLED/PLED
- * Segment/Common Driver with C
- *
- * Copyright (C) 2010 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * References: SSD1305.pdf, "Solomon Systech SSD1305 132x64 Dot Matrix OLED/PLED
- * Segment/Common Driver with Controller," Solomon Systech Limited,
- * http://www.solomon-systech.com, May, 2008.
- *
- * 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. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS 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.
- *
- **************************************************************************************/
-
-#ifndef __DRIVERS_LCD_SSD1305_H
-#define __DRIVERS_LCD_SSD1305_H
-
-/**************************************************************************************
- * Included Files
- **************************************************************************************/
-
-/**************************************************************************************
- * Pre-processor Definitions
- **************************************************************************************/
-/* General Definitions ******************************************************/
-
-#define SSD1305_COLORA 0
-#define SSD1305_COLORB 1
-#define SSD1305_COLORC 2
-#define SSD1305_COLORD 3
-
-/* Fundamental Commands *****************************************************/
-#define SSD1305_SETCOLL 0x00 /* 0x00-0x0f: Set lower column address */
-# define SSD1305_COLL_MASK 0x0f
-#define SSD1305_SETCOLH 0x10 /* 0x10-0x1f: Set higher column address */
-# define SSD1305_COLH_MASK 0x0f
-#define SSD1305_ADDRMODE 0x20 /* 0x20: Set memory address mode */
-# define SSD1305_ADDRMODE_HOR 0x00 /* Data 1: Set horizontal address mode */
-# define SSD1305_ADDRMODE_VIRT 0x01 /* Data 1: Set virtal address mode */
-# define SSD1305_ADDRMODE_PAGE 0x02 /* Data 1: Set page address mode */
-#define SSD1305_SETCOLADDR 0x21 /* 0x21: Set column address */
- /* Data 1: Column start address: 0-131 */
- /* Data 2: Column end address: 0-131 */
-#define SSD1305_SETPAGEADDR 0x22 /* 0x22: Set page address */
- /* Data 1: Page start address: 0x00-0x7d */
- /* Data 2: Page end address: 0x00-0x7d */
-#define SSD1305_SETSTARTLINE 0x40 /* 0x40-7f: Set display start line */
-# define SSD1305_STARTLINE_MASK 0x3f
-
-#define SSD1305_SETCONTRAST 0x81 /* 0x81: Set contrast control */
- /* Data 1: Set 1 of 256 contrast steps */
-#define SSD1305_SETBRIGHTNESS 0x82 /* 0x82: Set brightness */
- /* Data 1: Set 1 of 256 contrast steps */
-#define SSD1305_SETLUT 0x91 /* 0x01: Set lookup table */
- /* Data 1: Pulse width: 31-63 */
- /* Data 2: Color A: 31-63 */
- /* Data 3: Color B: 31-63 */
- /* Data 4: Color C: 31-63 */
-#define SSD1305_SETBANKCOLOR1 0x92 /* 0x92: Set bank 1-16 color */
-# define SSD1305_SETBANK1(c) (c) /* Data 1, Bits 0-1: Bank 1 color */
-# define SSD1305_SETBANK2(c) (c << 2) /* Data 1, Bits 2-3: Bank 2 color */
-# define SSD1305_SETBANK3(c) (c << 4) /* Data 1, Bits 4-5: Bank 3 color */
-# define SSD1305_SETBANK4(c) (c << 6) /* Data 1, Bits 6-7: Bank 4 color */
-# define SSD1305_SETBANK5(c) (c) /* Data 2, Bits 0-1: Bank 5 color */
-# define SSD1305_SETBANK6(c) (c << 2) /* Data 2, Bits 2-3: Bank 6 color */
-# define SSD1305_SETBANK7(c) (c << 4) /* Data 2, Bits 4-5: Bank 7 color */
-# define SSD1305_SETBANK8(c) (c << 6) /* Data 2, Bits 6-7: Bank 8 color */
-# define SSD1305_SETBANK9(c) (c) /* Data 3, Bits 0-1: Bank 9 color */
-# define SSD1305_SETBANK10(c) (c << 2) /* Data 3, Bits 2-3: Bank 10 color */
-# define SSD1305_SETBANK11(c) (c << 4) /* Data 3, Bits 4-5: Bank 11 color */
-# define SSD1305_SETBANK12(c) (c << 6) /* Data 3, Bits 6-7: Bank 12 color */
-# define SSD1305_SETBANK13(c) (c) /* Data 4, Bits 0-1: Bank 13 color */
-# define SSD1305_SETBANK14(c) (c << 2) /* Data 4, Bits 2-3: Bank 14 color */
-# define SSD1305_SETBANK15(c) (c << 4) /* Data 4, Bits 4-5: Bank 15 color */
-# define SSD1305_SETBANK16(c) (c << 6) /* Data 4, Bits 6-7: Bank 16 color */
-#define SSD1305_SETBANKCOLOR2 0x93 /* 0x93: Set bank 17-32 color */
-# define SSD1305_SETBANK17(c) (c) /* Data 1, Bits 0-1: Bank 17 color */
-# define SSD1305_SETBANK18(c) (c << 2) /* Data 1, Bits 2-3: Bank 18 color */
-# define SSD1305_SETBANK19(c) (c << 4) /* Data 1, Bits 4-5: Bank 19 color */
-# define SSD1305_SETBANK20(c) (c << 6) /* Data 1, Bits 6-7: Bank 20 color */
-# define SSD1305_SETBANK21(c) (c) /* Data 2, Bits 0-1: Bank 21 color */
-# define SSD1305_SETBANK22(c) (c << 2) /* Data 2, Bits 2-3: Bank 22 color */
-# define SSD1305_SETBANK23(c) (c << 4) /* Data 2, Bits 4-5: Bank 23 color */
-# define SSD1305_SETBANK24(c) (c << 6) /* Data 2, Bits 6-7: Bank 24 color */
-# define SSD1305_SETBANK25(c) (c) /* Data 3, Bits 0-1: Bank 25 color */
-# define SSD1305_SETBANK26(c) (c << 2) /* Data 3, Bits 2-3: Bank 26 color */
-# define SSD1305_SETBANK27(c) (c << 4) /* Data 3, Bits 4-5: Bank 27 color */
-# define SSD1305_SETBANK28(c) (c << 6) /* Data 3, Bits 6-7: Bank 28 color */
-# define SSD1305_SETBANK29(c) (c) /* Data 4, Bits 0-1: Bank 29 color */
-# define SSD1305_SETBANK30(c) (c << 2) /* Data 4, Bits 2-3: Bank 30 color */
-# define SSD1305_SETBANK31(c) (c << 4) /* Data 4, Bits 4-5: Bank 31 color */
-# define SSD1305_SETBANK32(c) (c << 6) /* Data 4, Bits 6-7: Bank 32 color */
-#define SSD1305_MAPCOL0 0xa0 /* 0xa0: Column address 0 is mapped to SEG0 */
-#define SSD1305_MAPCOL131 0xa1 /* 0xa1: Column address 131 is mapped to SEG0 */
-#define SSD1305_DISPRAM 0xa4 /* 0xa4: Resume to RAM content display */
-#define SSD1305_DISPENTIRE 0xa5 /* 0xa5: Entire display ON */
-#define SSD1305_DISPNORMAL 0xa6 /* 0xa6: Normal display */
-#define SSD1305_DISPINVERTED 0xa7 /* 0xa7: Inverse display */
-
-#define SSD1305_SETMUX 0xa8 /* 0xa8: Set Multiplex Ratio*/
- /* Data 1: MUX ratio -1: 15-63 */
-#define SSD1305_DIMMODE 0xab /* 0xab: Dim mode setting */
- /* Data 1: Reserverd, must be zero */
- /* Data 2: Contrast for bank1: 0-255 */
- /* Data 3: Brightness for color bank: 0-255 */
-#define SSD1305_MSTRCONFIG 0xad /* 0xad: Master configuration */
-# define SSD1305_MSTRCONFIG_EXTVCC 0x8e /* Data 1: Select external Vcc */
-#define SSD1305_DISPONDIM 0xac /* 0xac: Display ON in dim mode */
-#define SSD1305_DISPOFF 0xae /* 0xae: Display OFF (sleep mode) */
-#define SSD1305_DISPON 0xaf /* 0xaf: Display ON in normal mode */
-#define SSD1305_SETPAGESTART 0xb0 /* 0xb0-b7: Set page start address */
-# define SSD1305_PAGESTART_MASK 0x07
-#define SSD1305_SETCOMNORMAL 0xc0 /* 0xc0: Set COM output, normal mode */
-#define SSD1305_SETCOMREMAPPED 0xc8 /* 0xc8: Set COM output, remapped mode */
-
-#define SSD1305_SETOFFSET 0xd3 /* 0xd3: Set display offset */
- /* Data 1: Vertical shift by COM: 0-63 */
-#define SSD1305_SETDCLK 0xd5 /* 0xd5: Set display clock divide ratio/oscillator */
-# define SSD1305_DCLKDIV_SHIFT (0) /* Data 1, Bits 0-3: DCLK divide ratio/frequency*/
-# define SSD1305_DCLKDIV_MASK 0x0f
-# define SSD1305_DCLKFREQ_SHIFT (4) /* Data 1, Bits 4-7: DCLK divide oscillator frequency */
-# define SSD1305_DCLKFREQ_MASK 0xf0
-#define SSD1305_SETCOLORMODE 0xd8 /* 0xd: Set area color and low power display modes */
-# define SSD1305_COLORMODE_MONO 0x00 /* Data 1, Bits 4-5: 00=monochrome */
-# define SSD1305_COLORMODE_COLOR 0x30 /* Data 1, Bits 4-5: 11=area color enable */
-# define SSD1305_POWERMODE_NORMAL 0x00 /* Data 1, Bits 0,2: 00=normal power mode */
-# define SSD1305_POWERMODE_LOW 0x05 /* Data 1, Bits 0,2: 11=low power display mode */
-#define SSD1305_SETPRECHARGE 0xd9 /* 0xd9: Set pre-charge period */
-# define SSD1305_PHASE1_SHIFT (0) /* Data 1, Bits 0-3: Phase 1 period of up to 15 DCLK clocks */
-# define SSD1305_PHASE1_MASK 0x0f
-# define SSD1305_PHASE2_SHIFT (4) /* Data 1, Bits 4-7: Phase 2 period of up to 15 DCLK clocks */
-# define SSD1305_PHASE2_MASK 0xf0
-#define SSD1305_SETCOMCONFIG 0xda /* 0xda: Set COM configuration */
-# define SSD1305_COMCONFIG_SEQ 0x02 /* Data 1, Bit 4: 0=Sequential COM pin configuration */
-# define SSD1305_COMCONFIG_ALT 0x12 /* Data 1, Bit 4: 1=Alternative COM pin configuration */
-# define SSD1305_COMCONFIG_NOREMAP 0x02 /* Data 1, Bit 5: 0=Disable COM Left/Right remap */
-# define SSD1305_COMCONFIG_REMAP 0x22 /* Data 1, Bit 5: 1=Enable COM Left/Right remap */
-#define SSD1305_SETVCOMHDESEL 0xdb /* 0xdb: Set VCOMH delselect level */
-# define SSD1305_VCOMH_x4p3 0x00 /* Data 1: ~0.43 x Vcc */
-# define SSD1305_VCOMH_x7p7 0x34 /* Data 1: ~0.77 x Vcc */
-# define SSD1305_VCOMH_x8p3 0x3c /* Data 1: ~0.83 x Vcc */
-#define SSD1305_ENTER_RMWMODE 0xe0 /* 0xe0: Enter the Read Modify Write mode */
-#define SSD1305_NOP 0xe3 /* 0xe3: NOP Command for no operation */
-#define SSD1305_EXIT_RMWMODE 0xee /* 0xee: Leave the Read Modify Write mode */
-
-/* Graphic Acceleration Commands ********************************************/
-
-#define SSD1305_HSCROLL_RIGHT 0x26 /* 0x26: Right horizontal scroll */
-#define SSD1305_HSCROLL_LEFT 0x27 /* 0x27: Left horizontal scroll */
- /* Data 1, Bits 0-2: Column scroll offset: 0-4 */
- /* Data 2, Bits 0-2: Start page address: 0-7 */
-#define SSD1305_HSCROLL_FRAMES6 0x00 /* Data 3, Bits 0-2: Timer interval, 000=6 frames */
-#define SSD1305_HSCROLL_FRAMES32 0x01 /* Data 3, Bits 0-2: Timer interval, 001=32 frames */
-#define SSD1305_HSCROLL_FRAMES64 0x02 /* Data 3, Bits 0-2: Timer interval, 010=64 frames */
-#define SSD1305_HSCROLL_FRAMES128 0x03 /* Data 3, Bits 0-2: Timer interval, 011=128 frames */
-#define SSD1305_HSCROLL_FRAMES3 0x04 /* Data 3, Bits 0-2: Timer interval, 100=3 frames */
-#define SSD1305_HSCROLL_FRAMES4 0x05 /* Data 3, Bits 0-2: Timer interval, 101=4 frames */
-#define SSD1305_HSCROLL_FRAMES2 0x06 /* Data 3, Bits 0-2: Timer interval, 110=2 frames */
- /* Data 4, Bits 0-2: End page address: 0-7 */
-
-#define SSD1305_VSCROLL_RIGHT 0x29 /* 0x26: Vertical and right horizontal scroll */
-#define SSD1305_VSCROLL_LEFT 0x2a /* 0x27: Vertical and left horizontal scroll */
- /* Data 1, Bits 0-2: Column scroll offset: 0-4 */
- /* Data 2, Bits 0-2: Start page address: 0-7 */
-#define SSD1305_VSCROLL_FRAMES6 0x00 /* Data 3, Bits 0-2: Timer interval, 000=6 frames */
-#define SSD1305_VSCROLL_FRAMES32 0x01 /* Data 3, Bits 0-2: Timer interval, 001=32 frames */
-#define SSD1305_VSCROLL_FRAMES64 0x02 /* Data 3, Bits 0-2: Timer interval, 010=64 frames */
-#define SSD1305_VSCROLL_FRAMES128 0x03 /* Data 3, Bits 0-2: Timer interval, 011=128 frames */
-#define SSD1305_VSCROLL_FRAMES3 0x04 /* Data 3, Bits 0-2: Timer interval, 100=3 frames */
-#define SSD1305_VSCROLL_FRAMES4 0x05 /* Data 3, Bits 0-2: Timer interval, 101=4 frames */
-#define SSD1305_VSCROLL_FRAMES2 0x06 /* Data 3, Bits 0-2: Timer interval, 110=2 frames */
- /* Data 4, Bits 0-2: End page address: 0-7 */
- /* Data 5, Bits 0-5: Vertical scrolling offset: 0-63 */
-#define SSD1305_SCROLL_STOP 0x2e /* 0x2e: Deactivate scroll */
-#define SSD1305_SCROLL_START 0x2f /* 0x2f: Activate scroll */
-#define SSD1305_VSCROLL_AREA 0xa3 /* 0xa3: Set vertical scroll area */
- /* Data 1: Number of rows in the top fixed area */
- /* Data 1: Number of rows in the scroll area */
-
-/* Status register bit definitions ******************************************/
-
-#define SSD1305_STATUS_DISPOFF (1 << 6) /* Bit 6: 1=Display off */
-
-#endif /* __DRIVERS_LCD_SSD1305_H */
+/************************************************************************************** + * drivers/lcd/ssd1305.h + * Definitions for the Solomon Systech SSD1305 132x64 Dot Matrix OLED/PLED + * Segment/Common Driver with C + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * References: SSD1305.pdf, "Solomon Systech SSD1305 132x64 Dot Matrix OLED/PLED + * Segment/Common Driver with Controller," Solomon Systech Limited, + * http://www.solomon-systech.com, May, 2008. + * + * 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. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS 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. + * + **************************************************************************************/ + +#ifndef __DRIVERS_LCD_SSD1305_H +#define __DRIVERS_LCD_SSD1305_H + +/************************************************************************************** + * Included Files + **************************************************************************************/ + +/************************************************************************************** + * Pre-processor Definitions + **************************************************************************************/ +/* General Definitions ******************************************************/ + +#define SSD1305_COLORA 0 +#define SSD1305_COLORB 1 +#define SSD1305_COLORC 2 +#define SSD1305_COLORD 3 + +/* Fundamental Commands *****************************************************/ +#define SSD1305_SETCOLL 0x00 /* 0x00-0x0f: Set lower column address */ +# define SSD1305_COLL_MASK 0x0f +#define SSD1305_SETCOLH 0x10 /* 0x10-0x1f: Set higher column address */ +# define SSD1305_COLH_MASK 0x0f +#define SSD1305_ADDRMODE 0x20 /* 0x20: Set memory address mode */ +# define SSD1305_ADDRMODE_HOR 0x00 /* Data 1: Set horizontal address mode */ +# define SSD1305_ADDRMODE_VIRT 0x01 /* Data 1: Set virtal address mode */ +# define SSD1305_ADDRMODE_PAGE 0x02 /* Data 1: Set page address mode */ +#define SSD1305_SETCOLADDR 0x21 /* 0x21: Set column address */ + /* Data 1: Column start address: 0-131 */ + /* Data 2: Column end address: 0-131 */ +#define SSD1305_SETPAGEADDR 0x22 /* 0x22: Set page address */ + /* Data 1: Page start address: 0x00-0x7d */ + /* Data 2: Page end address: 0x00-0x7d */ +#define SSD1305_SETSTARTLINE 0x40 /* 0x40-7f: Set display start line */ +# define SSD1305_STARTLINE_MASK 0x3f + +#define SSD1305_SETCONTRAST 0x81 /* 0x81: Set contrast control */ + /* Data 1: Set 1 of 256 contrast steps */ +#define SSD1305_SETBRIGHTNESS 0x82 /* 0x82: Set brightness */ + /* Data 1: Set 1 of 256 contrast steps */ +#define SSD1305_SETLUT 0x91 /* 0x01: Set lookup table */ + /* Data 1: Pulse width: 31-63 */ + /* Data 2: Color A: 31-63 */ + /* Data 3: Color B: 31-63 */ + /* Data 4: Color C: 31-63 */ +#define SSD1305_SETBANKCOLOR1 0x92 /* 0x92: Set bank 1-16 color */ +# define SSD1305_SETBANK1(c) (c) /* Data 1, Bits 0-1: Bank 1 color */ +# define SSD1305_SETBANK2(c) (c << 2) /* Data 1, Bits 2-3: Bank 2 color */ +# define SSD1305_SETBANK3(c) (c << 4) /* Data 1, Bits 4-5: Bank 3 color */ +# define SSD1305_SETBANK4(c) (c << 6) /* Data 1, Bits 6-7: Bank 4 color */ +# define SSD1305_SETBANK5(c) (c) /* Data 2, Bits 0-1: Bank 5 color */ +# define SSD1305_SETBANK6(c) (c << 2) /* Data 2, Bits 2-3: Bank 6 color */ +# define SSD1305_SETBANK7(c) (c << 4) /* Data 2, Bits 4-5: Bank 7 color */ +# define SSD1305_SETBANK8(c) (c << 6) /* Data 2, Bits 6-7: Bank 8 color */ +# define SSD1305_SETBANK9(c) (c) /* Data 3, Bits 0-1: Bank 9 color */ +# define SSD1305_SETBANK10(c) (c << 2) /* Data 3, Bits 2-3: Bank 10 color */ +# define SSD1305_SETBANK11(c) (c << 4) /* Data 3, Bits 4-5: Bank 11 color */ +# define SSD1305_SETBANK12(c) (c << 6) /* Data 3, Bits 6-7: Bank 12 color */ +# define SSD1305_SETBANK13(c) (c) /* Data 4, Bits 0-1: Bank 13 color */ +# define SSD1305_SETBANK14(c) (c << 2) /* Data 4, Bits 2-3: Bank 14 color */ +# define SSD1305_SETBANK15(c) (c << 4) /* Data 4, Bits 4-5: Bank 15 color */ +# define SSD1305_SETBANK16(c) (c << 6) /* Data 4, Bits 6-7: Bank 16 color */ +#define SSD1305_SETBANKCOLOR2 0x93 /* 0x93: Set bank 17-32 color */ +# define SSD1305_SETBANK17(c) (c) /* Data 1, Bits 0-1: Bank 17 color */ +# define SSD1305_SETBANK18(c) (c << 2) /* Data 1, Bits 2-3: Bank 18 color */ +# define SSD1305_SETBANK19(c) (c << 4) /* Data 1, Bits 4-5: Bank 19 color */ +# define SSD1305_SETBANK20(c) (c << 6) /* Data 1, Bits 6-7: Bank 20 color */ +# define SSD1305_SETBANK21(c) (c) /* Data 2, Bits 0-1: Bank 21 color */ +# define SSD1305_SETBANK22(c) (c << 2) /* Data 2, Bits 2-3: Bank 22 color */ +# define SSD1305_SETBANK23(c) (c << 4) /* Data 2, Bits 4-5: Bank 23 color */ +# define SSD1305_SETBANK24(c) (c << 6) /* Data 2, Bits 6-7: Bank 24 color */ +# define SSD1305_SETBANK25(c) (c) /* Data 3, Bits 0-1: Bank 25 color */ +# define SSD1305_SETBANK26(c) (c << 2) /* Data 3, Bits 2-3: Bank 26 color */ +# define SSD1305_SETBANK27(c) (c << 4) /* Data 3, Bits 4-5: Bank 27 color */ +# define SSD1305_SETBANK28(c) (c << 6) /* Data 3, Bits 6-7: Bank 28 color */ +# define SSD1305_SETBANK29(c) (c) /* Data 4, Bits 0-1: Bank 29 color */ +# define SSD1305_SETBANK30(c) (c << 2) /* Data 4, Bits 2-3: Bank 30 color */ +# define SSD1305_SETBANK31(c) (c << 4) /* Data 4, Bits 4-5: Bank 31 color */ +# define SSD1305_SETBANK32(c) (c << 6) /* Data 4, Bits 6-7: Bank 32 color */ +#define SSD1305_MAPCOL0 0xa0 /* 0xa0: Column address 0 is mapped to SEG0 */ +#define SSD1305_MAPCOL131 0xa1 /* 0xa1: Column address 131 is mapped to SEG0 */ +#define SSD1305_DISPRAM 0xa4 /* 0xa4: Resume to RAM content display */ +#define SSD1305_DISPENTIRE 0xa5 /* 0xa5: Entire display ON */ +#define SSD1305_DISPNORMAL 0xa6 /* 0xa6: Normal display */ +#define SSD1305_DISPINVERTED 0xa7 /* 0xa7: Inverse display */ + +#define SSD1305_SETMUX 0xa8 /* 0xa8: Set Multiplex Ratio*/ + /* Data 1: MUX ratio -1: 15-63 */ +#define SSD1305_DIMMODE 0xab /* 0xab: Dim mode setting */ + /* Data 1: Reserverd, must be zero */ + /* Data 2: Contrast for bank1: 0-255 */ + /* Data 3: Brightness for color bank: 0-255 */ +#define SSD1305_MSTRCONFIG 0xad /* 0xad: Master configuration */ +# define SSD1305_MSTRCONFIG_EXTVCC 0x8e /* Data 1: Select external Vcc */ +#define SSD1305_DISPONDIM 0xac /* 0xac: Display ON in dim mode */ +#define SSD1305_DISPOFF 0xae /* 0xae: Display OFF (sleep mode) */ +#define SSD1305_DISPON 0xaf /* 0xaf: Display ON in normal mode */ +#define SSD1305_SETPAGESTART 0xb0 /* 0xb0-b7: Set page start address */ +# define SSD1305_PAGESTART_MASK 0x07 +#define SSD1305_SETCOMNORMAL 0xc0 /* 0xc0: Set COM output, normal mode */ +#define SSD1305_SETCOMREMAPPED 0xc8 /* 0xc8: Set COM output, remapped mode */ + +#define SSD1305_SETOFFSET 0xd3 /* 0xd3: Set display offset */ + /* Data 1: Vertical shift by COM: 0-63 */ +#define SSD1305_SETDCLK 0xd5 /* 0xd5: Set display clock divide ratio/oscillator */ +# define SSD1305_DCLKDIV_SHIFT (0) /* Data 1, Bits 0-3: DCLK divide ratio/frequency*/ +# define SSD1305_DCLKDIV_MASK 0x0f +# define SSD1305_DCLKFREQ_SHIFT (4) /* Data 1, Bits 4-7: DCLK divide oscillator frequency */ +# define SSD1305_DCLKFREQ_MASK 0xf0 +#define SSD1305_SETCOLORMODE 0xd8 /* 0xd: Set area color and low power display modes */ +# define SSD1305_COLORMODE_MONO 0x00 /* Data 1, Bits 4-5: 00=monochrome */ +# define SSD1305_COLORMODE_COLOR 0x30 /* Data 1, Bits 4-5: 11=area color enable */ +# define SSD1305_POWERMODE_NORMAL 0x00 /* Data 1, Bits 0,2: 00=normal power mode */ +# define SSD1305_POWERMODE_LOW 0x05 /* Data 1, Bits 0,2: 11=low power display mode */ +#define SSD1305_SETPRECHARGE 0xd9 /* 0xd9: Set pre-charge period */ +# define SSD1305_PHASE1_SHIFT (0) /* Data 1, Bits 0-3: Phase 1 period of up to 15 DCLK clocks */ +# define SSD1305_PHASE1_MASK 0x0f +# define SSD1305_PHASE2_SHIFT (4) /* Data 1, Bits 4-7: Phase 2 period of up to 15 DCLK clocks */ +# define SSD1305_PHASE2_MASK 0xf0 +#define SSD1305_SETCOMCONFIG 0xda /* 0xda: Set COM configuration */ +# define SSD1305_COMCONFIG_SEQ 0x02 /* Data 1, Bit 4: 0=Sequential COM pin configuration */ +# define SSD1305_COMCONFIG_ALT 0x12 /* Data 1, Bit 4: 1=Alternative COM pin configuration */ +# define SSD1305_COMCONFIG_NOREMAP 0x02 /* Data 1, Bit 5: 0=Disable COM Left/Right remap */ +# define SSD1305_COMCONFIG_REMAP 0x22 /* Data 1, Bit 5: 1=Enable COM Left/Right remap */ +#define SSD1305_SETVCOMHDESEL 0xdb /* 0xdb: Set VCOMH delselect level */ +# define SSD1305_VCOMH_x4p3 0x00 /* Data 1: ~0.43 x Vcc */ +# define SSD1305_VCOMH_x7p7 0x34 /* Data 1: ~0.77 x Vcc */ +# define SSD1305_VCOMH_x8p3 0x3c /* Data 1: ~0.83 x Vcc */ +#define SSD1305_ENTER_RMWMODE 0xe0 /* 0xe0: Enter the Read Modify Write mode */ +#define SSD1305_NOP 0xe3 /* 0xe3: NOP Command for no operation */ +#define SSD1305_EXIT_RMWMODE 0xee /* 0xee: Leave the Read Modify Write mode */ + +/* Graphic Acceleration Commands ********************************************/ + +#define SSD1305_HSCROLL_RIGHT 0x26 /* 0x26: Right horizontal scroll */ +#define SSD1305_HSCROLL_LEFT 0x27 /* 0x27: Left horizontal scroll */ + /* Data 1, Bits 0-2: Column scroll offset: 0-4 */ + /* Data 2, Bits 0-2: Start page address: 0-7 */ +#define SSD1305_HSCROLL_FRAMES6 0x00 /* Data 3, Bits 0-2: Timer interval, 000=6 frames */ +#define SSD1305_HSCROLL_FRAMES32 0x01 /* Data 3, Bits 0-2: Timer interval, 001=32 frames */ +#define SSD1305_HSCROLL_FRAMES64 0x02 /* Data 3, Bits 0-2: Timer interval, 010=64 frames */ +#define SSD1305_HSCROLL_FRAMES128 0x03 /* Data 3, Bits 0-2: Timer interval, 011=128 frames */ +#define SSD1305_HSCROLL_FRAMES3 0x04 /* Data 3, Bits 0-2: Timer interval, 100=3 frames */ +#define SSD1305_HSCROLL_FRAMES4 0x05 /* Data 3, Bits 0-2: Timer interval, 101=4 frames */ +#define SSD1305_HSCROLL_FRAMES2 0x06 /* Data 3, Bits 0-2: Timer interval, 110=2 frames */ + /* Data 4, Bits 0-2: End page address: 0-7 */ + +#define SSD1305_VSCROLL_RIGHT 0x29 /* 0x26: Vertical and right horizontal scroll */ +#define SSD1305_VSCROLL_LEFT 0x2a /* 0x27: Vertical and left horizontal scroll */ + /* Data 1, Bits 0-2: Column scroll offset: 0-4 */ + /* Data 2, Bits 0-2: Start page address: 0-7 */ +#define SSD1305_VSCROLL_FRAMES6 0x00 /* Data 3, Bits 0-2: Timer interval, 000=6 frames */ +#define SSD1305_VSCROLL_FRAMES32 0x01 /* Data 3, Bits 0-2: Timer interval, 001=32 frames */ +#define SSD1305_VSCROLL_FRAMES64 0x02 /* Data 3, Bits 0-2: Timer interval, 010=64 frames */ +#define SSD1305_VSCROLL_FRAMES128 0x03 /* Data 3, Bits 0-2: Timer interval, 011=128 frames */ +#define SSD1305_VSCROLL_FRAMES3 0x04 /* Data 3, Bits 0-2: Timer interval, 100=3 frames */ +#define SSD1305_VSCROLL_FRAMES4 0x05 /* Data 3, Bits 0-2: Timer interval, 101=4 frames */ +#define SSD1305_VSCROLL_FRAMES2 0x06 /* Data 3, Bits 0-2: Timer interval, 110=2 frames */ + /* Data 4, Bits 0-2: End page address: 0-7 */ + /* Data 5, Bits 0-5: Vertical scrolling offset: 0-63 */ +#define SSD1305_SCROLL_STOP 0x2e /* 0x2e: Deactivate scroll */ +#define SSD1305_SCROLL_START 0x2f /* 0x2f: Activate scroll */ +#define SSD1305_VSCROLL_AREA 0xa3 /* 0xa3: Set vertical scroll area */ + /* Data 1: Number of rows in the top fixed area */ + /* Data 1: Number of rows in the scroll area */ + +/* Status register bit definitions ******************************************/ + +#define SSD1305_STATUS_DISPOFF (1 << 6) /* Bit 6: 1=Display off */ + +#endif /* __DRIVERS_LCD_SSD1305_H */ diff --git a/nuttx/drivers/lcd/ug-9664hswag01.c b/nuttx/drivers/lcd/ug-9664hswag01.c index bb49f20e6..e0e8e8e3a 100644 --- a/nuttx/drivers/lcd/ug-9664hswag01.c +++ b/nuttx/drivers/lcd/ug-9664hswag01.c @@ -4,7 +4,7 @@ * controller. * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Reference: "Product Specification, OEL Display Module, UG-9664HSWAG01", Univision * Technology Inc., SAS1-6020-B, January 3, 2008. diff --git a/nuttx/drivers/mmcsd/Kconfig b/nuttx/drivers/mmcsd/Kconfig index fc682e706..c224f220a 100644 --- a/nuttx/drivers/mmcsd/Kconfig +++ b/nuttx/drivers/mmcsd/Kconfig @@ -40,7 +40,7 @@ config MMCSD_HAVECARDDETECT config MMCSD_SPI bool "MMC/SD spi transfer support" default y - + config MMCSD_SPICLOCK int "MMC/SD maximum SPI clock" default 20000000 diff --git a/nuttx/drivers/mmcsd/Make.defs b/nuttx/drivers/mmcsd/Make.defs index 48e5d4fb6..850456597 100644 --- a/nuttx/drivers/mmcsd/Make.defs +++ b/nuttx/drivers/mmcsd/Make.defs @@ -2,7 +2,7 @@ # drivers/mmcsd/Make.defs # # Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/mmcsd/mmcsd_csd.h b/nuttx/drivers/mmcsd/mmcsd_csd.h index e35eacad5..d5343aa84 100644 --- a/nuttx/drivers/mmcsd/mmcsd_csd.h +++ b/nuttx/drivers/mmcsd/mmcsd_csd.h @@ -2,7 +2,7 @@ * drivers/mmcsd/mmcsd_csd.h * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/mmcsd/mmcsd_debug.c b/nuttx/drivers/mmcsd/mmcsd_debug.c index 03872f5cf..0bd7f896e 100644 --- a/nuttx/drivers/mmcsd/mmcsd_debug.c +++ b/nuttx/drivers/mmcsd/mmcsd_debug.c @@ -2,7 +2,7 @@ * drivers/mmcsd/mmcsd_debug.c * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/mmcsd/mmcsd_internal.h b/nuttx/drivers/mmcsd/mmcsd_internal.h index 577ebbba9..ed669cdfa 100644 --- a/nuttx/drivers/mmcsd/mmcsd_internal.h +++ b/nuttx/drivers/mmcsd/mmcsd_internal.h @@ -2,7 +2,7 @@ * drivers/mmcsd/mmcsd_internal.h * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.c b/nuttx/drivers/mmcsd/mmcsd_sdio.c index 90c73261a..d0bc6659c 100644 --- a/nuttx/drivers/mmcsd/mmcsd_sdio.c +++ b/nuttx/drivers/mmcsd/mmcsd_sdio.c @@ -3171,7 +3171,9 @@ errout_with_buffers: rwb_uninitialize(&priv->rwbuffer); errout_with_hwinit: #endif - mmcsd_hwuninitialize(priv); + mmcsd_hwuninitialize(priv); /* This will free the private data structure */ + return ret; + errout_with_alloc: kfree(priv); return ret; diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.h b/nuttx/drivers/mmcsd/mmcsd_sdio.h index 75c97bd65..9e3794e25 100644 --- a/nuttx/drivers/mmcsd/mmcsd_sdio.h +++ b/nuttx/drivers/mmcsd/mmcsd_sdio.h @@ -1,339 +1,339 @@ -/********************************************************************************************
- * drivers/mmcsd/mmcsd_sdio.h
- *
- * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * 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. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS 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.
- *
- ********************************************************************************************/
-
-#ifndef __DRIVERS_MMCSD_MMCSD_SDIO_H
-#define __DRIVERS_MMCSD_MMCSD_SDIO_H
-
-/********************************************************************************************
- * Included Files
- ********************************************************************************************/
-
-#include <nuttx/config.h>
-#include <stdint.h>
-
-/********************************************************************************************
- * Pre-Processor Definitions
- ********************************************************************************************/
-
-/* CMD8 Argument:
- * [31:12]: Reserved (shall be set to '0')
- * [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V)
- * [7:0]: Check Pattern (recommended 0xaa)
- * CMD8 Response: R7
- */
-
-#define MMCSD_CMD8VOLTAGE_SHIFT (8) /* Bits 8-11: Supply voltage */
-#define MMCSD_CMD8VOLTAGE_MASK ((uint32_t)0x0f << MMCSD_CMD8VOLTAGE_SHIFT)
-# define MMCSD_CMD8VOLTAGE_27 ((uint32_t)0x01 << MMCSD_CMD8VOLTAGE_SHIFT) /* 2.7-3.6V */
-#define MMCSD_CMD8ECHO_SHIFT (0) /* Bits 0-7: Check pattern */
-#define MMCSD_CMD8ECHO_MASK ((uint32_t)0xff << MMCSD_CMD8ECHO_SHIFT)
-# define MMCSD_CMD8CHECKPATTERN ((uint32_t)0xaa << MMCSD_CMD8ECHO_SHIFT)
-
-/* ACMD6 argument */
-
-#define MMCSD_ACMD6_BUSWIDTH_1 ((uint32_t)0) /* Bus width = 1-bit */
-#define MMCSD_ACMD6_BUSWIDTH_4 ((uint32_t)2) /* Bus width = 4-bit */
-
-/* ACMD41 argument */
-
-#define MMCSD_ACMD41_VOLTAGEWINDOW ((uint32_t)0x80100000)
-#define MMCSD_ACMD41_HIGHCAPACITY ((uint32_t)1 << 30)
-#define MMCSD_ACMD41_STDCAPACITY ((uint32_t)0)
-
-/* ACMD42 argument */
-
-#define MMCSD_ACMD42_CD_DISCONNECT ((uint32_t)0) /* Disconnect card detection logic */
-#define MMCSD_ACMD42_CD_CONNECT ((uint32_t)1) /* Connect card detection logic */
-
-/* R1 Card Status bit definitions */
-
-#define MMCSD_R1_OUTOFRANGE ((uint32_t)1 << 31) /* Bad argument */
-#define MMCSD_R1_ADDRESSERROR ((uint32_t)1 << 30) /* Bad address */
-#define MMCSD_R1_BLOCKLENERROR ((uint32_t)1 << 29) /* Bad block length */
-#define MMCSD_R1_ERASESEQERROR ((uint32_t)1 << 28) /* Erase cmd error */
-#define MMCSD_R1_ERASEPARAM ((uint32_t)1 << 27) /* Bad write blocks */
-#define MMCSD_R1_WPVIOLATION ((uint32_t)1 << 26) /* Erase access failure */
-#define MMCSD_R1_CARDISLOCKED ((uint32_t)1 << 25) /* Card is locked */
-#define MMCSD_R1_LOCKUNLOCKFAILED ((uint32_t)1 << 24) /* Password error */
-#define MMCSD_R1_COMCRCERROR ((uint32_t)1 << 23) /* CRC error */
-#define MMCSD_R1_ILLEGALCOMMAND ((uint32_t)1 << 22) /* Bad command */
-#define MMCSD_R1_CARDECCFAILED ((uint32_t)1 << 21) /* Failed to correct data */
-#define MMCSD_R1_CCERROR ((uint32_t)1 << 20) /* Card controller error */
-#define MMCSD_R1_ERROR ((uint32_t)1 << 19) /* General error */
-#define MMCSD_R1_UNDERRUN ((uint32_t)1 << 18) /* Underrun (MMC only) */
-#define MMCSD_R1_OVERRRUN ((uint32_t)1 << 17) /* Overrun (MMC only) */
-#define MMCSD_R1_CIDCSDOVERWRITE ((uint32_t)1 << 16) /* CID/CSD error */
-#define MMCSD_R1_WPERASESKIP ((uint32_t)1 << 15) /* Not all erased */
-#define MMCSD_R1_CARDECCDISABLED ((uint32_t)1 << 14) /* Internal ECC not used */
-#define MMCSD_R1_ERASERESET ((uint32_t)1 << 13) /* Reset sequence cleared */
-#define MMCSD_R1_STATE_SHIFT (9) /* Current card state */
-#define MMCSD_R1_STATE_MASK ((uint32_t)15 << MMCSD_R1_STATE_SHIFT)
- /* Card identification mode states */
-# define MMCSD_R1_STATE_IDLE ((uint32_t)0 << MMCSD_R1_STATE_SHIFT) /* 0=Idle state */
-# define MMCSD_R1_STATE_READY ((uint32_t)1 << MMCSD_R1_STATE_SHIFT) /* 1=Ready state */
-# define MMCSD_R1_STATE_IDENT ((uint32_t)2 << MMCSD_R1_STATE_SHIFT) /* 2=Identification state */
- /* Data transfer states */
-# define MMCSD_R1_STATE_STBY ((uint32_t)3 << MMCSD_R1_STATE_SHIFT) /* 3=Standby state */
-# define MMCSD_R1_STATE_TRAN ((uint32_t)4 << MMCSD_R1_STATE_SHIFT) /* 4=Transfer state */
-# define MMCSD_R1_STATE_DATA ((uint32_t)5 << MMCSD_R1_STATE_SHIFT) /* 5=Sending data state */
-# define MMCSD_R1_STATE_RCV ((uint32_t)6 << MMCSD_R1_STATE_SHIFT) /* 6=Receiving data state */
-# define MMCSD_R1_STATE_PRG ((uint32_t)7 << MMCSD_R1_STATE_SHIFT) /* 7=Programming state */
-# define MMCSD_R1_STATE_DIS ((uint32_t)8 << MMCSD_R1_STATE_SHIFT) /* 8=Disconnect state */
-#define MMCSD_R1_READYFORDATA ((uint32_t)1 << 8) /* Buffer empty */
-#define MMCSD_R1_APPCMD ((uint32_t)1 << 5) /* Next CMD is ACMD */
-#define MMCSD_R1_AKESEQERROR ((uint32_t)1 << 3) /* Authentication error */
-#define MMCSD_R1_ERRORMASK ((uint32_t)0xfdffe008) /* Error mask */
-
-#define IS_STATE(v,s) ((((uint32_t)v)&MMCSD_R1_STATE_MASK)==(s))
-
-/* R3 (OCR) */
-
-#define MMC_VDD_20_36 ((uint32_t)0x00ffff00) /* VDD voltage 2.0-3.6 */
-
-#define MMCSD_VDD_145_150 ((uint32_t)1 << 0) /* VDD voltage 1.45 - 1.50 */
-#define MMCSD_VDD_150_155 ((uint32_t)1 << 1) /* VDD voltage 1.50 - 1.55 */
-#define MMCSD_VDD_155_160 ((uint32_t)1 << 2) /* VDD voltage 1.55 - 1.60 */
-#define MMCSD_VDD_160_165 ((uint32_t)1 << 3) /* VDD voltage 1.60 - 1.65 */
-#define MMCSD_VDD_165_170 ((uint32_t)1 << 4) /* VDD voltage 1.65 - 1.70 */
-#define MMCSD_VDD_17_18 ((uint32_t)1 << 5) /* VDD voltage 1.7 - 1.8 */
-#define MMCSD_VDD_18_19 ((uint32_t)1 << 6) /* VDD voltage 1.8 - 1.9 */
-#define MMCSD_VDD_19_20 ((uint32_t)1 << 7) /* VDD voltage 1.9 - 2.0 */
-#define MMCSD_VDD_20_21 ((uint32_t)1 << 8) /* VDD voltage 2.0-2.1 */
-#define MMCSD_VDD_21_22 ((uint32_t)1 << 9) /* VDD voltage 2.1-2.2 */
-#define MMCSD_VDD_22_23 ((uint32_t)1 << 10) /* VDD voltage 2.2-2.3 */
-#define MMCSD_VDD_23_24 ((uint32_t)1 << 11) /* VDD voltage 2.3-2.4 */
-#define MMCSD_VDD_24_25 ((uint32_t)1 << 12) /* VDD voltage 2.4-2.5 */
-#define MMCSD_VDD_25_26 ((uint32_t)1 << 13) /* VDD voltage 2.5-2.6 */
-#define MMCSD_VDD_26_27 ((uint32_t)1 << 14) /* VDD voltage 2.6-2.7 */
-#define MMCSD_VDD_27_28 ((uint32_t)1 << 15) /* VDD voltage 2.7-2.8 */
-#define MMCSD_VDD_28_29 ((uint32_t)1 << 16) /* VDD voltage 2.8-2.9 */
-#define MMCSD_VDD_29_30 ((uint32_t)1 << 17) /* VDD voltage 2.9-3.0 */
-#define MMCSD_VDD_30_31 ((uint32_t)1 << 18) /* VDD voltage 3.0-3.1 */
-#define MMCSD_VDD_31_32 ((uint32_t)1 << 19) /* VDD voltage 3.1-3.2 */
-#define MMCSD_VDD_32_33 ((uint32_t)1 << 20) /* VDD voltage 3.2-3.3 */
-#define MMCSD_VDD_33_34 ((uint32_t)1 << 21) /* VDD voltage 3.3-3.4 */
-#define MMCSD_VDD_34_35 ((uint32_t)1 << 22) /* VDD voltage 3.4-3.5 */
-#define MMCSD_VDD_35_36 ((uint32_t)1 << 23) /* VDD voltage 3.5-3.6 */
-#define MMCSD_R3_HIGHCAPACITY ((uint32_t)1 << 30) /* true: Card supports block addressing */
-#define MMCSD_CARD_BUSY ((uint32_t)1 << 31) /* Card power-up busy bit */
-
-/* R6 Card Status bit definitions */
-
-#define MMCSD_R6_RCA_SHIFT (16) /* New published RCA */
-#define MMCSD_R6_RCA_MASK ((uint32_t)0xffff << MMCSD_R6_RCA_SHIFT)
-#define MMCSD_R6_COMCRCERROR ((uint32_t)1 << 15) /* CRC error */
-#define MMCSD_R6_ILLEGALCOMMAND ((uint32_t)1 << 14) /* Bad command */
-#define MMCSD_R6_ERROR ((uint32_t)1 << 13) /* General error */
-#define MMCSD_R6_STATE_SHIFT (9) /* Current card state */
-#define MMCSD_R6_STATE_MASK ((uint32_t)15 << MMCSD_R6_STATE_SHIFT)
- /* Card identification mode states */
-# define MMCSD_R6_STATE_IDLE ((uint32_t)0 << MMCSD_R6_STATE_SHIFT) /* 0=Idle state */
-# define MMCSD_R6_STATE_READY ((uint32_t)1 << MMCSD_R6_STATE_SHIFT) /* 1=Ready state */
-# define MMCSD_R6_STATE_IDENT ((uint32_t)2 << MMCSD_R6_STATE_SHIFT) /* 2=Identification state */
- /* Data transfer states */
-# define MMCSD_R6_STATE_STBY ((uint32_t)3 << MMCSD_R6_STATE_SHIFT) /* 3=Standby state */
-# define MMCSD_R6_STATE_TRAN ((uint32_t)4 << MMCSD_R6_STATE_SHIFT) /* 4=Transfer state */
-# define MMCSD_R6_STATE_DATA (5(uint32_t) << MMCSD_R6_STATE_SHIFT) /* 5=Sending data state */
-# define MMCSD_R6_STATE_RCV ((uint32_t)6 << MMCSD_R6_STATE_SHIFT) /* 6=Receiving data state */
-# define MMCSD_R6_STATE_PRG ((uint32_t)7 << MMCSD_R6_STATE_SHIFT) /* 7=Programming state */
-# define MMCSD_R6_STATE_DIS ((uint32_t) << MMCSD_R6_STATE_SHIFT) /* 8=Disconnect state */
-#define MMCSD_R6_ERRORMASK ((uint32_t)0x0000e000) /* Error mask */
-
-/* SD Configuration Register (SCR) encoding */
-
-#define MMCSD_SCR_BUSWIDTH_1BIT (1)
-#define MMCSD_SCR_BUSWIDTH_2BIT (2)
-#define MMCSD_SCR_BUSWIDTH_4BIT (4)
-#define MMCSD_SCR_BUSWIDTH_8BIT (8)
-
-/* Last 4 bytes of the 48-bit R7 response */
-
-#define MMCSD_R7VERSION_SHIFT (28) /* Bits 28-31: Command version number */
-#define MMCSD_R7VERSION_MASK ((uint32_t)0x0f << MMCSD_R7VERSION_SHIFT)
-#define MMCSD_R7VOLTAGE_SHIFT (8) /* Bits 8-11: Voltage accepted */
-#define MMCSD_R7VOLTAGE_MASK ((uint32_t)0x0f << MMCSD_R7VOLTAGE_SHIFT)
-# define MMCSD_R7VOLTAGE_27 ((uint32_t)0x01 << MMCSD_R7VOLTAGE_SHIFT) /* 2.7-3.6V */
-#define MMCSD_R7ECHO_SHIFT (0) /* Bits 0-7: Echoed check pattern */
-#define MMCSD_R7ECHO_MASK ((uint32_t)0xff << MMCSD_R7ECHO_SHIFT)
-# define MMCSD_R7CHECKPATTERN ((uint32_t)0xaa << MMCSD_R7ECHO_SHIFT)
-
-/********************************************************************************************
- * Public Types
- ********************************************************************************************/
-
-/* Decoded Card Identification (CID) register */
-
-struct mmcsd_cid_s
-{
- uint8_t mid; /* 127:120 8-bit Manufacturer ID */
- uint16_t oid; /* 119:104 16-bit OEM/Application ID (ascii) */
- uint8_t pnm[6]; /* 103:64 40-bit Product Name (ascii) + null terminator */
- uint8_t prv; /* 63:56 8-bit Product revision */
- uint32_t psn; /* 55:24 32-bit Product serial number */
- /* 23:20 4-bit (reserved) */
- uint16_t mdt; /* 19:8 12-bit Manufacturing date */
- uint8_t crc; /* 7:1 7-bit CRC7 */
- /* 0:0 1-bit (not used) */
-};
-
-/* Decoded Card Specific Data (CSD) register */
-
-struct mmcsd_csd_s
-{
- uint8_t csdstructure; /* 127:126 CSD structure */
- uint8_t mmcspecvers; /* 125:122 MMC Spec version (MMC only) */
-
- struct
- {
- uint8_t timeunit; /* 2:0 Time exponent */
- uint8_t timevalue; /* 6:3 Time mantissa */
- } taac; /* 119:112 Data read access-time-1 */
-
- uint8_t nsac; /* 111:104 Data read access-time-2 in CLK cycle(NSAC*100) */
-
- struct
- {
- uint8_t transferrateunit; /* 2:0 Rate exponent */
- uint8_t timevalue; /* 6:3 Rate mantissa */
- } transpeed; /* 103:96 Max. data transfer rate */
-
- uint16_t ccc; /* 95:84 Card command classes */
- uint8_t readbllen; /* 83:80 Max. read data block length */
- uint8_t readblpartial; /* 79:79 Partial blocks for read allowed */
- uint8_t writeblkmisalign; /* 78:78 Write block misalignment */
- uint8_t readblkmisalign; /* 77:77 Read block misalignment */
- uint8_t dsrimp; /* 76:76 DSR implemented */
-
- union
- {
-#ifdef CONFIG_MMCSD_MMCSUPPORT
- struct
- {
- uint16_t csize; /* 73:62 Device size */
- uint8_t vddrcurrmin; /* 61:59 Max. read current at Vdd min */
- uint8_t vddrcurrmax; /* 58:56 Max. read current at Vdd max */
- uint8_t vddwcurrmin; /* 55:53 Max. write current at Vdd min */
- uint8_t vddwcurrmax; /* 52:50 Max. write current at Vdd max */
- uint8_t csizemult; /* 49:47 Device size multiplier */
-
- union
- {
- struct /* MMC system specification version 3.1 */
- {
- uint8_t ergrpsize; /* 46:42 Erase group size (MMC 3.1) */
- uint8_t ergrpmult; /* 41:37 Erase group multiplier (MMC 3.1) */
- } mmc31;
- struct /* MMC system specification version 2.2 */
- {
- uint8_t sectorsize; /* 46:42 Erase sector size (MMC 2.2) */
- uint8_t ergrpsize; /* 41:37 Erase group size (MMC 2.2) */
- } mmc22;
- } er;
-
- uint8_t mmcwpgrpsize; /* 36:32 Write protect group size (MMC) */
- } mmc;
-#endif
- struct
- {
- uint16_t csize; /* 73:62 Device size */
- uint8_t vddrcurrmin; /* 61:59 Max. read current at Vdd min */
- uint8_t vddrcurrmax; /* 58:56 Max. read current at Vdd max */
- uint8_t vddwcurrmin; /* 55:53 Max. write current at Vdd min */
- uint8_t vddwcurrmax; /* 52:50 Max. write current at Vdd max */
- uint8_t csizemult; /* 49:47 Device size multiplier */
- uint8_t sderblen; /* 46:46 Erase single block enable (SD) */
- uint8_t sdsectorsize; /* 45:39 Erase sector size (SD) */
- uint8_t sdwpgrpsize; /* 38:32 Write protect group size (SD) */
- } sdbyte;
-
- struct
- {
- /* 73:70 (reserved) */
- uint32_t csize; /* 69:48 Device size */
- /* 47:47 (reserved) */
- uint8_t sderblen; /* 46:46 Erase single block enable (SD) */
- uint8_t sdsectorsize; /* 45:39 Erase sector size (SD) */
- uint8_t sdwpgrpsize; /* 38:32 Write protect group size (SD) */
- } sdblock;
- } u;
-
- uint8_t wpgrpen; /* 31:31 Write protect group enable */
- uint8_t mmcdfltecc; /* 30:29 Manufacturer default ECC (MMC) */
- uint8_t r2wfactor; /* 28:26 Write speed factor */
- uint8_t writebllen; /* 25:22 Max. write data block length */
- uint8_t writeblpartial; /* 21:21 Partial blocks for write allowed */
- uint8_t fileformatgrp; /* 15:15 File format group */
- uint8_t copy; /* 14:14 Copy flag (OTP) */
- uint8_t permwriteprotect; /* 13:13 Permanent write protection */
- uint8_t tmpwriteprotect; /* 12:12 Temporary write protection */
- uint8_t fileformat; /* 10:11 File format */
- uint8_t mmcecc; /* 9:8 ECC (MMC) */
- uint8_t crc; /* 7:1 CRC */
- /* 0:0 Not used */
-};
-
-struct mmcsd_scr_s
-{
- uint8_t scrversion; /* 63:60 Version of SCR structure */
- uint8_t sdversion; /* 59:56 SD memory card physical layer version */
- uint8_t erasestate; /* 55:55 Data state after erase (1 or 0) */
- uint8_t security; /* 54:52 SD security support */
- uint8_t buswidth; /* 51:48 DAT bus widthes supported */
- /* 47:32 SD reserved space */
- uint32_t mfgdata; /* 31:0 Reserved for manufacturing data */
-};
-
-/********************************************************************************************
- * Public Data
- ********************************************************************************************/
-
-#undef EXTERN
-#if defined(__cplusplus)
-#define EXTERN extern "C"
-extern "C" {
-#else
-#define EXTERN extern
-#endif
-
-/********************************************************************************************
- * Public Functions
- ********************************************************************************************/
-
-
-#undef EXTERN
-#if defined(__cplusplus)
-}
-#endif
-#endif /* __DRIVERS_MMCSD_MMCSD_SDIO_H */
+/******************************************************************************************** + * drivers/mmcsd/mmcsd_sdio.h + * + * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * 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. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS 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. + * + ********************************************************************************************/ + +#ifndef __DRIVERS_MMCSD_MMCSD_SDIO_H +#define __DRIVERS_MMCSD_MMCSD_SDIO_H + +/******************************************************************************************** + * Included Files + ********************************************************************************************/ + +#include <nuttx/config.h> +#include <stdint.h> + +/******************************************************************************************** + * Pre-Processor Definitions + ********************************************************************************************/ + +/* CMD8 Argument: + * [31:12]: Reserved (shall be set to '0') + * [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V) + * [7:0]: Check Pattern (recommended 0xaa) + * CMD8 Response: R7 + */ + +#define MMCSD_CMD8VOLTAGE_SHIFT (8) /* Bits 8-11: Supply voltage */ +#define MMCSD_CMD8VOLTAGE_MASK ((uint32_t)0x0f << MMCSD_CMD8VOLTAGE_SHIFT) +# define MMCSD_CMD8VOLTAGE_27 ((uint32_t)0x01 << MMCSD_CMD8VOLTAGE_SHIFT) /* 2.7-3.6V */ +#define MMCSD_CMD8ECHO_SHIFT (0) /* Bits 0-7: Check pattern */ +#define MMCSD_CMD8ECHO_MASK ((uint32_t)0xff << MMCSD_CMD8ECHO_SHIFT) +# define MMCSD_CMD8CHECKPATTERN ((uint32_t)0xaa << MMCSD_CMD8ECHO_SHIFT) + +/* ACMD6 argument */ + +#define MMCSD_ACMD6_BUSWIDTH_1 ((uint32_t)0) /* Bus width = 1-bit */ +#define MMCSD_ACMD6_BUSWIDTH_4 ((uint32_t)2) /* Bus width = 4-bit */ + +/* ACMD41 argument */ + +#define MMCSD_ACMD41_VOLTAGEWINDOW ((uint32_t)0x80100000) +#define MMCSD_ACMD41_HIGHCAPACITY ((uint32_t)1 << 30) +#define MMCSD_ACMD41_STDCAPACITY ((uint32_t)0) + +/* ACMD42 argument */ + +#define MMCSD_ACMD42_CD_DISCONNECT ((uint32_t)0) /* Disconnect card detection logic */ +#define MMCSD_ACMD42_CD_CONNECT ((uint32_t)1) /* Connect card detection logic */ + +/* R1 Card Status bit definitions */ + +#define MMCSD_R1_OUTOFRANGE ((uint32_t)1 << 31) /* Bad argument */ +#define MMCSD_R1_ADDRESSERROR ((uint32_t)1 << 30) /* Bad address */ +#define MMCSD_R1_BLOCKLENERROR ((uint32_t)1 << 29) /* Bad block length */ +#define MMCSD_R1_ERASESEQERROR ((uint32_t)1 << 28) /* Erase cmd error */ +#define MMCSD_R1_ERASEPARAM ((uint32_t)1 << 27) /* Bad write blocks */ +#define MMCSD_R1_WPVIOLATION ((uint32_t)1 << 26) /* Erase access failure */ +#define MMCSD_R1_CARDISLOCKED ((uint32_t)1 << 25) /* Card is locked */ +#define MMCSD_R1_LOCKUNLOCKFAILED ((uint32_t)1 << 24) /* Password error */ +#define MMCSD_R1_COMCRCERROR ((uint32_t)1 << 23) /* CRC error */ +#define MMCSD_R1_ILLEGALCOMMAND ((uint32_t)1 << 22) /* Bad command */ +#define MMCSD_R1_CARDECCFAILED ((uint32_t)1 << 21) /* Failed to correct data */ +#define MMCSD_R1_CCERROR ((uint32_t)1 << 20) /* Card controller error */ +#define MMCSD_R1_ERROR ((uint32_t)1 << 19) /* General error */ +#define MMCSD_R1_UNDERRUN ((uint32_t)1 << 18) /* Underrun (MMC only) */ +#define MMCSD_R1_OVERRRUN ((uint32_t)1 << 17) /* Overrun (MMC only) */ +#define MMCSD_R1_CIDCSDOVERWRITE ((uint32_t)1 << 16) /* CID/CSD error */ +#define MMCSD_R1_WPERASESKIP ((uint32_t)1 << 15) /* Not all erased */ +#define MMCSD_R1_CARDECCDISABLED ((uint32_t)1 << 14) /* Internal ECC not used */ +#define MMCSD_R1_ERASERESET ((uint32_t)1 << 13) /* Reset sequence cleared */ +#define MMCSD_R1_STATE_SHIFT (9) /* Current card state */ +#define MMCSD_R1_STATE_MASK ((uint32_t)15 << MMCSD_R1_STATE_SHIFT) + /* Card identification mode states */ +# define MMCSD_R1_STATE_IDLE ((uint32_t)0 << MMCSD_R1_STATE_SHIFT) /* 0=Idle state */ +# define MMCSD_R1_STATE_READY ((uint32_t)1 << MMCSD_R1_STATE_SHIFT) /* 1=Ready state */ +# define MMCSD_R1_STATE_IDENT ((uint32_t)2 << MMCSD_R1_STATE_SHIFT) /* 2=Identification state */ + /* Data transfer states */ +# define MMCSD_R1_STATE_STBY ((uint32_t)3 << MMCSD_R1_STATE_SHIFT) /* 3=Standby state */ +# define MMCSD_R1_STATE_TRAN ((uint32_t)4 << MMCSD_R1_STATE_SHIFT) /* 4=Transfer state */ +# define MMCSD_R1_STATE_DATA ((uint32_t)5 << MMCSD_R1_STATE_SHIFT) /* 5=Sending data state */ +# define MMCSD_R1_STATE_RCV ((uint32_t)6 << MMCSD_R1_STATE_SHIFT) /* 6=Receiving data state */ +# define MMCSD_R1_STATE_PRG ((uint32_t)7 << MMCSD_R1_STATE_SHIFT) /* 7=Programming state */ +# define MMCSD_R1_STATE_DIS ((uint32_t)8 << MMCSD_R1_STATE_SHIFT) /* 8=Disconnect state */ +#define MMCSD_R1_READYFORDATA ((uint32_t)1 << 8) /* Buffer empty */ +#define MMCSD_R1_APPCMD ((uint32_t)1 << 5) /* Next CMD is ACMD */ +#define MMCSD_R1_AKESEQERROR ((uint32_t)1 << 3) /* Authentication error */ +#define MMCSD_R1_ERRORMASK ((uint32_t)0xfdffe008) /* Error mask */ + +#define IS_STATE(v,s) ((((uint32_t)v)&MMCSD_R1_STATE_MASK)==(s)) + +/* R3 (OCR) */ + +#define MMC_VDD_20_36 ((uint32_t)0x00ffff00) /* VDD voltage 2.0-3.6 */ + +#define MMCSD_VDD_145_150 ((uint32_t)1 << 0) /* VDD voltage 1.45 - 1.50 */ +#define MMCSD_VDD_150_155 ((uint32_t)1 << 1) /* VDD voltage 1.50 - 1.55 */ +#define MMCSD_VDD_155_160 ((uint32_t)1 << 2) /* VDD voltage 1.55 - 1.60 */ +#define MMCSD_VDD_160_165 ((uint32_t)1 << 3) /* VDD voltage 1.60 - 1.65 */ +#define MMCSD_VDD_165_170 ((uint32_t)1 << 4) /* VDD voltage 1.65 - 1.70 */ +#define MMCSD_VDD_17_18 ((uint32_t)1 << 5) /* VDD voltage 1.7 - 1.8 */ +#define MMCSD_VDD_18_19 ((uint32_t)1 << 6) /* VDD voltage 1.8 - 1.9 */ +#define MMCSD_VDD_19_20 ((uint32_t)1 << 7) /* VDD voltage 1.9 - 2.0 */ +#define MMCSD_VDD_20_21 ((uint32_t)1 << 8) /* VDD voltage 2.0-2.1 */ +#define MMCSD_VDD_21_22 ((uint32_t)1 << 9) /* VDD voltage 2.1-2.2 */ +#define MMCSD_VDD_22_23 ((uint32_t)1 << 10) /* VDD voltage 2.2-2.3 */ +#define MMCSD_VDD_23_24 ((uint32_t)1 << 11) /* VDD voltage 2.3-2.4 */ +#define MMCSD_VDD_24_25 ((uint32_t)1 << 12) /* VDD voltage 2.4-2.5 */ +#define MMCSD_VDD_25_26 ((uint32_t)1 << 13) /* VDD voltage 2.5-2.6 */ +#define MMCSD_VDD_26_27 ((uint32_t)1 << 14) /* VDD voltage 2.6-2.7 */ +#define MMCSD_VDD_27_28 ((uint32_t)1 << 15) /* VDD voltage 2.7-2.8 */ +#define MMCSD_VDD_28_29 ((uint32_t)1 << 16) /* VDD voltage 2.8-2.9 */ +#define MMCSD_VDD_29_30 ((uint32_t)1 << 17) /* VDD voltage 2.9-3.0 */ +#define MMCSD_VDD_30_31 ((uint32_t)1 << 18) /* VDD voltage 3.0-3.1 */ +#define MMCSD_VDD_31_32 ((uint32_t)1 << 19) /* VDD voltage 3.1-3.2 */ +#define MMCSD_VDD_32_33 ((uint32_t)1 << 20) /* VDD voltage 3.2-3.3 */ +#define MMCSD_VDD_33_34 ((uint32_t)1 << 21) /* VDD voltage 3.3-3.4 */ +#define MMCSD_VDD_34_35 ((uint32_t)1 << 22) /* VDD voltage 3.4-3.5 */ +#define MMCSD_VDD_35_36 ((uint32_t)1 << 23) /* VDD voltage 3.5-3.6 */ +#define MMCSD_R3_HIGHCAPACITY ((uint32_t)1 << 30) /* true: Card supports block addressing */ +#define MMCSD_CARD_BUSY ((uint32_t)1 << 31) /* Card power-up busy bit */ + +/* R6 Card Status bit definitions */ + +#define MMCSD_R6_RCA_SHIFT (16) /* New published RCA */ +#define MMCSD_R6_RCA_MASK ((uint32_t)0xffff << MMCSD_R6_RCA_SHIFT) +#define MMCSD_R6_COMCRCERROR ((uint32_t)1 << 15) /* CRC error */ +#define MMCSD_R6_ILLEGALCOMMAND ((uint32_t)1 << 14) /* Bad command */ +#define MMCSD_R6_ERROR ((uint32_t)1 << 13) /* General error */ +#define MMCSD_R6_STATE_SHIFT (9) /* Current card state */ +#define MMCSD_R6_STATE_MASK ((uint32_t)15 << MMCSD_R6_STATE_SHIFT) + /* Card identification mode states */ +# define MMCSD_R6_STATE_IDLE ((uint32_t)0 << MMCSD_R6_STATE_SHIFT) /* 0=Idle state */ +# define MMCSD_R6_STATE_READY ((uint32_t)1 << MMCSD_R6_STATE_SHIFT) /* 1=Ready state */ +# define MMCSD_R6_STATE_IDENT ((uint32_t)2 << MMCSD_R6_STATE_SHIFT) /* 2=Identification state */ + /* Data transfer states */ +# define MMCSD_R6_STATE_STBY ((uint32_t)3 << MMCSD_R6_STATE_SHIFT) /* 3=Standby state */ +# define MMCSD_R6_STATE_TRAN ((uint32_t)4 << MMCSD_R6_STATE_SHIFT) /* 4=Transfer state */ +# define MMCSD_R6_STATE_DATA (5(uint32_t) << MMCSD_R6_STATE_SHIFT) /* 5=Sending data state */ +# define MMCSD_R6_STATE_RCV ((uint32_t)6 << MMCSD_R6_STATE_SHIFT) /* 6=Receiving data state */ +# define MMCSD_R6_STATE_PRG ((uint32_t)7 << MMCSD_R6_STATE_SHIFT) /* 7=Programming state */ +# define MMCSD_R6_STATE_DIS ((uint32_t) << MMCSD_R6_STATE_SHIFT) /* 8=Disconnect state */ +#define MMCSD_R6_ERRORMASK ((uint32_t)0x0000e000) /* Error mask */ + +/* SD Configuration Register (SCR) encoding */ + +#define MMCSD_SCR_BUSWIDTH_1BIT (1) +#define MMCSD_SCR_BUSWIDTH_2BIT (2) +#define MMCSD_SCR_BUSWIDTH_4BIT (4) +#define MMCSD_SCR_BUSWIDTH_8BIT (8) + +/* Last 4 bytes of the 48-bit R7 response */ + +#define MMCSD_R7VERSION_SHIFT (28) /* Bits 28-31: Command version number */ +#define MMCSD_R7VERSION_MASK ((uint32_t)0x0f << MMCSD_R7VERSION_SHIFT) +#define MMCSD_R7VOLTAGE_SHIFT (8) /* Bits 8-11: Voltage accepted */ +#define MMCSD_R7VOLTAGE_MASK ((uint32_t)0x0f << MMCSD_R7VOLTAGE_SHIFT) +# define MMCSD_R7VOLTAGE_27 ((uint32_t)0x01 << MMCSD_R7VOLTAGE_SHIFT) /* 2.7-3.6V */ +#define MMCSD_R7ECHO_SHIFT (0) /* Bits 0-7: Echoed check pattern */ +#define MMCSD_R7ECHO_MASK ((uint32_t)0xff << MMCSD_R7ECHO_SHIFT) +# define MMCSD_R7CHECKPATTERN ((uint32_t)0xaa << MMCSD_R7ECHO_SHIFT) + +/******************************************************************************************** + * Public Types + ********************************************************************************************/ + +/* Decoded Card Identification (CID) register */ + +struct mmcsd_cid_s +{ + uint8_t mid; /* 127:120 8-bit Manufacturer ID */ + uint16_t oid; /* 119:104 16-bit OEM/Application ID (ascii) */ + uint8_t pnm[6]; /* 103:64 40-bit Product Name (ascii) + null terminator */ + uint8_t prv; /* 63:56 8-bit Product revision */ + uint32_t psn; /* 55:24 32-bit Product serial number */ + /* 23:20 4-bit (reserved) */ + uint16_t mdt; /* 19:8 12-bit Manufacturing date */ + uint8_t crc; /* 7:1 7-bit CRC7 */ + /* 0:0 1-bit (not used) */ +}; + +/* Decoded Card Specific Data (CSD) register */ + +struct mmcsd_csd_s +{ + uint8_t csdstructure; /* 127:126 CSD structure */ + uint8_t mmcspecvers; /* 125:122 MMC Spec version (MMC only) */ + + struct + { + uint8_t timeunit; /* 2:0 Time exponent */ + uint8_t timevalue; /* 6:3 Time mantissa */ + } taac; /* 119:112 Data read access-time-1 */ + + uint8_t nsac; /* 111:104 Data read access-time-2 in CLK cycle(NSAC*100) */ + + struct + { + uint8_t transferrateunit; /* 2:0 Rate exponent */ + uint8_t timevalue; /* 6:3 Rate mantissa */ + } transpeed; /* 103:96 Max. data transfer rate */ + + uint16_t ccc; /* 95:84 Card command classes */ + uint8_t readbllen; /* 83:80 Max. read data block length */ + uint8_t readblpartial; /* 79:79 Partial blocks for read allowed */ + uint8_t writeblkmisalign; /* 78:78 Write block misalignment */ + uint8_t readblkmisalign; /* 77:77 Read block misalignment */ + uint8_t dsrimp; /* 76:76 DSR implemented */ + + union + { +#ifdef CONFIG_MMCSD_MMCSUPPORT + struct + { + uint16_t csize; /* 73:62 Device size */ + uint8_t vddrcurrmin; /* 61:59 Max. read current at Vdd min */ + uint8_t vddrcurrmax; /* 58:56 Max. read current at Vdd max */ + uint8_t vddwcurrmin; /* 55:53 Max. write current at Vdd min */ + uint8_t vddwcurrmax; /* 52:50 Max. write current at Vdd max */ + uint8_t csizemult; /* 49:47 Device size multiplier */ + + union + { + struct /* MMC system specification version 3.1 */ + { + uint8_t ergrpsize; /* 46:42 Erase group size (MMC 3.1) */ + uint8_t ergrpmult; /* 41:37 Erase group multiplier (MMC 3.1) */ + } mmc31; + struct /* MMC system specification version 2.2 */ + { + uint8_t sectorsize; /* 46:42 Erase sector size (MMC 2.2) */ + uint8_t ergrpsize; /* 41:37 Erase group size (MMC 2.2) */ + } mmc22; + } er; + + uint8_t mmcwpgrpsize; /* 36:32 Write protect group size (MMC) */ + } mmc; +#endif + struct + { + uint16_t csize; /* 73:62 Device size */ + uint8_t vddrcurrmin; /* 61:59 Max. read current at Vdd min */ + uint8_t vddrcurrmax; /* 58:56 Max. read current at Vdd max */ + uint8_t vddwcurrmin; /* 55:53 Max. write current at Vdd min */ + uint8_t vddwcurrmax; /* 52:50 Max. write current at Vdd max */ + uint8_t csizemult; /* 49:47 Device size multiplier */ + uint8_t sderblen; /* 46:46 Erase single block enable (SD) */ + uint8_t sdsectorsize; /* 45:39 Erase sector size (SD) */ + uint8_t sdwpgrpsize; /* 38:32 Write protect group size (SD) */ + } sdbyte; + + struct + { + /* 73:70 (reserved) */ + uint32_t csize; /* 69:48 Device size */ + /* 47:47 (reserved) */ + uint8_t sderblen; /* 46:46 Erase single block enable (SD) */ + uint8_t sdsectorsize; /* 45:39 Erase sector size (SD) */ + uint8_t sdwpgrpsize; /* 38:32 Write protect group size (SD) */ + } sdblock; + } u; + + uint8_t wpgrpen; /* 31:31 Write protect group enable */ + uint8_t mmcdfltecc; /* 30:29 Manufacturer default ECC (MMC) */ + uint8_t r2wfactor; /* 28:26 Write speed factor */ + uint8_t writebllen; /* 25:22 Max. write data block length */ + uint8_t writeblpartial; /* 21:21 Partial blocks for write allowed */ + uint8_t fileformatgrp; /* 15:15 File format group */ + uint8_t copy; /* 14:14 Copy flag (OTP) */ + uint8_t permwriteprotect; /* 13:13 Permanent write protection */ + uint8_t tmpwriteprotect; /* 12:12 Temporary write protection */ + uint8_t fileformat; /* 10:11 File format */ + uint8_t mmcecc; /* 9:8 ECC (MMC) */ + uint8_t crc; /* 7:1 CRC */ + /* 0:0 Not used */ +}; + +struct mmcsd_scr_s +{ + uint8_t scrversion; /* 63:60 Version of SCR structure */ + uint8_t sdversion; /* 59:56 SD memory card physical layer version */ + uint8_t erasestate; /* 55:55 Data state after erase (1 or 0) */ + uint8_t security; /* 54:52 SD security support */ + uint8_t buswidth; /* 51:48 DAT bus widthes supported */ + /* 47:32 SD reserved space */ + uint32_t mfgdata; /* 31:0 Reserved for manufacturing data */ +}; + +/******************************************************************************************** + * Public Data + ********************************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +/******************************************************************************************** + * Public Functions + ********************************************************************************************/ + + +#undef EXTERN +#if defined(__cplusplus) +} +#endif +#endif /* __DRIVERS_MMCSD_MMCSD_SDIO_H */ diff --git a/nuttx/drivers/mmcsd/mmcsd_spi.h b/nuttx/drivers/mmcsd/mmcsd_spi.h index 055862beb..8c6f9bae7 100644 --- a/nuttx/drivers/mmcsd/mmcsd_spi.h +++ b/nuttx/drivers/mmcsd/mmcsd_spi.h @@ -2,7 +2,7 @@ * drivers/mmcsd/mmcsd_spi.h * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/mtd/at45db.c b/nuttx/drivers/mtd/at45db.c index f4a695de0..f3c0c72c1 100644 --- a/nuttx/drivers/mtd/at45db.c +++ b/nuttx/drivers/mtd/at45db.c @@ -3,7 +3,7 @@ * Driver for SPI-based AT45DB161D (16Mbit) * * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/mtd/flash_eraseall.c b/nuttx/drivers/mtd/flash_eraseall.c index 77666ff03..ce0cfe649 100644 --- a/nuttx/drivers/mtd/flash_eraseall.c +++ b/nuttx/drivers/mtd/flash_eraseall.c @@ -2,7 +2,7 @@ * drivers/mtd/flash_eraseall.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/mtd/ftl.c b/nuttx/drivers/mtd/ftl.c index b16397883..cdb35aa5c 100644 --- a/nuttx/drivers/mtd/ftl.c +++ b/nuttx/drivers/mtd/ftl.c @@ -2,7 +2,7 @@ * drivers/mtd/ftl.c * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/mtd/skeleton.c b/nuttx/drivers/mtd/skeleton.c index 673ddadb3..a2fb98238 100644 --- a/nuttx/drivers/mtd/skeleton.c +++ b/nuttx/drivers/mtd/skeleton.c @@ -2,7 +2,7 @@ * drivers/mtd/skeleton.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/mtd/sst25.c b/nuttx/drivers/mtd/sst25.c index 01838f078..66d201add 100644 --- a/nuttx/drivers/mtd/sst25.c +++ b/nuttx/drivers/mtd/sst25.c @@ -1,5 +1,5 @@ /************************************************************************************ - * drivers/mtd/m25px.c + * drivers/mtd/sst25.c * Driver for SPI-based SST25 FLASH. * * Copyright (C) 2012 Gregory Nutt. All rights reserved. diff --git a/nuttx/drivers/net/Kconfig b/nuttx/drivers/net/Kconfig index 988b96c94..b5c09bf01 100644 --- a/nuttx/drivers/net/Kconfig +++ b/nuttx/drivers/net/Kconfig @@ -36,9 +36,13 @@ config ENC28J60_NINTERFACES config ENC28J60_SPIMODE int "SPI mode" - default 2 + default 0 ---help--- - Controls the SPI mode + Controls the SPI mode. The ENC28J60 spec says that it supports SPI + mode 0,0 only: "The implementation used on this device supports SPI + mode 0,0 only. In addition, the SPI port requires that SCK be at Idle + in a low state; selectable clock polarity is not supported." + However, sometimes you need to tinker with these things. config ENC28J60_FREQUENCY int "SPI frequency" diff --git a/nuttx/drivers/net/Make.defs b/nuttx/drivers/net/Make.defs index ab256cd8a..bb0d6a718 100644 --- a/nuttx/drivers/net/Make.defs +++ b/nuttx/drivers/net/Make.defs @@ -1,8 +1,8 @@ ############################################################################ # drivers/net/Make.defs # -# Copyright (C) 2007, 2010-2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Copyright (C) 2007, 2010-2012 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -47,7 +47,7 @@ ifeq ($(CONFIG_NET_CS89x0),y) CSRCS += cs89x0.c endif -ifeq ($(CONFIG_NET_ENC28J60),y) +ifeq ($(CONFIG_ENC28J60),y) CSRCS += enc28j60.c endif diff --git a/nuttx/drivers/net/cs89x0.c b/nuttx/drivers/net/cs89x0.c index 0f301ee00..22b9b87a5 100644 --- a/nuttx/drivers/net/cs89x0.c +++ b/nuttx/drivers/net/cs89x0.c @@ -2,7 +2,7 @@ * drivers/net/cs89x0.c * * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/net/cs89x0.h b/nuttx/drivers/net/cs89x0.h index c2073eb98..f6d99120a 100644 --- a/nuttx/drivers/net/cs89x0.h +++ b/nuttx/drivers/net/cs89x0.h @@ -1,326 +1,326 @@ -/****************************************************************************
- * drivers/net/cs89x0.h
- *
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * 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. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS 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.
- *
- ****************************************************************************/
-
-#ifndef __DRIVERS_NET_CS89x0_H
-#define __DRIVERS_NET_CS89x0_H
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/* CONFIG_CS89x0_ALIGN16/32 determines if the 16-bit CS89x0 registers are
- * aligned to 16-bit or 32-bit address boundaries. NOTE: If there multiple
- * CS89x00 parts in the board architecture, we assume that the address
- * alignment is the same for all implementations. If that is not the
- * case, then it will be necessary to move a shift value into
- * the cs89x0_driver_s structure and calculate the offsets dynamically in
- * the putreg and getreg functions.
- */
-
-#if defined(CONFIG_CS89x0_ALIGN16)
-# define CS89x0_RTDATA_OFFSET (0 << 1)
-# define CS89x0_TxCMD_OFFSET (2 << 1)
-# define CS89x0_TxLEN_OFFSET (3 << 1)
-# define CS89x0_ISQ_OFFSET (4 << 1)
-# define CS89x0_PPTR_OFFSET (5 << 1)
-# define CS89x0_PDATA_OFFSET (6 << 1)
-#elif defined(CONFIG_CS89x0_ALIGN32)
-# define CS89x0_RTDATA_OFFSET (0 << 2)
-# define CS89x0_TxCMD_OFFSET (2 << 2)
-# define CS89x0_TxLEN_OFFSET (3 << 2)
-# define CS89x0_ISQ_OFFSET (4 << 2)
-# define CS89x0_PPTR_OFFSET (5 << 2)
-# define CS89x0_PDATA_OFFSET (6 << 2)
-#else
-# error "CS89x00 address alignment is not defined"
-#endif
-
-/* ISQ register bit definitions */
-
-#define ISQ_EVENTMASK 0x003f /* Bits 0-5 indicate the status register */
-#define ISQ_RXEVENT 0x0004
-#define ISQ_TXEVENT 0x0008
-#define ISQ_BUFEVENT 0x000c
-#define ISQ_RXMISSEVENT 0x0010
-#define ISQ_TXCOLEVENT 0x0012
-
-/* ISQ register TxEVENT bit definitions*/
-
-#define ISQ_RXEVENT_IAHASH (1 << 6)
-#define ISQ_RXEVENT_DRIBBLE (1 << 7)
-#define ISQ_RXEVENT_RXOK (1 << 8)
-#define ISQ_RXEVENT_HASHED (1 << 9)
-#define ISQ_RXEVENT_HASHNDX_SHIFT 10
-#define ISQ_RXEVENT_HASHNDX_MASK (0x3f << ISQ_RXEVENT_HASHNDX_SHIFT)
-
-/* ISQ register TxEVENT bit definitions*/
-
-#define ISQ_TXEVENT_LOSSOFCRS (1 << 6)
-#define ISQ_TXEVENT_SQEERROR (1 << 7)
-#define ISQ_TXEVENT_TXOK (1 << 8)
-#define ISQ_TXEVENT_OUTWINDOW (1 << 9)
-#define ISQ_TXEVENT_JABBER (1 << 10)
-#define ISQ_TXEVENT_NCOLLISION_SHIFT 11
-#define ISQ_TXEVENT_NCOLLISION_MASK (15 << ISQ_TXEVENT_NCOLLISION_SHIFT)
-#define ISQ_TXEVENT_16COLL (1 << 15)
-
-/* ISQ register BufEVENT bit definitions */
-
-#define ISQ_BUFEVENT_SWINT (1 << 6)
-#define ISQ_BUFEVENT_RXDMAFRAME (1 << 7)
-#define ISQ_BUFEVENT_RDY4TX (1 << 8)
-#define ISQ_BUFEVENT_TXUNDERRUN (1 << 9)
-#define ISQ_BUFEVENT_RXMISS (1 << 10)
-#define ISQ_BUFEVENT_RX128 (1 << 11)
-#define ISQ_BUFEVENT_RXDEST (1 << 15)
-
-/* Packet page register offsets *********************************************/
-
-/* 0x0000 Bus interface registers */
-
-#define PPR_CHIPID 0x0000 /* Chip identifier - must be 0x630E */
-#define PPR_CHIPREV 0x0002 /* Chip revision, model codes */
-#define PPR_IOBASEADDRESS 0x0020 /* I/O Base Address */
-#define PPR_INTREG 0x0022 /* Interrupt configuration */
-# define PPR_INTREG_IRQ0 0x0000 /* Use INTR0 pin */
-# define PPR_INTREG_IRQ1 0x0001 /* Use INTR1 pin */
-# define PPR_INTREG_IRQ2 0x0002 /* Use INTR2 pin */
-# define PPR_INTREG_IRQ3 0x0003 /* Use INTR3 pin */
-
-#define PPR_DMACHANNELNUMBER 0x0024 /* DMA Channel Number (0,1, or 2) */
-#define PPR_DMASTARTOFFRAME 0x0026 /* DMA Start of Frame */
-#define PPR_DMAFRAMECOUNT 0x0028 /* DMA Frame Count (12-bits) */
-#define PPR_RXDMABYTECOUNT 0x002a /* Rx DMA Byte Count */
-#define PPR_MEMORYBASEADDRESS 0x002c /* Memory Base Address Register (20-bit) */
-#define PPR_BOOTPROMBASEADDRESS 0x0030 /* Boot PROM Base Address */
-#define PPR_BOOTPROMADDRESSMASK 0x0034 /* Boot PROM Address Mask */
-#define PPR_EEPROMCOMMAND 0x0040 /* EEPROM Command */
-#define PPR_EEPROMDATA 0x0042 /* EEPROM Data */
-#define PPR_RECVFRAMEBYTES 0x0050 /* Received Frame Byte Counter */
-
-/* 0x0100 - Configuration and control registers */
-
-#define PPR_RXCFG 0x0102 /* Receiver configuration */
-# define PPR_RXCFG_SKIP1 (1 << 6) /* Skip (discard) current frame */
-# define PPR_RXCFG_STREAM (1 << 7) /* Enable streaming mode */
-# define PPR_RXCFG_RXOK (1 << 8) /* RxOK interrupt enable */
-# define PPR_RxCFG_RxDMAonly (1 << 9) /* Use RxDMA for all frames */
-# define PPR_RxCFG_AutoRxDMA (1 << 10) /* Select RxDMA automatically */
-# define PPR_RxCFG_BufferCRC (1 << 11) /* Include CRC characters in frame */
-# define PPR_RxCFG_CRC (1 << 12) /* Enable interrupt on CRC error */
-# define PPR_RxCFG_RUNT (1 << 13) /* Enable interrupt on RUNT frames */
-# define PPR_RxCFG_EXTRA (1 << 14) /* Enable interrupt on frames with extra data */
-
-#define PPR_RXCTL 0x0104 /* Receiver control */
-# define PPR_RXCTL_IAHASH (1 << 6) /* Accept frames that match hash */
-# define PPR_RXCTL_PROMISCUOUS (1 << 7) /* Accept any frame */
-# define PPR_RXCTL_RXOK (1 << 8) /* Accept well formed frames */
-# define PPR_RXCTL_MULTICAST (1 << 9) /* Accept multicast frames */
-# define PPR_RXCTL_IA (1 << 10) /* Accept frame that matches IA */
-# define PPR_RXCTL_BROADCAST (1 << 11) /* Accept broadcast frames */
-# define PPR_RXCTL_CRC (1 << 12) /* Accept frames with bad CRC */
-# define PPR_RXCTL_RUNT (1 << 13) /* Accept runt frames */
-# define PPR_RXCTL_EXTRA (1 << 14) /* Accept frames that are too long */
-
-#define PPR_TXCFG 0x0106 /* Transmit configuration */
-# define PPR_TXCFG_CRS (1 << 6) /* Enable interrupt on loss of carrier */
-# define PPR_TXCFG_SQE (1 << 7) /* Enable interrupt on Signal Quality Error */
-# define PPR_TXCFG_TXOK (1 << 8) /* Enable interrupt on successful xmits */
-# define PPR_TXCFG_LATE (1 << 9) /* Enable interrupt on "out of window" */
-# define PPR_TXCFG_JABBER (1 << 10) /* Enable interrupt on jabber detect */
-# define PPR_TXCFG_COLLISION (1 << 11) /* Enable interrupt if collision */
-# define PPR_TXCFG_16COLLISIONS (1 << 15) /* Enable interrupt if > 16 collisions */
-
-#define PPR_TXCMD 0x0108 /* Transmit command status */
-# define PPR_TXCMD_TXSTART5 (0 << 6) /* Start after 5 bytes in buffer */
-# define PPR_TXCMD_TXSTART381 (1 << 6) /* Start after 381 bytes in buffer */
-# define PPR_TXCMD_TXSTART1021 (2 << 6) /* Start after 1021 bytes in buffer */
-# define PPR_TXCMD_TXSTARTFULL (3 << 6) /* Start after all bytes loaded */
-# define PPR_TXCMD_FORCE (1 << 8) /* Discard any pending packets */
-# define PPR_TXCMD_ONECOLLISION (1 << 9) /* Abort after a single collision */
-# define PPR_TXCMD_NOCRC (1 << 12) /* Do not add CRC */
-# define PPR_TXCMD_NOPAD (1 << 13) /* Do not pad short packets */
-
-#define PPR_BUFCFG 0x010a /* Buffer configuration */
-# define PPR_BUFCFG_SWI (1 << 6) /* Force interrupt via software */
-# define PPR_BUFCFG_RXDMA (1 << 7) /* Enable interrupt on Rx DMA */
-# define PPR_BUFCFG_TXRDY (1 << 8) /* Enable interrupt when ready for Tx */
-# define PPR_BUFCFG_TXUE (1 << 9) /* Enable interrupt in Tx underrun */
-# define PPR_BUFCFG_RXMISS (1 << 10) /* Enable interrupt on missed Rx packets */
-# define PPR_BUFCFG_RX128 (1 << 11) /* Enable Rx interrupt after 128 bytes */
-# define PPR_BUFCFG_TXCOL (1 << 12) /* Enable int on Tx collision ctr overflow */
-# define PPR_BUFCFG_MISS (1 << 13) /* Enable int on Rx miss ctr overflow */
-# define PPR_BUFCFG_RXDEST (1 << 15) /* Enable int on Rx dest addr match */
-
-#define PPR_LINECTL 0x0112 /* Line control */
-# define PPR_LINECTL_RX (1 << 6) /* Enable receiver */
-# define PPR_LINECTL_TX (1 << 7) /* Enable transmitter */
-# define PPR_LINECTL_AUIONLY (1 << 8) /* AUI interface only */
-# define PPR_LINECTL_AUTOAUI10BT (1 << 9) /* Autodetect AUI or 10BaseT interface */
-# define PPR_LINECTL_MODBACKOFFE (1 << 11) /* Enable modified backoff algorithm */
-# define PPR_LINECTL_POLARITYDIS (1 << 12) /* Disable Rx polarity autodetect */
-# define PPR_LINECTL_2PARTDEFDIS (1 << 13) /* Disable two-part defferal */
-# define PPR_LINECTL_LORXSQUELCH (1 << 14) /* Reduce receiver squelch threshold */
-
-#define PPR_SELFCTL 0x0114 /* Chip self control */
-# define PPR_SELFCTL_RESET (1 << 6) /* Self-clearing reset */
-# define PPR_SELFCTL_SWSUSPEND (1 << 8) /* Initiate suspend mode */
-# define PPR_SELFCTL_HWSLEEPE (1 << 9) /* Enable SLEEP input */
-# define PPR_SELFCTL_HWSTANDBYE (1 << 10) /* Enable standby mode */
-# define PPR_SELFCTL_HC0E (1 << 12) /* Use HCB0 for LINK LED */
-# define PPR_SELFCTL_HC1E (1 << 13) /* Use HCB1 for BSTATUS LED */
-# define PPR_SELFCTL_HCB0 (1 << 14) /* Control LINK LED if HC0E set */
-# define PPR_SELFCTL_HCB1 (1 << 15) /* Cntrol BSTATUS LED if HC1E set */
-
-#define PPR_BUSCTL 0x0116 /* Bus control */
-# define PPR_BUSCTL_RESETRXDMA (1 << 6) /* Reset RxDMA pointer */
-# define PPR_BUSCTL_DMAEXTEND (1 << 8) /* Extend DMA cycle */
-# define PPR_BUSCTL_USESA (1 << 9) /* Assert MEMCS16 on address decode */
-# define PPR_BUSCTL_MEMORYE (1 << 10) /* Enable memory mode */
-# define PPR_BUSCTL_DMABURST (1 << 11) /* Limit DMA access burst */
-# define PPR_BUSCTL_IOCHRDYE (1 << 12) /* Set IOCHRDY high impedence */
-# define PPR_BUSCTL_RXDMASIZE (1 << 13) /* Set DMA buffer size 64KB */
-# define PPR_BUSCTL_ENABLEIRQ (1 << 15) /* Generate interrupt on interrupt event */
-
-#define PPR_TESTCTL 0x0118 /* Test control */
-# define PPR_TESTCTL_DISABLELT (1 << 7) /* Disable link status */
-# define PPR_TESTCTL_ENDECLOOP (1 << 9) /* Internal loopback */
-# define PPR_TESTCTL_AUILOOP (1 << 10) /* AUI loopback */
-# define PPR_TESTCTL_DISBACKOFF (1 << 11) /* Disable backoff algorithm */
-# define PPR_TESTCTL_FDX (1 << 14) /* Enable full duplex mode */
-
-/* 0x0120 - Status and Event Registers */
-
-#define PPR_ISQ 0x0120 /* Interrupt Status Queue */
-#define PPR_RER 0x0124 /* Receive event */
-# define PPR_RER_IAHASH (1 << 6) /* Frame hash match */
-# define PPR_RER_DRIBBLE (1 << 7) /* Frame had 1-7 extra bits after last byte */
-# define PPR_RER_RXOK (1 << 8) /* Frame received with no errors */
-# define PPR_RER_HASHED (1 << 9) /* Frame address hashed OK */
-# define PPR_RER_IA (1 << 10) /* Frame address matched IA */
-# define PPR_RER_BROADCAST (1 << 11) /* Broadcast frame */
-# define PPR_RER_CRC (1 << 12) /* Frame had CRC error */
-# define PPR_RER_RUNT (1 << 13) /* Runt frame */
-# define PPR_RER_EXTRA (1 << 14) /* Frame was too long */
-
-#define PPR_TER 0x0128 /* Transmit event */
-# define PPR_TER_CRS (1 << 6) /* Carrier lost */
-# define PPR_TER_SQE (1 << 7) /* Signal Quality Error */
-# define PPR_TER_TXOK (1 << 8) /* Packet sent without error */
-# define PPR_TER_LATE (1 << 9) /* Out of window */
-# define PPR_TER_JABBER (1 << 10) /* Stuck transmit? */
-# define PPR_TER_NUMCOLLISIONS_SHIFT 11
-# define PPR_TER_NUMCOLLISIONS_MASK (15 << PPR_TER_NUMCOLLISIONS_SHIFT)
-# define PPR_TER_16COLLISIONS (1 << 15) /* > 16 collisions */
-
-#define PPR_BER 0x012C /* Buffer event */
-# define PPR_BER_SWINT (1 << 6) /* Software interrupt */
-# define PPR_BER_RXDMAFRAME (1 << 7) /* Received framed DMAed */
-# define PPR_BER_RDY4TX (1 << 8) /* Ready for transmission */
-# define PPR_BER_TXUNDERRUN (1 << 9) /* Transmit underrun */
-# define PPR_BER_RXMISS (1 << 10) /* Received frame missed */
-# define PPR_BER_RX128 (1 << 11) /* 128 bytes received */
-# define PPR_BER_RXDEST (1 << 15) /* Received framed passed address filter */
-
-#define PPR_RXMISS 0x0130 /* Receiver miss counter */
-#define PPR_TXCOL 0x0132 /* Transmit collision counter */
-#define PPR_LINESTAT 0x0134 /* Line status */
-# define PPR_LINESTAT_LINKOK (1 << 7) /* Line is connected and working */
-# define PPR_LINESTAT_AUI (1 << 8) /* Connected via AUI */
-# define PPR_LINESTAT_10BT (1 << 9) /* Connected via twisted pair */
-# define PPR_LINESTAT_POLARITY (1 << 12) /* Line polarity OK (10BT only) */
-# define PPR_LINESTAT_CRS (1 << 14) /* Frame being received */
-
-#define PPR_SELFSTAT 0x0136 /* Chip self status */
-# define PPR_SELFSTAT_33VACTIVE (1 << 6) /* supply voltage is 3.3V */
-# define PPR_SELFSTAT_INITD (1 << 7) /* Chip initialization complete */
-# define PPR_SELFSTAT_SIBSY (1 << 8) /* EEPROM is busy */
-# define PPR_SELFSTAT_EEPROM (1 << 9) /* EEPROM present */
-# define PPR_SELFSTAT_EEPROMOK (1 << 10) /* EEPROM checks out */
-# define PPR_SELFSTAT_ELPRESENT (1 << 11) /* External address latch logic available */
-# define PPR_SELFSTAT_EESIZE (1 << 12) /* Size of EEPROM */
-
-#define PPR_BUSSTAT 0x0138 /* Bus status */
-# define PPR_BUSSTAT_TXBID (1 << 7) /* Tx error */
-# define PPR_BUSSTAT_TXRDY (1 << 8) /* Ready for Tx data */
-
-#define PPR_TDR 0x013C /* AUI Time Domain Reflectometer */
-
-/* 0x0144 - Initiate transmit registers */
-
-#define PPR_TXCOMMAND 0x0144 /* Tx Command */
-#define PPR_TXLENGTH 0x0146 /* Tx Length */
-
-/* 0x0150 - Address filter registers */
-
-#define PPR_LAF 0x0150 /* Logical address filter (6 bytes) */
-#define PPR_IA 0x0158 /* Individual address (MAC) */
-
-/* 0x0400 - Frame location registers */
-
-#define PPR_RXSTATUS 0x0400 /* Rx Status */
-#define PPR_RXLENGTH 0x0402 /* Rx Length */
-#define PPR_RXFRAMELOCATION 0x0404 /* Rx Frame Location */
-#define PPR_TXFRAMELOCATION 0x0a00 /* Tx Frame Location */
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-#ifdef __cplusplus
-#define EXTERN extern "C"
-extern "C" {
-#else
-#define EXTERN extern
-#endif
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-#undef EXTERN
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __DRIVERS_NET_CS89x0_H */
+/**************************************************************************** + * drivers/net/cs89x0.h + * + * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * 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. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS 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. + * + ****************************************************************************/ + +#ifndef __DRIVERS_NET_CS89x0_H +#define __DRIVERS_NET_CS89x0_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* CONFIG_CS89x0_ALIGN16/32 determines if the 16-bit CS89x0 registers are + * aligned to 16-bit or 32-bit address boundaries. NOTE: If there multiple + * CS89x00 parts in the board architecture, we assume that the address + * alignment is the same for all implementations. If that is not the + * case, then it will be necessary to move a shift value into + * the cs89x0_driver_s structure and calculate the offsets dynamically in + * the putreg and getreg functions. + */ + +#if defined(CONFIG_CS89x0_ALIGN16) +# define CS89x0_RTDATA_OFFSET (0 << 1) +# define CS89x0_TxCMD_OFFSET (2 << 1) +# define CS89x0_TxLEN_OFFSET (3 << 1) +# define CS89x0_ISQ_OFFSET (4 << 1) +# define CS89x0_PPTR_OFFSET (5 << 1) +# define CS89x0_PDATA_OFFSET (6 << 1) +#elif defined(CONFIG_CS89x0_ALIGN32) +# define CS89x0_RTDATA_OFFSET (0 << 2) +# define CS89x0_TxCMD_OFFSET (2 << 2) +# define CS89x0_TxLEN_OFFSET (3 << 2) +# define CS89x0_ISQ_OFFSET (4 << 2) +# define CS89x0_PPTR_OFFSET (5 << 2) +# define CS89x0_PDATA_OFFSET (6 << 2) +#else +# error "CS89x00 address alignment is not defined" +#endif + +/* ISQ register bit definitions */ + +#define ISQ_EVENTMASK 0x003f /* Bits 0-5 indicate the status register */ +#define ISQ_RXEVENT 0x0004 +#define ISQ_TXEVENT 0x0008 +#define ISQ_BUFEVENT 0x000c +#define ISQ_RXMISSEVENT 0x0010 +#define ISQ_TXCOLEVENT 0x0012 + +/* ISQ register TxEVENT bit definitions*/ + +#define ISQ_RXEVENT_IAHASH (1 << 6) +#define ISQ_RXEVENT_DRIBBLE (1 << 7) +#define ISQ_RXEVENT_RXOK (1 << 8) +#define ISQ_RXEVENT_HASHED (1 << 9) +#define ISQ_RXEVENT_HASHNDX_SHIFT 10 +#define ISQ_RXEVENT_HASHNDX_MASK (0x3f << ISQ_RXEVENT_HASHNDX_SHIFT) + +/* ISQ register TxEVENT bit definitions*/ + +#define ISQ_TXEVENT_LOSSOFCRS (1 << 6) +#define ISQ_TXEVENT_SQEERROR (1 << 7) +#define ISQ_TXEVENT_TXOK (1 << 8) +#define ISQ_TXEVENT_OUTWINDOW (1 << 9) +#define ISQ_TXEVENT_JABBER (1 << 10) +#define ISQ_TXEVENT_NCOLLISION_SHIFT 11 +#define ISQ_TXEVENT_NCOLLISION_MASK (15 << ISQ_TXEVENT_NCOLLISION_SHIFT) +#define ISQ_TXEVENT_16COLL (1 << 15) + +/* ISQ register BufEVENT bit definitions */ + +#define ISQ_BUFEVENT_SWINT (1 << 6) +#define ISQ_BUFEVENT_RXDMAFRAME (1 << 7) +#define ISQ_BUFEVENT_RDY4TX (1 << 8) +#define ISQ_BUFEVENT_TXUNDERRUN (1 << 9) +#define ISQ_BUFEVENT_RXMISS (1 << 10) +#define ISQ_BUFEVENT_RX128 (1 << 11) +#define ISQ_BUFEVENT_RXDEST (1 << 15) + +/* Packet page register offsets *********************************************/ + +/* 0x0000 Bus interface registers */ + +#define PPR_CHIPID 0x0000 /* Chip identifier - must be 0x630E */ +#define PPR_CHIPREV 0x0002 /* Chip revision, model codes */ +#define PPR_IOBASEADDRESS 0x0020 /* I/O Base Address */ +#define PPR_INTREG 0x0022 /* Interrupt configuration */ +# define PPR_INTREG_IRQ0 0x0000 /* Use INTR0 pin */ +# define PPR_INTREG_IRQ1 0x0001 /* Use INTR1 pin */ +# define PPR_INTREG_IRQ2 0x0002 /* Use INTR2 pin */ +# define PPR_INTREG_IRQ3 0x0003 /* Use INTR3 pin */ + +#define PPR_DMACHANNELNUMBER 0x0024 /* DMA Channel Number (0,1, or 2) */ +#define PPR_DMASTARTOFFRAME 0x0026 /* DMA Start of Frame */ +#define PPR_DMAFRAMECOUNT 0x0028 /* DMA Frame Count (12-bits) */ +#define PPR_RXDMABYTECOUNT 0x002a /* Rx DMA Byte Count */ +#define PPR_MEMORYBASEADDRESS 0x002c /* Memory Base Address Register (20-bit) */ +#define PPR_BOOTPROMBASEADDRESS 0x0030 /* Boot PROM Base Address */ +#define PPR_BOOTPROMADDRESSMASK 0x0034 /* Boot PROM Address Mask */ +#define PPR_EEPROMCOMMAND 0x0040 /* EEPROM Command */ +#define PPR_EEPROMDATA 0x0042 /* EEPROM Data */ +#define PPR_RECVFRAMEBYTES 0x0050 /* Received Frame Byte Counter */ + +/* 0x0100 - Configuration and control registers */ + +#define PPR_RXCFG 0x0102 /* Receiver configuration */ +# define PPR_RXCFG_SKIP1 (1 << 6) /* Skip (discard) current frame */ +# define PPR_RXCFG_STREAM (1 << 7) /* Enable streaming mode */ +# define PPR_RXCFG_RXOK (1 << 8) /* RxOK interrupt enable */ +# define PPR_RxCFG_RxDMAonly (1 << 9) /* Use RxDMA for all frames */ +# define PPR_RxCFG_AutoRxDMA (1 << 10) /* Select RxDMA automatically */ +# define PPR_RxCFG_BufferCRC (1 << 11) /* Include CRC characters in frame */ +# define PPR_RxCFG_CRC (1 << 12) /* Enable interrupt on CRC error */ +# define PPR_RxCFG_RUNT (1 << 13) /* Enable interrupt on RUNT frames */ +# define PPR_RxCFG_EXTRA (1 << 14) /* Enable interrupt on frames with extra data */ + +#define PPR_RXCTL 0x0104 /* Receiver control */ +# define PPR_RXCTL_IAHASH (1 << 6) /* Accept frames that match hash */ +# define PPR_RXCTL_PROMISCUOUS (1 << 7) /* Accept any frame */ +# define PPR_RXCTL_RXOK (1 << 8) /* Accept well formed frames */ +# define PPR_RXCTL_MULTICAST (1 << 9) /* Accept multicast frames */ +# define PPR_RXCTL_IA (1 << 10) /* Accept frame that matches IA */ +# define PPR_RXCTL_BROADCAST (1 << 11) /* Accept broadcast frames */ +# define PPR_RXCTL_CRC (1 << 12) /* Accept frames with bad CRC */ +# define PPR_RXCTL_RUNT (1 << 13) /* Accept runt frames */ +# define PPR_RXCTL_EXTRA (1 << 14) /* Accept frames that are too long */ + +#define PPR_TXCFG 0x0106 /* Transmit configuration */ +# define PPR_TXCFG_CRS (1 << 6) /* Enable interrupt on loss of carrier */ +# define PPR_TXCFG_SQE (1 << 7) /* Enable interrupt on Signal Quality Error */ +# define PPR_TXCFG_TXOK (1 << 8) /* Enable interrupt on successful xmits */ +# define PPR_TXCFG_LATE (1 << 9) /* Enable interrupt on "out of window" */ +# define PPR_TXCFG_JABBER (1 << 10) /* Enable interrupt on jabber detect */ +# define PPR_TXCFG_COLLISION (1 << 11) /* Enable interrupt if collision */ +# define PPR_TXCFG_16COLLISIONS (1 << 15) /* Enable interrupt if > 16 collisions */ + +#define PPR_TXCMD 0x0108 /* Transmit command status */ +# define PPR_TXCMD_TXSTART5 (0 << 6) /* Start after 5 bytes in buffer */ +# define PPR_TXCMD_TXSTART381 (1 << 6) /* Start after 381 bytes in buffer */ +# define PPR_TXCMD_TXSTART1021 (2 << 6) /* Start after 1021 bytes in buffer */ +# define PPR_TXCMD_TXSTARTFULL (3 << 6) /* Start after all bytes loaded */ +# define PPR_TXCMD_FORCE (1 << 8) /* Discard any pending packets */ +# define PPR_TXCMD_ONECOLLISION (1 << 9) /* Abort after a single collision */ +# define PPR_TXCMD_NOCRC (1 << 12) /* Do not add CRC */ +# define PPR_TXCMD_NOPAD (1 << 13) /* Do not pad short packets */ + +#define PPR_BUFCFG 0x010a /* Buffer configuration */ +# define PPR_BUFCFG_SWI (1 << 6) /* Force interrupt via software */ +# define PPR_BUFCFG_RXDMA (1 << 7) /* Enable interrupt on Rx DMA */ +# define PPR_BUFCFG_TXRDY (1 << 8) /* Enable interrupt when ready for Tx */ +# define PPR_BUFCFG_TXUE (1 << 9) /* Enable interrupt in Tx underrun */ +# define PPR_BUFCFG_RXMISS (1 << 10) /* Enable interrupt on missed Rx packets */ +# define PPR_BUFCFG_RX128 (1 << 11) /* Enable Rx interrupt after 128 bytes */ +# define PPR_BUFCFG_TXCOL (1 << 12) /* Enable int on Tx collision ctr overflow */ +# define PPR_BUFCFG_MISS (1 << 13) /* Enable int on Rx miss ctr overflow */ +# define PPR_BUFCFG_RXDEST (1 << 15) /* Enable int on Rx dest addr match */ + +#define PPR_LINECTL 0x0112 /* Line control */ +# define PPR_LINECTL_RX (1 << 6) /* Enable receiver */ +# define PPR_LINECTL_TX (1 << 7) /* Enable transmitter */ +# define PPR_LINECTL_AUIONLY (1 << 8) /* AUI interface only */ +# define PPR_LINECTL_AUTOAUI10BT (1 << 9) /* Autodetect AUI or 10BaseT interface */ +# define PPR_LINECTL_MODBACKOFFE (1 << 11) /* Enable modified backoff algorithm */ +# define PPR_LINECTL_POLARITYDIS (1 << 12) /* Disable Rx polarity autodetect */ +# define PPR_LINECTL_2PARTDEFDIS (1 << 13) /* Disable two-part defferal */ +# define PPR_LINECTL_LORXSQUELCH (1 << 14) /* Reduce receiver squelch threshold */ + +#define PPR_SELFCTL 0x0114 /* Chip self control */ +# define PPR_SELFCTL_RESET (1 << 6) /* Self-clearing reset */ +# define PPR_SELFCTL_SWSUSPEND (1 << 8) /* Initiate suspend mode */ +# define PPR_SELFCTL_HWSLEEPE (1 << 9) /* Enable SLEEP input */ +# define PPR_SELFCTL_HWSTANDBYE (1 << 10) /* Enable standby mode */ +# define PPR_SELFCTL_HC0E (1 << 12) /* Use HCB0 for LINK LED */ +# define PPR_SELFCTL_HC1E (1 << 13) /* Use HCB1 for BSTATUS LED */ +# define PPR_SELFCTL_HCB0 (1 << 14) /* Control LINK LED if HC0E set */ +# define PPR_SELFCTL_HCB1 (1 << 15) /* Cntrol BSTATUS LED if HC1E set */ + +#define PPR_BUSCTL 0x0116 /* Bus control */ +# define PPR_BUSCTL_RESETRXDMA (1 << 6) /* Reset RxDMA pointer */ +# define PPR_BUSCTL_DMAEXTEND (1 << 8) /* Extend DMA cycle */ +# define PPR_BUSCTL_USESA (1 << 9) /* Assert MEMCS16 on address decode */ +# define PPR_BUSCTL_MEMORYE (1 << 10) /* Enable memory mode */ +# define PPR_BUSCTL_DMABURST (1 << 11) /* Limit DMA access burst */ +# define PPR_BUSCTL_IOCHRDYE (1 << 12) /* Set IOCHRDY high impedence */ +# define PPR_BUSCTL_RXDMASIZE (1 << 13) /* Set DMA buffer size 64KB */ +# define PPR_BUSCTL_ENABLEIRQ (1 << 15) /* Generate interrupt on interrupt event */ + +#define PPR_TESTCTL 0x0118 /* Test control */ +# define PPR_TESTCTL_DISABLELT (1 << 7) /* Disable link status */ +# define PPR_TESTCTL_ENDECLOOP (1 << 9) /* Internal loopback */ +# define PPR_TESTCTL_AUILOOP (1 << 10) /* AUI loopback */ +# define PPR_TESTCTL_DISBACKOFF (1 << 11) /* Disable backoff algorithm */ +# define PPR_TESTCTL_FDX (1 << 14) /* Enable full duplex mode */ + +/* 0x0120 - Status and Event Registers */ + +#define PPR_ISQ 0x0120 /* Interrupt Status Queue */ +#define PPR_RER 0x0124 /* Receive event */ +# define PPR_RER_IAHASH (1 << 6) /* Frame hash match */ +# define PPR_RER_DRIBBLE (1 << 7) /* Frame had 1-7 extra bits after last byte */ +# define PPR_RER_RXOK (1 << 8) /* Frame received with no errors */ +# define PPR_RER_HASHED (1 << 9) /* Frame address hashed OK */ +# define PPR_RER_IA (1 << 10) /* Frame address matched IA */ +# define PPR_RER_BROADCAST (1 << 11) /* Broadcast frame */ +# define PPR_RER_CRC (1 << 12) /* Frame had CRC error */ +# define PPR_RER_RUNT (1 << 13) /* Runt frame */ +# define PPR_RER_EXTRA (1 << 14) /* Frame was too long */ + +#define PPR_TER 0x0128 /* Transmit event */ +# define PPR_TER_CRS (1 << 6) /* Carrier lost */ +# define PPR_TER_SQE (1 << 7) /* Signal Quality Error */ +# define PPR_TER_TXOK (1 << 8) /* Packet sent without error */ +# define PPR_TER_LATE (1 << 9) /* Out of window */ +# define PPR_TER_JABBER (1 << 10) /* Stuck transmit? */ +# define PPR_TER_NUMCOLLISIONS_SHIFT 11 +# define PPR_TER_NUMCOLLISIONS_MASK (15 << PPR_TER_NUMCOLLISIONS_SHIFT) +# define PPR_TER_16COLLISIONS (1 << 15) /* > 16 collisions */ + +#define PPR_BER 0x012C /* Buffer event */ +# define PPR_BER_SWINT (1 << 6) /* Software interrupt */ +# define PPR_BER_RXDMAFRAME (1 << 7) /* Received framed DMAed */ +# define PPR_BER_RDY4TX (1 << 8) /* Ready for transmission */ +# define PPR_BER_TXUNDERRUN (1 << 9) /* Transmit underrun */ +# define PPR_BER_RXMISS (1 << 10) /* Received frame missed */ +# define PPR_BER_RX128 (1 << 11) /* 128 bytes received */ +# define PPR_BER_RXDEST (1 << 15) /* Received framed passed address filter */ + +#define PPR_RXMISS 0x0130 /* Receiver miss counter */ +#define PPR_TXCOL 0x0132 /* Transmit collision counter */ +#define PPR_LINESTAT 0x0134 /* Line status */ +# define PPR_LINESTAT_LINKOK (1 << 7) /* Line is connected and working */ +# define PPR_LINESTAT_AUI (1 << 8) /* Connected via AUI */ +# define PPR_LINESTAT_10BT (1 << 9) /* Connected via twisted pair */ +# define PPR_LINESTAT_POLARITY (1 << 12) /* Line polarity OK (10BT only) */ +# define PPR_LINESTAT_CRS (1 << 14) /* Frame being received */ + +#define PPR_SELFSTAT 0x0136 /* Chip self status */ +# define PPR_SELFSTAT_33VACTIVE (1 << 6) /* supply voltage is 3.3V */ +# define PPR_SELFSTAT_INITD (1 << 7) /* Chip initialization complete */ +# define PPR_SELFSTAT_SIBSY (1 << 8) /* EEPROM is busy */ +# define PPR_SELFSTAT_EEPROM (1 << 9) /* EEPROM present */ +# define PPR_SELFSTAT_EEPROMOK (1 << 10) /* EEPROM checks out */ +# define PPR_SELFSTAT_ELPRESENT (1 << 11) /* External address latch logic available */ +# define PPR_SELFSTAT_EESIZE (1 << 12) /* Size of EEPROM */ + +#define PPR_BUSSTAT 0x0138 /* Bus status */ +# define PPR_BUSSTAT_TXBID (1 << 7) /* Tx error */ +# define PPR_BUSSTAT_TXRDY (1 << 8) /* Ready for Tx data */ + +#define PPR_TDR 0x013C /* AUI Time Domain Reflectometer */ + +/* 0x0144 - Initiate transmit registers */ + +#define PPR_TXCOMMAND 0x0144 /* Tx Command */ +#define PPR_TXLENGTH 0x0146 /* Tx Length */ + +/* 0x0150 - Address filter registers */ + +#define PPR_LAF 0x0150 /* Logical address filter (6 bytes) */ +#define PPR_IA 0x0158 /* Individual address (MAC) */ + +/* 0x0400 - Frame location registers */ + +#define PPR_RXSTATUS 0x0400 /* Rx Status */ +#define PPR_RXLENGTH 0x0402 /* Rx Length */ +#define PPR_RXFRAMELOCATION 0x0404 /* Rx Frame Location */ +#define PPR_TXFRAMELOCATION 0x0a00 /* Tx Frame Location */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __DRIVERS_NET_CS89x0_H */ diff --git a/nuttx/drivers/net/dm90x0.c b/nuttx/drivers/net/dm90x0.c index 15433e0f8..2f5b26abb 100644 --- a/nuttx/drivers/net/dm90x0.c +++ b/nuttx/drivers/net/dm90x0.c @@ -2,7 +2,7 @@ * drivers/net/dm9x.c * * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Davicom data sheets (DM9000-DS-F03-041906.pdf, * DM9010-DS-F01-103006.pdf) and looking at lots of other DM90x0 diff --git a/nuttx/drivers/net/enc28j60.c b/nuttx/drivers/net/enc28j60.c index 76b0f205b..47a84ec9f 100644 --- a/nuttx/drivers/net/enc28j60.c +++ b/nuttx/drivers/net/enc28j60.c @@ -42,7 +42,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#if defined(CONFIG_NET) && defined(CONFIG_NET_ENC28J60) +#if defined(CONFIG_NET) && defined(CONFIG_ENC28J60) #include <stdint.h> #include <stdbool.h> @@ -74,7 +74,7 @@ /* ENC28J60 Configuration Settings: * - * CONFIG_NET_ENC28J60 - Enabled ENC28J60 support + * CONFIG_ENC28J60 - Enabled ENC28J60 support * CONFIG_ENC28J60_SPIMODE - Controls the SPI mode * CONFIG_ENC28J60_FREQUENCY - Define to use a different bus frequency * CONFIG_ENC28J60_NINTERFACES - Specifies the number of physical ENC28J60 @@ -83,12 +83,15 @@ * CONFIG_ENC28J60_HALFDUPPLEX - Default is full duplex */ -/* The ENC28J60 spec says that is supports SPI mode 0,0 only. However, - * somtimes you need to tinker with these things. +/* The ENC28J60 spec says that it supports SPI mode 0,0 only: "The + * implementation used on this device supports SPI mode 0,0 only. In + * addition, the SPI port requires that SCK be at Idle in a low state; + * selectable clock polarity is not supported." However, sometimes you + * need to tinker with these things. */ #ifndef CONFIG_ENC28J60_SPIMODE -# define CONFIG_ENC28J60_SPIMODE SPIDEV_MODE2 +# define CONFIG_ENC28J60_SPIMODE SPIDEV_MODE0 #endif /* CONFIG_ENC28J60_NINTERFACES determines the number of physical interfaces @@ -164,6 +167,15 @@ * Private Types ****************************************************************************/ +/* The state of the interface */ + +enum enc_state_e +{ + ENCSTATE_UNIT = 0, /* The interface is in an unknown state */ + ENCSTATE_DOWN, /* The interface is down */ + ENCSTATE_UP /* The interface is up */ +}; + /* The enc_driver_s encapsulates all state information for a single hardware * interface */ @@ -172,22 +184,25 @@ struct enc_driver_s { /* Device control */ - bool bifup; /* true:ifup false:ifdown */ - uint8_t bank; /* Currently selected bank */ - uint16_t nextpkt; /* Next packet address */ - int irq; /* GPIO IRQ configured for the ENC28J60 */ + uint8_t ifstate; /* Interface state: See ENCSTATE_* */ + uint8_t bank; /* Currently selected bank */ +#ifndef CONFIG_SPI_OWNBUS + uint8_t lockcount; /* Avoid recursive locks */ +#endif + uint16_t nextpkt; /* Next packet address */ + FAR const struct enc_lower_s *lower; /* Low-level MCU-specific support */ /* Timing */ - WDOG_ID txpoll; /* TX poll timer */ - WDOG_ID txtimeout; /* TX timeout timer */ + WDOG_ID txpoll; /* TX poll timer */ + WDOG_ID txtimeout; /* TX timeout timer */ - /* We we don't own the SPI bus, then we cannot do SPI accesses from the + /* If we don't own the SPI bus, then we cannot do SPI accesses from the * interrupt handler. */ #ifndef CONFIG_SPI_OWNBUS - struct work_s work; /* Work queue support */ + struct work_s work; /* Work queue support */ #endif /* This is the contained SPI driver intstance */ @@ -196,12 +211,12 @@ struct enc_driver_s /* This holds the information visible to uIP/NuttX */ - struct uip_driver_s dev; /* Interface understood by uIP */ + struct uip_driver_s dev; /* Interface understood by uIP */ /* Statistics */ #ifdef CONFIG_ENC28J60_STATS - struct enc_stats_s stats; + struct enc_stats_s stats; #endif }; @@ -219,11 +234,11 @@ static struct enc_driver_s g_enc28j60[CONFIG_ENC28J60_NINTERFACES]; static inline void enc_configspi(FAR struct spi_dev_s *spi); #ifdef CONFIG_SPI_OWNBUS -static inline void enc_select(FAR struct spi_dev_s *spi); -static inline void enc_deselect(FAR struct spi_dev_s *spi); +static inline void enc_select(FAR struct enc_driver_s *priv); +static inline void enc_deselect(FAR struct enc_driver_s *priv); #else -static void enc_select(FAR struct spi_dev_s *spi); -static void enc_deselect(FAR struct spi_dev_s *spi); +static void enc_select(FAR struct enc_driver_s *priv); +static void enc_deselect(FAR struct enc_driver_s *priv); #endif /* SPI control register access */ @@ -231,11 +246,12 @@ static void enc_deselect(FAR struct spi_dev_s *spi); static uint8_t enc_rdgreg2(FAR struct enc_driver_s *priv, uint8_t cmd); static void enc_wrgreg2(FAR struct enc_driver_s *priv, uint8_t cmd, uint8_t wrdata); +static inline void enc_src(FAR struct enc_driver_s *priv); static void enc_setbank(FAR struct enc_driver_s *priv, uint8_t bank); static uint8_t enc_rdbreg(FAR struct enc_driver_s *priv, uint8_t ctrlreg); static void enc_wrbreg(FAR struct enc_driver_s *priv, uint8_t ctrlreg, uint8_t wrdata); -static int enc_waitbreg(FAR struct enc_driver_s *priv, uint8_t ctrlreg, +static int enc_waitbreg(FAR struct enc_driver_s *priv, uint8_t ctrlreg, uint8_t bits, uint8_t value); /* SPI buffer transfers */ @@ -342,31 +358,50 @@ static inline void enc_configspi(FAR struct spi_dev_s *spi) ****************************************************************************/ #ifdef CONFIG_SPI_OWNBUS -static inline void enc_select(FAR struct spi_dev_s *spi) +static inline void enc_select(FAR struct enc_driver_s *priv) { /* We own the SPI bus, so just select the chip */ - SPI_SELECT(spi, SPIDEV_ETHERNET, true); + SPI_SELECT(priv->spi, SPIDEV_ETHERNET, true); } #else -static void enc_select(FAR struct spi_dev_s *spi) +static void enc_select(FAR struct enc_driver_s *priv) { - /* Select ENC28J60 chip (locking the SPI bus in case there are multiple - * devices competing for the SPI bus + /* Lock the SPI bus in case there are multiple devices competing for the SPI + * bus. First check if we already hold the lock. */ - SPI_LOCK(spi, true); - SPI_SELECT(spi, SPIDEV_ETHERNET, true); + if (priv->lockcount > 0) + { + /* Yes... just increment the lock count. In this case, we know + * that the bus has already been configured for the ENC28J60. + */ - /* Now make sure that the SPI bus is configured for the ENC28J60 (it - * might have gotten configured for a different device while unlocked) - */ + DEBUGASSERT(priv->lockcount < 255); + priv->lockcount++; + } + else + { + /* No... take the lock and set the lock count to 1 */ - SPI_SETMODE(spi, CONFIG_ENC28J60_SPIMODE); - SPI_SETBITS(spi, 8); + DEBUGASSERT(priv->lockcount == 0); + SPI_LOCK(priv->spi, true); + priv->lockcount = 1; + + /* Now make sure that the SPI bus is configured for the ENC28J60 (it + * might have gotten configured for a different device while unlocked) + */ + + SPI_SETMODE(priv->spi, CONFIG_ENC28J60_SPIMODE); + SPI_SETBITS(priv->spi, 8); #ifdef CONFIG_ENC28J60_FREQUENCY - SPI_SETFREQUENCY(spi, CONFIG_ENC28J60_FREQUENCY); + SPI_SETFREQUENCY(priv->spi, CONFIG_ENC28J60_FREQUENCY); #endif + } + + /* Select ENC28J60 chip. */ + + SPI_SELECT(priv->spi, SPIDEV_ETHERNET, true); } #endif @@ -387,19 +422,33 @@ static void enc_select(FAR struct spi_dev_s *spi) ****************************************************************************/ #ifdef CONFIG_SPI_OWNBUS -static inline void enc_deselect(FAR struct spi_dev_s *spi) +static inline void enc_deselect(FAR struct enc_driver_s *priv) { /* We own the SPI bus, so just de-select the chip */ - SPI_SELECT(spi, SPIDEV_ETHERNET, false); + SPI_SELECT(priv->spi, SPIDEV_ETHERNET, false); } #else -static void enc_deselect(FAR struct spi_dev_s *spi) +static void enc_deselect(FAR struct enc_driver_s *priv) { - /* De-select ENC28J60 chip and relinquish the SPI bus. */ + /* De-select ENC28J60 chip. */ + + SPI_SELECT(priv->spi, SPIDEV_ETHERNET, false); - SPI_SELECT(spi, SPIDEV_ETHERNET, false); - SPI_LOCK(spi, false); + /* And relinquishthe lock on the bus. If the lock count is > 1 then we + * are in a nested lock and we only need to decrement the lock cound. + */ + + if (priv->lockcount <= 1) + { + DEBUGASSERT(priv->lockcount == 1); + SPI_LOCK(priv->spi, false); + priv->lockcount = 0; + } + else + { + priv->lockcount--; + } } #endif @@ -423,26 +472,24 @@ static void enc_deselect(FAR struct spi_dev_s *spi) static uint8_t enc_rdgreg2(FAR struct enc_driver_s *priv, uint8_t cmd) { - FAR struct spi_dev_s *spi; uint8_t rddata; DEBUGASSERT(priv && priv->spi); - spi = priv->spi; /* Select ENC28J60 chip */ - enc_select(spi); + enc_select(priv); /* Send the read command and collect the data. The sequence requires * 16-clocks: 8 to clock out the cmd + 8 to clock in the data. */ - (void)SPI_SEND(spi, cmd); /* Clock out the command */ - rddata = SPI_SEND(spi, 0); /* Clock in the data */ + (void)SPI_SEND(priv->spi, cmd); /* Clock out the command */ + rddata = SPI_SEND(priv->spi, 0); /* Clock in the data */ /* De-select ENC28J60 chip */ - enc_deselect(spi); + enc_deselect(priv); return rddata; } @@ -468,25 +515,75 @@ static uint8_t enc_rdgreg2(FAR struct enc_driver_s *priv, uint8_t cmd) static void enc_wrgreg2(FAR struct enc_driver_s *priv, uint8_t cmd, uint8_t wrdata) { - FAR struct spi_dev_s *spi; - DEBUGASSERT(priv && priv->spi); - spi = priv->spi; /* Select ENC28J60 chip */ - enc_select(spi); + enc_select(priv); /* Send the write command and data. The sequence requires 16-clocks: * 8 to clock out the cmd + 8 to clock out the data. */ - (void)SPI_SEND(spi, cmd); /* Clock out the command */ - (void)SPI_SEND(spi, wrdata); /* Clock out the data */ + (void)SPI_SEND(priv->spi, cmd); /* Clock out the command */ + (void)SPI_SEND(priv->spi, wrdata); /* Clock out the data */ /* De-select ENC28J60 chip. */ - enc_deselect(spi); + enc_deselect(priv); +} + +/**************************************************************************** + * Function: enc_src + * + * Description: + * Send the single byte system reset command (SRC). + * + * "The System Reset Command (SRC) allows the host controller to issue a + * System Soft Reset command. Unlike other SPI commands, the SRC is + * only a single byte command and does not operate on any register. The + * command is started by pulling the CS pin low. The SRC opcode is the + * sent, followed by a 5-bit Soft Reset command constant of 1Fh. The + * SRC operation is terminated by raising the CS pin." + * + * Parameters: + * priv - Reference to the driver state structure + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +static inline void enc_src(FAR struct enc_driver_s *priv) +{ + DEBUGASSERT(priv && priv->spi); + + /* Select ENC28J60 chip */ + + enc_select(priv); + + /* Send the system reset command. */ + + (void)SPI_SEND(priv->spi, ENC_SRC); + + /* Check CLKRDY bit to see when the reset is complete. There is an errata + * that says the CLKRDY may be invalid. We'll wait a couple of msec to + * workaround this condition. + * + * Also, "After a System Reset, all PHY registers should not be read or + * written to until at least 50 µs have passed since the Reset has ended. + * All registers will revert to their Reset default values. The dual + * port buffer memory will maintain state throughout the System Reset." + */ + + up_mdelay(2); + /* while ((enc_rdgreg(priv, ENC_ESTAT) & ESTAT_CLKRDY) != 0); */ + + /* De-select ENC28J60 chip. */ + + enc_deselect(priv); } /**************************************************************************** @@ -551,39 +648,38 @@ static void enc_setbank(FAR struct enc_driver_s *priv, uint8_t bank) static uint8_t enc_rdbreg(FAR struct enc_driver_s *priv, uint8_t ctrlreg) { - FAR struct spi_dev_s *spi; uint8_t rddata; DEBUGASSERT(priv && priv->spi); - spi = priv->spi; - - /* Select ENC28J60 chip */ - - enc_select(spi); /* Set the bank */ enc_setbank(priv, GETBANK(ctrlreg)); + /* Select ENC28J60 chip */ + + enc_select(priv); + /* Send the RCR command and collect the data. How we collect the data * depends on if this is a PHY/CAN or not. The normal sequence requires * 16-clocks: 8 to clock out the cmd and 8 to clock in the data. */ - (void)SPI_SEND(spi, ENC_RCR | GETADDR(ctrlreg)); /* Clock out the command */ + (void)SPI_SEND(priv->spi, ENC_RCR | GETADDR(ctrlreg)); /* Clock out the command */ if (ISPHYMAC(ctrlreg)) { /* The PHY/MAC sequence requires 24-clocks: 8 to clock out the cmd, * 8 dummy bits, and 8 to clock in the PHY/MAC data. */ - (void)SPI_SEND(spi,0); /* Clock in the dummy byte */ + (void)SPI_SEND(priv->spi, 0); /* Clock in the dummy byte */ } - rddata = SPI_SEND(spi, 0); /* Clock in the data */ + + rddata = SPI_SEND(priv->spi, 0); /* Clock in the data */ /* De-select ENC28J60 chip */ - enc_deselect(spi); + enc_deselect(priv); return rddata; } @@ -610,14 +706,11 @@ static uint8_t enc_rdbreg(FAR struct enc_driver_s *priv, uint8_t ctrlreg) static void enc_wrbreg(FAR struct enc_driver_s *priv, uint8_t ctrlreg, uint8_t wrdata) { - FAR struct spi_dev_s *spi; - DEBUGASSERT(priv && priv->spi); - spi = priv->spi; /* Select ENC28J60 chip */ - enc_select(spi); + enc_select(priv); /* Set the bank */ @@ -627,12 +720,12 @@ static void enc_wrbreg(FAR struct enc_driver_s *priv, uint8_t ctrlreg, * 8 to clock out the cmd + 8 to clock out the data. */ - (void)SPI_SEND(spi, ENC_WCR | GETADDR(ctrlreg)); /* Clock out the command */ - (void)SPI_SEND(spi, wrdata); /* Clock out the data */ + (void)SPI_SEND(priv->spi, ENC_WCR | GETADDR(ctrlreg)); /* Clock out the command */ + (void)SPI_SEND(priv->spi, wrdata); /* Clock out the data */ /* De-select ENC28J60 chip. */ - enc_deselect(spi); + enc_deselect(priv); } /**************************************************************************** @@ -672,6 +765,7 @@ static int enc_waitbreg(FAR struct enc_driver_s *priv, uint8_t ctrlreg, elapsed = clock_systimer() - start; } while ((rddata & bits) != value || elapsed > ENC_POLLTIMEOUT); + return (rddata & bits) == value ? -ETIMEDOUT : OK; } @@ -697,26 +791,23 @@ static int enc_waitbreg(FAR struct enc_driver_s *priv, uint8_t ctrlreg, static void enc_rdbuffer(FAR struct enc_driver_s *priv, FAR uint8_t *buffer, size_t buflen) { - FAR struct spi_dev_s *spi; - DEBUGASSERT(priv && priv->spi); - spi = priv->spi; /* Select ENC28J60 chip */ - enc_select(spi); + enc_select(priv); /* Send the read buffer memory command (ignoring the response) */ - (void)SPI_SEND(spi, ENC_RBM); + (void)SPI_SEND(priv->spi, ENC_RBM); /* Then read the buffer data */ - SPI_RECVBLOCK(spi, buffer, buflen); + SPI_RECVBLOCK(priv->spi, buffer, buflen); /* De-select ENC28J60 chip. */ - enc_deselect(spi); + enc_deselect(priv); } /**************************************************************************** @@ -741,26 +832,23 @@ static void enc_rdbuffer(FAR struct enc_driver_s *priv, FAR uint8_t *buffer, static void enc_wrbuffer(FAR struct enc_driver_s *priv, FAR const uint8_t *buffer, size_t buflen) { - FAR struct spi_dev_s *spi; - DEBUGASSERT(priv && priv->spi); - spi = priv->spi; /* Select ENC28J60 chip */ - enc_select(spi); + enc_select(priv); /* Send the write buffer memory command (ignoring the response) */ - (void)SPI_SEND(spi, ENC_WBM); + (void)SPI_SEND(priv->spi, ENC_WBM); /* Then send the buffer */ - SPI_SNDBLOCK(spi, buffer, buflen); + SPI_SNDBLOCK(priv->spi, buffer, buflen); /* De-select ENC28J60 chip. */ - enc_deselect(spi); + enc_deselect(priv); } /**************************************************************************** @@ -802,6 +890,7 @@ static uint16_t enc_rdphy(FAR struct enc_driver_s *priv, uint8_t phyaddr) data = (uint16_t)enc_rdbreg(priv, ENC_MIRDL); data |= (uint16_t)enc_rdbreg(priv, ENC_MIRDH) << 8; } + return data; } @@ -1294,7 +1383,14 @@ static void enc_worker(FAR void *arg) DEBUGASSERT(priv); - /* Disable further interrupts by clearing the global interrup enable bit */ + /* Disable further interrupts by clearing the global interrupt enable bit. + * "After an interrupt occurs, the host controller should clear the global + * enable bit for the interrupt pin before servicing the interrupt. Clearing + * the enable bit will cause the interrupt pin to return to the non-asserted + * state (high). Doing so will prevent the host controller from missing a + * falling edge should another interrupt occur while the immediate interrupt + * is being serviced." + */ enc_bfcgreg(priv, ENC_EIE, EIE_INTIE); @@ -1462,12 +1558,17 @@ static void enc_worker(FAR void *arg) enc_rxerif(priv); /* Handle the RX error */ enc_bfcgreg(priv, ENC_EIR, EIR_RXERIF); /* Clear the RXERIF interrupt */ } - } /* Enable Ethernet interrupts */ enc_bfsgreg(priv, ENC_EIE, EIE_INTIE); + + /* Enable GPIO interrupts if they were disbled in enc_interrupt */ + +#ifndef CONFIG_SPI_OWNBUS + priv->lower->enable(priv->lower); +#endif } /**************************************************************************** @@ -1491,8 +1592,6 @@ static int enc_interrupt(int irq, FAR void *context) { register FAR struct enc_driver_s *priv = &g_enc28j60[0]; - DEBUGASSERT(priv->irq == irq); - #ifdef CONFIG_SPI_OWNBUS /* In very simple environments, we own the SPI and can do data transfers * from the interrupt handler. That is actually a very bad idea in any @@ -1509,7 +1608,15 @@ static int enc_interrupt(int irq, FAR void *context) * a good thing to do in any event. */ - return work_queue(&priv->work, enc_worker, (FAR void *)priv, 0); + DEBUGASSERT(work_available(&priv->work)); + + /* Notice that further GPIO interrupts are disabled until the work is + * actually performed. This is to prevent overrun of the worker thread. + * Interrupts are re-enabled in enc_worker() when the work is completed. + */ + + priv->lower->disable(priv->lower); + return work_queue(HPWORK, &priv->work, enc_worker, (FAR void *)priv, 0); #endif } @@ -1658,9 +1765,10 @@ static int enc_ifup(struct uip_driver_s *dev) * controller */ - priv->bifup = true; - up_enable_irq(priv->irq); + priv->ifstate = ENCSTATE_UP; + priv->lower->enable(priv->lower); } + return ret; } @@ -1687,13 +1795,13 @@ static int enc_ifdown(struct uip_driver_s *dev) int ret; nlldbg("Taking down: %d.%d.%d.%d\n", - dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, - (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 ); + dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, + (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 ); /* Disable the Ethernet interrupt */ flags = irqsave(); - up_disable_irq(priv->irq); + priv->lower->disable(priv->lower); /* Cancel the TX poll timer and TX timeout timers */ @@ -1705,7 +1813,7 @@ static int enc_ifdown(struct uip_driver_s *dev) ret = enc_reset(priv); enc_pwrsave(priv); - priv->bifup = false; + priv->ifstate = ENCSTATE_DOWN; irqrestore(flags); return ret; } @@ -1738,7 +1846,7 @@ static int enc_txavail(struct uip_driver_s *dev) /* Ignore the notification if the interface is not yet up */ - if (priv->bifup) + if (priv->ifstate == ENCSTATE_UP) { /* Check if the hardware is ready to send another packet. The driver * starts a transmission process by setting ECON1.TXRTS. When the packet is @@ -1991,15 +2099,7 @@ static int enc_reset(FAR struct enc_driver_s *priv) /* Reset the ENC28J60 */ - enc_wrgreg(priv, ENC_SRC, ENC_SRC); - - /* Check CLKRDY bit to see when the reset is complete. There is an errata - * that says the CLKRDY may be invalid. We'll wait a couple of msec to - * workaround this condition. - */ - - up_mdelay(2); - /* while ((enc_rdgreg(priv, ENC_ESTAT) & ESTAT_CLKRDY) != 0); */ + enc_src(priv); /* Initialize ECON1: Clear ECON1 */ @@ -2045,6 +2145,7 @@ static int enc_reset(FAR struct enc_driver_s *priv) nlldbg("Bad Rev ID: %02x\n", regval); return -ENODEV; } + nllvdbg("Rev ID: %02x\n", regval); /* Set filter mode: unicast OR broadcast AND crc valid */ @@ -2117,10 +2218,10 @@ static int enc_reset(FAR struct enc_driver_s *priv) * * Parameters: * spi - A reference to the platform's SPI driver for the ENC28J60 + * lower - The MCU-specific interrupt used to control low-level MCU + * functions (i.e., ENC28J60 GPIO interrupts). * devno - If more than one ENC28J60 is supported, then this is the * zero based number that identifies the ENC28J60; - * irq - The fully configured GPIO IRQ that ENC28J60 interrupts will be - * asserted on. This driver will attach and entable this IRQ. * * Returned Value: * OK on success; Negated errno on failure. @@ -2129,10 +2230,10 @@ static int enc_reset(FAR struct enc_driver_s *priv) * ****************************************************************************/ -int enc_initialize(FAR struct spi_dev_s *spi, unsigned int devno, unsigned int irq) +int enc_initialize(FAR struct spi_dev_s *spi, + FAR const struct enc_lower_s *lower, unsigned int devno) { - FAR struct enc_driver_s *priv ; - int ret; + FAR struct enc_driver_s *priv; DEBUGASSERT(devno < CONFIG_ENC28J60_NINTERFACES); priv = &g_enc28j60[devno]; @@ -2154,30 +2255,30 @@ int enc_initialize(FAR struct spi_dev_s *spi, unsigned int devno, unsigned int i priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ priv->spi = spi; /* Save the SPI instance */ - priv->irq = irq; /* Save the IRQ number */ - - /* Make sure that the interface is in the down state. NOTE: The MAC - * address will not be set up until ifup. That gives the app time to set - * the MAC address before bringing the interface up. + priv->lower = lower; /* Save the low-level MCU interface */ + + /* The interface should be in the down state. However, this function is called + * too early in initalization to perform the ENC28J60 reset in enc_ifdown. We + * are depending upon the fact that the application level logic will call enc_ifdown + * later to reset the ENC28J60. NOTE: The MAC address will not be set up until + * enc_ifup() is called. That gives the app time to set the MAC address before + * bringing the interface up. */ - ret = enc_ifdown(&priv->dev); - if (ret == OK) - { - /* Attach the IRQ to the driver (but don't enable it yet) */ - - if (irq_attach(irq, enc_interrupt)) - { - /* We could not attach the ISR to the interrupt */ + priv->ifstate = ENCSTATE_UNIT; - ret = -EAGAIN; - } + /* Attach the interrupt to the driver (but don't enable it yet) */ - /* Register the device with the OS so that socket IOCTLs can be performed */ + if (lower->attach(lower, enc_interrupt)) + { + /* We could not attach the ISR to the interrupt */ - (void)netdev_register(&priv->dev); + return -EAGAIN; } - return ret; + + /* Register the device with the OS so that socket IOCTLs can be performed */ + + return netdev_register(&priv->dev); } /**************************************************************************** diff --git a/nuttx/drivers/net/enc28j60.h b/nuttx/drivers/net/enc28j60.h index 408224b22..3c787c533 100644 --- a/nuttx/drivers/net/enc28j60.h +++ b/nuttx/drivers/net/enc28j60.h @@ -2,7 +2,7 @@ * drivers/net/enc28j60.h * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: * - ENC28J60 Data Sheet, Stand-Alone Ethernet Controller with SPI Interface, @@ -56,7 +56,7 @@ */ #define ENC_RCR (0x00) /* Read Control Register - * 000 | aaaaa | (Registe value returned)) */ + * 000 | aaaaa | (Register value returned)) */ #define ENC_RBM (0x3a) /* Read Buffer Memory * 001 | 11010 | (Read buffer data follows) */ #define ENC_WCR (0x40) /* Write Control Register diff --git a/nuttx/drivers/power/pm_activity.c b/nuttx/drivers/power/pm_activity.c index f52fc93ff..d3c8a52e7 100644 --- a/nuttx/drivers/power/pm_activity.c +++ b/nuttx/drivers/power/pm_activity.c @@ -2,7 +2,7 @@ * drivers/power/pm_activity.c * * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/power/pm_update.c b/nuttx/drivers/power/pm_update.c index ae5e1f840..4b6b58c55 100644 --- a/nuttx/drivers/power/pm_update.c +++ b/nuttx/drivers/power/pm_update.c @@ -328,7 +328,7 @@ void pm_update(int16_t accum) /* The work will be performed on the worker thread */ DEBUGASSERT(g_pmglobals.work.worker == NULL); - (void)work_queue(&g_pmglobals.work, pm_worker, (FAR void*)((intptr_t)accum), 0); + (void)work_queue(HPWORK, &g_pmglobals.work, pm_worker, (FAR void*)((intptr_t)accum), 0); } -#endif /* CONFIG_PM */
\ No newline at end of file +#endif /* CONFIG_PM */ diff --git a/nuttx/drivers/rwbuffer.c b/nuttx/drivers/rwbuffer.c index 1d924e2a0..076ebc781 100644 --- a/nuttx/drivers/rwbuffer.c +++ b/nuttx/drivers/rwbuffer.c @@ -213,7 +213,7 @@ static void rwb_wrstarttimeout(FAR struct rwbuffer_s *rwb) */ int ticks = (CONFIG_FS_WRDELAY + CLK_TCK/2) / CLK_TCK; - (void)work_queue(&rwb->work, rwb_wrtimeout, (FAR void *)rwb, ticks); + (void)work_queue(LPWORK, &rwb->work, rwb_wrtimeout, (FAR void *)rwb, ticks); } /**************************************************************************** @@ -222,7 +222,7 @@ static void rwb_wrstarttimeout(FAR struct rwbuffer_s *rwb) static inline void rwb_wrcanceltimeout(struct rwbuffer_s *rwb) { - (void)work_cancel(&rwb->work); + (void)work_cancel(LPWORK, &rwb->work); } /**************************************************************************** diff --git a/nuttx/drivers/sensors/Make.defs b/nuttx/drivers/sensors/Make.defs index d04e7541e..866ccb053 100644 --- a/nuttx/drivers/sensors/Make.defs +++ b/nuttx/drivers/sensors/Make.defs @@ -2,7 +2,7 @@ # drivers/sensors/Make.defs # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/sensors/lm75.c b/nuttx/drivers/sensors/lm75.c index 8e1a0fb4b..2d3346447 100644 --- a/nuttx/drivers/sensors/lm75.c +++ b/nuttx/drivers/sensors/lm75.c @@ -3,7 +3,7 @@ * Character driver for the STMicro LM-75 Temperature Sensor * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/sercomm/Make.defs b/nuttx/drivers/sercomm/Make.defs index 3585f5314..0cf93d4c8 100644 --- a/nuttx/drivers/sercomm/Make.defs +++ b/nuttx/drivers/sercomm/Make.defs @@ -2,7 +2,7 @@ # drivers/serial/Make.defs # # Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/sercomm/README.txt b/nuttx/drivers/sercomm/README.txt index a9239a204..a9239a204 100755..100644 --- a/nuttx/drivers/sercomm/README.txt +++ b/nuttx/drivers/sercomm/README.txt diff --git a/nuttx/drivers/serial/Kconfig b/nuttx/drivers/serial/Kconfig index b8867bd3f..43869fdec 100644 --- a/nuttx/drivers/serial/Kconfig +++ b/nuttx/drivers/serial/Kconfig @@ -44,10 +44,10 @@ config 16550_UART0_BITS 16550 UART0 number of bits. Default: 8 config 16550_UART0_2STOP - bool "16550 UART0 two stop bits" - default n + int "16550 UART0 two stop bits" + default 0 ---help--- - 16550 UART0 two stop bits. Default: 1 + 0=1 stop bit, 1=Two stop bits. Default: 1 stop bit config 16550_UART0_RXBUFSIZE int "16550 UART0 Rx buffer size" @@ -94,10 +94,10 @@ config 16550_UART1_BITS 16550 UART1 number of bits. Default: 8 config 16550_UART1_2STOP - bool "16550 UART1 two stop bits" - default n + int "16550 UART1 two stop bits" + default 0 ---help--- - 16550 UART1 two stop bits. Default: 1 + 0=1 stop bit, 1=Two stop bits. Default: 1 stop bit config 16550_UART1_RXBUFSIZE int "16550 UART1 Rx buffer size" @@ -144,10 +144,10 @@ config 16550_UART2_BITS 16550 UART2 number of bits. Default: 8 config 16550_UART2_2STOP - bool "16550 UART2 two stop bits" - default n + int "16550 UART2 two stop bits" + default 0 ---help--- - 16550 UART2 two stop bits. Default: 1 + 0=1 stop bit, 1=Two stop bits. Default: 1 stop bit config 16550_UART2_RXBUFSIZE int "16550 UART2 Rx buffer size" @@ -194,10 +194,10 @@ config 16550_UART3_BITS 16550 UART3 number of bits. Default: 8 config 16550_UART3_2STOP - bool "16550 UART3 two stop bits" - default n + int "16550 UART3 two stop bits" + default 0 ---help--- - 16550 UART3 two stop bits. Default: 1 + 0=1 stop bit, 1=Two stop bits. Default: 1 stop bit config 16550_UART3_RXBUFSIZE int "16550 UART3 Rx buffer size" @@ -215,25 +215,25 @@ endif choice prompt "16550 Serial Console" - default NO_SERIAL_CONSOLE + default 16550_NO_SERIAL_CONSOLE -config UART0_SERIAL_CONSOLE +config 16550_UART0_SERIAL_CONSOLE bool "16550 UART0 serial console" depends on 16550_UART0 -config UART1_SERIAL_CONSOLE +config 16550_UART1_SERIAL_CONSOLE bool "16550 UART1 serial console" depends on 16550_UART1 -config UART2_SERIAL_CONSOLE +config 16550_UART2_SERIAL_CONSOLE bool "16550 UART2 serial console" depends on 16550_UART2 -config UART3_SERIAL_CONSOLE +config 16550_UART3_SERIAL_CONSOLE bool "16550 UART3 serial console" depends on 16550_UART3 -config NO_SERIAL_CONSOLE +config 16550_NO_SERIAL_CONSOLE bool "No 16550 serial console" endchoice @@ -267,19 +267,783 @@ config 16550_ADDRWIDTH endif +# +# MCU serial peripheral driver? +# + +config ARCH_HAVE_UART + bool +config ARCH_HAVE_UART0 + bool +config ARCH_HAVE_UART1 + bool +config ARCH_HAVE_UART2 + bool +config ARCH_HAVE_UART3 + bool +config ARCH_HAVE_UART4 + bool +config ARCH_HAVE_UART5 + bool +config ARCH_HAVE_UART6 + bool + +config ARCH_HAVE_USART0 + bool +config ARCH_HAVE_USART1 + bool +config ARCH_HAVE_USART2 + bool +config ARCH_HAVE_USART3 + bool +config ARCH_HAVE_USART4 + bool +config ARCH_HAVE_USART5 + bool +config ARCH_HAVE_USART6 + bool + +config MCU_SERIAL + bool + default y if ARCH_HAVE_UART || ARCH_HAVE_UART0 || ARCH_HAVE_USART0 || ARCH_HAVE_UART1 || ARCH_HAVE_USART1 || \ + ARCH_HAVE_UART2 || ARCH_HAVE_USART2 || ARCH_HAVE_UART3 || ARCH_HAVE_USART3 || \ + ARCH_HAVE_UART4 || ARCH_HAVE_USART4 || ARCH_HAVE_UART5 || ARCH_HAVE_USART5 || ARCH_HAVE_UART6 || ARCH_HAVE_USART6 + +# +# Standard serial driver configuration +# + config STANDARD_SERIAL - bool "Standard serial" - default y if !LOWLEVEL_CONSOLE && !16550_UART + bool "Enable standard \"upper-half\" serial driver" + default y if MCU_SERIAL + default n if !MCU_SERIAL + depends on !LOWLEVEL_CONSOLE + ---help--- + Enable the standard, upper-half serial driver used by most MCU serial peripherals. -if STANDARD_SERIAL config CONFIG_SERIAL_NPOLLWAITERS int "Number of poll threads" default 2 - depends on !DISABLE_POLL + depends on !DISABLE_POLL && STANDARD_SERIAL ---help--- Maximum number of threads than can be waiting for POLL events. Default: 2 -endif +# +# U[S]ARTn_XYZ settings for MCU serial drivers +# + +choice + prompt "Serial console" + depends on MCU_SERIAL + default NO_SERIAL_CONSOLE + +config UART_SERIAL_CONSOLE + bool "UART" + depends on ARCH_HAVE_UART + +config UART0_SERIAL_CONSOLE + bool "UART0" + depends on ARCH_HAVE_UART0 + +config USART0_SERIAL_CONSOLE + bool "USART0" + depends on ARCH_HAVE_USART0 + +config UART1_SERIAL_CONSOLE + bool "UART1" + depends on ARCH_HAVE_UART1 + +config USART1_SERIAL_CONSOLE + bool "USART1" + depends on ARCH_HAVE_USART1 + +config UART2_SERIAL_CONSOLE + bool "UART2" + depends on ARCH_HAVE_UART2 + +config USART2_SERIAL_CONSOLE + bool "USART2" + depends on ARCH_HAVE_USART2 + +config UART3_SERIAL_CONSOLE + bool "UART3" + depends on ARCH_HAVE_UART3 + +config USART3_SERIAL_CONSOLE + bool "USART3" + depends on ARCH_HAVE_USART3 + +config UART4_SERIAL_CONSOLE + bool "UART4" + depends on ARCH_HAVE_UART4 + +config USART4_SERIAL_CONSOLE + bool "USART4" + depends on ARCH_HAVE_USART4 + +config UART5_SERIAL_CONSOLE + bool "UART5" + depends on ARCH_HAVE_UART5 + +config USART5_SERIAL_CONSOLE + bool "USART5" + depends on ARCH_HAVE_USART5 + +config UART6_SERIAL_CONSOLE + bool "UART6" + depends on ARCH_HAVE_UART6 + +config USART6_SERIAL_CONSOLE + bool "USART6" + depends on ARCH_HAVE_USART6 + +config NO_SERIAL_CONSOLE + bool "No serial console" + +endchoice + +menu "UART Configuration" + depends on ARCH_HAVE_UART + +config UART_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config UART_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config UART_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the UART. + +config UART_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config UART_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config UART_2STOP + int "use 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "UART0 Configuration" + depends on ARCH_HAVE_UART0 + +config UART0_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config UART0_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config UART0_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the UART. + +config UART0_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config UART0_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config UART0_2STOP + int "use 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "USART0 Configuration" + depends on ARCH_HAVE_USART0 + +config USART0_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config USART0_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config USART0_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the USART. + +config USART0_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config USART0_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config USART0_2STOP + int "use 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "UART1 Configuration" + depends on ARCH_HAVE_UART1 + +config UART1_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config UART1_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config UART1_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the UART. + +config UART1_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config UART1_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config UART1_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "USART1 Configuration" + depends on ARCH_HAVE_USART1 + +config USART1_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config USART1_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config USART1_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the USART. + +config USART1_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config USART1_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config USART1_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "UART2 Configuration" + depends on ARCH_HAVE_UART2 + +config UART2_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config UART2_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. +config UART2_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the UART. + +config UART2_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config UART2_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config UART2_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "USART2 Configuration" + depends on ARCH_HAVE_USART2 + +config USART2_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config USART2_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config USART2_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the USART. + +config USART2_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config USART2_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config USART2_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "UART3 Configuration" + depends on ARCH_HAVE_UART3 + +config UART3_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config UART3_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config UART3_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the UART. + +config UART3_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config UART3_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config UART3_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "USART3 Configuration" + depends on ARCH_HAVE_USART3 + +config USART3_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config USART3_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config USART3_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the USART. + +config USART3_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config USART3_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config USART3_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "UART4 Configuration" + depends on ARCH_HAVE_UART4 + +config UART4_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config UART4_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config UART4_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the UART. + +config UART4_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config UART4_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config UART4_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "USART4 Configuration" + depends on ARCH_HAVE_USART4 + +config USART4_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config USART4_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config USART4_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the USART. + +config USART4_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config USART4_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config USART4_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "UART5 Configuration" + depends on ARCH_HAVE_UART5 + +config UART5_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config UART5_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config UART5_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the UART. + +config UART5_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config UART5_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config UART5_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "USART5 Configuration" + depends on ARCH_HAVE_USART5 + +config USART5_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config USART5_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config USART5_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the USART. + +config USART5_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config USART5_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config USART5_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "USART6 Configuration" + depends on ARCH_HAVE_USART6 + +config USART6_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config USART6_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config USART6_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the USART. + +config USART6_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config USART6_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config USART6_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits + +endmenu + +menu "UART6 Configuration" + depends on ARCH_HAVE_UART6 + +config UART6_RXBUFSIZE + int "receive buffer size" + default 256 + help + Characters are buffered as they are received. This specifies + the size of the receive buffer. + +config UART6_TXBUFSIZE + int "transmit buffer size" + default 256 + help + Characters are buffered before being sent. This specifies + the size of the transmit buffer. + +config UART6_BAUD + int "baud rate" + default 11520 + help + The configured BAUD of the UART. + +config UART6_BITS + int "character size" + default 8 + help + The number of bits. Must be either 7 or 8. + +config UART6_PARITY + int "parity setting" + default 0 + help + 0=no parity, 1=odd parity, 2=even parity + +config UART6_2STOP + int "uses 2 stop bits" + default 0 + help + 1=Two stop bits +endmenu diff --git a/nuttx/drivers/serial/uart_16550.c b/nuttx/drivers/serial/uart_16550.c index ea7d944f3..8fb71bfd2 100644 --- a/nuttx/drivers/serial/uart_16550.c +++ b/nuttx/drivers/serial/uart_16550.c @@ -128,20 +128,20 @@ struct uart_ops_s g_uart_ops = /* I/O buffers */ #ifdef CONFIG_16550_UART0 -static char g_uart0rxbuffer[CONFIG_UART0_RXBUFSIZE]; -static char g_uart0txbuffer[CONFIG_UART0_TXBUFSIZE]; +static char g_uart0rxbuffer[CONFIG_16550_UART0_RXBUFSIZE]; +static char g_uart0txbuffer[CONFIG_16550_UART0_TXBUFSIZE]; #endif #ifdef CONFIG_16550_UART1 -static char g_uart1rxbuffer[CONFIG_UART1_RXBUFSIZE]; -static char g_uart1txbuffer[CONFIG_UART1_TXBUFSIZE]; +static char g_uart1rxbuffer[CONFIG_16550_UART1_RXBUFSIZE]; +static char g_uart1txbuffer[CONFIG_16550_UART1_TXBUFSIZE]; #endif #ifdef CONFIG_16550_UART2 -static char g_uart2rxbuffer[CONFIG_UART1_RXBUFSIZE]; -static char g_uart2txbuffer[CONFIG_UART1_TXBUFSIZE]; +static char g_uart2rxbuffer[CONFIG_16550_UART2_RXBUFSIZE]; +static char g_uart2txbuffer[CONFIG_16550_UART2_TXBUFSIZE]; #endif #ifdef CONFIG_16550_UART3 -static char g_uart3rxbuffer[CONFIG_UART1_RXBUFSIZE]; -static char g_uart3txbuffer[CONFIG_UART1_TXBUFSIZE]; +static char g_uart3rxbuffer[CONFIG_16550_UART3_RXBUFSIZE]; +static char g_uart3txbuffer[CONFIG_16550_UART3_TXBUFSIZE]; #endif /* This describes the state of the LPC17xx uart0 port. */ @@ -151,16 +151,16 @@ static struct u16550_s g_uart0priv = { .uartbase = CONFIG_16550_UART0_BASE, #ifndef CONFIG_16550_SUPRESS_CONFIG - .baud = CONFIG_UART0_BAUD, + .baud = CONFIG_16550_UART0_BAUD, .uartclk = CONFIG_16550_UART0_CLOCK, #endif #ifndef CONFIG_SUPPRESS_SERIAL_INTS .irq = CONFIG_16550_UART0_IRQ, #endif #ifndef CONFIG_16550_SUPRESS_CONFIG - .parity = CONFIG_UART0_PARITY, - .bits = CONFIG_UART0_BITS, - .stopbits2 = CONFIG_UART0_2STOP, + .parity = CONFIG_16550_UART0_PARITY, + .bits = CONFIG_16550_UART0_BITS, + .stopbits2 = CONFIG_16550_UART0_2STOP, #endif }; @@ -168,12 +168,12 @@ static uart_dev_t g_uart0port = { .recv = { - .size = CONFIG_UART0_RXBUFSIZE, + .size = CONFIG_16550_UART0_RXBUFSIZE, .buffer = g_uart0rxbuffer, }, .xmit = { - .size = CONFIG_UART0_TXBUFSIZE, + .size = CONFIG_16550_UART0_TXBUFSIZE, .buffer = g_uart0txbuffer, }, .ops = &g_uart_ops, @@ -188,16 +188,16 @@ static struct u16550_s g_uart1priv = { .uartbase = CONFIG_16550_UART1_BASE, #ifndef CONFIG_16550_SUPRESS_CONFIG - .baud = CONFIG_UART1_BAUD, + .baud = CONFIG_16550_UART1_BAUD, .uartclk = CONFIG_16550_UART1_CLOCK, #endif #ifndef CONFIG_SUPPRESS_SERIAL_INTS .irq = CONFIG_16550_UART1_IRQ, #endif #ifndef CONFIG_16550_SUPRESS_CONFIG - .parity = CONFIG_UART1_PARITY, - .bits = CONFIG_UART1_BITS, - .stopbits2 = CONFIG_UART1_2STOP, + .parity = CONFIG_16550_UART1_PARITY, + .bits = CONFIG_16550_UART1_BITS, + .stopbits2 = CONFIG_16550_UART1_2STOP, #endif }; @@ -205,12 +205,12 @@ static uart_dev_t g_uart1port = { .recv = { - .size = CONFIG_UART1_RXBUFSIZE, + .size = CONFIG_16550_UART1_RXBUFSIZE, .buffer = g_uart1rxbuffer, }, .xmit = { - .size = CONFIG_UART1_TXBUFSIZE, + .size = CONFIG_16550_UART1_TXBUFSIZE, .buffer = g_uart1txbuffer, }, .ops = &g_uart_ops, @@ -225,16 +225,16 @@ static struct u16550_s g_uart2priv = { .uartbase = CONFIG_16550_UART2_BASE, #ifndef CONFIG_16550_SUPRESS_CONFIG - .baud = CONFIG_UART2_BAUD, + .baud = CONFIG_16550_UART2_BAUD, .uartclk = CONFIG_16550_UART2_CLOCK, #endif #ifndef CONFIG_SUPPRESS_SERIAL_INTS .irq = CONFIG_16550_UART2_IRQ, #endif #ifndef CONFIG_16550_SUPRESS_CONFIG - .parity = CONFIG_UART2_PARITY, - .bits = CONFIG_UART2_BITS, - .stopbits2 = CONFIG_UART2_2STOP, + .parity = CONFIG_16550_UART2_PARITY, + .bits = CONFIG_16550_UART2_BITS, + .stopbits2 = CONFIG_16550_UART2_2STOP, #endif }; @@ -242,12 +242,12 @@ static uart_dev_t g_uart2port = { .recv = { - .size = CONFIG_UART2_RXBUFSIZE, + .size = CONFIG_16550_UART2_RXBUFSIZE, .buffer = g_uart2rxbuffer, }, .xmit = { - .size = CONFIG_UART2_TXBUFSIZE, + .size = CONFIG_16550_UART2_TXBUFSIZE, .buffer = g_uart2txbuffer, }, .ops = &g_uart_ops, @@ -262,16 +262,16 @@ static struct u16550_s g_uart3priv = { .uartbase = CONFIG_16550_UART3_BASE, #ifndef CONFIG_16550_SUPRESS_CONFIG - .baud = CONFIG_UART3_BAUD, + .baud = CONFIG_16550_UART3_BAUD, .uartclk = CONFIG_16550_UART3_CLOCK, #endif #ifndef CONFIG_SUPPRESS_SERIAL_INTS .irq = CONFIG_16550_UART3_IRQ, #endif #ifndef CONFIG_16550_SUPRESS_CONFIG - .parity = CONFIG_UART3_PARITY, - .bits = CONFIG_UART3_BITS, - .stopbits2 = CONFIG_UART3_2STOP, + .parity = CONFIG_16550_UART3_PARITY, + .bits = CONFIG_16550_UART3_BITS, + .stopbits2 = CONFIG_16550_UART3_2STOP, #endif }; @@ -279,12 +279,12 @@ static uart_dev_t g_uart3port = { .recv = { - .size = CONFIG_UART3_RXBUFSIZE, + .size = CONFIG_16550_UART3_RXBUFSIZE, .buffer = g_uart3rxbuffer, }, .xmit = { - .size = CONFIG_UART3_TXBUFSIZE, + .size = CONFIG_16550_UART3_TXBUFSIZE, .buffer = g_uart3txbuffer, }, .ops = &g_uart_ops, @@ -294,7 +294,7 @@ static uart_dev_t g_uart3port = /* Which UART with be tty0/console and which tty1? tty2? tty3? */ -#if defined(CONFIG_UART0_SERIAL_CONSOLE) +#if defined(CONFIG_16550_UART0_SERIAL_CONSOLE) # define CONSOLE_DEV g_uart0port /* UART0=console */ # define TTYS0_DEV g_uart0port /* UART0=ttyS0 */ # ifdef CONFIG_16550_UART1 @@ -333,7 +333,7 @@ static uart_dev_t g_uart3port = # undef TTYS3_DEV /* No ttyS3 */ # endif # endif -#elif defined(CONFIG_UART1_SERIAL_CONSOLE) +#elif defined(CONFIG_16550_UART1_SERIAL_CONSOLE) # define CONSOLE_DEV g_uart1port /* UART1=console */ # define TTYS0_DEV g_uart1port /* UART1=ttyS0 */ # ifdef CONFIG_16550_UART @@ -372,7 +372,7 @@ static uart_dev_t g_uart3port = # undef TTYS3_DEV /* No ttyS3 */ # endif # endif -#elif defined(CONFIG_UART2_SERIAL_CONSOLE) +#elif defined(CONFIG_16550_UART2_SERIAL_CONSOLE) # define CONSOLE_DEV g_uart2port /* UART2=console */ # define TTYS0_DEV g_uart2port /* UART2=ttyS0 */ # ifdef CONFIG_16550_UART @@ -411,7 +411,7 @@ static uart_dev_t g_uart3port = # undef TTYS3_DEV /* No ttyS3 */ # endif # endif -#elif defined(CONFIG_UART3_SERIAL_CONSOLE) +#elif defined(CONFIG_16550_UART3_SERIAL_CONSOLE) # define CONSOLE_DEV g_uart3port /* UART3=console */ # define TTYS0_DEV g_uart3port /* UART3=ttyS0 */ # ifdef CONFIG_16550_UART @@ -1161,4 +1161,4 @@ int up_putc(int ch) } #endif -#endif /* CONFIG_UART_16550 */ +#endif /* CONFIG_16550_UART */ diff --git a/nuttx/drivers/usbdev/Kconfig b/nuttx/drivers/usbdev/Kconfig index 24b13f378..70c7a04f0 100644 --- a/nuttx/drivers/usbdev/Kconfig +++ b/nuttx/drivers/usbdev/Kconfig @@ -2,12 +2,97 @@ # For a description of the syntax of this configuration file, # see misc/tools/kconfig-language.txt. # + +menu "Device Controller Driver Options" + +config USBDEV_ISOCHRONOUS + bool "Enable isochronous" + default n + ---help--- + Build in extra support for isochronous endpoints + +config USBDEV_DUALSPEED + bool "Enable high and full speed" + default n + ---help--- + Hardware handles high and full speed operation (USB 2.0) + +choice USBDEV_POWERED + prompt "Select USB device powered" + default USBDEV_SELFPOWERED + +config USBDEV_SELFPOWERED + bool "Self powered" + ---help--- + Will cause USB features to indicate that the device is self-powered + +config USBDEV_BUSPOWERED + bool "Bus powered" + ---help--- + Will cause USB features to indicate that the device is self-powered + +endchoice + +config USBDEV_MAXPOWER + int "Maximum power consumption in mA" + default 100 + depends on USBDEV_BUSPOWERED + ---help--- + Maximum power consumption in mA + +config USBDEV_DMA + bool "Enable DMA methods" + default n + ---help--- + Select this enable DMA-related methods in USB device controller driver + interface. These methods include the DMA buffer allocation methods: + allobuffer() and freebuffer(). + + The USB class driver allocates packet I/O buffers for data transfer by + calling the driver allocbuffer() and freebuffer() methods. Those methods + are only available if USBDEV_DMA is defined in the system configuration. + +config USBDEV_DMAMEMORY +bool "Board DMA Allocation Hooks" + default n + depends on USBDEV_DMA + ---help--- + The USB class driver allocates packet I/O buffers for data transfer by + calling the driver allocbuffer() and freebuffer() methods. Those methods + are only available if USBDEV_DMA is defined in the system configuration. + + If USBDEV_DMAMEMORY is also defined in the NuttX configuration, then + the driver implementations of the allocbuffer() and freebuffer() + methods may use board-specific usbdev_dma_alloc() and usbdev_dma_free(). + If USBDEV_DMA and USBDEV_DMAMEMORY are both defined, then the board- + specific logic must provide the functions usbdev_dma_alloc() and + usbdev_dma_free(): usbdev_dma_alloc() will allocate DMA-capable + memory of the specified size; usbdev_dma_free() is the corresponding + function that will be called to free the DMA-capable memory. + +config USBDEV_TRACE + bool "Enable USB tracing for debug" + default n + ---help--- + Enables USB tracing for debug + +config USBDEV_TRACE_NRECORDS + int "Number of trace entries to remember" + default 32 + depends on USBDEV_TRACE + ---help--- + Number of trace entries to remember + +endmenu + menuconfig USBDEV_COMPOSITE bool "USB composite device support" default n ---help--- Enables USB composite device support + if USBDEV_COMPOSITE + #config COMPOSITE_IAD # bool "" # default n @@ -62,59 +147,12 @@ config COMPOSITE_VERSIONNO Interface version number. endif -config USBDEV_ISOCHRONOUS - bool "Enable isochronous" - default n - ---help--- - Build in extra support for isochronous endpoints - -config USBDEV_DUALSPEED - bool "Enable high and full speed" - default n - ---help--- - Hardware handles high and full speed - operation (USB 2.0) - -choice USBDEV_POWERED - prompt "Select USB device powered" - default USBDEV_SELFPOWERED -config USBDEV_SELFPOWERED - bool "Self powerd" - ---help--- - Will cause USB features to indicate - that the device is self-powered - -config USBDEV_BUSPOWERED - bool "Bus powerd" - ---help--- - Will cause USB features to indicate - that the device is self-powered -endchoice -config USBDEV_MAXPOWER - int "Maximum power consumption in mA" - default 100 - depends on USBDEV_BUSPOWERED - ---help--- - Maximum power consumption in mA - -config USBDEV_TRACE - bool "Enable USB tracing for debug" - default n - ---help--- - Enables USB tracing for debug - -config USBDEV_TRACE_NRECORDS - int "Number of trace entries to remember" - default 32 - depends on USBDEV_TRACE - ---help--- - Number of trace entries to remember - menuconfig PL2303 bool "Emulates the Prolific PL2303 serial/USB converter" default n ---help--- This logic emulates the Prolific PL2303 serial/USB converter + if PL2303 config PL2303_EPINTIN int "Logical endpoint numbers" @@ -178,6 +216,7 @@ menuconfig CDCACM default n ---help--- Enables USB Modem (CDC ACM) support + if CDCACM config CDCACM_COMPOSITE bool "CDCACM composite support" @@ -443,6 +482,10 @@ config USBMSC_PRODUCTSTR string "Mass stroage product string" default "Mass stroage" +config USBMSC_VERSIONNO + hex "USB MSC Version Number" + default "0x399" + config USBMSC_REMOVABLE bool "Mass stroage remove able" default n diff --git a/nuttx/drivers/usbhost/Make.defs b/nuttx/drivers/usbhost/Make.defs index cc28e874d..fd54ab53e 100644 --- a/nuttx/drivers/usbhost/Make.defs +++ b/nuttx/drivers/usbhost/Make.defs @@ -2,7 +2,7 @@ # drivers/usbhost/Make.defs # # Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/usbhost/usbhost_findclass.c b/nuttx/drivers/usbhost/usbhost_findclass.c index f08aff580..3e38670cf 100644 --- a/nuttx/drivers/usbhost/usbhost_findclass.c +++ b/nuttx/drivers/usbhost/usbhost_findclass.c @@ -2,7 +2,7 @@ * drivers/usbhost/usbhost_findclass.c * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/usbhost/usbhost_hidkbd.c b/nuttx/drivers/usbhost/usbhost_hidkbd.c index 73224ff5c..e69d68e7b 100644 --- a/nuttx/drivers/usbhost/usbhost_hidkbd.c +++ b/nuttx/drivers/usbhost/usbhost_hidkbd.c @@ -2,7 +2,7 @@ * drivers/usbhost/usbhost_hidkbd.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1674,7 +1674,7 @@ static int usbhost_disconnected(struct usbhost_class_s *class) */ DEBUGASSERT(priv->work.worker == NULL); - (void)work_queue(&priv->work, usbhost_destroy, priv, 0); + (void)work_queue(HPWORK, &priv->work, usbhost_destroy, priv, 0); } return OK; diff --git a/nuttx/drivers/usbhost/usbhost_registerclass.c b/nuttx/drivers/usbhost/usbhost_registerclass.c index 76ef511af..f4d1b64af 100644 --- a/nuttx/drivers/usbhost/usbhost_registerclass.c +++ b/nuttx/drivers/usbhost/usbhost_registerclass.c @@ -2,7 +2,7 @@ * drivers/usbhost/usbhost_registerclass.c * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/usbhost/usbhost_registry.c b/nuttx/drivers/usbhost/usbhost_registry.c index 56c03e2dc..fb2e900e2 100644 --- a/nuttx/drivers/usbhost/usbhost_registry.c +++ b/nuttx/drivers/usbhost/usbhost_registry.c @@ -2,7 +2,7 @@ * drivers/usbhost/usbhost_registry.c * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/usbhost/usbhost_registry.h b/nuttx/drivers/usbhost/usbhost_registry.h index 63436af5d..759a1c66e 100644 --- a/nuttx/drivers/usbhost/usbhost_registry.h +++ b/nuttx/drivers/usbhost/usbhost_registry.h @@ -2,7 +2,7 @@ * drivers/usbhost/usbdev_registry.h * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/usbhost/usbhost_skeleton.c b/nuttx/drivers/usbhost/usbhost_skeleton.c index 0a88a4f1b..c44a265e8 100644 --- a/nuttx/drivers/usbhost/usbhost_skeleton.c +++ b/nuttx/drivers/usbhost/usbhost_skeleton.c @@ -1,8 +1,8 @@ /**************************************************************************** * drivers/usbhost/usbhost_skeleton.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1015,7 +1015,7 @@ static int usbhost_disconnected(struct usbhost_class_s *class) uvdbg("Queuing destruction: worker %p->%p\n", priv->work.worker, usbhost_destroy); DEBUGASSERT(priv->work.worker == NULL); - (void)work_queue(&priv->work, usbhost_destroy, priv, 0); + (void)work_queue(HPWORK, &priv->work, usbhost_destroy, priv, 0); } else { diff --git a/nuttx/drivers/usbhost/usbhost_storage.c b/nuttx/drivers/usbhost/usbhost_storage.c index 2e3136b33..2b14676d7 100644 --- a/nuttx/drivers/usbhost/usbhost_storage.c +++ b/nuttx/drivers/usbhost/usbhost_storage.c @@ -1786,7 +1786,7 @@ static int usbhost_disconnected(struct usbhost_class_s *class) uvdbg("Queuing destruction: worker %p->%p\n", priv->work.worker, usbhost_destroy); DEBUGASSERT(priv->work.worker == NULL); - (void)work_queue(&priv->work, usbhost_destroy, priv, 0); + (void)work_queue(HPWORK, &priv->work, usbhost_destroy, priv, 0); } else { diff --git a/nuttx/drivers/wireless/Make.defs b/nuttx/drivers/wireless/Make.defs index ac73c8d85..f47f7666a 100644 --- a/nuttx/drivers/wireless/Make.defs +++ b/nuttx/drivers/wireless/Make.defs @@ -2,7 +2,7 @@ # drivers/wireless/Make.defs # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/drivers/wireless/cc1101/cc1101.c b/nuttx/drivers/wireless/cc1101/cc1101.c index 45faaecd2..45faaecd2 100755..100644 --- a/nuttx/drivers/wireless/cc1101/cc1101.c +++ b/nuttx/drivers/wireless/cc1101/cc1101.c diff --git a/nuttx/fs/fat/Kconfig b/nuttx/fs/fat/Kconfig index 30983799d..1de613ce4 100644 --- a/nuttx/fs/fat/Kconfig +++ b/nuttx/fs/fat/Kconfig @@ -11,12 +11,6 @@ config FS_FAT Enable FAT filesystem support if FS_FAT -config FAT_SECTORSIZE - int "FAT sector size" - default 512 - ---help--- - Max supported sector size - config FAT_LCNAMES bool "FAT upper/lower names" default n @@ -47,9 +41,26 @@ config FAT_MAXFNAME config FS_FATTIME bool "FAT timestamps" default n - ---help--- + ---help--- Support FAT date and time. NOTE: There is not much sense in supporting FAT date and time unless you have a hardware RTC or other way to get the time and date. +config FAT_DMAMEMORY + bool "DMA memory allocator" + default n + ---help--- + The FAT file system allocates two I/O buffers for data transfer, each + are the size of one device sector. One of the buffers is allocated + once for each FAT volume that is mounted; the other buffers are + allocated each time a FAT file is opened. + + Some hardware, however, may require special DMA-capable memory in + order to perform the the transfers. If FAT_DMAMEMORY is defined + then the architecture-specific hardware must provide the funtions + fat_dma_alloc() and fat_dma_free(): fat_dmalloc() will allocate + DMA-capable memory of the specified size; fat_dmafree() is the + corresponding function that will be called to free the DMA-capable + memory. + endif diff --git a/nuttx/fs/fat/Make.defs b/nuttx/fs/fat/Make.defs index 96be43961..136302b86 100644 --- a/nuttx/fs/fat/Make.defs +++ b/nuttx/fs/fat/Make.defs @@ -2,7 +2,7 @@ # Make.defs # # Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/fs/fat/fs_configfat.c b/nuttx/fs/fat/fs_configfat.c index 3a55a5215..2075caa9f 100644 --- a/nuttx/fs/fat/fs_configfat.c +++ b/nuttx/fs/fat/fs_configfat.c @@ -2,7 +2,7 @@ * fs/fat/fs_configfat.c * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c index 7b7ce1f5f..0c28cea67 100644 --- a/nuttx/fs/fat/fs_fat32.c +++ b/nuttx/fs/fat/fs_fat32.c @@ -302,7 +302,7 @@ static int fat_open(FAR struct file *filep, const char *relpath, /* Create a file buffer to support partial sector accesses */ - ff->ff_buffer = (uint8_t*)kmalloc(fs->fs_hwsectorsize); + ff->ff_buffer = (uint8_t*)fat_io_alloc(fs->fs_hwsectorsize); if (!ff->ff_buffer) { ret = -ENOMEM; @@ -405,7 +405,7 @@ static int fat_close(FAR struct file *filep) if (ff->ff_buffer) { - kfree(ff->ff_buffer); + fat_io_free(ff->ff_buffer, fs->fs_hwsectorsize); } /* Then free the file structure itself. */ @@ -1651,8 +1651,9 @@ static int fat_unbind(void *handle, FAR struct inode **blkdriver) if (fs->fs_buffer) { - kfree(fs->fs_buffer); + fat_io_free(fs->fs_buffer, fs->fs_hwsectorsize); } + kfree(fs); } diff --git a/nuttx/fs/fat/fs_fat32.h b/nuttx/fs/fat/fs_fat32.h index 5b82ff701..71a21333b 100644 --- a/nuttx/fs/fat/fs_fat32.h +++ b/nuttx/fs/fat/fs_fat32.h @@ -48,6 +48,7 @@ #include <semaphore.h> #include <time.h> +#include <nuttx/kmalloc.h> #include <nuttx/fs/dirent.h> /**************************************************************************** @@ -677,6 +678,33 @@ #endif /**************************************************************************** + * Name: fat_io_alloc and fat_io_free + * + * Description: + * The FAT file system allocates two I/O buffers for data transfer, each + * are the size of one device sector. One of the buffers is allocated + * once for each FAT volume that is mounted; the other buffers are + * allocated each time a FAT file is opened. + * + * Some hardware, however, may require special DMA-capable memory in + * order to perform the the transfers. If CONFIG_FAT_DMAMEMORY is defined + * then the architecture-specific hardware must provide the funtions + * fat_dma_alloc() and fat_dma_free() as prototyped below: fat_dmalloc() + * will allocate DMA-capable memory of the specified size; fat_dmafree() + * is the corresponding function that will be called to free the DMA- + * capable memory. + * + ****************************************************************************/ + +#ifdef CONFIG_FAT_DMAMEMORY +# define fat_io_alloc(s) fat_dma_alloc(s) +# define fat_io_free(m,s) fat_dma_free(m,s) +#else +# define fat_io_alloc(s) kmalloc(s) +# define fat_io_free(m,s) kfree(m) +#endif + +/**************************************************************************** * Public Types ****************************************************************************/ diff --git a/nuttx/fs/fat/fs_fat32dirent.c b/nuttx/fs/fat/fs_fat32dirent.c index 742fa1eeb..18cf67847 100644 --- a/nuttx/fs/fat/fs_fat32dirent.c +++ b/nuttx/fs/fat/fs_fat32dirent.c @@ -2,7 +2,7 @@ * fs/fat/fs_fat32dirent.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/fs/fat/fs_fat32util.c b/nuttx/fs/fat/fs_fat32util.c index 397467c41..7231456d7 100644 --- a/nuttx/fs/fat/fs_fat32util.c +++ b/nuttx/fs/fat/fs_fat32util.c @@ -542,7 +542,7 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable) /* Allocate a buffer to hold one hardware sector */ - fs->fs_buffer = (uint8_t*)kmalloc(fs->fs_hwsectorsize); + fs->fs_buffer = (uint8_t*)fat_io_alloc(fs->fs_hwsectorsize); if (!fs->fs_buffer) { ret = -ENOMEM; @@ -668,7 +668,7 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable) return OK; errout_with_buffer: - kfree(fs->fs_buffer); + fat_io_free(fs->fs_buffer, fs->fs_hwsectorsize); fs->fs_buffer = 0; errout: fs->fs_mounted = false; @@ -1563,7 +1563,7 @@ int fat_ffcacheflush(struct fat_mountpt_s *fs, struct fat_file_s *ff) */ if (ff->ff_cachesector && - ff->ff_bflags && (FFBUFF_DIRTY|FFBUFF_VALID) == (FFBUFF_DIRTY|FFBUFF_VALID)) + (ff->ff_bflags & (FFBUFF_DIRTY|FFBUFF_VALID)) == (FFBUFF_DIRTY|FFBUFF_VALID)) { /* Write the dirty sector */ diff --git a/nuttx/fs/fat/fs_mkfatfs.c b/nuttx/fs/fat/fs_mkfatfs.c index 7a8b2ab92..384aa9356 100644 --- a/nuttx/fs/fat/fs_mkfatfs.c +++ b/nuttx/fs/fat/fs_mkfatfs.c @@ -2,7 +2,7 @@ * fs/fat/fs_writefat.c * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/fs/fat/fs_mkfatfs.h b/nuttx/fs/fat/fs_mkfatfs.h index 214697c51..05801c92d 100644 --- a/nuttx/fs/fat/fs_mkfatfs.h +++ b/nuttx/fs/fat/fs_mkfatfs.h @@ -2,7 +2,7 @@ * fs/fat/fs_mkfat.h * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/fs/fat/fs_writefat.c b/nuttx/fs/fat/fs_writefat.c index 02d55d625..564be5b50 100644 --- a/nuttx/fs/fat/fs_writefat.c +++ b/nuttx/fs/fat/fs_writefat.c @@ -2,7 +2,7 @@ * fs/fat/fs_writefat.c * * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/fs/fs_fdopen.c b/nuttx/fs/fs_fdopen.c index ee6440bf5..fd6aa88a8 100644 --- a/nuttx/fs/fs_fdopen.c +++ b/nuttx/fs/fs_fdopen.c @@ -220,7 +220,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR _TCB *tcb) /* Allocate the IO buffer */ stream->fs_bufstart = kmalloc(CONFIG_STDIO_BUFFER_SIZE); - if (!stream) + if (!stream->fs_bufstart) { err = ENOMEM; goto errout_with_sem; diff --git a/nuttx/fs/mmap/Make.defs b/nuttx/fs/mmap/Make.defs index 2d3d00694..59857fe9c 100644 --- a/nuttx/fs/mmap/Make.defs +++ b/nuttx/fs/mmap/Make.defs @@ -2,7 +2,7 @@ # fs/mmap/Make.defs # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/fs/mmap/README.txt b/nuttx/fs/mmap/README.txt index cf4c51e9e..cf4c51e9e 100755..100644 --- a/nuttx/fs/mmap/README.txt +++ b/nuttx/fs/mmap/README.txt diff --git a/nuttx/fs/mmap/fs_mmap.c b/nuttx/fs/mmap/fs_mmap.c index 5764b16f1..85d796586 100644 --- a/nuttx/fs/mmap/fs_mmap.c +++ b/nuttx/fs/mmap/fs_mmap.c @@ -2,7 +2,7 @@ * fs/mmap/fs_mmap.c * * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/fs/mmap/fs_munmap.c b/nuttx/fs/mmap/fs_munmap.c index a4b9dc609..5d9416d45 100644 --- a/nuttx/fs/mmap/fs_munmap.c +++ b/nuttx/fs/mmap/fs_munmap.c @@ -2,7 +2,7 @@ * fs/mmap/fs_munmap.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/fs/mmap/fs_rammap.c b/nuttx/fs/mmap/fs_rammap.c index 0eaf313b5..f43541cc9 100644 --- a/nuttx/fs/mmap/fs_rammap.c +++ b/nuttx/fs/mmap/fs_rammap.c @@ -2,7 +2,7 @@ * fs/mmap/fs_rammmap.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -165,7 +165,7 @@ FAR void *rammap(int fd, size_t length, off_t offset) */ fdbg("Seek to position %d failed\n", (int)offset); - err = ENOMEM; + err = EINVAL; goto errout_with_region; } @@ -181,28 +181,35 @@ FAR void *rammap(int fd, size_t length, off_t offset) * signal. */ - if (nread != EINTR) + err = get_errno(); + if (err != EINTR) { /* All other read errors are bad. errno is already set. - * (but maybe should be forced to EINVAL?) + * (but maybe should be forced to EINVAL?). NOTE that if + * FS DEBUG is enabled, then the following fdbg() macro will + * destroy the errno value. */ - fdbg("Read failed: %d\n", (int)offset); + fdbg("Read failed: offset=%d errno=%d\n", (int)offset, err); +#ifdef CONFIG_DEBUG_FS + goto errout_with_region; +#else goto errout_with_errno; +#endif } + } - /* Check for end of file. */ + /* Check for end of file. */ - if (nread == 0) - { - break; - } + if (nread == 0) + { + break; + } - /* Increment number of bytes read */ + /* Increment number of bytes read */ - rdbuffer += nread; - length -= nread; - } + rdbuffer += nread; + length -= nread; } /* Zero any memory beyond the amount read from the file */ @@ -227,7 +234,7 @@ FAR void *rammap(int fd, size_t length, off_t offset) errout_with_region: kfree(alloc); errout: - errno = err; + set_errno(err); return MAP_FAILED; errout_with_errno: diff --git a/nuttx/fs/mmap/fs_rammap.h b/nuttx/fs/mmap/fs_rammap.h index 9076d7343..293a91ffb 100644 --- a/nuttx/fs/mmap/fs_rammap.h +++ b/nuttx/fs/mmap/fs_rammap.h @@ -2,7 +2,7 @@ * fs/mmap/rammap.h * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nfs/nfs_util.c b/nuttx/fs/nfs/nfs_util.c index 33c5f0a89..73fda72a7 100644 --- a/nuttx/fs/nfs/nfs_util.c +++ b/nuttx/fs/nfs/nfs_util.c @@ -2,7 +2,7 @@ * fs/nfs/nfs_util.c * * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/fs/nxffs/Make.defs b/nuttx/fs/nxffs/Make.defs index a73950c3f..b67ae4472 100644 --- a/nuttx/fs/nxffs/Make.defs +++ b/nuttx/fs/nxffs/Make.defs @@ -2,7 +2,7 @@ # fs/nxffs/Make.defs # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/fs/nxffs/README.txt b/nuttx/fs/nxffs/README.txt index a10fb97a5..a10fb97a5 100755..100644 --- a/nuttx/fs/nxffs/README.txt +++ b/nuttx/fs/nxffs/README.txt diff --git a/nuttx/fs/nxffs/nxffs_block.c b/nuttx/fs/nxffs/nxffs_block.c index a069048b8..6701b6e6b 100644 --- a/nuttx/fs/nxffs/nxffs_block.c +++ b/nuttx/fs/nxffs/nxffs_block.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_block.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nxffs/nxffs_blockstats.c b/nuttx/fs/nxffs/nxffs_blockstats.c index 590aa2ad0..348374e67 100644 --- a/nuttx/fs/nxffs/nxffs_blockstats.c +++ b/nuttx/fs/nxffs/nxffs_blockstats.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_blockstats.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nxffs/nxffs_cache.c b/nuttx/fs/nxffs/nxffs_cache.c index 5c5cbaa18..0cc97980e 100644 --- a/nuttx/fs/nxffs/nxffs_cache.c +++ b/nuttx/fs/nxffs/nxffs_cache.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_cache.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nxffs/nxffs_dirent.c b/nuttx/fs/nxffs/nxffs_dirent.c index 562a5320b..221549438 100644 --- a/nuttx/fs/nxffs/nxffs_dirent.c +++ b/nuttx/fs/nxffs/nxffs_dirent.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_dirent.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nxffs/nxffs_dump.c b/nuttx/fs/nxffs/nxffs_dump.c index d816ba6ca..6a89aaf1d 100644 --- a/nuttx/fs/nxffs/nxffs_dump.c +++ b/nuttx/fs/nxffs/nxffs_dump.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_dump.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nxffs/nxffs_ioctl.c b/nuttx/fs/nxffs/nxffs_ioctl.c index 41fabfbee..332878eb0 100644 --- a/nuttx/fs/nxffs/nxffs_ioctl.c +++ b/nuttx/fs/nxffs/nxffs_ioctl.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_ioctl.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nxffs/nxffs_open.c b/nuttx/fs/nxffs/nxffs_open.c index 339e25edc..eb7817c57 100644 --- a/nuttx/fs/nxffs/nxffs_open.c +++ b/nuttx/fs/nxffs/nxffs_open.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_open.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nxffs/nxffs_read.c b/nuttx/fs/nxffs/nxffs_read.c index 6ba49ca72..b638dbfd4 100644 --- a/nuttx/fs/nxffs/nxffs_read.c +++ b/nuttx/fs/nxffs/nxffs_read.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_read.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nxffs/nxffs_reformat.c b/nuttx/fs/nxffs/nxffs_reformat.c index cb10862ff..d3c00893d 100644 --- a/nuttx/fs/nxffs/nxffs_reformat.c +++ b/nuttx/fs/nxffs/nxffs_reformat.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_reformat.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nxffs/nxffs_stat.c b/nuttx/fs/nxffs/nxffs_stat.c index afb18093c..d4d58a72c 100644 --- a/nuttx/fs/nxffs/nxffs_stat.c +++ b/nuttx/fs/nxffs/nxffs_stat.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_stat.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nxffs/nxffs_unlink.c b/nuttx/fs/nxffs/nxffs_unlink.c index 9d0d5b49e..73b0f360a 100644 --- a/nuttx/fs/nxffs/nxffs_unlink.c +++ b/nuttx/fs/nxffs/nxffs_unlink.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_unlink.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/nxffs/nxffs_util.c b/nuttx/fs/nxffs/nxffs_util.c index ea2e97967..f424e71e0 100644 --- a/nuttx/fs/nxffs/nxffs_util.c +++ b/nuttx/fs/nxffs/nxffs_util.c @@ -2,7 +2,7 @@ * fs/nxffs/nxffs_util.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/romfs/Make.defs b/nuttx/fs/romfs/Make.defs index 56b4c9862..77de93c05 100644 --- a/nuttx/fs/romfs/Make.defs +++ b/nuttx/fs/romfs/Make.defs @@ -2,7 +2,7 @@ # fs/romfs/Make.defs # # Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/fs/romfs/fs_romfs.c b/nuttx/fs/romfs/fs_romfs.c index 8a2e69665..b95619d75 100644 --- a/nuttx/fs/romfs/fs_romfs.c +++ b/nuttx/fs/romfs/fs_romfs.c @@ -2,7 +2,7 @@ * rm/romfs/fs_romfs.h * * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/romfs/fs_romfs.h b/nuttx/fs/romfs/fs_romfs.h index f89196ff7..4081517fb 100644 --- a/nuttx/fs/romfs/fs_romfs.h +++ b/nuttx/fs/romfs/fs_romfs.h @@ -2,7 +2,7 @@ * fs/romfs/fs_romfs.h * * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/fs/romfs/fs_romfsutil.c b/nuttx/fs/romfs/fs_romfsutil.c index cb3f9f9ac..6ea114b5e 100644 --- a/nuttx/fs/romfs/fs_romfsutil.c +++ b/nuttx/fs/romfs/fs_romfsutil.c @@ -2,7 +2,7 @@ * rm/romfs/fs_romfsutil.h * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * References: Linux/Documentation/filesystems/romfs.txt * diff --git a/nuttx/include/nuttx/fs/fat.h b/nuttx/include/nuttx/fs/fat.h index f69bd8571..ac85c502f 100644 --- a/nuttx/include/nuttx/fs/fat.h +++ b/nuttx/include/nuttx/fs/fat.h @@ -40,6 +40,7 @@ * Included Files ****************************************************************************/ +#include <nuttx/config.h> #include <stdint.h> /**************************************************************************** @@ -75,11 +76,44 @@ extern "C" { #define EXTERN extern #endif -/* Non-standard functions to get and set FAT file/directory attributes */ +/**************************************************************************** + * Name: fat_getattrib and fat_setattrib + * + * Description: + * Non-standard functions to get and set FAT file/directory attributes + * + ****************************************************************************/ EXTERN int fat_getattrib(const char *path, fat_attrib_t *attrib); EXTERN int fat_setattrib(const char *path, fat_attrib_t setbits, fat_attrib_t clearbits); +/**************************************************************************** + * Name: fat_dma_alloc and fat_dma_free + * + * Description: + * The FAT file system allocates two I/O buffers for data transfer, each + * are the size of one device sector. One of the buffers is allocated + * once for each FAT volume that is mounted; the other buffers are + * allocated each time a FAT file is opened. + * + * Some hardware, however, may require special DMA-capable memory in + * order to perform the the transfers. If CONFIG_FAT_DMAMEMORY is defined + * then the architecture-specific hardware must provide the funtions + * fat_dma_alloc() and fat_dma_free() as prototyped below: fat_dma_alloc() + * will allocate DMA-capable memory of the specified size; fat_dma_free() + * is the corresponding function that will be called to free the DMA- + * capable memory. + * + * This functions may be simple wrappers around gran_alloc() and gran_free() + * (See nuttx/gran.h). + * + ****************************************************************************/ + +#ifdef CONFIG_FAT_DMAMEMORY +EXTERN FAR void *fat_dma_alloc(size_t size); +EXTERN void fat_dma_free(FAR void *memory, size_t size); +#endif + #undef EXTERN #ifdef __cplusplus } diff --git a/nuttx/include/nuttx/gran.h b/nuttx/include/nuttx/gran.h new file mode 100644 index 000000000..5e980dd9c --- /dev/null +++ b/nuttx/include/nuttx/gran.h @@ -0,0 +1,202 @@ +/**************************************************************************** + * include/nuttx/gran.h + * General purpose granule memory allocator. + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * 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. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS 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. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_GRAN_H +#define __INCLUDE_NUTTX_GRAN_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/types.h> +#include <stdint.h> + +#ifdef CONFIG_GRAN + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ +/* Configuration ************************************************************/ +/* CONFIG_GRAN - Enable granual allocator support + * CONFIG_GRAN_SINGLE - Select if there is only one instance of the + * granule allocator (i.e., gran_initialize will be called only once. + * In this case, (1) there are a few optimizations that can can be done + * and (2) the GRAN_HANDLE is not needed. + * CONFIG_GRAN_INTR - Normally mutual exclusive access to granule allocator + * data is assured using a semaphore. If this option is set then, instead, + * mutual exclusion logic will disable interrupts. While this options is + * more invasive to system performance, it will also support use of the + * granule allocator from interrupt level logic. + * CONFIG_DEBUG_GRAN - Just like CONFIG_DEBUG_MM, but only generates ouput + * from the gran allocation logic. + */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef CONFIG_GRAN_SINGLE +typedef FAR void *GRAN_HANDLE; +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: gran_initialize + * + * Description: + * Set up one granule allocator instance. Allocations will be aligned to + * the alignment size (log2align; allocations will be in units of the + * granule size (log2gran). Larger granules will give better performance + * and less overhead but more losses of memory due to quantization waste. + * Additional memory waste can occur from alignment; log2align should be + * set to 0 unless you are using the granule allocator to manage DMA memory + * and your hardware has specific memory alignment requirements. + * + * Geneneral Usage Summary. This is an example using the GCC section + * attribute to position a DMA heap in memory (logic in the linker script + * would assign the section .dmaheap to the DMA memory. + * + * FAR uint32_t g_dmaheap[DMAHEAP_SIZE] __attribute__((section(.dmaheap))); + * + * The heap is created by calling gran_initialize. Here the granual size + * is set to 64 bytes and the alignment to 16 bytes: + * + * GRAN_HANDLE handle = gran_initialize(g_dmaheap, DMAHEAP_SIZE, 6, 4); + * + * Then the GRAN_HANDLE can be used to allocate memory (There is no + * GRAN_HANDLE if CONFIG_GRAN_SINGLE=y): + * + * FAR uint8_t *dma_memory = (FAR uint8_t *)gran_alloc(handle, 47); + * + * The actual memory allocates will be 64 byte (wasting 17 bytes) and + * will be aligned at least to (1 << log2align). + * + * NOTE: The current implementation also restricts the maximum allocation + * size to 32 granules. That restriction could be eliminated with some + * additional coding effort. + * + * Input Parameters: + * heapstart - Start of the granule allocation heap + * heapsize - Size of heap in bytes + * log2gran - Log base 2 of the size of one granule. 0->1 byte, + * 1->2 bytes, 2->4 bytes, 3-> 8 bytes, etc. + * log2align - Log base 2 of required alignment. 0->1 byte, + * 1->2 bytes, 2->4 bytes, 3-> 8 bytes, etc. Note that + * log2gran must be greater than or equal to log2align + * so that all contiguous granules in memory will meet + * the minimum alignment requirement. A value of zero + * would mean that no alignment is required. + * + * Returned Value: + * On success, a non-NULL handle is returned that may be used with other + * granual allocator interfaces. + * + ****************************************************************************/ + +#ifdef CONFIG_GRAN_SINGLE +EXTERN int gran_initialize(FAR void *heapstart, size_t heapsize, + uint8_t log2gran, uint8_t log2align); +#else +EXTERN GRAN_HANDLE gran_initialize(FAR void *heapstart, size_t heapsize, + uint8_t log2gran, uint8_t log2align); +#endif + +/**************************************************************************** + * Name: gran_alloc + * + * Description: + * Allocate memory from the granule heap. + * + * NOTE: The current implementation also restricts the maximum allocation + * size to 32 granules. That restriction could be eliminated with some + * additional coding effort. + * + * Input Parameters: + * handle - The handle previously returned by gran_initialize + * size - The size of the memory region to allocate. + * + * Returned Value: + * On success, either a non-NULL pointer to the allocated memory (if + * CONFIG_GRAN_SINGLE) or zero (if !CONFIG_GRAN_SINGLE) is returned. + * + ****************************************************************************/ + +#ifdef CONFIG_GRAN_SINGLE +EXTERN FAR void *gran_alloc(size_t size); +#else +EXTERN FAR void *gran_alloc(GRAN_HANDLE handle, size_t size); +#endif + +/**************************************************************************** + * Name: gran_free + * + * Description: + * Return memory to the granule heap. + * + * Input Parameters: + * handle - The handle previously returned by gran_initialize + * memory - A pointer to memory previoiusly allocated by gran_alloc. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_GRAN_SINGLE +EXTERN void gran_free(FAR void *memory, size_t size); +#else +EXTERN void gran_free(GRAN_HANDLE handle, FAR void *memory, size_t size); +#endif + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_GRAN */ +#endif /* __INCLUDE_NUTTX_GRAN_H */ diff --git a/nuttx/include/nuttx/net/enc28j60.h b/nuttx/include/nuttx/net/enc28j60.h index 2507b1cf6..7d0d7c3e5 100644 --- a/nuttx/include/nuttx/net/enc28j60.h +++ b/nuttx/include/nuttx/net/enc28j60.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/net/enc28j60.h * - * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -43,13 +43,15 @@ #include <stdint.h> #include <stdbool.h> +#include <nuttx/irq.h> + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /* ENC28J60 Configuration Settings: * - * CONFIG_NET_ENC28J60 - Enabled ENC28J60 support + * CONFIG_ENC28J60 - Enabled ENC28J60 support * CONFIG_ENC28J60_SPIMODE - Controls the SPI mode * CONFIG_ENC28J60_FREQUENCY - Define to use a different bus frequency * CONFIG_ENC28J60_NINTERFACES - Specifies the number of physical ENC28J60 @@ -80,6 +82,34 @@ struct enc_stats_s }; #endif +/* The ENC28J60 normal provides interrupts to the MCU via a GPIO pin. The + * following structure provides an MCU-independent mechanixm for controlling + * the ENC28J60 GPIO interrupt. + * + * The ENC32J60 interrupt is an active low, *level* interrupt. "When an + * interrupt occurs, the interrupt flag is set. If the interrupt is enabled + * in the EIE register and the INTIE global interrupt enable bit is set, the + * INT pin will be driven low" + * + * "When an enabled interrupt occurs, the interrupt pin will remain low until + * all flags which are causing the interrupt are cleared or masked off + * (enable bit is cleared) by the host controller." However, the interrupt + * will behave like a falling edge interrupt because "After an interrupt + * occurs, the host controller [clears] the global enable bit for the + * interrupt pin before servicing the interrupt. Clearing the enable bit + * will cause the interrupt pin to return to the non-asserted state (high). + * Doing so will prevent the host controller from missing a falling edge + * should another interrupt occur while the immediate interrupt is being + * serviced." + */ + +struct enc_lower_s +{ + int (*attach)(FAR const struct enc_lower_s *lower, xcpt_t handler); + void (*enable)(FAR const struct enc_lower_s *lower); + void (*disable)(FAR const struct enc_lower_s *lower); +}; + /**************************************************************************** * Public Data ****************************************************************************/ @@ -104,10 +134,10 @@ extern "C" { * * Parameters: * spi - A reference to the platform's SPI driver for the ENC28J60 + * lower - The MCU-specific interrupt used to control low-level MCU + * functions (i.e., ENC28J60 GPIO interrupts). * devno - If more than one ENC28J60 is supported, then this is the * zero based number that identifies the ENC28J60; - * irq - The fully configured GPIO IRQ that ENC28J60 interrupts will be - * asserted on. This driver will attach and entable this IRQ. * * Returned Value: * OK on success; Negated errno on failure. @@ -117,8 +147,9 @@ extern "C" { ****************************************************************************/ struct spi_dev_s; /* see nuttx/spi.h */ -EXTERN int enc_initialize(FAR struct spi_dev_s *spi, unsigned int devno, - unsigned int irq); +EXTERN int enc_initialize(FAR struct spi_dev_s *spi, + FAR const struct enc_lower_s *lower, + unsigned int devno); /**************************************************************************** * Function: enc_stats diff --git a/nuttx/include/nuttx/net/uip/uipopt.h b/nuttx/include/nuttx/net/uip/uipopt.h index 4eff56fe8..9797e0482 100644 --- a/nuttx/include/nuttx/net/uip/uipopt.h +++ b/nuttx/include/nuttx/net/uip/uipopt.h @@ -296,7 +296,23 @@ /* The size of the TCP read buffer size */ #ifndef CONFIG_NET_TCP_READAHEAD_BUFSIZE -# define CONFIG_NET_TCP_READAHEAD_BUFSIZE UIP_TCP_MSS +# if CONFIG_NET_NTCP_READAHEAD_BUFFERS < 1 +# define CONFIG_NET_TCP_READAHEAD_BUFSIZE 0 +# else +# define CONFIG_NET_TCP_READAHEAD_BUFSIZE UIP_TCP_MSS +# endif +#endif + +/* Delay after receive to catch a following packet. No delay should be + * required if TCP/IP read-ahead buffering is enabled. + */ + +#ifndef CONFIG_NET_TCP_RECVDELAY +# if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0 +# define CONFIG_NET_TCP_RECVDELAY 0 +# else +# define CONFIG_NET_TCP_RECVDELAY 5 +# endif #endif /**************************************************************************** diff --git a/nuttx/include/nuttx/usb/cdc.h b/nuttx/include/nuttx/usb/cdc.h index 627dd77e3..627dd77e3 100755..100644 --- a/nuttx/include/nuttx/usb/cdc.h +++ b/nuttx/include/nuttx/usb/cdc.h diff --git a/nuttx/include/nuttx/usb/usbdev.h b/nuttx/include/nuttx/usb/usbdev.h index 89813cac9..1270fe13a 100644 --- a/nuttx/include/nuttx/usb/usbdev.h +++ b/nuttx/include/nuttx/usb/usbdev.h @@ -85,7 +85,7 @@ /* Allocate/free an I/O buffer. Should not be called from interrupt processing! */ -#ifdef CONFIG_ARCH_USBDEV_DMA +#ifdef CONFIG_USBDEV_DMA # define EP_ALLOCBUFFER(ep,nb) (ep)->ops->alloc(ep,nb) # define EP_FREEBUFFER(ep,buff) (ep)->ops->free(ep,buf) #else @@ -234,7 +234,7 @@ struct usbdev_epops_s /* Allocate and free I/O buffers */ -#ifdef CONFIG_ARCH_USBDEV_DMA +#ifdef CONFIG_USBDEV_DMA FAR void *(*allocbuffer)(FAR struct usbdev_ep_s *ep, uint16_t nbytes); void (*freebuffer)(FAR struct usbdev_ep_s *ep, FAR void *buf); #endif @@ -354,6 +354,37 @@ EXTERN int usbdev_register(FAR struct usbdevclass_driver_s *driver); EXTERN int usbdev_unregister(FAR struct usbdevclass_driver_s *driver); +/**************************************************************************** + * Name: usbdev_dma_alloc and usbdev_dma_free + * + * Description: + * The USB class driver allocates packet I/O buffers for data transfer by + * calling the driver allocbuffer() and freebuffer() methods. Those + * methods are only available if CONFIG_USBDEV_DMA is defined in the + * system configuration. + * + * If CONFIG_USBDEV_DMAMEMORY is also defined in the NuttX configuration, + * then the driver implementations of the allocbuffer() and freebuffer() + * methods may use board-specific usbdev_dma_alloc() and usbdev_dma_free(). + * If CONFIG_USBDEV_DMA and CONFIG_USBDEV_DMAMEMORY are both defined, + * then the board-specific logic must provide the functions + * usbdev_dma_alloc() and usbdev_dma_free() as prototyped below: + * usbdev_dma_alloc() will allocate DMA-capable memory of the specified + * size; usbdev_dma_free() is the corresponding function that will be + * called to free the DMA-capable memory. + * + * This functions may be simple wrappers around gran_alloc() and + * gran_free() (See nuttx/gran.h). Note that the gran_free() function + * does require the size of the allocation to be freed; that would need + * to be managed in the board-specific logic. + * + ****************************************************************************/ + +#if defined(CONFIG_USBDEV_DMA) && defined(CONFIG_USBDEV_DMAMEMORY) +EXTERN FAR void *usbdev_dma_alloc(size_t size); +EXTERN void usbdev_dma_free(FAR void *memory); +#endif + #undef EXTERN #if defined(__cplusplus) } diff --git a/nuttx/include/nuttx/vt100.h b/nuttx/include/nuttx/vt100.h index a0254e88a..d834f48f0 100644 --- a/nuttx/include/nuttx/vt100.h +++ b/nuttx/include/nuttx/vt100.h @@ -105,7 +105,7 @@ #define VT100_CURSORPOS(v,h) {ASCII_ESC, '[', (v), ';', (h), 'H'} /* Move cursor to screen location v,h */ #define VT100_HVHOME {ASCII_ESC, '[', 'f'} /* Move cursor to upper left corner */ -#define VT100_HVHOME_ {ASCII_ESC, '[', ;', 'f'} /* Move cursor to upper left corner */ +#define VT100_HVHOME_ {ASCII_ESC, '[', ';', 'f'} /* Move cursor to upper left corner */ #define VT100_HVPOS(v,h) {ASCII_ESC, '[', (v), ';', (h), 'f'} /* Move cursor to screen location v,h */ #define VT100_INDEX {ASCII_ESC, 'D'} /* Move/scroll window up one line */ #define VT100_REVINDEX {ASCII_ESC, 'M'} /* Move/scroll window down one line */ @@ -138,7 +138,7 @@ #define VT100_TERMNOK {ASCII_ESC, '3', 'n'} /* Response: terminal is not OK */ #define VT100_GETCURSOR {ASCII_ESC, '6', 'n'} /* Get cursor position */ -#define VT100_CURSORPOS {ASCII_ESC, (v), ';', (h), 'R'} /* Response: cursor is at v,h */ +#define VT100_CURSORPOSAT {ASCII_ESC, (v), ';', (h), 'R'} /* Response: cursor is at v,h */ #define VT100_IDENT {ASCII_ESC, '[', 'c'} /* Identify what terminal type */ #define VT100_IDENT_ {ASCII_ESC, '[', '0', 'c'} /* Identify what terminal type */ diff --git a/nuttx/include/nuttx/watchdog.h b/nuttx/include/nuttx/watchdog.h index bcf8b1522..bcf8b1522 100755..100644 --- a/nuttx/include/nuttx/watchdog.h +++ b/nuttx/include/nuttx/watchdog.h diff --git a/nuttx/include/nuttx/wqueue.h b/nuttx/include/nuttx/wqueue.h index dfd424c8d..644585c56 100644 --- a/nuttx/include/nuttx/wqueue.h +++ b/nuttx/include/nuttx/wqueue.h @@ -50,6 +50,75 @@ /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ +/* Configuration ************************************************************/ +/* CONFIG_SCHED_WORKQUEUE. Create a dedicated "worker" thread to + * handle delayed processing from interrupt handlers. This feature + * is required for some drivers but, if there are not complaints, + * can be safely disabled. The worker thread also performs + * garbage collection -- completing any delayed memory deallocations + * from interrupt handlers. If the worker thread is disabled, + * then that clean will be performed by the IDLE thread instead + * (which runs at the lowest of priority and may not be appropriate + * if memory reclamation is of high priority). If CONFIG_SCHED_WORKQUEUE + * is enabled, then the following options can also be used: + * CONFIG_SCHED_WORKPRIORITY - The execution priority of the worker + * thread. Default: 192 + * CONFIG_SCHED_WORKPERIOD - How often the worker thread checks for + * work in units of microseconds. Default: 50*1000 (50 MS). + * CONFIG_SCHED_WORKSTACKSIZE - The stack size allocated for the worker + * thread. Default: CONFIG_IDLETHREAD_STACKSIZE. + * CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up + * the worker thread. Default: 4 + * + * CONFIG_SCHED_LPWORK. If CONFIG_SCHED_WORKQUEUE is defined, then a single + * work queue is created by default. If CONFIG_SCHED_LPWORK is also defined + * then an additional, lower-priority work queue will also be created. This + * lower priority work queue is better suited for more extended processing + * (such as file system clean-up operations) + * CONFIG_SCHED_LPWORKPRIORITY - The execution priority of the lower priority + * worker thread. Default: 50 + * CONFIG_SCHED_LPWORKPERIOD - How often the lower priority worker thread + * checks for work in units of microseconds. Default: 50*1000 (50 MS). + * CONFIG_SCHED_LPWORKSTACKSIZE - The stack size allocated for the lower + * priority worker thread. Default: CONFIG_IDLETHREAD_STACKSIZE. + */ + +#ifndef CONFIG_SCHED_WORKPRIORITY +# define CONFIG_SCHED_WORKPRIORITY 192 +#endif + +#ifndef CONFIG_SCHED_WORKPERIOD +# define CONFIG_SCHED_WORKPERIOD (50*1000) /* 50 milliseconds */ +#endif + +#ifndef CONFIG_SCHED_WORKSTACKSIZE +# define CONFIG_SCHED_WORKSTACKSIZE CONFIG_IDLETHREAD_STACKSIZE +#endif + +#ifdef CONFIG_SCHED_LPWORK +# ifndef CONFIG_SCHED_LPWORKPRIORITY +# define CONFIG_SCHED_LPWORKPRIORITY 50 +# endif + +# ifndef CONFIG_SCHED_LPWORKPERIOD +# define CONFIG_SCHED_LPWORKPERIOD (50*1000) /* 50 milliseconds */ +# endif + +# ifndef CONFIG_SCHED_LPWORKSTACKSIZE +# define CONFIG_SCHED_LPWORKSTACKSIZE CONFIG_IDLETHREAD_STACKSIZE +# endif +#endif + +/* Work queue IDs (indices). These are both zero if there is only one work + * queue. + */ + +#define HPWORK 0 +#ifdef CONFIG_SCHED_LPWORK +# define LPWORK 1 +#else +# define LPWORK HPWORK +#endif /**************************************************************************** * Public Types @@ -86,10 +155,6 @@ extern "C" { #define EXTERN extern #endif -/* The task ID of the worker thread */ - -EXTERN pid_t g_worker; - /**************************************************************************** * Public Function Prototypes ****************************************************************************/ @@ -109,6 +174,7 @@ EXTERN pid_t g_worker; * and remove it from the work queue. * * Input parameters: + * qid - The work queue ID * work - The work structure to queue * worker - The worker callback to be invoked. The callback will invoked * on the worker thread of execution. @@ -122,7 +188,8 @@ EXTERN pid_t g_worker; * ****************************************************************************/ -EXTERN int work_queue(struct work_s *work, worker_t worker, FAR void *arg, uint32_t delay); +EXTERN int work_queue(int qid, FAR struct work_s *work, worker_t worker, + FAR void *arg, uint32_t delay); /**************************************************************************** * Name: work_cancel @@ -133,6 +200,7 @@ EXTERN int work_queue(struct work_s *work, worker_t worker, FAR void *arg, uint3 * again. * * Input parameters: + * qid - The work queue ID * work - The previously queue work structure to cancel * * Returned Value: @@ -140,7 +208,7 @@ EXTERN int work_queue(struct work_s *work, worker_t worker, FAR void *arg, uint3 * ****************************************************************************/ -EXTERN int work_cancel(struct work_s *work); +EXTERN int work_cancel(int qid, FAR struct work_s *work); /**************************************************************************** * Name: work_signal @@ -151,14 +219,14 @@ EXTERN int work_cancel(struct work_s *work); * user to force an immediate re-assessment of pending work. * * Input parameters: - * None + * qid - The work queue ID * * Returned Value: * Zero on success, a negated errno on failure * ****************************************************************************/ -#define work_signal() kill(g_worker, SIGWORK) +EXTERN int work_signal(int qid); /**************************************************************************** * Name: work_available diff --git a/nuttx/graphics/nxfonts/nxfonts_internal.h b/nuttx/include/sys/sendfile.h index fa7864170..0f3c05444 100644 --- a/nuttx/graphics/nxfonts/nxfonts_internal.h +++ b/nuttx/include/sys/sendfile.h @@ -1,8 +1,8 @@ /**************************************************************************** - * graphics/nxfonts/nxfonts_internal.h + * include/sys/sendfile.h * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __GRAPHICS_NXFONTS_NXFONTS_INTERNAL_H -#define __GRAPHICS_NXFONTS_NXFONTS_INTERNAL_H +#ifndef __INCLUDE_SYS_SENDFILE_H +#define __INCLUDE_SYS_SENDFILE_H /**************************************************************************** * Included Files @@ -42,47 +42,82 @@ #include <nuttx/config.h> -#include <nuttx/nx/nxfonts.h> +#include <sys/types.h> /**************************************************************************** - * Pre-processor definitions + * Pre-Processor Definitions ****************************************************************************/ - /* Configuration ************************************************************/ -#ifndef CONFIG_NXFONTS_CHARBITS -# define CONFIG_NXFONTS_CHARBITS 7 +#ifndef CONFIG_LIB_SENDFILE_BUFSIZE +# define CONFIG_LIB_SENDFILE_BUFSIZE 512 #endif /**************************************************************************** - * Public Types + * Public Type Definitions ****************************************************************************/ /**************************************************************************** - * Public Data + * Public Function Prototypes ****************************************************************************/ #undef EXTERN #if defined(__cplusplus) -# define EXTERN extern "C" +#define EXTERN extern "C" extern "C" { #else -# define EXTERN extern +#define EXTERN extern #endif -EXTERN struct nx_fontset_s g_7bitfonts; -#if CONFIG_NXFONTS_CHARBITS >= 8 -EXTERN struct nx_fontset_s g_8bitfonts; -#endif -EXTERN struct nx_font_s g_fonts; +/************************************************************************ + * Name: sendfile + * + * Description: + * sendfile() copies data between one file descriptor and another. + * sendfile() basically just wraps a sequence of reads() and writes() + * to perform a copy. It serves a purpose in systems where there is + * a penalty for copies to between user and kernal space, but really + * nothing in NuttX but provide some Linux compatible (and adding + * another 'almost standard' interface). + * + * NOTE: This interface is *not* specified in POSIX.1-2001, or other + * standards. The implementation here is very similar to the Linux + * sendfile interface. Other UNIX systems implement sendfile() with + * different semantics and prototypes. sendfile() should not be used + * in portable programs. + * + * Input Parmeters: + * infd - A file (or socket) descriptor opened for reading + * outfd - A descriptor opened for writing. + * offset - If 'offset' is not NULL, then it points to a variable + * holding the file offset from which sendfile() will start + * reading data from 'infd'. When sendfile() returns, this + * variable will be set to the offset of the byte following + * the last byte that was read. If 'offset' is not NULL, + * then sendfile() does not modify the current file offset of + * 'infd'; otherwise the current file offset is adjusted to + * reflect the number of bytes read from 'infd.' + * + * If 'offset' is NULL, then data will be read from 'infd' + * starting at the current file offset, and the file offset + * will be updated by the call. + * count - The number of bytes to copy between the file descriptors. + * + * Returned Value: + * If the transfer was successful, the number of bytes written to outfd is + * returned. On error, -1 is returned, and errno is set appropriately. + * There error values are those returned by read() or write() plus: + * + * EINVAL - Bad input parameters. + * ENOMEM - Could not allocated an I/O buffer + * + ************************************************************************/ -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ +EXTERN ssize_t sendfile (int outfd, int infd, FAR off_t *offset, size_t count); #undef EXTERN #if defined(__cplusplus) } #endif -#endif /* __GRAPHICS_NXFONTS_NXFONTS_INTERNAL_H */ +#endif /* __INCLUDE_SYS_SENDFILE_H */ diff --git a/nuttx/lib/Kconfig b/nuttx/lib/Kconfig index d94a274f9..69a55d09c 100644 --- a/nuttx/lib/Kconfig +++ b/nuttx/lib/Kconfig @@ -51,6 +51,29 @@ config LIBC_FLOATINGPOINT By default, floating point support in printf, sscanf, etc. is disabled. +choice + prompt "Newline Options" + default EOL_IS_EITHER_CRLF + ---help--- + This selection determines the line terminating character that is used. + Some environments may return CR as end-of-line, others LF, and others + both. If not specified, the default is either CR or LF (but not both) + as the line terminating charactor. + +config EOL_IS_CR + bool "EOL is CR" + +config EOL_IS_LF + bool "EOL is LF" + +config EOL_IS_BOTH_CRLF + bool "EOL is CR and LF" + +config EOL_IS_EITHER_CRLF + bool "EOL is CR or LF" + +endchoice + config LIBC_STRERROR bool "Enable strerror" default n @@ -82,35 +105,53 @@ config LIBC_PERROR_STDOUT be defined, however, to provide perror() output that is serialized with other stdout messages. -config LIBC_PERROR_DEVNAME - string "perror() to device" - default "/dev/console" - depends on !LIBC_PERROR_STDOUT - ---help--- - Another non-standard option is to provide perror() output to a logging device - or file. LIBC_PERROR_DEVNAME may be defined to be any write-able, - character device (or file). - config ARCH_LOWPUTC bool "Low-level console output" default "y" ---help--- - architecture supports low-level, boot time console output - -config ENABLE_ARCH_OPTIMIZED_FUN + architecture supports low-level, boot time console output + +config LIB_SENDFILE_BUFSIZE + int "sendfile() buffer size" + default 512 + ---help--- + Size of the I/O buffer to allocate in sendfile(). Default: 512b + +config ARCH_ROMGETC + bool "Support for ROM string access" + default n + ---help--- + In Harvard architectures, data accesses and instruction accesses + occur on different busses, perhaps concurrently. All data accesses + are performed on the data bus unless special machine instructions + are used to read data from the instruction address space. Also, in + the typical MCU, the available SRAM data memory is much smaller that + the non-volatile FLASH instruction memory. So if the application + requires many constant strings, the only practical solution may be + to store those constant strings in FLASH memory where they can only + be accessed using architecture-specific machine instructions. + + If ARCH_ROMGETC is defined, then the architecture logic must export + the function up_romgetc(). up_romgetc() will simply read one byte + of data from the instruction space. + + If ARCH_ROMGETC, certain C stdio functions are effected: (1) All + format strings in printf, fprintf, sprintf, etc. are assumed to lie + in FLASH (string arguments for %s are still assumed to reside in SRAM). + And (2), the string argument to puts and fputs is assumed to reside + in FLASH. Clearly, these assumptions may have to modified for the + particular needs of your environment. There is no "one-size-fits-all" + solution for this problem. + +config ARCH_OPTIMIZED_FUNCTIONS bool "Enable arch optimized functions" default n ---help--- - Allow for architecture optimized implementations - - The architecture can provide optimized versions of the - following to improve system performance - - The architecture may provide custom versions of certain - standard header files: - config ARCH_MATH_H, ARCH_STDBOOL_H, ARCH_STDINT_H + Allow for architecture optimized implementations of certain library + functions. Architecture-specific implementations can improve overall + system performance. -if ENABLE_ARCH_OPTIMIZED_FUN +if ARCH_OPTIMIZED_FUNCTIONS config ARCH_MEMCPY bool "memcpy" default n diff --git a/nuttx/lib/lib.csv b/nuttx/lib/lib.csv index aa63653f5..171f64e9b 100644 --- a/nuttx/lib/lib.csv +++ b/nuttx/lib/lib.csv @@ -109,6 +109,7 @@ "sched_get_priority_min","sched.h","","int","int" "sem_getvalue","semaphore.h","","int","FAR sem_t *","FAR int *" "sem_init","semaphore.h","","int","FAR sem_t *","int","unsigned int" +"sendfile","sys/sendfile.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","ssize_t","int","int","off_t","size_t" "sigaddset","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t *","int" "sigdelset","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t *","int" "sigemptyset","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t *" diff --git a/nuttx/lib/misc/Make.defs b/nuttx/lib/misc/Make.defs index 484f822d0..c12533f75 100644 --- a/nuttx/lib/misc/Make.defs +++ b/nuttx/lib/misc/Make.defs @@ -37,10 +37,24 @@ CSRCS += lib_init.c lib_filesem.c +# Add C files that depend on file OR socket descriptors + ifneq ($(CONFIG_NFILE_DESCRIPTORS),0) + +CSRCS += lib_sendfile.c ifneq ($(CONFIG_NFILE_STREAMS),0) CSRCS += lib_streamsem.c endif + +else +ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0) + +CSRCS += lib_sendfile.c +ifneq ($(CONFIG_NFILE_STREAMS),0) +CSRCS += lib_streamsem.c +endif + +endif endif # Add the miscellaneous C files to the build diff --git a/nuttx/lib/misc/lib_dbg.c b/nuttx/lib/misc/lib_dbg.c index 6f326bf4f..aacdaa30a 100644 --- a/nuttx/lib/misc/lib_dbg.c +++ b/nuttx/lib/misc/lib_dbg.c @@ -2,7 +2,7 @@ * lib/misc/lib_dbg.c * * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/misc/lib_dumpbuffer.c b/nuttx/lib/misc/lib_dumpbuffer.c index 1f1f54e8d..155468ca1 100644 --- a/nuttx/lib/misc/lib_dumpbuffer.c +++ b/nuttx/lib/misc/lib_dumpbuffer.c @@ -2,7 +2,7 @@ * lib/misc/lib_dumpbuffer.c * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/misc/lib_filesem.c b/nuttx/lib/misc/lib_filesem.c index e6a3fdb67..1d1f25c2f 100644 --- a/nuttx/lib/misc/lib_filesem.c +++ b/nuttx/lib/misc/lib_filesem.c @@ -2,7 +2,7 @@ * lib/misc/lib_filesem.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/misc/lib_init.c b/nuttx/lib/misc/lib_init.c index fb246b1ad..3403a837b 100644 --- a/nuttx/lib/misc/lib_init.c +++ b/nuttx/lib/misc/lib_init.c @@ -2,7 +2,7 @@ * lib/misc/lib_init.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/misc/lib_sendfile.c b/nuttx/lib/misc/lib_sendfile.c new file mode 100644 index 000000000..e4b53d8c8 --- /dev/null +++ b/nuttx/lib/misc/lib_sendfile.c @@ -0,0 +1,297 @@ +/************************************************************************ + * lib/misc/lib_streamsem.c + * + * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * 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. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS 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. + * + ************************************************************************/ + +/************************************************************************ + * Included Files + ************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/sendfile.h> +#include <stdbool.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> + +#if CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0 + +/************************************************************************ + * Private types + ************************************************************************/ + +/************************************************************************ + * Private Variables + ************************************************************************/ + +/************************************************************************ + * Public Variables + ************************************************************************/ + +/************************************************************************ + * Private Functions + ************************************************************************/ + +/************************************************************************ + * Public Functions + ************************************************************************/ + +/************************************************************************ + * Name: sendfile + * + * Description: + * sendfile() copies data between one file descriptor and another. + * sendfile() basically just wraps a sequence of reads() and writes() + * to perform a copy. It serves a purpose in systems where there is + * a penalty for copies to between user and kernal space, but really + * nothing in NuttX but provide some Linux compatible (and adding + * another 'almost standard' interface). + * + * NOTE: This interface is *not* specified in POSIX.1-2001, or other + * standards. The implementation here is very similar to the Linux + * sendfile interface. Other UNIX systems implement sendfile() with + * different semantics and prototypes. sendfile() should not be used + * in portable programs. + * + * Input Parmeters: + * infd - A file (or socket) descriptor opened for reading + * outfd - A descriptor opened for writing. + * offset - If 'offset' is not NULL, then it points to a variable + * holding the file offset from which sendfile() will start + * reading data from 'infd'. When sendfile() returns, this + * variable will be set to the offset of the byte following + * the last byte that was read. If 'offset' is not NULL, + * then sendfile() does not modify the current file offset of + * 'infd'; otherwise the current file offset is adjusted to + * reflect the number of bytes read from 'infd.' + * + * If 'offset' is NULL, then data will be read from 'infd' + * starting at the current file offset, and the file offset + * will be updated by the call. + * count - The number of bytes to copy between the file descriptors. + * + * Returned Value: + * If the transfer was successful, the number of bytes written to outfd is + * returned. On error, -1 is returned, and errno is set appropriately. + * There error values are those returned by read() or write() plus: + * + * EINVAL - Bad input parameters. + * ENOMEM - Could not allocated an I/O buffer + * + ************************************************************************/ + +ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count) +{ + FAR uint8_t *iobuffer; + FAR uint8_t *wrbuffer; + off_t startpos = 0; + ssize_t nbytesread; + ssize_t nbyteswritten; + size_t ntransferred; + bool endxfr; + + /* Get the current file position. */ + + if (offset) + { + /* Use lseek to get the current file position */ + + startpos = lseek(infd, 0, SEEK_CUR); + if (startpos == (off_t)-1) + { + return ERROR; + } + + /* Use lseek again to set the new file position */ + + if (lseek(infd, *offset, SEEK_SET) == (off_t)-1) + { + return ERROR; + } + } + + /* Allocate an I/O buffer */ + + iobuffer = (FAR void *)malloc(CONFIG_LIB_SENDFILE_BUFSIZE); + if (!iobuffer) + { + set_errno(ENOMEM); + return ERROR; + } + + /* Now transfer 'count' bytes from the infd to the outfd */ + + for (ntransferred = 0, endxfr = false; ntransferred < count && !endxfr; ) + { + /* Loop until the read side of the transfer comes to some conclusion */ + + do + { + /* Read a buffer of data from the infd */ + + nbytesread = read(infd, iobuffer, CONFIG_LIB_SENDFILE_BUFSIZE); + + /* Check for end of file */ + + if (nbytesread == 0) + { + /* End of file. Break out and return current number of bytes + * transferred. + */ + + endxfr = true; + break; + } + + /* Check for a read ERROR. EINTR is a special case. This function + * should break out and return an error if EINTR is returned and + * no data has been transferred. But what should it do if some + * data has been transferred? I suppose just continue? + */ + + else if (nbytesread < 0) + { + /* EINTR is not an error (but will still stop the copy) */ + +#ifndef CONFIG_DISABLE_SIGNALS + if (errno != EINTR || ntransferred == 0) +#endif + { + /* Read error. Break out and return the error condition. */ + + ntransferred = ERROR; + endxfr = true; + break; + } + } + } + while (nbytesread < 0); + + /* Was anything read? */ + + if (!endxfr) + { + /* Yes.. Loop until the read side of the transfer comes to some + * conclusion. + */ + + wrbuffer = iobuffer; + do + { + /* Write the buffer of data to the outfd */ + + nbyteswritten = write(outfd, wrbuffer, nbytesread); + + /* Check for a complete (or parial) write. write() should not + * return zero. + */ + + if (nbyteswritten >= 0) + { + /* Advance the buffer pointer and decrement the number of bytes + * remaining in the iobuffer. Typically, nbytesread will now + * be zero. + */ + + wrbuffer += nbyteswritten; + nbytesread -= nbyteswritten; + + /* Increment the total number of bytes successfully transferred. */ + + ntransferred += nbyteswritten; + } + + /* Otherwise an error occurred */ + + else + { + /* Check for a read ERROR. EINTR is a special case. This + * function should break out and return an error if EINTR + * is returned and no data has been transferred. But what + * should it do if some data has been transferred? I + * suppose just continue? + */ + +#ifndef CONFIG_DISABLE_SIGNALS + if (errno != EINTR || ntransferred == 0) +#endif + { + /* Write error. Break out and return the error condition */ + + ntransferred = ERROR; + endxfr = true; + break; + } + } + } + while (nbytesread > 0); + } + } + + /* Release the I/O buffer */ + + free(iobuffer); + + /* Return the current file position */ + + if (offset) + { + /* Use lseek to get the current file position */ + + off_t curpos = lseek(infd, 0, SEEK_CUR); + if (curpos == (off_t)-1) + { + return ERROR; + } + + /* Return the current file position */ + + *offset = curpos; + + /* Use lseek again to restore the original file position */ + + if (lseek(infd, startpos, SEEK_SET) == (off_t)-1) + { + return ERROR; + } + } + + /* Finally return the number of bytes actually transferred (or ERROR + * if any failure occurred). + */ + + return ntransferred; +} + +#endif /* CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0 */
\ No newline at end of file diff --git a/nuttx/lib/misc/lib_streamsem.c b/nuttx/lib/misc/lib_streamsem.c index 3d86ab280..fdf494e75 100644 --- a/nuttx/lib/misc/lib_streamsem.c +++ b/nuttx/lib/misc/lib_streamsem.c @@ -2,7 +2,7 @@ * lib/misc/lib_streamsem.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/mqueue/mq_getattr.c b/nuttx/lib/mqueue/mq_getattr.c index 005ec0f24..9c9f47fdc 100644 --- a/nuttx/lib/mqueue/mq_getattr.c +++ b/nuttx/lib/mqueue/mq_getattr.c @@ -2,7 +2,7 @@ * lib/mqueue/mq_getattr.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/mqueue/mq_setattr.c b/nuttx/lib/mqueue/mq_setattr.c index 5d82299fe..1276d64e8 100644 --- a/nuttx/lib/mqueue/mq_setattr.c +++ b/nuttx/lib/mqueue/mq_setattr.c @@ -2,7 +2,7 @@ * lib/mqueue/mq_setattr.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/dq_addafter.c b/nuttx/lib/queue/dq_addafter.c index e9f0d9a3e..bfbe0052d 100644 --- a/nuttx/lib/queue/dq_addafter.c +++ b/nuttx/lib/queue/dq_addafter.c @@ -2,7 +2,7 @@ * lib/queue/dq_addafter.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/dq_addbefore.c b/nuttx/lib/queue/dq_addbefore.c index c49dff78b..d740ea830 100644 --- a/nuttx/lib/queue/dq_addbefore.c +++ b/nuttx/lib/queue/dq_addbefore.c @@ -2,7 +2,7 @@ * lib/queue/dq_addbefore.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/dq_addfirst.c b/nuttx/lib/queue/dq_addfirst.c index 27da2c491..7c7312de3 100644 --- a/nuttx/lib/queue/dq_addfirst.c +++ b/nuttx/lib/queue/dq_addfirst.c @@ -2,7 +2,7 @@ * lib/queue/dq_addfirst.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/dq_addlast.c b/nuttx/lib/queue/dq_addlast.c index c7a060961..745deb27d 100644 --- a/nuttx/lib/queue/dq_addlast.c +++ b/nuttx/lib/queue/dq_addlast.c @@ -2,7 +2,7 @@ * lib/queue/dq_addlast.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/dq_rem.c b/nuttx/lib/queue/dq_rem.c index adf99efed..218427bf8 100644 --- a/nuttx/lib/queue/dq_rem.c +++ b/nuttx/lib/queue/dq_rem.c @@ -2,7 +2,7 @@ * lib/queue/dq_rem.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/dq_remfirst.c b/nuttx/lib/queue/dq_remfirst.c index c42f3f2cc..26c5fd7a6 100644 --- a/nuttx/lib/queue/dq_remfirst.c +++ b/nuttx/lib/queue/dq_remfirst.c @@ -2,7 +2,7 @@ * lib/queue/dq_remfirst.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/dq_remlast.c b/nuttx/lib/queue/dq_remlast.c index 6280a0e51..35adc73e2 100644 --- a/nuttx/lib/queue/dq_remlast.c +++ b/nuttx/lib/queue/dq_remlast.c @@ -2,7 +2,7 @@ * lib/queue/dq_remlast.c * * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/sq_addafter.c b/nuttx/lib/queue/sq_addafter.c index 05e1157fd..965ac2844 100644 --- a/nuttx/lib/queue/sq_addafter.c +++ b/nuttx/lib/queue/sq_addafter.c @@ -2,7 +2,7 @@ * lib/queue/sq_addafter.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/sq_addfirst.c b/nuttx/lib/queue/sq_addfirst.c index 8f55053d4..8fc8e0619 100644 --- a/nuttx/lib/queue/sq_addfirst.c +++ b/nuttx/lib/queue/sq_addfirst.c @@ -2,7 +2,7 @@ * lib/queue/sq_addfirst.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/sq_addlast.c b/nuttx/lib/queue/sq_addlast.c index 15054a703..f9f9625cc 100644 --- a/nuttx/lib/queue/sq_addlast.c +++ b/nuttx/lib/queue/sq_addlast.c @@ -2,7 +2,7 @@ * lib/queue/sq_addlast.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/sq_rem.c b/nuttx/lib/queue/sq_rem.c index 972e8e1c3..6ba52354d 100644 --- a/nuttx/lib/queue/sq_rem.c +++ b/nuttx/lib/queue/sq_rem.c @@ -2,7 +2,7 @@ * lib/queue/sq_rem.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/sq_remafter.c b/nuttx/lib/queue/sq_remafter.c index 781a2b6ad..4dcfb06e4 100644 --- a/nuttx/lib/queue/sq_remafter.c +++ b/nuttx/lib/queue/sq_remafter.c @@ -2,7 +2,7 @@ * lib/queue/sq_remafter.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/sq_remfirst.c b/nuttx/lib/queue/sq_remfirst.c index 5a273ad6a..43df6de41 100644 --- a/nuttx/lib/queue/sq_remfirst.c +++ b/nuttx/lib/queue/sq_remfirst.c @@ -2,7 +2,7 @@ * lib/queue/sq_remfirst.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/queue/sq_remlast.c b/nuttx/lib/queue/sq_remlast.c index a66c6bcbb..92cdbde98 100644 --- a/nuttx/lib/queue/sq_remlast.c +++ b/nuttx/lib/queue/sq_remlast.c @@ -2,7 +2,7 @@ * lib/queue/sq_remlast.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/stdio/lib_fgets.c b/nuttx/lib/stdio/lib_fgets.c index e84e031f9..a4f9089ed 100644 --- a/nuttx/lib/stdio/lib_fgets.c +++ b/nuttx/lib/stdio/lib_fgets.c @@ -50,13 +50,32 @@ * Definitions ****************************************************************************/ /* Some environments may return CR as end-of-line, others LF, and others - * both. The logic here assumes either but not both. + * both. If not specified, the logic here assumes either (but not both) as + * the default. */ -#undef CONFIG_EOL_IS_CR -#undef CONFIG_EOL_IS_LF -#undef CONFIG_EOL_IS_BOTH_CRLF -#define CONFIG_EOL_IS_EITHER_CRLF 1 +#if defined(CONFIG_EOL_IS_CR) +# undef CONFIG_EOL_IS_LF +# undef CONFIG_EOL_IS_BOTH_CRLF +# undef CONFIG_EOL_IS_EITHER_CRLF +#elif defined(CONFIG_EOL_IS_LF) +# undef CONFIG_EOL_IS_CR +# undef CONFIG_EOL_IS_BOTH_CRLF +# undef CONFIG_EOL_IS_EITHER_CRLF +#elif defined(CONFIG_EOL_IS_BOTH_CRLF) +# undef CONFIG_EOL_IS_CR +# undef CONFIG_EOL_IS_LF +# undef CONFIG_EOL_IS_EITHER_CRLF +#elif defined(CONFIG_EOL_IS_EITHER_CRLF) +# undef CONFIG_EOL_IS_CR +# undef CONFIG_EOL_IS_LF +# undef CONFIG_EOL_IS_BOTH_CRLF +#else +# undef CONFIG_EOL_IS_CR +# undef CONFIG_EOL_IS_LF +# undef CONFIG_EOL_IS_BOTH_CRLF +# define CONFIG_EOL_IS_EITHER_CRLF 1 +#endif /**************************************************************************** * Private Type Declarations diff --git a/nuttx/lib/stdio/lib_fopen.c b/nuttx/lib/stdio/lib_fopen.c index 52e44c59d..29ff4569c 100644 --- a/nuttx/lib/stdio/lib_fopen.c +++ b/nuttx/lib/stdio/lib_fopen.c @@ -64,7 +64,7 @@ enum open_mode_e MODE_A, /* "a" or "ab" open for writing, appending to file */ MODE_RPLUS, /* "r+", "rb+", or "r+b" open for update (reading and writing) */ MODE_WPLUS, /* "w+", "wb+", or "w+b" open for update, truncating or creating file */ - MODE_APLUS, /* "a+", "ab+", or "a+b" open for update, appending to file */ + MODE_APLUS /* "a+", "ab+", or "a+b" open for update, appending to file */ }; /**************************************************************************** diff --git a/nuttx/lib/stdio/lib_lowinstream.c b/nuttx/lib/stdio/lib_lowinstream.c index c97a4721f..499a647ea 100644 --- a/nuttx/lib/stdio/lib_lowinstream.c +++ b/nuttx/lib/stdio/lib_lowinstream.c @@ -39,8 +39,6 @@ #include <nuttx/config.h> -#ifdef CONFIG_ARCH_LOWGETC - #include <stdio.h> #include <assert.h> #include <errno.h> @@ -49,6 +47,8 @@ #include "lib_internal.h" +#ifdef CONFIG_ARCH_LOWGETC + /**************************************************************************** * Private Functions ****************************************************************************/ diff --git a/nuttx/lib/stdio/lib_sscanf.c b/nuttx/lib/stdio/lib_sscanf.c index c77907711..01c96c21d 100644 --- a/nuttx/lib/stdio/lib_sscanf.c +++ b/nuttx/lib/stdio/lib_sscanf.c @@ -91,13 +91,13 @@ static const char spaces[] = " \t\n\r\f\v"; * ****************************************************************************/ -int sscanf(const char *buf, const char *fmt, ...) +int sscanf(FAR const char *buf, FAR const char *fmt, ...) { va_list ap; int count; va_start(ap, fmt); - count = vsscanf((char*)buf, fmt, ap); + count = vsscanf((FAR char*)buf, fmt, ap); va_end(ap); return count; } @@ -109,15 +109,15 @@ int sscanf(const char *buf, const char *fmt, ...) * ANSI standard vsscanf implementation. * ****************************************************************************/ -int vsscanf(char *buf, const char *s, va_list ap) +int vsscanf(FAR char *buf, FAR const char *s, va_list ap) { int count; int noassign; int width; int base = 10; int lflag; - char *tv; - const char *tc; + FAR char *tv; + FAR const char *tc; char tmp[MAXLN]; lvdbg("vsscanf: buf=\"%s\" fmt=\"%s\"\n", buf, s); diff --git a/nuttx/lib/string/Make.defs b/nuttx/lib/string/Make.defs index 495634a9e..6b21c7f14 100644 --- a/nuttx/lib/string/Make.defs +++ b/nuttx/lib/string/Make.defs @@ -36,13 +36,13 @@ # Add the string C files to the build CSRCS += lib_checkbase.c lib_isbasedigit.c lib_memset.c lib_memchr.c \ - lib_memccpy.c lib_memcpy.c lib_memcmp.c lib_memmove.c lib_skipspace.c \ - lib_strcasecmp.c lib_strcat.c lib_strchr.c lib_strcpy.c lib_strcmp.c \ - lib_strcspn.c lib_strdup.c lib_strerror.c lib_strlen.c lib_strnlen.c \ - lib_strncasecmp.c lib_strncat.c lib_strncmp.c lib_strncpy.c \ - lib_strndup.c lib_strcasestr.c lib_strpbrk.c lib_strrchr.c\ - lib_strspn.c lib_strstr.c lib_strtok.c lib_strtokr.c lib_strtol.c \ - lib_strtoll.c lib_strtoul.c lib_strtoull.c lib_strtod.c + lib_memccpy.c lib_memcpy.c lib_memcmp.c lib_memmove.c lib_skipspace.c \ + lib_strcasecmp.c lib_strcat.c lib_strchr.c lib_strcpy.c lib_strcmp.c \ + lib_strcspn.c lib_strdup.c lib_strerror.c lib_strlen.c lib_strnlen.c \ + lib_strncasecmp.c lib_strncat.c lib_strncmp.c lib_strncpy.c \ + lib_strndup.c lib_strcasestr.c lib_strpbrk.c lib_strrchr.c\ + lib_strspn.c lib_strstr.c lib_strtok.c lib_strtokr.c lib_strtol.c \ + lib_strtoll.c lib_strtoul.c lib_strtoull.c lib_strtod.c # Add the string directory to the build diff --git a/nuttx/lib/string/lib_checkbase.c b/nuttx/lib/string/lib_checkbase.c index bec131b5c..bc79ab2ce 100644 --- a/nuttx/lib/string/lib_checkbase.c +++ b/nuttx/lib/string/lib_checkbase.c @@ -2,7 +2,7 @@ * lib/string/lib_checkbase.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_isbasedigit.c b/nuttx/lib/string/lib_isbasedigit.c index 26426e821..a2421bf2a 100644 --- a/nuttx/lib/string/lib_isbasedigit.c +++ b/nuttx/lib/string/lib_isbasedigit.c @@ -2,7 +2,7 @@ * lib/string/lib_isbasedigit.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_memcmp.c b/nuttx/lib/string/lib_memcmp.c index cd874a85e..eb2e1fd12 100644 --- a/nuttx/lib/string/lib_memcmp.c +++ b/nuttx/lib/string/lib_memcmp.c @@ -2,7 +2,7 @@ * lib/string/lib_memcmp.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_memmove.c b/nuttx/lib/string/lib_memmove.c index 97bac99ed..ecaeb54cf 100644 --- a/nuttx/lib/string/lib_memmove.c +++ b/nuttx/lib/string/lib_memmove.c @@ -2,7 +2,7 @@ * lib/string/lib_memmove.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_memset.c b/nuttx/lib/string/lib_memset.c index f3a5497a9..916351b97 100644 --- a/nuttx/lib/string/lib_memset.c +++ b/nuttx/lib/string/lib_memset.c @@ -2,7 +2,7 @@ * lib/string/lib_memset.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_skipspace.c b/nuttx/lib/string/lib_skipspace.c index 826559efe..b4e6588e5 100644 --- a/nuttx/lib/string/lib_skipspace.c +++ b/nuttx/lib/string/lib_skipspace.c @@ -2,7 +2,7 @@ * lib/string/lib_skipspace.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strcasecmp.c b/nuttx/lib/string/lib_strcasecmp.c index ed5217831..d4aa8cc03 100644 --- a/nuttx/lib/string/lib_strcasecmp.c +++ b/nuttx/lib/string/lib_strcasecmp.c @@ -2,7 +2,7 @@ * lib/string/lib_strcasecmp.c * * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strcat.c b/nuttx/lib/string/lib_strcat.c index 2d12dd5a6..20350fec0 100644 --- a/nuttx/lib/string/lib_strcat.c +++ b/nuttx/lib/string/lib_strcat.c @@ -1,62 +1,62 @@ -/****************************************************************************
- * lib/string/lib_strcat.c
- *
- * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * 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. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <string.h>
-
-/****************************************************************************
- * Global Functions
- ****************************************************************************/
-
-#ifndef CONFIG_ARCH_STRCAT
-char *strcat(char *dest, const char *src)
-{
- char *ret = dest;
-
- dest += strlen(dest);
- while (*src != '\0')
- {
- *dest++ = *src++;
- }
- *dest = '\0';
-
- return ret;
-}
-#endif
+/**************************************************************************** + * lib/string/lib_strcat.c + * + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * 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. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <string.h> + +/**************************************************************************** + * Global Functions + ****************************************************************************/ + +#ifndef CONFIG_ARCH_STRCAT +char *strcat(char *dest, const char *src) +{ + char *ret = dest; + + dest += strlen(dest); + while (*src != '\0') + { + *dest++ = *src++; + } + *dest = '\0'; + + return ret; +} +#endif diff --git a/nuttx/lib/string/lib_strcmp.c b/nuttx/lib/string/lib_strcmp.c index 1d78cb049..0e3eee890 100644 --- a/nuttx/lib/string/lib_strcmp.c +++ b/nuttx/lib/string/lib_strcmp.c @@ -2,7 +2,7 @@ * lib/string/lib_strcmp.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strcpy.c b/nuttx/lib/string/lib_strcpy.c index 774e15534..e2f70b94e 100644 --- a/nuttx/lib/string/lib_strcpy.c +++ b/nuttx/lib/string/lib_strcpy.c @@ -2,7 +2,7 @@ * lib/string/lib_strcpy.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strcspn.c b/nuttx/lib/string/lib_strcspn.c index b28f22343..9da89241c 100644 --- a/nuttx/lib/string/lib_strcspn.c +++ b/nuttx/lib/string/lib_strcspn.c @@ -2,7 +2,7 @@ * lib/string/lib_strcspn.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strdup.c b/nuttx/lib/string/lib_strdup.c index a353c629d..44a0cbc0d 100644 --- a/nuttx/lib/string/lib_strdup.c +++ b/nuttx/lib/string/lib_strdup.c @@ -2,7 +2,7 @@ * lib/string//lib_strdup.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strlen.c b/nuttx/lib/string/lib_strlen.c index ee964c137..833305809 100644 --- a/nuttx/lib/string/lib_strlen.c +++ b/nuttx/lib/string/lib_strlen.c @@ -2,7 +2,7 @@ * lib/string/lib_strlen.c * * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strncasecmp.c b/nuttx/lib/string/lib_strncasecmp.c index 78b18a3fb..be369cf0d 100644 --- a/nuttx/lib/string/lib_strncasecmp.c +++ b/nuttx/lib/string/lib_strncasecmp.c @@ -2,7 +2,7 @@ * lib/string/lib_strncasecmp.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strncat.c b/nuttx/lib/string/lib_strncat.c index 6b7d54f81..af893e0f9 100644 --- a/nuttx/lib/string/lib_strncat.c +++ b/nuttx/lib/string/lib_strncat.c @@ -2,7 +2,7 @@ * lib/string/lib_strncat.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strncmp.c b/nuttx/lib/string/lib_strncmp.c index 147dfc536..ce2282024 100644 --- a/nuttx/lib/string/lib_strncmp.c +++ b/nuttx/lib/string/lib_strncmp.c @@ -2,7 +2,7 @@ * lib/lib_strncmp.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strncpy.c b/nuttx/lib/string/lib_strncpy.c index b5702cae2..149369d50 100644 --- a/nuttx/lib/string/lib_strncpy.c +++ b/nuttx/lib/string/lib_strncpy.c @@ -2,7 +2,7 @@ * lib/string/lib_strncpy.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strndup.c b/nuttx/lib/string/lib_strndup.c index 68b7c74c3..ffaf892ea 100644 --- a/nuttx/lib/string/lib_strndup.c +++ b/nuttx/lib/string/lib_strndup.c @@ -2,7 +2,7 @@ * lib/string//lib_strndup.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strnlen.c b/nuttx/lib/string/lib_strnlen.c index c2ffc248e..2b64fe984 100644 --- a/nuttx/lib/string/lib_strnlen.c +++ b/nuttx/lib/string/lib_strnlen.c @@ -9,7 +9,7 @@ * Derives from the file lib/lib_strlen.c: * * Copyright (C) 2007, 2008, 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strpbrk.c b/nuttx/lib/string/lib_strpbrk.c index 134058775..02e2ea2c7 100644 --- a/nuttx/lib/string/lib_strpbrk.c +++ b/nuttx/lib/string/lib_strpbrk.c @@ -2,7 +2,7 @@ * lib/string/lib_strpbrk.c * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use str source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strrchr.c b/nuttx/lib/string/lib_strrchr.c index e89b26d52..91243ce58 100644 --- a/nuttx/lib/string/lib_strrchr.c +++ b/nuttx/lib/string/lib_strrchr.c @@ -2,7 +2,7 @@ * lib/string/lib_strrchr.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strspn.c b/nuttx/lib/string/lib_strspn.c index e5cab9ad6..e7b5ea0a5 100644 --- a/nuttx/lib/string/lib_strspn.c +++ b/nuttx/lib/string/lib_strspn.c @@ -2,7 +2,7 @@ * lib/string/lib_strspn.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strstr.c b/nuttx/lib/string/lib_strstr.c index 27ca6e19b..b8c896fa2 100644 --- a/nuttx/lib/string/lib_strstr.c +++ b/nuttx/lib/string/lib_strstr.c @@ -2,7 +2,7 @@ * lib/string/lib_strstr.c * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use str source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strtod.c b/nuttx/lib/string/lib_strtod.c index 86719c510..8fecd4571 100644 --- a/nuttx/lib/string/lib_strtod.c +++ b/nuttx/lib/string/lib_strtod.c @@ -37,10 +37,15 @@ * Included Files ****************************************************************************/ +#include <nuttx/config.h> +#include <nuttx/compiler.h> + #include <stdlib.h> #include <ctype.h> #include <errno.h> +#ifdef CONFIG_HAVE_DOUBLE + /**************************************************************************** * Pre-processor definitions ****************************************************************************/ @@ -232,3 +237,5 @@ double_t strtod(const char *str, char **endptr) return number; } +#endif /* CONFIG_HAVE_DOUBLE */ + diff --git a/nuttx/lib/string/lib_strtok.c b/nuttx/lib/string/lib_strtok.c index bafa94853..c40993135 100644 --- a/nuttx/lib/string/lib_strtok.c +++ b/nuttx/lib/string/lib_strtok.c @@ -2,7 +2,7 @@ * lib/string/lib_strtok.c * * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strtokr.c b/nuttx/lib/string/lib_strtokr.c index 0d12a2381..1c571b6ae 100644 --- a/nuttx/lib/string/lib_strtokr.c +++ b/nuttx/lib/string/lib_strtokr.c @@ -2,7 +2,7 @@ * lib/string/lib_strtokr.c * * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strtol.c b/nuttx/lib/string/lib_strtol.c index 4f6904793..c17d87e63 100644 --- a/nuttx/lib/string/lib_strtol.c +++ b/nuttx/lib/string/lib_strtol.c @@ -2,7 +2,7 @@ * lib/string/lib_strtol.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strtoll.c b/nuttx/lib/string/lib_strtoll.c index 9c730b431..242e025c0 100644 --- a/nuttx/lib/string/lib_strtoll.c +++ b/nuttx/lib/string/lib_strtoll.c @@ -2,7 +2,7 @@ * lib/string/lib_strtoll.c * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strtoul.c b/nuttx/lib/string/lib_strtoul.c index 2aacc7cea..b0d2d090e 100644 --- a/nuttx/lib/string/lib_strtoul.c +++ b/nuttx/lib/string/lib_strtoul.c @@ -2,7 +2,7 @@ * /lib/string/lib_strtoul.c * * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/lib/string/lib_strtoull.c b/nuttx/lib/string/lib_strtoull.c index 334162148..6567457c0 100644 --- a/nuttx/lib/string/lib_strtoull.c +++ b/nuttx/lib/string/lib_strtoull.c @@ -2,7 +2,7 @@ * /lib/string/lib_strtoull.c * * Copyright (C) 2009, 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/libxx/Makefile b/nuttx/libxx/Makefile index f34a52600..4122931ac 100644 --- a/nuttx/libxx/Makefile +++ b/nuttx/libxx/Makefile @@ -2,7 +2,7 @@ # libxx/Makefile # # Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/libxx/libxx_delete.cxx b/nuttx/libxx/libxx_delete.cxx index 223a7bea9..d9203a228 100644 --- a/nuttx/libxx/libxx_delete.cxx +++ b/nuttx/libxx/libxx_delete.cxx @@ -2,7 +2,7 @@ // libxx/libxx_new.cxx // // Copyright (C) 2009 Gregory Nutt. All rights reserved. -// Author: Gregory Nutt <spudmonkey@racsa.co.cr> +// Author: Gregory Nutt <gnutt@nuttx.org> // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions diff --git a/nuttx/libxx/libxx_deletea.cxx b/nuttx/libxx/libxx_deletea.cxx index 3c519bd2c..e7cfee647 100644 --- a/nuttx/libxx/libxx_deletea.cxx +++ b/nuttx/libxx/libxx_deletea.cxx @@ -2,7 +2,7 @@ // libxx/libxx_newa.cxx // // Copyright (C) 2009 Gregory Nutt. All rights reserved. -// Author: Gregory Nutt <spudmonkey@racsa.co.cr> +// Author: Gregory Nutt <gnutt@nuttx.org> // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions diff --git a/nuttx/libxx/libxx_new.cxx b/nuttx/libxx/libxx_new.cxx index 8ec725ca8..0563b6580 100644 --- a/nuttx/libxx/libxx_new.cxx +++ b/nuttx/libxx/libxx_new.cxx @@ -2,7 +2,7 @@ // libxx/libxx_new.cxx // // Copyright (C) 2009 Gregory Nutt. All rights reserved. -// Author: Gregory Nutt <spudmonkey@racsa.co.cr> +// Author: Gregory Nutt <gnutt@nuttx.org> // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions diff --git a/nuttx/libxx/libxx_newa.cxx b/nuttx/libxx/libxx_newa.cxx index 855160c41..ad7806865 100644 --- a/nuttx/libxx/libxx_newa.cxx +++ b/nuttx/libxx/libxx_newa.cxx @@ -2,7 +2,7 @@ // libxx/libxx_newa.cxx // // Copyright (C) 2009 Gregory Nutt. All rights reserved. -// Author: Gregory Nutt <spudmonkey@racsa.co.cr> +// Author: Gregory Nutt <gnutt@nuttx.org> // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions diff --git a/nuttx/mm/Kconfig b/nuttx/mm/Kconfig index 000217dc5..5da12b65e 100644 --- a/nuttx/mm/Kconfig +++ b/nuttx/mm/Kconfig @@ -3,15 +3,6 @@ # see misc/tools/kconfig-language.txt. # -config MM_REGIONS - int "Number of memory regions" - default 1 - ---help--- - If the architecture includes multiple, non-contiguous regions of - memory to allocate from, this specifies the number of memory regions - that the memory manager must handle and enables the API - mm_addregion(start, end); - config MM_SMALL bool "Small memory model" default n @@ -24,3 +15,71 @@ config MM_SMALL have internal SRAM of size less than or equal to 64Kb. In this case, CONFIG_MM_SMALL can be defined so that those MCUs will also benefit from the smaller, 16-bit-based allocation overhead. + +config MM_REGIONS + int "Number of memory regions" + default 1 + ---help--- + If the architecture includes multiple, non-contiguous regions of + memory to allocate from, this specifies the number of memory regions + that the memory manager must handle and enables the API + mm_addregion(start, end); + +config ARCH_HAVE_HEAP2 + bool + +config HEAP2_BASE + hex "Start address of second heap region" + default 0x00000000 + depends on ARCH_HAVE_HEAP2 + ---help--- + The base address of the second heap region. + +config HEAP2_SIZE + int "Size of the second heap region" + default 0 + depends on ARCH_HAVE_HEAP2 + ---help--- + The size of the second heap region. + +config GRAN + bool "Enable Granule Allocator" + default n + ---help--- + Enable granual allocator support. Allocations will be aligned to the + granule size; allocations will be in units of the granule size. + Larger granules will give better performance and less overhead but + more losses of memory due to alignment and quantization waste. + + NOTE: The current implementation also restricts the maximum + allocation size to 32 granaules. That restriction could be + eliminated with some additional coding effort. + +config GRAN_SINGLE + bool "Single Granule Allocator" + default n + depends on GRAN + ---help--- + Select if there is only one instance of the granule allocator (i.e., + gran_initialize will be called only once. In this case, (1) there + are a few optimizations that can can be done and (2) the GRAN_HANDLE + is not needed. + +config GRAN_INTR + bool "Interrupt level support" + default n + depends on GRAN + ---help--- + Normally mutual exclusive access to granule allocator data is assured + using a semaphore. If this option is set then, instead, mutual + exclusion logic will disable interrupts. While this options is more + invasive to system performance, it will also support use of the granule + allocator from interrupt level logic. + +config DEBUG_GRAN + bool "Granule Allocator Debug" + default n + depends on GRAN && DEBUG + ---help--- + Just like CONFIG_DEBUG_MM, but only generates ouput from the gran + allocation logic. diff --git a/nuttx/mm/Makefile b/nuttx/mm/Makefile index 7e6eb68a7..0ccf5a09a 100644 --- a/nuttx/mm/Makefile +++ b/nuttx/mm/Makefile @@ -1,7 +1,7 @@ ############################################################################ # mm/Makefile # -# Copyright (C) 2007 Gregory Nutt. All rights reserved. +# Copyright (C) 2007, 2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -36,10 +36,15 @@ -include $(TOPDIR)/Make.defs ASRCS = -AOBJS = $(ASRCS:.S=$(OBJEXT)) CSRCS = mm_initialize.c mm_sem.c mm_addfreechunk.c mm_size2ndx.c mm_shrinkchunk.c \ mm_malloc.c mm_zalloc.c mm_calloc.c mm_realloc.c \ mm_memalign.c mm_free.c mm_mallinfo.c + +ifeq ($(CONFIG_GRAN),y) +CSRCS += mm_graninit.c mm_granalloc.c mm_granfree.c mm_grancritical.c +endif + +AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) diff --git a/nuttx/mm/README.txt b/nuttx/mm/README.txt new file mode 100644 index 000000000..2668432e3 --- /dev/null +++ b/nuttx/mm/README.txt @@ -0,0 +1,92 @@ +mm/README.txt +============= + +This directory contains the NuttX memory management logic. This include: + +1) The standard memory management functions as prototyped in stdlib.h as + specified in the Base definitions volume of IEEE Std 1003.1-2001. This + include the files: + + o Standard Interfaces: mm_malloc.c, mm_calloc.c, mm_realloc.c, + mm_memalign.c, mm_free.c + o Less-Standard Interfaces: mm_zalloc.c, mm_mallinfo.c + o Internal Implementation: mm_initialize.c mm_sem.c mm_addfreechunk.c + mm_size2ndx.c mm_shrinkchunk.c, mm_internal.h + o Build and Configuration files: Kconfig, Makefile + + Memory Models: + + o Small Memory Model. If the MCU supports only 16-bit data addressing + then the small memory model is automatically used. The maximum size + of the heap is then 64K. The small memory model can also be forced + MCUs with wider addressing by defining CONFIG_SMALL_MEMORY in the + NuttX configuration file. + o Large Memory Model. Otherwise, the allocator uses a model that + supports a heap of up to 4G. + + This implementation uses a variable length allocator with the following + properties: + + o Overhead: Either 8- or 4-bytes per allocation for large and small + models, respectively. + o Alignment: All allocations are aligned to 8- or 4-bytes for large + and small models, respectively. + +2) Test Program. There is also a host-best test program that can be + used to verify the memory manager. These are the file: + + Makefile.test, mm_test.c, and mm_environment.h. + + Build instructions: + + make -f Makefile.test + + The executable will be built in the top-level directory as nuttx/mm_text + (or mm_test.exe under Cygwin). + +3) Granule Allocator. A non-standard granule allocator is also available + in this directory The granule allocator allocates memory in units + of a fixed sized block ("granule"). Allocations may be aligned to a user- + provided address boundary. + + The granule allocator interfaces are defined in nuttx/include/nuttx/gran.h. + The granule allocator consists of these files in this directory: + + mm_gran.h, mm_granalloc.c, mm_grancritical.c, mm_granfree.c + mm_graninit.c + + The granule allocator is not used anywhere within the base NuttX code + as of this writing. The intent of the granule allocator is to provide + a tool to support platform-specific management of aligned DMA memory. + + NOTE: Because each granule may be aligned and each allocation is in + units of the granule size, selection of the granule size is important: + Larger granules will give better performance and less overhead but more + losses of memory due to quantization waste. Additional memory waste + can occur from alignment; Of course, heap alignment should no be + used unless (a) you are using the granule allocator to manage DMA memory + and (b) your hardware has specific memory alignment requirements. + + The current implementation also restricts the maximum allocation size + to 32 granules. That restriction could be eliminated with some + additional coding effort, but currently requires larger granule + sizes for larger allocations. + + Geneneral Usage Example. This is an example using the GCC section + attribute to position a DMA heap in memory (logic in the linker script + would assign the section .dmaheap to the DMA memory. + + FAR uint32_t g_dmaheap[DMAHEAP_SIZE] __attribute__((section(.dmaheap))); + + The heap is created by calling gran_initialize. Here the granual size + is set to 64 bytes and the alignment to 16 bytes: + + GRAN_HANDLE handle = gran_initialize(g_dmaheap, DMAHEAP_SIZE, 6, 4); + + Then the GRAN_HANDLE can be used to allocate memory (There is no + GRAN_HANDLE if CONFIG_GRAN_SINGLE=y): + + FAR uint8_t *dma_memory = (FAR uint8_t *)gran_alloc(handle, 47); + + The actual memory allocates will be 64 byte (wasting 17 bytes) and + will be aligned at least to (1 << log2align). diff --git a/nuttx/mm/mm_environment.h b/nuttx/mm/mm_environment.h index 70e611116..d28fbf1d7 100644 --- a/nuttx/mm/mm_environment.h +++ b/nuttx/mm/mm_environment.h @@ -105,12 +105,16 @@ extern void mm_addregion(FAR void *heapstart, size_t heapsize); /* Debug macros are always on */ -# define CONFIG_DEBUG +# define CONFIG_DEBUG 1 # undef mdbg # define mdbg(format, arg...) printf(format, ##arg) # undef mvdg # define mvdbg(format, arg...) printf(format, ##arg) +# undef mlldbg +# define mlldbg(format, arg...) printf(format, ##arg) +# undef mllvdg +# define mllvdbg(format, arg...) printf(format, ##arg) #else # define mm_errno get_errno() diff --git a/nuttx/graphics/nxtk/nxtk_movewindow.c b/nuttx/mm/mm_gran.h index 4c45c101c..a4f51490d 100644 --- a/nuttx/graphics/nxtk/nxtk_movewindow.c +++ b/nuttx/mm/mm_gran.h @@ -1,8 +1,8 @@ /**************************************************************************** - * graphics/nxtk/nxtk_movewindow.c + * mm/mm_gran.h * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,86 +33,100 @@ * ****************************************************************************/ +#ifndef __MM_MM_GRAN_H +#define __MM_MM_GRAN_H + /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> -#include <stdlib.h> -#include <errno.h> -#include <debug.h> - -#include <nuttx/nx/nx.h> -#include <nuttx/nx/nxtk.h> +#include <stdint.h> +#include <semaphore.h> -#include "nxfe.h" -#include "nxtk_internal.h" +#include <arch/types.h> +#include <nuttx/gran.h> /**************************************************************************** - * Pre-Processor Definitions + * Pre-processor Definitions ****************************************************************************/ -/**************************************************************************** - * Private Types - ****************************************************************************/ +/* Sizes of things */ + +#define SIZEOF_GAT(n) \ + ((n + 31) >> 5) +#define SIZEOF_GRAN_S(n) \ + (sizeof(struct gran_s) + sizeof(uint32_t) * (SIZEOF_GAT(n) - 1)) + +/* Debug */ + +#ifdef CONFIG_CPP_HAVE_VARARGS +# ifdef CONFIG_DEBUG_GRAM +# define gramdbg(format, arg...) dbg(format, ##arg) +# define gramvdbg(format, arg...) vdbg(format, ##arg) +# else +# define gramdbg(format, arg...) mdbg(format, ##arg) +# define gramvdbg(format, arg...) mvdbg(format, ##arg) +# endif +#else +# ifdef CONFIG_DEBUG_GRAM +# define gramdbg dbg +# define gramvdbg vdbg +# else +# define gramdbg (void) +# define gramvdbg (void) +# endif +#endif /**************************************************************************** - * Private Data + * Public Types ****************************************************************************/ +/* This structure represents the state of on granual allocation */ + +struct gran_s +{ + uint8_t log2gran; /* Log base 2 of the size of one granule */ + uint16_t ngranules; /* The total number of (aligned) granules in the heap */ +#ifdef CONFIG_GRAN_INTR + irqstate_t irqstate; /* For exclusive access to the GAT */ +#else + sem_t exclsem; /* For exclusive access to the GAT */ +#endif + uintptr_t heapstart; /* The aligned start of the granule heap */ + uint32_t gat[1]; /* Start of the granule allocation table */ +}; + /**************************************************************************** * Public Data ****************************************************************************/ -/**************************************************************************** - * Private Functions - ****************************************************************************/ +/* State of the single GRAN allocator */ + +#ifdef CONFIG_GRAN_SINGLE +extern FAR struct gran_s *g_graninfo; +#endif /**************************************************************************** - * Public Functions + * Public Function Prototypes ****************************************************************************/ /**************************************************************************** - * Name: nxtk_movewindow + * Name: gran_enter_critical and gran_leave_critical * * Description: - * Move a rectangular region within the client sub-window of a framed window + * Critical section management for the granule allocator. * * Input Parameters: - * hfwnd - The client sub-window within which the move is to be done. - * This must have been previously created by nxtk_openwindow(). - * rect - Describes the rectangular region relative to the client - * sub-window to move - * offset - The offset to move the region + * priv - Pointer to the gran state * - * Return: - * OK on success; ERROR on failure with errno set appropriately + * Returned Value: + * None * ****************************************************************************/ -int nxtk_movewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, - FAR const struct nxgl_point_s *offset) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; - struct nxgl_rect_s srcrect; - struct nxgl_point_s clipoffset; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !rect || !offset) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Make sure that both the source and dest rectangle lie within the - * client sub-window - */ - - nxtk_subwindowmove(fwnd, &srcrect, &clipoffset, rect, offset, &fwnd->fwrect); - - /* Then move it within the client window */ +void gran_enter_critical(FAR struct gran_s *priv); +void gran_leave_critical(FAR struct gran_s *priv); - return nx_move((NXWINDOW)hfwnd, &srcrect, &clipoffset); -} +#endif /* __MM_MM_GRAN_H */ diff --git a/nuttx/mm/mm_granalloc.c b/nuttx/mm/mm_granalloc.c new file mode 100644 index 000000000..e95709b31 --- /dev/null +++ b/nuttx/mm/mm_granalloc.c @@ -0,0 +1,358 @@ +/**************************************************************************** + * mm/mm_granalloc.c + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * 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. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <assert.h> + +#include <nuttx/gran.h> + +#include "mm_gran.h" + +#ifdef CONFIG_GRAN + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Name: gran_common_alloc + * + * Description: + * Allocate memory from the granule heap. + * + * Input Parameters: + * priv - The granule heap state structure. + * alloc - The adress of the allocation. + * ngranules - The number of granules allocated + * + * Returned Value: + * None + * + ****************************************************************************/ + +static inline void gran_mark_allocated(FAR struct gran_s *priv, + uintptr_t alloc, + unsigned int ngranules) +{ + unsigned int granno; + unsigned int gatidx; + unsigned int gatbit; + unsigned int avail; + uint32_t gatmask; + + /* Determine the granule number of the allocation */ + + granno = (alloc - priv->heapstart) >> priv->log2gran; + + /* Determine the GAT table index associated with the allocation */ + + gatidx = granno >> 5; + gatbit = granno & 31; + + /* Mark bits in the GAT entry or entries */ + + avail = 32 - gatbit; + if (ngranules > avail) + { + /* Mark bits in the first GAT entry */ + + gatmask =0xffffffff << gatbit; + DEBUGASSERT((priv->gat[gatidx] & gatmask) == 0); + + priv->gat[gatidx] |= gatmask; + ngranules -= avail; + + /* Mark bits in the second GAT entry */ + + gatmask = 0xffffffff >> (32 - ngranules); + DEBUGASSERT((priv->gat[gatidx+1] & gatmask) == 0); + + priv->gat[gatidx+1] |= gatmask; + } + + /* Handle the case where where all of the granules come from one entry */ + + else + { + /* Mark bits in a single GAT entry */ + + gatmask = 0xffffffff >> (32 - ngranules); + gatmask <<= gatbit; + DEBUGASSERT((priv->gat[gatidx] & gatmask) == 0); + + priv->gat[gatidx] |= gatmask; + return; + } + +} + +/**************************************************************************** + * Name: gran_common_alloc + * + * Description: + * Allocate memory from the granule heap. + * + * Input Parameters: + * priv - The granule heap state structure. + * size - The size of the memory region to allocate. + * + * Returned Value: + * On success, a non-NULL pointer to the allocated memory is returned. + * + ****************************************************************************/ + +static inline FAR void *gran_common_alloc(FAR struct gran_s *priv, size_t size) +{ + unsigned int ngranules; + size_t tmpmask; + uintptr_t alloc; + uint32_t curr; + uint32_t next; + uint32_t mask; + int granidx; + int gatidx; + int bitidx; + int shift; + + DEBUGASSERT(priv && size <= 32 * (1 << priv->log2gran)); + + if (priv && size > 0) + { + /* Get exclusive access to the GAT */ + + gran_enter_critical(priv); + + /* How many contiguous granules we we need to find? */ + + tmpmask = (1 << priv->log2gran) - 1; + ngranules = (size + tmpmask) >> priv->log2gran; + + /* Then create mask for that number of granules */ + + DEBUGASSERT(ngranules <= 32); + mask = 0xffffffff >> (32 - ngranules); + + /* Now search the granule allocation table for that number of contiguous */ + + alloc = priv->heapstart; + + for (granidx = 0; granidx < priv->ngranules; granidx += 32) + { + /* Get the GAT index associated with the granule table entry */ + + gatidx = granidx >> 5; + curr = priv->gat[gatidx]; + + /* Handle the case where there are no free granules in the entry */ + + if (curr == 0xffffffff) + { + alloc += (32 << priv->log2gran); + continue; + } + + /* Get the next entry from the GAT to support a 64 bit shift */ + + if (granidx < priv->ngranules) + { + next = priv->gat[gatidx + 1]; + } + + /* Use all ones when are at the last entry in the GAT (meaning + * nothing can be allocated. + */ + + else + { + next = 0xffffffff; + } + + /* Search through the allocations in the 'curr' GAT entry + * to see if we can satisfy the allocation starting in that + * entry. + * + * This loop continues until either all of the bits have been + * examined (bitidx >= 32), or until there are insufficient + * granules left to satisfy the allocation. + */ + + for (bitidx = 0; + bitidx < 32 && (granidx + bitidx + ngranules) <= priv->ngranules; + ) + { + /* Break out if there are no further free bits in 'curr'. + * All of the zero bits might have gotten shifted out. + */ + + if (curr == 0xffffffff) + { + break; + } + + /* Check for the first zero bit in the lower or upper 16-bits. + * From the test above, we know that at least one of the 32- + * bits in 'curr' is zero. + */ + + else if ((curr & 0x0000ffff) == 0x0000ffff) + { + /* Not in the lower 16 bits. The first free bit must be + * in the upper 16 bits. + */ + + shift = 16; + } + + /* We know that the first free bit is now within the lower 16 + * bits of 'curr'. Is it in the upper or lower byte? + */ + + else if ((curr & 0x0000ff) == 0x000000ff) + { + /* Not in the lower 8 bits. The first free bit must be in + * the upper 8 bits. + */ + + shift = 8; + } + + /* We know that the first free bit is now within the lower 4 + * bits of 'curr'. Is it in the upper or lower nibble? + */ + + else if ((curr & 0x00000f) == 0x0000000f) + { + /* Not in the lower 4 bits. The first free bit must be in + * the upper 4 bits. + */ + + shift = 4; + } + + /* We know that the first free bit is now within the lower 4 bits + * of 'curr'. Is it in the upper or lower pair? + */ + + else if ((curr & 0x000003) == 0x00000003) + { + /* Not in the lower 2 bits. The first free bit must be in + * the upper 2 bits. + */ + + shift = 2; + } + + /* We know that the first free bit is now within the lower 4 bits + * of 'curr'. Check if we have the allocation at this bit position. + */ + + else if ((curr & mask) == 0) + { + /* Yes.. mark these granules allocated */ + + gran_mark_allocated(priv, alloc, ngranules); + + /* And return the allocation address */ + + gran_leave_critical(priv); + return (FAR void *)alloc; + } + + /* The free allocation does not start at this position */ + + else + { + shift = 1; + } + + /* Set up for the next time through the loop. Perform a 64 + * bit shift to move to the next gram position andi ncrement + * to the next candidate allocation address. + */ + + alloc += (shift << priv->log2gran); + curr = (curr >> shift) | (next << (32 - shift)); + next >>= shift; + bitidx += shift; + } + } + } + + gran_leave_critical(priv); + return NULL; +} + +/**************************************************************************** + * Global Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: gran_alloc + * + * Description: + * Allocate memory from the granule heap. + * + * NOTE: The current implementation also restricts the maximum allocation + * size to 32 granules. That restriction could be eliminated with some + * additional coding effort. + * + * Input Parameters: + * handle - The handle previously returned by gran_initialize + * size - The size of the memory region to allocate. + * + * Returned Value: + * On success, either a non-NULL pointer to the allocated memory (if + * CONFIG_GRAN_SINGLE) or zero (if !CONFIG_GRAN_SINGLE) is returned. + * + ****************************************************************************/ + +#ifdef CONFIG_GRAN_SINGLE +FAR void *gran_alloc(size_t size) +{ + return gran_common_alloc(g_graninfo, size); +} +#else +FAR void *gran_alloc(GRAN_HANDLE handle, size_t size) +{ + return gran_common_alloc((FAR struct gran_s *)handle, size); +} +#endif + +#endif /* CONFIG_GRAN */ diff --git a/nuttx/graphics/nxsu/nx_closewindow.c b/nuttx/mm/mm_grancritical.c index c5a2799ea..190aa3e7d 100644 --- a/nuttx/graphics/nxsu/nx_closewindow.c +++ b/nuttx/mm/mm_grancritical.c @@ -1,8 +1,8 @@ /**************************************************************************** - * graphics/nxsu/nx_closewindow.c + * mm/mm_grancritical.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -40,22 +40,18 @@ #include <nuttx/config.h> #include <stdlib.h> +#include <assert.h> #include <errno.h> -#include <debug.h> -#include <nuttx/nx/nx.h> -#include "nxfe.h" +#include <arch/irq.h> +#include <nuttx/gran.h> -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ +#include "mm_gran.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ +#ifdef CONFIG_GRAN /**************************************************************************** - * Private Data + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -71,30 +67,50 @@ ****************************************************************************/ /**************************************************************************** - * Name: nx_closewindow + * Name: gran_enter_critical and gran_leave_critical * * Description: - * Destroy a window created by nx_openwindow. + * Critical section management for the granule allocator. * * Input Parameters: - * wnd - The window to be destroyed + * priv - Pointer to the gran state * - * Return: - * OK on success; ERROR on failure with errno set appropriately + * Returned Value: + * None * ****************************************************************************/ -int nx_closewindow(NXWINDOW hwnd) +void gran_enter_critical(FAR struct gran_s *priv) { -#ifdef CONFIG_DEBUG - if (!hwnd) +#ifdef CONFIG_GRAN_INTR + priv->irqstate = irqsave(); +#else + int ret; + + /* Continue waiting if we are awakened by a signal */ + + do { - errno = EINVAL; - return ERROR; + ret = sem_wait(&priv->exclsem); + if (ret < 0) + { + DEBUGASSERT(errno == EINTR); + } } + while (ret < 0); #endif +} - nxbe_closewindow((FAR struct nxbe_window_s *)hwnd); - return OK; +void gran_leave_critical(FAR struct gran_s *priv) +{ +#ifdef CONFIG_GRAN_INTR + irqrestore(priv->irqstate); +#else + sem_post(&priv->exclsem); +#endif } + +#endif /* CONFIG_GRAN */ + + diff --git a/nuttx/graphics/nxconsole/nxcon_redraw.c b/nuttx/mm/mm_granfree.c index 05f0a47f8..fcab11af9 100755..100644 --- a/nuttx/graphics/nxconsole/nxcon_redraw.c +++ b/nuttx/mm/mm_granfree.c @@ -1,5 +1,5 @@ /**************************************************************************** - * nuttx/graphics/nxconsole/nxcon_bkgd.c + * mm/mm_granfree.c * * Copyright (C) 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> @@ -39,114 +39,132 @@ #include <nuttx/config.h> -#include <stdint.h> -#include <stdbool.h> -#include <semaphore.h> #include <assert.h> -#include <errno.h> -#include <debug.h> -#include <nuttx/nx/nx.h> -#include <nuttx/nx/nxglib.h> +#include <nuttx/gran.h> -#include "nxcon_internal.h" +#include "mm_gran.h" -/**************************************************************************** - * Definitions - ****************************************************************************/ +#ifdef CONFIG_GRAN /**************************************************************************** - * Private Types + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxcon_redraw + * Name: gran_common_free * * Description: - * Re-draw a portion of the NX console. This function should be called - * from the appropriate window callback logic. + * Return memory to the granule heap. * * Input Parameters: - * handle - A handle previously returned by nx_register, nxtk_register, or - * nxtool_register. - * rect - The rectangle that needs to be re-drawn (in window relative - * coordinates) - * more - true: More re-draw requests will follow + * handle - The handle previously returned by gran_initialize + * memory - A pointer to memory previoiusly allocated by gran_alloc. * * Returned Value: * None * ****************************************************************************/ -void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool more) +static inline void gran_common_free(FAR struct gran_s *priv, + FAR void *memory, size_t size) { - FAR struct nxcon_state_s *priv; - int ret; - int i; + unsigned int granno; + unsigned int gatidx; + unsigned int gatbit; + unsigned int granmask; + unsigned int ngranules; + unsigned int avail; + uint32_t gatmask; - DEBUGASSERT(handle && rect); - gvdbg("rect={(%d,%d),(%d,%d)} more=%s\n", - rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, - more ? "true" : "false"); + DEBUGASSERT(priv && memory && size <= 32 * (1 << priv->log2gran)); - /* Recover our private state structure */ + /* Get exclusive access to the GAT */ - priv = (FAR struct nxcon_state_s *)handle; + gran_enter_critical(priv); - /* Get exclusive access to the state structure */ + /* Determine the granule number of the first granule in the allocation */ - do - { - ret = nxcon_semwait(priv); + granno = ((uintptr_t)memory - priv->heapstart) >> priv->log2gran; + + /* Determine the GAT table index and bit number associated with the + * allocation. + */ - /* Check for errors */ + gatidx = granno >> 5; + gatbit = granno & 31; - if (ret < 0) - { - /* The only expected error is if the wait failed because of it - * was interrupted by a signal. - */ + /* Determine the number of granules in the allocation */ - DEBUGASSERT(errno == EINTR); - } - } - while (ret < 0); + granmask = (1 << priv->log2gran) - 1; + ngranules = (size + granmask) >> priv->log2gran; - /* Fill the rectangular region with the window background color */ + /* Clear bits in the GAT entry or entries */ - ret = priv->ops->fill(priv, rect, priv->wndo.wcolor); - if (ret < 0) + avail = 32 - gatbit; + if (ngranules > avail) { - gdbg("fill failed: %d\n", errno); + /* Clear bits in the first GAT entry */ + + gatmask = (0xffffffff << gatbit); + DEBUGASSERT((priv->gat[gatidx] & gatmask) == gatmask); + + priv->gat[gatidx] &= ~gatmask; + ngranules -= avail; + + /* Clear bits in the second GAT entry */ + + gatmask = 0xffffffff >> (32 - ngranules); + DEBUGASSERT((priv->gat[gatidx+1] & gatmask) == gatmask); + + priv->gat[gatidx+1] &= ~gatmask; } - /* Then redraw each character on the display (Only the characters within - * the rectangle will actually be redrawn). - */ + /* Handle the case where where all of the granules came from one entry */ - for (i = 0; i < priv->nchars; i++) + else { - nxcon_fillchar(priv, rect, &priv->bm[i]); + /* Clear bits in a single GAT entry */ + + gatmask = 0xffffffff >> (32 - ngranules); + gatmask <<= gatbit; + DEBUGASSERT((priv->gat[gatidx] & gatmask) == gatmask); + + priv->gat[gatidx] &= ~gatmask; } - ret = nxcon_sempost(priv); + + gran_leave_critical(priv); } + +/**************************************************************************** + * Global Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: gran_free + * + * Description: + * Return memory to the granule heap. + * + * Input Parameters: + * handle - The handle previously returned by gran_initialize + * memory - A pointer to memory previoiusly allocated by gran_alloc. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_GRAN_SINGLE +void gran_free(FAR void *memory, size_t size) +{ + return gran_common_free(g_graninfo, memory, size); +} +#else +void gran_free(GRAN_HANDLE handle, FAR void *memory, size_t size) +{ + return gran_common_free((FAR struct gran_s *)handle, memory, size); +} +#endif + +#endif /* CONFIG_GRAN */ diff --git a/nuttx/mm/mm_graninit.c b/nuttx/mm/mm_graninit.c new file mode 100644 index 000000000..e43839ad6 --- /dev/null +++ b/nuttx/mm/mm_graninit.c @@ -0,0 +1,230 @@ +/**************************************************************************** + * mm/mm_graninit.c + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * 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. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdlib.h> +#include <assert.h> +#include <errno.h> + +#include <nuttx/gran.h> + +#include "mm_gran.h" + +#ifdef CONFIG_GRAN + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* State of the single GRAN allocator */ + +#ifdef CONFIG_GRAN_SINGLE +FAR struct gran_s *g_graninfo; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: gran_common_initialize + * + * Description: + * Perfrom common GRAN initialization. + * + * Input Parameters: + * info - Private granule data structure pointer + * heapstart - Start of the granule allocation heap + * heapsize - Size of heap in bytes + * log2gran - Log base 2 of the size of one granule. 0->1 byte, + * 1->2 bytes, 2->4 bytes, 3-> 8 bytes, etc. + * log2align - Log base 2 of required alignment. 0->1 byte, + * 1->2 bytes, 2->4 bytes, 3-> 8 bytes, etc. Note that + * log2gran must be greater than or equal to log2align + * so that all contiguous granules in memory will meet + * the minimum alignment requirement. A value of zero + * would mean that no alignment is required. + * + * Returned Value: + * On success, a non-NULL info structure is returned that may be used with + * other granule allocator interfaces. + * + ****************************************************************************/ + +static inline FAR struct gran_s * +gran_common_initialize(FAR void *heapstart, size_t heapsize, uint8_t log2gran, + uint8_t log2align) +{ + FAR struct gran_s *priv; + uintptr_t heapend; + uintptr_t alignedstart; + unsigned int mask; + unsigned int alignedsize; + unsigned int ngranules; + + /* Check parameters if debug is on. Note the the size of a granual is + * limited to 2**31 bytes and that the size of the granule must be greater + * than the alignment size. + */ + + DEBUGASSERT(heapstart && heapsize > 0 && + log2gran > 0 && log2gran < 32 && + log2gran > log2align); + + /* Get the aligned start of the heap */ + + mask = (1 << log2align) - 1; + alignedstart = ((uintptr_t)heapstart + mask) & ~mask; + + /* Determine the number of granules */ + + mask = (1 << log2gran) - 1; + heapend = (uintptr_t)heapstart + heapsize; + alignedsize = (heapend - alignedstart) & ~mask; + ngranules = alignedsize >> log2gran; + + /* Allocate the information structure with a granule table of the + * correct size. + */ + + priv = ( FAR struct gran_s *)zalloc(SIZEOF_GRAN_S(ngranules)); + if (priv) + { + /* Initialize non-zero elements of the granules heap info structure */ + + priv->log2gran = log2gran; + priv->ngranules = ngranules; + priv->heapstart = alignedstart; + + /* Initialize mutual exclusion support */ + +#ifndef CONFIG_GRAN_INTR + sem_init(&priv->exclsem, 0, 1); +#endif + } + + return priv; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: gran_initialize + * + * Description: + * Set up one granule allocator instance. Allocations will be aligned to + * the alignment size (log2align; allocations will be in units of the + * granule size (log2gran). Larger granules will give better performance + * and less overhead but more losses of memory due to quantization waste. + * Additional memory waste can occur from alignment; log2align should be + * set to 0 unless you are using the granule allocator to manage DMA memory + * and your hardware has specific memory alignment requirements. + * + * Geneneral Usage Summary. This is an example using the GCC section + * attribute to position a DMA heap in memory (logic in the linker script + * would assign the section .dmaheap to the DMA memory. + * + * FAR uint32_t g_dmaheap[DMAHEAP_SIZE] __attribute__((section(.dmaheap))); + * + * The heap is created by calling gran_initialize(). Here the granual size + * is set to 64 bytes (2**6) and the alignment to 16 bytes (2**4): + * + * GRAN_HANDLE handle = gran_initialize(g_dmaheap, DMAHEAP_SIZE, 6, 4); + * + * Then the GRAN_HANDLE can be used to allocate memory (There is no + * GRAN_HANDLE if CONFIG_GRAN_SINGLE=y): + * + * FAR uint8_t *dma_memory = (FAR uint8_t *)gran_alloc(handle, 47); + * + * The actual memory allocates will be 64 byte (wasting 17 bytes) and + * will be aligned at least to (1 << log2align). + * + * NOTE: The current implementation also restricts the maximum allocation + * size to 32 granules. That restriction could be eliminated with some + * additional coding effort. + * + * Input Parameters: + * heapstart - Start of the granule allocation heap + * heapsize - Size of heap in bytes + * log2gran - Log base 2 of the size of one granule. 0->1 byte, + * 1->2 bytes, 2->4 bytes, 3-> 8 bytes, etc. + * log2align - Log base 2 of required alignment. 0->1 byte, + * 1->2 bytes, 2->4 bytes, 3-> 8 bytes, etc. Note that + * log2gran must be greater than or equal to log2align + * so that all contiguous granules in memory will meet + * the minimum alignment requirement. A value of zero + * would mean that no alignment is required. + * + * Returned Value: + * On success, a non-NULL handle is returned that may be used with other + * granual allocator interfaces. + * + ****************************************************************************/ + +#ifdef CONFIG_GRAN_SINGLE +int gran_initialize(FAR void *heapstart, size_t heapsize, uint8_t log2gran, + uint8_t log2align) +int gran_initialize(FAR void *heapstart, size_t heapsize, uint8_t log2gran) +{ + g_graninfo = gran_common_initialize(heapstart, heapsize, log2gran, + log2align); + if (!g_graninfo) + { + return -ENOMEM; + } + + return OK; +} +#else +GRAN_HANDLE gran_initialize(FAR void *heapstart, size_t heapsize, + uint8_t log2gran, uint8_t log2align) +{ + return (GRAN_HANDLE)gran_common_initialize(heapstart, heapsize, + log2gran, log2align); +} +#endif + +#endif /* CONFIG_GRAN */ diff --git a/nuttx/net/Kconfig b/nuttx/net/Kconfig index dc16150ba..267045402 100644 --- a/nuttx/net/Kconfig +++ b/nuttx/net/Kconfig @@ -9,8 +9,27 @@ config NET ---help--- Enable or disable all network features +config ARCH_HAVE_PHY + bool + if NET +choice + prompt "Board PHY Selection" + depends on ARCH_HAVE_PHY + default PHY_KS8721 + +config PHY_KS8721 + bool "Micrel KS8721 PHY" + +config PHY_DP83848C + bool "National Semiconduction DP83848C PHY" + +config PHY_LAN8720 + bool "SMSC LAN8720 PHY" + +endchoice + config NET_NOINTS bool "Not interrupt driven" default n @@ -45,9 +64,10 @@ config NSOCKET_DESCRIPTORS config NET_NACTIVESOCKETS int "Max socket operations" + default 16 ---help--- Maximum number of concurrent socket operations (recv, send, etc.). - Default: NET_TCP_CONNS+NET_UCP_CONNS + Default: 16 config NET_SOCKOPTS bool "Socket options" @@ -93,16 +113,43 @@ config NET_MAX_LISTENPORTS Maximum number of listening TCP/IP ports (all tasks). Default: 20 config NET_TCP_READAHEAD_BUFSIZE - bool "TCP/IP read-ahead buffer size" + int "TCP/IP read-ahead buffer size" default 562 ---help--- - Size of TCP/IP read-ahead buffers + Read-ahead buffers allows buffering of TCP/IP packets when there is no + receive in place to catch the TCP packet. In that case, the packet + will be retained in the NuttX read-ahead buffers. + + This setting specifies the size of one TCP/IP read-ahead buffer. + This should best be a equal to the maximum packet size (NET_BUFSIZE). config NET_NTCP_READAHEAD_BUFFERS int "Number of TCP/IP read-ahead buffers" default 8 ---help--- - Number of TCP/IP read-ahead buffers (may be zero) + Read-ahead buffers allows buffering of TCP/IP packets when there is no + receive in place to catch the TCP packet. In that case, the packet + will be retained in the NuttX read-ahead buffers. + + This setting specifies the number of TCP/IP read-ahead buffers This + value can be set to zero to disable all TCP/IP read-ahead buffering. + You might want to disable TCP/IP read-ahead buffering on a highly + memory constained system that does not have any TCP/IP packet rate + issues. + +config NET_TCP_RECVDELAY + int "TCP Rx delay" + default 0 + ---help--- + If NET_NTCP_READAHEAD_BUFFERS is zero, then there will be no buffering + of TCP/IP packets: Any TCP/IP packet received will be ACKed, but its contents + will be dropped in the bit-bucket. + + One low-performance option is delay for a short period of time after a + TCP/IP packet is received to see if another comes right behind it. Then + the packet data from both can be combined. This option only makes since + if performance is not an issue and you need to handle short bursts of + small, back-to-back packets. The delay is in units of deciseconds. config NET_TCPBACKLOG bool "TCP/IP backlog support" @@ -192,8 +239,12 @@ config NET_STATISTICS config NET_RECEIVE_WINDOW int "Receive window size" + default 562 ---help--- - The size of the advertised receiver's window + The size of the advertised receiver's window. Should be set low + (i.e., to the size of the NET_BUFSIZE) if the application is slow + to process incoming data, or high (32768 bytes) if the application + processes data quickly. config NET_ARPTAB_SIZE int "ARP table size" @@ -214,11 +265,6 @@ config NET_MULTICAST ---help--- Outgoing multi-cast address support -config NET_FWCACHE_SIZE - int "FW cache size" - ---help--- - Number of packets to remember when looking for duplicates - config NET_SLIP bool "SLIP support" default n diff --git a/nuttx/net/listen.c b/nuttx/net/listen.c index bddb0ab08..5e3c62f69 100644 --- a/nuttx/net/listen.c +++ b/nuttx/net/listen.c @@ -2,7 +2,7 @@ * net/listen.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/net_arptimer.c b/nuttx/net/net_arptimer.c index 89db9f656..2c5d33c91 100644 --- a/nuttx/net/net_arptimer.c +++ b/nuttx/net/net_arptimer.c @@ -2,7 +2,7 @@ * net/net_arptimer.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/net_checksd.c b/nuttx/net/net_checksd.c index 3da3cea62..0a6975cad 100644 --- a/nuttx/net/net_checksd.c +++ b/nuttx/net/net_checksd.c @@ -2,7 +2,7 @@ * net/net_checksd.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/net_dsec2timeval.c b/nuttx/net/net_dsec2timeval.c index c9d3aeb66..0f570cb39 100644 --- a/nuttx/net/net_dsec2timeval.c +++ b/nuttx/net/net_dsec2timeval.c @@ -2,7 +2,7 @@ * net/net_dsec2timeval.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/net_dup.c b/nuttx/net/net_dup.c index 8465b7ce4..300459544 100644 --- a/nuttx/net/net_dup.c +++ b/nuttx/net/net_dup.c @@ -2,7 +2,7 @@ * net/net_dup.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/net_dup2.c b/nuttx/net/net_dup2.c index b27bb6967..3403a70c3 100644 --- a/nuttx/net/net_dup2.c +++ b/nuttx/net/net_dup2.c @@ -2,7 +2,7 @@ * net/net_dup2.c * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/net_timeval2dsec.c b/nuttx/net/net_timeval2dsec.c index 4ca5ecb5f..e0b25db98 100644 --- a/nuttx/net/net_timeval2dsec.c +++ b/nuttx/net/net_timeval2dsec.c @@ -2,7 +2,7 @@ * net/net_timeval2dsec.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/netdev_count.c b/nuttx/net/netdev_count.c index 17f0894da..8db1191a2 100644 --- a/nuttx/net/netdev_count.c +++ b/nuttx/net/netdev_count.c @@ -2,7 +2,7 @@ * net/netdev_count.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/netdev_findbyaddr.c b/nuttx/net/netdev_findbyaddr.c index 50a246f67..e8083e4d0 100644 --- a/nuttx/net/netdev_findbyaddr.c +++ b/nuttx/net/netdev_findbyaddr.c @@ -2,7 +2,7 @@ * net/netdev_findbyaddr.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/netdev_findbyname.c b/nuttx/net/netdev_findbyname.c index a6ddf0452..9f6f895ac 100644 --- a/nuttx/net/netdev_findbyname.c +++ b/nuttx/net/netdev_findbyname.c @@ -2,7 +2,7 @@ * net/netdev_findbyname.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/netdev_unregister.c b/nuttx/net/netdev_unregister.c index e1aec0e4d..39927340a 100644 --- a/nuttx/net/netdev_unregister.c +++ b/nuttx/net/netdev_unregister.c @@ -2,7 +2,7 @@ * net/netdev_unregister.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/recvfrom.c b/nuttx/net/recvfrom.c index 741cd4c72..91dbcce81 100644 --- a/nuttx/net/recvfrom.c +++ b/nuttx/net/recvfrom.c @@ -59,8 +59,6 @@ * Definitions ****************************************************************************/ -#define TCP_TIMEO 10 /* Deciseconds after data received before recv() returns */ - #define UDPBUF ((struct uip_udpip_hdr *)&dev->d_buf[UIP_LLH_LEN]) #define TCPBUF ((struct uip_tcpip_hdr *)&dev->d_buf[UIP_LLH_LEN]) @@ -354,31 +352,39 @@ static int recvfrom_timeout(struct recvfrom_s *pstate) FAR struct socket *psock = 0; socktimeo_t timeo = 0; - /* If this is a TCP socket that has already received some data, - * than we will always use a short timeout. + /* Check for a timeout configured via setsockopts(SO_RCVTIMEO). If none... + * we well let the read hang forever (except for the special case below). */ - if (pstate->rf_recvlen > 0) + /* Get the socket reference from the private data */ + + psock = pstate->rf_sock; + if (psock) { - /* Use the short timeout */ + /* Recover the timeout value (zero if no timeout) */ - timeo = TCP_TIMEO; + timeo = psock->s_rcvtimeo; } - /* No.. check for a timeout configured via setsockopts(SO_RCVTIMEO). - * If none... we well let the read hang forever. + /* Use a fixed, configurable delay under the following circumstances: + * + * 1) This delay function has been enabled with CONFIG_NET_TCP_RECVDELAY > 0 + * 2) Some data has already been received from the socket. Since this can + * only be true for a TCP/IP socket, this logic applies only to TCP/IP + * sockets. And either + * 3) There is no configured receive timeout, or + * 4) The configured receive timeout is greater than than the delay */ - else +#if CONFIG_NET_TCP_RECVDELAY > 0 + if ((timeo == 0 || timeo > CONFIG_NET_TCP_RECVDELAY) && + pstate->rf_recvlen > 0) { - /* Get the socket reference from the private data */ + /* Use the configured timeout */ - psock = pstate->rf_sock; - if (psock) - { - timeo = psock->s_rcvtimeo; - } + timeo = CONFIG_NET_TCP_RECVDELAY; } +#endif /* Is there an effective timeout? */ @@ -389,7 +395,7 @@ static int recvfrom_timeout(struct recvfrom_s *pstate) return net_timeo(pstate->rf_starttime, timeo); } - /* No timeout */ + /* No timeout -- hang forever waiting for data. */ return FALSE; } @@ -489,9 +495,28 @@ static uint16_t recvfrom_tcpinterrupt(struct uip_driver_s *dev, void *conn, flags = (flags & ~UIP_NEWDATA) | UIP_SNDACK; - /* If the user buffer has been filled, then we are finished. */ + /* Check for transfer complete. We will consider the transfer + * complete in own of two different ways, depending on the setting + * of CONFIG_NET_TCP_RECVDELAY. + * + * 1) If CONFIG_NET_TCP_RECVDELAY == 0 then we will consider the + * TCP/IP transfer complete as soon as any data has been received. + * This is safe because if any additional data is received, it + * will be retained inthe TCP/IP read-ahead buffer until the + * next receive is performed. + * 2) CONFIG_NET_TCP_RECVDELAY > 0 may be set to wait a little + * bit to determine if more data will be received. You might + * do this if read-ahead buffereing is disabled and we want to + * minimize the loss of back-to-back packets. In this case, + * the transfer is complete when either a) the entire user buffer + * is full or 2) when the receive timeout occurs (below). + */ +#if CONFIG_NET_TCP_RECVDELAY > 0 if (pstate->rf_buflen == 0) +#else + if (pstate->rf_recvlen > 0) +#endif { nllvdbg("TCP resume\n"); @@ -571,9 +596,14 @@ static uint16_t recvfrom_tcpinterrupt(struct uip_driver_s *dev, void *conn, pstate->rf_cb->priv = NULL; pstate->rf_cb->event = NULL; - /* Report an error only if no data has been received */ + /* Report an error only if no data has been received. (If + * CONFIG_NET_TCP_RECVDELAY then rf_recvlen should always be + * zero). + */ +#if CONFIG_NET_TCP_RECVDELAY > 0 if (pstate->rf_recvlen == 0) +#endif { /* Report the timeout error */ @@ -1049,7 +1079,26 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, else #endif + + /* We get here when we we decide that we need to setup the wait for incoming + * TCP/IP data. Just a few more conditions to check: + * + * 1) Make sure thet there is buffer space to receive additional data + * (state.rf_buflen > 0). This could be zero, for example, if read-ahead + * buffering was enabled and we filled the user buffer with data from + * the read-ahead buffers. Aand + * 2) if read-ahead buffering is enabled (CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0) + * and delay logic is disabled (CONFIG_NET_TCP_RECVDELAY == 0), then we + * not want to wait if we already obtained some data from the read-ahead + * buffer. In that case, return now with what we have (don't want for more + * because there may be no timeout). + */ + +#if CONFIG_NET_TCP_RECVDELAY == 0 && CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0 + if (state.rf_recvlen == 0 && state.rf_buflen > 0) +#else if (state.rf_buflen > 0) +#endif { struct uip_conn *conn = (struct uip_conn *)psock->s_conn; diff --git a/nuttx/net/send.c b/nuttx/net/send.c index 950b3fc0b..8a5154191 100644 --- a/nuttx/net/send.c +++ b/nuttx/net/send.c @@ -268,7 +268,7 @@ static uint16_t send_interrupt(struct uip_driver_s *dev, void *pvconn, * then the send won't actually make it out... it will be replaced with * an ARP request. * - * NOTE 1: This could an expensive check if there are a lot of entries + * NOTE 1: This could be an expensive check if there are a lot of entries * in the ARP table. Hence, we only check on the first packet -- when * snd_sent is zero. * diff --git a/nuttx/net/uip/Make.defs b/nuttx/net/uip/Make.defs index 8bd8d1839..c5d915e61 100644 --- a/nuttx/net/uip/Make.defs +++ b/nuttx/net/uip/Make.defs @@ -2,7 +2,7 @@ # Make.defs # # Copyright (C) 2007, 2009-20010 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/net/uip/uip_arptab.c b/nuttx/net/uip/uip_arptab.c index 1a29f25df..3dff97070 100644 --- a/nuttx/net/uip/uip_arptab.c +++ b/nuttx/net/uip/uip_arptab.c @@ -3,7 +3,7 @@ * Implementation of the ARP Address Resolution Protocol. * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Based originally on uIP which also has a BSD style license: * diff --git a/nuttx/net/uip/uip_callback.c b/nuttx/net/uip/uip_callback.c index 730aa7758..0c8c3aaa0 100644 --- a/nuttx/net/uip/uip_callback.c +++ b/nuttx/net/uip/uip_callback.c @@ -2,7 +2,7 @@ * net/uip/uip_callback.c * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/uip/uip_icmppoll.c b/nuttx/net/uip/uip_icmppoll.c index ca1d684c0..bcf7fe94b 100644 --- a/nuttx/net/uip/uip_icmppoll.c +++ b/nuttx/net/uip/uip_icmppoll.c @@ -2,7 +2,7 @@ * net/uip/uip_icmppoll.c * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/uip/uip_igmpgroup.c b/nuttx/net/uip/uip_igmpgroup.c index 220de047e..b92db5476 100755..100644 --- a/nuttx/net/uip/uip_igmpgroup.c +++ b/nuttx/net/uip/uip_igmpgroup.c @@ -3,7 +3,7 @@ * IGMP group data structure management logic * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * The NuttX implementation of IGMP was inspired by the IGMP add-on for the * lwIP TCP/IP stack by Steve Reynolds: diff --git a/nuttx/net/uip/uip_igmpinit.c b/nuttx/net/uip/uip_igmpinit.c index 7954e7b3e..740ddf44b 100755..100644 --- a/nuttx/net/uip/uip_igmpinit.c +++ b/nuttx/net/uip/uip_igmpinit.c @@ -3,7 +3,7 @@ * IGMP initialization logic * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * The NuttX implementation of IGMP was inspired by the IGMP add-on for the * lwIP TCP/IP stack by Steve Reynolds: diff --git a/nuttx/net/uip/uip_igmpinput.c b/nuttx/net/uip/uip_igmpinput.c index 5b4fbefa4..40c1cf3ba 100755..100644 --- a/nuttx/net/uip/uip_igmpinput.c +++ b/nuttx/net/uip/uip_igmpinput.c @@ -2,7 +2,7 @@ * net/uip/uip_igminput.c * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * The NuttX implementation of IGMP was inspired by the IGMP add-on for the * lwIP TCP/IP stack by Steve Reynolds: diff --git a/nuttx/net/uip/uip_igmpjoin.c b/nuttx/net/uip/uip_igmpjoin.c index eb6e88837..c02b0bb8f 100755..100644 --- a/nuttx/net/uip/uip_igmpjoin.c +++ b/nuttx/net/uip/uip_igmpjoin.c @@ -2,7 +2,7 @@ * net/uip/uip_igmpjoin.c * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * The NuttX implementation of IGMP was inspired by the IGMP add-on for the * lwIP TCP/IP stack by Steve Reynolds: diff --git a/nuttx/net/uip/uip_igmpleave.c b/nuttx/net/uip/uip_igmpleave.c index 7e2a31a19..4e08df576 100755..100644 --- a/nuttx/net/uip/uip_igmpleave.c +++ b/nuttx/net/uip/uip_igmpleave.c @@ -2,7 +2,7 @@ * net/uip/uip_igmpleave.c * * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * The NuttX implementation of IGMP was inspired by the IGMP add-on for the * lwIP TCP/IP stack by Steve Reynolds: diff --git a/nuttx/net/uip/uip_igmpmsg.c b/nuttx/net/uip/uip_igmpmsg.c index 9ea3daa4e..5209eaf7a 100755..100644 --- a/nuttx/net/uip/uip_igmpmsg.c +++ b/nuttx/net/uip/uip_igmpmsg.c @@ -2,7 +2,7 @@ * net/uip/uip_igmpmgs.c * * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * The NuttX implementation of IGMP was inspired by the IGMP add-on for the * lwIP TCP/IP stack by Steve Reynolds: diff --git a/nuttx/net/uip/uip_igmppoll.c b/nuttx/net/uip/uip_igmppoll.c index cec2a5e1b..e86eb687b 100755..100644 --- a/nuttx/net/uip/uip_igmppoll.c +++ b/nuttx/net/uip/uip_igmppoll.c @@ -2,7 +2,7 @@ * net/uip/uip_igmppoll.c * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * The NuttX implementation of IGMP was inspired by the IGMP add-on for the * lwIP TCP/IP stack by Steve Reynolds: diff --git a/nuttx/net/uip/uip_igmpsend.c b/nuttx/net/uip/uip_igmpsend.c index 21fc2beb0..f22282b62 100755..100644 --- a/nuttx/net/uip/uip_igmpsend.c +++ b/nuttx/net/uip/uip_igmpsend.c @@ -2,7 +2,7 @@ * net/uip/uip_igmpsend.c * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/uip/uip_igmptimer.c b/nuttx/net/uip/uip_igmptimer.c index 27e2f9ff0..4655f3a2f 100755..100644 --- a/nuttx/net/uip/uip_igmptimer.c +++ b/nuttx/net/uip/uip_igmptimer.c @@ -2,7 +2,7 @@ * net/uip/uip_igmptimer.c * * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * The NuttX implementation of IGMP was inspired by the IGMP add-on for the * lwIP TCP/IP stack by Steve Reynolds: diff --git a/nuttx/net/uip/uip_initialize.c b/nuttx/net/uip/uip_initialize.c index 8839836c4..e737d646e 100644 --- a/nuttx/net/uip/uip_initialize.c +++ b/nuttx/net/uip/uip_initialize.c @@ -2,7 +2,7 @@ * net/uip/uip_initialize.c * * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Adapted for NuttX from logic in uIP which also has a BSD-like license: * diff --git a/nuttx/net/uip/uip_listen.c b/nuttx/net/uip/uip_listen.c index 5f867fef2..420fbb070 100644 --- a/nuttx/net/uip/uip_listen.c +++ b/nuttx/net/uip/uip_listen.c @@ -2,7 +2,7 @@ * net/uip/uip_listen.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * A direct leverage of logic from uIP which also has b BSD style license * diff --git a/nuttx/net/uip/uip_mcastmac.c b/nuttx/net/uip/uip_mcastmac.c index 7795becab..9bd146198 100755..100644 --- a/nuttx/net/uip/uip_mcastmac.c +++ b/nuttx/net/uip/uip_mcastmac.c @@ -2,7 +2,7 @@ * net/uip/uip_mcastmac.c * * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * The NuttX implementation of IGMP was inspired by the IGMP add-on for the * lwIP TCP/IP stack by Steve Reynolds: diff --git a/nuttx/net/uip/uip_neighbor.h b/nuttx/net/uip/uip_neighbor.h index eac08f938..b55835b74 100644 --- a/nuttx/net/uip/uip_neighbor.h +++ b/nuttx/net/uip/uip_neighbor.h @@ -3,7 +3,7 @@ * to be used by future ARP code. * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * A direct leverage of logic from uIP which also has b BSD style license * diff --git a/nuttx/net/uip/uip_send.c b/nuttx/net/uip/uip_send.c index fd0f4f7da..b26c799a0 100644 --- a/nuttx/net/uip/uip_send.c +++ b/nuttx/net/uip/uip_send.c @@ -2,7 +2,7 @@ * net/uip/uip_send.c * * Copyright (C) 2007i, 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Based in part on uIP which also has a BSD stylie license: * diff --git a/nuttx/net/uip/uip_setipid.c b/nuttx/net/uip/uip_setipid.c index f9d13cc9d..12a94860b 100644 --- a/nuttx/net/uip/uip_setipid.c +++ b/nuttx/net/uip/uip_setipid.c @@ -2,7 +2,7 @@ * net/uip/uip_setipid.c * * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/net/uip/uip_tcpappsend.c b/nuttx/net/uip/uip_tcpappsend.c index d8a187503..dfddbcff9 100644 --- a/nuttx/net/uip/uip_tcpappsend.c +++ b/nuttx/net/uip/uip_tcpappsend.c @@ -2,7 +2,7 @@ * net/uip/uip_tcpappsend.c * * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Adapted for NuttX from logic in uIP which also has a BSD-like license: * diff --git a/nuttx/net/uip/uip_tcpcallback.c b/nuttx/net/uip/uip_tcpcallback.c index 9ce8eb132..8ac1351f7 100644 --- a/nuttx/net/uip/uip_tcpcallback.c +++ b/nuttx/net/uip/uip_tcpcallback.c @@ -2,7 +2,7 @@ * net/uip/uip_tcpcallback.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/uip/uip_tcpconn.c b/nuttx/net/uip/uip_tcpconn.c index c2b64ad89..31e020f63 100644 --- a/nuttx/net/uip/uip_tcpconn.c +++ b/nuttx/net/uip/uip_tcpconn.c @@ -2,7 +2,7 @@ * net/uip/uip_tcpconn.c * * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Large parts of this file were leveraged from uIP logic: * diff --git a/nuttx/net/uip/uip_tcppoll.c b/nuttx/net/uip/uip_tcppoll.c index 29cb6d4b4..ddc8ab029 100644 --- a/nuttx/net/uip/uip_tcppoll.c +++ b/nuttx/net/uip/uip_tcppoll.c @@ -3,7 +3,7 @@ * Poll for the availability of TCP TX data * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Adapted for NuttX from logic in uIP which also has a BSD-like license: * diff --git a/nuttx/net/uip/uip_tcpreadahead.c b/nuttx/net/uip/uip_tcpreadahead.c index 21ed58b99..a304925a8 100644 --- a/nuttx/net/uip/uip_tcpreadahead.c +++ b/nuttx/net/uip/uip_tcpreadahead.c @@ -2,7 +2,7 @@ * net/uip/uip_tcpreadahead.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/uip/uip_tcpseqno.c b/nuttx/net/uip/uip_tcpseqno.c index eab3a054a..2eca06e85 100755..100644 --- a/nuttx/net/uip/uip_tcpseqno.c +++ b/nuttx/net/uip/uip_tcpseqno.c @@ -2,7 +2,7 @@ * net/uip/uip_tcpseqno.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Large parts of this file were leveraged from uIP logic: * diff --git a/nuttx/net/uip/uip_tcptimer.c b/nuttx/net/uip/uip_tcptimer.c index c95376ab0..a0772136e 100644 --- a/nuttx/net/uip/uip_tcptimer.c +++ b/nuttx/net/uip/uip_tcptimer.c @@ -3,7 +3,7 @@ * Poll for the availability of TCP TX data * * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Adapted for NuttX from logic in uIP which also has a BSD-like license: * diff --git a/nuttx/net/uip/uip_udpcallback.c b/nuttx/net/uip/uip_udpcallback.c index f00c5e0f8..ef4b36e49 100644 --- a/nuttx/net/uip/uip_udpcallback.c +++ b/nuttx/net/uip/uip_udpcallback.c @@ -2,7 +2,7 @@ * net/uip/uip_udpcallback.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/net/uip/uip_udpinput.c b/nuttx/net/uip/uip_udpinput.c index 456c34799..fa7bf8c41 100644 --- a/nuttx/net/uip/uip_udpinput.c +++ b/nuttx/net/uip/uip_udpinput.c @@ -3,7 +3,7 @@ * Handling incoming UDP input * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Adapted for NuttX from logic in uIP which also has a BSD-like license: * diff --git a/nuttx/net/uip/uip_udppoll.c b/nuttx/net/uip/uip_udppoll.c index 984566ed4..05c2508bc 100644 --- a/nuttx/net/uip/uip_udppoll.c +++ b/nuttx/net/uip/uip_udppoll.c @@ -3,7 +3,7 @@ * Poll for the availability of UDP TX data * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Adapted for NuttX from logic in uIP which also has a BSD-like license: * diff --git a/nuttx/net/uip/uip_udpsend.c b/nuttx/net/uip/uip_udpsend.c index 1dc33bbd1..9ba8ec8f5 100644 --- a/nuttx/net/uip/uip_udpsend.c +++ b/nuttx/net/uip/uip_udpsend.c @@ -2,7 +2,7 @@ * net/uip/uip_udpsend.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Adapted for NuttX from logic in uIP which also has a BSD-like license: * diff --git a/nuttx/sched/Kconfig b/nuttx/sched/Kconfig index 37ce0ebd6..4f7149595 100644 --- a/nuttx/sched/Kconfig +++ b/nuttx/sched/Kconfig @@ -166,6 +166,39 @@ config SIG_SIGWORK The signal number that will be used to wake-up the worker thread. Default: 4 +config SCHED_LPWORK + bool "Enable a lower priority worker thread" + default n + depends on SCHED_WORKQUEUE + ---help--- + If SCHED_WORKQUEUE is defined, then a single work queue is created by + default. If SCHED_LPWORK is also defined then an additional, lower- + priority work queue will also be created. This lower priority work + queue is better suited for more extended processing (such as file system + clean-up operations) + +config SCHED_LPWORKPRIORITY + int "Lower priority worker thread priority" + default 50 + depends on SCHED_LPWORK + ---help--- + The execution priority of the lopwer priority worker thread. Default: 192 + +config SCHED_LPWORKPERIOD + int "Lower priority worker thread period" + default 50000 + depends on SCHED_LPWORK + ---help--- + How often the lower priority worker thread checks for work in units + of microseconds. Default: 50*1000 (50 MS). + +config SCHED_LPWORKSTACKSIZE + int "Lower priority worker thread stack size" + default 2048 + depends on SCHED_LPWORK + ---help--- + The stack size allocated for the lower priority worker thread. Default: 2K. + config SCHED_WAITPID bool "Enable waitpid() API" default n @@ -203,7 +236,7 @@ config SCHED_ONEXIT_MAX number that you require. config USER_ENTRYPOINT - string "Appliation entry point" + string "Application entry point" default "user_start" ---help--- The name of the entry point for user applications. For the example @@ -348,20 +381,6 @@ config PREALLOC_TIMERS comment "Stack and heap information" -config BOOT_RUNFROMFLASH - bool "boot run from flash" - default n - ---help--- - Some configurations support XIP operation from FLASH but must copy - initialized .data sections to RAM - -config BOOT_COPYTORAM - bool "boot copy to ram" - default n - ---help--- - Some configurations boot in FLASH - but copy themselves entirely into RAM for better performance. - config CUSTOM_STACK bool "Enable custom stack" default n @@ -370,11 +389,6 @@ config CUSTOM_STACK nuttx model. This is necessary for certain architectures that have have hardware stacks (such as the 8051 family). -config STACK_POINTER - hex "The initial stack pointer" - ---help--- - The initial stack pointer (arm7tdmi only). - config IDLETHREAD_STACKSIZE int "Idle thread stack size" default 1024 diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile index dfdc6f68b..1e0a55aea 100644 --- a/nuttx/sched/Makefile +++ b/nuttx/sched/Makefile @@ -141,7 +141,7 @@ TIMER_SRCS = timer_initialize.c timer_create.c timer_delete.c timer_getoverrun.c endif ifeq ($(CONFIG_SCHED_WORKQUEUE),y) -WORK_SRCS = work_thread.c work_queue.c work_cancel.c +WORK_SRCS = work_thread.c work_queue.c work_cancel.c work_signal.c endif ifeq ($(CONFIG_PAGING),y) diff --git a/nuttx/sched/os_bringup.c b/nuttx/sched/os_bringup.c index d6d943137..ec6152891 100644 --- a/nuttx/sched/os_bringup.c +++ b/nuttx/sched/os_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/os_bringup.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * With extensions by: @@ -47,6 +47,7 @@ #include <debug.h> #include <nuttx/init.h> +#include <nuttx/wqueue.h> #include "os_internal.h" #ifdef CONFIG_PAGING @@ -149,10 +150,23 @@ int os_bringup(void) #ifdef CONFIG_SCHED_WORKQUEUE svdbg("Starting worker thread\n"); - g_worker = KERNEL_THREAD("work", CONFIG_SCHED_WORKPRIORITY, - CONFIG_SCHED_WORKSTACKSIZE, - (main_t)work_thread, (const char **)NULL); - ASSERT(g_worker != ERROR); + g_work[HPWORK].pid = KERNEL_THREAD("work0", CONFIG_SCHED_WORKPRIORITY, + CONFIG_SCHED_WORKSTACKSIZE, + (main_t)work_hpthread, (const char **)NULL); + ASSERT(g_work[HPWORK].pid != ERROR); + + /* Start a lower priority worker thread for other, non-critical continuation + * tasks + */ + +#ifdef CONFIG_SCHED_LPWORK + svdbg("Starting worker thread\n"); + + g_work[LPWORK].pid = KERNEL_THREAD("work1", CONFIG_SCHED_LPWORKPRIORITY, + CONFIG_SCHED_LPWORKSTACKSIZE, + (main_t)work_lpthread, (const char **)NULL); + ASSERT(g_work[LPWORK].pid != ERROR); +#endif #endif /* Once the operating system has been initialized, the system must be diff --git a/nuttx/sched/prctl.c b/nuttx/sched/prctl.c index b340d0ec8..d71a0e174 100644 --- a/nuttx/sched/prctl.c +++ b/nuttx/sched/prctl.c @@ -91,7 +91,7 @@ int prctl(int option, ...) { /* Get the prctl arguments */ - char *name = va_arg(ap, char *); + FAR char *name = va_arg(ap, FAR char *); int pid = va_arg(ap, int); FAR _TCB *tcb; diff --git a/nuttx/sched/sched_free.c b/nuttx/sched/sched_free.c index 4df77b109..e5e0bdacf 100644 --- a/nuttx/sched/sched_free.c +++ b/nuttx/sched/sched_free.c @@ -1,7 +1,7 @@ /************************************************************************ * sched/sched_free.c * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -99,7 +99,7 @@ void sched_free(FAR void *address) /* Signal the worker thread that is has some clean up to do */ #ifdef CONFIG_SCHED_WORKQUEUE - work_signal(); + work_signal(LPWORK); #endif irqrestore(saved_state); } diff --git a/nuttx/sched/task_exithook.c b/nuttx/sched/task_exithook.c index 63dc28aa0..e94476f2a 100644 --- a/nuttx/sched/task_exithook.c +++ b/nuttx/sched/task_exithook.c @@ -44,6 +44,7 @@ #include <debug.h> #include <errno.h> +#include <nuttx/sched.h> #include <nuttx/fs/fs.h> #include "os_internal.h" @@ -180,6 +181,7 @@ static inline void task_onexit(FAR _TCB *tcb, int status) tcb->onexitfunc = NULL; } #endif +} #else # define task_onexit(tcb,status) #endif diff --git a/nuttx/sched/work_cancel.c b/nuttx/sched/work_cancel.c index 30b650826..55df86f44 100644 --- a/nuttx/sched/work_cancel.c +++ b/nuttx/sched/work_cancel.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/work_cancel.c * - * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2010, 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -74,6 +74,7 @@ /**************************************************************************** * Public Functions ****************************************************************************/ + /**************************************************************************** * Name: work_cancel * @@ -83,6 +84,7 @@ * again. * * Input parameters: + * qid - The work queue ID * work - The previously queue work structure to cancel * * Returned Value: @@ -90,11 +92,12 @@ * ****************************************************************************/ -int work_cancel(struct work_s *work) +int work_cancel(int qid, FAR struct work_s *work) { + FAR struct wqueue_s *wqueue = &g_work[qid]; irqstate_t flags; - DEBUGASSERT(work != NULL); + DEBUGASSERT(work != NULL && (unsigned)qid < NWORKERS); /* Cancelling the work is simply a matter of removing the work structure * from the work queue. This must be done with interrupts disabled because @@ -106,18 +109,19 @@ int work_cancel(struct work_s *work) { /* A little test of the integrity of the work queue */ - DEBUGASSERT(work->dq.flink ||(FAR dq_entry_t *)work == g_work.tail); - DEBUGASSERT(work->dq.blink ||(FAR dq_entry_t *)work == g_work.head); + DEBUGASSERT(work->dq.flink ||(FAR dq_entry_t *)work == wqueue->q.tail); + DEBUGASSERT(work->dq.blink ||(FAR dq_entry_t *)work == wqueue->q.head); /* Remove the entry from the work queue and make sure that it is * mark as availalbe (i.e., the worker field is nullified). */ - dq_rem((FAR dq_entry_t *)work, &g_work); + dq_rem((FAR dq_entry_t *)work, &wqueue->q); work->worker = NULL; } irqrestore(flags); return OK; } + #endif /* CONFIG_SCHED_WORKQUEUE */ diff --git a/nuttx/sched/work_internal.h b/nuttx/sched/work_internal.h index 69b7bf547..7f6c1a937 100644 --- a/nuttx/sched/work_internal.h +++ b/nuttx/sched/work_internal.h @@ -51,51 +51,49 @@ /* Configuration ************************************************************/ -#ifndef CONFIG_SCHED_WORKPRIORITY -# define CONFIG_SCHED_WORKPRIORITY 50 -#endif - -#ifndef CONFIG_SCHED_WORKPERIOD -# define CONFIG_SCHED_WORKPERIOD (50*1000) /* 50 milliseconds */ -#endif - -#ifndef CONFIG_SCHED_WORKSTACKSIZE -# define CONFIG_SCHED_WORKSTACKSIZE CONFIG_IDLETHREAD_STACKSIZE -#endif - #ifdef CONFIG_DISABLE_SIGNALS # warning "Worker thread support requires signals" #endif +#ifdef CONFIG_SCHED_LPWORK +# define NWORKERS 2 +#else +# define NWORKERS 1 +#endif + /**************************************************************************** * Public Types ****************************************************************************/ #ifndef __ASSEMBLY__ +/* This structure defines the state on one work queue */ + +struct wqueue_s +{ + pid_t pid; /* The task ID of the worker thread */ + struct dq_queue_s q; /* The queue of pending work */ +}; + /**************************************************************************** * Public Data ****************************************************************************/ -/* The queue of pending work */ - -extern struct dq_queue_s g_work; +/* The state of each work queue */ -/* The task ID of the worker thread */ - -extern pid_t g_worker; +extern struct wqueue_s g_work[NWORKERS]; /**************************************************************************** * Public Function Prototypes ****************************************************************************/ /**************************************************************************** - * Name: work_thread + * Name: work_hpthread and work_lpthread * * Description: - * This is the main worker thread that performs actions placed on the work - * queue. It also performs periodic garbage collection (that is performed - * by the idle thread if CONFIG_SCHED_WORKQUEUE is not defined). + * These are the main worker threads that performs actions placed on the + * work lists. One thread also performs periodic garbage collection (that + * is performed by the idle thread if CONFIG_SCHED_WORKQUEUE is not defined). * * Input parameters: * argc, argv (not used) @@ -105,7 +103,11 @@ extern pid_t g_worker; * ****************************************************************************/ -int work_thread(int argc, char *argv[]); +int work_hpthread(int argc, char *argv[]); + +#ifdef CONFIG_SCHED_LPWORK +int work_lpthread(int argc, char *argv[]); +#endif #endif /* __ASSEMBLY__ */ #endif /* CONFIG_SCHED_WORKQUEUE */ diff --git a/nuttx/sched/work_queue.c b/nuttx/sched/work_queue.c index beeac168d..075f08a4d 100644 --- a/nuttx/sched/work_queue.c +++ b/nuttx/sched/work_queue.c @@ -76,6 +76,7 @@ /**************************************************************************** * Public Functions ****************************************************************************/ + /**************************************************************************** * Name: work_queue * @@ -91,6 +92,7 @@ * and remove it from the work queue. * * Input parameters: + * qid - The work queue ID (index) * work - The work structure to queue * worker - The worker callback to be invoked. The callback will invoked * on the worker thread of execution. @@ -104,11 +106,13 @@ * ****************************************************************************/ -int work_queue(struct work_s *work, worker_t worker, FAR void *arg, uint32_t delay) +int work_queue(int qid, FAR struct work_s *work, worker_t worker, + FAR void *arg, uint32_t delay) { + FAR struct wqueue_s *wqueue = &g_work[qid]; irqstate_t flags; - DEBUGASSERT(work != NULL); + DEBUGASSERT(work != NULL && (unsigned)qid < NWORKERS); /* First, initialize the work structure */ @@ -123,8 +127,10 @@ int work_queue(struct work_s *work, worker_t worker, FAR void *arg, uint32_t del flags = irqsave(); work->qtime = clock_systimer(); /* Time work queued */ - dq_addlast((FAR dq_entry_t *)work, &g_work); - work_signal(); /* Wake up the worker thread */ + + dq_addlast((FAR dq_entry_t *)work, &wqueue->q); + kill(wqueue->pid, SIGWORK); /* Wake up the worker thread */ + irqrestore(flags); return OK; } diff --git a/nuttx/graphics/nxsu/nx_raise.c b/nuttx/sched/work_signal.c index cf4e38b64..6e6838c69 100644 --- a/nuttx/graphics/nxsu/nx_raise.c +++ b/nuttx/sched/work_signal.c @@ -1,8 +1,8 @@ /**************************************************************************** - * graphics/nxsu/nx_raise.c + * sched/work_signal.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Copyright (C) 2009-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,26 +39,29 @@ #include <nuttx/config.h> -#include <errno.h> -#include <debug.h> +#include <signal.h> +#include <assert.h> -#include <nuttx/nx/nx.h> -#include "nxfe.h" +#include <nuttx/wqueue.h> + +#include "work_internal.h" + +#ifdef CONFIG_SCHED_WORKQUEUE /**************************************************************************** - * Pre-Processor Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** - * Private Types + * Private Type Declarations ****************************************************************************/ /**************************************************************************** - * Private Data + * Public Variables ****************************************************************************/ /**************************************************************************** - * Public Data + * Private Variables ****************************************************************************/ /**************************************************************************** @@ -68,32 +71,26 @@ /**************************************************************************** * Public Functions ****************************************************************************/ - /**************************************************************************** - * Name: nx_raise + * Name: work_signal * * Description: - * Bring the specified window to the top of the display. + * Signal the worker thread to process the work queue now. This function + * is used internally by the work logic but could also be used by the + * user to force an immediate re-assessment of pending work. * * Input parameters: - * hwnd - the window to be raised + * qid - The work queue ID * - * Returned value: - * OK on success; ERROR on failure with errno set appropriately + * Returned Value: + * Zero on success, a negated errno on failure * ****************************************************************************/ -int nx_raise(NXWINDOW hwnd) +int work_signal(int qid) { -#ifdef CONFIG_DEBUG - if (!hwnd) - { - errno = EINVAL; - return ERROR; - } -#endif - - nxbe_raise((FAR struct nxbe_window_s *)hwnd); - return OK; + DEBUGASSERT((unsigned)qid < NWORKERS); + return kill(g_work[qid].pid, SIGWORK); } +#endif /* CONFIG_SCHED_WORKQUEUE */ diff --git a/nuttx/sched/work_thread.c b/nuttx/sched/work_thread.c index fe14ae5e5..abd86f771 100644 --- a/nuttx/sched/work_thread.c +++ b/nuttx/sched/work_thread.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/work_thread.c * - * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -67,15 +67,9 @@ * Public Variables ****************************************************************************/ -/* The queue of pending work */ +/* The state of each work queue */ -struct dq_queue_s g_work; - -/* The task ID of the worker thread */ - -#ifdef CONFIG_SCHED_WORKQUEUE -pid_t g_worker; -#endif +struct wqueue_s g_work[NWORKERS]; /**************************************************************************** * Private Variables @@ -86,130 +80,177 @@ pid_t g_worker; ****************************************************************************/ /**************************************************************************** - * Public Functions - ****************************************************************************/ -/**************************************************************************** - * Name: work_thread + * Name: work_process * * Description: - * This is the main worker thread that performs actions placed on the work - * list. It also performs periodic garbage collection (that is performed - * by the idle thread if CONFIG_SCHED_WORKQUEUE is not defined). + * This is the logic that performs actions placed on any work list. * * Input parameters: - * argc, argv (not used) + * wqueue - Describes the work queue to be processed * * Returned Value: - * Does not return + * None * ****************************************************************************/ -int work_thread(int argc, char *argv[]) +static void work_process(FAR struct wqueue_s *wqueue) { volatile FAR struct work_s *work; worker_t worker; + irqstate_t flags; FAR void *arg; uint32_t elapsed; uint32_t remaining; uint32_t next; - int usec; - irqstate_t flags; - /* Loop forever */ + /* Then process queued work. We need to keep interrupts disabled while + * we process items in the work list. + */ - usec = CONFIG_SCHED_WORKPERIOD; + next = CONFIG_SCHED_WORKPERIOD / USEC_PER_TICK; flags = irqsave(); - for (;;) + work = (FAR struct work_s *)wqueue->q.head; + while (work) { - /* Wait awhile to check the work list. We will wait here until either - * the time elapses or until we are awakened by a signal. + /* Is this work ready? It is ready if there is no delay or if + * the delay has elapsed. qtime is the time that the work was added + * to the work queue. It will always be greater than or equal to + * zero. Therefore a delay of zero will always execute immediately. */ - usleep(usec); - irqrestore(flags); + elapsed = clock_systimer() - work->qtime; + if (elapsed >= work->delay) + { + /* Remove the ready-to-execute work from the list */ - /* First, perform garbage collection. This cleans-up memory de-allocations - * that were queued because they could not be freed in that execution - * context (for example, if the memory was freed from an interrupt handler). - * NOTE: If the work thread is disabled, this clean-up is performed by - * the IDLE thread (at a very, very lower priority). - */ + (void)dq_rem((struct dq_entry_s *)work, &wqueue->q); - sched_garbagecollection(); + /* Extract the work description from the entry (in case the work + * instance by the re-used after it has been de-queued). + */ - /* Then process queued work. We need to keep interrupts disabled while - * we process items in the work list. - */ + worker = work->worker; + arg = work->arg; + + /* Mark the work as no longer being queued */ + + work->worker = NULL; + + /* Do the work. Re-enable interrupts while the work is being + * performed... we don't have any idea how long that will take! + */ + + irqrestore(flags); + worker(arg); - next = CONFIG_SCHED_WORKPERIOD / USEC_PER_TICK; - flags = irqsave(); - work = (FAR struct work_s *)g_work.head; - while (work) + /* Now, unfortunately, since we re-enabled interrupts we don't + * know the state of the work list and we will have to start + * back at the head of the list. + */ + + flags = irqsave(); + work = (FAR struct work_s *)wqueue->q.head; + } + else { - /* Is this work ready? It is ready if there is no delay or if - * the delay has elapsed. qtime is the time that the work was added - * to the work queue. It will always be greater than or equal to - * zero. Therefore a delay of zero will always execute immediately. + /* This one is not ready.. will it be ready before the next + * scheduled wakeup interval? */ - elapsed = clock_systimer() - work->qtime; - if (elapsed >= work->delay) + remaining = elapsed - work->delay; + if (remaining < next) { - /* Remove the ready-to-execute work from the list */ + /* Yes.. Then schedule to wake up when the work is ready */ - (void)dq_rem((struct dq_entry_s *)work, &g_work); + next = remaining; + } + + /* Then try the next in the list. */ - /* Extract the work description from the entry (in case the work - * instance by the re-used after it has been de-queued). - */ + work = (FAR struct work_s *)work->dq.flink; + } + } - worker = work->worker; - arg = work->arg; + /* Wait awhile to check the work list. We will wait here until either + * the time elapses or until we are awakened by a signal. + */ - /* Mark the work as no longer being queued */ + usleep(next * USEC_PER_TICK); + irqrestore(flags); +} - work->worker = NULL; +/**************************************************************************** + * Public Functions + ****************************************************************************/ +/**************************************************************************** + * Name: work_hpthread and work_lpthread + * + * Description: + * These are the main worker threads that performs actions placed on the + * work lists. One thread also performs periodic garbage collection (that + * is performed by the idle thread if CONFIG_SCHED_WORKQUEUE is not defined). + * + * Input parameters: + * argc, argv (not used) + * + * Returned Value: + * Does not return + * + ****************************************************************************/ - /* Do the work. Re-enable interrupts while the work is being - * performed... we don't have any idea how long that will take! - */ +int work_hpthread(int argc, char *argv[]) +{ + /* Loop forever */ - irqrestore(flags); - worker(arg); + for (;;) + { + /* First, perform garbage collection. This cleans-up memory de-allocations + * that were queued because they could not be freed in that execution + * context (for example, if the memory was freed from an interrupt handler). + * NOTE: If the work thread is disabled, this clean-up is performed by + * the IDLE thread (at a very, very lower priority). + */ - /* Now, unfortunately, since we re-enabled interrupts we don't - * know the state of the work list and we will have to start - * back at the head of the list. - */ +#ifdef CONFIG_SCHED_LPWORK + sched_garbagecollection(); +#endif - flags = irqsave(); - work = (FAR struct work_s *)g_work.head; - } - else - { - /* This one is not ready.. will it be ready before the next - * scheduled wakeup interval? - */ + /* Then process queued work. We need to keep interrupts disabled while + * we process items in the work list. + */ + + work_process(&g_work[HPWORK]); + } - remaining = elapsed - work->delay; - if (remaining < next) - { - /* Yes.. Then schedule to wake up when the work is ready */ + return OK; /* To keep some compilers happy */ +} - next = remaining; - } - - /* Then try the next in the list. */ +#ifdef CONFIG_SCHED_LPWORK +int work_lpthread(int argc, char *argv[]) +{ + /* Loop forever */ - work = (FAR struct work_s *)work->dq.flink; - } - } + for (;;) + { + /* First, perform garbage collection. This cleans-up memory de-allocations + * that were queued because they could not be freed in that execution + * context (for example, if the memory was freed from an interrupt handler). + * NOTE: If the work thread is disabled, this clean-up is performed by + * the IDLE thread (at a very, very lower priority). + */ - /* Now calculate the microsecond delay we should wait */ + sched_garbagecollection(); - usec = next * USEC_PER_TICK; + /* Then process queued work. We need to keep interrupts disabled while + * we process items in the work list. + */ + + work_process(&g_work[LPWORK]); } return OK; /* To keep some compilers happy */ } + +#endif /* CONFIG_SCHED_LPWORK */ + #endif /* CONFIG_SCHED_WORKQUEUE */ diff --git a/nuttx/syscall/Makefile b/nuttx/syscall/Makefile index 7ef1a4629..88365759d 100644 --- a/nuttx/syscall/Makefile +++ b/nuttx/syscall/Makefile @@ -2,7 +2,7 @@ # syscall/Makefile # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/syscall/proxies/Make.defs b/nuttx/syscall/proxies/Make.defs index abd6c0102..a14e3562e 100644 --- a/nuttx/syscall/proxies/Make.defs +++ b/nuttx/syscall/proxies/Make.defs @@ -2,7 +2,7 @@ # syscall/proxies/Make.defs # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/syscall/stub_lookup.h b/nuttx/syscall/stub_lookup.h index 9b4a92814..1c749ee62 100644 --- a/nuttx/syscall/stub_lookup.h +++ b/nuttx/syscall/stub_lookup.h @@ -2,7 +2,7 @@ * syscall/stub_lookup.h * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/syscall/stubs/Make.defs b/nuttx/syscall/stubs/Make.defs index 10d10c08a..0f40052c0 100644 --- a/nuttx/syscall/stubs/Make.defs +++ b/nuttx/syscall/stubs/Make.defs @@ -2,7 +2,7 @@ # syscall/stubs/Make.defs # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/tools/README.txt b/nuttx/tools/README.txt index ae19be273..5d52eaeff 100755..100644 --- a/nuttx/tools/README.txt +++ b/nuttx/tools/README.txt @@ -17,6 +17,12 @@ configure.sh target board. See configs/README.txt or Documentation/NuttxPortingGuide.html for a description of how to configure NuttX with this script. +discover.py + + Example script for discovering devices in the local network. + It is the counter part to apps/netutils/discover + + mkconfig.c, cfgparser.c, and cfgparser.h These are Cs file that are used to build mkconfig program. The mkconfig diff --git a/nuttx/tools/configure.sh b/nuttx/tools/configure.sh index 8b4a3e486..3b68fe3f6 100755 --- a/nuttx/tools/configure.sh +++ b/nuttx/tools/configure.sh @@ -101,21 +101,38 @@ if [ ! -d "${configpath}" ]; then fi if [ ! -r "${configpath}/Make.defs" ]; then - echo "File ${configpath}/Make.defs does not exist" + echo "File \"${configpath}/Make.defs\" does not exist" exit 4 fi if [ ! -r "${configpath}/setenv.sh" ]; then - echo "File ${configpath}/setenv.sh does not exist" + echo "File \"${configpath}/setenv.sh\" does not exist" exit 5 fi if [ ! -r "${configpath}/defconfig" ]; then - echo "File ${configpath}/defconfig does not exist" + echo "File \"${configpath}/defconfig\" does not exist" exit 6 fi -# Check for the apps/ dir in the usual place if appdir was not provided +# Extract values needed from the defconfig file. We need: +# (1) The CONFIG_NUTTX_NEWCONFIG setting to know if this is a "new" style +# configuration, and +# (2) The CONFIG_APPS_DIR to see if there is a configured location for the +# application directory. + +newconfig=`grep CONFIG_NUTTX_NEWCONFIG= "${configpath}/defconfig" | cut -d'=' -f2` + +defappdir=y +if [ -z "${appdir}" ]; then + quoted=`grep "^CONFIG_APPS_DIR=" "${configpath}/defconfig" | cut -d'=' -f2` + if [ ! -z "${appdir}" ]; then + appdir=`echo ${quoted} | sed -e "s/\"//g"` + defappdir=n + fi +fi + +# Check for the apps/ directory in the usual place if appdir was not provided if [ -z "${appdir}" ]; then @@ -140,7 +157,15 @@ if [ -z "${appdir}" ]; then fi fi -# Okay... setup the configuration +# If appsdir was provided (or discovered) then make sure that the apps/ +# directory exists + +if [ ! -z "${appdir}" -a ! -d "${TOPDIR}/${appdir}" ]; then + echo "Directory \"${TOPDIR}/${appdir}\" does not exist" + exit 7 +fi + +# Okay... Everything looks good. Setup the configuration install -C "${configpath}/Make.defs" "${TOPDIR}/." || \ { echo "Failed to copy ${configpath}/Make.defs" ; exit 7 ; } @@ -150,19 +175,28 @@ chmod 755 "${TOPDIR}/setenv.sh" install -C "${configpath}/defconfig" "${TOPDIR}/.configX" || \ { echo "Failed to copy ${configpath}/defconfig" ; exit 9 ; } -# Copy option appconfig +# If we did not use the CONFIG_APPS_DIR that was in the defconfig config file, +# then append the correct application information to the tail of the .config +# file -if [ ! -z "${appdir}" ]; then +if [ "X${defappdir}" = "Xy" ]; then + sed -i -e "/^CONFIG_APPS_DIR/d" "${TOPDIR}/.configX" + echo "" >> "${TOPDIR}/.configX" + echo "# Application configuration" >> "${TOPDIR}/.configX" + echo "" >> "${TOPDIR}/.configX" + echo "CONFIG_APPS_DIR=\"$appdir\"" >> "${TOPDIR}/.configX" +fi + +# Copy appconfig file. The appconfig file will be copied to ${appdir}/.config +# if both (1) ${appdir} is defined and (2) we are not using the new configuration +# (which does not require a .config file in the appsdir. + +if [ ! -z "${appdir}" -a "X${newconfig}" != "Xy" ]; then if [ ! -r "${configpath}/appconfig" ]; then echo "NOTE: No readable appconfig file found in ${configpath}" else install -C "${configpath}/appconfig" "${TOPDIR}/${appdir}/.config" || \ { echo "Failed to copy ${configpath}/appconfig" ; exit 10 ; } - - echo "" >> "${TOPDIR}/.configX" - echo "# Application configuration" >> "${TOPDIR}/.configX" - echo "" >> "${TOPDIR}/.configX" - echo "CONFIG_APPS_DIR=\"$appdir\"" >> "${TOPDIR}/.configX" fi fi diff --git a/nuttx/tools/csvparser.c b/nuttx/tools/csvparser.c index 739e5e1f8..3f1916e2b 100644 --- a/nuttx/tools/csvparser.c +++ b/nuttx/tools/csvparser.c @@ -67,17 +67,27 @@ int g_lineno; * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: skip_space + ****************************************************************************/ + static char *skip_space(char *ptr) { while (*ptr && isspace((int)*ptr)) ptr++; return ptr; } +/**************************************************************************** + * Name: copy_parm + ****************************************************************************/ + static char *copy_parm(char *src, char *dest) { char *start = src; int i; + /* De-quote the parameter and copy it into the parameter array */ + for (i = 0; i < MAX_PARMSIZE; i++) { if (*src == '"') @@ -100,6 +110,10 @@ static char *copy_parm(char *src, char *dest) exit(3); } +/**************************************************************************** + * Name: find_parm + ****************************************************************************/ + static char *find_parm(char *ptr) { char *start = ptr; @@ -138,6 +152,10 @@ static char *find_parm(char *ptr) * Public Functions ****************************************************************************/ +/**************************************************************************** + * Name: read_line + ****************************************************************************/ + char *read_line(FILE *stream) { char *ptr; @@ -166,6 +184,10 @@ char *read_line(FILE *stream) } } +/**************************************************************************** + * Name: parse_csvline + ****************************************************************************/ + int parse_csvline(char *ptr) { int nparms; @@ -185,6 +207,10 @@ int parse_csvline(char *ptr) ptr++; nparms = 0; + /* Copy each comma-separated value in an array (stripping quotes from each + * of the values). + */ + do { ptr = copy_parm(ptr, &g_parm[nparms][0]); @@ -193,6 +219,8 @@ int parse_csvline(char *ptr) } while (ptr); + /* If debug is enabled, show what we got */ + if (g_debug) { printf("Parameters: %d\n", nparms); @@ -201,5 +229,6 @@ int parse_csvline(char *ptr) printf(" Parm%d: \"%s\"\n", i+1, g_parm[i]); } } + return nparms; } diff --git a/nuttx/tools/discover.py b/nuttx/tools/discover.py new file mode 100755 index 000000000..cc82a0cad --- /dev/null +++ b/nuttx/tools/discover.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +############################################################################ +# tools/discover.py +# +# Copyright (C) 2012 Max Holtzberg. All rights reserved. +# Author: Max Holtzberg <mh@uvc.de> +# +# 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. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS 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. +# +############################################################################ + +import array +import time +from socket import * + +PORT = 96 + +DISCOVER_PROTO_ID = 0x99 +DISCOVER_ALL = 0xff # 0xff means all devices +DISCOVER_REQUEST = 0x01 +DISCOVER_RESPONSE = 0x02 +DISCOVER_REQUEST_SIZE = 4 +DISCOVER_RESPONSE_SIZE = 35 + +def check_sum(data): + chksum = 0 + for c in data[:-1]: + chksum -= c + return (chksum & 0xff) == data[-1] + +def send_discover(socket): + cmd = array.array('B', [0] * DISCOVER_REQUEST_SIZE) + cmd[0] = DISCOVER_PROTO_ID # Tag for identification of the protocol + cmd[1] = DISCOVER_REQUEST # Request command + cmd[2] = DISCOVER_ALL + chksum = 0 + for c in cmd[:3]: + chksum -= c; + cmd[3] = chksum & 0xff + + socket.sendto(cmd, ('<broadcast>', PORT)) + +def read_responses(socket): + res = [] + response = array.array('B', [0] * DISCOVER_RESPONSE_SIZE) + try: + while 1: + size, src = socket.recvfrom_into(response) + if (size == DISCOVER_RESPONSE_SIZE + and response[0] == DISCOVER_PROTO_ID + and response[1] == DISCOVER_RESPONSE + and check_sum(response)): + + dev = {} + dev['addr'] = src[0] + dev['descr'] = response[2:-1].tostring().rstrip('\0') + res.append(dev) + + except timeout: + return res + +if __name__ == '__main__': + print 'Sending discover...' + + s = socket(AF_INET, SOCK_DGRAM) + s.bind(('0.0.0.0', PORT)) + s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) + s.settimeout(1.0); + send_discover(s) + devices = read_responses(s) + socket.close(s) + + print devices diff --git a/nuttx/tools/unlink.sh b/nuttx/tools/unlink.sh index 47079f085..485db3691 100755 --- a/nuttx/tools/unlink.sh +++ b/nuttx/tools/unlink.sh @@ -3,7 +3,7 @@ # tools/unlink.sh # # Copyright (C) 2008 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/tools/version.sh b/nuttx/tools/version.sh index 7cad7ee03..d15adb186 100755 --- a/nuttx/tools/version.sh +++ b/nuttx/tools/version.sh @@ -2,7 +2,7 @@ # version.sh # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/tools/winlink.sh b/nuttx/tools/winlink.sh index c081cee35..f79eda2bd 100755 --- a/nuttx/tools/winlink.sh +++ b/nuttx/tools/winlink.sh @@ -3,7 +3,7 @@ # tools/winlink.sh # # Copyright (C) 2008 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/nuttx/tools/xmlrpc_test.py b/nuttx/tools/xmlrpc_test.py new file mode 100644 index 000000000..64cc89dc9 --- /dev/null +++ b/nuttx/tools/xmlrpc_test.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +############################################################################ +# tools/xmlrpc_test.py +# +# Copyright (C) 2012 Max Holtzberg. All rights reserved. +# Author: Max Holtzberg <mh@uvc.de> +# +# 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. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS 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. +# +############################################################################ + +import sys +import xmlrpclib + +if __name__ == '__main__': + if len(sys.argv) != 2: + print 'Usage: %s <ip address>' % sys.argv[0] + quit(1) + + server_url = 'http://%s/device' % sys.argv[1] + server = xmlrpclib.ServerProxy(server_url) + result = server.get_device_stats("username", "password", 0) + print result diff --git a/nuttx/tools/zipme.sh b/nuttx/tools/zipme.sh index a10beaaab..a8cd160ab 100755 --- a/nuttx/tools/zipme.sh +++ b/nuttx/tools/zipme.sh @@ -2,7 +2,7 @@ # zipme.sh # # Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions |