-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
2,678 additions
and
2,369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,301 @@ | ||
# EC-student | ||
|
||
# EC HAL Documentation | ||
--- | ||
|
||
https://github.com/ykkimhgu/EC-student/blob/main/docs/EC_HAL_Documentation.md | ||
# Embedded Controller - STM32f411 HAL API | ||
|
||
Documentation for HAL functions | ||
|
||
Written by: 000 | ||
|
||
Course: 임베디드컨트롤러 | ||
|
||
|
||
|
||
Program: C/C++ | ||
|
||
IDE/Compiler: Keil uVision 5 | ||
|
||
OS: WIn10 | ||
|
||
MCU: STM32F411RE (Nucleo-64) | ||
|
||
|
||
|
||
--- | ||
|
||
[TOC] | ||
|
||
* [GPIO Digital In/Out](#gpio-digital-inout) | ||
+ [Header File](#header-file) | ||
+ [GPIO_init\(\)](#gpio-init----) | ||
+ [GPIO_mode\(\)](#gpio-mode----) | ||
+ [GPIO_write\(\)](#gpio-write----) | ||
+ [GPIO_read\(\)](#gpio-read----) | ||
+ [GPIO_ospeed\(\)](#gpio-ospeed----) | ||
+ [GPIO_otype\(\)](#gpio-otype----) | ||
+ [GPIO_pupdr\(\)](#gpio-pupdr----) | ||
|
||
--- | ||
|
||
## GPIO Digital InOut | ||
|
||
### Header File | ||
|
||
`#include "ecGPIO.h"` | ||
|
||
|
||
```c++ | ||
#include "stm32f411xe.h" | ||
#include "ecRCC.h" | ||
|
||
#ifndef __ECGPIO_H | ||
#define __ECGPIO_H | ||
|
||
// MODER | ||
#define INPUT 0x00 | ||
#define OUTPUT 0x01 | ||
#define AF 0x02 | ||
#define ANALOG 0x03 | ||
|
||
// IDR & ODR | ||
#define HIGH 1 | ||
#define LOW 0 | ||
|
||
// OSPEED | ||
#define LOW_SPEED 0x00 | ||
#define MID_SPEED 0x01 | ||
#define FAST_SPEED 0x02 | ||
#define HIGH_SPEED 0x03 | ||
|
||
// OTYPER | ||
#define PUSH_PULL 0 // Push-pull | ||
#define OPEN_DRAIN 1 // Open-Drain | ||
|
||
// PUDR | ||
#define NO_PUPD 0x00 // No pull-up, pull-down | ||
#define PULL_UP 0x01 // Pull-up | ||
#define PULL_DOWN 0x02 // Pull-down | ||
#define RESERVED 0x03 // Reserved | ||
|
||
// PIN | ||
#define LED_PIN 5 | ||
#define BUTTON_PIN 13 | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif /* __cplusplus */ | ||
|
||
void GPIO_init(GPIO_TypeDef *Port, int pin, int mode); | ||
void GPIO_mode(GPIO_TypeDef* Port, int pin, int mode); | ||
void GPIO_write(GPIO_TypeDef *Port, int pin, int output); | ||
int GPIO_read(GPIO_TypeDef *Port, int pin); | ||
void GPIO_ospeed(GPIO_TypeDef* Port, int pin, int speed); | ||
void GPIO_otype(GPIO_TypeDef* Port, int pin, int type); | ||
void GPIO_pupdr(GPIO_TypeDef* Port, int pin, int pupd); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif /* __cplusplus */ | ||
|
||
#endif | ||
``` | ||
### GPIO_init\(\) | ||
Initializes GPIO pins with default setting and Enables GPIO Clock. Mode: In/Out/AF/Analog | ||
```c++ | ||
void GPIO_init(GPIO_TypeDef *Port, int pin, int mode); | ||
``` | ||
|
||
**Parameters** | ||
|
||
* **Port:** Port Number, GPIOA~GPIOH | ||
|
||
* **pin**: pin number (int) 0~15 | ||
|
||
* **mode**: INPUT(0), OUTPUT(1), AF(02), ANALOG (03) | ||
|
||
|
||
|
||
**Example code** | ||
|
||
```c++ | ||
GPIO_init(GPIOA, 5, OUTPUT); | ||
GPIO_init(GPIOC, 13, INPUT); //GPIO_init(GPIOC, 13, 0); | ||
``` | ||
### GPIO_mode\(\) | ||
Configures GPIO pin modes: In/Out/AF/Analog | ||
```c++ | ||
void GPIO_init(GPIO_TypeDef *Port, int pin, int mode); | ||
``` | ||
|
||
**Parameters** | ||
|
||
* **Port:** Port Number, GPIOA~GPIOH | ||
|
||
* **pin**: pin number (int) 0~15 | ||
|
||
* **mode**: INPUT (0), OUTPUT (1), AF(02), ANALOG (03) | ||
|
||
|
||
|
||
**Example code** | ||
|
||
```c++ | ||
GPIO_mode(GPIOA, 5, OUTPUT); | ||
``` | ||
### GPIO_write\(\) | ||
Write the data to GPIO pin: High, Low | ||
```c++ | ||
write(GPIO_TypeDef *Port, int pin, int output); | ||
``` | ||
|
||
**Parameters** | ||
|
||
* **Port:** Port Number, GPIOA~GPIOH | ||
* **pin**: pin number (int) 0~15 | ||
* **output**: LOW(0), HIGH(1) | ||
|
||
|
||
|
||
**Example code** | ||
|
||
```c++ | ||
GPIO_write(GPIOA, 5, 1); // 1: High | ||
``` | ||
### GPIO_read\(\) | ||
Read the data from GPIO pin | ||
```c++ | ||
int GPIO_read(GPIO_TypeDef *Port, int pin); | ||
``` | ||
|
||
**Parameters** | ||
|
||
* **Port:** Port Number, GPIOA~GPIOH | ||
* **pin**: pin number (int) 0~15 | ||
|
||
|
||
|
||
**Example code** | ||
|
||
```c++ | ||
GPIO_read(GPIOC, 13); | ||
``` | ||
### GPIO_ospeed\(\) | ||
Configures output speed of GPIO pin : Low, Mid, Fast, High | ||
```c++ | ||
void GPIO_ospeed(GPIO_TypeDef* Port, int pin, int speed); | ||
``` | ||
|
||
**Parameters** | ||
|
||
* **Port:** Port Number, GPIOA~GPIOH | ||
* **pin**: pin number (int) 0~15 | ||
* **speed**: LOW_SPEED(0), MID_SPEED(1), FAST_SPEED(2) , HIGH_SPEED(3) | ||
|
||
|
||
|
||
**Example code** | ||
|
||
```c++ | ||
GPIO_ospeed(GPIOA, 5, 2); // 2: FAST_SPEED | ||
``` | ||
### GPIO_otype\(\) | ||
Configures output type of GPIO pin: Push-Pull / Open-Drain | ||
```c++ | ||
void GPIO_otype(GPIO_TypeDef* Port, int pin, int type); | ||
``` | ||
|
||
**Parameters** | ||
|
||
* **Port:** Port Number, GPIOA~GPIOH | ||
* **pin**: pin number (int) 0~15 | ||
* **type**: PUSH_PULL(0), OPEN_DRAIN(1) | ||
|
||
|
||
|
||
**Example code** | ||
|
||
```c++ | ||
GPIO_otype(GPIOA, 5, 0); // 0: Push-Pull | ||
``` | ||
### GPIO_pupdr\(\) | ||
Configures Pull-up/Pull-down mode of GPIO pin: No Pull-up, Pull-down/ Pull-up/ Pull-down/ Reserved | ||
```c++ | ||
void GPIO_pupdr(GPIO_TypeDef* Port, int pin, int pupd); | ||
``` | ||
|
||
**Parameters** | ||
|
||
* **Port:** Port Number, GPIOA~GPIOH | ||
* **pin**: pin number (int) 0~15 | ||
* **pupd**: NO_PUPD(0), PULL_UP(1), PULL_DOWN(2), RESERVED(3) | ||
|
||
|
||
|
||
**Example code** | ||
|
||
```c++ | ||
GPIO_pupdr(GPIOA, 5, 0); // 0: No Pull-up, Pull-down | ||
``` | ||
------ | ||
## Class or Header name | ||
### Function Name | ||
```text | ||
``` | ||
|
||
**Parameters** | ||
|
||
* p1 | ||
* p2 | ||
|
||
**Example code** | ||
|
||
```text | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
# EC-student | ||
# EC-student | ||
|
||
|
||
|
||
Your own library of STM32F4 go here | ||
|
||
* header and definition files (*.h, *.c) | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.