Exemple #1
0
bool hal_aci_tl_send(hal_aci_data_t *p_aci_cmd)
{
  const uint8_t length = p_aci_cmd->buffer[0];
  bool ret_val = false;

  if (length > HAL_ACI_MAX_LENGTH)
  {
    return false;
  }
  else
  {
    if (m_aci_q_enqueue(&aci_tx_q, p_aci_cmd))
    {
      ret_val = true;
    }
  }

  if (true == aci_debug_print)
  {
    Serial.print("C");
    m_print_aci_data(p_aci_cmd);
  }
  
  digitalWrite(a_pins_local_ptr->reqn_pin, 0);
  return ret_val;
}
bool hal_aci_tl_send(hal_aci_data_t *p_aci_cmd)
{
  const uint8_t length = p_aci_cmd->buffer[0];
  bool ret_val = false;

  if (length > HAL_ACI_MAX_LENGTH)
  {
    return false;
  }
  else
  {
    if (m_aci_q_enqueue(&aci_tx_q, p_aci_cmd))
    {
      ret_val = true;
    }
  }

  if (true == aci_debug_print)
  {
    Serial.print("C");
    m_print_aci_data(p_aci_cmd);
  }
  
  HAL_IO_SET_STATE(HAL_IO_RADIO_REQN, 0);
  return ret_val;
}
Exemple #3
0
void m_rdy_line_handle(void)
{
  hal_aci_data_t *p_aci_data;
  
  if (true == a_pins_local_ptr->interface_is_interrupt)
  {
    detachInterrupt(a_pins_local_ptr->interrupt_number);
  }
  
  // Receive or transmit data
  p_aci_data = hal_aci_tl_poll_get();
  
  // Check if we received data
  if (p_aci_data->buffer[0] > 0)
  {
    if (!m_aci_q_enqueue(&aci_rx_q, p_aci_data))
    {
      /* Receive Buffer full.
         Should never happen.
         Spin in a while loop.
         */	  
       while(1);
    }
    if (m_aci_q_is_full(&aci_rx_q))
    {
      /* Disable RDY line interrupt.
         Will latch any pending RDY lines, so when enabled it again this
         routine should be taken again */
	  if (true == a_pins_local_ptr->interface_is_interrupt)
	  {
		//EIMSK &= ~(0x2); //AVR Specific - PIC32,DUE,STM32 todo
	  }
    }    
  }
}
void m_rdy_line_handle(void)
{
  hal_aci_data_t *p_aci_data;
  
  sleep_disable();
  detachInterrupt(1);
  
  // Receive or transmit data
  p_aci_data = hal_aci_tl_poll_get();
  
  // Check if we received data
  if (p_aci_data->buffer[0] > 0)
  {
    if (!m_aci_q_enqueue(&aci_rx_q, p_aci_data))
    {
      /* Receive Buffer full.
         Should never happen.
         Spin in a while loop.
         */
       while(1);
    }
    if (m_aci_q_is_full(&aci_rx_q))
    {
      /* Disable RDY line interrupt.
         Will latch any pending RDY lines, so when enabled it again this
         routine should be taken again */
      toggle_eimsk(false);
    }    
  }
}
Exemple #5
0
void lib_aci_board_init(aci_state_t *aci_stat)
{
	hal_aci_evt_t *aci_data = NULL;
	aci_data = (hal_aci_evt_t *)&msg_to_send;
					
	if (REDBEARLAB_SHIELD_V1_1 == aci_stat->aci_pins.board_name)
	{
	  /*
	  The Bluetooth low energy Arduino shield v1.1 requires about 100ms to reset.
	  This is not required for the nRF2740, nRF2741 modules
	  */
	  delay(100);
  
	  /*
	  Send the soft reset command to the nRF8001 to get the nRF8001 to a known state.
	  */
	  lib_aci_radio_reset();
  
	  while (1)
	  {
		/*Wait for the command response of the radio reset command.
		as the nRF8001 will be in either SETUP or STANDBY after the ACI Reset Radio is processed
		*/

			
		if (true == lib_aci_event_get(aci_stat, aci_data))
		{
		  aci_evt_t * aci_evt;      
		  aci_evt = &(aci_data->evt);
	  
		  if (ACI_EVT_CMD_RSP == aci_evt->evt_opcode)
		  {
				if (ACI_STATUS_ERROR_DEVICE_STATE_INVALID == aci_evt->params.cmd_rsp.cmd_status) //in SETUP
				{
					//Inject a Device Started Event Setup to the ACI Event Queue
					msg_to_send.buffer[0] = 4;    //Length
					msg_to_send.buffer[1] = 0x81; //Device Started Event
					msg_to_send.buffer[2] = 0x02; //Setup
					msg_to_send.buffer[3] = 0;    //Hardware Error -> None
					msg_to_send.buffer[4] = 2;    //Data Credit Available
					m_aci_q_enqueue(&aci_rx_q, &msg_to_send);            
				}
				else if (ACI_STATUS_SUCCESS == aci_evt->params.cmd_rsp.cmd_status) //We are now in STANDBY
				{
					//Inject a Device Started Event Standby to the ACI Event Queue
					msg_to_send.buffer[0] = 4;    //Length
					msg_to_send.buffer[1] = 0x81; //Device Started Event
					msg_to_send.buffer[2] = 0x03; //Standby
					msg_to_send.buffer[3] = 0;    //Hardware Error -> None
					msg_to_send.buffer[4] = 2;    //Data Credit Available
					m_aci_q_enqueue(&aci_rx_q, &msg_to_send);            
				}
				else if (ACI_STATUS_ERROR_CMD_UNKNOWN == aci_evt->params.cmd_rsp.cmd_status) //We are now in TEST
				{
					//Inject a Device Started Event Standby to the ACI Event Queue
					msg_to_send.buffer[0] = 4;    //Length
					msg_to_send.buffer[1] = 0x81; //Device Started Event
					msg_to_send.buffer[2] = 0x01; //Test
					msg_to_send.buffer[3] = 0;    //Hardware Error -> None
					msg_to_send.buffer[4] = 0;    //Data Credit Available
					m_aci_q_enqueue(&aci_rx_q, &msg_to_send);
				}
				
				//Break out of the while loop
				break;
		  }
		  else
		  {			
			//Serial.println(F("Discard any other ACI Events"));
		  }
	  
		}
	  }		
	}
}