2009-11-29 08:50:13 +00:00
|
|
|
/*
|
2011-03-18 18:38:08 +00:00
|
|
|
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
|
|
|
|
2011 Giovanni Di Sirio.
|
2009-11-29 08:50:13 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-02-07 11:11:45 +00:00
|
|
|
* @file templates/can_lld.c
|
|
|
|
* @brief CAN Driver subsystem low level driver source template.
|
|
|
|
*
|
2010-10-25 18:48:13 +00:00
|
|
|
* @addtogroup CAN
|
2009-11-29 08:50:13 +00:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ch.h"
|
|
|
|
#include "hal.h"
|
|
|
|
|
2010-11-01 17:29:56 +00:00
|
|
|
#if HAL_USE_CAN || defined(__DOXYGEN__)
|
2009-11-29 08:50:13 +00:00
|
|
|
|
2011-08-26 13:47:22 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver local definitions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2009-11-29 08:50:13 +00:00
|
|
|
/*===========================================================================*/
|
2009-12-29 11:12:05 +00:00
|
|
|
/* Driver exported variables. */
|
2009-11-29 08:50:13 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
2009-12-29 11:12:05 +00:00
|
|
|
/* Driver local variables. */
|
2009-11-29 08:50:13 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
2009-12-29 11:12:05 +00:00
|
|
|
/* Driver local functions. */
|
2009-11-29 08:50:13 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
2009-12-29 11:12:05 +00:00
|
|
|
/* Driver interrupt handlers. */
|
2009-11-29 08:50:13 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
2009-12-29 11:12:05 +00:00
|
|
|
/* Driver exported functions. */
|
2009-11-29 08:50:13 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/**
|
2010-02-07 11:11:45 +00:00
|
|
|
* @brief Low level CAN driver initialization.
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @notapi
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
void can_lld_init(void) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-07 11:11:45 +00:00
|
|
|
* @brief Configures and activates the CAN peripheral.
|
2009-11-29 08:50:13 +00:00
|
|
|
*
|
2010-02-07 11:11:45 +00:00
|
|
|
* @param[in] canp pointer to the @p CANDriver object
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @notapi
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
void can_lld_start(CANDriver *canp) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-07 11:11:45 +00:00
|
|
|
* @brief Deactivates the CAN peripheral.
|
2009-11-29 08:50:13 +00:00
|
|
|
*
|
2010-02-07 11:11:45 +00:00
|
|
|
* @param[in] canp pointer to the @p CANDriver object
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @notapi
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
void can_lld_stop(CANDriver *canp) {
|
|
|
|
|
2009-12-04 20:56:51 +00:00
|
|
|
/* If in ready state then disables the CAN peripheral.*/
|
2011-03-08 10:09:57 +00:00
|
|
|
if (canp->state == CAN_READY) {
|
2009-12-04 20:56:51 +00:00
|
|
|
|
|
|
|
}
|
2009-11-29 08:50:13 +00:00
|
|
|
}
|
|
|
|
|
2009-12-04 20:56:51 +00:00
|
|
|
|
2009-11-29 08:50:13 +00:00
|
|
|
/**
|
2010-02-07 11:11:45 +00:00
|
|
|
* @brief Determines whether a frame can be transmitted.
|
2010-02-21 07:24:53 +00:00
|
|
|
*
|
2010-02-07 11:11:45 +00:00
|
|
|
* @param[in] canp pointer to the @p CANDriver object
|
|
|
|
* @return The queue space availability.
|
|
|
|
* @retval FALSE no space in the transmit queue.
|
2010-02-21 07:24:53 +00:00
|
|
|
* @retval TRUE transmit slot available.
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @notapi
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
bool_t can_lld_can_transmit(CANDriver *canp) {
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-07 11:11:45 +00:00
|
|
|
* @brief Inserts a frame into the transmit queue.
|
2009-11-29 08:50:13 +00:00
|
|
|
*
|
2009-12-04 20:56:51 +00:00
|
|
|
* @param[in] canp pointer to the @p CANDriver object
|
|
|
|
* @param[in] ctfp pointer to the CAN frame to be transmitted
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @notapi
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
2009-12-04 20:56:51 +00:00
|
|
|
void can_lld_transmit(CANDriver *canp, const CANTxFrame *ctfp) {
|
2009-11-29 08:50:13 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-07 11:11:45 +00:00
|
|
|
* @brief Determines whether a frame has been received.
|
2009-11-29 08:50:13 +00:00
|
|
|
*
|
2010-02-07 11:11:45 +00:00
|
|
|
* @param[in] canp pointer to the @p CANDriver object
|
|
|
|
* @return The queue space availability.
|
|
|
|
* @retval FALSE no space in the transmit queue.
|
|
|
|
* @retval TRUE transmit slot available.
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @notapi
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
bool_t can_lld_can_receive(CANDriver *canp) {
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-07 11:11:45 +00:00
|
|
|
* @brief Receives a frame from the input queue.
|
2009-11-29 08:50:13 +00:00
|
|
|
*
|
2009-12-04 20:56:51 +00:00
|
|
|
* @param[in] canp pointer to the @p CANDriver object
|
|
|
|
* @param[out] crfp pointer to the buffer where the CAN frame is copied
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @notapi
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
2009-12-04 20:56:51 +00:00
|
|
|
void can_lld_receive(CANDriver *canp, CANRxFrame *crfp) {
|
2009-11-29 08:50:13 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CAN_USE_SLEEP_MODE || defined(__DOXYGEN__)
|
|
|
|
/**
|
2010-02-07 11:11:45 +00:00
|
|
|
* @brief Enters the sleep mode.
|
2009-11-29 08:50:13 +00:00
|
|
|
*
|
|
|
|
* @param[in] canp pointer to the @p CANDriver object
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @notapi
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
void can_lld_sleep(CANDriver *canp) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-07 11:11:45 +00:00
|
|
|
* @brief Enforces leaving the sleep mode.
|
2009-11-29 08:50:13 +00:00
|
|
|
*
|
|
|
|
* @param[in] canp pointer to the @p CANDriver object
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @notapi
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
void can_lld_wakeup(CANDriver *canp) {
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif /* CAN_USE_SLEEP_MODE */
|
|
|
|
|
2010-11-01 17:29:56 +00:00
|
|
|
#endif /* HAL_USE_CAN */
|
2009-11-29 08:50:13 +00:00
|
|
|
|
|
|
|
/** @} */
|