diff --git a/Documentation/introduction/detailed_support.rst b/Documentation/introduction/detailed_support.rst index 31553d1349..e297e7325e 100644 --- a/Documentation/introduction/detailed_support.rst +++ b/Documentation/introduction/detailed_support.rst @@ -2197,6 +2197,24 @@ Refer to the EK-TM4C1294XL board `README `__ file for more detailed information about this port. +TI/Tiva TM4C129E +---------------- + +This port uses the TI Tiva C Series TM4C129E Crypto Connected +LaunchPad `(EK-TM4C129EXL) `__. + +**STATUS:** + +- Support for the EK-TM4C129EXL is based on support for the similar + EK-TM4C1294XL. This basic board support includes a configuration + for the NuttShell :ref:`NSH `), a configuration for testing + IPv6, and a configuration for testing the RTOS using the ostest + example in the NuttX apps repository. + +Refer to the EK-TM4C129EXL board +`README `__ +file for more detailed information about this port. + TI/Tiva TM4C129X ---------------- diff --git a/Documentation/introduction/supported_platforms.rst b/Documentation/introduction/supported_platforms.rst index 92e219c749..5433d13d56 100644 --- a/Documentation/introduction/supported_platforms.rst +++ b/Documentation/introduction/supported_platforms.rst @@ -268,6 +268,7 @@ MCU. Follow the links for the details: - :ref:`introduction/detailed_support:TI/Stellaris LM4F120x` (ARM Cortex-M4) - :ref:`introduction/detailed_support:TI/Tiva TM4C123G` (ARM Cortex-M4) - :ref:`introduction/detailed_support:TI/Tiva TM4C1294` (ARM Cortex-M4) + - :ref:`introduction/detailed_support:TI/Tiva TM4C129E` (ARM Cortex-M4) - :ref:`introduction/detailed_support:TI/Tiva TM4C129X` (ARM Cortex-M4) - :ref:`introduction/detailed_support:TI/SimpleLink CC13x2` (ARM Cortex-M4) - :ref:`introduction/detailed_support:TI/Hercules TMS570LS04xx` (ARM Cortex-R4) diff --git a/boards/Kconfig b/boards/Kconfig index 3cecc628b6..2805aa19d6 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -2316,6 +2316,16 @@ config ARCH_BOARD_TM4C1294_LAUNCHPAD ---help--- Tiva EK-TM4C1294XL LaunchPad. +config ARCH_BOARD_TM4C129E_LAUNCHPAD + bool "Tiva EK-TM4C129EXL Crypto Connected LaunchPad" + depends on ARCH_CHIP_TM4C129ENCPDT + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS + ---help--- + Tiva EK-TM4C129EXL Crypto Connected LaunchPad featuring the + TM4C129ENCPDT chip. + config ARCH_BOARD_TMS570LS31X_USB_KIT bool "TI TMS570LS31X_USB_KIT" depends on ARCH_CHIP_TMS570LS3137ZWT @@ -2808,6 +2818,7 @@ config ARCH_BOARD default "teensy-lc" if ARCH_BOARD_TEENSY_LC default "tm4c123g-launchpad" if ARCH_BOARD_TM4C123G_LAUNCHPAD default "tm4c1294-launchpad" if ARCH_BOARD_TM4C1294_LAUNCHPAD + default "tm4c129e-launchpad" if ARCH_BOARD_TM4C129E_LAUNCHPAD default "tms570ls31x-usb-kit" if ARCH_BOARD_TMS570LS31X_USB_KIT default "ttgo_lora_esp32" if ARCH_BOARD_TTGO_LORA_ESP32 default "ttgo_t_display_esp32" if ARCH_BOARD_TTGO_T_DISPLAY_ESP32 @@ -3440,6 +3451,9 @@ endif if ARCH_BOARD_TM4C1294_LAUNCHPAD source "boards/arm/tiva/tm4c1294-launchpad/Kconfig" endif +if ARCH_BOARD_TM4C129E_LAUNCHPAD +source "boards/arm/tiva/tm4c129e-launchpad/Kconfig" +endif if ARCH_BOARD_LAUNCHXL_TMS57004 source "boards/arm/tms570/launchxl-tms57004/Kconfig" endif diff --git a/boards/README.txt b/boards/README.txt index 074dae74d7..df0b86233e 100644 --- a/boards/README.txt +++ b/boards/README.txt @@ -860,6 +860,11 @@ boards/arm/tiva/tm4c1294-launchpad platform for ARM Cortex-M4F-based microcontrollers from Texas Instruments. +boards/arm/tiva/tm4c129e-launchpad + This is a port of NuttX to the Tiva TM4C129E Crypto Connected LaunchPad. This + board is a low-cost evaluation platform for ARM Cortex-M4F-based + microcontrollers from Texas Instruments. + boards/arm/tmx570/tms570ls31x-usb-kit TI Hercules TMS570LS31xx Evaluation Kit (TMDS570ls31xx USB Kit) featuring the Hercules TMS570LS3137ZWT chip. diff --git a/boards/arm/tiva/tm4c129e-launchpad/Kconfig b/boards/arm/tiva/tm4c129e-launchpad/Kconfig new file mode 100644 index 0000000000..5a026560db --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/Kconfig @@ -0,0 +1,75 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_TM4C129E_LAUNCHPAD +if TIMER && TIVA_TIMER32_PERIODIC + +config TM4C129E_LAUNCHPAD_TIMER + bool + default n + +choice + prompt "Timer driver selection" + default TM4C129E_LAUNCHPAD_TIMER_NONE + +config TM4C129E_LAUNCHPAD_TIMER_NONE + bool "None" + +config TM4C129E_LAUNCHPAD_TIMER0 + bool "Timer 0" + depends on TIVA_TIMER0 + select TM4C129E_LAUNCHPAD_TIMER + +config TM4C129E_LAUNCHPAD_TIMER1 + bool "Timer 1" + depends on TIVA_TIMER1 + select TM4C129E_LAUNCHPAD_TIMER + +config TM4C129E_LAUNCHPAD_TIMER2 + bool "Timer 2" + depends on TIVA_TIMER2 + select TM4C129E_LAUNCHPAD_TIMER + +config TM4C129E_LAUNCHPAD_TIMER3 + bool "Timer 3" + depends on TIVA_TIMER3 + select TM4C129E_LAUNCHPAD_TIMER + +config TM4C129E_LAUNCHPAD_TIMER4 + bool "Timer 4" + depends on TIVA_TIMER4 + select TM4C129E_LAUNCHPAD_TIMER + +config TM4C129E_LAUNCHPAD_TIMER5 + bool "Timer 5" + depends on TIVA_TIMER5 + select TM4C129E_LAUNCHPAD_TIMER + +config TM4C129E_LAUNCHPAD_TIMER6 + bool "Timer 6" + depends on TIVA_TIMER6 + select TM4C129E_LAUNCHPAD_TIMER + +config TM4C129E_LAUNCHPAD_TIMER7 + bool "Timer 7" + depends on TIVA_TIMER7 + select TM4C129E_LAUNCHPAD_TIMER + +endchoice # Timer driver selection + +if TM4C129E_LAUNCHPAD_TIMER + +config TM4C129E_LAUNCHPAD_TIMER_DEVNAME + string "Timer device name" + default "/dev/timer0" + +config TM4C129E_LAUNCHPAD_TIMER_ALTCLK + bool "Use alternate clock source" + default n + depends on EXPERIMENTAL + +endif # TM4C129E_LAUNCHPAD_TIMER +endif # TIVA_TIMER32_PERIODIC +endif # ARCH_BOARD_TM4C129E_LAUNCHPAD diff --git a/boards/arm/tiva/tm4c129e-launchpad/README.txt b/boards/arm/tiva/tm4c129e-launchpad/README.txt new file mode 100644 index 0000000000..dfd5747db5 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/README.txt @@ -0,0 +1,226 @@ +README +====== + + This is the README file for a port of NuttX to the TM4C129E Crypto Connected + LaunchPad (more correctly, the EK-TM4C129EXL). For more information about this + board, see https://www.ti.com/tool/EK-TM4C129EXL. + +EK-TM4C1294XL and DK-TM4C129X +============================= + + This board configuration derives from the EK-TM4C1294XL, which in turn derives + from the DK-T4C129X. Refer to the following README files for additional + information that may be relevant to this board as well: + + boards/arm/tiva/tm4c1294-launchpad/README.txt + boards/arm/tiva/dk-tm4c129x/README.txt + +Directory Structure +=================== + +Layout for board support package directories: +$TOPDIR/boards/ - Directory containing BSP subdirectories + arch - CPU architecture (e.g., arm) + chip - Chip type (e.g., tiva) + +Within chip subdirectory: + - Subdirectory for each board (e.g., LaunchPad129) + drivers - Board-specific drivers + include - Board-specific headers + scripts - Board-specific build scripts (e.g., linker, Make.defs) + src - Board-specific code + tools - Board-specific tools or scripts (e.g., OpenOCD startup) + configs/ - Subdirectory for one or more board configuration(s) + - Configuration for use with tools/configure.sh or .bat + +Serial Console +============== + + These configurations use UART0 for the serial console. UART0 is connected to + the on-board TM4C123G-based debugger and is forwarded through the ICDI virtual + UART. + +Buttons and LEDs +================ + + Buttons + ------- + + The board has two on-board pushbuttons accessible to software. These are + connected to GPIO pins PJ0 and PJ1. + + In addition, the board also has a Reset switch and a Wake switch. The Reset + switch asserts the reset signal to the microcontroller, the Breadboard + headers, and the BoosterPack headers and, therefore, any attached + BoosterPack boards. The Wake switch is provided as one of the means to wake + the microcontroller from hibernate mode. + + LEDs + ---- + + The board has four LEDs which are accessible to software. LEDs D1 and D2 are + connected to GPIOs PN1 and PN0 and are dedicated for software use. LEDs D3 + and D4 are connected to GPIOs PF4 and PF0 and can be controlled either by + software or by the integrated Ethernet PHY of the TM4C129ENCPDT. + +Configurations +============== + +Each EK-TM4C129EXL configuration is maintained in a sub-directory and can be +selected as follow: + + tools/configure.sh tm4c129e-launchpad: + +Where is one of the following: + + nsh: + --- + Configures the NuttShell (nsh) located at apps/examples/nsh. The + configuration enables the serial ICDI virtual UART on UART0. Support for + builtin applications is enabled, but in the base configuration no builtin + applications are selected. + + NOTES: + + 1. This configuration uses the mconf-based configuration tool. To change + this configuration using that tool, you should: + + a. Build and install the kconfig-mconf tool. See nuttx/README.txt see + additional README.txt files in the NuttX tools repository. + + b. Execute 'make menuconfig' in nuttx/ in order to start the + reconfiguration process. + + 2. By default, this configuration uses the GNU ARM EABI toolchain + (Linaro) such as the one delivered with TI's Code Composer + Studio (CCS) and builds under Linux. (Cygwin / MSYS / MSYS2 under + Windows might work as well.) These options can be reconfigured + with 'make menuconfig' as described above. + + CONFIG_HOST_LINUX=y : Linux (Cygwin under Windows okay too). + CONFIG_ARCH_TOOLCHAIN_GNU=y : GNU toolchain (arm-none-eabi-gcc) + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y + CONFIG_RAW_BINARY=y : Output formats: ELF and raw binary + + 3. Default stack sizes are large and should really be tuned to reduce the + RAM footprint: + + CONFIG_SCHED_HPWORKSTACKSIZE=2048 + CONFIG_IDLETHREAD_STACKSIZE=1024 + CONFIG_INIT_STACKSIZE=2048 + CONFIG_PTHREAD_STACK_DEFAULT=2048 + CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024 + CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048 + CONFIG_BUILTIN_PROXY_STACKSIZE=1024 + CONFIG_NSH_TELNETD_DAEMONSTACKSIZE=2048 + CONFIG_NSH_TELNETD_CLIENTSTACKSIZE=2048 + + 4. This configuration has the network enabled by default. See the paragraph + "Using the network with NSH" in the DK-TM4C129X README). + + Networking can easily be disabled or reconfigured with 'make menuconfig' + if desired. + + By default: + + This configuration assumes a DHCP network. + + The network initialization thread is enabled. NSH will create + a separate thread when it starts to initialize the network. + This eliminates start-up delays to bring up the network. + + The persistent network monitor thread is enabled. It monitors + changes in link status, takes the network down when the link is + lost (e.g., cable disconnected), abd brings the network back up + when the link becomes available again (e.g., cable connected). + + The Ethernet MAC address is factory-programmed into the non-volatile + USER0 and USER1 registers. If CONFIG_TIVA_BOARDMAC is defined, the + function tiva_ethernetmac() will obtain the MAC address from these + registers and use it. + + ipv6: + ---- + This is another version of the NuttShell configuration. It is very similar + to the nsh configuration except that it has IPv6 enabled and IPv4 disabled. + Several network utilities that are not yet available under IPv6 are + disabled. + + NOTES: + + 1. As of 2022-09-06, this configuration was identical to the nsh + configuration other than using IPv6. So all of the notes above regarding + the nsh configuration apply. + + Telnet does work with IPv6 but is not enabled in this configuration (but + could be). + + 2. This configuration can be modified so that both IPv4 and IPv6 are + supported. Here is a summary of the additional configuration settings + required to support both IPv4 and IPv6: + + CONFIG_NET_IPv4=y + CONFIG_NET_ARP=y + CONFIG_NET_ARP_SEND=y (optional) + CONFIG_NET_ICMP=y + CONFIG_NET_ICMP_SOCKET=y + + CONFIG_NETDB_DNSCLIENT=y + CONFIG_NETUTILS_TELNETD=y + + CONFIG_NSH_IPADDR=0x0a000002 + CONFIG_NSH_DRIPADDR=0x0a000001 + CONFIG_NSH_NETMASK=0xffffff00 + CONFIG_NSH_TELNET=y + + Then from NSH, you have both ping and ping6 commands: + + nsh> ping 10.0.0.1 + nsh> ping6 fc00::1 + + And from the host you can do similar: + + ping 10.0.0.2 + ping6 fc00::2 (Linux) + ping -6 fc00::2 (Windows cmd) + + and Telnet is now enabled and works from the host... but only using IPv6 + addressing: + + telnet fc00::2 + + That is because the Telnet daemon will default to IPv6 and there is no + Telnet option to let you select which if both IPv4 and IPv6 are enabled. + + 3. You can enable IPv6 autonomous address configuration with the following + changes to the configuration: + + + CONFIG_NET_ICMPv6_AUTOCONF=y + + CONFIG_ICMPv6_AUTOCONF_DELAYMSEC=100 + + CONFIG_ICMPv6_AUTOCONF_MAXTRIES=5 + + - CONFIG_NSH_DRIPv6ADDR_1=0xfc00 + - CONFIG_NSH_DRIPv6ADDR_2=0x0000 + - CONFIG_NSH_DRIPv6ADDR_3=0x0000 + - CONFIG_NSH_DRIPv6ADDR_4=0x0000 + - CONFIG_NSH_DRIPv6ADDR_5=0x0000 + - CONFIG_NSH_DRIPv6ADDR_6=0x0000 + - CONFIG_NSH_DRIPv6ADDR_7=0x0000 + - CONFIG_NSH_DRIPv6ADDR_8=0x0001 + + - CONFIG_NSH_IPv6ADDR_1=0xfc00 + - CONFIG_NSH_IPv6ADDR_2=0x0000 + - CONFIG_NSH_IPv6ADDR_3=0x0000 + - CONFIG_NSH_IPv6ADDR_4=0x0000 + - CONFIG_NSH_IPv6ADDR_5=0x0000 + - CONFIG_NSH_IPv6ADDR_6=0x0000 + - CONFIG_NSH_IPv6ADDR_7=0x0000 + - CONFIG_NSH_IPv6ADDR_8=0x0002 + - CONFIG_NSH_IPv6NETMASK_1=0xffff + - CONFIG_NSH_IPv6NETMASK_2=0xffff + - CONFIG_NSH_IPv6NETMASK_3=0xffff + - CONFIG_NSH_IPv6NETMASK_4=0xffff + - CONFIG_NSH_IPv6NETMASK_5=0xffff + - CONFIG_NSH_IPv6NETMASK_6=0xffff + - CONFIG_NSH_IPv6NETMASK_7=0xffff + - CONFIG_NSH_IPv6NETMASK_8=0xff80 diff --git a/boards/arm/tiva/tm4c129e-launchpad/configs/ipv6/defconfig b/boards/arm/tiva/tm4c129e-launchpad/configs/ipv6/defconfig new file mode 100644 index 0000000000..44fb84d920 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/configs/ipv6/defconfig @@ -0,0 +1,63 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_FPU is not set +# CONFIG_NET_IPv4 is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="tm4c129e-launchpad" +CONFIG_ARCH_BOARD_TM4C129E_LAUNCHPAD=y +CONFIG_ARCH_CHIP="tiva" +CONFIG_ARCH_CHIP_TIVA=y +CONFIG_ARCH_CHIP_TM4C129=y +CONFIG_ARCH_CHIP_TM4C129ENCPDT=y +CONFIG_ARCH_CHIP_TM4C=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=11401 +CONFIG_BUILTIN=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_LIBC_FLOATINGPOINT=y +CONFIG_LIBM=y +CONFIG_NET=y +CONFIG_NETINIT_IPv6NETMASK_4=0x0000 +CONFIG_NETINIT_IPv6NETMASK_8=0xff80 +CONFIG_NETINIT_MONITOR=y +CONFIG_NETINIT_THREAD=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ICMPv6=y +CONFIG_NET_ICMPv6_SOCKET=y +CONFIG_NET_IPv6=y +CONFIG_NET_SOCKOPTS=y +CONFIG_NET_STATISTICS=y +CONFIG_NET_TCP=y +CONFIG_NET_TCPBACKLOG=y +CONFIG_NET_TCP_NOTIFIER=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_UDP=y +CONFIG_NET_UDP_NOTIFIER=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=262144 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_YEAR=2015 +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_PING6=y +CONFIG_TIVA_BOARDMAC=y +CONFIG_TIVA_ETHERNET=y +CONFIG_TIVA_PHY_INTERRUPTS=y +CONFIG_TIVA_UART0=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/tiva/tm4c129e-launchpad/configs/nsh/defconfig b/boards/arm/tiva/tm4c129e-launchpad/configs/nsh/defconfig new file mode 100644 index 0000000000..733f2a65d2 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/configs/nsh/defconfig @@ -0,0 +1,69 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_FPU is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="tm4c129e-launchpad" +CONFIG_ARCH_BOARD_TM4C129E_LAUNCHPAD=y +CONFIG_ARCH_CHIP="tiva" +CONFIG_ARCH_CHIP_TIVA=y +CONFIG_ARCH_CHIP_TM4C129=y +CONFIG_ARCH_CHIP_TM4C129ENCPDT=y +CONFIG_ARCH_CHIP_TM4C=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=11401 +CONFIG_BUILTIN=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_LIBC_FLOATINGPOINT=y +CONFIG_LIBM=y +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSSERVER_NOADDR=y +CONFIG_NETINIT_DHCPC=y +CONFIG_NETINIT_DRIPADDR=0xc0a80a01 +CONFIG_NETINIT_MONITOR=y +CONFIG_NETINIT_THREAD=y +CONFIG_NETUTILS_DHCPC=y +CONFIG_NETUTILS_TELNETD=y +CONFIG_NETUTILS_TFTPC=y +CONFIG_NETUTILS_WEBCLIENT=y +CONFIG_NET_ARP_IPIN=y +CONFIG_NET_ARP_SEND=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_PKTSIZE=1518 +CONFIG_NET_ICMP=y +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_STATISTICS=y +CONFIG_NET_TCP=y +CONFIG_NET_TCPBACKLOG=y +CONFIG_NET_TCP_NOTIFIER=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_UDP=y +CONFIG_NET_UDP_NOTIFIER=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=262144 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_YEAR=2015 +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_PING=y +CONFIG_TIVA_BOARDMAC=y +CONFIG_TIVA_ETHERNET=y +CONFIG_TIVA_PHY_INTERRUPTS=y +CONFIG_TIVA_UART0=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/tiva/tm4c129e-launchpad/configs/ostest/defconfig b/boards/arm/tiva/tm4c129e-launchpad/configs/ostest/defconfig new file mode 100644 index 0000000000..f8f4a4ad8d --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/configs/ostest/defconfig @@ -0,0 +1,78 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_FPU is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="tm4c129e-launchpad" +CONFIG_ARCH_BOARD_TM4C129E_LAUNCHPAD=y +CONFIG_ARCH_CHIP="tiva" +CONFIG_ARCH_CHIP_TIVA=y +CONFIG_ARCH_CHIP_TM4C129=y +CONFIG_ARCH_CHIP_TM4C129ENCPDT=y +CONFIG_ARCH_CHIP_TM4C=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=11401 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_ERROR=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEBUG_WARN=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_LIBC_FLOATINGPOINT=y +CONFIG_LIBM=y +CONFIG_NDEBUG=y +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSSERVER_NOADDR=y +CONFIG_NETINIT_DHCPC=y +CONFIG_NETINIT_DRIPADDR=0xc0a80a01 +CONFIG_NETINIT_MONITOR=y +CONFIG_NETINIT_THREAD=y +CONFIG_NETUTILS_DHCPC=y +CONFIG_NETUTILS_TELNETD=y +CONFIG_NETUTILS_TFTPC=y +CONFIG_NETUTILS_WEBCLIENT=y +CONFIG_NET_ARP_IPIN=y +CONFIG_NET_ARP_SEND=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_PKTSIZE=1518 +CONFIG_NET_ICMP=y +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_STATISTICS=y +CONFIG_NET_TCP=y +CONFIG_NET_TCPBACKLOG=y +CONFIG_NET_TCP_NOTIFIER=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_UDP=y +CONFIG_NET_UDP_NOTIFIER=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=262144 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_STACK_CANARIES=y +CONFIG_STACK_COLORATION=y +CONFIG_START_YEAR=2015 +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_PING=y +CONFIG_TESTING_OSTEST=y +CONFIG_TIVA_BOARDMAC=y +CONFIG_TIVA_ETHERNET=y +CONFIG_TIVA_PHY_INTERRUPTS=y +CONFIG_TIVA_UART0=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/tiva/tm4c129e-launchpad/include/board.h b/boards/arm/tiva/tm4c129e-launchpad/include/board.h new file mode 100644 index 0000000000..7194103cc0 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/include/board.h @@ -0,0 +1,208 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/include/board.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_TIVA_TM4C129E_LAUNCHPAD_INCLUDE_BOARD_H +#define __BOARDS_ARM_TIVA_TM4C129E_LAUNCHPAD_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#ifndef __ASSEMBLY__ +# include +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +/* Crystals on-board the EK-TM4C129EXL include: + * + * 1. 25.0MHz (Y2) is connected to OSC0/1 pins and is used as the run mode + * input to the PLL. + * 2. 32.768kHz (Y3) connected to XOSC0/1 and clocks the hibernation module. + */ + +#define SYSCON_RCC_XTAL SYSCON_RCC_XTAL16000KHZ /* On-board crystal is 25 MHz */ +#define XTAL_FREQUENCY 25000000 + +/* Frequencies of other clock sources */ + +#define PIOSC_FREQUENCY 16000000 /* Precision internal oscillator */ +#define RTCOSC_FREQUENCY 32768 /* Hibernation module RTC oscillator */ +#define LFIOSC_FREQUENCY 33000 /* Low frequency internal oscillator */ + +/* The PLL generates Fvco according to the following formulae. + * The input clock to the PLL may be either the external crystal (Fxtal) + * or PIOSC (Fpiosc). + * This logic supports only the external crystal as the PLL source clock. + * + * Fin = Fxtal / (Q + 1 )(N + 1) -OR- Fpiosc / (Q + 1)(N + 1) + * Mdiv = Mint + (MFrac / 1024) + * Fvco = Fin * Mdiv + * + * Where the register fields Q and N actually hold (Q-1) and (N-1). + * The following setup then generates Fvco = 480MHz: + * + * Fin = 25 MHz / 1 / 5 = 5 MHz + * Mdiv = 96 + * Fvco = 480 + */ + +#define BOARD_PLL_MINT 96 /* Integer part of PLL M value */ +#define BOARD_PLL_MFRAC 0 /* Fractional part of PLL M value */ +#define BOARD_PLL_N 5 /* PLL N value */ +#define BOARD_PLL_Q 1 /* PLL Q value */ + +#define BOARD_FVCO_FREQUENCY 480000000 /* Resulting Fvco */ + +/* When the PLL is active, the system clock frequency (SysClk) is calculated + * using the following equation: + * + * SysClk = Fvco/ (sysdiv + 1) + * + * The following setup generates Sysclk = 120MHz: + */ + +#define BOARD_PLL_SYSDIV 4 /* Sysclk = Fvco / 4 = 120MHz */ +#define SYSCLK_FREQUENCY 120000000 /* Resulting SysClk frequency */ + +/* Peripheral Clock (PCLK) + * + * Same frequency as the SYSCLK + */ + +#define PCLK_FREQUENCY SYSCLK_FREQUENCY + +/* Alternate Clock (ALTCLK) + * + * The ALTCLK provides a clock source of numerous frequencies to the + * general-purpose timer, SSI, and UART modules. + * The default source for the ALTCLK is the Precision + * Internal Oscillator (PIOSC). + * The Hibernation Real-time Clock (RTCOSC) and Low + * Frequency Internal Oscillator (LFIOSC) are alternatives. + * If the RTCOSC Output is selected, the clock source must also be enabled + * in the Hibernation module. + */ + +#define BOARD_ALTCLKCFG SYSCON_ALTCLKCFG_ALTCLK_PIOSC +#define ALTCLK_FREQUENCY PIOSC_FREQUENCY + +/* LED definitions **********************************************************/ + +/* The EK-TM4C129EXL has 5 green LEDs. + * LED D0 is lit when 3.3V power supply is available . + * LEDs D1 and D2 are general purpose LEDs. + * LEDs D3 and D4 can be used for Ethernet link and activity. + * + * --- ------------ + * Pin Pin Function + * --- ------------ + * PN1 green LED D1 + * PN0 green LED D2 + * PF4 green LED D3 + * PF0 green LED D4 + * --- ------------ + */ + +/* LED index values for use with board_userled() */ + +#define BOARD_LED_D1 0 +#define BOARD_LED_D2 1 +#define BOARD_LED_D3 2 +#define BOARD_LED_D4 3 +#define BOARD_NLEDS 4 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED_D1_BIT (1 << BOARD_LED_D1) +#define BOARD_LED_D2_BIT (1 << BOARD_LED_D2) +#define BOARD_LED_D3_BIT (1 << BOARD_LED_D3) +#define BOARD_LED_D4_BIT (1 << BOARD_LED_D4) + +/* If CONFIG_ARCH_LEDS is defined, + * then automated support for the EK-TM4C129EXL LED + * will be included in the build: + * LED1 LED2 LED3 LED4 + */ + +#define LED_STARTED 1 /* ON OFF NC NC */ +#define LED_HEAPALLOCATE 0 /* NC NC NC NC */ +#define LED_IRQSENABLED 0 /* NC NC NC NC */ +#define LED_STACKCREATED 2 /* ON ON NC NC */ +#define LED_INIRQ 0 /* NC NC NC NC */ +#define LED_SIGNAL 0 /* NC NC NC NC */ +#define LED_ASSERTION 0 /* NC NC NC NC */ +#define LED_PANIC 3 /* OFF ON NC NC (flashing 2Hz) */ + +/* Button definitions *******************************************************/ + +/* There are four push buttons on the board. + * Two of them are user controllable. + * The others are RESET and WAKE + * + * --- ------------ + * Pin Pin Function + * --- ------------ + * PJ0 USR_SW1 + * PJ1 USR_SW2 + * --- ------------ + */ + +#define BUTTON_SW1 0 +#define BUTTON_SW2 1 +#define NUM_BUTTONS 2 + +#define BUTTON_SW1_BIT (1 << BUTTON_SW1) +#define BUTTON_SW2_BIT (1 << BUTTON_SW2) + +/* Pin Multiplexing Disambiguation ******************************************/ + +/* Ethernet LEDs + * + * PF0/PF4/PF1 are used for Ethernet LEDs. + * PF0/EN0LED0/LED4 Ethernet link OK + * PF4/EN0LED1/LED3 Ethernet TX/RX activity + * PF1/EN0LED2 Ethernet 100-base TX + */ + +#define GPIO_EN0_LED0 GPIO_EN0_LED0_1 +#define GPIO_EN0_LED1 GPIO_EN0_LED1_1 +#define GPIO_EN0_LED2 GPIO_EN0_LED2_1 + +/* Control pins for BOOST-CC2564MODA plugged into BoosterPack1 + * + * --- ------------ + * Pin Pin Function + * --- ------------ + * PM3 NSHUTD + * PG0 RTS + * PL4 CTS + * --- ------------ + */ + +#define UART7_GPIO_NSHUTD (GPIO_FUNC_OUTPUT | GPIO_PORTM | GPIO_PIN_3) +#define UART7_GPIO_RTS (GPIO_FUNC_OUTPUT | GPIO_PORTG | GPIO_PIN_0) +#define UART7_GPIO_CTS (GPIO_FUNC_INPUT | GPIO_PORTL | GPIO_PIN_4) + +#endif /* __BOARDS_ARM_TIVA_TM4C129E_LAUNCHPAD_INCLUDE_BOARD_H */ diff --git a/boards/arm/tiva/tm4c129e-launchpad/scripts/Make.defs b/boards/arm/tiva/tm4c129e-launchpad/scripts/Make.defs new file mode 100644 index 0000000000..57c91091a5 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/scripts/Make.defs @@ -0,0 +1,38 @@ +############################################################################ +# boards/arm/tiva/tm4c129e-launchpad/scripts/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script + +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 diff --git a/boards/arm/tiva/tm4c129e-launchpad/scripts/ld.script b/boards/arm/tiva/tm4c129e-launchpad/scripts/ld.script new file mode 100644 index 0000000000..83b98ef597 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/scripts/ld.script @@ -0,0 +1,103 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/scripts/ld.script + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/* The TM4C129ENCPDT has 1024Kib of FLASH beginning at address 0x0000:0000 and + * 256Kib of SRAM beginning at 0x2000:0000. + */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x00000000, LENGTH = 1M + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) + +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .init_section : ALIGN(4) { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : ALIGN(4) { + *(.ARM.extab*) + } > flash + + .ARM.exidx : ALIGN(4) { + __exidx_start = ABSOLUTE(.); + *(.ARM.exidx*) + __exidx_end = ABSOLUTE(.); + } > flash + + _eronly = ABSOLUTE(.); + + .data : ALIGN(4) { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : ALIGN(4) { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/tiva/tm4c129e-launchpad/src/Makefile b/boards/arm/tiva/tm4c129e-launchpad/src/Makefile new file mode 100644 index 0000000000..c67fa4be50 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/src/Makefile @@ -0,0 +1,53 @@ +############################################################################ +# boards/arm/tiva/tm4c129e-launchpad/src/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/Make.defs + +CSRCS = tm4c_boot.c tm4c_bringup.c + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += tm4c_autoleds.c +else +CSRCS += tm4c_userleds.c +endif + +ifeq ($(CONFIG_ARCH_BUTTONS),y) +CSRCS += tm4c_buttons.c +endif + +ifeq ($(CONFIG_TIVA_ETHERNET),y) +CSRCS += tm4c_ethernet.c +endif + +ifeq ($(CONFIG_DK_TM4C129X_TIMER),y) +CSRCS += tm4c_timer.c +endif + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += tm4c_appinit.c +endif + +ifeq ($(CONFIG_TIVA_HCIUART),y) +ifeq ($(CONFIG_BLUETOOTH_UART),y) +CSRCS += tm4c_hciuart.c +endif +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/tiva/tm4c129e-launchpad/src/tm4c129e-launchpad.h b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c129e-launchpad.h new file mode 100644 index 0000000000..151d18c80f --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c129e-launchpad.h @@ -0,0 +1,235 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/src/tm4c129e-launchpad.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_TIVA_TM4C129E_LAUNCHPAD_TM4C129E_LAUNCHPAD_H +#define __BOARDS_ARM_TIVA_TM4C129E_LAUNCHPAD_TM4C129E_LAUNCHPAD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "chip.h" +#include "tiva_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +#define HAVE_HCIUART 1 + +#if !defined(CONFIG_TIVA_HCIUART) || !defined(CONFIG_BLUETOOTH_UART) +# undef HAVE_HCIUART +#elif defined(CONFIG_TIVA_UART0_HCIUART) +# define HCIUART_SERDEV HCIUART0 +#elif defined(CONFIG_TIVA_UART1_HCIUART) +# define HCIUART_SERDEV HCIUART1 +#elif defined(CONFIG_TIVA_UART2_HCIUART) +# define HCIUART_SERDEV HCIUART2 +#elif defined(CONFIG_TIVA_UART3_HCIUART) +# define HCIUART_SERDEV HCIUART3 +#elif defined(CONFIG_TIVA_UART4_HCIUART) +# define HCIUART_SERDEV HCIUART4 +#elif defined(CONFIG_TIVA_UART5_HCIUART) +# define HCIUART_SERDEV HCIUART5 +#elif defined(CONFIG_TIVA_UART6_HCIUART) +# define HCIUART_SERDEV HCIUART6 +#elif defined(CONFIG_TIVA_UART7_HCIUART) +# define HCIUART_SERDEV HCIUART7 +#else +# error No HCI UART specifified +#endif + +/* How many SSI modules does this chip support? */ + +#if TIVA_NSSI < 1 +# undef CONFIG_TIVA_SSI0 +# undef CONFIG_TIVA_SSI0 +#elif TIVA_NSSI < 2 +# undef CONFIG_TIVA_SSI0 +#endif + +/* Do we need to register I2C drivers on behalf of the I2C tool? */ + +#define HAVE_I2CTOOL 1 +#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER) +# undef HAVE_I2CTOOL +#endif + +/* LED definitions **********************************************************/ + +/* The EK-TM4C129EXL has a four green LEDs. + * + * --- ------------ + * Pin Pin Function + * --- ------------ + * PN1 Green LED D1 + * PN0 Green LED D2 + * PF4 Green LED D3 + * PF0 Green LED D4 + * --- ------------ + * + * A high output illuminates the LED. + */ + +#define GPIO_LED_D1 (GPIO_FUNC_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTN | GPIO_PIN_1) +#define GPIO_LED_D2 (GPIO_FUNC_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTN | GPIO_PIN_0) +#define GPIO_LED_D3 (GPIO_FUNC_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTF | GPIO_PIN_4) +#define GPIO_LED_D4 (GPIO_FUNC_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTF | GPIO_PIN_0) + +/* Check if we have the LED driver */ + +#define HAVE_USERLED_DRIVER 1 +#if !defined(CONFIG_USERLED) || !defined(CONFIG_USERLED_LOWER) +# undef HAVE_USERLED_DRIVER +#endif + +/* Button definitions *******************************************************/ + +/* There are four push buttons on the board. + * Two of them are user controllable. + * The others are RESET and WAKE + * + * --- ------------ + * Pin Pin Function + * --- ------------ + * PJ0 USR_SW1 + * PJ1 USR_SW2 + * --- ------------ + */ + +#ifdef CONFIG_ARCH_IRQBUTTONS +# define GPIO_SW1 (GPIO_FUNC_INTERRUPT | GPIO_INT_BOTHEDGES | \ + GPIO_STRENGTH_2MA | GPIO_PADTYPE_STDWPU | \ + GPIO_PORTJ | GPIO_PIN_0) +# define GPIO_SW2 (GPIO_FUNC_INTERRUPT | GPIO_INT_BOTHEDGES | \ + GPIO_STRENGTH_2MA | GPIO_PADTYPE_STDWPU | \ + GPIO_PORTJ | GPIO_PIN_1) +#else +# define GPIO_SW1 (GPIO_FUNC_INPUT | GPIO_PORTJ | GPIO_PIN_0) +# define GPIO_SW2 (GPIO_FUNC_INPUT | GPIO_PORTJ | GPIO_PIN_1) +#endif + +/* SPI Chip selects *********************************************************/ + +/* SSI0: PA3 is used for SSI0 chip select to the second booster pack + * (No pull- ups) + * SSI3: PH4 selects the SD card and PQ1 selects the on-board SPI flash. + * Both pulled up on board. + */ + +#define GPIO_BSTR2_CS (GPIO_FUNC_OUTPUT | GPIO_PADTYPE_STDWPU | GPIO_STRENGTH_4MA | \ + GPIO_VALUE_ONE | GPIO_PORTA | GPIO_PIN_3) +#define GPIO_FLASH_CS (GPIO_FUNC_OUTPUT | GPIO_PADTYPE_STD | GPIO_STRENGTH_4MA | \ + GPIO_VALUE_ONE | GPIO_PORTH | GPIO_PIN_4) +#define GPIO_SD_CS (GPIO_FUNC_OUTPUT | GPIO_PADTYPE_STD | GPIO_STRENGTH_4MA | \ + GPIO_VALUE_ONE | GPIO_PORTH | GPIO_PIN_4) + +/* I2C **********************************************************************/ + +/* I2C3: PG4-5 are provide to the BoostPack 1 interface + * I2C7: PA4-5 are provide to the BoostPack 2 interface + * I2C6: PB6-7 are used for I2C to the connector. + */ + +/* Speaker outputs **********************************************************/ + +/* PB2/PD4 are used for the speaker output */ + +/* Touchscreen **************************************************************/ + +/* PE7/PP7/PT2-3 are used for the touch screen */ + +/**************************************************************************** + * Public Functions Definitions + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Name: tm4c_ssidev_initialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the EK-TM4C129EXL. + * + ****************************************************************************/ + +void weak_function tm4c_ssidev_initialize(void); + +/**************************************************************************** + * Name: tm4c_led_initialize + * + * Description: + * Called to initialize the on-board LEDs. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_LEDS +void tm4c_led_initialize(void); +#endif + +/**************************************************************************** + * Name: tm4c_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int tm4c_bringup(void); + +/**************************************************************************** + * Name: tiva_timer_configure + * + * Description: + * Configure the timer driver + * + ****************************************************************************/ + +#ifdef CONFIG_TM4C129E_LAUNCHPAD_TIMER +int tiva_timer_configure(void); +#endif + +/**************************************************************************** + * Name: hciuart_dev_initialize + * + * Description: + * This function is called by board initialization logic to configure the + * Bluetooth HCI UART driver + * + * Input Parameters: + * None + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef HAVE_HCIUART +int hciuart_dev_initialize(void); +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_TIVA_TM4C129E_LAUNCHPAD_TM4C129E_LAUNCHPAD_H */ diff --git a/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_appinit.c b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_appinit.c new file mode 100644 index 0000000000..9f8f2905fe --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_appinit.c @@ -0,0 +1,75 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/src/tm4c_appinit.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include "tm4c129e-launchpad.h" + +#ifdef CONFIG_BOARDCTL + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ + /* If CONFIG_BOARD_LATE_INITIALIZE is selected then board initialization + * was already performed in board_late_initialize. + */ + +#ifndef CONFIG_BOARD_LATE_INITIALIZE + return tm4c_bringup(); +#else + return OK; +#endif +} + +#endif /* CONFIG_BOARDCTL */ diff --git a/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_autoleds.c b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_autoleds.c new file mode 100644 index 0000000000..8c5f2907ea --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_autoleds.c @@ -0,0 +1,140 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/src/tm4c_autoleds.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include "tiva_gpio.h" +#include "tm4c129e-launchpad.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tm4c_led_initialize + * + * Description: + * Called to initialize the on-board LEDs. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_LEDS +void tm4c_led_initialize(void) +{ + /* Configure LED PIOs for output */ + + tiva_configgpio(GPIO_LED_D1); + tiva_configgpio(GPIO_LED_D2); + tiva_configgpio(GPIO_LED_D3); + tiva_configgpio(GPIO_LED_D4); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ +/* --------------- ------- ----- ----- ----- ----- ---------- + * STATE VALUE LED1 LED2 LED3 LED4 + * --------------- ------- ----- ----- ----- ----- ---------- + * LED_STARTED 1 ON OFF NC NC + * LED_HEAPALLOCATE 0 NC NC NC NC + * LED_IRQSENABLED 0 NC NC NC NC + * LED_STACKCREATED 2 ON ON NC NC + * LED_INIRQ 0 NC NC NC NC + * LED_SIGNAL 0 NC NC NC NC + * LED_ASSERTION 0 NC NC NC NC + * LED_PANIC 3 OFF ON NC NC (flashing 2Hz) + * --------------- ------- ----- ----- ----- --------------- + * + * A high output illuminates the LED. + */ + + switch (led) + { + default: + case 0: /* No change */ + break; + + case 1: /* LED1=OFF, LED2=OFF, LED3=NC, LED4=NC */ + tiva_gpiowrite(GPIO_LED_D1, true); + tiva_gpiowrite(GPIO_LED_D2, false); + break; + + case 2: /* LED1=ON, LED2=ON, LED3=NC, LED4=NC */ + tiva_gpiowrite(GPIO_LED_D1, true); + tiva_gpiowrite(GPIO_LED_D2, true); + break; + + case 3: /* LED1=OFF, LED2=ON, LED3=NC, LED4=NC */ + tiva_gpiowrite(GPIO_LED_D1, false); + tiva_gpiowrite(GPIO_LED_D2, true); + break; + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ +/* --------------- ------- ----- ----- ----- ----- ---------- + * STATE VALUE LED1 LED2 LED3 LED4 + * --------------- ------- ----- ----- ----- ----- ---------- + * LED_STARTED 1 ON OFF NC NC + * LED_HEAPALLOCATE 0 NC NC NC NC + * LED_IRQSENABLED 0 NC NC NC NC + * LED_STACKCREATED 2 ON ON NC NC + * LED_INIRQ 0 NC NC NC NC + * LED_SIGNAL 0 NC NC NC NC + * LED_ASSERTION 0 NC NC NC NC + * LED_PANIC 3 ON OFF NC NC (flashing 2Hz) + * --------------- ------- ----- ----- ----- --------------- + * + * A high output illuminates the LED. + */ + + switch (led) + { + case 0: /* No change */ + case 1: /* Will not happen */ + case 2: /* Will not happen */ + default: + break; + + case 3: /* LED1=ON, LED2=OFF, LED3=NC, LED4=NC */ + tiva_gpiowrite(GPIO_LED_D1, true); + tiva_gpiowrite(GPIO_LED_D2, false); + break; + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_boot.c b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_boot.c new file mode 100644 index 0000000000..8446fb4262 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_boot.c @@ -0,0 +1,103 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/src/tm4c_boot.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include "tm4c129e-launchpad.h" +#include "arm_internal.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tiva_boardinitialize + * + * Description: + * All Tiva architectures must provide the following entry point. + * This entry point is called early in the initialization -- after all + * memory has been configured and mapped but before any devices have been + * initialized. + * + ****************************************************************************/ + +void tiva_boardinitialize(void) +{ + /* Configure SPI chip selects if + * 1) SSI is not disabled, and + * 2) the weak function + * tm4c_ssidev_initialize() has been brought into the link. + */ + + /* The DK-TM4C129X microSD CS and OLED are on SSI0 */ + +#if defined(CONFIG_TIVA_SSI0) || defined(CONFIG_TIVA_SSI1) + if (tm4c_ssidev_initialize) + { + tm4c_ssidev_initialize(); + } +#endif + + /* Configure on-board LEDs if LED support has been selected. */ + +#ifdef CONFIG_ARCH_LEDS + tm4c_led_initialize(); +#endif +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will + * be called immediately after up_initialize() is called and just before + * the initial application is started. This additional initialization + * phase may be used, for example, to initialize board-specific device + * drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board initialization */ + + tm4c_bringup(); +} +#endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_bringup.c b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_bringup.c new file mode 100644 index 0000000000..f7b9331c38 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_bringup.c @@ -0,0 +1,364 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/src/tm4c_bringup.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#ifdef CONFIG_INPUT_BUTTONS +# include +#endif + +#include "tiva_i2c.h" +#include "tiva_pwm.h" +#include "tiva_qencoder.h" +#include "tm4c129e-launchpad.h" + +#ifdef HAVE_USERLED_DRIVER +# include +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_DK_TM4C129X_TIMER +# define HAVE_TIMER +#endif + +#ifdef CONFIG_TM4C129E_LAUNCHPAD_PWM +# define HAVE_PWM +#endif + +#if defined(CONFIG_TIVA_QEI0) || defined(CONFIG_TIVA_QEI1) +# define HAVE_QEI +#endif + +#define PWM_PATH_FMT "/dev/pwm%d" +#define PWM_PATH_FMTLEN (10) + +#define QEI_PATH_FMT "/dev/qei%d" +#define QEI_PATH_FMTLEN (10) + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tm4c_i2c_register + * + * Description: + * Register one I2C drivers for the I2C tool. + * + ****************************************************************************/ + +#ifdef HAVE_I2CTOOL +static void tm4c_i2c_register(int bus) +{ + struct i2c_master_s *i2c; + int ret; + + i2c = tiva_i2cbus_initialize(bus); + if (i2c == NULL) + { + _err("ERROR: Failed to get I2C%d interface\n", bus); + } + else + { + ret = i2c_register(i2c, bus); + if (ret < 0) + { + _err("ERROR: Failed to register I2C%d driver: %d\n", bus, ret); + tiva_i2cbus_uninitialize(i2c); + } + } +} +#endif + +/**************************************************************************** + * Name: tm4c_i2ctool + * + * Description: + * Register I2C drivers for the I2C tool. + * + ****************************************************************************/ + +#ifdef HAVE_I2CTOOL +static void tm4c_i2ctool(void) +{ +#ifdef CONFIG_TIVA_I2C0 + tm4c_i2c_register(0); +#endif +#ifdef CONFIG_TIVA_I2C1 + tm4c_i2c_register(1); +#endif +#ifdef CONFIG_TIVA_I2C2 + tm4c_i2c_register(2); +#endif +#ifdef CONFIG_TIVA_I2C3 + tm4c_i2c_register(3); +#endif +#ifdef CONFIG_TIVA_I2C4 + tm4c_i2c_register(4); +#endif +#ifdef CONFIG_TIVA_I2C5 + tm4c_i2c_register(5); +#endif +#ifdef CONFIG_TIVA_I2C6 + tm4c_i2c_register(6); +#endif +#ifdef CONFIG_TIVA_I2C7 + tm4c_i2c_register(7); +#endif +#ifdef CONFIG_TIVA_I2C8 + tm4c_i2c_register(8); +#endif +#ifdef CONFIG_TIVA_I2C9 + tm4c_i2c_register(9); +#endif +} +#else +# define tm4c_i2ctool() +#endif + +/**************************************************************************** + * Name: tm4c_pwm_register + * + * Description: + * Register a PWM dev file with the upper_level PWM driver. + * + * Input Parameters: + * channel - A number identifying the PWM channel use. + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#ifdef HAVE_PWM +static void tm4c_pwm_register(int channel) +{ + struct pwm_lowerhalf_s *dev; + char pwm_path[PWM_PATH_FMTLEN]; + int ret; + + dev = tiva_pwm_initialize(channel); + if (dev == NULL) + { + _err("ERROR: Failed to get PWM%d interface\n", channel); + } + else + { + snprintf(pwm_path, PWM_PATH_FMTLEN, PWM_PATH_FMT, channel); + ret = pwm_register(pwm_path, dev); + if (ret < 0) + { + _err("ERROR: Failed to register PWM%d driver: %d\n", + channel, ret); + } + } +} +#endif + +/**************************************************************************** + * Name: tm4c_pwm + * + * Description: + * Register PWM drivers for the PWM tool. + * + ****************************************************************************/ + +#ifdef HAVE_PWM +static void tm4c_pwm(void) +{ +#ifdef CONFIG_TIVA_PWM0_CHAN0 + tm4c_pwm_register(0); +#endif +#ifdef CONFIG_TIVA_PWM0_CHAN1 + tm4c_pwm_register(1); +#endif +#ifdef CONFIG_TIVA_PWM0_CHAN2 + tm4c_pwm_register(2); +#endif +#ifdef CONFIG_TIVA_PWM0_CHAN3 + tm4c_pwm_register(3); +#endif +#ifdef CONFIG_TIVA_PWM0_CHAN4 + tm4c_pwm_register(4); +#endif +#ifdef CONFIG_TIVA_PWM0_CHAN5 + tm4c_pwm_register(5); +#endif +#ifdef CONFIG_TIVA_PWM0_CHAN6 + tm4c_pwm_register(6); +#endif +#ifdef CONFIG_TIVA_PWM0_CHAN7 + tm4c_pwm_register(7); +#endif +} +#endif + +/**************************************************************************** + * Name: tm4c_qei_register + * + * Description: + * Register a QEI dev file with the upper_level QEI driver. + * + * Input Parameters: + * id - A number identifying the QEI. + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#ifdef HAVE_QEI +static void tm4c_qei_register(int id) +{ + struct qe_lowerhalf_s *dev; + int ret; + char qe_path[QEI_PATH_FMTLEN]; + + dev = tiva_qei_initialize(id); + if (dev == NULL) + { + _err("ERROR: Failed to get QEI %d\n", id); + } + else + { + snprintf(qe_path, QEI_PATH_FMTLEN, QEI_PATH_FMT, id); + ret = qe_register(qe_path, dev); + if (ret < 0) + { + _err("ERROR: Failed to register QEI %d driver: %d\n", id, ret); + } + } +} +#endif + +/**************************************************************************** + * Name: tm4c_qei + * + * Description: + * Register QEI drivers for the QEI tool. + * + ****************************************************************************/ + +#ifdef HAVE_QEI +static void tm4c_qei(void) +{ +#ifdef CONFIG_TIVA_QEI0 + tm4c_qei_register(0); +#endif +#ifdef CONFIG_TIVA_QEI1 + tm4c_qei_register(1); +#endif +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tm4c_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int tm4c_bringup(void) +{ + int ret; + + /* Register I2C drivers on behalf of the I2C tool */ + + tm4c_i2ctool(); + +#ifdef HAVE_PWM + /* Register PWM drivers */ + + tm4c_pwm(); +#endif + +#ifdef HAVE_QEI + /* Register QEI drivers */ + + tm4c_qei(); +#endif + +#ifdef HAVE_TIMER + /* Initialize the timer driver */ + + ret = tiva_timer_configure(); + if (ret < 0) + { + _err("ERROR: Failed to initialize timer driver: %d\n", ret); + } +#endif + +#ifdef HAVE_HCIUART + /* Register the Bluetooth HCI UART device */ + + ret = hciuart_dev_initialize(); + if (ret < 0) + { + serr("ERROR: Failed to initialize HCI UART driver: %d\n", ret); + } +#endif + +#ifdef CONFIG_INPUT_BUTTONS_LOWER + /* Register the BUTTON driver */ + + ret = btn_lower_initialize("/dev/buttons"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret); + } +#endif + +#ifdef HAVE_USERLED_DRIVER + /* Register the LED driver */ + + ret = userled_lower_initialize("/dev/userleds"); + if (ret != OK) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", + ret); + return ret; + } +#endif + + UNUSED(ret); + return OK; +} diff --git a/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_buttons.c b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_buttons.c new file mode 100644 index 0000000000..da55c79d54 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_buttons.c @@ -0,0 +1,158 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/src/tm4c_buttons.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include +#include + +#include "tm4c129e-launchpad.h" + +#ifdef CONFIG_ARCH_BUTTONS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Pin configuration for each STM3210E-EVAL button. This array is indexed by + * the BUTTON_* and JOYSTICK_* definitions in board.h + */ + +static const uint32_t g_buttons[NUM_BUTTONS] = +{ + GPIO_SW1, GPIO_SW2 +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_button_initialize + * + * Description: + * board_button_initialize() must be called to initialize button resources. + * After that, board_buttons() may be called to collect the current state + * of all buttons or board_button_irq() may be called to register button + * interrupt handlers. + * + ****************************************************************************/ + +uint32_t board_button_initialize(void) +{ + int i; + + /* Configure the GPIO pins as inputs. */ + + for (i = 0; i < NUM_BUTTONS; i++) + { + tiva_configgpio(g_buttons[i]); + } + +#ifdef CONFIG_ARCH_IRQBUTTONS + /* Configure GPIO interrupts */ + + tiva_gpioirqinitialize(); +#endif + return NUM_BUTTONS; +} + +/**************************************************************************** + * Name: board_buttons + ****************************************************************************/ + +uint32_t board_buttons(void) +{ + uint32_t ret = 0; + int i; + + /* Check that state of each key */ + + for (i = 0; i < NUM_BUTTONS; i++) + { + /* A LOW value means that the key is pressed. */ + + bool released = tiva_gpioread(g_buttons[i]); + + /* Accumulate the set of depressed (not released) keys */ + + if (!released) + { + ret |= (1 << i); + } + } + + return ret; +} + +/**************************************************************************** + * Name: board_button_irq + * + * Description: + * This function may be called to register an interrupt handler that will + * be called when a button is depressed or released. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_IRQBUTTONS +int board_button_irq(int id, xcpt_t irqhandler, void *arg) +{ + int ret; + + if (id < 0 || id >= NUM_BUTTONS) + { + ret = -EINVAL; + } + else + { + /* Are we attaching or detaching? */ + + if (irqhandler != NULL) + { + ret = tiva_gpioirqattach(g_buttons[id], irqhandler, arg); + } + else + { + ret = tiva_gpioirqdetach(g_buttons[id]); + } + } + + return ret; +} +#endif + +#endif /* CONFIG_ARCH_BUTTONS */ diff --git a/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_ethernet.c b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_ethernet.c new file mode 100644 index 0000000000..d790311641 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_ethernet.c @@ -0,0 +1,87 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/src/tm4c_ethernet.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "arm_internal.h" +#include "chip.h" +#include "hardware/tiva_flash.h" +#include "tiva_ethernet.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tiva_ethernetmac + * + * Description: + * For the Ethernet Eval Kits, the MAC address will be stored in the + * non-volatile USER0 and USER1 registers. + * If CONFIG_TIVA_BOARDMAC is defined, this function + * will obtain the MAC address from these registers. + * + ****************************************************************************/ + +#ifdef CONFIG_TIVA_BOARDMAC +void tiva_ethernetmac(struct ether_addr *ethaddr) +{ + uint32_t user0; + uint32_t user1; + + /* Get the current value of the user registers */ + + user0 = getreg32(TIVA_FLASH_USERREG0); + user1 = getreg32(TIVA_FLASH_USERREG1); + + ninfo("user: %06" PRIx32 ":%06" PRIx32 "\n", + user1 & 0x00ffffff, user0 & 0x00ffffff); + DEBUGASSERT(user0 != 0xffffffff && user1 != 0xffffffff); + + /* Re-format that MAC address the way that the network expects to see it */ + + ethaddr->ether_addr_octet[0] = ((user0 >> 0) & 0xff); + ethaddr->ether_addr_octet[1] = ((user0 >> 8) & 0xff); + ethaddr->ether_addr_octet[2] = ((user0 >> 16) & 0xff); + ethaddr->ether_addr_octet[3] = ((user1 >> 0) & 0xff); + ethaddr->ether_addr_octet[4] = ((user1 >> 8) & 0xff); + ethaddr->ether_addr_octet[5] = ((user1 >> 16) & 0xff); +} +#endif diff --git a/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_hciuart.c b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_hciuart.c new file mode 100644 index 0000000000..4259afab8c --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_hciuart.c @@ -0,0 +1,82 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/src/tm4c_hciuart.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include + +#include "tiva_hciuart.h" +#include "tm4c129e-launchpad.h" + +#include + +#ifdef HAVE_HCIUART + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: hciuart_dev_initialize + * + * Description: + * This function is called by board initialization logic to configure the + * Bluetooth HCI UART driver + * + * Input Parameters: + * None + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +int hciuart_dev_initialize(void) +{ + int ret; + + /* Perform one-time initialization */ + + hciuart_initialize(); + + /* Instantiate the HCI UART lower half interface + * Then initialize the HCI UART upper half driver with the bluetooth stack + */ + + ret = btuart_register(hciuart_instantiate(HCIUART_SERDEV)); + if (ret < 0) + { + wlerr("ERROR: btuart_register() failed: %d\n", ret); + } + + return ret; +} + +#endif /* HAVE_HCIUART */ diff --git a/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_timer.c b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_timer.c new file mode 100644 index 0000000000..cb750c2595 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_timer.c @@ -0,0 +1,103 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/src/tm4c_timer.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include "tiva_timer.h" +#include "tm4c129e-launchpad.h" + +#ifdef CONFIG_TM4C129E_LAUNCHPAD_TIMER + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +#ifndef CONFIG_TIMER +# error CONFIG_TIMER is not defined +#endif + +#ifndef CONFIG_TIVA_TIMER32_PERIODIC +# error CONFIG_TIVA_TIMER32_PERIODIC is not defined +#endif + +#if defined(CONFIG_DK_TM4CTM4C129E_LAUNCHPADX_TIMER0) +# define GPTM 0 +#elif defined(CONFIG_TM4C129E_LAUNCHPAD_TIMER1) +# define GPTM 1 +#elif defined(CONFIG_TM4C129E_LAUNCHPAD_TIMER2) +# define GPTM 2 +#elif defined(CONFIG_TM4C129E_LAUNCHPAD_TIMER3) +# define GPTM 3 +#elif defined(CONFIG_TM4C129E_LAUNCHPAD_TIMER4) +# define GPTM 4 +#elif defined(CONFIG_TM4C129E_LAUNCHPAD_TIMER5) +# define GPTM 5 +#elif defined(CONFIG_TM4C129E_LAUNCHPAD_TIMER6) +# define GPTM 6 +#elif defined(CONFIG_TM4C129E_LAUNCHPAD_TIMER7) +# define GPTM 7 +#else +# error No CONFIG_TM4C129E_LAUNCHPAD_TIMERn definition +#endif + +#ifndef CONFIG_TM4C129E_LAUNCHPAD_TIMER_DEVNAME +# define CONFIG_TM4C129E_LAUNCHPAD_TIMER_DEVNAME "/dev/timer0" +#endif + +#undef CONFIG_TM4C129E_LAUNCHPAD_TIMER_ALTCLK +#define ALTCLK false + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tiva_timer_configure + * + * Description: + * Configure the timer driver + * + ****************************************************************************/ + +int tiva_timer_configure(void) +{ + int ret; + + tmrinfo("Registering TIMER%d at %s\n", + GPTM, CONFIG_TM4C129E_LAUNCHPAD_TIMER_DEVNAME); + + ret = tiva_timer_register(CONFIG_TM4C129E_LAUNCHPAD_TIMER_DEVNAME, + GPTM, ALTCLK); + if (ret < 0) + { + tmrerr("ERROR: Failed to register timer driver: %d\n", ret); + } + + return ret; +} + +#endif /* CONFIG_TM4C129E_LAUNCHPAD_TIMER */ diff --git a/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_userleds.c b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_userleds.c new file mode 100644 index 0000000000..3fec0fa7ec --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/src/tm4c_userleds.c @@ -0,0 +1,124 @@ +/**************************************************************************** + * boards/arm/tiva/tm4c129e-launchpad/src/tm4c_userleds.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/* The EK-TM4C129EXL has a four green LEDs. + * + * --- ------------ + * Pin Pin Function + * --- ------------ + * PN1 Green LED D1 + * PN0 Green LED D2 + * PF4 Green LED D3 + * PF0 Green LED D4 + * --- ------------ + * + * A high output illuminates the LED. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include "tiva_gpio.h" +#include "tm4c129e-launchpad.h" + +#ifndef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +uint32_t board_userled_initialize(void) +{ + /* Configure LED PIOs for output */ + + tiva_configgpio(GPIO_LED_D1); + tiva_configgpio(GPIO_LED_D2); + tiva_configgpio(GPIO_LED_D3); + tiva_configgpio(GPIO_LED_D4); + return BOARD_NLEDS; +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + uint32_t ledcfg; + + if (led == BOARD_LED_D1) + { + ledcfg = GPIO_LED_D1; + } + else if (led == BOARD_LED_D2) + { + ledcfg = GPIO_LED_D2; + } + else if (led == BOARD_LED_D3) + { + ledcfg = GPIO_LED_D3; + } + else if (led == BOARD_LED_D4) + { + ledcfg = GPIO_LED_D4; + } + else + { + return; + } + + tiva_gpiowrite(ledcfg, ledon); +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint32_t ledset) +{ + bool ledon; + + ledon = ((ledset & BOARD_LED_D1_BIT) != 0); + tiva_gpiowrite(GPIO_LED_D1, ledon); + + ledon = ((ledset & BOARD_LED_D2_BIT) != 0); + tiva_gpiowrite(GPIO_LED_D2, ledon); + + ledon = ((ledset & BOARD_LED_D3_BIT) != 0); + tiva_gpiowrite(GPIO_LED_D3, ledon); + + ledon = ((ledset & BOARD_LED_D4_BIT) != 0); + tiva_gpiowrite(GPIO_LED_D4, ledon); +} + +#endif /* !CONFIG_ARCH_LEDS */ diff --git a/boards/arm/tiva/tm4c129e-launchpad/tools/ek-tm4c129exl.cfg b/boards/arm/tiva/tm4c129e-launchpad/tools/ek-tm4c129exl.cfg new file mode 100644 index 0000000000..b703041b41 --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/tools/ek-tm4c129exl.cfg @@ -0,0 +1,12 @@ +# +# TI Tiva C Series ek-tm4c129exl Launchpad Evaluation Kit +# +# https://www.ti.com/tool/EK-TM4C129EXL +# + +source [find interface/ti-icdi.cfg] +transport select hla_jtag + +set WORKAREASIZE 0x40000 +set CHIPNAME tm4c129encpdt +source [find target/stellaris.cfg] diff --git a/boards/arm/tiva/tm4c129e-launchpad/tools/oocd.sh b/boards/arm/tiva/tm4c129e-launchpad/tools/oocd.sh new file mode 100755 index 0000000000..f9b2e6522d --- /dev/null +++ b/boards/arm/tiva/tm4c129e-launchpad/tools/oocd.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# +# See boards/arm/tiva/tm4c129e-launchpad/README.txt for information about +# this file. + +TOPDIR=$1 +USAGE="$0 [-d]" +if [ -z "${TOPDIR}" ]; then + echo "Missing argument" + echo $USAGE + exit 1 +fi + +# Assume that OpenOCD was installed and at /usr/local/bin. Uncomment +# the following to run directly from the build directory + +# OPENOCD_PATH="/home/OpenOCD/openocd/src" +OPENOCD_PATH="/usr/bin" +# OPENOCD_PATH="/usr/local/bin" + +# TARGET_PATH="/home/OpenOCD/openocd/tcl" +TARGET_PATH="/usr/share/openocd/scripts" +# TARGET_PATH="/usr/local/share/openocd/scripts" + +# Assume a Unix development environment. Uncomment to use a Windows +# like environment + +# OPENOCD_EXE=openocd.exe +OPENOCD_EXE=openocd + +OPENOCD_CFG="${TOPDIR}/boards/arm/tiva/tm4c129e-launchpad/tools/ek-tm4c129exl.cfg" +OPENOCD_ARGS="-f ${OPENOCD_CFG} -s ${TARGET_PATH}" + +if [ "X$2" = "X-d" ]; then + OPENOCD_ARGS=$OPENOCD_ARGS" -d3" + set -x +fi + +if [ ! -d ${OPENOCD_PATH} ]; then + echo "OpenOCD path does not exist: ${OPENOCD_PATH}" + exit 1 +fi +if [ ! -x ${OPENOCD_PATH}/${OPENOCD_EXE} ]; then + echo "OpenOCD does not exist: ${OPENOCD_PATH}/${OPENOCD_EXE}" + exit 1 +fi +if [ ! -f ${OPENOCD_CFG} ]; then + echo "OpenOCD config file does not exist: ${OPENOCD_CFG}" + exit 1 +fi + +echo "Starting OpenOCD" +cd ${OPENOCD_PATH} || { echo "Failed to CD to ${OPENOCD_PATH}"; exit 1; } +${OPENOCD_EXE} ${OPENOCD_ARGS} & +echo "OpenOCD daemon started" +ps -ef | grep openocd +echo "In GDB: target remote localhost:3333"