更换timer11,解决闪烁问题
This commit is contained in:
parent
f71b4c3e1f
commit
62dbf65bf2
27
.config
27
.config
|
@ -23,7 +23,10 @@ CONFIG_RT_HOOK_USING_FUNC_PTR=y
|
||||||
CONFIG_RT_USING_IDLE_HOOK=y
|
CONFIG_RT_USING_IDLE_HOOK=y
|
||||||
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
|
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
|
||||||
CONFIG_IDLE_THREAD_STACK_SIZE=1024
|
CONFIG_IDLE_THREAD_STACK_SIZE=1024
|
||||||
# CONFIG_RT_USING_TIMER_SOFT is not set
|
CONFIG_RT_USING_TIMER_SOFT=y
|
||||||
|
CONFIG_RT_TIMER_THREAD_PRIO=4
|
||||||
|
CONFIG_RT_TIMER_THREAD_STACK_SIZE=512
|
||||||
|
# CONFIG_RT_USING_TIMER_ALL_SOFT is not set
|
||||||
# CONFIG_RT_USING_CPU_USAGE_TRACER is not set
|
# CONFIG_RT_USING_CPU_USAGE_TRACER is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -326,7 +329,10 @@ CONFIG_RT_USING_POSIX_SOCKET=y
|
||||||
# end of Interprocess Communication (IPC)
|
# end of Interprocess Communication (IPC)
|
||||||
# end of POSIX (Portable Operating System Interface) layer
|
# end of POSIX (Portable Operating System Interface) layer
|
||||||
|
|
||||||
# CONFIG_RT_USING_CPLUSPLUS is not set
|
CONFIG_RT_USING_CPLUSPLUS=y
|
||||||
|
# CONFIG_RT_USING_CPLUSPLUS11 is not set
|
||||||
|
# CONFIG_RT_USING_CPP_WRAPPER is not set
|
||||||
|
# CONFIG_RT_USING_CPP_EXCEPTIONS is not set
|
||||||
# end of C/C++ and POSIX layer
|
# end of C/C++ and POSIX layer
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -929,7 +935,12 @@ CONFIG_PKG_RT_VSNPRINTF_FULL_VER="latest"
|
||||||
# CONFIG_PKG_USING_CAIRO is not set
|
# CONFIG_PKG_USING_CAIRO is not set
|
||||||
# CONFIG_PKG_USING_PIXMAN is not set
|
# CONFIG_PKG_USING_PIXMAN is not set
|
||||||
# CONFIG_PKG_USING_PARTITION is not set
|
# CONFIG_PKG_USING_PARTITION is not set
|
||||||
# CONFIG_PKG_USING_PERF_COUNTER is not set
|
CONFIG_PKG_USING_PERF_COUNTER=y
|
||||||
|
CONFIG_PKG_PERF_COUNTER_PATH="/packages/system/perf_counter"
|
||||||
|
# CONFIG_PKG_PERF_COUNTER_USING_THREAD_STATISTIC is not set
|
||||||
|
CONFIG_PKG_USING_PERF_COUNTER_V2241=y
|
||||||
|
# CONFIG_PKG_USING_PERF_COUNTER_LATEST_VERSION is not set
|
||||||
|
CONFIG_PKG_PERF_COUNTER_VER="v2.2.4.1"
|
||||||
# CONFIG_PKG_USING_FILEX is not set
|
# CONFIG_PKG_USING_FILEX is not set
|
||||||
# CONFIG_PKG_USING_LEVELX is not set
|
# CONFIG_PKG_USING_LEVELX is not set
|
||||||
# CONFIG_PKG_USING_FLASHDB is not set
|
# CONFIG_PKG_USING_FLASHDB is not set
|
||||||
|
@ -1146,14 +1157,10 @@ CONFIG_NEC_DEVIATION=100
|
||||||
# end of Select infrared decoder
|
# end of Select infrared decoder
|
||||||
|
|
||||||
CONFIG_PKG_USING_DRV_INFRARED=y
|
CONFIG_PKG_USING_DRV_INFRARED=y
|
||||||
CONFIG_INFRARED_SEND=y
|
# CONFIG_INFRARED_SEND is not set
|
||||||
CONFIG_INFRARED_SEND_PWM="pwm3"
|
|
||||||
CONFIG_INFRARED_PWM_DEV_CHANNEL=4
|
|
||||||
CONFIG_INFRARED_SEND_HWTIMER="timer13"
|
|
||||||
CONFIG_INFRARED_MAX_SEND_SIZE=1000
|
|
||||||
CONFIG_INFRARED_RECEIVE=y
|
CONFIG_INFRARED_RECEIVE=y
|
||||||
CONFIG_INFRARED_RECEIVE_PIN=88
|
CONFIG_INFRARED_RECEIVE_PIN=88
|
||||||
CONFIG_INFRARED_RECEIVE_HWTIMER="timer14"
|
CONFIG_INFRARED_RECEIVE_HWTIMER="timer11"
|
||||||
# CONFIG_PKG_USING_INFRARED_V010 is not set
|
# CONFIG_PKG_USING_INFRARED_V010 is not set
|
||||||
CONFIG_PKG_USING_INFRARED_V011=y
|
CONFIG_PKG_USING_INFRARED_V011=y
|
||||||
# CONFIG_PKG_USING_INFRARED_LATEST_VERSION is not set
|
# CONFIG_PKG_USING_INFRARED_LATEST_VERSION is not set
|
||||||
|
@ -1646,7 +1653,7 @@ CONFIG_BSP_USING_UART6=y
|
||||||
# CONFIG_BSP_UART6_RX_USING_DMA is not set
|
# CONFIG_BSP_UART6_RX_USING_DMA is not set
|
||||||
# CONFIG_BSP_UART6_TX_USING_DMA is not set
|
# CONFIG_BSP_UART6_TX_USING_DMA is not set
|
||||||
CONFIG_BSP_USING_TIM=y
|
CONFIG_BSP_USING_TIM=y
|
||||||
# CONFIG_BSP_USING_TIM11 is not set
|
CONFIG_BSP_USING_TIM11=y
|
||||||
CONFIG_BSP_USING_TIM13=y
|
CONFIG_BSP_USING_TIM13=y
|
||||||
CONFIG_BSP_USING_TIM14=y
|
CONFIG_BSP_USING_TIM14=y
|
||||||
CONFIG_BSP_USING_PWM=y
|
CONFIG_BSP_USING_PWM=y
|
||||||
|
|
|
@ -40,3 +40,4 @@ RTE/
|
||||||
settings/
|
settings/
|
||||||
*.uvguix*
|
*.uvguix*
|
||||||
cconfig.h
|
cconfig.h
|
||||||
|
Arduino-IRremote-master
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
总算可以了
|
总算可以了
|
||||||
调整好针脚等可以运行了,但一闪一闪的,估计是线程切换的原因?
|
调整好针脚等可以运行了,但一闪一闪的,估计是线程切换的原因?
|
||||||
注释掉红外线线程,也没有用,改了优先级终于可以了
|
注释掉红外线线程,也没有用,改了优先级终于可以了
|
||||||
|
**破案了!lcd、红外线用的同一个timer14,[哭笑不得]😂**
|
||||||
|
换了个timer11就不闪了!!!
|
||||||
``` c
|
``` c
|
||||||
Snake_Thread = rt_thread_create("Snake_Thread", snake_entry, RT_NULL, THREAD_STACK_SIZE, 10, THREAD_TIMESLICE);
|
Snake_Thread = rt_thread_create("Snake_Thread", snake_entry, RT_NULL, THREAD_STACK_SIZE, 10, THREAD_TIMESLICE);
|
||||||
```
|
```
|
||||||
|
@ -54,4 +56,47 @@ if(page_chosen == 1)
|
||||||
{
|
{
|
||||||
rt_mdelay(1000);
|
rt_mdelay(1000);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 附:ringbuffer(环形缓冲区)
|
||||||
|
注意:RT-Thread 的 ringbuffer 组件并未提供线程阻塞的功能,因此 ringbuffer 本质上是一个全局共享的对象,多线程使用时注意使用互斥锁保护。
|
||||||
|
![alt text](image-3.png)
|
||||||
|
``` c
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <ipc/ringbuffer.h>
|
||||||
|
|
||||||
|
typedef struct rb_example {
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
} rb_example_t;
|
||||||
|
|
||||||
|
int ringbuffer_example(void)
|
||||||
|
{
|
||||||
|
rb_example_t data = {
|
||||||
|
.a = 1,
|
||||||
|
.b = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rt_ringbuffer * rb = rt_ringbuffer_create(sizeof(rb_example_t) * 2);
|
||||||
|
RT_ASSERT(rb != RT_NULL);
|
||||||
|
|
||||||
|
rt_kprintf("Put data to ringbuffer, a: %d b: %d size: %d\n", data.a, data.b, sizeof(data));
|
||||||
|
rt_ringbuffer_put(rb, (rt_uint8_t *)&data, sizeof(data));
|
||||||
|
|
||||||
|
|
||||||
|
rb_example_t recv_data;
|
||||||
|
rt_size_t recv = rt_ringbuffer_get(rb, (rt_uint8_t *)&recv_data, sizeof(recv_data));
|
||||||
|
RT_ASSERT(recv == sizeof(recv_data));
|
||||||
|
rt_kprintf("Get data from ringbuffer, a: %d b: %d size: %d\n", recv_data.a, recv_data.b, sizeof(recv_data));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MSH_CMD_EXPORT(ringbuffer_example, ringbuffer example);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### union(联合体)
|
||||||
|
约等于结构体
|
||||||
|
1. 可以通过v.u来操作一个uint32类型的对象,当需要将uint32变量的低端字节看做一个字符的时候,只需要访问v.c就可以了
|
||||||
|
2. 共享同一块大小的内存
|
Binary file not shown.
After Width: | Height: | Size: 107 KiB |
|
@ -25,21 +25,21 @@ void snake_compare(rt_uint8_t key)
|
||||||
rt_sprintf(tmp, "%02X", key);
|
rt_sprintf(tmp, "%02X", key);
|
||||||
rt_atomic_store(&snake_pressed, snake_max + 1);
|
rt_atomic_store(&snake_pressed, snake_max + 1);
|
||||||
|
|
||||||
if (rt_strcmp(tmp, "30") == 0)
|
if (rt_strcmp(tmp, "30") == 0|| rt_strcmp(tmp, "53") == 0)
|
||||||
if (rt_atomic_load(&now_direction) != 2)
|
if (rt_atomic_load(&now_direction) != 2)
|
||||||
rt_atomic_store(&now_direction, 0);
|
rt_atomic_store(&now_direction, 0);
|
||||||
|
|
||||||
if (rt_strcmp(tmp, "E8") == 0)
|
if (rt_strcmp(tmp, "E8") == 0|| rt_strcmp(tmp, "99") == 0)
|
||||||
if (rt_atomic_load(&now_direction) != 3)
|
if (rt_atomic_load(&now_direction) != 3)
|
||||||
rt_atomic_store(&now_direction, 1);
|
rt_atomic_store(&now_direction, 1);
|
||||||
if (rt_strcmp(tmp, "B0") == 0)
|
if (rt_strcmp(tmp, "B0") == 0|| rt_strcmp(tmp, "4B") == 0)
|
||||||
if (rt_atomic_load(&now_direction) != 0)
|
if (rt_atomic_load(&now_direction) != 0)
|
||||||
rt_atomic_store(&now_direction, 2);
|
rt_atomic_store(&now_direction, 2);
|
||||||
if (rt_strcmp(tmp, "68") == 0)
|
if (rt_strcmp(tmp, "68") == 0|| rt_strcmp(tmp, "83") == 0)
|
||||||
if (rt_atomic_load(&now_direction) != 1)
|
if (rt_atomic_load(&now_direction) != 1)
|
||||||
rt_atomic_store(&now_direction, 3);
|
rt_atomic_store(&now_direction, 3);
|
||||||
if (rt_strcmp(tmp, "88") == 0)
|
// if (rt_strcmp(tmp, "88") == 0)
|
||||||
page_chosen = (page_chosen % PAGE_MAX) + 1;
|
// page_chosen = (page_chosen % PAGE_MAX) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void myir_entry(void *parameter)
|
void myir_entry(void *parameter)
|
||||||
|
|
|
@ -199,14 +199,14 @@ void tmp_payload(void)
|
||||||
// sprintf(tmp, "Temp: %.1f;Humi: %.1f;Count: %d\n", Temp, Humi,++cnt);
|
// sprintf(tmp, "Temp: %.1f;Humi: %.1f;Count: %d\n", Temp, Humi,++cnt);
|
||||||
// rt_kprintf("\n%f %f tmp:%s\n",Humi,Temp,tmp);
|
// rt_kprintf("\n%f %f tmp:%s\n",Humi,Temp,tmp);
|
||||||
// make_file();
|
// make_file();
|
||||||
if (page_chosen == 2)
|
// if (page_chosen == 2)
|
||||||
{
|
// {
|
||||||
show_lcd();
|
// show_lcd();
|
||||||
}
|
// }
|
||||||
if (ps_data > 14)
|
// if (ps_data > 14)
|
||||||
{
|
// {
|
||||||
page_chosen = (page_chosen % PAGE_MAX) + 1;
|
// page_chosen = (page_chosen % PAGE_MAX) + 1;
|
||||||
}
|
// }
|
||||||
sprintf(tmp, "{\"params\":{\"temperature\":%.2f,\"humidity\":%.2f,\"LightLux\":%.2f,\"Psdata\":%d,\"Snakelen\":%d}}", Temp, Humi, brightness, ps_data, snake_len);
|
sprintf(tmp, "{\"params\":{\"temperature\":%.2f,\"humidity\":%.2f,\"LightLux\":%.2f,\"Psdata\":%d,\"Snakelen\":%d}}", Temp, Humi, brightness, ps_data, snake_len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
14
rtconfig.h
14
rtconfig.h
|
@ -17,6 +17,9 @@
|
||||||
#define RT_USING_IDLE_HOOK
|
#define RT_USING_IDLE_HOOK
|
||||||
#define RT_IDLE_HOOK_LIST_SIZE 4
|
#define RT_IDLE_HOOK_LIST_SIZE 4
|
||||||
#define IDLE_THREAD_STACK_SIZE 1024
|
#define IDLE_THREAD_STACK_SIZE 1024
|
||||||
|
#define RT_USING_TIMER_SOFT
|
||||||
|
#define RT_TIMER_THREAD_PRIO 4
|
||||||
|
#define RT_TIMER_THREAD_STACK_SIZE 512
|
||||||
|
|
||||||
/* kservice optimization */
|
/* kservice optimization */
|
||||||
|
|
||||||
|
@ -203,6 +206,7 @@
|
||||||
|
|
||||||
/* end of Interprocess Communication (IPC) */
|
/* end of Interprocess Communication (IPC) */
|
||||||
/* end of POSIX (Portable Operating System Interface) layer */
|
/* end of POSIX (Portable Operating System Interface) layer */
|
||||||
|
#define RT_USING_CPLUSPLUS
|
||||||
/* end of C/C++ and POSIX layer */
|
/* end of C/C++ and POSIX layer */
|
||||||
|
|
||||||
/* Network */
|
/* Network */
|
||||||
|
@ -458,6 +462,8 @@
|
||||||
/* Micrium: Micrium software products porting for RT-Thread */
|
/* Micrium: Micrium software products porting for RT-Thread */
|
||||||
|
|
||||||
/* end of Micrium: Micrium software products porting for RT-Thread */
|
/* end of Micrium: Micrium software products porting for RT-Thread */
|
||||||
|
#define PKG_USING_PERF_COUNTER
|
||||||
|
#define PKG_USING_PERF_COUNTER_V2241
|
||||||
/* end of system packages */
|
/* end of system packages */
|
||||||
|
|
||||||
/* peripheral libraries and drivers */
|
/* peripheral libraries and drivers */
|
||||||
|
@ -499,14 +505,9 @@
|
||||||
#define NEC_DEVIATION 100
|
#define NEC_DEVIATION 100
|
||||||
/* end of Select infrared decoder */
|
/* end of Select infrared decoder */
|
||||||
#define PKG_USING_DRV_INFRARED
|
#define PKG_USING_DRV_INFRARED
|
||||||
#define INFRARED_SEND
|
|
||||||
#define INFRARED_SEND_PWM "pwm3"
|
|
||||||
#define INFRARED_PWM_DEV_CHANNEL 4
|
|
||||||
#define INFRARED_SEND_HWTIMER "timer13"
|
|
||||||
#define INFRARED_MAX_SEND_SIZE 1000
|
|
||||||
#define INFRARED_RECEIVE
|
#define INFRARED_RECEIVE
|
||||||
#define INFRARED_RECEIVE_PIN 88
|
#define INFRARED_RECEIVE_PIN 88
|
||||||
#define INFRARED_RECEIVE_HWTIMER "timer14"
|
#define INFRARED_RECEIVE_HWTIMER "timer11"
|
||||||
#define PKG_USING_INFRARED_V011
|
#define PKG_USING_INFRARED_V011
|
||||||
/* end of peripheral libraries and drivers */
|
/* end of peripheral libraries and drivers */
|
||||||
|
|
||||||
|
@ -624,6 +625,7 @@
|
||||||
#define BSP_USING_UART1
|
#define BSP_USING_UART1
|
||||||
#define BSP_USING_UART6
|
#define BSP_USING_UART6
|
||||||
#define BSP_USING_TIM
|
#define BSP_USING_TIM
|
||||||
|
#define BSP_USING_TIM11
|
||||||
#define BSP_USING_TIM13
|
#define BSP_USING_TIM13
|
||||||
#define BSP_USING_TIM14
|
#define BSP_USING_TIM14
|
||||||
#define BSP_USING_PWM
|
#define BSP_USING_PWM
|
||||||
|
|
Loading…
Reference in New Issue