feat: 适配新板卡蓝牙
This commit is contained in:
42
app/jj_blueteeth.c
Normal file
42
app/jj_blueteeth.c
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#include "jj_blueteeth.h"
|
||||||
|
|
||||||
|
#include "zf_common_headfile.h"
|
||||||
|
|
||||||
|
#define BT_UART_BAUDRATE (115200)
|
||||||
|
#define BT_UART_INDEX UART_8
|
||||||
|
#define BT_UART_TX_PIN UART8_MAP0_TX_C4
|
||||||
|
#define BT_UART_RX_PIN UART8_MAP0_RX_C5
|
||||||
|
|
||||||
|
bool bt_rx_flag = false;
|
||||||
|
uint8_t bt_buffer; // 接收字符存入
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 蓝牙初始化
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
void jj_bt_init()
|
||||||
|
{
|
||||||
|
uart_init(BT_UART_INDEX, BT_UART_BAUDRATE, BT_UART_TX_PIN, UART8_MAP0_RX_C5);
|
||||||
|
uart_rx_interrupt(BT_UART_INDEX, ENABLE);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*@brief 蓝牙中断回调函数
|
||||||
|
*/
|
||||||
|
void jj_bt_run()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void jj_bt_printf(const char *format, ...)
|
||||||
|
{
|
||||||
|
char sbuf[40];
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
vsnprintf(sbuf, 40, format, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
for (uint16_t i = 0; i < strlen(sbuf); i++) {
|
||||||
|
while (USART_GetFlagStatus((USART_TypeDef *)uart_index[BT_UART_INDEX], USART_FLAG_TC) == RESET)
|
||||||
|
;
|
||||||
|
USART_SendData((USART_TypeDef *)uart_index[BT_UART_INDEX], sbuf[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
9
app/jj_blueteeth.h
Normal file
9
app/jj_blueteeth.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#ifndef _JJ_BLUETEETH_H_
|
||||||
|
#define _JJ_BLUETEETH_H_
|
||||||
|
|
||||||
|
#include "stdio.h"
|
||||||
|
|
||||||
|
void jj_bt_init();
|
||||||
|
void jj_bt_run();
|
||||||
|
void jj_bt_printf(const char *format, ...);
|
||||||
|
#endif
|
||||||
10
app/main.c
10
app/main.c
@@ -23,9 +23,11 @@
|
|||||||
********************************************************************************************************************/
|
********************************************************************************************************************/
|
||||||
#include "gl_headfile.h"
|
#include "gl_headfile.h"
|
||||||
#include "./page/page.h"
|
#include "./page/page.h"
|
||||||
#include "jj_param.h"
|
|
||||||
#include "by_buzzer.h"
|
#include "by_buzzer.h"
|
||||||
#include "by_led.h"
|
#include "by_led.h"
|
||||||
|
#include "jj_param.h"
|
||||||
|
#include "jj_blueteeth.h"
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -40,12 +42,14 @@ int main(void)
|
|||||||
by_buzzer_init();
|
by_buzzer_init();
|
||||||
by_button_init();
|
by_button_init();
|
||||||
|
|
||||||
// while (imu660ra_init())
|
jj_bt_init();
|
||||||
// ;
|
|
||||||
// jj_param_eeprom_init();
|
// jj_param_eeprom_init();
|
||||||
|
|
||||||
Page_Init();
|
Page_Init();
|
||||||
|
|
||||||
pit_ms_init(TIM6_PIT, 2);
|
pit_ms_init(TIM6_PIT, 2);
|
||||||
pit_ms_init(TIM1_PIT, 2);
|
pit_ms_init(TIM1_PIT, 2);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
Page_Run();
|
Page_Run();
|
||||||
queue_pop_read();
|
queue_pop_read();
|
||||||
|
|||||||
Reference in New Issue
Block a user