diff --git a/examples/UnitUnified/NFCA/Detect/main/Detect.cpp b/examples/UnitUnified/NFCA/Detect/main/Detect.cpp index 7e08bde..8ad317a 100644 --- a/examples/UnitUnified/NFCA/Detect/main/Detect.cpp +++ b/examples/UnitUnified/NFCA/Detect/main/Detect.cpp @@ -51,7 +51,7 @@ void setup() auto pin_num_scl = M5.getPin(m5::pin_name_t::port_a_scl); M5_LOGI("getPin: SDA:%u SCL:%u", pin_num_sda, pin_num_scl); Wire.end(); - Wire.begin(pin_num_sda, pin_num_scl, 100 * 1000U); + Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U); if (!Units.add(unit, Wire) || !Units.begin()) { M5_LOGE("Failed to begin"); diff --git a/examples/UnitUnified/NFCF/Detect/main/Detect.cpp b/examples/UnitUnified/NFCF/Detect/main/Detect.cpp index 0a5e164..9ccaf9f 100644 --- a/examples/UnitUnified/NFCF/Detect/main/Detect.cpp +++ b/examples/UnitUnified/NFCF/Detect/main/Detect.cpp @@ -57,7 +57,7 @@ void setup() auto pin_num_scl = M5.getPin(m5::pin_name_t::port_a_scl); M5_LOGI("getPin: SDA:%u SCL:%u", pin_num_sda, pin_num_scl); Wire.end(); - Wire.begin(pin_num_sda, pin_num_scl, 100 * 1000U); + Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U); if (!Units.add(unit, Wire) || !Units.begin()) { M5_LOGE("Failed to begin"); diff --git a/src/nfc/f/nfcf.cpp b/src/nfc/f/nfcf.cpp index 73bfe78..4ca55cf 100644 --- a/src/nfc/f/nfcf.cpp +++ b/src/nfc/f/nfcf.cpp @@ -10,8 +10,8 @@ #include "nfcf.hpp" #include -#include #include +#include namespace { constexpr char name_unknown[] = "Unknown"; @@ -19,7 +19,7 @@ constexpr char name_standard[] = "FeliCa Standard"; constexpr char name_lite[] = "FeliCa Lite"; constexpr char name_lite_s[] = "FeliCa Lite-S"; constexpr char name_plug[] = "FeliCa Plug"; -constexpr const char* name_table[] = {name_unknown, name_standard, name_lite, name_lite_s, name_plug}; +constexpr const char *name_table[] = {name_unknown, name_standard, name_lite, name_lite_s, name_plug}; // Maximum block number (Note that there are gaps in the blocks) constexpr uint16_t max_block_table[] = {0, 0, 0x88, 0xA0, 0}; @@ -31,7 +31,7 @@ constexpr uint16_t max_write_block_table[] = {0, 1, 1, 1, 1}; // [first/last] constexpr uint8_t user_block_table[][2] = {{0XFF, 0XFF}, {0XFF, 0XFF}, {0x00, 0x0D}, {0x00, 0x0D}, {0XFF, 0XFF}}; -std::string to_string(const uint8_t* p, const uint8_t size) +std::string to_string(const uint8_t *p, const uint8_t size) { char buf[2 * size + 1]{}; if (p && size) { @@ -86,15 +86,6 @@ uint8_t get_maxumum_write_blocks(const Type t) return max_write_block_table[idx < m5::stl::size(max_block_table) ? idx : 0]; } -bool make_session_key(uint8_t sk1[8], uint8_t sk2[8], const uint8_t ck1[8], const uint8_t ck2[8], const uint8_t rc1[8], - const uint8_t rc2[8]) -{ - if (!sk1 || !sk2 || !ck1 || !ck2 || !rc1 || !rc2) { - return false; - } - return false; -} - // std::string PICC::idmAsString() const { diff --git a/src/nfc/f/nfcf.hpp b/src/nfc/f/nfcf.hpp index b17baa9..6832725 100644 --- a/src/nfc/f/nfcf.hpp +++ b/src/nfc/f/nfcf.hpp @@ -499,14 +499,6 @@ inline bool can_write_reg(const REG& o, const REG& n) return (o.regA() >= n.regA()) && (o.regB() >= n.regB()); } -///@name AES for MAC -///@{ - -bool make_session_key(uint8_t sk1[8], uint8_t sk2[8], const uint8_t ck1[8], const uint8_t ck2[8], const uint8_t rc1[8], - const uint8_t rc2[8]); - -///@} - } // namespace f } // namespace nfc } // namespace m5 diff --git a/src/unit/unit_ST25R3916.cpp b/src/unit/unit_ST25R3916.cpp index 481a7aa..46a7151 100644 --- a/src/unit/unit_ST25R3916.cpp +++ b/src/unit/unit_ST25R3916.cpp @@ -512,78 +512,78 @@ bool UnitST25R3916::read_register8(const uint8_t reg, uint8_t& v) { TRANSACTION_GUARD(); v = 0; - return readRegister8(to_read_reg(reg), v, 0, false); + return readRegister8(to_read_reg(reg), v, 0, false /*I2C, SPI not used*/); } bool UnitST25R3916::read_register8(const uint16_t reg, uint8_t& v) { TRANSACTION_GUARD(); v = 0; - return readRegister8(to_read_reg(reg), v, 0, false); + return readRegister8(to_read_reg(reg), v, 0, false /*I2C, SPI not used*/); } bool UnitST25R3916::write_register8(const uint8_t reg, const uint8_t v) { TRANSACTION_GUARD(); - return writeRegister8(to_write_reg(reg), v, false); + return writeRegister8(to_write_reg(reg), v, true /*I2C, SPI not used*/); } bool UnitST25R3916::write_register8(const uint16_t reg, const uint8_t v) { TRANSACTION_GUARD(); - return writeRegister8(to_write_reg(reg), v, false); + return writeRegister8(to_write_reg(reg), v, true /*I2C, SPI not used*/); } bool UnitST25R3916::read_register16(const uint8_t reg, uint16_t& v) { TRANSACTION_GUARD(); v = 0; - return readRegister16BE(to_read_reg(reg), v, 0, false); + return readRegister16BE(to_read_reg(reg), v, 0, false /*I2C, SPI not used*/); } bool UnitST25R3916::read_register16(const uint16_t reg, uint16_t& v) { TRANSACTION_GUARD(); v = 0; - return readRegister16BE(to_read_reg(reg), v, 0, false); + return readRegister16BE(to_read_reg(reg), v, 0, false /*I2C, SPI not used*/); } bool UnitST25R3916::write_register16(const uint8_t reg, const uint16_t v) { TRANSACTION_GUARD(); - return writeRegister16BE(to_write_reg(reg), v, false); + return writeRegister16BE(to_write_reg(reg), v, true /*I2C, SPI not used*/); } bool UnitST25R3916::write_register16(const uint16_t reg, const uint16_t v) { TRANSACTION_GUARD(); - return writeRegister16BE(to_write_reg(reg), v, false); + return writeRegister16BE(to_write_reg(reg), v, true /*I2C, SPI not used*/); } bool UnitST25R3916::read_register32(const uint8_t reg, uint32_t& v) { TRANSACTION_GUARD(); v = 0; - return readRegister32BE(to_read_reg(reg), v, 0, false); + return readRegister32BE(to_read_reg(reg), v, 0, false /*I2C, SPI not used*/); } bool UnitST25R3916::read_register32(const uint16_t reg, uint32_t& v) { TRANSACTION_GUARD(); v = 0; - return readRegister32BE(to_read_reg(reg), v, 0, false); + return readRegister32BE(to_read_reg(reg), v, 0, false /*I2C, SPI not used*/); } bool UnitST25R3916::write_register32(const uint8_t reg, const uint32_t v) { TRANSACTION_GUARD(); - return writeRegister32BE(to_write_reg(reg), v, false); + return writeRegister32BE(to_write_reg(reg), v, true /*I2C, SPI not used*/); } bool UnitST25R3916::write_register32(const uint16_t reg, const uint32_t v) { TRANSACTION_GUARD(); - return writeRegister32BE(to_write_reg(reg), v, false); + return writeRegister32BE(to_write_reg(reg), v, true /*I2C, SPI not used*/); } bool UnitST25R3916::modify_bit_register8(const uint8_t reg, const uint8_t set_mask, const uint8_t clear_mask) diff --git a/src/unit/unit_ST25R3916.hpp b/src/unit/unit_ST25R3916.hpp index a4cf9ed..74390f2 100644 --- a/src/unit/unit_ST25R3916.hpp +++ b/src/unit/unit_ST25R3916.hpp @@ -37,6 +37,9 @@ class UnitST25R3916 : public Component { public: explicit UnitST25R3916(const uint8_t arg = DEFAULT_ADDRESS) : Component(arg) { + auto ccfg = component_config(); + ccfg.clock = 400 * 1000U; + component_config(ccfg); } virtual ~UnitST25R3916() = default; @@ -1863,7 +1866,7 @@ public: @warning FeliCa Standard only */ bool nfcfRequestSystemCode(uint16_t code_list[255], uint8_t& code_num, const m5::nfc::f::PICC& picc); - + /*! @brief Read the area that does not require authentication @param[out] rx Buffer(at least 16 bytes * number of blocks)