├── COPYING.GPL3.txt ├── COPYING.LGPL3.txt ├── README.txt ├── bits ├── adc.tcc ├── afio.tcc ├── bkp.tcc ├── can.tcc ├── cec.tcc ├── clock.tcc ├── crc.tcc ├── cryp.tcc ├── dac.tcc ├── dbg.tcc ├── dcmi.tcc ├── device_select.tcc ├── dma.tcc ├── eth.tcc ├── exti.tcc ├── flash.tcc ├── fpu.tcc ├── fsmc.tcc ├── gpio.tcc ├── hash.tcc ├── i2c.tcc ├── iwdg.tcc ├── l3gd20.tcc ├── lsm303dlhc.tcc ├── mpu.tcc ├── nvic.tcc ├── pwr.tcc ├── rcc.tcc ├── rng.tcc ├── rtc.tcc ├── scb.tcc ├── sccb.tcc ├── sdio.tcc ├── servo.tcc ├── spi.tcc ├── stk.tcc ├── syscfg.tcc ├── tim.tcc ├── usart.tcc ├── usb_fs.tcc ├── usb_hs.tcc └── wwdg.tcc ├── demo ├── adc_single.hpp ├── dma_usart_tx.hpp ├── f4dev │ ├── configure_bluetooth.hpp │ ├── led.hpp │ ├── led_blink.hpp │ ├── marg.hpp │ ├── marg_printf.hpp │ ├── ov7670 │ │ ├── binary_single_shot.hpp │ │ ├── hex_single_shot.hpp │ │ └── scan_sccb.hpp │ ├── readme.txt │ ├── robbie.hpp │ ├── uart_bluetooth.hpp │ └── uart_usb.hpp ├── f4discovery │ ├── led.hpp │ ├── led_wheel.hpp │ └── readme.txt ├── fpu_math.hpp ├── gpio_pin.hpp ├── printf.hpp ├── servo.hpp ├── servo_usart.hpp ├── tim_blink_led.hpp ├── usart_serialport.hpp └── vldiscovery │ ├── led.hpp │ ├── led_blink.hpp │ ├── readme.txt │ └── user_button.hpp ├── include ├── bitband.hpp ├── cfunctions.hpp ├── clock.hpp ├── core.hpp ├── core │ ├── fpu.hpp │ ├── mpu.hpp │ ├── nvic.hpp │ ├── scb.hpp │ └── stk.hpp ├── defs.hpp ├── device_select.hpp ├── driver.hpp ├── driver │ ├── l3gd20.hpp │ ├── lsm303dlhc.hpp │ ├── sccb.hpp │ └── servo.hpp ├── interrupt.hpp ├── interrupt_cpp.hpp ├── peripheral.hpp ├── peripheral │ ├── adc.hpp │ ├── afio.hpp │ ├── bkp.hpp │ ├── can.hpp │ ├── cec.hpp │ ├── crc.hpp │ ├── cryp.hpp │ ├── dac.hpp │ ├── dbg.hpp │ ├── dcmi.hpp │ ├── dma.hpp │ ├── eth.hpp │ ├── exti.hpp │ ├── flash.hpp │ ├── fsmc.hpp │ ├── gpio.hpp │ ├── hash.hpp │ ├── i2c.hpp │ ├── iwdg.hpp │ ├── pwr.hpp │ ├── rcc.hpp │ ├── rng.hpp │ ├── rtc.hpp │ ├── sdio.hpp │ ├── spi.hpp │ ├── syscfg.hpp │ ├── tim.hpp │ ├── usart.hpp │ ├── usb_fs.hpp │ ├── usb_hs.hpp │ └── wwdg.hpp ├── system_call.hpp └── system_call_cpp.hpp └── memorymap ├── adc.hpp ├── afio.hpp ├── bkp.hpp ├── can.hpp ├── cec.hpp ├── common.hpp ├── crc.hpp ├── cryp.hpp ├── dac.hpp ├── dbg.hpp ├── dcmi.hpp ├── dma.hpp ├── eth.hpp ├── exti.hpp ├── flash.hpp ├── fpu.hpp ├── fsmc.hpp ├── gpio.hpp ├── hash.hpp ├── i2c.hpp ├── iwdg.hpp ├── l3gd20.hpp ├── lsm303dlhc.hpp ├── mpu.hpp ├── nvic.hpp ├── pwr.hpp ├── rcc.hpp ├── rng.hpp ├── rtc.hpp ├── scb.hpp ├── sdio.hpp ├── spi.hpp ├── stk.hpp ├── syscfg.hpp ├── tim.hpp ├── usart.hpp ├── usb_fs.hpp ├── usb_hs.hpp └── wwdg.hpp /README.txt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | ABOUT 23 | ===== 24 | 25 | libstm32pp is a template peripheral library for the STM32F1/STM32F2/STM32F4 26 | family of microcontrollers(uC). 27 | 28 | This library is written in C++, and uses heavily template metaprogramming, 29 | statics assertions, templates and enumerators. 30 | 31 | All these features provide a memory efficient implementation, compile-time 32 | error-checking and strong typing. 33 | 34 | INSTALLATION AND USE 35 | ==================== 36 | 37 | There is no installation, this is a header file only library. 38 | 39 | To use this library, simply link the libstm32pp/include folder to your source. 40 | 41 | The following files are important: 42 | 43 | + device_select.hpp Here the microcontroller family must be selected. 44 | (uncomment the family you are going to use) 45 | 46 | + clock.hpp Here the uC clocks can be configured. 47 | (be sure to call clk::initialize() as soon as possible 48 | in your program) 49 | 50 | + interrupt_cpp.hpp This is actually a source file that configures the uC 51 | interrupts. 52 | (include this file in a source file .cpp) 53 | 54 | + system_call_cpp.hpp This is actually a source file that implements the 55 | newlib hardware dependant functions. 56 | (include this file in a source file .cpp) 57 | 58 | Check the "demo" folder for examples. 59 | 60 | An editor with auto-complete feature is highly recommended for development using 61 | this library. 62 | 63 | If you need an open source framework for development of these families of uCs, 64 | you should check the bareCortexM project: 65 | 66 | (https://github.com/JorgeAparicio/bareCortexM) 67 | 68 | It's a framework based on the Eclipse IDE and the GCC toolchain, for bare metal 69 | development of Cortex™ M Series processors. 70 | 71 | LICENSE 72 | ======= 73 | 74 | This project is licensed under the: 75 | 76 | GNU Lesser General Public License (LGPL) version 3. 77 | 78 | See COPYING.GPL3.txt and COPYING.LGPL3.txt for more details. 79 | 80 | DISCLAIMER 81 | ========== 82 | 83 | Cortex™ is a trademark of ARM Limited. ST, STM32 are trademarks of 84 | STMicroelectronics. All other trademarks are property of their respective 85 | owners. 86 | -------------------------------------------------------------------------------- /bits/afio.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace afio { 27 | void Functions::enableClock() 28 | { 29 | RCC::enableClocks(); 30 | } 31 | 32 | void Functions::disableClock() 33 | { 34 | RCC::disableClocks(); 35 | } 36 | 37 | template < 38 | exticr::States PORT, 39 | u8 PIN 40 | > 41 | void Functions::configureExti() 42 | { 43 | reinterpret_cast(ADDRESS)->EXTICR[PIN / 4] &= 44 | exticr::MASK << (exticr::POSITION * (PIN % 4)); 45 | 46 | reinterpret_cast(ADDRESS)->EXTICR[PIN / 4] |= 47 | PORT << (exticr::POSITION * (PIN % 4)); 48 | } 49 | 50 | } // namespace afio 51 | -------------------------------------------------------------------------------- /bits/bkp.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace bkp { 27 | void Functions::enableClock() 28 | { 29 | RCC::enableClocks(); 30 | } 31 | 32 | void Functions::disableClock() 33 | { 34 | RCC::disableClocks(); 35 | } 36 | } // namespace bkp 37 | -------------------------------------------------------------------------------- /bits/can.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace can { 27 | template
28 | void Functions::enableClocks() 29 | { 30 | switch (C) { 31 | #if defined CONNECTIVITY_LINE || not defined STM32F1XX 32 | case CAN1: 33 | RCC::enableClocks(); 34 | break; 35 | case CAN2: 36 | RCC::enableClocks(); 37 | break; 38 | #else // !CONNECTIVTY_LINE || STM32F1XX 39 | case CAN: 40 | RCC::enableClocks(); 41 | break; 42 | #endif // !CONNECTIVITY_LINE 43 | } 44 | } 45 | 46 | template
47 | void Functions::disableClocks() 48 | { 49 | switch (C) { 50 | #if defined CONNECTIVITY_LINE || not defined STM32F1XX 51 | case CAN1: 52 | RCC::disableClocks(); 53 | break; 54 | case CAN2: 55 | RCC::disableClocks(); 56 | break; 57 | #else // !CONNECTIVTY_LINE || STM32F1XX 58 | case CAN: 59 | RCC::disableClocks(); 60 | break; 61 | #endif // !CONNECTIVITY_LINE 62 | } 63 | } 64 | } // namespace can 65 | -------------------------------------------------------------------------------- /bits/cec.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace cec { 27 | void Functions::enableClock() 28 | { 29 | RCC::enableClocks(); 30 | } 31 | 32 | void Functions::disableClock() 33 | { 34 | RCC::disableClocks(); 35 | } 36 | } // namespace can 37 | -------------------------------------------------------------------------------- /bits/crc.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace crc { 27 | void Functions::enableClock() 28 | { 29 | #ifndef STM32F1XX 30 | RCC::enableClocks(); 31 | #else // !STM32F1XX 32 | RCC::enableClocks(); 33 | #endif // !STM32F1XX 34 | } 35 | 36 | void Functions::disableClock() 37 | { 38 | #ifndef STM32F1XX 39 | RCC::disableClocks(); 40 | #else // !STM32F1XX 41 | RCC::disableClocks(); 42 | #endif // !STM32F1XX 43 | } 44 | } // namespace crc 45 | -------------------------------------------------------------------------------- /bits/cryp.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace cryp { 27 | void Functions::enableClock() 28 | { 29 | RCC::enableClocks(); 30 | } 31 | 32 | void Functions::disableClock() 33 | { 34 | RCC::disableClocks(); 35 | } 36 | } // namespace cryp 37 | -------------------------------------------------------------------------------- /bits/dac.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace dac { 27 | void Functions::enableClock() 28 | { 29 | RCC::enableClocks(); 30 | } 31 | 32 | void Functions::disableClock() 33 | { 34 | RCC::disableClocks(); 35 | } 36 | } // namespace dac 37 | -------------------------------------------------------------------------------- /bits/dbg.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | namespace dbg { 25 | // DBG function implementation 26 | }// namespace dbg 27 | -------------------------------------------------------------------------------- /bits/device_select.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | // Must select at least one family 25 | #if not defined STM32F1XX && \ 26 | not defined STM32F2XX && \ 27 | not defined STM32F4XX 28 | #error "Must select at least one family." 29 | #endif 30 | 31 | // No more than one device family allowed 32 | #if (defined STM32F1XX && defined STM32F2XX) || \ 33 | (defined STM32F1XX && defined STM32F4XX) || \ 34 | (defined STM32F2XX && defined STM32F4XX) || \ 35 | (defined VALUE_LINE && defined CONNECTIVITY_LINE) || \ 36 | (defined VALUE_LINE && defined XL_DENSITY) || \ 37 | (defined CONNECTIVITY_LINE && defined XL_DENSITY) 38 | #error "More than one device family selected." 39 | #endif 40 | 41 | 42 | -------------------------------------------------------------------------------- /bits/eth.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace eth { 27 | void Functions::enableClocks() 28 | { 29 | #ifndef STM32F1XX 30 | RCC::enableClocks< 31 | rcc::ahb1enr::ETH_MAC, 32 | rcc::ahb1enr::ETH_MAC_TX, 33 | rcc::ahb1enr::ETH_MAC_RX, 34 | rcc::ahb1enr::ETH_MAC_PTP 35 | >(); 36 | #else // !STM32F1XX 37 | RCC::enableClocks< 38 | rcc::ahbenr::ETH_MAC, 39 | rcc::ahbenr::ETH_MAC_TX, 40 | rcc::ahbenr::ETH_MAC_RX 41 | >(); 42 | #endif // STM32F1XX 43 | } 44 | 45 | void Functions::disableClocks() 46 | { 47 | #ifndef STM32F1XX 48 | RCC::disableClocks< 49 | rcc::ahb1enr::ETH_MAC, 50 | rcc::ahb1enr::ETH_MAC_TX, 51 | rcc::ahb1enr::ETH_MAC_RX, 52 | rcc::ahb1enr::ETH_MAC_PTP 53 | >(); 54 | #else // !STM32F1XX 55 | RCC::disableClocks< 56 | rcc::ahbenr::ETH_MAC, 57 | rcc::ahbenr::ETH_MAC_TX, 58 | rcc::ahbenr::ETH_MAC_RX 59 | >(); 60 | #endif // STM32F1XX 61 | } 62 | } // namespace eth 63 | -------------------------------------------------------------------------------- /bits/fpu.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | namespace fpu { 25 | 26 | void Functions::enableFullAccess() 27 | { 28 | _FPU->CPACR = cpacr::cp10::FULL_ACCESS + 29 | cpacr::cp11::FULL_ACCESS; 30 | } 31 | 32 | void Functions::enablePrivilegedAccess() 33 | { 34 | _FPU->CPACR = cpacr::cp10::PRIVILEGED_ACCESS + 35 | cpacr::cp11::PRIVILEGED_ACCESS; 36 | } 37 | 38 | void Functions::disable() 39 | { 40 | _FPU->CPACR = 0; 41 | } 42 | 43 | } // namespace fpu 44 | -------------------------------------------------------------------------------- /bits/fsmc.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace fsmc { 27 | void Functions::enableClock() 28 | { 29 | #ifndef STM32F1XX 30 | RCC::enableClocks(); 31 | #else // STM32F1XX 32 | #ifndef CONNECTIVITY_LINE 33 | RCC::enableClocks(); 34 | #endif // CONNECTIVITY_LINE 35 | #endif // STM32F1XX 36 | } 37 | 38 | void Functions::disableClock() 39 | { 40 | #ifndef STM32F1XX 41 | RCC::disableClocks(); 42 | #else // STM32F1XX 43 | #ifndef CONNECTIVITY_LINE 44 | RCC::disableClocks(); 45 | #endif // CONNECTIVITY_LINE 46 | #endif // STM32F1XX 47 | } 48 | } // namespace fsmc 49 | -------------------------------------------------------------------------------- /bits/hash.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace hash { 27 | void Functions::enableClock() 28 | { 29 | RCC::enableClocks(); 30 | } 31 | 32 | void Functions::disableClock() 33 | { 34 | RCC::disableClocks(); 35 | } 36 | } // namespace hash 37 | -------------------------------------------------------------------------------- /bits/iwdg.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | namespace iwdg { 25 | // TODO IWDG functions implementation 26 | } // namespace iwdg 27 | -------------------------------------------------------------------------------- /bits/l3gd20.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | namespace l3gd20 { 25 | template< 26 | i2c::Address I, 27 | Address A 28 | > 29 | void Functions::configure( 30 | l3gd20::ctrl1::xen::States XEN, 31 | l3gd20::ctrl1::yen::States YEN, 32 | l3gd20::ctrl1::zen::States ZEN, 33 | l3gd20::ctrl1::pd::States PD, 34 | l3gd20::ctrl1::bw_odr::States DR_BW, 35 | l3gd20::ctrl4::sim::States SIM, 36 | l3gd20::ctrl4::fs::States FS, 37 | l3gd20::ctrl4::ble::States BLE, 38 | l3gd20::ctrl4::bdu::States BDU) 39 | { 40 | i2c::Standard::writeSlaveRegister( 41 | A, 42 | ctrl1::ADDRESS, 43 | PD + DR_BW + XEN + YEN + ZEN); 44 | i2c::Standard::writeSlaveRegister( 45 | A, 46 | ctrl4::ADDRESS, 47 | SIM + FS + BLE + BDU); 48 | } 49 | 50 | /** 51 | * @brief Reads the low byte of the X axis magnetic field. 52 | */ 53 | template 54 | u8 Functions::readXLow() 55 | { 56 | return i2c::Standard::readSlaveRegister( 57 | A, 58 | out_x_l::ADDRESS); 59 | } 60 | 61 | /** 62 | * @brief Reads the high byte of the X axis magnetic field. 63 | */ 64 | template 65 | u8 Functions::readXHigh() 66 | { 67 | return i2c::Standard::readSlaveRegister( 68 | A, 69 | out_x_h::ADDRESS); 70 | } 71 | 72 | /** 73 | * @brief Reads the low byte of the Y axis magnetic field. 74 | */ 75 | template 76 | u8 Functions::readYLow() 77 | { 78 | return i2c::Standard::readSlaveRegister( 79 | A, 80 | out_y_l::ADDRESS); 81 | } 82 | 83 | /** 84 | * @brief Reads the high byte of the Y axis magnetic field. 85 | */ 86 | template 87 | u8 Functions::readYHigh() 88 | { 89 | return i2c::Standard::readSlaveRegister( 90 | A, 91 | out_y_h::ADDRESS); 92 | } 93 | 94 | /** 95 | * @brief Reads the low byte of the Z axis magnetic field. 96 | */ 97 | template 98 | u8 Functions::readZLow() 99 | { 100 | return i2c::Standard::readSlaveRegister( 101 | A, 102 | out_z_l::ADDRESS); 103 | } 104 | 105 | /** 106 | * @brief Reads the high byte of the Z axis magnetic field. 107 | */ 108 | template 109 | u8 Functions::readZHigh() 110 | { 111 | return i2c::Standard::readSlaveRegister( 112 | A, 113 | out_z_h::ADDRESS); 114 | } 115 | 116 | } // namespace l3gd20 117 | -------------------------------------------------------------------------------- /bits/mpu.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | namespace mpu { 25 | // TODO MPU function implementations. 26 | } // namespace mpu 27 | -------------------------------------------------------------------------------- /bits/nvic.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | namespace nvic { 25 | /** 26 | * @brief Enables an interrupt request. 27 | */ 28 | template 29 | void Functions::enableIrq(void) 30 | { 31 | reinterpret_cast(ADDRESS)->ISER[I >> 5] = 1 << (I % 32); 32 | } 33 | 34 | /** 35 | * @brief Disables an interrupt request. 36 | */ 37 | template 38 | void Functions::disableIrq(void) 39 | { 40 | reinterpret_cast(ADDRESS)->ICER[I >> 5] = 1 << (I % 32); 41 | } 42 | 43 | /** 44 | * @brief Sets the interrupt priority level. 45 | * @note A lower priority number, means higher priority. 46 | */ 47 | template 48 | void Functions::setPriority() 49 | { 50 | static_assert(P % 32 == 31, 51 | "The priority number must have it 4 lower bits set to 1."); 52 | 53 | reinterpret_cast(ADDRESS)->IPR[I >> 2] &= 54 | irqn::MASK << (8 * (I % 4)); 55 | 56 | reinterpret_cast(ADDRESS)->IPR[I >> 2] |= 57 | P << (8 * (I % 4)); 58 | } 59 | } // namespace nvic 60 | -------------------------------------------------------------------------------- /bits/pwr.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/bitband.hpp" 25 | #include "../include/peripheral/rcc.hpp" 26 | 27 | namespace pwr { 28 | void Functions::enableClock() 29 | { 30 | RCC::enableClocks(); 31 | } 32 | 33 | void Functions::disableClock() 34 | { 35 | RCC::disableClocks(); 36 | } 37 | 38 | void Functions::enableBackupDomainWriteProtection() 39 | { 40 | *(u32 volatile*) (bitband::peripheral< 41 | ADDRESS + cr::OFFSET, 42 | cr::dbp::POSITION 43 | >()) = 1; 44 | } 45 | 46 | void Functions::disableBackupDomainWriteProtection() 47 | { 48 | *(u32 volatile*) (bitband::peripheral< 49 | ADDRESS + cr::OFFSET, 50 | cr::dbp::POSITION 51 | >()) = 0; 52 | } 53 | } // namespace pwr 54 | -------------------------------------------------------------------------------- /bits/rng.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | #include "../include/peripheral/rcc.hpp" 24 | 25 | namespace rng { 26 | /** 27 | * @brief Enables the Random Number Generator clock. 28 | * @note Registers can't be written when the clock is disabled. 29 | */ 30 | void Functions::enableClock() 31 | { 32 | RCC::enableClocks< 33 | rcc::ahb2enr::RNG 34 | >(); 35 | } 36 | 37 | /** 38 | * @brief Disables the Random Number Generator clock. 39 | * @note Registers can't be written when the clock is disabled. 40 | */ 41 | void Functions::disableClock() 42 | { 43 | RCC::disableClocks< 44 | rcc::ahb2enr::RNG 45 | >(); 46 | } 47 | 48 | /** 49 | * @brief Enables the Random Number Generator. 50 | */ 51 | void Functions::startGenerator() 52 | { 53 | RNG_REGS->CR |= 54 | cr::rngen::RANDOM_NUMBER_GENERATOR_ENABLED; 55 | } 56 | 57 | /** 58 | * @brief Disables the Random Number Generator. 59 | */ 60 | void Functions::stopGenerator() 61 | { 62 | RNG_REGS->CR &= 63 | ~cr::rngen::RANDOM_NUMBER_GENERATOR_ENABLED; 64 | } 65 | 66 | /** 67 | * @brief Enables the interrupt. 68 | */ 69 | void Functions::enableInterrupts() 70 | { 71 | RNG_REGS->CR |= 72 | cr::ie::INTERRUPT_ENABLED; 73 | } 74 | 75 | /** 76 | * @brief Disables the interrupt. 77 | */ 78 | void Functions::disableInterrupts() 79 | { 80 | RNG_REGS->CR &= 81 | ~cr::ie::INTERRUPT_ENABLED; 82 | } 83 | 84 | /** 85 | * @brief Gets a random number. 86 | * @note User should check if the random number is valid first. 87 | */ 88 | template 89 | T Functions::getValue() 90 | { 91 | return *(T*) (ADDRESS + dr::OFFSET); 92 | } 93 | 94 | /** 95 | * @brief Returns true if there is data ready to be read. 96 | */ 97 | bool Functions::isDataReady() 98 | { 99 | return (RNG_REGS->SR & 100 | sr::drdy::VALID_RANDOM_DATA_READY); 101 | } 102 | 103 | /** 104 | * @brief Returns true if the seed is valid. 105 | */ 106 | bool Functions::isSeedValid() 107 | { 108 | return (RNG_REGS->SR & sr::secs::SEED_OK); 109 | } 110 | 111 | /** 112 | * @brief Returns true if the clock is valid. 113 | */ 114 | bool Functions::isClockValid() 115 | { 116 | return (RNG_REGS->SR & sr::cecs::CLOCK_OK); 117 | } 118 | 119 | /** 120 | * @brief Clears the seed error flag. 121 | */ 122 | void Functions::clearSeedErrorFlag() 123 | { 124 | RNG_REGS->SR &= 125 | ~sr::seis::SEED_ERROR_DETECTED; 126 | } 127 | 128 | /** 129 | * @brief Clears the seed error flag. 130 | */ 131 | void Functions::clearClockErrorFlag() 132 | { 133 | RNG_REGS->SR &= 134 | ~sr::ceis::CLOCK_ERROR_DETECTED; 135 | } 136 | 137 | } // namespace rng 138 | -------------------------------------------------------------------------------- /bits/rtc.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | namespace rtc { 25 | 26 | }// namespace rtc 27 | -------------------------------------------------------------------------------- /bits/scb.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | namespace scb { 25 | // TODO SCB function implementations 26 | } // namespace scb 27 | -------------------------------------------------------------------------------- /bits/sdio.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace sdio { 27 | void Functions::enableClock() 28 | { 29 | RCC::enableClocks(); 30 | } 31 | 32 | void Functions::disableClock() 33 | { 34 | RCC::disableClocks(); 35 | } 36 | } // namespace sdio 37 | -------------------------------------------------------------------------------- /bits/stk.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | namespace stk { 25 | // TODO STK functions implementation 26 | }// namespace stk 27 | -------------------------------------------------------------------------------- /bits/syscfg.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/syscfg.hpp" 25 | 26 | namespace syscfg { 27 | /** 28 | * @brief Enables the System Configuration Controller clock. 29 | * @note Registers can't be written when the clock is disabled. 30 | */ 31 | void Functions::enableClock() 32 | { 33 | RCC::enableClocks< 34 | rcc::apb2enr::SYSCFG 35 | >(); 36 | } 37 | 38 | /** 39 | * @brief Disables the System Configuration Controller clock. 40 | * @note Registers can't be written when the clock is disabled. 41 | */ 42 | void Functions::disableClock() 43 | { 44 | RCC::disableClocks< 45 | rcc::apb2enr::SYSCFG 46 | >(); 47 | } 48 | 49 | /** 50 | * @brief Maps the selected pin to select EXTI line. 51 | */ 52 | template< 53 | u8 LINE, 54 | exticr::States EXTICR 55 | > 56 | void Functions::selectExtiPin() 57 | { 58 | static_assert(LINE < 16, 59 | "Only the first 16 EXTI lines can be mapped to GPIO pins"); 60 | 61 | SYSCFG_REGS->EXTICR[LINE / 4] &= 62 | (exticr::MASK << (4 * (LINE % 4))); 63 | 64 | SYSCFG_REGS->EXTICR[LINE / 4] |= EXTICR << (4 * (LINE % 4)); 65 | } 66 | } // namespace syscfg 67 | 68 | -------------------------------------------------------------------------------- /bits/usb_fs.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace usb_fs { 27 | void Functions::enableClock() 28 | { 29 | #ifdef CONNECTIVITY_LINE 30 | RCC::enableClocks< 31 | rcc::ahbenr::USB_OTG_FS 32 | >(); 33 | #else 34 | RCC::enableClocks< 35 | rcc::ahb2enr::USB_OTG_FS 36 | >(); 37 | #endif 38 | } 39 | 40 | void Functions::disableClock() 41 | { 42 | #ifdef CONNECTIVITY_LINE 43 | RCC::disableClocks< 44 | rcc::ahbenr::USB_OTG_FS 45 | >(); 46 | #else 47 | RCC::disableClocks< 48 | rcc::ahb2enr::USB_OTG_FS 49 | >(); 50 | #endif 51 | } 52 | } // namespace usb_fs 53 | -------------------------------------------------------------------------------- /bits/usb_hs.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace usb_hs { 27 | void Functions::enableClock() 28 | { 29 | RCC::enableClocks(); 30 | RCC::enableClocks(); 31 | } 32 | 33 | void Functions::disableClock() 34 | { 35 | RCC::disableClocks(); 36 | RCC::disableClocks(); 37 | } 38 | } // namespace usb_hs 39 | -------------------------------------------------------------------------------- /bits/wwdg.tcc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/peripheral/rcc.hpp" 25 | 26 | namespace wwdg { 27 | void Functions::enableClock() 28 | { 29 | RCC::enableClocks(); 30 | } 31 | 32 | void Functions::disableClock() 33 | { 34 | RCC::disableClocks(); 35 | } 36 | } // namespace wwdg 37 | 38 | -------------------------------------------------------------------------------- /demo/adc_single.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | //////////////////////////////////////////////////////////////////////////////// 25 | // Tested on STM32VLDISCOVERY 26 | // Tested on STM32F4DISCOVERY 27 | // Tested on F4Dev 28 | #include "clock.hpp" 29 | 30 | #include "peripheral/gpio.hpp" 31 | 32 | #include "peripheral/adc.hpp" 33 | 34 | u16 reading = 0; 35 | 36 | void initializeGpio() 37 | { 38 | PA0::enableClock(); 39 | #ifdef STM32F1XX 40 | PA0::setMode(gpio::cr::ANALOG_INPUT); 41 | #else 42 | PA0::setMode(gpio::moder::ANALOG); 43 | #endif 44 | } 45 | 46 | void initializeAdc() 47 | { 48 | ADC1::enableClock(); 49 | ADC1::configure( 50 | adc::cr1::awdch::SET_ANALOG_WATCHDOG_ON_CHANNEL0, 51 | adc::cr1::eocie::END_OF_CONVERSION_INTERRUPT_DISABLED, 52 | adc::cr1::awdie::ANALOG_WATCHDOG_INTERRUPT_DISABLED, 53 | adc::cr1::jeocie::END_OF_ALL_INJECTED_CONVERSIONS_INTERRUPT_DISABLED, 54 | adc::cr1::scan::SCAN_MODE_DISABLED, 55 | adc::cr1::awdsgl::ANALOG_WATCHDOG_ENABLED_ON_ALL_CHANNELS, 56 | adc::cr1::jauto::AUTOMATIC_INJECTED_CONVERSION_DISABLED, 57 | adc::cr1::discen::DISCONTINUOUS_MODE_ON_REGULAR_CHANNELS_DISABLED, 58 | adc::cr1::jdiscen::DISCONTINUOUS_MODE_ON_INJECTED_CHANNELS_DISABLED, 59 | adc::cr1::discnum::_1_CHANNEL_FOR_DISCONTINUOUS_MODE, 60 | adc::cr1::jawden::ANALOG_WATCHDOG_DISABLED_ON_INJECTED_CHANNELS, 61 | adc::cr1::awden::ANALOG_WATCHDOG_DISABLED_ON_REGULAR_CHANNELS, 62 | adc::cr1::res::_12_BITS_RESOLUTION, 63 | adc::cr1::ovrie::OVERRUN_INTERRUPT_DISABLED, 64 | adc::cr2::adon::ADC_ENABLED, 65 | adc::cr2::cont::SINGLE_CONVERSION_MODE, 66 | adc::cr2::dma::DMA_MODE_DISABLED, 67 | adc::cr2::dds::NO_NEW_DMA_REQUEST_IS_ISSUED_AFTER_THE_LAST_TRANSFER, 68 | adc::cr2::eocs::EOC_BIT_IS_SET_AFTER_A_SEQUENCE_OF_REGULAR_CONVERSIONS, 69 | adc::cr2::align::RIGTH_ALIGNED_DATA, 70 | adc::cr2::jextsel::INJECTED_GROUP_TRIGGERED_BY_TIMER1_CC4, 71 | adc::cr2::jexten::INJECTED_TRIGGER_DISABLED, 72 | adc::cr2::jswstart::INJECTED_CHANNELS_ON_RESET_STATE, 73 | adc::cr2::extsel::REGULAR_GROUP_TRIGGERED_BY_TIMER1_CC1, 74 | adc::cr2::exten::REGULAR_TRIGGER_DISABLED, 75 | adc::cr2::swstart::REGULAR_CHANNELS_ON_RESET_STATE); 76 | ADC1::setRegularSequenceOrder<1, 0>(); 77 | ADC1::setNumberOfRegularChannels<1>(); 78 | } 79 | 80 | void initializePeripherals() 81 | { 82 | initializeGpio(); 83 | initializeAdc(); 84 | } 85 | 86 | void loop() 87 | { 88 | // Test connecting the pin to VDD or VSS. 89 | ADC1::startRegularConversions(); 90 | 91 | while (!ADC1::hasRegularConversionEnded()) { 92 | } 93 | 94 | reading = ADC1::getConversionResult(); 95 | } 96 | 97 | int main() 98 | { 99 | clk::initialize(); 100 | 101 | initializePeripherals(); 102 | 103 | while (true) { 104 | loop(); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /demo/f4dev/led.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | #include "clock.hpp" 25 | 26 | #include "peripheral/gpio.hpp" 27 | 28 | typedef PC13 LED; 29 | 30 | void initializeGpio() 31 | { 32 | LED::enableClock(); 33 | LED::setMode(gpio::moder::OUTPUT); 34 | } 35 | 36 | void loop() 37 | { 38 | LED::setLow(); 39 | LED::setHigh(); 40 | } 41 | 42 | int main() 43 | { 44 | clk::initialize(); 45 | 46 | initializeGpio(); 47 | 48 | while (true) { 49 | loop(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /demo/f4dev/led_blink.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | #include "clock.hpp" 25 | 26 | #include "interrupt.hpp" 27 | 28 | #include "peripheral/gpio.hpp" 29 | 30 | typedef PC13 LED; 31 | 32 | #include "peripheral/tim.hpp" 33 | 34 | void initializeGpio() 35 | { 36 | LED::enableClock(); 37 | LED::setMode(gpio::moder::OUTPUT); 38 | } 39 | 40 | void initializeTimer() 41 | { 42 | TIM6::enableClock(); 43 | TIM6::configurePeriodicInterrupt< 44 | 8 /* Hz */ 45 | >(); 46 | } 47 | 48 | void initializePeripherals() 49 | { 50 | initializeGpio(); 51 | initializeTimer(); 52 | 53 | TIM6::startCounter(); 54 | } 55 | 56 | void loop() 57 | { 58 | 59 | } 60 | 61 | int main() 62 | { 63 | clk::initialize(); 64 | 65 | initializePeripherals(); 66 | 67 | while (true) { 68 | loop(); 69 | } 70 | } 71 | 72 | void interrupt::TIM6_DAC() 73 | { 74 | static u8 count = 0; 75 | 76 | TIM6::clearUpdateFlag(); 77 | 78 | if (count++ % 2) 79 | LED::setHigh(); 80 | else 81 | LED::setLow(); 82 | } 83 | -------------------------------------------------------------------------------- /demo/f4dev/readme.txt: -------------------------------------------------------------------------------- 1 | FOR THE F4DEV BOARD USE THIS CONFIGURATION: 2 | 3 | + device_select.h: Uncomment STM32F4XX 4 | + Linker script: stm32f407ve.ld 5 | + OpenOCD interface: ujtag.cfg 6 | + OpenOCD target: stm32f4x.cfg 7 | + GDB script: stm32f407ve.script or any of these: 8 | stm32f4_16kb.script, 9 | stm32f4_32kb.script, 10 | etc 11 | -------------------------------------------------------------------------------- /demo/f4discovery/led.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | #include "clock.hpp" 25 | 26 | #include "interrupt.hpp" 27 | 28 | #include "peripheral/gpio.hpp" 29 | 30 | typedef PD13 LD3; // ORANGE 31 | typedef PD12 LD4; // GREEN 32 | typedef PD14 LD5; // RED 33 | typedef PD15 LD6; // BLUE 34 | 35 | #include "peripheral/tim.hpp" 36 | 37 | void initializeGpio() 38 | { 39 | GPIOD::enableClock(); 40 | 41 | LD3::setMode(gpio::moder::OUTPUT); 42 | LD4::setMode(gpio::moder::OUTPUT); 43 | LD6::setMode(gpio::moder::OUTPUT); 44 | LD5::setMode(gpio::moder::OUTPUT); 45 | } 46 | 47 | void loop() 48 | { 49 | LD3::setLow(); 50 | LD4::setLow(); 51 | LD5::setLow(); 52 | LD6::setLow(); 53 | 54 | LD3::setHigh(); 55 | LD4::setHigh(); 56 | LD5::setHigh(); 57 | LD6::setHigh(); 58 | } 59 | 60 | int main() 61 | { 62 | clk::initialize(); 63 | 64 | initializeGpio(); 65 | 66 | while (true) { 67 | loop(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /demo/f4discovery/led_wheel.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | #include "clock.hpp" 25 | 26 | #include "interrupt.hpp" 27 | 28 | #include "peripheral/gpio.hpp" 29 | 30 | typedef PD13 LD3; // ORANGE 31 | typedef PD12 LD4; // GREEN 32 | typedef PD14 LD5; // RED 33 | typedef PD15 LD6; // BLUE 34 | 35 | #include "peripheral/tim.hpp" 36 | 37 | void initializeGpio() 38 | { 39 | GPIOD::enableClock(); 40 | 41 | LD3::setMode(gpio::moder::OUTPUT); 42 | LD4::setMode(gpio::moder::OUTPUT); 43 | LD6::setMode(gpio::moder::OUTPUT); 44 | LD5::setMode(gpio::moder::OUTPUT); 45 | } 46 | 47 | void initializeTimer() 48 | { 49 | TIM6::enableClock(); 50 | TIM6::configurePeriodicInterrupt< 51 | 8 /* Hz */ 52 | >(); 53 | } 54 | 55 | void initializePeripherals() 56 | { 57 | initializeGpio(); 58 | initializeTimer(); 59 | 60 | TIM6::startCounter(); 61 | } 62 | 63 | void loop() 64 | { 65 | 66 | } 67 | 68 | int main() 69 | { 70 | clk::initialize(); 71 | 72 | initializePeripherals(); 73 | 74 | while (true) { 75 | loop(); 76 | } 77 | } 78 | 79 | void interrupt::TIM6_DAC() 80 | { 81 | static u8 counter = 0; 82 | 83 | TIM6::clearUpdateFlag(); 84 | 85 | switch (counter++ % 4) { 86 | case 0: 87 | LD3::setHigh(); 88 | LD5::setLow(); 89 | break; 90 | case 1: 91 | LD3::setLow(); 92 | LD4::setHigh(); 93 | break; 94 | case 2: 95 | LD4::setLow(); 96 | LD6::setHigh(); 97 | break; 98 | case 3: 99 | LD6::setLow(); 100 | LD5::setHigh(); 101 | break; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /demo/f4discovery/readme.txt: -------------------------------------------------------------------------------- 1 | FOR THE STM32F4DISCOVERY BOARD USE THIS CONFIGURATION: 2 | 3 | + device_select.h: Uncomment STM32F4XX 4 | + Linker script: stm32f407vg.ld 5 | + OpenOCD interface: stlink-v2.cfg 6 | + OpenOCD target: stm32f4x_stlink.cfg 7 | + GDB script: stm32f407vg.script or any of these: 8 | stm32f4_16kb.script, 9 | stm32f4_32kb.script, 10 | etc 11 | -------------------------------------------------------------------------------- /demo/fpu_math.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | //////////////////////////////////////////////////////////////////////////////// 25 | // Tested on STM32F4DISCOVERY 26 | // Tested on F4Dev 27 | #include "clock.hpp" 28 | 29 | #include "core/fpu.hpp" 30 | 31 | #include 32 | 33 | #ifndef M_PI 34 | #define M_PI 3.14159265358979323846264338327 35 | #endif 36 | 37 | float debug = 1; 38 | 39 | void initializeFpu() 40 | { 41 | FPU::enableFullAccess(); 42 | } 43 | 44 | void loop() 45 | { 46 | debug *= 16; // 16.0 47 | debug = sqrtf(debug); // 4.0 48 | debug = 1 / debug; // .25 49 | debug = powf(debug, .5); // .5 50 | debug *= M_PI; // PI / 2 51 | debug = sinf(debug); // 1.0 52 | } 53 | 54 | int main() 55 | { 56 | clk::initialize(); 57 | 58 | initializeFpu(); 59 | 60 | while (true) { 61 | loop(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /demo/gpio_pin.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | //////////////////////////////////////////////////////////////////////////////// 25 | // Tested on STM32VLDISCOVERY 26 | // Tested on STM32F4DISCOVERY 27 | // Tested on F4Dev 28 | #include "clock.hpp" 29 | 30 | #include "peripheral/gpio.hpp" 31 | 32 | // Change this pin from PA0 to any other pin. 33 | typedef PA0 LED; 34 | 35 | void initializeGpio() 36 | { 37 | LED::enableClock(); 38 | #ifdef STM32F1XX 39 | LED::setMode(gpio::cr::GP_PUSH_PULL_10MHZ); 40 | #else // STM32F1XX 41 | LED::setMode(gpio::moder::OUTPUT); 42 | #endif // STM32F1XX 43 | } 44 | 45 | void loop() 46 | { 47 | LED::setLow(); 48 | LED::setHigh(); 49 | } 50 | 51 | int main() 52 | { 53 | clk::initialize(); 54 | 55 | initializeGpio(); 56 | 57 | while (true) { 58 | loop(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /demo/servo.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | //////////////////////////////////////////////////////////////////////////////// 25 | // Tested on STM32VLDISCOVERY 26 | // Tested on STM32F4DISCOVERY 27 | // Tested on F4Dev 28 | #include "clock.hpp" 29 | 30 | #include "interrupt.hpp" 31 | 32 | #include "peripheral/gpio.hpp" 33 | 34 | typedef PA0 Servo1; 35 | typedef PA1 Servo2; 36 | typedef PA2 Servo3; 37 | typedef PA3 Servo4; 38 | 39 | #include "driver/servo.hpp" 40 | 41 | servo::Functions< 42 | tim::TIM6, 43 | 50, // Hz 44 | tim::TIM7, 45 | 1500, // us 46 | 4 47 | > Servo; 48 | 49 | void initializeGpio() 50 | { 51 | #ifdef STM32F1XX 52 | Servo1::enableClock(); 53 | Servo1::setMode(gpio::cr::GP_PUSH_PULL_2MHZ); 54 | 55 | Servo2::enableClock(); 56 | Servo2::setMode(gpio::cr::GP_PUSH_PULL_2MHZ); 57 | 58 | Servo3::enableClock(); 59 | Servo3::setMode(gpio::cr::GP_PUSH_PULL_2MHZ); 60 | 61 | Servo4::enableClock(); 62 | Servo4::setMode(gpio::cr::GP_PUSH_PULL_2MHZ); 63 | #else 64 | Servo1::enableClock(); 65 | Servo1::setMode(gpio::moder::OUTPUT); 66 | 67 | Servo2::enableClock(); 68 | Servo2::setMode(gpio::moder::OUTPUT); 69 | 70 | Servo3::enableClock(); 71 | Servo3::setMode(gpio::moder::OUTPUT); 72 | 73 | Servo4::enableClock(); 74 | Servo4::setMode(gpio::moder::OUTPUT); 75 | #endif 76 | } 77 | 78 | void initializeServoController() 79 | { 80 | Servo.setPin(0, (u32*) (Servo1::OUT_ADDRESS)); 81 | Servo.setPin(1, (u32*) (Servo2::OUT_ADDRESS)); 82 | Servo.setPin(2, (u32*) (Servo3::OUT_ADDRESS)); 83 | Servo.setPin(3, (u32*) (Servo4::OUT_ADDRESS)); 84 | 85 | Servo.initialize(); 86 | } 87 | 88 | void initializePeripherals() 89 | { 90 | initializeGpio(); 91 | initializeServoController(); 92 | 93 | Servo.start(); 94 | } 95 | 96 | void loop() 97 | { 98 | // In debug mode: Modify the Servo.buffer variable. 99 | } 100 | 101 | int main(void) 102 | { 103 | clk::initialize(); 104 | 105 | initializePeripherals(); 106 | 107 | while (true) 108 | { 109 | loop(); 110 | } 111 | } 112 | 113 | #if defined VALUE_LINE || \ 114 | defined STM32F2XX || \ 115 | defined STM32F4XX 116 | void interrupt::TIM6_DAC() 117 | #else 118 | void interrupt::TIM6() 119 | #endif 120 | { 121 | Servo.onPeriodTimerInterrupt(); 122 | } 123 | 124 | void interrupt::TIM7() 125 | { 126 | Servo.onDutyCycleTimerInterrupt(); 127 | } 128 | -------------------------------------------------------------------------------- /demo/tim_blink_led.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | //////////////////////////////////////////////////////////////////////////////// 25 | // Tested on STM32VLDISCOVERY 26 | // Tested on STM32F4DISCOVERY 27 | // Tested on F4Dev 28 | #include "clock.hpp" 29 | 30 | #include "interrupt.hpp" 31 | 32 | #include "peripheral/gpio.hpp" 33 | 34 | typedef PA0 LED; 35 | 36 | #include "peripheral/tim.hpp" 37 | 38 | void initializeGpio() 39 | { 40 | LED::enableClock(); 41 | 42 | #ifdef STM32F1XX 43 | LED::setMode(gpio::cr::GP_PUSH_PULL_2MHZ); 44 | #else 45 | LED::setMode(gpio::moder::OUTPUT); 46 | #endif 47 | } 48 | 49 | void initializeTimer() 50 | { 51 | TIM6::enableClock(); 52 | TIM6::configurePeriodicInterrupt< 53 | 4 /* Hz */ 54 | >(); 55 | } 56 | 57 | void initializePeripherals() 58 | { 59 | initializeGpio(); 60 | initializeTimer(); 61 | 62 | TIM6::startCounter(); 63 | } 64 | 65 | void loop() 66 | { 67 | 68 | } 69 | 70 | int main() 71 | { 72 | clk::initialize(); 73 | 74 | initializePeripherals(); 75 | 76 | while (true) { 77 | loop(); 78 | } 79 | } 80 | 81 | #if defined VALUE_LINE || \ 82 | defined STM32F2XX || \ 83 | defined STM32F4XX 84 | void interrupt::TIM6_DAC() 85 | #else 86 | void interrupt::TIM6() 87 | #endif 88 | { 89 | static u8 counter = 0; 90 | 91 | TIM6::clearUpdateFlag(); 92 | 93 | if (counter++ % 2) 94 | LED::setHigh(); 95 | else 96 | LED::setLow(); 97 | } 98 | -------------------------------------------------------------------------------- /demo/usart_serialport.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | //////////////////////////////////////////////////////////////////////////////// 25 | // Tested on STM32VLDISCOVERY 26 | // Tested on F4Dev 27 | #define UART_BAUD_RATE 9600 28 | 29 | #include "clock.hpp" 30 | 31 | #include "interrupt.hpp" 32 | 33 | #include "peripheral/gpio.hpp" 34 | 35 | #include "peripheral/usart.hpp" 36 | 37 | typedef PA9 U1TX; 38 | typedef PA10 U1RX; 39 | 40 | const char msg[] = "Hello World!\n\r"; 41 | 42 | void initializeGpio() 43 | { 44 | GPIOA::enableClock(); 45 | 46 | #ifdef STM32F1XX 47 | U1TX::setMode(gpio::cr::AF_PUSH_PULL_2MHZ); 48 | 49 | U1RX::setMode(gpio::cr::FLOATING_INPUT); 50 | #else 51 | U1TX::setAlternateFunction(gpio::afr::USART1_3); 52 | U1TX::setMode(gpio::moder::ALTERNATE); 53 | 54 | U1RX::setAlternateFunction(gpio::afr::USART1_3); 55 | U1RX::setMode(gpio::moder::ALTERNATE); 56 | #endif 57 | } 58 | 59 | void initializeUsart() 60 | { 61 | USART1::enableClock(); 62 | USART1::configure( 63 | usart::cr1::rwu::RECEIVER_IN_ACTIVE_MODE, 64 | usart::cr1::re::RECEIVER_ENABLED, 65 | usart::cr1::te::TRANSMITTER_ENABLED, 66 | usart::cr1::idleie::IDLE_INTERRUPT_DISABLED, 67 | usart::cr1::rxneie::RXNE_ORE_INTERRUPT_DISABLED, 68 | usart::cr1::tcie::TC_INTERRUPT_DISABLED, 69 | usart::cr1::txeie::TXEIE_INTERRUPT_DISABLED, 70 | usart::cr1::peie::PEIE_INTERRUPT_DISABLED, 71 | usart::cr1::ps::EVEN_PARITY, 72 | usart::cr1::pce::PARITY_CONTROL_DISABLED, 73 | usart::cr1::wake::WAKE_ON_IDLE_LINE, 74 | usart::cr1::m::START_8_DATA_N_STOP, 75 | usart::cr1::ue::USART_ENABLED, 76 | usart::cr1::over8::OVERSAMPLING_BY_16, 77 | usart::cr2::stop::_1_STOP_BIT, 78 | usart::cr3::eie::ERROR_INTERRUPT_DISABLED, 79 | usart::cr3::hdsel::FULL_DUPLEX, 80 | usart::cr3::dmar::RECEIVER_DMA_DISABLED, 81 | usart::cr3::dmat::TRANSMITTER_DMA_DISABLED, 82 | usart::cr3::rtse::RTS_HARDWARE_FLOW_DISABLED, 83 | usart::cr3::ctse::CTS_HARDWARE_FLOW_DISABLED, 84 | usart::cr3::ctsie::CTS_INTERRUPT_DISABLED, 85 | usart::cr3::onebit::ONE_SAMPLE_BIT_METHOD); 86 | USART1::setBaudRate< 87 | UART_BAUD_RATE /* bps */ 88 | >(); 89 | } 90 | 91 | void initializePeripherals() 92 | { 93 | initializeGpio(); 94 | initializeUsart(); 95 | } 96 | 97 | void loop() 98 | { 99 | for (u8 i = 0; i < sizeof(msg); i++) { 100 | while (!USART1::canSendDataYet()) { 101 | } 102 | 103 | USART1::sendData(msg[i]); 104 | } 105 | } 106 | 107 | int main() 108 | { 109 | clk::initialize(); 110 | 111 | initializePeripherals(); 112 | 113 | while (true) { 114 | loop(); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /demo/vldiscovery/led.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | #include "clock.hpp" 25 | 26 | #include "peripheral/gpio.hpp" 27 | 28 | typedef PC9 LD3; // Green 29 | typedef PC8 LD4; // Blue 30 | 31 | void initializeGpio() 32 | { 33 | GPIOC::enableClock(); 34 | 35 | LD3::setMode(gpio::cr::GP_PUSH_PULL_10MHZ); 36 | LD4::setMode(gpio::cr::GP_PUSH_PULL_10MHZ); 37 | } 38 | 39 | void loop() 40 | { 41 | LD3::setLow(); 42 | LD4::setLow(); 43 | LD3::setHigh(); 44 | LD4::setHigh(); 45 | } 46 | 47 | int main() 48 | { 49 | clk::initialize(); 50 | 51 | initializeGpio(); 52 | 53 | while (true) { 54 | loop(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /demo/vldiscovery/led_blink.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | #include "clock.hpp" 25 | 26 | #include "interrupt.hpp" 27 | 28 | #include "peripheral/gpio.hpp" 29 | 30 | typedef PC8 LD4; // Blue 31 | typedef PC9 LD3; // Green 32 | 33 | #include "peripheral/tim.hpp" 34 | 35 | void initializeGpio() 36 | { 37 | GPIOC::enableClock(); 38 | 39 | LD4::setMode(gpio::cr::GP_PUSH_PULL_10MHZ); 40 | LD3::setMode(gpio::cr::GP_PUSH_PULL_10MHZ); 41 | } 42 | 43 | void initializeTimer() 44 | { 45 | TIM6::enableClock(); 46 | TIM6::configurePeriodicInterrupt< 47 | 8 /* Hz */ 48 | >(); 49 | } 50 | 51 | void initializePeripherals() 52 | { 53 | initializeGpio(); 54 | initializeTimer(); 55 | 56 | TIM6::startCounter(); 57 | } 58 | 59 | void loop() 60 | { 61 | 62 | } 63 | 64 | int main() 65 | { 66 | clk::initialize(); 67 | 68 | initializePeripherals(); 69 | 70 | while (true) { 71 | loop(); 72 | } 73 | } 74 | 75 | void interrupt::TIM6_DAC() 76 | { 77 | static u8 count = 0; 78 | 79 | TIM6::clearUpdateFlag(); 80 | 81 | if (count++ % 2) { 82 | LD3::setHigh(); 83 | LD4::setLow(); 84 | } else { 85 | LD3::setLow(); 86 | LD4::setHigh(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /demo/vldiscovery/readme.txt: -------------------------------------------------------------------------------- 1 | FOR THE STM32VLDISCOVERY BOARD USE THIS CONFIGURATION: 2 | 3 | + device_select.h: Uncomment STM32F1XX and VALUE_LINE 4 | + Linker script: stm32f100rb.ld 5 | + OpenOCD interface: stlink-v1.cfg 6 | + OpenOCD target: stm32f1x_stlink.cfg 7 | + GDB script: stm32vldiscovery.script** 8 | 9 | ** The flash protection of the device must be disabled or this configuration 10 | won't work. -------------------------------------------------------------------------------- /demo/vldiscovery/user_button.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | // DO NOT INCLUDE THIS FILE ANYWHERE. THIS DEMO IS JUST A REFERENCE TO BE USED 23 | // IN YOUR MAIN SOURCE FILE. 24 | #include "clock.hpp" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | typedef PA0 USER_BUTTON; 32 | typedef PC9 LD3; // Green 33 | typedef PC8 LD4; // Blue 34 | 35 | void configureLeds() 36 | { 37 | GPIOC::enableClock(); 38 | 39 | LD3::setMode(gpio::cr::GP_PUSH_PULL_2MHZ); 40 | LD4::setMode(gpio::cr::GP_PUSH_PULL_2MHZ); 41 | 42 | LD3::setHigh(); 43 | } 44 | 45 | void configureButton() 46 | { 47 | USER_BUTTON::enableClock(); 48 | 49 | USER_BUTTON::setMode(gpio::cr::AF_OPEN_DRAIN_2MHZ); 50 | // USER_BUTTON::pullDown(); // Button is already in pull-down! 51 | 52 | AFIO::configureExti< 53 | afio::exticr::PA, 54 | 0 55 | >(); // Maps EXTI0 to PA0. 56 | } 57 | 58 | void configureExti() 59 | { 60 | EXTI0::enableHardwareInterruptByRisingEdge(); 61 | EXTI0::unmaskInterrupt(); 62 | } 63 | 64 | void configure() 65 | { 66 | configureLeds(); 67 | configureButton(); 68 | 69 | configureExti(); 70 | } 71 | 72 | void loop() 73 | { 74 | // Nothing! 75 | } 76 | 77 | int main() 78 | { 79 | clk::initialize(); 80 | 81 | configure(); 82 | 83 | while(true) 84 | loop(); 85 | } 86 | 87 | void interrupt::EXTI0() 88 | { 89 | static u8 count = 0; 90 | 91 | EXTI0::clearPendingFlag(); 92 | 93 | if (count++ % 2) { 94 | LD3::setLow(); 95 | LD4::setHigh(); 96 | } else { 97 | LD3::setHigh(); 98 | LD4::setLow(); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /include/bitband.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "defs.hpp" 25 | #include "../memorymap/common.hpp" 26 | 27 | namespace bitband { 28 | template 29 | constexpr u32 peripheral() 30 | { 31 | static_assert( 32 | ((Address - alias::PERIPH) >= 0) && 33 | ((Address - alias::PERIPH) < 0x100000), 34 | "This is not a valid Peripheral address for bit-banding." 35 | ); 36 | 37 | static_assert(Bit < 32, "Only 32 bits can be bit-banded."); 38 | 39 | return PERIPH + ((Address - alias::PERIPH) << 5) + (Bit << 2); 40 | } 41 | 42 | template 43 | constexpr u32 ram() 44 | { 45 | static_assert( 46 | ((Address - alias::SRAM) >= 0) && 47 | ((Address - alias::SRAM) < 0x100000), 48 | "This is not a valid RAM address for bit-banding." 49 | ); 50 | 51 | static_assert(Bit < 32, "Only 32 bits can be bit-banded."); 52 | 53 | return SRAM + ((Address - alias::SRAM) << 5) + (Bit << 2); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /include/cfunctions.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | #include "defs.hpp" 24 | 25 | /** 26 | * @brief Summation of elements 27 | */ 28 | 29 | template 30 | struct cSum; 31 | 32 | template <> 33 | struct cSum<> { 34 | enum { 35 | value = 0 36 | }; 37 | }; 38 | 39 | template 40 | struct cSum { 41 | enum { 42 | value = cSum::value + first, 43 | }; 44 | }; 45 | 46 | /** 47 | * @brief Product of elements 48 | */ 49 | template 50 | struct cProduct; 51 | 52 | template <> 53 | struct cProduct<> { 54 | enum { 55 | value = 1 56 | }; 57 | }; 58 | 59 | template 60 | struct cProduct { 61 | enum { 62 | value = first * cProduct::value, 63 | }; 64 | }; 65 | 66 | /** 67 | * @brief Computes b ^ n. 68 | */ 69 | template 70 | struct cPow { 71 | enum { 72 | value = b * cPow::value, 73 | }; 74 | }; 75 | 76 | template 77 | struct cPow { 78 | enum { 79 | value = 1, 80 | }; 81 | }; 82 | 83 | /** 84 | * @brief Computes the factorial 85 | */ 86 | constexpr u32 cFactorial(u32 const N) 87 | { 88 | return N > 0? N * cFactorial(N - 1) : 1; 89 | } 90 | 91 | /** 92 | * @brief Prints as an error 93 | */ 94 | template struct _; 95 | #define cPrint(x) _ __ 96 | -------------------------------------------------------------------------------- /include/core.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "core/fpu.hpp" 25 | #include "core/mpu.hpp" 26 | #include "core/nvic.hpp" 27 | #include "core/scb.hpp" 28 | #include "core/stk.hpp" 29 | -------------------------------------------------------------------------------- /include/core/fpu.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Floating Point Unit 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/fpu.hpp" 34 | 35 | // Low-level access to the registers 36 | #define _FPU reinterpret_cast(fpu::ADDRESS) 37 | 38 | // High-level functions 39 | namespace fpu { 40 | class Functions { 41 | public: 42 | static inline void enableFullAccess(); 43 | static inline void enablePrivilegedAccess(); 44 | static inline void disable(); 45 | 46 | private: 47 | Functions(); 48 | }; 49 | } // namespace fpu 50 | 51 | // High-level access to the peripheral 52 | typedef fpu::Functions FPU; 53 | 54 | #include "../../bits/fpu.tcc" 55 | -------------------------------------------------------------------------------- /include/core/mpu.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Memory Protection Unit 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/mpu.hpp" 34 | 35 | // Low-level access to the registers 36 | #define _MPU reinterpret_cast(mpu::ADDRESS) 37 | 38 | // High-level functions 39 | namespace mpu { 40 | class Functions { 41 | public: 42 | // TODO MPU functions declaration 43 | private: 44 | Functions(); 45 | }; 46 | } // namespace mpu 47 | 48 | // High-level access to the peripheral 49 | // TODO MPU high-level access 50 | 51 | #include "../../bits/mpu.tcc" 52 | -------------------------------------------------------------------------------- /include/core/nvic.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Nested Vector Interrupt Controller 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | #include "../defs.hpp" 32 | 33 | #include "../../memorymap/nvic.hpp" 34 | 35 | // Low-level access to the registers 36 | #define _NVIC reinterpret_cast(nvic::ADDRESS) 37 | 38 | // High-level functions 39 | namespace nvic { 40 | class Functions { 41 | public: 42 | template< 43 | nvic::irqn::E I 44 | > 45 | static inline void enableIrq(); 46 | template< 47 | nvic::irqn::E I 48 | > 49 | static inline void disableIrq(); 50 | 51 | template< 52 | nvic::irqn::E I, u8 P 53 | > 54 | static inline void setPriority(); 55 | 56 | private: 57 | Functions(); 58 | }; 59 | } // namespace nvic 60 | 61 | // High-level access to the perihperal 62 | typedef nvic::Functions NVIC; 63 | 64 | #include "../../bits/nvic.tcc" 65 | -------------------------------------------------------------------------------- /include/core/scb.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * System Control Block 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/scb.hpp" 34 | 35 | // Low-level access to the registers 36 | #define _SCB reinterpret_cast(scb::ADDRESS) 37 | 38 | // High-level functions 39 | namespace scb { 40 | class Functions { 41 | public: 42 | // TODO SCB functions declaration 43 | private: 44 | Functions(); 45 | }; 46 | } // namespace scb 47 | 48 | // High-level access to the peripheral 49 | // TODO SCB high-level access 50 | 51 | #include "../../bits/scb.tcc" 52 | -------------------------------------------------------------------------------- /include/core/stk.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * System Timer 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | #include "../defs.hpp" 32 | 33 | #include "../../memorymap/stk.hpp" 34 | 35 | // Low-level access to the registers 36 | #define _STK reinterpret_cast(stk::ADDRESS) 37 | 38 | // High-level functions 39 | namespace stk { 40 | class Functions { 41 | public: 42 | // TODO STK functions declaration 43 | private: 44 | Functions(); 45 | }; 46 | } // namespace stk 47 | 48 | // High-level access to the peripheral 49 | // TODO STK high-level access 50 | 51 | #include "../../bits/stk.tcc" 52 | -------------------------------------------------------------------------------- /include/defs.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | typedef int8_t s8; 27 | typedef int16_t s16; 28 | typedef int32_t s32; 29 | typedef int64_t s64; 30 | 31 | typedef uint8_t u8; 32 | typedef uint16_t u16; 33 | typedef uint32_t u32; 34 | typedef uint64_t u64; 35 | 36 | // Read only permission 37 | #define __R volatile 38 | 39 | // Write only permission 40 | #define __W volatile 41 | 42 | // Read/Write permission 43 | #define __RW volatile 44 | -------------------------------------------------------------------------------- /include/device_select.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | /******************************************************************************* 25 | * 26 | * Select your target device below. 27 | * 28 | ******************************************************************************/ 29 | 30 | /** STM32F1 Device? ***********************************************************/ 31 | //#define STM32F1XX 32 | /********* Comment the macro above to answer no, otherwise your answer is yes */ 33 | 34 | #ifdef STM32F1XX 35 | 36 | /** Value Line Device? ********************************************************/ 37 | //#define VALUE_LINE 38 | /********* Comment the macro above to answer no, otherwise your answer is yes */ 39 | 40 | #ifndef VALUE_LINE 41 | 42 | /** Connectivity Line Device? *************************************************/ 43 | //#define CONNECTIVITY_LINE 44 | /********* Comment the macro above to answer no, otherwise your answer is yes */ 45 | 46 | #endif // VALUE_LINE 47 | #if not defined VALUE_LINE && \ 48 | not defined CONNECTIVITY_LINE 49 | 50 | /** XL-Density Device? ********************************************************/ 51 | //#define XL_DENSITY 52 | /********* Comment the macro above to answer no, otherwise your answer is yes */ 53 | 54 | #endif //!VALUE_LINE && !CONNECTIVITY_LINE 55 | #endif // STM32F1XX 56 | #ifndef STM32F1XX 57 | 58 | /** STM32F2 Device? ***********************************************************/ 59 | //#define STM32F2XX 60 | /********* Comment the macro above to answer no, otherwise your answer is yes */ 61 | 62 | #endif 63 | #if not defined STM32F1XX && \ 64 | not defined STM32F2XX 65 | 66 | /** STM32F4 Device? ***********************************************************/ 67 | #define STM32F4XX 68 | /********* Comment the macro above to answer no, otherwise your answer is yes */ 69 | 70 | #endif // !STM32F1XX && !STM32F2XX 71 | 72 | #include "../bits/device_select.tcc" 73 | -------------------------------------------------------------------------------- /include/driver.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "driver/l3gd20.hpp" 25 | #include "driver/lsm303dlhc.hpp" 26 | #include "driver/servo.hpp" 27 | #include "driver/sccb.hpp" 28 | -------------------------------------------------------------------------------- /include/driver/l3gd20.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * L3GD20: Three axis MEMS gyroscope 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | #include "../defs.hpp" 32 | 33 | #include "../../memorymap/l3gd20.hpp" 34 | #include "../include/peripheral/i2c.hpp" 35 | 36 | // High-level functions 37 | namespace l3gd20 { 38 | template< 39 | i2c::Address I, 40 | Address A 41 | > 42 | class Functions { 43 | public: 44 | static void configure( 45 | l3gd20::ctrl1::xen::States, 46 | l3gd20::ctrl1::yen::States, 47 | l3gd20::ctrl1::zen::States, 48 | l3gd20::ctrl1::pd::States, 49 | l3gd20::ctrl1::bw_odr::States, 50 | l3gd20::ctrl4::sim::States, 51 | l3gd20::ctrl4::fs::States, 52 | l3gd20::ctrl4::ble::States, 53 | l3gd20::ctrl4::bdu::States); 54 | 55 | static inline u8 readXLow(); 56 | static inline u8 readXHigh(); 57 | static inline u8 readYLow(); 58 | static inline u8 readYHigh(); 59 | static inline u8 readZLow(); 60 | static inline u8 readZHigh(); 61 | 62 | private: 63 | Functions(); 64 | }; 65 | } // namespace l3gd20 66 | 67 | #include "../../bits/l3gd20.tcc" 68 | -------------------------------------------------------------------------------- /include/driver/lsm303dlhc.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * LSM303DLHC: Three axis MEMS accelerometer + three axis MEMS magnetometer 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../include/peripheral/i2c.hpp" 34 | #include "../../memorymap/lsm303dlhc.hpp" 35 | 36 | // High-level functions 37 | namespace lsm303dlhc { 38 | namespace accelerometer { 39 | template 40 | class Functions { 41 | public: 42 | static void configure( 43 | lsm303dlhc::accelerometer::ctrl1::lpen::States, 44 | lsm303dlhc::accelerometer::ctrl1::odr::States, 45 | lsm303dlhc::accelerometer::ctrl1::xen::States, 46 | lsm303dlhc::accelerometer::ctrl1::yen::States, 47 | lsm303dlhc::accelerometer::ctrl1::zen::States, 48 | lsm303dlhc::accelerometer::ctrl4::sim::States, 49 | lsm303dlhc::accelerometer::ctrl4::hr::States, 50 | lsm303dlhc::accelerometer::ctrl4::fs::States, 51 | lsm303dlhc::accelerometer::ctrl4::ble::States, 52 | lsm303dlhc::accelerometer::ctrl4::bdu::States); 53 | 54 | static inline u8 readXLow(); 55 | static inline u8 readXHigh(); 56 | static inline u8 readYLow(); 57 | static inline u8 readYHigh(); 58 | static inline u8 readZLow(); 59 | static inline u8 readZHigh(); 60 | 61 | private: 62 | Functions(); 63 | }; 64 | } // namespace accelerometer 65 | 66 | namespace magnetometer { 67 | template 68 | class Functions { 69 | public: 70 | static void setDataRate(lsm303dlhc::magnetometer::cra::do_::States); 71 | static void setReadingRange(lsm303dlhc::magnetometer::crb::gn::States); 72 | static void setMode(lsm303dlhc::magnetometer::mr::md::States); 73 | static inline u8 readXLow(); 74 | static inline u8 readXHigh(); 75 | static inline u8 readYLow(); 76 | static inline u8 readYHigh(); 77 | static inline u8 readZLow(); 78 | static inline u8 readZHigh(); 79 | 80 | private: 81 | Functions(); 82 | }; 83 | } // namespace magnetometer 84 | 85 | namespace thermometer { 86 | template 87 | class Functions { 88 | public: 89 | static void disable(); 90 | static void enable(); 91 | 92 | private: 93 | Functions(); 94 | }; 95 | } // namespace thermometer 96 | } // namespace lsm303dlhc 97 | 98 | #include "../../bits/lsm303dlhc.tcc" 99 | -------------------------------------------------------------------------------- /include/driver/sccb.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../device_select.hpp" 25 | #include "../defs.hpp" 26 | 27 | #include "../peripheral/gpio.hpp" 28 | #include "../peripheral/tim.hpp" 29 | 30 | namespace sccb { 31 | template< 32 | gpio::Address SDIO_C_PORT, 33 | u8 SDIO_C_PIN, 34 | gpio::Address SDIO_D_PORT, 35 | u8 SDIO_D_PIN, 36 | tim::Address DELAY_TIMER_ADDRESS, 37 | u32 FREQUENCY 38 | > 39 | class Functions { 40 | enum { 41 | DELAY = 1000000 / (2 * FREQUENCY) 42 | }; 43 | 44 | static_assert(SDIO_C_PIN < 16, "Invalid GPIO pin."); 45 | static_assert(SDIO_D_PIN < 16, "Invalid GPIO pin."); 46 | static_assert(DELAY != 0, "Can't reach this frequency."); 47 | 48 | typedef gpio::Pin SDIO_C; 49 | typedef gpio::Pin SDIO_D; 50 | typedef tim::Functions TIMER; 51 | 52 | public: 53 | static inline void initialize(); 54 | static void sendStart(); 55 | static void sendStop(); 56 | static void sendNACK(); 57 | static bool sendByte(u8 const); 58 | static u8 getByte(); 59 | static bool writeSlaveRegister( 60 | u8 const slaveAddress, 61 | u8 const registerAddress, 62 | u8 const value); 63 | static bool readSlaveRegister( 64 | u8 const slaveAddress, 65 | u8 const registerAddress, 66 | u8& value); 67 | 68 | private: 69 | Functions(); 70 | }; 71 | } 72 | 73 | #include "../../bits/sccb.tcc" 74 | -------------------------------------------------------------------------------- /include/driver/servo.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Servo motor driver 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | #include "../defs.hpp" 32 | #include "../peripheral/tim.hpp" 33 | 34 | // High-level functions 35 | namespace servo { 36 | /** 37 | * This class implements a servo controller that can handle servos at the 38 | * same time with a resolution of 1us. 39 | * 40 | * The controller will take over pins for the control, the bit-band 41 | * address of these pins are stores in . 42 | * 43 | * The controller will generate digital signals with an ON time of: 44 | * 45 | * ( + value[i]) us 46 | * 47 | * for each controller at a rate of Hz 48 | * 49 | * This controller uses two timers: 50 | * + PeriodTimer: Whose address is 51 | * + DutyCycleTimer: Whose address is 52 | * 53 | * The user must configure every as output, and must also enable 54 | * both timer's interrupts. 55 | * 56 | * Additionally the user must call the functions: 57 | * 58 | * + onPeriodTimerInterrupt 59 | * + onDutyCycleTimerInterrupt 60 | * 61 | * on their corresponding interrupts. 62 | * 63 | * See the demo folder for an example. 64 | * 65 | */ 66 | template< 67 | tim::Address PeriodTimerAddress, 68 | u32 Frequency, 69 | tim::Address DutyCycleTimerAddress, 70 | u16 MidValue, 71 | u8 N 72 | > 73 | class Functions { 74 | public: 75 | Functions(); 76 | 77 | typedef tim::Functions PeriodTimer; 78 | typedef tim::Functions DutyCycleTimer; 79 | 80 | inline void initialize(); 81 | inline void setPin(u8 const, u32* const); 82 | inline void start(); 83 | inline void stop(); 84 | inline bool isActive(); 85 | inline void load(s16 const (&)[N]); 86 | inline void onPeriodTimerInterrupt(); 87 | inline void onDutyCycleTimerInterrupt(); 88 | 89 | private: 90 | s16 buffer[N]; 91 | u32* pin[N]; 92 | s16 value[N]; 93 | u8 sortedIndices[N]; 94 | u8 servoIndex; 95 | }; 96 | } // namespace servo 97 | 98 | #include "../../bits/servo.tcc" 99 | -------------------------------------------------------------------------------- /include/peripheral.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "peripheral/adc.hpp" 25 | #include "peripheral/afio.hpp" 26 | #include "peripheral/bkp.hpp" 27 | #include "peripheral/can.hpp" 28 | #include "peripheral/cec.hpp" 29 | #include "peripheral/crc.hpp" 30 | #include "peripheral/cryp.hpp" 31 | #include "peripheral/dac.hpp" 32 | #include "peripheral/dbg.hpp" 33 | #include "peripheral/dcmi.hpp" 34 | #include "peripheral/dma.hpp" 35 | #include "peripheral/eth.hpp" 36 | #include "peripheral/exti.hpp" 37 | #include "peripheral/flash.hpp" 38 | #include "peripheral/fsmc.hpp" 39 | #include "peripheral/gpio.hpp" 40 | #include "peripheral/hash.hpp" 41 | #include "peripheral/i2c.hpp" 42 | #include "peripheral/iwdg.hpp" 43 | #include "peripheral/pwr.hpp" 44 | #include "peripheral/rcc.hpp" 45 | #include "peripheral/rng.hpp" 46 | #include "peripheral/rtc.hpp" 47 | #include "peripheral/sdio.hpp" 48 | #include "peripheral/spi.hpp" 49 | #include "peripheral/syscfg.hpp" 50 | #include "peripheral/tim.hpp" 51 | #include "peripheral/usart.hpp" 52 | #include "peripheral/usb_fs.hpp" 53 | #include "peripheral/usb_hs.hpp" 54 | #include "peripheral/wwdg.hpp" 55 | -------------------------------------------------------------------------------- /include/peripheral/afio.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * This file is part of libstm32pp. 4 | * 5 | * Copyright (C) 2012 Jorge Aparicio 6 | * 7 | * This file is part of libstm32pp. 8 | * 9 | * libstm32pp is free software: you can redistribute it and/or modify it under 10 | * the terms of the GNU Lesser General Public License as published by the Free 11 | * Software Foundation, either version 3 of the License, or (at your option) 12 | * any later version. 13 | * 14 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 17 | * for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libstm32pp. If not, see . 21 | * 22 | ******************************************************************************/ 23 | 24 | /******************************************************************************* 25 | * 26 | * Alternate Function I/O 27 | * 28 | ******************************************************************************/ 29 | 30 | #pragma once 31 | 32 | #include "../device_select.hpp" 33 | 34 | #ifdef STM32F1XX 35 | 36 | #include "../defs.hpp" 37 | #include "../../memorymap/afio.hpp" 38 | 39 | // Low-level access to the registers 40 | #define AFIO_REGS reinterpret_cast(afio::ADDRESS) 41 | 42 | // High-level functions 43 | namespace afio { 44 | class Functions { 45 | public: 46 | static inline void enableClock(); 47 | static inline void disableClock(); 48 | 49 | template < 50 | exticr::States PORT, 51 | u8 PIN 52 | > 53 | static inline void configureExti(); 54 | 55 | private: 56 | Functions(); 57 | }; 58 | } // namespace afio" 59 | 60 | // High-level access to the peripheral 61 | typedef afio::Functions AFIO; 62 | 63 | #include "../../bits/afio.tcc" 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/peripheral/bkp.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Backup registers 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #ifdef STM32F1XX 33 | 34 | #include "../defs.hpp" 35 | #include "../../memorymap/bkp.hpp" 36 | 37 | // Low-level access to the registers 38 | #define BKP_REGS reinterpret_cast(bkp::ADDRESS) 39 | 40 | // High-level functions 41 | namespace bkp { 42 | class Functions { 43 | public: 44 | static inline void enableClock(); 45 | static inline void disableClock(); 46 | 47 | private: 48 | Functions(); 49 | }; 50 | } // namespace bkp 51 | 52 | // High-level access to the peripheral 53 | typedef bkp::Functions BKP; 54 | 55 | #include "../../bits/bkp.tcc" 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/peripheral/can.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Controller Area Network 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #ifndef VALUE_LINE 33 | 34 | #include "../defs.hpp" 35 | #include "../../memorymap/can.hpp" 36 | 37 | #if defined CONNECTIVITY_LINE || not defined STM32F1XX 38 | #define CAN1_REGS reinterpret_cast(can::address::E::CAN1) 39 | #define CAN2_REGS reinterpret_cast(can::address::E::CAN2) 40 | #else // !CONNECTIVITY_LINE || STM32F1XX 41 | #define CAN_REGS reinterpret_cast(can::address::E::CAN) 42 | #endif // !CONNECTIVITY_LINE || STM32F1XX 43 | namespace can { 44 | template
45 | class Functions { 46 | static inline void enableClocks(); 47 | static inline void disableClocks(); 48 | }; 49 | } // namespace can 50 | 51 | // High-level access to the peripheral 52 | #if defined CONNECTIVITY_LINE || not defined STM32F1XX 53 | typedef can::Functions CAN1; 54 | typedef can::Functions CAN2; 55 | #else // !CONNECTIVITY_LINE || STM32F1XX 56 | typedef can::Functions CAN; 57 | #endif // !CONNECTIVITY_LINE || STM32F1XX 58 | #include "../../bits/can.tcc" 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/peripheral/cec.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Consumer Electronic Control Controller 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #ifdef VALUE_LINE 33 | 34 | #include "../defs.hpp" 35 | #include "../../memorymap/cec.hpp" 36 | 37 | // Low-level access to the registers 38 | #define CEC_REGS reinterpret_cast(cec::ADDRESS) 39 | 40 | // High-level functions 41 | namespace cec { 42 | class Functions { 43 | public: 44 | static inline void enableClock(); 45 | static inline void disableClock(); 46 | private: 47 | Functions(); 48 | }; 49 | } // namespace cec 50 | 51 | // High-level access to the peripheral 52 | typedef cec::Functions CEC; 53 | 54 | #include "../../bits/cec.tcc" 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/peripheral/crc.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * CRC Calculation Unit 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/crc.hpp" 34 | 35 | // Low-level access to the registers 36 | #define CRC_REGS reinterpret_cast(crc::ADDRESS) 37 | 38 | // High-level functions 39 | namespace crc { 40 | class Functions { 41 | public: 42 | static inline void enableClock(); 43 | static inline void disableClock(); 44 | 45 | private: 46 | Functions(); 47 | }; 48 | } // namespace crc 49 | 50 | // High-level access to the peripheral 51 | typedef crc::Functions CRC; 52 | 53 | #include "../../bits/crc.tcc" 54 | -------------------------------------------------------------------------------- /include/peripheral/cryp.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Cryptographic Processor 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #ifndef STM32F1XX 33 | 34 | #include "../defs.hpp" 35 | #include "../../memorymap/cryp.hpp" 36 | 37 | // Low-level access to the registers 38 | #define CRYP_REGS reinterpret_cast(cryp::ADDRESS) 39 | 40 | // High-level functions 41 | namespace cryp { 42 | class Functions { 43 | public: 44 | static inline void enableClock(); 45 | static inline void disableClock(); 46 | 47 | private: 48 | Functions(); 49 | }; 50 | } // namespace cryp 51 | 52 | // High-level access to the peripheral 53 | typedef cryp::Functions CRYP; 54 | 55 | #include "../../bits/cryp.tcc" 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/peripheral/dac.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Digital to Analog Converter 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/dac.hpp" 34 | 35 | // Low-level access to the registers 36 | #define DAC_REGS reinterpret_cast(dac::ADDRESS) 37 | 38 | // High-level functions 39 | namespace dac { 40 | class Functions { 41 | public: 42 | static inline void enableClock(); 43 | static inline void disableClock(); 44 | 45 | private: 46 | Functions(); 47 | }; 48 | } // namespace dac 49 | 50 | // High-level access to the peripheral 51 | typedef dac::Functions DAC; 52 | 53 | #include "../../bits/dac.tcc" 54 | -------------------------------------------------------------------------------- /include/peripheral/dbg.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Debug Support 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | #include "../defs.hpp" 32 | 33 | #include "../../memorymap/dbg.hpp" 34 | 35 | // Low-level access to the registers 36 | #define DBG_REGS reinterpret_cast(dbg::ADDRESS) 37 | 38 | // High-level functions 39 | namespace dbg { 40 | class Functions { 41 | public: 42 | // TODO DBG functions declaration 43 | private: 44 | Functions(); 45 | }; 46 | } // namespace dbg 47 | 48 | // High-level access to the peripheral 49 | typedef dbg::Functions DBG; 50 | 51 | #include "../../bits/dbg.tcc" 52 | -------------------------------------------------------------------------------- /include/peripheral/eth.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Ethernet 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #if not defined STM32F1XX || defined CONNECTIVITY_LINE 33 | 34 | #include "../defs.hpp" 35 | #include "../../memorymap/eth.hpp" 36 | 37 | // Low-level access to the registers 38 | #define ETH_REGS reinterpret_cast(eth::ADDRESS) 39 | 40 | // High-level functions 41 | namespace eth { 42 | class Functions { 43 | public: 44 | static inline void enableClocks(); 45 | static inline void disableClocks(); 46 | 47 | private: 48 | Functions(); 49 | }; 50 | } // namespace eth 51 | 52 | // High-level access to the peripherals 53 | typedef eth::Functions ETH; 54 | 55 | #include "../../bits/eth.tcc" 56 | 57 | #endif // !STM32F1XX || CONNECTIVITY_LINE 58 | -------------------------------------------------------------------------------- /include/peripheral/exti.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * External Interrupt/Event Controller 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/exti.hpp" 34 | 35 | // Low-level access to the registers 36 | #define EXTI_REGS reinterpret_cast(exti::ADDRESS) 37 | 38 | // High-level functions 39 | namespace exti { 40 | template 41 | class Functions { 42 | static_assert(LINE < 23, "There are only 23 (0-22) external interrupt lines"); 43 | 44 | public: 45 | static inline void clearPendingFlag(); 46 | static inline void disableAll(); 47 | static inline void disableEvent(); 48 | static inline void disableInterrupt(); 49 | static inline void unmaskInterrupt(); 50 | static inline void maskInterrupt(); 51 | static inline void enableHardwareEventByFallingEdge(); 52 | static inline void enableHardwareEventByRisingEdge(); 53 | static inline void enableHardwareInterruptByFallingEdge(); 54 | static inline void enableHardwareInterruptByRisingEdge(); 55 | static inline void enableSoftwareEvent(); 56 | static inline void enableSoftwareInterrupt(); 57 | 58 | private: 59 | Functions(); 60 | }; 61 | } // namespace exti 62 | 63 | // High-level access to the peripheral 64 | typedef exti::Functions<0> EXTI0; 65 | typedef exti::Functions<1> EXTI1; 66 | typedef exti::Functions<2> EXTI2; 67 | typedef exti::Functions<3> EXTI3; 68 | typedef exti::Functions<4> EXTI4; 69 | typedef exti::Functions<5> EXTI5; 70 | typedef exti::Functions<6> EXTI6; 71 | typedef exti::Functions<7> EXTI7; 72 | typedef exti::Functions<8> EXTI8; 73 | typedef exti::Functions<9> EXTI9; 74 | typedef exti::Functions<10> EXTI10; 75 | typedef exti::Functions<11> EXTI11; 76 | typedef exti::Functions<12> EXTI12; 77 | typedef exti::Functions<13> EXTI13; 78 | typedef exti::Functions<14> EXTI14; 79 | typedef exti::Functions<15> EXTI15; 80 | typedef exti::Functions<16> EXTI16; 81 | typedef exti::Functions<17> EXTI17; 82 | typedef exti::Functions<18> EXTI18; 83 | typedef exti::Functions<19> EXTI19; 84 | typedef exti::Functions<20> EXTI20; 85 | typedef exti::Functions<21> EXTI21; 86 | typedef exti::Functions<22> EXTI22; 87 | 88 | #include "../../bits/exti.tcc" 89 | -------------------------------------------------------------------------------- /include/peripheral/flash.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * FLASH Registers 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/flash.hpp" 34 | 35 | // Low-level access to the registers 36 | #define FLASH_REGS reinterpret_cast(flash::ADDRESS) 37 | 38 | // High-level functions 39 | namespace flash { 40 | class Functions { 41 | public: 42 | #ifndef VALUE_LINE 43 | static inline void setLatency(flash::acr::latency::States); 44 | #endif // VALUE_LINE 45 | #ifdef STM32F1XX 46 | #ifndef VALUE_LINE 47 | static inline void enablePrefetch(); 48 | static inline void disablePrefetch(); 49 | 50 | #endif // !VALUE_LINE 51 | static inline void enableHalfCycleFlashAccess(); 52 | static inline void disableHalfCycleFlashAccess(); 53 | #ifdef VALUE_LINE 54 | static inline void configure(flash::acr::hlfcya::States); 55 | #else // VALUE_LINE 56 | static inline void configure( 57 | flash::acr::latency::States, 58 | flash::acr::hlfcya::States, 59 | flash::acr::prftbe::States); 60 | #endif // VALUE_LINE 61 | #else // STM32F1XX 62 | static inline void enablePrefetch(); 63 | static inline void disablePrefetch(); 64 | static inline void enableDataCache(); 65 | static inline void disableDataCache(); 66 | static inline void enableInstructionCache(); 67 | static inline void disableInstructionCache(); 68 | 69 | static inline void configure( 70 | flash::acr::latency::States, 71 | flash::acr::prften::States, 72 | flash::acr::dcen::States, 73 | flash::acr::icen::States); 74 | 75 | #endif // STM32F1XX 76 | private: 77 | Functions(); 78 | }; 79 | } // namespace flash 80 | 81 | // High-level access to the peripheral 82 | typedef flash::Functions FLASH; 83 | 84 | #include "../../bits/flash.tcc" 85 | -------------------------------------------------------------------------------- /include/peripheral/fsmc.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Flexible Static Memory Controller 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/fsmc.hpp" 34 | 35 | // Low-level access to the registers 36 | #define FSMC_REGS reinterpret_cast(fsmc::ADDRESS) 37 | 38 | // High-level functions 39 | namespace fsmc { 40 | class Functions { 41 | public: 42 | static inline void enableClock(); 43 | static inline void disableClock(); 44 | 45 | private: 46 | Functions(); 47 | }; 48 | } // namespace fsmc 49 | 50 | // High-level access to the peripheral 51 | typedef fsmc::Functions FSMC; 52 | 53 | #include "../../bits/fsmc.tcc" 54 | -------------------------------------------------------------------------------- /include/peripheral/hash.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Hash Processor 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #ifndef STM32F1XX 33 | 34 | #include "../defs.hpp" 35 | #include "../../memorymap/hash.hpp" 36 | 37 | // Low-level access to the registers 38 | #define HASH_REGS reinterpret_cast(hash::ADDRESS) 39 | 40 | // High-level functions 41 | namespace hash { 42 | class Functions { 43 | public: 44 | static inline void enableClock(); 45 | static inline void disableClock(); 46 | 47 | private: 48 | Functions(); 49 | }; 50 | } // namespace hash 51 | 52 | // High-level access to the peripheral 53 | typedef hash::Functions HASH; 54 | 55 | #include "../../bits/hash.tcc" 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/peripheral/iwdg.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Independent WATCHDOG 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/iwdg.hpp" 34 | 35 | // Low-level access to the registers 36 | #define IWDG_REGS reinterpret_cast(iwdg::ADDRESS) 37 | 38 | // High-level functions 39 | namespace iwdg { 40 | class Functions { 41 | public: 42 | // TODO IWDG functions declaration 43 | private: 44 | Functions(); 45 | }; 46 | } // namespace iwdg 47 | 48 | // High-level access to the peripheral 49 | typedef iwdg::Functions IWDG; 50 | 51 | #include "../../bits/iwdg.tcc" 52 | -------------------------------------------------------------------------------- /include/peripheral/pwr.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Power Control 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/pwr.hpp" 34 | 35 | // Low-level access to the registers 36 | #define PWR_REGS reinterpret_cast(pwr::ADDRESS) 37 | 38 | // High-level functions 39 | namespace pwr { 40 | class Functions { 41 | public: 42 | static inline void enableClock(); 43 | static inline void disableClock(); 44 | 45 | static inline void enableBackupDomainWriteProtection(); 46 | static inline void disableBackupDomainWriteProtection(); 47 | private: 48 | Functions(); 49 | }; 50 | } // namespace pwr 51 | 52 | // High-level access to the peripheral 53 | typedef pwr::Functions PWR; 54 | 55 | #include "../../bits/pwr.tcc" 56 | -------------------------------------------------------------------------------- /include/peripheral/rng.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Random Number Generator 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #ifndef STM32F1XX 33 | 34 | #include "../defs.hpp" 35 | #include "../../memorymap/rng.hpp" 36 | 37 | // Low-level access to registers 38 | #define RNG_REGS reinterpret_cast(rng::ADDRESS) 39 | 40 | // High-level functions 41 | namespace rng { 42 | class Functions { 43 | public: 44 | static inline void enableClock(); 45 | static inline void disableClock(); 46 | static inline void startGenerator(); 47 | static inline void stopGenerator(); 48 | static inline void enableInterrupts(); 49 | static inline void disableInterrupts(); 50 | 51 | template 52 | static inline T getValue(); 53 | 54 | static inline bool isDataReady(void); 55 | static inline bool isSeedValid(void); 56 | static inline bool isClockValid(void); 57 | static inline void clearSeedErrorFlag(void); 58 | static inline void clearClockErrorFlag(void); 59 | 60 | private: 61 | Functions(); 62 | }; 63 | 64 | } // namespace rng 65 | 66 | // High-level access to the peripheral 67 | typedef rng::Functions RNG; 68 | 69 | #include "../../bits/rng.tcc" 70 | 71 | #endif // !STM32F1XX 72 | -------------------------------------------------------------------------------- /include/peripheral/rtc.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Real-Time Clock 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/rtc.hpp" 34 | 35 | // Low-level access to the registers 36 | #define RTC_REGS reinterpret_cast(rtc::ADDRESS) 37 | 38 | // High-level functions 39 | namespace rtc { 40 | class Functions { 41 | public: 42 | 43 | 44 | private: 45 | Functions(); 46 | }; 47 | } 48 | 49 | // High-level access to the peripheral 50 | typedef rtc::Functions RTC; 51 | 52 | #include "../../bits/rtc.tcc" 53 | -------------------------------------------------------------------------------- /include/peripheral/sdio.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Secure Digital I/O Interface 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #ifndef STM32F1XX 33 | 34 | #include "../defs.hpp" 35 | #include "../../memorymap/sdio.hpp" 36 | 37 | // Low-level access to the registers 38 | #define SDIO_REGS reinterpret_cast(sdio::ADDRESS) 39 | 40 | // High-level functions 41 | namespace sdio { 42 | class Functions { 43 | public: 44 | static inline void enableClock(); 45 | static inline void disableClock(); 46 | 47 | private: 48 | Functions(); 49 | }; 50 | } // namespace sdio 51 | 52 | // High-level access to the peripheral 53 | typedef sdio::Functions SDIO; 54 | 55 | #include "../../bits/sdio.tcc" 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/peripheral/spi.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | /******************************************************************************* 25 | * 26 | * Serial Peripheral Interface 27 | * 28 | ******************************************************************************/ 29 | 30 | #pragma once 31 | 32 | #include "../device_select.hpp" 33 | 34 | #include "../defs.hpp" 35 | #include "../../memorymap/spi.hpp" 36 | 37 | // Low-level access to the registers 38 | #define SPI1_REGS reinterpret_cast(spi::SPI1) 39 | #define SPI2_REGS reinterpret_cast(spi::SPI2) 40 | #define SPI3_REGS reinterpret_cast(spi::SPI3) 41 | 42 | // High-level functions 43 | namespace spi { 44 | template
45 | class Functions { 46 | public: 47 | static inline void enableClock(); 48 | static inline void disableClock(); 49 | static inline void sendByte(const u8); 50 | static inline u8 getByte(); 51 | static inline void sendWord(const u16); 52 | static inline u16 getWord(); 53 | static inline void enable(); 54 | static inline void disable(); 55 | static inline bool candSendData(); 56 | static inline bool hasReceivedData(); 57 | static inline void configure( 58 | spi::cr1::cpha::States, 59 | spi::cr1::cpol::States, 60 | spi::cr1::msrt::States, 61 | spi::cr1::br::States, 62 | spi::cr1::lsbfirst::States, 63 | spi::cr1::ssm::States, 64 | spi::cr1::rxonly::States, 65 | spi::cr1::dff::States, 66 | spi::cr1::crcnext::States, 67 | spi::cr1::crcen::States, 68 | spi::cr1::bidioe::States, 69 | spi::cr1::bidimode::States, 70 | spi::cr2::errie::States, 71 | spi::cr2::frf::States, 72 | spi::cr2::rxdmaen::States, 73 | spi::cr2::rxneie::States, 74 | spi::cr2::ssoe::States, 75 | spi::cr2::txdmaen::States, 76 | spi::cr2::txeie::States); 77 | 78 | private: 79 | Functions(); 80 | }; 81 | } // namespace spi 82 | 83 | // High-level access to the peripheral 84 | typedef spi::Functions SPI1; 85 | typedef spi::Functions SPI2; 86 | typedef spi::Functions SPI3; 87 | 88 | #include "../../bits/spi.tcc" 89 | -------------------------------------------------------------------------------- /include/peripheral/syscfg.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | /******************************************************************************* 25 | * 26 | * System Configuration Controller 27 | * 28 | ******************************************************************************/ 29 | 30 | #pragma once 31 | 32 | #include "../device_select.hpp" 33 | 34 | #ifndef STM32F1XX 35 | 36 | #include "../defs.hpp" 37 | #include "../../memorymap/syscfg.hpp" 38 | 39 | // Low-level access to the registers 40 | #define SYSCFG_REGS reinterpret_cast(syscfg::ADDRESS) 41 | 42 | // High-level functions 43 | namespace syscfg { 44 | class Functions { 45 | public: 46 | static inline void enableClock(); 47 | static inline void disableClock(); 48 | template< 49 | u8 LINE, 50 | syscfg::exticr::States 51 | > 52 | static inline void selectExtiPin(); 53 | 54 | private: 55 | Functions(); 56 | }; 57 | } // namespace syscfg 58 | 59 | // High-level access to the peripheral 60 | typedef syscfg::Functions SYSCFG; 61 | 62 | #include "../../bits/syscfg.tcc" 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /include/peripheral/usb_fs.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Universal Serial Bus Full Speed 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #if not defined STM32F1XX || defined CONNECTIVITY_LINE 33 | 34 | #include "../defs.hpp" 35 | #include "../../memorymap/usb_fs.hpp" 36 | 37 | // Low-level access to the registers 38 | #define USB_FS_REGS reinterpret_cast(usb_fs::ADDRESS) 39 | 40 | // High-level functions 41 | namespace usb_fs { 42 | class Functions { 43 | public: 44 | static inline void enableClock(); 45 | static inline void disableClock(); 46 | 47 | private: 48 | Functions(); 49 | }; 50 | } // namespace usb_fs 51 | 52 | // High-level access to the peripheral 53 | typedef usb_fs::Functions USB_FS; 54 | 55 | #include "../../bits/usb_fs.tcc" 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/peripheral/usb_hs.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Universal Serial Bus High Speed 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #ifndef STM32F1XX 33 | 34 | #include "../defs.hpp" 35 | #include "../../memorymap/usb_hs.hpp" 36 | 37 | // Low-level access to the registers 38 | #define USB_HS_REGS reinterpret_cast(usb_hs::ADDRESS) 39 | 40 | // High-level functions 41 | namespace usb_hs { 42 | class Functions { 43 | public: 44 | static inline void enableClock(); 45 | static inline void disableClock(); 46 | 47 | private: 48 | Functions(); 49 | }; 50 | } // namespace usb_hs 51 | 52 | // High-level access to the peripheral 53 | typedef usb_hs::Functions USB_HS; 54 | 55 | #include "../../bits/usb_hs.tcc" 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/peripheral/wwdg.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | /******************************************************************************* 23 | * 24 | * Window Watchdog 25 | * 26 | ******************************************************************************/ 27 | 28 | #pragma once 29 | 30 | #include "../device_select.hpp" 31 | 32 | #include "../defs.hpp" 33 | #include "../../memorymap/wwdg.hpp" 34 | 35 | // Low-level access to the registers 36 | #define WWDG_REGS reinterpret_cast(wwdg::ADDRESS) 37 | 38 | // High-level functions 39 | namespace wwdg { 40 | class Functions { 41 | public: 42 | static inline void enableClock(); 43 | static inline void disableClock(); 44 | 45 | private: 46 | Functions(); 47 | }; 48 | 49 | } // namespace wwdg 50 | 51 | // High-level access to the peripheral 52 | typedef wwdg::Functions WWDG; 53 | 54 | #include "../../bits/wwdg.tcc" 55 | -------------------------------------------------------------------------------- /include/system_call.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "peripheral/usart.hpp" 25 | 26 | /* Choose a USART port (1-6) for standard output */ 27 | #define STDOUT_USART 1 28 | -------------------------------------------------------------------------------- /memorymap/afio.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace afio { 27 | enum { 28 | ADDRESS = alias::APB2 + 0x0000 29 | }; 30 | 31 | struct Registers 32 | { 33 | __RW 34 | u32 EVCR; // 0x00: Event control 35 | __RW 36 | u32 MAPR; // 0x04: Remap and debug configuration 37 | __RW 38 | u32 EXTICR[4]; // 0x08: External interrupt configuration 39 | u32 _RESERVED0; 40 | __RW 41 | u32 MAPR2; // 0x1C: Remap and debug configuration 2 42 | }; 43 | 44 | namespace exticr { 45 | enum { 46 | MASK = 0b1111, 47 | POSITION = 4 48 | }; 49 | enum States { 50 | PA = 0, 51 | PB = 1, 52 | PC = 2, 53 | PD = 3, 54 | PE = 4, 55 | PF = 5, 56 | PG = 6, 57 | }; 58 | } // namespace exticr 59 | }// namespace afio 60 | -------------------------------------------------------------------------------- /memorymap/bkp.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace bkp { 27 | enum { 28 | ADDRESS = alias::APB1 + 0x6C00, 29 | }; 30 | 31 | struct Registers 32 | { 33 | u32 _RESERVED0; 34 | __RW 35 | u32 DR1[10]; // 0x04-0x28: Data 1 36 | __RW 37 | u32 RTCCR; // 0x2C: RTC clock calibration 38 | __RW 39 | u32 CR; // 0x30: Control 40 | __RW 41 | u32 CSR; // 0x34: Control/status 42 | u32 _RESERVED1[2]; 43 | __RW 44 | u32 DR2[32]; // 0x40-0xBC: Data 2 45 | }; 46 | 47 | namespace rtccr { 48 | enum { 49 | OFFSET = 0x2C 50 | }; 51 | } // namespace rtccr 52 | 53 | namespace cr { 54 | enum { 55 | OFFSET = 0x30 56 | }; 57 | } // namespace cr 58 | 59 | namespace csr { 60 | enum { 61 | OFFSET = 0x34 62 | }; 63 | } // namespace csr 64 | } // namespace bkp 65 | -------------------------------------------------------------------------------- /memorymap/can.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace can { 27 | struct Registers { 28 | __RW 29 | u32 MCR; // 0x000: Master control 30 | __RW 31 | u32 MSR; // 0x004: Master status 32 | __RW 33 | u32 TSR; // 0x008: Transmit status 34 | __RW 35 | u32 RFR[2]; // 0x00C: Receive FIFO 36 | __RW 37 | u32 IER; // 0x014: Interrupt enable 38 | __RW 39 | u32 ESR; // 0x018: Error status 40 | __RW 41 | u32 BTR; // 0x01C: Bit timing 42 | u32 _RESERVED0[88]; 43 | struct { 44 | __RW 45 | u32 IR; // 0x180, 0x190, 0x1A0: identifier 46 | __RW 47 | u32 DTR; // 0x184, 0x194, 0x1A4: data length control and time stamp 48 | __RW 49 | u32 DLR; // 0x188, 0x198, 0x1A8: data low 50 | __RW 51 | u32 DHR; // 0x18C, 0x19C, 0x1AC: data high 52 | } TX[3]; // TX FIFO mailbox 53 | struct { 54 | __RW 55 | u32 IR; // 0x1B0, 0x1C0: Identifier 56 | __RW 57 | u32 DTR; // 0x1B4, 0x1C4: Data length control and time stamp 58 | __RW 59 | u32 DLR; // 0x1B8, 0x1C8: Data low 60 | __RW 61 | u32 DHR; // 0x1BC, 0x1CC: Data high 62 | } RX[2]; // RX FIFO mailbox 63 | u32 _RESERVED1[12]; 64 | __RW 65 | u32 FMR; // 0x200: Filter master 66 | __RW 67 | u32 FM1R; // 0x204: Filter mode 68 | u32 _RESERVED2; 69 | __RW 70 | u32 FS1R; // 0x20C: Filter scale 71 | u32 _RESERVED3; 72 | __RW 73 | u32 FFA1R; // 0x214: Filter FIFO assignment 74 | u32 _RESERVED4; 75 | __RW 76 | u32 FA1R; // 0x21C: Filter activation 77 | u32 _RESERVED5[8]; 78 | struct { 79 | __RW 80 | u32 L; // 0x240 + 8 * I: Low 81 | __RW 82 | u32 H; // 0x244 + 8 * I: High 83 | } FR[ 84 | #if not defined STM32F1XX || defined CONNECTIVITY_LINE 85 | 27 // 0x240-0x31C: Filter bank 86 | #else // !STM32F1XX || CONNECTIVITY_LINE 87 | 13// 0x240-0x2AC: Filter bank 88 | #endif // !STM32F1XX || CONNECTIVITY_LINE 89 | ]; 90 | }; 91 | 92 | enum Address { 93 | #if defined CONNECTIVITY_LINE || not defined STM32F1XX 94 | CAN1 = alias::APB1 + 0x6400, 95 | CAN2 = alias::APB1 + 0x6800, 96 | #else // !CONNECTIVITY_LINE || STM32F1XX 97 | CAN = alias::APB1 + 0x6400, 98 | #endif // !CONNECTIVITY_LINE || STM32F1XX 99 | }; 100 | 101 | // TODO CAN register bits 102 | 103 | }// namespace can 104 | -------------------------------------------------------------------------------- /memorymap/cec.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | #pragma once 22 | 23 | #include "common.hpp" 24 | 25 | namespace cec { 26 | struct Registers { 27 | __RW 28 | u32 CFGR; // 0x00: Configuration 29 | __RW 30 | u32 OAR; // 0x04: Own address 31 | __RW 32 | u32 PRES; // 0x08: Prescaler 33 | __RW 34 | u32 ESR; // 0x0C: Error status 35 | __RW 36 | u32 CSR; // 0x10: Control and status 37 | __RW 38 | u32 TXD; // 0x14: Tx data 39 | __RW 40 | u32 RXD; // 0x18: Rx data 41 | }; 42 | 43 | enum { 44 | ADDRESS = alias::APB1 + 0x7800 45 | }; 46 | 47 | namespace cfgr { 48 | enum { 49 | OFFSET = 0x00 50 | }; 51 | } // namespace cfgr 52 | 53 | namespace oar { 54 | enum { 55 | OFFSET = 0x04 56 | }; 57 | } // namespace oar 58 | 59 | namespace pres { 60 | enum { 61 | OFFSET = 0x08 62 | }; 63 | } // namespace pres 64 | 65 | namespace esr { 66 | enum { 67 | OFFSET = 0x0C 68 | }; 69 | } // namespace esr 70 | 71 | namespace csr { 72 | enum { 73 | OFFSET = 0x10 74 | }; 75 | } // namespace csr 76 | 77 | namespace txd { 78 | enum { 79 | OFFSET = 0x14 80 | }; 81 | } // namespace txd 82 | 83 | namespace rxd { 84 | enum { 85 | OFFSET = 0x18 86 | }; 87 | } // namespace rxd 88 | } // namespace cec 89 | -------------------------------------------------------------------------------- /memorymap/common.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "../include/device_select.hpp" 25 | 26 | namespace alias { 27 | enum Address { 28 | FLASH = 0x08000000, 29 | SRAM = 0x20000000, 30 | PERIPH = 0x40000000, 31 | PPB = 0xE000E000, 32 | DBG = 0xE0042000, 33 | FSMC = 0xA0000000, 34 | APB1 = PERIPH, 35 | APB2 = PERIPH + 0x00010000, 36 | #ifdef STM32F1XX 37 | USB = 0x50000000, 38 | AHB = PERIPH + 0x00020000, 39 | 40 | #elif defined (STM32F2XX) 41 | AHB1 = PERIPH + 0x00020000, 42 | AHB2 = PERIPH + 0x10000000, 43 | 44 | #else /* STM32F4XX */ 45 | CCMDATARAM = 0x10000000, 46 | SRAM1 = SRAM, 47 | SRAM2 = SRAM + 0x1C000, 48 | BKPSRAM = 0x40024000, 49 | AHB1 = PERIPH + 0x00020000, 50 | AHB2 = PERIPH + 0x10000000, 51 | #endif 52 | }; 53 | } // namespace alias 54 | 55 | namespace bitband { 56 | enum Address { 57 | SRAM = 0x22000000, 58 | PERIPH = 0x42000000, 59 | }; 60 | } // namespace bitband 61 | -------------------------------------------------------------------------------- /memorymap/crc.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace crc { 27 | struct Registers { 28 | __RW 29 | u32 DR; // 0x00: Data 30 | __RW 31 | u32 IDR; // 0x04: Independent data 32 | __RW 33 | u32 CR; // 0x08: Control 34 | }; 35 | 36 | #ifdef STM32F1XX 37 | enum { 38 | ADDRESS = alias::AHB + 0x3000 39 | }; 40 | #else 41 | enum { 42 | ADDRESS = alias::AHB1 + 0x3000 43 | }; 44 | #endif 45 | 46 | namespace dr { 47 | enum { 48 | OFFSET = 0x00 49 | }; 50 | } // namespace dr 51 | 52 | namespace idr { 53 | enum { 54 | OFFSET = 0x04 55 | }; 56 | } // namespace idr 57 | 58 | namespace cr { 59 | enum { 60 | OFFSET = 0x08 61 | }; 62 | } // namespace cr 63 | } // namespace crc 64 | -------------------------------------------------------------------------------- /memorymap/cryp.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace cryp { 27 | enum { 28 | ADDRESS = alias::AHB2 + 0x60000 29 | }; 30 | 31 | struct Registers { 32 | __RW 33 | u32 CR; // 0x00: Control 34 | __RW 35 | u32 SR; // 0x04: Status 36 | __RW 37 | u32 DR; // 0x08: Data input 38 | __RW 39 | u32 DOUT; // 0x0C: Data output 40 | __RW 41 | u32 DMACR; // 0x10: DMA control 42 | __RW 43 | u32 IMSCR; // 0x14: Interrupt mask set/clear 44 | __RW 45 | u32 RISR; // 0x18: Raw interrupt status 46 | __RW 47 | u32 MISR; // 0x1C: Masked interrupt status 48 | struct { 49 | __RW 50 | u32 L; // 0x20, 0x28, 0x30, 0x38: Left word 51 | __RW 52 | u32 R; // 0x24, 0x2C, 0x34, 0x3C: Right word 53 | } KR[4]; // Key 54 | struct { 55 | __RW 56 | u32 L; // 0x40, 0x48: Left word 57 | __RW 58 | u32 R; // 0x44, 0x4C: Right word 59 | } IVR[2]; // Initialization vector 60 | }; 61 | 62 | namespace cr { 63 | enum { 64 | OFFSET = 0x00 65 | }; 66 | } // namespace cr 67 | 68 | namespace sr { 69 | enum { 70 | OFFSET = 0x04 71 | }; 72 | } // namespace sr 73 | 74 | namespace dr { 75 | enum { 76 | OFFSET = 0x08 77 | }; 78 | } // namespace dr 79 | 80 | namespace dout { 81 | enum { 82 | OFFSET = 0x0C 83 | }; 84 | } // namespace dout 85 | 86 | namespace dmacr { 87 | enum { 88 | OFFSET = 0x10 89 | }; 90 | } // namespace dmacr 91 | 92 | namespace imscr { 93 | enum { 94 | OFFSET = 0x14 95 | }; 96 | } // namespace imscr 97 | 98 | namespace risr { 99 | enum { 100 | OFFSET = 0x18 101 | }; 102 | } // namespace risr 103 | 104 | namespace misr { 105 | enum { 106 | OFFSET = 0x1C 107 | }; 108 | } // namespace misr 109 | } // namespace cryp 110 | -------------------------------------------------------------------------------- /memorymap/dac.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace dac { 27 | enum { 28 | ADDRESS = alias::APB1 + 0x7400 29 | }; 30 | 31 | struct Registers { 32 | __RW 33 | u32 CR; // 0x00: Control 34 | __RW 35 | u32 SWTRIGR; // 0x04: Software trigger 36 | struct { 37 | __RW 38 | u32 R12; // 0x08, 0x14: 12-bit right-aligned 39 | __RW 40 | u32 L12; // 0x0C, 0x18: 12-bit left-aligned 41 | __RW 42 | u32 R8; // 0x10, 0x1C: 8-bit right-aligned 43 | } DHR[2]; // Channel data holding 44 | __RW 45 | u32 DHR12RD; // 0x20: Dual 12-bit right-aligned data holding 46 | __RW 47 | u32 DHR12LD; // 0x24: Dual 12-bit left-aligned data holding 48 | __RW 49 | u32 DHR8RD; // 0x28: Dual 8-bit right-aligned data holding 50 | __RW 51 | u32 DOR[2]; // 0x2C: Channel data output 52 | #if defined VALUE_LINE || \ 53 | defined STM32F2XX || \ 54 | defined STM32F4XX 55 | __RW 56 | u32 SR; // 0x34: Status 57 | #endif 58 | }; 59 | 60 | namespace cr { 61 | enum { 62 | OFFSET = 0x00 63 | }; 64 | } // namespace cr 65 | 66 | namespace swtrigr { 67 | enum { 68 | OFFSET = 0x04 69 | }; 70 | } // namespace swtrigr 71 | 72 | namespace sr { 73 | enum { 74 | OFFSET = 0x34 75 | }; 76 | } // namespace sr 77 | } // namespace dac 78 | -------------------------------------------------------------------------------- /memorymap/dbg.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace dbg { 27 | enum { 28 | ADDRESS = alias::DBG 29 | }; 30 | 31 | struct Registers { 32 | __RW 33 | u32 IDCODE; // 0x00: MCU device ID code 34 | __RW 35 | u32 CR; // 0x04: Configuration 36 | #ifndef STM32F1XX 37 | __RW 38 | u32 APB1FZ; // 0x08: APB1 freeze register 39 | __RW 40 | u32 APB2FZ; // 0x0C: APB2 freeze register 41 | #endif 42 | }; 43 | 44 | namespace idcode { 45 | enum { 46 | OFFSET = 0x00 47 | }; 48 | } // namespace idcode 49 | 50 | namespace cr { 51 | enum { 52 | OFFSET = 0x04 53 | }; 54 | } // namespace cr 55 | 56 | #ifndef STM32F1XX 57 | namespace apb1fz { 58 | enum { 59 | OFFSET = 0x08 60 | }; 61 | } // namespace apb1fz 62 | 63 | namespace apb2fz { 64 | enum { 65 | OFFSET = 0x0C 66 | }; 67 | } // namespace apb2fz 68 | #endif 69 | } // namespace dbg 70 | -------------------------------------------------------------------------------- /memorymap/exti.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace exti { 27 | enum { 28 | #ifdef STM32F1XX 29 | ADDRESS = alias::APB2 + 0x0400 30 | #else 31 | ADDRESS = alias::APB2 + 0x3C00 32 | #endif 33 | }; 34 | 35 | struct Registers { 36 | __RW 37 | u32 IMR; // 0x00: Interrupt mask 38 | __RW 39 | u32 EMR; // 0x04: Event mask 40 | __RW 41 | u32 RTSR; // 0x08: Rising trigger selection 42 | __RW 43 | u32 FTSR; // 0x0C: Falling trigger selection 44 | __RW 45 | u32 SWIER; // 0x10: Software interrupt event 46 | __RW 47 | u32 PR; // 0x14: Pending 48 | }; 49 | 50 | namespace imr { 51 | enum { 52 | OFFSET = 0x00 53 | }; 54 | } // namespace imr 55 | 56 | namespace emr { 57 | enum { 58 | OFFSET = 0x04 59 | }; 60 | } // namespace imr 61 | 62 | namespace rtsr { 63 | enum { 64 | OFFSET = 0x08 65 | }; 66 | } // namespace rtsr 67 | 68 | namespace ftsr { 69 | enum { 70 | OFFSET = 0x0C 71 | }; 72 | } // namespace ftsr 73 | 74 | namespace swier { 75 | enum { 76 | OFFSET = 0x10 77 | }; 78 | } // namespace swier 79 | 80 | namespace pr { 81 | enum { 82 | OFFSET = 0x14 83 | }; 84 | } // namespace pr 85 | 86 | } // namespace exti 87 | -------------------------------------------------------------------------------- /memorymap/fpu.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace fpu { 27 | enum { 28 | ADDRESS = alias::PPB + 0xD88 29 | }; 30 | 31 | struct Registers { 32 | __RW 33 | u32 CPACR; // 0x000: Coprocessor access control 34 | u32 _RESERVED[106]; 35 | __RW 36 | u32 FPCCR; // 0x1AC: Floating point context control 37 | __RW 38 | u32 FPCAR; // 0x1B0: Floating point context address 39 | __RW 40 | u32 FPDSCR; // 0x1B4: Floating point default status control 41 | }; 42 | 43 | namespace cpacr { 44 | enum { 45 | OFFSET = 0x00 46 | }; 47 | namespace cp10 { 48 | enum { 49 | POSITION = 20, 50 | MASK = 0b11 << POSITION 51 | }; 52 | enum States { 53 | ACCESS_DENIED = 0 << POSITION, 54 | PRIVILEGED_ACCESS = 1 << POSITION, 55 | FULL_ACCESS = 3 << POSITION 56 | }; 57 | } // namespace cp10 58 | 59 | namespace cp11 { 60 | enum { 61 | POSITION = 22, 62 | MASK = 0b11 << POSITION 63 | }; 64 | enum States { 65 | ACCESS_DENIED = 0 << POSITION, 66 | PRIVILEGED_ACCESS = 1 << POSITION, 67 | FULL_ACCESS = 3 << POSITION 68 | }; 69 | } // namespace cp11 70 | } // namespace cpacr 71 | } // namespace fpu 72 | -------------------------------------------------------------------------------- /memorymap/fsmc.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace fsmc { 27 | enum { 28 | ADDRESS = alias::FSMC 29 | }; 30 | 31 | struct Registers { 32 | // TODO FSMC registers 33 | }; 34 | 35 | // TODO FSMC register bits 36 | }// namespace fsmc 37 | -------------------------------------------------------------------------------- /memorymap/hash.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace hash { 27 | enum { 28 | ADDRESS = alias::AHB2 + 0x60400 29 | }; 30 | 31 | struct Registers { 32 | __RW 33 | u32 CR; // 0x00: Control 34 | __RW 35 | u32 DIN; // 0x04: Data input 36 | __RW 37 | u32 STR; // 0x08: Start 38 | __RW 39 | u32 HR[5]; // 0x0C: Digest 40 | __RW 41 | u32 IMR; // 0x20: Interrupt enable 42 | __RW 43 | u32 SR; // 0x24: Status 44 | u32 _RESERVED[52]; 45 | __RW 46 | u32 CSR[51]; // 0xF8: Context swap 47 | }; 48 | 49 | namespace cr { 50 | enum { 51 | OFFSET = 0x00 52 | }; 53 | } // namespace cr 54 | 55 | namespace din { 56 | enum { 57 | OFFSET = 0x04 58 | }; 59 | } // namespace din 60 | 61 | namespace str { 62 | enum { 63 | OFFSET = 0x08 64 | }; 65 | } // namespace str 66 | 67 | namespace imr { 68 | enum { 69 | OFFSET = 0x20 70 | }; 71 | } // namespace imr 72 | } // namespace hash 73 | -------------------------------------------------------------------------------- /memorymap/iwdg.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace iwdg { 27 | enum { 28 | ADDRESS = alias::APB1 + 0x3000 29 | }; 30 | 31 | struct Registers { 32 | __RW 33 | u32 KR; // 0x00: Key 34 | __RW 35 | u32 PR; // 0x04: Prescaler 36 | __RW 37 | u32 RLR; // 0x08: Reload 38 | __RW 39 | u32 SR; // 0x0C: Status 40 | }; 41 | 42 | namespace kr { 43 | enum { 44 | OFFSET = 0x00 45 | }; 46 | } // namespace kr 47 | 48 | namespace pr { 49 | enum { 50 | OFFSET = 0x04 51 | }; 52 | } // namespace pr 53 | 54 | namespace rlr { 55 | enum { 56 | OFFSET = 0x08 57 | }; 58 | } // namespace rlr 59 | 60 | namespace sr { 61 | enum { 62 | OFFSET = 0x0C 63 | }; 64 | } // namespace sr 65 | } // namespace iwdg 66 | -------------------------------------------------------------------------------- /memorymap/mpu.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace mpu { 27 | enum { 28 | ADDRESS = alias::PPB + 0xD90 29 | }; 30 | 31 | struct Registers { 32 | __RW 33 | u32 TYPER; // 0x00: Type 34 | __RW 35 | u32 CR; // 0x04: Control 36 | __RW 37 | u32 RNR; // 0x08: Region number 38 | __RW 39 | u32 RBAR; // 0x0C: Region base address 40 | __RW 41 | u32 RASR; // 0x10: Region attribute and size 42 | }; 43 | 44 | namespace typer { 45 | enum { 46 | OFFSET = 0x00 47 | }; 48 | } // namespace typer 49 | 50 | namespace control { 51 | enum { 52 | OFFSET = 0x04 53 | }; 54 | } // namespace control 55 | 56 | namespace rnr { 57 | enum { 58 | OFFSET = 0x08 59 | }; 60 | } // namespace rnr 61 | 62 | namespace rbar { 63 | enum { 64 | OFFSET = 0x0C 65 | }; 66 | } // namespace rbar 67 | 68 | namespace rasr { 69 | enum { 70 | OFFSET = 0x10 71 | }; 72 | } // namespace rasr 73 | } // namespace mpu 74 | -------------------------------------------------------------------------------- /memorymap/rng.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace rng { 27 | enum { 28 | ADDRESS = alias::AHB2 + 0x60800 29 | }; 30 | 31 | struct Registers { 32 | __RW 33 | u32 CR; /* 0x00: Control */ 34 | __RW 35 | u32 SR; /* 0x04: Status */ 36 | __RW 37 | u32 DR; /* 0x08: Data */ 38 | }; 39 | 40 | namespace cr { 41 | enum { 42 | OFFSET = 0x00 43 | }; 44 | namespace rngen { 45 | enum { 46 | POSITION = 2, 47 | MASK = 1 << POSITION 48 | }; 49 | enum States { 50 | RANDOM_NUMBER_GENERATOR_DISABLED = 0 << POSITION, 51 | RANDOM_NUMBER_GENERATOR_ENABLED = 1 << POSITION, 52 | }; 53 | } // namespace rngen 54 | 55 | namespace ie { 56 | enum { 57 | POSITION = 3, 58 | MASK = 1 << POSITION 59 | }; 60 | enum States { 61 | INTERRUPT_DISABLED = 0 << POSITION, 62 | INTERRUPT_ENABLED = 1 << POSITION, 63 | }; 64 | } // namespace ie 65 | } // namespace cr 66 | 67 | namespace sr { 68 | enum { 69 | OFFSET = 0x04 70 | }; 71 | namespace drdy { 72 | enum { 73 | POSITION = 0, 74 | MASK = 1 << POSITION 75 | }; 76 | enum States { 77 | NO_VALID_RANDOM_DATA_READY = 0 << POSITION, 78 | VALID_RANDOM_DATA_READY = 1 << POSITION, 79 | }; 80 | } // namespace drdy 81 | 82 | namespace cecs { 83 | enum { 84 | POSITION = 1, 85 | MASK = 1 << POSITION 86 | }; 87 | enum States { 88 | CLOCK_OK = 0 << POSITION, 89 | CLOCK_ERROR_DETECTED = 1 << POSITION, 90 | }; 91 | } // namespace cecs 92 | 93 | namespace secs { 94 | enum { 95 | POSITION = 2, 96 | MASK = 1 << POSITION 97 | }; 98 | enum States { 99 | SEED_OK = 0 << POSITION, 100 | SEED_ERROR_DETECTED = 1 << POSITION, 101 | }; 102 | } // namespace secs 103 | 104 | namespace ceis { 105 | enum { 106 | POSITION = 5, 107 | MASK = 1 << POSITION 108 | }; 109 | enum States { 110 | CLOCK_OK = 0 << POSITION, 111 | CLOCK_ERROR_DETECTED = 1 << POSITION, 112 | }; 113 | } // namespace ceis 114 | 115 | namespace seis { 116 | enum { 117 | POSITION = 6, 118 | MASK = 1 << POSITION 119 | }; 120 | enum States { 121 | SEED_OK = 0 << POSITION, 122 | SEED_ERROR_DETECTED = 1 << POSITION, 123 | }; 124 | } // namespace seis 125 | } // namespace sr 126 | 127 | namespace dr { 128 | enum { 129 | OFFSET = 0x08 130 | }; 131 | } // namespace dr 132 | } // namespace rng 133 | -------------------------------------------------------------------------------- /memorymap/rtc.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace rtc { 27 | struct Registers { 28 | enum { 29 | ADDRESS = alias::APB1 + 0x2800 30 | }; 31 | 32 | #ifdef STM32F1XX 33 | __RW 34 | u32 CR[2]; // 0x00, 0x04: Control 35 | __RW 36 | u32 PRL[2];// 0x08, 0x1C: Prescaler load 37 | __RW 38 | u32 DIV[2];// 0x10, 0x14: Prescaler divider 39 | __RW 40 | u32 CNT[2];// 0x18, 0x1C: Counter 41 | __RW 42 | u32 ALR[2];// 0x20, 0x24: Alarm 43 | #elif defined STM32F2XX 44 | __RW 45 | u32 TR; // 0x00: Time 46 | __RW 47 | u32 DR;// 0x04: Date 48 | __RW 49 | u32 CR;// 0x08: Control 50 | __RW 51 | u32 ISR;// 0x0C: Initialization and status 52 | __RW 53 | u32 PRER;// 0x10: Prescaler 54 | __RW 55 | u32 WUTR;// 0x14: Wakeup timer 56 | __RW 57 | u32 CALIBR;// 0x18: Calibration 58 | __RW 59 | u32 ALRMR[2];// 0x1C, 0x20: Alarm 60 | __RW 61 | u32 WPR;// 0x24: Write protection 62 | u32 _RESERVED0[2]; 63 | __RW 64 | u32 TSTR;// 0x30: Time stamp time 65 | __RW 66 | u32 TSDR;// 0x34: Time stamp date 67 | u32 _RESERVED1[2]; 68 | __RW 69 | u32 TAFCR;// 0x40: Tamper and alternate function configuration 70 | u32 _RESERVED2[3]; 71 | __RW 72 | u32 BKPR[20];// 0x50-0x9C: Backup 73 | #else 74 | __RW 75 | u32 TR; // 0x00: Time 76 | __RW 77 | u32 DR; // 0x04: Date 78 | __RW 79 | u32 CR; // 0x08: Control 80 | __RW 81 | u32 ISR; // 0x0C: Initialization and status 82 | __RW 83 | u32 PRER; // 0x10: Prescaler 84 | __RW 85 | u32 WUTR; // 0x14: Wakeup timer 86 | __RW 87 | u32 CALIBR; // 0x18: Calibration 88 | __RW 89 | u32 ALRMR[2]; // 0x1C, 0x20: Alarm 90 | __RW 91 | u32 WPR; // 0x24: Write protection 92 | __RW 93 | u32 SSR; // 0x28: Sub second 94 | __RW 95 | u32 SHIFTR; // 0x2C: Shift control 96 | __RW 97 | u32 TSTR; // 0x30: Time stamp time 98 | __RW 99 | u32 TSDR; // 0x34: Time stamp date 100 | __RW 101 | u32 TSSSR; // 0x38: Time stamp sub second 102 | __RW 103 | u32 CALR; // 0x3C: Calibration 104 | __RW 105 | u32 TAFCR; // 0x40: Tamper and alternate function configuration 106 | __RW 107 | u32 ALRMSSR[2]; // 0x44, 0x48: Alarm sub second 108 | u32 RESERVED0; 109 | __RW 110 | u32 BKPR[20]; // 0x50-0x9C: Backup 111 | #endif 112 | }; 113 | 114 | // TODO RTC register bits 115 | }// namespace rtc 116 | -------------------------------------------------------------------------------- /memorymap/scb.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | namespace scb { 25 | enum { 26 | ADDRESS = alias::PPB + 0xD00 27 | }; 28 | 29 | struct Registers { 30 | __RW 31 | u32 CPUID; // 0x00: CPU ID 32 | __RW 33 | u32 ICSR; // 0x04: Interrupt control and state 34 | __RW 35 | u32 VTOR; // 0x08: Vector table offset 36 | __RW 37 | u32 AIRCR; // 0x0C: Application interrupt and reset control 38 | __RW 39 | u32 SCR; // 0x10: System control 40 | __RW 41 | u32 CCR; // 0x14: Configuration and control 42 | __RW 43 | u32 SHPR1; // 0x18: System handler priority 1 44 | __RW 45 | u32 SHPR2; // 0x1C: System handler priority 2 46 | __RW 47 | u32 SHPR3; // 0x20: System handler priority 3 48 | __RW 49 | u32 SHCRS; // 0x24: System handler control and state 50 | __RW 51 | u32 CFSR; // 0x28: Configurable fault status 52 | __RW 53 | u32 HFSR; // 0x2C: Hard fault status 54 | __RW 55 | u32 MMAR; // 0x30: Memory management fault address 56 | __RW 57 | u32 BFAR; // 0x34: Bus fault address 58 | __RW 59 | u32 AFSR; // 0x38: Auxiliary fault status 60 | }; 61 | 62 | // TODO SCB register bits 63 | }// namespace scb 64 | 65 | -------------------------------------------------------------------------------- /memorymap/sdio.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace sdio { 27 | enum { 28 | #ifdef STM32F1XX 29 | ADDRESS = alias::PERIPH + 0x18000 30 | #else 31 | ADDRESS = alias::APB2 + 0x2C00 32 | #endif 33 | }; 34 | 35 | struct Registers { 36 | __RW 37 | u32 POWER; // 0x00: Power control 38 | __RW 39 | u32 CLKCR; // 0x04: Clock control 40 | __RW 41 | u32 ARG; // 0x08: Argument 42 | __RW 43 | u32 CMD; // 0x0C: Command 44 | __R 45 | u32 RESPCMD; // 0x10: Command response 46 | __R 47 | u32 RESP[4]; // 0x14-0x20: Response 48 | __RW 49 | u32 DTIMER; // 0x24: Data timer 50 | __RW 51 | u32 DLEN; // 0x28: Data length 52 | __RW 53 | u32 DCTRL; // 0x2C: Data control 54 | __R 55 | u32 DCOUNT; // 0x30: Data counter 56 | __R 57 | u32 STA; // 0x34: Status 58 | __RW 59 | u32 ICR; // 0x38: Interrupt clear 60 | __RW 61 | u32 MASK; // 0x3C: Mask 62 | u32 _RESERVED0[2]; 63 | __R 64 | u32 FIFOCNT; // 0x48: FIFO counter 65 | u32 _RESERVED1[13]; 66 | __RW 67 | u32 FIFO; // 0x80: Data FIFO 68 | }; 69 | 70 | namespace power { 71 | enum { 72 | OFFSET = 0x00 73 | }; 74 | } // namespace power 75 | 76 | namespace clkcr { 77 | enum { 78 | OFFSET = 0x04 79 | }; 80 | } // namespace clkcr 81 | 82 | namespace arg { 83 | enum { 84 | OFFSET = 0x08 85 | }; 86 | } // namespace arg 87 | 88 | namespace cmd { 89 | enum { 90 | OFFSET = 0x0C 91 | }; 92 | } // namespace cmd 93 | 94 | namespace respcmd { 95 | enum { 96 | OFFSET = 0x10 97 | }; 98 | } // namespace respcmd 99 | 100 | namespace dtimer { 101 | enum { 102 | OFFSET = 0x24 103 | }; 104 | } // namespace dtimer 105 | 106 | namespace dlen { 107 | enum { 108 | OFFSET = 0x28 109 | }; 110 | } // namespace dlen 111 | 112 | namespace dctrl { 113 | enum { 114 | OFFSET = 0x2C 115 | }; 116 | } // namespace dctrl 117 | 118 | namespace dcount { 119 | enum { 120 | OFFSET = 0x30 121 | }; 122 | } // namespace dcount 123 | 124 | namespace sta { 125 | enum { 126 | OFFSET = 0x34 127 | }; 128 | } // namespace sta 129 | 130 | namespace icr { 131 | enum { 132 | OFFSET = 0x38 133 | }; 134 | } // namespace icr 135 | 136 | namespace fifocnt { 137 | enum { 138 | OFFSET = 0x48 139 | }; 140 | } // namespace fifocnt 141 | 142 | namespace fifo { 143 | enum { 144 | OFFSET = 0x80 145 | }; 146 | } // namespace fifo 147 | } // namespace sdio 148 | -------------------------------------------------------------------------------- /memorymap/stk.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace stk { 27 | enum { 28 | ADDRESS = alias::PPB + 0x10 29 | }; 30 | 31 | struct Registers { 32 | __RW 33 | u32 CTRL; // 0x00: Control and status 34 | __RW 35 | u32 LOAD; // 0x04: Reload value 36 | __RW 37 | u32 VAL; // 0x08: Current value 38 | __RW 39 | u32 CALIB; // 0x0C: Calibration value 40 | }; 41 | 42 | // TODO STK register bits 43 | }// namespace stk 44 | -------------------------------------------------------------------------------- /memorymap/syscfg.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace syscfg { 27 | enum { 28 | ADDRESS = alias::APB2 + 0x3800 29 | }; 30 | 31 | struct Registers { 32 | __RW 33 | u32 MEMRMP; // 0x00: Memory remap 34 | __RW 35 | u32 PMC; // 0x04: Peripheral mode configuration 36 | __RW 37 | u32 EXTICR[4]; // 0x08: External interrupt configuration 38 | u32 _RESERVED[2]; 39 | __RW 40 | u32 CMPCR; // 0x20: Compensation cell control 41 | }; 42 | 43 | namespace memrmp { 44 | enum { 45 | OFFSET = 0x00 46 | }; 47 | // TODO SYSCFG MEMRMP bits 48 | }// namespace memrmp 49 | 50 | namespace pmc { 51 | enum { 52 | OFFSET = 0x04 53 | }; 54 | // TODO SYSCFG PMC bits 55 | }// namespace pmc 56 | 57 | namespace exticr1 { 58 | enum { 59 | OFFSET = 0x08 60 | }; 61 | } // namespace exticr1 62 | 63 | namespace exticr2 { 64 | enum { 65 | OFFSET = 0x0C 66 | }; 67 | } // namespace exticr2 68 | 69 | namespace exticr3 { 70 | enum { 71 | OFFSET = 0x10 72 | }; 73 | } // namespace exticr3 74 | 75 | namespace exticr4 { 76 | enum { 77 | OFFSET = 0x14 78 | }; 79 | } // namespace exticr4 80 | 81 | namespace exticr { 82 | enum { 83 | MASK = 0b1111 84 | }; 85 | 86 | enum States { 87 | PA = 0, 88 | PB = 1, 89 | PC = 2, 90 | PD = 3, 91 | PE = 4, 92 | PF = 5, 93 | PG = 6, 94 | PH = 7, 95 | PI = 8, 96 | }; 97 | 98 | } // namespace exticr 99 | 100 | namespace cmpcr { 101 | enum { 102 | OFFSET = 0x20 103 | }; 104 | // TODO SYSCFG CMPCR bits 105 | }// namespace cmpcr 106 | } // namespace syscfg 107 | -------------------------------------------------------------------------------- /memorymap/wwdg.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2012 Jorge Aparicio 4 | * 5 | * This file is part of libstm32pp. 6 | * 7 | * libstm32pp is free software: you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License as published by the Free 9 | * Software Foundation, either version 3 of the License, or (at your option) 10 | * any later version. 11 | * 12 | * libstm32pp is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libstm32pp. If not, see . 19 | * 20 | ******************************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include "common.hpp" 25 | 26 | namespace wwdg { 27 | enum { 28 | ADDRESS = alias::APB1 + 0x2C00 29 | }; 30 | 31 | struct Registers { 32 | __RW 33 | u32 CR; // 0x00: Control 34 | __RW 35 | u32 CFR; // 0x04: Configuration 36 | __RW 37 | u32 SR; // 0x08: Status 38 | }; 39 | 40 | // TODO WWDG register bits 41 | }// namespace wwdg 42 | --------------------------------------------------------------------------------