aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2013-03-01 09:04:52 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2013-03-01 09:04:52 +1000
commit6ee8b005ae3ee2bc48ea6ac972b0d3b2a2949608 (patch)
tree2ea08726aae7357443420ce45100c8118923dfdd /include
parent9bec5967b293d6c23c9d7e9338d8ece4873f6eac (diff)
downloaduGFX-6ee8b005ae3ee2bc48ea6ac972b0d3b2a2949608.tar.gz
uGFX-6ee8b005ae3ee2bc48ea6ac972b0d3b2a2949608.tar.bz2
uGFX-6ee8b005ae3ee2bc48ea6ac972b0d3b2a2949608.zip
GAUDIN implemented with GADC driver
Diffstat (limited to 'include')
-rw-r--r--include/gadc/gadc.h34
-rw-r--r--include/gaudin/gaudin.h350
-rw-r--r--include/gaudin/lld/gaudin_lld.h105
-rw-r--r--include/gfx.h340
-rw-r--r--include/gfx_rules.h11
-rw-r--r--include/gmisc/gmisc.h214
6 files changed, 597 insertions, 457 deletions
diff --git a/include/gadc/gadc.h b/include/gadc/gadc.h
index be7af516..bd35b30c 100644
--- a/include/gadc/gadc.h
+++ b/include/gadc/gadc.h
@@ -96,10 +96,15 @@ typedef struct GEventADC_t {
} GEventADC;
/**
- * @brief A callback function (executed in a thread context)
+ * @brief A callback function (executed in a thread context) for a low speed conversion
*/
typedef void (*GADCCallbackFunction)(adcsample_t *buffer, void *param);
+/**
+ * @brief A callback function (executed in an ISR context) for a high speed conversion
+ */
+typedef void (*GADCISRCallbackFunction)(adcsample_t *buffer, size_t size);
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
@@ -121,9 +126,9 @@ extern "C" {
* @note If the high speed ADC is running it will be stopped. The Event subsystem is
* disconnected from the high speed ADC and any binary semaphore event is forgotten.
* @note bufcount must be greater than countPerEvent (usually 2 or more times) otherwise
- * the buffer will be overwitten with new data while the application is still trying
+ * the buffer will be overwritten with new data while the application is still trying
* to process the old data.
- * @note Due to a bug in Chibi-OS countPerEvent must be even. If bufcount is not
+ * @note Due to a bug/feature in Chibi-OS countPerEvent must be even. If bufcount is not
* evenly divisable by countPerEvent, the remainder must also be even.
* @note The physdev parameter may be used to turn on more than one ADC channel.
* Each channel is then interleaved into the provided buffer. Note 'bufcount'
@@ -143,8 +148,7 @@ extern "C" {
* @note While the high speed ADC is running, low speed conversions can only occur at
* the frequency of the high speed events. Thus if high speed events are
* being created at 50Hz (eg countPerEvent = 100, frequency = 5kHz) then the maximum
- * frequency for low speed conversions is likely to be 50Hz (although it might be
- * 100Hz on some hardware).
+ * frequency for low speed conversions will be 50Hz.
*
* @api
*/
@@ -159,8 +163,8 @@ void gadcHighSpeedInit(uint32_t physdev, uint32_t frequency, adcsample_t *buffer
* called first. This saves processing time if the application does
* not want to use the GEVENT sub-system for the high speed ADC.
* Once turned on it can only be turned off by calling @p gadcHighSpeedInit() again.
- * @note The high speed ADC is capable of signalling via this method and a binary semaphore
- * at the same time.
+ * @note The high speed ADC is capable of signalling via this method, an ISR callback and a
+ * binary semaphore at the same time.
*
* @api
*/
@@ -168,6 +172,20 @@ void gadcHighSpeedInit(uint32_t physdev, uint32_t frequency, adcsample_t *buffer
#endif
/**
+ * @brief Allow retrieving of results from the high speed ADC using an ISR callback.
+ *
+ * @param[in] isrfn The callback function (called in an ISR context).
+ *
+ * @note Passing a NULL for isrfn will turn off signalling via this method as will calling
+ * @p gadcHighSpeedInit().
+ * @note The high speed ADC is capable of signalling via this method, a binary semaphore and the GEVENT
+ * sub-system at the same time.
+ *
+ * @api
+ */
+void gadcHighSpeedSetISRCallback(GADCISRCallbackFunction isrfn);
+
+/**
* @brief Allow retrieving of results from the high speed ADC using a Binary Semaphore and a static event buffer.
*
* @param[in] pbsem The binary semaphore is signaled when data is available.
@@ -175,7 +193,7 @@ void gadcHighSpeedInit(uint32_t physdev, uint32_t frequency, adcsample_t *buffer
*
* @note Passing a NULL for pbsem or pEvent will turn off signalling via this method as will calling
* @p gadcHighSpeedInit().
- * @note The high speed ADC is capable of signalling via this method and the GEVENT
+ * @note The high speed ADC is capable of signalling via this method, an ISR callback and the GEVENT
* sub-system at the same time.
*
* @api
diff --git a/include/gaudin/gaudin.h b/include/gaudin/gaudin.h
index 6f35ba19..8c5d658a 100644
--- a/include/gaudin/gaudin.h
+++ b/include/gaudin/gaudin.h
@@ -1,170 +1,180 @@
-/*
- ChibiOS/GFX - Copyright (C) 2012
- Joel Bodenmann aka Tectu <joel@unormal.org>
-
- This file is part of ChibiOS/GFX.
-
- ChibiOS/GFX is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS/GFX is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * @file include/gaudin/gaudin.h
- * @brief GAUDIN - Audio Input subsystem header file.
- *
- * @addtogroup GAUDIN
- *
- * @{
- */
-
-#ifndef _GAUDIN_H
-#define _GAUDIN_H
-
-#include "gfx.h"
-
-#if GFX_USE_GAUDIN || defined(__DOXYGEN__)
-
-/* Include the driver defines */
-#include "gaudin_lld_config.h"
-//audio_in_sample_t
-//GAUDIN_SAMPLE_FORMAT ARRAY_DATA_10BITUNSIGNED
-//GAUDIN_STEREO_DEVICE FALSE
-
-/*===========================================================================*/
-/* Type definitions */
-/*===========================================================================*/
-
-// Event types for GAUDIN
-#define GEVENT_AUDIO_IN (GEVENT_GAUDIN_FIRST+0)
-
-/**
- * @brief The Audio Input event structure.
- * @{
- */
-typedef struct GEventAudioIn_t {
- /**
- * @brief The type of this event (GEVENT_AUDIO_IN)
- */
- GEventType type;
- /**
- * @brief The event flags
- */
- uint16_t flags;
- /**
- * @brief The event flag values.
- * @{
- */
- #define GADC_AUDIO_IN_LOSTEVENT 0x0001 /**< @brief The last GEVENT_AUDIO_IN event was lost */
- /** @} */
- /**
- * @brief The number of audio samples in the buffer
- */
- size_t count;
- /**
- * @brief The buffer containing the audio samples
- */
- audio_in_sample_t *buffer;
- } GEventAudioIn;
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief Initialise the Audio Input Subsystem.
- * @details Initialises but does not start the audio in.
- *
- * @param[in] frequency The sample frequency
- * @param[in] buffer The static buffer to put the samples into.
- * @param[in] bufcount The total number of conversions that will fit in the buffer.
- * @param[in] countPerEvent The number of conversions to do before returning an event.
- *
- * @note If the audio input is running it will be stopped.
- * @note Due to a bug in Chibi-OS countPerEvent must be even for the GADC audio driver.
- * If bufcount is not evenly divisable by countPerEvent, the remainder must also be even.
- * This requirement may not apply to other GAUDIN drivers.
- * @note The number of samples for stereo devices will be double the number of conversions.
- * Make sure you allocate your buffers large enough. Each channel is then interleaved
- * into the provided buffer. Note 'bufcount' and 'countPerEvent' parameters describe the
- * number of conversions not the number of samples.
- * @note The buffer is circular. When the end of the buffer is reached it will start
- * putting data into the beginning of the buffer again.
- * @note The event listener must process the event (and the data in it) before the
- * next event occurs. If not, the following event will be lost.
- * @note If bufcount is evenly divisable by countPerEvent, then every event will return
- * countPerEvent conversions. If bufcount is not evenly divisable, it will return
- * a block of samples containing less than countPerEvent samples when it reaches the
- * end of the buffer.
- *
- * @api
- */
-void gaudinInit(uint32_t frequency, adcsample_t *buffer, size_t bufcount, size_t samplesPerEvent);
-
-#if GFX_USE_GEVENT || defined(__DOXYGEN__)
- /**
- * @brief Turn on sending results to the GEVENT sub-system.
- * @details Returns a GSourceHandle to listen for GEVENT_AUDIO_IN events.
- *
- * @note The audio input will not use the GEVENT system unless this is
- * called first. This saves processing time if the application does
- * not want to use the GEVENT sub-system for audio input.
- * Once turned on it cannot be turned off.
- * @note The audio input is capable of signalling via this method and a binary semaphore
- * at the same time.
- *
- * @api
- */
- GSourceHandle gaudinGetSource(void);
-#endif
-
-/**
- * @brief Allow retrieving of results from the audio input using a Binary Semaphore and a static event buffer.
- *
- * @param[in] pbsem The binary semaphore is signaled when data is available.
- * @param[in] pEvent The static event buffer to place the result information.
- *
- * @note Passing a NULL for pbsem or pEvent will turn off signalling via this method.
- * @note The audio input is capable of signalling via this method and the GEVENT
- * sub-system at the same time.
- *
- * @api
- */
-void gaudinSetBSem(BinarySemaphore *pbsem, GEventAudioIn *pEvent);
-
-/**
- * @brief Start the audio input conversions.
- * @pre It must have been initialised first with @p gaudinInit()
- *
- * @api
- */
-GSourceHandle gaudinStart(void);
-
-/**
- * @brief Stop the audio input conversions.
- *
- * @api
- */
-void gaudinStop(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GFX_USE_GAUDIN */
-
-#endif /* _GAUDIN_H */
-/** @} */
-
+/*
+ ChibiOS/GFX - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file include/gaudin/gaudin.h
+ * @brief GAUDIN - Audio Input subsystem header file.
+ *
+ * @addtogroup GAUDIN
+ *
+ * @{
+ */
+
+#ifndef _GAUDIN_H
+#define _GAUDIN_H
+
+#include "gfx.h"
+
+#if GFX_USE_GAUDIN || defined(__DOXYGEN__)
+
+/* Include the driver defines */
+#include "gaudin_lld_config.h"
+
+/*===========================================================================*/
+/* Type definitions */
+/*===========================================================================*/
+
+// Event types for GAUDIN
+#define GEVENT_AUDIO_IN (GEVENT_GAUDIN_FIRST+0)
+
+/**
+ * @brief The Audio Input event structure.
+ * @{
+ */
+typedef struct GEventAudioIn_t {
+ #if GFX_USE_GEVENT || defined(__DOXYGEN__)
+ /**
+ * @brief The type of this event (GEVENT_AUDIO_IN)
+ */
+ GEventType type;
+ #endif
+ /**
+ * @brief The current channel
+ */
+ uint16_t channel;
+ /**
+ * @brief The event flags
+ */
+ uint16_t flags;
+ /**
+ * @brief The event flag values.
+ * @{
+ */
+ #define GADC_AUDIO_IN_LOSTEVENT 0x0001 /**< @brief The last GEVENT_AUDIO_IN event was lost */
+ /** @} */
+ /**
+ * @brief The number of audio samples in the buffer
+ */
+ size_t count;
+ /**
+ * @brief The buffer containing the audio samples
+ */
+ audin_sample_t *buffer;
+ } GEventAudioIn;
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Initialise (but not start) the Audio Input Subsystem.
+ * @details Returns FALSE for an invalid channel or other invalid parameter.
+ *
+ * @param[in] channel The channel to convert. Can be set from 0 to GAUDIN_NUM_CHANNELS - 1.
+ * @param[in] frequency The sample frequency
+ * @param[in] buffer The static buffer to put the samples into.
+ * @param[in] bufcount The total number of conversions that will fit in the buffer.
+ * @param[in] countPerEvent The number of conversions to do before returning an event.
+ *
+ * @note Only one channel is active at a time. If an audio input is running it will be stopped.
+ * The Event subsystem is disconnected from the audio subsystem and any binary semaphore
+ * event is forgotten.
+ * @note Some channels may be stereo channels which return twice as much sample data with
+ * the left and right channel data interleaved. Other channels may be mono channels.
+ * Where stereo channels exist it would be common for the low level driver to also
+ * offer the left and right channels separately.
+ * @note Due to a bug in Chibi-OS countPerEvent must be even if using the GADC low level audio driver.
+ * If bufcount is not evenly divisable by countPerEvent, the remainder must also be even.
+ * This requirement may not apply to other GAUDIN drivers.
+ * @note The number of samples for stereo devices will be double the number of conversions.
+ * Make sure you allocate your buffers large enough. Each channel is then interleaved
+ * into the provided buffer. Note 'bufcount' and 'countPerEvent' parameters describe the
+ * number of conversions not the number of samples.
+ * @note The buffer is circular. When the end of the buffer is reached it will start
+ * putting data into the beginning of the buffer again.
+ * @note The event listener must process the event (and the data in it) before the
+ * next event occurs. If not, the following event will be lost.
+ * @note If bufcount is evenly divisable by countPerEvent, then every event will return
+ * countPerEvent conversions. If bufcount is not evenly divisable, it will return
+ * a block of samples containing less than countPerEvent samples when it reaches the
+ * end of the buffer.
+ *
+ * @api
+ */
+bool_t gaudinInit(uint16_t channel, uint32_t frequency, audin_sample_t *buffer, size_t bufcount, size_t samplesPerEvent);
+
+#if GFX_USE_GEVENT || defined(__DOXYGEN__)
+ /**
+ * @brief Turn on sending results to the GEVENT sub-system.
+ * @details Returns a GSourceHandle to listen for GEVENT_AUDIO_IN events.
+ *
+ * @note The audio input will not use the GEVENT system unless this is
+ * called first. This saves processing time if the application does
+ * not want to use the GEVENT sub-system for audio input.
+ * Once turned on it can only be turned off by calling @p gadcHighSpeedInit() again.
+ * @note The audio input is capable of signalling via this method and a binary semaphore
+ * at the same time.
+ *
+ * @api
+ */
+ GSourceHandle gaudinGetSource(void);
+#endif
+
+/**
+ * @brief Allow retrieving of results from the audio input using a Binary Semaphore and a static event buffer.
+ *
+ * @param[in] pbsem The binary semaphore is signaled when data is available.
+ * @param[in] pEvent The static event buffer to place the result information.
+ *
+ * @note Passing a NULL for pbsem or pEvent will turn off signalling via this method.
+ * @note The audio input is capable of signalling via this method and the GEVENT
+ * sub-system at the same time.
+ *
+ * @api
+ */
+void gaudinSetBSem(BinarySemaphore *pbsem, GEventAudioIn *pEvent);
+
+/**
+ * @brief Start the audio input conversions.
+ * @pre It must have been initialised first with @p gaudinInit()
+ *
+ * @api
+ */
+void gaudinStart(void);
+
+/**
+ * @brief Stop the audio input conversions.
+ *
+ * @api
+ */
+void gaudinStop(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GFX_USE_GAUDIN */
+
+#endif /* _GAUDIN_H */
+/** @} */
+
diff --git a/include/gaudin/lld/gaudin_lld.h b/include/gaudin/lld/gaudin_lld.h
new file mode 100644
index 00000000..2b2db86e
--- /dev/null
+++ b/include/gaudin/lld/gaudin_lld.h
@@ -0,0 +1,105 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012, 2013
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file include/gaudin/lld/gaudin_lld.h
+ * @brief GAUDIN - Audio Input driver header file.
+ *
+ * @defgroup Driver Driver
+ * @ingroup GAUDIN
+ * @{
+ */
+
+#ifndef _GAUDIN_LLD_H
+#define _GAUDIN_LLD_H
+
+#include "gfx.h"
+
+#if GFX_USE_GADC || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Type definitions */
+/*===========================================================================*/
+
+/**
+ * @brief The structure passed to start a audio conversion
+ * @note We use the structure instead of parameters purely to save
+ * interrupt stack space which is very limited in some platforms.
+ * @{
+ */
+typedef struct gaudin_params_t {
+ uint16_t channel;
+ uint32_t frequency;
+ audin_sample_t *buffer;
+ size_t bufcount;
+ size_t samplesPerEvent;
+ } gaudin_params;
+/* @} */
+
+/**
+ * @brief These routines are the callbacks that the driver uses.
+ * @details Defined in the high level GAUDIN code.
+ *
+ * @icode
+ * @notapi
+ * @{
+ */
+extern void GAUDIN_ISR_CompleteI(audin_sample_t *buffer, size_t n);
+extern void GAUDIN_ISR_ErrorI(void);
+/**
+ * @}
+ */
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Initialise the driver
+ *
+ * @api
+ */
+void gaudin_lld_init(const gaudin_params *paud);
+
+/**
+ * @brief Start the audio input sampling
+ *
+ * @api
+ */
+void gadc_lld_start(void);
+
+/**
+ * @brief Stop the audio input sampling
+ *
+ * @api
+ */
+void gadc_lld_stop(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GFX_USE_GADC */
+
+#endif /* _GADC_LLD_H */
+/** @} */
diff --git a/include/gfx.h b/include/gfx.h
index 552e3294..e6b8d03e 100644
--- a/include/gfx.h
+++ b/include/gfx.h
@@ -1,170 +1,170 @@
-/*
- ChibiOS/GFX - Copyright (C) 2012
- Joel Bodenmann aka Tectu <joel@unormal.org>
-
- This file is part of ChibiOS/GFX.
-
- ChibiOS/GFX is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS/GFX is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/**
- * @file include/gfx.h
- * @brief GFX system header file.
- *
- * @addtogroup GFX
- * @{
- */
-
-#ifndef _GFX_H
-#define _GFX_H
-
-/* gfxconf.h is the user's project configuration for the GFX system. */
-#include "gfxconf.h"
-
-/**
- * @name GFX sub-systems that can be turned on
- * @{
- */
- /**
- * @brief GFX Graphics Display Basic API
- * @details Defaults to FALSE
- * @note Also add the specific hardware driver to your makefile.
- * Eg. include $(GFXLIB)/drivers/gdisp/Nokia6610/gdisp_lld.mk
- */
- #ifndef GFX_USE_GDISP
- #define GFX_USE_GDISP FALSE
- #endif
- /**
- * @brief GFX Text Display Basic API
- * @details Defaults to FALSE
- * @note Also add the specific hardware driver to your makefile.
- * Eg. include $(GFXLIB)/drivers/tdisp/HD44780/tdisp_lld.mk
- */
- #ifndef GFX_USE_TDISP
- #define GFX_USE_TDISP FALSE
- #endif
- /**
- * @brief GFX Graphics Windowing API
- * @details Defaults to FALSE
- * @details Extends the GDISP API to add the concept of graphic windows.
- * @note Also supports high-level "window" objects such as console windows,
- * buttons, graphing etc
- */
- #ifndef GFX_USE_GWIN
- #define GFX_USE_GWIN FALSE
- #endif
- /**
- * @brief GFX Event API
- * @details Defaults to FALSE
- * @details Defines the concept of a "Source" that can send "Events" to "Listeners".
- */
- #ifndef GFX_USE_GEVENT
- #define GFX_USE_GEVENT FALSE
- #endif
- /**
- * @brief GFX Timer API
- * @details Defaults to FALSE
- * @details Provides thread context timers - both one-shot and periodic.
- */
- #ifndef GFX_USE_GTIMER
- #define GFX_USE_GTIMER FALSE
- #endif
- /**
- * @brief GFX Input Device API
- * @details Defaults to FALSE
- * @note Also add the specific hardware drivers to your makefile.
- * Eg.
- * include $(GFXLIB)/drivers/ginput/toggle/Pal/ginput_lld.mk
- * and...
- * include $(GFXLIB)/drivers/ginput/touch/MCU/ginput_lld.mk
- */
- #ifndef GFX_USE_GINPUT
- #define GFX_USE_GINPUT FALSE
- #endif
- /**
- * @brief GFX Generic Periodic ADC API
- * @details Defaults to FALSE
- */
- #ifndef GFX_USE_GADC
- #define GFX_USE_GADC FALSE
- #endif
- /**
- * @brief GFX Audio Input Device API
- * @details Defaults to FALSE
- * @note Also add the specific hardware drivers to your makefile.
- * Eg.
- * include $(GFXLIB)/drivers/gaudin/GADC/gaudin_lld.mk
- */
- #ifndef GFX_USE_GAUDIN
- #define GFX_USE_GAUDIN FALSE
- #endif
- /**
- * @brief GFX Audio Output Device API
- * @details Defaults to FALSE
- * @note Also add the specific hardware drivers to your makefile.
- * Eg.
- * include $(GFXLIB)/drivers/gaudout/PWM/gaudout_lld.mk
- */
- #ifndef GFX_USE_GAUDOUT
- #define GFX_USE_GAUDOUT FALSE
- #endif
- /**
- * @brief GFX Miscellaneous Routines API
- * @details Defaults to FALSE
- * @note Turning this on without turning on any GMISC_NEED_xxx macros will result
- * in no extra code being compiled in. GMISC is made up from the sum of its
- * parts.
- */
- #ifndef GFX_USE_GMISC
- #define GFX_USE_GMISC FALSE
- #endif
-/** @} */
-
-/**
- * Get all the options for each sub-system.
- *
- */
-#include "gmisc/options.h"
-#include "gevent/options.h"
-#include "gtimer/options.h"
-#include "gdisp/options.h"
-#include "gwin/options.h"
-#include "ginput/options.h"
-#include "tdisp/options.h"
-#include "gadc/options.h"
-#include "gaudin/options.h"
-#include "gaudout/options.h"
-
-/**
- * Inter-dependancy safety checks on the sub-systems.
- *
- */
-#include "gfx_rules.h"
-
-/**
- * Include the sub-system header files
- */
-#include "gevent/gevent.h"
-#include "gtimer/gtimer.h"
-#include "gdisp/gdisp.h"
-#include "gwin/gwin.h"
-#include "ginput/ginput.h"
-#include "tdisp/tdisp.h"
-#include "gadc/gadc.h"
-#include "gaudin/gaudin.h"
-#include "gaudout/gaudout.h"
-#include "gmisc/gmisc.h"
-
-#endif /* _GFX_H */
-/** @} */
+/*
+ ChibiOS/GFX - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file include/gfx.h
+ * @brief GFX system header file.
+ *
+ * @addtogroup GFX
+ * @{
+ */
+
+#ifndef _GFX_H
+#define _GFX_H
+
+/* gfxconf.h is the user's project configuration for the GFX system. */
+#include "gfxconf.h"
+
+/**
+ * @name GFX sub-systems that can be turned on
+ * @{
+ */
+ /**
+ * @brief GFX Graphics Display Basic API
+ * @details Defaults to FALSE
+ * @note Also add the specific hardware driver to your makefile.
+ * Eg. include $(GFXLIB)/drivers/gdisp/Nokia6610/gdisp_lld.mk
+ */
+ #ifndef GFX_USE_GDISP
+ #define GFX_USE_GDISP FALSE
+ #endif
+ /**
+ * @brief GFX Text Display Basic API
+ * @details Defaults to FALSE
+ * @note Also add the specific hardware driver to your makefile.
+ * Eg. include $(GFXLIB)/drivers/tdisp/HD44780/tdisp_lld.mk
+ */
+ #ifndef GFX_USE_TDISP
+ #define GFX_USE_TDISP FALSE
+ #endif
+ /**
+ * @brief GFX Graphics Windowing API
+ * @details Defaults to FALSE
+ * @details Extends the GDISP API to add the concept of graphic windows.
+ * @note Also supports high-level "window" objects such as console windows,
+ * buttons, graphing etc
+ */
+ #ifndef GFX_USE_GWIN
+ #define GFX_USE_GWIN FALSE
+ #endif
+ /**
+ * @brief GFX Event API
+ * @details Defaults to FALSE
+ * @details Defines the concept of a "Source" that can send "Events" to "Listeners".
+ */
+ #ifndef GFX_USE_GEVENT
+ #define GFX_USE_GEVENT FALSE
+ #endif
+ /**
+ * @brief GFX Timer API
+ * @details Defaults to FALSE
+ * @details Provides thread context timers - both one-shot and periodic.
+ */
+ #ifndef GFX_USE_GTIMER
+ #define GFX_USE_GTIMER FALSE
+ #endif
+ /**
+ * @brief GFX Input Device API
+ * @details Defaults to FALSE
+ * @note Also add the specific hardware drivers to your makefile.
+ * Eg.
+ * include $(GFXLIB)/drivers/ginput/toggle/Pal/ginput_lld.mk
+ * and...
+ * include $(GFXLIB)/drivers/ginput/touch/MCU/ginput_lld.mk
+ */
+ #ifndef GFX_USE_GINPUT
+ #define GFX_USE_GINPUT FALSE
+ #endif
+ /**
+ * @brief GFX Generic Periodic ADC API
+ * @details Defaults to FALSE
+ */
+ #ifndef GFX_USE_GADC
+ #define GFX_USE_GADC FALSE
+ #endif
+ /**
+ * @brief GFX Audio Input Device API
+ * @details Defaults to FALSE
+ * @note Also add the specific hardware drivers to your makefile.
+ * Eg.
+ * include $(GFXLIB)/drivers/gaudin/GADC/gaudin_lld.mk
+ */
+ #ifndef GFX_USE_GAUDIN
+ #define GFX_USE_GAUDIN FALSE
+ #endif
+ /**
+ * @brief GFX Audio Output Device API
+ * @details Defaults to FALSE
+ * @note Also add the specific hardware drivers to your makefile.
+ * Eg.
+ * include $(GFXLIB)/drivers/gaudout/PWM/gaudout_lld.mk
+ */
+ #ifndef GFX_USE_GAUDOUT
+ #define GFX_USE_GAUDOUT FALSE
+ #endif
+ /**
+ * @brief GFX Miscellaneous Routines API
+ * @details Defaults to FALSE
+ * @note Turning this on without turning on any GMISC_NEED_xxx macros will result
+ * in no extra code being compiled in. GMISC is made up from the sum of its
+ * parts.
+ */
+ #ifndef GFX_USE_GMISC
+ #define GFX_USE_GMISC FALSE
+ #endif
+/** @} */
+
+/**
+ * Get all the options for each sub-system.
+ *
+ */
+#include "gmisc/options.h"
+#include "gevent/options.h"
+#include "gtimer/options.h"
+#include "gdisp/options.h"
+#include "gwin/options.h"
+#include "ginput/options.h"
+#include "tdisp/options.h"
+#include "gadc/options.h"
+#include "gaudin/options.h"
+#include "gaudout/options.h"
+
+/**
+ * Inter-dependancy safety checks on the sub-systems.
+ *
+ */
+#include "gfx_rules.h"
+
+/**
+ * Include the sub-system header files
+ */
+#include "gmisc/gmisc.h"
+#include "gevent/gevent.h"
+#include "gtimer/gtimer.h"
+#include "gdisp/gdisp.h"
+#include "gwin/gwin.h"
+#include "ginput/ginput.h"
+#include "tdisp/tdisp.h"
+#include "gadc/gadc.h"
+#include "gaudin/gaudin.h"
+#include "gaudout/gaudout.h"
+
+#endif /* _GFX_H */
+/** @} */
diff --git a/include/gfx_rules.h b/include/gfx_rules.h
index ce6bea50..27316204 100644
--- a/include/gfx_rules.h
+++ b/include/gfx_rules.h
@@ -99,6 +99,14 @@
#if GFX_USE_TDISP
#endif
+#if GFX_USE_GAUDIN
+ #if GFX_USE_GEVENT && !GFX_USE_GTIMER
+ #warning "GAUDIN: GFX_USE_GTIMER is required if GFX_USE_GAUDIN and GFX_USE_GEVENT are TRUE. It has been turned on for you."
+ #undef GFX_USE_GTIMER
+ #define GFX_USE_GTIMER TRUE
+ #endif
+#endif
+
#if GFX_USE_GADC
#if !CH_USE_MUTEXES || !CH_USE_SEMAPHORES
#error "GADC: CH_USE_MUTEXES and CH_USE_SEMAPHORES must be defined in chconf.h"
@@ -123,9 +131,6 @@
#endif
#endif
-#if GFX_USE_GAUDIN
-#endif
-
#if GFX_USE_GAUDOUT
#endif
diff --git a/include/gmisc/gmisc.h b/include/gmisc/gmisc.h
index c68e5ca2..b11a912b 100644
--- a/include/gmisc/gmisc.h
+++ b/include/gmisc/gmisc.h
@@ -1,106 +1,108 @@
-/*
- ChibiOS/GFX - Copyright (C) 2012
- Joel Bodenmann aka Tectu <joel@unormal.org>
-
- This file is part of ChibiOS/GFX.
-
- ChibiOS/GFX is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS/GFX is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * @file include/gmisc/gmisc.h
- * @brief GMISC - Miscellaneous Routines header file.
- *
- * @addtogroup GAUDIN
- *
- * @{
- */
-
-#ifndef _GMISC_H
-#define _GMISC_H
-
-#include "gfx.h"
-
-/*===========================================================================*/
-/* Type definitions */
-/*===========================================================================*/
-
-/**
- * @brief Sample data formats
- */
-typedef enum ArrayDataFormat_e {
- ARRAY_DATA_4BITUNSIGNED = 4, ARRAY_DATA_4BITSIGNED = 5,
- ARRAY_DATA_8BITUNSIGNED = 8, ARRAY_DATA_8BITSIGNED = 9,
- ARRAY_DATA_10BITUNSIGNED = 10, ARRAY_DATA_10BITSIGNED = 11,
- ARRAY_DATA_12BITUNSIGNED = 12, ARRAY_DATA_12BITSIGNED = 13,
- ARRAY_DATA_14BITUNSIGNED = 14, ARRAY_DATA_14BITSIGNED = 15,
- ARRAY_DATA_16BITUNSIGNED = 16, ARRAY_DATA_16BITSIGNED = 17,
- } ArrayDataFormat;
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#if GFX_USE_GMISC || defined(__DOXYGEN__)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if GMISC_NEED_ARRAYOPS || defined(__DOXYGEN__)
- /**
- * @brief Convert from one array format to another array format.
- *
- * @param[in] srcfmt The format of the source array
- * @param[in] src The source array
- * @param[in] dstfmt The format of the destination array
- * @param[in] dst The dstination array
- * @param[in] cnt The number of array elements to convert
- *
- * @note Assumes the destination buffer is large enough for the resultant data.
- * @note This routine is optimised to perform as fast as possible.
- * @note No type checking is performed on the source format. It is assumed to
- * have only valid values eg. ARRAY_DATA_4BITSIGNED will have values
- * 0000 -> 0111 for positive numbers and 1111 -> 1000 for negative numbers
- * Bits 5 -> 8 in the storage byte are treated in an undefined manner.
- * @note If srcfmt or dstfmt is an unknown format, this routine does nothing
- * with no warning that something is wrong
- *
- * @api
- */
- void gmiscArrayConvert(ArrayDataFormat srcfmt, void *src, ArrayDataFormat dstfmt, void *dst, size_t cnt);
-
- #if 0
- void gmiscArrayTranslate(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int trans);
-
- void gmiscArrayMultiply(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int mult);
-
- void gmiscArrayDivide(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int mdiv);
-
- void gmiscArrayMultDiv(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int mult, int div);
-
- void gmiscArrayAdd(ArrayDataFormat fmt, void *src1, void *src2, void *dst, size_t cnt);
-
- void gmiscArrayAddNoOverflow(ArrayDataFormat fmt, void *src1, void *src2, void *dst, size_t cnt);
- #endif
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GFX_USE_MISC */
-
-#endif /* _GMISC_H */
-/** @} */
-
+/*
+ ChibiOS/GFX - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file include/gmisc/gmisc.h
+ * @brief GMISC - Miscellaneous Routines header file.
+ *
+ * @addtogroup GAUDIN
+ *
+ * @{
+ */
+
+#ifndef _GMISC_H
+#define _GMISC_H
+
+#include "gfx.h"
+
+/*===========================================================================*/
+/* Type definitions */
+/*===========================================================================*/
+
+/**
+ * @brief Sample data formats
+ * @note These are defined regardless of whether you use the GMISC module
+ * or not as they are used in lots of places.
+ */
+typedef enum ArrayDataFormat_e {
+ ARRAY_DATA_4BITUNSIGNED = 4, ARRAY_DATA_4BITSIGNED = 5,
+ ARRAY_DATA_8BITUNSIGNED = 8, ARRAY_DATA_8BITSIGNED = 9,
+ ARRAY_DATA_10BITUNSIGNED = 10, ARRAY_DATA_10BITSIGNED = 11,
+ ARRAY_DATA_12BITUNSIGNED = 12, ARRAY_DATA_12BITSIGNED = 13,
+ ARRAY_DATA_14BITUNSIGNED = 14, ARRAY_DATA_14BITSIGNED = 15,
+ ARRAY_DATA_16BITUNSIGNED = 16, ARRAY_DATA_16BITSIGNED = 17,
+ } ArrayDataFormat;
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#if GFX_USE_GMISC || defined(__DOXYGEN__)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if GMISC_NEED_ARRAYOPS || defined(__DOXYGEN__)
+ /**
+ * @brief Convert from one array format to another array format.
+ *
+ * @param[in] srcfmt The format of the source array
+ * @param[in] src The source array
+ * @param[in] dstfmt The format of the destination array
+ * @param[in] dst The dstination array
+ * @param[in] cnt The number of array elements to convert
+ *
+ * @note Assumes the destination buffer is large enough for the resultant data.
+ * @note This routine is optimised to perform as fast as possible.
+ * @note No type checking is performed on the source format. It is assumed to
+ * have only valid values eg. ARRAY_DATA_4BITSIGNED will have values
+ * 0000 -> 0111 for positive numbers and 1111 -> 1000 for negative numbers
+ * Bits 5 -> 8 in the storage byte are treated in an undefined manner.
+ * @note If srcfmt or dstfmt is an unknown format, this routine does nothing
+ * with no warning that something is wrong
+ *
+ * @api
+ */
+ void gmiscArrayConvert(ArrayDataFormat srcfmt, void *src, ArrayDataFormat dstfmt, void *dst, size_t cnt);
+
+ #if 0
+ void gmiscArrayTranslate(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int trans);
+
+ void gmiscArrayMultiply(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int mult);
+
+ void gmiscArrayDivide(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int mdiv);
+
+ void gmiscArrayMultDiv(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int mult, int div);
+
+ void gmiscArrayAdd(ArrayDataFormat fmt, void *src1, void *src2, void *dst, size_t cnt);
+
+ void gmiscArrayAddNoOverflow(ArrayDataFormat fmt, void *src1, void *src2, void *dst, size_t cnt);
+ #endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GFX_USE_MISC */
+
+#endif /* _GMISC_H */
+/** @} */
+