<commit_before>/* automaton
 * (c) 2013 <NAME>
 * The source code of this project is distributed under the terms of the
 * simplified BSD license. See the LICENSE file for details.
 */


#include "io/spi.h"


static void spi_select(uint8_t slave) {
	io_write(PORT(IO_SPI), IO_SPI_SS_ALL, IO_SPI_SS_ALL ^ slave);
}

static void spi_deselect(void) {
	io_write(PORT(IO_SPI), IO_SPI_SS_ALL, IO_SPI_SS_ALL);
}


void spi_init(void) {
	io_write(DDR(IO_SPI), IO_SPI_ALL | IO_SPI_SS_ALL,
		(IO_SPI_ALL ^ IO_SPI_MISO) | IO_SPI_SS_ALL);
	io_write(PORT(IO_SPI), IO_SPI_ALL | IO_SPI_SS_ALL, IO_SPI_SS_ALL);
}


void spi_begin(uint8_t slave, uint8_t settings) {
	SPCR = _BV(SPIE) | _BV(MSTR) | (settings & ~_BV(7));
	SPSR = ((settings & _BV(7)) ? _BV(SPI2X) : 0);
	
	/* clear out any existing state */
	(void)SPSR;
	(void)SPDR;
	<commit_msg>io/spi: document IO port settings<commit_after>/* automaton
 * (c) 2013 <NAME>
 * The source code of this project is distributed under the terms of the
 * simplified BSD license. See the LICENSE file for details.
 */


#include "io/spi.h"


static void spi_select(uint8_t slave) {
	io_write(PORT(IO_SPI), IO_SPI_SS_ALL, IO_SPI_SS_ALL ^ slave);
}

static void spi_deselect(void) {
	io_write(PORT(IO_SPI), IO_SPI_SS_ALL, IO_SPI_SS_ALL);
}


void spi_init(void) {
	/* all output except MISO; all high, plus pullups on MISO */
	io_write(DDR(IO_SPI), IO_SPI_ALL | IO_SPI_SS_ALL,
		(IO_SPI_ALL ^ IO_SPI_MISO) | IO_SPI_SS_ALL);
	io_write(PORT(IO_SPI), IO_SPI_ALL | IO_SPI_SS_ALL, IO_SPI_SS_ALL);
}


void spi_begin(uint8_t slave, uint8_t settings) {
	SPCR = _BV(SPIE) | _BV(MSTR) | (settings & ~_BV(7));
	SPSR = ((settings & _BV(7)) ? _BV(SPI2X) : 0);
	
	/* clear out any existing state */
	(void)SPSR;
	(void)SPDR;
	
{'fraction_non_alphanumeric': 0.13003452243958574, 'fraction_numerical': 0.012658227848101266, 'mean_word_length': 4.8552188552188555, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7408653', 'n_tokens_mistral': 765, 'n_tokens_neox': 731, 'n_words': 168}