diff options
Diffstat (limited to 'build/default/production/ds3231.i')
-rwxr-xr-x | build/default/production/ds3231.i | 244 |
1 files changed, 192 insertions, 52 deletions
diff --git a/build/default/production/ds3231.i b/build/default/production/ds3231.i index c360bea..97a8948 100755 --- a/build/default/production/ds3231.i +++ b/build/default/production/ds3231.i @@ -7,7 +7,11 @@ # 1 "C:\\Program Files (x86)\\Microchip\\xc8\\v2.05\\pic\\include\\language_support.h" 1 3 # 2 "<built-in>" 2 # 1 "ds3231.c" 2 -# 15 "ds3231.c" + + + + + # 1 "./ds3231.h" 1 # 1 "./conf.h" 1 # 1 "C:\\Program Files (x86)\\Microchip\\xc8\\v2.05\\pic\\include\\xc.h" 1 3 @@ -1738,16 +1742,23 @@ extern __bank0 __bit __timeout; # 1 "./ds3231.h" 2 +char dayOfWeek[7][4]; +char monthOfYear[12][4]; + int BCD_2_DEC(int); int DEC_2_BCD(int); +unsigned int Get_DayOfWeek(unsigned int, unsigned int, unsigned int); +unsigned int Get_Days_In_Month(unsigned int, unsigned int); +unsigned int Get_Is_Leap_Year(unsigned int); +char* Get_WeekDay(unsigned int); void Read_Alarms_Temp(void); void Set_Date(void); -void Set_DayOfWeek(void); +void Set_DayOfWeek(int); +void Set_Sqwe(int); void Set_Time(void); -void Set_Time_Date(void); void Update_Current_Date_Time(void); void Write_Alarms(void); -# 15 "ds3231.c" 2 +# 6 "ds3231.c" 2 # 1 "./i2c.h" 1 void I2C_Master_Init(const unsigned long); @@ -1757,68 +1768,185 @@ void I2C_Master_Repeated_Start(void); void I2C_Master_Stop(void); void I2C_Master_Write(unsigned); unsigned short I2C_Master_Read(unsigned short); -# 16 "ds3231.c" 2 +# 7 "ds3231.c" 2 # 1 "./main.h" 1 +# 1 "./lcd.h" 1 +# 1 "./conf.h" 1 + + + +#pragma config FOSC = HS +#pragma config WDTE = OFF +#pragma config PWRTE = ON +#pragma config BOREN = ON +#pragma config LVP = OFF +#pragma config CPD = OFF +#pragma config WRT = OFF +#pragma config CP = OFF +# 1 "./lcd.h" 2 + + +void Lcd_Port(char); +void Lcd_Cmd(char); +void Lcd_Clear(void); +void Lcd_Set_Cursor(char, char); +void Lcd_Init(void); +void Lcd_Write_Char(char); +void Lcd_Write_String(char *); +void Lcd_Shift_Right(void); +void Lcd_Shift_Left(void); + + + +void Vfd_Set_Brightness(int); +# 1 "./main.h" 2 -unsigned int sec = 30; -unsigned int min = 42; -unsigned int hour = 21; -unsigned int dayOfWeek = 7; -unsigned int date = 27; -unsigned int month = 7; -unsigned int year = 19; -unsigned int century = 20; -unsigned int alarm1_sec, alarm1_min, alarm1_hour; -unsigned int alarm2_min, alarm2_hour; -unsigned int status_reg, alarm1_status, alarm2_status; -unsigned int control_reg; +# 1 "./i2c.h" 1 +void I2C_Master_Init(const unsigned long); +void I2C_Master_Wait(void); +void I2C_Master_Start(void); +void I2C_Master_Repeated_Start(void); +void I2C_Master_Stop(void); +void I2C_Master_Write(unsigned); +unsigned short I2C_Master_Read(unsigned short); +# 2 "./main.h" 2 +# 1 "./ds3231.h" 1 +# 1 "./conf.h" 1 -unsigned int temperature_lsb = 0; -int temperature_msb = 0; -unsigned char temp_sign = ' '; -char* weekday; +#pragma config FOSC = HS +#pragma config WDTE = OFF +#pragma config PWRTE = ON +#pragma config BOREN = ON +#pragma config LVP = OFF +#pragma config CPD = OFF +#pragma config WRT = OFF +#pragma config CP = OFF +# 1 "./ds3231.h" 2 -unsigned int sec_chg = 0; +char dayOfWeek[7][4]; +char monthOfYear[12][4]; +int BCD_2_DEC(int); +int DEC_2_BCD(int); +unsigned int Get_DayOfWeek(unsigned int, unsigned int, unsigned int); +unsigned int Get_Days_In_Month(unsigned int, unsigned int); +unsigned int Get_Is_Leap_Year(unsigned int); +char* Get_WeekDay(unsigned int); +void Read_Alarms_Temp(void); +void Set_Date(void); +void Set_DayOfWeek(int); +void Set_Sqwe(int); +void Set_Time(void); +void Update_Current_Date_Time(void); +void Write_Alarms(void); +# 3 "./main.h" 2 -unsigned char sec_0, sec_1; -unsigned char min_0, min_1; -unsigned char hour_0, hour_1; -unsigned char day_0, day_1; -unsigned char month_0, month_1; -unsigned char year_0, year_1; -unsigned char temp_0, temp_1, temp_2; -unsigned char alarm1_sec_0, alarm1_sec_1, alarm1_min_0, alarm1_min_1, - alarm1_hour_0, alarm1_hour_1; -unsigned char alarm2_min_0, alarm2_min_1, alarm2_hour_0, alarm2_hour_1; -char buf[40]; +# 1 "./adc.h" 1 +# 1 "./conf.h" 1 -void format_DateTimeChars(void); +#pragma config FOSC = HS +#pragma config WDTE = OFF +#pragma config PWRTE = ON +#pragma config BOREN = ON +#pragma config LVP = OFF +#pragma config CPD = OFF +#pragma config WRT = OFF +#pragma config CP = OFF +# 1 "./adc.h" 2 -void format_Temperature(void); -void getWeekDay(unsigned int); +void Adc_Init(void); -void Get_Alarm_Status(void); +unsigned int Adc_Read(unsigned int); +# 6 "./main.h" 2 + + +# 1 "./beep.h" 1 +# 1 "./conf.h" 1 + + + +#pragma config FOSC = HS +#pragma config WDTE = OFF +#pragma config PWRTE = ON +#pragma config BOREN = ON +#pragma config LVP = OFF +#pragma config CPD = OFF +#pragma config WRT = OFF +#pragma config CP = OFF +# 1 "./beep.h" 2 + + +void alarm(unsigned int); +# 9 "./main.h" 2 +# 18 "./main.h" +unsigned int ldr; + + + + +unsigned int brtlvl_chg; + + +unsigned int update; + + +unsigned int edit_datetime; + + +extern unsigned int sec; +extern unsigned int min; +extern unsigned int hour; +extern unsigned int day; +extern unsigned int date; +extern unsigned int month; +extern unsigned int year; +extern unsigned int century; +extern unsigned int alarm1_sec, alarm1_min, alarm1_hour; +extern unsigned int alarm2_min, alarm2_hour; +extern unsigned int status_reg, alarm1_status, alarm2_status; +extern unsigned int control_reg; + + +extern unsigned int temperature_lsb; +extern int temperature_msb; +unsigned char temp_sign; +# 60 "./main.h" +void display_Digit(unsigned int); void display_Intro(void); void display_Lcd_Layout(void); +void edit_Date_Time(void); + + +void format_Temperature(void); + + +void Get_Alarm_Status(void); + void update_Display(void); -# 17 "ds3231.c" 2 +# 8 "ds3231.c" 2 + + + +char dayOfWeek[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; +char monthOfYear[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", + "Aug", "Sep", "Oct", "Nov", "Dec"}; + int BCD_2_DEC(int to_convert) { return (to_convert >> 4) * 10 + (to_convert & 0x0F); } @@ -1827,6 +1955,23 @@ int DEC_2_BCD(int to_convert) { return ((to_convert / 10) << 4) + (to_convert % 10); } +unsigned int Get_DayOfWeek(unsigned int y, unsigned int m, unsigned int d) { + return (d += m < 3 ? y-- : y - 2, 23 * m / 9 + d + 4 + y / 4 - y / 100 + y / 400) % 7 + 1; +} + +unsigned int Get_Days_In_Month(unsigned int y, unsigned int m) { + return (m == 2) ? + (28 + Get_Is_Leap_Year(y)) : 31 - (m - 1) % 7 % 2; +} + +unsigned int Get_Is_Leap_Year(unsigned int y) { + return (year % 4) || ((year % 100 == 0) && (year % 400)) ? 0 : 1; +} + +char* Get_WeekDay(unsigned int d){ + return dayOfWeek[d - 1]; +} + void Read_Alarms_Temp() { I2C_Master_Start(); I2C_Master_Write(0xD0); @@ -1862,35 +2007,29 @@ void Set_Date() { I2C_Master_Stop(); } -void Set_DayOfWeek() { +void Set_DayOfWeek(int dow) { I2C_Master_Start(); I2C_Master_Write(0xD0); I2C_Master_Write(3); - I2C_Master_Write(dayOfWeek); + I2C_Master_Write(dow); I2C_Master_Stop(); } -void Set_Time() { +void Set_Sqwe(int contvalue) { I2C_Master_Start(); I2C_Master_Write(0xD0); - I2C_Master_Write(0); - I2C_Master_Write(DEC_2_BCD(sec)); - I2C_Master_Write(DEC_2_BCD(min)); - I2C_Master_Write(DEC_2_BCD(hour)); + I2C_Master_Write(0x0E); + I2C_Master_Write(contvalue); I2C_Master_Stop(); } -void Set_Time_Date() { +void Set_Time() { I2C_Master_Start(); I2C_Master_Write(0xD0); I2C_Master_Write(0); I2C_Master_Write(DEC_2_BCD(sec)); I2C_Master_Write(DEC_2_BCD(min)); I2C_Master_Write(DEC_2_BCD(hour)); - I2C_Master_Write(1); - I2C_Master_Write(DEC_2_BCD(date)); - I2C_Master_Write(DEC_2_BCD(month)); - I2C_Master_Write(DEC_2_BCD(year)); I2C_Master_Stop(); } @@ -1899,14 +2038,15 @@ void Update_Current_Date_Time() { I2C_Master_Start(); I2C_Master_Write(0xD0); I2C_Master_Write(0); - I2C_Master_Repeated_Start(); + I2C_Master_Stop(); + I2C_Master_Start(); I2C_Master_Write(0xD1); sec = BCD_2_DEC(I2C_Master_Read(1)); min = BCD_2_DEC(I2C_Master_Read(1)); hour = BCD_2_DEC(I2C_Master_Read(1)); - weekday = I2C_Master_Read(1); + day = I2C_Master_Read(1); date = BCD_2_DEC(I2C_Master_Read(1)); month = BCD_2_DEC(I2C_Master_Read(1)); year = BCD_2_DEC(I2C_Master_Read(1)); |