Ejemplo n.º 1
0
	void Server::Start()
	{
		async::network::socket_handle_ptr sck(async::network::make_socket(io_, 
			async::network::tcp::v4().family(), async::network::tcp::v4().type(), async::network::tcp::v4().protocol()));
		
		acceptor_.async_accept(sck, 
			std::bind(&Server::_HandleAccept, this, async::iocp::_Error, async::iocp::_Socket));
	}
Ejemplo n.º 2
0
void SPI::begin() {
	OutputPin sck(SPI_SCK_PORT, SPI_SCK_PIN);
	OutputPin mosi(SPI_MOSI_PORT, SPI_MOSI_PIN);
	InputPin miso(SPI_MISO_PORT, SPI_MISO_PIN);
	OutputPin ss(SPI_SS_PORT, SPI_SS_PIN);

	sck.begin();
	mosi.begin();
	miso.begin();
	ss.begin();

	sck.clear();
	mosi.clear();
	ss.set();	

	// Warning: if the SS pin ever becomes a LOW INPUT then SPI 
	// automatically switches to Slave, so the data direction of 
	// the SS pin MUST be kept as OUTPUT.
	SPCR = (1<<MSTR) | (1<<SPE);
}