Exemplo n.º 1
0
bool aci_queue_peek_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
  ble_assert(NULL != aci_q);
  ble_assert(NULL != p_data);

  if (aci_queue_is_empty_from_isr(aci_q))
  {
    return false;
  }

  memcpy((uint8_t *)p_data, (uint8_t *)&(aci_q->aci_data[aci_q->head % ACI_QUEUE_SIZE]), sizeof(hal_aci_data_t));

  return true;
}
Exemplo n.º 2
0
bool aci_queue_dequeue(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
  ble_assert(NULL != aci_q);
  ble_assert(NULL != p_data);

  if (aci_queue_is_empty(aci_q))
  {
    return false;
  }

  memcpy((uint8_t *)p_data, (uint8_t *)&(aci_q->aci_data[aci_q->head]), sizeof(hal_aci_data_t));
  aci_q->head = (aci_q->head + 1) % ACI_QUEUE_SIZE;

  return true;
}
Exemplo n.º 3
0
bool aci_queue_is_full(aci_queue_t *aci_q)
{
  uint8_t next;
  bool state;

  ble_assert(NULL != aci_q);

  //This should be done in a critical section
  noInterrupts();
  next = (aci_q->tail + 1) % ACI_QUEUE_SIZE;

  if (next == aci_q->head)
  {
    state = true;
  }
  else
  {
    state = false;
  }

  interrupts();
  //end

  return state;
}
Exemplo n.º 4
0
bool aci_queue_is_full_from_isr(aci_queue_t *aci_q)
{
  const uint8_t next = (aci_q->tail + 1) % ACI_QUEUE_SIZE;

  ble_assert(NULL != aci_q);

  return next == aci_q->head;
}
Exemplo n.º 5
0
bool aci_queue_enqueue_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
  const uint8_t length = p_data->buffer[0];

  ble_assert(NULL != aci_q);
  ble_assert(NULL != p_data);

  if (aci_queue_is_full_from_isr(aci_q))
  {
    return false;
  }

  aci_q->aci_data[aci_q->tail % ACI_QUEUE_SIZE].status_byte = 0;
  memcpy((uint8_t *)&(aci_q->aci_data[aci_q->tail % ACI_QUEUE_SIZE].buffer[0]), (uint8_t *)&p_data->buffer[0], length + 1);
  ++aci_q->tail;

  return true;
}
Exemplo n.º 6
0
void aci_queue_init(aci_queue_t *aci_q)
{
  uint8_t loop;

  ble_assert(NULL != aci_q);

  aci_q->head = 0;
  aci_q->tail = 0;
  for(loop=0; loop<ACI_QUEUE_SIZE; loop++)
  {
    aci_q->aci_data[loop].buffer[0] = 0x00;
    aci_q->aci_data[loop].buffer[1] = 0x00;
  }
}
Exemplo n.º 7
0
bool aci_queue_is_full(aci_queue_t *aci_q)
{
  bool state;

  ble_assert(NULL != aci_q);

  //This should be done in a critical section
  noInterrupts();
  
  state = (aci_q->tail == aci_q->head + ACI_QUEUE_SIZE);

  interrupts();
  //end

  return state;
}
Exemplo n.º 8
0
bool aci_queue_is_empty(aci_queue_t *aci_q)
{
  bool state = false;

  ble_assert(NULL != aci_q);

  //Critical section
  noInterrupts();
  if (aci_q->head == aci_q->tail)
  {
    state = true;
  }
  interrupts();

  return state;
}
Exemplo n.º 9
0
bool aci_queue_is_empty(aci_queue_t *aci_q)
{
  bool state = false;

  ble_assert(NULL != aci_q);

  //Critical section
  __disable_irq();
  uint8_t head = aci_q->head;
  uint8_t tail = aci_q->tail;
  if (head == tail)
  {
    state = true;
  }
  __enable_irq();

  return state;
}
Exemplo n.º 10
0
bool aci_queue_is_full(aci_queue_t *aci_q)
{
  bool state = false;

  ble_assert(NULL != aci_q);

  //This should be done in a critical section
  __disable_irq();
  
  uint8_t tail = aci_q->tail;
  uint8_t head = aci_q->head;
  if(tail == (head + ACI_QUEUE_SIZE)) {
    state = true;
  }

  __enable_irq();
  //end

  return state;
}
bool aci_queue_is_full(aci_queue_t *aci_q)
{
  bool state;

  ble_assert(NULL != aci_q);

#ifdef HAL_ACI_TL_INTERRUPT
  //This should be done in a critical section
  noInterrupts();
#endif

  state = (aci_q->tail == aci_q->head + ACI_QUEUE_SIZE);

#ifdef HAL_ACI_TL_INTERRUPT
  interrupts();
  //end
#endif

  return state;
}
bool aci_queue_is_empty(aci_queue_t *aci_q)
{
  bool state = false;

  ble_assert(NULL != aci_q);

#ifdef HAL_ACI_TL_INTERRUPT
  //Critical section
  noInterrupts();
#endif
  if (aci_q->head == aci_q->tail)
  {
    state = true;
  }
#ifdef HAL_ACI_TL_INTERRUPT
  interrupts();
#endif

  return state;
}
Exemplo n.º 13
0
bool aci_queue_is_full_from_isr(aci_queue_t *aci_q)
{
  ble_assert(NULL != aci_q);

  return (aci_q->tail == (aci_q->head + ACI_QUEUE_SIZE));
}
Exemplo n.º 14
0
bool aci_queue_is_empty_from_isr(aci_queue_t *aci_q)
{
  ble_assert(NULL != aci_q);

  return aci_q->head == aci_q->tail;
}