Skip to content

Commit

Permalink
Formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Remus7 committed Oct 18, 2023
1 parent a5b3a0d commit 8bcf09e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
24 changes: 12 additions & 12 deletions examples/rtc_app/main.c
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
#include <stdio.h>
#include <rtc.h>
#include <stdio.h>
#include <timer.h>

int main(void){
// Initialises a date struct with a certain timestamp
struct Date date = {
.year = 2023,
.year = 2023,
.month = JANUARY,
.day = 1,
.day = 1,

.day_of_week = MONDAY,
.hour = 12,
.minute = 30,
.seconds = 1
.hour = 12,
.minute = 30,
.seconds = 1
};

set_date(&date);
// Clock has a small delay before starting to count seconds
delay_ms(2000);

while(1){
while (1) {
get_date(&date);
printf("Date: {year: %d, month: %d, day: %d, day_of_week: %d, hour: %d, minute: %d, seconds: %d}\n\n", date.year, date.month, date.day, date.day_of_week, date.hour, date.minute, date.seconds);
printf("Date: {year: %d, month: %d, day: %d, day_of_week: %d, hour: %d, minute: %d, seconds: %d}\n\n", date.year,
date.month, date.day, date.day_of_week, date.hour, date.minute, date.seconds);

// This delay uses an underlying timer in the kernel
delay_ms(1000);
// This delay uses an underlying timer in the kernel
delay_ms(1000);
}
return 0;
}

21 changes: 11 additions & 10 deletions libtock/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

int date, time;

static void rtc_cb(int status __attribute__ ((unused)),
int upcall1,
int upcall2,
static void rtc_cb(int status __attribute__ ((unused)),
int upcall1,
int upcall2,
void* ud __attribute__ ((unused))){
date = upcall1;
time = upcall2;
Expand All @@ -19,19 +19,19 @@ int get_date(struct Date *put_date){
}

syscall_return_t rval = command(DRIVER_NUM_RTC, 1, 0, 0);
if(!(rval.type == 128)){
if (!(rval.type == 128)) {
printf("%d", rval.type);
}

struct Date date_result = {
.year = date % (1 << 21) / (1 << 9),
.year = date % (1 << 21) / (1 << 9),
.month = date % (1 << 9) / (1 << 5),
.day = date % (1 << 5),
.day = date % (1 << 5),

.day_of_week = time % (1 << 20) / (1 << 17),
.hour = time % (1 << 17) / (1 << 12),
.minute = time % (1 << 12) / (1 << 6),
.seconds = time % (1 << 6)
.hour = time % (1 << 17) / (1 << 12),
.minute = time % (1 << 12) / (1 << 6),
.seconds = time % (1 << 6)
};

*put_date = date_result;
Expand All @@ -40,7 +40,8 @@ int get_date(struct Date *put_date){

int set_date(const struct Date *set_date){
date = set_date->year * (1 << 9) + set_date->month * (1 << 5) + set_date->day;
time = set_date->day_of_week * (1 << 17) + set_date->hour * (1 << 12) + set_date->minute * (1 << 6) + set_date->seconds;
time = set_date->day_of_week *
(1 << 17) + set_date->hour * (1 << 12) + set_date->minute * (1 << 6) + set_date->seconds;

syscall_return_t rval = command(DRIVER_NUM_RTC, 2, date, time);
return tock_command_return_novalue_to_returncode(rval);
Expand Down
Binary file removed simple-ble/build/cortex-m0/simple-ble.a
Binary file not shown.
Binary file removed simple-ble/build/cortex-m3/simple-ble.a
Binary file not shown.
Binary file removed simple-ble/build/cortex-m4/simple-ble.a
Binary file not shown.
Binary file removed simple-ble/build/cortex-m7/simple-ble.a
Binary file not shown.

0 comments on commit 8bcf09e

Please sign in to comment.