rxcplt callback

This commit is contained in:
Thomas Kuschel 2022-06-10 18:59:20 +02:00
parent a3fcd0e57c
commit b0d317663d
6 changed files with 103 additions and 69 deletions

View File

@ -63,8 +63,6 @@ void Error_Handler(void);
#define LD3_GPIO_Port GPIOB
#define USB_OverCurrent_Pin GPIO_PIN_5
#define USB_OverCurrent_GPIO_Port GPIOG
#define USB_PowerSwitchOn_Pin GPIO_PIN_6
#define USB_PowerSwitchOn_GPIO_Port GPIOG
#define STLK_RX_Pin GPIO_PIN_7
#define STLK_RX_GPIO_Port GPIOG
#define STLK_TX_Pin GPIO_PIN_8

View File

@ -53,6 +53,7 @@ void BusFault_Handler(void);
void UsageFault_Handler(void);
void DebugMon_Handler(void);
void TIM6_DAC_IRQHandler(void);
void LPUART1_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */

View File

@ -84,14 +84,15 @@ const osSemaphoreAttr_t si5351_attributes = {
};
/* USER CODE BEGIN PV */
int leds_on = 1;
uint8_t UART1_rxBuffer[12] = {0};
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_LPUART1_UART_Init(void);
static void MX_I2C1_Init(void);
static void MX_RTC_Init(void);
static void MX_I2C1_Init(void);
void StartDefaultTask(void *argument);
void start_terminal_task(void *argument);
void start_morse_task(void *argument);
@ -116,6 +117,8 @@ int main(void)
{
/* USER CODE BEGIN 1 */
/* int status = 0; */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
@ -137,8 +140,8 @@ int main(void)
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_LPUART1_UART_Init();
MX_I2C1_Init();
MX_RTC_Init();
MX_I2C1_Init();
/* USER CODE BEGIN 2 */
si5351_inst_t si5351_inst = 0;
@ -179,7 +182,7 @@ int main(void)
HAL_Delay(10000);
#endif
#if 1
#if 0
si5351_set_clk0(si5351_inst, 3550000);
si5351_enable_output(si5351_inst,0);
@ -213,7 +216,9 @@ int main(void)
#endif
HAL_Delay(60000);
HAL_Delay(20000);
#if 0
while (1) {
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
@ -244,6 +249,8 @@ int main(void)
HAL_ResumeTick();
}
#endif
/* World Youth ARDF Championship Romania 2022 */
/* 80 m . RF power 3 W, QRG MOE-MO5: 3550 MHz, MO: 3600 MHz, Antenna 8m
* 80 m Sprint pwr 1 W, TX 1-5: MOE-MO5: 3530 MHz, S: 3550 MHz, TX 1F-5F MOE-MO5: 3570 MHz
@ -258,7 +265,7 @@ int main(void)
// si5351_enable_output(si5351_inst,1);
// HAL_Delay(1000);
#if 0
#if 1
si5351_set_clk0(si5351_inst, 3550000);
si5351_set_clk(si5351_inst, 3570000, 2, SI5351_PLLB);
@ -294,16 +301,16 @@ int main(void)
/* Create the thread(s) */
/* creation of defaultTask */
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
//defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
/* creation of terminalTask */
terminalTaskHandle = osThreadNew(start_terminal_task, NULL, &terminalTask_attributes);
/* creation of morseTask */
morseTaskHandle = osThreadNew(start_morse_task, (void*) si5351_inst, &morseTask_attributes);
//morseTaskHandle = osThreadNew(start_morse_task, (void*) si5351_inst, &morseTask_attributes);
/* creation of clk2Task */
clk2TaskHandle = osThreadNew(start_clk2_task, (void*) si5351_inst, &clk2Task_attributes);
//clk2TaskHandle = osThreadNew(start_clk2_task, (void*) si5351_inst, &clk2Task_attributes);
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
@ -561,7 +568,7 @@ static void MX_GPIO_Init(void)
HAL_GPIO_WritePin(GPIOB, LD3_Pin|LD2_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(USB_PowerSwitchOn_GPIO_Port, USB_PowerSwitchOn_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_6, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_RESET);
@ -667,12 +674,12 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(USB_OverCurrent_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : USB_PowerSwitchOn_Pin */
GPIO_InitStruct.Pin = USB_PowerSwitchOn_Pin;
/*Configure GPIO pin : PG6 */
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(USB_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
/*Configure GPIO pin : LD1_Pin */
GPIO_InitStruct.Pin = LD1_Pin;
@ -692,6 +699,12 @@ static void MX_GPIO_Init(void)
}
/* USER CODE BEGIN 4 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *hlpuart) {
HAL_UART_Transmit(&hlpuart1, UART1_rxBuffer, 1, 100);
HAL_UART_Receive_IT(&hlpuart1, UART1_rxBuffer, 1);
}
/**
* @brief Retargets the C library printf function to the USART.
* @param None
@ -893,9 +906,11 @@ void start_terminal_task(void *argument)
HAL_StatusTypeDef status;
RTC_TimeTypeDef time;
RTC_DateTypeDef date;
uint8_t LPUART1_rxBuffer[100];
/* Infinite loop */
for(;;) {
HAL_UART_Receive_IT(&hlpuart1, UART1_rxBuffer, 1);
status = HAL_RTC_GetTime(&hrtc, &time, RTC_FORMAT_BIN);
if (status != HAL_OK)

View File

@ -196,6 +196,9 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
GPIO_InitStruct.Alternate = GPIO_AF8_LPUART1;
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
/* LPUART1 interrupt Init */
HAL_NVIC_SetPriority(LPUART1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(LPUART1_IRQn);
/* USER CODE BEGIN LPUART1_MspInit 1 */
/* USER CODE END LPUART1_MspInit 1 */
@ -225,6 +228,8 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
*/
HAL_GPIO_DeInit(GPIOG, STLK_RX_Pin|STLK_TX_Pin);
/* LPUART1 interrupt DeInit */
HAL_NVIC_DisableIRQ(LPUART1_IRQn);
/* USER CODE BEGIN LPUART1_MspDeInit 1 */
/* USER CODE END LPUART1_MspDeInit 1 */

View File

@ -55,6 +55,7 @@
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
extern UART_HandleTypeDef hlpuart1;
extern TIM_HandleTypeDef htim6;
/* USER CODE BEGIN EV */
@ -173,6 +174,20 @@ void TIM6_DAC_IRQHandler(void)
/* USER CODE END TIM6_DAC_IRQn 1 */
}
/**
* @brief This function handles LPUART1 global interrupt.
*/
void LPUART1_IRQHandler(void)
{
/* USER CODE BEGIN LPUART1_IRQn 0 */
/* USER CODE END LPUART1_IRQn 0 */
HAL_UART_IRQHandler(&hlpuart1);
/* USER CODE BEGIN LPUART1_IRQn 1 */
/* USER CODE END LPUART1_IRQn 1 */
}
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */

View File

@ -82,61 +82,61 @@ Mcu.Pin32=PA7
Mcu.Pin33=PC4
Mcu.Pin34=PC5
Mcu.Pin35=PB0
Mcu.Pin36=PB1
Mcu.Pin37=PB2
Mcu.Pin38=PF11
Mcu.Pin39=PF12
Mcu.Pin36=PB2
Mcu.Pin37=PF11
Mcu.Pin38=PF12
Mcu.Pin39=PF13
Mcu.Pin4=PE6
Mcu.Pin40=PF13
Mcu.Pin41=PF14
Mcu.Pin42=PF15
Mcu.Pin43=PG0
Mcu.Pin44=PG1
Mcu.Pin45=PE7
Mcu.Pin46=PE8
Mcu.Pin47=PE9
Mcu.Pin48=PE10
Mcu.Pin49=PE11
Mcu.Pin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A8
Mcu.Pin79=PA9
Mcu.Pin8=PF0
Mcu.Pin80=PA9
Mcu.Pin81=PA10
Mcu.Pin82=PA11
Mcu.Pin83=PA12
Mcu.Pin84=PA13 (JTMS/SWDIO)
Mcu.Pin85=PA14 (JTCK/SWCLK)
Mcu.Pin80=PA10
Mcu.Pin81=PA11
Mcu.Pin82=PA12
Mcu.Pin83=PA13 (JTMS/SWDIO)
Mcu.Pin84=PA14 (JTCK/SWCLK)
Mcu.Pin85=PA15 (JTDI)
Mcu.Pin86=PD0
Mcu.Pin87=PD1
Mcu.Pin88=PD3
@ -162,6 +162,7 @@ NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false\:true
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false\:true
NVIC.LPUART1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false\:true
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false\:true
NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false\:true
@ -199,6 +200,7 @@ PA14\ (JTCK/SWCLK).GPIO_Label=TCK
PA14\ (JTCK/SWCLK).Locked=true
PA14\ (JTCK/SWCLK).Mode=Trace_Asynchronous_SW
PA14\ (JTCK/SWCLK).Signal=SYS_JTCK-SWCLK
PA15\ (JTDI).Signal=GPIO_Analog
PA2.Mode=Clock-out-LSCO
PA2.Signal=RCC_LSCO
PA3.Signal=GPIO_Analog
@ -215,7 +217,6 @@ PA9.GPIO_Label=USB_VBUS
PA9.Locked=true
PA9.Signal=USB_OTG_FS_VBUS
PB0.Signal=GPIO_Analog
PB1.Signal=GPIO_Analog
PB10.Signal=GPIO_Analog
PB11.Signal=GPIO_Analog
PB12.Signal=GPIO_Analog
@ -370,8 +371,6 @@ PG5.GPIOParameters=GPIO_Label
PG5.GPIO_Label=USB_OverCurrent [STMPS2151STR_FAULT]
PG5.Locked=true
PG5.Signal=GPIO_Input
PG6.GPIOParameters=GPIO_Label
PG6.GPIO_Label=USB_PowerSwitchOn [STMPS2151STR_EN]
PG6.Locked=true
PG6.Signal=GPIO_Output
PG7.GPIOParameters=GPIO_Speed,GPIO_Label
@ -419,7 +418,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_LPUART1_UART_Init-LPUART1-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_RTC_Init-RTC-false-HAL-true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_LPUART1_UART_Init-LPUART1-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true
RCC.ADCFreq_Value=48000000
RCC.AHBCLKDivider=RCC_SYSCLK_DIV8
RCC.AHBFreq_Value=5916666.666666667
@ -498,3 +497,4 @@ VP_SYS_VS_tim6.Mode=TIM6
VP_SYS_VS_tim6.Signal=SYS_VS_tim6
board=NUCLEO-L4A6ZG
boardIOC=true
isbadioc=false