遥控器控制电机转动,队列用法还没实现
This commit is contained in:
49
Core/Src/bsp_rc.c
Normal file
49
Core/Src/bsp_rc.c
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "bsp_rc.h"
|
||||
#include "main.h"
|
||||
|
||||
extern UART_HandleTypeDef huart3;
|
||||
extern DMA_HandleTypeDef hdma_usart3_rx;
|
||||
|
||||
void RC_init(uint8_t *rx1_buf, uint8_t *rx2_buf, uint16_t dma_buf_num)
|
||||
{
|
||||
//enable the DMA transfer for the receiver request
|
||||
//ʹ<><CAB9>DMA<4D><41><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>
|
||||
SET_BIT(huart3.Instance->CR3, USART_CR3_DMAR);
|
||||
|
||||
//enalbe idle interrupt
|
||||
//ʹ<>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
__HAL_UART_ENABLE_IT(&huart3, UART_IT_IDLE);
|
||||
|
||||
//disable DMA
|
||||
//ʧЧDMA
|
||||
__HAL_DMA_DISABLE(&hdma_usart3_rx);
|
||||
while(hdma_usart3_rx.Instance->CR & DMA_SxCR_EN)
|
||||
{
|
||||
__HAL_DMA_DISABLE(&hdma_usart3_rx);
|
||||
}
|
||||
|
||||
hdma_usart3_rx.Instance->PAR = (uint32_t) & (USART3->DR);
|
||||
//memory buffer 1
|
||||
//<2F>ڴ滺<DAB4><E6BBBA><EFBFBD><EFBFBD>1
|
||||
hdma_usart3_rx.Instance->M0AR = (uint32_t)(rx1_buf);
|
||||
//memory buffer 2
|
||||
//<2F>ڴ滺<DAB4><E6BBBA><EFBFBD><EFBFBD>2
|
||||
hdma_usart3_rx.Instance->M1AR = (uint32_t)(rx2_buf);
|
||||
//data length
|
||||
//<2F><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
hdma_usart3_rx.Instance->NDTR = dma_buf_num;
|
||||
//enable double memory buffer
|
||||
//ʹ<><CAB9>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SET_BIT(hdma_usart3_rx.Instance->CR, DMA_SxCR_DBM);
|
||||
|
||||
//enable DMA
|
||||
//ʹ<><CAB9>DMA
|
||||
__HAL_DMA_ENABLE(&hdma_usart3_rx);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user