1-Wire® library for mbed. Complete 1-Wire library that supports our silicon masters along with a bit-bang master on the MAX32600MBED platform with one common interface for mbed. Slave support has also been included and more slaves will be added as time permits.
Dependents: MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more
Superseded by MaximInterface.
Diff: OneWire_Masters/DS2465/DS2465.cpp
- Revision:
- 48:6f9208ae280e
- Parent:
- 47:307dc45952db
- Child:
- 69:f915c4c59a69
diff -r 307dc45952db -r 6f9208ae280e OneWire_Masters/DS2465/DS2465.cpp --- a/OneWire_Masters/DS2465/DS2465.cpp Thu Apr 07 10:26:26 2016 -0500 +++ b/OneWire_Masters/DS2465/DS2465.cpp Thu Apr 07 11:26:20 2016 -0500 @@ -86,32 +86,32 @@ OneWireMaster::CmdResult DS2465::computeNextMasterSecret(bool swap, unsigned int pageNum, PageRegion region) { - std::uint8_t command[2] = { CMD_CNMS, (swap ? (0xC8 | (pageNum << 4) | region) : 0xBF) }; + std::uint8_t command[2] = { CMD_CNMS, (std::uint8_t)(swap ? (0xC8 | (pageNum << 4) | region) : 0xBF) }; return writeMemory(ADDR_CMD_REG, command, 2); } OneWireMaster::CmdResult DS2465::computeWriteMac(bool regwrite, bool swap, unsigned int pageNum, unsigned int segmentNum) const { - std::uint8_t command[2] = { CMD_CSWM, ((regwrite << 7) | (swap << 6) | (pageNum << 4) | segmentNum) }; + std::uint8_t command[2] = { CMD_CSWM, (std::uint8_t)((regwrite << 7) | (swap << 6) | (pageNum << 4) | segmentNum) }; return cWriteMemory(ADDR_CMD_REG, command, 2); } OneWireMaster::CmdResult DS2465::computeAuthMac(bool swap, unsigned int pageNum, PageRegion region) const { - std::uint8_t command[2] = { CMD_CSAM, (swap ? (0xC8 | (pageNum << 4) | region) : 0xBF) }; + std::uint8_t command[2] = { CMD_CSAM, (std::uint8_t)(swap ? (0xC8 | (pageNum << 4) | region) : 0xBF) }; return cWriteMemory(ADDR_CMD_REG, command, 2); } OneWireMaster::CmdResult DS2465::computeSlaveSecret(bool swap, unsigned int pageNum, PageRegion region) { - std::uint8_t command[2] = { CMD_CSS, (swap ? (0xC8 | (pageNum << 4) | region) : 0xBF) }; + std::uint8_t command[2] = { CMD_CSS, (std::uint8_t)(swap ? (0xC8 | (pageNum << 4) | region) : 0xBF) }; return writeMemory(ADDR_CMD_REG, command, 2); } -ISha256MacCoprocessor::CmdResult DS2465::setMasterSecret(const Secret & secret) +ISha256MacCoprocessor::CmdResult DS2465::setMasterSecret(const Secret & masterSecret) { OneWireMaster::CmdResult result; - result = writeMemory(ADDR_SPAD, secret, secret.length); + result = writeMemory(ADDR_SPAD, masterSecret, masterSecret.length); if (result == OneWireMaster::Success) result = copyScratchpadToSecret(); if (result == OneWireMaster::Success) @@ -190,7 +190,7 @@ OneWireMaster::CmdResult DS2465::copyScratchpad(bool destSecret, unsigned int pageNum, bool notFull, unsigned int segmentNum) { - std::uint8_t command[2] = { CMD_CPS, (destSecret ? 0 : (0x80 | (pageNum << 4) | (notFull << 3) | segmentNum)) }; + std::uint8_t command[2] = { CMD_CPS, (std::uint8_t)(destSecret ? 0 : (0x80 | (pageNum << 4) | (notFull << 3) | segmentNum)) }; return writeMemory(ADDR_CMD_REG, command, 2); } @@ -242,7 +242,7 @@ // SS indicates byte containing search direction bit value in msbit OneWireMaster::CmdResult result; - std::uint8_t command[2] = { CMD_1WT, ((search_direction == DIRECTION_WRITE_ONE) ? 0x80 : 0x00) }; + std::uint8_t command[2] = { CMD_1WT, (std::uint8_t)((search_direction == DIRECTION_WRITE_ONE) ? 0x80 : 0x00) }; result = writeMemory(ADDR_CMD_REG, command, 2); if (result == OneWireMaster::Success) { @@ -291,7 +291,7 @@ OneWireMaster::CmdResult DS2465::OWWriteBlock(bool tx_mac, const std::uint8_t *tran_buf, std::uint8_t tran_len) { OneWireMaster::CmdResult result; - std::uint8_t command[2] = { CMD_1WTB, (tx_mac ? 0xFF : tran_len) }; + std::uint8_t command[2] = { CMD_1WTB, (std::uint8_t)(tx_mac ? 0xFF : tran_len) }; if (!tx_mac) { @@ -386,7 +386,7 @@ if (result != OneWireMaster::Success) return result; - std::uint8_t command[2] = { CMD_1WSB, (sendrecvbit ? 0x80 : 0x00) }; + std::uint8_t command[2] = { CMD_1WSB, (std::uint8_t)(sendrecvbit ? 0x80 : 0x00) }; std::uint8_t status; result = writeMemory(ADDR_CMD_REG, command, 2);