Subversion Repositories idreammicro-avr

Compare Revisions

Ignore whitespace Rev 42 → Rev 37

/trunk/projects/clock/clock.c
37,30 → 37,11
#include <avr/io.h>
#include <util/delay.h>
 
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void clock__transmit_string(const char* p_string)
*
* \brief Transmit a string through USART.
*
* \param[in] p_string String to transmit.
******************************************************************************/
static
void
clock__transmit_string
(
const char* p_string
);
 
/******************************************************************************
* Main function.
******************************************************************************/
 
83,27 → 64,27
twi__initialize(100000);
 
// Initialize RTC.
ds1307__initialize();
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;
// 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
};
datetime__date_t date =
{
.day = 3,
.date = 5,
.month = 5,
.year = 9
};
 
// Initialize Deuligne and configure display.
// Initialize Deuligne and configure display.
deuligne__initialize();
deuligne__set_display(true, true, true);
 
110,21 → 91,21
// Switch on backlight.
deuligne__switch_on_backlight();
 
// Set time and hour mode.
//ds1307__set_time(&time, hour_mode);
// Set time and hour mode.
//ds1307__set_time(&time, hour_mode);
 
// Set date.
//ds1307__set_date(&date);
// Set date.
//ds1307__set_date(&date);
 
for (;;)
{
// Get RTC time.
ds1307__get_time(&time, &hour_mode);
for (;;)
{
// Get RTC time.
ds1307__get_time(&time, &hour_mode);
 
// Get RTC date.
ds1307__get_date(&date);
// Get RTC date.
ds1307__get_date(&date);
 
char str_date[] = "dd/mm/yy";
char str_date[] = "dd/mm/yy";
snprintf
(
str_date,
146,9 → 127,20
time.seconds
);
 
clock__transmit_string(&(str_date[0]));
char* p_date = &(str_date[0]);
while(*p_date != '\0')
{
usart0__transmit_byte(*p_date);
p_date++;
}
usart0__transmit_byte(' ');
clock__transmit_string(&(str_time[0]));
 
char* p_time = &(str_time[0]);
while(*p_time != '\0')
{
usart0__transmit_byte(*p_time);
p_time++;
}
usart0__transmit_byte('\n');
 
deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_1, 0);
157,35 → 149,8
deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 0);
deuligne__write_string(str_time);
 
_delay_ms(1000);
}
_delay_ms(1000);
}
 
return 0;
return 0;
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void clock__transmit_string(const char* p_string)
*
* \brief Transmit a string through USART.
*
* \param[in] p_string String to transmit.
******************************************************************************/
static
void
clock__transmit_string
(
const char* p_string
){
// Check the preconditions.
assert(NULL != p_string);
 
while (*p_string != '\0')
{
usart0__transmit_byte(*p_string);
p_string++;
}
}