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
|
/*
* Devices.cpp
*
* Created on: 11 Aug 2020
* Author: David
*/
#include "Devices.h"
#include <RepRapFirmware.h>
#include <AnalogIn.h>
#include <AnalogOut.h>
#include <pmc/pmc.h>
AsyncSerial Serial (UART0, UART0_IRQn, ID_UART0, 512, 512, [](AsyncSerial*) noexcept { }, [](AsyncSerial*) noexcept { });
AsyncSerial Serial1(UART1, UART1_IRQn, ID_UART1, 512, 512, [](AsyncSerial*) noexcept { }, [](AsyncSerial*) noexcept { });
SerialCDC SerialUSB;
void UART0_Handler(void) noexcept
{
Serial.IrqHandler();
}
void UART1_Handler(void) noexcept
{
Serial1.IrqHandler();
}
void SerialInit() noexcept
{
SetPinFunction(APIN_Serial0_RXD, Serial0PeriphMode);
SetPinFunction(APIN_Serial0_TXD, Serial0PeriphMode);
SetPullup(APIN_Serial0_RXD, true);
SetPinFunction(APIN_Serial1_RXD, Serial1PeriphMode);
SetPinFunction(APIN_Serial1_TXD, Serial1PeriphMode);
SetPullup(APIN_Serial1_RXD, true);
}
void SdhcInit() noexcept
{
SetPinFunction(HsmciClockPin, HsmciPinsFunction);
for (Pin p : HsmciOtherPins)
{
SetPinFunction(p, HsmciPinsFunction);
SetPullup(p, true);
}
}
void WireInit() noexcept
{
pmc_enable_periph_clk(WIRE_INTERFACE_ID);
SetPinFunction(TWI_Data, TWIPeriphMode);
SetPinFunction(TWI_CK, TWIPeriphMode);
NVIC_DisableIRQ(WIRE_ISR_ID);
NVIC_ClearPendingIRQ(WIRE_ISR_ID);
}
TwoWire Wire(WIRE_INTERFACE, WireInit);
// Device initialisation
void DeviceInit() noexcept
{
LegacyAnalogIn::AnalogInInit();
AnalogOut::Init();
SerialInit();
SdhcInit();
}
void StopAnalogTask() noexcept
{
}
// End
|