Ver código fonte

[fix] Check address range [0x00, 0x7F]

wuhanstudio 2 anos atrás
pai
commit
ea2e27d4ad
1 arquivos alterados com 4 adições e 0 exclusões
  1. 4 0
      src/i2c_tools.cpp

+ 4 - 0
src/i2c_tools.cpp

@@ -53,6 +53,10 @@ static void i2c(int argc,char *argv[])
                 }
             }
         #endif
+            if (start_addr >= 0x80 || stop_addr > 0x80) {
+                rt_kprintf("[i2c] The addresses only range from 0x00 to 0x7F\n");
+                return;
+            }
             if (start_addr >= stop_addr) {
                 rt_kprintf("[i2c] The stop address should be higher than the start address\n");
                 return;