I wrote "lightweight" time library and I have struct and typedef like this:
struct tmt {
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
uint8_t weekday;
uint8_t is_dst;
};
typedef struct tmt tm_t;
I have a function that returns tm_t
:
tm_t rtc_get_current_time(void){
tm_t tm;
xSemaphoreTake(rtc_mutex, RTC_MUTEX_MAX_WAIT);
tm = rtc.current_time;
xSemaphoreGive(rtc_mutex);
return tm;
}
And I want to use it like this:
tm_t s;
s = rtc_get_current_time(); // error is here
I'm getting this error:
incompatible types when assigning to type 'tm_t' {aka 'struct tmt'} from type 'int'
I have also tried to change function and variable like this:
struct tmt rtc_get_current_time(void){
tm_t tm;
xSemaphoreTake(rtc_mutex, RTC_MUTEX_MAX_WAIT);
tm = rtc.current_time;
xSemaphoreGive(rtc_mutex);
return tm;
}
struct tmt tm = rtc_get_current_time();
What I am doing wrong?