/*
 * Code generated from Atmel Start.
 *
 * This file will be overwritten when reconfiguring your Atmel Start project.
 * Please copy examples or other code you want to keep to a separate file
 * to avoid losing it when reconfiguring.
 */

#include "driver_examples.h"
#include "driver_init.h"
#include "utils.h"

/**
 * Example of using TARGET_IO to write "Hello World" using the IO abstraction.
 */
void TARGET_IO_example(void)
{
	struct io_descriptor *io;
	usart_sync_get_io_descriptor(&TARGET_IO, &io);
	usart_sync_enable(&TARGET_IO);

	io_write(io, (uint8_t *)"Hello World!", 12);
}

void COMMUNICATION_IO_example(void)
{
	struct io_descriptor *COMMUNICATION_IO_io;

	i2c_m_sync_get_io_descriptor(&COMMUNICATION_IO, &COMMUNICATION_IO_io);
	i2c_m_sync_enable(&COMMUNICATION_IO);
	i2c_m_sync_set_slaveaddr(&COMMUNICATION_IO, 0x12, I2C_M_SEVEN);
	io_write(COMMUNICATION_IO_io, (uint8_t *)"Hello World!", 12);
}

/**
 * Example of using INTERFACE_INSTANCE to write "Hello World" using the IO abstraction.
 */
static uint8_t example_INTERFACE_INSTANCE[12] = "Hello World!";

void INTERFACE_INSTANCE_example(void)
{
	struct io_descriptor *io;
	spi_m_sync_get_io_descriptor(&INTERFACE_INSTANCE, &io);

	spi_m_sync_enable(&INTERFACE_INSTANCE);
	io_write(io, example_INTERFACE_INSTANCE, 12);
}
