Esempio n. 1
0
// -----------------------------------------------------------------------------
// This function starts the specified data stream at the specified period. Note
// that this stream has to be renewed periodically by resending the request. If
// no renewing request is received, then the stream will time out after a while.
// Also note that the stream output period will be quantized to the main control
// frequency.
void SetMKDataStream(enum MKStream mk_stream, uint16_t period_10ms)
{
  mk_stream_ = mk_stream;

  uint16_t stream_period = period_10ms * 10;  // ms
  if (!stream_period_)
    stream_timer_ = GetTimestampMillisFromNow(0);  // Start stream immediately
  else if (stream_period < stream_period_)
    stream_timer_ = GetTimestampMillisFromNow(stream_period);
  stream_period_ = stream_period;
  stream_timeout_ = GetTimestampMillisFromNow(STREAM_TIMEOUT);
}
Esempio n. 2
0
// -----------------------------------------------------------------------------
// This function delays execution of the program for "t" ms. Functions triggered
// by interrupts will still execute during this period. This function works for
// time periods up to 32767 ms.
void Wait(uint16_t w)
{
  uint16_t timestamp = GetTimestampMillisFromNow(w);
  while (!TimestampInPast(timestamp));
}