2011-02-28 18:44:46 +00:00
|
|
|
/*
|
2011-03-18 18:38:08 +00:00
|
|
|
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
|
2013-02-02 10:58:09 +00:00
|
|
|
2011,2012,2013 Giovanni Di Sirio.
|
2011-02-28 18:44:46 +00:00
|
|
|
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file templates/gpt_lld.c
|
|
|
|
* @brief GPT Driver subsystem low level driver source template.
|
|
|
|
*
|
|
|
|
* @addtogroup GPT
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ch.h"
|
|
|
|
#include "hal.h"
|
|
|
|
|
|
|
|
#if HAL_USE_GPT || defined(__DOXYGEN__)
|
|
|
|
|
2011-08-26 13:47:22 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver local definitions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2011-02-28 18:44:46 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver exported variables. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2013-02-25 11:58:40 +00:00
|
|
|
/**
|
|
|
|
* @brief GPTD1 driver identifier.
|
|
|
|
*/
|
2013-02-24 15:45:04 +00:00
|
|
|
#if PLATFORM_GPT_USE_GPT1 || defined(__DOXYGEN__)
|
|
|
|
GPTDriver GPTD1;
|
|
|
|
#endif
|
|
|
|
|
2011-02-28 18:44:46 +00:00
|
|
|
/*===========================================================================*/
|
2013-02-28 16:23:19 +00:00
|
|
|
/* Driver local variables and types. */
|
2011-02-28 18:44:46 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver local functions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver interrupt handlers. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver exported functions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Low level GPT driver initialization.
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void gpt_lld_init(void) {
|
|
|
|
|
2013-02-24 15:45:04 +00:00
|
|
|
#if PLATFORM2_GPT_USE_TIM1
|
|
|
|
/* Driver initialization.*/
|
|
|
|
gptObjectInit(&GPTD1);
|
|
|
|
#endif
|
2011-02-28 18:44:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Configures and activates the GPT peripheral.
|
|
|
|
*
|
|
|
|
* @param[in] gptp pointer to the @p GPTDriver object
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void gpt_lld_start(GPTDriver *gptp) {
|
|
|
|
|
|
|
|
if (gptp->state == GPT_STOP) {
|
2013-02-27 10:42:09 +00:00
|
|
|
/* Enables the peripheral.*/
|
2013-02-24 15:45:04 +00:00
|
|
|
#if PLATFORM_GPT_USE_GPT1
|
|
|
|
if (&GPTD1 == gptp) {
|
2011-02-28 18:44:46 +00:00
|
|
|
|
2013-02-24 15:45:04 +00:00
|
|
|
}
|
|
|
|
#endif /* PLATFORM_GPT_USE_GPT1 */
|
2011-02-28 18:44:46 +00:00
|
|
|
}
|
2013-02-24 15:45:04 +00:00
|
|
|
/* Configures the peripheral.*/
|
|
|
|
|
2011-02-28 18:44:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Deactivates the GPT peripheral.
|
|
|
|
*
|
|
|
|
* @param[in] gptp pointer to the @p GPTDriver object
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void gpt_lld_stop(GPTDriver *gptp) {
|
|
|
|
|
|
|
|
if (gptp->state == GPT_READY) {
|
2013-02-24 15:45:04 +00:00
|
|
|
/* Resets the peripheral.*/
|
|
|
|
|
|
|
|
/* Disables the peripheral.*/
|
|
|
|
#if PLATFORM_GPT_USE_GPT1
|
|
|
|
if (&GPTD1 == gptp) {
|
2011-02-28 18:44:46 +00:00
|
|
|
|
2013-02-24 15:45:04 +00:00
|
|
|
}
|
|
|
|
#endif /* PLATFORM_GPT_USE_GPT1 */
|
2011-02-28 18:44:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Starts the timer in continuous mode.
|
|
|
|
*
|
|
|
|
* @param[in] gptp pointer to the @p GPTDriver object
|
2013-02-24 15:45:04 +00:00
|
|
|
* @param[in] interval period in ticks
|
2011-02-28 18:44:46 +00:00
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
2013-02-24 15:45:04 +00:00
|
|
|
void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t interval) {
|
2011-02-28 18:44:46 +00:00
|
|
|
|
2013-02-25 11:58:40 +00:00
|
|
|
(void)gptp;
|
|
|
|
(void)interval;
|
|
|
|
|
2011-02-28 18:44:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Stops the timer.
|
|
|
|
*
|
|
|
|
* @param[in] gptp pointer to the @p GPTDriver object
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void gpt_lld_stop_timer(GPTDriver *gptp) {
|
|
|
|
|
2013-02-25 11:58:40 +00:00
|
|
|
(void)gptp;
|
|
|
|
|
2011-02-28 18:44:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Starts the timer in one shot mode and waits for completion.
|
|
|
|
* @details This function specifically polls the timer waiting for completion
|
|
|
|
* in order to not have extra delays caused by interrupt servicing,
|
|
|
|
* this function is only recommended for short delays.
|
|
|
|
*
|
|
|
|
* @param[in] gptp pointer to the @p GPTDriver object
|
|
|
|
* @param[in] interval time interval in ticks
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval) {
|
|
|
|
|
2013-02-25 11:58:40 +00:00
|
|
|
(void)gptp;
|
|
|
|
(void)interval;
|
|
|
|
|
2011-02-28 18:44:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAL_USE_GPT */
|
|
|
|
|
|
|
|
/** @} */
|