diff --git a/ADC.cpp b/ADC.cpp index cd03bf4e..cff5d44f 100644 --- a/ADC.cpp +++ b/ADC.cpp @@ -6,13 +6,13 @@ Pin ADC_Pins[] = ADC1_PINS; ADConverter::ADConverter(byte line, uint channel) { - assert_param(line >= 1 && line <= 3); + assert_param2(line >= 1 && line <= 3, "ADC Line"); Line = line; Channel = channel; - uint dat = 1; - Count = 0; + uint dat = 1; + Count = 0; for(int i=0; iRegister(OnPress, this); @@ -31,7 +30,6 @@ Button_magnetic::Button_magnetic(Pin key, Pin led, bool ledInvert, Pin relay_pin { Init(); - assert_param(key != P0); Key = new InputPort(key); Key->Register(OnPress, this); diff --git a/App/Sensor.cpp b/App/Sensor.cpp index a0677df5..136358b4 100644 --- a/App/Sensor.cpp +++ b/App/Sensor.cpp @@ -19,7 +19,6 @@ Sensor::Sensor(Pin key, Pin led, Pin buzzer) { Init(); - assert_param(key != P0); Key = new InputPort(key); Key->Register(OnPress, this); @@ -31,7 +30,6 @@ Sensor::Sensor(Pin key, Pin led, bool ledInvert, Pin buzzer, bool buzzerInvert) { Init(); - assert_param(key != P0); Key = new InputPort(key); Key->Register(OnPress, this); diff --git a/Debug.cpp b/Debug.cpp index 107a3f77..576eac4d 100644 --- a/Debug.cpp +++ b/Debug.cpp @@ -51,7 +51,6 @@ void* operator new(uint size) if((uint)p + size + 0x40 >= end) mem_printf(" + %d near HeapEnd=0x%08x", size, end); } - assert_param(p); return p; } @@ -81,7 +80,6 @@ void* operator new[](uint size) uint end = __get_MSP(); if((uint)p + size + 0x40 >= end) mem_printf(" + %d near HeapEnd=0x%08x", size, end); } - assert_param(p); return p; } diff --git a/Drivers/AT45DB.cpp b/Drivers/AT45DB.cpp index 8064a33d..6a2f6c92 100644 --- a/Drivers/AT45DB.cpp +++ b/Drivers/AT45DB.cpp @@ -70,7 +70,7 @@ bool AT45DB::WaitForEnd() and put the value of the status register in FLASH_Status variable */ status = _spi->Write(Dummy_Byte); } - while ((status & 0x80) == RESET && --retry); /* Busy in progress */ + while ((status & 0x80) == 0 && --retry); /* Busy in progress */ // 重试次数没有用完,才返回成功 return retry > 0; diff --git a/Drivers/NRF24L01.cpp b/Drivers/NRF24L01.cpp index b3d26865..8e471fc4 100644 --- a/Drivers/NRF24L01.cpp +++ b/Drivers/NRF24L01.cpp @@ -840,8 +840,6 @@ bool NRF24L01::SendTo(const Array& bs, const Array& addr) // 检查要发送数据的长度 uint len = bs.Length(); byte pw = 32; - if(pw && len > pw) debug_printf("%d > %d \r\n", len, pw); - assert_param(pw == 0 || len <= pw); if(pw > 0) len = pw; Array bs2(bs.GetBuffer(), len); WriteBuf(cmd, bs2); diff --git a/I2C.cpp b/I2C.cpp index 67a40296..c98b020e 100644 --- a/I2C.cpp +++ b/I2C.cpp @@ -208,7 +208,7 @@ void HardI2C::Init(byte index, uint speedHz) _index = index; I2C_TypeDef* g_I2Cs[] = I2CS; - assert_param(_index < ArrayLength(g_I2Cs)); + assert_param2(_index < ArrayLength(g_I2Cs), "I2C::Init"); _IIC = g_I2Cs[_index]; SCL.OpenDrain = true; diff --git a/Net/ESP8266.cpp b/Net/ESP8266.cpp index 8bb18ff2..ab9c8d99 100644 --- a/Net/ESP8266.cpp +++ b/Net/ESP8266.cpp @@ -2,8 +2,6 @@ ESP8266::ESP8266(ITransport* port, Pin rst) { - assert_param(port); - Set(port); if(rst != P0) _rst.Set(rst); diff --git a/Net/Net.cpp b/Net/Net.cpp index 383284b5..b6981fe7 100644 --- a/Net/Net.cpp +++ b/Net/Net.cpp @@ -60,8 +60,6 @@ IPAddress& IPAddress::operator=(const Array& arr) // 重载索引运算符[],让它可以像数组一样使用下标索引。 byte& IPAddress::operator[](int i) { - assert_param(i >= 0 && i < 4); - return ((byte*)&Value)[i]; } @@ -234,8 +232,6 @@ MacAddress& MacAddress::operator=(const Array& arr) // 重载索引运算符[],让它可以像数组一样使用下标索引。 byte& MacAddress::operator[](int i) { - assert_param(i >= 0 && i < 6); - return ((byte*)&Value)[i]; } diff --git a/TinyNet/Tiny.cpp b/TinyNet/Tiny.cpp index f490f147..1bcbb20e 100644 --- a/TinyNet/Tiny.cpp +++ b/TinyNet/Tiny.cpp @@ -67,7 +67,7 @@ void Fix2401(void* param) } } -ITransport* Create2401(SPI_TypeDef* spi_, Pin ce, Pin irq, Pin power, bool powerInvert, IDataPort* led) +ITransport* Create2401(byte spi_, Pin ce, Pin irq, Pin power, bool powerInvert, IDataPort* led) { auto spi = new Spi(spi_, 10000000, true); auto nrf = new NRF24L01(); diff --git a/TinyNet/Tiny.h b/TinyNet/Tiny.h index 4f899bc1..0be64aad 100644 --- a/TinyNet/Tiny.h +++ b/TinyNet/Tiny.h @@ -14,7 +14,7 @@ void Setup(ushort code, const char* name, COM_Def message = COM1, int baudRate = void* InitConfig(void* data, uint size); void ClearConfig(); -ITransport* Create2401(SPI_TypeDef* spi_, Pin ce, Pin irq, Pin power = P0, bool powerInvert = false, IDataPort* led = NULL); +ITransport* Create2401(byte spi, Pin ce, Pin irq, Pin power = P0, bool powerInvert = false, IDataPort* led = NULL); ITransport* CreateShunCom(COM_Def index, int baudRate, Pin rst, Pin power, Pin slp, Pin cfg, IDataPort* led = NULL); TinyClient* CreateTinyClient(ITransport* port); diff --git a/TokenNet/Token.cpp b/TokenNet/Token.cpp index 7076f896..5a2ff5e0 100644 --- a/TokenNet/Token.cpp +++ b/TokenNet/Token.cpp @@ -42,7 +42,7 @@ static void OnDhcpStop5500(void* sender, void* param) if(dhcp->Times <= 1) Sys.AddTask(StartGateway, net, 0, -1, "启动网关"); } -ISocketHost* Token::CreateW5500(SPI_TypeDef* spi_, Pin irq, Pin rst, Pin power, IDataPort* led) +ISocketHost* Token::CreateW5500(byte spi_, Pin irq, Pin rst, Pin power, IDataPort* led) { debug_printf("\r\nW5500::Create \r\n"); @@ -205,7 +205,7 @@ void Fix2401(void* param) } } -ITransport* Token::Create2401(SPI_TypeDef* spi_, Pin ce, Pin irq, Pin power, bool powerInvert, IDataPort* led) +ITransport* Token::Create2401(byte spi_, Pin ce, Pin irq, Pin power, bool powerInvert, IDataPort* led) { static Spi spi(spi_, 10000000, true); static NRF24L01 nrf; diff --git a/TokenNet/Token.h b/TokenNet/Token.h index c55c07c9..50b1cb77 100644 --- a/TokenNet/Token.h +++ b/TokenNet/Token.h @@ -18,10 +18,10 @@ class Token public: static void Setup(ushort code, const char* name, COM_Def message = COM1, int baudRate = 0); - static ISocketHost* CreateW5500(SPI_TypeDef* spi, Pin irq, Pin rst = P0, Pin power = P0, IDataPort* led = NULL); - static ISocketHost* Create2860(SPI_TypeDef* spi_, Pin irq, Pin rst); + static ISocketHost* CreateW5500(byte spi, Pin irq, Pin rst = P0, Pin power = P0, IDataPort* led = NULL); + static ISocketHost* Create2860(byte spi, Pin irq, Pin rst); - static ITransport* Create2401(SPI_TypeDef* spi_, Pin ce, Pin irq, Pin power = P0, bool powerInvert = false, IDataPort* led = NULL); + static ITransport* Create2401(byte spi, Pin ce, Pin irq, Pin power = P0, bool powerInvert = false, IDataPort* led = NULL); static ITransport* CreateShunCom(COM_Def index, int baudRate, Pin rst, Pin power, Pin slp, Pin cfg, IDataPort* led = NULL); static TokenClient* CreateClient(ISocketHost* host); diff --git a/TokenNet/Token2860.cpp b/TokenNet/Token2860.cpp index 8df29892..21af133f 100644 --- a/TokenNet/Token2860.cpp +++ b/TokenNet/Token2860.cpp @@ -44,7 +44,7 @@ static void OnDhcpStop(void* sender, void* param) if(dhcp->Times <= 1) Sys.AddTask(StartGateway, tip, 0, -1, "启动网关"); } -ISocketHost* Token::Create2860(SPI_TypeDef* spi_, Pin irq, Pin rst) +ISocketHost* Token::Create2860(byte spi_, Pin irq, Pin rst) { debug_printf("\r\nENC2860::Create \r\n");