Ersa Wearable Platform
Embedded smartwatch firmware and application framework
Loading...
Searching...
No Matches
board_terra.h
Go to the documentation of this file.
1#pragma once
2
3#if defined(ARDUINO)
4
5#include "ersa/board/board.h"
18
19namespace ersa {
20namespace board {
21
27class TerraC6Pins final : public Pins {
28public:
30 const I2cPins& i2c() const override { return i2c_; }
32 const SpiPins& spi() const override { return spi_; }
34 const DisplayPins& display() const override { return display_; }
36 const ButtonPins& buttons() const override { return buttons_; }
38 const BatteryPins& battery() const override { return battery_; }
39
40private:
41 const I2cPins i2c_{{22, PinFunction::I2c}, {23, PinFunction::I2c}};
42 const SpiPins spi_{{19, PinFunction::Spi}, {18, PinFunction::Spi}, {-1, PinFunction::Spi}};
43 const DisplayPins display_{{21, PinFunction::Gpio, PinPull::None, PinActiveLevel::Low, PinDirection::Output},
44 {17, PinFunction::Gpio, PinPull::None, PinActiveLevel::High, PinDirection::Output},
45 {16, PinFunction::Gpio, PinPull::None, PinActiveLevel::Low, PinDirection::Output},
46 {20, PinFunction::Gpio, PinPull::None, PinActiveLevel::High, PinDirection::Input}};
47 const ButtonPins buttons_{{2, PinFunction::Gpio, PinPull::Up, PinActiveLevel::Low, PinDirection::Input},
48 {1, PinFunction::Gpio, PinPull::Up, PinActiveLevel::Low, PinDirection::Input}};
49 const BatteryPins battery_{{0, PinFunction::Adc, PinPull::None, PinActiveLevel::High, PinDirection::Input}, 2, 1};
50};
51
60class BoardTerraC6 : public Board {
61public:
63 BoardTerraC6();
65 ~BoardTerraC6() override = default;
66
68 Result<void> init() override;
70 const char* getName() const override { return getDeviceInfo().name; }
72 const DeviceInfo& getDeviceInfo() const override;
74 const BoardConfig& getConfig() const override { return config_; }
76 const Pins& getPins() const override { return pins_; }
77
79 hal::IDisplay& getDisplay() override { return display_; }
81 hal::IRtc& getRtc() override { return rtc_; }
83 hal::IBattery& getBattery() override { return battery_; }
85 hal::IInput& getInput() override { return input_; }
87 hal::IBluetooth& getBluetooth() override { return bluetooth_; }
89 hal::ICompanionSource& getCompanionSource() override { return bluetooth_; }
91 hal::IWifiRadio& getWifi() override { return wifi_; }
93 hal::IPowerManagement& getPowerManagement() override { return powerManagement_; }
95 hal::IConsole& getConsole() override { return console_; }
96 hal::IHttpServer& getHttpServer() override { return web_; }
97 hal::IDnsServer& getDnsServer() override { return web_; }
98 hal::IHttpClient& getHttpClient() override { return httpClient_; }
99 hal::INtpTimeSource& getNtpTimeSource() override { return ntpTimeSource_; }
100 hal::IPlatformDiagnostics& getDiagnostics() override { return diagnostics_; }
101
103 uint32_t getUptimeMs() const override;
105 void delayMs(uint32_t ms) override;
107 void restart() override;
108
110 static BoardTerraC6& instance();
111
112private:
113 BoardConfig config_;
114 TerraC6Pins pins_;
115 drivers::display::Ssd1681Display display_;
116 hal::Esp32Rtc rtc_;
117 hal::Esp32Battery battery_;
118 hal::Esp32Input input_;
119 hal::Esp32Bluetooth bluetooth_;
120 hal::Esp32Wifi wifi_;
121 hal::Esp32PowerManagement powerManagement_;
122 hal::Esp32UsbConsole console_;
123 hal::Esp32WebServer web_;
124 hal::Esp32HttpClient httpClient_;
125 hal::Esp32NtpTimeSource ntpTimeSource_;
126 hal::Esp32PlatformDiagnostics diagnostics_;
127};
128
129} // namespace board
130} // namespace ersa
131
132#endif // ARDUINO
Definition application.h:10