Skip to content

Commit 13ee5c9

Browse files
committed
Remove complex Eslov interface activation and simplify code
This method works only if Wire slave thread stack is freed when deleted (ArduinoCore-mbed PR #375)
1 parent 8c91fa9 commit 13ee5c9

File tree

3 files changed

+1
-32
lines changed

3 files changed

+1
-32
lines changed

src/EslovHandler.cpp

+1-30
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ EslovHandler::~EslovHandler()
2020

2121
bool EslovHandler::begin(bool passthrough)
2222
{
23-
pinMode(_eslovIntPin, OUTPUT);
24-
digitalWrite(_eslovIntPin, LOW);
25-
23+
pinMode(_eslovIntPin, INPUT);
2624
Wire.begin();
2725
Wire.setClock(400000);
2826
if (passthrough) {
@@ -40,16 +38,12 @@ void EslovHandler::update()
4038
if (_rxBuffer[0] == HOST_DFU_EXTERNAL_OPCODE || _rxBuffer[0] == HOST_DFU_INTERNAL_OPCODE) {
4139
if (_rxIndex == sizeof(DFUPacket) + 1) {
4240

43-
toggleEslovIntPin();
44-
4541
if (!_dfuLedOn) {
4642
pinMode(LED_BUILTIN, OUTPUT);
4743
digitalWrite(LED_BUILTIN, HIGH);
4844
flushWire();
4945
}
5046

51-
pinMode(_eslovIntPin, INPUT);
52-
5347
//Wait for Nicla to set _eslovIntPin HIGH, meaning that is ready to receive
5448
while(!digitalRead(_eslovIntPin)) {
5549
if (_debug) _debug->println("Waiting for Eslov Int pin to be released");
@@ -123,7 +117,6 @@ void EslovHandler::update()
123117
} else if (_rxBuffer[0] == HOST_CONFIG_SENSOR_OPCODE) {
124118
if (_rxIndex == sizeof(SensorConfigurationPacket) + 1) {
125119

126-
toggleEslovIntPin();
127120
SensorConfigurationPacket* config = (SensorConfigurationPacket*)&_rxBuffer[1];
128121
if (_debug) {
129122
_debug->print("received config: ");
@@ -276,28 +269,6 @@ bool EslovHandler::requestSensorLongData(SensorLongDataPacket &sData)
276269
return true;
277270
}
278271

279-
void EslovHandler::toggleEslovIntPin()
280-
{
281-
if (!_intPinAsserted) {
282-
// Indicates eslov presence
283-
pinMode(_eslovIntPin, OUTPUT);
284-
digitalWrite(_eslovIntPin, LOW);
285-
_intPinAsserted = true;
286-
if (_debug) {
287-
_debug->println("Eslov int LOW");
288-
}
289-
//Use 1 sec delay to let Nicla see the LOW pin and enable Eslov
290-
delay(500);
291-
292-
digitalWrite(_eslovIntPin, HIGH);
293-
_intPinCleared = true;
294-
if (_debug) {
295-
_debug->println("Eslov int pin cleared");
296-
}
297-
delay(500);
298-
}
299-
}
300-
301272
void EslovHandler::niclaAsShield()
302273
{
303274
_eslovIntPin = I2C_INT_PIN;

src/EslovHandler.h

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class EslovHandler {
5454
uint8_t requestAvailableLongData();
5555
bool requestSensorData(SensorDataPacket &sData);
5656
bool requestSensorLongData(SensorLongDataPacket &sData);
57-
void toggleEslovIntPin();
5857

5958
protected:
6059
void niclaAsShield();

src/sensors/SensorClass.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ void SensorClass::configure(float rate, uint32_t latency)
3838
if (BHY2Host.getNiclaConnection() == NICLA_VIA_BLE) {
3939
BHY2Host.configureSensor(config);
4040
} else {
41-
eslovHandler.toggleEslovIntPin();
4241
uint8_t ack = 0;
4342
while(ack != 15) {
4443
BHY2Host.configureSensor(config);

0 commit comments

Comments
 (0)