-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathgp2040aux.cpp
71 lines (58 loc) · 1.81 KB
/
gp2040aux.cpp
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
// GP2040 includes
#include "gp2040aux.h"
#include "gamepad.h"
#include "drivermanager.h"
#include "storagemanager.h"
#include "usbhostmanager.h"
#include "addons/board_led.h" // Add-Ons
#include "addons/buzzerspeaker.h"
#include "addons/display.h"
#include "addons/pleds.h"
#include "addons/neopicoleds.h"
#include "addons/reactiveleds.h"
#include "addons/drv8833_rumble.h"
#include <iterator>
GP2040Aux::GP2040Aux() : isReady(false), inputDriver(nullptr) {
}
GP2040Aux::~GP2040Aux() {
}
// GP2040Aux will always come after GP2040 setup(), so we can rely on the
// GP2040 setup function for certain setup functions.
void GP2040Aux::setup() {
PeripheralManager::getInstance().initI2C();
PeripheralManager::getInstance().initSPI();
PeripheralManager::getInstance().initUSB();
// Initialize our input driver's auxilliary functions
inputDriver = DriverManager::getInstance().getDriver();
if ( inputDriver != nullptr ) {
inputDriver->initializeAux();
// Check if we have a USB listener
USBListener * listener = inputDriver->get_usb_auth_listener();
if (listener != nullptr) {
USBHostManager::getInstance().pushListener(listener);
}
}
// Setup Add-ons
addons.LoadAddon(new DisplayAddon());
addons.LoadAddon(new NeoPicoLEDAddon());
addons.LoadAddon(new PlayerLEDAddon());
addons.LoadAddon(new BoardLedAddon());
addons.LoadAddon(new BuzzerSpeakerAddon());
addons.LoadAddon(new DRV8833RumbleAddon());
addons.LoadAddon(new ReactiveLEDAddon());
// Initialize our USB manager
USBHostManager::getInstance().start();
// Ready to sync Core0 and Core1
isReady = true;
}
void GP2040Aux::run() {
while (1) {
// Pre, Process, and Post
addons.PreprocessAddons();
addons.ProcessAddons();
// Run auxiliary functions for input driver on Core1
if ( inputDriver != nullptr ) {
inputDriver->processAux();
}
}
}