Monday, December 30, 2019

EC25 adb and fastboot devices installation of ubuntu linux


How to install android drivers on ubuntu


How to Install ADB & Fastboot on Ubuntu 16.04, 16.10, 14.04



This tutorial is going to show you how to install ADB & fastboot on Ubuntu 16.04, 14.04, 16.10, which is quite easy.
What is ADB and Fastboot
ADB and fastboot are two components of the Android SDK Platform-Tools.
ADB stands for Android Debug Bridge. It’s a command line utility that allows you to do the following stuff:
  • Control your Android device over USB from your computer
  • Copy files back and forth
  • install and uninstall apps
  • run shell commands
  • and much more
Fastboot is a command line tool for flashing and Android device, boot an Android device to fastboot mode, etc…
How to Install ADB and Fastboot on Ubuntu 16.04, 16.10, 14.04
It’s super easy. Simply run the following commands in a terminal window to install them from Ubuntu repository.
sudo apt update
sudo apt install android-tools-adb android-tools-fastboot
To check ADB version, run
adb version
Sample output:
Android Debug Bridge version 1.0.32
Enable USB Debugging on Your Android Device
While you Android device is unplugged from USB, go to your Android settings, scroll all the way down and tap About phone or About device. Then tap Build number 7 times which makes you a developer.
Now go back to the settings, you will see a new button called Developer options. Tap that button and enable USB debugging.
Test the Installation
To check if ADB is working properly, connect your Android device to your Ubuntu computer via USB cable. After that, type the following command in your Ubuntu terminal window.
adb devices
You will be prompted to allow USB debugging from Ubuntu computer like the screenshot below. Select OK.

Then type run adb devices command again and your Android device will show up.

If you get the following error,
????????????    no permissions
Then all you need to do is restart adb daemon, run
sudo adb kill-server
Then
sudo adb start-server


EC25 basic commands list

use qcomm for debug which support at commands ..tool is very useful
download here


Friday, December 27, 2019

How to add a image to tkinter python

# -*- coding: utf-8 -*-
"""
Created on Fri Dec 27 14:38:52 2019

@author: Onyx1
"""
from tkinter import *
import tkinter as tk
from PIL import ImageTk, Image
from tkinter import ttk


#path = 'C:/xxxx/xxxx.jpg'
path = 'F:\my_workspace\python_workspace\onyx-logo.png'


root = tk.Tk()
img = ImageTk.PhotoImage(Image.open(path))
panel = tk.Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
root.mainloop()

output:


Saturday, December 21, 2019

Html table using python

# -*- coding: utf-8 -*-
"""
Created on Sat Dec 21 18:01:13 2019

@author: anil durgam
"""
import os
 
html = ""
def table(x):
global html
""" Create table with data in a multiline
string as first argument x)"""
html = "<!-- table -->"
html += "<table border=1>"
for line in x.splitlines():
for n in line.split():
html += f"<td>{n}</td>"
html += "<tr>"
html += "</table>"
return html

def create(a):
tab = table(text.get("1.0", tk.END))
text.delete("1.0", tk.END)
text.insert("1.0", tab)
label['text'] = "Now you can copy the html code for the table (ctrl + a)"

def save_html():
if html != "":
with open("table.html", "w") as file:
file.write(text.get("1.0", tk.END))

def show_html():
if os.path.exists("table.html"):
os.startfile("table.html")

def convert_to_html():
html = table(text.get("1.0",tk.END))
clear()
text.insert("1.0", html)

def clear():
text.delete("1.0", tk.END)

import tkinter as tk
root = tk.Tk()
root.title("Html table converter")
label = tk.Label(root, text="Insert data here separated by space and press Ctrl+c to convert to html table:")
label.pack()
text = tk.Text(root)
text.pack()
text.bind("<Control-c>", create)
text.focus()
# create a toplevel menu
menubar = tk.Menu(root)
menubar.add_command(label="Convert - crtl+c |", command=convert_to_html)
menubar.add_command(label="Save  |", command=save_html)
menubar.add_command(label="Show  |", command=show_html)
menubar.add_command(label="Clear screen  |", command=clear)
# display the menu
root.config(menu=menubar)
root.mainloop()

output:



tkinter nested for loop in python

# !/usr/bin/python3
from  tkinter import *
root = Tk(  )
b = 0
for r in range(6):
   for c in range(6):
      b = b + 1
      Button(root, text = str(b), borderwidth = 1 ).grid(row = r,column = c)

root.mainloop()

output:

set in python


s={10,20,30,40}
print(s)
print(type(s))


output:
{40, 10, 20, 30}
<class 'set'>

example 2:
s={10,20,30,40}
s1=s
print(s)
print(type(s))
print(id(s1),id(s))

output:
{40, 10, 20, 30}
<class 'set'>
1861259155048 1861259155048

In above case both s1 and s representing same id
but copying is not done


example 3:
by copy method

s={10,20,30,40}
s1=s.copy()
print(s)
print(type(s))
print(id(s1),id(s))

output:
{40, 10, 20, 30}
<class 'set'>
1861259156840 1861259157288

both s1 and s address are different

Friday, December 20, 2019

drop down menu in python using Tkinter

# -*- coding: utf-8 -*-
"""
Created on Fri Dec 20 13:15:37 2019

@author: anil durgam
version:1.0
example:MM32 microcontroller drop down menu
"""

from tkinter import ttk
import tkinter as tk
#from pprint import pprint
#scr = Tk()


class Application(ttk.Frame):
   
    def __init__(self, main_window):
        super().__init__(main_window)
        main_window.title("MM32_MENU_SELECTOR")
        tk.Label(main_window,text="MM32 microcontroller selected",fg = "blue",font = "Times").pack()
       
        self.combo = ttk.Combobox(self)
        self.combo.place(x=50, y=50)
        self.combo["values"] = ["MM32F", "MM32L",  "MM32W", "MM32SPIN", "MM32P"]
        self.combo.bind("<<ComboboxSelected>>", self.selection_changed)
           
        main_window.configure(width=1024, height=500)
        self.place(width=300, height=200)
       
    def selection_changed(self, event):
        print("your selected::", self.combo.get())
        if self.combo.get()== "MM32F" :
            print("mm32f submenu displayed here\n")
            self.combo = ttk.Combobox(self)
            self.combo.place(x=50, y=100)
            self.combo["values"] = ["MM32F003", "MM32F031", "MM32F032", "MM32F103"]
            self.combo.bind("<<ComboboxSelected>>", self.selection_changed)
           
            if self.combo.get()=="MM32F003":
                 print("mm32f003 submenu displayed here\n")
                 self.combo = ttk.Combobox(self)
                 self.combo.place(x=50, y=150)
                 self.combo["values"] = ["MM32F003TW", "MM32F003NW"]
                 self.combo.bind("<<ComboboxSelected>>", self.selection_changed)
               
           
        elif self.combo.get()== "MM32L" :
            print("mm32L submenu displayed here\n")
            self.combo = ttk.Combobox(self)
            self.combo.place(x=50, y=100)
            self.combo["values"] = ["MM32L050", "MM32L051", "MM32L052", "MM32L061",
                      "MM32L062","MM32L072","MM32L073","MM32L362","MM32L373","MM32L384",
                      "MM32L395"]
            self.combo.bind("<<ComboboxSelected>>", self.selection_changed)
         
       
        elif self.combo.get()== "MM32W" :
            print("mm32W submenu displayed here\n")
            self.combo = ttk.Combobox(self)
            self.combo.place(x=50, y=100)
            self.combo["values"] = ["MM32W051", "MM32W062", "MM32W073", "MM32W362"
                      , "MM32W373", "MM32W384", "MM32W395"]
            self.combo.bind("<<ComboboxSelected>>", self.selection_changed)
         
           
        elif self.combo.get()== "MM32SPIN" :
            print("mm32SPIN submenu displayed here\n")
            self.combo = ttk.Combobox(self)
            self.combo.place(x=50, y=100)
            self.combo["values"] = ["MM32F003", "MM32F031", "MM32F032", "MM32F103"]
            self.combo.bind("<<ComboboxSelected>>", self.selection_changed)
           
       
        else :
            print("mm32P submenu displayed here\n")
            self.combo = ttk.Combobox(self)
            self.combo.place(x=50, y=100)
            self.combo["values"] = ["MM32F003", "MM32F031", "MM32F032", "MM32F103"]
            self.combo.bind("<<ComboboxSelected>>", self.selection_changed)
main_window = tk.Tk()
#lbl.pack()
#pprint(dict(lbl))
#root = tk.Tk()
T = tk.Text(main_window,width=100, height=10)
T.pack()
T.insert(tk.END, "MM32 main details\navailable here\n")

app = Application(main_window)
app.mainloop()



drop down menu in python

# -*- coding: utf-8 -*-
"""
Created on Fri Dec 20 13:15:37 2019

@author: anil durgam
"""

from tkinter import ttk
import tkinter as tk
class Application(ttk.Frame):
   
    def __init__(self, main_window):
        super().__init__(main_window)
        main_window.title("MM32_MENU_SELECTOR")
       
        self.combo = ttk.Combobox(self)
        self.combo.place(x=50, y=50)
        self.combo["values"] = ["MM32F", "MM32L", "MM32SPIN", "MM32W", "MM32P"]
        self.combo.bind("<<ComboboxSelected>>", self.selection_changed)
       
        main_window.configure(width=1024, height=500)
        self.place(width=300, height=200)
       
    def selection_changed(self, event):
        print("your selected::", self.combo.get())
main_window = tk.Tk()
app = Application(main_window)
app.mainloop()

Monday, December 16, 2019

tkinter text and font display


from tkinter import *
from pprint import pprint

scr = Tk()
scr.title("Label - Tkinter Widgets")

lbl = Label(scr, text="Hello", padx=5, pady=10, font=("Arial Bold", 20))


lbl.pack()
pprint(dict(lbl))
scr.mainloop()

Monday, December 9, 2019

write a program to take a tuple of numbers from the keyboard and print sum ,avg

a=eval(input("Enter  some of tuple numbers"))
l=len(a)
sum=0
for x in a:
    sum=sum+x
print("The sum=",sum)
print("The avg=",sum/l)

output:
Enter  some of tuple numbers(10,20,30)
The sum= 60
The avg= 20.0

Tuple comprehension not support in python

a=(x*x for x in range(1,11))
#print(a)
for x in a:
    print(x)

output:
1
4
9
16
25
36
49
64
81
100

Write a program for tuple packing in python

Tuple packing:
====================================

t=(10,20,30,40)
a,b,c,d=t
print("a=",a,"b=",b,"c=",c,"d=",d)

output:
a= 10 b= 20 c= 30 d= 40



Tuple packing for strings:
==============================
t="abcd"
a,b,c,d=t
print("a=",a,"b=",b,"c=",c,"d=",d)

output:
a= a b= b c= c d= d

Perform Addition, Subtraction, Multiplication, Division and Modulus operation on two integers.


#include<stdio.h>
void main()
{ int a,b;
printf("\n enter two values: ");
scanf("%d %d",&a,&b);
printf("\n a + b = %d", a+b);
printf("\n a - b = %d", a-b);
printf("\n a * b = %d", a*b);
printf("\n a / b = %d", a/b);
printf("\n a modulus b = %d", a%b);
getch();
}




input:

 enter two values: 13  5

output:

 a + b = 18           
 a - b = 8
 a * b = 65
 a / b = 2
 a modulus b = 3

Tuesday, December 3, 2019

MM32f103 led blink program

To work on mind motion MM32 microcontroller we need to install the keil uvision 5 version
then install the mm32-link programmer

go to library folder their you will get the
MM32F103_library_examples\MM32F103xx_m_Lib_Samples_V1.01_SC\MM32F103RegLibMB_Ver1.9.5\Boards_MM32x103\MB103CBT6_lib\BLINK\IOToggle\KEIL_PRJ

open the file in keil. options target  their to need to do mm32-ulink.


/****************************************Copyright (c)****************************************************
**
**                                   
**
**--------------File Info---------------------------------------------------------------------------------
** File name:      main.c
** modified Date:  2019-12-04
** Last Version:   V1.9.5
** Descriptions:   Led blink program by anil durgam
**
*********************************************************************************************************/
#include "sys.h"
#include "delay.h"
#include "uart.h"
#include "led.h"

int main(void)
{
 
    delay_init();  
 
    LED_Init();
 
    while(1)           
    {
        LED1=!LED1;
        LED2=!LED2;
        LED3=!LED3;
        LED4=!LED4;
        delay_ms(1000); 
    }
}



Monday, December 2, 2019

finding the length of tuple in python

t1=(10,20,30)
print(len(t1))

output:
3


multiplication of Tuple in python

t1=(10,20,30)
t2=t1*2
print(t2)


output:
(10, 20, 30, 10, 20, 30)

example 2:


t1=(10,20,30)
t2=t1*3
print(t2)

output:
(10, 20, 30, 10, 20, 30, 10, 20, 30)

addition of Tuple in python

t1=(10,20,30)
t2=(40,50,60)
t3=t1+t2
print(t1)
print(t2)
print(t3)

output 1:
(10, 20, 30)
(40, 50, 60)
(10, 20, 30, 40, 50, 60)

Tuesday, November 26, 2019

single value Tuple in python

If we indicate the parenthesis with single value  then that should not be considered as tuple .

example 1:

t=(10)
print(type(t))
print(t)

output:
<class 'int'>
10

example 2:
t=('A')
print(type(t))

print(t)

output:
<class 'str'>
A

single value tuple indicates as (first value,)

example 3:
t=(10)
print(type(t))
print(t)
t=('A')
print(type(t))
print(t)
t=(10,)
print(type(t))

print(t)

output:
<class 'int'>
10
<class 'str'>
A
<class 'tuple'>
(10,)


Monday, November 25, 2019

write a program to search the vowel in the given string in python

# -*- coding: utf-8 -*-
"""
Created on Tue Nov 26 07:16:18 2019

@author: anil durgam
program:
    write a program to search the vowel in the given string
   
"""
vowels=['a','e','i','o','u']
word=input("enter the some word to search for vowels\n")
found=[]
for letter in word:
    if letter in vowels:
        if letter not in found:
            found.append(letter)
print(found)
print("the number of different vowels present in",word,"is:",len(found) )


output:

enter the some word to search for vowels
anildurgam
['a', 'i', 'u']
the number of different vowels present in anildurgam is: 3


slice operator in python

# -*- coding: utf-8 -*-
"""
Created on Tue Nov 26 06:53:23 2019

@author: anil
Topic:slice operator

"""
a='0123456789'
#a[begin index:end index:direction]
#begin index start from zero
#end index goes upto length of the string.in my case it is ten
#the last parameter indicates the direction if that is '+' its mean positive direction
#if that is '-' then negative direction and also step to increse
print(a[0:11:1])
#in end index forward direction then it should be '-1' need to delete
print(a[0:11:2])
print(a[0:11:3])
print(a[0:11:4])
print(a[0:11:5])
print(a[0:11:6])
print(a[0:11:7])
print(a[0:11:8])
print(a[0:11:9])

#begin index from different values
print()
print("slice operator begin value from different indexes")
print(a[1:11:2])
print(a[1:11:3])
print(a[1:11:4])

output:
0123456789
02468
0369
048
05
06
07
08
09

slice operator begin value from different indexes
13579
147
159


Happy face symbol using arcade game library in python

# -*- coding: utf-8 -*-
"""
Drawing an example happy face

If Python and Arcade are installed, this example can be run from the command line with:
python -m arcade.examples.happy_face
"""

import arcade

# Set constants for the screen size
SCREEN_WIDTH = 600
SCREEN_HEIGHT = 600
SCREEN_TITLE = "Happy Face Example"

# Open the window. Set the window title and dimensions
arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)

# Set the background color
arcade.set_background_color(arcade.color.WHITE)

# Clear screen and start render process
arcade.start_render()

# --- Drawing Commands Will Go Here ---

# Draw the face
x = 300
y = 300
radius = 200
arcade.draw_circle_filled(x, y, radius, arcade.color.YELLOW)

# Draw the right eye
x = 370
y = 350
radius = 20
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)

# Draw the left eye
x = 230
y = 350
radius = 20
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)

# Draw the smile
x = 300
y = 280
width = 120
height = 100
start_angle = 190
end_angle = 350
arcade.draw_arc_outline(x, y, width, height, arcade.color.BLACK,
                        start_angle, end_angle, 10)

# Finish drawing and display the result
arcade.finish_render()

# Keep the window open until the user hits the 'close' button
arcade.run()

Sunday, November 24, 2019

pygame introduction program

this code shows that how to display a window using pygame library


import pygame

# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)

pygame.init()

# Set the width and height of the screen [width, height]
size = (700, 500)
screen = pygame.display.set_mode(size)

pygame.display.set_caption("My Game")

# Loop until the user clicks the close button.
done = False

# Used to manage how fast the screen updates
clock = pygame.time.Clock()

# -------- Main Program Loop -----------
while not done:
    # --- Main event loop
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True

    # --- Game logic should go here

    # --- Screen-clearing code goes here

    # Here, we clear the screen to white. Don't put other drawing commands
    # above this, or they will be erased with this command.

    # If you want a background image, replace this clear with blit'ing the
    # background image.
    screen.fill(WHITE)

    # --- Drawing code should go here

    # --- Go ahead and update the screen with what we've drawn.
    pygame.display.flip()

    # --- Limit to 60 frames per second
    clock.tick(60)

# Close the window and quit.
pygame.quit()

Thursday, November 21, 2019

tkinter label example

from tkinter import *
root = Tk()

one =Label(root,text="ONE",bg="red",fg="white")
one.pack()
two =Label(root,text="TWO",bg="green",fg="black")
two.pack(fill=X)
three =Label(root,text="THREE",bg="blue",fg="white")
three.pack(side=LEFT,fill=Y)


root.mainloop()

output:

tkinter example making of button


from tkinter import *

mm32=tk.Tk()

topframe = Frame(mm32)
topframe.pack()
bottomframe=Frame(mm32)
bottomframe.pack(side=BOTTOM)

button1=Button(topframe,text="MM32F",fg="red",font=('Helvetica', 15))
button2=Button(topframe,text="MM32L",fg="red",font=('Helvetica', 15))
button3=Button(topframe,text="MM32SPIN",fg="red",font=('Helvetica', 15))
button4=Button(topframe,text="MM32W",fg="red",font=('Helvetica', 15))
button5=Button(topframe,text="MM32P",fg="red",font=('Helvetica', 15))

button1.pack(side=LEFT)
button2.pack(side=LEFT)
button3.pack(side=LEFT)
button4.pack(side=LEFT)
button5.pack(side=LEFT)

mm32.mainloop()

OUTPUT:


tkinter introduction


from tkinter import *
root = Tk()
root.mainloop()

output:




from tkinter import *

mm32=tk.Tk()

thelabel=tk.Label(text="MM32_DATASHEETS", font=('Helvetica',20), fg='green')
thelabel.pack()
mm32.configure(background="light green")

mm32.mainloop()

output:

Wednesday, November 20, 2019

drop down list using tkinter library in python

try:
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk
def select():
    sf = "value is %s" % var.get()
    root.title(sf)
    # optional
    color = var.get()
    root['bg'] = color
root = tk.Tk()
# use width x height + x_offset + y_offset (no spaces!)
#root.geometry("%dx%d+%d+%d" % (330, 80, 200, 150))
#root.geometry("%dx%d+%d+%d" % (220, 40, 200, 150))
root.title("MM32_MICROCONTROLLER_DATA")
root.configure(background="light green")
var = tk.StringVar(root)
# initial value
var.set('MM32F_SERIES')
choices = ['MM32F_SERIES', 'MM32L_SERIES', 'MM32SPIN_SERIES', 'MM32W_SERIES','MM32P_SERIES']
Fchoices = ['MM32F003', 'MM32L_SERIES', 'MM32SPIN_SERIES', 'MM32W_SERIES','MM32P_SERIES']
option = tk.OptionMenu(root, var, *choices)
option.pack(side='left', padx=1, pady=1)
button = tk.Button(root, text="check value slected", command=select)
button.pack(side='left', padx=20, pady=1)
root.mainloop()

output





matrix list in python

a=[[10,20,30],[25,40,50],[60,70,80]]
print(a)
for r in a:
    print(r)

output:
[[10, 20, 30], [25, 40, 50], [60, 70, 80]]
[10, 20, 30]
[25, 40, 50]
[60, 70, 80]

nested list in python

a=[10,20,[30,40]]
print(a)
print(a[0])
print(a[1])
print(a[2][0])
print(a[2][1])

output:
[10, 20, [30, 40]]
10
20
30
40

clear method in python

clear method is used for to clear entire list ,list elements

a=[10,20,30]
print(a)
a.clear()
print(a)

output:
[10, 20, 30]
[]

list elements check using print

a=[10,20,30]
print(10 in a)
print(100 in a)
print(100 not in a)

output:
True
False
True

comparing the list elements in python


comparing list elements.

x=['abc','bcd','cde']
y=['abc','bcd','cde']
z=['ABC','BCD','CDE']
print(x==y)
print(x==z)
print(x!=z)

output:
True
False
True

example 2:
x=['abc','bcd','cde']
y=['abc','bcd','cde']
z=['ABC','BCD','CDE']
print(x[0] is y[0])
print(x==z)
print(x!=z)

output:
True
False
True

mathematical operation on the list in python

a1=[20,5,16,10,8]
a2=[10, 20, 30, 40]
c=a1+a2
print(c)

output:
[20, 5, 16, 10, 8, 10, 20, 30, 40]

copy method in python

a1=[20,5,16,10,8]
y=a1.copy()
print(a1)
print(y)

output:
[20, 5, 16, 10, 8]
[20, 5, 16, 10, 8]

slice operator using list

list we can copy  by using slice operator  ,the element of the first  list should same in the next list but when you change the element from the cloned list  that elements only changes previous list should same like before.

x=[10,20,30,40]
y=x[:]
print(x)
y[1]=111
print(id(x))
print(id(y))
print(y)
print(x)

output:
[10, 20, 30, 40]
2576163316104
2576163860680
[10, 111, 30, 40]
[10, 20, 30, 40]

list alias in python

In the list we can make many alias for the single list

x1 = [5, 8, 10, 16, 20]
y=x1
print(x1)
print(y)
print(id(x1))
print(id(y))

output:
[5, 8, 10, 16, 20]
[5, 8, 10, 16, 20]
2576163839240
2576163839240

sorting the element of the list in reverse using sort method

a1=[20,5,16,10,8]
a1.sort()
print(a1)
a1.sort(reverse=True)
print(a1)

output:

[5, 8, 10, 16, 20]
[20, 16, 10, 8, 5]

example:
if reverse is false then it will give normal sorting order only
a1=[20,5,16,10,8]
a1.sort()
print(a1)
a1.sort(reverse=True)
print(a1)
a1.sort(reverse=False)
print(a1)

output:
[5, 8, 10, 16, 20]
[20, 16, 10, 8, 5]
[5, 8, 10, 16, 20]

Tuesday, November 19, 2019

sort method in python

a1=[30,5,14,8,0]
a1.sort()
print(a1)

output:
[0, 5, 8, 14, 30]

example2:

a1=[30,5,14,8,0]
a1.sort()
print(a1)
a2=["bat","ant","dog","cat"]
a2.sort()
print(a2)

output:
[0, 5, 8, 14, 30]
['ant', 'bat', 'cat', 'dog']

example3:
if upper case strings and lowercase strings are present then it will shows the uppercase string first then it will shows the lower case strings

a1=[30,5,14,8,0]
a1.sort()
print(a1)
a2=["Bat","ant","Dog","Cat"]
a2.sort()
print(a2)

output:
[0, 5, 8, 14, 30]
['Bat', 'Cat', 'Dog', 'ant']

example 4:
strings and integers with in list then they will not sorted .compiler will shows the error

a1=[10,'B',20,'C',4,'A']
a1.sort()
print(a1)

output:
TypeError: '<' not supported between instances of 'str' and 'int'

reverse method in python



l1=[10, 30, 40, 50, 60, 70]
l1.reverse()
print(l1)

output:
[70, 60, 50, 40, 30, 10]

pop method in python

pop method removes the last element of the python and also return the which element is deleted

l1=[10, 30, 40, 50, 60, 70]
print(l1.pop())
print(l1)
print(l1.pop())
print(l1)

output:
70
[10, 30, 40, 50, 60]
60
[10, 30, 40, 50]

remove method in python

l1=[10,20,30,40]
print(l1)
l1.remove(20)
print(l1)

output:
[10, 20, 30, 40]
[10, 30, 40]

example 2:

l1=[10,20,30,40,50,60,70]
x=int(input("enter elements to be removed"))
if x in l1:
    l1.remove(x)
    print("removed successfully")
    print(l1)
else:
    print("specified element is not available")

output:
enter elements to be removed10
removed successfully
[20, 30, 40, 50, 60, 70]

enter elements to be removed20
removed successfully
[10, 30, 40, 50, 60, 70]

enter elements to be removed82
specified element is not available


append and extend methods in python


l1=[10,20,30]
l2=[40,50,60]
l1.extend(l2)
print(l1)
l1.extend('anil')
print(l1)
l1.append('anil')
print(l1)

output:
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60, 'a', 'n', 'i', 'l']
[10, 20, 30, 40, 50, 60, 'a', 'n', 'i', 'l', 'anil']

extend method in python

l1=["chicken","mutton","fish"]
l2=["biryani","fry","roast"]
l1.extend(l2)
print(l1)
print(l2)

output:
['chicken', 'mutton', 'fish', 'biryani', 'fry', 'roast']
['biryani', 'fry', 'roast']


example 2:
l1=["chicken","mutton","fish"]
l2=["biryani","fry","roast"]
l1.extend(l2)
print(l1)
print(l2)
l2.extend(l1)
print(l2)

output:

['chicken', 'mutton', 'fish', 'biryani', 'fry', 'roast']
['biryani', 'fry', 'roast']
['biryani', 'fry', 'roast', 'chicken', 'mutton', 'fish', 'biryani', 'fry', 'roast']

example3:
If we are adding a string using extend method then extire string added to given list but individual character.

l1=[10,20,30]
l2=[40,50,60]
l1.extend(l2)
print(l1)
l1.extend('anil')
print(l1)

output:
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60, 'a', 'n', 'i', 'l']

insert method in python

l=[]
l.append(10)
l.append(20)
l.append(30)
l.append(40)
print(l)
l.insert(1,50)
print(l)

output:
[10, 20, 30, 40]
[10, 50, 20, 30, 40]

example 2:

l=[]
l.append(10)
l.append(20)
l.append(30)
l.append(40)
print(l)
l.insert(1,50)
print(l)
l.insert(50,888)
print(l)
l.insert(-20,333)
print(l)

output:
[10, 20, 30, 40]
[10, 50, 20, 30, 40]
[10, 50, 20, 30, 40, 888]
[333, 10, 50, 20, 30, 40, 888]

l=[]
l.append(10)
l.append(20)
l.append(30)
l.append(40)
print(l)
l.insert(1,50)
print(l)
l.insert(50,888)
print(l)
l.insert(-20,333)
print(l)
print(l.index(888))
print(l.index(333))

output:
[10, 20, 30, 40]
[10, 50, 20, 30, 40]
[10, 50, 20, 30, 40, 888]
[333, 10, 50, 20, 30, 40, 888]
6
0



write a program in python to append all even number upto 100 which are divisible by 10

write a program in python to append all even number upto 100 which are divisible by 10

l=[]
for x in range(101) :
    if x%10==0:
        l.append(x)
    else:
        x=x+1
print(l)
 
output:
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]

or
l=[]
for x in range(0,101,10) :
        l.append(x)
print(l)


output:
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]

write a program in python to append all even number upto 100


l=[]
for x in range(101) :
    if x%2==0:
        l.append(x)
    else:
        x=x+1
print(l)
 
output:
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]


write a program in python to append all odd numbers upto 100

l=[]
for x in range(101) :
    if x%2==1:
        l.append(x)
    else:
        x=x+1
print(l)

output:
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]

append method in python

single element adding by using append method
l=[]
l.append(10)
print(l)

output:
[10]


multiple methods adding by using append method
l=[]
l.append(10)
l.append(20)
l.append(30)
l.append(40)
print(l)

output:
[10, 20, 30, 40]

try and except method in python

l=[10,20,30,40,10,20,10,10]
target=int(input("enter the value to search"))
try:
    print(target,"available and its first occurence is at:",l.index(target))
except ValueError:
    print(target,"not available")

output
enter the value to search20
20 available and its first occurence is at: 1


enter the value to search30
30 available and its first occurence is at: 2


enter the value to search50
50 not available

count method in python

l=[10,20,30,40,10,20,10,10]
print(l.count(20))

output:
2


index method
it tells first occurrence of the given number

l=[10,20,30,40,10,20,10,10]
print(l.count(20))
print(l.index(10))

output:
2
0


if the value is  not there in the given string then it will show the value error

l=[10,20,30,40,10,20,10,10]

print(l.index(50))


output:

ValueError: 50 is not in list



l=[10,20,30,40,10,20,10,10]
target=int(input("enter the value to search"))
if target in l:
    print(target,"available and its first occurence is at:",l.index(target))
else:
    print(target,"not available")

output:
enter the value to search10
10 available and its first occurence is at: 0



enter the value to search30
30 available and its first occurence is at: 2


enter the value to search50
50 not available

Saturday, November 16, 2019

a function which is outside the method is called as method

a function  which is outside the method is called as method.
def f1():
    print("this is the function")
class student:
    def info(self):
        print("this is the method")
f1()
s=student()
s.info()

output:
this is the function
this is the method

Friday, November 15, 2019

list in python

l=[10,20,30,40]
print(l[0])
print(l[-4])


output:
10
10

example 2:
l=[10,20,30,40]
print(l[0])
print(l[-1])

output:
10
10

example3:
l=[10,20,[30,40]]
print(l[2])
print(l[-1])

output:
[30, 40]
[30, 40]

example4:
l=[10,20,[30,40]]
print(l[2][0])
print(l[2][1])

output:
30
40



list elements printing using while loop

list=[1,2,3,4,5,6,325,7,8]
i=0
while i<len(list):
    print(list[i])
    i=i+1

output:
1
2
3
4
5
6
325
7
8

list elements printing using for loop

list=[1,2,3,4,5,6,7,8,9]
for x in list:
    print(x)

output:
1
2
3
4
5
6
7
8
9

printing the even places of the list elements
list=[1,2,3,4,5,6,7,8,9]
for x in list:
    if x%2==0:
        print(x)

output:
2
4
6
8

Sunday, November 10, 2019

merging strings in python

s1=input("enter the first string::")
s2=input("enter the second string::")
output=''
i=j=0
while i<len(s1) or j<len(s2):
    output=output+s1[i]+s2[j]
    i=i+1
    j=j+1
print(output)

output:
enter the first string::anil

enter the second string::durg
adnuirlg


example 2:
s1=input("enter the first string::")
s2=input("enter the second string::")
output=''
i=j=0
while i<len(s1) or j<len(s2):
    if i<len(s1):
        output=output+s1[i]
        i=i+1
    if i<len(s2):
        output=output+s2[j]
        j=j+1
print(output)

output:
enter the first string::anil

enter the second string::durgam
adnuirlgam

printing unicode character in place of numbers in python

s= input("Enter some string:")
output=''
for x in s:
    if x.isalpha():
        output=output+x
        previous=x
    else:
        newch=chr(ord(previous)+int(x))
        output=output+newch
print(output)

output:
Enter some string:a4b2d9
aebddm

using sorted keyword and extracting alphabets and numbers using python

s= input("Enter some string:")
s1=s2=output=''
for x in s:
    if x.isalpha():
        s1=s1+x
    else:
        s2=s2+x
print(s1)
print(s2)


output:
Enter some string:a1b2c3
abc
123

example 2:
s= input("Enter some string:")
s1=s2=output=''
for x in s:
    if x.isalpha():
        s1=s1+x
    else:
        s2=s2+x
for x in sorted(s1):
    output=output+x
for x in sorted(s2):
    output=output+x
print(output)

output:
Enter some string:a1b2c3d4
abcd1234


example 3:
s= input("Enter some string:")
output=''
for x in s:
    if x.isalpha():
        output=output+x
        previous=x
    else:
        output=output+previous*(int(x)-1)
print(output)


output:
Enter some string:a4b2c5d2
aaaabbcccccdd

Wednesday, November 6, 2019

printing the character at even and odd positions

# -*- coding: utf-8 -*-
"""
Created on Thu Nov  7 07:46:59 2019

@author: Onyx1
"""

a=input("Enter some string::")
i=0
print("The Characters at even positions:")
while i<len(a):
    print(a[i],end=',')
    i=i+2
i=1
print("The Characters at odd positions:")
while i<len(a):
    print(a[i],end=',')
    i=i+2

output:
Enter some string::anildurgam
The Characters at even positions:
a,i,d,r,a,The Characters at odd positions:
n,l,u,g,m,




example2:
a=input("Enter some string::")
i=0
print("The Characters at even positions:")
while i<len(a):
    print(a[i],end=',')
    i=i+2
i=1
print()
print("The Characters at odd positions:")
while i<len(a):
    print(a[i],end=',')
    i=i+2

output:
Enter some string::anildurgam
The Characters at even positions:
a,i,d,r,a,
The Characters at odd positions:
n,l,u,g,m,

printing the character at even and odd positions in python

a=input("enter some string::")
print("Character of the even positions",a[::2])
print("Character of the even positions",a[1::2])


output:
enter some string::anil
Character of the even positions ai
Character of the even positions nl

reverse the given string using slice operator


a=input("Enter some string::")
print(a[::-1])

output:
Enter some string::anil durgam
magrud lina


method 2:
 using inbuilt functions


a=input("Enter some string::")
for x in reversed(a):
    print(x)

output:
Enter some string::anil durgam
m
a
g
r
u
d

l
i
n
a

join method

a=input("Enter some string::")
print(''.join(reversed(a)))

output:
Enter some string::anil
lina


without new line of the reversed string

a=input("Enter some string::")
for x in reversed(a):
    print(x,end='')

output:
Enter some string::anil
lina

Tuesday, November 5, 2019

format method in python

# -*- coding: utf-8 -*-
"""
Created on Wed Nov  6 07:28:23 2019
@author: Anil Durgam
"""

name="anil"
age=29
salary = 20000
print("{}'s age is {} and his salary is{}".format(name,age,salary))
print("{0}'s age is {1} and his salary is{2}".format(name,age,salary))
print("{x}'s age is {y} and his salary is{z}".format(x=name,y=age,z=salary))
print("{x}'s age is {y} and his salary is{z}".format(z=salary,x=name,y=age))

output:
anil's age is 29 and his salary is20000
anil's age is 29 and his salary is20000
anil's age is 29 and his salary is20000
anil's age is 29 and his salary is20000

isalnum,isalpha,islower,isspace methods in python


"""
Created on Sun Nov  3 09:54:15 2019

@author: anil durgam
"""

s=input("Enter any character:")
if s.isalnum():
    print("Alpha numeric character")
    if s.isalpha():
        print("Alphabet character")
        if s.islower():
            print("Lower case alphabet character")
        else:
            print("Upper case alphabet character")
    else:
        print("It is a digit")
elif s.isspace():
    print("It is space character")
else:
    print("Non space Special character")


output:

Enter any character:5
Alpha numeric character
It is a digit



Enter any character:a
Alpha numeric character
Alphabet character
Lower case alphabet character


Enter any character:
It is space character
    

Sunday, November 3, 2019

startwith,endswith methods in python

Example 1:

s="Learning Python is very easy"
print(s.startswith("Learning"))
print(s.endswith("Easy"))
print(s.endswith("easy"))

output:
True
False
True

upper,lower,title,swapcase,capitalize methods in python


example 1:

s="Anil Durgam Learning Python"
print(s.upper())
print(s.lower())
print(s.swapcase())
print(s.title())
print(s.capitalize())

output:
ANIL DURGAM LEARNING PYTHON
anil durgam learning python
aNIL dURGAM lEARNING pYTHON
Anil Durgam Learning Python
Anil durgam learning python

join method in python

join method is used for to join the strings . especially used for the list and tuples

example 1:
list joining using join method
s=["anil", "durgam", "embedded"]
l="-".join(s)
print(l)

output:
anil-durgam-embedded

example 2:
tuple joining with join method
s=("anil", "durgam", "embedded")
l="-".join(s)
print(l)

output:
anil-durgam-embedded

example 3:
s=("anil", "durgam", "embedded")
l=":".join(s)
print(l)

output:
anil:durgam:embedded

example 4:
s=("anil", "durgam", "embedded")
l=" ".join(s)
print(l)

output:
anil durgam embedded

example 5:
s=("anil", "durgam", "embedded")
l="".join(s)
print(l)

output:
anildurgamembedded

rsplit method in python

rsplit method is used for  to print the given string in right to left direction

example 1:
s="10 20 30 40 50 60 70 80"
l=s.rsplit(" ",3)
print(l)
for x in l:
    print(x)

output :
10 20 30 40 50
60
70
80

example 2:

s="10 20 30 40 50 60 70 80"
l=s.rsplit(" ",4)
print(l)
for x in l:
    print(x)

output:

10 20 30 40
50
60
70
80

default value for the rsplit is  -1
s="10 20 30 40 50 60 70 80"
l=s.rsplit(" ",-1)
print(l)
for x in l:
    print(x)

output:
10
20
30
40
50
60
70
80

Saturday, November 2, 2019

split method in python


example 1:
split method is used for to split the given string in the left to right direction

s="anil durgam embedded"
l=s.split()
print(l)

output:
['anil', 'durgam', 'embedded']

example2:

s="anil durgam embedded"
l=s.split()
print(l)
for x in l:
    print(x)

output:
['anil', 'durgam', 'embedded']
anil
durgam
embedded


example 4:

s="03-11-2019"
l=s.split("-")
print(l)
for x in l:
    print(x)

output:
['03', '11', '2019']
03
11
2019


example 5:

s="anil durgam embedded developer india"
l=s.split(" ",3)
print(l)
for x in l:
    print(x)

output:
anil
durgam
embedded
developer india

example 6:
s="10 20 30 40 50 60 70 80"
l=s.split(" ",3)
print(l)
for x in l:
    print(x)

output:
10
20
30
40 50 60 70 80


replace method in python

s="ababa"
print(s)
s1=s.replace('a','b')
print(s1)

output:
ababa
bbbbb

example 2:


s="ababa"
print(s)
print("address of ::",id(s))
s1=s.replace('a','b')
print(s1)
print("address of ::",id(s1))

output:

ababa
address of :: 1358579616712
bbbbb
address of :: 1358567155280


example 3:

string data type is immutable but create the new object



s="ababa"
print(s)
print("address of ::",id(s))
s=s.replace('a','b')
print(s)
print("address of ::",id(s))

output:
ababa
address of :: 1358579616712
bbbbb
address of :: 1358579722816

Tuesday, October 29, 2019

"sizeof" function in c language

#include <stdio.h>
#include <stdlib.h>

int main()
{
   int a =0;
   char c="b";
   float d=1.10;
   long e=12345678;
   double f=1234567812345;
   long double g=123456789;
   printf("int==%d\nchar==%d\nfloat====%d",sizeof(a),sizeof(c),sizeof(d));
   printf("\nlong==%d",sizeof(e));
   printf("\ndouble==%d",sizeof(f));
   printf("\nlong double==%d",sizeof(g));
    return 0;
}

output:

int==4
char==1
float====4
long==4
double==8

long double==12

note :i am using code block ide ...so my values are like this ....if your using any other compiler then values will be changed as per the compiler

Monday, October 28, 2019

MM32 INSTALLATION ON KEIL





IC PACKAGES

  • BQFPH - Bumpered Quad Flat Pack with Heat spreader:   This form of quad flat package utilises the pin protectors at the corners, it also has heat spreaders to enable larger levels of power to be dissipated.
  • CQFP - Ceramic Quad Flat Pack:   This is a high quality version of the quad flat pack using ceramic for the package.
  • FQFP - Fine pitched Quad Flat Pack:   A quad flat pack with, as the name indicates, a fine pitch for the pins.
  • HQFP - Heat sinked Quad Flat Pack:   With many integrated circuits, especially those with high pins counts which have a high level of circuitry may dissipate high levels of heat. This heat may need to be removed. To achieve this a number of the pins, often in the centre of opposing sides are replaced with a thicker pin which is soldered to a large pad on the PCB with a large area of copper connected to it. This will remove a significant amount of heat.
  • LQFP - Low profile Quad Flat Pack:   The Low Profile Quad Flat Pack is based upon the metric QFP, MQFP, but it is are thinner with a body thickness or height of 1.4mm. This helps solve problems where component height may be a problem. It has a standard lead-frame footprint - 2.0mm lead footprint. Lead counts for the LQFP range from 32 to 256. Body sizes range from 5 x 5mm to 28 x 28mm. Lead pitches available for LQFP package are 0.3, 0.4, 0.5, & 0.65mm.
  • MQFP - Metric Quad Flat Pack:   A quad flat package where the measurements and in particular the pin spacing is defined in metric dimensions. Standard QFPs normally use Imperial measurements and have pin spacing etc defined in terms of convenient Imperial dimensions.
  • PQFP - Plastic Quad Flat Pack:   A quad flat pack where the package material is plastic. Some QFPs can use ceramic.
  • TQFP - Thin Quad Flat Pack:   The Thin Quad Flat Pack, TQFP is a form of low profile quad flat pack. Having a body thickness of 1.0mm and have a standard lead-frame footprint with 2.0mm lead footprint. The TQFP package material used is plastic.

Wednesday, October 23, 2019

WHILE loop in python

EXAMPLE 1:
while 1:
    print("Hello")

output:
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
......

EXAMPLE 2:

x=0
while 1:
    print(x)

    x+=1

output:
1
2
3
4
5
.....

Tuesday, October 22, 2019

FOR loop in python

in loops concept For loop plays major role

range is inbuilt function which is having 3 integers values
range(start,stop,step)
start---from where to start the iteration
stop---upto which value(max value) to execute
step---how much increment is looking for each iteration


example 1:

for x in range(1,10):
    print(x)

out put:
1
2
3
4
5
6
7
8
9



example 2:

for x in range(1,10):

    print("*")

output:
*
*
*
*
*
*
*
*
*

nested for loop

for x in range(1,5):
    for y in range (1,5):

          print("*")

output:
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

example 4:
for x in range(2, 30, 3):
  print(x)

output:
2
5
8
11
14
17
20
23
26
29

example 5:
adj = ["red", "big", "tasty"]
fruits = ["apple", "banana", "cherry"]

for x in adj:
  for y in fruits:

    print(x, y)

output:
red apple
red banana
red cherry
big apple
big banana
big cherry
tasty apple
tasty banana
tasty cherry

example 6:
sentence = ["the", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog"]

for i in sentence:
    print(i)
    i=+1

output:
the
quick
brown
fox
jumped
over
the
lazy
dog

Friday, September 27, 2019

stm32f103c8t6 with uart communication


main lines to add:
uint8_t bufftx[10]="Hello\n\r";
while (1)
  {
    /* USER CODE END WHILE */
HAL_UART_Transmit(&huart2, bufftx, 10,100);
HAL_Delay(1000);
    /* USER CODE BEGIN 3 */

  }



/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#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 ---------------------------------------------------------*/
UART_HandleTypeDef huart1;
UART_HandleTypeDef huart2;

/* USER CODE BEGIN PV */
uint8_t bufftx[10]="Hello\n\r";

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_USART2_UART_Init(void);
/* USER CODE BEGIN PFP */

/* 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_USART1_UART_Init();
  MX_USART2_UART_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
HAL_UART_Transmit(&huart2, bufftx, 10,100);
HAL_Delay(1000);
    /* 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};

  /** Initializes the CPU, AHB and APB busses clocks
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
  /** Initializes the CPU, AHB and APB busses 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();
  }
}

/**
  * @brief USART1 Initialization Function
  * @param None
  * @retval None
  */
static void MX_USART1_UART_Init(void)
{

  /* USER CODE BEGIN USART1_Init 0 */

  /* USER CODE END USART1_Init 0 */

  /* USER CODE BEGIN USART1_Init 1 */

  /* USER CODE END USART1_Init 1 */
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 115200;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART1_Init 2 */

  /* USER CODE END USART1_Init 2 */

}

/**
  * @brief USART2 Initialization Function
  * @param None
  * @retval None
  */
static void MX_USART2_UART_Init(void)
{

  /* USER CODE BEGIN USART2_Init 0 */

  /* USER CODE END USART2_Init 0 */

  /* USER CODE BEGIN USART2_Init 1 */

  /* USER CODE END USART2_Init 1 */
  huart2.Instance = USART2;
  huart2.Init.BaudRate = 9600;
  huart2.Init.WordLength = UART_WORDLENGTH_8B;
  huart2.Init.StopBits = UART_STOPBITS_1;
  huart2.Init.Parity = UART_PARITY_NONE;
  huart2.Init.Mode = UART_MODE_TX_RX;
  huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart2) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART2_Init 2 */

  /* USER CODE END USART2_Init 2 */

}

/**
  * @brief GPIO Initialization Function
  * @param None
  * @retval None
  */
static void MX_GPIO_Init(void)
{

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOD_CLK_ENABLE();
  __HAL_RCC_GPIOA_CLK_ENABLE();

}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
  * @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 */

  /* 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,
     tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/


output :

python class topic video