Skip to content

Commit f9e4564

Browse files
committed
Be more specific with BHY2Host and ESLOV Handler
1 parent 9f09121 commit f9e4564

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed

src/Arduino_BHY2Host.h

+25-22
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ class Arduino_BHY2Host {
4545

4646
// Necessary API. Update function should be continuously polled if PASSTHORUGH is ENABLED
4747
/**
48-
* @brief Initialise the BHY2 functionality on the host board, for a given @ref NiclaWiring configuration.
48+
* @brief Establishes a connection with the client (Nicla Sense ME) using the given type of communication (ESLOV/BLE/As shield).
4949
*
5050
* @note When called without input parameters, I2C communication is over ESLOV by default.
5151
*
5252
* @param passthrough Define passthrough state. Disabled by default
53-
* @param NiclaWiring Defining I2C configuration (NICLA_VIA_ESLOV, NICLA_AS_SHIELD or NICLA_VIA_BLE). @see NiclaWiring
53+
* @param niclaConnection Defining I2C configuration (NICLA_VIA_ESLOV, NICLA_AS_SHIELD or NICLA_VIA_BLE). @see NiclaWiring
5454
*
5555
* Configuring for operation as a Shield:
5656
* @code
@@ -59,17 +59,21 @@ class Arduino_BHY2Host {
5959
*/
6060
bool begin(bool passthrough = false, NiclaWiring niclaConnection = NICLA_VIA_ESLOV);
6161
/**
62-
* @brief Update sensor data by reading the FIFO buffer on the BHI260 and then pass it to a suitable parser.
62+
* @brief Requests new sensor data from the client (Nicla Sense ME) and saves it locally so it can be retrieved via `Sensor` objects.
6363
*
6464
* @param ms (optional) Time (in milliseconds) to wait before returning data.
6565
*/
6666
void update();
67+
/**
68+
* @brief Requests new sensor data from the client (Nicla Sense ME) and saves it locally so it can be retrieved via `Sensor` objects. The Nicla Sense ME's sensors are then put to sleep for the given amount of milliseconds.
69+
*
70+
* @param ms (optional) time to set Nicla Sense ME to sleep in milliseconds
71+
*/
6772
void update(unsigned long ms); // Update and then sleep
6873

6974
// Functions for controlling the BHY when PASSTHROUGH is DISABLED
7075
/**
71-
* @brief Configure a virtual sensor on the BHI260 to have a set sample rate (Hz) and latency (milliseconds)
72-
* This can be achieved
76+
* @brief Configures a sensor to be read using a given sample rate and latency. The configuration is packaged up in a `SensorConfigurationPacket` object.
7377
*
7478
* @param config Instance of @see SensorConfigurationPacket class, with sensorID, sampleRate and latency
7579
*
@@ -90,52 +94,51 @@ class Arduino_BHY2Host {
9094
*/
9195
void configureSensor(SensorConfigurationPacket& config);
9296
void configureSensor(uint8_t sensorId, float sampleRate, uint32_t latency);
97+
/**
98+
* @brief Recieve acknowledgement from Nicla board over ESLOV
99+
*
100+
* @return uint8_t One byte of data read from the I2C bus.
101+
*/
93102
uint8_t requestAck();
94103
/**
95104
* @brief Return available sensor data within the FIFO buffer queue
96105
*
97-
* @return uint8_t The amount of data in bytes
106+
* @return uint8_t Amount of bytes.
98107
*/
99108
uint8_t availableSensorData();
100109
/**
101110
* @brief Return available long sensor data within the FIFO buffer queue
102111
*
103-
* @return uint8_t The amount of data in bytes
112+
* @return uint8_t Returns the amount of 16 bit chunks of the available sensor data.
104113
*/
105114
uint8_t availableSensorLongData();
106115
/**
107116
* @brief Read sensor data from the top element of the queue
108117
*
109-
* @param data Structure including sensorID, sampleRate and latency
118+
* @param data SensorDataPacket object including SensorID, size, and data payload
110119
*/
111120
bool readSensorData(SensorDataPacket &data);
112121
/**
113122
* @brief Read long sensor data from the top element of the queue
114123
*
115-
* @param data Structure including sensorID, sampleRate and latency
124+
* @param data SensorDataPacket object including SensorID, size , and data payload
116125
*/
117126
bool readSensorLongData(SensorLongDataPacket &data);
118127
/**
119-
* @brief Parse XYZ Cartesian data from a given data packet
128+
* @brief Parse XYZ Cartesian data from `SensorDataPacket` and store within `DataXYZ` vector
120129
*
121-
* @param data data packet including SensorID
122-
* @param vector vector with XYZ
130+
* @param data SensorDataPacket object including SensorID, size, and data payload
131+
* @param vector DataXYZ vector with XYZ values stores as int16_t
123132
*/
124133
void parse(SensorDataPacket& data, DataXYZ& vector);
125134
/**
126-
* @brief Parse orientation from a given data packet
135+
* @brief Parse orientation data from `SensorDataPacket` and store within `DataOrientation` vector. Optional argument for scale factor
127136
*
128-
* @param data Data packet including SensorID
129-
* @param vector Vector with heading, pitch and roll
137+
* @param data SensorDataPacket object including SensorID, size, and data payload
138+
* @param vector DataOrientation vector with heading, pitch and roll stored as float
139+
* @param scaleFactor (optional) scale factor for vector. Defined by format "Euler". See section 15.1.2 in datasheet.
130140
*/
131141
void parse(SensorDataPacket& data, DataOrientation& vector);
132-
/**
133-
* @brief Parse orientation with scale factor
134-
*
135-
* @param data Data packet including SensorID
136-
* @param vector Vector with heading, pitch and roll
137-
* @param scaleFactor scale factor for vector
138-
*/
139142
void parse(SensorDataPacket& data, DataOrientation& vector, float scaleFactor);
140143

141144
NiclaWiring getNiclaConnection();

src/EslovHandler.h

+9-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define I2C_INT_PIN (0)
1515

1616
/**
17-
* @brief Enumerator for ESLOV operational state
17+
* @brief Enumerator for ESLOV operational state. Defines what state the I2C protocol of the ESLOV device should be in. Used to set DFU (Device Firmware Update) mode in the ANNA-B112 and BHY260 of the Nicla Sense ME.
1818
*
1919
*/
2020
enum EslovOpcode {
@@ -24,6 +24,10 @@ enum EslovOpcode {
2424
ESLOV_SENSOR_STATE_OPCODE /*!< ESLOV Sensor State */
2525
};
2626

27+
/**
28+
* @brief Enumeration for the host device operational status.
29+
*
30+
*/
2731
enum HostOpcode {
2832
HOST_DFU_INTERNAL_OPCODE = ESLOV_DFU_INTERNAL_OPCODE,
2933
HOST_DFU_EXTERNAL_OPCODE = ESLOV_DFU_EXTERNAL_OPCODE,
@@ -66,16 +70,16 @@ class EslovHandler {
6670
*/
6771
void update();
6872
/**
69-
* @brief Write a DFU (Device Firmware Update) packet to the Nicla Board over ESLOV
73+
* @brief Write a DFU (Device Firmware Update) packet to the Nicla Board over ESLOV. On the last packet, the built-in LED is pulled down.
7074
*
71-
* @param data pointer to data to be uploaded to Nicla board (uint8_t)
72-
* @param length length of the data to be written to the Nicla in bytes (int)
75+
* @param data pointer to data to be uploaded to Nicla board as a byte array
76+
* @param length amount of data to be written to the Nicla in bytes (int)
7377
*/
7478
void writeDfuPacket(uint8_t *data, uint8_t length);
7579
/**
7680
* @brief Waits for the ESLOV interrupt pin to be pulled high, then sends a packet with the @see ESLOV_SENSOR_STATE_OPCODE to over I2C
7781
*
78-
* @param state enumeration of EslovState to be written over ESLOV to the Nicla
82+
* @param state State value sent to Nicla Sense ME based on @ref EslovState enumerator.
7983
*/
8084
void writeStateChange(EslovState state);
8185
/**

0 commit comments

Comments
 (0)