summaryrefslogtreecommitdiffstats
path: root/nuttx/configs
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-07-27 23:31:10 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-07-27 23:31:10 +0000
commit17d494e95dcdbf313f9bd2b1d8d63886d672f2c2 (patch)
tree0b3fc1501e2444fbfb0adb0fcffe625eb824582b /nuttx/configs
parentf3cc6da14b94f8e5568196b5d7bc14d0cec9939e (diff)
PM update
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4986 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/configs')
-rw-r--r--nuttx/configs/stm3210e-eval/src/up_idle.c220
-rw-r--r--nuttx/configs/stm3210e-eval/src/up_lcd.c26
2 files changed, 163 insertions, 83 deletions
diff --git a/nuttx/configs/stm3210e-eval/src/up_idle.c b/nuttx/configs/stm3210e-eval/src/up_idle.c
index 983089d4af..b412aa5a99 100644
--- a/nuttx/configs/stm3210e-eval/src/up_idle.c
+++ b/nuttx/configs/stm3210e-eval/src/up_idle.c
@@ -33,7 +33,6 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- *
****************************************************************************/
/****************************************************************************
@@ -123,7 +122,7 @@
****************************************************************************/
#if defined(CONFIG_PM) && defined(CONFIG_RTC_ALARM)
-static void up_alarmcb(void);
+static volatile bool g_alarmwakeup;
#endif
/****************************************************************************
@@ -131,6 +130,113 @@ static void up_alarmcb(void);
****************************************************************************/
/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_alarmcb
+ *
+ * Description:
+ * RTC alarm callback
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_PM) && defined(CONFIG_RTC_ALARM)
+static void up_alarmcb(void)
+{
+ /* Note that we were awaken by an alarm */
+
+ g_alarmwakeup = true;
+}
+#endif
+
+/****************************************************************************
+ * Name: up_alarm_exti
+ *
+ * Description:
+ * RTC alarm EXTI interrupt service routine
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_PM) && defined(CONFIG_RTC_ALARM)
+static void up_alarm_exti(int irq, FAR void *context);
+{
+ up_alarmcb();
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: up_exti_cancel
+ *
+ * Description:
+ * Disable the ALARM EXTI interrupt
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_PM) && defined(CONFIG_RTC_ALARM)
+static void up_exti_cancel(void);
+{
+ (void)stm32_exti_alarm(false, false, false, NULL);
+}
+#endif
+
+/****************************************************************************
+ * Name: up_rtc_alarm
+ *
+ * Description:
+ * Set the alarm
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_PM) && defined(CONFIG_RTC_ALARM)
+static int int up_rtc_alarm(int irq, FAR void *context);
+{
+ struct timespec alarmtime;
+ int ret;
+
+ /* Configure to receive RTC Alarm EXTI interrupt */
+
+ if (exti)
+ {
+ /* TODO: Make sure that that is no pending EXTI interrupt */
+
+ stm32_exti_alarm(true, true, true, up_alarm_exti);
+ }
+
+ /* Configure the RTC alarm to Auto Wake the system */
+
+ (void)up_rtc_gettime(&alarmtime);
+
+ alarmtime.tv_sec += tv_sec;
+ alarmtime.tv_nsec += tv_nsec;
+
+ /* The tv_nsec value must not exceed 1,000,000,000. That
+ * would be an invalid time.
+ */
+
+ if (alarmtime.tv_nsec >= NSEC_PER_SEC)
+ {
+ /* Carry to the seconds */
+
+ alarmtime.tv_sec++;
+ alarmtime.tv_nsec -= NSEC_PER_SEC;
+ }
+
+ /* Set the alarm */
+
+ g_alarmwakeup = false;
+ ret = up_rtc_setalarm(&alarmtime, up_alarmcb);
+ if (ret < 0)
+ {
+ lldbg("Warning: The alarm is already set\n");
+ }
+
+ return ret;
+}
+#endif
+
+/****************************************************************************
* Name: up_idlepm
*
* Description:
@@ -141,9 +247,6 @@ static void up_alarmcb(void);
#ifdef CONFIG_PM
static void up_idlepm(void)
{
-#ifdef CONFIG_RTC_ALARM
- struct timespec alarmtime;
-#endif
static enum pm_state_e oldstate = PM_NORMAL;
enum pm_state_e newstate;
int ret;
@@ -171,7 +274,7 @@ static void up_idlepm(void)
/* No state change... */
- return;
+ goto errout;
}
/* Then perform board-specific, state-dependent logic here */
@@ -185,7 +288,7 @@ static void up_idlepm(void)
*/
if (oldstate == PM_STANDBY)
- {
+ {
stm32_clockconfig();
}
}
@@ -198,38 +301,15 @@ static void up_idlepm(void)
case PM_STANDBY:
{
-#ifdef CONFIG_RTC_ALARM
- /* Disable RTC Alarm interrupt */
-
- stm32_exti_alarm(true, true, true, NULL);
+ /* Set the alarm as an EXTI Line */
- /* Configure the RTC alarm to Auto Wake the system */
-
- (void)up_rtc_gettime(&alarmtime);
-
- alarmtime.tv_sec += CONFIG_PM_ALARM_SEC;
- alarmtime.tv_nsec += CONFIG_PM_ALARM_NSEC;
-
- /* The tv_nsec value must not exceed 1,000,000,000. That
- * would be an invalid time.
- */
-
- if (alarmtime.tv_nsec >= NSEC_PER_SEC)
- {
- /* Carry to the seconds */
-
- alarmtime.tv_sec++;
- alarmtime.tv_nsec -= NSEC_PER_SEC;
- }
+#ifdef CONFIG_RTC_ALARM
+ up_rtc_alarm(CONFIG_PM_ALARM_SEC, CONFIG_PM_ALARM_NSEC, true);
+#endif
+ /* Wait 10ms */
- /* Set the alarm */
+ up_mdelay(10);
- ret = up_rtc_setalarm(&alarmtime, &up_alarmcb);
- if (ret < 0)
- {
- lldbg("Warning: The alarm is already set\n");
- }
-#endif
/* Enter the STM32 stop mode */
(void)stm32_pmstop(false);
@@ -240,15 +320,28 @@ static void up_idlepm(void)
*/
#ifdef CONFIG_RTC_ALARM
+ up_exti_cancel();
ret = up_rtc_cancelalarm();
if (ret < 0)
{
lldbg("Warning: Cancel alarm failed\n");
}
+
+ /* Were we awakened by the alarm? */
+
+ if (g_alarmwakeup)
+ {
+ /* Yes.. Go to SLEEP mode */
+
+ pm_changestate(PM_SLEEP);
+ }
+ else
#endif
- /* Resume normal operation */
+ {
+ /* Resume normal operation */
- pm_changestate(PM_NORMAL);
+ pm_changestate(PM_NORMAL);
+ }
}
break;
@@ -258,37 +351,17 @@ static void up_idlepm(void)
* of standby is via the reset path.
*/
-#ifdef CONFIG_PM_SLEEP_WAKEUP
/* Configure the RTC alarm to Auto Reset the system */
- (void)up_rtc_gettime(&alarmtime);
-
- alarmtime.tv_sec +=CONFIG_PM_SLEEP_WAKEUP_SEC;
- alarmtime.tv_nsec +=CONFIG_PM_SLEEP_WAKEUP_NSEC;
-
- /* The tv_nsec value must not exceed 1,000,000,000. That
- * would be an invalid time.
- */
-
- if (alarmtime.tv_nsec >= NSEC_PER_SEC)
- {
- /* Carry to the seconds */
-
- alarmtime.tv_sec++;
- alarmtime.tv_nsec -= NSEC_PER_SEC;
- }
+#ifdef CONFIG_PM_SLEEP_WAKEUP
+ up_rtc_alarm(CONFIG_PM_SLEEP_WAKEUP_SEC, CONFIG_PM_SLEEP_WAKEUP_NSEC, false);
+#endif
+ /* Wait 10ms */
- /* Set the alarm */
+ up_mdelay(10);
- ret = up_rtc_setalarm(&alarmtime, &up_alarmcb);
- if (ret < 0)
- {
- lldbg("Warning: The alarm is already set\n");
- }
-#endif
/* Enter the STM32 standby mode */
- up_mdelay(10);
(void)stm32_pmstandby();
}
break;
@@ -301,6 +374,7 @@ static void up_idlepm(void)
oldstate = newstate;
+errout:
sched_unlock();
}
}
@@ -308,25 +382,6 @@ static void up_idlepm(void)
# define up_idlepm()
#endif
-/************************************************************************************
- * Name: up_alarmcb
- *
- * Description:
- * RTC alarm service routine
- *
- ************************************************************************************/
-
-#if defined(CONFIG_PM) && defined(CONFIG_RTC_ALARM)
-static void up_alarmcb(void)
-{
- /* This alarm occurs because there wasn't any EXTI interrupt during the
- * PM_STANDBY period. So just go to sleep.
- */
-
- pm_changestate(PM_SLEEP);
-}
-#endif
-
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -361,4 +416,3 @@ void up_idle(void)
END_IDLE();
#endif
}
-
diff --git a/nuttx/configs/stm3210e-eval/src/up_lcd.c b/nuttx/configs/stm3210e-eval/src/up_lcd.c
index 045f564c34..6f50323ed1 100644
--- a/nuttx/configs/stm3210e-eval/src/up_lcd.c
+++ b/nuttx/configs/stm3210e-eval/src/up_lcd.c
@@ -1213,6 +1213,32 @@ static void stm3210e_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstat
{
/* Entering SLEEP mode - Turn off LCD */
+ if (g_lcddev.type == LCD_TYPE_AM240320)
+ {
+ /* Display off sequence */
+
+ stm3210e_writereg(LCD_REG_0, 0xa0); /* White display mode setting */
+ up_mdelay(10); /* Wait for 2 frame scan */
+ stm3210e_writereg(LCD_REG_59, 0x00); /* Gate scan stop */
+
+ /* Power off sequence */
+
+ stm3210e_writereg(LCD_REG_30, 0x09); /* VCOM stop */
+ stm3210e_writereg(LCD_REG_27, 0x0e); /* VS/VDH turn off */
+ stm3210e_writereg(LCD_REG_24, 0xc0); /* CP1, CP2, CP3 turn off */
+ up_mdelay(10); /* wait 10 ms */
+
+ stm3210e_writereg(LCD_REG_24, 0x00); /* VR1 / VR2 off*/
+ stm3210e_writereg(LCD_REG_28, 0x30); /* Step up circuit operating current stop */
+ up_mdelay(10);
+
+ stm3210e_poweroff();
+ stm3210e_writereg(LCD_REG_0, 0xa0); /* White display mode setting */
+ up_mdelay(10); /* Wait for 2 frame scan */
+
+ stm3210e_writereg(LCD_REG_59, 0x00); /* Gate scan stop */
+ }
+// Does this belong here?
(void)stm3210e_poweroff();
}
break;