Skip to content

Commit f4804d0

Browse files
authored
Merge pull request #18 from eurkaaaa/Athena-efficiency
add uartsend
2 parents cb979b6 + ea6ac48 commit f4804d0

5 files changed

Lines changed: 30 additions & 15 deletions

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"dwtypes.h": "c",
1717
"libdw3000.h": "c",
1818
"calibration.h": "c",
19-
"freertos.h": "c"
19+
"freertos.h": "c",
20+
"stdbool.h": "c"
2021
}
2122
}

Core/Inc/usart.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ extern "C" {
2929
#include "main.h"
3030

3131
/* USER CODE BEGIN Includes */
32-
32+
#include <stdint.h>
33+
#include <stdbool.h>
3334
/* USER CODE END Includes */
3435

3536
/* USER CODE BEGIN Private defines */
36-
37+
void uart3SendData(uint32_t size, uint8_t* data);
38+
void Uart3_SendStr(char*SendBuf);
3739
/* USER CODE END Private defines */
3840

3941
void MX_USART1_UART_Init(void);

Core/Src/freertos.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "dwTypes.h"
3939
#include "dw3000_cbll.h"
4040
#include "tof_get_data.c"
41+
#include "usart.h"
4142

4243
#include "DebugPrint_example.h"
4344
#include "../../examples/tinymap/inc/calibration.h"
@@ -76,11 +77,11 @@ int spi_deck_init(void)
7677
}
7778

7879
osThreadId_t ledTaskHandle;
79-
//const osThreadAttr_t ledTask_attributes = {
80-
// .name = "ledTask",
81-
// .stack_size = 128 * 2,
82-
// .priority = (osPriority_t) osPriorityNormal,
83-
//};
80+
const osThreadAttr_t ledTask_attributes = {
81+
.name = "ledTask",
82+
.stack_size = 128 * 2,
83+
.priority = (osPriority_t) osPriorityNormal,
84+
};
8485
osThreadId_t uwbTaskHandle;
8586
const osThreadAttr_t uwbTask_attributes = {
8687
.name = "uwbTask",
@@ -142,9 +143,9 @@ void MX_FREERTOS_Init(void) {
142143
}
143144
spi_deck_init();
144145
// TOF_exampleHandle = osThreadNew(tof_get_data, NULL, &tof_get_data_attributes);
145-
Debug_ExampleHandle = osThreadNew(Debug_example, NULL, &Debug_Example_attributes);
146+
// Debug_ExampleHandle = osThreadNew(Debug_example, NULL, &Debug_Example_attributes);
146147
// FS_ExampleHandle = osThreadNew(FS_Example, NULL, &FS_Example_attributes);
147-
// ledTaskHandle = osThreadNew(ledTask, NULL, &ledTask_attributes);
148+
ledTaskHandle = osThreadNew(ledTask, NULL, &ledTask_attributes);
148149
// uwbTaskHandle = osThreadNew(uwbTask, NULL, &uwbTask_attributes);
149150
}
150151

@@ -217,11 +218,13 @@ static void uwbTask(void *argument)
217218

218219
static void ledTask(void *argument)
219220
{
220-
// static uint8_t data[16];
221-
// for(int i=0;i<5;i++)data[i] = i+1;
221+
static uint8_t data[6];
222+
for(int i=0;i<=5;i++)data[i] = i+1;
222223
while(1)
223224
{
224225
// LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
226+
// uart3SendData(6,data);
227+
Uart3_SendStr(data);
225228
vTaskDelay(100);
226229
}
227230
}

Core/Src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ int main(void)
107107
MX_SPI3_Init();
108108
MX_SPI2_Init();
109109
MX_SPI1_Init();
110-
//MX_USART3_UART_Init();
110+
MX_USART3_UART_Init();
111111
MX_USART1_UART_Init();
112112
/* USER CODE BEGIN 2 */
113113

Core/Src/usart.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "usart.h"
2222

2323
/* USER CODE BEGIN 0 */
24-
24+
// static bool isInit = false;
2525
/* USER CODE END 0 */
2626

2727
/* USART1 init function */
@@ -200,11 +200,20 @@ void MX_USART3_UART_Init(void)
200200
LL_USART_ConfigAsyncMode(USART3);
201201
LL_USART_Enable(USART3);
202202
/* USER CODE BEGIN USART3_Init 2 */
203-
203+
// isInit = true;
204204
/* USER CODE END USART3_Init 2 */
205205

206206
}
207207

208208
/* USER CODE BEGIN 1 */
209+
void Uart3_SendStr(char*SendBuf)//串口1发送字符串
210+
{
211+
while(*SendBuf)
212+
{
213+
while(LL_USART_IsActiveFlag_TC(USART3)!=1);//等待发送完成
214+
LL_USART_TransmitData8(USART3,(uint8_t)(*SendBuf & (uint8_t)0xff));//发送数据
215+
SendBuf++;
216+
}
217+
}
209218

210219
/* USER CODE END 1 */

0 commit comments

Comments
 (0)