From c3e4c9a25c2910d2d66d52215b3406b13d5b23d5 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Sun, 29 Jun 2014 12:34:32 +0300 Subject: Add more board models --- boards/dk-tm4c129x/hibernate/Makefile | 94 ++ boards/dk-tm4c129x/hibernate/ccs/.ccsimportspec | 8 + boards/dk-tm4c129x/hibernate/ccs/.ccsproject | 10 + boards/dk-tm4c129x/hibernate/ccs/.cproject | 195 +++ boards/dk-tm4c129x/hibernate/ccs/.project | 80 + .../ccs/.settings/org.eclipse.cdt.codan.core.prefs | 3 + .../dk-tm4c129x/hibernate/ccs/Debug/hibernate.bin | Bin 0 -> 40856 bytes .../dk-tm4c129x/hibernate/ccs/Debug/hibernate.out | Bin 0 -> 381834 bytes .../dk-tm4c129x/hibernate/ccs/macros.ini_initial | 1 + .../dk-tm4c129x/hibernate/ccs/target_config.ccxml | 13 + .../dk-tm4c129x/hibernate/ewarm/Exe/hibernate.bin | Bin 0 -> 36988 bytes .../dk-tm4c129x/hibernate/ewarm/Exe/hibernate.out | Bin 0 -> 360712 bytes boards/dk-tm4c129x/hibernate/gcc/hibernate.axf | Bin 0 -> 113666 bytes boards/dk-tm4c129x/hibernate/gcc/hibernate.bin | Bin 0 -> 40360 bytes boards/dk-tm4c129x/hibernate/hibernate.c | 1568 ++++++++++++++++++++ boards/dk-tm4c129x/hibernate/hibernate.ewd | 614 ++++++++ boards/dk-tm4c129x/hibernate/hibernate.ewp | 810 ++++++++++ boards/dk-tm4c129x/hibernate/hibernate.icf | 78 + boards/dk-tm4c129x/hibernate/hibernate.ld | 57 + boards/dk-tm4c129x/hibernate/hibernate.sct | 47 + boards/dk-tm4c129x/hibernate/hibernate.uvopt | 387 +++++ boards/dk-tm4c129x/hibernate/hibernate.uvproj | 459 ++++++ boards/dk-tm4c129x/hibernate/hibernate_ccs.cmd | 70 + boards/dk-tm4c129x/hibernate/readme.txt | 37 + boards/dk-tm4c129x/hibernate/rvmdk/hibernate.axf | Bin 0 -> 312416 bytes boards/dk-tm4c129x/hibernate/rvmdk/hibernate.bin | Bin 0 -> 38408 bytes boards/dk-tm4c129x/hibernate/startup_ccs.c | 275 ++++ boards/dk-tm4c129x/hibernate/startup_ewarm.c | 306 ++++ boards/dk-tm4c129x/hibernate/startup_gcc.c | 322 ++++ boards/dk-tm4c129x/hibernate/startup_rvmdk.S | 331 +++++ 30 files changed, 5765 insertions(+) create mode 100644 boards/dk-tm4c129x/hibernate/Makefile create mode 100644 boards/dk-tm4c129x/hibernate/ccs/.ccsimportspec create mode 100644 boards/dk-tm4c129x/hibernate/ccs/.ccsproject create mode 100644 boards/dk-tm4c129x/hibernate/ccs/.cproject create mode 100644 boards/dk-tm4c129x/hibernate/ccs/.project create mode 100644 boards/dk-tm4c129x/hibernate/ccs/.settings/org.eclipse.cdt.codan.core.prefs create mode 100644 boards/dk-tm4c129x/hibernate/ccs/Debug/hibernate.bin create mode 100644 boards/dk-tm4c129x/hibernate/ccs/Debug/hibernate.out create mode 100644 boards/dk-tm4c129x/hibernate/ccs/macros.ini_initial create mode 100644 boards/dk-tm4c129x/hibernate/ccs/target_config.ccxml create mode 100644 boards/dk-tm4c129x/hibernate/ewarm/Exe/hibernate.bin create mode 100644 boards/dk-tm4c129x/hibernate/ewarm/Exe/hibernate.out create mode 100644 boards/dk-tm4c129x/hibernate/gcc/hibernate.axf create mode 100644 boards/dk-tm4c129x/hibernate/gcc/hibernate.bin create mode 100644 boards/dk-tm4c129x/hibernate/hibernate.c create mode 100644 boards/dk-tm4c129x/hibernate/hibernate.ewd create mode 100644 boards/dk-tm4c129x/hibernate/hibernate.ewp create mode 100644 boards/dk-tm4c129x/hibernate/hibernate.icf create mode 100644 boards/dk-tm4c129x/hibernate/hibernate.ld create mode 100644 boards/dk-tm4c129x/hibernate/hibernate.sct create mode 100644 boards/dk-tm4c129x/hibernate/hibernate.uvopt create mode 100644 boards/dk-tm4c129x/hibernate/hibernate.uvproj create mode 100644 boards/dk-tm4c129x/hibernate/hibernate_ccs.cmd create mode 100644 boards/dk-tm4c129x/hibernate/readme.txt create mode 100644 boards/dk-tm4c129x/hibernate/rvmdk/hibernate.axf create mode 100644 boards/dk-tm4c129x/hibernate/rvmdk/hibernate.bin create mode 100644 boards/dk-tm4c129x/hibernate/startup_ccs.c create mode 100644 boards/dk-tm4c129x/hibernate/startup_ewarm.c create mode 100644 boards/dk-tm4c129x/hibernate/startup_gcc.c create mode 100644 boards/dk-tm4c129x/hibernate/startup_rvmdk.S (limited to 'boards/dk-tm4c129x/hibernate') diff --git a/boards/dk-tm4c129x/hibernate/Makefile b/boards/dk-tm4c129x/hibernate/Makefile new file mode 100644 index 0000000..86e91fa --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/Makefile @@ -0,0 +1,94 @@ +#****************************************************************************** +# +# Makefile - Rules for building the Hibernate Example. +# +# Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved. +# Software License Agreement +# +# Texas Instruments (TI) is supplying this software for use solely and +# exclusively on TI's microcontroller products. The software is owned by +# TI and/or its suppliers, and is protected under applicable copyright +# laws. You may not combine this software with "viral" open-source +# software in order to form a larger program. +# +# THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +# NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +# NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +# CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +# DAMAGES, FOR ANY REASON WHATSOEVER. +# +# This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package. +# +#****************************************************************************** + +# +# Defines the part type that this project uses. +# +PART=TM4C129XNCZAD + +# +# The base directory for TivaWare. +# +ROOT=../../../.. + +# +# Include the common make definitions. +# +include ${ROOT}/makedefs + +# +# Where to find source files that do not live in this directory. +# +VPATH=../drivers +VPATH+=../../../../utils + +# +# Where to find header files that do not live in the source directory. +# +IPATH=. +IPATH+=.. +IPATH+=../../../.. + +# +# The default rule, which causes the Hibernate Example to be built. +# +all: ${COMPILER} +all: ${COMPILER}/hibernate.axf + +# +# The rule to clean out all the build products. +# +clean: + @rm -rf ${COMPILER} ${wildcard *~} + +# +# The rule to create the target directory. +# +${COMPILER}: + @mkdir -p ${COMPILER} + +# +# Rules for building the Hibernate Example. +# +${COMPILER}/hibernate.axf: ${COMPILER}/frame.o +${COMPILER}/hibernate.axf: ${COMPILER}/hibernate.o +${COMPILER}/hibernate.axf: ${COMPILER}/kentec320x240x16_ssd2119.o +${COMPILER}/hibernate.axf: ${COMPILER}/pinout.o +${COMPILER}/hibernate.axf: ${COMPILER}/startup_${COMPILER}.o +${COMPILER}/hibernate.axf: ${COMPILER}/touch.o +${COMPILER}/hibernate.axf: ${COMPILER}/uartstdio.o +${COMPILER}/hibernate.axf: ${COMPILER}/ustdlib.o +${COMPILER}/hibernate.axf: ${ROOT}/grlib/${COMPILER}/libgr.a +${COMPILER}/hibernate.axf: ${ROOT}/driverlib/${COMPILER}/libdriver.a +${COMPILER}/hibernate.axf: hibernate.ld +SCATTERgcc_hibernate=hibernate.ld +ENTRY_hibernate=ResetISR +CFLAGSgcc=-DTARGET_IS_TM4C129_RA0 -DSNOWFLAKE + +# +# Include the automatically generated dependency files. +# +ifneq (${MAKECMDGOALS},clean) +-include ${wildcard ${COMPILER}/*.d} __dummy__ +endif diff --git a/boards/dk-tm4c129x/hibernate/ccs/.ccsimportspec b/boards/dk-tm4c129x/hibernate/ccs/.ccsimportspec new file mode 100644 index 0000000..160e565 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/ccs/.ccsimportspec @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/boards/dk-tm4c129x/hibernate/ccs/.ccsproject b/boards/dk-tm4c129x/hibernate/ccs/.ccsproject new file mode 100644 index 0000000..59a3400 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/ccs/.ccsproject @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/boards/dk-tm4c129x/hibernate/ccs/.cproject b/boards/dk-tm4c129x/hibernate/ccs/.cproject new file mode 100644 index 0000000..acbab34 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/ccs/.cproject @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/boards/dk-tm4c129x/hibernate/ccs/.project b/boards/dk-tm4c129x/hibernate/ccs/.project new file mode 100644 index 0000000..690bde8 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/ccs/.project @@ -0,0 +1,80 @@ + + + hibernate + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + com.ti.ccstudio.core.ccsNature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + hibernate.c + 1 + SW_ROOT/examples/boards/dk-tm4c129x/hibernate/hibernate.c + + + hibernate_ccs.cmd + 1 + SW_ROOT/examples/boards/dk-tm4c129x/hibernate/hibernate_ccs.cmd + + + startup_ccs.c + 1 + SW_ROOT/examples/boards/dk-tm4c129x/hibernate/startup_ccs.c + + + drivers/frame.c + 1 + SW_ROOT/examples/boards/dk-tm4c129x/drivers/frame.c + + + drivers/kentec320x240x16_ssd2119.c + 1 + SW_ROOT/examples/boards/dk-tm4c129x/drivers/kentec320x240x16_ssd2119.c + + + drivers/pinout.c + 1 + SW_ROOT/examples/boards/dk-tm4c129x/drivers/pinout.c + + + drivers/touch.c + 1 + SW_ROOT/examples/boards/dk-tm4c129x/drivers/touch.c + + + utils/uartstdio.c + 1 + SW_ROOT/utils/uartstdio.c + + + utils/ustdlib.c + 1 + SW_ROOT/utils/ustdlib.c + + + + + SW_ROOT + $%7BPARENT-5-PROJECT_LOC%7D + + + diff --git a/boards/dk-tm4c129x/hibernate/ccs/.settings/org.eclipse.cdt.codan.core.prefs b/boards/dk-tm4c129x/hibernate/ccs/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000..98b6350 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/ccs/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +inEditor=false +onBuild=false diff --git a/boards/dk-tm4c129x/hibernate/ccs/Debug/hibernate.bin b/boards/dk-tm4c129x/hibernate/ccs/Debug/hibernate.bin new file mode 100644 index 0000000..153b5fa Binary files /dev/null and b/boards/dk-tm4c129x/hibernate/ccs/Debug/hibernate.bin differ diff --git a/boards/dk-tm4c129x/hibernate/ccs/Debug/hibernate.out b/boards/dk-tm4c129x/hibernate/ccs/Debug/hibernate.out new file mode 100644 index 0000000..d4c5e2e Binary files /dev/null and b/boards/dk-tm4c129x/hibernate/ccs/Debug/hibernate.out differ diff --git a/boards/dk-tm4c129x/hibernate/ccs/macros.ini_initial b/boards/dk-tm4c129x/hibernate/ccs/macros.ini_initial new file mode 100644 index 0000000..31214b5 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/ccs/macros.ini_initial @@ -0,0 +1 @@ +SW_ROOT = ../../../../.. diff --git a/boards/dk-tm4c129x/hibernate/ccs/target_config.ccxml b/boards/dk-tm4c129x/hibernate/ccs/target_config.ccxml new file mode 100644 index 0000000..6e5ef45 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/ccs/target_config.ccxml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/boards/dk-tm4c129x/hibernate/ewarm/Exe/hibernate.bin b/boards/dk-tm4c129x/hibernate/ewarm/Exe/hibernate.bin new file mode 100644 index 0000000..2be59c3 Binary files /dev/null and b/boards/dk-tm4c129x/hibernate/ewarm/Exe/hibernate.bin differ diff --git a/boards/dk-tm4c129x/hibernate/ewarm/Exe/hibernate.out b/boards/dk-tm4c129x/hibernate/ewarm/Exe/hibernate.out new file mode 100644 index 0000000..d9c2972 Binary files /dev/null and b/boards/dk-tm4c129x/hibernate/ewarm/Exe/hibernate.out differ diff --git a/boards/dk-tm4c129x/hibernate/gcc/hibernate.axf b/boards/dk-tm4c129x/hibernate/gcc/hibernate.axf new file mode 100644 index 0000000..20a7f82 Binary files /dev/null and b/boards/dk-tm4c129x/hibernate/gcc/hibernate.axf differ diff --git a/boards/dk-tm4c129x/hibernate/gcc/hibernate.bin b/boards/dk-tm4c129x/hibernate/gcc/hibernate.bin new file mode 100644 index 0000000..780b615 Binary files /dev/null and b/boards/dk-tm4c129x/hibernate/gcc/hibernate.bin differ diff --git a/boards/dk-tm4c129x/hibernate/hibernate.c b/boards/dk-tm4c129x/hibernate/hibernate.c new file mode 100644 index 0000000..0062fd3 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/hibernate.c @@ -0,0 +1,1568 @@ +//***************************************************************************** +// +// hibernate.c - Hibernation Example. +// +// Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved. +// Software License Agreement +// +// Texas Instruments (TI) is supplying this software for use solely and +// exclusively on TI's microcontroller products. The software is owned by +// TI and/or its suppliers, and is protected under applicable copyright +// laws. You may not combine this software with "viral" open-source +// software in order to form a larger program. +// +// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +// DAMAGES, FOR ANY REASON WHATSOEVER. +// +// This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package. +// +//***************************************************************************** + +#include +#include +#include +#include +#include "inc/hw_gpio.h" +#include "inc/hw_hibernate.h" +#include "inc/hw_ints.h" +#include "inc/hw_memmap.h" +#include "inc/hw_sysctl.h" +#include "inc/hw_types.h" +#include "driverlib/debug.h" +#include "driverlib/gpio.h" +#include "driverlib/hibernate.h" +#include "driverlib/interrupt.h" +#include "driverlib/pin_map.h" +#include "driverlib/rom.h" +#include "driverlib/rom_map.h" +#include "driverlib/sysctl.h" +#include "driverlib/uart.h" +#include "grlib/grlib.h" +#include "grlib/widget.h" +#include "grlib/canvas.h" +#include "grlib/pushbutton.h" +#include "drivers/frame.h" +#include "drivers/kentec320x240x16_ssd2119.h" +#include "drivers/pinout.h" +#include "drivers/touch.h" +#include "utils/ustdlib.h" + +//***************************************************************************** +// +//! \addtogroup example_list +//!

Hibernate Example (hibernate)

+//! +//! An example to demonstrate the use of the Hibernation module. The user +//! can put the microcontroller in hibernation by touching the display. The +//! microcontroller will then wake on its own after 5 seconds, or immediately +//! if the user presses the RESET button. External WAKE pin and GPIO (PK5) +//! wake sources can also be used to wake immediately from hibernation. The +//! following wiring enables the use of these pins as wake sources. +//! WAKE on J27 to SEL on J37 +//! PK5 on J28 to UP on J37 +//! +//! The program keeps a count of the number of times it has entered +//! hibernation. The value of the counter is stored in the battery backed +//! memory of the Hibernation module so that it can be retrieved when the +//! microcontroller wakes. The program displays the wall time and date by +//! making use of the calendar function of the Hibernate module. User can +//! modify the date and time if so desired. +// +//***************************************************************************** + +//***************************************************************************** +// +// A collection of wake sources that will be displayed to indicate the source +// of the most recent wake. +// +//***************************************************************************** +static char *g_ppcWakeSource[] = +{ + "RTC TIMEOUT", + "RESET", + "WAKE PIN", + "GPIO WAKE", + "SYSTEM RESET" +}; + +//***************************************************************************** +// +// Lookup table to convert numerical value of a month into text. +// +//***************************************************************************** +static char *g_ppcMonth[12] = +{ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec" +}; + +//***************************************************************************** +// +// Flag to indicate that main screen is active so that main screen buffers can +// be updated and widgets redrawn. +// +//***************************************************************************** +bool g_bMainScreen; + +//***************************************************************************** +// +// Flag that informs that the user has requested hibernation. +// +//***************************************************************************** +volatile bool g_bHibernate; + +//***************************************************************************** +// +// Flag that informs that date and time have to be set. +// +//***************************************************************************** +volatile bool g_bSetDate; + +//***************************************************************************** +// +// Buffers to store widget display information. +// +//***************************************************************************** +char g_pcWakeBuf[40], g_pcHibBuf[40], g_pcDateTimeBuf[40]; +char g_pcInfoBuf0[40], g_pcInfoBuf1[40], g_pcInfoBuf2[40], g_pcInfoBuf3[40]; +char g_pcMonBuf[4], g_pcDayBuf[3], g_pcYearBuf[5]; +char g_pcHourBuf[3], g_pcMinBuf[3], g_pcAMPMBuf[3]; + +//***************************************************************************** +// +// Variables that keep track of the date and time across different screens. +// +//***************************************************************************** +uint32_t g_ui32MonthIdx, g_ui32DayIdx, g_ui32YearIdx; +uint32_t g_ui32HourIdx, g_ui32MinIdx; + +//***************************************************************************** +// +// Forward reference for widget structures. +// +//***************************************************************************** +extern tCanvasWidget g_sMainScreen; +extern tCanvasWidget g_sWakeInfo, g_sHibCount, g_sDateTime; +extern tPushButtonWidget g_sInfoStrBtn; +extern tCanvasWidget g_sInfoStr1, g_sInfoStr2, g_sInfoStr3; +extern tPushButtonWidget g_sDateTimeSetBtn; +extern tCanvasWidget g_sDateScreen; +extern tCanvasWidget g_sMonText; +extern tPushButtonWidget g_sMonUpBtn, g_sMonDwnBtn; +extern tCanvasWidget g_sDayText; +extern tPushButtonWidget g_sDayUpBtn, g_sDayDwnBtn; +extern tCanvasWidget g_sYearText; +extern tPushButtonWidget g_sYearUpBtn, g_sYearDwnBtn; +extern tPushButtonWidget g_sDateNextBtn; +extern tCanvasWidget g_sTimeScreen; +extern tCanvasWidget g_sHourText; +extern tPushButtonWidget g_sHourUpBtn, g_sHourDwnBtn; +extern tCanvasWidget g_sMinText; +extern tPushButtonWidget g_sMinUpBtn, g_sMinDwnBtn; +extern tCanvasWidget g_sAMPMText; +extern tPushButtonWidget g_sAMPMUpBtn, g_sAMPMDwnBtn; +extern tPushButtonWidget g_sTimeDoneBtn; + +//***************************************************************************** +// +// Forward reference of functions that are called on a button press. +// +//***************************************************************************** +void OnInfoStrBtnPress(tWidget *psWidget); +void OnDateTimeSetBtnPress(tWidget *psWidget); +void OnMonUpBtnPress(tWidget *psWidget); +void OnMonDwnBtnPress(tWidget *psWidget); +void OnDayUpBtnPress(tWidget *psWidget); +void OnDayDwnBtnPress(tWidget *psWidget); +void OnYearUpBtnPress(tWidget *psWidget); +void OnYearDwnBtnPress(tWidget *psWidget); +void OnDateNextBtnPress(tWidget *psWidget); +void OnHourUpBtnPress(tWidget *psWidget); +void OnHourDwnBtnPress(tWidget *psWidget); +void OnMinUpBtnPress(tWidget *psWidget); +void OnMinDwnBtnPress(tWidget *psWidget); +void OnAMPMBtnPress(tWidget *psWidget); +void OnTimeDoneBtnPress(tWidget *psWidget); + +//***************************************************************************** +// +// The graphics library structures for the Main screen. +// +//***************************************************************************** +RectangularButton(g_sDateTimeSetBtn, &g_sMainScreen, 0, 0, + &g_sKentec320x240x16_SSD2119, (319 - 9 - 95), 34, 95, 45, + (PB_STYLE_TEXT | PB_STYLE_FILL | PB_STYLE_OUTLINE | + PB_STYLE_TEXT_OPAQUE), ClrDarkBlue, ClrBlue, 0, ClrWhite, + g_psFontCm16, "DATE/TIME", 0, 0, 0, 0, + OnDateTimeSetBtnPress); +Canvas(g_sDateTime, &g_sMainScreen, &g_sDateTimeSetBtn, 0, + &g_sKentec320x240x16_SSD2119, 9, 50, (310 - 9 - 100), 17, + (CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT), ClrBlack, 0, ClrWhite, + g_psFontCm16, g_pcDateTimeBuf, 0, 0); +Canvas(g_sWakeInfo, &g_sMainScreen, &g_sDateTime, 0, + &g_sKentec320x240x16_SSD2119, 9, 100, (310 - 9), 17, CANVAS_STYLE_TEXT, + ClrBlack, 0, ClrWhite, g_psFontCm16, g_pcWakeBuf, 0, 0); +Canvas(g_sHibCount, &g_sMainScreen, &g_sWakeInfo, 0, + &g_sKentec320x240x16_SSD2119, 9, 120, (310 - 9), 17, CANVAS_STYLE_TEXT, + ClrBlack, 0, ClrWhite, g_psFontCm16, g_pcHibBuf, 0, 0); +RectangularButton(g_sInfoStrBtn, &g_sMainScreen, &g_sHibCount, 0, + &g_sKentec320x240x16_SSD2119, 9, 150, (310 - 9), 25, + (PB_STYLE_TEXT | PB_STYLE_FILL | PB_STYLE_OUTLINE | + PB_STYLE_TEXT_OPAQUE), ClrDarkBlue, ClrBlue, 0, ClrWhite, + g_psFontCm16, g_pcInfoBuf0, 0, 0, 0, 0, OnInfoStrBtnPress); +Canvas(g_sInfoStr1, &g_sMainScreen, &g_sInfoStrBtn, 0, + &g_sKentec320x240x16_SSD2119, 9, 175, (310 - 9), 17, + (CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT), ClrBlack, 0, ClrWhite, + g_psFontCm16, g_pcInfoBuf1, 0, 0); +Canvas(g_sInfoStr2, &g_sMainScreen, &g_sInfoStr1, 0, + &g_sKentec320x240x16_SSD2119, 9, 192, (310 - 9), 17, + (CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT), ClrBlack, 0, ClrWhite, + g_psFontCm16, g_pcInfoBuf2, 0, 0); +Canvas(g_sInfoStr3, &g_sMainScreen, &g_sInfoStr2, 0, + &g_sKentec320x240x16_SSD2119, 9, 209, (310 - 9), 17, + (CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT), ClrBlack, 0, ClrWhite, + g_psFontCm16, g_pcInfoBuf3, 0, 0); +Canvas(g_sMainScreen, WIDGET_ROOT, 0, &g_sInfoStr3, + &g_sKentec320x240x16_SSD2119, 9, 25, (310 - 9), (230 - 25), + CANVAS_STYLE_FILL, ClrBlack, 0, 0, 0, 0, 0, 0); + +//***************************************************************************** +// +// The graphics library structures for the Date screen. +// +//***************************************************************************** +RectangularButton(g_sDateNextBtn, &g_sDateScreen, 0, 0, + &g_sKentec320x240x16_SSD2119, 240, 190, 60, 30, + (PB_STYLE_TEXT | PB_STYLE_FILL | PB_STYLE_OUTLINE | + PB_STYLE_TEXT_OPAQUE), ClrDarkBlue, ClrBlue, 0, ClrWhite, + g_psFontCm16, "NEXT", 0, 0, 0, 0, OnDateNextBtnPress); +CircularButton(g_sYearDwnBtn, &g_sDateScreen, &g_sDateNextBtn, 0, + &g_sKentec320x240x16_SSD2119, 260, 90, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE | PB_STYLE_AUTO_REPEAT), + ClrDarkBlue, ClrBlue, 0, ClrWhite, g_psFontCm20, "+", 0, 0, 100, + 10, OnYearDwnBtnPress); +CircularButton(g_sYearUpBtn, &g_sDateScreen, &g_sYearDwnBtn, 0, + &g_sKentec320x240x16_SSD2119, 260, 153, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE | PB_STYLE_AUTO_REPEAT), + ClrDarkBlue, ClrBlue, 0, ClrWhite, g_psFontCm20, "-", 0, 0, 100, + 10, OnYearUpBtnPress); +Canvas(g_sYearText, &g_sDateScreen, &g_sYearUpBtn, 0, + &g_sKentec320x240x16_SSD2119, 230, 110, 60, 25, (CANVAS_STYLE_OUTLINE | + CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT), ClrBlack, ClrWhite, ClrWhite, + g_psFontCm16, g_pcYearBuf, 0, 0); +CircularButton(g_sDayDwnBtn, &g_sDateScreen, &g_sYearText, 0, + &g_sKentec320x240x16_SSD2119, 160, 90, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE | PB_STYLE_AUTO_REPEAT), + ClrDarkBlue, ClrBlue, 0, ClrWhite, g_psFontCm20, "+", 0, 0, 100, + 10, OnDayDwnBtnPress); +CircularButton(g_sDayUpBtn, &g_sDateScreen, &g_sDayDwnBtn, 0, + &g_sKentec320x240x16_SSD2119, 160, 153, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE | PB_STYLE_AUTO_REPEAT), + ClrDarkBlue, ClrBlue, 0, ClrWhite, g_psFontCm20, "-", 0, 0, 100, + 10, OnDayUpBtnPress); +Canvas(g_sDayText, &g_sDateScreen, &g_sDayUpBtn, 0, + &g_sKentec320x240x16_SSD2119, 130, 110, 60, 25, (CANVAS_STYLE_OUTLINE | + CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT), ClrBlack, ClrWhite, ClrWhite, + g_psFontCm16, g_pcDayBuf, 0, 0); +CircularButton(g_sMonDwnBtn, &g_sDateScreen, &g_sDayText, 0, + &g_sKentec320x240x16_SSD2119, 60, 90, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE | PB_STYLE_AUTO_REPEAT), + ClrDarkBlue, ClrBlue, 0, ClrWhite, g_psFontCm20, "+", 0, 0, 100, + 20, OnMonDwnBtnPress); +CircularButton(g_sMonUpBtn, &g_sDateScreen, &g_sMonDwnBtn, 0, + &g_sKentec320x240x16_SSD2119, 60, 153, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE | PB_STYLE_AUTO_REPEAT), + ClrDarkBlue, ClrBlue, 0, ClrWhite, g_psFontCm20, "-", 0, 0, 100, + 20, OnMonUpBtnPress); +Canvas(g_sMonText, &g_sDateScreen, &g_sMonUpBtn, 0, + &g_sKentec320x240x16_SSD2119, 30, 110, 60, 25, (CANVAS_STYLE_OUTLINE | + CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT), ClrBlack, ClrWhite, ClrWhite, + g_psFontCm16, g_pcMonBuf, 0, 0); +Canvas(g_sDateScreen, WIDGET_ROOT, 0, &g_sMonText, + &g_sKentec320x240x16_SSD2119, 9, 25, (310 - 9), (230 - 25), + CANVAS_STYLE_FILL, ClrBlack, 0, 0, 0, 0, 0, 0); + +//***************************************************************************** +// +// The graphics library structures for the Time screen. +// +//***************************************************************************** +RectangularButton(g_sTimeDoneBtn, &g_sTimeScreen, 0, 0, + &g_sKentec320x240x16_SSD2119, 240, 190, 60, 30, + (PB_STYLE_TEXT | PB_STYLE_FILL | PB_STYLE_OUTLINE | + PB_STYLE_TEXT_OPAQUE), ClrDarkBlue, ClrBlue, 0, ClrWhite, + g_psFontCm16, "DONE", 0, 0, 0, 0, OnTimeDoneBtnPress); +CircularButton(g_sAMPMDwnBtn, &g_sTimeScreen, &g_sTimeDoneBtn, 0, + &g_sKentec320x240x16_SSD2119, 260, 90, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE), ClrDarkBlue, ClrBlue, 0, + ClrWhite, g_psFontCm20, "+", 0, 0, 0, 0, OnAMPMBtnPress); +CircularButton(g_sAMPMUpBtn, &g_sTimeScreen, &g_sAMPMDwnBtn, 0, + &g_sKentec320x240x16_SSD2119, 260, 153, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE), ClrDarkBlue, ClrBlue, 0, + ClrWhite, g_psFontCm20, "-", 0, 0, 0, 0, OnAMPMBtnPress); +Canvas(g_sAMPMText, &g_sTimeScreen, &g_sAMPMUpBtn, 0, + &g_sKentec320x240x16_SSD2119, 230, 110, 60, 25, (CANVAS_STYLE_OUTLINE | + CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT), ClrBlack, ClrWhite, ClrWhite, + g_psFontCm16, g_pcAMPMBuf, 0, 0); +CircularButton(g_sMinDwnBtn, &g_sTimeScreen, &g_sAMPMText, 0, + &g_sKentec320x240x16_SSD2119, 160, 90, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE | PB_STYLE_AUTO_REPEAT), + ClrDarkBlue, ClrBlue, 0, ClrWhite, g_psFontCm20, "+", 0, 0, 100, + 10, OnMinDwnBtnPress); +CircularButton(g_sMinUpBtn, &g_sTimeScreen, &g_sMinDwnBtn, 0, + &g_sKentec320x240x16_SSD2119, 160, 153, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE | PB_STYLE_AUTO_REPEAT), + ClrDarkBlue, ClrBlue, 0, ClrWhite, g_psFontCm20, "-", 0, 0, 100, + 10, OnMinUpBtnPress); +Canvas(g_sMinText, &g_sTimeScreen, &g_sMinUpBtn, 0, + &g_sKentec320x240x16_SSD2119, 130, 110, 60, 25, (CANVAS_STYLE_OUTLINE | + CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT), ClrBlack, ClrWhite, ClrWhite, + g_psFontCm16, g_pcMinBuf, 0, 0); +CircularButton(g_sHourDwnBtn, &g_sTimeScreen, &g_sMinText, 0, + &g_sKentec320x240x16_SSD2119, 60, 90, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE | PB_STYLE_AUTO_REPEAT), + ClrDarkBlue, ClrBlue, 0, ClrWhite, g_psFontCm20, "+", 0, 0, 100, + 20, OnHourDwnBtnPress); +CircularButton(g_sHourUpBtn, &g_sTimeScreen, &g_sHourDwnBtn, 0, + &g_sKentec320x240x16_SSD2119, 60, 153, 15, (PB_STYLE_TEXT | + PB_STYLE_FILL | PB_STYLE_TEXT_OPAQUE | PB_STYLE_AUTO_REPEAT), + ClrDarkBlue, ClrBlue, 0, ClrWhite, g_psFontCm20, "-", 0, 0, 100, + 20, OnHourUpBtnPress); +Canvas(g_sHourText, &g_sTimeScreen, &g_sHourUpBtn, 0, + &g_sKentec320x240x16_SSD2119, 30, 110, 60, 25, (CANVAS_STYLE_OUTLINE | + CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT), ClrBlack, ClrWhite, ClrWhite, + g_psFontCm16, g_pcHourBuf, 0, 0); +Canvas(g_sTimeScreen, WIDGET_ROOT, 0, &g_sHourText, + &g_sKentec320x240x16_SSD2119, 9, 25, (310 - 9), (230 - 25), + CANVAS_STYLE_FILL, ClrBlack, 0, 0, 0, 0, 0, 0); + +//***************************************************************************** +// +// The error routine that is called if the driver library encounters an error. +// +//***************************************************************************** +#ifdef DEBUG +void +__error__(char *pcFilename, uint32_t ui32Line) +{ +} +#endif + +//***************************************************************************** +// +// This function reads the current date and time from the calendar logic of the +// hibernate module. Return status indicates the validity of the data read. +// If the received data is valid, the 24-hour time format is converted to +// 12-hour format. +// +//***************************************************************************** +bool +DateTimeGet(struct tm *sTime, char *pcAMPM) +{ + // + // Get the latest time. + // + HibernateCalendarGet(sTime); + + // + // Is valid data read? + // + if(((sTime->tm_sec < 0) || (sTime->tm_sec > 59)) || + ((sTime->tm_min < 0) || (sTime->tm_min > 59)) || + ((sTime->tm_hour < 0) || (sTime->tm_hour > 23)) || + ((sTime->tm_mday < 1) || (sTime->tm_mday > 31)) || + ((sTime->tm_mon < 0) || (sTime->tm_mon > 11)) || + ((sTime->tm_year < 100) || (sTime->tm_year > 199))) + { + // + // No - Let the application know the same by returning relevant + // message. + // + return false; + } + + // + // Set AM as default. + // + strcpy(pcAMPM, "AM"); + + // + // Convert 24-hour format into 12-hour format with AM/PM indication. + // + if(sTime->tm_hour == 0) + { + sTime->tm_hour = 12; + strcpy(pcAMPM, "AM"); + } + else if(sTime->tm_hour == 12) + { + strcpy(pcAMPM, "PM"); + } + else if(sTime->tm_hour > 12) + { + sTime->tm_hour -= 12; + strcpy(pcAMPM, "PM"); + } + + // + // Return that new data is available so that it can be displayed. + // + return true; +} + +//***************************************************************************** +// +// This function formats valid new date and time to be displayed on the home +// screen in the format "MMM DD, YYYY HH : MM : SS AM/PM". Example of this +// format is Aug 01, 2013 08:15:30 AM. It also indicates if valid new data +// is available or not. If date and time is invalid, this function sets the +// date and time to default value. +// +//***************************************************************************** +bool +DateTimeDisplayGet(char *pcBuf, uint32_t ui32BufSize) +{ + static uint32_t ui32SecondsPrev = 0xFF; + struct tm sTime; + char pcAMPM[3]; + uint32_t ui32Len; + + // + // Get the latest date and time and check the validity. + // + if(DateTimeGet(&sTime, pcAMPM) == false) + { + // + // Invalid - Force set the date and time to default values and return + // false to indicate no information to display. + // + g_bSetDate = true; + return false; + } + + // + // If date and time is valid, check if seconds have updated from previous + // visit. + // + if(ui32SecondsPrev == sTime.tm_sec) + { + // + // No - Return false to indicate no information to display. + // + return false; + } + + // + // If valid new date and time is available, update a local variable to keep + // track of seconds to determine new data for next visit. + // + ui32SecondsPrev = sTime.tm_sec; + + // + // Format the date and time into a user readable format. + // + ui32Len = usnprintf(pcBuf, ui32BufSize, "%s %02u, 20%02u ", + g_ppcMonth[sTime.tm_mon], sTime.tm_mday, + sTime.tm_year - 100); + usnprintf(&pcBuf[ui32Len], ui32BufSize - ui32Len, "%02u : %02u : %02u %s", + sTime.tm_hour, sTime.tm_min, sTime.tm_sec, pcAMPM); + + // + // Return true to indicate new information to display. + // + return true; +} + +//***************************************************************************** +// +// This function updates individual buffers with valid date and time to be +// displayed on the date screen so that the date and time can be updated. +// +//***************************************************************************** +bool +DateTimeUpdateGet(char *pcMon, char *pcDay, char *pcYear, char *pcHour, + char *pcMin, char *pcAMPM) +{ + struct tm sTime; + + // + // Get the latest date and time and check the validity. + // + if(DateTimeGet(&sTime, pcAMPM) == false) + { + // + // Invalid - Return here with false as no information to update. So + // use default values. + // + return false; + } + + // + // If date and time is valid, copy the date and time values into respective + // indexes. + // + g_ui32MonthIdx = sTime.tm_mon; + g_ui32DayIdx = sTime.tm_mday; + g_ui32YearIdx = sTime.tm_year - 100; + g_ui32HourIdx = sTime.tm_hour; + g_ui32MinIdx = sTime.tm_min; + + // + // Convert the date and time into string format and copy into supplied + // buffers. + // + usnprintf(pcMon, 4, "%s", g_ppcMonth[g_ui32MonthIdx]); + usnprintf(pcDay, 3, "%u", g_ui32DayIdx); + usnprintf(pcYear, 5, "20%02u", g_ui32YearIdx); + usnprintf(pcHour, 3, "%u", g_ui32HourIdx); + usnprintf(pcMin, 3, "%02u", g_ui32MinIdx); + + // + // Return true to indicate new information has been updated. + // + return true; +} + +//***************************************************************************** +// +// This function writes the requested date and time to the calendar logic of +// hibernation module. +// +//***************************************************************************** +void +DateTimeSet(void) +{ + struct tm sTime; + + // + // Get the latest date and time. This is done here so that unchanged + // parts of date and time can be written back as is. + // + HibernateCalendarGet(&sTime); + + // + // Set the date and time values that are to be updated. + // + sTime.tm_hour = g_ui32HourIdx; + sTime.tm_min = g_ui32MinIdx; + sTime.tm_mon = g_ui32MonthIdx; + sTime.tm_mday = g_ui32DayIdx; + sTime.tm_year = 100 + g_ui32YearIdx; + + // + // Convert 12-hour format into 24-hour format. + // + if(strcmp(g_pcAMPMBuf, "PM") == 0) + { + if(sTime.tm_hour < 12) + { + sTime.tm_hour += 12; + } + } + else + { + if(sTime.tm_hour > 11) + { + sTime.tm_hour -= 12; + } + } + + // + // Update the calendar logic of hibernation module with the requested data. + // + HibernateCalendarSet(&sTime); +} + +//***************************************************************************** +// +// This function returns the number of days in a month including for a leap +// year. +// +//***************************************************************************** +uint32_t +GetDaysInMonth(uint32_t ui32Year, uint32_t ui32Mon) +{ + // + // Return the number of days based on the month. + // + if(ui32Mon == 1) + { + // + // For February return the number of days based on the year being a + // leap year or not. + // + if((ui32Year % 4) == 0) + { + // + // If leap year return 29. + // + return 29; + } + else + { + // + // If not leap year return 28. + // + return 28; + } + } + else if((ui32Mon == 3) || (ui32Mon == 5) || (ui32Mon == 8) || + (ui32Mon == 10)) + { + // + // For April, June, September and November return 30. + // + return 30; + } + + // + // For all the other months return 31. + // + return 31; +} + +//***************************************************************************** +// +// This function returns the date and time value that is written to the +// calendar match register. 5 seconds are added to the current time. Any +// side-effects due to this addition are handled here. +// +//***************************************************************************** +void +GetCalendarMatchValue(struct tm* sTime) +{ + uint32_t ui32MonthDays; + + // + // Get the current date and time and add 5 secs to it. + // + HibernateCalendarGet(sTime); + sTime->tm_sec += 5; + + // + // Check if seconds is out of bounds. If so subtract seconds by 60 and + // increment minutes. + // + if(sTime->tm_sec > 59) + { + sTime->tm_sec -= 60; + sTime->tm_min++; + } + + // + // Check if minutes is out of bounds. If so subtract minutes by 60 and + // increment hours. + // + if(sTime->tm_min > 59) + { + sTime->tm_min -= 60; + sTime->tm_hour++; + } + + // + // Check if hours is out of bounds. If so subtract minutes by 24 and + // increment days. + // + if(sTime->tm_hour > 23) + { + sTime->tm_hour -= 24; + sTime->tm_mday++; + } + + // + // Since different months have varying number of days, get the number of + // days for the current month and year. + // + ui32MonthDays = GetDaysInMonth(sTime->tm_year, sTime->tm_mon); + + // + // Check if days is out of bounds for the current month and year. If so + // subtract days by the number of days in the current month and increment + // months. + // + if(sTime->tm_mday > ui32MonthDays) + { + sTime->tm_mday -= ui32MonthDays; + sTime->tm_mon++; + } + + // + // Check if months is out of bounds. If so subtract months by 11 and + // increment years. + // + if(sTime->tm_mon > 11) + { + sTime->tm_mon -= 11; + sTime->tm_year++; + } + + // + // Check if years is out of bounds. If so subtract years by 100. + // + if(sTime->tm_year > 99) + { + sTime->tm_year -= 100; + } +} +//***************************************************************************** +// +// Handle the Info String button press on Main Screen. +// +//***************************************************************************** +void +OnInfoStrBtnPress(tWidget *psWidget) +{ + // + // If this button is pressed then user wants to enter hibernation. So + // set the respective flag. + // + g_bHibernate = true; +} + +//***************************************************************************** +// +// Handle the "Date/Time" button press on Main Screen. +// +//***************************************************************************** +void +OnDateTimeSetBtnPress(tWidget *psWidget) +{ + // + // Update the date and time screen buffers before painting the screens. + // Even though only buffers used with the date screen are needed at this + // time, we update both to save few cycles. + // + DateTimeUpdateGet(g_pcMonBuf, g_pcDayBuf, g_pcYearBuf, g_pcHourBuf, + g_pcMinBuf, g_pcAMPMBuf); + + // + // Remove the main screen from the root. + // + WidgetRemove((tWidget *)&g_sMainScreen); + + // + // Add the date screen to the root. + // + WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sDateScreen); + + // + // Add the widget tree to message queue so that it can be drawn on the + // display. + // + WidgetPaint(WIDGET_ROOT); + + // + // Set the flag to indicate that the main screen is not active. + // + g_bMainScreen = false; +} + +//***************************************************************************** +// +// Handle the Month "-" button press on Date Screen. +// +//***************************************************************************** +void +OnMonUpBtnPress(tWidget *psWidget) +{ + uint32_t ui32DaysInMonth; + + // + // User wants to decrement the month. So reduce index by one such that the + // index cycles back to the bottom of the list if it is at the top. + // + g_ui32MonthIdx = (g_ui32MonthIdx == 0) ? 11 : g_ui32MonthIdx - 1; + + // + // Store the index in a buffer as a string and add the widget to the + // message queue so that it can be redrawn. + // + strcpy(g_pcMonBuf, g_ppcMonth[g_ui32MonthIdx]); + WidgetPaint(&g_sMonText.sBase); + + // + // Makes sure that the day value does not exceed the number of days for the + // selected month. + // + ui32DaysInMonth = GetDaysInMonth(g_ui32YearIdx, g_ui32MonthIdx); + g_ui32DayIdx = (g_ui32DayIdx > ui32DaysInMonth) ? ui32DaysInMonth : + g_ui32DayIdx; + + // + // Since the day value might also have been modified, store the day index + // in a buffer as a string and add the widget to the message queue so that + // it can be redrawn. + // + usnprintf(g_pcDayBuf, sizeof(g_pcDayBuf), "%02u", g_ui32DayIdx); + WidgetPaint(&g_sDayText.sBase); +} + +//***************************************************************************** +// +// Handle the Month "+" button press on Date Screen. +// +//***************************************************************************** +void +OnMonDwnBtnPress(tWidget *psWidget) +{ + uint32_t ui32DaysInMonth; + + // + // User wants to increment the month. So increment index by one such that + // the index cycles back to the top of the list if it is at the bottom. + // + g_ui32MonthIdx = (g_ui32MonthIdx == 11) ? 0 : g_ui32MonthIdx + 1; + + // + // Store the index in a buffer as a string and add the widget to the + // message queue so that it can be redrawn. + // + strcpy(g_pcMonBuf, g_ppcMonth[g_ui32MonthIdx]); + WidgetPaint(&g_sMonText.sBase); + + // + // Makes sure that the day value does not exceed the number of days for the + // selected month. + // + ui32DaysInMonth = GetDaysInMonth(g_ui32YearIdx, g_ui32MonthIdx); + g_ui32DayIdx = (g_ui32DayIdx > ui32DaysInMonth) ? ui32DaysInMonth : + g_ui32DayIdx; + + // + // Since the day value might also have been modified, store the day index + // in a buffer as a string and add the widget to the message queue so that + // it can be redrawn. + // + usnprintf(g_pcDayBuf, sizeof(g_pcDayBuf), "%02u", g_ui32DayIdx); + WidgetPaint(&g_sDayText.sBase); +} + +//***************************************************************************** +// +// Handle the Day "-" button press on Date Screen. +// +//***************************************************************************** +void +OnDayUpBtnPress(tWidget *psWidget) +{ + uint32_t ui32DaysInMonth; + + // + // User wants to decrement the day. So reduce index by one such that the + // index cycles back to the bottom of the list if it is at the top. Make + // sure that the day index is adjusted based on the number of days in a + // month. + // + ui32DaysInMonth = GetDaysInMonth(g_ui32YearIdx, g_ui32MonthIdx); + g_ui32DayIdx = (g_ui32DayIdx < 2) ? ui32DaysInMonth : g_ui32DayIdx - 1; + + // + // Store the index in a buffer as a string and add the widget to the + // message queue so that it can be redrawn. + // + usnprintf(g_pcDayBuf, sizeof(g_pcDayBuf), "%02u", g_ui32DayIdx); + WidgetPaint(&g_sDayText.sBase); +} + +//***************************************************************************** +// +// Handle the Day "+" button press on Date Screen. +// +//***************************************************************************** +void +OnDayDwnBtnPress(tWidget *psWidget) +{ + uint32_t ui32DaysInMonth; + + // + // User wants to increment the day. So increment index by one such that + // the index cycles back to the top of the list if it is at the bottom. + // Make sure that the day index does not exceed the number of days for the + // selected month. + // + ui32DaysInMonth = GetDaysInMonth(g_ui32YearIdx, g_ui32MonthIdx); + g_ui32DayIdx = (g_ui32DayIdx > (ui32DaysInMonth - 1)) ? 1 : + (g_ui32DayIdx + 1); + + // + // Store the index in a buffer as a string and add the widget to the + // message queue so that it can be redrawn. + // + usnprintf(g_pcDayBuf, sizeof(g_pcDayBuf), "%02u", g_ui32DayIdx); + WidgetPaint(&g_sDayText.sBase); +} + +//***************************************************************************** +// +// Handle the Year "-" button press on Date Screen. +// +//***************************************************************************** +void +OnYearUpBtnPress(tWidget *psWidget) +{ + uint32_t ui32DaysInMonth; + + // + // User wants to decrement the year. So reduce index by one such that the + // index cycles back to the bottom of the list if it is at the top. + // + g_ui32YearIdx = (g_ui32YearIdx == 0) ? 99 : g_ui32YearIdx - 1; + + // + // Store the index in a buffer as a string and add the widget to the + // message queue so that it can be redrawn. + // + usnprintf(g_pcYearBuf, sizeof(g_pcYearBuf), "20%02u", g_ui32YearIdx); + WidgetPaint(&g_sYearText.sBase); + + // + // Makes sure that the day value does not exceed the number of days for the + // selected month. + // + ui32DaysInMonth = GetDaysInMonth(g_ui32YearIdx, g_ui32MonthIdx); + g_ui32DayIdx = (g_ui32DayIdx > ui32DaysInMonth) ? ui32DaysInMonth : + g_ui32DayIdx; + + // + // Since the day value might also have been modified, store the day index + // in a buffer as a string and add the widget to the message queue so that + // it can be redrawn. + // + usnprintf(g_pcDayBuf, sizeof(g_pcDayBuf), "%02u", g_ui32DayIdx); + WidgetPaint(&g_sDayText.sBase); +} + +//***************************************************************************** +// +// Handle the Year "+" button press on Date Screen. +// +//***************************************************************************** +void +OnYearDwnBtnPress(tWidget *psWidget) +{ + uint32_t ui32DaysInMonth; + + // + // User wants to increment the year. So increment index by one such that + // the index cycles back to the top of the list if it is at the bottom. + // + g_ui32YearIdx = (g_ui32YearIdx == 99) ? 0 : g_ui32YearIdx + 1; + + // + // Store the index in a buffer as a string and add the widget to the + // message queue so that it can be redrawn. + // + usnprintf(g_pcYearBuf, sizeof(g_pcYearBuf), "20%02u", g_ui32YearIdx); + WidgetPaint(&g_sYearText.sBase); + + // + // Makes sure that the day value does not exceed the number of days for the + // selected month. + // + ui32DaysInMonth = GetDaysInMonth(g_ui32YearIdx, g_ui32MonthIdx); + g_ui32DayIdx = (g_ui32DayIdx > ui32DaysInMonth) ? ui32DaysInMonth : + g_ui32DayIdx; + + // + // Since the day value might also have been modified, store the day index + // in a buffer as a string and add the widget to the message queue so that + // it can be redrawn. + // + usnprintf(g_pcDayBuf, sizeof(g_pcDayBuf), "%02u", g_ui32DayIdx); + WidgetPaint(&g_sDayText.sBase); +} + +//***************************************************************************** +// +// Handle the "NEXT" button press on Date Screen. +// +//***************************************************************************** +void +OnDateNextBtnPress(tWidget *psWidget) +{ + // + // Remove the main screen from the root. + // + WidgetRemove((tWidget *)&g_sDateScreen); + + // + // Add the date screen to the root. + // + WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sTimeScreen); + + // + // Add the widget tree to message queue so that it can be drawn on the + // display. + // + WidgetPaint(WIDGET_ROOT); +} + +//***************************************************************************** +// +// Handle the Hour "-" button press on Time Screen. +// +//***************************************************************************** +void +OnHourUpBtnPress(tWidget *psWidget) +{ + // + // User wants to decrement the hour. So reduce index by one such that the + // index cycles back to the bottom of the list if it is at the top. + // + g_ui32HourIdx = (g_ui32HourIdx == 1) ? 12 : g_ui32HourIdx - 1; + + // + // Store the index in a buffer as a string and add the widget to the + // message queue so that it can be redrawn. + // + usnprintf(g_pcHourBuf, sizeof(g_pcHourBuf), "%u", g_ui32HourIdx); + WidgetPaint(&g_sHourText.sBase); +} + +//***************************************************************************** +// +// Handle the Hour "+" button press on Time Screen. +// +//***************************************************************************** +void +OnHourDwnBtnPress(tWidget *psWidget) +{ + // + // User wants to increment the hour. So increment index by one such that + // the index cycles back to the top of the list if it is at the bottom. + // + g_ui32HourIdx = (g_ui32HourIdx == 12) ? 1 : g_ui32HourIdx + 1; + + // + // Store the index in a buffer as a string and add the widget to the + // message queue so that it can be redrawn. + // + usnprintf(g_pcHourBuf, sizeof(g_pcHourBuf), "%u", g_ui32HourIdx); + WidgetPaint(&g_sHourText.sBase); +} + +//***************************************************************************** +// +// Handle the Minute "-" button press on Time Screen. +// +//***************************************************************************** +void +OnMinUpBtnPress(tWidget *psWidget) +{ + // + // User wants to decrement the minute. So reduce index by one such that + // the index cycles back to the bottom of the list if it is at the top. + // + g_ui32MinIdx = (g_ui32MinIdx == 0) ? 59 : g_ui32MinIdx - 1; + + // + // Store the index in a buffer as a string and add the widget to the + // message queue so that it can be redrawn. + // + usnprintf(g_pcMinBuf, sizeof(g_pcMinBuf), "%02u", g_ui32MinIdx); + WidgetPaint(&g_sMinText.sBase); +} + +//***************************************************************************** +// +// Handle the Minute "+" button press on Time Screen. +// +//***************************************************************************** +void +OnMinDwnBtnPress(tWidget *psWidget) +{ + // + // User wants to increment the minute. So increment index by one such that + // the index cycles back to the top of the list if it is at the bottom. + // + g_ui32MinIdx = (g_ui32MinIdx == 59) ? 0 : g_ui32MinIdx + 1; + + // + // Store the index in a buffer as a string and add the widget to the + // message queue so that it can be redrawn. + // + usnprintf(g_pcMinBuf, sizeof(g_pcMinBuf), "%02u", g_ui32MinIdx); + WidgetPaint(&g_sMinText.sBase); +} + +//***************************************************************************** +// +// Handle the AM/PM "+" and "-" button press on Time Screen. The same function +// handles both the button presses. +// +//***************************************************************************** +void +OnAMPMBtnPress(tWidget *psWidget) +{ + // + // User wants to change AM to PM or vice versa. Change to "PM" if "AM" and + // vice versa. + // + if(strcmp(g_pcAMPMBuf, "AM") == 0) + { + strcpy(g_pcAMPMBuf, "PM"); + } + else + { + strcpy(g_pcAMPMBuf, "AM"); + } + + // + // Add the widget to the message queue so that it can be redrawn. + // + WidgetPaint(&g_sAMPMText.sBase); +} + +//***************************************************************************** +// +// Handle the "DONE" button press on Time Screen. +// +//***************************************************************************** +void +OnTimeDoneBtnPress(tWidget *psWidget) +{ + // + // Remove the main screen from the root. + // + WidgetRemove((tWidget *)&g_sTimeScreen); + + // + // Add the date screen to the root. + // + WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sMainScreen); + + // + // Add the widget tree to message queue so that it can be drawn on the + // display. + // + WidgetPaint(WIDGET_ROOT); + + // + // Set the flag to indicate that date and time have to updated. + // + g_bSetDate = true; +} + +//***************************************************************************** +// +// This example demonstrates the different hibernate wake sources. The +// microcontroller is put into hibernation by the user and wakes up based on +// timeout or one of the user inputs. This example also demonstrates the RTC +// calendar function that keeps track of date and time. +// +//***************************************************************************** +int +main(void) +{ + tContext sContext; + struct tm sTime; + bool bUpdate; + uint32_t ui32SysClock, ui32Status, ui32HibernateCount, ui32Len; + + // + // Run from the PLL at 120 MHz. + // + ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | + SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | + SYSCTL_CFG_VCO_480), 120000000); + + // + // Configure the device pins. + // + PinoutSet(); + + // + // Initialize the display driver. + // + Kentec320x240x16_SSD2119Init(ui32SysClock); + + // + // Initialize the graphics context. + // + GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119); + + // + // Draw the application frame. + // + FrameDraw(&sContext, "hibernate"); + + // + // Flush any cached drawing operations. + // + GrFlush(&sContext); + + // + // Set a font henceforth. + // + GrContextFontSet(&sContext, g_psFontCm16); + + // + // Initialize the touch screen driver. + // + TouchScreenInit(ui32SysClock); + TouchScreenCallbackSet(WidgetPointerMessage); + + // + // Add the compile-time defined widgets to the widget tree. + // + WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sMainScreen); + + // + // Enable the hibernate module. + // + SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE); + + // + // Initialize these variables before they are used. + // + ui32Status = 0; + ui32HibernateCount = 0; + + // + // Check to see if Hibernation module is already active, which could mean + // that the processor is waking from a hibernation. + // + if(HibernateIsActive()) + { + // + // Read the status bits to see what caused the wake. Clear the wake + // source so that the device can be put into hibernation again. + // + ui32Status = HibernateIntStatus(0); + HibernateIntClear(ui32Status); + + // + // Store the common part of the wake information message into a buffer. + // The wake source will be appended based on the status bits. + // + ui32Len = usnprintf(g_pcWakeBuf, sizeof(g_pcWakeBuf), + "Wake Due To : "); + + // + // Wake was due to RTC match. + // + if(ui32Status & HIBERNATE_INT_RTC_MATCH_0) + { + ui32Len = usnprintf(&g_pcWakeBuf[ui32Len], + sizeof(g_pcWakeBuf) - ui32Len, "%s", + g_ppcWakeSource[0]); + } + + // + // Wake was due to Reset button. + // + else if(ui32Status & HIBERNATE_INT_RESET_WAKE) + { + ui32Len = usnprintf(&g_pcWakeBuf[ui32Len], + sizeof(g_pcWakeBuf) - ui32Len, "%s", + g_ppcWakeSource[1]); + } + + // + // Wake was due to the External Wake pin. + // + else if(ui32Status & HIBERNATE_INT_PIN_WAKE) + { + ui32Len = usnprintf(&g_pcWakeBuf[ui32Len], + sizeof(g_pcWakeBuf) - ui32Len, "%s", + g_ppcWakeSource[2]); + } + + // + // Wake was due to GPIO wake. + // + else if(ui32Status & HIBERNATE_INT_GPIO_WAKE) + { + ui32Len = usnprintf(&g_pcWakeBuf[ui32Len], + sizeof(g_pcWakeBuf) - ui32Len, "%s", + g_ppcWakeSource[3]); + } + + // + // If the wake is due to any of the configured wake sources, then read + // the first location from the battery backed memory, as the + // hibernation count. + // + if(ui32Status & (HIBERNATE_INT_PIN_WAKE | HIBERNATE_INT_RTC_MATCH_0 | + HIBERNATE_INT_GPIO_WAKE | HIBERNATE_INT_RESET_WAKE)) + { + HibernateDataGet(&ui32HibernateCount, 1); + } + } + + // + // Configure Hibernate module clock. + // + HibernateEnableExpClk(ui32SysClock); + + // + // If the wake was not due to the above sources, then it was a system + // reset. + // + if(!(ui32Status & (HIBERNATE_INT_PIN_WAKE | HIBERNATE_INT_RTC_MATCH_0 | + HIBERNATE_INT_GPIO_WAKE | HIBERNATE_INT_RESET_WAKE))) + { + // + // Configure the module clock source. + // + HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE); + + // + // Store that this was a system restart, not wake from hibernation. + // + ui32Len = usnprintf(g_pcWakeBuf, sizeof(g_pcWakeBuf), "%s", + g_ppcWakeSource[4]); + + // + // Set Calendar time to start from 08/29/2013 at 8:30AM + // + g_ui32MonthIdx = 7; + g_ui32DayIdx = 29; + g_ui32YearIdx = 13; + g_ui32HourIdx = 8; + g_ui32MinIdx = 30; + strcpy(g_pcMonBuf, "AUG"); + strcpy(g_pcDayBuf, "29"); + strcpy(g_pcYearBuf, "2013"); + strcpy(g_pcHourBuf, "8"); + strcpy(g_pcMinBuf, "30"); + strcpy(g_pcAMPMBuf, "AM"); + } + + // + // Store the hibernation count message into the respective widget buffer. + // + usnprintf(g_pcHibBuf, sizeof(g_pcHibBuf), "Hibernate count = %u", + ui32HibernateCount); + + // + // Store the text, that informs the user on how to hibernate, into the + // respective widget buffer. + // + usnprintf(g_pcInfoBuf0, sizeof(g_pcInfoBuf0), "To hibernate touch HERE."); + + // + // Add the widget tree to the message queue so that it can be drawn. + // + WidgetPaint(WIDGET_ROOT); + + // + // Enable RTC mode. + // + HibernateRTCEnable(); + + // + // Configure the hibernate module counter to 24-hour calendar mode. + // + HibernateCounterMode(HIBERNATE_COUNTER_24HR); + + // + // Configure GPIOs used as Hibernate wake source + // + GPIOPadConfigSet(GPIO_PORTK_BASE, 0x20, GPIO_STRENGTH_2MA, + (GPIO_PIN_TYPE_WAKE_LOW | GPIO_PIN_TYPE_STD_WPU)); + + // + // Enable processor interrupts. + // + IntMasterEnable(); + + // + // If hibernation count is very large, it may be that there was already + // a value in the hibernate memory, so reset the count. + // + ui32HibernateCount = (ui32HibernateCount > 10000) ? 0 : ui32HibernateCount; + + // + // Increment the hibernation count, and store it in the battery backed + // memory. + // + ui32HibernateCount++; + HibernateDataSet(&ui32HibernateCount, 1); + + // + // Initialize the necessary flags before entering indefinite loop. + // + g_bMainScreen = true; + g_bHibernate = false; + g_bSetDate = false; + + // + // Loop forever. + // + while(1) + { + // + // Process any messages for/from the widgets. + // + WidgetMessageQueueProcess(); + + // + // Check if date and time has to be written to the calendar logic of + // hibernate module. + // + if(g_bSetDate == true) + { + // + // Yes - Clear the flag to avoid unwanted writes to the calendar + // logic. + // + g_bSetDate = false; + + // + // Write the requested date and time. + // + DateTimeSet(); + + // + // Set the flag to indicate that the main screen is active. + // + g_bMainScreen = true; + } + + // + // Check if main screen is active and update the required buffers and + // redraw the required widgets. + // + if(g_bMainScreen) + { + // + // Update the buffer that displays date and time on the main + // screen. + // + bUpdate = DateTimeDisplayGet(g_pcDateTimeBuf, + sizeof(g_pcDateTimeBuf)); + + // + // Is a new value of date and time available to be displayed? + // + if(bUpdate == true) + { + // + // Yes - Redraw the widget. + // + WidgetPaint(&g_sDateTime.sBase); + } + } + + // + // Check if user wants to enter hibernation. + // + if(g_bHibernate == true) + { + // + // Yes - Clear the flag. + // + g_bHibernate = false; + + // + // Store the text, that informs the user on how to wake-up from + // hibernation, into the respective widget buffers. + // + usnprintf(g_pcInfoBuf1, sizeof(g_pcInfoBuf1), "To wake up wait " + "for 5 secs or press the"); + usnprintf(g_pcInfoBuf2, sizeof(g_pcInfoBuf2), "RESET button. " + "Refer document for"); + usnprintf(g_pcInfoBuf3, sizeof(g_pcInfoBuf3), "additional " + "wake sources."); + + // + // Redraw the widgets to display the updated buffers. These + // widgets have to be redrawn here instead of adding to the message + // queue by using WidgetPaint() function as + // WidgetMessageQueueProcess() function won't be executed before + // entering hibernation. + // + CanvasMsgProc(&g_sInfoStr1.sBase, WIDGET_MSG_PAINT, 0, 0); + CanvasMsgProc(&g_sInfoStr2.sBase, WIDGET_MSG_PAINT, 0, 0); + CanvasMsgProc(&g_sInfoStr3.sBase, WIDGET_MSG_PAINT, 0, 0); + + // + // Get calendar match value to be 5 seconds from the current time. + // + GetCalendarMatchValue(&sTime); + + // + // Set the calendar match register such that it wakes up from + // hibernation in 5 seconds. + // + HibernateCalendarMatchSet(0, &sTime); + + // + // Read and clear any status bits that might have been set since + // last clearing them. + // + ui32Status = HibernateIntStatus(0); + HibernateIntClear(ui32Status); + + // + // Configure Hibernate wake sources. + // + HibernateWakeSet(HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_GPIO | + HIBERNATE_WAKE_RESET | HIBERNATE_WAKE_RTC); + + // + // Request Hibernation. + // + HibernateRequest(); + + // + // Wait for a while for hibernate to activate. It should never get + // past this point. + // + SysCtlDelay(100); + + // + // If it ever gets here, store the text, that informs the user on + // what to do, into the respective widget buffers. + // + usnprintf(g_pcInfoBuf1, sizeof(g_pcInfoBuf1), "The controller did " + "not enter hibernate mode."); + usnprintf(g_pcInfoBuf2, sizeof(g_pcInfoBuf2), "TOUCH THE DISPLAY " + "TO RESTART."); + usnprintf(g_pcInfoBuf3, sizeof(g_pcInfoBuf3), ""); + + // + // Redraw the widgets to display the updated buffers. + // + CanvasMsgProc(&g_sInfoStr1.sBase, WIDGET_MSG_PAINT, 0, 0); + CanvasMsgProc(&g_sInfoStr2.sBase, WIDGET_MSG_PAINT, 0, 0); + CanvasMsgProc(&g_sInfoStr3.sBase, WIDGET_MSG_PAINT, 0, 0); + + // + // Wait for the user request to reset processor. Then reset the + // processor. + // + g_bHibernate = false; + while(g_bHibernate != true) + { + } + + // + // Reset the processor. + // + ROM_SysCtlReset(); + + // + // Wait here. + // + while(1) + { + } + } + } +} diff --git a/boards/dk-tm4c129x/hibernate/hibernate.ewd b/boards/dk-tm4c129x/hibernate/hibernate.ewd new file mode 100644 index 0000000..484e41a --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/hibernate.ewd @@ -0,0 +1,614 @@ + + + + 1 + + Debug + + ARM + + 1 + + C-SPY + 2 + + 15 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARMSIM_ID + 2 + + 1 + 1 + 1 + + + + + + + + ANGEL_ID + 2 + + 0 + 1 + 1 + + + + + + + + + + + + GDBSERVER_ID + 2 + + 0 + 1 + 1 + + + + + + + + + + + IARROM_ID + 2 + + 0 + 1 + 1 + + + + + + + + + + JLINK_ID + 2 + + 9 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LMIFTDI_ID + 2 + + 1 + 1 + 1 + + + + + + + + MACRAIGOR_ID + 2 + + 2 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + RDI_ID + 2 + + 1 + 1 + 1 + + + + + + + + + + + + + + + + + THIRDPARTY_ID + 2 + + 0 + 1 + 1 + + + + + + + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\OSE\OseEpsilonPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\PowerPac\PowerPacRTOS.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\Profiling\Profiling.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Stack\Stack.ENU.ewplugin + 1 + + + + diff --git a/boards/dk-tm4c129x/hibernate/hibernate.ewp b/boards/dk-tm4c129x/hibernate/hibernate.ewp new file mode 100644 index 0000000..fd4a9ad --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/hibernate.ewp @@ -0,0 +1,810 @@ + + + + 1 + + Debug + + ARM + + 1 + + General + 3 + + 14 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 19 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 7 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 1 + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 5 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 1 + + + + + + + BILINK + 0 + + + + + Libraries + + $PROJ_DIR$\..\..\..\..\driverlib\ewarm\Exe\driverlib.a + + + $PROJ_DIR$\..\..\..\..\grlib\ewarm\Exe\grlib.a + + + + Source + + $PROJ_DIR$\..\drivers\frame.c + + + $PROJ_DIR$\hibernate.c + + + $PROJ_DIR$\..\drivers\kentec320x240x16_ssd2119.c + + + $PROJ_DIR$\..\drivers\pinout.c + + + $PROJ_DIR$\startup_ewarm.c + + + $PROJ_DIR$\..\drivers\touch.c + + + $PROJ_DIR$\..\..\..\..\utils\uartstdio.c + + + $PROJ_DIR$\..\..\..\..\utils\ustdlib.c + + + diff --git a/boards/dk-tm4c129x/hibernate/hibernate.icf b/boards/dk-tm4c129x/hibernate/hibernate.icf new file mode 100644 index 0000000..8ecb442 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/hibernate.icf @@ -0,0 +1,78 @@ +//***************************************************************************** +// +// hibernate.icf - Linker configuration file for hibernate. +// +// Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved. +// Software License Agreement +// +// Texas Instruments (TI) is supplying this software for use solely and +// exclusively on TI's microcontroller products. The software is owned by +// TI and/or its suppliers, and is protected under applicable copyright +// laws. You may not combine this software with "viral" open-source +// software in order to form a larger program. +// +// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +// DAMAGES, FOR ANY REASON WHATSOEVER. +// +// This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package. +// +//***************************************************************************** + +// +// Define a memory region that covers the entire 4 GB addressible space of the +// processor. +// +define memory mem with size = 4G; + +// +// Define a region for the on-chip flash. +// +define region FLASH = mem:[from 0x00000000 to 0x000fffff]; + +// +// Define a region for the on-chip SRAM. +// +define region SRAM = mem:[from 0x20000000 to 0x2003ffff]; + +// +// Define a block for the heap. The size should be set to something other +// than zero if things in the C library that require the heap are used. +// +define block HEAP with alignment = 8, size = 0x00000000 { }; + +// +// Indicate that the read/write values should be initialized by copying from +// flash. +// +initialize by copy { readwrite }; + +// +// Indicate that the noinit values should be left alone. This includes the +// stack, which if initialized will destroy the return address from the +// initialization code, causing the processor to branch to zero and fault. +// +do not initialize { section .noinit }; + +// +// Place the interrupt vectors at the start of flash. +// +place at start of FLASH { readonly section .intvec }; + +// +// Place the remainder of the read-only items into flash. +// +place in FLASH { readonly }; + +// +// Place the RAM vector table at the start of SRAM. +// +place at start of SRAM { section VTABLE }; + +// +// Place all read/write items into SRAM. +// +place in SRAM { readwrite, block HEAP }; diff --git a/boards/dk-tm4c129x/hibernate/hibernate.ld b/boards/dk-tm4c129x/hibernate/hibernate.ld new file mode 100644 index 0000000..91ddcfa --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/hibernate.ld @@ -0,0 +1,57 @@ +/****************************************************************************** + * + * hibernate.ld - Linker configuration file for hibernate. + * + * Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved. + * Software License Agreement + * + * Texas Instruments (TI) is supplying this software for use solely and + * exclusively on TI's microcontroller products. The software is owned by + * TI and/or its suppliers, and is protected under applicable copyright + * laws. You may not combine this software with "viral" open-source + * software in order to form a larger program. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. + * NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT + * NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY + * CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL + * DAMAGES, FOR ANY REASON WHATSOEVER. + * + * This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package. + * + *****************************************************************************/ + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00100000 + SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00040000 +} + +SECTIONS +{ + .text : + { + _text = .; + KEEP(*(.isr_vector)) + *(.text*) + *(.rodata*) + _etext = .; + } > FLASH + + .data : AT(ADDR(.text) + SIZEOF(.text)) + { + _data = .; + *(vtable) + *(.data*) + _edata = .; + } > SRAM + + .bss : + { + _bss = .; + *(.bss*) + *(COMMON) + _ebss = .; + } > SRAM +} diff --git a/boards/dk-tm4c129x/hibernate/hibernate.sct b/boards/dk-tm4c129x/hibernate/hibernate.sct new file mode 100644 index 0000000..25625e4 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/hibernate.sct @@ -0,0 +1,47 @@ +;****************************************************************************** +; +; hibernate.sct - Linker configuration file for hibernate. +; +; Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved. +; Software License Agreement +; +; Texas Instruments (TI) is supplying this software for use solely and +; exclusively on TI's microcontroller products. The software is owned by +; TI and/or its suppliers, and is protected under applicable copyright +; laws. You may not combine this software with "viral" open-source +; software in order to form a larger program. +; +; THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +; NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +; NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +; CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +; DAMAGES, FOR ANY REASON WHATSOEVER. +; +; This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package. +; +;****************************************************************************** + +LR_IROM 0x00000000 0x00100000 +{ + ; + ; Specify the Execution Address of the code and the size. + ; + ER_IROM 0x00000000 0x00100000 + { + *.o (RESET, +First) + * (InRoot$$Sections, +RO) + } + + ; + ; Specify the Execution Address of the data area. + ; + RW_IRAM 0x20000000 0x00040000 + { + ; + ; Uncomment the following line in order to use IntRegister(). + ; + ;* (vtable, +First) + * (+RW, +ZI) + } +} diff --git a/boards/dk-tm4c129x/hibernate/hibernate.uvopt b/boards/dk-tm4c129x/hibernate/hibernate.uvopt new file mode 100644 index 0000000..fa3bf3b --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/hibernate.uvopt @@ -0,0 +1,387 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + + + + 0 + 0 + + + + hibernate + 0x4 + ARM-ADS + + 25000000 + + 1 + 1 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\rvmdk\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 255 + + + 0 + Data Sheet + DATASHTS\Luminary\TM4C129XNCZAD.PDF + + + + SARMCM3.DLL + -MPU + DCM.DLL + -pCM4 + SARMCM3.DLL + -MPU + TCM.DLL + -pCM4 + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + 0 + 0 + 4 + + + + + + + + + + + BIN\lmidk-agdi.dll + + + + 0 + lmidk-agdi + -O4614 -S1 -FO29 + + + 0 + DLGTARM + + + + 0 + ARMDBGFLAGS + + + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + Source + 1 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\drivers\frame.c + frame.c + + + 1 + 2 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + .\hibernate.c + hibernate.c + + + 1 + 3 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\drivers\kentec320x240x16_ssd2119.c + kentec320x240x16_ssd2119.c + + + 1 + 4 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\drivers\pinout.c + pinout.c + + + 1 + 5 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + .\startup_rvmdk.S + startup_rvmdk.S + + + 1 + 6 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\drivers\touch.c + touch.c + + + 1 + 7 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\..\utils\uartstdio.c + uartstdio.c + + + 1 + 8 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\..\utils\ustdlib.c + ustdlib.c + + + + + Libraries + 1 + 0 + 0 + + 2 + 9 + 4 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\..\driverlib\rvmdk\driverlib.lib + driverlib.lib + + + 2 + 10 + 4 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\..\grlib\rvmdk\grlib.lib + grlib.lib + + + + + Documentation + 1 + 0 + 0 + + 3 + 11 + 5 + 0 + 1 + 0 + 0 + 1 + 1 + 0 + .\readme.txt + readme.txt + + 44 + 0 + 1 + + -1 + -1 + + + -1 + -1 + + + 0 + 0 + 729 + 300 + + + + + + + 1 + 0 + + 100 + 0 + + + .\readme.txt + 0 + 1 + 1 + + + + + +
diff --git a/boards/dk-tm4c129x/hibernate/hibernate.uvproj b/boards/dk-tm4c129x/hibernate/hibernate.uvproj new file mode 100644 index 0000000..f9c0bb3 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/hibernate.uvproj @@ -0,0 +1,459 @@ + + + + 1.1 + +
### uVision Project, (C) Keil Software
+ + + + hibernate + 0x4 + ARM-ADS + + + TM4C129XNCZAD + Texas Instruments + IRAM(0x20000000-0x2003FFFF) IROM(0-0xFFFFF) CLOCK(25000000) CPUTYPE("Cortex-M4") FPU2 + + "STARTUP\Luminary\Startup.s" ("Luminary Startup Code") + UL2CM3(-O207 -S0 -C0 -FO7 -FD20000000 -FC800 -FN1 -FF0LM4F_1024 -FS00 -FL0100000) + 5919 + LM4Fxxxx.H + + + + + + + + + + 0 + + + + Luminary\ + Luminary\ + + 0 + 0 + 0 + 0 + 1 + + .\rvmdk\ + hibernate + 1 + 0 + 0 + 1 + 1 + .\rvmdk\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + + + 0 + 0 + + + 0 + 0 + + + 1 + 0 + fromelf --bin --output .\rvmdk\hibernate.bin .\rvmdk\hibernate.axf + + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + + + SARMCM3.DLL + -MPU + DCM.DLL + -pCM4 + SARMCM3.DLL + -MPU + TCM.DLL + -pCM4 + + + + 1 + 0 + 0 + 0 + 16 + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + + + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + + 0 + 4 + + + + + + + + + + + + + + BIN\lmidk-agdi.dll + + + + + 1 + 0 + 0 + 0 + 1 + 4099 + + BIN\lmidk-agdi.dll + + + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M4" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 2 + 0 + 0 + 8 + 1 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x40000 + + + 1 + 0x0 + 0x100000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x100000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x40000 + + + 0 + 0x0 + 0x0 + + + + + + 0 + 3 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + + --c99 + rvmdk PART_TM4C129XNCZAD TARGET_IS_TM4C129_RA0 SNOWFLAKE + + .;..;..\..\..\..; + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + hibernate.sct + + + --entry Reset_Handler + + + + + + + + Source + + + frame.c + 1 + ..\drivers\frame.c + + + hibernate.c + 1 + .\hibernate.c + + + kentec320x240x16_ssd2119.c + 1 + ..\drivers\kentec320x240x16_ssd2119.c + + + pinout.c + 1 + ..\drivers\pinout.c + + + startup_rvmdk.S + 2 + .\startup_rvmdk.S + + + touch.c + 1 + ..\drivers\touch.c + + + uartstdio.c + 1 + ..\..\..\..\utils\uartstdio.c + + + ustdlib.c + 1 + ..\..\..\..\utils\ustdlib.c + + + + + Libraries + + + driverlib.lib + 4 + ..\..\..\..\driverlib\rvmdk\driverlib.lib + + + grlib.lib + 4 + ..\..\..\..\grlib\rvmdk\grlib.lib + + + + + Documentation + + + readme.txt + 5 + .\readme.txt + + + + + + + +
diff --git a/boards/dk-tm4c129x/hibernate/hibernate_ccs.cmd b/boards/dk-tm4c129x/hibernate/hibernate_ccs.cmd new file mode 100644 index 0000000..e89de9d --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/hibernate_ccs.cmd @@ -0,0 +1,70 @@ +/****************************************************************************** + * + * hibernate_ccs.cmd - CCS linker configuration file for hibernate. + * + * Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved. + * Software License Agreement + * + * Texas Instruments (TI) is supplying this software for use solely and + * exclusively on TI's microcontroller products. The software is owned by + * TI and/or its suppliers, and is protected under applicable copyright + * laws. You may not combine this software with "viral" open-source + * software in order to form a larger program. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. + * NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT + * NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY + * CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL + * DAMAGES, FOR ANY REASON WHATSOEVER. + * + * This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package. + * + *****************************************************************************/ + +--retain=g_pfnVectors + +/* The following command line options are set as part of the CCS project. */ +/* If you are building using the command line, or for some reason want to */ +/* define them here, you can uncomment and modify these lines as needed. */ +/* If you are using CCS for building, it is probably better to make any such */ +/* modifications in your CCS project and leave this file alone. */ +/* */ +/* --heap_size=0 */ +/* --stack_size=256 */ +/* --library=rtsv7M3_T_le_eabi.lib */ + +/* The starting address of the application. Normally the interrupt vectors */ +/* must be located at the beginning of the application. */ +#define APP_BASE 0x00000000 +#define RAM_BASE 0x20000000 + +/* System memory map */ + +MEMORY +{ + /* Application stored in and executes from internal flash */ + FLASH (RX) : origin = APP_BASE, length = 0x00100000 + /* Application uses internal RAM for data */ + SRAM (RWX) : origin = 0x20000000, length = 0x00040000 +} + +/* Section allocation in memory */ + +SECTIONS +{ + .intvecs: > APP_BASE + .text : > FLASH + .const : > FLASH + .cinit : > FLASH + .pinit : > FLASH + .init_array : > FLASH + + .vtable : > RAM_BASE + .data : > SRAM + .bss : > SRAM + .sysmem : > SRAM + .stack : > SRAM +} + +__STACK_TOP = __stack + 1024; diff --git a/boards/dk-tm4c129x/hibernate/readme.txt b/boards/dk-tm4c129x/hibernate/readme.txt new file mode 100644 index 0000000..d446a9f --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/readme.txt @@ -0,0 +1,37 @@ +Hibernate Example + +An example to demonstrate the use of the Hibernation module. The user +can put the microcontroller in hibernation by touching the display. The +microcontroller will then wake on its own after 5 seconds, or immediately +if the user presses the RESET button. External WAKE pin and GPIO (PK5) +wake sources can also be used to wake immediately from hibernation. The +following wiring enables the use of these pins as wake sources. + WAKE on J27 to SEL on J37 + PK5 on J28 to UP on J37 + +The program keeps a count of the number of times it has entered +hibernation. The value of the counter is stored in the battery backed +memory of the Hibernation module so that it can be retrieved when the +microcontroller wakes. The program displays the wall time and date by +making use of the calendar function of the Hibernate module. User can +modify the date and time if so desired. + +------------------------------------------------------------------------------- + +Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved. +Software License Agreement + +Texas Instruments (TI) is supplying this software for use solely and +exclusively on TI's microcontroller products. The software is owned by +TI and/or its suppliers, and is protected under applicable copyright +laws. You may not combine this software with "viral" open-source +software in order to form a larger program. + +THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, FOR ANY REASON WHATSOEVER. + +This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package. diff --git a/boards/dk-tm4c129x/hibernate/rvmdk/hibernate.axf b/boards/dk-tm4c129x/hibernate/rvmdk/hibernate.axf new file mode 100644 index 0000000..e2192cb Binary files /dev/null and b/boards/dk-tm4c129x/hibernate/rvmdk/hibernate.axf differ diff --git a/boards/dk-tm4c129x/hibernate/rvmdk/hibernate.bin b/boards/dk-tm4c129x/hibernate/rvmdk/hibernate.bin new file mode 100644 index 0000000..9e86066 Binary files /dev/null and b/boards/dk-tm4c129x/hibernate/rvmdk/hibernate.bin differ diff --git a/boards/dk-tm4c129x/hibernate/startup_ccs.c b/boards/dk-tm4c129x/hibernate/startup_ccs.c new file mode 100644 index 0000000..5d2884c --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/startup_ccs.c @@ -0,0 +1,275 @@ +//***************************************************************************** +// +// startup_ccs.c - Startup code for use with TI's Code Composer Studio. +// +// Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved. +// Software License Agreement +// +// Texas Instruments (TI) is supplying this software for use solely and +// exclusively on TI's microcontroller products. The software is owned by +// TI and/or its suppliers, and is protected under applicable copyright +// laws. You may not combine this software with "viral" open-source +// software in order to form a larger program. +// +// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +// DAMAGES, FOR ANY REASON WHATSOEVER. +// +// This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package. +// +//***************************************************************************** + +#include +#include "inc/hw_nvic.h" +#include "inc/hw_types.h" + +//***************************************************************************** +// +// Forward declaration of the default fault handlers. +// +//***************************************************************************** +void ResetISR(void); +static void NmiSR(void); +static void FaultISR(void); +static void IntDefaultHandler(void); + +//***************************************************************************** +// +// External declaration for the reset handler that is to be called when the +// processor is started +// +//***************************************************************************** +extern void _c_int00(void); + +//***************************************************************************** +// +// Linker variable that marks the top of the stack. +// +//***************************************************************************** +extern uint32_t __STACK_TOP; + +//***************************************************************************** +// +// External declaration for the interrupt handler used by the application. +// +//***************************************************************************** +extern void TouchScreenIntHandler(void); + +//***************************************************************************** +// +// The vector table. Note that the proper constructs must be placed on this to +// ensure that it ends up at physical address 0x0000.0000 or at the start of +// the program if located at a start address other than 0. +// +//***************************************************************************** +#pragma DATA_SECTION(g_pfnVectors, ".intvecs") +void (* const g_pfnVectors[])(void) = +{ + (void (*)(void))((uint32_t)&__STACK_TOP), + // The initial stack pointer + ResetISR, // The reset handler + NmiSR, // The NMI handler + FaultISR, // The hard fault handler + IntDefaultHandler, // The MPU fault handler + IntDefaultHandler, // The bus fault handler + IntDefaultHandler, // The usage fault handler + 0, // Reserved + 0, // Reserved + 0, // Reserved + 0, // Reserved + IntDefaultHandler, // SVCall handler + IntDefaultHandler, // Debug monitor handler + 0, // Reserved + IntDefaultHandler, // The PendSV handler + IntDefaultHandler, // The SysTick handler + IntDefaultHandler, // GPIO Port A + IntDefaultHandler, // GPIO Port B + IntDefaultHandler, // GPIO Port C + IntDefaultHandler, // GPIO Port D + IntDefaultHandler, // GPIO Port E + IntDefaultHandler, // UART0 Rx and Tx + IntDefaultHandler, // UART1 Rx and Tx + IntDefaultHandler, // SSI0 Rx and Tx + IntDefaultHandler, // I2C0 Master and Slave + IntDefaultHandler, // PWM Fault + IntDefaultHandler, // PWM Generator 0 + IntDefaultHandler, // PWM Generator 1 + IntDefaultHandler, // PWM Generator 2 + IntDefaultHandler, // Quadrature Encoder 0 + IntDefaultHandler, // ADC Sequence 0 + IntDefaultHandler, // ADC Sequence 1 + IntDefaultHandler, // ADC Sequence 2 + TouchScreenIntHandler, // ADC Sequence 3 + IntDefaultHandler, // Watchdog timer + IntDefaultHandler, // Timer 0 subtimer A + IntDefaultHandler, // Timer 0 subtimer B + IntDefaultHandler, // Timer 1 subtimer A + IntDefaultHandler, // Timer 1 subtimer B + IntDefaultHandler, // Timer 2 subtimer A + IntDefaultHandler, // Timer 2 subtimer B + IntDefaultHandler, // Analog Comparator 0 + IntDefaultHandler, // Analog Comparator 1 + IntDefaultHandler, // Analog Comparator 2 + IntDefaultHandler, // System Control (PLL, OSC, BO) + IntDefaultHandler, // FLASH Control + IntDefaultHandler, // GPIO Port F + IntDefaultHandler, // GPIO Port G + IntDefaultHandler, // GPIO Port H + IntDefaultHandler, // UART2 Rx and Tx + IntDefaultHandler, // SSI1 Rx and Tx + IntDefaultHandler, // Timer 3 subtimer A + IntDefaultHandler, // Timer 3 subtimer B + IntDefaultHandler, // I2C1 Master and Slave + IntDefaultHandler, // CAN0 + IntDefaultHandler, // CAN1 + IntDefaultHandler, // Ethernet + IntDefaultHandler, // Hibernate + IntDefaultHandler, // USB0 + IntDefaultHandler, // PWM Generator 3 + IntDefaultHandler, // uDMA Software Transfer + IntDefaultHandler, // uDMA Error + IntDefaultHandler, // ADC1 Sequence 0 + IntDefaultHandler, // ADC1 Sequence 1 + IntDefaultHandler, // ADC1 Sequence 2 + IntDefaultHandler, // ADC1 Sequence 3 + IntDefaultHandler, // External Bus Interface 0 + IntDefaultHandler, // GPIO Port J + IntDefaultHandler, // GPIO Port K + IntDefaultHandler, // GPIO Port L + IntDefaultHandler, // SSI2 Rx and Tx + IntDefaultHandler, // SSI3 Rx and Tx + IntDefaultHandler, // UART3 Rx and Tx + IntDefaultHandler, // UART4 Rx and Tx + IntDefaultHandler, // UART5 Rx and Tx + IntDefaultHandler, // UART6 Rx and Tx + IntDefaultHandler, // UART7 Rx and Tx + IntDefaultHandler, // I2C2 Master and Slave + IntDefaultHandler, // I2C3 Master and Slave + IntDefaultHandler, // Timer 4 subtimer A + IntDefaultHandler, // Timer 4 subtimer B + IntDefaultHandler, // Timer 5 subtimer A + IntDefaultHandler, // Timer 5 subtimer B + IntDefaultHandler, // FPU + 0, // Reserved + 0, // Reserved + IntDefaultHandler, // I2C4 Master and Slave + IntDefaultHandler, // I2C5 Master and Slave + IntDefaultHandler, // GPIO Port M + IntDefaultHandler, // GPIO Port N + 0, // Reserved + IntDefaultHandler, // Tamper + IntDefaultHandler, // GPIO Port P (Summary or P0) + IntDefaultHandler, // GPIO Port P1 + IntDefaultHandler, // GPIO Port P2 + IntDefaultHandler, // GPIO Port P3 + IntDefaultHandler, // GPIO Port P4 + IntDefaultHandler, // GPIO Port P5 + IntDefaultHandler, // GPIO Port P6 + IntDefaultHandler, // GPIO Port P7 + IntDefaultHandler, // GPIO Port Q (Summary or Q0) + IntDefaultHandler, // GPIO Port Q1 + IntDefaultHandler, // GPIO Port Q2 + IntDefaultHandler, // GPIO Port Q3 + IntDefaultHandler, // GPIO Port Q4 + IntDefaultHandler, // GPIO Port Q5 + IntDefaultHandler, // GPIO Port Q6 + IntDefaultHandler, // GPIO Port Q7 + IntDefaultHandler, // GPIO Port R + IntDefaultHandler, // GPIO Port S + IntDefaultHandler, // SHA/MD5 0 + IntDefaultHandler, // AES 0 + IntDefaultHandler, // DES3DES 0 + IntDefaultHandler, // LCD Controller 0 + IntDefaultHandler, // Timer 6 subtimer A + IntDefaultHandler, // Timer 6 subtimer B + IntDefaultHandler, // Timer 7 subtimer A + IntDefaultHandler, // Timer 7 subtimer B + IntDefaultHandler, // I2C6 Master and Slave + IntDefaultHandler, // I2C7 Master and Slave + IntDefaultHandler, // HIM Scan Matrix Keyboard 0 + IntDefaultHandler, // One Wire 0 + IntDefaultHandler, // HIM PS/2 0 + IntDefaultHandler, // HIM LED Sequencer 0 + IntDefaultHandler, // HIM Consumer IR 0 + IntDefaultHandler, // I2C8 Master and Slave + IntDefaultHandler, // I2C9 Master and Slave + IntDefaultHandler // GPIO Port T +}; + +//***************************************************************************** +// +// This is the code that gets called when the processor first starts execution +// following a reset event. Only the absolutely necessary set is performed, +// after which the application supplied entry() routine is called. Any fancy +// actions (such as making decisions based on the reset cause register, and +// resetting the bits in that register) are left solely in the hands of the +// application. +// +//***************************************************************************** +void +ResetISR(void) +{ + // + // Jump to the CCS C initialization routine. This will enable the + // floating-point unit as well, so that does not need to be done here. + // + __asm(" .global _c_int00\n" + " b.w _c_int00"); +} + +//***************************************************************************** +// +// This is the code that gets called when the processor receives a NMI. This +// simply enters an infinite loop, preserving the system state for examination +// by a debugger. +// +//***************************************************************************** +static void +NmiSR(void) +{ + // + // Enter an infinite loop. + // + while(1) + { + } +} + +//***************************************************************************** +// +// This is the code that gets called when the processor receives a fault +// interrupt. This simply enters an infinite loop, preserving the system state +// for examination by a debugger. +// +//***************************************************************************** +static void +FaultISR(void) +{ + // + // Enter an infinite loop. + // + while(1) + { + } +} + +//***************************************************************************** +// +// This is the code that gets called when the processor receives an unexpected +// interrupt. This simply enters an infinite loop, preserving the system state +// for examination by a debugger. +// +//***************************************************************************** +static void +IntDefaultHandler(void) +{ + // + // Go into an infinite loop. + // + while(1) + { + } +} diff --git a/boards/dk-tm4c129x/hibernate/startup_ewarm.c b/boards/dk-tm4c129x/hibernate/startup_ewarm.c new file mode 100644 index 0000000..860b8a6 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/startup_ewarm.c @@ -0,0 +1,306 @@ +//***************************************************************************** +// +// startup_ewarm.c - Startup code for use with IAR's Embedded Workbench, +// version 5. +// +// Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved. +// Software License Agreement +// +// Texas Instruments (TI) is supplying this software for use solely and +// exclusively on TI's microcontroller products. The software is owned by +// TI and/or its suppliers, and is protected under applicable copyright +// laws. You may not combine this software with "viral" open-source +// software in order to form a larger program. +// +// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +// DAMAGES, FOR ANY REASON WHATSOEVER. +// +// This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package. +// +//***************************************************************************** + +#include +#include "inc/hw_nvic.h" +#include "inc/hw_types.h" + +//***************************************************************************** +// +// Enable the IAR extensions for this source file. +// +//***************************************************************************** +#pragma language=extended + +//***************************************************************************** +// +// Forward declaration of the default fault handlers. +// +//***************************************************************************** +void ResetISR(void); +static void NmiSR(void); +static void FaultISR(void); +static void IntDefaultHandler(void); + +//***************************************************************************** +// +// External declaration for the interrupt handler used by the application. +// +//***************************************************************************** +extern void TouchScreenIntHandler(void); + +//***************************************************************************** +// +// The entry point for the application startup code. +// +//***************************************************************************** +extern void __iar_program_start(void); + +//***************************************************************************** +// +// Reserve space for the system stack. +// +//***************************************************************************** +static uint32_t pui32Stack[256] @ ".noinit"; + +//***************************************************************************** +// +// A union that describes the entries of the vector table. The union is needed +// since the first entry is the stack pointer and the remainder are function +// pointers. +// +//***************************************************************************** +typedef union +{ + void (*pfnHandler)(void); + uint32_t ui32Ptr; +} +uVectorEntry; + +//***************************************************************************** +// +// The vector table. Note that the proper constructs must be placed on this to +// ensure that it ends up at physical address 0x0000.0000. +// +//***************************************************************************** +__root const uVectorEntry __vector_table[] @ ".intvec" = +{ + { .ui32Ptr = (uint32_t)pui32Stack + sizeof(pui32Stack) }, + // The initial stack pointer + ResetISR, // The reset handler + NmiSR, // The NMI handler + FaultISR, // The hard fault handler + IntDefaultHandler, // The MPU fault handler + IntDefaultHandler, // The bus fault handler + IntDefaultHandler, // The usage fault handler + 0, // Reserved + 0, // Reserved + 0, // Reserved + 0, // Reserved + IntDefaultHandler, // SVCall handler + IntDefaultHandler, // Debug monitor handler + 0, // Reserved + IntDefaultHandler, // The PendSV handler + IntDefaultHandler, // The SysTick handler + IntDefaultHandler, // GPIO Port A + IntDefaultHandler, // GPIO Port B + IntDefaultHandler, // GPIO Port C + IntDefaultHandler, // GPIO Port D + IntDefaultHandler, // GPIO Port E + IntDefaultHandler, // UART0 Rx and Tx + IntDefaultHandler, // UART1 Rx and Tx + IntDefaultHandler, // SSI0 Rx and Tx + IntDefaultHandler, // I2C0 Master and Slave + IntDefaultHandler, // PWM Fault + IntDefaultHandler, // PWM Generator 0 + IntDefaultHandler, // PWM Generator 1 + IntDefaultHandler, // PWM Generator 2 + IntDefaultHandler, // Quadrature Encoder 0 + IntDefaultHandler, // ADC Sequence 0 + IntDefaultHandler, // ADC Sequence 1 + IntDefaultHandler, // ADC Sequence 2 + TouchScreenIntHandler, // ADC Sequence 3 + IntDefaultHandler, // Watchdog timer + IntDefaultHandler, // Timer 0 subtimer A + IntDefaultHandler, // Timer 0 subtimer B + IntDefaultHandler, // Timer 1 subtimer A + IntDefaultHandler, // Timer 1 subtimer B + IntDefaultHandler, // Timer 2 subtimer A + IntDefaultHandler, // Timer 2 subtimer B + IntDefaultHandler, // Analog Comparator 0 + IntDefaultHandler, // Analog Comparator 1 + IntDefaultHandler, // Analog Comparator 2 + IntDefaultHandler, // System Control (PLL, OSC, BO) + IntDefaultHandler, // FLASH Control + IntDefaultHandler, // GPIO Port F + IntDefaultHandler, // GPIO Port G + IntDefaultHandler, // GPIO Port H + IntDefaultHandler, // UART2 Rx and Tx + IntDefaultHandler, // SSI1 Rx and Tx + IntDefaultHandler, // Timer 3 subtimer A + IntDefaultHandler, // Timer 3 subtimer B + IntDefaultHandler, // I2C1 Master and Slave + IntDefaultHandler, // CAN0 + IntDefaultHandler, // CAN1 + IntDefaultHandler, // Ethernet + IntDefaultHandler, // Hibernate + IntDefaultHandler, // USB0 + IntDefaultHandler, // PWM Generator 3 + IntDefaultHandler, // uDMA Software Transfer + IntDefaultHandler, // uDMA Error + IntDefaultHandler, // ADC1 Sequence 0 + IntDefaultHandler, // ADC1 Sequence 1 + IntDefaultHandler, // ADC1 Sequence 2 + IntDefaultHandler, // ADC1 Sequence 3 + IntDefaultHandler, // External Bus Interface 0 + IntDefaultHandler, // GPIO Port J + IntDefaultHandler, // GPIO Port K + IntDefaultHandler, // GPIO Port L + IntDefaultHandler, // SSI2 Rx and Tx + IntDefaultHandler, // SSI3 Rx and Tx + IntDefaultHandler, // UART3 Rx and Tx + IntDefaultHandler, // UART4 Rx and Tx + IntDefaultHandler, // UART5 Rx and Tx + IntDefaultHandler, // UART6 Rx and Tx + IntDefaultHandler, // UART7 Rx and Tx + IntDefaultHandler, // I2C2 Master and Slave + IntDefaultHandler, // I2C3 Master and Slave + IntDefaultHandler, // Timer 4 subtimer A + IntDefaultHandler, // Timer 4 subtimer B + IntDefaultHandler, // Timer 5 subtimer A + IntDefaultHandler, // Timer 5 subtimer B + IntDefaultHandler, // FPU + 0, // Reserved + 0, // Reserved + IntDefaultHandler, // I2C4 Master and Slave + IntDefaultHandler, // I2C5 Master and Slave + IntDefaultHandler, // GPIO Port M + IntDefaultHandler, // GPIO Port N + 0, // Reserved + IntDefaultHandler, // Tamper + IntDefaultHandler, // GPIO Port P (Summary or P0) + IntDefaultHandler, // GPIO Port P1 + IntDefaultHandler, // GPIO Port P2 + IntDefaultHandler, // GPIO Port P3 + IntDefaultHandler, // GPIO Port P4 + IntDefaultHandler, // GPIO Port P5 + IntDefaultHandler, // GPIO Port P6 + IntDefaultHandler, // GPIO Port P7 + IntDefaultHandler, // GPIO Port Q (Summary or Q0) + IntDefaultHandler, // GPIO Port Q1 + IntDefaultHandler, // GPIO Port Q2 + IntDefaultHandler, // GPIO Port Q3 + IntDefaultHandler, // GPIO Port Q4 + IntDefaultHandler, // GPIO Port Q5 + IntDefaultHandler, // GPIO Port Q6 + IntDefaultHandler, // GPIO Port Q7 + IntDefaultHandler, // GPIO Port R + IntDefaultHandler, // GPIO Port S + IntDefaultHandler, // SHA/MD5 0 + IntDefaultHandler, // AES 0 + IntDefaultHandler, // DES3DES 0 + IntDefaultHandler, // LCD Controller 0 + IntDefaultHandler, // Timer 6 subtimer A + IntDefaultHandler, // Timer 6 subtimer B + IntDefaultHandler, // Timer 7 subtimer A + IntDefaultHandler, // Timer 7 subtimer B + IntDefaultHandler, // I2C6 Master and Slave + IntDefaultHandler, // I2C7 Master and Slave + IntDefaultHandler, // HIM Scan Matrix Keyboard 0 + IntDefaultHandler, // One Wire 0 + IntDefaultHandler, // HIM PS/2 0 + IntDefaultHandler, // HIM LED Sequencer 0 + IntDefaultHandler, // HIM Consumer IR 0 + IntDefaultHandler, // I2C8 Master and Slave + IntDefaultHandler, // I2C9 Master and Slave + IntDefaultHandler // GPIO Port T +}; + +//***************************************************************************** +// +// This is the code that gets called when the processor first starts execution +// following a reset event. Only the absolutely necessary set is performed, +// after which the application supplied entry() routine is called. Any fancy +// actions (such as making decisions based on the reset cause register, and +// resetting the bits in that register) are left solely in the hands of the +// application. +// +//***************************************************************************** +void +ResetISR(void) +{ + // + // Enable the floating-point unit. This must be done here to handle the + // case where main() uses floating-point and the function prologue saves + // floating-point registers (which will fault if floating-point is not + // enabled). Any configuration of the floating-point unit using DriverLib + // APIs must be done here prior to the floating-point unit being enabled. + // + // Note that this does not use DriverLib since it might not be included in + // this project. + // + HWREG(NVIC_CPAC) = ((HWREG(NVIC_CPAC) & + ~(NVIC_CPAC_CP10_M | NVIC_CPAC_CP11_M)) | + NVIC_CPAC_CP10_FULL | NVIC_CPAC_CP11_FULL); + + // + // Call the application's entry point. + // + __iar_program_start(); +} + +//***************************************************************************** +// +// This is the code that gets called when the processor receives a NMI. This +// simply enters an infinite loop, preserving the system state for examination +// by a debugger. +// +//***************************************************************************** +static void +NmiSR(void) +{ + // + // Enter an infinite loop. + // + while(1) + { + } +} + +//***************************************************************************** +// +// This is the code that gets called when the processor receives a fault +// interrupt. This simply enters an infinite loop, preserving the system state +// for examination by a debugger. +// +//***************************************************************************** +static void +FaultISR(void) +{ + // + // Enter an infinite loop. + // + while(1) + { + } +} + +//***************************************************************************** +// +// This is the code that gets called when the processor receives an unexpected +// interrupt. This simply enters an infinite loop, preserving the system state +// for examination by a debugger. +// +//***************************************************************************** +static void +IntDefaultHandler(void) +{ + // + // Go into an infinite loop. + // + while(1) + { + } +} diff --git a/boards/dk-tm4c129x/hibernate/startup_gcc.c b/boards/dk-tm4c129x/hibernate/startup_gcc.c new file mode 100644 index 0000000..fad3049 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/startup_gcc.c @@ -0,0 +1,322 @@ +//***************************************************************************** +// +// startup_gcc.c - Startup code for use with GNU tools. +// +// Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved. +// Software License Agreement +// +// Texas Instruments (TI) is supplying this software for use solely and +// exclusively on TI's microcontroller products. The software is owned by +// TI and/or its suppliers, and is protected under applicable copyright +// laws. You may not combine this software with "viral" open-source +// software in order to form a larger program. +// +// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +// DAMAGES, FOR ANY REASON WHATSOEVER. +// +// This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package. +// +//***************************************************************************** + +#include +#include "inc/hw_nvic.h" +#include "inc/hw_types.h" + +//***************************************************************************** +// +// Forward declaration of the default fault handlers. +// +//***************************************************************************** +void ResetISR(void); +static void NmiSR(void); +static void FaultISR(void); +static void IntDefaultHandler(void); + +//***************************************************************************** +// +// External declaration for the interrupt handler used by the application. +// +//***************************************************************************** +extern void TouchScreenIntHandler(void); + +//***************************************************************************** +// +// The entry point for the application. +// +//***************************************************************************** +extern int main(void); + +//***************************************************************************** +// +// Reserve space for the system stack. +// +//***************************************************************************** +static uint32_t pui32Stack[256]; + +//***************************************************************************** +// +// The vector table. Note that the proper constructs must be placed on this to +// ensure that it ends up at physical address 0x0000.0000. +// +//***************************************************************************** +__attribute__ ((section(".isr_vector"))) +void (* const g_pfnVectors[])(void) = +{ + (void (*)(void))((uint32_t)pui32Stack + sizeof(pui32Stack)), + // The initial stack pointer + ResetISR, // The reset handler + NmiSR, // The NMI handler + FaultISR, // The hard fault handler + IntDefaultHandler, // The MPU fault handler + IntDefaultHandler, // The bus fault handler + IntDefaultHandler, // The usage fault handler + 0, // Reserved + 0, // Reserved + 0, // Reserved + 0, // Reserved + IntDefaultHandler, // SVCall handler + IntDefaultHandler, // Debug monitor handler + 0, // Reserved + IntDefaultHandler, // The PendSV handler + IntDefaultHandler, // The SysTick handler + IntDefaultHandler, // GPIO Port A + IntDefaultHandler, // GPIO Port B + IntDefaultHandler, // GPIO Port C + IntDefaultHandler, // GPIO Port D + IntDefaultHandler, // GPIO Port E + IntDefaultHandler, // UART0 Rx and Tx + IntDefaultHandler, // UART1 Rx and Tx + IntDefaultHandler, // SSI0 Rx and Tx + IntDefaultHandler, // I2C0 Master and Slave + IntDefaultHandler, // PWM Fault + IntDefaultHandler, // PWM Generator 0 + IntDefaultHandler, // PWM Generator 1 + IntDefaultHandler, // PWM Generator 2 + IntDefaultHandler, // Quadrature Encoder 0 + IntDefaultHandler, // ADC Sequence 0 + IntDefaultHandler, // ADC Sequence 1 + IntDefaultHandler, // ADC Sequence 2 + TouchScreenIntHandler, // ADC Sequence 3 + IntDefaultHandler, // Watchdog timer + IntDefaultHandler, // Timer 0 subtimer A + IntDefaultHandler, // Timer 0 subtimer B + IntDefaultHandler, // Timer 1 subtimer A + IntDefaultHandler, // Timer 1 subtimer B + IntDefaultHandler, // Timer 2 subtimer A + IntDefaultHandler, // Timer 2 subtimer B + IntDefaultHandler, // Analog Comparator 0 + IntDefaultHandler, // Analog Comparator 1 + IntDefaultHandler, // Analog Comparator 2 + IntDefaultHandler, // System Control (PLL, OSC, BO) + IntDefaultHandler, // FLASH Control + IntDefaultHandler, // GPIO Port F + IntDefaultHandler, // GPIO Port G + IntDefaultHandler, // GPIO Port H + IntDefaultHandler, // UART2 Rx and Tx + IntDefaultHandler, // SSI1 Rx and Tx + IntDefaultHandler, // Timer 3 subtimer A + IntDefaultHandler, // Timer 3 subtimer B + IntDefaultHandler, // I2C1 Master and Slave + IntDefaultHandler, // CAN0 + IntDefaultHandler, // CAN1 + IntDefaultHandler, // Ethernet + IntDefaultHandler, // Hibernate + IntDefaultHandler, // USB0 + IntDefaultHandler, // PWM Generator 3 + IntDefaultHandler, // uDMA Software Transfer + IntDefaultHandler, // uDMA Error + IntDefaultHandler, // ADC1 Sequence 0 + IntDefaultHandler, // ADC1 Sequence 1 + IntDefaultHandler, // ADC1 Sequence 2 + IntDefaultHandler, // ADC1 Sequence 3 + IntDefaultHandler, // External Bus Interface 0 + IntDefaultHandler, // GPIO Port J + IntDefaultHandler, // GPIO Port K + IntDefaultHandler, // GPIO Port L + IntDefaultHandler, // SSI2 Rx and Tx + IntDefaultHandler, // SSI3 Rx and Tx + IntDefaultHandler, // UART3 Rx and Tx + IntDefaultHandler, // UART4 Rx and Tx + IntDefaultHandler, // UART5 Rx and Tx + IntDefaultHandler, // UART6 Rx and Tx + IntDefaultHandler, // UART7 Rx and Tx + IntDefaultHandler, // I2C2 Master and Slave + IntDefaultHandler, // I2C3 Master and Slave + IntDefaultHandler, // Timer 4 subtimer A + IntDefaultHandler, // Timer 4 subtimer B + IntDefaultHandler, // Timer 5 subtimer A + IntDefaultHandler, // Timer 5 subtimer B + IntDefaultHandler, // FPU + 0, // Reserved + 0, // Reserved + IntDefaultHandler, // I2C4 Master and Slave + IntDefaultHandler, // I2C5 Master and Slave + IntDefaultHandler, // GPIO Port M + IntDefaultHandler, // GPIO Port N + 0, // Reserved + IntDefaultHandler, // Tamper + IntDefaultHandler, // GPIO Port P (Summary or P0) + IntDefaultHandler, // GPIO Port P1 + IntDefaultHandler, // GPIO Port P2 + IntDefaultHandler, // GPIO Port P3 + IntDefaultHandler, // GPIO Port P4 + IntDefaultHandler, // GPIO Port P5 + IntDefaultHandler, // GPIO Port P6 + IntDefaultHandler, // GPIO Port P7 + IntDefaultHandler, // GPIO Port Q (Summary or Q0) + IntDefaultHandler, // GPIO Port Q1 + IntDefaultHandler, // GPIO Port Q2 + IntDefaultHandler, // GPIO Port Q3 + IntDefaultHandler, // GPIO Port Q4 + IntDefaultHandler, // GPIO Port Q5 + IntDefaultHandler, // GPIO Port Q6 + IntDefaultHandler, // GPIO Port Q7 + IntDefaultHandler, // GPIO Port R + IntDefaultHandler, // GPIO Port S + IntDefaultHandler, // SHA/MD5 0 + IntDefaultHandler, // AES 0 + IntDefaultHandler, // DES3DES 0 + IntDefaultHandler, // LCD Controller 0 + IntDefaultHandler, // Timer 6 subtimer A + IntDefaultHandler, // Timer 6 subtimer B + IntDefaultHandler, // Timer 7 subtimer A + IntDefaultHandler, // Timer 7 subtimer B + IntDefaultHandler, // I2C6 Master and Slave + IntDefaultHandler, // I2C7 Master and Slave + IntDefaultHandler, // HIM Scan Matrix Keyboard 0 + IntDefaultHandler, // One Wire 0 + IntDefaultHandler, // HIM PS/2 0 + IntDefaultHandler, // HIM LED Sequencer 0 + IntDefaultHandler, // HIM Consumer IR 0 + IntDefaultHandler, // I2C8 Master and Slave + IntDefaultHandler, // I2C9 Master and Slave + IntDefaultHandler // GPIO Port T +}; + +//***************************************************************************** +// +// The following are constructs created by the linker, indicating where the +// the "data" and "bss" segments reside in memory. The initializers for the +// for the "data" segment resides immediately following the "text" segment. +// +//***************************************************************************** +extern uint32_t _etext; +extern uint32_t _data; +extern uint32_t _edata; +extern uint32_t _bss; +extern uint32_t _ebss; + +//***************************************************************************** +// +// This is the code that gets called when the processor first starts execution +// following a reset event. Only the absolutely necessary set is performed, +// after which the application supplied entry() routine is called. Any fancy +// actions (such as making decisions based on the reset cause register, and +// resetting the bits in that register) are left solely in the hands of the +// application. +// +//***************************************************************************** +void +ResetISR(void) +{ + uint32_t *pui32Src, *pui32Dest; + + // + // Copy the data segment initializers from flash to SRAM. + // + pui32Src = &_etext; + for(pui32Dest = &_data; pui32Dest < &_edata; ) + { + *pui32Dest++ = *pui32Src++; + } + + // + // Zero fill the bss segment. + // + __asm(" ldr r0, =_bss\n" + " ldr r1, =_ebss\n" + " mov r2, #0\n" + " .thumb_func\n" + "zero_loop:\n" + " cmp r0, r1\n" + " it lt\n" + " strlt r2, [r0], #4\n" + " blt zero_loop"); + + // + // Enable the floating-point unit. This must be done here to handle the + // case where main() uses floating-point and the function prologue saves + // floating-point registers (which will fault if floating-point is not + // enabled). Any configuration of the floating-point unit using DriverLib + // APIs must be done here prior to the floating-point unit being enabled. + // + // Note that this does not use DriverLib since it might not be included in + // this project. + // + HWREG(NVIC_CPAC) = ((HWREG(NVIC_CPAC) & + ~(NVIC_CPAC_CP10_M | NVIC_CPAC_CP11_M)) | + NVIC_CPAC_CP10_FULL | NVIC_CPAC_CP11_FULL); + + // + // Call the application's entry point. + // + main(); +} + +//***************************************************************************** +// +// This is the code that gets called when the processor receives a NMI. This +// simply enters an infinite loop, preserving the system state for examination +// by a debugger. +// +//***************************************************************************** +static void +NmiSR(void) +{ + // + // Enter an infinite loop. + // + while(1) + { + } +} + +//***************************************************************************** +// +// This is the code that gets called when the processor receives a fault +// interrupt. This simply enters an infinite loop, preserving the system state +// for examination by a debugger. +// +//***************************************************************************** +static void +FaultISR(void) +{ + // + // Enter an infinite loop. + // + while(1) + { + } +} + +//***************************************************************************** +// +// This is the code that gets called when the processor receives an unexpected +// interrupt. This simply enters an infinite loop, preserving the system state +// for examination by a debugger. +// +//***************************************************************************** +static void +IntDefaultHandler(void) +{ + // + // Go into an infinite loop. + // + while(1) + { + } +} diff --git a/boards/dk-tm4c129x/hibernate/startup_rvmdk.S b/boards/dk-tm4c129x/hibernate/startup_rvmdk.S new file mode 100644 index 0000000..07659c1 --- /dev/null +++ b/boards/dk-tm4c129x/hibernate/startup_rvmdk.S @@ -0,0 +1,331 @@ +; <<< Use Configuration Wizard in Context Menu >>> +;****************************************************************************** +; +; startup_rvmdk.S - Startup code for use with Keil's uVision. +; +; Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved. +; Software License Agreement +; +; Texas Instruments (TI) is supplying this software for use solely and +; exclusively on TI's microcontroller products. The software is owned by +; TI and/or its suppliers, and is protected under applicable copyright +; laws. You may not combine this software with "viral" open-source +; software in order to form a larger program. +; +; THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +; NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +; NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +; CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +; DAMAGES, FOR ANY REASON WHATSOEVER. +; +; This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package. +; +;****************************************************************************** + +;****************************************************************************** +; +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; +;****************************************************************************** +Stack EQU 0x00000400 + +;****************************************************************************** +; +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; +;****************************************************************************** +Heap EQU 0x00000000 + +;****************************************************************************** +; +; Allocate space for the stack. +; +;****************************************************************************** + AREA STACK, NOINIT, READWRITE, ALIGN=3 +StackMem + SPACE Stack +__initial_sp + +;****************************************************************************** +; +; Allocate space for the heap. +; +;****************************************************************************** + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +HeapMem + SPACE Heap +__heap_limit + +;****************************************************************************** +; +; Indicate that the code in this file preserves 8-byte alignment of the stack. +; +;****************************************************************************** + PRESERVE8 + +;****************************************************************************** +; +; Place code into the reset code section. +; +;****************************************************************************** + AREA RESET, CODE, READONLY + THUMB + +;****************************************************************************** +; +; External declaration for the interrupt handler used by the application. +; +;****************************************************************************** + EXTERN TouchScreenIntHandler + +;****************************************************************************** +; +; The vector table. +; +;****************************************************************************** + EXPORT __Vectors +__Vectors + DCD StackMem + Stack ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NmiSR ; NMI Handler + DCD FaultISR ; Hard Fault Handler + DCD IntDefaultHandler ; The MPU fault handler + DCD IntDefaultHandler ; The bus fault handler + DCD IntDefaultHandler ; The usage fault handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD IntDefaultHandler ; SVCall handler + DCD IntDefaultHandler ; Debug monitor handler + DCD 0 ; Reserved + DCD IntDefaultHandler ; The PendSV handler + DCD IntDefaultHandler ; The SysTick handler + DCD IntDefaultHandler ; GPIO Port A + DCD IntDefaultHandler ; GPIO Port B + DCD IntDefaultHandler ; GPIO Port C + DCD IntDefaultHandler ; GPIO Port D + DCD IntDefaultHandler ; GPIO Port E + DCD IntDefaultHandler ; UART0 Rx and Tx + DCD IntDefaultHandler ; UART1 Rx and Tx + DCD IntDefaultHandler ; SSI0 Rx and Tx + DCD IntDefaultHandler ; I2C0 Master and Slave + DCD IntDefaultHandler ; PWM Fault + DCD IntDefaultHandler ; PWM Generator 0 + DCD IntDefaultHandler ; PWM Generator 1 + DCD IntDefaultHandler ; PWM Generator 2 + DCD IntDefaultHandler ; Quadrature Encoder 0 + DCD IntDefaultHandler ; ADC Sequence 0 + DCD IntDefaultHandler ; ADC Sequence 1 + DCD IntDefaultHandler ; ADC Sequence 2 + DCD TouchScreenIntHandler ; ADC Sequence 3 + DCD IntDefaultHandler ; Watchdog timer + DCD IntDefaultHandler ; Timer 0 subtimer A + DCD IntDefaultHandler ; Timer 0 subtimer B + DCD IntDefaultHandler ; Timer 1 subtimer A + DCD IntDefaultHandler ; Timer 1 subtimer B + DCD IntDefaultHandler ; Timer 2 subtimer A + DCD IntDefaultHandler ; Timer 2 subtimer B + DCD IntDefaultHandler ; Analog Comparator 0 + DCD IntDefaultHandler ; Analog Comparator 1 + DCD IntDefaultHandler ; Analog Comparator 2 + DCD IntDefaultHandler ; System Control (PLL, OSC, BO) + DCD IntDefaultHandler ; FLASH Control + DCD IntDefaultHandler ; GPIO Port F + DCD IntDefaultHandler ; GPIO Port G + DCD IntDefaultHandler ; GPIO Port H + DCD IntDefaultHandler ; UART2 Rx and Tx + DCD IntDefaultHandler ; SSI1 Rx and Tx + DCD IntDefaultHandler ; Timer 3 subtimer A + DCD IntDefaultHandler ; Timer 3 subtimer B + DCD IntDefaultHandler ; I2C1 Master and Slave + DCD IntDefaultHandler ; CAN0 + DCD IntDefaultHandler ; CAN1 + DCD IntDefaultHandler ; Ethernet + DCD IntDefaultHandler ; Hibernate + DCD IntDefaultHandler ; USB0 + DCD IntDefaultHandler ; PWM Generator 3 + DCD IntDefaultHandler ; uDMA Software Transfer + DCD IntDefaultHandler ; uDMA Error + DCD IntDefaultHandler ; ADC1 Sequence 0 + DCD IntDefaultHandler ; ADC1 Sequence 1 + DCD IntDefaultHandler ; ADC1 Sequence 2 + DCD IntDefaultHandler ; ADC1 Sequence 3 + DCD IntDefaultHandler ; External Bus Interface 0 + DCD IntDefaultHandler ; GPIO Port J + DCD IntDefaultHandler ; GPIO Port K + DCD IntDefaultHandler ; GPIO Port L + DCD IntDefaultHandler ; SSI2 Rx and Tx + DCD IntDefaultHandler ; SSI3 Rx and Tx + DCD IntDefaultHandler ; UART3 Rx and Tx + DCD IntDefaultHandler ; UART4 Rx and Tx + DCD IntDefaultHandler ; UART5 Rx and Tx + DCD IntDefaultHandler ; UART6 Rx and Tx + DCD IntDefaultHandler ; UART7 Rx and Tx + DCD IntDefaultHandler ; I2C2 Master and Slave + DCD IntDefaultHandler ; I2C3 Master and Slave + DCD IntDefaultHandler ; Timer 4 subtimer A + DCD IntDefaultHandler ; Timer 4 subtimer B + DCD IntDefaultHandler ; Timer 5 subtimer A + DCD IntDefaultHandler ; Timer 5 subtimer B + DCD IntDefaultHandler ; FPU + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD IntDefaultHandler ; I2C4 Master and Slave + DCD IntDefaultHandler ; I2C5 Master and Slave + DCD IntDefaultHandler ; GPIO Port M + DCD IntDefaultHandler ; GPIO Port N + DCD 0 ; Reserved + DCD IntDefaultHandler ; Tamper + DCD IntDefaultHandler ; GPIO Port P (Summary or P0) + DCD IntDefaultHandler ; GPIO Port P1 + DCD IntDefaultHandler ; GPIO Port P2 + DCD IntDefaultHandler ; GPIO Port P3 + DCD IntDefaultHandler ; GPIO Port P4 + DCD IntDefaultHandler ; GPIO Port P5 + DCD IntDefaultHandler ; GPIO Port P6 + DCD IntDefaultHandler ; GPIO Port P7 + DCD IntDefaultHandler ; GPIO Port Q (Summary or Q0) + DCD IntDefaultHandler ; GPIO Port Q1 + DCD IntDefaultHandler ; GPIO Port Q2 + DCD IntDefaultHandler ; GPIO Port Q3 + DCD IntDefaultHandler ; GPIO Port Q4 + DCD IntDefaultHandler ; GPIO Port Q5 + DCD IntDefaultHandler ; GPIO Port Q6 + DCD IntDefaultHandler ; GPIO Port Q7 + DCD IntDefaultHandler ; GPIO Port R + DCD IntDefaultHandler ; GPIO Port S + DCD IntDefaultHandler ; SHA/MD5 0 + DCD IntDefaultHandler ; AES 0 + DCD IntDefaultHandler ; DES3DES 0 + DCD IntDefaultHandler ; LCD Controller 0 + DCD IntDefaultHandler ; Timer 6 subtimer A + DCD IntDefaultHandler ; Timer 6 subtimer B + DCD IntDefaultHandler ; Timer 7 subtimer A + DCD IntDefaultHandler ; Timer 7 subtimer B + DCD IntDefaultHandler ; I2C6 Master and Slave + DCD IntDefaultHandler ; I2C7 Master and Slave + DCD IntDefaultHandler ; HIM Scan Matrix Keyboard 0 + DCD IntDefaultHandler ; One Wire 0 + DCD IntDefaultHandler ; HIM PS/2 0 + DCD IntDefaultHandler ; HIM LED Sequencer 0 + DCD IntDefaultHandler ; HIM Consumer IR 0 + DCD IntDefaultHandler ; I2C8 Master and Slave + DCD IntDefaultHandler ; I2C9 Master and Slave + DCD IntDefaultHandler ; GPIO Port T + +;****************************************************************************** +; +; This is the code that gets called when the processor first starts execution +; following a reset event. +; +;****************************************************************************** + EXPORT Reset_Handler +Reset_Handler + ; + ; Enable the floating-point unit. This must be done here to handle the + ; case where main() uses floating-point and the function prologue saves + ; floating-point registers (which will fault if floating-point is not + ; enabled). Any configuration of the floating-point unit using + ; DriverLib APIs must be done here prior to the floating-point unit + ; being enabled. + ; + ; Note that this does not use DriverLib since it might not be included + ; in this project. + ; + MOVW R0, #0xED88 + MOVT R0, #0xE000 + LDR R1, [R0] + ORR R1, #0x00F00000 + STR R1, [R0] + + ; + ; Call the C library enty point that handles startup. This will copy + ; the .data section initializers from flash to SRAM and zero fill the + ; .bss section. + ; + IMPORT __main + B __main + +;****************************************************************************** +; +; This is the code that gets called when the processor receives a NMI. This +; simply enters an infinite loop, preserving the system state for examination +; by a debugger. +; +;****************************************************************************** +NmiSR + B NmiSR + +;****************************************************************************** +; +; This is the code that gets called when the processor receives a fault +; interrupt. This simply enters an infinite loop, preserving the system state +; for examination by a debugger. +; +;****************************************************************************** +FaultISR + B FaultISR + +;****************************************************************************** +; +; This is the code that gets called when the processor receives an unexpected +; interrupt. This simply enters an infinite loop, preserving the system state +; for examination by a debugger. +; +;****************************************************************************** +IntDefaultHandler + B IntDefaultHandler + +;****************************************************************************** +; +; Make sure the end of this section is aligned. +; +;****************************************************************************** + ALIGN + +;****************************************************************************** +; +; Some code in the normal code section for initializing the heap and stack. +; +;****************************************************************************** + AREA |.text|, CODE, READONLY + +;****************************************************************************** +; +; The function expected of the C library startup code for defining the stack +; and heap memory locations. For the C library version of the startup code, +; provide this function so that the C library initialization code can find out +; the location of the stack and heap. +; +;****************************************************************************** + IF :DEF: __MICROLIB + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + ELSE + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + LDR R0, =HeapMem + LDR R1, =(StackMem + Stack) + LDR R2, =(HeapMem + Heap) + LDR R3, =StackMem + BX LR + ENDIF + +;****************************************************************************** +; +; Make sure the end of this section is aligned. +; +;****************************************************************************** + ALIGN + +;****************************************************************************** +; +; Tell the assembler that we're done. +; +;****************************************************************************** + END -- cgit v1.3.1