| ... | ... | @@ -21,7 +21,7 @@ typedef struct |
|
|
|
volatile uint32_t AFR[2];
|
|
|
|
} GPIO_TypeDef;
|
|
|
|
```
|
|
|
|
Remmeber that strcut member's are allocated to consecutive addresses in memory.
|
|
|
|
Remember that strcut members are allocated to consecutive addresses in memory.
|
|
|
|
|
|
|
|
In order to access a specific register (address) we need a pointer to a `GPIO_TypeDef` structure.
|
|
|
|
Assuming we want to control the `GPIOA` port and that it can be found at `0x48000000`:
|
| ... | ... | @@ -30,7 +30,7 @@ Assuming we want to control the `GPIOA` port and that it can be found at `0x4800 |
|
|
|
```
|
|
|
|
By simply changing the pointer address we can access to different GPIO ports.
|
|
|
|
|
|
|
|
Via *bitwise operations* we can modify single bits of the GPIO registers:
|
|
|
|
Via _bitwise operations_ we can modify single bits of the GPIO registers:
|
|
|
|
```cpp
|
|
|
|
// set 5th bit of ODR to 1
|
|
|
|
GPIOA->ODR |= (1 << 4);
|
| ... | ... | @@ -66,10 +66,9 @@ The available pin modes and speeds can be found in the |
|
|
|
If you want to know more about GPIOs, check out the [GPIO Tutorial - Miosix Wiki](https://miosix.org/wiki/index.php?title=GPIO_tutorial) page.
|
|
|
|
|
|
|
|
## GPIO Drivers
|
|
|
|
|
|
|
|
Lukily for us, Miosix provides all the needed drivers for manipulate the GPIOs and enabling all their possible functionalities and configurations.
|
|
|
|
|
|
|
|
##### 1. Template API
|
|
|
|
#### 1. Template API
|
|
|
|
To use a pin in your board you can simply do:
|
|
|
|
```cpp
|
|
|
|
// define pin PA5 as somePin
|
| ... | ... | @@ -98,7 +97,7 @@ somePin::alternateFunction(5); // Specify the alternate function number |
|
|
|
```
|
|
|
|
The above method provides *optimal performance*.
|
|
|
|
|
|
|
|
##### 2. GpioPin Class
|
|
|
|
#### 2. GpioPin Class
|
|
|
|
As an alternative you can use the `GpioPin` class.
|
|
|
|
```cpp
|
|
|
|
GpioPin somePin(GPIOA_BASE, 5);
|
| ... | ... | @@ -122,7 +121,7 @@ somePin.alternateFunction(5); |
|
|
|
> ```
|
|
|
|
|
|
|
|
## Discovery Board Pins
|
|
|
|
These are some commonly used pins that you'll need when writing software for **Discovery boards**.
|
|
|
|
These are some commonly used pins that you'll need when writing software for _Discovery boards_.
|
|
|
|
|
|
|
|
#### STM32F429ZI Discovery
|
|
|
|
|
| ... | ... | @@ -147,7 +146,7 @@ You can find a complete pin usage description [here](https://os.mbed.com/platfor |
|
|
|
You can find more in the [user manual](http://www.st.com/content/ccc/resource/technical/document/user_manual/70/fe/4a/3f/e7/e1/4f/7d/DM00039084.pdf/files/DM00039084.pdf/jcr:content/translations/en.DM00039084.pdf) for more.
|
|
|
|
|
|
|
|
## Miosix Used Pins
|
|
|
|
These are some pins that are used by default from the kernel when running on **STM32 micros** (all paths are referred to `/libs/miosix-kernel/miosix`):
|
|
|
|
These are some pins that are used by default from the kernel when running on _STM32 micros_ (all paths are referred to `/libs/miosix-kernel/miosix`):
|
|
|
|
|
|
|
|
- SD memory: `arch/common/drivers/sd_stm32f2_f4.cpp`
|
|
|
|
|
| ... | ... | |