SlideShare une entreprise Scribd logo
1  sur  27
Part 2: GPIO meets LED
ben6
2014-04-21
F9-Microkernel App Development
Agenda
• Why we have to know GPIO?
• What’s GPIO?
• How to use GPIO?
F9
Why we have to know GPIO?
Basis of external hardware control
GPIO (General-purpose input/output)
Storage
devices
NICs Buttons LED
…
Agenda
• Why we have to know GPIO?
• What’s GPIO?
– F9 GPIO API for basic app
– Code reading about F9 GPIO Hooks
• How to use GPIO?
F9
What’s GPIO?
• GPIO -- General-purpose
input/output
– Generic pin on a chip whose behavior
can be controlled by the user at run
time
– Support DMA (Direct Memory Access)
control
STM32F407VGT6 GPIOx
GPIO input
• Floating: unknown voltage input stage
• Pull-up: connect to high voltage
• Pull-down: connected to ground
• Non-analog mode: input data register (GPIO_IDR)
Memory Devices
gpio_input_bit(port, pin)
{
if (*GPIO_IDR(port) & (1 << pin))
return 1;
return 0;
}
GPIO output
• push-pull with pull-up/pull-down
• open-drain with pull-up/pull-down
• Non-analog mode, output data register (GPIO_ODR)
Memory Devices
*GPIO_ODR(GPIOA) |= (1 << pin);
Agenda
• Why we have to know GPIO?
• What’s GPIO?
– F9 GPIO API for basic app
– Code reading about F9 GPIO Hooks
• How to use GPIO?
F9
PR #86 GPIO V1 implementation
Kernel part
• include/thread.h
• include/user-gpioer.h
• kernel/ipc.c
• kernel/user-gpioer.c
App part: library and app
• user/apps/gpioer/main.c
• user/include/gpioer.h
• user/lib/io/gpioer.c
Pull request#86 https://github.com/f9micro/f9-kernel/pull/86
GPIO V2: Kernel part GPIO driver code
will move to user-space because this
part violates L4 design principle
GPIO V2: How to make thread has
authority to access AHB1_1DEV?
V1: F9 GPIO API for basic app
• Defined in user/include/gpioer.h
• gpioer_config_output
• gpioer_out
void gpioer_config_output(uint8_t port, uint8_t pin, uint8_t
pupd, uint8_t speed);
void gpioer_out(uint8_t port, uint8_t pin, uint8_t action);
V1: gpioer_config_output
void gpioer_config_output(
uint8_t port, /* Ex: GPIOA, … , GPIOD, …*/
uint8_t pin, /* 0 – 15 */
uint8_t pupd, /* GPIO_PUPDR_UP */
uint8_t speed /* GPIO_PUPDR_UP,GPIO_OSPEEDR_50M */
);
Wrap gpio_config_output from include/platform/stm32f4/gpio.h
GPIO Output Type
#define GPIO_OTYPER_PP (uint32_t (0x0) /* Output push-pull */
#define GPIO_OTYPER_OD (uint32_t)(0x1) /* Output open drain */
include/platform/stm32f4/registers.h
GPIO Speed
#define GPIO_OSPEEDR_2M (uint32_t) (0x0) /* Output speed 2MHz
*/
#define GPIO_OSPEEDR_25M (uint32_t) (0x1) /* Output speed 25MHz
*/
#define GPIO_OSPEEDR_50M (uint32_t) (0x2) /* Output speed 50MHz
*/
#define GPIO_OSPEEDR_100M(uint32_t) (0x3) /* Output speed
100MHz*/
include/platform/stm32f4/registers.h
V1: gpioer_out
void gpioer_out(uint8_t port,
uint8_t pin,
uint8_t action /* GPIO_HIGH or GPIO_LOW */
);
Wrap gpio_out_high and gpio_out_low from include/platform/stm32f4/gpio.h
Agenda
• Why we have to know GPIO?
• What’s GPIO?
– F9 GPIO API for basic app
– Code reading about F9 GPIO Hooks
• How to use GPIO?
F9
Code reading of GPIO for user part
• user/include/gpioer.h
• user/lib/io/gpioer.c
Code reading about F9 GPIO Hooks
– include/thread.h
– include/user-gpioer.h
– kernel/build.mk
– kernel/ipc.c
– kernel/user-gpioer.c
Implementation of this hook by reference the THREAD_LOG printf function
Agenda
• Why we have to know GPIO?
• What’s GPIO?
• How to use GPIO?
– First f9 GPIO app practice to control led light
– Lab3: make led blinking in turns
F9
First f9 GPIO app practice to control
led light
• PR86
– https://github.com/f9micro/f9-kernel/pull/86
• Demo
1. built-in 4 LEDs Blinking
2. trigger External LED
Live Demo 1: built-in 4 LEDs Blinking
STM32F407 Built-in 4 User LEDs
LD3 (orange)
LD4 (green)
LD5 (red)
LD6 (blue)
PD13
PD12
PD14
PD15
Live Demo 2: trigger External LED
Lab 3: LEDs blinking Rocks
Requirements
– Modify LED sample to let the led in turns
– Blinking interval 2 seconds
Hints: reference user/apps/gpioer/main.c
git clone https://github.com/benwei/f9-kernel.git
git checkout 0421-gpioer
Summary: Points recall
• GPIO is the basis of external control
• What’s implementation of GPIO api for user app
• Easy to use API for gpioer for pin output control
Discussions
?
F9
References
• F9 Microkernel source code and introduction
• GCC Naked Attribute
• ARM: Memory Model of Cortex M4
• Cortex™ -M4 Devices Generic User Guide pdf
• General-purpose Input/Output (GPIO)
• UM1472 User manual Discovery kit for STM32F407/417 lines
• STM32F4-Discovery 中文使用手冊

Contenu connexe

Tendances

Manual usuario - Inspur cx-h81-m1 v2 0
Manual usuario  - Inspur cx-h81-m1 v2 0Manual usuario  - Inspur cx-h81-m1 v2 0
Manual usuario - Inspur cx-h81-m1 v2 0Pablo J. Rodriguez H.
 
Pci gaming security & io card specifications and key feature
Pci gaming security & io card specifications and key featurePci gaming security & io card specifications and key feature
Pci gaming security & io card specifications and key featureChiman L. Patel
 
Cisco Router EIGRP Config
Cisco Router EIGRP ConfigCisco Router EIGRP Config
Cisco Router EIGRP ConfigKadir CIKIS
 
How to configure Rip version2 on a Cisco router
How to configure Rip version2 on a Cisco routerHow to configure Rip version2 on a Cisco router
How to configure Rip version2 on a Cisco routertcpipguru
 
Powerful Electronics with Arduino
Powerful Electronics with ArduinoPowerful Electronics with Arduino
Powerful Electronics with ArduinoAbdallah Hodieb
 
Pstn alarm system with lcd dispay and voice
Pstn alarm system with lcd dispay and voicePstn alarm system with lcd dispay and voice
Pstn alarm system with lcd dispay and voicejasen lin
 
OCP 2015 summit_honey badger_and_panther+_update
OCP 2015 summit_honey badger_and_panther+_updateOCP 2015 summit_honey badger_and_panther+_update
OCP 2015 summit_honey badger_and_panther+_updateMike Yan
 
Le parti del pc - didattica differenziata
Le parti del pc - didattica differenziataLe parti del pc - didattica differenziata
Le parti del pc - didattica differenziataIacopo Pappalardo
 
Wobd2 original orange5 programming device package display
Wobd2 original orange5 programming device package displayWobd2 original orange5 programming device package display
Wobd2 original orange5 programming device package displaycarobd2
 
Interfacing two wire adc0831 to raspberry pi2 / Pi3
Interfacing two wire adc0831 to raspberry pi2 / Pi3Interfacing two wire adc0831 to raspberry pi2 / Pi3
Interfacing two wire adc0831 to raspberry pi2 / Pi3Dnyanesh Patil
 
Aewin network security appliance network management platform_scb6983
Aewin network security appliance network management platform_scb6983Aewin network security appliance network management platform_scb6983
Aewin network security appliance network management platform_scb6983Sirena Cheng
 
Aewin embedded mb7210 mini_itx
Aewin embedded mb7210 mini_itxAewin embedded mb7210 mini_itx
Aewin embedded mb7210 mini_itxSirena Cheng
 
Control processing unit and control sequence of ADD and SUB
Control processing unit and control sequence of ADD and SUBControl processing unit and control sequence of ADD and SUB
Control processing unit and control sequence of ADD and SUBRomilkumar Siddhapura
 
Exor e top-epc_brochure
Exor e top-epc_brochureExor e top-epc_brochure
Exor e top-epc_brochureElectromate
 
Handling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUsHandling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUsCorrado Santoro
 

Tendances (20)

Manual usuario - Inspur cx-h81-m1 v2 0
Manual usuario  - Inspur cx-h81-m1 v2 0Manual usuario  - Inspur cx-h81-m1 v2 0
Manual usuario - Inspur cx-h81-m1 v2 0
 
Pci gaming security & io card specifications and key feature
Pci gaming security & io card specifications and key featurePci gaming security & io card specifications and key feature
Pci gaming security & io card specifications and key feature
 
Cisco Router EIGRP Config
Cisco Router EIGRP ConfigCisco Router EIGRP Config
Cisco Router EIGRP Config
 
Capitulo 2
Capitulo 2Capitulo 2
Capitulo 2
 
How to configure Rip version2 on a Cisco router
How to configure Rip version2 on a Cisco routerHow to configure Rip version2 on a Cisco router
How to configure Rip version2 on a Cisco router
 
Powerful Electronics with Arduino
Powerful Electronics with ArduinoPowerful Electronics with Arduino
Powerful Electronics with Arduino
 
Pstn alarm system with lcd dispay and voice
Pstn alarm system with lcd dispay and voicePstn alarm system with lcd dispay and voice
Pstn alarm system with lcd dispay and voice
 
OCP 2015 summit_honey badger_and_panther+_update
OCP 2015 summit_honey badger_and_panther+_updateOCP 2015 summit_honey badger_and_panther+_update
OCP 2015 summit_honey badger_and_panther+_update
 
Le parti del pc - didattica differenziata
Le parti del pc - didattica differenziataLe parti del pc - didattica differenziata
Le parti del pc - didattica differenziata
 
EntroWatch V1.2 (1)
EntroWatch V1.2 (1)EntroWatch V1.2 (1)
EntroWatch V1.2 (1)
 
Wobd2 original orange5 programming device package display
Wobd2 original orange5 programming device package displayWobd2 original orange5 programming device package display
Wobd2 original orange5 programming device package display
 
Interfacing two wire adc0831 to raspberry pi2 / Pi3
Interfacing two wire adc0831 to raspberry pi2 / Pi3Interfacing two wire adc0831 to raspberry pi2 / Pi3
Interfacing two wire adc0831 to raspberry pi2 / Pi3
 
Aewin network security appliance network management platform_scb6983
Aewin network security appliance network management platform_scb6983Aewin network security appliance network management platform_scb6983
Aewin network security appliance network management platform_scb6983
 
Log
LogLog
Log
 
Aewin embedded mb7210 mini_itx
Aewin embedded mb7210 mini_itxAewin embedded mb7210 mini_itx
Aewin embedded mb7210 mini_itx
 
Lampiran 1.programdocx
Lampiran 1.programdocxLampiran 1.programdocx
Lampiran 1.programdocx
 
Control processing unit and control sequence of ADD and SUB
Control processing unit and control sequence of ADD and SUBControl processing unit and control sequence of ADD and SUB
Control processing unit and control sequence of ADD and SUB
 
Exor e top-epc_brochure
Exor e top-epc_brochureExor e top-epc_brochure
Exor e top-epc_brochure
 
Handling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUsHandling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUs
 
modu2 SA - Block Diagram (v20)
modu2 SA - Block Diagram (v20)modu2 SA - Block Diagram (v20)
modu2 SA - Block Diagram (v20)
 

Similaire à F9 microkernel app development part 2 gpio meets led

Ins and Outs of GPIO Programming
Ins and Outs of GPIO ProgrammingIns and Outs of GPIO Programming
Ins and Outs of GPIO ProgrammingICS
 
Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development FastBit Embedded Brain Academy
 
I made some more expansion board for M5Stack
I made some more expansion  board for M5StackI made some more expansion  board for M5Stack
I made some more expansion board for M5StackMasawo Yamazaki
 
Project ACRN GPIO mediator introduction
Project ACRN GPIO mediator introductionProject ACRN GPIO mediator introduction
Project ACRN GPIO mediator introductionProject ACRN
 
Ls catalog thiet bi tu dong gm e_0908_dienhathe.vn
Ls catalog thiet bi tu dong gm e_0908_dienhathe.vnLs catalog thiet bi tu dong gm e_0908_dienhathe.vn
Ls catalog thiet bi tu dong gm e_0908_dienhathe.vnDien Ha The
 
Ls catalog thiet bi tu dong gm e_0908
Ls catalog thiet bi tu dong gm e_0908Ls catalog thiet bi tu dong gm e_0908
Ls catalog thiet bi tu dong gm e_0908Dien Ha The
 
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...Anne Nicolas
 
Raspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentRaspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentCorley S.r.l.
 
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRaspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRICELEEIO
 
Openwrt, linux e GPIO al LinuxDay 2010 Roma
Openwrt, linux e GPIO al LinuxDay 2010 RomaOpenwrt, linux e GPIO al LinuxDay 2010 Roma
Openwrt, linux e GPIO al LinuxDay 2010 RomaClaudio Mignanti
 
ELC North America 2021 Introduction to pin muxing and gpio control under linux
ELC  North America 2021 Introduction to pin muxing and gpio control under linuxELC  North America 2021 Introduction to pin muxing and gpio control under linux
ELC North America 2021 Introduction to pin muxing and gpio control under linuxNeil Armstrong
 
Arduino Microcontroller
Arduino MicrocontrollerArduino Microcontroller
Arduino MicrocontrollerShyam Mohan
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218CAVEDU Education
 
eece237lab2EECE237Lab2.uvproj 1.1 ### uVision .docx
eece237lab2EECE237Lab2.uvproj    1.1   ### uVision .docxeece237lab2EECE237Lab2.uvproj    1.1   ### uVision .docx
eece237lab2EECE237Lab2.uvproj 1.1 ### uVision .docxSALU18
 
plc_training_manual.pdf
plc_training_manual.pdfplc_training_manual.pdf
plc_training_manual.pdfMarioHaguila
 

Similaire à F9 microkernel app development part 2 gpio meets led (20)

Ins and Outs of GPIO Programming
Ins and Outs of GPIO ProgrammingIns and Outs of GPIO Programming
Ins and Outs of GPIO Programming
 
Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development
 
PPT+.pdf
PPT+.pdfPPT+.pdf
PPT+.pdf
 
Atomic pi Mini PC
Atomic pi Mini PCAtomic pi Mini PC
Atomic pi Mini PC
 
Atomic PI apug
Atomic PI apugAtomic PI apug
Atomic PI apug
 
I made some more expansion board for M5Stack
I made some more expansion  board for M5StackI made some more expansion  board for M5Stack
I made some more expansion board for M5Stack
 
Project ACRN GPIO mediator introduction
Project ACRN GPIO mediator introductionProject ACRN GPIO mediator introduction
Project ACRN GPIO mediator introduction
 
Ls catalog thiet bi tu dong gm e_0908_dienhathe.vn
Ls catalog thiet bi tu dong gm e_0908_dienhathe.vnLs catalog thiet bi tu dong gm e_0908_dienhathe.vn
Ls catalog thiet bi tu dong gm e_0908_dienhathe.vn
 
Ls catalog thiet bi tu dong gm e_0908
Ls catalog thiet bi tu dong gm e_0908Ls catalog thiet bi tu dong gm e_0908
Ls catalog thiet bi tu dong gm e_0908
 
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
 
Raspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentRaspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application Development
 
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRaspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
 
Led blinking using TMS320C6745
Led blinking using TMS320C6745Led blinking using TMS320C6745
Led blinking using TMS320C6745
 
Openwrt, linux e GPIO al LinuxDay 2010 Roma
Openwrt, linux e GPIO al LinuxDay 2010 RomaOpenwrt, linux e GPIO al LinuxDay 2010 Roma
Openwrt, linux e GPIO al LinuxDay 2010 Roma
 
PPT+.pdf
PPT+.pdfPPT+.pdf
PPT+.pdf
 
ELC North America 2021 Introduction to pin muxing and gpio control under linux
ELC  North America 2021 Introduction to pin muxing and gpio control under linuxELC  North America 2021 Introduction to pin muxing and gpio control under linux
ELC North America 2021 Introduction to pin muxing and gpio control under linux
 
Arduino Microcontroller
Arduino MicrocontrollerArduino Microcontroller
Arduino Microcontroller
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218
 
eece237lab2EECE237Lab2.uvproj 1.1 ### uVision .docx
eece237lab2EECE237Lab2.uvproj    1.1   ### uVision .docxeece237lab2EECE237Lab2.uvproj    1.1   ### uVision .docx
eece237lab2EECE237Lab2.uvproj 1.1 ### uVision .docx
 
plc_training_manual.pdf
plc_training_manual.pdfplc_training_manual.pdf
plc_training_manual.pdf
 

Plus de Benux Wei

F9 microkernel app development part 1
F9 microkernel app development part 1F9 microkernel app development part 1
F9 microkernel app development part 1Benux Wei
 
F9 microkernel code reading part 4 memory management
F9 microkernel code reading part 4 memory managementF9 microkernel code reading part 4 memory management
F9 microkernel code reading part 4 memory managementBenux Wei
 
F9 Microkernel code reading part 2 scheduling
F9 Microkernel code reading part 2 schedulingF9 Microkernel code reading part 2 scheduling
F9 Microkernel code reading part 2 schedulingBenux Wei
 
While software engineer meets 3d printer
While software engineer meets 3d printerWhile software engineer meets 3d printer
While software engineer meets 3d printerBenux Wei
 
F9 Microkernel code reading - part 1
F9 Microkernel code reading - part 1F9 Microkernel code reading - part 1
F9 Microkernel code reading - part 1Benux Wei
 
Real practice of Networking design on specialized for ARM Cortex-M
Real practice of Networking design on specialized for ARM Cortex-MReal practice of Networking design on specialized for ARM Cortex-M
Real practice of Networking design on specialized for ARM Cortex-MBenux Wei
 
Tdd with python unittest for embedded c
Tdd with python unittest for embedded cTdd with python unittest for embedded c
Tdd with python unittest for embedded cBenux Wei
 
Stm32 f4 first touch
Stm32 f4 first touchStm32 f4 first touch
Stm32 f4 first touchBenux Wei
 
Preparation for mit ose lab4
Preparation for mit ose lab4Preparation for mit ose lab4
Preparation for mit ose lab4Benux Wei
 

Plus de Benux Wei (9)

F9 microkernel app development part 1
F9 microkernel app development part 1F9 microkernel app development part 1
F9 microkernel app development part 1
 
F9 microkernel code reading part 4 memory management
F9 microkernel code reading part 4 memory managementF9 microkernel code reading part 4 memory management
F9 microkernel code reading part 4 memory management
 
F9 Microkernel code reading part 2 scheduling
F9 Microkernel code reading part 2 schedulingF9 Microkernel code reading part 2 scheduling
F9 Microkernel code reading part 2 scheduling
 
While software engineer meets 3d printer
While software engineer meets 3d printerWhile software engineer meets 3d printer
While software engineer meets 3d printer
 
F9 Microkernel code reading - part 1
F9 Microkernel code reading - part 1F9 Microkernel code reading - part 1
F9 Microkernel code reading - part 1
 
Real practice of Networking design on specialized for ARM Cortex-M
Real practice of Networking design on specialized for ARM Cortex-MReal practice of Networking design on specialized for ARM Cortex-M
Real practice of Networking design on specialized for ARM Cortex-M
 
Tdd with python unittest for embedded c
Tdd with python unittest for embedded cTdd with python unittest for embedded c
Tdd with python unittest for embedded c
 
Stm32 f4 first touch
Stm32 f4 first touchStm32 f4 first touch
Stm32 f4 first touch
 
Preparation for mit ose lab4
Preparation for mit ose lab4Preparation for mit ose lab4
Preparation for mit ose lab4
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

Dernier (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

F9 microkernel app development part 2 gpio meets led

  • 1. Part 2: GPIO meets LED ben6 2014-04-21 F9-Microkernel App Development
  • 2. Agenda • Why we have to know GPIO? • What’s GPIO? • How to use GPIO? F9
  • 3. Why we have to know GPIO? Basis of external hardware control GPIO (General-purpose input/output) Storage devices NICs Buttons LED …
  • 4. Agenda • Why we have to know GPIO? • What’s GPIO? – F9 GPIO API for basic app – Code reading about F9 GPIO Hooks • How to use GPIO? F9
  • 5. What’s GPIO? • GPIO -- General-purpose input/output – Generic pin on a chip whose behavior can be controlled by the user at run time – Support DMA (Direct Memory Access) control
  • 7. GPIO input • Floating: unknown voltage input stage • Pull-up: connect to high voltage • Pull-down: connected to ground • Non-analog mode: input data register (GPIO_IDR) Memory Devices gpio_input_bit(port, pin) { if (*GPIO_IDR(port) & (1 << pin)) return 1; return 0; }
  • 8. GPIO output • push-pull with pull-up/pull-down • open-drain with pull-up/pull-down • Non-analog mode, output data register (GPIO_ODR) Memory Devices *GPIO_ODR(GPIOA) |= (1 << pin);
  • 9. Agenda • Why we have to know GPIO? • What’s GPIO? – F9 GPIO API for basic app – Code reading about F9 GPIO Hooks • How to use GPIO? F9
  • 10. PR #86 GPIO V1 implementation Kernel part • include/thread.h • include/user-gpioer.h • kernel/ipc.c • kernel/user-gpioer.c App part: library and app • user/apps/gpioer/main.c • user/include/gpioer.h • user/lib/io/gpioer.c Pull request#86 https://github.com/f9micro/f9-kernel/pull/86 GPIO V2: Kernel part GPIO driver code will move to user-space because this part violates L4 design principle GPIO V2: How to make thread has authority to access AHB1_1DEV?
  • 11. V1: F9 GPIO API for basic app • Defined in user/include/gpioer.h • gpioer_config_output • gpioer_out void gpioer_config_output(uint8_t port, uint8_t pin, uint8_t pupd, uint8_t speed); void gpioer_out(uint8_t port, uint8_t pin, uint8_t action);
  • 12. V1: gpioer_config_output void gpioer_config_output( uint8_t port, /* Ex: GPIOA, … , GPIOD, …*/ uint8_t pin, /* 0 – 15 */ uint8_t pupd, /* GPIO_PUPDR_UP */ uint8_t speed /* GPIO_PUPDR_UP,GPIO_OSPEEDR_50M */ ); Wrap gpio_config_output from include/platform/stm32f4/gpio.h
  • 13. GPIO Output Type #define GPIO_OTYPER_PP (uint32_t (0x0) /* Output push-pull */ #define GPIO_OTYPER_OD (uint32_t)(0x1) /* Output open drain */ include/platform/stm32f4/registers.h
  • 14. GPIO Speed #define GPIO_OSPEEDR_2M (uint32_t) (0x0) /* Output speed 2MHz */ #define GPIO_OSPEEDR_25M (uint32_t) (0x1) /* Output speed 25MHz */ #define GPIO_OSPEEDR_50M (uint32_t) (0x2) /* Output speed 50MHz */ #define GPIO_OSPEEDR_100M(uint32_t) (0x3) /* Output speed 100MHz*/ include/platform/stm32f4/registers.h
  • 15. V1: gpioer_out void gpioer_out(uint8_t port, uint8_t pin, uint8_t action /* GPIO_HIGH or GPIO_LOW */ ); Wrap gpio_out_high and gpio_out_low from include/platform/stm32f4/gpio.h
  • 16. Agenda • Why we have to know GPIO? • What’s GPIO? – F9 GPIO API for basic app – Code reading about F9 GPIO Hooks • How to use GPIO? F9
  • 17. Code reading of GPIO for user part • user/include/gpioer.h • user/lib/io/gpioer.c
  • 18. Code reading about F9 GPIO Hooks – include/thread.h – include/user-gpioer.h – kernel/build.mk – kernel/ipc.c – kernel/user-gpioer.c Implementation of this hook by reference the THREAD_LOG printf function
  • 19. Agenda • Why we have to know GPIO? • What’s GPIO? • How to use GPIO? – First f9 GPIO app practice to control led light – Lab3: make led blinking in turns F9
  • 20. First f9 GPIO app practice to control led light • PR86 – https://github.com/f9micro/f9-kernel/pull/86 • Demo 1. built-in 4 LEDs Blinking 2. trigger External LED
  • 21. Live Demo 1: built-in 4 LEDs Blinking
  • 22. STM32F407 Built-in 4 User LEDs LD3 (orange) LD4 (green) LD5 (red) LD6 (blue) PD13 PD12 PD14 PD15
  • 23. Live Demo 2: trigger External LED
  • 24. Lab 3: LEDs blinking Rocks Requirements – Modify LED sample to let the led in turns – Blinking interval 2 seconds Hints: reference user/apps/gpioer/main.c git clone https://github.com/benwei/f9-kernel.git git checkout 0421-gpioer
  • 25. Summary: Points recall • GPIO is the basis of external control • What’s implementation of GPIO api for user app • Easy to use API for gpioer for pin output control
  • 27. References • F9 Microkernel source code and introduction • GCC Naked Attribute • ARM: Memory Model of Cortex M4 • Cortex™ -M4 Devices Generic User Guide pdf • General-purpose Input/Output (GPIO) • UM1472 User manual Discovery kit for STM32F407/417 lines • STM32F4-Discovery 中文使用手冊

Notes de l'éditeur

  1. 其實日常使用設備裡都有 GPIO,小到 LED 燈號,大到各式外接設備,大多都會使用到 GPIO。通常我們program使用的data都是放在memory比較多,而GPIO也提供類似的操作方法給programmer(讓我們去更改記憶體內容就可以去控制pin,並影響周遭設備的運行),但真正的設備的位置並非真正落在記憶體上(如:LED、Button、…等),故GPIO的核心是記憶體操作與設備之間的一些電路特性。
  2. Typically, A GPIO port is grouped 8 GPIO pinsGPIO雖然建立起記憶體與設備之間的橋梁,但也並非我們就可以隨意使用,我們必須要經過設定之後才能讓我們想要的設備正常工作。一個pin通常可被設定成input、output、alternatefunction或analog,input會有兩種狀態表現(floating, pull-up/down),output也有兩種狀態表現(push-pull with pull-up/pull-down or open drain with pull-up/down)。input/output方向解說 : input是指記憶體方接收來自設備的訊號源,output是指記憶體傳送訊號給設備。當pin被設定成input時,非analog的設定下,我們可以利用GPIO的input data register(GPIOx_IDR) 或是memory中提供給目標設備的data register (當設成alternatefunction的時候)去接收data。當pin被設定成output時,非analog的設定下,GPIO本身有提供output data register (GPIOx_ODR)來對目標設備做控制,但要是pin不是使用原本預先定義好的功能時(非預先定義的功能都算是alternate function的類別),此時要用memory中,另外規劃給目標設備用的register。如果pin被設成analog的話,無論input or output都會由adc那邊做處理。
  3. floating vs. pull-up/pull-down當input pin被處在高阻抗的模式下,若沒有外部訊號源進來的話,此時是無法確定pin的狀態(不能確定現在處在高電位或低電位),除非有外部訊號來驅動電路。換句話說,input floating,這個input電位狀態完全是由外部訊號來決定,沒有訊號驅動的話,就會呈現高阻抗狀態。剛剛提到floating在沒有外部訊號驅動的情況下是呈現高阻抗狀態(無法確定電位狀態=&gt;不能明確表示現在值是0或1),如果我們需要這個pin有一個明確的預設狀態時,必須借助pull-up(pull-down)resistor來做調整,在pull-up resistor(pull-up外接高電壓,pull-down通常會接地)加入之下,讓pin的維持在明確的高電壓狀態(pull-down則是讓pin維持在低電壓狀態)。舉例來說,如果我們定電壓在3-4 V之間是1的狀態,0-1之間是0的狀態,高阻抗的時候,電壓是不明確的,有可能電壓值會落在1-3之間的不明確地帶,甚至是沒有在任何一個狀態維持一段時間,此時的狀態是未定的,但如果我們加入pull-up resistor的話,這個pin接受來自pull-up另一端的電壓供應,讓pin至少維持在3v以上時,我們就可以確定在沒有外部訊號驅動時,pin是維持在高電位狀態。
  4. Typically, A GPIO port is grouped 8 GPIO pinsGPIO雖然建立起記憶體與設備之間的橋梁,但也並非我們就可以隨意使用,我們必須要經過設定之後才能讓我們想要的設備正常工作。一個pin通常可被設定成input、output、alternatefunction或analog,input會有兩種狀態表現(floating, pull-up/down),output也有兩種狀態表現(push-pull with pull-up/pull-down or open drain with pull-up/down)。input/output方向解說 : input是指記憶體方接收來自設備的訊號源,output是指記憶體傳送訊號給設備。當pin被設定成input時,非analog的設定下,我們可以利用GPIO的input data register(GPIOx_IDR) 或是memory中提供給目標設備的data register (當設成alternatefunction的時候)去接收data。當pin被設定成output時,非analog的設定下,GPIO本身有提供output data register (GPIOx_ODR)來對目標設備做控制,但要是pin不是使用原本預先定義好的功能時(非預先定義的功能都算是alternate function的類別),此時要用memory中,另外規劃給目標設備用的register。如果pin被設成analog的話,無論input or output都會由adc那邊做處理。
  5. GPIO_OTYPER_PP
  6. 而push-pull输出的优势是速度快,因为线路是以两种方式驱动的。而带了上拉电阻的线路,即使以最快的速度去提升电压,最快也要一个常量的R×C的时间。其中R是电阻,C是寄生电容(parasitic capacitance),包括了pin脚的电容和板子的电容。但是,push-pull相对的缺点是往往需要消耗更多的电流,即功耗相对大。而open-drain所消耗的电流相对较小,由电阻R所限制,而R不能太小,因为当输出为低电平的时候,需要sink更低的transistor,这意味着更高的功耗。而open-drain的好处之一是,允许你short多个open-drain的电路,共用一个上拉电阻,此种做法称为wired-OR连接,此时可以通过拉低任何一个IO的pin脚使得输出为低电平。为了输出高电平,则所有的都输出高电平。此种逻辑,就是“线与”的功能,可以不需要额外的门电路来实现此部分逻辑。http://www.douban.com/note/206867792/
  7. 一些有預設控制元件的腳位(詳見- STM32F4-Discovery 中文使用手冊P.16)LD3:橙色,連接到STM32F407VGT6的PD13LD4:綠色,連接到STM32F407VGT6的PD12LD5:红色,連接到STM32F407VGT6的PD14LD6:藍色,連接到STM32F407VGT6的PD15B1(USER):連接到STM32F407VGT6的PA0B2(RESET):連接到NRST,用於重置STM32F407VGT6