123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- /*
- ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
- /**
- * @file hal_can_lld.c
- * @brief PLATFORM CAN subsystem low level driver source.
- *
- * @addtogroup CAN
- * @{
- */
- #include "hal.h"
- #if (HAL_USE_CAN == TRUE) || defined(__DOXYGEN__)
- /*===========================================================================*/
- /* Driver local definitions. */
- /*===========================================================================*/
- /*===========================================================================*/
- /* Driver exported variables. */
- /*===========================================================================*/
- /**
- * @brief CAN1 driver identifier.
- */
- #if (PLATFORM_CAN_USE_CAN1 == TRUE) || defined(__DOXYGEN__)
- CANDriver CAND1;
- #endif
- /*===========================================================================*/
- /* Driver local variables and types. */
- /*===========================================================================*/
- /*===========================================================================*/
- /* Driver local functions. */
- /*===========================================================================*/
- /*===========================================================================*/
- /* Driver interrupt handlers. */
- /*===========================================================================*/
- /*===========================================================================*/
- /* Driver exported functions. */
- /*===========================================================================*/
- /**
- * @brief Low level CAN driver initialization.
- *
- * @notapi
- */
- void can_lld_init(void) {
- #if PLATFORM_CAN_USE_CAN1 == TRUE
- /* Driver initialization.*/
- canObjectInit(&CAND1);
- #endif
- }
- /**
- * @brief Configures and activates the CAN peripheral.
- *
- * @param[in] canp pointer to the @p CANDriver object
- *
- * @notapi
- */
- void can_lld_start(CANDriver *canp) {
- if (canp->state == CAN_STOP) {
- /* Enables the peripheral.*/
- #if PLATFORM_CAN_USE_CAN1 == TRUE
- if (&CAND1 == canp) {
- }
- #endif
- }
- /* Configures the peripheral.*/
- }
- /**
- * @brief Deactivates the CAN peripheral.
- *
- * @param[in] canp pointer to the @p CANDriver object
- *
- * @notapi
- */
- void can_lld_stop(CANDriver *canp) {
- if (canp->state == CAN_READY) {
- /* Resets the peripheral.*/
- /* Disables the peripheral.*/
- #if PLATFORM_CAN_USE_CAN1 == TRUE
- if (&CAND1 == canp) {
- }
- #endif
- }
- }
- /**
- * @brief Determines whether a frame can be transmitted.
- *
- * @param[in] canp pointer to the @p CANDriver object
- * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
- *
- * @return The queue space availability.
- * @retval false no space in the transmit queue.
- * @retval true transmit slot available.
- *
- * @notapi
- */
- bool can_lld_is_tx_empty(CANDriver *canp, canmbx_t mailbox) {
- (void)canp;
- switch (mailbox) {
- case CAN_ANY_MAILBOX:
- return false;
- case 1:
- return false;
- case 2:
- return false;
- case 3:
- return false;
- default:
- return false;
- }
- }
- /**
- * @brief Inserts a frame into the transmit queue.
- *
- * @param[in] canp pointer to the @p CANDriver object
- * @param[in] ctfp pointer to the CAN frame to be transmitted
- * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
- *
- * @notapi
- */
- void can_lld_transmit(CANDriver *canp,
- canmbx_t mailbox,
- const CANTxFrame *ctfp) {
- (void)canp;
- (void)mailbox;
- (void)ctfp;
- }
- /**
- * @brief Determines whether a frame has been received.
- *
- * @param[in] canp pointer to the @p CANDriver object
- * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
- *
- * @return The queue space availability.
- * @retval false no space in the transmit queue.
- * @retval true transmit slot available.
- *
- * @notapi
- */
- bool can_lld_is_rx_nonempty(CANDriver *canp, canmbx_t mailbox) {
- (void)canp;
- (void)mailbox;
- switch (mailbox) {
- case CAN_ANY_MAILBOX:
- return false;
- case 1:
- return false;
- case 2:
- return false;
- default:
- return false;
- }
- }
- /**
- * @brief Receives a frame from the input queue.
- *
- * @param[in] canp pointer to the @p CANDriver object
- * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
- * @param[out] crfp pointer to the buffer where the CAN frame is copied
- *
- * @notapi
- */
- void can_lld_receive(CANDriver *canp,
- canmbx_t mailbox,
- CANRxFrame *crfp) {
- (void)canp;
- (void)mailbox;
- (void)crfp;
- }
- #if (CAN_USE_SLEEP_MODE == TRUE) || defined(__DOXYGEN__)
- /**
- * @brief Enters the sleep mode.
- *
- * @param[in] canp pointer to the @p CANDriver object
- *
- * @notapi
- */
- void can_lld_sleep(CANDriver *canp) {
- (void)canp;
- }
- /**
- * @brief Enforces leaving the sleep mode.
- *
- * @param[in] canp pointer to the @p CANDriver object
- *
- * @notapi
- */
- void can_lld_wakeup(CANDriver *canp) {
- (void)canp;
- }
- #endif /* CAN_USE_SLEEP_MOD == TRUEE */
- #endif /* HAL_USE_CAN == TRUE */
- /** @} */
|