diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index cf1db49..2baae2c 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/README.md b/README.md index 7b6f9c6..b5002f6 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,22 @@ RT-Thread 软件打开 [点击下载](https://www.rt-thread.org/download.html#do --- +#### 控制台命令 +| 命令 | 作用 | +| ---------------- | ------------ | +| log_lte | 4G与mqtt的log | +| log_moddbus | modbus的log | +| log_adc | adc的log | +| no_log | 关闭log | +| IO_key < 0-8 > < 1 0 >| 指定输出端口改变电平 | + + + + +--- + #### 空间与引脚分配 - MB85RS64储存分布说明,8192 字节 diff --git a/applications/IO/inout.c b/applications/IO/inout.c index 52d7b21..767eb16 100644 --- a/applications/IO/inout.c +++ b/applications/IO/inout.c @@ -136,6 +136,60 @@ rt_uint32_t get_IO_count(rt_uint8_t io){ return IO.IO_Data[io].Temp_Count; } + +/** + * @brief 计算转速,500毫秒的中断次数乘2为1秒次数,1秒次数乘60为rpm单位转速 + * @param none + * @return: None + */ +void updateSpeed(void) +{ + rt_uint16_t tmp_start = 0; + rt_uint16_t tmp_end = 0; + //rt_tick_t tick_start = 0; + //rt_tick_t tick_end = 0; + rt_uint16_t temp = 0; + + temp = IO.IO_Data[IO.IO_Flag.Speed_io].Speed; + tmp_start = IO.IO_Data[IO.IO_Flag.Speed_io].Temp_Count; + + //tick_start = rt_tick_get_millisecond(); + rt_thread_mdelay(500); + //tick_end = rt_tick_get_millisecond(); + + tmp_end = IO.IO_Data[IO.IO_Flag.Speed_io].Temp_Count; + + if (tmp_end < tmp_start) + { + IO.IO_Data[IO.IO_Flag.Speed_io].Speed = (tmp_end + 65535 - tmp_start) * 120; + } + else + { + IO.IO_Data[IO.IO_Flag.Speed_io].Speed = (tmp_end - tmp_start) * 120; + } + + if (IO.IO_Flag.log) { + rt_kprintf("Speed: %d %d\n", IO.IO_Flag.Speed_io+1, IO.IO_Data[IO.IO_Flag.Speed_io].Speed); + } + + // if(tmp_end < tmp_start){ + // IO.IO_Data[i].Temp_Speed = (tmp_end + 65535 - tmp_start) / ((tick_end - tick_start) / 1000); + // } + // else { + // IO.IO_Data[i].Temp_Speed = (tmp_end - tmp_start) / ((tick_end - tick_start) / 1000); + // } + + if (temp != IO.IO_Data[IO.IO_Flag.Speed_io].Speed) + { + IO.IO_Flag.SpeedUpdateFlag = 1; + } + else + { + IO.IO_Flag.SpeedUpdateFlag = 0; + } + +} + //控制台更改电平 void IO_key(int argc, char**argv){ diff --git a/applications/IO/inout.h b/applications/IO/inout.h index c6b21a6..bd2d7dc 100644 --- a/applications/IO/inout.h +++ b/applications/IO/inout.h @@ -55,6 +55,7 @@ typedef struct rt_uint8_t Needle_io;//针数端口 rt_uint8_t SpeedUpdateFlag; // 速度更新标志位 rt_uint8_t NeedleCountUpdateFlag; // 针数更新标志位 + rt_uint8_t log; } Flag; // IO状态 typedef struct diff --git a/applications/main.c b/applications/main.c index 04bac41..51135ac 100644 --- a/applications/main.c +++ b/applications/main.c @@ -14,9 +14,14 @@ #define DBG_LVL DBG_LOG #include #include +#include +#include int main(void) { + spi_flash_mb85rs_init(); + read_config(); + thread_IO_Key(); thread_Wireless(); thread_LCD(); diff --git a/applications/thread/thread.c b/applications/thread/thread.c index 413493b..f3625da 100644 --- a/applications/thread/thread.c +++ b/applications/thread/thread.c @@ -65,7 +65,6 @@ static void Task_IO_Key(void *parameter) gpio_output_init(); while (1) { -// chage_IO_key(); // updateKeyValue(); rt_thread_mdelay(1); } @@ -73,11 +72,11 @@ static void Task_IO_Key(void *parameter) static void Task_IO_Speed(void *parameter) { - spi_flash_mb85rs_init(); - read_config(); +// spi_flash_mb85rs_init(); +// read_config(); while (1) { - +// updateSpeed(); rt_thread_mdelay(1000); } }