/*
Description:

<Add description of the proximity application.

The ACI Evt Data Credit provides the radio level ack of a transmitted packet.
*/
void setup(void)
{ 
  Serial.begin(9600);
  Serial.println(F("Arduino setup"));
  
  Counter = BUZZER_OFF;
  
  /**
  Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001
  */   
  if (NULL != services_pipe_type_mapping)
  {
    aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
  }
  else
  {
    aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
  }
  aci_state.aci_setup_info.number_of_pipes    = NUMBER_OF_PIPES;
  aci_state.aci_setup_info.setup_msgs         = setup_msgs;
  aci_state.aci_setup_info.num_setup_msgs     = NB_SETUP_MESSAGES;

	//Tell the ACI library, the MCU to nRF8001 pin connections
	aci_state.aci_pins.board_name = REDBEARLAB_SHIELD_V1_1; //See board.h for details
	aci_state.aci_pins.reqn_pin   = 9;
	aci_state.aci_pins.rdyn_pin   = 8;
	aci_state.aci_pins.mosi_pin   = MOSI;
	aci_state.aci_pins.miso_pin   = MISO;
	aci_state.aci_pins.sck_pin    = SCK;
	
	aci_state.aci_pins.spi_clock_divider     = SPI_CLOCK_DIV8;
	  
	aci_state.aci_pins.reset_pin             = UNUSED;
	aci_state.aci_pins.active_pin            = UNUSED;
	aci_state.aci_pins.optional_chip_sel_pin = UNUSED;
	  
	aci_state.aci_pins.interface_is_interrupt	  = false;
	aci_state.aci_pins.interrupt_number			  = UNUSED;
  
  //We reset the nRF8001 here by toggling the RESET line connected to the nRF8001
  //and initialize the data structures required to setup the nRF8001
  lib_aci_init(&aci_state);
  aci_state.bonded = ACI_BOND_STATUS_FAILED;
  
//  pinMode(8, OUTPUT);
//  pinMode(8, LOW);

  pinMode(3, OUTPUT);//buzzer

  pinMode(6, INPUT); //Pin #6 on Arduino -> PAIRING CLEAR pin: Connect to 3.3v to clear the pairing
  if (0x01 == digitalRead(6))
  {
    //Clear the pairing
    Serial.println(F("Pairing/Bonding info cleared from EEPROM."));
    Serial.println(F("Remove the wire on Pin 6 and reset the board for normal operation."));
    //Address. Value
    EEPROM.write(0, 0);
    while(1) {};
  }  
}
bool Adafruit_BLE_UART::begin(uint16_t advTimeout, uint16_t advInterval) 
{
  /* Store the advertising timeout and interval */
  adv_timeout = advTimeout;   /* ToDo: Check range! */
  adv_interval = advInterval; /* ToDo: Check range! */
  
  /* Setup the service data from nRFGo Studio (services.h) */
  if (NULL != services_pipe_type_mapping)
  {
    aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
  }
  else
  {
    aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
  }
  aci_state.aci_setup_info.number_of_pipes    = NUMBER_OF_PIPES;
  aci_state.aci_setup_info.setup_msgs         = (hal_aci_data_t*)setup_msgs;
  aci_state.aci_setup_info.num_setup_msgs     = NB_SETUP_MESSAGES;

  /* Pass the service data into the appropriate struct in the ACI */
  lib_aci_init(&aci_state);

  /* ToDo: Check for chip ID to make sure we're connected! */
  
  return true;
}
Esempio n. 3
0
void nrf8001_usart_setup(bool debug) {
  aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
  aci_state.aci_setup_info.number_of_pipes    = NUMBER_OF_PIPES;
  aci_state.aci_setup_info.setup_msgs         = (hal_aci_data_t*)setup_msgs;
  aci_state.aci_setup_info.num_setup_msgs     = NB_SETUP_MESSAGES;

  lib_aci_init(&aci_state, debug);
}
Esempio n. 4
0
void ble_begin()
{
    	spi_old = SPCR;
    	SPI.setBitOrder(LSBFIRST);
    	SPI.setClockDivider(SPI_CLOCK_DIV8);
    	SPI.setDataMode(SPI_MODE0);

	/* Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001 */   
	if (NULL != services_pipe_type_mapping)
	{
			aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
	}
	else
	{
			aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
	}
	aci_state.aci_setup_info.number_of_pipes    = NUMBER_OF_PIPES;
	aci_state.aci_setup_info.setup_msgs         = setup_msgs;
	aci_state.aci_setup_info.num_setup_msgs     = NB_SETUP_MESSAGES;

	/*
		Tell the ACI library, the MCU to nRF8001 pin connections.
		The Active pin is optional and can be marked UNUSED
	*/	  	
	aci_state.aci_pins.board_name = REDBEARLAB_SHIELD_V1_1; //See board.h for details
	aci_state.aci_pins.reqn_pin   = reqn_pin;
	aci_state.aci_pins.rdyn_pin   = rdyn_pin;
	aci_state.aci_pins.mosi_pin   = MOSI;
	aci_state.aci_pins.miso_pin   = MISO;
	aci_state.aci_pins.sck_pin    = SCK;
	
#if defined(__SAM3X8E__)
	aci_state.aci_pins.spi_clock_divider     = 84;
#else
	aci_state.aci_pins.spi_clock_divider     = SPI_CLOCK_DIV8;
#endif
	  
	aci_state.aci_pins.reset_pin             = UNUSED;
	aci_state.aci_pins.active_pin            = UNUSED;
	aci_state.aci_pins.optional_chip_sel_pin = UNUSED;
	  
	aci_state.aci_pins.interface_is_interrupt	  = false;
	aci_state.aci_pins.interrupt_number			  = 1;

	//Turn debug printing on for the ACI Commands and Events to be printed on the Serial
	lib_aci_debug_print(true);

	/*
		We reset the nRF8001 here by toggling the RESET line connected to the nRF8001
		and initialize the data structures required to setup the nRF8001
	*/
	lib_aci_init(&aci_state); 
	delay(100);

	SPCR = spi_old;
	SPI.begin();
}
/**************************************************************************
 *
 *   Configures the nRF8001 and starts advertising the service
 *
 *   @param[in]  advTimeout
 *               The advertising timeout in seconds
 *               (0 = infinite advertising).
 *   @param[in]  advInterval
 *               The delay between advertising packets in 0.625ms units
 *               (1600 = 1 second).
 *
 **************************************************************************/
bool GoosciBleGatt::begin(int advTimeout, int advInterval) {
  // Store the advertising timeout and interval
  // TODO(nmai): check for valid ranges.
  adTimeout = advTimeout;
  adInterval = advInterval;

  // Setup the service data from nRFGo Studio (services.h)
  if (NULL != services_pipe_type_mapping) {
    aci_state.aci_setup_info.services_pipe_type_mapping =
        &services_pipe_type_mapping[0];
  } else {
    aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
  }

  aci_state.aci_setup_info.number_of_pipes = NUMBER_OF_PIPES;
  aci_state.aci_setup_info.setup_msgs = (hal_aci_data_t *)setup_msgs;
  aci_state.aci_setup_info.num_setup_msgs = NB_SETUP_MESSAGES;

  // Setup the nRF8001 pins.
  aci_state.aci_pins.board_name = BOARD_DEFAULT;
  aci_state.aci_pins.reqn_pin = _REQ;
  aci_state.aci_pins.rdyn_pin = _RDY;
  aci_state.aci_pins.mosi_pin = MOSI;
  aci_state.aci_pins.miso_pin = MISO;
  aci_state.aci_pins.sck_pin = SCK;

  // SPI_CLOCK_DIV8  = 2MHz SPI speed.
  aci_state.aci_pins.spi_clock_divider = SPI_CLOCK_DIV8;

  // The Active pin is optional and can be marked UNUSED.
  aci_state.aci_pins.reset_pin = _RST;
  aci_state.aci_pins.active_pin = UNUSED;
  aci_state.aci_pins.optional_chip_sel_pin = UNUSED;

  // Interrupts still not available in Chipkit.
  aci_state.aci_pins.interface_is_interrupt = false;
  aci_state.aci_pins.interrupt_number = 1;

  // The second parameter is for turning debug printing on
  // for the ACI Commands and Events so they be printed on the Serial
  lib_aci_init(&aci_state, false);

  // Get the device address
  lib_aci_get_address();
  // Wait for the get address response
  addrReceived = false;
  while (!addrReceived) {
    pollACI();
  }

  return true;
}
void nRF8001BleUartSetup(uint8_t pin_mosi, uint8_t pin_miso, uint8_t pin_sck, uint8_t pin_reqn, uint8_t pin_rdyn, uint8_t pin_reset)
{
	Serial.println(F("Spark Core Setup"));
	Serial.println(F("Set line ending to newline to send data from the serial monitor"));

  /**
  Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001
  */
  if (NULL != services_pipe_type_mapping)
  {
    aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
  }
  else
  {
    aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
  }
  aci_state.aci_setup_info.number_of_pipes    = NUMBER_OF_PIPES;
  aci_state.aci_setup_info.setup_msgs         = (hal_aci_data_t*) setup_msgs;
  aci_state.aci_setup_info.num_setup_msgs     = NB_SETUP_MESSAGES;

  /*
  Tell the ACI library, the MCU to nRF8001 pin connections.
  The Active pin is optional and can be marked NRF_UNUSED
  */
  aci_state.aci_pins.board_name = BOARD_DEFAULT; //See board.h for details 
  aci_state.aci_pins.mosi_pin   = pin_mosi;
  aci_state.aci_pins.miso_pin   = pin_miso;
  aci_state.aci_pins.reqn_pin   = pin_reqn; 
  aci_state.aci_pins.rdyn_pin   = pin_rdyn; 
  aci_state.aci_pins.sck_pin    = pin_sck;
  aci_state.aci_pins.reset_pin  = pin_reset;

  aci_state.aci_pins.spi_clock_divider      = SPI_CLOCK_DIV8;//SPI_CLOCK_DIV8  = 2MHz SPI speed
                                                             //SPI_CLOCK_DIV16 = 1MHz SPI speed
  
  aci_state.aci_pins.active_pin             = NRF_UNUSED;
  aci_state.aci_pins.optional_chip_sel_pin  = SS;

  aci_state.aci_pins.interface_is_interrupt = false; //Interrupts still not available in Spark Core
  aci_state.aci_pins.interrupt_number       = 1;

  //We reset the nRF8001 here by toggling the RESET line connected to the nRF8001
  //If the RESET line is not available we call the ACI Radio Reset to soft reset the nRF8001
  //then we initialize the data structures required to setup the nRF8001
  //The second parameter is for turning debug printing on for the ACI Commands and Events so they be printed on the Serial
  lib_aci_init(&aci_state, false);
	
	Serial.println(F("SETUP DONE"));
}
bool Adafruit_BLE_UART::begin(uint16_t advTimeout, uint16_t advInterval) 
{
  Serial.println("Initializing UART service");
  /* Store the advertising timeout and interval */
  adv_timeout = advTimeout;   /* ToDo: Check range! */
  adv_interval = advInterval; /* ToDo: Check range! */
  
  /* Setup the service data from nRFGo Studio (services.h) */
  if (NULL != services_pipe_type_mapping)
  {
    aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
  }
  else
  {
    aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
  }
  aci_state.aci_setup_info.number_of_pipes    = NUMBER_OF_PIPES;
  aci_state.aci_setup_info.setup_msgs         = (hal_aci_data_t*)setup_msgs;
  aci_state.aci_setup_info.num_setup_msgs     = NB_SETUP_MESSAGES;

 /*
  Tell the ACI library, the MCU to nRF8001 pin connections.
  The Active pin is optional and can be marked UNUSED
  */
  aci_state.aci_pins.board_name = BOARD_DEFAULT; //See board.h for details REDBEARLAB_SHIELD_V1_1 or BOARD_DEFAULT
  aci_state.aci_pins.reqn_pin   = _REQ; //SS for Nordic board, 9 for REDBEARLAB_SHIELD_V1_1
  aci_state.aci_pins.rdyn_pin   = _RDY; //3 for Nordic board, 8 for REDBEARLAB_SHIELD_V1_1
  aci_state.aci_pins.mosi_pin   = MOSI;
  aci_state.aci_pins.miso_pin   = MISO;
  aci_state.aci_pins.sck_pin    = SCK;

  aci_state.aci_pins.spi_clock_divider      = SPI_CLOCK_DIV8;//SPI_CLOCK_DIV8  = 2MHz SPI speed
                                                             //SPI_CLOCK_DIV16 = 1MHz SPI speed
  
  aci_state.aci_pins.reset_pin              = _RST; //4 for Nordic board, UNUSED for REDBEARLAB_SHIELD_V1_1
  aci_state.aci_pins.active_pin             = UNUSED;
  aci_state.aci_pins.optional_chip_sel_pin  = UNUSED;

  aci_state.aci_pins.interface_is_interrupt = false; //Interrupts still not available in Chipkit
  aci_state.aci_pins.interrupt_number       = 1;

  /* Pass the service data into the appropriate struct in the ACI */
  lib_aci_init(&aci_state, debugMode);

  /* ToDo: Check for chip ID to make sure we're connected! */
  
  return true;
}
Esempio n. 8
0
void ble_begin()
{
	hal_aci_tl_io_config();  

	is_connected = 0;

	app_state = APP_INIT;
	lib_aci_init();

	ENABLE_INTERRUPTS();

	lib_aci_radio_reset();

	app_state = APP_SLEEP;
	on_process_app();
}
Esempio n. 9
0
void aci_setup(void)
{ 
  
	// Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001
	if (NULL != services_pipe_type_mapping)
	{
	aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
	}
	else
	{
	aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
	}
	aci_state.aci_setup_info.number_of_pipes    = NUMBER_OF_PIPES;
	aci_state.aci_setup_info.setup_msgs         = setup_msgs;
	aci_state.aci_setup_info.num_setup_msgs     = NB_SETUP_MESSAGES;

	// Tell the ACI library, the MCU to nRF8001 pin connections.
	// The Active pin is optional and can be marked UNUSED
	aci_state.aci_pins.board_name = REDBEARLAB_SHIELD_V1_1; //See board.h for details REDBEARLAB_SHIELD_V1_1 or BOARD_DEFAULT
	aci_state.aci_pins.reqn_pin   = 9; //SS for Nordic board, 9 for REDBEARLAB_SHIELD_V1_1
	aci_state.aci_pins.rdyn_pin   = 8; //3 for Nordic board, 8 for REDBEARLAB_SHIELD_V1_1
	aci_state.aci_pins.mosi_pin   = MOSI;
	aci_state.aci_pins.miso_pin   = MISO;
	aci_state.aci_pins.sck_pin    = SCK;

	aci_state.aci_pins.spi_clock_divider          = SPI_CLOCK_DIV8;

	aci_state.aci_pins.reset_pin             = UNUSED; //4 for Nordic board, UNUSED for REDBEARLAB_SHIELD_V1_1
	aci_state.aci_pins.active_pin            = UNUSED;
	aci_state.aci_pins.optional_chip_sel_pin = UNUSED;

	aci_state.aci_pins.interface_is_interrupt	  = false;
	aci_state.aci_pins.interrupt_number		  = 1;

        // Turn debug printing on for the ACI Commands and Events to be printed on the Serial
	lib_aci_debug_print(false);

	//We reset the nRF8001 here by toggling the RESET line connected to the nRF8001
	//If the RESET line is not available we call the ACI Radio Reset to soft reset the nRF8001
	//then we initialize the data structures required to setup the nRF8001

//        delay(50);
//        lib_aci_radio_reset();
//        delay(50); 
        
        lib_aci_init(&aci_state, false);
}
void ble_begin()
{
     /* Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001 */
    if (NULL != services_pipe_type_mapping)
    {
        aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
    }
    else
    {
        aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
    }
    aci_state.aci_setup_info.number_of_pipes    = NUMBER_OF_PIPES;
    aci_state.aci_setup_info.setup_msgs         = setup_msgs;
    aci_state.aci_setup_info.num_setup_msgs     = NB_SETUP_MESSAGES;

    /*
    Tell the ACI library, the MCU to nRF8001 pin connections.
    The Active pin is optional and can be marked UNUSED
    */
    aci_state.aci_pins.board_name = REDBEARLAB_SHIELD_V1_1; //See board.h for details
    aci_state.aci_pins.reqn_pin   = 6;
    aci_state.aci_pins.rdyn_pin   = 7;
    aci_state.aci_pins.mosi_pin   = MOSI;
    aci_state.aci_pins.miso_pin   = MISO;
    aci_state.aci_pins.sck_pin    = SCK;

    aci_state.aci_pins.spi_clock_divider     = SPI_CLOCK_DIV8;

    aci_state.aci_pins.reset_pin             = UNUSED;
    aci_state.aci_pins.active_pin            = UNUSED;
    aci_state.aci_pins.optional_chip_sel_pin = UNUSED;

    aci_state.aci_pins.interface_is_interrupt	  = false;
    aci_state.aci_pins.interrupt_number			  = 4;

    //We reset the nRF8001 here by toggling the RESET line connected to the nRF8001
    //If the RESET line is not available we call the ACI Radio Reset to soft reset the nRF8001
    //then we initialize the data structures required to setup the nRF8001
    //The second parameter is for turning debug printing on for the ACI Commands and Events so they be printed on the Serial
    lib_aci_init(&aci_state, false);

    SPI.begin();
}
Esempio n. 11
0
/**
 * This is the default setup loop.
 */
void NRF8001Driver::setup(){
	
	/**
	 *	Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001
	 */
	if (NULL != this->_services_pipe_type_mapping){
		this->_aci_state->aci_setup_info.services_pipe_type_mapping = &this->_services_pipe_type_mapping[0];
		
	// Nothing was generated beforehand
	}else{ 
		this->_aci_state->aci_setup_info.services_pipe_type_mapping = NULL;
	}

	// We reset the nRF8001 here by toggling the RESET line connected to the nRF8001
	// If the RESET line is not available we call the ACI Radio Reset to soft reset the nRF8001
	// then we initialize the data structures required to setup the nRF8001
	// The second parameter is for turning debug printing on for the ACI Commands and Events so they be printed on the Serial
	lib_aci_init(this->_aci_state, false);
}
Esempio n. 12
0
void ble_begin(E_BLE_INIT_MODE eInitMode)
{
	//if(E_BLE_INIT_MODE_POST_LATCH!=eInitMode)
	{
		 /* Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001 */   
		if (NULL != services_pipe_type_mapping)
		{
			//shreedee teensy fix
				aci_state.aci_setup_info.services_pipe_type_mapping = (services_pipe_type_mapping_t*) &services_pipe_type_mapping[0];
		}
		else
		{
				aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
		 }
		
		aci_state.aci_setup_info.number_of_pipes    = NUMBER_OF_PIPES;

		//shreedee teensy fix
		aci_state.aci_setup_info.setup_msgs         = (hal_aci_data_t*)setup_msgs;
		
		
		aci_state.aci_setup_info.num_setup_msgs     = NB_SETUP_MESSAGES;

			/*
		Tell the ACI library, the MCU to nRF8001 pin connections.
		The Active pin is optional and can be marked UNUSED
		*/	  	
		aci_state.aci_pins.board_name = REDBEARLAB_SHIELD_V1_1; //See board.h for details
		aci_state.aci_pins.reqn_pin   = reqn_pin;
		aci_state.aci_pins.rdyn_pin   = rdyn_pin;
		aci_state.aci_pins.mosi_pin   = MOSI;
		aci_state.aci_pins.miso_pin   = MISO;
		aci_state.aci_pins.sck_pin    = SCK;
	
#if defined(__SAM3X8E__)
		aci_state.aci_pins.spi_clock_divider     = 84;
#else
		aci_state.aci_pins.spi_clock_divider     = SPI_CLOCK_DIV8;
#endif
	  
		aci_state.aci_pins.reset_pin             = UNUSED;
		aci_state.aci_pins.active_pin            = UNUSED;
		aci_state.aci_pins.optional_chip_sel_pin = UNUSED;
	  
		aci_state.aci_pins.interface_is_interrupt	  = false;
		aci_state.aci_pins.interrupt_number			  = 1;

		if(_interrupt_number!=0xFF)
		{
			aci_state.aci_pins.interface_is_interrupt	  = true;
			aci_state.aci_pins.interrupt_number			  = _interrupt_number;
			aci_state.aci_pins.interrupt_mode = _interrupt_mode;
		}

		//Turn debug printing on for the ACI Commands and Events to be printed on the Serial
		lib_aci_debug_print(true);
	}
	
	/*We reset the nRF8001 here by toggling the RESET line connected to the nRF8001
		and initialize the data structures required to setup the nRF8001*/
	lib_aci_init(&aci_state,eInitMode); 
	
	if(E_BLE_INIT_MODE_PRELATCH!=eInitMode)
	//if(E_BLE_INIT_MODE_POR==eInitMode)
	{
	delay(100);
	}
		/*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_state, &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
							{
									Serial.println(F("Do setup"));
									if (ACI_STATUS_TRANSACTION_COMPLETE != do_aci_setup(&aci_state))
									{
											Serial.println(F("Error in ACI Setup"));
									}              
							}
							else if (ACI_STATUS_SUCCESS == aci_evt->params.cmd_rsp.cmd_status) //We are now in STANDBY
							{*/
									//Looking for an iPhone by sending radio advertisements
									//When an iPhone connects to us we will get an ACI_EVT_CONNECTED event from the nRF8001
				//					lib_aci_connect(180/* in seconds */, 0x0050 /* advertising interval 50ms*/);
				/*					Serial.println(F("Advertising started"));              
							}
							break;
					}
					else
					{
							Serial.println(F("Device Started"));
					} 
				}
		}*/
}
Esempio n. 13
0
void ble_begin()
{
#if ( !defined(__SAM3X8E__) && !defined(__PIC32MX__) )
    spi_old = SPCR;
    SPI.setBitOrder(LSBFIRST);
	SPI.setClockDivider(SPI_CLOCK_DIV8);
    SPI.setDataMode(SPI_MODE0);
#endif
	
	memset(bd_addr_own, 0x00, BTLE_DEVICE_ADDRESS_SIZE);

     /* Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001 */
    if (NULL != services_pipe_type_mapping)
    {
        aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0];
    }
    else
    {
        aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
    }
    aci_state.aci_setup_info.number_of_pipes    = NUMBER_OF_PIPES;
    aci_state.aci_setup_info.setup_msgs         = (hal_aci_data_t*)setup_msgs;
    aci_state.aci_setup_info.num_setup_msgs     = NB_SETUP_MESSAGES;

    /*
    Tell the ACI library, the MCU to nRF8001 pin connections.
    The Active pin is optional and can be marked UNUSED
    */
    aci_state.aci_pins.board_name = REDBEARLAB_SHIELD_V2; //See board.h for details
    aci_state.aci_pins.reqn_pin   = reqn_pin;
    aci_state.aci_pins.rdyn_pin   = rdyn_pin;
    aci_state.aci_pins.mosi_pin   = MOSI;
    aci_state.aci_pins.miso_pin   = MISO;
    aci_state.aci_pins.sck_pin    = SCK;

#if defined(__SAM3X8E__)
    aci_state.aci_pins.spi_clock_divider     = 84;
#else
    aci_state.aci_pins.spi_clock_divider     = SPI_CLOCK_DIV8;
#endif

    aci_state.aci_pins.reset_pin             = UNUSED;
    aci_state.aci_pins.active_pin            = UNUSED;
    aci_state.aci_pins.optional_chip_sel_pin = UNUSED;

    aci_state.aci_pins.interface_is_interrupt	  = false;
    aci_state.aci_pins.interrupt_number			  = 4;//1;

    //We reset the nRF8001 here by toggling the RESET line connected to the nRF8001
    //If the RESET line is not available we call the ACI Radio Reset to soft reset the nRF8001
    //then we initialize the data structures required to setup the nRF8001
    //The second parameter is for turning debug printing on for the ACI Commands and Events so they be printed on the Serial
    lib_aci_init(&aci_state, false);

#if ( !defined(__SAM3X8E__) && !defined(__PIC32MX__) )
#if (ARDUINO < 150)
    SPCR = spi_old;
    SPI.begin();
#endif
#endif
}