Adding I2C interrupt
This commit is contained in:
parent
ee42fc0bbc
commit
40edb62e44
7 changed files with 49 additions and 12 deletions
12
.mxproject
12
.mxproject
File diff suppressed because one or more lines are too long
|
@ -17,7 +17,6 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
|||
project(stm32_thermal_cam C CXX ASM)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(PROJECT_NAME stm32_thermal_cam)
|
||||
|
||||
#Uncomment for hardware floating point
|
||||
#add_compile_definitions(ARM_MATH_CM4;ARM_MATH_MATRIX_CHECK;ARM_MATH_ROUNDING)
|
||||
|
|
|
@ -55,6 +55,7 @@ void SVC_Handler(void);
|
|||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
void I2C1_EV_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
|
13
Src/main.c
13
Src/main.c
|
@ -54,6 +54,8 @@ static void MX_GPIO_Init(void);
|
|||
|
||||
static void MX_I2C1_Init(void);
|
||||
|
||||
static void MX_NVIC_Init(void);
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
@ -134,6 +136,7 @@ int main(void) {
|
|||
/* Initialize all configured peripherals */
|
||||
MX_GPIO_Init();
|
||||
MX_I2C1_Init();
|
||||
MX_NVIC_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
// TODO: configs
|
||||
configure_sensor(); {
|
||||
|
@ -158,6 +161,7 @@ int main(void) {
|
|||
|
||||
/**
|
||||
* @brief System Clock Configuration
|
||||
* @retval None
|
||||
*/
|
||||
void SystemClock_Config(void) {
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
|
||||
|
@ -195,6 +199,15 @@ void SystemClock_Config(void) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief NVIC Configuration.
|
||||
*/
|
||||
static void MX_NVIC_Init(void) {
|
||||
/* I2C1_EV_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(I2C1_EV_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C1 Initialization Function
|
||||
*/
|
||||
|
|
|
@ -109,7 +109,7 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
|
|||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
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);
|
||||
|
@ -148,6 +148,8 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
|
|||
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_9);
|
||||
|
||||
/* I2C1 interrupt DeInit */
|
||||
HAL_NVIC_DisableIRQ(I2C1_EV_IRQn);
|
||||
/* USER CODE BEGIN I2C1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END I2C1_MspDeInit 1 */
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
/* USER CODE END 0 */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
|
||||
extern I2C_HandleTypeDef hi2c1;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
@ -198,6 +198,20 @@ void SysTick_Handler(void)
|
|||
/* please refer to the startup file (startup_stm32l4xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles I2C1 event interrupt.
|
||||
*/
|
||||
void I2C1_EV_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN I2C1_EV_IRQn 0 */
|
||||
|
||||
/* USER CODE END I2C1_EV_IRQn 0 */
|
||||
HAL_I2C_EV_IRQHandler(&hi2c1);
|
||||
/* USER CODE BEGIN I2C1_EV_IRQn 1 */
|
||||
|
||||
/* USER CODE END I2C1_EV_IRQn 1 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
|
|
@ -3,9 +3,12 @@ CAD.formats=[]
|
|||
CAD.pinconfig=Dual
|
||||
CAD.provider=
|
||||
File.Version=6
|
||||
GPIO.groupedBy=
|
||||
GPIO.groupedBy=Group By Peripherals
|
||||
I2C1.CustomTiming=Disabled
|
||||
I2C1.I2C_Fall_Time=100
|
||||
I2C1.I2C_Rise_Time=100
|
||||
I2C1.I2C_Speed_Mode=I2C_Fast
|
||||
I2C1.IPParameters=Timing,I2C_Speed_Mode
|
||||
I2C1.IPParameters=Timing,I2C_Speed_Mode,I2C_Rise_Time,I2C_Fall_Time,CustomTiming
|
||||
I2C1.Timing=0x00000003
|
||||
KeepUserPlacement=false
|
||||
Mcu.CPN=STM32L476RGT3
|
||||
|
@ -30,6 +33,7 @@ NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
|||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.ForceEnableDMAVector=true
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.I2C1_EV_IRQn=true\:0\:0\:false\:true\:true\:1\:true\:true\:true
|
||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
|
@ -37,9 +41,13 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
|||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
PB8.GPIOParameters=GPIO_Pu
|
||||
PB8.GPIO_Pu=GPIO_PULLUP
|
||||
PB8.Locked=true
|
||||
PB8.Mode=I2C
|
||||
PB8.Signal=I2C1_SCL
|
||||
PB9.GPIOParameters=GPIO_Pu
|
||||
PB9.GPIO_Pu=GPIO_PULLUP
|
||||
PB9.Locked=true
|
||||
PB9.Mode=I2C
|
||||
PB9.Signal=I2C1_SDA
|
||||
|
@ -61,7 +69,7 @@ ProjectManager.KeepUserCode=true
|
|||
ProjectManager.LastFirmware=true
|
||||
ProjectManager.LibraryCopy=1
|
||||
ProjectManager.MainLocation=Src
|
||||
ProjectManager.NoMain=false
|
||||
ProjectManager.NoMain=true
|
||||
ProjectManager.PreviousToolchain=STM32CubeIDE
|
||||
ProjectManager.ProjectBuild=false
|
||||
ProjectManager.ProjectFileName=stm32_thermal_cam.ioc
|
||||
|
|
Loading…
Add table
Reference in a new issue