Skip to content

Commit

Permalink
so0me correction in time module, SRS first command.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertK66 committed Nov 28, 2023
1 parent 6b358b1 commit e10464c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ClimbObc/src/mod/srs/radsensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ void srs_main() {
srsTx[9] = srs_crc(srsTx, 8);
srsJob.tx_size = 10;
srsJob.tx_data = srsTx;
srsJob.rx_size = 0; //10;
srsJob.rx_data = 0; //srsRx;
srsJob.rx_size = 10;
srsJob.rx_data = srsRx;
srsJobInProgress = true;
i2c_add_job(&srsJob);
}
Expand Down
17 changes: 15 additions & 2 deletions ClimbObc/src/mod/tim/obc_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ void timSyncUtc(uint16_t year, obc_systime32_t systemTime, juliandayfraction utc

float diff = fabs(syncData.newOffset - syncData.oldOffset);
if ( diff > 0.00005) {
ObcSystemTime.utcOffset.year = year;
ObcSystemTime.utcOffset.dayOfYear = syncData.newOffset;

// Now we (re)calculate current Time (from systime and offset) and set this to our RTC registers
Expand Down Expand Up @@ -484,11 +485,23 @@ obc_systime32_t inline timGetSystime(void) {
}

uint32_t leapDaysSince1970() {
return 12;
int days = 0;
for (int y=1972; y<ObcSystemTime.utcOffset.year ; y=y+4) {
days++; // 1. Leap day all 4 years
if (y%100 == 0) {
if (y%400 == 0) { // 3. all 400 years the skipping is NOT done!
} else {
y--; // 2. all 100 years it is skipped
}
} else {

}
}
return days;
}

uint64_t timGetUnixTime(void) {
uint32_t unixDays = (ObcSystemTime.utcOffset.year - 1970) * 365 + (uint32_t)ObcSystemTime.utcOffset.dayOfYear + leapDaysSince1970();
uint32_t unixDays = (ObcSystemTime.utcOffset.year - 1970) * 365 + (uint32_t)(ObcSystemTime.utcOffset.dayOfYear -1) + leapDaysSince1970(); // Day of year starts with 1 on 1.1. !!!!!
uint16_t daysOfYearInt = (uint16_t)ObcSystemTime.utcOffset.dayOfYear;
juliandayfraction secOfDay = (ObcSystemTime.utcOffset.dayOfYear - (juliandayfraction)(daysOfYearInt)) * 86400;

Expand Down

0 comments on commit e10464c

Please sign in to comment.