amiro-os / modules / PowerManagement_1-1 / board.c @ 10fd7ac9
History | View | Annotate | Download (5.78 KB)
| 1 | e545e620 | Thomas Schöpping | /*
|
|---|---|---|---|
| 2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
| 3 | 84f0ce9e | Thomas Schöpping | Copyright (C) 2016..2019 Thomas Schöpping et al.
|
| 4 | e545e620 | Thomas Schöpping | |
| 5 | This program is free software: you can redistribute it and/or modify
|
||
| 6 | it under the terms of the GNU General Public License as published by
|
||
| 7 | the Free Software Foundation, either version 3 of the License, or
|
||
| 8 | (at your option) any later version.
|
||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful,
|
||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
| 13 | GNU General Public License for more details.
|
||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License
|
||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
| 17 | */
|
||
| 18 | |||
| 19 | 53710ca3 | Marc Rothmann | /**
|
| 20 | 37bacabf | Thomas Schöpping | * @file
|
| 21 | 53710ca3 | Marc Rothmann | * @brief PowerManagement v1.1 Board specific initializations.
|
| 22 | *
|
||
| 23 | * @addtogroup powermanagement_board
|
||
| 24 | * @{
|
||
| 25 | */
|
||
| 26 | |||
| 27 | e545e620 | Thomas Schöpping | #include <hal.h> |
| 28 | 0128be0f | Marc Rothmann | #include <stm32_gpio.h> |
| 29 | e545e620 | Thomas Schöpping | |
| 30 | cda14729 | Thomas Schöpping | /*===========================================================================*/
|
| 31 | /* Driver local definitions. */
|
||
| 32 | /*===========================================================================*/
|
||
| 33 | 0128be0f | Marc Rothmann | |
| 34 | cda14729 | Thomas Schöpping | /*===========================================================================*/
|
| 35 | /* Driver exported variables. */
|
||
| 36 | /*===========================================================================*/
|
||
| 37 | 0128be0f | Marc Rothmann | |
| 38 | cda14729 | Thomas Schöpping | /*===========================================================================*/
|
| 39 | /* Driver local variables and types. */
|
||
| 40 | /*===========================================================================*/
|
||
| 41 | |||
| 42 | /*===========================================================================*/
|
||
| 43 | /* Driver local functions. */
|
||
| 44 | /*===========================================================================*/
|
||
| 45 | 0128be0f | Marc Rothmann | |
| 46 | /**
|
||
| 47 | * @brief GPIO initialization.
|
||
| 48 | *
|
||
| 49 | 37bacabf | Thomas Schöpping | * @param[in] gpiop GPIO register block.
|
| 50 | * @param[in] moder Mode register configuration.
|
||
| 51 | * @param[in] otyper Otype register configuration.
|
||
| 52 | * @param[in] ospeedr Ospeed register configuration.
|
||
| 53 | * @param[in] pupdr Pupd register configuration.
|
||
| 54 | * @param[in] odr OD register configuration.
|
||
| 55 | * @param[in] afrl AF register (low) configuration.
|
||
| 56 | * @param[in] afrh AF register (high ) configuration.
|
||
| 57 | 0128be0f | Marc Rothmann | */
|
| 58 | acc97cbf | Thomas Schöpping | static void _gpio_init(stm32_gpio_t *gpiop, |
| 59 | 37bacabf | Thomas Schöpping | const uint32_t moder,
|
| 60 | const uint32_t otyper,
|
||
| 61 | const uint32_t ospeedr,
|
||
| 62 | const uint32_t pupdr,
|
||
| 63 | const uint32_t odr,
|
||
| 64 | const uint32_t afrl,
|
||
| 65 | 340f2bdf | Thomas Schöpping | const uint32_t afrh) {
|
| 66 | |||
| 67 | gpiop->OTYPER = otyper; |
||
| 68 | gpiop->OSPEEDR = ospeedr; |
||
| 69 | gpiop->PUPDR = pupdr; |
||
| 70 | gpiop->ODR = odr; |
||
| 71 | gpiop->AFRL = afrl; |
||
| 72 | gpiop->AFRH = afrh; |
||
| 73 | gpiop->MODER = moder; |
||
| 74 | |||
| 75 | return;
|
||
| 76 | 0128be0f | Marc Rothmann | } |
| 77 | |||
| 78 | /**
|
||
| 79 | * @brief GPIO initilization for all ports.
|
||
| 80 | */
|
||
| 81 | acc97cbf | Thomas Schöpping | static void _stm32_gpio_init(void) { |
| 82 | 0128be0f | Marc Rothmann | |
| 83 | /* Enabling GPIO-related clocks, the mask comes from the
|
||
| 84 | registry header file.*/
|
||
| 85 | rccResetAHB1(STM32_GPIO_EN_MASK); |
||
| 86 | rccEnableAHB1(STM32_GPIO_EN_MASK, true);
|
||
| 87 | |||
| 88 | /* Initializing all the defined GPIO ports.*/
|
||
| 89 | #if STM32_HAS_GPIOA
|
||
| 90 | 340f2bdf | Thomas Schöpping | _gpio_init(GPIOA, VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR, VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH); |
| 91 | 0128be0f | Marc Rothmann | #endif
|
| 92 | #if STM32_HAS_GPIOB
|
||
| 93 | 340f2bdf | Thomas Schöpping | _gpio_init(GPIOB, VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR, VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH); |
| 94 | 0128be0f | Marc Rothmann | #endif
|
| 95 | #if STM32_HAS_GPIOC
|
||
| 96 | 340f2bdf | Thomas Schöpping | _gpio_init(GPIOC, VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR, VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH); |
| 97 | 0128be0f | Marc Rothmann | #endif
|
| 98 | #if STM32_HAS_GPIOD
|
||
| 99 | 340f2bdf | Thomas Schöpping | _gpio_init(GPIOD, VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR, VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH); |
| 100 | 0128be0f | Marc Rothmann | #endif
|
| 101 | #if STM32_HAS_GPIOE
|
||
| 102 | 340f2bdf | Thomas Schöpping | _gpio_init(GPIOE, VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR, VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH); |
| 103 | 0128be0f | Marc Rothmann | #endif
|
| 104 | #if STM32_HAS_GPIOF
|
||
| 105 | 340f2bdf | Thomas Schöpping | _gpio_init(GPIOF, VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR, VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH); |
| 106 | 0128be0f | Marc Rothmann | #endif
|
| 107 | #if STM32_HAS_GPIOG
|
||
| 108 | 340f2bdf | Thomas Schöpping | _gpio_init(GPIOG, VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR, VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH); |
| 109 | 0128be0f | Marc Rothmann | #endif
|
| 110 | #if STM32_HAS_GPIOH
|
||
| 111 | 340f2bdf | Thomas Schöpping | _gpio_init(GPIOH, VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR, VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH); |
| 112 | 0128be0f | Marc Rothmann | #endif
|
| 113 | #if STM32_HAS_GPIOI
|
||
| 114 | 340f2bdf | Thomas Schöpping | _gpio_init(GPIOI, VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR, VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRL); |
| 115 | e545e620 | Thomas Schöpping | #endif
|
| 116 | 0128be0f | Marc Rothmann | #if STM32_HAS_GPIOJ
|
| 117 | 340f2bdf | Thomas Schöpping | _gpio_init(GPIOJ, VAL_GPIOJ_MODER, VAL_GPIOJ_OTYPER, VAL_GPIOJ_OSPEEDR, VAL_GPIOJ_PUPDR, VAL_GPIOJ_ODR, VAL_GPIOJ_AFRL, VAL_GPIOJ_AFRH); |
| 118 | 0128be0f | Marc Rothmann | #endif
|
| 119 | #if STM32_HAS_GPIOK
|
||
| 120 | 340f2bdf | Thomas Schöpping | _gpio_init(GPIOK, VAL_GPIOK_MODER, VAL_GPIOK_OTYPER, VAL_GPIOK_OSPEEDR, VAL_GPIOK_PUPDR, VAL_GPIOK_ODR, VAL_GPIOK_AFRL, VAL_GPIOK_AFRH); |
| 121 | 0128be0f | Marc Rothmann | #endif
|
| 122 | } |
||
| 123 | e545e620 | Thomas Schöpping | |
| 124 | cda14729 | Thomas Schöpping | /*===========================================================================*/
|
| 125 | /* Driver interrupt handlers. */
|
||
| 126 | /*===========================================================================*/
|
||
| 127 | |||
| 128 | /*===========================================================================*/
|
||
| 129 | /* Driver exported functions. */
|
||
| 130 | /*===========================================================================*/
|
||
| 131 | |||
| 132 | e545e620 | Thomas Schöpping | /**
|
| 133 | * @brief Early initialization code.
|
||
| 134 | * @details This initialization must be performed just after stack setup
|
||
| 135 | * and before any other initialization.
|
||
| 136 | */
|
||
| 137 | void __early_init(void) { |
||
| 138 | |||
| 139 | acc97cbf | Thomas Schöpping | _stm32_gpio_init(); |
| 140 | e545e620 | Thomas Schöpping | stm32_clock_init(); |
| 141 | } |
||
| 142 | |||
| 143 | /**
|
||
| 144 | * @brief Board-specific initialization code.
|
||
| 145 | * @todo Add your board-specific code, if any.
|
||
| 146 | */
|
||
| 147 | void boardInit(void) { |
||
| 148 | } |
||
| 149 | 53710ca3 | Marc Rothmann | |
| 150 | /** @} */ |