|
|
|
@ -58,6 +58,7 @@ static void MX_ICACHE_Init(void);
|
|
|
|
static void MX_TIM5_Init(void);
|
|
|
|
static void MX_TIM5_Init(void);
|
|
|
|
static void MX_TIM2_Init(void);
|
|
|
|
static void MX_TIM2_Init(void);
|
|
|
|
static void MX_UART5_Init(void);
|
|
|
|
static void MX_UART5_Init(void);
|
|
|
|
|
|
|
|
static void MX_USART3_UART_Init(void);
|
|
|
|
/* USER CODE BEGIN PFP */
|
|
|
|
/* USER CODE BEGIN PFP */
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END PFP */
|
|
|
|
/* USER CODE END PFP */
|
|
|
|
@ -140,6 +141,7 @@ int main(void)
|
|
|
|
MX_TIM5_Init();
|
|
|
|
MX_TIM5_Init();
|
|
|
|
MX_TIM2_Init();
|
|
|
|
MX_TIM2_Init();
|
|
|
|
MX_UART5_Init();
|
|
|
|
MX_UART5_Init();
|
|
|
|
|
|
|
|
MX_USART3_UART_Init();
|
|
|
|
/* USER CODE BEGIN 2 */
|
|
|
|
/* USER CODE BEGIN 2 */
|
|
|
|
LL_TIM_GenerateEvent_UPDATE(TIM2);
|
|
|
|
LL_TIM_GenerateEvent_UPDATE(TIM2);
|
|
|
|
LL_TIM_EnableCounter(TIM2);
|
|
|
|
LL_TIM_EnableCounter(TIM2);
|
|
|
|
@ -172,7 +174,6 @@ int main(void)
|
|
|
|
if (TickChk(&Tick1secRef, 1000)) { // execute every 1s
|
|
|
|
if (TickChk(&Tick1secRef, 1000)) { // execute every 1s
|
|
|
|
LD2_Toggle();
|
|
|
|
LD2_Toggle();
|
|
|
|
static uint8_t cnt = 0;
|
|
|
|
static uint8_t cnt = 0;
|
|
|
|
DispPutDigit(1, 'a'+cnt, 1);
|
|
|
|
|
|
|
|
DispPutDigit(2, 'A'+cnt, 0);
|
|
|
|
DispPutDigit(2, 'A'+cnt, 0);
|
|
|
|
cnt = (cnt + 1) % 16;
|
|
|
|
cnt = (cnt + 1) % 16;
|
|
|
|
static uint32_t Trefus = 0;
|
|
|
|
static uint32_t Trefus = 0;
|
|
|
|
@ -180,6 +181,7 @@ int main(void)
|
|
|
|
uint32_t tdif = t - Trefus;
|
|
|
|
uint32_t tdif = t - Trefus;
|
|
|
|
printf("%6luus\n", tdif);
|
|
|
|
printf("%6luus\n", tdif);
|
|
|
|
Trefus = t;
|
|
|
|
Trefus = t;
|
|
|
|
|
|
|
|
LL_USART_TransmitData8(USART3, 'A' + cnt); // direct send without buffer and interrupt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static uint32_t Tick100msRef = 0;
|
|
|
|
static uint32_t Tick100msRef = 0;
|
|
|
|
@ -189,6 +191,11 @@ int main(void)
|
|
|
|
DispPutDigit(3, ' ', dot);
|
|
|
|
DispPutDigit(3, ' ', dot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (LL_USART_IsActiveFlag_RXNE_RXFNE(USART3)) { // check if data received
|
|
|
|
|
|
|
|
char rxch = LL_USART_ReceiveData8(USART3); // direct receive without buffer and interrupt
|
|
|
|
|
|
|
|
DispPutDigit(1, rxch, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int16_t ch = Uart5_GetByte();
|
|
|
|
int16_t ch = Uart5_GetByte();
|
|
|
|
if (ch != -1) { // if data received
|
|
|
|
if (ch != -1) { // if data received
|
|
|
|
char c = ch;
|
|
|
|
char c = ch;
|
|
|
|
@ -441,6 +448,68 @@ static void MX_UART5_Init(void)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief USART3 Initialization Function
|
|
|
|
|
|
|
|
* @param None
|
|
|
|
|
|
|
|
* @retval None
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void MX_USART3_UART_Init(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN USART3_Init 0 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END USART3_Init 0 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LL_USART_InitTypeDef USART_InitStruct = {0};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LL_RCC_SetUSARTClockSource(LL_RCC_USART3_CLKSOURCE_PCLK1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Peripheral clock enable */
|
|
|
|
|
|
|
|
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);
|
|
|
|
|
|
|
|
/**USART3 GPIO Configuration
|
|
|
|
|
|
|
|
PB1 ------> USART3_RX
|
|
|
|
|
|
|
|
PB10 ------> USART3_TX
|
|
|
|
|
|
|
|
PB14 ------> USART3_DE
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_1|LL_GPIO_PIN_10|LL_GPIO_PIN_14;
|
|
|
|
|
|
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
|
|
|
|
|
|
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
|
|
|
|
|
|
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
|
|
|
|
|
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
|
|
|
|
|
|
GPIO_InitStruct.Alternate = LL_GPIO_AF_7;
|
|
|
|
|
|
|
|
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN USART3_Init 1 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END USART3_Init 1 */
|
|
|
|
|
|
|
|
USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1;
|
|
|
|
|
|
|
|
USART_InitStruct.BaudRate = 115200;
|
|
|
|
|
|
|
|
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
|
|
|
|
|
|
|
|
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
|
|
|
|
|
|
|
|
USART_InitStruct.Parity = LL_USART_PARITY_NONE;
|
|
|
|
|
|
|
|
USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;
|
|
|
|
|
|
|
|
USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
|
|
|
|
|
|
|
|
USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16;
|
|
|
|
|
|
|
|
LL_USART_Init(USART3, &USART_InitStruct);
|
|
|
|
|
|
|
|
LL_USART_SetTXFIFOThreshold(USART3, LL_USART_FIFOTHRESHOLD_1_8);
|
|
|
|
|
|
|
|
LL_USART_SetRXFIFOThreshold(USART3, LL_USART_FIFOTHRESHOLD_1_8);
|
|
|
|
|
|
|
|
LL_USART_EnableDEMode(USART3);
|
|
|
|
|
|
|
|
LL_USART_SetDESignalPolarity(USART3, LL_USART_DE_POLARITY_HIGH);
|
|
|
|
|
|
|
|
LL_USART_SetDEAssertionTime(USART3, 0);
|
|
|
|
|
|
|
|
LL_USART_SetDEDeassertionTime(USART3, 0);
|
|
|
|
|
|
|
|
LL_USART_DisableFIFO(USART3);
|
|
|
|
|
|
|
|
LL_USART_ConfigAsyncMode(USART3);
|
|
|
|
|
|
|
|
LL_USART_Enable(USART3);
|
|
|
|
|
|
|
|
/* USER CODE BEGIN USART3_Init 2 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END USART3_Init 2 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief GPIO Initialization Function
|
|
|
|
* @brief GPIO Initialization Function
|
|
|
|
* @param None
|
|
|
|
* @param None
|
|
|
|
@ -456,9 +525,9 @@ static void MX_GPIO_Init(void)
|
|
|
|
/* GPIO Ports Clock Enable */
|
|
|
|
/* GPIO Ports Clock Enable */
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC);
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC);
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOH);
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOH);
|
|
|
|
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA);
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA);
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOD);
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOD);
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**/
|
|
|
|
/**/
|
|
|
|
LL_GPIO_ResetOutputPin(GPIOC, SHR_CLK_Pin|SHR_STR_Pin);
|
|
|
|
LL_GPIO_ResetOutputPin(GPIOC, SHR_CLK_Pin|SHR_STR_Pin);
|
|
|
|
|