Пример #1
0
bool gzll_ack_payload_write(const uint8_t *src, uint8_t length, uint8_t pipe)
{
  ASSERT(length <= GZLL_MAX_ACK_PAYLOAD_LENGTH && length > 0);
  ASSERT(pipe <= 5);

  gzll_interupts_disable_rfck_enable();

  if(length == 0 || (length > GZLL_MAX_ACK_PAYLOAD_LENGTH) || hal_nrf_tx_fifo_full())
  {
    gzll_interupts_enable_rfck_disable();
    return false;                             // ACK payload not written
  }
  hal_nrf_write_ack_payload(pipe, src, length);
  gzll_interupts_enable_rfck_disable();
  return true;                                // ACK payload successfully written
}
Пример #2
0
static app_states_t app_normal(void)   
{
	usb_state_t data temp_state = usb_get_state();
	 uint8_t i = 0;
     uint8_t xdata *buf_ptr;
     uint8_t xdata *bc_ptr;

	if(temp_state == USB_REM_WU_ENABLE)   
  	{   
    	return APP_SUSP_WE;    
  	}   
       
  	if(temp_state == USB_REM_WU_DISABLE)   
  	{   
    	return APP_SUSP_WD;    
  	}
	
	if(ep2_rx) // process data we got over USB
	{
		ep2_rx = false;

		hal_nrf_write_ack_payload(0, ackPayload, SIZEOFPROG);
	//	hal_usb_send_data(2, "\x00\x00", 2);	
	}

  	if(blockNeedsSending) // process data from Wireless
	{
		blockNeedsSending = 0;

	/*   hal_usb_send_data(1,  payload[0], 31); */
	    P0_5=1;
    // Calculate the buffer pointer and byte count pointer

	    buf_ptr = CALCULATE_BUF_IN_PTR(2);
	    bc_ptr = CALCULATE_BC_IN_PTR(2);
		
		if( 0 == block )
		{
		//	buf_ptr = buf_ptr + 31; 
		}
	    // Copy the data into the USB controller
	    for( i = 0; i < PKTLENGTH; ++i )
	    {
	        buf_ptr[i] = payload[block][i];
	    }
    
//	    buf_ptr[30] = block + (0xAA);
    	*bc_ptr = PKTLENGTH;
		// Set the number of bytes we want to send to USB-host. This also trigger sending of data to USB-host.
    	

		if(block)
		{
			block = 0;
		} else {
		 	block = 1;
		}
		P0_5=0;
		/********/
    	/*
		// Write payload to radio USB FIFO
    	hal_usb_send_data(1, payload[(block^0x01)], 31);
		blockNeedsSending = 0;*/
 	}
	 
	return APP_NORMAL; 
}