1# `esp_hw_support` (G1 component) 2 3This component contains hardware-related operations for supporting the system. These operations are one level above that of `hal` in that: 4 51. it uses system services such as memory allocation, logging, scheduling 62. it may be multi-step operations involving/affecting multiple parts of the SoC 73. it offers a service for other components vary from multiple layers (G1, G2 and G3) of ESP-IDF 8 9Implementations that don't fit other components cleanly, but are not worth creating a new component for (yet) may also be placed here as long as they don't pull dependencies other than the core system components. 10 11## Event-Task Service (esp_etm) 12 13### esp_etm driver design 14 15`esp_etm` driver is divided into two parts: 16 17* The **core** driver, which focuses on ETM channel allocation and offers APIs to connect the channel with ETM tasks and ETM events that come from other peripherals. 18* **Peripheral** side extensions, e.g. GPTimer support generating different kinds of ETM events, and accept multiple ETM tasks. These extensions are implemented in the peripheral driver, and can be located in different components. Usually, the task and event extensions will simply inherit the interface that defined in the core driver. 19 20See the following class diagram, we take the GPIO and GPTimer as the example to illustrate the architecture of `esp_etm` driver. 21 22```mermaid 23classDiagram 24 esp_etm_channel_t "1" --> "1" esp_etm_event_t : Has 25 esp_etm_channel_t "1" --> "1" esp_etm_task_t : Has 26 class esp_etm_channel_t { 27 -int chan_id 28 -esp_etm_event_t event 29 -esp_etm_task_t task 30 +enable() esp_err_t 31 +disable() esp_err_t 32 +connect(event, task) esp_err_t 33 +dump() esp_err_t 34 } 35 36 class esp_etm_event_t { 37 <<interface>> 38 #int event_id 39 #etm_trigger_peripheral_t trig_periph 40 #del() esp_err_t 41 } 42 43 class esp_etm_task_t { 44 <<interface>> 45 #int task_id 46 #etm_trigger_peripheral_t trig_periph 47 #del() esp_err_t 48 } 49 50 gpio_etm_event_t --|> esp_etm_event_t : Inheritance 51 class gpio_etm_event_t { 52 -int chan_id 53 +bind_gpio(gpio_num_t gpio) esp_err_t 54 } 55 56 gpio_etm_task_t --|> esp_etm_task_t : Inheritance 57 class gpio_etm_task_t { 58 -int chan_id 59 +add_gpio(gpio_num) esp_err_t 60 +rm_gpio(gpio_num) esp_err_t 61 } 62 63 gptimer_t "1" --> "1..*" gptimer_etm_event_t : Has 64 gptimer_t "1" --> "1..*" gptimer_etm_task_t : Has 65 class gptimer_t { 66 -gptimer_etm_event_t[] events 67 -gptimer_etm_task_t[] tasks 68 } 69 70 gptimer_etm_event_t --|> esp_etm_event_t : Inheritance 71 class gptimer_etm_event_t { 72 } 73 74 gptimer_etm_task_t --|> esp_etm_task_t : Inheritance 75 class gptimer_etm_task_t { 76 } 77``` 78