1# rule
2
3## Description
4
5A rule is a sequence of actions that can be shared by multiple regulators in the
6config file. Rules define a standard way to perform an operation. Rules are used
7to minimize duplication in the config file.
8
9For example, the following action sequences might be sharable using a rule:
10
11- Actions that set the output voltage of a regulator rail
12- Actions that read all the sensors of a regulator rail
13- Actions that detect down-level hardware using version registers
14- Actions that detect phase faults
15
16## Properties
17
18| Name     | Required | Type                          | Description                                                                                       |
19| :------- | :------: | :---------------------------- | :------------------------------------------------------------------------------------------------ |
20| comments |    no    | array of strings              | One or more comment lines describing this rule.                                                   |
21| id       |   yes    | string                        | Unique ID for this rule. Can only contain letters (A-Z, a-z), numbers (0-9), and underscore (\_). |
22| actions  |   yes    | array of [actions](action.md) | One or more actions to execute.                                                                   |
23
24## Return Value
25
26Return value of the last action in the "actions" property.
27
28## Example
29
30```json
31{
32  "comments": ["Sets output voltage of PAGE 0 of a PMBus regulator"],
33  "id": "set_page0_voltage_rule",
34  "actions": [
35    { "i2c_write_byte": { "register": "0x00", "value": "0x00" } },
36    { "pmbus_write_vout_command": { "format": "linear" } }
37  ]
38}
39```
40
41... later in the config file ...
42
43```json
44"configuration": {
45  "volts": 1.03,
46  "rule_id": "set_page0_voltage_rule"
47}
48```
49