blob: 3e127c9350d4d4e20821d720f0be8d26b2167264 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/*
* InputMonitor.h
*
* Created on: 17 Sep 2019
* Author: David
*/
#ifndef SRC_ENDSTOPS_INPUTMONITOR_H_
#define SRC_ENDSTOPS_INPUTMONITOR_H_
#include <RepRapFirmware.h>
#if SUPPORT_REMOTE_COMMANDS
#include <Hardware/IoPorts.h>
#include <GCodes/GCodeResult.h>
#include <RTOSIface/RTOSIface.h>
struct CanMessageCreateInputMonitor;
struct CanMessageChangeInputMonitor;
struct CanMessageInputChanged;
class CanMessageBuffer;
class InputMonitor
{
public:
InputMonitor() noexcept { }
static void Init() noexcept;
static GCodeResult Create(const CanMessageCreateInputMonitor& msg, size_t dataLength, const StringRef& reply, uint8_t& extra) noexcept;
static GCodeResult Change(const CanMessageChangeInputMonitor& msg, const StringRef& reply, uint8_t& extra) noexcept;
static uint32_t AddStateChanges(CanMessageInputChanged *msg) noexcept;
static void ReadInputs(CanMessageBuffer *buf) noexcept;
static void CommonDigitalPortInterrupt(CallbackParameter cbp) noexcept;
static void CommonAnalogPortInterrupt(CallbackParameter cbp, uint16_t reading) noexcept;
private:
bool Activate() noexcept;
void Deactivate() noexcept;
void DigitalInterrupt() noexcept;
void AnalogInterrupt(uint16_t reading) noexcept;
uint16_t GetAnalogValue() const noexcept;
static bool Delete(uint16_t hndl) noexcept;
static ReadLockedPointer<InputMonitor> Find(uint16_t hndl) noexcept;
InputMonitor *next;
IoPort port;
uint32_t whenLastSent;
uint16_t handle;
uint16_t minInterval;
uint16_t threshold;
bool active;
volatile bool state;
volatile bool sendDue;
static InputMonitor * volatile monitorsList;
static InputMonitor * volatile freeList;
static ReadWriteLock listLock;
};
#endif // SUPPORT_CAN_EXPANSION
#endif /* SRC_ENDSTOPS_INPUTMONITOR_H_ */
|