Skip to content

Commit de755a0

Browse files
author
hyhkjiy
committed
[UPD]注释
1 parent 932240f commit de755a0

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

projects/art_pi_ble_mesh_gateway/applications/app_jr6001.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ void jr_thread_entry(void *params)
4848
config.bufsz = 128;
4949
config.parity = PARITY_NONE;
5050

51-
/* step3:控制串口设备。通过控制接口传入命令控制字,与控制参数 */
5251
rt_device_control(serial, RT_DEVICE_CTRL_CONFIG, &config);
5352

54-
/* step4:打开串口设备。以中断接收及轮询发送模式打开串口设备 */
5553
rt_device_open(serial, RT_DEVICE_FLAG_INT_RX);
5654

5755
jr_send_command("AF:20");
@@ -62,7 +60,6 @@ void jr_thread_entry(void *params)
6260
// 等待播放结束
6361
while (rt_pin_read(PLAY_BUSY_PIN))
6462
{
65-
// rt_kprintf("jr60001: %d\n", rt_pin_read(PLAY_BUSY_PIN));
6663
rt_thread_mdelay(10);
6764
}
6865

@@ -73,15 +70,12 @@ void jr_thread_entry(void *params)
7370

7471
char buf = 0;
7572

76-
/* 从消息队列中接收消息 */
7773
if (rt_mq_recv(&player_mq, &buf, sizeof(buf), RT_WAITING_FOREVER) == RT_EOK)
7874
{
79-
8075
rt_mutex_take(player_use_mtx, RT_WAITING_FOREVER);
8176
rt_pin_write(LED_G, 0);
8277

83-
memset(command, 0, 20);
84-
// sprintf(command, "A7:0000%c", buf);
78+
memset(command, 0, 20); // 设置音量
8579
sprintf(command, "A8:02/0000%c*MP3", buf);
8680
jr_send_command(command);
8781

@@ -112,7 +106,6 @@ int create_jr6001_thread(void)
112106
sizeof(msg_pool),
113107
RT_IPC_FLAG_FIFO);
114108

115-
// 初始化信号量
116109
player_use_mtx = rt_mutex_create("player_use_mtx", RT_IPC_FLAG_FIFO);
117110

118111
if (result != RT_EOK)

projects/art_pi_ble_mesh_gateway/applications/app_mesh_device.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@
1515
#define THREAD_TIMESLICE 40
1616
#define UART_NAME "uart5"
1717

18-
/* 消息队列控制块 */
1918
static struct rt_messagequeue mesh_mq;
2019
static rt_thread_t mesh_command_tx_thread = RT_NULL;
2120
static rt_thread_t mesh_command_rx_thread = RT_NULL;
2221
static rt_uint8_t thread_priority = 20;
23-
static rt_device_t serial; /* 串口设备句柄 */
24-
static struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; /* 初始化配置参数 */
22+
static rt_device_t serial;
23+
static struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
2524
static struct rt_semaphore rx_sem;
2625

27-
/* 消息队列中用到的放置消息的内存池 */
2826
static rt_uint8_t msg_pool[2048];
2927

3028
void mesh_send_command(command_opcode_t opc, uint16_t addr, uint8_t *data)
@@ -45,10 +43,8 @@ void mesh_send_command(command_opcode_t opc, uint16_t addr, uint8_t *data)
4543
LOG_HEX("Uart send data", 11, command, sizeof(command));
4644
}
4745

48-
/* 接收数据回调函数 */
4946
static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
5047
{
51-
/* 串口接收到数据后产生中断,调用此回调函数,然后发送接收信号量 */
5248
rt_sem_release(&rx_sem);
5349

5450
return RT_EOK;
@@ -59,17 +55,14 @@ static void mesh_command_tx_thread_entry(void *params)
5955
serial = rt_device_find(UART_NAME);
6056
if (serial != RT_NULL)
6157
{
62-
/* 修改串口配置参数 */
6358
config.baud_rate = BAUD_RATE_115200;
6459
config.data_bits = DATA_BITS_8;
6560
config.stop_bits = STOP_BITS_1;
6661
config.bufsz = 128;
6762
config.parity = PARITY_NONE;
6863

69-
/* 控制串口设备。通过控制接口传入命令控制字,与控制参数 */
7064
rt_device_control(serial, RT_DEVICE_CTRL_CONFIG, &config);
7165

72-
/* 打开串口设备。以中断接收及轮询发送模式打开串口设备 */
7366
rt_device_open(serial, RT_DEVICE_FLAG_INT_RX);
7467

7568
rt_device_set_rx_indicate(serial, uart_input);
@@ -79,7 +72,6 @@ static void mesh_command_tx_thread_entry(void *params)
7972

8073
char command[11];
8174

82-
/* 从消息队列中接收消息 */
8375
if (rt_mq_recv(&mesh_mq, command, sizeof(command), RT_WAITING_FOREVER) == RT_EOK)
8476
{
8577
rt_size_t res = rt_device_write(serial, 0, command, sizeof(command));
@@ -136,7 +128,6 @@ static void mesh_command_rx_thread_entry(void *parameter)
136128
uint8_t ch;
137129
while (rt_device_read(serial, -1, &ch, 1) != 1)
138130
{
139-
/* 阻塞等待接收信号量,等到信号量后再次读取数据 */
140131
rt_sem_take(&rx_sem, RT_WAITING_FOREVER);
141132
}
142133

0 commit comments

Comments
 (0)