/* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. ChibiOS/RT 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/RT 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 . */ /** * @file adc.c * @brief ADC Driver code. * * @addtogroup ADC * @{ */ #include "ch.h" #include "hal.h" #if HAL_USE_ADC || defined(__DOXYGEN__) /*===========================================================================*/ /* Driver exported variables. */ /*===========================================================================*/ /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ /*===========================================================================*/ /* Driver local functions. */ /*===========================================================================*/ /*===========================================================================*/ /* Driver exported functions. */ /*===========================================================================*/ /** * @brief ADC Driver initialization. * * @init */ void adcInit(void) { adc_lld_init(); } /** * @brief Initializes the standard part of a @p ADCDriver structure. * * @param[in] adcp pointer to the @p ADCDriver object * * @init */ void adcObjectInit(ADCDriver *adcp) { adcp->ad_state = ADC_STOP; adcp->ad_config = NULL; adcp->ad_samples = NULL; adcp->ad_depth = 0; adcp->ad_grpp = NULL; #if ADC_USE_WAIT adcp->ad_thread = NULL; #endif /* ADC_USE_WAIT */ #if ADC_USE_MUTUAL_EXCLUSION #if CH_USE_MUTEXES chMtxInit(&adcp->ad_mutex); #else chSemInit(&adcp->ad_semaphore, 1); #endif #endif /* ADC_USE_MUTUAL_EXCLUSION */ #if defined(ADC_DRIVER_EXT_INIT_HOOK) ADC_DRIVER_EXT_INIT_HOOK(adcp); #endif } /** * @brief Configures and activates the ADC peripheral. * * @param[in] adcp pointer to the @p ADCDriver object * @param[in] config pointer to the @p ADCConfig object * * @api */ void adcStart(ADCDriver *adcp, const ADCConfig *config) { chDbgCheck((adcp != NULL) && (config != NULL), "adcStart"); chSysLock(); chDbgAssert((adcp->ad_state == ADC_STOP) || (adcp->ad_state == ADC_READY), "adcStart(), #1", "invalid state"); adcp->ad_config = config; adc_lld_start(adcp); adcp->ad_state = ADC_READY; chSysUnlock(); } /** * @brief Deactivates the ADC peripheral. * * @param[in] adcp pointer to the @p ADCDriver object * * @api */ void adcStop(ADCDriver *adcp) { chDbgCheck(adcp != NULL, "adcStop"); chSysLock(); chDbgAssert((adcp->ad_state == ADC_STOP) || (adcp->ad_state == ADC_READY), "adcStop(), #1", "invalid state"); adc_lld_stop(adcp); adcp->ad_state = ADC_STOP; chSysUnlock(); } /** * @brie
# A visualization library for the TMK keyboard firmware

This library is designed to work together with the [TMK keyboard firmware](https://github.com/tmk/tmk_keyboard). Currently it only works for [Chibios](http://www.chibios.org/)
 flavors, but it would be possible to add support for other configurations as well. The LCD display functionality is provided by the [uGFX library](http://www.ugfx.org/). 

## To use this library as a user
You can and should modify the visualizer\_user.c file. Check the comments in the file for more information.

## To add this library to custom keyboard projects

1. Add tmk_visualizer as a submodule to your project
1. Set VISUALIZER_DIR in the main keyboard project makefile to point to the submodule
1. Define LCD\_ENABLE and/or LCD\_BACKLIGHT\_ENABLE, to enable support
1. Include the visualizer.mk make file
1. Copy the files in the example\_integration folder to your keyboard project
1. All other files than the callback.c file are included automatically, so you will need to add callback.c to your makefile manually. If you already have a similar file in your project, you can just copy the functions instead of the whole file.
1. Edit the files to match your hardware. You might might want to read the Chibios and UGfx documentation, for more information.
1. If you enable LCD support you might also have to write a custom uGFX display driver, check the uGFX documentation for that. You probably also want to enable SPI support in your Chibios configuration.