118 lines
2.2 KiB
C
118 lines
2.2 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 ADC_0 to generate waveform.
|
|
*/
|
|
void ADC_0_example(void)
|
|
{
|
|
uint8_t buffer[2];
|
|
|
|
adc_sync_enable_channel(&ADC_0, 0);
|
|
|
|
while (1) {
|
|
adc_sync_read_channel(&ADC_0, 0, buffer, 2);
|
|
}
|
|
}
|
|
|
|
static void button_on_PB05_pressed(void)
|
|
{
|
|
}
|
|
|
|
static void button_on_PA22_pressed(void)
|
|
{
|
|
}
|
|
|
|
static void button_on_PA23_pressed(void)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Example of using EXTERNAL_IRQ_0
|
|
*/
|
|
void EXTERNAL_IRQ_0_example(void)
|
|
{
|
|
|
|
ext_irq_register(PIN_PB05, button_on_PB05_pressed);
|
|
ext_irq_register(PIN_PA22, button_on_PA22_pressed);
|
|
ext_irq_register(PIN_PA23, button_on_PA23_pressed);
|
|
}
|
|
|
|
/**
|
|
* Example of using CALENDAR_0.
|
|
*/
|
|
static struct calendar_alarm alarm;
|
|
|
|
static void alarm_cb(struct calendar_descriptor *const descr)
|
|
{
|
|
/* alarm expired */
|
|
}
|
|
|
|
void CALENDAR_0_example(void)
|
|
{
|
|
struct calendar_date date;
|
|
struct calendar_time time;
|
|
|
|
calendar_enable(&CALENDAR_0);
|
|
|
|
date.year = 2000;
|
|
date.month = 12;
|
|
date.day = 31;
|
|
|
|
time.hour = 12;
|
|
time.min = 59;
|
|
time.sec = 59;
|
|
|
|
calendar_set_date(&CALENDAR_0, &date);
|
|
calendar_set_time(&CALENDAR_0, &time);
|
|
|
|
alarm.cal_alarm.datetime.time.sec = 4;
|
|
alarm.cal_alarm.option = CALENDAR_ALARM_MATCH_SEC;
|
|
alarm.cal_alarm.mode = REPEAT;
|
|
|
|
calendar_set_alarm(&CALENDAR_0, &alarm, alarm_cb);
|
|
}
|
|
|
|
void I2C_0_example(void)
|
|
{
|
|
struct io_descriptor *I2C_0_io;
|
|
|
|
i2c_m_sync_get_io_descriptor(&I2C_0, &I2C_0_io);
|
|
i2c_m_sync_enable(&I2C_0);
|
|
i2c_m_sync_set_slaveaddr(&I2C_0, 0x12, I2C_M_SEVEN);
|
|
io_write(I2C_0_io, (uint8_t *)"Hello World!", 12);
|
|
}
|
|
|
|
void delay_example(void)
|
|
{
|
|
delay_ms(5000);
|
|
}
|
|
|
|
/**
|
|
* Example of using PWM_1.
|
|
*/
|
|
void PWM_1_example(void)
|
|
{
|
|
pwm_set_parameters(&PWM_1, 10000, 5000);
|
|
pwm_enable(&PWM_1);
|
|
}
|
|
|
|
#define SLCD_EXAMPLE_SEGID SLCD_SEGID(1, 0)
|
|
/**
|
|
* Example of using SEGMENT_LCD_0
|
|
*/
|
|
void SEGMENT_LCD_0_example(void)
|
|
{
|
|
slcd_sync_enable(&SEGMENT_LCD_0);
|
|
slcd_sync_seg_on(&SEGMENT_LCD_0, SLCD_EXAMPLE_SEGID);
|
|
}
|