How I program GPIOs in C | Embedded System Project Series #12

preview_player
Показать описание
I program the I/O-pins on my robot (and development board) according to the pin assignment in my schematic. Writing to registers is cumbersome, so to make things easier, I implement a code abstraction in C that lets me configure and initialize all pins in a single place.

The git repository:

0:00 Recap
0:44 Introduction
1:57 Why start here?
3:18 Setup
4:00 Pin Mapping
5:40 How are IO pins configured?
7:25 Memory-mapped registers
8:56 Blinky example
9:42 Defining the interface (io.h)
10:15 Select register
11:32 Direction register
11:59 Resistor register (pullup/pulldown)
13:22 Input register
13:57 First commit
14:39 How to implement?
15:39 Bitwise operation (code trick!)
17:29 Array indexing (code trick!)
18:52 Implementation (io.c)
19:53 Testing the code
22:38 Second commit
22:55 Initialize all pins
28:27 Third commit
28:44 Last words

#embeddedsystems #gpio #cprogramming

⌨️ My development environment

🌍 Links

👨‍💻 About me
Hi and welcome. I'm Niklas, an embedded systems engineer from Sweden. On this channel, I make practical videos about embedded systems or, in general terms, about building and programming hardware.
Рекомендации по теме
Комментарии
Автор

i was searching for copper but found a gold
this channel is best imo

needywallaby
Автор

You are so, so smart and good at explaining this. Coming from Arduino and slowly leveling up my knowledge and realizing that even something as simple as direct bit banging was the TIP OF THE ICEBERG for all of firmware

redwoodenjoyer
Автор

Thank you for this wonderful series. Can't wait to see what's next.

palaaaurinkoon
Автор

This series is awesome man! Very good content!

renanpils
Автор

Only now I've realized: TI - Texas Instruments😁🤣

sjkhpfn
Автор

Any good sources where the preprocessors like #ifndef, #end, etc are explained and exemplified with use cases?

zDoubleE
Автор

in 16:55 min,
what is pin_bit? i understand pin number and port number.
what is different between io_pin_bit and io_pin_idx?
(io & IO_PORT_MASK) >> IO_PORT_OFFSET this gives port 0 instead of port one for IO_10?

deesuk
Автор

Hi there, just found this channel, and this is exactly what I would love to do. I'm learning self-taught, but gets to hard for me. Can you please tell me something like a routemap so I can use to study?. (Something like: first you have to learn C, then electronics, then ...).

pablocabellojordan
Автор

CAN YOU PLEASE MAKE VIDEOS IN SLOW MANNER ....YOU MOVED FAST FARWARD YOUR CODE WHICH IS VERY UNCOMFORTABLE TO UNDERSTAND FOR ME

bhojasd
Автор

NEXT TIME PLEASE DON DO FARWARDING OF CODE PORTION MAKE IT SLOW AND ALSO TALK SLOWLY ....LOVE FROM INDIA

bhojasd
join shbcf.ru