First Commit, build a driver for the Si5153
This commit is contained in:
59
Core/Src/freertos.c
Normal file
59
Core/Src/freertos.c
Normal file
@ -0,0 +1,59 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : freertos.c
|
||||
* Description : Code for freertos applications
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "main.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Variables */
|
||||
|
||||
/* USER CODE END Variables */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN FunctionPrototypes */
|
||||
|
||||
/* USER CODE END FunctionPrototypes */
|
||||
|
||||
/* Private application code --------------------------------------------------*/
|
||||
/* USER CODE BEGIN Application */
|
||||
|
||||
/* USER CODE END Application */
|
||||
|
663
Core/Src/main.c
Normal file
663
Core/Src/main.c
Normal file
@ -0,0 +1,663 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : main.c
|
||||
* @brief : Main program body
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include <stdio.h>
|
||||
#include "at1_defines.h"
|
||||
#include "stm32_si5351.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
I2C_HandleTypeDef hi2c1;
|
||||
|
||||
UART_HandleTypeDef hlpuart1;
|
||||
|
||||
PCD_HandleTypeDef hpcd_USB_OTG_FS;
|
||||
|
||||
/* Definitions for defaultTask */
|
||||
osThreadId_t defaultTaskHandle;
|
||||
const osThreadAttr_t defaultTask_attributes = {
|
||||
.name = "defaultTask",
|
||||
.stack_size = 128 * 4,
|
||||
.priority = (osPriority_t) osPriorityNormal,
|
||||
};
|
||||
/* Definitions for terminalTask */
|
||||
osThreadId_t terminalTaskHandle;
|
||||
const osThreadAttr_t terminalTask_attributes = {
|
||||
.name = "terminalTask",
|
||||
.stack_size = 128 * 4,
|
||||
.priority = (osPriority_t) osPriorityBelowNormal,
|
||||
};
|
||||
/* Definitions for idTask */
|
||||
osThreadId_t idTaskHandle;
|
||||
const osThreadAttr_t idTask_attributes = {
|
||||
.name = "idTask",
|
||||
.stack_size = 128 * 4,
|
||||
.priority = (osPriority_t) osPriorityLow,
|
||||
};
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* 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_USB_OTG_FS_PCD_Init(void);
|
||||
static void MX_I2C1_Init(void);
|
||||
void StartDefaultTask(void *argument);
|
||||
void start_terminal_task(void *argument);
|
||||
void start_id_task(void *argument);
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
// redirect the output of the printf function to the USART print function
|
||||
// is calling fputc to transmit the output via the USART.
|
||||
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
* @brief The application entry point.
|
||||
* @retval int
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/* MCU Configuration--------------------------------------------------------*/
|
||||
|
||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
||||
HAL_Init();
|
||||
|
||||
/* USER CODE BEGIN Init */
|
||||
|
||||
/* USER CODE END Init */
|
||||
|
||||
/* Configure the system clock */
|
||||
SystemClock_Config();
|
||||
|
||||
/* USER CODE BEGIN SysInit */
|
||||
|
||||
/* USER CODE END SysInit */
|
||||
|
||||
/* Initialize all configured peripherals */
|
||||
MX_GPIO_Init();
|
||||
MX_LPUART1_UART_Init();
|
||||
MX_USB_OTG_FS_PCD_Init();
|
||||
MX_I2C1_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
si5351_inst_t instance_si5351[3] = {0};
|
||||
|
||||
// 1st SI5351 chip and with an A0 = 0:
|
||||
instance_si5351[0] = si5351_init(&hi2c1, 27000000, 0x61);
|
||||
// 2nd SI5351 chip on the same I2C bus "hi2c1" but address line A0 = 1
|
||||
instance_si5351[1] = si5351_init(&hi2c1, 27000000, 0x60);
|
||||
// 3rd SI5351 chip on another IC2 bus with handle "hi2c2" *\/
|
||||
instance_si5351[2] = si5351_init(&hi2c1, 25000000, 0x60);
|
||||
|
||||
for (int i=0; i<3 ;i++) {
|
||||
int ready;
|
||||
ready = si5351_isready(instance_si5351[i]);
|
||||
printf("Device No. %d (Instance No: 0x%x) is %s\n", i, (unsigned int) instance_si5351[i], (ready==0) ? "ready" : "N/A");
|
||||
}
|
||||
|
||||
for (int i=2; i>=0; i--) {
|
||||
si5351_deinit(instance_si5351[i]);
|
||||
}
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Init scheduler */
|
||||
osKernelInitialize();
|
||||
|
||||
/* USER CODE BEGIN RTOS_MUTEX */
|
||||
/* add mutexes, ... */
|
||||
/* USER CODE END RTOS_MUTEX */
|
||||
|
||||
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
||||
/* add semaphores, ... */
|
||||
/* USER CODE END RTOS_SEMAPHORES */
|
||||
|
||||
/* USER CODE BEGIN RTOS_TIMERS */
|
||||
/* start timers, add new ones, ... */
|
||||
/* USER CODE END RTOS_TIMERS */
|
||||
|
||||
/* USER CODE BEGIN RTOS_QUEUES */
|
||||
/* add queues, ... */
|
||||
/* USER CODE END RTOS_QUEUES */
|
||||
|
||||
/* Create the thread(s) */
|
||||
/* creation of defaultTask */
|
||||
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
|
||||
|
||||
/* creation of terminalTask */
|
||||
terminalTaskHandle = osThreadNew(start_terminal_task, NULL, &terminalTask_attributes);
|
||||
|
||||
/* creation of idTask */
|
||||
idTaskHandle = osThreadNew(start_id_task, NULL, &idTask_attributes);
|
||||
|
||||
/* USER CODE BEGIN RTOS_THREADS */
|
||||
/* add threads, ... */
|
||||
/* USER CODE END RTOS_THREADS */
|
||||
|
||||
/* USER CODE BEGIN RTOS_EVENTS */
|
||||
/* add events, ... */
|
||||
/* USER CODE END RTOS_EVENTS */
|
||||
|
||||
/* Start scheduler */
|
||||
osKernelStart();
|
||||
|
||||
/* We should never get here as control is now taken by the scheduler */
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
while (1)
|
||||
{
|
||||
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
}
|
||||
/* USER CODE END 3 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief System Clock Configuration
|
||||
* @retval None
|
||||
*/
|
||||
void SystemClock_Config(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
|
||||
/** Configure the main internal regulator output voltage
|
||||
*/
|
||||
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Configure LSE Drive Capability
|
||||
*/
|
||||
HAL_PWR_EnableBkUpAccess();
|
||||
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
|
||||
|
||||
/** Initializes the RCC Oscillators according to the specified parameters
|
||||
* in the RCC_OscInitTypeDef structure.
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI;
|
||||
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
|
||||
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
|
||||
RCC_OscInitStruct.MSICalibrationValue = 0;
|
||||
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
|
||||
RCC_OscInitStruct.PLL.PLLM = 1;
|
||||
RCC_OscInitStruct.PLL.PLLN = 71;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV6;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Initializes the CPU, AHB and APB buses clocks
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Enable MSI Auto calibration
|
||||
*/
|
||||
HAL_RCCEx_EnableMSIPLLMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C1 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_I2C1_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN I2C1_Init 0 */
|
||||
|
||||
/* USER CODE END I2C1_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN I2C1_Init 1 */
|
||||
|
||||
/* USER CODE END I2C1_Init 1 */
|
||||
hi2c1.Instance = I2C1;
|
||||
hi2c1.Init.Timing = 0x00505B89;
|
||||
hi2c1.Init.OwnAddress1 = 0;
|
||||
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
||||
hi2c1.Init.OwnAddress2 = 0;
|
||||
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
|
||||
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
||||
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Configure Analogue filter
|
||||
*/
|
||||
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Configure Digital filter
|
||||
*/
|
||||
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN I2C1_Init 2 */
|
||||
|
||||
/* USER CODE END I2C1_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LPUART1 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_LPUART1_UART_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN LPUART1_Init 0 */
|
||||
|
||||
/* USER CODE END LPUART1_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN LPUART1_Init 1 */
|
||||
|
||||
/* USER CODE END LPUART1_Init 1 */
|
||||
hlpuart1.Instance = LPUART1;
|
||||
hlpuart1.Init.BaudRate = 115200;
|
||||
hlpuart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
hlpuart1.Init.StopBits = UART_STOPBITS_1;
|
||||
hlpuart1.Init.Parity = UART_PARITY_NONE;
|
||||
hlpuart1.Init.Mode = UART_MODE_TX_RX;
|
||||
hlpuart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
hlpuart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
|
||||
hlpuart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
||||
if (HAL_UART_Init(&hlpuart1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN LPUART1_Init 2 */
|
||||
|
||||
/* USER CODE END LPUART1_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USB_OTG_FS Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_USB_OTG_FS_PCD_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN USB_OTG_FS_Init 0 */
|
||||
|
||||
/* USER CODE END USB_OTG_FS_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN USB_OTG_FS_Init 1 */
|
||||
|
||||
/* USER CODE END USB_OTG_FS_Init 1 */
|
||||
hpcd_USB_OTG_FS.Instance = USB_OTG_FS;
|
||||
hpcd_USB_OTG_FS.Init.dev_endpoints = 6;
|
||||
hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;
|
||||
hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
|
||||
hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE;
|
||||
hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE;
|
||||
hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE;
|
||||
hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE;
|
||||
hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;
|
||||
hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE;
|
||||
if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN USB_OTG_FS_Init 2 */
|
||||
|
||||
/* USER CODE END USB_OTG_FS_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GPIO Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_GPIO_Init(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOG_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
HAL_PWREx_EnableVddIO2();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
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);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pins : PE2 PE3 PE4 PE5
|
||||
PE6 PE7 PE8 PE9
|
||||
PE10 PE11 PE12 PE13
|
||||
PE14 PE15 PE0 PE1 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
|
||||
|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9
|
||||
|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13
|
||||
|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : B1_Pin */
|
||||
GPIO_InitStruct.Pin = B1_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PF0 PF1 PF2 PF3
|
||||
PF4 PF5 PF6 PF7
|
||||
PF8 PF9 PF10 PF11
|
||||
PF12 PF13 PF14 PF15 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|
||||
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
|
||||
|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|
||||
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PH0 PH3 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_3;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PC0 PC1 PC2 PC3
|
||||
PC4 PC5 PC6 PC8
|
||||
PC9 PC10 PC11 PC12 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|
||||
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_8
|
||||
|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PA0 PA1 PA2 PA3
|
||||
PA4 PA5 PA6 PA7
|
||||
PA15 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|
||||
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
|
||||
|GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PB0 PB1 PB2 PB10
|
||||
PB11 PB12 PB13 PB15
|
||||
PB4 PB5 PB6 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10
|
||||
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_15
|
||||
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PG0 PG1 PG2 PG3
|
||||
PG4 PG9 PG10 PG11
|
||||
PG12 PG13 PG14 PG15 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|
||||
|GPIO_PIN_4|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|
||||
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : LD3_Pin LD2_Pin */
|
||||
GPIO_InitStruct.Pin = LD3_Pin|LD2_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PD8 PD9 PD10 PD11
|
||||
PD12 PD13 PD14 PD15
|
||||
PD0 PD1 PD2 PD3
|
||||
PD4 PD5 PD6 PD7 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|
||||
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15
|
||||
|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|
||||
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : USB_OverCurrent_Pin */
|
||||
GPIO_InitStruct.Pin = USB_OverCurrent_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
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;
|
||||
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);
|
||||
|
||||
/*Configure GPIO pin : LD1_Pin */
|
||||
GPIO_InitStruct.Pin = LD1_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(LD1_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 4 */
|
||||
/**
|
||||
* @brief Retargets the C library printf function to the USART.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
PUTCHAR_PROTOTYPE
|
||||
{
|
||||
/* Place your implementation of fputc here */
|
||||
/* e.g. write a character to the USART1 and Loop until the end of transmission */
|
||||
HAL_UART_Transmit(&hlpuart1, (uint8_t *)&ch, 1, 0xFFFF);
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* USER CODE END 4 */
|
||||
|
||||
/* USER CODE BEGIN Header_StartDefaultTask */
|
||||
/**
|
||||
* @brief Function implementing the defaultTask thread.
|
||||
* @param argument: Not used
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_StartDefaultTask */
|
||||
void StartDefaultTask(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN 5 */
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
// HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin);
|
||||
HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_SET);
|
||||
osDelay(1);
|
||||
HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_RESET);
|
||||
osDelay(1999);
|
||||
}
|
||||
/* USER CODE END 5 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN Header_start_terminal_task */
|
||||
/**
|
||||
* @brief Function implementing the terminalTask thread.
|
||||
* @param argument: Not used
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_start_terminal_task */
|
||||
void start_terminal_task(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN start_terminal_task */
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
osDelay(1);
|
||||
}
|
||||
/* USER CODE END start_terminal_task */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN Header_start_id_task */
|
||||
/**
|
||||
* @brief Function implementing the idTask thread.
|
||||
* @param argument: Not used
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_start_id_task */
|
||||
void start_id_task(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN start_id_task */
|
||||
//uint8_t tx_buf[80];
|
||||
//int tx_buf_len;
|
||||
/* check if the SI5351 is present */
|
||||
int status = HAL_I2C_IsDeviceReady(&hi2c1, SI5351_I2C_ADDR, 3, 10 /*HAL_MAX_DELAY*/ ); // HAL_MAX_DELAY is blocking, use 10 ms
|
||||
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
printf("\n" PROGRAM_ID "\n");
|
||||
printf(AUTHOR_STRING "\n");
|
||||
if (status == HAL_OK) {
|
||||
printf("Si5351 device found.\n");
|
||||
} else {
|
||||
printf("Error: Could not detect Si5351 device.\n");
|
||||
}
|
||||
osDelay(30*60);
|
||||
}
|
||||
/* USER CODE END start_id_task */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Period elapsed callback in non blocking mode
|
||||
* @note This function is called when TIM16 interrupt took place, inside
|
||||
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
|
||||
* a global variable "uwTick" used as application time base.
|
||||
* @param htim : TIM handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
{
|
||||
/* USER CODE BEGIN Callback 0 */
|
||||
|
||||
/* USER CODE END Callback 0 */
|
||||
if (htim->Instance == TIM16) {
|
||||
HAL_IncTick();
|
||||
}
|
||||
/* USER CODE BEGIN Callback 1 */
|
||||
|
||||
/* USER CODE END Callback 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function is executed in case of error occurrence.
|
||||
* @retval None
|
||||
*/
|
||||
void Error_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN Error_Handler_Debug */
|
||||
/* User can add his own implementation to report the HAL error return state */
|
||||
__disable_irq();
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
/* USER CODE END Error_Handler_Debug */
|
||||
}
|
||||
|
||||
#ifdef USE_FULL_ASSERT
|
||||
/**
|
||||
* @brief Reports the name of the source file and the source line number
|
||||
* where the assert_param error has occurred.
|
||||
* @param file: pointer to the source file name
|
||||
* @param line: assert_param error line source number
|
||||
* @retval None
|
||||
*/
|
||||
void assert_failed(uint8_t *file, uint32_t line)
|
||||
{
|
||||
/* USER CODE BEGIN 6 */
|
||||
/* User can add his own implementation to report the file name and line number,
|
||||
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
||||
/* USER CODE END 6 */
|
||||
}
|
||||
#endif /* USE_FULL_ASSERT */
|
889
Core/Src/si5351.c
Normal file
889
Core/Src/si5351.c
Normal file
@ -0,0 +1,889 @@
|
||||
/*
|
||||
* si5351.c
|
||||
*
|
||||
* Created on: Jan 14, 2019
|
||||
* Author: Petr Polasek
|
||||
*
|
||||
* To make this library useable on any other device than
|
||||
* STM32Fxxx Cortex Mx, please edit these parts of the library:
|
||||
*
|
||||
* DEFINES:
|
||||
* SI5351_I2C_PERIPHERAL - the I2C peripheral name according
|
||||
* to your devices HAL library
|
||||
* I2C_TIMEOUT - time for the communication to time out
|
||||
*
|
||||
* TYPEDEFS:
|
||||
* Si5351_ConfigTypeDef - the I2Cx parameter should be changed
|
||||
* so that its type corresponds to your HAL library
|
||||
*
|
||||
* FUNCTIONS:
|
||||
* Si5351_WriteRegister
|
||||
* Si5351_ReadRegister
|
||||
* You need to write your own I2C handlers here
|
||||
*
|
||||
*/
|
||||
|
||||
//put your I2C HAL library name here
|
||||
//#include "stm32f10x_i2c.h"
|
||||
#include "stm32l4xx_hal.h"
|
||||
|
||||
#if 0
|
||||
|
||||
#include "si5351.h"
|
||||
|
||||
int Si5351_WriteRegister(Si5351_ConfigTypeDef *Si5351_ConfigStruct, uint8_t reg_address, uint8_t reg_data)
|
||||
{
|
||||
uint32_t error_wait;
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_GetFlagStatus(Si5351_ConfigStruct->I2Cx, I2C_FLAG_BUSY) == SET)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0)
|
||||
{
|
||||
I2C_SoftwareResetCmd(Si5351_ConfigStruct->I2Cx, ENABLE);
|
||||
I2C_SoftwareResetCmd(Si5351_ConfigStruct->I2Cx, DISABLE);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//wait for I2C to get ready, if not ready in time, reset I2C and return
|
||||
|
||||
I2C_GenerateSTART(Si5351_ConfigStruct->I2Cx, ENABLE);
|
||||
//send START condition
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_CheckEvent(Si5351_ConfigStruct->I2Cx, I2C_EVENT_MASTER_MODE_SELECT) == ERROR)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait for START to be sent, if not sent in time, return
|
||||
|
||||
I2C_Send7bitAddress(Si5351_ConfigStruct->I2Cx, Si5351_ConfigStruct->HW_I2C_Address, I2C_Direction_Transmitter);
|
||||
//send address+RW bit
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_CheckEvent(Si5351_ConfigStruct->I2Cx, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED) == ERROR)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait for address to be sent, if not sent in time, return
|
||||
|
||||
I2C_SendData(Si5351_ConfigStruct->I2Cx, reg_address);
|
||||
//send reg address
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_CheckEvent(Si5351_ConfigStruct->I2Cx, I2C_EVENT_MASTER_BYTE_TRANSMITTED) == ERROR)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait for reg address to be sent
|
||||
|
||||
I2C_SendData(Si5351_ConfigStruct->I2Cx, reg_data);
|
||||
//send reg data
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_CheckEvent(Si5351_ConfigStruct->I2Cx, I2C_EVENT_MASTER_BYTE_TRANSMITTED) == ERROR)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait for data to be sent, if not sent in time, return
|
||||
|
||||
I2C_GenerateSTOP(Si5351_ConfigStruct->I2Cx, ENABLE);
|
||||
//generate STOP condition
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_GetFlagStatus(Si5351_ConfigStruct->I2Cx, I2C_FLAG_STOPF))
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait until STOP is cleared
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t Si5351_ReadRegister(Si5351_ConfigTypeDef *Si5351_ConfigStruct, uint8_t reg_address)
|
||||
{
|
||||
uint32_t error_wait;
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_GetFlagStatus(Si5351_ConfigStruct->I2Cx, I2C_FLAG_BUSY) == SET)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0)
|
||||
{
|
||||
I2C_SoftwareResetCmd(Si5351_ConfigStruct->I2Cx, ENABLE);
|
||||
I2C_SoftwareResetCmd(Si5351_ConfigStruct->I2Cx, DISABLE);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//wait for I2C to get ready, if not ready in time, reset I2C and return
|
||||
|
||||
I2C_GenerateSTART(Si5351_ConfigStruct->I2Cx, ENABLE);
|
||||
//send START condition
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_CheckEvent(Si5351_ConfigStruct->I2Cx, I2C_EVENT_MASTER_MODE_SELECT) == ERROR)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait for START to be sent, if not sent in time, return
|
||||
|
||||
I2C_Send7bitAddress(Si5351_ConfigStruct->I2Cx, Si5351_ConfigStruct->HW_I2C_Address, I2C_Direction_Transmitter);
|
||||
//send address+RW bit
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_CheckEvent(Si5351_ConfigStruct->I2Cx, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED) == ERROR)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait for address to be sent, if not sent in time, return
|
||||
|
||||
I2C_SendData(Si5351_ConfigStruct->I2Cx, reg_address);
|
||||
//send reg address
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_CheckEvent(Si5351_ConfigStruct->I2Cx, I2C_EVENT_MASTER_BYTE_TRANSMITTED) == ERROR)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait for reg address to be sent
|
||||
|
||||
I2C_GenerateSTOP(Si5351_ConfigStruct->I2Cx, ENABLE);
|
||||
//generate STOP condition
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_GetFlagStatus(Si5351_ConfigStruct->I2Cx, I2C_FLAG_STOPF))
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait until STOP is cleared
|
||||
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_GetFlagStatus(Si5351_ConfigStruct->I2Cx, I2C_FLAG_BUSY) == SET)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0)
|
||||
{
|
||||
I2C_SoftwareResetCmd(Si5351_ConfigStruct->I2Cx, ENABLE);
|
||||
I2C_SoftwareResetCmd(Si5351_ConfigStruct->I2Cx, DISABLE);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//wait for I2C to get ready, if not ready in time, reset I2C and return
|
||||
|
||||
I2C_GenerateSTART(Si5351_ConfigStruct->I2Cx, ENABLE);
|
||||
//send START condition
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_CheckEvent(Si5351_ConfigStruct->I2Cx, I2C_EVENT_MASTER_MODE_SELECT) == ERROR)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait for START to be sent, if not sent in time, return
|
||||
|
||||
I2C_Send7bitAddress(Si5351_ConfigStruct->I2Cx, Si5351_ConfigStruct->HW_I2C_Address, I2C_Direction_Receiver);
|
||||
//send address+RW bit
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_CheckEvent(Si5351_ConfigStruct->I2Cx, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED) == ERROR)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait for address to be sent, if not sent in time, return
|
||||
|
||||
while (I2C_CheckEvent(Si5351_ConfigStruct->I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED) == ERROR)
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait for data
|
||||
|
||||
uint8_t reg_data;
|
||||
reg_data = I2C_ReceiveData(Si5351_ConfigStruct->I2Cx);
|
||||
//receive reg data
|
||||
|
||||
I2C_GenerateSTOP(Si5351_ConfigStruct->I2Cx, ENABLE);
|
||||
//generate STOP condition
|
||||
|
||||
error_wait = I2C_TIMEOUT;
|
||||
while (I2C_GetFlagStatus(Si5351_ConfigStruct->I2Cx, I2C_FLAG_STOPF))
|
||||
{
|
||||
error_wait--;
|
||||
if (error_wait==0) return 1;
|
||||
}
|
||||
//wait until STOP is cleared
|
||||
|
||||
return reg_data;
|
||||
}
|
||||
|
||||
//set safe values in the config structure
|
||||
void Si5351_StructInit(Si5351_ConfigTypeDef *Si5351_ConfigStruct)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
Si5351_ConfigStruct->HW_I2C_Address = SI5351_I2C_ADDRESS;
|
||||
Si5351_ConfigStruct->I2Cx = SI5351_I2C_PERIPHERAL;
|
||||
|
||||
Si5351_ConfigStruct->f_CLKIN = SI5351_CLKIN_FREQ;
|
||||
Si5351_ConfigStruct->f_XTAL = SI5351_XTAL_FREQ;
|
||||
|
||||
Si5351_ConfigStruct->Interrupt_Mask_CLKIN = ON;
|
||||
Si5351_ConfigStruct->Interrupt_Mask_PLLA = ON;
|
||||
Si5351_ConfigStruct->Interrupt_Mask_PLLB = ON;
|
||||
Si5351_ConfigStruct->Interrupt_Mask_SysInit = ON;
|
||||
Si5351_ConfigStruct->Interrupt_Mask_XTAL = ON;
|
||||
|
||||
Si5351_ConfigStruct->Fanout_CLKIN_EN = ON;
|
||||
Si5351_ConfigStruct->Fanout_MS_EN = ON;
|
||||
Si5351_ConfigStruct->Fanout_XO_EN = ON;
|
||||
|
||||
Si5351_ConfigStruct->OSC.CLKIN_Div = CLKINDiv_Div1;
|
||||
Si5351_ConfigStruct->OSC.OSC_XTAL_Load = XTAL_Load_10_pF;
|
||||
Si5351_ConfigStruct->OSC.VCXO_Pull_Range_ppm = 0; //maybe should be set to 30 ppm, not clear from the AN-619
|
||||
|
||||
for (i=0; i<=1; i++)
|
||||
{
|
||||
Si5351_ConfigStruct->PLL[i].PLL_Clock_Source = PLL_Clock_Source_XTAL;
|
||||
Si5351_ConfigStruct->PLL[i].PLL_Multiplier_Integer = 32; //range 24..36 for 25 MHz clock
|
||||
Si5351_ConfigStruct->PLL[i].PLL_Multiplier_Numerator = 0; //range 0..1048575
|
||||
Si5351_ConfigStruct->PLL[i].PLL_Multiplier_Denominator = 1; //range 1..1048575
|
||||
Si5351_ConfigStruct->PLL[i].PLL_Capacitive_Load = PLL_Capacitive_Load_0; //select 0, unless you want to tune the PLL to <200 MHZ
|
||||
}
|
||||
|
||||
Si5351_ConfigStruct->SS.SS_Amplitude_ppm = 0; //1.5% modulation = 15000
|
||||
Si5351_ConfigStruct->SS.SS_Enable = OFF;
|
||||
Si5351_ConfigStruct->SS.SS_Mode = SS_Mode_CenterSpread;
|
||||
Si5351_ConfigStruct->SS.SS_NCLK = SS_NCLK_0; //default value, this parameter is unexplained in documentation
|
||||
|
||||
for (i=0; i<=7; i++)
|
||||
{
|
||||
Si5351_ConfigStruct->MS[i].MS_Clock_Source = MS_Clock_Source_PLLA;
|
||||
Si5351_ConfigStruct->MS[i].MS_Divider_Integer = 4;
|
||||
Si5351_ConfigStruct->MS[i].MS_Divider_Numerator = 0;
|
||||
Si5351_ConfigStruct->MS[i].MS_Divider_Denominator = 1;
|
||||
|
||||
Si5351_ConfigStruct->CLK[i].CLK_Clock_Source = CLK_Clock_Source_MS_Own;
|
||||
Si5351_ConfigStruct->CLK[i].CLK_Disable_State = CLK_Disable_State_HIGH_Z;
|
||||
Si5351_ConfigStruct->CLK[i].CLK_Enable = OFF;
|
||||
Si5351_ConfigStruct->CLK[i].CLK_I_Drv = CLK_I_Drv_8mA;
|
||||
Si5351_ConfigStruct->CLK[i].CLK_Invert = OFF;
|
||||
Si5351_ConfigStruct->CLK[i].CLK_PowerDown = OFF;
|
||||
Si5351_ConfigStruct->CLK[i].CLK_QuarterPeriod_Offset = 0;
|
||||
Si5351_ConfigStruct->CLK[i].CLK_R_Div = CLK_R_Div1;
|
||||
Si5351_ConfigStruct->CLK[i].CLK_Use_OEB_Pin = OFF;
|
||||
}
|
||||
}
|
||||
|
||||
void Si5351_OSCConfig(Si5351_ConfigTypeDef *Si5351_ConfigStruct)
|
||||
{
|
||||
uint8_t tmp;
|
||||
uint32_t VCXO_Param;
|
||||
|
||||
//set XTAL capacitive load and PLL VCO load capacitance
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_XTAL_CL);
|
||||
tmp &= ~(XTAL_CL_MASK | PLL_CL_MASK);
|
||||
tmp |= (XTAL_CL_MASK & (Si5351_ConfigStruct->OSC.OSC_XTAL_Load)) | (PLL_CL_MASK & ((Si5351_ConfigStruct->PLL[0].PLL_Capacitive_Load) << 1)) | (PLL_CL_MASK & ((Si5351_ConfigStruct->PLL[1].PLL_Capacitive_Load) << 4));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_XTAL_CL, tmp);
|
||||
|
||||
//set CLKIN pre-divider
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLKIN_DIV);
|
||||
tmp &= ~CLKIN_MASK;
|
||||
tmp |= CLKIN_MASK & Si5351_ConfigStruct->OSC.CLKIN_Div;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLKIN_DIV, tmp);
|
||||
|
||||
//set fanout of XO, MS0, MS4 and CLKIN - should be always on unless you
|
||||
//need to reduce power consumption
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_FANOUT_EN);
|
||||
tmp &= ~(FANOUT_CLKIN_EN_MASK | FANOUT_MS_EN_MASK | FANOUT_XO_EN_MASK);
|
||||
if (Si5351_ConfigStruct->Fanout_CLKIN_EN == ON) tmp |= FANOUT_CLKIN_EN_MASK;
|
||||
if (Si5351_ConfigStruct->Fanout_MS_EN == ON) tmp |= FANOUT_MS_EN_MASK;
|
||||
if (Si5351_ConfigStruct->Fanout_XO_EN == ON) tmp |= FANOUT_XO_EN_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_FANOUT_EN, tmp);
|
||||
|
||||
//if "b" in PLLB set to 10^6, set VCXO parameter
|
||||
if (Si5351_ConfigStruct->PLL[1].PLL_Multiplier_Denominator == 1000000)
|
||||
{
|
||||
VCXO_Param = VCXO_PARAM_MASK & (uint32_t)
|
||||
((103 * Si5351_ConfigStruct->OSC.VCXO_Pull_Range_ppm
|
||||
* ((uint64_t)128000000 * Si5351_ConfigStruct->PLL[1].PLL_Multiplier_Integer +
|
||||
Si5351_ConfigStruct->PLL[1].PLL_Multiplier_Numerator))/100000000);
|
||||
} else {
|
||||
VCXO_Param = 0;
|
||||
}
|
||||
|
||||
tmp = (uint8_t) VCXO_Param;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_VCXO_PARAM_0_7, tmp);
|
||||
tmp = (uint8_t)(VCXO_Param>>8);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_VCXO_PARAM_8_15, tmp);
|
||||
tmp = (uint8_t)((VCXO_Param>>16) & VCXO_PARAM_16_21_MASK);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_VCXO_PARAM_16_21, tmp);
|
||||
}
|
||||
|
||||
EnableState Si5351_CheckStatusBit(Si5351_ConfigTypeDef *Si5351_ConfigStruct, Si5351_StatusBitTypeDef StatusBit)
|
||||
{
|
||||
uint8_t tmp;
|
||||
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_DEV_STATUS);
|
||||
tmp &= StatusBit;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
EnableState Si5351_CheckStickyBit(Si5351_ConfigTypeDef *Si5351_ConfigStruct, Si5351_StatusBitTypeDef StatusBit)
|
||||
{
|
||||
uint8_t tmp;
|
||||
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_DEV_STICKY);
|
||||
tmp &= StatusBit;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void Si5351_InterruptConfig(Si5351_ConfigTypeDef *Si5351_ConfigStruct)
|
||||
{
|
||||
uint8_t tmp;
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_INT_MASK);
|
||||
|
||||
tmp &= ~INT_MASK_LOS_XTAL_MASK;
|
||||
if (Si5351_ConfigStruct->Interrupt_Mask_XTAL == ON)
|
||||
{
|
||||
tmp |= INT_MASK_LOS_XTAL_MASK;
|
||||
}
|
||||
|
||||
tmp &= ~INT_MASK_LOS_CLKIN_MASK;
|
||||
if (Si5351_ConfigStruct->Interrupt_Mask_CLKIN == ON)
|
||||
{
|
||||
tmp |= INT_MASK_LOS_CLKIN_MASK;
|
||||
}
|
||||
|
||||
tmp &= ~INT_MASK_LOL_A_MASK;
|
||||
if (Si5351_ConfigStruct->Interrupt_Mask_PLLA == ON)
|
||||
{
|
||||
tmp |= INT_MASK_LOL_A_MASK;
|
||||
}
|
||||
|
||||
tmp &= ~INT_MASK_LOL_B_MASK;
|
||||
if (Si5351_ConfigStruct->Interrupt_Mask_PLLB == ON)
|
||||
{
|
||||
tmp |= INT_MASK_LOL_B_MASK;
|
||||
}
|
||||
|
||||
tmp &= ~INT_MASK_SYS_INIT_MASK;
|
||||
if (Si5351_ConfigStruct->Interrupt_Mask_SysInit == ON)
|
||||
{
|
||||
tmp |= INT_MASK_SYS_INIT_MASK;
|
||||
}
|
||||
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_INT_MASK, tmp);
|
||||
}
|
||||
|
||||
void Si5351_ClearStickyBit(Si5351_ConfigTypeDef *Si5351_ConfigStruct, Si5351_StatusBitTypeDef StatusBit)
|
||||
{
|
||||
uint8_t tmp;
|
||||
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_DEV_STICKY);
|
||||
tmp &= ~StatusBit;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_DEV_STICKY, tmp);
|
||||
}
|
||||
|
||||
void Si5351_PLLConfig(Si5351_ConfigTypeDef *Si5351_ConfigStruct, Si5351_PLLChannelTypeDef PLL_Channel)
|
||||
{
|
||||
uint8_t tmp, tmp_mask;
|
||||
uint32_t MSN_P1, MSN_P2, MSN_P3;
|
||||
|
||||
//set PLL clock source
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_PLL_CLOCK_SOURCE);
|
||||
tmp_mask = PLLA_CLOCK_SOURCE_MASK << PLL_Channel;
|
||||
tmp &= ~tmp_mask;
|
||||
tmp |= tmp_mask & Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Clock_Source;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_PLL_CLOCK_SOURCE, tmp);
|
||||
|
||||
//if new multiplier not even integer, disable the integer mode
|
||||
if ((Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Numerator != 0) | ((Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Integer & 0x01) != 0 ))
|
||||
{
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_FB_INT + PLL_Channel);
|
||||
tmp &= ~FB_INT_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_FB_INT + PLL_Channel, tmp);
|
||||
}
|
||||
|
||||
//configure the PLL multiplier
|
||||
MSN_P1 = 128 * Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Integer + ((128 * Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Numerator) / Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Denominator) - 512;
|
||||
MSN_P2 = 128 * Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Numerator - Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Denominator * ((128 * Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Numerator) / Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Denominator);
|
||||
MSN_P3 = Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Denominator;
|
||||
|
||||
tmp = (uint8_t) MSN_P1;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MSN_P1_0_7 + 8 * PLL_Channel, tmp);
|
||||
tmp = (uint8_t) (MSN_P1 >> 8);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MSN_P1_8_15 + 8 * PLL_Channel, tmp);
|
||||
tmp = (uint8_t) (MSN_P1_16_17_MASK & (MSN_P1 >> 16));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MSN_P1_16_17 + 8 * PLL_Channel, tmp);
|
||||
|
||||
tmp = (uint8_t) MSN_P2;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MSN_P2_0_7 + 8 * PLL_Channel, tmp);
|
||||
tmp = (uint8_t) (MSN_P2 >> 8);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MSN_P2_8_15 + 8 * PLL_Channel, tmp);
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_MSN_P2_16_19);
|
||||
tmp &= ~MSN_P2_16_19_MASK;
|
||||
tmp |= (uint8_t) (MSN_P2_16_19_MASK & (MSN_P2 >> 16));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MSN_P2_16_19 + 8 * PLL_Channel, tmp);
|
||||
|
||||
tmp = (uint8_t) MSN_P3;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MSN_P3_0_7 + 8 * PLL_Channel, tmp);
|
||||
tmp = (uint8_t) (MSN_P3 >> 8);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MSN_P3_8_15 + 8 * PLL_Channel, tmp);
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_MSN_P3_16_19);
|
||||
tmp &= ~MSN_P3_16_19_MASK;
|
||||
tmp |= (uint8_t) (MSN_P3_16_19_MASK & ((MSN_P3 >> 16) << 4));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MSN_P3_16_19 + 8 * PLL_Channel, tmp);
|
||||
|
||||
//if new multiplier is an even integer, enable integer mode
|
||||
if ((Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Numerator == 0) & ((Si5351_ConfigStruct->PLL[PLL_Channel].PLL_Multiplier_Integer & 0x01) == 0 ))
|
||||
{
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_FB_INT + PLL_Channel);
|
||||
tmp |= FB_INT_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_FB_INT + PLL_Channel, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
void Si5351_PLLReset(Si5351_ConfigTypeDef *Si5351_ConfigStruct, Si5351_PLLChannelTypeDef PLL_Channel)
|
||||
{
|
||||
uint8_t tmp;
|
||||
|
||||
//reset PLL
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_PLL_RESET);
|
||||
if (PLL_Channel == PLL_A)
|
||||
{
|
||||
tmp |= PLLA_RESET_MASK;
|
||||
} else {
|
||||
tmp |= PLLB_RESET_MASK;
|
||||
}
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_PLL_RESET, tmp);
|
||||
}
|
||||
|
||||
void Si5351_PLLSimultaneousReset(Si5351_ConfigTypeDef *Si5351_ConfigStruct)
|
||||
{
|
||||
uint8_t tmp;
|
||||
|
||||
//reset PLL
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_PLL_RESET);
|
||||
tmp |= PLLA_RESET_MASK | PLLB_RESET_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_PLL_RESET, tmp);
|
||||
}
|
||||
|
||||
void Si5351_SSConfig(Si5351_ConfigTypeDef *Si5351_ConfigStruct)
|
||||
{
|
||||
uint8_t tmp;
|
||||
uint32_t SSUDP, SSUP_P1, SSUP_P2, SSUP_P3, SSDN_P1, SSDN_P2, SSDN_P3;
|
||||
uint64_t SSDN, SSUP;
|
||||
|
||||
//turn off SS if it should be disabled
|
||||
if ((Si5351_ConfigStruct->SS.SS_Enable == OFF)|
|
||||
(((Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Integer & 0x01) == 0)
|
||||
& (Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Numerator == 0)) )
|
||||
{
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_SSC_EN);
|
||||
tmp &= ~SSC_EN_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSC_EN, tmp);
|
||||
}
|
||||
|
||||
//set default value of SS_NCLK - spread spectrum reserved register
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_SS_NCLK);
|
||||
tmp &= ~SS_NCLK_MASK;
|
||||
tmp |= SS_NCLK_MASK & (Si5351_ConfigStruct->SS.SS_NCLK);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SS_NCLK, tmp);
|
||||
|
||||
//set SS mode
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_SSC_MODE);
|
||||
tmp &= ~SSC_MODE_MASK;
|
||||
tmp |= SSC_MODE_MASK & Si5351_ConfigStruct->SS.SS_Mode;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSC_MODE, tmp);
|
||||
|
||||
//set SSUDP parameter
|
||||
if (Si5351_ConfigStruct->PLL[0].PLL_Clock_Source == PLL_Clock_Source_CLKIN)
|
||||
{
|
||||
SSUDP = (Si5351_ConfigStruct->f_CLKIN)/(4*31500);
|
||||
} else {
|
||||
SSUDP = (Si5351_ConfigStruct->f_XTAL)/(4*31500);
|
||||
}
|
||||
|
||||
//set SSUDP parameter
|
||||
tmp = (uint8_t) SSUDP;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSUDP_0_7, tmp);
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_SSUDP_8_11);
|
||||
tmp &= ~SSUDP_8_11_MASK;
|
||||
tmp |= (uint8_t) (SSUDP_8_11_MASK & ((SSUDP >> 8) << 4));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSUDP_8_11, tmp);
|
||||
|
||||
//calculate SSUP and SSDN parameters
|
||||
if (Si5351_ConfigStruct->SS.SS_Mode == SS_Mode_CenterSpread)
|
||||
{
|
||||
SSUP = ((uint64_t)(64000000*Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Integer
|
||||
+ (64000000*Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Numerator)/(Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Denominator)
|
||||
) * Si5351_ConfigStruct->SS.SS_Amplitude_ppm
|
||||
) / ((1000000 - Si5351_ConfigStruct->SS.SS_Amplitude_ppm) * SSUDP);
|
||||
|
||||
SSDN = ((uint64_t)(64000000*Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Integer
|
||||
+ (64000000*Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Numerator)/(Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Denominator)
|
||||
) * Si5351_ConfigStruct->SS.SS_Amplitude_ppm
|
||||
) / ((1000000 + Si5351_ConfigStruct->SS.SS_Amplitude_ppm) * SSUDP);
|
||||
|
||||
SSUP_P1 = (uint32_t) (SSUP/1000000);
|
||||
SSUP_P2 = (uint32_t)(32767*(SSUP/1000000-SSUP_P1));
|
||||
SSUP_P3 = 0x7FFF;
|
||||
|
||||
} else {
|
||||
|
||||
SSDN = ((uint64_t)(64000000*Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Integer
|
||||
+ (64000000*Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Numerator)/(Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Denominator)
|
||||
) * Si5351_ConfigStruct->SS.SS_Amplitude_ppm
|
||||
) / ((1000000 + Si5351_ConfigStruct->SS.SS_Amplitude_ppm) * SSUDP);
|
||||
|
||||
SSUP_P1 = 0;
|
||||
SSUP_P2 = 0;
|
||||
SSUP_P3 = 1;
|
||||
|
||||
}
|
||||
|
||||
//set SSDN parameter
|
||||
SSDN_P1 = (uint32_t) (SSDN/1000000);
|
||||
SSDN_P2 = (uint32_t)(32767*(SSDN/1000000-SSDN_P1));
|
||||
SSDN_P3 = 0x7FFF;
|
||||
|
||||
//write SSUP parameter P1
|
||||
tmp = (uint8_t) SSUP_P1;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSUP_P1_0_7, tmp);
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_SSUP_P1_8_11);
|
||||
tmp &= ~SSUP_P1_8_11_MASK;
|
||||
tmp |= (uint8_t)(SSUP_P1_8_11_MASK & (SSUP_P1 >> 8));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSUP_P1_8_11, tmp);
|
||||
|
||||
//write SSUP parameter P2
|
||||
tmp = (uint8_t) SSUP_P2;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSUP_P2_0_7, tmp);
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_SSUP_P2_8_14);
|
||||
tmp &= ~SSUP_P2_8_14_MASK;
|
||||
tmp |= (uint8_t)(SSUP_P2_8_14_MASK & (SSUP_P2 >> 8));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSUP_P2_8_14, tmp);
|
||||
|
||||
//write SSUP parameter P3
|
||||
tmp = (uint8_t) SSUP_P3;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSUP_P3_0_7, tmp);
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_SSUP_P3_8_14);
|
||||
tmp &= ~SSUP_P3_8_14_MASK;
|
||||
tmp |= (uint8_t)(SSUP_P3_8_14_MASK & (SSUP_P3 >> 8));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSUP_P3_8_14, tmp);
|
||||
|
||||
//write SSDN parameter P1
|
||||
tmp = (uint8_t) SSDN_P1;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSDN_P1_0_7, tmp);
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_SSDN_P1_8_11);
|
||||
tmp &= ~SSDN_P1_8_11_MASK;
|
||||
tmp |= (uint8_t)(SSDN_P1_8_11_MASK & (SSDN_P1 >> 8));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSDN_P1_8_11, tmp);
|
||||
|
||||
//write SSDN parameter P2
|
||||
tmp = (uint8_t) SSDN_P2;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSDN_P2_0_7, tmp);
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_SSDN_P2_8_14);
|
||||
tmp &= ~SSDN_P2_8_14_MASK;
|
||||
tmp |= (uint8_t)(SSDN_P2_8_14_MASK & (SSDN_P2 >> 8));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSDN_P2_8_14, tmp);
|
||||
|
||||
//write SSDN parameter P3
|
||||
tmp = (uint8_t) SSDN_P3;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSDN_P3_0_7, tmp);
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_SSDN_P3_8_14);
|
||||
tmp &= ~SSDN_P3_8_14_MASK;
|
||||
tmp |= (uint8_t)(SSDN_P3_8_14_MASK & (SSDN_P3 >> 8));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSDN_P3_8_14, tmp);
|
||||
|
||||
//turn on SS if it should be enabled
|
||||
if ((Si5351_ConfigStruct->SS.SS_Enable == ON)
|
||||
& (((Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Integer & 0x01) != 0)
|
||||
| (Si5351_ConfigStruct->PLL[0].PLL_Multiplier_Numerator != 0)))
|
||||
{
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_SSC_EN);
|
||||
tmp |= SSC_EN_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_SSC_EN, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
void Si5351_MSConfig(Si5351_ConfigTypeDef *Si5351_ConfigStruct, Si5351_MSChannelTypeDef MS_Channel)
|
||||
{
|
||||
uint8_t tmp;
|
||||
uint32_t MS_P1, MS_P2, MS_P3;
|
||||
|
||||
//configure MultiSynth clock source
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_MS_SRC + MS_Channel);
|
||||
tmp &= ~MS_SRC_MASK;
|
||||
if (Si5351_ConfigStruct->MS[MS_Channel].MS_Clock_Source == MS_Clock_Source_PLLB)
|
||||
{
|
||||
tmp |= MS_SRC_MASK;
|
||||
}
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_SRC + MS_Channel, tmp);
|
||||
|
||||
if (MS_Channel <= MS5) //configuration is simpler for MS6 and 7 since they are integer-only
|
||||
{
|
||||
//if next value not in even integer mode or if divider is not equal to 4, disable DIVBY4
|
||||
if ((Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Integer != 4)|(Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Numerator != 0))
|
||||
{
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_MS_DIVBY4 + 8 * MS_Channel);
|
||||
tmp &= ~MS_DIVBY4_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_DIVBY4 + 8 * MS_Channel, tmp);
|
||||
}
|
||||
|
||||
//if next value not in even integer mode or SS enabled, disable integer mode
|
||||
if ((Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Numerator != 0)|((Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Integer & 0x01) != 0)|(Si5351_ConfigStruct->SS.SS_Enable == ON))
|
||||
{
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_MS_INT + MS_Channel);
|
||||
tmp &= ~MS_INT_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_INT + MS_Channel, tmp);
|
||||
}
|
||||
|
||||
//set new divider value
|
||||
MS_P1 = 128 * Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Integer
|
||||
+ ((128 * Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Numerator) / Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Denominator)
|
||||
- 512;
|
||||
MS_P2 = 128 * Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Numerator
|
||||
- Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Denominator
|
||||
* ((128 * Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Numerator) / Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Denominator);
|
||||
MS_P3 = Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Denominator;
|
||||
|
||||
tmp = (uint8_t) MS_P1;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_P1_0_7 + 8 * MS_Channel, tmp);
|
||||
tmp = (uint8_t) (MS_P1 >> 8);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_P1_8_15 + 8 * MS_Channel, tmp);
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_MS_P1_16_17);
|
||||
tmp &= ~MS_P1_16_17_MASK;
|
||||
tmp |= (uint8_t) (MS_P1_16_17_MASK & (MS_P1 >> 16));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_P1_16_17 + 8 * MS_Channel, tmp);
|
||||
|
||||
tmp = (uint8_t) MS_P2;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_P2_0_7 + 8 * MS_Channel, tmp);
|
||||
tmp = (uint8_t) (MS_P2 >> 8);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_P2_8_15 + 8 * MS_Channel, tmp);
|
||||
Si5351_ReadRegister(Si5351_ConfigStruct, REG_MS_P2_16_19 + 8 * MS_Channel);
|
||||
tmp &= ~MS_P2_16_19_MASK;
|
||||
tmp |= (uint8_t) (MS_P2_16_19_MASK & (MS_P2 >> 16));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_P2_16_19 + 8 * MS_Channel, tmp);
|
||||
|
||||
tmp = (uint8_t) MS_P3;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_P3_0_7 + 8 * MS_Channel, tmp);
|
||||
tmp = (uint8_t) (MS_P3 >> 8);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_P3_8_15 + 8 * MS_Channel, tmp);
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_MS_P3_16_19 + 8 * MS_Channel);
|
||||
tmp &= ~MS_P3_16_19_MASK;
|
||||
tmp |= (uint8_t) (MS_P3_16_19_MASK & ((MS_P3 >> 16) << 4));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_P3_16_19 + 8 * MS_Channel, tmp);
|
||||
|
||||
//if next value is even integer and SS not enabled, enable integer mode
|
||||
if ((Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Numerator == 0) & ((Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Integer & 0x01) == 0) & (Si5351_ConfigStruct->SS.SS_Enable == OFF))
|
||||
{
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_MS_INT + MS_Channel);
|
||||
tmp |= MS_INT_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_INT + MS_Channel, tmp);
|
||||
|
||||
//if next value in integer mode and if divider is equal to 4, enable DIVBY4
|
||||
if (Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Integer == 4)
|
||||
{
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_MS_DIVBY4 + 8 * MS_Channel);
|
||||
tmp |= MS_DIVBY4_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS_DIVBY4 + 8 * MS_Channel, tmp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//configure divider of Multisynth 6 and 7
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_MS67_P1 + (MS_Channel - MS6), (uint8_t)(Si5351_ConfigStruct->MS[MS_Channel].MS_Divider_Integer));
|
||||
//can be only even integers between 6 and 254, inclusive
|
||||
}
|
||||
}
|
||||
|
||||
void Si5351_CLKPowerCmd(Si5351_ConfigTypeDef *Si5351_ConfigStruct, Si5351_CLKChannelTypeDef CLK_Channel)
|
||||
{
|
||||
uint8_t tmp, tmp_mask;
|
||||
|
||||
//set CLK disable state
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLK_DIS_STATE + (CLK_Channel >> 2)); //increment the address by 1 if CLKx>=CLK4
|
||||
tmp_mask = CLK_DIS_STATE_MASK << ((CLK_Channel & 0x03)<<1); //shift the mask according to the selected channel
|
||||
tmp &= ~tmp_mask;
|
||||
tmp |= tmp_mask & ((Si5351_ConfigStruct->CLK[CLK_Channel].CLK_Disable_State) << ((CLK_Channel & 0x03)<<1));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLK_DIS_STATE + (CLK_Channel >> 2), tmp);
|
||||
|
||||
//set OEB pin
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLK_OEB);
|
||||
tmp_mask = 1 << CLK_Channel;
|
||||
tmp &= ~tmp_mask;
|
||||
if (Si5351_ConfigStruct->CLK[CLK_Channel].CLK_Use_OEB_Pin == OFF)
|
||||
{
|
||||
tmp |= tmp_mask;
|
||||
}
|
||||
|
||||
if (Si5351_ConfigStruct->CLK[CLK_Channel].CLK_Enable == OFF) //disable clock
|
||||
{
|
||||
//power down the clock
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLK_EN);
|
||||
tmp |= 1 << CLK_Channel;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLK_EN, tmp);
|
||||
}
|
||||
|
||||
if (Si5351_ConfigStruct->CLK[CLK_Channel].CLK_PowerDown == ON) //power down clock
|
||||
{
|
||||
//power down output driver
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLK_PDN + CLK_Channel);
|
||||
tmp |= CLK_PDN_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLK_PDN + CLK_Channel, tmp);
|
||||
}
|
||||
|
||||
if (Si5351_ConfigStruct->CLK[CLK_Channel].CLK_PowerDown == OFF) //power up clock
|
||||
{
|
||||
//power up output driver
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLK_PDN + CLK_Channel);
|
||||
tmp &= ~CLK_PDN_MASK;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLK_PDN + CLK_Channel, tmp);
|
||||
}
|
||||
|
||||
if (Si5351_ConfigStruct->CLK[CLK_Channel].CLK_Enable == ON) //enable clock
|
||||
{
|
||||
//power up the clock
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLK_EN);
|
||||
tmp &= ~(1 << CLK_Channel);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLK_EN, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
void Si5351_CLKConfig(Si5351_ConfigTypeDef *Si5351_ConfigStruct, Si5351_CLKChannelTypeDef CLK_Channel)
|
||||
{
|
||||
uint8_t tmp, tmp_mask;
|
||||
|
||||
//set CLK source clock
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLK_SRC + CLK_Channel);
|
||||
tmp &= ~CLK_SRC_MASK;
|
||||
tmp |= CLK_SRC_MASK & Si5351_ConfigStruct->CLK[CLK_Channel].CLK_Clock_Source;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLK_SRC + CLK_Channel, tmp);
|
||||
|
||||
//set CLK inversion
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLK_INV + CLK_Channel);
|
||||
tmp &= ~CLK_INV_MASK;
|
||||
if (Si5351_ConfigStruct->CLK[CLK_Channel].CLK_Invert == ON)
|
||||
{
|
||||
tmp |= CLK_INV_MASK;
|
||||
}
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLK_INV + CLK_Channel, tmp);
|
||||
|
||||
//set CLK current drive
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLK_IDRV + CLK_Channel);
|
||||
tmp &= ~CLK_IDRV_MASK;
|
||||
tmp |= CLK_IDRV_MASK & Si5351_ConfigStruct->CLK[CLK_Channel].CLK_I_Drv;
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLK_IDRV + CLK_Channel, tmp);
|
||||
|
||||
if (CLK_Channel <= CLK5) //CLK6 and 7 are integer only, which causes several limitations
|
||||
{
|
||||
//set CLK phase offset
|
||||
tmp = CLK_PHOFF_MASK & (Si5351_ConfigStruct->CLK[CLK_Channel].CLK_QuarterPeriod_Offset);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLK_PHOFF + CLK_Channel, tmp);
|
||||
//set Rx divider
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLK_R_DIV + CLK_Channel * CLK_R_DIV_STEP);
|
||||
tmp &= ~CLK_R_DIV_MASK;
|
||||
tmp |= CLK_R_DIV_MASK & (Si5351_ConfigStruct->CLK[CLK_Channel].CLK_R_Div);
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLK_R_DIV + CLK_Channel * CLK_R_DIV_STEP, tmp);
|
||||
} else {
|
||||
//CLK6 and CLK7 have no fractional mode, so they lack the phase offset function
|
||||
|
||||
//set Rx divider
|
||||
tmp_mask = CLK_R67_DIV_MASK << ((CLK_Channel-CLK6) << 2); //shift mask left by 4 if CLK7
|
||||
tmp = Si5351_ReadRegister(Si5351_ConfigStruct, REG_CLK_R67_DIV);
|
||||
tmp &= ~tmp_mask;
|
||||
tmp |= tmp_mask & ((Si5351_ConfigStruct->CLK[CLK_Channel].CLK_R_Div >> 4) << ((CLK_Channel-CLK6) << 2));
|
||||
Si5351_WriteRegister(Si5351_ConfigStruct, REG_CLK_R67_DIV, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
int Si5351_Init(Si5351_ConfigTypeDef *Si5351_ConfigStruct)
|
||||
{
|
||||
uint32_t timeout = SI5351_TIMEOUT;
|
||||
uint8_t i;
|
||||
|
||||
//wait for the 5351 to initialize
|
||||
while (Si5351_CheckStatusBit(Si5351_ConfigStruct, StatusBit_SysInit))
|
||||
{
|
||||
timeout--;
|
||||
if (timeout==0) return 1; //return 1 if initialization timed out
|
||||
}
|
||||
|
||||
//configure oscillator, fanout, interrupts, VCXO
|
||||
Si5351_OSCConfig(Si5351_ConfigStruct);
|
||||
Si5351_InterruptConfig(Si5351_ConfigStruct);
|
||||
|
||||
//configure PLLs
|
||||
for (i=PLL_A; i<=PLL_B; i++)
|
||||
{
|
||||
Si5351_PLLConfig(Si5351_ConfigStruct, i);
|
||||
Si5351_PLLReset(Si5351_ConfigStruct, i);
|
||||
}
|
||||
|
||||
//configure Spread Spectrum
|
||||
Si5351_SSConfig(Si5351_ConfigStruct);
|
||||
|
||||
//Configure Multisynths
|
||||
for (i=MS0; i<=MS7; i++)
|
||||
{
|
||||
Si5351_MSConfig(Si5351_ConfigStruct, i);
|
||||
}
|
||||
|
||||
//configure outputs
|
||||
for (i=CLK0; i<=CLK7; i++)
|
||||
{
|
||||
Si5351_CLKConfig(Si5351_ConfigStruct, i);
|
||||
}
|
||||
|
||||
//wait for PLLs to lock
|
||||
while (Si5351_CheckStatusBit(Si5351_ConfigStruct, StatusBit_SysInit | StatusBit_PLLA | StatusBit_PLLB))
|
||||
{
|
||||
timeout--;
|
||||
if (timeout==0) return 1; //return 1 if problem with any PLL
|
||||
}
|
||||
|
||||
//clear sticky bits
|
||||
Si5351_ClearStickyBit(Si5351_ConfigStruct, StatusBit_SysInit | StatusBit_PLLA | StatusBit_PLLB);
|
||||
|
||||
if (Si5351_ConfigStruct->f_CLKIN != 0) //if CLKIN used, check it as well
|
||||
{
|
||||
while (Si5351_CheckStatusBit(Si5351_ConfigStruct, StatusBit_CLKIN))
|
||||
{
|
||||
timeout--;
|
||||
if (timeout==0) return 1; //return 1 if initialization timed out
|
||||
}
|
||||
//clear CLKIN sticky bit
|
||||
Si5351_ClearStickyBit(Si5351_ConfigStruct, StatusBit_CLKIN);
|
||||
}
|
||||
|
||||
if (Si5351_ConfigStruct->f_XTAL != 0) //if XTAL used, check it as well
|
||||
{
|
||||
while (Si5351_CheckStatusBit(Si5351_ConfigStruct, StatusBit_XTAL))
|
||||
{
|
||||
timeout--;
|
||||
if (timeout==0) return 1; //return 1 if initialization timed out
|
||||
}
|
||||
//clear XTAL sticky bit
|
||||
Si5351_ClearStickyBit(Si5351_ConfigStruct, StatusBit_XTAL);
|
||||
}
|
||||
|
||||
//power on or off the outputs
|
||||
for (i=CLK0; i<=CLK7; i++)
|
||||
{
|
||||
Si5351_CLKPowerCmd(Si5351_ConfigStruct, i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
1025
Core/Src/stm32_si5351.c
Normal file
1025
Core/Src/stm32_si5351.c
Normal file
File diff suppressed because it is too large
Load Diff
359
Core/Src/stm32l4xx_hal_msp.c
Normal file
359
Core/Src/stm32l4xx_hal_msp.c
Normal file
@ -0,0 +1,359 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l4xx_hal_msp.c
|
||||
* @brief This file provides code for the MSP Initialization
|
||||
* and de-Initialization codes.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN TD */
|
||||
|
||||
/* USER CODE END TD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Define */
|
||||
|
||||
/* USER CODE END Define */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Macro */
|
||||
|
||||
/* USER CODE END Macro */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* External functions --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ExternalFunctions */
|
||||
|
||||
/* USER CODE END ExternalFunctions */
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
/**
|
||||
* Initializes the Global MSP.
|
||||
*/
|
||||
void HAL_MspInit(void)
|
||||
{
|
||||
/* USER CODE BEGIN MspInit 0 */
|
||||
|
||||
/* USER CODE END MspInit 0 */
|
||||
|
||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
|
||||
/* System interrupt init*/
|
||||
/* PendSV_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0);
|
||||
|
||||
/* USER CODE BEGIN MspInit 1 */
|
||||
|
||||
/* USER CODE END MspInit 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hi2c: I2C handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
||||
if(hi2c->Instance==I2C1)
|
||||
{
|
||||
/* USER CODE BEGIN I2C1_MspInit 0 */
|
||||
|
||||
/* USER CODE END I2C1_MspInit 0 */
|
||||
|
||||
/** Initializes the peripherals clock
|
||||
*/
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_I2C1;
|
||||
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**I2C1 GPIO Configuration
|
||||
PB8 ------> I2C1_SCL
|
||||
PB9 ------> I2C1_SDA
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_I2C1_CLK_ENABLE();
|
||||
/* USER CODE BEGIN I2C1_MspInit 1 */
|
||||
|
||||
/* USER CODE END I2C1_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hi2c: I2C handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
|
||||
{
|
||||
if(hi2c->Instance==I2C1)
|
||||
{
|
||||
/* USER CODE BEGIN I2C1_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END I2C1_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_I2C1_CLK_DISABLE();
|
||||
|
||||
/**I2C1 GPIO Configuration
|
||||
PB8 ------> I2C1_SCL
|
||||
PB9 ------> I2C1_SDA
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_9);
|
||||
|
||||
/* USER CODE BEGIN I2C1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END I2C1_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UART MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param huart: UART handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
||||
if(huart->Instance==LPUART1)
|
||||
{
|
||||
/* USER CODE BEGIN LPUART1_MspInit 0 */
|
||||
|
||||
/* USER CODE END LPUART1_MspInit 0 */
|
||||
|
||||
/** Initializes the peripherals clock
|
||||
*/
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
|
||||
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_LPUART1_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOG_CLK_ENABLE();
|
||||
HAL_PWREx_EnableVddIO2();
|
||||
/**LPUART1 GPIO Configuration
|
||||
PG7 ------> LPUART1_TX
|
||||
PG8 ------> LPUART1_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = STLK_RX_Pin|STLK_TX_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
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 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UART MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param huart: UART handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
||||
{
|
||||
if(huart->Instance==LPUART1)
|
||||
{
|
||||
/* USER CODE BEGIN LPUART1_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END LPUART1_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_LPUART1_CLK_DISABLE();
|
||||
|
||||
/**LPUART1 GPIO Configuration
|
||||
PG7 ------> LPUART1_TX
|
||||
PG8 ------> LPUART1_RX
|
||||
*/
|
||||
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 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PCD MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hpcd: PCD handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
||||
if(hpcd->Instance==USB_OTG_FS)
|
||||
{
|
||||
/* USER CODE BEGIN USB_OTG_FS_MspInit 0 */
|
||||
|
||||
/* USER CODE END USB_OTG_FS_MspInit 0 */
|
||||
|
||||
/** Initializes the peripherals clock
|
||||
*/
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
|
||||
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1M = 1;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1N = 24;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV2;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2;
|
||||
PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**USB_OTG_FS GPIO Configuration
|
||||
PA8 ------> USB_OTG_FS_SOF
|
||||
PA9 ------> USB_OTG_FS_VBUS
|
||||
PA10 ------> USB_OTG_FS_ID
|
||||
PA11 ------> USB_OTG_FS_DM
|
||||
PA12 ------> USB_OTG_FS_DP
|
||||
*/
|
||||
GPIO_InitStruct.Pin = USB_SOF_Pin|USB_ID_Pin|USB_DM_Pin|USB_DP_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = USB_VBUS_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(USB_VBUS_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
|
||||
|
||||
/* Enable VDDUSB */
|
||||
if(__HAL_RCC_PWR_IS_CLK_DISABLED())
|
||||
{
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
HAL_PWREx_EnableVddUSB();
|
||||
__HAL_RCC_PWR_CLK_DISABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_PWREx_EnableVddUSB();
|
||||
}
|
||||
/* USER CODE BEGIN USB_OTG_FS_MspInit 1 */
|
||||
|
||||
/* USER CODE END USB_OTG_FS_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PCD MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hpcd: PCD handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
|
||||
{
|
||||
if(hpcd->Instance==USB_OTG_FS)
|
||||
{
|
||||
/* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END USB_OTG_FS_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_USB_OTG_FS_CLK_DISABLE();
|
||||
|
||||
/**USB_OTG_FS GPIO Configuration
|
||||
PA8 ------> USB_OTG_FS_SOF
|
||||
PA9 ------> USB_OTG_FS_VBUS
|
||||
PA10 ------> USB_OTG_FS_ID
|
||||
PA11 ------> USB_OTG_FS_DM
|
||||
PA12 ------> USB_OTG_FS_DP
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, USB_SOF_Pin|USB_VBUS_Pin|USB_ID_Pin|USB_DM_Pin
|
||||
|USB_DP_Pin);
|
||||
|
||||
/* Disable VDDUSB */
|
||||
if(__HAL_RCC_PWR_IS_CLK_DISABLED())
|
||||
{
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
HAL_PWREx_DisableVddUSB();
|
||||
__HAL_RCC_PWR_CLK_DISABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_PWREx_DisableVddUSB();
|
||||
}
|
||||
/* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END USB_OTG_FS_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
111
Core/Src/stm32l4xx_hal_timebase_tim.c
Normal file
111
Core/Src/stm32l4xx_hal_timebase_tim.c
Normal file
@ -0,0 +1,111 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l4xx_hal_timebase_TIM.c
|
||||
* @brief HAL time base based on the hardware TIM.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l4xx_hal.h"
|
||||
#include "stm32l4xx_hal_tim.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
TIM_HandleTypeDef htim16;
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief This function configures the TIM16 as a time base source.
|
||||
* The time source is configured to have 1ms time base with a dedicated
|
||||
* Tick interrupt priority.
|
||||
* @note This function is called automatically at the beginning of program after
|
||||
* reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig().
|
||||
* @param TickPriority: Tick interrupt priority.
|
||||
* @retval HAL status
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
|
||||
{
|
||||
RCC_ClkInitTypeDef clkconfig;
|
||||
uint32_t uwTimclock = 0;
|
||||
uint32_t uwPrescalerValue = 0;
|
||||
uint32_t pFLatency;
|
||||
/*Configure the TIM16 IRQ priority */
|
||||
HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, TickPriority ,0);
|
||||
|
||||
/* Enable the TIM16 global Interrupt */
|
||||
HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn);
|
||||
|
||||
/* Enable TIM16 clock */
|
||||
__HAL_RCC_TIM16_CLK_ENABLE();
|
||||
|
||||
/* Get clock configuration */
|
||||
HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
|
||||
|
||||
/* Compute TIM16 clock */
|
||||
uwTimclock = HAL_RCC_GetPCLK2Freq();
|
||||
/* Compute the prescaler value to have TIM16 counter clock equal to 1MHz */
|
||||
uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U);
|
||||
|
||||
/* Initialize TIM16 */
|
||||
htim16.Instance = TIM16;
|
||||
|
||||
/* Initialize TIMx peripheral as follow:
|
||||
+ Period = [(TIM16CLK/1000) - 1]. to have a (1/1000) s time base.
|
||||
+ Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
|
||||
+ ClockDivision = 0
|
||||
+ Counter direction = Up
|
||||
*/
|
||||
htim16.Init.Period = (1000000U / 1000U) - 1U;
|
||||
htim16.Init.Prescaler = uwPrescalerValue;
|
||||
htim16.Init.ClockDivision = 0;
|
||||
htim16.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
|
||||
if(HAL_TIM_Base_Init(&htim16) == HAL_OK)
|
||||
{
|
||||
/* Start the TIM time Base generation in interrupt mode */
|
||||
return HAL_TIM_Base_Start_IT(&htim16);
|
||||
}
|
||||
|
||||
/* Return function status */
|
||||
return HAL_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Suspend Tick increment.
|
||||
* @note Disable the tick increment by disabling TIM16 update interrupt.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SuspendTick(void)
|
||||
{
|
||||
/* Disable TIM16 update Interrupt */
|
||||
__HAL_TIM_DISABLE_IT(&htim16, TIM_IT_UPDATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Resume Tick increment.
|
||||
* @note Enable the tick increment by Enabling TIM16 update interrupt.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_ResumeTick(void)
|
||||
{
|
||||
/* Enable TIM16 Update interrupt */
|
||||
__HAL_TIM_ENABLE_IT(&htim16, TIM_IT_UPDATE);
|
||||
}
|
||||
|
193
Core/Src/stm32l4xx_it.c
Normal file
193
Core/Src/stm32l4xx_it.c
Normal file
@ -0,0 +1,193 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l4xx_it.c
|
||||
* @brief Interrupt Service Routines.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "stm32l4xx_it.h"
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN TD */
|
||||
|
||||
/* USER CODE END TD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern UART_HandleTypeDef hlpuart1;
|
||||
extern TIM_HandleTypeDef htim16;
|
||||
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @brief This function handles Non maskable interrupt.
|
||||
*/
|
||||
void NMI_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
||||
|
||||
/* USER CODE END NonMaskableInt_IRQn 0 */
|
||||
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
/* USER CODE END NonMaskableInt_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Hard fault interrupt.
|
||||
*/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN HardFault_IRQn 0 */
|
||||
|
||||
/* USER CODE END HardFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
|
||||
/* USER CODE END W1_HardFault_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Memory management fault.
|
||||
*/
|
||||
void MemManage_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
||||
|
||||
/* USER CODE END MemoryManagement_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
|
||||
/* USER CODE END W1_MemoryManagement_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Prefetch fault, memory access fault.
|
||||
*/
|
||||
void BusFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN BusFault_IRQn 0 */
|
||||
|
||||
/* USER CODE END BusFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
|
||||
/* USER CODE END W1_BusFault_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Undefined instruction or illegal state.
|
||||
*/
|
||||
void UsageFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
||||
|
||||
/* USER CODE END UsageFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
|
||||
/* USER CODE END W1_UsageFault_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Debug monitor.
|
||||
*/
|
||||
void DebugMon_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
||||
|
||||
/* USER CODE END DebugMonitor_IRQn 0 */
|
||||
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
|
||||
|
||||
/* USER CODE END DebugMonitor_IRQn 1 */
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* STM32L4xx Peripheral Interrupt Handlers */
|
||||
/* Add here the Interrupt Handlers for the used peripherals. */
|
||||
/* For the available peripheral interrupt handler names, */
|
||||
/* please refer to the startup file (startup_stm32l4xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles TIM1 update interrupt and TIM16 global interrupt.
|
||||
*/
|
||||
void TIM1_UP_TIM16_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIM1_UP_TIM16_IRQn 0 */
|
||||
|
||||
/* USER CODE END TIM1_UP_TIM16_IRQn 0 */
|
||||
HAL_TIM_IRQHandler(&htim16);
|
||||
/* USER CODE BEGIN TIM1_UP_TIM16_IRQn 1 */
|
||||
|
||||
/* USER CODE END TIM1_UP_TIM16_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 */
|
155
Core/Src/syscalls.c
Normal file
155
Core/Src/syscalls.c
Normal file
@ -0,0 +1,155 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file syscalls.c
|
||||
* @author Auto-generated by STM32CubeIDE
|
||||
* @brief STM32CubeIDE Minimal System calls file
|
||||
*
|
||||
* For more information about which c-functions
|
||||
* need which of these lowlevel functions
|
||||
* please consult the Newlib libc-manual
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes */
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/times.h>
|
||||
|
||||
|
||||
/* Variables */
|
||||
extern int __io_putchar(int ch) __attribute__((weak));
|
||||
extern int __io_getchar(void) __attribute__((weak));
|
||||
|
||||
|
||||
char *__env[1] = { 0 };
|
||||
char **environ = __env;
|
||||
|
||||
|
||||
/* Functions */
|
||||
void initialise_monitor_handles()
|
||||
{
|
||||
}
|
||||
|
||||
int _getpid(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _kill(int pid, int sig)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void _exit (int status)
|
||||
{
|
||||
_kill(status, -1);
|
||||
while (1) {} /* Make sure we hang here */
|
||||
}
|
||||
|
||||
__attribute__((weak)) int _read(int file, char *ptr, int len)
|
||||
{
|
||||
int DataIdx;
|
||||
|
||||
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||
{
|
||||
*ptr++ = __io_getchar();
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
__attribute__((weak)) int _write(int file, char *ptr, int len)
|
||||
{
|
||||
int DataIdx;
|
||||
|
||||
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||
{
|
||||
__io_putchar(*ptr++);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
int _close(int file)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int _fstat(int file, struct stat *st)
|
||||
{
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isatty(int file)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _lseek(int file, int ptr, int dir)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _open(char *path, int flags, ...)
|
||||
{
|
||||
/* Pretend like we always fail */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _wait(int *status)
|
||||
{
|
||||
errno = ECHILD;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _unlink(char *name)
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _times(struct tms *buf)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _stat(char *file, struct stat *st)
|
||||
{
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _link(char *old, char *new)
|
||||
{
|
||||
errno = EMLINK;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _fork(void)
|
||||
{
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _execve(char *name, char **argv, char **env)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
79
Core/Src/sysmem.c
Normal file
79
Core/Src/sysmem.c
Normal file
@ -0,0 +1,79 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file sysmem.c
|
||||
* @author Generated by STM32CubeIDE
|
||||
* @brief STM32CubeIDE System Memory calls file
|
||||
*
|
||||
* For more information about which C functions
|
||||
* need which of these lowlevel functions
|
||||
* please consult the newlib libc manual
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes */
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Pointer to the current high watermark of the heap usage
|
||||
*/
|
||||
static uint8_t *__sbrk_heap_end = NULL;
|
||||
|
||||
/**
|
||||
* @brief _sbrk() allocates memory to the newlib heap and is used by malloc
|
||||
* and others from the C library
|
||||
*
|
||||
* @verbatim
|
||||
* ############################################################################
|
||||
* # .data # .bss # newlib heap # MSP stack #
|
||||
* # # # # Reserved by _Min_Stack_Size #
|
||||
* ############################################################################
|
||||
* ^-- RAM start ^-- _end _estack, RAM end --^
|
||||
* @endverbatim
|
||||
*
|
||||
* This implementation starts allocating at the '_end' linker symbol
|
||||
* The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack
|
||||
* The implementation considers '_estack' linker symbol to be RAM end
|
||||
* NOTE: If the MSP stack, at any point during execution, grows larger than the
|
||||
* reserved size, please increase the '_Min_Stack_Size'.
|
||||
*
|
||||
* @param incr Memory size
|
||||
* @return Pointer to allocated memory
|
||||
*/
|
||||
void *_sbrk(ptrdiff_t incr)
|
||||
{
|
||||
extern uint8_t _end; /* Symbol defined in the linker script */
|
||||
extern uint8_t _estack; /* Symbol defined in the linker script */
|
||||
extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */
|
||||
const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size;
|
||||
const uint8_t *max_heap = (uint8_t *)stack_limit;
|
||||
uint8_t *prev_heap_end;
|
||||
|
||||
/* Initialize heap end at first call */
|
||||
if (NULL == __sbrk_heap_end)
|
||||
{
|
||||
__sbrk_heap_end = &_end;
|
||||
}
|
||||
|
||||
/* Protect heap from growing into the reserved MSP stack */
|
||||
if (__sbrk_heap_end + incr > max_heap)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return (void *)-1;
|
||||
}
|
||||
|
||||
prev_heap_end = __sbrk_heap_end;
|
||||
__sbrk_heap_end += incr;
|
||||
|
||||
return (void *)prev_heap_end;
|
||||
}
|
332
Core/Src/system_stm32l4xx.c
Normal file
332
Core/Src/system_stm32l4xx.c
Normal file
@ -0,0 +1,332 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file system_stm32l4xx.c
|
||||
* @author MCD Application Team
|
||||
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File
|
||||
*
|
||||
* This file provides two functions and one global variable to be called from
|
||||
* user application:
|
||||
* - SystemInit(): This function is called at startup just after reset and
|
||||
* before branch to main program. This call is made inside
|
||||
* the "startup_stm32l4xx.s" file.
|
||||
*
|
||||
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
|
||||
* by the user application to setup the SysTick
|
||||
* timer or configure other parameters.
|
||||
*
|
||||
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
|
||||
* be called whenever the core clock is changed
|
||||
* during program execution.
|
||||
*
|
||||
* After each device reset the MSI (4 MHz) is used as system clock source.
|
||||
* Then SystemInit() function is called, in "startup_stm32l4xx.s" file, to
|
||||
* configure the system clock before to branch to main program.
|
||||
*
|
||||
* This file configures the system clock as follows:
|
||||
*=============================================================================
|
||||
*-----------------------------------------------------------------------------
|
||||
* System Clock source | MSI
|
||||
*-----------------------------------------------------------------------------
|
||||
* SYSCLK(Hz) | 4000000
|
||||
*-----------------------------------------------------------------------------
|
||||
* HCLK(Hz) | 4000000
|
||||
*-----------------------------------------------------------------------------
|
||||
* AHB Prescaler | 1
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB1 Prescaler | 1
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB2 Prescaler | 1
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_M | 1
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_N | 8
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_P | 7
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_Q | 2
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_R | 2
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLLSAI1_P | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLLSAI1_Q | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLLSAI1_R | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLLSAI2_P | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLLSAI2_Q | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLLSAI2_R | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* Require 48MHz for USB OTG FS, | Disabled
|
||||
* SDIO and RNG clock |
|
||||
*-----------------------------------------------------------------------------
|
||||
*=============================================================================
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup CMSIS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup stm32l4xx_system
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L4xx_System_Private_Includes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "stm32l4xx.h"
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L4xx_System_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L4xx_System_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
#if !defined (MSI_VALUE)
|
||||
#define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/
|
||||
#endif /* MSI_VALUE */
|
||||
|
||||
#if !defined (HSI_VALUE)
|
||||
#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/
|
||||
#endif /* HSI_VALUE */
|
||||
|
||||
/* Note: Following vector table addresses must be defined in line with linker
|
||||
configuration. */
|
||||
/*!< Uncomment the following line if you need to relocate the vector table
|
||||
anywhere in Flash or Sram, else the vector table is kept at the automatic
|
||||
remap of boot address selected */
|
||||
/* #define USER_VECT_TAB_ADDRESS */
|
||||
|
||||
#if defined(USER_VECT_TAB_ADDRESS)
|
||||
/*!< Uncomment the following line if you need to relocate your vector Table
|
||||
in Sram else user remap will be done in Flash. */
|
||||
/* #define VECT_TAB_SRAM */
|
||||
|
||||
#if defined(VECT_TAB_SRAM)
|
||||
#define VECT_TAB_BASE_ADDRESS SRAM1_BASE /*!< Vector Table base address field.
|
||||
This value must be a multiple of 0x200. */
|
||||
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||
This value must be a multiple of 0x200. */
|
||||
#else
|
||||
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
|
||||
This value must be a multiple of 0x200. */
|
||||
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||
This value must be a multiple of 0x200. */
|
||||
#endif /* VECT_TAB_SRAM */
|
||||
#endif /* USER_VECT_TAB_ADDRESS */
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L4xx_System_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L4xx_System_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
/* The SystemCoreClock variable is updated in three ways:
|
||||
1) by calling CMSIS function SystemCoreClockUpdate()
|
||||
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
|
||||
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
|
||||
Note: If you use this function to configure the system clock; then there
|
||||
is no need to call the 2 first functions listed above, since SystemCoreClock
|
||||
variable is updated automatically.
|
||||
*/
|
||||
uint32_t SystemCoreClock = 4000000U;
|
||||
|
||||
const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U};
|
||||
const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U};
|
||||
const uint32_t MSIRangeTable[12] = {100000U, 200000U, 400000U, 800000U, 1000000U, 2000000U, \
|
||||
4000000U, 8000000U, 16000000U, 24000000U, 32000000U, 48000000U};
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L4xx_System_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L4xx_System_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Setup the microcontroller system.
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
#if defined(USER_VECT_TAB_ADDRESS)
|
||||
/* Configure the Vector Table location -------------------------------------*/
|
||||
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
|
||||
#endif
|
||||
|
||||
/* FPU settings ------------------------------------------------------------*/
|
||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||
SCB->CPACR |= ((3UL << 20U)|(3UL << 22U)); /* set CP10 and CP11 Full Access */
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update SystemCoreClock variable according to Clock Register Values.
|
||||
* The SystemCoreClock variable contains the core clock (HCLK), it can
|
||||
* be used by the user application to setup the SysTick timer or configure
|
||||
* other parameters.
|
||||
*
|
||||
* @note Each time the core clock (HCLK) changes, this function must be called
|
||||
* to update SystemCoreClock variable value. Otherwise, any configuration
|
||||
* based on this variable will be incorrect.
|
||||
*
|
||||
* @note - The system frequency computed by this function is not the real
|
||||
* frequency in the chip. It is calculated based on the predefined
|
||||
* constant and the selected clock source:
|
||||
*
|
||||
* - If SYSCLK source is MSI, SystemCoreClock will contain the MSI_VALUE(*)
|
||||
*
|
||||
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**)
|
||||
*
|
||||
* - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***)
|
||||
*
|
||||
* - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***)
|
||||
* or HSI_VALUE(*) or MSI_VALUE(*) multiplied/divided by the PLL factors.
|
||||
*
|
||||
* (*) MSI_VALUE is a constant defined in stm32l4xx_hal.h file (default value
|
||||
* 4 MHz) but the real value may vary depending on the variations
|
||||
* in voltage and temperature.
|
||||
*
|
||||
* (**) HSI_VALUE is a constant defined in stm32l4xx_hal.h file (default value
|
||||
* 16 MHz) but the real value may vary depending on the variations
|
||||
* in voltage and temperature.
|
||||
*
|
||||
* (***) HSE_VALUE is a constant defined in stm32l4xx_hal.h file (default value
|
||||
* 8 MHz), user has to ensure that HSE_VALUE is same as the real
|
||||
* frequency of the crystal used. Otherwise, this function may
|
||||
* have wrong result.
|
||||
*
|
||||
* - The result of this function could be not correct when using fractional
|
||||
* value for HSE crystal.
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void SystemCoreClockUpdate(void)
|
||||
{
|
||||
uint32_t tmp, msirange, pllvco, pllsource, pllm, pllr;
|
||||
|
||||
/* Get MSI Range frequency--------------------------------------------------*/
|
||||
if ((RCC->CR & RCC_CR_MSIRGSEL) == 0U)
|
||||
{ /* MSISRANGE from RCC_CSR applies */
|
||||
msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U;
|
||||
}
|
||||
else
|
||||
{ /* MSIRANGE from RCC_CR applies */
|
||||
msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U;
|
||||
}
|
||||
/*MSI frequency range in HZ*/
|
||||
msirange = MSIRangeTable[msirange];
|
||||
|
||||
/* Get SYSCLK source -------------------------------------------------------*/
|
||||
switch (RCC->CFGR & RCC_CFGR_SWS)
|
||||
{
|
||||
case 0x00: /* MSI used as system clock source */
|
||||
SystemCoreClock = msirange;
|
||||
break;
|
||||
|
||||
case 0x04: /* HSI used as system clock source */
|
||||
SystemCoreClock = HSI_VALUE;
|
||||
break;
|
||||
|
||||
case 0x08: /* HSE used as system clock source */
|
||||
SystemCoreClock = HSE_VALUE;
|
||||
break;
|
||||
|
||||
case 0x0C: /* PLL used as system clock source */
|
||||
/* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
|
||||
SYSCLK = PLL_VCO / PLLR
|
||||
*/
|
||||
pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC);
|
||||
pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U ;
|
||||
|
||||
switch (pllsource)
|
||||
{
|
||||
case 0x02: /* HSI used as PLL clock source */
|
||||
pllvco = (HSI_VALUE / pllm);
|
||||
break;
|
||||
|
||||
case 0x03: /* HSE used as PLL clock source */
|
||||
pllvco = (HSE_VALUE / pllm);
|
||||
break;
|
||||
|
||||
default: /* MSI used as PLL clock source */
|
||||
pllvco = (msirange / pllm);
|
||||
break;
|
||||
}
|
||||
pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U);
|
||||
pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U;
|
||||
SystemCoreClock = pllvco/pllr;
|
||||
break;
|
||||
|
||||
default:
|
||||
SystemCoreClock = msirange;
|
||||
break;
|
||||
}
|
||||
/* Compute HCLK clock frequency --------------------------------------------*/
|
||||
/* Get HCLK prescaler */
|
||||
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)];
|
||||
/* HCLK clock frequency */
|
||||
SystemCoreClock >>= tmp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
Reference in New Issue
Block a user