Skip to content

Commit 999bf61

Browse files
authored
Updating api refernce (#27)
* Added GPIO API * Updated bundle * Refereshed sensors and timers parameter table with a "type" * Updated the expected output after flashing the Ocre runtime * Added the ocre_runtime api, as well as re-organized the API structure in the references section. * Minor formatting tweaks
1 parent 072f3fa commit 999bf61

10 files changed

Lines changed: 742 additions & 41 deletions

File tree

docs/quickstart/firmware/hardware.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ To flash the Ocre Runtime to your device follow these steps:
8888
```
8989
3. After flashing, restart/reset your board to run the application. If successful, you should see the following output on your console:
9090

91-
![](../success.png)
91+
```sh
92+
ocre:~$
93+
94+
Ocre runtime started
95+
Hello world from Ocre.
96+
```
9297

9398
---
9499

docs/quickstart/firmware/simulated.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ To run the application, simply run the following command:
9494

9595
If successful, you should see the following output:
9696

97-
![](../success.png)
97+
```sh
98+
ocre:~$
99+
100+
Ocre runtime started
101+
Hello world from Ocre.
102+
```
98103

99104
---
100105

-117 KB
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: GPIO
33
layout: default
4-
parent: Container APIs
4+
parent: Container
55
has_toc: false
66
---
77

@@ -439,4 +439,4 @@ int main() {
439439
| [`ocre_gpio_pin_toggle`](#toggle-gpio-pin) | Toggles a GPIO pin state | `pin`: GPIO pin number | `0` on success, negative on error | `ENODEV`, `EINVAL` |
440440
| [`ocre_gpio_register_callback`](#register-gpio-callback) | Registers callback for GPIO changes | `pin`: GPIO pin number<br/>`callback`: Callback function | `0` on success, negative on error | `ENODEV`, `EINVAL` |
441441
| [`ocre_gpio_unregister_callback`](#unregister-gpio-callback) | Removes GPIO callback | `pin`: GPIO pin number | `0` on success, negative on error | `ENODEV`, `EINVAL` |
442-
| [`get_pin_id`](#get-pin-id) | Calculates pin ID from port and pin | `port`: GPIO port number<br/>`pin`: Pin number within port | Pin ID or `-1` on invalid Pin | N/A |
442+
| [`get_pin_id`](#get-pin-id) | Calculates pin ID from port and pin | `port`: GPIO port number<br/>`pin`: Pin number within port | Pin ID or `-1` on invalid Pin | N/A |
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: Container
3+
layout: default
4+
parent: APIs
5+
has_toc: false
6+
---
7+
# Container APIs
8+
9+
Container APIs provide direct interfaces for containers to efficiently interact with underlying system resources and capabilities. Designed with simplicity, security, and consistency in mind, these APIs follow well-defined patterns to facilitate ease of use and seamless integration.
10+
11+
---
12+
13+
## Available APIs
14+
15+
Below are the core APIs available for Ocre containers. Each API includes detailed documentation with usage examples, error handling patterns, and best practices.
16+
17+
### System Interaction
18+
19+
| API | Description |
20+
|-----|-------------|
21+
| **[GPIO](gpio)** | Control digital pins for input/output operations with hardware peripherals and external components |
22+
| **[Sensors](sensors)** | Interface with hardware sensors for environmental and motion data |
23+
| **[Timers](timers)** | Create and manage timed events with millisecond precision |

docs/reference/container-api/sensors.md renamed to docs/reference/apis/container-api/sensors.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Sensors
33
layout: default
4-
parent: Container APIs
4+
parent: Container
55
---
66

77
# Sensors
@@ -58,7 +58,7 @@ typedef struct ocre_sensor_handle_t {
5858
} ocre_sensor_handle_t;
5959
```
6060

61-
The sensor handle contains a unique ID, device name, and a reference to the underlying device structure. It is used to reference a specific sensor in all operations.
61+
The sensor handle contains a unique `ID`, device name, and a reference to the underlying device structure. It is used to reference a specific sensor in all operations.
6262

6363
### Sensor Instance
6464

@@ -169,8 +169,8 @@ ocre_sensors_status_t ocre_sensors_discover_sensors(ocre_sensor_t *sensors, int
169169

170170
| Name | Type | Description |
171171
| ------ | ------ | ----------- |
172-
| `sensors` | *ocre_sensor_t** | Pointer to the sensor list to store the discovered info about available sensors |
173-
| `sensors_count` | *int** | Pointer to variable to store the number of discovered sensors |
172+
| `sensors` | *ocre_sensor_t* * | Pointer to the sensor list to store the discovered info about available sensors |
173+
| `sensors_count` | *int* * | Pointer to variable to store the number of discovered sensors |
174174

175175
**Returns**:
176176

@@ -191,7 +191,7 @@ ocre_sensors_status_t ocre_sensors_open(ocre_sensor_handle_t *sensor_handle);
191191
192192
| Name | Type | Description |
193193
| ------ | ------ | ----------- |
194-
| `sensor_handle` | *ocre_sensor_handle_t** | Pointer to the sensor handle to open |
194+
| `sensor_handle` | *ocre_sensor_handle_t* * | Pointer to the sensor handle to open |
195195
196196
**Returns**:
197197
@@ -213,7 +213,7 @@ ocre_sensors_sample_t sensor_read_sample(ocre_sensor_handle_t *sensor_handle);
213213

214214
| Name | Type | Description |
215215
| ------ | ------ | ----------- |
216-
| `sensor_handle` | *ocre_sensor_handle_t** | Pointer to the sensor handle to read from |
216+
| `sensor_handle` | *ocre_sensor_handle_t* * | Pointer to the sensor handle to read from |
217217

218218
**Returns**:
219219

@@ -264,7 +264,7 @@ ocre_sensors_status_t ocre_sensors_set_trigger(ocre_sensor_handle_t sensor_handl
264264
| `channel` | *sensor_channel_t* | Channel to set the trigger on |
265265
| `trigger_type` | *enum sensor_trigger_type* | Type of trigger (e.g., data ready, threshold) |
266266
| `callback` | *ocre_sensor_trigger_cb* | Function to be called when trigger occurs |
267-
| `subscription_id` | *int** | Pointer to store the subscription ID |
267+
| `subscription_id` | *int* * | Pointer to store the subscription `ID` |
268268

269269
**Returns**:
270270

@@ -288,7 +288,7 @@ ocre_sensors_status_t ocre_sensors_clear_trigger(ocre_sensor_handle_t sensor_han
288288
| ------ | ------ | ----------- |
289289
| `sensor_handle` | *ocre_sensor_handle_t* | Handle of the sensor |
290290
| `channel` | *sensor_channel_t* | The specific channel (e.g., `SENSOR_CHANNEL_TEMPERATURE`) from which the trigger should be removed |
291-
| `subscription_id` | *int* | ID of the subscription to remove |
291+
| `subscription_id` | *int* | `ID` of the subscription to remove |
292292
293293
**Returns**:
294294
@@ -463,6 +463,6 @@ int main() {
463463
| [`ocre_sensors_open`](#open-sensor) | Opens sensor | `sensor_handle`: Sensor to open | Status code | `SENSOR_API_STATUS_OK`,<br/>`SENSOR_API_STATUS_ERROR` |
464464
| [`sensor_read_sample`](#read-sensor-sample) | Reads sensor data | `sensor_handle`: Sensor to read from | `ocre_sensors_sample_t` structure | N/A |
465465
| [`sensor_get_channel`](#get-sensor-channel) | Gets channel data | `sample`: Sensor sample<br/>`channel`: Channel to retrieve | `ocre_sensor_value_t` structure | N/A |
466-
| [`ocre_sensors_set_trigger`](#set-sensor-trigger) | Sets sensor trigger | `sensor_handle`: Target sensor<br/>`channel`: Target channel<br/>`trigger_type`: Trigger type<br/>`callback`: Callback function<br/>`subscription_id`: ID output | Status code | `SENSOR_API_STATUS_OK`,<br/>`SENSOR_API_STATUS_ERROR` |
466+
| [`ocre_sensors_set_trigger`](#set-sensor-trigger) | Sets sensor trigger | `sensor_handle`: Target sensor<br/>`channel`: Target channel<br/>`trigger_type`: Trigger type<br/>`callback`: Callback function<br/>`subscription_id`: `ID` output | Status code | `SENSOR_API_STATUS_OK`,<br/>`SENSOR_API_STATUS_ERROR` |
467467
| [`ocre_sensors_clear_trigger`](#clear-sensor-trigger) | Removes sensor trigger | `sensor_handle`: Target sensor<br/>`channel`: Target channel<br/>`subscription_id`: Subscription to remove | Status code | `SENSOR_API_STATUS_OK`,<br/>`SENSOR_API_STATUS_ERROR` |
468-
| [`ocre_sensors_cleanup`](#clean-up-sensor-environment) | Cleans up resources | None | Status code | `SENSOR_API_STATUS_OK`,<br/>`SENSOR_API_STATUS_ERROR` |
468+
| [`ocre_sensors_cleanup`](#clean-up-sensor-environment) | Cleans up resources | None | Status code | `SENSOR_API_STATUS_OK`,<br/>`SENSOR_API_STATUS_ERROR` |

docs/reference/container-api/timers.md renamed to docs/reference/apis/container-api/timers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Timers
33
layout: default
4-
parent: Container APIs
4+
parent: Container
55
---
66

77
# Timers

docs/reference/apis/index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: APIs
3+
layout: default
4+
parent: Reference
5+
has_toc: false
6+
---
7+
8+
# APIs
9+
10+
This page provides an overview of the Application Programming Interfaces (APIs) available in the Ocre platform. These APIs allow developers to interact with various features of the Ocre runtime and create containerized applications.
11+
12+
---
13+
14+
## Overview
15+
16+
Ocre provides *two* primary categories of APIs:
17+
18+
1. **[Container APIs:](../apis/container-api)** APIs that are accessible from within containers and allow applications to interact with hardware, timers, and other system resources. These are designed for application developers building solutions that will run within Ocre containers.
19+
20+
2. **[Runtime API:](../apis/runtime-api)** The API for managing the Ocre runtime environment itself, including container lifecycle operations. The Runtime API is intended for system implementors and integrators looking to incorporate the Ocre runtime into their own solutions.
21+
22+
23+
---
24+
25+
## Next Steps
26+
27+
Check out some of the the [Sample Applications](../../samples) for practical examples using these APIs

0 commit comments

Comments
 (0)