@@ 53,19 53,26 @@ static inline uint8_t mod10(uint8_t v)
*/
int mcp7940n_init(const struct tm *tm)
{
- struct mcp7940n_timekeeping_regs tmp;
+ uint8_t control;
+ uint8_t sec;
+ int ret;
- if (!mcp7940n_read(offsetof(struct mcp7940n, timekeeping), &tmp,
- sizeof(tmp)))
+ if (!mcp7940n_read(offsetof(struct mcp7940n, timekeeping.sec), &sec,
+ sizeof(sec)))
return -1;
- if (tmp.sec & MCP7940N_SEC_ST)
- return +1; /* already started, don't disturb the time */
+ if (sec & MCP7940N_SEC_ST) {
+ ret = +1; /* already running, don't disturb the time */
+ } else {
+ if (!mcp7940n_settime(tm))
+ return -1;
- if (!mcp7940n_settime(tm))
- return -1;
+ ret = 0; /* started just now */
+ }
- return 0;
+ /* ... initialize MFP here as desired ... */
+
+ return ret;
}
/*