Merge pull request #31 from inmarket/master
New Subsystems GADC, GAUDIN, GAUDOUT, GMISC
This commit is contained in:
commit
58eaf10591
4
gfx.mk
4
gfx.mk
@ -12,3 +12,7 @@ include $(GFXLIB)/src/gevent/gevent.mk
|
||||
include $(GFXLIB)/src/gtimer/gtimer.mk
|
||||
include $(GFXLIB)/src/gwin/gwin.mk
|
||||
include $(GFXLIB)/src/ginput/ginput.mk
|
||||
include $(GFXLIB)/src/gadc/gadc.mk
|
||||
include $(GFXLIB)/src/gaudin/gaudin.mk
|
||||
include $(GFXLIB)/src/gaudout/gaudout.mk
|
||||
include $(GFXLIB)/src/gmisc/gmisc.mk
|
||||
|
@ -21,6 +21,10 @@
|
||||
#define GFX_USE_GEVENT FALSE
|
||||
#define GFX_USE_GTIMER FALSE
|
||||
#define GFX_USE_GINPUT FALSE
|
||||
#define GFX_USE_GADC FALSE
|
||||
#define GFX_USE_GAUDIN FALSE
|
||||
#define GFX_USE_GAUDOUT FALSE
|
||||
#define GFX_USE_GMISC FALSE
|
||||
|
||||
/* Features for the GDISP subsystem */
|
||||
#define GDISP_NEED_VALIDATION TRUE
|
||||
@ -67,12 +71,25 @@
|
||||
#define GINPUT_NEED_TOGGLE FALSE
|
||||
#define GINPUT_NEED_DIAL FALSE
|
||||
|
||||
/* Features for the GADC subsystem. */
|
||||
/* NONE */
|
||||
|
||||
/* Features for the GAUDIN subsystem. */
|
||||
/* NONE */
|
||||
|
||||
/* Features for the GAUDOUT subsystem. */
|
||||
/* NONE */
|
||||
|
||||
/* Features for the GMISC subsystem. */
|
||||
#define GMISC_NEED_ARRAYOPS FALSE
|
||||
|
||||
/* Optional Parameters for various subsystems */
|
||||
/*
|
||||
#define GDISP_MAX_FONT_HEIGHT 16
|
||||
#define GEVENT_MAXIMUM_SIZE 32
|
||||
#define GEVENT_MAX_SOURCE_LISTENERS 32
|
||||
#define GTIMER_THREAD_WORKAREA_SIZE 512
|
||||
#define GADC_MAX_LOWSPEED_DEVICES 4
|
||||
*/
|
||||
|
||||
/* Optional Low Level Driver Definitions */
|
||||
@ -87,4 +104,3 @@
|
||||
*/
|
||||
|
||||
#endif /* _GFXCONF_H */
|
||||
|
||||
|
250
include/gadc/gadc.h
Normal file
250
include/gadc/gadc.h
Normal file
@ -0,0 +1,250 @@
|
||||
/*
|
||||
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/gadc/gadc.h
|
||||
* @brief GADC - Periodic ADC subsystem header file.
|
||||
*
|
||||
* @addtogroup GADC
|
||||
*
|
||||
* @details The reason why ChibiOS/GFX has it's own ADC abstraction is because
|
||||
* the Chibi-OS drivers are very CPU specific and do not
|
||||
* provide a way across all hardware platforms to create periodic
|
||||
* ADC conversions. There are also issues with devices with different
|
||||
* characteristics or periodic requirements on the same ADC
|
||||
* device (but different channels). This layer attempts to solve these
|
||||
* problems to provide a architecture neutral API. It also provides extra
|
||||
* features such as multi-buffer chaining for high speed ADC sources.
|
||||
* It provides one high speed virtual ADC device (eg a microphone) and
|
||||
* numerous low speed (less than 100Hz) virtual ADC devices (eg dials,
|
||||
* temperature sensors etc). The high speed device has timer based polling
|
||||
* to ensure exact conversion periods and a buffer management system.
|
||||
* The low speed devices are assumed to be non-critical timing devices
|
||||
* and do not have any buffer management.
|
||||
* Note that while only one high speed device has been provided it can
|
||||
* be used to read multiple physical ADC channels on the one physical
|
||||
* ADC device.
|
||||
* All callback routines are thread based unlike the Chibi-OS interrupt based
|
||||
* routines.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _GADC_H
|
||||
#define _GADC_H
|
||||
|
||||
#include "gfx.h"
|
||||
|
||||
#if GFX_USE_GADC || defined(__DOXYGEN__)
|
||||
|
||||
/* Include the driver defines */
|
||||
#include "gadc_lld_config.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Type definitions */
|
||||
/*===========================================================================*/
|
||||
|
||||
// Event types for GADC
|
||||
#define GEVENT_ADC (GEVENT_GADC_FIRST+0)
|
||||
|
||||
/**
|
||||
* @brief The High Speed ADC event structure.
|
||||
* @{
|
||||
*/
|
||||
typedef struct GEventADC_t {
|
||||
/**
|
||||
* @brief The type of this event (GEVENT_ADC)
|
||||
*/
|
||||
GEventType type;
|
||||
/**
|
||||
* @brief The event flags
|
||||
*/
|
||||
uint16_t flags;
|
||||
/**
|
||||
* @brief The event flag values.
|
||||
* @{
|
||||
*/
|
||||
#define GADC_HSADC_LOSTEVENT 0x0001 /**< @brief The last GEVENT_HSDADC event was lost */
|
||||
/** @} */
|
||||
/**
|
||||
* @brief The number of conversions in the buffer
|
||||
*/
|
||||
size_t count;
|
||||
/**
|
||||
* @brief The buffer containing the conversion samples
|
||||
*/
|
||||
adcsample_t *buffer;
|
||||
} GEventADC;
|
||||
|
||||
/**
|
||||
* @brief A callback function (executed in a thread context)
|
||||
*/
|
||||
typedef void (*GADCCallbackFunction)(adcsample_t *buffer, void *param);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialise the high speed ADC.
|
||||
* @details Initialises but does not start the conversions.
|
||||
*
|
||||
* @param[in] physdev A value passed to describe which physical ADC devices/channels to use.
|
||||
* @param[in] frequency The frequency to create ADC conversions
|
||||
* @param[in] buffer The static buffer to put the ADC 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 high speed ADC is running it will be stopped.
|
||||
* @note Due to a bug 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'
|
||||
* and 'countPerEvent' parameters describe the number of conversions not the
|
||||
* number of samples.
|
||||
* As an example, if physdev turns on 2 devices then the buffer contains
|
||||
* alternate device samples and the buffer must contain 2 * bufcount samples.
|
||||
* The exact meaning of physdev is hardware dependent.
|
||||
* @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.
|
||||
* @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).
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gadcHighSpeedInit(uint32_t physdev, 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_ADC events.
|
||||
*
|
||||
* @note The high speed ADC 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 the high speed ADC.
|
||||
* Once turned on it cannot be turned off.
|
||||
* @note The high speed ADC is capable of signalling via this method and a binary semaphore
|
||||
* at the same time.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
GSourceHandle gadcHighSpeedGetSource(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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.
|
||||
* @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 high speed ADC is capable of signalling via this method and the GEVENT
|
||||
* sub-system at the same time.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gadcHighSpeedSetBSem(BinarySemaphore *pbsem, GEventADC *pEvent);
|
||||
|
||||
/**
|
||||
* @brief Start the high speed ADC conversions.
|
||||
* @pre It must have been initialised first with @p gadcHighSpeedInit()
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
GSourceHandle gadcHighSpeedStart(void);
|
||||
|
||||
/**
|
||||
* @brief Stop the high speed ADC conversions.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gadcHighSpeedStop(void);
|
||||
|
||||
/**
|
||||
* @brief Perform a single low speed ADC conversion
|
||||
* @details Blocks until the conversion is complete
|
||||
* @pre This should not be called from within a GTimer callback as this routine
|
||||
* blocks until the conversion is ready.
|
||||
*
|
||||
* @param[in] physdev A value passed to describe which physical ADC devices/channels to use.
|
||||
* @param[in] buffer The static buffer to put the ADC samples into.
|
||||
*
|
||||
* @note This may take a while to complete if the high speed ADC is running as the
|
||||
* conversion is interleaved with the high speed ADC conversions on a buffer
|
||||
* completion.
|
||||
* @note The result buffer must be large enough to store one sample per device
|
||||
* described by the 'physdev' parameter.
|
||||
* @note If calling this routine would exceed @p GADC_MAX_LOWSPEED_DEVICES simultaneous low
|
||||
* speed devices, the routine will wait for an available slot to complete the
|
||||
* conversion.
|
||||
* @note Specifying more than one device in physdev is possible but discouraged as the
|
||||
* calculations to ensure the high speed ADC correctness will be incorrect. Symptoms
|
||||
* from over-running the high speed ADC include high speed samples being lost.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gadcLowSpeedGet(uint32_t physdev, adcsample_t *buffer);
|
||||
|
||||
/**
|
||||
* @brief Perform a low speed ADC conversion with callback (in a thread context)
|
||||
* @details Returns FALSE if there are no free low speed ADC slots. See @p GADC_MAX_LOWSPEED_DEVICES for details.
|
||||
*
|
||||
* @param[in] physdev A value passed to describe which physical ADC devices/channels to use.
|
||||
* @param[in] buffer The static buffer to put the ADC samples into.
|
||||
* @param[in] fn The callback function to call when the conversion is complete.
|
||||
* @param[in] param A parameter to pass to the callback function.
|
||||
*
|
||||
* @note This may be safely called from within a GTimer callback.
|
||||
* @note The callback may take a while to occur if the high speed ADC is running as the
|
||||
* conversion is interleaved with the high speed ADC conversions on a buffer
|
||||
* completion.
|
||||
* @note The result buffer must be large enough to store one sample per device
|
||||
* described by the 'physdev' parameter.
|
||||
* @note As this routine uses a low speed ADC, it asserts if you try to run more than @p GADC_MAX_LOWSPEED_DEVICES
|
||||
* at the same time.
|
||||
* @note Specifying more than one device in physdev is possible but discouraged as the
|
||||
* calculations to ensure the high speed ADC correctness will be incorrect. Symptoms
|
||||
* from over-running the high speed ADC include high speed samples being lost.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
bool gadcLowSpeedStart(uint32_t physdev, adcsample_t *buffer, GADCCallbackFunction fn, void *param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GFX_USE_GADC */
|
||||
|
||||
#endif /* _GADC_H */
|
||||
/** @} */
|
||||
|
57
include/gadc/options.h
Normal file
57
include/gadc/options.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
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/gadc/options.h
|
||||
* @brief GADC - Periodic ADC subsystem options header file.
|
||||
*
|
||||
* @addtogroup GADC
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _GADC_OPTIONS_H
|
||||
#define _GADC_OPTIONS_H
|
||||
|
||||
/**
|
||||
* @name GADC Functionality to be included
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
* @name GADC Optional Sizing Parameters
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief The maximum simultaneous GADC low speed device conversions
|
||||
* @details Defaults to 4
|
||||
* @note This value must be less than the number of conversions that can occur
|
||||
* in a single high speed ADC cycle including the high speed ADC conversion.
|
||||
* For example, if the ADC can run at 132k samples per second and the high speed
|
||||
* virtual ADC is using 44kHz then GADC_MAX_LOWSPEED_DEVICES should be set to
|
||||
* 132/44 - 1 = 2
|
||||
*/
|
||||
#ifndef GADC_MAX_LOWSPEED_DEVICES
|
||||
#define GADC_MAX_LOWSPEED_DEVICES 4
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
#endif /* _GADC_OPTIONS_H */
|
||||
/** @} */
|
170
include/gaudin/gaudin.h
Normal file
170
include/gaudin/gaudin.h
Normal file
@ -0,0 +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/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 */
|
||||
/** @} */
|
||||
|
45
include/gaudin/options.h
Normal file
45
include/gaudin/options.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
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/options.h
|
||||
* @brief GAUDIN - Audio Input subsystem options header file.
|
||||
*
|
||||
* @addtogroup GAUDIN
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _GAUDIN_OPTIONS_H
|
||||
#define _GAUDIN_OPTIONS_H
|
||||
|
||||
/**
|
||||
* @name GAUDIN Functionality to be included
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
* @name GAUDIN Optional Sizing Parameters
|
||||
* @{
|
||||
*/
|
||||
/** @} */
|
||||
|
||||
#endif /* _GAUDIN_OPTIONS_H */
|
||||
/** @} */
|
56
include/gaudout/gaudout.h
Normal file
56
include/gaudout/gaudout.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
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/gaudout/gaudout.h
|
||||
* @brief GAUDOUT - Audio Output subsystem header file.
|
||||
*
|
||||
* @addtogroup GAUDOUT
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _GAUDOUT_H
|
||||
#define _GAUDOUT_H
|
||||
|
||||
#include "gfx.h"
|
||||
|
||||
#if GFX_USE_GAUDOUT || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Type definitions */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GFX_USE_GAUDOUT */
|
||||
|
||||
#endif /* _GAUDOUT_H */
|
||||
/** @} */
|
||||
|
45
include/gaudout/options.h
Normal file
45
include/gaudout/options.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
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/gaudout/options.h
|
||||
* @brief GAUDOUT - Audio Output subsystem options header file.
|
||||
*
|
||||
* @addtogroup GAUDOUT
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _GAUDOUT_OPTIONS_H
|
||||
#define _GAUDOUT_OPTIONS_H
|
||||
|
||||
/**
|
||||
* @name GAUDOUT Functionality to be included
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
* @name GAUDOUT Optional Sizing Parameters
|
||||
* @{
|
||||
*/
|
||||
/** @} */
|
||||
|
||||
#endif /* _GAUDOUT_OPTIONS_H */
|
||||
/** @} */
|
@ -53,6 +53,9 @@ typedef uint16_t GEventType;
|
||||
/* Other event types are allocated in ranges in their respective include files */
|
||||
#define GEVENT_GINPUT_FIRST 0x0100 // GINPUT events range from 0x0100 to 0x01FF
|
||||
#define GEVENT_GWIN_FIRST 0x0200 // GWIN events range from 0x0200 to 0x02FF
|
||||
#define GEVENT_GADC_FIRST 0x0300 // GADC events range from 0x0300 to 0x033F
|
||||
#define GEVENT_GAUDIN_FIRST 0x0340 // GAUDIN events range from 0x0340 to 0x037F
|
||||
#define GEVENT_GAUDOUT_FIRST 0x0380 // GAUDOUT events range from 0x0380 to 0x03BF
|
||||
#define GEVENT_USER_FIRST 0x8000 // Any application defined events start at 0x8000
|
||||
|
||||
// This object can be typecast to any GEventXxxxx type to allow any sub-system (or the application) to create events.
|
||||
|
@ -92,18 +92,59 @@
|
||||
#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.
|
||||
@ -120,6 +161,10 @@
|
||||
#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 */
|
||||
/** @} */
|
||||
|
@ -96,6 +96,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if GFX_USE_TDISP
|
||||
#endif
|
||||
|
||||
#if GFX_USE_GEVENT
|
||||
#if !CH_USE_MUTEXES || !CH_USE_SEMAPHORES
|
||||
#error "GEVENT: CH_USE_MUTEXES and CH_USE_SEMAPHORES must be defined in chconf.h"
|
||||
@ -109,5 +112,17 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if GFX_USE_GAUDIN
|
||||
#endif
|
||||
|
||||
#if GFX_USE_GAUDOUT
|
||||
#endif
|
||||
|
||||
#if GFX_USE_GADC
|
||||
#endif
|
||||
|
||||
#if GFX_USE_GMISC
|
||||
#endif
|
||||
|
||||
#endif /* _GFX_H */
|
||||
/** @} */
|
||||
|
106
include/gmisc/gmisc.h
Normal file
106
include/gmisc/gmisc.h
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
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 */
|
||||
/** @} */
|
||||
|
52
include/gmisc/options.h
Normal file
52
include/gmisc/options.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
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/options.h
|
||||
* @brief GMISC - Miscellaneous Routines options header file.
|
||||
*
|
||||
* @addtogroup GMISC
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _GMISC_OPTIONS_H
|
||||
#define _GMISC_OPTIONS_H
|
||||
|
||||
/**
|
||||
* @name GMISC Functionality to be included
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Include array operation functions
|
||||
* @details Defaults to FALSE
|
||||
*/
|
||||
#ifndef GMISC_NEED_ARRAYOPS
|
||||
#define GMISC_NEED_ARRAYOPS FALSE
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
* @name GMISC Optional Sizing Parameters
|
||||
* @{
|
||||
*/
|
||||
/** @} */
|
||||
|
||||
#endif /* _GMISC_OPTIONS_H */
|
||||
/** @} */
|
@ -6,6 +6,7 @@ current release: 1.5
|
||||
FEATURE: Added ILI9325 driver - Thanks to Chris van Dongen aka _Sjaak
|
||||
FEATURE: Added TDISP module
|
||||
FIX: tdispGotoXY() renamed to tdispSetCursor()
|
||||
FEATURE: Addition of GADC, GMISC, GAUDIN, GAUDOUT subsystems
|
||||
|
||||
|
||||
*** changes after 1.4 ***
|
||||
|
38
src/gadc/gadc.c
Normal file
38
src/gadc/gadc.c
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
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 src/gadc/gadc.c
|
||||
* @brief GADC sub-system code.
|
||||
*
|
||||
* @addtogroup GADC
|
||||
* @{
|
||||
*/
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "gfx.h"
|
||||
|
||||
#if GFX_USE_GADC || defined(__DOXYGEN__)
|
||||
|
||||
#error "GADC: Not implemented yet"
|
||||
|
||||
#endif /* GFX_USE_GADC */
|
||||
/** @} */
|
||||
|
1
src/gadc/gadc.mk
Normal file
1
src/gadc/gadc.mk
Normal file
@ -0,0 +1 @@
|
||||
GFXSRC += $(GFXLIB)/src/gadc/gadc.c
|
38
src/gaudin/gaudin.c
Normal file
38
src/gaudin/gaudin.c
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
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 src/gaudin/gaudin.c
|
||||
* @brief GAUDIN sub-system code.
|
||||
*
|
||||
* @addtogroup GAUDIN
|
||||
* @{
|
||||
*/
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "gfx.h"
|
||||
|
||||
#if GFX_USE_GAUDIN || defined(__DOXYGEN__)
|
||||
|
||||
#error "GAUDIN: Not implemented yet"
|
||||
|
||||
#endif /* GFX_USE_GAUDIN */
|
||||
/** @} */
|
||||
|
1
src/gaudin/gaudin.mk
Normal file
1
src/gaudin/gaudin.mk
Normal file
@ -0,0 +1 @@
|
||||
GFXSRC += $(GFXLIB)/src/gaudin/gaudin.c
|
38
src/gaudout/gaudout.c
Normal file
38
src/gaudout/gaudout.c
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
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 src/gaudout/gaudout.c
|
||||
* @brief GAUDOUT sub-system code.
|
||||
*
|
||||
* @addtogroup GAUDOUT
|
||||
* @{
|
||||
*/
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "gfx.h"
|
||||
|
||||
#if GFX_USE_GAUDOUT || defined(__DOXYGEN__)
|
||||
|
||||
#error "GAUDOUT: Not implemented yet"
|
||||
|
||||
#endif /* GFX_USE_GAUDOUT */
|
||||
/** @} */
|
||||
|
1
src/gaudout/gaudout.mk
Normal file
1
src/gaudout/gaudout.mk
Normal file
@ -0,0 +1 @@
|
||||
GFXSRC += $(GFXLIB)/src/gaudout/gaudout.c
|
241
src/gmisc/arrayops.c
Normal file
241
src/gmisc/arrayops.c
Normal file
@ -0,0 +1,241 @@
|
||||
/*
|
||||
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 src/gmisc/arrayops.c
|
||||
* @brief GMISC Array Operations code.
|
||||
*
|
||||
* @addtogroup GMISC
|
||||
* @{
|
||||
*/
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "gfx.h"
|
||||
|
||||
#if (GFX_USE_GMISC && GMISC_NEED_ARRAYOPS) || defined(__DOXYGEN__)
|
||||
|
||||
void gmiscArrayConvert(ArrayDataFormat srcfmt, void *src, ArrayDataFormat dstfmt, void *dst, size_t cnt) {
|
||||
uint8_t *src8, *dst8;
|
||||
uint16_t *src16, *dst16;
|
||||
|
||||
dst8 = dst;
|
||||
dst16 = dst;
|
||||
src8 = src;
|
||||
src16 = src;
|
||||
|
||||
/* We do this as a big switch in order to optimise efficiency for each transfer type */
|
||||
switch(dstfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break;
|
||||
case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8); } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst8++ = *src8++ >> 4; } break;
|
||||
case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128) >> 4; } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break;
|
||||
case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 6; } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break;
|
||||
case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 8; } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 10; } break;
|
||||
case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 10; } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 12; } break;
|
||||
case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 12; } break;
|
||||
}
|
||||
break;
|
||||
case ARRAY_DATA_4BITSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8); } break;
|
||||
case ARRAY_DATA_4BITSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128) >> 4; } break;
|
||||
case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst8++ = *src8++ >> 4; } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 6; } break;
|
||||
case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 8; } break;
|
||||
case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 10; } break;
|
||||
case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 10; } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 12; } break;
|
||||
case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 12; } break;
|
||||
}
|
||||
break;
|
||||
case ARRAY_DATA_8BITUNSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst8++ = *src8++ << 4; } break;
|
||||
case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8) << 4; } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break;
|
||||
case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128); } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 2; } break;
|
||||
case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 2; } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 4; } break;
|
||||
case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 4; } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break;
|
||||
case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 6; } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break;
|
||||
case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 8; } break;
|
||||
}
|
||||
break;
|
||||
case ARRAY_DATA_8BITSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 8) << 4; } break;
|
||||
case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst8++ = *src8++ << 4; } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst8++ = (*src8++ ^ 128); } break;
|
||||
case ARRAY_DATA_8BITSIGNED: if (dst != src) while(cnt--) { *dst8++ = *src8++; } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 512) >> 2; } break;
|
||||
case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 2; } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 2048) >> 4; } break;
|
||||
case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 4; } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 8192) >> 6; } break;
|
||||
case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 6; } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst8++ = (*src16++ ^ 32768) >> 8; } break;
|
||||
case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst8++ = *src16++ >> 8; } break;
|
||||
}
|
||||
break;
|
||||
case ARRAY_DATA_10BITUNSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break;
|
||||
case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 6; } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 2; } break;
|
||||
case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 2; } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
|
||||
case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512); } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
|
||||
case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 2; } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break;
|
||||
case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 4; } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 6; } break;
|
||||
case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 6; } break;
|
||||
}
|
||||
break;
|
||||
case ARRAY_DATA_10BITSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 6; } break;
|
||||
case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 2; } break;
|
||||
case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 2; } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512); } break;
|
||||
case ARRAY_DATA_10BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 2; } break;
|
||||
case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 4; } break;
|
||||
case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 6; } break;
|
||||
case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 6; } break;
|
||||
}
|
||||
break;
|
||||
case ARRAY_DATA_12BITUNSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break;
|
||||
case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 8; } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 4; } break;
|
||||
case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 4; } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break;
|
||||
case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 2; } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
|
||||
case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048); } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
|
||||
case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 2; } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break;
|
||||
case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 4; } break;
|
||||
}
|
||||
break;
|
||||
case ARRAY_DATA_12BITSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 8; } break;
|
||||
case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 4; } break;
|
||||
case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 4; } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 2; } break;
|
||||
case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048); } break;
|
||||
case ARRAY_DATA_12BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 2; } break;
|
||||
case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 4; } break;
|
||||
case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 4; } break;
|
||||
}
|
||||
break;
|
||||
case ARRAY_DATA_14BITUNSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 10; } break;
|
||||
case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 10; } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break;
|
||||
case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 6; } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break;
|
||||
case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 4; } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break;
|
||||
case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 2; } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
|
||||
case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192); } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
|
||||
case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 2; } break;
|
||||
}
|
||||
break;
|
||||
case ARRAY_DATA_14BITSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 10; } break;
|
||||
case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 10; } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 6; } break;
|
||||
case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 6; } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 4; } break;
|
||||
case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) << 2; } break;
|
||||
case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 2; } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192); } break;
|
||||
case ARRAY_DATA_14BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768) >> 2; } break;
|
||||
case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
|
||||
}
|
||||
break;
|
||||
case ARRAY_DATA_16BITUNSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 12; } break;
|
||||
case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 12; } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break;
|
||||
case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 8; } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 6; } break;
|
||||
case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 6; } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break;
|
||||
case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) >> 4; } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
|
||||
case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) >> 2; } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
|
||||
case ARRAY_DATA_16BITSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768); } break;
|
||||
}
|
||||
break;
|
||||
case ARRAY_DATA_16BITSIGNED:
|
||||
switch(srcfmt) {
|
||||
case ARRAY_DATA_4BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 8) << 12; } break;
|
||||
case ARRAY_DATA_4BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 12; } break;
|
||||
case ARRAY_DATA_8BITUNSIGNED: while(cnt--) { *dst16++ = (*src8++ ^ 128) << 8; } break;
|
||||
case ARRAY_DATA_8BITSIGNED: while(cnt--) { *dst16++ = *src8++ << 8; } break;
|
||||
case ARRAY_DATA_10BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 512) << 6; } break;
|
||||
case ARRAY_DATA_10BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 6; } break;
|
||||
case ARRAY_DATA_12BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 2048) << 4; } break;
|
||||
case ARRAY_DATA_12BITSIGNED: while(cnt--) { *dst16++ = *src16++ << 4; } break;
|
||||
case ARRAY_DATA_14BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 8192) << 2; } break;
|
||||
case ARRAY_DATA_14BITSIGNED: while(cnt--) { *dst16++ = *src16++ >> 2; } break;
|
||||
case ARRAY_DATA_16BITUNSIGNED: while(cnt--) { *dst16++ = (*src16++ ^ 32768); } break;
|
||||
case ARRAY_DATA_16BITSIGNED: if (dst != src) while(cnt--) { *dst16++ = *src16++; } break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* GFX_USE_GMISC && GMISC_NEED_ARRAYOPS */
|
||||
/** @} */
|
1
src/gmisc/gmisc.mk
Normal file
1
src/gmisc/gmisc.mk
Normal file
@ -0,0 +1 @@
|
||||
GFXSRC += $(GFXLIB)/src/gmisc/arrayops.c
|
Loading…
Reference in New Issue
Block a user