Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GpInPort.h « GPIO « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5ab78eeca919cd52471992c0ebe55f44217b0ef5 (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
/*
 * GpInPort.h
 *
 *  Created on: 11 Feb 2020
 *      Author: David
 */

#ifndef SRC_GPIO_GPINPORT_H_
#define SRC_GPIO_GPINPORT_H_

#include <RepRapFirmware.h>
#include <Hardware/IoPorts.h>
#include <ObjectModel/ObjectModel.h>

#if SUPPORT_CAN_EXPANSION
# include <RemoteInputHandle.h>
#endif

class GpInputPort INHERIT_OBJECT_MODEL
{
public:
	GpInputPort() noexcept :
#if SUPPORT_CAN_EXPANSION
		boardAddress(CanInterface::GetCanAddress()),
#endif
		currentState(false) { }
	GpInputPort(const GpInputPort&) = delete;

	bool GetState() const noexcept;
	bool IsUnused() const noexcept;

#if SUPPORT_CAN_EXPANSION
	void SetState(CanAddress src, bool b) noexcept { if (src == boardAddress) { currentState = b; } }
#endif

	GCodeResult Configure(uint32_t gpinNumber, GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException);

protected:
	DECLARE_OBJECT_MODEL

private:
	IoPort port;									// will be initialised by PwmPort default constructor
#if SUPPORT_CAN_EXPANSION
	RemoteInputHandle handle;
	CanAddress boardAddress;
#endif
	bool currentState;
};

#endif /* SRC_GPIO_GPINPORT_H_ */