Subversion Repositories idreammicro-avr

Compare Revisions

Ignore whitespace Rev 18 → Rev 19

/trunk/projects/clock/SConscript
0,0 → 1,22
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'clock'
 
# Set libraries to use.
libraries = [
'ds1307',
'twi',
'usart'
]
 
# Set source file.
sources = 'clock.c'
 
# Build project and libraries.
env_target.BuildProject(libraries, sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/projects/clock/SConstruct
0,0 → 1,31
# Set environment for AVR-GCC.
SConscript('#build_system/env_avr.py')
 
# Import environment set for AVR-GCC.
Import('env_avr')
 
# Append CPPPATH with the root path of libraries.
env_avr.Append(CPPPATH = [ '#libraries/' ])
 
# Define environments to use (one environment per target).
environments = [
'env_arduino_uno',
'env_arduino_mega2560'
]
 
# Browse environments.
for environment in environments:
# Set environment for target.
SConscript(
'#build_system/' + environment + '.py',
exports = 'env_avr'
)
# Import environment set for target.
Import('env_target')
# Build program.
SConscript(
'SConscript',
variant_dir = '#build/' + 'projects/clock/' + environment,
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/projects/clock/clock.c
0,0 → 1,121
/**************************************************************************//**
* \brief DS1307 RTC library - Demonstration program
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090501
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file demo_ds1307.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <ds1307/ds1307.h>
#include <usart/usart0.h>
#include <useful/datetime.h>
 
#include <avr/io.h>
#include <util/delay.h>
 
#include <stdio.h>
#include <string.h>
 
/******************************************************************************
* Main function.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
*
* \return 0
******************************************************************************/
int main(void)
{
// Initialize USART0.
usart0__initialize(NULL);
 
// Enbale transmitter.
usart0__enable_transmitter();
 
// Initialize RTC.
ds1307__initialize();
 
// Declare some variables.
datetime__time_t time =
{
.seconds = 00,
.minutes = 29,
.hours = 19,
.meridiem = 0
};
ds1307__hour_mode_t hour_mode = DS1307__HOUR_MODE__24_HOUR;
 
datetime__date_t date =
{
.day = 3,
.date = 5,
.month = 5,
.year = 9
};
 
// Set time and hour mode.
//ds1307__set_time(&time, hour_mode);
 
// Set date.
//ds1307__set_date(&date);
 
while (1)
{
// Get RTC time.
ds1307__get_time(&time, &hour_mode);
 
// Get RTC date.
ds1307__get_date(&date);
 
char str_datetime[] = "dd/mm/yy hh:mm:ss\n";
 
snprintf
(
str_datetime,
strlen(str_datetime) + 1,
"%02u/%02u/%02u %02u:%02u:%02u\n",
date.date,
date.month,
date.year,
time.hours,
time.minutes,
time.seconds
);
 
char* p_str = str_datetime;
while (*p_str != '\0')
{
usart0__transmit_byte(*p_str);
p_str++;
}
 
_delay_ms(1000);
}
 
return 0;
}