Question: Hello I have this code from a stm 3 2 controller in c code, that Im trying to change the button inputs, now into interupts
Hello I have this code from a stm controller in c code, that Im trying to change the button inputs, now into interupts for my code. I'll paste my code below The LED pins stay the same
#include "main.h
#include
UARTHandleTypeDef huart;
void SystemClockConfigvoid;
static void MXGPIOInitvoid;
static void MXUSARTUARTInitvoid;
int mainvoid
int count ;
HALInit;
SystemClockConfig;
MXGPIOInit;
MXUSARTUARTInit;
while
Button
ifHALGPIOReadPinGPIOC GPIOPIN
HALGPIOWritePinGPIOA GPIOPIN;
else
HALGPIOWritePinGPIOA GPIOPIN;
Button Falling Edge Toggling Cycle
ifHALGPIOReadPinGPIOC GPIOPIN
ifHALGPIOReadPinGPIOA GPIOPIN
HALGPIOWritePinGPIOA GPIOPIN;
else
HALGPIOWritePinGPIOA GPIOPIN;
whileHALGPIOReadPinGPIOC GPIOPIN
Button Rising Edge Toggling Cycle
ifHALGPIOReadPinGPIOC GPIOPIN
whileHALGPIOReadPinGPIOC GPIOPIN
ifHALGPIOReadPinGPIOA GPIOPIN
HALGPIOWritePinGPIOA GPIOPIN;
else
HALGPIOWritePinGPIOA GPIOPIN;
Button Double Click Falling Edge Toggling Cycle
ifHALGPIOReadPinGPIOA GPIOPIN
whileHALGPIOReadPinGPIOA GPIOPIN
ifcount
if HALGPIOReadPinGPIOB GPIOPIN
HALGPIOWritePinGPIOB GPIOPIN;
else
HALGPIOWritePinGPIOB GPIOPIN;
count ;
else
count count ;
void SystemClockConfigvoid
RCCOscInitTypeDef RCCOscInitStruct ;
RCCClkInitTypeDef RCCClkInitStruct ;
HALRCCPWRCLKENABLE;
HALPWRVOLTAGESCALINGCONFIGPWRREGULATORVOLTAGESCALE;
RCCOscInitStruct.OscillatorType RCCOSCILLATORTYPEHSI;
RCCOscInitStruct.HSIState RCCHSION;
RCCOscInitStruct.HSICalibrationValue RCCHSICALIBRATIONDEFAULT;
RCCOscInitStruct.PLLPLLState RCCPLLON;
RCCOscInitStruct.PLLPLLSource RCCPLLSOURCEHSI;
RCCOscInitStruct.PLLPLLM ;
RCCOscInitStruct.PLLPLLN ;
RCCOscInitStruct.PLLPLLP RCCPLLPDIV;
RCCOscInitStruct.PLLPLLQ ;
RCCOscInitStruct.PLLPLLR ;
if HALRCCOscConfig&RCCOscInitStruct HALOK
ErrorHandler;
RCCClkInitStruct.ClockType RCCCLOCKTYPEHCLKRCCCLOCKTYPESYSCLK
RCCCLOCKTYPEPCLKRCCCLOCKTYPEPCLK;
RCCClkInitStruct.SYSCLKSource RCCSYSCLKSOURCEPLLCLK;
RCCClkInitStruct.AHBCLKDivider RCCSYSCLKDIV;
RCCClkInitStruct.APBCLKDivider RCCHCLKDIV;
RCCClkInitStruct.APBCLKDivider RCCHCLKDIV;
if HALRCCClockConfig&RCCClkInitStruct, FLASHLATENCY HALOK
ErrorHandler;
static void MXUSARTUARTInitvoid
huartInstance USART;
huartInit.BaudRate ;
huartInit.WordLength UARTWORDLENGTHB;
huartInit.StopBits UARTSTOPBITS;
huartInit.Parity UARTPARITYNONE;
huartInit.Mode UARTMODETXRX;
huartInit.HwFlowCtl UARTHWCONTROLNONE;
huartInit.OverSampling UARTOVERSAMPLING;
if HALUARTInit&huart HALOK
ErrorHandler;
static void MXGPIOInitvoid
GPIOInitTypeDef GPIOInitStruct ;
HALRCCGPIOCCLKENABLE;
HALRCCGPIOHCLKENABLE;
HALRCCGPIOACLKENABLE;
HALRCCGPIOBCLKENABLE;
HALGPIOWritePinGPIOA GPIOPINGPIOPINGPIOPIN GPIOPINSET;
HALGPIOWritePinGPIOB GPIOPIN GPIOPINSET;
GPIOInitStruct.Pin GPIOPINGPIOPINGPIOPIN;
GPIOInitStruct.Mode GPIOMODEINPUT;
GPIOInitStruct.Pull GPIOPULLUP;
HALGPIOInitGPIOC &GPIOInitStruct;
GPIOInitStruct.Pin GPIOPINGPIOPINGPIOPIN;
GPIOInitStruct.Mode GPIOMODEOUTPUTPP;
GPIOInitStruct.Pull GPIOPULLUP;
GPIOInitStruct.Speed GPIOSPEEDFREQLOW;
HALGPIOInitGPIOA &GPIOInitStruct;
GPIOInitStruct.Pin GPIOPIN;
GPIOInitStruct.Mode GPIOMODEINPUT;
GPIOInitStruct.Pull GPIOPULLUP;
HALGPIOInitGPIOB &GPIOInitStruct;
GPIOInitStruct.Pin GPIOPIN;
GPIOInitStruct.Mode GPIOMODEOUTPUTPP;
GPIOInitStruct.Pull GPIOPULLUP;
GPIOInitStruct.Speed GPIOSPEEDFREQLOW;
HALGPIOInitGPIOB &GPIOInitStruct;
GPIOInitStruct.Pin GPIOPIN;
GPIOInitStruct.Mode GPIOMODEINPUT;
GPIOInitStruct.Pull GPIOPULLUP;
HALGPIOInitGPIOA &GPIOInitStruct;
void ErrorHandlervoid
disableirq;
while
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
