Add NSH date command
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3932 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
6dcc46c8aa
commit
f2e7858d3a
@ -1377,6 +1377,8 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Support for the NetClamps VSN was included in version 5.18 of NuttX.
|
Support for the NetClamps VSN was included in version 5.18 of NuttX.
|
||||||
|
Uros Platise added support for timers, RTC, I2C, FLASH, extended power management
|
||||||
|
and other features.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
|
@ -222,11 +222,12 @@ clock_t up_rtc_getclock(void)
|
|||||||
*
|
*
|
||||||
* \param time The unit depends on the prescaler value
|
* \param time The unit depends on the prescaler value
|
||||||
**/
|
**/
|
||||||
void up_rtc_setclock(clock_t clock)
|
|
||||||
|
void up_rtc_setclock(clock_t newclock)
|
||||||
{
|
{
|
||||||
stm32_rtc_beginwr();
|
stm32_rtc_beginwr();
|
||||||
putreg16(clock >> 16, STM32_RTC_CNTH);
|
putreg16(newclock >> 16, STM32_RTC_CNTH);
|
||||||
putreg16(clock & 0xFFFF, STM32_RTC_CNTL);
|
putreg16(newclock & 0xFFFF, STM32_RTC_CNTL);
|
||||||
stm32_rtc_endwr();
|
stm32_rtc_endwr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,14 +264,14 @@ time_t up_rtc_gettime(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void up_rtc_settime(time_t time)
|
void up_rtc_settime(time_t newtime)
|
||||||
{
|
{
|
||||||
/* Do reverse compared to gettime above */
|
/* Do reverse compared to gettime above */
|
||||||
|
|
||||||
uint32_t time_lsb = time << RTC_CLOCKS_SHIFT |
|
uint32_t time_lsb = newtime << RTC_CLOCKS_SHIFT |
|
||||||
(up_rtc_getclock() & ((1<<RTC_CLOCKS_SHIFT)-1));
|
(up_rtc_getclock() & ((1<<RTC_CLOCKS_SHIFT)-1));
|
||||||
|
|
||||||
uint32_t time_msb = time >> (32-RTC_CLOCKS_SHIFT);
|
uint32_t time_msb = newtime >> (32-RTC_CLOCKS_SHIFT);
|
||||||
|
|
||||||
irqstate_t irqs = irqsave();
|
irqstate_t irqs = irqsave();
|
||||||
|
|
||||||
|
@ -398,9 +398,9 @@ CONFIG_ARCH_LOWPUTC=y
|
|||||||
CONFIG_RR_INTERVAL=200
|
CONFIG_RR_INTERVAL=200
|
||||||
CONFIG_SCHED_INSTRUMENTATION=n
|
CONFIG_SCHED_INSTRUMENTATION=n
|
||||||
CONFIG_TASK_NAME_SIZE=16
|
CONFIG_TASK_NAME_SIZE=16
|
||||||
CONFIG_START_YEAR=2009
|
CONFIG_START_YEAR=2011
|
||||||
CONFIG_START_MONTH=9
|
CONFIG_START_MONTH=8
|
||||||
CONFIG_START_DAY=21
|
CONFIG_START_DAY=23
|
||||||
CONFIG_GREGORIAN_TIME=n
|
CONFIG_GREGORIAN_TIME=n
|
||||||
CONFIG_JULIAN_TIME=n
|
CONFIG_JULIAN_TIME=n
|
||||||
CONFIG_DEV_CONSOLE=y
|
CONFIG_DEV_CONSOLE=y
|
||||||
|
@ -33,6 +33,27 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
/* Definition of terms. Various "sleep" and low power consumption states
|
||||||
|
* have various names and are sometimes used in conflicting ways. In the
|
||||||
|
* PM logic, we will use the following terminology:
|
||||||
|
*
|
||||||
|
* NORMAL - The normal, full power operating mode.
|
||||||
|
* REDUCED - This is still basically normal operational mode, but with some
|
||||||
|
* simple changes to reduce power consumption. Perhaps this just
|
||||||
|
* means just dimming the backlight.
|
||||||
|
* STANDBY - Standby is a very low power consumption mode. It is the lowest
|
||||||
|
* power from which the system can recover quickly.
|
||||||
|
* SLEEP - The lowest power consumption mode. It may require some time
|
||||||
|
* to get back to normal operation from SLEEP (some parts may
|
||||||
|
* even require going through reset).
|
||||||
|
*
|
||||||
|
* State changes always proceed from higher to lower power usage:
|
||||||
|
*
|
||||||
|
* NORMAL->REDUCED->STANDBY->SLEEP
|
||||||
|
* ^ | | |
|
||||||
|
* | V V V
|
||||||
|
* +-------+---------+--------+
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __INCLUDE_NUTTX_PM_H
|
#ifndef __INCLUDE_NUTTX_PM_H
|
||||||
#define __INCLUDE_NUTTX_PM_H
|
#define __INCLUDE_NUTTX_PM_H
|
||||||
@ -42,11 +63,30 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/fs.h>
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-Processor Definitions
|
* Pre-Processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
/* Configuration ************************************************************/
|
||||||
|
/* Time slices */
|
||||||
|
|
||||||
|
#ifndef CONFIG_PM_SLICEMS
|
||||||
|
# define CONFIG_PM_SLICEMS 100 /* Default is 100 msec */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_PM_NREDUCED
|
||||||
|
# define CONFIG_PM_NREDUCED 30 /* Thiry IDLE slices to enter reduced mode */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_PM_NSTANDBY
|
||||||
|
# define CONFIG_PM_NSTANDBY 80 /* Eight IDLE slices to enter standby mode */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_PM_NSLEEP
|
||||||
|
# define CONFIG_PM_NSLEEP 150 /* 150 IDLE slices to enter standby mode */
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
@ -56,33 +96,31 @@
|
|||||||
* state indication is the state transition event.
|
* state indication is the state transition event.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum pm_event_e
|
enum pm_state_e
|
||||||
{
|
{
|
||||||
PM_IDLE = 0, /* Drivers will receive periodic idle indications. The driver
|
PM_REDUCED = 0, /* Drivers will receive periodic this indications if it is
|
||||||
* may use these IDLE indications to perform driver-specific
|
* appropriate to enter a simple reduced power state. This
|
||||||
* power optimizations.
|
* would include simple things such as displaying display back-
|
||||||
*/
|
* lighting. The driver should essentially be ready to resume
|
||||||
PM_SLEEP_PREP, /* This is a warning that the system is about to enter into
|
* normal activity instantly.
|
||||||
* sleep mode. The driver should begin whatever operations
|
*
|
||||||
* that may be required to enter sleep mode. The driver
|
* PM_REDUCED may be followed by PM_STANDBY or PM_RESUME.
|
||||||
* may abort the sleep mode by returning a non-zero value
|
*/
|
||||||
* from the callback function.
|
PM_STANDBY, /* The system is entering standby mode. The driver should
|
||||||
*/
|
* already be prepared for this mode.
|
||||||
PM_STOP_PREP, /* This is a warning that the system is about to enter into
|
*
|
||||||
* stop mode. The driver should begin whatever operations
|
* PM_STANDBY may be followed PM_SLEEP or by PM_RESUME
|
||||||
* that may be required to enter stop mode. The driver
|
*/
|
||||||
* may abort the stop mode by returning a non-zero value
|
PM_SLEEP, /* The system is entering deep sleep mode. The driver should
|
||||||
* from the callback function.
|
* already be prepared for this mode.
|
||||||
*/
|
*
|
||||||
PM_SLEEP, /* The system is entering sleep mode. The driver should
|
* PM_SLEEP may be following by PM_RESUME
|
||||||
* already be prepared for this mode.
|
*/
|
||||||
*/
|
PM_RESUME, /* The system is resuming normal operation. The driver should
|
||||||
PM_STOP, /* The system is entering stop mode. The driver should
|
* reinitialize for normal operation.
|
||||||
* already be prepared for this mode.
|
*
|
||||||
*/
|
* PM_RESUME may be followed by PM_REDUCED.
|
||||||
PM_RESUME, /* The system resuming normal operation. The driver should
|
*/
|
||||||
* reinitialize for normal operation.
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This structure contain pointers callback functions in the driver. These
|
/* This structure contain pointers callback functions in the driver. These
|
||||||
@ -93,7 +131,53 @@ enum pm_event_e
|
|||||||
struct pm_callback_s
|
struct pm_callback_s
|
||||||
{
|
{
|
||||||
struct pm_callback_s *flink; /* Supports a singly linked list */
|
struct pm_callback_s *flink; /* Supports a singly linked list */
|
||||||
int (*notify)(enum pm_event_e pmevent); /* PM event callback */
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Name: prepare
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Notify the driver to prepare for a new power confition .This is a
|
||||||
|
* warning that the system is about to enter into a new power state. The
|
||||||
|
* driver should begin whatever operations that may be required to enter
|
||||||
|
* power state. The driver may abort the state change mode by returning
|
||||||
|
* a non-zero value from the callback function
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* cb - Returned to the driver. The driver version of the callback
|
||||||
|
* strucure may include additional, driver-specific state
|
||||||
|
* data at the end of the structure.
|
||||||
|
* pmstate - Idenfifies the new PM state
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* 0 (OK) means the event was successfully processed. Non-zero means
|
||||||
|
* means that the driver is not prepared to perform the tasks needed
|
||||||
|
* achieve this power setting.
|
||||||
|
*
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
int (*prepare)(FAR struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Name: notify
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Notify the driver of new power state. This callback is called after
|
||||||
|
* all drivers have had the opportunity to prepare for the new power
|
||||||
|
* state.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* cb - Returned to the driver. The driver version of the callback
|
||||||
|
* strucure may include additional, driver-specific state
|
||||||
|
* data at the end of the structure.
|
||||||
|
* pmstate - Idenfifies the new PM state
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* 0 (OK) means the event was successfully processed. Non-zero means
|
||||||
|
* means that the driver failed to enter the power mode.
|
||||||
|
*
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
int (*notify)(FAR struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -128,29 +212,41 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN int pm_register(FAR const struct pm_callback_s *callbacks);
|
EXTERN int pm_register(FAR struct pm_callback_s *callbacks);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: pm_broadcast
|
* Name: pm_changestate
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This function is used to platform-specific power managmeent logic. It
|
* This function is used to platform-specific power managmeent logic. It
|
||||||
* will announce the power management event to all drivers that have
|
* will announce the power management power management state change to all
|
||||||
* registered for power management event callbacks.
|
* drivers that have registered for power management event callbacks.
|
||||||
*
|
*
|
||||||
*
|
* Input Parameters:
|
||||||
|
* pmstate - Idenfifies the new PM state
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* 0 (OK) means that the callback function for all registered drivers
|
||||||
|
* returned OK (meaning that they accept the state change).
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN int pm_broadcast(enum pm_event_s pmevent);
|
EXTERN int pm_changestate(enum pm_event_s pmstate);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: pm_activity
|
* Name: pm_activity
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This function is called by a device driver to indicate that it is
|
* This function is called by a device driver to indicate that it is
|
||||||
* performing meaningful activities (non-idle). This will restart a
|
* performing meaningful activities (non-idle). This increment an activty
|
||||||
* idle timer and prevent entering reduced power states.
|
* cound and/or will restart a idle timer and prevent entering reduced
|
||||||
|
* power states.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The current activity count.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -164,6 +260,12 @@ EXTERN int pm_activity(void);
|
|||||||
* was called. A count of zero will indicate that no meaningful activity
|
* was called. A count of zero will indicate that no meaningful activity
|
||||||
* occurred since the last time this function was called.
|
* occurred since the last time this function was called.
|
||||||
*
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The current activity count.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN int pm_checkactivity(void);
|
EXTERN int pm_checkactivity(void);
|
||||||
@ -174,4 +276,5 @@ EXTERN int pm_checkactivity(void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
|
#endif /* CONFIG_PM */
|
||||||
#endif /* __INCLUDE_NUTTX_PM_H */
|
#endif /* __INCLUDE_NUTTX_PM_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user