示例#1
0
static void packetbuf_out_next_packet(void){
	if (USB_ep_out_received(2) && packetbuf_out_can_write()){
		cli();
		USB_ep_out_start(2, out_buf[out_end_index]);
		out_end_index = (out_end_index+1)%PACKETS_BUFFER;
		out_count++;
		sei();
	}
}
示例#2
0
void pollEndpoint(void){
	if (USB_ep_out_received(1)){		
		
		pageOffs += EP1_SIZE;

		if (pageOffs == APP_SECTION_PAGE_SIZE){
			// Write a page to flash
			SP_LoadFlashPage(pageBuf);
			NVM.CMD = NVM_CMD_NO_OPERATION_gc;
			SP_WriteApplicationPage(page*APP_SECTION_PAGE_SIZE);
			SP_WaitForSPM();
			NVM.CMD = NVM_CMD_NO_OPERATION_gc;
			
			page++;
			pageOffs = 0;
		}

		if (page * APP_SECTION_PAGE_SIZE < APP_SECTION_END){
			// If there's remaining room in flash, configure the endpoint to accept more data
			USB_ep_out_start(1, &pageBuf[pageOffs]);
		}
	}
}