From 21136cafcc0b6854b8860f9629709e7ca681b5e2 Mon Sep 17 00:00:00 2001 From: Aashish chaddha Date: Thu, 11 Oct 2018 12:39:46 -0500 Subject: [PATCH 1/3] improve can documentation --- drivers/CAN.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/CAN.h b/drivers/CAN.h index c1aae5c771e..d4c24a1c063 100644 --- a/drivers/CAN.h +++ b/drivers/CAN.h @@ -85,7 +85,7 @@ class CANMessage : public CAN_Message { class CAN : private NonCopyable { public: - /** Creates an CAN interface connected to specific pins. + /** Creates a CAN interface connected to specific pins. * * @param rd read from transmitter * @param td transmit to transmitter @@ -94,11 +94,15 @@ class CAN : private NonCopyable { * @code * #include "mbed.h" * + * #if defined (DEVICE_CAN) || defined(DOXYGEN_ONLY) + * * Ticker ticker; * DigitalOut led1(LED1); * DigitalOut led2(LED2); - * CAN can1(p9, p10); - * CAN can2(p30, p29); + * //The constructor takes in RX, and TX pin respectively. + * //These pins, for this example, are defined in mbed_app.json + * CAN can1(MBED_CONF_APP_CAN1_RD, MBED_CONF_APP_CAN1_TD); + * CAN can2(MBED_CONF_APP_CAN2_RD, MBED_CONF_APP_CAN2_TD); * * char counter = 0; * @@ -121,14 +125,19 @@ class CAN : private NonCopyable { * wait(0.2); * } * } + * + * #else + * #error CAN NOT SUPPORTED + * + * #endif * @endcode */ CAN(PinName rd, PinName td); /** Initialize CAN interface and set the frequency * - * @param rd the rd pin - * @param td the td pin + * @param rd the read pin + * @param td the transmit pin * @param hz the bus frequency in hertz */ CAN(PinName rd, PinName td, int hz); @@ -288,6 +297,7 @@ class CAN : private NonCopyable { static void _irq_handler(uint32_t id, CanIrqType type); +#if !defined(DOXYGEN_ONLY) protected: virtual void lock(); virtual void unlock(); @@ -295,6 +305,7 @@ class CAN : private NonCopyable { Callback _irq[IrqCnt]; PlatformMutex _mutex; }; +#endif } // namespace mbed From f0a44510546ecd394bcebe56a070ca0ed376dcba Mon Sep 17 00:00:00 2001 From: Aashish chaddha Date: Fri, 12 Oct 2018 10:01:38 -0500 Subject: [PATCH 2/3] fix critical bug where I was hiding a lot more class members than i should. Add "CAN_NOT_SUPPORTED" guard to header instead of example --- drivers/CAN.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/CAN.h b/drivers/CAN.h index d4c24a1c063..ff108576e40 100644 --- a/drivers/CAN.h +++ b/drivers/CAN.h @@ -94,7 +94,6 @@ class CAN : private NonCopyable { * @code * #include "mbed.h" * - * #if defined (DEVICE_CAN) || defined(DOXYGEN_ONLY) * * Ticker ticker; * DigitalOut led1(LED1); @@ -126,10 +125,6 @@ class CAN : private NonCopyable { * } * } * - * #else - * #error CAN NOT SUPPORTED - * - * #endif * @endcode */ CAN(PinName rd, PinName td); @@ -304,11 +299,13 @@ class CAN : private NonCopyable { can_t _can; Callback _irq[IrqCnt]; PlatformMutex _mutex; -}; #endif +}; } // namespace mbed +#else + #error CAN NOT SUPPORTED #endif #endif // MBED_CAN_H From a9ce00bb4dee1f2380e404e05adb2b714e42dfb8 Mon Sep 17 00:00:00 2001 From: Aashish chaddha Date: Fri, 12 Oct 2018 10:16:32 -0500 Subject: [PATCH 3/3] fixed a mistake where I was adding "can not supprted" error at wrong place --- drivers/CAN.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/CAN.h b/drivers/CAN.h index ff108576e40..cc96f76733f 100644 --- a/drivers/CAN.h +++ b/drivers/CAN.h @@ -304,8 +304,6 @@ class CAN : private NonCopyable { } // namespace mbed -#else - #error CAN NOT SUPPORTED #endif #endif // MBED_CAN_H