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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*
* Devices.cpp
*
* Created on: 11 Aug 2020
* Author: David
*/
#include "Devices.h"
#include <RepRapFirmware.h>
#include <AnalogIn.h>
#include <AnalogOut.h>
#include <matrix/matrix.h>
AsyncSerial Serial(UART2, UART2_IRQn, ID_UART2, 512, 512,
[](AsyncSerial*) noexcept
{
SetPinFunction(APIN_Serial0_RXD, Serial0PinFunction);
SetPinFunction(APIN_Serial0_TXD, Serial0PinFunction);
},
[](AsyncSerial*) noexcept
{
ClearPinFunction(APIN_Serial0_RXD);
ClearPinFunction(APIN_Serial0_TXD);
}
);
USARTClass Serial1(USART2, USART2_IRQn, ID_USART2, 512, 512,
[](AsyncSerial*) noexcept
{
SetPinFunction(APIN_Serial1_RXD, Serial1PinFunction);
SetPinFunction(APIN_Serial1_TXD, Serial1PinFunction);
},
[](AsyncSerial*) noexcept
{
ClearPinFunction(APIN_Serial1_RXD);
ClearPinFunction(APIN_Serial1_TXD);
}
);
SerialCDC SerialUSB;
void UART2_Handler(void) noexcept
{
Serial.IrqHandler();
}
void USART2_Handler(void) noexcept
{
Serial1.IrqHandler();
}
void SdhcInit() noexcept
{
SetPinFunction(HsmciMclkPin, HsmciMclkPinFunction);
for (Pin p : HsmciOtherPins)
{
SetPinFunction(p, HsmciOtherPinsFunction);
EnablePullup(p);
}
}
void EthernetInit() noexcept
{
// Initialize Ethernet pins
for (Pin p : EthernetPhyOtherPins)
{
SetPinFunction(p, EthernetPhyOtherPinsFunction);
}
}
// Device initialisation
void DeviceInit() noexcept
{
LegacyAnalogIn::AnalogInInit();
AnalogOut::Init();
SdhcInit();
EthernetInit();
#if defined(DUET3_MB6HC) || defined(DUET3_MB6XD)
# ifdef DEBUG
// Set up PB4..PB5 as normal I/O, not JTAG. Leave PB6/7 pins as SWD. STATUS and ACT LEDs will not work.
matrix_set_system_io(CCFG_SYSIO_SYSIO4 | CCFG_SYSIO_SYSIO5);
# else
// Set up PB4..PB7 as normal I/O, not JTAG or SWD
matrix_set_system_io(CCFG_SYSIO_SYSIO4 | CCFG_SYSIO_SYSIO5 | CCFG_SYSIO_SYSIO6 | CCFG_SYSIO_SYSIO7);
# endif
#endif
}
void StopAnalogTask() noexcept
{
}
// End
|