Remove unused header files; eliminate warnings

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3731 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2011-06-21 23:53:00 +00:00
parent 83c452fa5d
commit 05eeae8418
4 changed files with 33 additions and 450 deletions
-256
View File
@@ -1,256 +0,0 @@
/****************************************************************************
* include/nuttx/event.h
*
* Copyright(C) 2011 Uros Platise. All rights reserved.
* Author: Uros Platise <uros.platise@isotel.eu>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/** \file
* \author Uros Platise
* \brief Events
*
* Event moudle offer real-time signaling and handling of real-time
* events at precision of system resolution clock_t.
*
* Events are based on periodic timers, where each started event starts
* counting at its relative time = 0, and overflows at given period.
* Overflow is signalized by posted event that is handled by the
* event_eventhandler() called by each thread or task working with
* Events.
*
* Events may be used inside one thread or task only or between tasks
* and threads. An event can also be bind to another event i.e.:
* - System Clock may issue a notification about Power Failure
* - Other threads may connect to this event and when handled, they may
* inquiry for pricise time when this event has happend, using the
* event_gettime()
*
* Or system is about to control a process, and instead of looping and
* inquiring for time, system timers offer simple and effective
* mechanism to control timed actions:
* - First event is about to wait 5 seconds, then it must assert some
* switch, triggering another event after 2 seconds, to check the
* state of the system.
* - After 2 seconds new event is triggerred, if it is time criticial
* it may check for the overrun time and handle further actions,
* - ...
*
* Each event is denoted by a callback function event_callback_t, and
* an argument. Posted event with the same callback but different
* argument is treated as different event, while the same callback with
* the same argument replaces previously started event.
**/
#ifdef CONFIG_EVENT
#ifndef __INCLUDE_NUTTX_EVENT_H
#define __INCLUDE_NUTTX_EVENT_H
#include <nuttx/config.h>
#include <time.h>
#include <stdint.h>
#include <stdbool.h>
#include <nuttx/clock.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Types
****************************************************************************/
/** Event Callback
*
* \param arg an argument as posted by the event_post(),
* event_signal() or event_start() methods.
*
* \return Optional time to increment to retrigger. This time is added
* to present actual time, so an event returning with constant value
* as return PERIOD would be periodic with long-term absolute precision.
*
* \retval >0 Time to increment to second post of the event.
* \retval 0 Acknowledge event.
*/
typedef clock_t (*event_callback_t)(FAR void *arg);
typedef struct event_s event_t;
/****************************************************************************
* Public Functions
****************************************************************************/
/** Create new instance of Events (typically per thread)
*
* \param base Future extension to support multiple base timers. Pass NULL at
* the moment.
*
* \return Valid structure or NULL on error with errno set.
*/
event_t * event_create(void * base);
/** Delete unused instance of Events. A call to this function also destroys
* all bindings.
*
* \param events Pointer to a structure as returned by event_create()
* \return 0 On success or -1 on error.
*/
int event_delete(event_t *events);
/** Post an event, equal to period = 0
*
* In case of connected events, those are called prior calling
* the given event. Since the event is called last on the list
* it may serve as an acknowledgement mechanism.
*
* \param events Pointer to a structure as returned by event_create()
* \param event Callback to be called
* \param arg Optional argument to be passed to the event.
* \return 0 On success or -1 on error.
*/
int event_post(event_t *events, event_callback_t event, void *arg);
/** Trigger an event without calling it but may trigger connected events
*
* \param events Pointer to a structure as returned by event_create()
* \param event Callback to be called
* \param arg Optional argument to be passed to the event.
* \return 0 On success or -1 on error.
*/
int event_signal(event_t *events, event_callback_t event, void *arg);
/** Calls all connected events only immediately.
*
* \param events Pointer to a structure as returned by event_create()
* \param event Callback to be called
* \param arg Optional argument to be passed to the event.
* \return 0 On success or -1 on error.
*/
int event_call(event_t *events, event_callback_t event, void *arg);
/** Are there any connections to given event
* \param events Pointer to a structure as returned by event_create()
* \param event Callback to be called
* \return 1 When empty otherwise 0
*/
int event_isempty(event_t *events, event_callback_t event);
/** Start timer with given period
*
* \param events Pointer to a structure as returned by event_create()
* \param event Callback to be called
* \param arg Optional argument to be passed to the event.
* \param period Time to first occurence.
* \return 0 On success or -1 on error.
*/
int event_start(event_t *events, event_callback_t event, void *arg, clock_t period);
/** Stop timer, matches only those with equal event and arg.
*
* \param events Pointer to a structure as returned by event_create()
* \param event Callback to be called
* \param arg Optional argument to be passed to the event.
* \return 0 On success or -1 on error.
*/
int event_stop(event_t *events, event_callback_t event, void *arg);
/** Stop all timers related to the same event callback
*
* \param events Pointer to a structure as returned by event_create()
* \param event Callback to be called
* \return 0 On success or -1 on error.
*/
int event_stopall(event_t *events, event_callback_t event);
/** Get present time of given timer
*
* \param events Pointer to a structure as returned by event_create()
* \param event Callback to be called
* \param arg Optional argument to be passed to the event.
* \return 0 On success or -1 on error.
*/
clock_t event_gettime(event_t *events, event_callback_t event, void *arg);
/** Bind two events
*
* \param source_events Pointer to source event structure.
* \param source_event Source event
* \param dest_events Pointer to destination event structure
* \param dest_event Destination event to be called, when source fires
* \return 0 On success or -1 on error.
*/
int event_connect(event_t *source_events, event_callback_t source_event,
event_t *dest_events, event_callback_t dest_event);
/** Unbind two events
*
* \param source_events Pointer to source event structure.
* \param source_event Source event
* \param dest_events Pointer to destination event structure
* \param dest_event Destination event to be called, when source fires
* \return 0 On success or -1 on error.
*/
int event_disconnect(event_t *source_events, event_callback_t source_event,
event_t *dest_events, event_callback_t dest_event);
/** Unbind all events related to given destination
*
* \param dest_events Pointer to destination event structure
* \param dest_event Destination event to be called, when source fires
* \return 0 On success or -1 on error.
*/
int event_disconnectall(event_t *dest_events, event_callback_t dest_event);
/** Handle callbacks
*
* \param events Pointer to a structure as returned by event_create()
* \param timeout Time to wait for a callback to be served.
* \return Remaining time.
* */
clock_t event_handle(event_t *events, clock_t timeout);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __INCLUDE_NUTTX_EVENT_H */
#endif /* CONFIG_EVENT */
-193
View File
@@ -1,193 +0,0 @@
/****************************************************************************
* include/nuttx/resource.h
*
* Copyright(C) 2011 Uros Platise. All rights reserved.
* Author: Uros Platise <uros.platise@isotel.eu>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/** \file
* \author Uros Platise
* \brief System Resources
*
* System resource provides interface to device drivers to list possible
* configurations that can be changed by system to minimize (optimize)
* energy and power usage, to lock a specific resource, fixing it at
* desired value and to support multiple power down capabilities by the
* up_idle().
*
* System resources are provided on the chip or board level, such as:
* - clock scaling (chip level)
* - voltage scaling (board level)
*
* This interface is to be used by low-level peripherals only and its
* purpose is to be as fast as possible to do quick power and energy
* optimizations (including deep power savings).
*
* A separate common device driver interface would be required to allow
* access from user programs (i.e. to select voltage and similar).
**/
#ifdef CONFIG_RESOURCE
#ifndef __INCLUDE_NUTTX_RESOURCE_H
#define __INCLUDE_NUTTX_RESOURCE_H
#include <nuttx/config.h>
#include <nuttx/arch/chip/resource.h>
#include <nuttx/arch/board/resource.h>
#include <stdint.h>
/****************************************************************************
* TO BE MOVED UNDER arch/chip/resource.h
****************************************************************************/
/** Clocking */
#define RESOURCE_CLOCK_HCLK
#define RESOURCE_CLOCK_PCLK1
#define RESOURCE_CLOCK_PCLK2
/****************************************************************************
* TO BE MOVED UNDER arch/board/resource.h
****************************************************************************/
/** Voltage, Vcc Minimum Requirements */
#define RESOURCE_VOLTAGE_VCC_MIN2_3 0x00
#define RESOURCE_VOLTAGE_VCC_MIN3_0 0x01 /* A/D converter starts working at this level */
#define RESOURCE_VOLTAGE_VCC_MIN3_3 0x02
/****************************************************************************
* Available Options to be enabled in the .config
****************************************************************************/
#if 0
/** Enable Resources
*/
#define CONFIG_RESOURCE
/** Enable resource: clock scaling, allocates an array of options bits
* for each peripheral. On STM32 this option adds about 64-128 bytes.
* This option is provided by chip: nuttx/arch/board/resource.h
*
* Clock resources are used by low-level driver before they starts a
* transaction. System may pick up any of the clock options that suit
* all of the drivers. The selected clock option is returned, and is up
* to the driver to recalculate and modify i.e. period or additional
* prescaler to achieve the desired frequency of operation. After lock()
* call, clock will not change, until unlock() is called.
*
* As long there is a single clock lock, system will not be able to
* enter low power-down mode in which all of the clocks are disabled.
*
* The isactive() function is called typically by the up_idle() to
* decide which power-down mode to select. If none of the clocks are
* required to run, then ultra low power-down mode can be entered,
* reducing power as low as downto 35 uA or 25 uA (with LDO in low-power
* mode).
*
* Note: AD may continue to consume power in stop mode, so it's up
* to AD driver to disable its power when its unused.
*/
#define CONFIG_RESOURCE_CLOCK_SCALING
/** Enable resource: voltage scaling.
*
* This option is provided by the board: nuttx/arch/board/resource.h
*/
#define CONFIG_RESOURCE_VOLTAGE_SCALING
/** Resource Check: check for multiple locks/unlocks conditions and
* report errors.
*
* For proper operation after lock(resourceN) only one unlock(resourceN)
* may follow. Enabling this option adds time consuming checks to detect
* errors in low-level drivers.
*/
#define CONFIG_RESOURCE_CHECK_MULTIPLES
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Interface
****************************************************************************/
/** Resource Interface */
struct resource_ops_s {
/** Set possible options for specific domain and peripheral ID */
uint32_t (*setopts)(struct resource_dev_t *dev, uint8_t domain_id);
/** Get available options */
uint32_t (*getopts)(struct resource_dev_t *dev, uint8_t domain);
/** Lock resource, means, that it cannot be changed meanwhile */
uint32_t (*lock)(struct resource_dev_t *dev, uint8_t domain_id);
/** Unlock resource, means, allow further changes */
uint32_t (*unlock)(struct resource_dev_t *dev, uint8_t domain_id);
/** Reports present activity
* \retval >0 activity
* \retval =0 Inactivity allowing system entering deep power down modes.
* \retval <0 internal error, system cannot resolve requests.
*/
int (*isactive)(struct resource_dev_t *dev);
};
#define RESOURCE_SETOPTS(dev, domain_id) dev->setopts(dev, domain_id)
#define RESOURCE_GETOPTS(dev, domain) dev->getopts(dev, domain)
#define RESOURCE_LOCK(dev, domain_id) dev->lock(dev, domain_id)
#define RESOURCE_UNLOCK(dev, domain_id) dev->unlock(dev, domain_id)
#define RESOURCE_ISACTIVE(dev) dev->isactive(dev)
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __INCLUDE_NUTTX_EVENT_H */
#endif /* CONFIG_RESOURCE */