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
|
/*
* 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 { }, [](AsyncSerial*) noexcept { });
USARTClass Serial1(USART2, USART2_IRQn, ID_USART2, 512, 512, [](AsyncSerial*) noexcept { }, [](AsyncSerial*) noexcept { });
SerialCDC SerialUSB;
void UART2_Handler(void) noexcept
{
Serial.IrqHandler();
}
void USART2_Handler(void) noexcept
{
Serial1.IrqHandler();
}
void SerialInit() noexcept
{
SetPinFunction(APIN_Serial0_RXD, Serial0PinFunction);
SetPinFunction(APIN_Serial0_TXD, Serial0PinFunction);
SetPullup(APIN_Serial0_RXD, true);
SetPinFunction(APIN_Serial1_RXD, Serial1PinFunction);
SetPinFunction(APIN_Serial1_TXD, Serial1PinFunction);
SetPullup(APIN_Serial1_RXD, true);
}
void SdhcInit() noexcept
{
SetPinFunction(HsmciMclkPin, HsmciMclkPinFunction);
for (Pin p : HsmciOtherPins)
{
SetPinFunction(p, HsmciOtherPinsFunction);
SetPullup(p, true);
}
}
void EthernetInit() noexcept
{
// Initialize Ethernet pins
pinMode(EthernetPhyInterruptPin, INPUT_PULLUP);
for (Pin p : EthernetPhyOtherPins)
{
SetPinFunction(p, EthernetPhyOtherPinsFunction);
}
}
// Device initialisation
void DeviceInit() noexcept
{
LegacyAnalogIn::AnalogInInit();
AnalogOut::Init();
SerialInit();
SdhcInit();
EthernetInit();
// Set up PB4..PB5 as normal I/O, not JTAG
matrix_set_system_io(CCFG_SYSIO_SYSIO4 | CCFG_SYSIO_SYSIO5);
}
void StopAnalogTask() noexcept
{
}
// End
|