Skip to content

Commit

Permalink
added unique ID
Browse files Browse the repository at this point in the history
  • Loading branch information
odinthenerd committed Nov 5, 2021
1 parent 1616278 commit 657aeaf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/modm/driver/rtc/mcp7941.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct mcp7941
constexpr DateTime getDateTime(){
return date_time;
}
uint8_t unique_id[8];
private:
DateTime date_time;
};
Expand Down Expand Up @@ -78,6 +79,9 @@ class Mcp7941 : public mcp7941,
inline modm::ResumableResult<bool>
setDateTime(DateTime);

inline modm::ResumableResult<bool>
getUniqueID();

private:
mcp7941::Data &data;

Expand All @@ -89,6 +93,8 @@ class Mcp7941 : public mcp7941,
const uint8_t addr_days = 0x04;
const uint8_t addr_months = 0x05;
const uint8_t addr_years = 0x06;

const uint8_t addr_unique_id = 0xF0;
};

} // namespace modm
Expand Down
14 changes: 11 additions & 3 deletions src/modm/driver/rtc/mcp7941_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,24 @@ modm::Mcp7941<I2cMaster>::getDateTime(){
this->transaction.configureWriteRead(&addr_seconds, 1, scratch, 7);
if(RF_CALL(this->runTransaction())){
data.date_time.seconds = scratch[0];
data.date_time.seconds = scratch[1];
data.date_time.minutes = scratch[2];
data.date_time.hours = scratch[3];
data.date_time.minutes = scratch[1];
data.date_time.hours = scratch[2];
//no need for day of the week
data.date_time.days = scratch[4];
data.date_time.months = scratch[5];
data.date_time.years = scratch[6];
}
RF_END_RETURN(true);
}

template < typename I2cMaster >
inline modm::ResumableResult<bool>
modm::Mcp7941<I2cMaster>::getUniqueID(){
RF_BEGIN();
this->transaction.configureWriteRead(&addr_unique_id, 1, data.unique_id, 8);
RF_END_RETURN_CALL(this->runTransaction());
}

template < typename I2cMaster >
inline modm::ResumableResult<bool>
modm::Mcp7941<I2cMaster>::setDateTime(mcp7941::DateTime dt){
Expand Down

0 comments on commit 657aeaf

Please sign in to comment.