Mercurial > public > ostc4
comparison Small_CPU/Src/externalInterface.c @ 1081:1b38d7b8da35 Icon_Integration
Send sensor data cyclic:
In the previous version the sensor data which had been updated at last was send to the main CPU. With the introduction of the hud a second device is sending sensor data information => in case of fast sensor data updated it could happen that a sensor data record was never transmitted. To avoid this the sensor data of all sensor slots is now transmitted on a cyclic basis.
| author | Ideenmodellierer |
|---|---|
| date | Sun, 15 Mar 2026 21:28:53 +0100 |
| parents | b02311fbb1e1 |
| children |
comparison
equal
deleted
inserted
replaced
| 1080:b02311fbb1e1 | 1081:1b38d7b8da35 |
|---|---|
| 545 } | 545 } |
| 546 } | 546 } |
| 547 | 547 |
| 548 uint8_t externalInterface_GetSensorData(uint8_t sensorId, uint8_t* pDataStruct) | 548 uint8_t externalInterface_GetSensorData(uint8_t sensorId, uint8_t* pDataStruct) |
| 549 { | 549 { |
| 550 static uint8_t cyclingSensorId = 0; | |
| 550 uint8_t index = 0; | 551 uint8_t index = 0; |
| 551 uint8_t localId = sensorId; | 552 uint8_t localId = sensorId; |
| 552 if(localId == 0xFF) | 553 if(localId == 0xFF) |
| 553 { | 554 { |
| 554 localId = lastSensorDataId; | 555 if(lastSensorDataId != 0xFF) |
| 556 { | |
| 557 localId = lastSensorDataId; | |
| 558 lastSensorDataId = 0xFF; | |
| 559 } | |
| 560 else | |
| 561 { | |
| 562 localId = cyclingSensorId; | |
| 563 cyclingSensorId++; | |
| 564 if(cyclingSensorId == EXT_INTERFACE_SENSOR_CNT) | |
| 565 { | |
| 566 cyclingSensorId = 0; | |
| 567 } | |
| 568 } | |
| 555 } | 569 } |
| 556 | 570 |
| 557 if((pDataStruct != NULL) && (localId <= EXT_INTERFACE_SENSOR_CNT)) | 571 if((pDataStruct != NULL) && (localId <= EXT_INTERFACE_SENSOR_CNT)) |
| 558 { | 572 { |
| 559 externalInterface_CopySensorData(localId, pDataStruct, &sensorData[localId][0]); | 573 externalInterface_CopySensorData(localId, pDataStruct, &sensorData[localId][0]); |
| 574 } | 588 } |
| 575 | 589 |
| 576 return localId; | 590 return localId; |
| 577 } | 591 } |
| 578 | 592 |
| 593 void externalInterface_ResetSensorData(uint8_t sensorId) | |
| 594 { | |
| 595 if(sensorId < EXT_INTERFACE_SENSOR_CNT) | |
| 596 { | |
| 597 memset(&sensorData[sensorId],0,EXTIF_SENSOR_INFO_SIZE); | |
| 598 } | |
| 599 } | |
| 579 void externalInterface_SetSensorData(uint8_t sensorId, uint8_t* pDataStruct) | 600 void externalInterface_SetSensorData(uint8_t sensorId, uint8_t* pDataStruct) |
| 580 { | 601 { |
| 581 uint8_t index = 0; | 602 uint8_t index = 0; |
| 582 | 603 |
| 583 if(pDataStruct != NULL) | 604 if((pDataStruct != NULL) && (sensorId < EXT_INTERFACE_SENSOR_CNT)) |
| 584 { | 605 { |
| 585 if((sensorId != 0xFF) && (sensorId < EXT_INTERFACE_SENSOR_CNT)) | 606 externalInterface_CopySensorData(sensorId, &sensorData[sensorId][0], pDataStruct); |
| 586 { | 607 lastSensorDataId = sensorId; |
| 587 externalInterface_CopySensorData(sensorId, &sensorData[sensorId][0], pDataStruct); | 608 if(sensorId >= MAX_ADC_CHANNEL) |
| 588 lastSensorDataId = sensorId; | 609 { |
| 589 if(sensorId >= MAX_ADC_CHANNEL) | 610 for(index = 0; index < MAX_ADC_CHANNEL; index++) |
| 590 { | 611 { |
| 591 for(index = 0; index < MAX_ADC_CHANNEL; index++) | 612 if(Mux2ADCMap[index] == sensorId) |
| 592 { | 613 { |
| 593 if(Mux2ADCMap[index] == sensorId) | 614 externalInterface_CopySensorData(index, &sensorData[index][0], pDataStruct); |
| 594 { | 615 lastSensorDataId = index; |
| 595 externalInterface_CopySensorData(index, &sensorData[index][0], pDataStruct); | 616 break; |
| 596 lastSensorDataId = index; | |
| 597 break; | |
| 598 } | |
| 599 } | 617 } |
| 600 } | 618 } |
| 601 } | |
| 602 else | |
| 603 { | |
| 604 memset(&sensorData,0,EXTIF_SENSOR_INFO_SIZE * EXT_INTERFACE_SENSOR_CNT); | |
| 605 lastSensorDataId = 0xFF; | |
| 606 } | 619 } |
| 607 } | 620 } |
| 608 } | 621 } |
| 609 | 622 |
| 610 void externalInface_SetSensorMap(uint8_t* pMap) | 623 void externalInface_SetSensorMap(uint8_t* pMap) |
