开了红外接收又不行了
4
.config
|
@ -1147,7 +1147,9 @@ CONFIG_NEC_DEVIATION=100
|
|||
|
||||
CONFIG_PKG_USING_DRV_INFRARED=y
|
||||
# CONFIG_INFRARED_SEND is not set
|
||||
# CONFIG_INFRARED_RECEIVE is not set
|
||||
CONFIG_INFRARED_RECEIVE=y
|
||||
CONFIG_INFRARED_RECEIVE_PIN=17
|
||||
CONFIG_INFRARED_RECEIVE_HWTIMER="timer16"
|
||||
# CONFIG_PKG_USING_INFRARED_V010 is not set
|
||||
CONFIG_PKG_USING_INFRARED_V011=y
|
||||
# CONFIG_PKG_USING_INFRARED_LATEST_VERSION is not set
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# My_project
|
||||
#### LCD 显示温湿度
|
||||
![LCD温湿度](/my_pro/lcdtemp.jpg)
|
||||
![LCD温湿度](/my_picture/lcdtemp.jpg)
|
||||
左上角是(0,0) →x,↓y
|
||||
|
||||
### 简易贪吃蛇
|
||||
![alt text](/my_pro/660c6c04fddc1bd3ccbe4255df5d449.jpg)
|
||||
![alt text](/my_picture/660c6c04fddc1bd3ccbe4255df5d449.jpg)
|
||||
# STM32F407 星火一号开发板 BSP 说明
|
||||
|
||||
## 简介
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
![语法错误图](syntax_env1.5.png)
|
||||
|
||||
|
||||
换了env2就可以?
|
||||
|
||||
![alt text](image-1.png)
|
||||
|
@ -7,3 +9,11 @@
|
|||
![alt text](image.png)
|
||||
对照示例0.1.1版什么都不用做,也不会报错什么没定义
|
||||
.config/rtconfig.h
|
||||
### GET_PIN(F, 11) 的头文件
|
||||
|
||||
``` c
|
||||
#include <drv_gpio.h>
|
||||
/* 配置 LED 灯引脚 */
|
||||
#define PIN_LED_B GET_PIN(F, 11) // PF11 : LED_B --> LED
|
||||
#define PIN_LED_R GET_PIN(F, 12) // PF12 : LED_R --> LED
|
||||
```
|
Before Width: | Height: | Size: 857 KiB After Width: | Height: | Size: 857 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 222 KiB After Width: | Height: | Size: 222 KiB |
|
@ -0,0 +1,56 @@
|
|||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <board.h>
|
||||
#include "infrared.h"
|
||||
#include <drv_gpio.h>
|
||||
|
||||
#define DBG_TAG "main"
|
||||
#define DBG_LVL DBG_LOG
|
||||
#include <rtdbg.h>
|
||||
#include <ulog.h>
|
||||
|
||||
/* 配置 LED 灯引脚 */
|
||||
#define PIN_LED_B GET_PIN(F, 11) // PF11 : LED_B --> LED
|
||||
#define PIN_LED_R GET_PIN(F, 12) // PF12 : LED_R --> LED
|
||||
|
||||
|
||||
void myir_entry(void *parameter)
|
||||
{
|
||||
rt_kprintf("myir_entry\n");
|
||||
unsigned int count = 1;
|
||||
rt_int16_t key;
|
||||
struct infrared_decoder_data infrared_data;
|
||||
|
||||
/* 选择 NEC 解码器 */
|
||||
ir_select_decoder("nec");
|
||||
|
||||
/* 设置 RGB 引脚为输出模式*/
|
||||
rt_pin_mode(PIN_LED_R, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(PIN_LED_B, PIN_MODE_OUTPUT);
|
||||
|
||||
rt_pin_write(PIN_LED_R, PIN_HIGH);
|
||||
rt_pin_write(PIN_LED_B, PIN_HIGH);
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
if (infrared_read("nec", &infrared_data) == RT_EOK)
|
||||
{
|
||||
/* 读取到红外数据,红灯亮起 */
|
||||
rt_pin_write(PIN_LED_R, PIN_LOW);
|
||||
LOG_I("RECEIVE OK: addr:0x%02X key:0x%02X repeat:%d", infrared_data.data.nec.addr,
|
||||
infrared_data.data.nec.key, infrared_data.data.nec.repeat);
|
||||
rt_kprintf("RECEIVE OK\n");
|
||||
}
|
||||
rt_thread_mdelay(10);
|
||||
|
||||
/* 熄灭蓝灯 */
|
||||
rt_pin_write(PIN_LED_B, PIN_HIGH);
|
||||
/* 熄灭红灯 */
|
||||
rt_pin_write(PIN_LED_R, PIN_HIGH);
|
||||
count++;
|
||||
// if( count % 100 == 0)
|
||||
// rt_kprintf("count = %d\n", count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include <drv_lcd.h>
|
||||
#include "mysnake.h"
|
||||
|
||||
|
||||
char DEMO_PRODUCT_KEY[IOTX_PRODUCT_KEY_LEN + 1] = {0};
|
||||
char DEMO_DEVICE_NAME[IOTX_DEVICE_NAME_LEN + 1] = {0};
|
||||
char DEMO_DEVICE_SECRET[IOTX_DEVICE_SECRET_LEN + 1] = {0};
|
||||
|
@ -49,9 +50,13 @@ float brightness;
|
|||
int lcd_y;
|
||||
int int_tmp;
|
||||
|
||||
extern void myir_entry(void *parameter);
|
||||
|
||||
void ath_init(void);
|
||||
void mqt_init(void);
|
||||
int ap3_init(void);
|
||||
void irf_init(void);
|
||||
|
||||
|
||||
#define EXAMPLE_TRACE(fmt, ...) \
|
||||
do \
|
||||
|
@ -300,6 +305,7 @@ static void mqtt_example_main(void *parameter)
|
|||
|
||||
rt_thread_t MQTT_Thread = RT_NULL;
|
||||
rt_thread_t Snake_Thread = RT_NULL;
|
||||
rt_thread_t Irfrared_Thread = RT_NULL;
|
||||
|
||||
void ath_init(void)
|
||||
{
|
||||
|
@ -355,6 +361,20 @@ MSH_CMD_EXPORT_ALIAS(snk_init, snake, "snake game");
|
|||
// return 0;
|
||||
|
||||
// }
|
||||
void irf_init(void)
|
||||
{
|
||||
Irfrared_Thread = rt_thread_create("Irfrared_Thread", myir_entry, RT_NULL, THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE);
|
||||
|
||||
if (Irfrared_Thread != RT_NULL)
|
||||
{
|
||||
rt_thread_startup(Irfrared_Thread);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("Irfrared Thread Create Failed!\n");
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT_ALIAS(irf_init, irf, "Irfrared");
|
||||
void my_project(void)
|
||||
{
|
||||
ath_init();
|
||||
|
@ -362,5 +382,7 @@ void my_project(void)
|
|||
mqt_init();
|
||||
|
||||
ap3_init();
|
||||
|
||||
irf_init();
|
||||
}
|
||||
MSH_CMD_EXPORT_ALIAS(my_project, myproject, run my project);
|
|
@ -498,6 +498,9 @@
|
|||
#define NEC_DEVIATION 100
|
||||
/* end of Select infrared decoder */
|
||||
#define PKG_USING_DRV_INFRARED
|
||||
#define INFRARED_RECEIVE
|
||||
#define INFRARED_RECEIVE_PIN 17
|
||||
#define INFRARED_RECEIVE_HWTIMER "timer16"
|
||||
#define PKG_USING_INFRARED_V011
|
||||
/* end of peripheral libraries and drivers */
|
||||
|
||||
|
|