Skip to content

Commit dc2eae1

Browse files
committed
README: fill in high-level design details
1 parent fed3aeb commit dc2eae1

File tree

1 file changed

+132
-4
lines changed

1 file changed

+132
-4
lines changed

README.md

Lines changed: 132 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,136 @@
1-
# embedded-services
2-
IPC, feature abstraction and behavioral overrides for embedded subsystems
1+
# Overview
32

4-
## Overview
3+
EC service is where the business logic glues the HAL + common EC functional traits + EC peripheral driver together.
4+
5+
# Building Blocks
6+
7+
## MCU Platform HAL
8+
9+
Hardware specific HAL leveraging Rust Async framework
10+
11+
- Must implement embedded-hal traits to allow a generic hardware agnostic interface
12+
- Desire is for HALs to be open-sourced and upstreamed to Embassy main repo
13+
- Plan to partner with MCU vendor to support more MCU in the future
14+
15+
For example, [embassy-imxrt](https://github.com/pop-project/embassy-imxrt)
16+
17+
18+
```mermaid
19+
classDiagram
20+
class embassy-imxrt["embassy-imxrt I2C master HAL"]
21+
class embedded-hal["embedded-hal I2C master traits"]
22+
<<interface>> embedded-hal
23+
embedded-hal <|-- embassy-imxrt
24+
embedded-hal: +read()
25+
embedded-hal: +write()
26+
embassy-imxrt: +read()
27+
embassy-imxrt: +write()
28+
```
29+
30+
## EC Subsystem Platform Abstractions
31+
32+
There are sets of generic Rust traits the define an EC functional subsystem like thermal, USB PD, fan, battery. This abstraction serves to abstract the underlying HW design away from the business logic.
33+
34+
For example, [embedded-sensor](https://github.com/pop-project/embedded-sensors)
35+
36+
```mermaid
37+
classDiagram
38+
embedded-sensor: +temperature()
39+
<<interface>> embedded-sensor
40+
```
41+
42+
## Rust Based Drivers for EC Peripherals
43+
44+
There are MCU platform agnostic Rust drivers for specific HW parts connected to the EC like TMP108 temp sensor.
45+
46+
- Depending on embedded-hal interface so it is talking to a generic HW interface, not tying to any specific MCU platform
47+
- Implements a EC function platform abstraction traits like `embedded-sensor`, `embedded-battery`, `embedded-fan`
48+
- Plan to partner with vendor to open-source these drivers
49+
50+
For example, [tmp108](https://github.com/pop-project/tmp108)
51+
52+
```mermaid
53+
classDiagram
54+
embedded-sensor <|-- TMP108
55+
embedded-sensor: +temperature()
56+
<<interface>> embedded-sensor
57+
TMP108 --> embedded-hal
58+
TMP108: +temperature()
59+
class embassy-imxrt["embassy-imxrt I2C master HAL"]
60+
class embedded-hal["embedded-hal I2C master traits"]
61+
<<interface>> embedded-hal
62+
embedded-hal <|-- embassy-imxrt
63+
embedded-hal: +read()
64+
embedded-hal: +write()
65+
embassy-imxrt: +read()
66+
embassy-imxrt: +write()
67+
```
68+
69+
# EC Services
70+
71+
EC service houses the business logic that glues the EC peripheral Rust driver + EC subsystem platform abstraction + MC platform HAL together/.
72+
73+
# Repo Organization
74+
- embedded-services repo
75+
- embedded-services library crate
76+
- service traits
77+
- intrusive-list
78+
- transport/router
79+
- power-button-service
80+
- library crate
81+
- hid-service
82+
- library crate
83+
84+
85+
## embedded-services
86+
87+
This houses common EC service utilities to build a service. It includes:
88+
- instrusive-list that allows dynamic number of subscribers and publishers for a service
89+
- transport (IPC) logic that allows EC services to talk to each other
90+
91+
## Individual service
92+
93+
Other service will be separate cargo in this repo.
94+
95+
The service itself should be hardware/platform agnostic and contains the application logic for EC functionality.
96+
97+
For example, temperature_service
98+
99+
```mermaid
100+
classDiagram
101+
temperature-service --> embedded-hal
102+
temperature-service --> embedded-sensor
103+
embedded-sensor <|-- TMP108
104+
embedded-sensor: +temperature()
105+
<<interface>> embedded-sensor
106+
TMP108 --> embedded-hal
107+
TMP108: +temperature()
108+
class embassy-imxrt["embassy-imxrt I2C master HAL"]
109+
class embedded-hal["embedded-hal I2C master traits"]
110+
<<interface>> embedded-hal
111+
embedded-hal <|-- embassy-imxrt
112+
embedded-hal: +read()
113+
embedded-hal: +write()
114+
embassy-imxrt: +read()
115+
embassy-imxrt: +write()
116+
```
117+
118+
# EC Top-Level
119+
120+
At the top-level, a EC is an aggregate of service.
121+
122+
Sets of services be grouped into subsystem. For instance, thermal subsystem will consist of temperature-service + fan-service + battery-service + debug-service + host-comm-service. The service talks to each other through the transport (IPC) layer. An EC service will also be shared between different subsystems. For instance, debug-service will subcribe to debug messages from other services.
123+
124+
```
125+
async fn (spawner: Spawner) {
126+
//initialize HW peripheral and system level managemetn
127+
spawn(services(periphal, configuration))
128+
...
129+
}
130+
```
131+
132+
## Example: Simplified Layer of Subsystem + Services
5133
![Simplified Layer View](docs/images/simplified_layers.png "Simplified Layered View of Services")
6134

7-
## Example: Keyboard over eSPI
135+
## Example: E2E of Keyboard over eSPI
8136
![Keyboard to Host via eSPI Example](docs/images/keyboard_to_espi_example.png "Keyboard to Host via eSPI Example")

0 commit comments

Comments
 (0)