You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.6 KiB
C

/*
* 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 CALENDER_INTERFACE.
*/
static struct calendar_alarm alarm;
static void alarm_cb(struct calendar_descriptor *const descr)
{
/* alarm expired */
}
void CALENDER_INTERFACE_example(void)
{
struct calendar_date date;
struct calendar_time time;
calendar_enable(&CALENDER_INTERFACE);
date.year = 2000;
date.month = 12;
date.day = 31;
time.hour = 12;
time.min = 59;
time.sec = 59;
calendar_set_date(&CALENDER_INTERFACE, &date);
calendar_set_time(&CALENDER_INTERFACE, &time);
alarm.cal_alarm.datetime.time.sec = 4;
alarm.cal_alarm.option = CALENDAR_ALARM_MATCH_SEC;
alarm.cal_alarm.mode = REPEAT;
calendar_set_alarm(&CALENDER_INTERFACE, &alarm, alarm_cb);
}
/**
* Example of using USART_0 to write "Hello World" using the IO abstraction.
*/
void USART_0_example(void)
{
struct io_descriptor *io;
usart_sync_get_io_descriptor(&USART_0, &io);
usart_sync_enable(&USART_0);
io_write(io, (uint8_t *)"Hello World!", 12);
}
/**
* Example of using SPI_0 to write "Hello World" using the IO abstraction.
*/
static uint8_t example_SPI_0[12] = "Hello World!";
void SPI_0_example(void)
{
struct io_descriptor *io;
spi_m_sync_get_io_descriptor(&SPI_0, &io);
spi_m_sync_enable(&SPI_0);
io_write(io, example_SPI_0, 12);
}