 Okay, I'm here again with my GPO example, which we do before. I think it's the most useful example because we spend with this example a lot of time. But here I will go to the GPO in it. We talk about the clock enable because we need to enable the clock before we start work with the GPOs. Here we configure the default state of this pin that in case that we start to initialize this pin we force this pin to stay low in case that our application have some proprietary settings requirements that for example after initialization the pin must be always high and we can change this here. But then we can found the init structure. We can see here we define the init structure variable the GPO underscore init struct and we put into this stack some some some values and then on the end we called the GPO init when the one parameter is the let GPO port which is my define let and then as the second parameter is this structure then into this structure we save all information about the behavior of the pin and when we called the GPO HL GPO init this pin will get these parameters and the parameters inside the stack is the pin, mode, pull function and the speed. Okay now how to discover which structure to define and what is the name of the structure the type. For me the easiest way one way is to look into the help file I am more than less like because we know that the initialization always start with the init then we look directly into the drivers into the GPO drivers which are here the dot c usually the init init function is the first we can see and here we know we see the parameters first parameter is the GPO X and here he advice us advice us that it must be in range from the A to I from A to I and second parameter must be the init stacked then we can copy this this part and define it into into our initialization in case that is necessary. Okay then we put the stack then how discover the parameters of the stack you can use the the dot convention then usually all the IDEs try to advise you then you click on the dot and he select show for you alternate the possible possible parameters or press control space to force this whispering in case that you are not sure I advise here double to mark this type definition click with the right click and use the go to go to definition it's always the same in the IR Kyle or the the atolic and then you can see which what are the parts of this structure and here also you can see that if you want to to see what you can put inside this to refer this this define for example I am not sure which in definition can be here then I copy this a press control C usually control F okay and I say search for it it's usually a little bit lower only and you see as the as a pin you can put all these parameters okay then why we cannot try it on your own I think it's very good good it will be very good experience I do this in in Michael then what to do on our discovery kit we have the lead but let is already defined that I think it's no reason to to do this again but we have also button then we can define this button why not okay then we use this this this this definition and I think we can only copy this one in its tract I think it's not necessary and we define this pin in our main here in the section use a code begin to think it will be good good option but definitely we need to to define our private variable which will be called button by not okay then I use the button here and I start with the initialization but first what I forget is check which button and where is the button what is the the button button position and the type this I have here okay and the button user blue it's connected to pin PC 13 then we need to remember on this button is also pull up resistor then if the button is pressed the the on the microcontra pen is zero if it's not pressed there is the VDD this mean one then it's pin PC 13 okay then remember this then first of all we talk about the clocks then before we want to work with the pay pay we need to enable clocks if we we know here that in the GPO in it we enabled the clocks for the for the GPO A but our pin is GPO C we can simply copy this part and here we only change the GPO N to GPO C this enable the clock for us for the pin pins PC and we can also in it in the dispens then we tie button I can use the that dot and first I definitely select the pin because this is the most important part which pin to select I'm not sure I must say then I can return into my H file here I search for the GPO pins definition and I have a lot of pens we know our pen is 13 then we here select the PC 13 I put it here everything okay then again need to define all most of the parameters because not only one usually undefined parameter can be very dangerous because we know I'm not sure what can be there stored during the initialization we select the mode if you remember we have outputs inputs alternative function analog function but the button will be definitely digital input we again look into our age here is the definition of our structure we search for the mode definitions yes it's here and you can see input output then for us is valid the floating input mode then I will use this one in my in my project it will be pin PC 13 and it will be configured as a input button then we select the pull up or pull down mode again into the H file I think the pull up pull down will be here I don't want to use the pull up or pull down because on the spin is pull up already as an external component then the speed I can set it as the as the low but speed is not used if we configure this pin as an input but for sure I will I will let it here and the last part is the is the alternate alternate function I think the alternative function will be defined here and the alternative function settings okay it's related to the other profiles then because we don't have the alternative function we can delete delete this part okay and now we need to to init this this pin it was only we feel now only the structure but now we need to call the function for init then it start the hl underscore GPIO underscore and then the name init then the first parameter is the GPO part if we look here into go to definition the GPO part he advises us it must be the name GPO x the x name will be name of the part then here we put the GPIO and x it's our in our case c and then the the pointer to to structure and here we need to use the the add no sorry and symbol put the button here and this is everything after that our our our pin will be initialized as the as the input then I think we can test this because okay we incised the pin and we can we can test here you can for example delete the delay it's not necessary and definitely we can here put the hl underscore GPIO as usually and we can look what the available function functions we have and I think the read pin will be the correct function we want to read the button we put again the GPO x it will be the GPIO underscore GPIO c and then the name name of the pin we can copy it from here the GPIO underscore pin underscore 13 okay but what we get back we can go to the definition of this function and you see the return parameter is the GPIO pin state we can check what is the GPIO pin state again with the go to definition and you can see that the state can be set or reset we know when the pin pin is pressed then we are on the zero then we check when the pin is pressed then I put here the if and if this pin is equal to reset then we can do do something then do something I think the toggle is not not so not so happy option then I think we here can find something better hl underscore GPIO underscore we can look I think the we can use the write pin we can copy this part it's the same and the last part is again the pin state and when the button is pressed we set the pin as a as a set okay and we could we don't need to toggle anymore and we put also else when the pin is not pressed then when the pin is not pressed here set the pin then now I can compile the code we download the code into the microcontroller okay it's there here on the code and we check the behavior if we press the button the the lettuce on if we erase the button let this off then it's working how we want it it's perfect and the pin was configured with our own with our own the one remark maybe in the GPIO in it you are wondering when we why we not using here the GPIO GPIO A here and here also the GPIO pin the correct names which pin we used in the lat you see here is something like underscore GPIO underscore port where is this defined because I used in the cube mx the label for the naming of this pin here for me name this pin it's very in the fixed name if we want to know where the definition is we can go to the definition it's in the mx constants.h file and you can see the GPIO part is defined as the GPIO A and the lat lat pin is as the GPIO pin underscore 5 then here I really put there the same parameters as we do here in in our button then now you know how to configure the pins now you definitely can set the pins as the inputs and also as the outputs