SENT Adapter / SENT simulation
Simulating SENT communication from the miniHIL involves using a hardware timer paired with a DMA channel to output the correct SENT waveform. The miniHIL library contains a single channel SENT abstraction which handles timing calculation, sending and queueing of cyclic sent messages for a single slave.
The abstraction can be found in the SimModelLib in the following namespace minihil.platform.adapters.sent.
|
The api of the abstraction is not stabilized. There may be breaking changes in the future. |
|
The abstraction currently does not support slow channel communication, but the status nibble is exposed to the user. Therefore SENT slow channel communication can be implemented in the user application if needed. |
Usage example
|
Usually you would want to build a simulation actor which simulates a specific type of sensor which uses SENT. That Actor would use the sent abstraction. The examples here directly use cage to configure the SENT actor and to trigger sending of aperiodic messages. |
The model documentation can be found in the code and here.
Configuration from within cage
targetcode: ``
#include "minihil/platform/adapters/sent/ESentMode.h"
#include "minihil/platform/adapters/sent/ESentDataLength.h"
``
// [.....]
/* Tick length in us should be set between 3 and 90 us as required in the SENT specification */
Step configureSentActor(real tickLength_us, int fixedMessageLength_ticks):
timeout 10 ms
action
``
DSentConfig cfg;
cfg.tickLength_uS = tickLength_us;
cfg.fixedMessageLength_ticks = fixedMessageLength_ticks;
cfg.lowStretch_ticks = 0;
cfg.mode = ESentMode_DEFAULT;
``
sentCfg.config(``&cfg``)
reaction
expect sentCfg.configurationCpl
expect absent sentCfg.error
;
Sending a single SENT message from within cage
targetcode: ``
#include "minihil/platform/adapters/sent/ESentMode.h"
#include "minihil/platform/adapters/sent/ESentDataLength.h"
``
// [.....]
action
``
DSentData data;
data.status = 0;
data.data[0] = 0x12;
data.data[1] = 0x34;
data.data[2] = 0x56;
data.data[3] = 0x78;
data.dataLength = ESentDataLength_BITS_24;
``
sent.setSentData(``&data``)
reaction
expect sent.dataAccepted
reaction
// This message is received once the message has been passed to the DMA for sending.
// There is no send complete message. Since the duration for a sent message is deterministic (if tick duration and sent data are known)
// It is possible to time the end of the SENT message by waiting the known duration after the "transmissionStarted" message is received.
expect sent.transmissionStarted
Structure used in the examples above
ActorRef testActor: SENTTestActor
ActorRef sentSender: ASentAdapter_TIM16_PF6_DMA1S6
Binding testActor.sent and sentSender.fct
Binding testActor.sentCfg and sentSender.cfg