Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
Lpc17xx40xxCan.hxx
Go to the documentation of this file.
1
35#ifndef _FREERTOS_DRIVERS_NXP_LPC17XX40XXCAN_HXX_
36#define _FREERTOS_DRIVERS_NXP_LPC17XX40XXCAN_HXX_
37
38#include <cstdint>
39
40#include "Can.hxx"
41
42#include "cmsis.h"
43#if defined (CHIP_LPC175X_6X)
44#include "cmsis_175x_6x.h"
45#elif defined (CHIP_LPC177X_9X)
46#include "cmsis_177x_8x.h"
47#elif defined (CHIP_LPC407X_8X)
48#include "cmsis_407x_8x.h"
49#else
50#error "LPC CHIP undefined"
51#endif
52#include "core_cm3.h"
53#include "can_17xx_40xx.h"
54
57class LpcCan : public Can
58{
59public:
64 LpcCan(const char *name, LPC_CAN_T *base);
65
69 {
70 }
71
74 static void interrupt_handler()
75 {
76 for (unsigned i = 0; i < 2; ++i)
77 {
78 if (instances[i])
79 {
80 uint32_t status = Chip_CAN_GetIntStatus(instances[i]->base);
81 if (status != 0)
82 {
83 instances[i]->interrupt_handler(status);
84 }
85 }
86 }
87 }
88
89private:
90 void enable() override;
91 void disable() override;
92 void tx_msg() override;
97 void interrupt_handler(uint32_t status);
98
99 LPC_CAN_T *base;
104 static unsigned int intCount;
105
107 static LpcCan *instances[2];
108
112
114};
115
116#endif /* _FREERTOS_DRIVERS_NXP_LPC17XX40XXCAN_HXX_ */
Base class for a CAN device for the Arduino environment.
const char * name
device name
Definition Devtab.hxx:266
Specialization of CAN driver for LPC17xx and LPC40xx CAN.
void enable() override
function to enable device
~LpcCan()
Destructor.
void disable() override
function to disable device
static unsigned int intCount
one interrupt vector is shared between two CAN controllers, so we need to keep track of the number of...
static void interrupt_handler()
Translate an interrupt handler into C++ object context.
void tx_msg() override
function to try and transmit a message
static LpcCan * instances[2]
Instance pointers help us get context from the interrupt handler(s)
LPC_CAN_T * base
base address of this device
LpcCan()
Default constructor.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
Definition macros.h:171