├── .gitignore ├── Inc ├── main.h ├── stm32f4xx_hal_conf.h └── stm32f4xx_it.h ├── LICENSE ├── Makefile ├── README.md ├── STM32F411RETx_FLASH.ld ├── Src ├── gpio.tmp ├── license.tmp ├── main.c ├── stm32f4xx_hal_msp.c ├── stm32f4xx_it.c ├── system.tmp └── system_stm32f4xx.c ├── cubefix.sh ├── img ├── image-to-mem.py └── parrot_128x128.png ├── main.ioc ├── mx.scratch ├── st7735 ├── fonts.c ├── fonts.h ├── st7735.c ├── st7735.h └── testimg.h └── startup_stm32f411xe.s /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.backup 3 | .mxproject 4 | -------------------------------------------------------------------------------- /Inc/main.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : main.hpp 4 | * Description : This file contains the common defines of the application 5 | ****************************************************************************** 6 | ** This notice applies to any and all portions of this file 7 | * that are not between comment pairs USER CODE BEGIN and 8 | * USER CODE END. Other portions of this file, whether 9 | * inserted by the user or by software development tools 10 | * are owned by their respective copyright owners. 11 | * 12 | * COPYRIGHT(c) 2018 STMicroelectronics 13 | * 14 | * Redistribution and use in source and binary forms, with or without modification, 15 | * are permitted provided that the following conditions are met: 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 22 | * may be used to endorse or promote products derived from this software 23 | * without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | ****************************************************************************** 37 | */ 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __MAIN_H 40 | #define __MAIN_H 41 | /* Includes ------------------------------------------------------------------*/ 42 | 43 | /* Includes ------------------------------------------------------------------*/ 44 | /* USER CODE BEGIN Includes */ 45 | 46 | /* USER CODE END Includes */ 47 | 48 | /* Private define ------------------------------------------------------------*/ 49 | 50 | #define B1_Pin GPIO_PIN_13 51 | #define B1_GPIO_Port GPIOC 52 | #define USART_TX_Pin GPIO_PIN_2 53 | #define USART_TX_GPIO_Port GPIOA 54 | #define USART_RX_Pin GPIO_PIN_3 55 | #define USART_RX_GPIO_Port GPIOA 56 | #define Btn2_Pin GPIO_PIN_10 57 | #define Btn2_GPIO_Port GPIOB 58 | #define Btn1_Pin GPIO_PIN_8 59 | #define Btn1_GPIO_Port GPIOA 60 | #define TMS_Pin GPIO_PIN_13 61 | #define TMS_GPIO_Port GPIOA 62 | #define TCK_Pin GPIO_PIN_14 63 | #define TCK_GPIO_Port GPIOA 64 | #define SWO_Pin GPIO_PIN_3 65 | #define SWO_GPIO_Port GPIOB 66 | #define Btn3_Pin GPIO_PIN_4 67 | #define Btn3_GPIO_Port GPIOB 68 | #define Btn4_Pin GPIO_PIN_5 69 | #define Btn4_GPIO_Port GPIOB 70 | 71 | /* ########################## Assert Selection ############################## */ 72 | /** 73 | * @brief Uncomment the line below to expanse the "assert_param" macro in the 74 | * HAL drivers code 75 | */ 76 | /* #define USE_FULL_ASSERT 1U */ 77 | 78 | /* USER CODE BEGIN Private defines */ 79 | 80 | /* USER CODE END Private defines */ 81 | 82 | #ifdef __cplusplus 83 | extern "C" { 84 | #endif 85 | void _Error_Handler(char *, int); 86 | 87 | #define Error_Handler() _Error_Handler(__FILE__, __LINE__) 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | #endif /* __MAIN_H */ 101 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 102 | -------------------------------------------------------------------------------- /Inc/stm32f4xx_hal_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_conf.h 4 | * @brief HAL configuration file. 5 | ****************************************************************************** 6 | * @attention 7 | * 8 | *

© COPYRIGHT(c) 2018 STMicroelectronics

9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Define to prevent recursive inclusion -------------------------------------*/ 36 | #ifndef __STM32F4xx_HAL_CONF_H 37 | #define __STM32F4xx_HAL_CONF_H 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #include "main.h" 44 | /* Exported types ------------------------------------------------------------*/ 45 | /* Exported constants --------------------------------------------------------*/ 46 | 47 | /* ########################## Module Selection ############################## */ 48 | /** 49 | * @brief This is the list of modules to be used in the HAL driver 50 | */ 51 | #define HAL_MODULE_ENABLED 52 | 53 | /* #define HAL_ADC_MODULE_ENABLED */ 54 | /* #define HAL_CRYP_MODULE_ENABLED */ 55 | /* #define HAL_CAN_MODULE_ENABLED */ 56 | /* #define HAL_CRC_MODULE_ENABLED */ 57 | /* #define HAL_CRYP_MODULE_ENABLED */ 58 | /* #define HAL_DAC_MODULE_ENABLED */ 59 | /* #define HAL_DCMI_MODULE_ENABLED */ 60 | /* #define HAL_DMA2D_MODULE_ENABLED */ 61 | /* #define HAL_ETH_MODULE_ENABLED */ 62 | /* #define HAL_NAND_MODULE_ENABLED */ 63 | /* #define HAL_NOR_MODULE_ENABLED */ 64 | /* #define HAL_PCCARD_MODULE_ENABLED */ 65 | /* #define HAL_SRAM_MODULE_ENABLED */ 66 | /* #define HAL_SDRAM_MODULE_ENABLED */ 67 | /* #define HAL_HASH_MODULE_ENABLED */ 68 | /* #define HAL_I2C_MODULE_ENABLED */ 69 | /* #define HAL_I2S_MODULE_ENABLED */ 70 | /* #define HAL_IWDG_MODULE_ENABLED */ 71 | /* #define HAL_LTDC_MODULE_ENABLED */ 72 | /* #define HAL_RNG_MODULE_ENABLED */ 73 | #define HAL_RTC_MODULE_ENABLED 74 | /* #define HAL_SAI_MODULE_ENABLED */ 75 | /* #define HAL_SD_MODULE_ENABLED */ 76 | /* #define HAL_MMC_MODULE_ENABLED */ 77 | #define HAL_SPI_MODULE_ENABLED 78 | /* #define HAL_TIM_MODULE_ENABLED */ 79 | #define HAL_UART_MODULE_ENABLED 80 | /* #define HAL_USART_MODULE_ENABLED */ 81 | /* #define HAL_IRDA_MODULE_ENABLED */ 82 | /* #define HAL_SMARTCARD_MODULE_ENABLED */ 83 | /* #define HAL_WWDG_MODULE_ENABLED */ 84 | /* #define HAL_PCD_MODULE_ENABLED */ 85 | /* #define HAL_HCD_MODULE_ENABLED */ 86 | /* #define HAL_DSI_MODULE_ENABLED */ 87 | /* #define HAL_QSPI_MODULE_ENABLED */ 88 | /* #define HAL_QSPI_MODULE_ENABLED */ 89 | /* #define HAL_CEC_MODULE_ENABLED */ 90 | /* #define HAL_FMPI2C_MODULE_ENABLED */ 91 | /* #define HAL_SPDIFRX_MODULE_ENABLED */ 92 | /* #define HAL_DFSDM_MODULE_ENABLED */ 93 | /* #define HAL_LPTIM_MODULE_ENABLED */ 94 | #define HAL_GPIO_MODULE_ENABLED 95 | #define HAL_DMA_MODULE_ENABLED 96 | #define HAL_RCC_MODULE_ENABLED 97 | #define HAL_FLASH_MODULE_ENABLED 98 | #define HAL_PWR_MODULE_ENABLED 99 | #define HAL_CORTEX_MODULE_ENABLED 100 | 101 | /* ########################## HSE/HSI Values adaptation ##################### */ 102 | /** 103 | * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. 104 | * This value is used by the RCC HAL module to compute the system frequency 105 | * (when HSE is used as system clock source, directly or through the PLL). 106 | */ 107 | #if !defined (HSE_VALUE) 108 | #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */ 109 | #endif /* HSE_VALUE */ 110 | 111 | #if !defined (HSE_STARTUP_TIMEOUT) 112 | #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ 113 | #endif /* HSE_STARTUP_TIMEOUT */ 114 | 115 | /** 116 | * @brief Internal High Speed oscillator (HSI) value. 117 | * This value is used by the RCC HAL module to compute the system frequency 118 | * (when HSI is used as system clock source, directly or through the PLL). 119 | */ 120 | #if !defined (HSI_VALUE) 121 | #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ 122 | #endif /* HSI_VALUE */ 123 | 124 | /** 125 | * @brief Internal Low Speed oscillator (LSI) value. 126 | */ 127 | #if !defined (LSI_VALUE) 128 | #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ 129 | #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz 130 | The real value may vary depending on the variations 131 | in voltage and temperature.*/ 132 | /** 133 | * @brief External Low Speed oscillator (LSE) value. 134 | */ 135 | #if !defined (LSE_VALUE) 136 | #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ 137 | #endif /* LSE_VALUE */ 138 | 139 | #if !defined (LSE_STARTUP_TIMEOUT) 140 | #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ 141 | #endif /* LSE_STARTUP_TIMEOUT */ 142 | 143 | /** 144 | * @brief External clock source for I2S peripheral 145 | * This value is used by the I2S HAL module to compute the I2S clock source 146 | * frequency, this source is inserted directly through I2S_CKIN pad. 147 | */ 148 | #if !defined (EXTERNAL_CLOCK_VALUE) 149 | #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ 150 | #endif /* EXTERNAL_CLOCK_VALUE */ 151 | 152 | /* Tip: To avoid modifying this file each time you need to use different HSE, 153 | === you can define the HSE value in your toolchain compiler preprocessor. */ 154 | 155 | /* ########################### System Configuration ######################### */ 156 | /** 157 | * @brief This is the HAL system configuration section 158 | */ 159 | #define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ 160 | #define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ 161 | #define USE_RTOS 0U 162 | #define PREFETCH_ENABLE 1U 163 | #define INSTRUCTION_CACHE_ENABLE 1U 164 | #define DATA_CACHE_ENABLE 1U 165 | 166 | /* ########################## Assert Selection ############################## */ 167 | /** 168 | * @brief Uncomment the line below to expanse the "assert_param" macro in the 169 | * HAL drivers code 170 | */ 171 | /* #define USE_FULL_ASSERT 1U */ 172 | 173 | /* ################## Ethernet peripheral configuration ##################### */ 174 | 175 | /* Section 1 : Ethernet peripheral configuration */ 176 | 177 | /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ 178 | #define MAC_ADDR0 2U 179 | #define MAC_ADDR1 0U 180 | #define MAC_ADDR2 0U 181 | #define MAC_ADDR3 0U 182 | #define MAC_ADDR4 0U 183 | #define MAC_ADDR5 0U 184 | 185 | /* Definition of the Ethernet driver buffers size and count */ 186 | #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ 187 | #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ 188 | #define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ 189 | #define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ 190 | 191 | /* Section 2: PHY configuration section */ 192 | 193 | /* DP83848_PHY_ADDRESS Address*/ 194 | #define DP83848_PHY_ADDRESS 0x01U 195 | /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ 196 | #define PHY_RESET_DELAY ((uint32_t)0x000000FFU) 197 | /* PHY Configuration delay */ 198 | #define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) 199 | 200 | #define PHY_READ_TO ((uint32_t)0x0000FFFFU) 201 | #define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) 202 | 203 | /* Section 3: Common PHY Registers */ 204 | 205 | #define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ 206 | #define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ 207 | 208 | #define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ 209 | #define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ 210 | #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ 211 | #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ 212 | #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ 213 | #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ 214 | #define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ 215 | #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ 216 | #define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ 217 | #define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ 218 | 219 | #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ 220 | #define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ 221 | #define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ 222 | 223 | /* Section 4: Extended PHY Registers */ 224 | #define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ 225 | 226 | #define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ 227 | #define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ 228 | 229 | /* ################## SPI peripheral configuration ########################## */ 230 | 231 | /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver 232 | * Activated: CRC code is present inside driver 233 | * Deactivated: CRC code cleaned from driver 234 | */ 235 | 236 | #define USE_SPI_CRC 0U 237 | 238 | /* Includes ------------------------------------------------------------------*/ 239 | /** 240 | * @brief Include module's header file 241 | */ 242 | 243 | #ifdef HAL_RCC_MODULE_ENABLED 244 | #include "stm32f4xx_hal_rcc.h" 245 | #endif /* HAL_RCC_MODULE_ENABLED */ 246 | 247 | #ifdef HAL_GPIO_MODULE_ENABLED 248 | #include "stm32f4xx_hal_gpio.h" 249 | #endif /* HAL_GPIO_MODULE_ENABLED */ 250 | 251 | #ifdef HAL_DMA_MODULE_ENABLED 252 | #include "stm32f4xx_hal_dma.h" 253 | #endif /* HAL_DMA_MODULE_ENABLED */ 254 | 255 | #ifdef HAL_CORTEX_MODULE_ENABLED 256 | #include "stm32f4xx_hal_cortex.h" 257 | #endif /* HAL_CORTEX_MODULE_ENABLED */ 258 | 259 | #ifdef HAL_ADC_MODULE_ENABLED 260 | #include "stm32f4xx_hal_adc.h" 261 | #endif /* HAL_ADC_MODULE_ENABLED */ 262 | 263 | #ifdef HAL_CAN_MODULE_ENABLED 264 | #include "stm32f4xx_hal_can.h" 265 | #endif /* HAL_CAN_MODULE_ENABLED */ 266 | 267 | #ifdef HAL_CRC_MODULE_ENABLED 268 | #include "stm32f4xx_hal_crc.h" 269 | #endif /* HAL_CRC_MODULE_ENABLED */ 270 | 271 | #ifdef HAL_CRYP_MODULE_ENABLED 272 | #include "stm32f4xx_hal_cryp.h" 273 | #endif /* HAL_CRYP_MODULE_ENABLED */ 274 | 275 | #ifdef HAL_DMA2D_MODULE_ENABLED 276 | #include "stm32f4xx_hal_dma2d.h" 277 | #endif /* HAL_DMA2D_MODULE_ENABLED */ 278 | 279 | #ifdef HAL_DAC_MODULE_ENABLED 280 | #include "stm32f4xx_hal_dac.h" 281 | #endif /* HAL_DAC_MODULE_ENABLED */ 282 | 283 | #ifdef HAL_DCMI_MODULE_ENABLED 284 | #include "stm32f4xx_hal_dcmi.h" 285 | #endif /* HAL_DCMI_MODULE_ENABLED */ 286 | 287 | #ifdef HAL_ETH_MODULE_ENABLED 288 | #include "stm32f4xx_hal_eth.h" 289 | #endif /* HAL_ETH_MODULE_ENABLED */ 290 | 291 | #ifdef HAL_FLASH_MODULE_ENABLED 292 | #include "stm32f4xx_hal_flash.h" 293 | #endif /* HAL_FLASH_MODULE_ENABLED */ 294 | 295 | #ifdef HAL_SRAM_MODULE_ENABLED 296 | #include "stm32f4xx_hal_sram.h" 297 | #endif /* HAL_SRAM_MODULE_ENABLED */ 298 | 299 | #ifdef HAL_NOR_MODULE_ENABLED 300 | #include "stm32f4xx_hal_nor.h" 301 | #endif /* HAL_NOR_MODULE_ENABLED */ 302 | 303 | #ifdef HAL_NAND_MODULE_ENABLED 304 | #include "stm32f4xx_hal_nand.h" 305 | #endif /* HAL_NAND_MODULE_ENABLED */ 306 | 307 | #ifdef HAL_PCCARD_MODULE_ENABLED 308 | #include "stm32f4xx_hal_pccard.h" 309 | #endif /* HAL_PCCARD_MODULE_ENABLED */ 310 | 311 | #ifdef HAL_SDRAM_MODULE_ENABLED 312 | #include "stm32f4xx_hal_sdram.h" 313 | #endif /* HAL_SDRAM_MODULE_ENABLED */ 314 | 315 | #ifdef HAL_HASH_MODULE_ENABLED 316 | #include "stm32f4xx_hal_hash.h" 317 | #endif /* HAL_HASH_MODULE_ENABLED */ 318 | 319 | #ifdef HAL_I2C_MODULE_ENABLED 320 | #include "stm32f4xx_hal_i2c.h" 321 | #endif /* HAL_I2C_MODULE_ENABLED */ 322 | 323 | #ifdef HAL_I2S_MODULE_ENABLED 324 | #include "stm32f4xx_hal_i2s.h" 325 | #endif /* HAL_I2S_MODULE_ENABLED */ 326 | 327 | #ifdef HAL_IWDG_MODULE_ENABLED 328 | #include "stm32f4xx_hal_iwdg.h" 329 | #endif /* HAL_IWDG_MODULE_ENABLED */ 330 | 331 | #ifdef HAL_LTDC_MODULE_ENABLED 332 | #include "stm32f4xx_hal_ltdc.h" 333 | #endif /* HAL_LTDC_MODULE_ENABLED */ 334 | 335 | #ifdef HAL_PWR_MODULE_ENABLED 336 | #include "stm32f4xx_hal_pwr.h" 337 | #endif /* HAL_PWR_MODULE_ENABLED */ 338 | 339 | #ifdef HAL_RNG_MODULE_ENABLED 340 | #include "stm32f4xx_hal_rng.h" 341 | #endif /* HAL_RNG_MODULE_ENABLED */ 342 | 343 | #ifdef HAL_RTC_MODULE_ENABLED 344 | #include "stm32f4xx_hal_rtc.h" 345 | #endif /* HAL_RTC_MODULE_ENABLED */ 346 | 347 | #ifdef HAL_SAI_MODULE_ENABLED 348 | #include "stm32f4xx_hal_sai.h" 349 | #endif /* HAL_SAI_MODULE_ENABLED */ 350 | 351 | #ifdef HAL_SD_MODULE_ENABLED 352 | #include "stm32f4xx_hal_sd.h" 353 | #endif /* HAL_SD_MODULE_ENABLED */ 354 | 355 | #ifdef HAL_MMC_MODULE_ENABLED 356 | #include "stm32f4xx_hal_mmc.h" 357 | #endif /* HAL_MMC_MODULE_ENABLED */ 358 | 359 | #ifdef HAL_SPI_MODULE_ENABLED 360 | #include "stm32f4xx_hal_spi.h" 361 | #endif /* HAL_SPI_MODULE_ENABLED */ 362 | 363 | #ifdef HAL_TIM_MODULE_ENABLED 364 | #include "stm32f4xx_hal_tim.h" 365 | #endif /* HAL_TIM_MODULE_ENABLED */ 366 | 367 | #ifdef HAL_UART_MODULE_ENABLED 368 | #include "stm32f4xx_hal_uart.h" 369 | #endif /* HAL_UART_MODULE_ENABLED */ 370 | 371 | #ifdef HAL_USART_MODULE_ENABLED 372 | #include "stm32f4xx_hal_usart.h" 373 | #endif /* HAL_USART_MODULE_ENABLED */ 374 | 375 | #ifdef HAL_IRDA_MODULE_ENABLED 376 | #include "stm32f4xx_hal_irda.h" 377 | #endif /* HAL_IRDA_MODULE_ENABLED */ 378 | 379 | #ifdef HAL_SMARTCARD_MODULE_ENABLED 380 | #include "stm32f4xx_hal_smartcard.h" 381 | #endif /* HAL_SMARTCARD_MODULE_ENABLED */ 382 | 383 | #ifdef HAL_WWDG_MODULE_ENABLED 384 | #include "stm32f4xx_hal_wwdg.h" 385 | #endif /* HAL_WWDG_MODULE_ENABLED */ 386 | 387 | #ifdef HAL_PCD_MODULE_ENABLED 388 | #include "stm32f4xx_hal_pcd.h" 389 | #endif /* HAL_PCD_MODULE_ENABLED */ 390 | 391 | #ifdef HAL_HCD_MODULE_ENABLED 392 | #include "stm32f4xx_hal_hcd.h" 393 | #endif /* HAL_HCD_MODULE_ENABLED */ 394 | 395 | #ifdef HAL_DSI_MODULE_ENABLED 396 | #include "stm32f4xx_hal_dsi.h" 397 | #endif /* HAL_DSI_MODULE_ENABLED */ 398 | 399 | #ifdef HAL_QSPI_MODULE_ENABLED 400 | #include "stm32f4xx_hal_qspi.h" 401 | #endif /* HAL_QSPI_MODULE_ENABLED */ 402 | 403 | #ifdef HAL_CEC_MODULE_ENABLED 404 | #include "stm32f4xx_hal_cec.h" 405 | #endif /* HAL_CEC_MODULE_ENABLED */ 406 | 407 | #ifdef HAL_FMPI2C_MODULE_ENABLED 408 | #include "stm32f4xx_hal_fmpi2c.h" 409 | #endif /* HAL_FMPI2C_MODULE_ENABLED */ 410 | 411 | #ifdef HAL_SPDIFRX_MODULE_ENABLED 412 | #include "stm32f4xx_hal_spdifrx.h" 413 | #endif /* HAL_SPDIFRX_MODULE_ENABLED */ 414 | 415 | #ifdef HAL_DFSDM_MODULE_ENABLED 416 | #include "stm32f4xx_hal_dfsdm.h" 417 | #endif /* HAL_DFSDM_MODULE_ENABLED */ 418 | 419 | #ifdef HAL_LPTIM_MODULE_ENABLED 420 | #include "stm32f4xx_hal_lptim.h" 421 | #endif /* HAL_LPTIM_MODULE_ENABLED */ 422 | 423 | /* Exported macro ------------------------------------------------------------*/ 424 | #ifdef USE_FULL_ASSERT 425 | /** 426 | * @brief The assert_param macro is used for function's parameters check. 427 | * @param expr: If expr is false, it calls assert_failed function 428 | * which reports the name of the source file and the source 429 | * line number of the call that failed. 430 | * If expr is true, it returns no value. 431 | * @retval None 432 | */ 433 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) 434 | /* Exported functions ------------------------------------------------------- */ 435 | void assert_failed(uint8_t* file, uint32_t line); 436 | #else 437 | #define assert_param(expr) ((void)0U) 438 | #endif /* USE_FULL_ASSERT */ 439 | 440 | #ifdef __cplusplus 441 | } 442 | #endif 443 | 444 | #endif /* __STM32F4xx_HAL_CONF_H */ 445 | 446 | 447 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 448 | -------------------------------------------------------------------------------- /Inc/stm32f4xx_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_it.h 4 | * @brief This file contains the headers of the interrupt handlers. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2018 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __STM32F4xx_IT_H 36 | #define __STM32F4xx_IT_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | #include "stm32f4xx_hal.h" 44 | #include "main.h" 45 | /* Exported types ------------------------------------------------------------*/ 46 | /* Exported constants --------------------------------------------------------*/ 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* Exported functions ------------------------------------------------------- */ 49 | 50 | void SysTick_Handler(void); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif /* __STM32F4xx_IT_H */ 57 | 58 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Aleksander Alekseev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ########################################################################################################################## 2 | # File automatically-generated by tool: [projectgenerator] version: [2.26.0] date: [Thu Jan 04 15:34:05 MSK 2018] 3 | ########################################################################################################################## 4 | 5 | # ------------------------------------------------ 6 | # Generic Makefile (based on gcc) 7 | # 8 | # ChangeLog : 9 | # 2017-02-10 - Several enhancements + project update mode 10 | # 2015-07-22 - first version 11 | # ------------------------------------------------ 12 | 13 | ###################################### 14 | # target 15 | ###################################### 16 | TARGET = main 17 | FIRMWARE = $(HOME)/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0 18 | 19 | 20 | ###################################### 21 | # building variables 22 | ###################################### 23 | # debug build? 24 | DEBUG = 1 25 | # optimization 26 | OPT = -Og -Wall 27 | 28 | 29 | ####################################### 30 | # paths 31 | ####################################### 32 | # source path 33 | SOURCES_DIR = \ 34 | Drivers/STM32F4xx_HAL_Driver \ 35 | Application/User/Src/stm32f4xx_it.c \ 36 | Application/User/Src/main.c \ 37 | Drivers \ 38 | Application \ 39 | Application/User \ 40 | Application/MAKEFILE \ 41 | Drivers/CMSIS \ 42 | Application/User/Src/stm32f4xx_hal_msp.c \ 43 | Application/User/Src 44 | 45 | # firmware library path 46 | PERIFLIB_PATH = 47 | 48 | # Build path 49 | BUILD_DIR = build 50 | 51 | ###################################### 52 | # source 53 | ###################################### 54 | # C sources 55 | C_SOURCES = \ 56 | Src/main.c \ 57 | st7735/st7735.c \ 58 | st7735/fonts.c \ 59 | Src/stm32f4xx_it.c \ 60 | Src/system_stm32f4xx.c \ 61 | Src/stm32f4xx_hal_msp.c \ 62 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c \ 63 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \ 64 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \ 65 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \ 66 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \ 67 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \ 68 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \ 69 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \ 70 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \ 71 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \ 72 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \ 73 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \ 74 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc.c \ 75 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc_ex.c \ 76 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \ 77 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \ 78 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c \ 79 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c 80 | 81 | # $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c 82 | # $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c 83 | 84 | # ASM sources 85 | ASM_SOURCES = \ 86 | startup_stm32f411xe.s 87 | 88 | 89 | ###################################### 90 | # firmware library 91 | ###################################### 92 | PERIFLIB_SOURCES = 93 | 94 | 95 | ####################################### 96 | # binaries 97 | ####################################### 98 | BINPATH=/usr/bin 99 | PREFIX=arm-none-eabi- 100 | CC = $(BINPATH)/$(PREFIX)gcc 101 | AS = $(BINPATH)/$(PREFIX)gcc -x assembler-with-cpp 102 | CP = $(BINPATH)/$(PREFIX)objcopy 103 | AR = $(BINPATH)/$(PREFIX)ar 104 | SZ = $(BINPATH)/$(PREFIX)size 105 | HEX = $(CP) -O ihex 106 | BIN = $(CP) -O binary -S 107 | 108 | ####################################### 109 | # CFLAGS 110 | ####################################### 111 | # cpu 112 | CPU = -mcpu=cortex-m4 113 | 114 | # fpu 115 | FPU = -mfpu=fpv4-sp-d16 116 | 117 | # float-abi 118 | FLOAT-ABI = -mfloat-abi=hard 119 | 120 | # mcu 121 | MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) 122 | 123 | # macros for gcc 124 | # AS defines 125 | AS_DEFS = 126 | 127 | # C defines 128 | C_DEFS = \ 129 | -DUSE_HAL_DRIVER \ 130 | -DSTM32F411xE 131 | 132 | 133 | # AS includes 134 | AS_INCLUDES = 135 | 136 | # C includes 137 | C_INCLUDES = \ 138 | -IInc \ 139 | -Ist7735 \ 140 | -I$(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Inc \ 141 | -I$(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy \ 142 | -I$(FIRMWARE)/Drivers/CMSIS/Device/ST/STM32F4xx/Include \ 143 | -I$(FIRMWARE)/Drivers/CMSIS/Include 144 | 145 | 146 | # compile gcc flags 147 | ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 148 | 149 | CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 150 | 151 | ifeq ($(DEBUG), 1) 152 | CFLAGS += -g -gdwarf-2 153 | endif 154 | 155 | 156 | # Generate dependency information 157 | CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" 158 | 159 | 160 | ####################################### 161 | # LDFLAGS 162 | ####################################### 163 | # link script 164 | LDSCRIPT = STM32F411RETx_FLASH.ld 165 | 166 | # libraries 167 | LIBS = -lc -lm -lnosys 168 | LIBDIR = 169 | LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections 170 | 171 | # default action: build all 172 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin 173 | 174 | 175 | ####################################### 176 | # build the application 177 | ####################################### 178 | # list of objects 179 | OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) 180 | vpath %.c $(sort $(dir $(C_SOURCES))) 181 | # list of ASM program objects 182 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) 183 | vpath %.s $(sort $(dir $(ASM_SOURCES))) 184 | 185 | $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 186 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ 187 | 188 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) 189 | $(AS) -c $(CFLAGS) $< -o $@ 190 | 191 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile 192 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ 193 | $(SZ) $@ 194 | 195 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 196 | $(HEX) $< $@ 197 | 198 | $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 199 | $(BIN) $< $@ 200 | 201 | $(BUILD_DIR): 202 | mkdir $@ 203 | 204 | ####################################### 205 | # clean up 206 | ####################################### 207 | clean: 208 | -rm -fR .dep $(BUILD_DIR) 209 | 210 | flash: all 211 | st-flash --reset write build/$(TARGET).bin 0x8000000 212 | 213 | erase: 214 | st-flash --reset erase 215 | 216 | uart: 217 | screen /dev/ttyACM0 218 | 219 | ####################################### 220 | # dependencies 221 | ####################################### 222 | -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) 223 | 224 | # *** EOF *** 225 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # stm32-rtc-example 2 | STM32: example of usage of internal RTC 3 | -------------------------------------------------------------------------------- /STM32F411RETx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Abstract : Linker script for STM32F411RETx Device with 8 | ** 512KByte FLASH, 128KByte RAM 9 | ** 10 | ** Set heap size, stack size and stack location according 11 | ** to application requirements. 12 | ** 13 | ** Set memory bank area and size if external memory is used. 14 | ** 15 | ** Target : STMicroelectronics STM32 16 | ** 17 | ** 18 | ** Distribution: The file is distributed as is, without any warranty 19 | ** of any kind. 20 | ** 21 | ** (c)Copyright Ac6. 22 | ** You may use this file as-is or modify it according to the needs of your 23 | ** project. Distribution of this file (unmodified or modified) is not 24 | ** permitted. Ac6 permit registered System Workbench for MCU users the 25 | ** rights to distribute the assembled, compiled & linked contents of this 26 | ** file as part of an application binary file, provided that it is built 27 | ** using the System Workbench for MCU toolchain. 28 | ** 29 | ***************************************************************************** 30 | */ 31 | 32 | /* Entry Point */ 33 | ENTRY(Reset_Handler) 34 | 35 | /* Highest address of the user mode stack */ 36 | _estack = 0x20020000; /* end of RAM */ 37 | /* Generate a link error if heap and stack don't fit into RAM */ 38 | _Min_Heap_Size = 0x200; /* required amount of heap */ 39 | _Min_Stack_Size = 0x400; /* required amount of stack */ 40 | 41 | /* Specify the memory areas */ 42 | MEMORY 43 | { 44 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 45 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K 46 | } 47 | 48 | /* Define output sections */ 49 | SECTIONS 50 | { 51 | /* The startup code goes first into FLASH */ 52 | .isr_vector : 53 | { 54 | . = ALIGN(4); 55 | KEEP(*(.isr_vector)) /* Startup code */ 56 | . = ALIGN(4); 57 | } >FLASH 58 | 59 | /* The program code and other data goes into FLASH */ 60 | .text : 61 | { 62 | . = ALIGN(4); 63 | *(.text) /* .text sections (code) */ 64 | *(.text*) /* .text* sections (code) */ 65 | *(.glue_7) /* glue arm to thumb code */ 66 | *(.glue_7t) /* glue thumb to arm code */ 67 | *(.eh_frame) 68 | 69 | KEEP (*(.init)) 70 | KEEP (*(.fini)) 71 | 72 | . = ALIGN(4); 73 | _etext = .; /* define a global symbols at end of code */ 74 | } >FLASH 75 | 76 | /* Constant data goes into FLASH */ 77 | .rodata : 78 | { 79 | . = ALIGN(4); 80 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 81 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 82 | . = ALIGN(4); 83 | } >FLASH 84 | 85 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 86 | .ARM : { 87 | __exidx_start = .; 88 | *(.ARM.exidx*) 89 | __exidx_end = .; 90 | } >FLASH 91 | 92 | .preinit_array : 93 | { 94 | PROVIDE_HIDDEN (__preinit_array_start = .); 95 | KEEP (*(.preinit_array*)) 96 | PROVIDE_HIDDEN (__preinit_array_end = .); 97 | } >FLASH 98 | .init_array : 99 | { 100 | PROVIDE_HIDDEN (__init_array_start = .); 101 | KEEP (*(SORT(.init_array.*))) 102 | KEEP (*(.init_array*)) 103 | PROVIDE_HIDDEN (__init_array_end = .); 104 | } >FLASH 105 | .fini_array : 106 | { 107 | PROVIDE_HIDDEN (__fini_array_start = .); 108 | KEEP (*(SORT(.fini_array.*))) 109 | KEEP (*(.fini_array*)) 110 | PROVIDE_HIDDEN (__fini_array_end = .); 111 | } >FLASH 112 | 113 | /* used by the startup to initialize data */ 114 | _sidata = LOADADDR(.data); 115 | 116 | /* Initialized data sections goes into RAM, load LMA copy after code */ 117 | .data : 118 | { 119 | . = ALIGN(4); 120 | _sdata = .; /* create a global symbol at data start */ 121 | *(.data) /* .data sections */ 122 | *(.data*) /* .data* sections */ 123 | 124 | . = ALIGN(4); 125 | _edata = .; /* define a global symbol at data end */ 126 | } >RAM AT> FLASH 127 | 128 | 129 | /* Uninitialized data section */ 130 | . = ALIGN(4); 131 | .bss : 132 | { 133 | /* This is used by the startup in order to initialize the .bss secion */ 134 | _sbss = .; /* define a global symbol at bss start */ 135 | __bss_start__ = _sbss; 136 | *(.bss) 137 | *(.bss*) 138 | *(COMMON) 139 | 140 | . = ALIGN(4); 141 | _ebss = .; /* define a global symbol at bss end */ 142 | __bss_end__ = _ebss; 143 | } >RAM 144 | 145 | /* User_heap_stack section, used to check that there is enough RAM left */ 146 | ._user_heap_stack : 147 | { 148 | . = ALIGN(8); 149 | PROVIDE ( end = . ); 150 | PROVIDE ( _end = . ); 151 | . = . + _Min_Heap_Size; 152 | . = . + _Min_Stack_Size; 153 | . = ALIGN(8); 154 | } >RAM 155 | 156 | 157 | 158 | /* Remove information from the standard libraries */ 159 | /DISCARD/ : 160 | { 161 | libc.a ( * ) 162 | libm.a ( * ) 163 | libgcc.a ( * ) 164 | } 165 | 166 | .ARM.attributes 0 : { *(.ARM.attributes) } 167 | } 168 | 169 | 170 | -------------------------------------------------------------------------------- /Src/gpio.tmp: -------------------------------------------------------------------------------- 1 | 2 | #n/** Configure pins as #n #t#t #t* Analog #n #t#t #t* Input #n #t#t #t* Output#n #t#t #t* EVENT_OUT#n #t#t #t* EXTI 3 | */ 4 | static void MX_GPIO_Init(void) 5 | { 6 | #n 7 | #tGPIO_InitTypeDef GPIO_InitStruct; 8 | #n#t/* GPIO Ports Clock Enable */ 9 | #t__HAL_RCC_GPIOC_CLK_ENABLE(); 10 | #t__HAL_RCC_GPIOH_CLK_ENABLE(); 11 | #t__HAL_RCC_GPIOA_CLK_ENABLE(); 12 | #t__HAL_RCC_GPIOB_CLK_ENABLE(); 13 | #n#t/*Configure GPIO pin Output Level */ 14 | #tHAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_RESET); 15 | #n#t/*Configure GPIO pin Output Level */ 16 | #tHAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_RESET); 17 | #n#t/*Configure GPIO pin Output Level */ 18 | #tHAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET); 19 | #n#t/*Configure GPIO pin : B1_Pin */ 20 | #tGPIO_InitStruct.Pin = B1_Pin; 21 | #tGPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; 22 | #tGPIO_InitStruct.Pull = GPIO_NOPULL; 23 | #tHAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); 24 | #n#t/*Configure GPIO pins : Btn2_Pin Btn3_Pin Btn4_Pin */ 25 | #tGPIO_InitStruct.Pin = Btn2_Pin|Btn3_Pin|Btn4_Pin; 26 | #tGPIO_InitStruct.Mode = GPIO_MODE_INPUT; 27 | #tGPIO_InitStruct.Pull = GPIO_NOPULL; 28 | #tHAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 29 | #n#t/*Configure GPIO pin : PC7 */ 30 | #tGPIO_InitStruct.Pin = GPIO_PIN_7; 31 | #tGPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 32 | #tGPIO_InitStruct.Pull = GPIO_NOPULL; 33 | #tGPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 34 | #tHAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 35 | #n#t/*Configure GPIO pin : Btn1_Pin */ 36 | #tGPIO_InitStruct.Pin = Btn1_Pin; 37 | #tGPIO_InitStruct.Mode = GPIO_MODE_INPUT; 38 | #tGPIO_InitStruct.Pull = GPIO_NOPULL; 39 | #tHAL_GPIO_Init(Btn1_GPIO_Port, &GPIO_InitStruct); 40 | #n#t/*Configure GPIO pin : PA9 */ 41 | #tGPIO_InitStruct.Pin = GPIO_PIN_9; 42 | #tGPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 43 | #tGPIO_InitStruct.Pull = GPIO_NOPULL; 44 | #tGPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 45 | #tHAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 46 | #n#t/*Configure GPIO pin : PB6 */ 47 | #tGPIO_InitStruct.Pin = GPIO_PIN_6; 48 | #tGPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 49 | #tGPIO_InitStruct.Pull = GPIO_NOPULL; 50 | #tGPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 51 | #tHAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 52 | #n 53 | } 54 | #n 55 | -------------------------------------------------------------------------------- /Src/license.tmp: -------------------------------------------------------------------------------- 1 | ** This notice applies to any and all portions of this file 2 | * that are not between comment pairs USER CODE BEGIN and 3 | * USER CODE END. Other portions of this file, whether 4 | * inserted by the user or by software development tools 5 | * are owned by their respective copyright owners. 6 | * 7 | * COPYRIGHT(c) 2018 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | -------------------------------------------------------------------------------- /Src/main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "stm32f4xx_hal.h" 3 | 4 | /* USER CODE BEGIN Includes */ 5 | /* vim: set ai et ts=4 sw=4: */ 6 | #include 7 | #include 8 | #include 9 | #include "st7735.h" 10 | #include "fonts.h" 11 | /* USER CODE END Includes */ 12 | 13 | /* Private variables ---------------------------------------------------------*/ 14 | RTC_HandleTypeDef hrtc; 15 | RTC_TimeTypeDef sTime; 16 | RTC_DateTypeDef sDate; 17 | 18 | SPI_HandleTypeDef hspi1; 19 | 20 | UART_HandleTypeDef huart2; 21 | 22 | /* USER CODE BEGIN PV */ 23 | /* Private variables ---------------------------------------------------------*/ 24 | 25 | /* USER CODE END PV */ 26 | 27 | /* Private function prototypes -----------------------------------------------*/ 28 | void SystemClock_Config(void); 29 | static void MX_GPIO_Init(void); 30 | static void MX_SPI1_Init(void); 31 | static void MX_USART2_UART_Init(void); 32 | static void MX_RTC_Init(void); 33 | 34 | /* USER CODE BEGIN PFP */ 35 | /* Private function prototypes -----------------------------------------------*/ 36 | 37 | /* USER CODE END PFP */ 38 | 39 | /* USER CODE BEGIN 0 */ 40 | 41 | #define NCOLORS 7 42 | static const char colors[NCOLORS+1] = "wyrgbmc"; 43 | 44 | void UART_Printf(const char* fmt, ...) { 45 | char buff[256]; 46 | va_list args; 47 | va_start(args, fmt); 48 | vsnprintf(buff, sizeof(buff), fmt, args); 49 | HAL_UART_Transmit(&huart2, (uint8_t*)buff, strlen(buff), 50 | HAL_MAX_DELAY); 51 | va_end(args); 52 | } 53 | 54 | void Fix_Date(RTC_DateTypeDef* date, bool set_max) { 55 | if(date->Date == 0) { 56 | date->Date = 1; 57 | return; // no need to re-check 58 | } 59 | 60 | if(date->Date <= 28) { 61 | return; // always OK 62 | } 63 | 64 | // since Year is 0..99 there is no need to 65 | // check (Year % 100) and (Year % 400) cases. 66 | bool is_leap = (date->Year % 4) == 0; 67 | uint8_t days_in_month = 31; 68 | // There are 30 days in April, June, September and November 69 | if((date->Month == 4) || (date->Month == 6) || (date->Month == 9) || (date->Month == 11)) { 70 | days_in_month = 30; 71 | } else if(date->Month == 2) { // February 72 | days_in_month = is_leap ? 29 : 28; 73 | } 74 | 75 | if(date->Date > days_in_month) { 76 | date->Date = set_max ? days_in_month : 1; 77 | } 78 | } 79 | 80 | int RTC_Set( 81 | uint8_t year, uint8_t month, uint8_t day, 82 | uint8_t hour, uint8_t min, uint8_t sec, 83 | uint8_t dow) { 84 | HAL_StatusTypeDef res; 85 | RTC_TimeTypeDef time; 86 | RTC_DateTypeDef date; 87 | 88 | memset(&time, 0, sizeof(time)); 89 | memset(&date, 0, sizeof(date)); 90 | 91 | date.WeekDay = dow; 92 | date.Year = year; 93 | date.Month = month; 94 | date.Date = day; 95 | 96 | res = HAL_RTC_SetDate(&hrtc, &date, RTC_FORMAT_BIN); 97 | if(res != HAL_OK) { 98 | UART_Printf("HAL_RTC_SetDate failed: %d\r\n", res); 99 | return -1; 100 | } 101 | 102 | time.Hours = hour; 103 | time.Minutes = min; 104 | time.Seconds = sec; 105 | 106 | res = HAL_RTC_SetTime(&hrtc, &time, RTC_FORMAT_BIN); 107 | if(res != HAL_OK) { 108 | UART_Printf("HAL_RTC_SetTime failed: %d\r\n", res); 109 | return -2; 110 | } 111 | 112 | return 0; 113 | } 114 | 115 | void init() { 116 | ST7735_Init(); 117 | ST7735_FillScreen(ST7735_BLACK); 118 | 119 | HAL_PWR_EnableBkUpAccess(); 120 | 121 | UART_Printf("Ready!\r\n"); 122 | } 123 | 124 | uint16_t font_color(uint8_t clr, bool selected) { 125 | if(selected) { 126 | clr = (clr + 1) % NCOLORS; 127 | } 128 | 129 | switch(colors[clr]) { 130 | case 'w': 131 | return ST7735_WHITE; 132 | case 'y': 133 | return ST7735_YELLOW; 134 | case 'r': 135 | return ST7735_RED; 136 | case 'g': 137 | return ST7735_GREEN; 138 | case 'b': 139 | return ST7735_BLUE; 140 | case 'm': 141 | return ST7735_MAGENTA; 142 | case 'c': 143 | return ST7735_CYAN; 144 | default: // should never happen, return gray 145 | return ST7735_COLOR565(15, 31, 15); 146 | } 147 | } 148 | 149 | uint8_t cursor_offset = 0; 150 | 151 | void loop() { 152 | HAL_Delay(100); 153 | 154 | bool btn_dec = false; 155 | bool btn_inc = false; 156 | 157 | if(HAL_GPIO_ReadPin(Btn1_GPIO_Port, Btn1_Pin) == GPIO_PIN_RESET) { 158 | cursor_offset = (cursor_offset == 0) ? 7 : cursor_offset - 1; 159 | } 160 | 161 | if(HAL_GPIO_ReadPin(Btn2_GPIO_Port, Btn2_Pin) == GPIO_PIN_RESET) { 162 | cursor_offset = (cursor_offset + 1) % 9; 163 | } 164 | 165 | if(HAL_GPIO_ReadPin(Btn3_GPIO_Port, Btn3_Pin) == GPIO_PIN_RESET) { 166 | btn_dec = true; 167 | } 168 | 169 | if(HAL_GPIO_ReadPin(Btn4_GPIO_Port, Btn4_Pin) == GPIO_PIN_RESET) { 170 | btn_inc = true; 171 | } 172 | 173 | RTC_TimeTypeDef time; 174 | RTC_DateTypeDef date; 175 | HAL_StatusTypeDef res; 176 | 177 | res = HAL_RTC_GetTime(&hrtc, &time, RTC_FORMAT_BIN); 178 | if(res != HAL_OK) { 179 | UART_Printf("HAL_RTC_GetTime failed: %d\r\n", res); 180 | return; 181 | } 182 | 183 | res = HAL_RTC_GetDate(&hrtc, &date, RTC_FORMAT_BIN); 184 | if(res != HAL_OK) { 185 | UART_Printf("HAL_RTC_GetDate failed: %d\r\n", res); 186 | return; 187 | } 188 | 189 | uint8_t chosen_color = (uint8_t)HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1); 190 | chosen_color = chosen_color % NCOLORS; 191 | uint16_t default_color = font_color(chosen_color, false); 192 | 193 | char tmp[32]; 194 | snprintf(tmp, sizeof(tmp), "%02d", time.Hours); 195 | ST7735_WriteString(11*0, 18*0, tmp, Font_11x18, font_color(chosen_color, (cursor_offset == 1)), ST7735_BLACK); 196 | ST7735_WriteString(11*2, 18*0, ":", Font_11x18, default_color, ST7735_BLACK); 197 | snprintf(tmp, sizeof(tmp), "%02d", time.Minutes); 198 | ST7735_WriteString(11*3, 18*0, tmp, Font_11x18, font_color(chosen_color, (cursor_offset == 2)), ST7735_BLACK); 199 | ST7735_WriteString(11*5, 18*0, ":", Font_11x18, default_color, ST7735_BLACK); 200 | snprintf(tmp, sizeof(tmp), "%02d", time.Seconds); 201 | ST7735_WriteString(11*6, 18*0, tmp, Font_11x18, font_color(chosen_color, (cursor_offset == 3)), ST7735_BLACK); 202 | 203 | snprintf(tmp, sizeof(tmp), "%02d", date.Date); 204 | ST7735_WriteString(11*0, 18*1, tmp, Font_11x18, font_color(chosen_color, (cursor_offset == 4)), ST7735_BLACK); 205 | ST7735_WriteString(11*2, 18*1, ".", Font_11x18, default_color, ST7735_BLACK); 206 | snprintf(tmp, sizeof(tmp), "%02d", date.Month); 207 | ST7735_WriteString(11*3, 18*1, tmp, Font_11x18, font_color(chosen_color, (cursor_offset == 5)), ST7735_BLACK); 208 | ST7735_WriteString(11*5, 18*1, ".", Font_11x18, default_color, ST7735_BLACK); 209 | snprintf(tmp, sizeof(tmp), "%02d", date.Year); 210 | ST7735_WriteString(11*6, 18*1, tmp, Font_11x18, font_color(chosen_color, (cursor_offset == 6)), ST7735_BLACK); 211 | 212 | ST7735_WriteString(11*0, 18*2, "DOW: ", Font_11x18, default_color, ST7735_BLACK); 213 | snprintf(tmp, sizeof(tmp), "%02d", date.WeekDay); 214 | ST7735_WriteString(11*6, 18*2, tmp, Font_11x18, font_color(chosen_color, (cursor_offset == 7)), ST7735_BLACK); 215 | 216 | ST7735_WriteString(11*0, 18*3, "Color: ", Font_11x18, default_color, ST7735_BLACK); 217 | snprintf(tmp, sizeof(tmp), "%c/%c", colors[chosen_color], colors[(chosen_color + 1) % NCOLORS]); 218 | ST7735_WriteString(11*7, 18*3, tmp, Font_11x18, font_color(chosen_color, (cursor_offset == 8)), ST7735_BLACK); 219 | 220 | if(cursor_offset == 1) { // edit hour 221 | if(btn_dec) { 222 | if(time.Hours == 0) { 223 | time.Hours = 23; 224 | } else { 225 | time.Hours--; 226 | } 227 | } else if(btn_inc) { 228 | time.Hours = (time.Hours + 1) % 24; 229 | } 230 | } 231 | 232 | if(cursor_offset == 2) { // edit minute 233 | if(btn_dec) { 234 | if(time.Minutes == 0) { 235 | time.Minutes = 59; 236 | } else { 237 | time.Minutes--; 238 | } 239 | } else if(btn_inc) { 240 | time.Minutes = (time.Minutes + 1) % 60; 241 | } 242 | } 243 | 244 | if(cursor_offset == 3) { // edit second 245 | if(btn_dec) { 246 | if(time.Seconds == 0) { 247 | time.Seconds = 59; 248 | } else { 249 | time.Seconds--; 250 | } 251 | } else if(btn_inc) { 252 | time.Seconds = (time.Seconds + 1) % 60; 253 | } 254 | } 255 | 256 | if(cursor_offset == 4) { // edit day 257 | if(btn_dec) { 258 | if(date.Date == 1) { 259 | date.Date = 31; 260 | Fix_Date(&date, true); 261 | } else { 262 | date.Date--; 263 | } 264 | } else if(btn_inc) { 265 | date.Date++; 266 | Fix_Date(&date, false); 267 | } 268 | } 269 | 270 | if(cursor_offset == 5) { // edit month 271 | if(btn_dec) { 272 | if(date.Month == 1) { 273 | date.Month = 12; 274 | } else { 275 | date.Month--; 276 | } 277 | } else if(btn_inc) { 278 | if(date.Month == 12) { 279 | date.Month = 1; 280 | } else { 281 | date.Month++; 282 | } 283 | } 284 | 285 | Fix_Date(&date, true); 286 | } 287 | 288 | if(cursor_offset == 6) { // edit year 289 | if(btn_dec) { 290 | if(date.Year == 0) { 291 | date.Year = 99; 292 | } else { 293 | date.Year--; 294 | } 295 | } else if(btn_inc) { 296 | date.Year = (date.Year + 1) % 100; 297 | } 298 | Fix_Date(&date, true); 299 | } 300 | 301 | if(cursor_offset == 7) { // edit day of week 302 | if(btn_dec) { 303 | if(date.WeekDay == 1) { 304 | date.WeekDay = 7; 305 | } else { 306 | date.WeekDay--; 307 | } 308 | } else if(btn_inc) { 309 | if(date.WeekDay == 7) { 310 | date.WeekDay = 1; 311 | } else { 312 | date.WeekDay++; 313 | } 314 | } 315 | } 316 | 317 | if(cursor_offset == 8) { // edir color 318 | if(btn_dec) { 319 | if(chosen_color == 0) { 320 | chosen_color = NCOLORS-1; 321 | } else { 322 | chosen_color--; 323 | } 324 | } else if(btn_inc) { 325 | chosen_color = (chosen_color + 1) % NCOLORS; 326 | } 327 | } 328 | 329 | // Don't re-use RTC_*TypeDef structures filled by HAL_RTC_GetTime/GetDate 330 | // It causes bugs like 25th hour 331 | if((cursor_offset >= 1) && (cursor_offset <= 7) && (btn_dec || btn_inc)) { 332 | RTC_Set( 333 | date.Year, date.Month, date.Date, // Y, M, D 334 | time.Hours, time.Minutes, time.Seconds, // H, M, S 335 | date.WeekDay // day of week, 1-7 (mon-sun) 336 | ); 337 | } 338 | 339 | if((cursor_offset == 8) && (btn_dec || btn_inc)) { 340 | HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, (uint32_t)chosen_color); 341 | } 342 | } 343 | 344 | /* USER CODE END 0 */ 345 | 346 | int main(void) 347 | { 348 | 349 | /* USER CODE BEGIN 1 */ 350 | 351 | /* USER CODE END 1 */ 352 | 353 | /* MCU Configuration----------------------------------------------------------*/ 354 | 355 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 356 | HAL_Init(); 357 | 358 | /* USER CODE BEGIN Init */ 359 | 360 | /* USER CODE END Init */ 361 | 362 | /* Configure the system clock */ 363 | SystemClock_Config(); 364 | 365 | /* USER CODE BEGIN SysInit */ 366 | 367 | /* USER CODE END SysInit */ 368 | 369 | /* Initialize all configured peripherals */ 370 | MX_GPIO_Init(); 371 | MX_SPI1_Init(); 372 | MX_USART2_UART_Init(); 373 | MX_RTC_Init(); 374 | 375 | /* USER CODE BEGIN 2 */ 376 | 377 | /* USER CODE END 2 */ 378 | 379 | /* Infinite loop */ 380 | /* USER CODE BEGIN WHILE */ 381 | init(); 382 | while (1) 383 | { 384 | loop(); 385 | /* USER CODE END WHILE */ 386 | 387 | /* USER CODE BEGIN 3 */ 388 | 389 | } 390 | /* USER CODE END 3 */ 391 | 392 | } 393 | 394 | /** System Clock Configuration 395 | */ 396 | void SystemClock_Config(void) 397 | { 398 | 399 | RCC_OscInitTypeDef RCC_OscInitStruct; 400 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 401 | RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; 402 | 403 | /**Configure the main internal regulator output voltage 404 | */ 405 | __HAL_RCC_PWR_CLK_ENABLE(); 406 | 407 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); 408 | 409 | /**Initializes the CPU, AHB and APB busses clocks 410 | */ 411 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSE; 412 | RCC_OscInitStruct.LSEState = RCC_LSE_ON; 413 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 414 | RCC_OscInitStruct.HSICalibrationValue = 16; 415 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 416 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; 417 | RCC_OscInitStruct.PLL.PLLM = 16; 418 | RCC_OscInitStruct.PLL.PLLN = 336; 419 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; 420 | RCC_OscInitStruct.PLL.PLLQ = 4; 421 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 422 | { 423 | _Error_Handler(__FILE__, __LINE__); 424 | } 425 | 426 | /**Initializes the CPU, AHB and APB busses clocks 427 | */ 428 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 429 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 430 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 431 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 432 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; 433 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 434 | 435 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) 436 | { 437 | _Error_Handler(__FILE__, __LINE__); 438 | } 439 | 440 | PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; 441 | PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; 442 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) 443 | { 444 | _Error_Handler(__FILE__, __LINE__); 445 | } 446 | 447 | /**Configure the Systick interrupt time 448 | */ 449 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); 450 | 451 | /**Configure the Systick 452 | */ 453 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); 454 | 455 | /* SysTick_IRQn interrupt configuration */ 456 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 457 | } 458 | 459 | /* RTC init function */ 460 | static void MX_RTC_Init(void) 461 | { 462 | 463 | /**Initialize RTC Only 464 | */ 465 | hrtc.Instance = RTC; 466 | hrtc.Init.HourFormat = RTC_HOURFORMAT_24; 467 | hrtc.Init.AsynchPrediv = 127; 468 | hrtc.Init.SynchPrediv = 255; 469 | hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; 470 | hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; 471 | hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; 472 | if (HAL_RTC_Init(&hrtc) != HAL_OK) 473 | { 474 | _Error_Handler(__FILE__, __LINE__); 475 | } 476 | 477 | /**Initialize RTC and set the Time and Date 478 | */ 479 | if(HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR0) != 0x32F2){ 480 | if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK) 481 | { 482 | _Error_Handler(__FILE__, __LINE__); 483 | } 484 | 485 | if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN) != HAL_OK) 486 | { 487 | _Error_Handler(__FILE__, __LINE__); 488 | } 489 | 490 | HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR0,0x32F2); 491 | } 492 | 493 | } 494 | 495 | /* SPI1 init function */ 496 | static void MX_SPI1_Init(void) 497 | { 498 | 499 | /* SPI1 parameter configuration*/ 500 | hspi1.Instance = SPI1; 501 | hspi1.Init.Mode = SPI_MODE_MASTER; 502 | hspi1.Init.Direction = SPI_DIRECTION_1LINE; 503 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 504 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 505 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 506 | hspi1.Init.NSS = SPI_NSS_SOFT; 507 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; 508 | hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; 509 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; 510 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 511 | hspi1.Init.CRCPolynomial = 10; 512 | if (HAL_SPI_Init(&hspi1) != HAL_OK) 513 | { 514 | _Error_Handler(__FILE__, __LINE__); 515 | } 516 | 517 | } 518 | 519 | /* USART2 init function */ 520 | static void MX_USART2_UART_Init(void) 521 | { 522 | 523 | huart2.Instance = USART2; 524 | huart2.Init.BaudRate = 9600; 525 | huart2.Init.WordLength = UART_WORDLENGTH_8B; 526 | huart2.Init.StopBits = UART_STOPBITS_1; 527 | huart2.Init.Parity = UART_PARITY_NONE; 528 | huart2.Init.Mode = UART_MODE_TX_RX; 529 | huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; 530 | huart2.Init.OverSampling = UART_OVERSAMPLING_16; 531 | if (HAL_UART_Init(&huart2) != HAL_OK) 532 | { 533 | _Error_Handler(__FILE__, __LINE__); 534 | } 535 | 536 | } 537 | 538 | /** Configure pins as 539 | * Analog 540 | * Input 541 | * Output 542 | * EVENT_OUT 543 | * EXTI 544 | */ 545 | static void MX_GPIO_Init(void) 546 | { 547 | 548 | GPIO_InitTypeDef GPIO_InitStruct; 549 | 550 | /* GPIO Ports Clock Enable */ 551 | __HAL_RCC_GPIOC_CLK_ENABLE(); 552 | __HAL_RCC_GPIOH_CLK_ENABLE(); 553 | __HAL_RCC_GPIOA_CLK_ENABLE(); 554 | __HAL_RCC_GPIOB_CLK_ENABLE(); 555 | 556 | /*Configure GPIO pin Output Level */ 557 | HAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_RESET); 558 | 559 | /*Configure GPIO pin Output Level */ 560 | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_RESET); 561 | 562 | /*Configure GPIO pin Output Level */ 563 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET); 564 | 565 | /*Configure GPIO pin : B1_Pin */ 566 | GPIO_InitStruct.Pin = B1_Pin; 567 | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; 568 | GPIO_InitStruct.Pull = GPIO_NOPULL; 569 | HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); 570 | 571 | /*Configure GPIO pins : Btn2_Pin Btn3_Pin Btn4_Pin */ 572 | GPIO_InitStruct.Pin = Btn2_Pin|Btn3_Pin|Btn4_Pin; 573 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 574 | GPIO_InitStruct.Pull = GPIO_NOPULL; 575 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 576 | 577 | /*Configure GPIO pin : PC7 */ 578 | GPIO_InitStruct.Pin = GPIO_PIN_7; 579 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 580 | GPIO_InitStruct.Pull = GPIO_NOPULL; 581 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 582 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 583 | 584 | /*Configure GPIO pin : Btn1_Pin */ 585 | GPIO_InitStruct.Pin = Btn1_Pin; 586 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 587 | GPIO_InitStruct.Pull = GPIO_NOPULL; 588 | HAL_GPIO_Init(Btn1_GPIO_Port, &GPIO_InitStruct); 589 | 590 | /*Configure GPIO pin : PA9 */ 591 | GPIO_InitStruct.Pin = GPIO_PIN_9; 592 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 593 | GPIO_InitStruct.Pull = GPIO_NOPULL; 594 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 595 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 596 | 597 | /*Configure GPIO pin : PB6 */ 598 | GPIO_InitStruct.Pin = GPIO_PIN_6; 599 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 600 | GPIO_InitStruct.Pull = GPIO_NOPULL; 601 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 602 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 603 | 604 | } 605 | 606 | /* USER CODE BEGIN 4 */ 607 | 608 | /* USER CODE END 4 */ 609 | 610 | /** 611 | * @brief This function is executed in case of error occurrence. 612 | * @param None 613 | * @retval None 614 | */ 615 | void _Error_Handler(char * file, int line) 616 | { 617 | /* USER CODE BEGIN Error_Handler_Debug */ 618 | /* User can add his own implementation to report the HAL error return state */ 619 | while(1) 620 | { 621 | } 622 | /* USER CODE END Error_Handler_Debug */ 623 | } 624 | 625 | #ifdef USE_FULL_ASSERT 626 | 627 | /** 628 | * @brief Reports the name of the source file and the source line number 629 | * where the assert_param error has occurred. 630 | * @param file: pointer to the source file name 631 | * @param line: assert_param error line source number 632 | * @retval None 633 | */ 634 | void assert_failed(uint8_t* file, uint32_t line) 635 | { 636 | /* USER CODE BEGIN 6 */ 637 | /* User can add his own implementation to report the file name and line number, 638 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 639 | /* USER CODE END 6 */ 640 | 641 | } 642 | 643 | #endif 644 | 645 | /** 646 | * @} 647 | */ 648 | 649 | /** 650 | * @} 651 | */ 652 | 653 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 654 | -------------------------------------------------------------------------------- /Src/stm32f4xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : stm32f4xx_hal_msp.c 4 | * Description : This file provides code for the MSP Initialization 5 | * and de-Initialization codes. 6 | ****************************************************************************** 7 | ** This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * COPYRIGHT(c) 2018 STMicroelectronics 14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | /* Includes ------------------------------------------------------------------*/ 40 | #include "stm32f4xx_hal.h" 41 | 42 | extern void _Error_Handler(char *, int); 43 | /* USER CODE BEGIN 0 */ 44 | 45 | /* USER CODE END 0 */ 46 | /** 47 | * Initializes the Global MSP. 48 | */ 49 | void HAL_MspInit(void) 50 | { 51 | /* USER CODE BEGIN MspInit 0 */ 52 | 53 | /* USER CODE END MspInit 0 */ 54 | 55 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); 56 | 57 | /* System interrupt init*/ 58 | /* MemoryManagement_IRQn interrupt configuration */ 59 | HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); 60 | /* BusFault_IRQn interrupt configuration */ 61 | HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); 62 | /* UsageFault_IRQn interrupt configuration */ 63 | HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); 64 | /* SVCall_IRQn interrupt configuration */ 65 | HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0); 66 | /* DebugMonitor_IRQn interrupt configuration */ 67 | HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); 68 | /* PendSV_IRQn interrupt configuration */ 69 | HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); 70 | /* SysTick_IRQn interrupt configuration */ 71 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 72 | 73 | /* USER CODE BEGIN MspInit 1 */ 74 | 75 | /* USER CODE END MspInit 1 */ 76 | } 77 | 78 | void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) 79 | { 80 | 81 | if(hrtc->Instance==RTC) 82 | { 83 | /* USER CODE BEGIN RTC_MspInit 0 */ 84 | 85 | /* USER CODE END RTC_MspInit 0 */ 86 | /* Peripheral clock enable */ 87 | __HAL_RCC_RTC_ENABLE(); 88 | /* USER CODE BEGIN RTC_MspInit 1 */ 89 | 90 | /* USER CODE END RTC_MspInit 1 */ 91 | } 92 | 93 | } 94 | 95 | void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc) 96 | { 97 | 98 | if(hrtc->Instance==RTC) 99 | { 100 | /* USER CODE BEGIN RTC_MspDeInit 0 */ 101 | 102 | /* USER CODE END RTC_MspDeInit 0 */ 103 | /* Peripheral clock disable */ 104 | __HAL_RCC_RTC_DISABLE(); 105 | /* USER CODE BEGIN RTC_MspDeInit 1 */ 106 | 107 | /* USER CODE END RTC_MspDeInit 1 */ 108 | } 109 | 110 | } 111 | 112 | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) 113 | { 114 | 115 | GPIO_InitTypeDef GPIO_InitStruct; 116 | if(hspi->Instance==SPI1) 117 | { 118 | /* USER CODE BEGIN SPI1_MspInit 0 */ 119 | 120 | /* USER CODE END SPI1_MspInit 0 */ 121 | /* Peripheral clock enable */ 122 | __HAL_RCC_SPI1_CLK_ENABLE(); 123 | 124 | /**SPI1 GPIO Configuration 125 | PA5 ------> SPI1_SCK 126 | PA7 ------> SPI1_MOSI 127 | */ 128 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7; 129 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 130 | GPIO_InitStruct.Pull = GPIO_NOPULL; 131 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 132 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; 133 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 134 | 135 | /* USER CODE BEGIN SPI1_MspInit 1 */ 136 | 137 | /* USER CODE END SPI1_MspInit 1 */ 138 | } 139 | 140 | } 141 | 142 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) 143 | { 144 | 145 | if(hspi->Instance==SPI1) 146 | { 147 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ 148 | 149 | /* USER CODE END SPI1_MspDeInit 0 */ 150 | /* Peripheral clock disable */ 151 | __HAL_RCC_SPI1_CLK_DISABLE(); 152 | 153 | /**SPI1 GPIO Configuration 154 | PA5 ------> SPI1_SCK 155 | PA7 ------> SPI1_MOSI 156 | */ 157 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7); 158 | 159 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ 160 | 161 | /* USER CODE END SPI1_MspDeInit 1 */ 162 | } 163 | 164 | } 165 | 166 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) 167 | { 168 | 169 | GPIO_InitTypeDef GPIO_InitStruct; 170 | if(huart->Instance==USART2) 171 | { 172 | /* USER CODE BEGIN USART2_MspInit 0 */ 173 | 174 | /* USER CODE END USART2_MspInit 0 */ 175 | /* Peripheral clock enable */ 176 | __HAL_RCC_USART2_CLK_ENABLE(); 177 | 178 | /**USART2 GPIO Configuration 179 | PA2 ------> USART2_TX 180 | PA3 ------> USART2_RX 181 | */ 182 | GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin; 183 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 184 | GPIO_InitStruct.Pull = GPIO_PULLUP; 185 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 186 | GPIO_InitStruct.Alternate = GPIO_AF7_USART2; 187 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 188 | 189 | /* USER CODE BEGIN USART2_MspInit 1 */ 190 | 191 | /* USER CODE END USART2_MspInit 1 */ 192 | } 193 | 194 | } 195 | 196 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) 197 | { 198 | 199 | if(huart->Instance==USART2) 200 | { 201 | /* USER CODE BEGIN USART2_MspDeInit 0 */ 202 | 203 | /* USER CODE END USART2_MspDeInit 0 */ 204 | /* Peripheral clock disable */ 205 | __HAL_RCC_USART2_CLK_DISABLE(); 206 | 207 | /**USART2 GPIO Configuration 208 | PA2 ------> USART2_TX 209 | PA3 ------> USART2_RX 210 | */ 211 | HAL_GPIO_DeInit(GPIOA, USART_TX_Pin|USART_RX_Pin); 212 | 213 | /* USER CODE BEGIN USART2_MspDeInit 1 */ 214 | 215 | /* USER CODE END USART2_MspDeInit 1 */ 216 | } 217 | 218 | } 219 | 220 | /* USER CODE BEGIN 1 */ 221 | 222 | /* USER CODE END 1 */ 223 | 224 | /** 225 | * @} 226 | */ 227 | 228 | /** 229 | * @} 230 | */ 231 | 232 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 233 | -------------------------------------------------------------------------------- /Src/stm32f4xx_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_it.c 4 | * @brief Interrupt Service Routines. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2018 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "stm32f4xx_hal.h" 35 | #include "stm32f4xx.h" 36 | #include "stm32f4xx_it.h" 37 | 38 | /* USER CODE BEGIN 0 */ 39 | 40 | /* USER CODE END 0 */ 41 | 42 | /* External variables --------------------------------------------------------*/ 43 | 44 | /******************************************************************************/ 45 | /* Cortex-M4 Processor Interruption and Exception Handlers */ 46 | /******************************************************************************/ 47 | 48 | /** 49 | * @brief This function handles System tick timer. 50 | */ 51 | void SysTick_Handler(void) 52 | { 53 | /* USER CODE BEGIN SysTick_IRQn 0 */ 54 | 55 | /* USER CODE END SysTick_IRQn 0 */ 56 | HAL_IncTick(); 57 | HAL_SYSTICK_IRQHandler(); 58 | /* USER CODE BEGIN SysTick_IRQn 1 */ 59 | 60 | /* USER CODE END SysTick_IRQn 1 */ 61 | } 62 | 63 | /******************************************************************************/ 64 | /* STM32F4xx Peripheral Interrupt Handlers */ 65 | /* Add here the Interrupt Handlers for the used peripherals. */ 66 | /* For the available peripheral interrupt handler names, */ 67 | /* please refer to the startup file (startup_stm32f4xx.s). */ 68 | /******************************************************************************/ 69 | 70 | /* USER CODE BEGIN 1 */ 71 | 72 | /* USER CODE END 1 */ 73 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 74 | -------------------------------------------------------------------------------- /Src/system.tmp: -------------------------------------------------------------------------------- 1 | #n 2 | #n 3 | #tHAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0);#n 4 | #t/* System interrupt init*/ 5 | #t/* MemoryManagement_IRQn interrupt configuration */ 6 | #tNVIC_SetPriority(MemoryManagement_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); 7 | #t/* BusFault_IRQn interrupt configuration */ 8 | #tNVIC_SetPriority(BusFault_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); 9 | #t/* UsageFault_IRQn interrupt configuration */ 10 | #tNVIC_SetPriority(UsageFault_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); 11 | #t/* SVCall_IRQn interrupt configuration */ 12 | #tNVIC_SetPriority(SVCall_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); 13 | #t/* DebugMonitor_IRQn interrupt configuration */ 14 | #tNVIC_SetPriority(DebugMonitor_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); 15 | #t/* PendSV_IRQn interrupt configuration */ 16 | #tNVIC_SetPriority(PendSV_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); 17 | #t/* SysTick_IRQn interrupt configuration */ 18 | #tNVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); 19 | #n 20 | #n 21 | -------------------------------------------------------------------------------- /Src/system_stm32f4xx.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.c 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. 6 | * 7 | * This file provides two functions and one global variable to be called from 8 | * user application: 9 | * - SystemInit(): This function is called at startup just after reset and 10 | * before branch to main program. This call is made inside 11 | * the "startup_stm32f4xx.s" file. 12 | * 13 | * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used 14 | * by the user application to setup the SysTick 15 | * timer or configure other parameters. 16 | * 17 | * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must 18 | * be called whenever the core clock is changed 19 | * during program execution. 20 | * 21 | * 22 | ****************************************************************************** 23 | * @attention 24 | * 25 | *

© COPYRIGHT 2017 STMicroelectronics

26 | * 27 | * Redistribution and use in source and binary forms, with or without modification, 28 | * are permitted provided that the following conditions are met: 29 | * 1. Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * 2. Redistributions in binary form must reproduce the above copyright notice, 32 | * this list of conditions and the following disclaimer in the documentation 33 | * and/or other materials provided with the distribution. 34 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 35 | * may be used to endorse or promote products derived from this software 36 | * without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | * 49 | ****************************************************************************** 50 | */ 51 | 52 | /** @addtogroup CMSIS 53 | * @{ 54 | */ 55 | 56 | /** @addtogroup stm32f4xx_system 57 | * @{ 58 | */ 59 | 60 | /** @addtogroup STM32F4xx_System_Private_Includes 61 | * @{ 62 | */ 63 | 64 | 65 | #include "stm32f4xx.h" 66 | 67 | #if !defined (HSE_VALUE) 68 | #define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */ 69 | #endif /* HSE_VALUE */ 70 | 71 | #if !defined (HSI_VALUE) 72 | #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ 73 | #endif /* HSI_VALUE */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** @addtogroup STM32F4xx_System_Private_TypesDefinitions 80 | * @{ 81 | */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @addtogroup STM32F4xx_System_Private_Defines 88 | * @{ 89 | */ 90 | 91 | /************************* Miscellaneous Configuration ************************/ 92 | /*!< Uncomment the following line if you need to use external SRAM or SDRAM as data memory */ 93 | #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\ 94 | || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ 95 | || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) 96 | /* #define DATA_IN_ExtSRAM */ 97 | #endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx ||\ 98 | STM32F412Zx || STM32F412Vx */ 99 | 100 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ 101 | || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) 102 | /* #define DATA_IN_ExtSDRAM */ 103 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\ 104 | STM32F479xx */ 105 | 106 | /*!< Uncomment the following line if you need to relocate your vector Table in 107 | Internal SRAM. */ 108 | /* #define VECT_TAB_SRAM */ 109 | #define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. 110 | This value must be a multiple of 0x200. */ 111 | /******************************************************************************/ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @addtogroup STM32F4xx_System_Private_Macros 118 | * @{ 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** @addtogroup STM32F4xx_System_Private_Variables 126 | * @{ 127 | */ 128 | /* This variable is updated in three ways: 129 | 1) by calling CMSIS function SystemCoreClockUpdate() 130 | 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 131 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 132 | Note: If you use this function to configure the system clock; then there 133 | is no need to call the 2 first functions listed above, since SystemCoreClock 134 | variable is updated automatically. 135 | */ 136 | uint32_t SystemCoreClock = 16000000; 137 | const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; 138 | const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; 139 | /** 140 | * @} 141 | */ 142 | 143 | /** @addtogroup STM32F4xx_System_Private_FunctionPrototypes 144 | * @{ 145 | */ 146 | 147 | #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) 148 | static void SystemInit_ExtMemCtl(void); 149 | #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ 150 | 151 | /** 152 | * @} 153 | */ 154 | 155 | /** @addtogroup STM32F4xx_System_Private_Functions 156 | * @{ 157 | */ 158 | 159 | /** 160 | * @brief Setup the microcontroller system 161 | * Initialize the FPU setting, vector table location and External memory 162 | * configuration. 163 | * @param None 164 | * @retval None 165 | */ 166 | void SystemInit(void) 167 | { 168 | /* FPU settings ------------------------------------------------------------*/ 169 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) 170 | SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ 171 | #endif 172 | /* Reset the RCC clock configuration to the default reset state ------------*/ 173 | /* Set HSION bit */ 174 | RCC->CR |= (uint32_t)0x00000001; 175 | 176 | /* Reset CFGR register */ 177 | RCC->CFGR = 0x00000000; 178 | 179 | /* Reset HSEON, CSSON and PLLON bits */ 180 | RCC->CR &= (uint32_t)0xFEF6FFFF; 181 | 182 | /* Reset PLLCFGR register */ 183 | RCC->PLLCFGR = 0x24003010; 184 | 185 | /* Reset HSEBYP bit */ 186 | RCC->CR &= (uint32_t)0xFFFBFFFF; 187 | 188 | /* Disable all interrupts */ 189 | RCC->CIR = 0x00000000; 190 | 191 | #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) 192 | SystemInit_ExtMemCtl(); 193 | #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ 194 | 195 | /* Configure the Vector Table location add offset address ------------------*/ 196 | #ifdef VECT_TAB_SRAM 197 | SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ 198 | #else 199 | SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ 200 | #endif 201 | } 202 | 203 | /** 204 | * @brief Update SystemCoreClock variable according to Clock Register Values. 205 | * The SystemCoreClock variable contains the core clock (HCLK), it can 206 | * be used by the user application to setup the SysTick timer or configure 207 | * other parameters. 208 | * 209 | * @note Each time the core clock (HCLK) changes, this function must be called 210 | * to update SystemCoreClock variable value. Otherwise, any configuration 211 | * based on this variable will be incorrect. 212 | * 213 | * @note - The system frequency computed by this function is not the real 214 | * frequency in the chip. It is calculated based on the predefined 215 | * constant and the selected clock source: 216 | * 217 | * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) 218 | * 219 | * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) 220 | * 221 | * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) 222 | * or HSI_VALUE(*) multiplied/divided by the PLL factors. 223 | * 224 | * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value 225 | * 16 MHz) but the real value may vary depending on the variations 226 | * in voltage and temperature. 227 | * 228 | * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value 229 | * depends on the application requirements), user has to ensure that HSE_VALUE 230 | * is same as the real frequency of the crystal used. Otherwise, this function 231 | * may have wrong result. 232 | * 233 | * - The result of this function could be not correct when using fractional 234 | * value for HSE crystal. 235 | * 236 | * @param None 237 | * @retval None 238 | */ 239 | void SystemCoreClockUpdate(void) 240 | { 241 | uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; 242 | 243 | /* Get SYSCLK source -------------------------------------------------------*/ 244 | tmp = RCC->CFGR & RCC_CFGR_SWS; 245 | 246 | switch (tmp) 247 | { 248 | case 0x00: /* HSI used as system clock source */ 249 | SystemCoreClock = HSI_VALUE; 250 | break; 251 | case 0x04: /* HSE used as system clock source */ 252 | SystemCoreClock = HSE_VALUE; 253 | break; 254 | case 0x08: /* PLL used as system clock source */ 255 | 256 | /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N 257 | SYSCLK = PLL_VCO / PLL_P 258 | */ 259 | pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; 260 | pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; 261 | 262 | if (pllsource != 0) 263 | { 264 | /* HSE used as PLL clock source */ 265 | pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); 266 | } 267 | else 268 | { 269 | /* HSI used as PLL clock source */ 270 | pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); 271 | } 272 | 273 | pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; 274 | SystemCoreClock = pllvco/pllp; 275 | break; 276 | default: 277 | SystemCoreClock = HSI_VALUE; 278 | break; 279 | } 280 | /* Compute HCLK frequency --------------------------------------------------*/ 281 | /* Get HCLK prescaler */ 282 | tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; 283 | /* HCLK frequency */ 284 | SystemCoreClock >>= tmp; 285 | } 286 | 287 | #if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM) 288 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ 289 | || defined(STM32F469xx) || defined(STM32F479xx) 290 | /** 291 | * @brief Setup the external memory controller. 292 | * Called in startup_stm32f4xx.s before jump to main. 293 | * This function configures the external memories (SRAM/SDRAM) 294 | * This SRAM/SDRAM will be used as program data memory (including heap and stack). 295 | * @param None 296 | * @retval None 297 | */ 298 | void SystemInit_ExtMemCtl(void) 299 | { 300 | __IO uint32_t tmp = 0x00; 301 | 302 | register uint32_t tmpreg = 0, timeout = 0xFFFF; 303 | register __IO uint32_t index; 304 | 305 | /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */ 306 | RCC->AHB1ENR |= 0x000001F8; 307 | 308 | /* Delay after an RCC peripheral clock enabling */ 309 | tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN); 310 | 311 | /* Connect PDx pins to FMC Alternate function */ 312 | GPIOD->AFR[0] = 0x00CCC0CC; 313 | GPIOD->AFR[1] = 0xCCCCCCCC; 314 | /* Configure PDx pins in Alternate function mode */ 315 | GPIOD->MODER = 0xAAAA0A8A; 316 | /* Configure PDx pins speed to 100 MHz */ 317 | GPIOD->OSPEEDR = 0xFFFF0FCF; 318 | /* Configure PDx pins Output type to push-pull */ 319 | GPIOD->OTYPER = 0x00000000; 320 | /* No pull-up, pull-down for PDx pins */ 321 | GPIOD->PUPDR = 0x00000000; 322 | 323 | /* Connect PEx pins to FMC Alternate function */ 324 | GPIOE->AFR[0] = 0xC00CC0CC; 325 | GPIOE->AFR[1] = 0xCCCCCCCC; 326 | /* Configure PEx pins in Alternate function mode */ 327 | GPIOE->MODER = 0xAAAA828A; 328 | /* Configure PEx pins speed to 100 MHz */ 329 | GPIOE->OSPEEDR = 0xFFFFC3CF; 330 | /* Configure PEx pins Output type to push-pull */ 331 | GPIOE->OTYPER = 0x00000000; 332 | /* No pull-up, pull-down for PEx pins */ 333 | GPIOE->PUPDR = 0x00000000; 334 | 335 | /* Connect PFx pins to FMC Alternate function */ 336 | GPIOF->AFR[0] = 0xCCCCCCCC; 337 | GPIOF->AFR[1] = 0xCCCCCCCC; 338 | /* Configure PFx pins in Alternate function mode */ 339 | GPIOF->MODER = 0xAA800AAA; 340 | /* Configure PFx pins speed to 50 MHz */ 341 | GPIOF->OSPEEDR = 0xAA800AAA; 342 | /* Configure PFx pins Output type to push-pull */ 343 | GPIOF->OTYPER = 0x00000000; 344 | /* No pull-up, pull-down for PFx pins */ 345 | GPIOF->PUPDR = 0x00000000; 346 | 347 | /* Connect PGx pins to FMC Alternate function */ 348 | GPIOG->AFR[0] = 0xCCCCCCCC; 349 | GPIOG->AFR[1] = 0xCCCCCCCC; 350 | /* Configure PGx pins in Alternate function mode */ 351 | GPIOG->MODER = 0xAAAAAAAA; 352 | /* Configure PGx pins speed to 50 MHz */ 353 | GPIOG->OSPEEDR = 0xAAAAAAAA; 354 | /* Configure PGx pins Output type to push-pull */ 355 | GPIOG->OTYPER = 0x00000000; 356 | /* No pull-up, pull-down for PGx pins */ 357 | GPIOG->PUPDR = 0x00000000; 358 | 359 | /* Connect PHx pins to FMC Alternate function */ 360 | GPIOH->AFR[0] = 0x00C0CC00; 361 | GPIOH->AFR[1] = 0xCCCCCCCC; 362 | /* Configure PHx pins in Alternate function mode */ 363 | GPIOH->MODER = 0xAAAA08A0; 364 | /* Configure PHx pins speed to 50 MHz */ 365 | GPIOH->OSPEEDR = 0xAAAA08A0; 366 | /* Configure PHx pins Output type to push-pull */ 367 | GPIOH->OTYPER = 0x00000000; 368 | /* No pull-up, pull-down for PHx pins */ 369 | GPIOH->PUPDR = 0x00000000; 370 | 371 | /* Connect PIx pins to FMC Alternate function */ 372 | GPIOI->AFR[0] = 0xCCCCCCCC; 373 | GPIOI->AFR[1] = 0x00000CC0; 374 | /* Configure PIx pins in Alternate function mode */ 375 | GPIOI->MODER = 0x0028AAAA; 376 | /* Configure PIx pins speed to 50 MHz */ 377 | GPIOI->OSPEEDR = 0x0028AAAA; 378 | /* Configure PIx pins Output type to push-pull */ 379 | GPIOI->OTYPER = 0x00000000; 380 | /* No pull-up, pull-down for PIx pins */ 381 | GPIOI->PUPDR = 0x00000000; 382 | 383 | /*-- FMC Configuration -------------------------------------------------------*/ 384 | /* Enable the FMC interface clock */ 385 | RCC->AHB3ENR |= 0x00000001; 386 | /* Delay after an RCC peripheral clock enabling */ 387 | tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); 388 | 389 | FMC_Bank5_6->SDCR[0] = 0x000019E4; 390 | FMC_Bank5_6->SDTR[0] = 0x01115351; 391 | 392 | /* SDRAM initialization sequence */ 393 | /* Clock enable command */ 394 | FMC_Bank5_6->SDCMR = 0x00000011; 395 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020; 396 | while((tmpreg != 0) && (timeout-- > 0)) 397 | { 398 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020; 399 | } 400 | 401 | /* Delay */ 402 | for (index = 0; index<1000; index++); 403 | 404 | /* PALL command */ 405 | FMC_Bank5_6->SDCMR = 0x00000012; 406 | timeout = 0xFFFF; 407 | while((tmpreg != 0) && (timeout-- > 0)) 408 | { 409 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020; 410 | } 411 | 412 | /* Auto refresh command */ 413 | FMC_Bank5_6->SDCMR = 0x00000073; 414 | timeout = 0xFFFF; 415 | while((tmpreg != 0) && (timeout-- > 0)) 416 | { 417 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020; 418 | } 419 | 420 | /* MRD register program */ 421 | FMC_Bank5_6->SDCMR = 0x00046014; 422 | timeout = 0xFFFF; 423 | while((tmpreg != 0) && (timeout-- > 0)) 424 | { 425 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020; 426 | } 427 | 428 | /* Set refresh count */ 429 | tmpreg = FMC_Bank5_6->SDRTR; 430 | FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1)); 431 | 432 | /* Disable write protection */ 433 | tmpreg = FMC_Bank5_6->SDCR[0]; 434 | FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF); 435 | 436 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) 437 | /* Configure and enable Bank1_SRAM2 */ 438 | FMC_Bank1->BTCR[2] = 0x00001011; 439 | FMC_Bank1->BTCR[3] = 0x00000201; 440 | FMC_Bank1E->BWTR[2] = 0x0fffffff; 441 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ 442 | #if defined(STM32F469xx) || defined(STM32F479xx) 443 | /* Configure and enable Bank1_SRAM2 */ 444 | FMC_Bank1->BTCR[2] = 0x00001091; 445 | FMC_Bank1->BTCR[3] = 0x00110212; 446 | FMC_Bank1E->BWTR[2] = 0x0fffffff; 447 | #endif /* STM32F469xx || STM32F479xx */ 448 | 449 | (void)(tmp); 450 | } 451 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 452 | #elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) 453 | /** 454 | * @brief Setup the external memory controller. 455 | * Called in startup_stm32f4xx.s before jump to main. 456 | * This function configures the external memories (SRAM/SDRAM) 457 | * This SRAM/SDRAM will be used as program data memory (including heap and stack). 458 | * @param None 459 | * @retval None 460 | */ 461 | void SystemInit_ExtMemCtl(void) 462 | { 463 | __IO uint32_t tmp = 0x00; 464 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ 465 | || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) 466 | #if defined (DATA_IN_ExtSDRAM) 467 | register uint32_t tmpreg = 0, timeout = 0xFFFF; 468 | register __IO uint32_t index; 469 | 470 | #if defined(STM32F446xx) 471 | /* Enable GPIOA, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG interface 472 | clock */ 473 | RCC->AHB1ENR |= 0x0000007D; 474 | #else 475 | /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface 476 | clock */ 477 | RCC->AHB1ENR |= 0x000001F8; 478 | #endif /* STM32F446xx */ 479 | /* Delay after an RCC peripheral clock enabling */ 480 | tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN); 481 | 482 | #if defined(STM32F446xx) 483 | /* Connect PAx pins to FMC Alternate function */ 484 | GPIOA->AFR[0] |= 0xC0000000; 485 | GPIOA->AFR[1] |= 0x00000000; 486 | /* Configure PDx pins in Alternate function mode */ 487 | GPIOA->MODER |= 0x00008000; 488 | /* Configure PDx pins speed to 50 MHz */ 489 | GPIOA->OSPEEDR |= 0x00008000; 490 | /* Configure PDx pins Output type to push-pull */ 491 | GPIOA->OTYPER |= 0x00000000; 492 | /* No pull-up, pull-down for PDx pins */ 493 | GPIOA->PUPDR |= 0x00000000; 494 | 495 | /* Connect PCx pins to FMC Alternate function */ 496 | GPIOC->AFR[0] |= 0x00CC0000; 497 | GPIOC->AFR[1] |= 0x00000000; 498 | /* Configure PDx pins in Alternate function mode */ 499 | GPIOC->MODER |= 0x00000A00; 500 | /* Configure PDx pins speed to 50 MHz */ 501 | GPIOC->OSPEEDR |= 0x00000A00; 502 | /* Configure PDx pins Output type to push-pull */ 503 | GPIOC->OTYPER |= 0x00000000; 504 | /* No pull-up, pull-down for PDx pins */ 505 | GPIOC->PUPDR |= 0x00000000; 506 | #endif /* STM32F446xx */ 507 | 508 | /* Connect PDx pins to FMC Alternate function */ 509 | GPIOD->AFR[0] = 0x000000CC; 510 | GPIOD->AFR[1] = 0xCC000CCC; 511 | /* Configure PDx pins in Alternate function mode */ 512 | GPIOD->MODER = 0xA02A000A; 513 | /* Configure PDx pins speed to 50 MHz */ 514 | GPIOD->OSPEEDR = 0xA02A000A; 515 | /* Configure PDx pins Output type to push-pull */ 516 | GPIOD->OTYPER = 0x00000000; 517 | /* No pull-up, pull-down for PDx pins */ 518 | GPIOD->PUPDR = 0x00000000; 519 | 520 | /* Connect PEx pins to FMC Alternate function */ 521 | GPIOE->AFR[0] = 0xC00000CC; 522 | GPIOE->AFR[1] = 0xCCCCCCCC; 523 | /* Configure PEx pins in Alternate function mode */ 524 | GPIOE->MODER = 0xAAAA800A; 525 | /* Configure PEx pins speed to 50 MHz */ 526 | GPIOE->OSPEEDR = 0xAAAA800A; 527 | /* Configure PEx pins Output type to push-pull */ 528 | GPIOE->OTYPER = 0x00000000; 529 | /* No pull-up, pull-down for PEx pins */ 530 | GPIOE->PUPDR = 0x00000000; 531 | 532 | /* Connect PFx pins to FMC Alternate function */ 533 | GPIOF->AFR[0] = 0xCCCCCCCC; 534 | GPIOF->AFR[1] = 0xCCCCCCCC; 535 | /* Configure PFx pins in Alternate function mode */ 536 | GPIOF->MODER = 0xAA800AAA; 537 | /* Configure PFx pins speed to 50 MHz */ 538 | GPIOF->OSPEEDR = 0xAA800AAA; 539 | /* Configure PFx pins Output type to push-pull */ 540 | GPIOF->OTYPER = 0x00000000; 541 | /* No pull-up, pull-down for PFx pins */ 542 | GPIOF->PUPDR = 0x00000000; 543 | 544 | /* Connect PGx pins to FMC Alternate function */ 545 | GPIOG->AFR[0] = 0xCCCCCCCC; 546 | GPIOG->AFR[1] = 0xCCCCCCCC; 547 | /* Configure PGx pins in Alternate function mode */ 548 | GPIOG->MODER = 0xAAAAAAAA; 549 | /* Configure PGx pins speed to 50 MHz */ 550 | GPIOG->OSPEEDR = 0xAAAAAAAA; 551 | /* Configure PGx pins Output type to push-pull */ 552 | GPIOG->OTYPER = 0x00000000; 553 | /* No pull-up, pull-down for PGx pins */ 554 | GPIOG->PUPDR = 0x00000000; 555 | 556 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ 557 | || defined(STM32F469xx) || defined(STM32F479xx) 558 | /* Connect PHx pins to FMC Alternate function */ 559 | GPIOH->AFR[0] = 0x00C0CC00; 560 | GPIOH->AFR[1] = 0xCCCCCCCC; 561 | /* Configure PHx pins in Alternate function mode */ 562 | GPIOH->MODER = 0xAAAA08A0; 563 | /* Configure PHx pins speed to 50 MHz */ 564 | GPIOH->OSPEEDR = 0xAAAA08A0; 565 | /* Configure PHx pins Output type to push-pull */ 566 | GPIOH->OTYPER = 0x00000000; 567 | /* No pull-up, pull-down for PHx pins */ 568 | GPIOH->PUPDR = 0x00000000; 569 | 570 | /* Connect PIx pins to FMC Alternate function */ 571 | GPIOI->AFR[0] = 0xCCCCCCCC; 572 | GPIOI->AFR[1] = 0x00000CC0; 573 | /* Configure PIx pins in Alternate function mode */ 574 | GPIOI->MODER = 0x0028AAAA; 575 | /* Configure PIx pins speed to 50 MHz */ 576 | GPIOI->OSPEEDR = 0x0028AAAA; 577 | /* Configure PIx pins Output type to push-pull */ 578 | GPIOI->OTYPER = 0x00000000; 579 | /* No pull-up, pull-down for PIx pins */ 580 | GPIOI->PUPDR = 0x00000000; 581 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 582 | 583 | /*-- FMC Configuration -------------------------------------------------------*/ 584 | /* Enable the FMC interface clock */ 585 | RCC->AHB3ENR |= 0x00000001; 586 | /* Delay after an RCC peripheral clock enabling */ 587 | tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); 588 | 589 | /* Configure and enable SDRAM bank1 */ 590 | #if defined(STM32F446xx) 591 | FMC_Bank5_6->SDCR[0] = 0x00001954; 592 | #else 593 | FMC_Bank5_6->SDCR[0] = 0x000019E4; 594 | #endif /* STM32F446xx */ 595 | FMC_Bank5_6->SDTR[0] = 0x01115351; 596 | 597 | /* SDRAM initialization sequence */ 598 | /* Clock enable command */ 599 | FMC_Bank5_6->SDCMR = 0x00000011; 600 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020; 601 | while((tmpreg != 0) && (timeout-- > 0)) 602 | { 603 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020; 604 | } 605 | 606 | /* Delay */ 607 | for (index = 0; index<1000; index++); 608 | 609 | /* PALL command */ 610 | FMC_Bank5_6->SDCMR = 0x00000012; 611 | timeout = 0xFFFF; 612 | while((tmpreg != 0) && (timeout-- > 0)) 613 | { 614 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020; 615 | } 616 | 617 | /* Auto refresh command */ 618 | #if defined(STM32F446xx) 619 | FMC_Bank5_6->SDCMR = 0x000000F3; 620 | #else 621 | FMC_Bank5_6->SDCMR = 0x00000073; 622 | #endif /* STM32F446xx */ 623 | timeout = 0xFFFF; 624 | while((tmpreg != 0) && (timeout-- > 0)) 625 | { 626 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020; 627 | } 628 | 629 | /* MRD register program */ 630 | #if defined(STM32F446xx) 631 | FMC_Bank5_6->SDCMR = 0x00044014; 632 | #else 633 | FMC_Bank5_6->SDCMR = 0x00046014; 634 | #endif /* STM32F446xx */ 635 | timeout = 0xFFFF; 636 | while((tmpreg != 0) && (timeout-- > 0)) 637 | { 638 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020; 639 | } 640 | 641 | /* Set refresh count */ 642 | tmpreg = FMC_Bank5_6->SDRTR; 643 | #if defined(STM32F446xx) 644 | FMC_Bank5_6->SDRTR = (tmpreg | (0x0000050C<<1)); 645 | #else 646 | FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1)); 647 | #endif /* STM32F446xx */ 648 | 649 | /* Disable write protection */ 650 | tmpreg = FMC_Bank5_6->SDCR[0]; 651 | FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF); 652 | #endif /* DATA_IN_ExtSDRAM */ 653 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */ 654 | 655 | #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\ 656 | || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ 657 | || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) 658 | 659 | #if defined(DATA_IN_ExtSRAM) 660 | /*-- GPIOs Configuration -----------------------------------------------------*/ 661 | /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */ 662 | RCC->AHB1ENR |= 0x00000078; 663 | /* Delay after an RCC peripheral clock enabling */ 664 | tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN); 665 | 666 | /* Connect PDx pins to FMC Alternate function */ 667 | GPIOD->AFR[0] = 0x00CCC0CC; 668 | GPIOD->AFR[1] = 0xCCCCCCCC; 669 | /* Configure PDx pins in Alternate function mode */ 670 | GPIOD->MODER = 0xAAAA0A8A; 671 | /* Configure PDx pins speed to 100 MHz */ 672 | GPIOD->OSPEEDR = 0xFFFF0FCF; 673 | /* Configure PDx pins Output type to push-pull */ 674 | GPIOD->OTYPER = 0x00000000; 675 | /* No pull-up, pull-down for PDx pins */ 676 | GPIOD->PUPDR = 0x00000000; 677 | 678 | /* Connect PEx pins to FMC Alternate function */ 679 | GPIOE->AFR[0] = 0xC00CC0CC; 680 | GPIOE->AFR[1] = 0xCCCCCCCC; 681 | /* Configure PEx pins in Alternate function mode */ 682 | GPIOE->MODER = 0xAAAA828A; 683 | /* Configure PEx pins speed to 100 MHz */ 684 | GPIOE->OSPEEDR = 0xFFFFC3CF; 685 | /* Configure PEx pins Output type to push-pull */ 686 | GPIOE->OTYPER = 0x00000000; 687 | /* No pull-up, pull-down for PEx pins */ 688 | GPIOE->PUPDR = 0x00000000; 689 | 690 | /* Connect PFx pins to FMC Alternate function */ 691 | GPIOF->AFR[0] = 0x00CCCCCC; 692 | GPIOF->AFR[1] = 0xCCCC0000; 693 | /* Configure PFx pins in Alternate function mode */ 694 | GPIOF->MODER = 0xAA000AAA; 695 | /* Configure PFx pins speed to 100 MHz */ 696 | GPIOF->OSPEEDR = 0xFF000FFF; 697 | /* Configure PFx pins Output type to push-pull */ 698 | GPIOF->OTYPER = 0x00000000; 699 | /* No pull-up, pull-down for PFx pins */ 700 | GPIOF->PUPDR = 0x00000000; 701 | 702 | /* Connect PGx pins to FMC Alternate function */ 703 | GPIOG->AFR[0] = 0x00CCCCCC; 704 | GPIOG->AFR[1] = 0x000000C0; 705 | /* Configure PGx pins in Alternate function mode */ 706 | GPIOG->MODER = 0x00085AAA; 707 | /* Configure PGx pins speed to 100 MHz */ 708 | GPIOG->OSPEEDR = 0x000CAFFF; 709 | /* Configure PGx pins Output type to push-pull */ 710 | GPIOG->OTYPER = 0x00000000; 711 | /* No pull-up, pull-down for PGx pins */ 712 | GPIOG->PUPDR = 0x00000000; 713 | 714 | /*-- FMC/FSMC Configuration --------------------------------------------------*/ 715 | /* Enable the FMC/FSMC interface clock */ 716 | RCC->AHB3ENR |= 0x00000001; 717 | 718 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) 719 | /* Delay after an RCC peripheral clock enabling */ 720 | tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); 721 | /* Configure and enable Bank1_SRAM2 */ 722 | FMC_Bank1->BTCR[2] = 0x00001011; 723 | FMC_Bank1->BTCR[3] = 0x00000201; 724 | FMC_Bank1E->BWTR[2] = 0x0fffffff; 725 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ 726 | #if defined(STM32F469xx) || defined(STM32F479xx) 727 | /* Delay after an RCC peripheral clock enabling */ 728 | tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); 729 | /* Configure and enable Bank1_SRAM2 */ 730 | FMC_Bank1->BTCR[2] = 0x00001091; 731 | FMC_Bank1->BTCR[3] = 0x00110212; 732 | FMC_Bank1E->BWTR[2] = 0x0fffffff; 733 | #endif /* STM32F469xx || STM32F479xx */ 734 | #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)\ 735 | || defined(STM32F412Zx) || defined(STM32F412Vx) 736 | /* Delay after an RCC peripheral clock enabling */ 737 | tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN); 738 | /* Configure and enable Bank1_SRAM2 */ 739 | FSMC_Bank1->BTCR[2] = 0x00001011; 740 | FSMC_Bank1->BTCR[3] = 0x00000201; 741 | FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF; 742 | #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx */ 743 | 744 | #endif /* DATA_IN_ExtSRAM */ 745 | #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\ 746 | STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */ 747 | (void)(tmp); 748 | } 749 | #endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */ 750 | /** 751 | * @} 752 | */ 753 | 754 | /** 755 | * @} 756 | */ 757 | 758 | /** 759 | * @} 760 | */ 761 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 762 | -------------------------------------------------------------------------------- /cubefix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Fix project after updating it with STM32CubeMX 4 | 5 | set -e 6 | 7 | cp Makefile.backup Makefile 8 | dos2unix Src/main.c 9 | sed -i -e '1,39d' Src/main.c 10 | -------------------------------------------------------------------------------- /img/image-to-mem.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # vim: set ai et ts=4 sw=4: 4 | 5 | from PIL import Image 6 | import sys 7 | import os 8 | 9 | if len(sys.argv) < 2: 10 | print("Usage: {} ".format(sys.argv[0])) 11 | sys.exit(1) 12 | 13 | fname = sys.argv[1] 14 | 15 | img = Image.open(fname) 16 | if img.width != 128 or img.height != 128: 17 | print("Error: 128x128 image expected"); 18 | sys.exit(2) 19 | 20 | print("const uint16_t test_img_128x128[][128] = {"); 21 | 22 | for y in range(0, img.height): 23 | s = "{" 24 | for x in range(0, img.width): 25 | (r, g, b) = img.getpixel( (x, y) ) 26 | color565 = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3) 27 | # for right endiness, so ST7735_DrawImage would work 28 | color565 = ((color565 & 0xFF00) >> 8) | ((color565 & 0xFF) << 8) 29 | s += "0x{:04X},".format(color565) 30 | s += "}," 31 | print(s) 32 | 33 | print("};") 34 | -------------------------------------------------------------------------------- /img/parrot_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/afiskon/stm32-rtc-example/466c726afc7e25f575d4f5880217a1ae7ca64db6/img/parrot_128x128.png -------------------------------------------------------------------------------- /main.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | KeepUserPlacement=true 4 | Mcu.Family=STM32F4 5 | Mcu.IP0=NVIC 6 | Mcu.IP1=RCC 7 | Mcu.IP2=RTC 8 | Mcu.IP3=SPI1 9 | Mcu.IP4=SYS 10 | Mcu.IP5=USART2 11 | Mcu.IPNb=6 12 | Mcu.Name=STM32F411R(C-E)Tx 13 | Mcu.Package=LQFP64 14 | Mcu.Pin0=PC13-ANTI_TAMP 15 | Mcu.Pin1=PC14-OSC32_IN 16 | Mcu.Pin10=PC7 17 | Mcu.Pin11=PA8 18 | Mcu.Pin12=PA9 19 | Mcu.Pin13=PA13 20 | Mcu.Pin14=PA14 21 | Mcu.Pin15=PB3 22 | Mcu.Pin16=PB4 23 | Mcu.Pin17=PB5 24 | Mcu.Pin18=PB6 25 | Mcu.Pin19=VP_RTC_VS_RTC_Activate 26 | Mcu.Pin2=PC15-OSC32_OUT 27 | Mcu.Pin20=VP_RTC_VS_RTC_Calendar 28 | Mcu.Pin21=VP_SYS_VS_Systick 29 | Mcu.Pin3=PH0 - OSC_IN 30 | Mcu.Pin4=PH1 - OSC_OUT 31 | Mcu.Pin5=PA2 32 | Mcu.Pin6=PA3 33 | Mcu.Pin7=PA5 34 | Mcu.Pin8=PA7 35 | Mcu.Pin9=PB10 36 | Mcu.PinsNb=22 37 | Mcu.UserConstants= 38 | Mcu.UserName=STM32F411RETx 39 | MxCube.Version=4.23.0 40 | MxDb.Version=DB.4.0.230 41 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false 42 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false 43 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false 44 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false 45 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false 46 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:false\:false 47 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_0 48 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false 49 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:true 50 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false 51 | PA13.GPIOParameters=GPIO_Label 52 | PA13.GPIO_Label=TMS 53 | PA13.Locked=true 54 | PA13.Signal=SYS_JTMS-SWDIO 55 | PA14.GPIOParameters=GPIO_Label 56 | PA14.GPIO_Label=TCK 57 | PA14.Locked=true 58 | PA14.Signal=SYS_JTCK-SWCLK 59 | PA2.GPIOParameters=GPIO_Label 60 | PA2.GPIO_Label=USART_TX 61 | PA2.Locked=true 62 | PA2.Mode=Asynchronous 63 | PA2.Signal=USART2_TX 64 | PA3.GPIOParameters=GPIO_Label 65 | PA3.GPIO_Label=USART_RX 66 | PA3.Locked=true 67 | PA3.Mode=Asynchronous 68 | PA3.Signal=USART2_RX 69 | PA5.Mode=Simplex_Bidirectional_Master 70 | PA5.Signal=SPI1_SCK 71 | PA7.Mode=Simplex_Bidirectional_Master 72 | PA7.Signal=SPI1_MOSI 73 | PA8.GPIOParameters=GPIO_Label 74 | PA8.GPIO_Label=Btn1 75 | PA8.Locked=true 76 | PA8.Signal=GPIO_Input 77 | PA9.Locked=true 78 | PA9.Signal=GPIO_Output 79 | PB10.GPIOParameters=GPIO_Label 80 | PB10.GPIO_Label=Btn2 81 | PB10.Locked=true 82 | PB10.Signal=GPIO_Input 83 | PB3.GPIOParameters=GPIO_Label 84 | PB3.GPIO_Label=SWO 85 | PB3.Locked=true 86 | PB3.Signal=SYS_JTDO-SWO 87 | PB4.GPIOParameters=GPIO_Label 88 | PB4.GPIO_Label=Btn3 89 | PB4.Locked=true 90 | PB4.Signal=GPIO_Input 91 | PB5.GPIOParameters=GPIO_Label 92 | PB5.GPIO_Label=Btn4 93 | PB5.Locked=true 94 | PB5.Signal=GPIO_Input 95 | PB6.Locked=true 96 | PB6.Signal=GPIO_Output 97 | PC13-ANTI_TAMP.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI 98 | PC13-ANTI_TAMP.GPIO_Label=B1 [Blue PushButton] 99 | PC13-ANTI_TAMP.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING 100 | PC13-ANTI_TAMP.Locked=true 101 | PC13-ANTI_TAMP.Signal=GPXTI13 102 | PC14-OSC32_IN.Locked=true 103 | PC14-OSC32_IN.Mode=LSE-External-Oscillator 104 | PC14-OSC32_IN.Signal=RCC_OSC32_IN 105 | PC15-OSC32_OUT.Locked=true 106 | PC15-OSC32_OUT.Mode=LSE-External-Oscillator 107 | PC15-OSC32_OUT.Signal=RCC_OSC32_OUT 108 | PC7.Locked=true 109 | PC7.Signal=GPIO_Output 110 | PCC.Checker=false 111 | PCC.Line=STM32F411 112 | PCC.MCU=STM32F411R(C-E)Tx 113 | PCC.PartNumber=STM32F411RETx 114 | PCC.Seq0=0 115 | PCC.Series=STM32F4 116 | PCC.Temperature=25 117 | PCC.Vdd=null 118 | PH0\ -\ OSC_IN.Locked=true 119 | PH0\ -\ OSC_IN.Signal=RCC_OSC_IN 120 | PH1\ -\ OSC_OUT.Locked=true 121 | PH1\ -\ OSC_OUT.Signal=RCC_OSC_OUT 122 | PinOutPanel.RotationAngle=0 123 | ProjectManager.AskForMigrate=true 124 | ProjectManager.BackupPrevious=false 125 | ProjectManager.CompilerOptimize=2 126 | ProjectManager.ComputerToolchain=false 127 | ProjectManager.CoupleFile=false 128 | ProjectManager.CustomerFirmwarePackage=/home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0 129 | ProjectManager.DefaultFWLocation=true 130 | ProjectManager.DeletePrevious=true 131 | ProjectManager.DeviceId=STM32F411RETx 132 | ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.18.0 133 | ProjectManager.FreePins=false 134 | ProjectManager.HalAssertFull=false 135 | ProjectManager.HeapSize=0x200 136 | ProjectManager.KeepUserCode=true 137 | ProjectManager.LastFirmware=true 138 | ProjectManager.LibraryCopy=2 139 | ProjectManager.PreviousToolchain= 140 | ProjectManager.ProjectBuild=false 141 | ProjectManager.ProjectFileName=main.ioc 142 | ProjectManager.ProjectName=main 143 | ProjectManager.StackSize=0x400 144 | ProjectManager.TargetToolchain=Makefile 145 | ProjectManager.ToolChainLocation= 146 | ProjectManager.UnderRoot=false 147 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL,2-SystemClock_Config-RCC-false-HAL,3-MX_SPI1_Init-SPI1-false-HAL,4-MX_USART2_UART_Init-USART2-false-HAL,5-MX_RTC_Init-RTC-false-HAL 148 | RCC.48MHZClocksFreq_Value=84000000 149 | RCC.AHBFreq_Value=84000000 150 | RCC.APB1CLKDivider=RCC_HCLK_DIV2 151 | RCC.APB1Freq_Value=42000000 152 | RCC.APB1TimFreq_Value=84000000 153 | RCC.APB2Freq_Value=84000000 154 | RCC.APB2TimFreq_Value=84000000 155 | RCC.CortexFreq_Value=84000000 156 | RCC.EthernetFreq_Value=84000000 157 | RCC.FCLKCortexFreq_Value=84000000 158 | RCC.FLatency-AdvancedSettings=FLASH_LATENCY_2 159 | RCC.FamilyName=M 160 | RCC.HCLKFreq_Value=84000000 161 | RCC.HSE_VALUE=8000000 162 | RCC.HSI_VALUE=16000000 163 | RCC.I2SClocksFreq_Value=96000000 164 | RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FLatency-AdvancedSettings,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLN,PLLP,PLLQCLKFreq_Value,RCC_RTC_Clock_Source,RCC_RTC_Clock_SourceVirtual,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOInputMFreq_Value,VCOOutputFreq_Value,VcooutputI2S 165 | RCC.LSI_VALUE=32000 166 | RCC.MCO2PinFreq_Value=84000000 167 | RCC.PLLCLKFreq_Value=84000000 168 | RCC.PLLN=336 169 | RCC.PLLP=RCC_PLLP_DIV4 170 | RCC.PLLQCLKFreq_Value=84000000 171 | RCC.RCC_RTC_Clock_Source=RCC_RTCCLKSOURCE_LSE 172 | RCC.RCC_RTC_Clock_SourceVirtual=RCC_RTCCLKSOURCE_LSE 173 | RCC.RTCFreq_Value=32768 174 | RCC.RTCHSEDivFreq_Value=4000000 175 | RCC.SYSCLKFreq_VALUE=84000000 176 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 177 | RCC.VCOI2SOutputFreq_Value=192000000 178 | RCC.VCOInputFreq_Value=1000000 179 | RCC.VCOInputMFreq_Value=1000000 180 | RCC.VCOOutputFreq_Value=336000000 181 | RCC.VcooutputI2S=96000000 182 | RTC.Format=RTC_FORMAT_BIN 183 | RTC.IPParameters=Format 184 | SH.GPXTI13.0=GPIO_EXTI13 185 | SH.GPXTI13.ConfNb=1 186 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2 187 | SPI1.CalculateBaudRate=42.0 MBits/s 188 | SPI1.Direction=SPI_DIRECTION_1LINE 189 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler 190 | SPI1.Mode=SPI_MODE_MASTER 191 | SPI1.VirtualType=VM_MASTER 192 | USART2.BaudRate=9600 193 | USART2.IPParameters=VirtualMode,BaudRate 194 | USART2.VirtualMode=VM_ASYNC 195 | VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled 196 | VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate 197 | VP_RTC_VS_RTC_Calendar.Mode=RTC_Calendar 198 | VP_RTC_VS_RTC_Calendar.Signal=RTC_VS_RTC_Calendar 199 | VP_SYS_VS_Systick.Mode=SysTick 200 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 201 | board=NUCLEO-F411RE 202 | boardIOC=true 203 | -------------------------------------------------------------------------------- /mx.scratch: -------------------------------------------------------------------------------- 1 | 2 | 3 | /home/eax/projects/sandbox/stm32/stm32-rtc-st7735/\main 4 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/CMSIS 5 | /home/eax/STM32Cube/Repository//STM32Cube_FW_F4_V1.18.0/Drivers/CMSIS 6 | 7 | Makefile 8 | 0 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | main 26 | STM32F411RETx 27 | 0x200 28 | 0x400 29 | 30 | NUCLEO-F411RE 31 | 32 | true 33 | 34 | 35 | 0 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | USE_FULL_LL_DRIVER 54 | MBEDTLS_CONFIG_FILE="mbedtls_config.h" 55 | _TIMEVAL_DEFINED 56 | _SYS_TIME_H_ 57 | 58 | 59 | 60 | 61 | Inc 62 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Inc 63 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy 64 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include 65 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/CMSIS/Include 66 | 67 | 68 | 69 | 70 | 71 | false 72 | 73 | 74 | Drivers 75 | 76 | STM32F4xx_HAL_Driver 77 | 78 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc.c 79 | 80 | 81 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc_ex.c 82 | 83 | 84 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c 85 | 86 | 87 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c 88 | 89 | 90 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c 91 | 92 | 93 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c 94 | 95 | 96 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c 97 | 98 | 99 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c 100 | 101 | 102 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c 103 | 104 | 105 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c 106 | 107 | 108 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c 109 | 110 | 111 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c 112 | 113 | 114 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c 115 | 116 | 117 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c 118 | 119 | 120 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c 121 | 122 | 123 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c 124 | 125 | 126 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c 127 | 128 | 129 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c 130 | 131 | 132 | 133 | CMSIS 134 | 135 | Src/system_stm32f4xx.c 136 | 137 | 138 | 139 | 140 | Application 141 | 142 | User 143 | 144 | Src/main.c 145 | 146 | 147 | 148 | Src/stm32f4xx_it.c 149 | 150 | 151 | 152 | Src/stm32f4xx_hal_msp.c 153 | 154 | 155 | 156 | 157 | 158 | Src 159 | 160 | main.c 161 | 162 | Src/main.c 163 | 164 | 165 | 166 | 167 | Src 168 | 169 | stm32f4xx_hal_msp.c 170 | 171 | Src/stm32f4xx_hal_msp.c 172 | 173 | 174 | 175 | 176 | Src 177 | 178 | stm32f4xx_it.c 179 | 180 | Src/stm32f4xx_it.c 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | -------------------------------------------------------------------------------- /st7735/fonts.c: -------------------------------------------------------------------------------- 1 | /* vim: set ai et ts=4 sw=4: */ 2 | #include "fonts.h" 3 | 4 | static const uint16_t Font7x10 [] = { 5 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // sp 6 | 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x1000, 0x0000, 0x0000, // ! 7 | 0x2800, 0x2800, 0x2800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // " 8 | 0x2400, 0x2400, 0x7C00, 0x2400, 0x4800, 0x7C00, 0x4800, 0x4800, 0x0000, 0x0000, // # 9 | 0x3800, 0x5400, 0x5000, 0x3800, 0x1400, 0x5400, 0x5400, 0x3800, 0x1000, 0x0000, // $ 10 | 0x2000, 0x5400, 0x5800, 0x3000, 0x2800, 0x5400, 0x1400, 0x0800, 0x0000, 0x0000, // % 11 | 0x1000, 0x2800, 0x2800, 0x1000, 0x3400, 0x4800, 0x4800, 0x3400, 0x0000, 0x0000, // & 12 | 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ' 13 | 0x0800, 0x1000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x1000, 0x0800, // ( 14 | 0x2000, 0x1000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x1000, 0x2000, // ) 15 | 0x1000, 0x3800, 0x1000, 0x2800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // * 16 | 0x0000, 0x0000, 0x1000, 0x1000, 0x7C00, 0x1000, 0x1000, 0x0000, 0x0000, 0x0000, // + 17 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1000, 0x1000, 0x1000, // , 18 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3800, 0x0000, 0x0000, 0x0000, 0x0000, // - 19 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0x0000, // . 20 | 0x0800, 0x0800, 0x1000, 0x1000, 0x1000, 0x1000, 0x2000, 0x2000, 0x0000, 0x0000, // / 21 | 0x3800, 0x4400, 0x4400, 0x5400, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // 0 22 | 0x1000, 0x3000, 0x5000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // 1 23 | 0x3800, 0x4400, 0x4400, 0x0400, 0x0800, 0x1000, 0x2000, 0x7C00, 0x0000, 0x0000, // 2 24 | 0x3800, 0x4400, 0x0400, 0x1800, 0x0400, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, // 3 25 | 0x0800, 0x1800, 0x2800, 0x2800, 0x4800, 0x7C00, 0x0800, 0x0800, 0x0000, 0x0000, // 4 26 | 0x7C00, 0x4000, 0x4000, 0x7800, 0x0400, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, // 5 27 | 0x3800, 0x4400, 0x4000, 0x7800, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // 6 28 | 0x7C00, 0x0400, 0x0800, 0x1000, 0x1000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, // 7 29 | 0x3800, 0x4400, 0x4400, 0x3800, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // 8 30 | 0x3800, 0x4400, 0x4400, 0x4400, 0x3C00, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, // 9 31 | 0x0000, 0x0000, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0x0000, // : 32 | 0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0x0000, 0x0000, 0x1000, 0x1000, 0x1000, // ; 33 | 0x0000, 0x0000, 0x0C00, 0x3000, 0x4000, 0x3000, 0x0C00, 0x0000, 0x0000, 0x0000, // < 34 | 0x0000, 0x0000, 0x0000, 0x7C00, 0x0000, 0x7C00, 0x0000, 0x0000, 0x0000, 0x0000, // = 35 | 0x0000, 0x0000, 0x6000, 0x1800, 0x0400, 0x1800, 0x6000, 0x0000, 0x0000, 0x0000, // > 36 | 0x3800, 0x4400, 0x0400, 0x0800, 0x1000, 0x1000, 0x0000, 0x1000, 0x0000, 0x0000, // ? 37 | 0x3800, 0x4400, 0x4C00, 0x5400, 0x5C00, 0x4000, 0x4000, 0x3800, 0x0000, 0x0000, // @ 38 | 0x1000, 0x2800, 0x2800, 0x2800, 0x2800, 0x7C00, 0x4400, 0x4400, 0x0000, 0x0000, // A 39 | 0x7800, 0x4400, 0x4400, 0x7800, 0x4400, 0x4400, 0x4400, 0x7800, 0x0000, 0x0000, // B 40 | 0x3800, 0x4400, 0x4000, 0x4000, 0x4000, 0x4000, 0x4400, 0x3800, 0x0000, 0x0000, // C 41 | 0x7000, 0x4800, 0x4400, 0x4400, 0x4400, 0x4400, 0x4800, 0x7000, 0x0000, 0x0000, // D 42 | 0x7C00, 0x4000, 0x4000, 0x7C00, 0x4000, 0x4000, 0x4000, 0x7C00, 0x0000, 0x0000, // E 43 | 0x7C00, 0x4000, 0x4000, 0x7800, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, // F 44 | 0x3800, 0x4400, 0x4000, 0x4000, 0x5C00, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // G 45 | 0x4400, 0x4400, 0x4400, 0x7C00, 0x4400, 0x4400, 0x4400, 0x4400, 0x0000, 0x0000, // H 46 | 0x3800, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x3800, 0x0000, 0x0000, // I 47 | 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, // J 48 | 0x4400, 0x4800, 0x5000, 0x6000, 0x5000, 0x4800, 0x4800, 0x4400, 0x0000, 0x0000, // K 49 | 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7C00, 0x0000, 0x0000, // L 50 | 0x4400, 0x6C00, 0x6C00, 0x5400, 0x4400, 0x4400, 0x4400, 0x4400, 0x0000, 0x0000, // M 51 | 0x4400, 0x6400, 0x6400, 0x5400, 0x5400, 0x4C00, 0x4C00, 0x4400, 0x0000, 0x0000, // N 52 | 0x3800, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // O 53 | 0x7800, 0x4400, 0x4400, 0x4400, 0x7800, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, // P 54 | 0x3800, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x5400, 0x3800, 0x0400, 0x0000, // Q 55 | 0x7800, 0x4400, 0x4400, 0x4400, 0x7800, 0x4800, 0x4800, 0x4400, 0x0000, 0x0000, // R 56 | 0x3800, 0x4400, 0x4000, 0x3000, 0x0800, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, // S 57 | 0x7C00, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // T 58 | 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // U 59 | 0x4400, 0x4400, 0x4400, 0x2800, 0x2800, 0x2800, 0x1000, 0x1000, 0x0000, 0x0000, // V 60 | 0x4400, 0x4400, 0x5400, 0x5400, 0x5400, 0x6C00, 0x2800, 0x2800, 0x0000, 0x0000, // W 61 | 0x4400, 0x2800, 0x2800, 0x1000, 0x1000, 0x2800, 0x2800, 0x4400, 0x0000, 0x0000, // X 62 | 0x4400, 0x4400, 0x2800, 0x2800, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // Y 63 | 0x7C00, 0x0400, 0x0800, 0x1000, 0x1000, 0x2000, 0x4000, 0x7C00, 0x0000, 0x0000, // Z 64 | 0x1800, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1800, // [ 65 | 0x2000, 0x2000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800, 0x0000, 0x0000, /* \ */ 66 | 0x3000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x3000, // ] 67 | 0x1000, 0x2800, 0x2800, 0x4400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ^ 68 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFE00, // _ 69 | 0x2000, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ` 70 | 0x0000, 0x0000, 0x3800, 0x4400, 0x3C00, 0x4400, 0x4C00, 0x3400, 0x0000, 0x0000, // a 71 | 0x4000, 0x4000, 0x5800, 0x6400, 0x4400, 0x4400, 0x6400, 0x5800, 0x0000, 0x0000, // b 72 | 0x0000, 0x0000, 0x3800, 0x4400, 0x4000, 0x4000, 0x4400, 0x3800, 0x0000, 0x0000, // c 73 | 0x0400, 0x0400, 0x3400, 0x4C00, 0x4400, 0x4400, 0x4C00, 0x3400, 0x0000, 0x0000, // d 74 | 0x0000, 0x0000, 0x3800, 0x4400, 0x7C00, 0x4000, 0x4400, 0x3800, 0x0000, 0x0000, // e 75 | 0x0C00, 0x1000, 0x7C00, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // f 76 | 0x0000, 0x0000, 0x3400, 0x4C00, 0x4400, 0x4400, 0x4C00, 0x3400, 0x0400, 0x7800, // g 77 | 0x4000, 0x4000, 0x5800, 0x6400, 0x4400, 0x4400, 0x4400, 0x4400, 0x0000, 0x0000, // h 78 | 0x1000, 0x0000, 0x7000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // i 79 | 0x1000, 0x0000, 0x7000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0xE000, // j 80 | 0x4000, 0x4000, 0x4800, 0x5000, 0x6000, 0x5000, 0x4800, 0x4400, 0x0000, 0x0000, // k 81 | 0x7000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // l 82 | 0x0000, 0x0000, 0x7800, 0x5400, 0x5400, 0x5400, 0x5400, 0x5400, 0x0000, 0x0000, // m 83 | 0x0000, 0x0000, 0x5800, 0x6400, 0x4400, 0x4400, 0x4400, 0x4400, 0x0000, 0x0000, // n 84 | 0x0000, 0x0000, 0x3800, 0x4400, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // o 85 | 0x0000, 0x0000, 0x5800, 0x6400, 0x4400, 0x4400, 0x6400, 0x5800, 0x4000, 0x4000, // p 86 | 0x0000, 0x0000, 0x3400, 0x4C00, 0x4400, 0x4400, 0x4C00, 0x3400, 0x0400, 0x0400, // q 87 | 0x0000, 0x0000, 0x5800, 0x6400, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, // r 88 | 0x0000, 0x0000, 0x3800, 0x4400, 0x3000, 0x0800, 0x4400, 0x3800, 0x0000, 0x0000, // s 89 | 0x2000, 0x2000, 0x7800, 0x2000, 0x2000, 0x2000, 0x2000, 0x1800, 0x0000, 0x0000, // t 90 | 0x0000, 0x0000, 0x4400, 0x4400, 0x4400, 0x4400, 0x4C00, 0x3400, 0x0000, 0x0000, // u 91 | 0x0000, 0x0000, 0x4400, 0x4400, 0x2800, 0x2800, 0x2800, 0x1000, 0x0000, 0x0000, // v 92 | 0x0000, 0x0000, 0x5400, 0x5400, 0x5400, 0x6C00, 0x2800, 0x2800, 0x0000, 0x0000, // w 93 | 0x0000, 0x0000, 0x4400, 0x2800, 0x1000, 0x1000, 0x2800, 0x4400, 0x0000, 0x0000, // x 94 | 0x0000, 0x0000, 0x4400, 0x4400, 0x2800, 0x2800, 0x1000, 0x1000, 0x1000, 0x6000, // y 95 | 0x0000, 0x0000, 0x7C00, 0x0800, 0x1000, 0x2000, 0x4000, 0x7C00, 0x0000, 0x0000, // z 96 | 0x1800, 0x1000, 0x1000, 0x1000, 0x2000, 0x2000, 0x1000, 0x1000, 0x1000, 0x1800, // { 97 | 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, // | 98 | 0x3000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800, 0x1000, 0x1000, 0x1000, 0x3000, // } 99 | 0x0000, 0x0000, 0x0000, 0x7400, 0x4C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ~ 100 | }; 101 | 102 | static const uint16_t Font11x18 [] = { 103 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // sp 104 | 0x0000, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // ! 105 | 0x0000, 0x1B00, 0x1B00, 0x1B00, 0x1B00, 0x1B00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // " 106 | 0x0000, 0x1980, 0x1980, 0x1980, 0x1980, 0x7FC0, 0x7FC0, 0x1980, 0x3300, 0x7FC0, 0x7FC0, 0x3300, 0x3300, 0x3300, 0x3300, 0x0000, 0x0000, 0x0000, // # 107 | 0x0000, 0x1E00, 0x3F00, 0x7580, 0x6580, 0x7400, 0x3C00, 0x1E00, 0x0700, 0x0580, 0x6580, 0x6580, 0x7580, 0x3F00, 0x1E00, 0x0400, 0x0400, 0x0000, // $ 108 | 0x0000, 0x7000, 0xD800, 0xD840, 0xD8C0, 0xD980, 0x7300, 0x0600, 0x0C00, 0x1B80, 0x36C0, 0x66C0, 0x46C0, 0x06C0, 0x0380, 0x0000, 0x0000, 0x0000, // % 109 | 0x0000, 0x1E00, 0x3F00, 0x3300, 0x3300, 0x3300, 0x1E00, 0x0C00, 0x3CC0, 0x66C0, 0x6380, 0x6180, 0x6380, 0x3EC0, 0x1C80, 0x0000, 0x0000, 0x0000, // & 110 | 0x0000, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ' 111 | 0x0080, 0x0100, 0x0300, 0x0600, 0x0600, 0x0400, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0400, 0x0600, 0x0600, 0x0300, 0x0100, 0x0080, // ( 112 | 0x2000, 0x1000, 0x1800, 0x0C00, 0x0C00, 0x0400, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0400, 0x0C00, 0x0C00, 0x1800, 0x1000, 0x2000, // ) 113 | 0x0000, 0x0C00, 0x2D00, 0x3F00, 0x1E00, 0x3300, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // * 114 | 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0xFFC0, 0xFFC0, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // + 115 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0400, 0x0400, 0x0800, // , 116 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1E00, 0x1E00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // - 117 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // . 118 | 0x0000, 0x0300, 0x0300, 0x0300, 0x0600, 0x0600, 0x0600, 0x0600, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x1800, 0x1800, 0x1800, 0x0000, 0x0000, 0x0000, // / 119 | 0x0000, 0x1E00, 0x3F00, 0x3300, 0x6180, 0x6180, 0x6180, 0x6D80, 0x6D80, 0x6180, 0x6180, 0x6180, 0x3300, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 0 120 | 0x0000, 0x0600, 0x0E00, 0x1E00, 0x3600, 0x2600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, // 1 121 | 0x0000, 0x1E00, 0x3F00, 0x7380, 0x6180, 0x6180, 0x0180, 0x0300, 0x0600, 0x0C00, 0x1800, 0x3000, 0x6000, 0x7F80, 0x7F80, 0x0000, 0x0000, 0x0000, // 2 122 | 0x0000, 0x1C00, 0x3E00, 0x6300, 0x6300, 0x0300, 0x0E00, 0x0E00, 0x0300, 0x0180, 0x0180, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 3 123 | 0x0000, 0x0600, 0x0E00, 0x0E00, 0x1E00, 0x1E00, 0x1600, 0x3600, 0x3600, 0x6600, 0x7F80, 0x7F80, 0x0600, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, // 4 124 | 0x0000, 0x7F00, 0x7F00, 0x6000, 0x6000, 0x6000, 0x6E00, 0x7F00, 0x6380, 0x0180, 0x0180, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 5 125 | 0x0000, 0x1E00, 0x3F00, 0x3380, 0x6180, 0x6000, 0x6E00, 0x7F00, 0x7380, 0x6180, 0x6180, 0x6180, 0x3380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 6 126 | 0x0000, 0x7F80, 0x7F80, 0x0180, 0x0300, 0x0300, 0x0600, 0x0600, 0x0C00, 0x0C00, 0x0C00, 0x0800, 0x1800, 0x1800, 0x1800, 0x0000, 0x0000, 0x0000, // 7 127 | 0x0000, 0x1E00, 0x3F00, 0x6380, 0x6180, 0x6180, 0x2100, 0x1E00, 0x3F00, 0x6180, 0x6180, 0x6180, 0x6180, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 8 128 | 0x0000, 0x1E00, 0x3F00, 0x7300, 0x6180, 0x6180, 0x6180, 0x7380, 0x3F80, 0x1D80, 0x0180, 0x6180, 0x7300, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 9 129 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // : 130 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0400, 0x0400, 0x0800, // ; 131 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0380, 0x0E00, 0x3800, 0x6000, 0x3800, 0x0E00, 0x0380, 0x0080, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // < 132 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7F80, 0x7F80, 0x0000, 0x0000, 0x7F80, 0x7F80, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // = 133 | 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x7000, 0x1C00, 0x0700, 0x0180, 0x0700, 0x1C00, 0x7000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // > 134 | 0x0000, 0x1F00, 0x3F80, 0x71C0, 0x60C0, 0x00C0, 0x01C0, 0x0380, 0x0700, 0x0E00, 0x0C00, 0x0C00, 0x0000, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // ? 135 | 0x0000, 0x1E00, 0x3F00, 0x3180, 0x7180, 0x6380, 0x6F80, 0x6D80, 0x6D80, 0x6F80, 0x6780, 0x6000, 0x3200, 0x3E00, 0x1C00, 0x0000, 0x0000, 0x0000, // @ 136 | 0x0000, 0x0E00, 0x0E00, 0x1B00, 0x1B00, 0x1B00, 0x1B00, 0x3180, 0x3180, 0x3F80, 0x3F80, 0x3180, 0x60C0, 0x60C0, 0x60C0, 0x0000, 0x0000, 0x0000, // A 137 | 0x0000, 0x7C00, 0x7E00, 0x6300, 0x6300, 0x6300, 0x6300, 0x7E00, 0x7E00, 0x6300, 0x6180, 0x6180, 0x6380, 0x7F00, 0x7E00, 0x0000, 0x0000, 0x0000, // B 138 | 0x0000, 0x1E00, 0x3F00, 0x3180, 0x6180, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6180, 0x3180, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // C 139 | 0x0000, 0x7C00, 0x7F00, 0x6300, 0x6380, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6300, 0x6300, 0x7E00, 0x7C00, 0x0000, 0x0000, 0x0000, // D 140 | 0x0000, 0x7F80, 0x7F80, 0x6000, 0x6000, 0x6000, 0x6000, 0x7F00, 0x7F00, 0x6000, 0x6000, 0x6000, 0x6000, 0x7F80, 0x7F80, 0x0000, 0x0000, 0x0000, // E 141 | 0x0000, 0x7F80, 0x7F80, 0x6000, 0x6000, 0x6000, 0x6000, 0x7F00, 0x7F00, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, // F 142 | 0x0000, 0x1E00, 0x3F00, 0x3180, 0x6180, 0x6000, 0x6000, 0x6000, 0x6380, 0x6380, 0x6180, 0x6180, 0x3180, 0x3F80, 0x1E00, 0x0000, 0x0000, 0x0000, // G 143 | 0x0000, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x7F80, 0x7F80, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x0000, 0x0000, 0x0000, // H 144 | 0x0000, 0x3F00, 0x3F00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x3F00, 0x3F00, 0x0000, 0x0000, 0x0000, // I 145 | 0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x6180, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // J 146 | 0x0000, 0x60C0, 0x6180, 0x6300, 0x6600, 0x6600, 0x6C00, 0x7800, 0x7C00, 0x6600, 0x6600, 0x6300, 0x6180, 0x6180, 0x60C0, 0x0000, 0x0000, 0x0000, // K 147 | 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x7F80, 0x7F80, 0x0000, 0x0000, 0x0000, // L 148 | 0x0000, 0x71C0, 0x71C0, 0x7BC0, 0x7AC0, 0x6AC0, 0x6AC0, 0x6EC0, 0x64C0, 0x60C0, 0x60C0, 0x60C0, 0x60C0, 0x60C0, 0x60C0, 0x0000, 0x0000, 0x0000, // M 149 | 0x0000, 0x7180, 0x7180, 0x7980, 0x7980, 0x7980, 0x6D80, 0x6D80, 0x6D80, 0x6580, 0x6780, 0x6780, 0x6780, 0x6380, 0x6380, 0x0000, 0x0000, 0x0000, // N 150 | 0x0000, 0x1E00, 0x3F00, 0x3300, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x3300, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // O 151 | 0x0000, 0x7E00, 0x7F00, 0x6380, 0x6180, 0x6180, 0x6180, 0x6380, 0x7F00, 0x7E00, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, // P 152 | 0x0000, 0x1E00, 0x3F00, 0x3300, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6580, 0x6780, 0x3300, 0x3F80, 0x1E40, 0x0000, 0x0000, 0x0000, // Q 153 | 0x0000, 0x7E00, 0x7F00, 0x6380, 0x6180, 0x6180, 0x6380, 0x7F00, 0x7E00, 0x6600, 0x6300, 0x6300, 0x6180, 0x6180, 0x60C0, 0x0000, 0x0000, 0x0000, // R 154 | 0x0000, 0x0E00, 0x1F00, 0x3180, 0x3180, 0x3000, 0x3800, 0x1E00, 0x0700, 0x0380, 0x6180, 0x6180, 0x3180, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // S 155 | 0x0000, 0xFFC0, 0xFFC0, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // T 156 | 0x0000, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // U 157 | 0x0000, 0x60C0, 0x60C0, 0x60C0, 0x3180, 0x3180, 0x3180, 0x1B00, 0x1B00, 0x1B00, 0x1B00, 0x0E00, 0x0E00, 0x0E00, 0x0400, 0x0000, 0x0000, 0x0000, // V 158 | 0x0000, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xCCC0, 0x4C80, 0x4C80, 0x5E80, 0x5280, 0x5280, 0x7380, 0x6180, 0x6180, 0x0000, 0x0000, 0x0000, // W 159 | 0x0000, 0xC0C0, 0x6080, 0x6180, 0x3300, 0x3B00, 0x1E00, 0x0C00, 0x0C00, 0x1E00, 0x1F00, 0x3B00, 0x7180, 0x6180, 0xC0C0, 0x0000, 0x0000, 0x0000, // X 160 | 0x0000, 0xC0C0, 0x6180, 0x6180, 0x3300, 0x3300, 0x1E00, 0x1E00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // Y 161 | 0x0000, 0x3F80, 0x3F80, 0x0180, 0x0300, 0x0300, 0x0600, 0x0C00, 0x0C00, 0x1800, 0x1800, 0x3000, 0x6000, 0x7F80, 0x7F80, 0x0000, 0x0000, 0x0000, // Z 162 | 0x0F00, 0x0F00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0F00, 0x0F00, // [ 163 | 0x0000, 0x1800, 0x1800, 0x1800, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0600, 0x0600, 0x0600, 0x0600, 0x0300, 0x0300, 0x0300, 0x0000, 0x0000, 0x0000, /* \ */ 164 | 0x1E00, 0x1E00, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x1E00, 0x1E00, // ] 165 | 0x0000, 0x0C00, 0x0C00, 0x1E00, 0x1200, 0x3300, 0x3300, 0x6180, 0x6180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ^ 166 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFE0, 0x0000, // _ 167 | 0x0000, 0x3800, 0x1800, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ` 168 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1F00, 0x3F80, 0x6180, 0x0180, 0x1F80, 0x3F80, 0x6180, 0x6380, 0x7F80, 0x38C0, 0x0000, 0x0000, 0x0000, // a 169 | 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6E00, 0x7F00, 0x7380, 0x6180, 0x6180, 0x6180, 0x6180, 0x7380, 0x7F00, 0x6E00, 0x0000, 0x0000, 0x0000, // b 170 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1E00, 0x3F00, 0x7380, 0x6180, 0x6000, 0x6000, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // c 171 | 0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x1D80, 0x3F80, 0x7380, 0x6180, 0x6180, 0x6180, 0x6180, 0x7380, 0x3F80, 0x1D80, 0x0000, 0x0000, 0x0000, // d 172 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1E00, 0x3F00, 0x7300, 0x6180, 0x7F80, 0x7F80, 0x6000, 0x7180, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // e 173 | 0x0000, 0x07C0, 0x0FC0, 0x0C00, 0x0C00, 0x7F80, 0x7F80, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // f 174 | 0x0000, 0x0000, 0x0000, 0x0000, 0x1D80, 0x3F80, 0x7380, 0x6180, 0x6180, 0x6180, 0x6180, 0x7380, 0x3F80, 0x1D80, 0x0180, 0x6380, 0x7F00, 0x3E00, // g 175 | 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6F00, 0x7F80, 0x7180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x0000, 0x0000, 0x0000, // h 176 | 0x0000, 0x0600, 0x0600, 0x0000, 0x0000, 0x3E00, 0x3E00, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, // i 177 | 0x0600, 0x0600, 0x0000, 0x0000, 0x3E00, 0x3E00, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x4600, 0x7E00, 0x3C00, // j 178 | 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6180, 0x6300, 0x6600, 0x6C00, 0x7C00, 0x7600, 0x6300, 0x6300, 0x6180, 0x60C0, 0x0000, 0x0000, 0x0000, // k 179 | 0x0000, 0x3E00, 0x3E00, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, // l 180 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xDD80, 0xFFC0, 0xCEC0, 0xCCC0, 0xCCC0, 0xCCC0, 0xCCC0, 0xCCC0, 0xCCC0, 0xCCC0, 0x0000, 0x0000, 0x0000, // m 181 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6F00, 0x7F80, 0x7180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x0000, 0x0000, 0x0000, // n 182 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1E00, 0x3F00, 0x7380, 0x6180, 0x6180, 0x6180, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // o 183 | 0x0000, 0x0000, 0x0000, 0x0000, 0x6E00, 0x7F00, 0x7380, 0x6180, 0x6180, 0x6180, 0x6180, 0x7380, 0x7F00, 0x6E00, 0x6000, 0x6000, 0x6000, 0x6000, // p 184 | 0x0000, 0x0000, 0x0000, 0x0000, 0x1D80, 0x3F80, 0x7380, 0x6180, 0x6180, 0x6180, 0x6180, 0x7380, 0x3F80, 0x1D80, 0x0180, 0x0180, 0x0180, 0x0180, // q 185 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6700, 0x3F80, 0x3900, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x0000, // r 186 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1E00, 0x3F80, 0x6180, 0x6000, 0x7F00, 0x3F80, 0x0180, 0x6180, 0x7F00, 0x1E00, 0x0000, 0x0000, 0x0000, // s 187 | 0x0000, 0x0000, 0x0800, 0x1800, 0x1800, 0x7F00, 0x7F00, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1F80, 0x0F80, 0x0000, 0x0000, 0x0000, // t 188 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6380, 0x7F80, 0x3D80, 0x0000, 0x0000, 0x0000, // u 189 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x60C0, 0x3180, 0x3180, 0x3180, 0x1B00, 0x1B00, 0x1B00, 0x0E00, 0x0E00, 0x0600, 0x0000, 0x0000, 0x0000, // v 190 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xDD80, 0xDD80, 0xDD80, 0x5500, 0x5500, 0x5500, 0x7700, 0x7700, 0x2200, 0x2200, 0x0000, 0x0000, 0x0000, // w 191 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6180, 0x3300, 0x3300, 0x1E00, 0x0C00, 0x0C00, 0x1E00, 0x3300, 0x3300, 0x6180, 0x0000, 0x0000, 0x0000, // x 192 | 0x0000, 0x0000, 0x0000, 0x0000, 0x6180, 0x6180, 0x3180, 0x3300, 0x3300, 0x1B00, 0x1B00, 0x1B00, 0x0E00, 0x0E00, 0x0E00, 0x1C00, 0x7C00, 0x7000, // y 193 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7FC0, 0x7FC0, 0x0180, 0x0300, 0x0600, 0x0C00, 0x1800, 0x3000, 0x7FC0, 0x7FC0, 0x0000, 0x0000, 0x0000, // z 194 | 0x0380, 0x0780, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0E00, 0x1C00, 0x1C00, 0x0E00, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0780, 0x0380, // { 195 | 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, // | 196 | 0x3800, 0x3C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0E00, 0x0700, 0x0700, 0x0E00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x3C00, 0x3800, // } 197 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3880, 0x7F80, 0x4700, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ~ 198 | }; 199 | 200 | static const uint16_t Font16x26 [] = { 201 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [ ] 202 | 0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03C0,0x03C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0000,0x0000,0x0000,0x03E0,0x03E0,0x03E0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [!] 203 | 0x1E3C,0x1E3C,0x1E3C,0x1E3C,0x1E3C,0x1E3C,0x1E3C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = ["] 204 | 0x01CE,0x03CE,0x03DE,0x039E,0x039C,0x079C,0x3FFF,0x7FFF,0x0738,0x0F38,0x0F78,0x0F78,0x0E78,0xFFFF,0xFFFF,0x1EF0,0x1CF0,0x1CE0,0x3CE0,0x3DE0,0x39E0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [#] 205 | 0x03FC,0x0FFE,0x1FEE,0x1EE0,0x1EE0,0x1EE0,0x1EE0,0x1FE0,0x0FE0,0x07E0,0x03F0,0x01FC,0x01FE,0x01FE,0x01FE,0x01FE,0x01FE,0x01FE,0x3DFE,0x3FFC,0x0FF0,0x01E0,0x01E0,0x0000,0x0000,0x0000, // Ascii = [$] 206 | 0x3E03,0xF707,0xE78F,0xE78E,0xE39E,0xE3BC,0xE7B8,0xE7F8,0xF7F0,0x3FE0,0x01C0,0x03FF,0x07FF,0x07F3,0x0FF3,0x1EF3,0x3CF3,0x38F3,0x78F3,0xF07F,0xE03F,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [%] 207 | 0x07E0,0x0FF8,0x0F78,0x1F78,0x1F78,0x1F78,0x0F78,0x0FF0,0x0FE0,0x1F80,0x7FC3,0xFBC3,0xF3E7,0xF1F7,0xF0F7,0xF0FF,0xF07F,0xF83E,0x7C7F,0x3FFF,0x1FEF,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [&] 208 | 0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03C0,0x01C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = ['] 209 | 0x003F,0x007C,0x01F0,0x01E0,0x03C0,0x07C0,0x0780,0x0780,0x0F80,0x0F00,0x0F00,0x0F00,0x0F00,0x0F00,0x0F00,0x0F80,0x0780,0x0780,0x07C0,0x03C0,0x01E0,0x01F0,0x007C,0x003F,0x000F,0x0000, // Ascii = [(] 210 | 0x7E00,0x1F00,0x07C0,0x03C0,0x01E0,0x01F0,0x00F0,0x00F0,0x00F8,0x0078,0x0078,0x0078,0x0078,0x0078,0x0078,0x00F8,0x00F0,0x00F0,0x01F0,0x01E0,0x03C0,0x07C0,0x1F00,0x7E00,0x7800,0x0000, // Ascii = [)] 211 | 0x03E0,0x03C0,0x01C0,0x39CE,0x3FFF,0x3F7F,0x0320,0x0370,0x07F8,0x0F78,0x1F3C,0x0638,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [*] 212 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0xFFFF,0xFFFF,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [+] 213 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x03E0,0x03E0,0x03E0,0x01E0,0x01E0,0x01E0,0x01C0,0x0380, // Ascii = [,] 214 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3FFE,0x3FFE,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [-] 215 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x03E0,0x03E0,0x03E0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [.] 216 | 0x000F,0x000F,0x001E,0x001E,0x003C,0x003C,0x0078,0x0078,0x00F0,0x00F0,0x01E0,0x01E0,0x03C0,0x03C0,0x0780,0x0780,0x0F00,0x0F00,0x1E00,0x1E00,0x3C00,0x3C00,0x7800,0x7800,0xF000,0x0000, // Ascii = [/] 217 | 0x07F0,0x0FF8,0x1F7C,0x3E3E,0x3C1E,0x7C1F,0x7C1F,0x780F,0x780F,0x780F,0x780F,0x780F,0x780F,0x780F,0x7C1F,0x7C1F,0x3C1E,0x3E3E,0x1F7C,0x0FF8,0x07F0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [0] 218 | 0x00F0,0x07F0,0x3FF0,0x3FF0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x3FFF,0x3FFF,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [1] 219 | 0x0FE0,0x3FF8,0x3C7C,0x003C,0x003E,0x003E,0x003E,0x003C,0x003C,0x007C,0x00F8,0x01F0,0x03E0,0x07C0,0x0780,0x0F00,0x1E00,0x3E00,0x3C00,0x3FFE,0x3FFE,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [2] 220 | 0x0FF0,0x1FF8,0x1C7C,0x003E,0x003E,0x003E,0x003C,0x003C,0x00F8,0x0FF0,0x0FF8,0x007C,0x003E,0x001E,0x001E,0x001E,0x001E,0x003E,0x1C7C,0x1FF8,0x1FE0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [3] 221 | 0x0078,0x00F8,0x00F8,0x01F8,0x03F8,0x07F8,0x07F8,0x0F78,0x1E78,0x1E78,0x3C78,0x7878,0x7878,0xFFFF,0xFFFF,0x0078,0x0078,0x0078,0x0078,0x0078,0x0078,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [4] 222 | 0x1FFC,0x1FFC,0x1FFC,0x1E00,0x1E00,0x1E00,0x1E00,0x1E00,0x1FE0,0x1FF8,0x00FC,0x007C,0x003E,0x003E,0x001E,0x003E,0x003E,0x003C,0x1C7C,0x1FF8,0x1FE0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [5] 223 | 0x01FC,0x07FE,0x0F8E,0x1F00,0x1E00,0x3E00,0x3C00,0x3C00,0x3DF8,0x3FFC,0x7F3E,0x7E1F,0x3C0F,0x3C0F,0x3C0F,0x3C0F,0x3E0F,0x1E1F,0x1F3E,0x0FFC,0x03F0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [6] 224 | 0x3FFF,0x3FFF,0x3FFF,0x000F,0x001E,0x001E,0x003C,0x0038,0x0078,0x00F0,0x00F0,0x01E0,0x01E0,0x03C0,0x03C0,0x0780,0x0F80,0x0F80,0x0F00,0x1F00,0x1F00,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [7] 225 | 0x07F8,0x0FFC,0x1F3E,0x1E1E,0x3E1E,0x3E1E,0x1E1E,0x1F3C,0x0FF8,0x07F0,0x0FF8,0x1EFC,0x3E3E,0x3C1F,0x7C1F,0x7C0F,0x7C0F,0x3C1F,0x3F3E,0x1FFC,0x07F0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [8] 226 | 0x07F0,0x0FF8,0x1E7C,0x3C3E,0x3C1E,0x7C1F,0x7C1F,0x7C1F,0x7C1F,0x3C1F,0x3E3F,0x1FFF,0x07EF,0x001F,0x001E,0x001E,0x003E,0x003C,0x38F8,0x3FF0,0x1FE0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [9] 227 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x03E0,0x03E0,0x03E0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x03E0,0x03E0,0x03E0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [:] 228 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x03E0,0x03E0,0x03E0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x03E0,0x03E0,0x03E0,0x01E0,0x01E0,0x01E0,0x03C0,0x0380, // Ascii = [;] 229 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0003,0x000F,0x003F,0x00FC,0x03F0,0x0FC0,0x3F00,0xFE00,0x3F00,0x0FC0,0x03F0,0x00FC,0x003F,0x000F,0x0003,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [<] 230 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xFFFF,0xFFFF,0x0000,0x0000,0x0000,0xFFFF,0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [=] 231 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xE000,0xF800,0x7E00,0x1F80,0x07E0,0x01F8,0x007E,0x001F,0x007E,0x01F8,0x07E0,0x1F80,0x7E00,0xF800,0xE000,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [>] 232 | 0x1FF0,0x3FFC,0x383E,0x381F,0x381F,0x001E,0x001E,0x003C,0x0078,0x00F0,0x01E0,0x03C0,0x03C0,0x07C0,0x07C0,0x0000,0x0000,0x0000,0x07C0,0x07C0,0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [?] 233 | 0x03F8,0x0FFE,0x1F1E,0x3E0F,0x3C7F,0x78FF,0x79EF,0x73C7,0xF3C7,0xF38F,0xF38F,0xF38F,0xF39F,0xF39F,0x73FF,0x7BFF,0x79F7,0x3C00,0x1F1C,0x0FFC,0x03F8,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [@] 234 | 0x0000,0x0000,0x0000,0x03E0,0x03E0,0x07F0,0x07F0,0x07F0,0x0F78,0x0F78,0x0E7C,0x1E3C,0x1E3C,0x3C3E,0x3FFE,0x3FFF,0x781F,0x780F,0xF00F,0xF007,0xF007,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [A] 235 | 0x0000,0x0000,0x0000,0x3FF8,0x3FFC,0x3C3E,0x3C1E,0x3C1E,0x3C1E,0x3C3E,0x3C7C,0x3FF0,0x3FF8,0x3C7E,0x3C1F,0x3C1F,0x3C0F,0x3C0F,0x3C1F,0x3FFE,0x3FF8,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [B] 236 | 0x0000,0x0000,0x0000,0x01FF,0x07FF,0x1F87,0x3E00,0x3C00,0x7C00,0x7800,0x7800,0x7800,0x7800,0x7800,0x7C00,0x7C00,0x3E00,0x3F00,0x1F83,0x07FF,0x01FF,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [C] 237 | 0x0000,0x0000,0x0000,0x7FF0,0x7FFC,0x787E,0x781F,0x781F,0x780F,0x780F,0x780F,0x780F,0x780F,0x780F,0x780F,0x780F,0x781F,0x781E,0x787E,0x7FF8,0x7FE0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [D] 238 | 0x0000,0x0000,0x0000,0x3FFF,0x3FFF,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3FFE,0x3FFE,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3FFF,0x3FFF,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [E] 239 | 0x0000,0x0000,0x0000,0x1FFF,0x1FFF,0x1E00,0x1E00,0x1E00,0x1E00,0x1E00,0x1E00,0x1FFF,0x1FFF,0x1E00,0x1E00,0x1E00,0x1E00,0x1E00,0x1E00,0x1E00,0x1E00,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [F] 240 | 0x0000,0x0000,0x0000,0x03FE,0x0FFF,0x1F87,0x3E00,0x7C00,0x7C00,0x7800,0xF800,0xF800,0xF87F,0xF87F,0x780F,0x7C0F,0x7C0F,0x3E0F,0x1F8F,0x0FFF,0x03FE,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [G] 241 | 0x0000,0x0000,0x0000,0x7C1F,0x7C1F,0x7C1F,0x7C1F,0x7C1F,0x7C1F,0x7C1F,0x7C1F,0x7FFF,0x7FFF,0x7C1F,0x7C1F,0x7C1F,0x7C1F,0x7C1F,0x7C1F,0x7C1F,0x7C1F,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [H] 242 | 0x0000,0x0000,0x0000,0x3FFF,0x3FFF,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x3FFF,0x3FFF,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [I] 243 | 0x0000,0x0000,0x0000,0x1FFC,0x1FFC,0x007C,0x007C,0x007C,0x007C,0x007C,0x007C,0x007C,0x007C,0x007C,0x007C,0x007C,0x0078,0x0078,0x38F8,0x3FF0,0x3FC0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [J] 244 | 0x0000,0x0000,0x0000,0x3C1F,0x3C1E,0x3C3C,0x3C78,0x3CF0,0x3DE0,0x3FE0,0x3FC0,0x3F80,0x3FC0,0x3FE0,0x3DF0,0x3CF0,0x3C78,0x3C7C,0x3C3E,0x3C1F,0x3C0F,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [K] 245 | 0x0000,0x0000,0x0000,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3FFF,0x3FFF,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [L] 246 | 0x0000,0x0000,0x0000,0xF81F,0xFC1F,0xFC1F,0xFE3F,0xFE3F,0xFE3F,0xFF7F,0xFF77,0xFF77,0xF7F7,0xF7E7,0xF3E7,0xF3E7,0xF3C7,0xF007,0xF007,0xF007,0xF007,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [M] 247 | 0x0000,0x0000,0x0000,0x7C0F,0x7C0F,0x7E0F,0x7F0F,0x7F0F,0x7F8F,0x7F8F,0x7FCF,0x7BEF,0x79EF,0x79FF,0x78FF,0x78FF,0x787F,0x783F,0x783F,0x781F,0x781F,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [N] 248 | 0x0000,0x0000,0x0000,0x07F0,0x1FFC,0x3E3E,0x7C1F,0x780F,0x780F,0xF80F,0xF80F,0xF80F,0xF80F,0xF80F,0xF80F,0x780F,0x780F,0x7C1F,0x3E3E,0x1FFC,0x07F0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [O] 249 | 0x0000,0x0000,0x0000,0x3FFC,0x3FFF,0x3E1F,0x3E0F,0x3E0F,0x3E0F,0x3E0F,0x3E1F,0x3E3F,0x3FFC,0x3FF0,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x3E00,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [P] 250 | 0x0000,0x0000,0x0000,0x07F0,0x1FFC,0x3E3E,0x7C1F,0x780F,0x780F,0xF80F,0xF80F,0xF80F,0xF80F,0xF80F,0xF80F,0x780F,0x780F,0x7C1F,0x3E3E,0x1FFC,0x07F8,0x007C,0x003F,0x000F,0x0003,0x0000, // Ascii = [Q] 251 | 0x0000,0x0000,0x0000,0x3FF0,0x3FFC,0x3C7E,0x3C3E,0x3C1E,0x3C1E,0x3C3E,0x3C3C,0x3CFC,0x3FF0,0x3FE0,0x3DF0,0x3CF8,0x3C7C,0x3C3E,0x3C1E,0x3C1F,0x3C0F,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [R] 252 | 0x0000,0x0000,0x0000,0x07FC,0x1FFE,0x3E0E,0x3C00,0x3C00,0x3C00,0x3E00,0x1FC0,0x0FF8,0x03FE,0x007F,0x001F,0x000F,0x000F,0x201F,0x3C3E,0x3FFC,0x1FF0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [S] 253 | 0x0000,0x0000,0x0000,0xFFFF,0xFFFF,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [T] 254 | 0x0000,0x0000,0x0000,0x7C0F,0x7C0F,0x7C0F,0x7C0F,0x7C0F,0x7C0F,0x7C0F,0x7C0F,0x7C0F,0x7C0F,0x7C0F,0x7C0F,0x7C0F,0x3C1E,0x3C1E,0x3E3E,0x1FFC,0x07F0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [U] 255 | 0x0000,0x0000,0x0000,0xF007,0xF007,0xF807,0x780F,0x7C0F,0x3C1E,0x3C1E,0x3E1E,0x1E3C,0x1F3C,0x1F78,0x0F78,0x0FF8,0x07F0,0x07F0,0x07F0,0x03E0,0x03E0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [V] 256 | 0x0000,0x0000,0x0000,0xE003,0xF003,0xF003,0xF007,0xF3E7,0xF3E7,0xF3E7,0x73E7,0x7BF7,0x7FF7,0x7FFF,0x7F7F,0x7F7F,0x7F7E,0x3F7E,0x3E3E,0x3E3E,0x3E3E,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [W] 257 | 0x0000,0x0000,0x0000,0xF807,0x7C0F,0x3E1E,0x3E3E,0x1F3C,0x0FF8,0x07F0,0x07E0,0x03E0,0x03E0,0x07F0,0x0FF8,0x0F7C,0x1E7C,0x3C3E,0x781F,0x780F,0xF00F,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [X] 258 | 0x0000,0x0000,0x0000,0xF807,0x7807,0x7C0F,0x3C1E,0x3E1E,0x1F3C,0x0F78,0x0FF8,0x07F0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x03E0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [Y] 259 | 0x0000,0x0000,0x0000,0x7FFF,0x7FFF,0x000F,0x001F,0x003E,0x007C,0x00F8,0x00F0,0x01E0,0x03E0,0x07C0,0x0F80,0x0F00,0x1E00,0x3E00,0x7C00,0x7FFF,0x7FFF,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [Z] 260 | 0x07FF,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x07FF,0x07FF,0x0000, // Ascii = [[] 261 | 0x7800,0x7800,0x3C00,0x3C00,0x1E00,0x1E00,0x0F00,0x0F00,0x0780,0x0780,0x03C0,0x03C0,0x01E0,0x01E0,0x00F0,0x00F0,0x0078,0x0078,0x003C,0x003C,0x001E,0x001E,0x000F,0x000F,0x0007,0x0000, // Ascii = [\] 262 | 0x7FF0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x00F0,0x7FF0,0x7FF0,0x0000, // Ascii = []] 263 | 0x00C0,0x01C0,0x01C0,0x03E0,0x03E0,0x07F0,0x07F0,0x0778,0x0F78,0x0F38,0x1E3C,0x1E3C,0x3C1E,0x3C1E,0x380F,0x780F,0x7807,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [^] 264 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xFFFF,0xFFFF,0x0000,0x0000,0x0000, // Ascii = [_] 265 | 0x00F0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [`] 266 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0FF8,0x3FFC,0x3C7C,0x003E,0x003E,0x003E,0x07FE,0x1FFE,0x3E3E,0x7C3E,0x783E,0x7C3E,0x7C7E,0x3FFF,0x1FCF,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [a] 267 | 0x3C00,0x3C00,0x3C00,0x3C00,0x3C00,0x3C00,0x3DF8,0x3FFE,0x3F3E,0x3E1F,0x3C0F,0x3C0F,0x3C0F,0x3C0F,0x3C0F,0x3C0F,0x3C1F,0x3C1E,0x3F3E,0x3FFC,0x3BF0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [b] 268 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03FE,0x0FFF,0x1F87,0x3E00,0x3E00,0x3C00,0x7C00,0x7C00,0x7C00,0x3C00,0x3E00,0x3E00,0x1F87,0x0FFF,0x03FE,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [c] 269 | 0x001F,0x001F,0x001F,0x001F,0x001F,0x001F,0x07FF,0x1FFF,0x3E3F,0x3C1F,0x7C1F,0x7C1F,0x7C1F,0x781F,0x781F,0x7C1F,0x7C1F,0x3C3F,0x3E7F,0x1FFF,0x0FDF,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [d] 270 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03F8,0x0FFC,0x1F3E,0x3E1E,0x3C1F,0x7C1F,0x7FFF,0x7FFF,0x7C00,0x7C00,0x3C00,0x3E00,0x1F07,0x0FFF,0x03FE,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [e] 271 | 0x01FF,0x03E1,0x03C0,0x07C0,0x07C0,0x07C0,0x7FFF,0x7FFF,0x07C0,0x07C0,0x07C0,0x07C0,0x07C0,0x07C0,0x07C0,0x07C0,0x07C0,0x07C0,0x07C0,0x07C0,0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [f] 272 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x07EF,0x1FFF,0x3E7F,0x3C1F,0x7C1F,0x7C1F,0x781F,0x781F,0x781F,0x7C1F,0x7C1F,0x3C3F,0x3E7F,0x1FFF,0x0FDF,0x001E,0x001E,0x001E,0x387C,0x3FF8, // Ascii = [g] 273 | 0x3C00,0x3C00,0x3C00,0x3C00,0x3C00,0x3C00,0x3DFC,0x3FFE,0x3F9E,0x3F1F,0x3E1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [h] 274 | 0x01F0,0x01F0,0x0000,0x0000,0x0000,0x0000,0x7FE0,0x7FE0,0x01E0,0x01E0,0x01E0,0x01E0,0x01E0,0x01E0,0x01E0,0x01E0,0x01E0,0x01E0,0x01E0,0x01E0,0x01E0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [i] 275 | 0x00F8,0x00F8,0x0000,0x0000,0x0000,0x0000,0x3FF8,0x3FF8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F8,0x00F0,0x71F0,0x7FE0, // Ascii = [j] 276 | 0x3C00,0x3C00,0x3C00,0x3C00,0x3C00,0x3C00,0x3C1F,0x3C3E,0x3C7C,0x3CF8,0x3DF0,0x3DE0,0x3FC0,0x3FC0,0x3FE0,0x3DF0,0x3CF8,0x3C7C,0x3C3E,0x3C1F,0x3C1F,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [k] 277 | 0x7FF0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [l] 278 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xF79E,0xFFFF,0xFFFF,0xFFFF,0xFBE7,0xF9E7,0xF1C7,0xF1C7,0xF1C7,0xF1C7,0xF1C7,0xF1C7,0xF1C7,0xF1C7,0xF1C7,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [m] 279 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3DFC,0x3FFE,0x3F9E,0x3F1F,0x3E1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x3C1F,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [n] 280 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x07F0,0x1FFC,0x3E3E,0x3C1F,0x7C1F,0x780F,0x780F,0x780F,0x780F,0x780F,0x7C1F,0x3C1F,0x3E3E,0x1FFC,0x07F0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [o] 281 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3DF8,0x3FFE,0x3F3E,0x3E1F,0x3C0F,0x3C0F,0x3C0F,0x3C0F,0x3C0F,0x3C0F,0x3C1F,0x3E1E,0x3F3E,0x3FFC,0x3FF8,0x3C00,0x3C00,0x3C00,0x3C00,0x3C00, // Ascii = [p] 282 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x07EE,0x1FFE,0x3E7E,0x3C1E,0x7C1E,0x781E,0x781E,0x781E,0x781E,0x781E,0x7C1E,0x7C3E,0x3E7E,0x1FFE,0x0FDE,0x001E,0x001E,0x001E,0x001E,0x001E, // Ascii = [q] 283 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1F7F,0x1FFF,0x1FE7,0x1FC7,0x1F87,0x1F00,0x1F00,0x1F00,0x1F00,0x1F00,0x1F00,0x1F00,0x1F00,0x1F00,0x1F00,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [r] 284 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x07FC,0x1FFE,0x1E0E,0x3E00,0x3E00,0x3F00,0x1FE0,0x07FC,0x00FE,0x003E,0x001E,0x001E,0x3C3E,0x3FFC,0x1FF0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [s] 285 | 0x0000,0x0000,0x0000,0x0780,0x0780,0x0780,0x7FFF,0x7FFF,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x0780,0x07C0,0x03FF,0x01FF,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [t] 286 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3C1E,0x3C1E,0x3C1E,0x3C1E,0x3C1E,0x3C1E,0x3C1E,0x3C1E,0x3C1E,0x3C1E,0x3C3E,0x3C7E,0x3EFE,0x1FFE,0x0FDE,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [u] 287 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xF007,0x780F,0x780F,0x3C1E,0x3C1E,0x3E1E,0x1E3C,0x1E3C,0x0F78,0x0F78,0x0FF0,0x07F0,0x07F0,0x03E0,0x03E0,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [v] 288 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xF003,0xF1E3,0xF3E3,0xF3E7,0xF3F7,0xF3F7,0x7FF7,0x7F77,0x7F7F,0x7F7F,0x7F7F,0x3E3E,0x3E3E,0x3E3E,0x3E3E,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [w] 289 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7C0F,0x3E1E,0x3E3C,0x1F3C,0x0FF8,0x07F0,0x07F0,0x03E0,0x07F0,0x07F8,0x0FF8,0x1E7C,0x3E3E,0x3C1F,0x781F,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [x] 290 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xF807,0x780F,0x7C0F,0x3C1E,0x3C1E,0x1E3C,0x1E3C,0x1F3C,0x0F78,0x0FF8,0x07F0,0x07F0,0x03E0,0x03E0,0x03C0,0x03C0,0x03C0,0x0780,0x0F80,0x7F00, // Ascii = [y] 291 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3FFF,0x3FFF,0x001F,0x003E,0x007C,0x00F8,0x01F0,0x03E0,0x07C0,0x0F80,0x1F00,0x1E00,0x3C00,0x7FFF,0x7FFF,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [z] 292 | 0x01FE,0x03E0,0x03C0,0x03C0,0x03C0,0x03C0,0x01E0,0x01E0,0x01E0,0x01C0,0x03C0,0x3F80,0x3F80,0x03C0,0x01C0,0x01E0,0x01E0,0x01E0,0x03C0,0x03C0,0x03C0,0x03C0,0x03E0,0x01FE,0x007E,0x0000, // Ascii = [{] 293 | 0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0000, // Ascii = [|] 294 | 0x3FC0,0x03E0,0x01E0,0x01E0,0x01E0,0x01E0,0x01C0,0x03C0,0x03C0,0x01C0,0x01E0,0x00FE,0x00FE,0x01E0,0x01C0,0x03C0,0x03C0,0x01C0,0x01E0,0x01E0,0x01E0,0x01E0,0x03E0,0x3FC0,0x3F00,0x0000, // Ascii = [}] 295 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3F07,0x7FC7,0x73E7,0xF1FF,0xF07E,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Ascii = [~] 296 | }; 297 | 298 | 299 | FontDef Font_7x10 = {7,10,Font7x10}; 300 | FontDef Font_11x18 = {11,18,Font11x18}; 301 | FontDef Font_16x26 = {16,26,Font16x26}; 302 | -------------------------------------------------------------------------------- /st7735/fonts.h: -------------------------------------------------------------------------------- 1 | /* vim: set ai et ts=4 sw=4: */ 2 | #ifndef __FONTS_H__ 3 | #define __FONTS_H__ 4 | 5 | #include 6 | 7 | typedef struct { 8 | const uint8_t width; 9 | uint8_t height; 10 | const uint16_t *data; 11 | } FontDef; 12 | 13 | 14 | extern FontDef Font_7x10; 15 | extern FontDef Font_11x18; 16 | extern FontDef Font_16x26; 17 | 18 | #endif // __FONTS_H__ 19 | -------------------------------------------------------------------------------- /st7735/st7735.c: -------------------------------------------------------------------------------- 1 | /* vim: set ai et ts=4 sw=4: */ 2 | #include "stm32f4xx_hal.h" 3 | #include "st7735.h" 4 | 5 | #define DELAY 0x80 6 | 7 | // based on Adafruit ST7735 library for Arduino 8 | static const uint8_t 9 | init_cmds1[] = { // Init for 7735R, part 1 (red or green tab) 10 | 15, // 15 commands in list: 11 | ST7735_SWRESET, DELAY, // 1: Software reset, 0 args, w/delay 12 | 150, // 150 ms delay 13 | ST7735_SLPOUT , DELAY, // 2: Out of sleep mode, 0 args, w/delay 14 | 255, // 500 ms delay 15 | ST7735_FRMCTR1, 3 , // 3: Frame rate ctrl - normal mode, 3 args: 16 | 0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D) 17 | ST7735_FRMCTR2, 3 , // 4: Frame rate control - idle mode, 3 args: 18 | 0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D) 19 | ST7735_FRMCTR3, 6 , // 5: Frame rate ctrl - partial mode, 6 args: 20 | 0x01, 0x2C, 0x2D, // Dot inversion mode 21 | 0x01, 0x2C, 0x2D, // Line inversion mode 22 | ST7735_INVCTR , 1 , // 6: Display inversion ctrl, 1 arg, no delay: 23 | 0x07, // No inversion 24 | ST7735_PWCTR1 , 3 , // 7: Power control, 3 args, no delay: 25 | 0xA2, 26 | 0x02, // -4.6V 27 | 0x84, // AUTO mode 28 | ST7735_PWCTR2 , 1 , // 8: Power control, 1 arg, no delay: 29 | 0xC5, // VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD 30 | ST7735_PWCTR3 , 2 , // 9: Power control, 2 args, no delay: 31 | 0x0A, // Opamp current small 32 | 0x00, // Boost frequency 33 | ST7735_PWCTR4 , 2 , // 10: Power control, 2 args, no delay: 34 | 0x8A, // BCLK/2, Opamp current small & Medium low 35 | 0x2A, 36 | ST7735_PWCTR5 , 2 , // 11: Power control, 2 args, no delay: 37 | 0x8A, 0xEE, 38 | ST7735_VMCTR1 , 1 , // 12: Power control, 1 arg, no delay: 39 | 0x0E, 40 | ST7735_INVOFF , 0 , // 13: Don't invert display, no args, no delay 41 | ST7735_MADCTL , 1 , // 14: Memory access control (directions), 1 arg: 42 | ST7735_ROTATION, // row addr/col addr, bottom to top refresh 43 | ST7735_COLMOD , 1 , // 15: set color mode, 1 arg, no delay: 44 | 0x05 }, // 16-bit color 45 | 46 | #if (defined(ST7735_IS_128X128) || defined(ST7735_IS_160X128)) 47 | init_cmds2[] = { // Init for 7735R, part 2 (1.44" display) 48 | 2, // 2 commands in list: 49 | ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay: 50 | 0x00, 0x00, // XSTART = 0 51 | 0x00, 0x7F, // XEND = 127 52 | ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay: 53 | 0x00, 0x00, // XSTART = 0 54 | 0x00, 0x7F }, // XEND = 127 55 | #endif // ST7735_IS_128X128 56 | 57 | #ifdef ST7735_IS_160X80 58 | init_cmds2[] = { // Init for 7735S, part 2 (160x80 display) 59 | 3, // 3 commands in list: 60 | ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay: 61 | 0x00, 0x00, // XSTART = 0 62 | 0x00, 0x4F, // XEND = 79 63 | ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay: 64 | 0x00, 0x00, // XSTART = 0 65 | 0x00, 0x9F , // XEND = 159 66 | ST7735_INVON, 0 }, // 3: Invert colors 67 | #endif 68 | 69 | init_cmds3[] = { // Init for 7735R, part 3 (red or green tab) 70 | 4, // 4 commands in list: 71 | ST7735_GMCTRP1, 16 , // 1: Magical unicorn dust, 16 args, no delay: 72 | 0x02, 0x1c, 0x07, 0x12, 73 | 0x37, 0x32, 0x29, 0x2d, 74 | 0x29, 0x25, 0x2B, 0x39, 75 | 0x00, 0x01, 0x03, 0x10, 76 | ST7735_GMCTRN1, 16 , // 2: Sparkles and rainbows, 16 args, no delay: 77 | 0x03, 0x1d, 0x07, 0x06, 78 | 0x2E, 0x2C, 0x29, 0x2D, 79 | 0x2E, 0x2E, 0x37, 0x3F, 80 | 0x00, 0x00, 0x02, 0x10, 81 | ST7735_NORON , DELAY, // 3: Normal display on, no args, w/delay 82 | 10, // 10 ms delay 83 | ST7735_DISPON , DELAY, // 4: Main screen turn on, no args w/delay 84 | 100 }; // 100 ms delay 85 | 86 | static void ST7735_Select() { 87 | HAL_GPIO_WritePin(ST7735_CS_GPIO_Port, ST7735_CS_Pin, GPIO_PIN_RESET); 88 | } 89 | 90 | void ST7735_Unselect() { 91 | HAL_GPIO_WritePin(ST7735_CS_GPIO_Port, ST7735_CS_Pin, GPIO_PIN_SET); 92 | } 93 | 94 | static void ST7735_Reset() { 95 | HAL_GPIO_WritePin(ST7735_RES_GPIO_Port, ST7735_RES_Pin, GPIO_PIN_RESET); 96 | HAL_Delay(5); 97 | HAL_GPIO_WritePin(ST7735_RES_GPIO_Port, ST7735_RES_Pin, GPIO_PIN_SET); 98 | } 99 | 100 | static void ST7735_WriteCommand(uint8_t cmd) { 101 | HAL_GPIO_WritePin(ST7735_DC_GPIO_Port, ST7735_DC_Pin, GPIO_PIN_RESET); 102 | HAL_SPI_Transmit(&ST7735_SPI_PORT, &cmd, sizeof(cmd), HAL_MAX_DELAY); 103 | } 104 | 105 | static void ST7735_WriteData(uint8_t* buff, size_t buff_size) { 106 | HAL_GPIO_WritePin(ST7735_DC_GPIO_Port, ST7735_DC_Pin, GPIO_PIN_SET); 107 | HAL_SPI_Transmit(&ST7735_SPI_PORT, buff, buff_size, HAL_MAX_DELAY); 108 | } 109 | 110 | static void ST7735_ExecuteCommandList(const uint8_t *addr) { 111 | uint8_t numCommands, numArgs; 112 | uint16_t ms; 113 | 114 | numCommands = *addr++; 115 | while(numCommands--) { 116 | uint8_t cmd = *addr++; 117 | ST7735_WriteCommand(cmd); 118 | 119 | numArgs = *addr++; 120 | // If high bit set, delay follows args 121 | ms = numArgs & DELAY; 122 | numArgs &= ~DELAY; 123 | if(numArgs) { 124 | ST7735_WriteData((uint8_t*)addr, numArgs); 125 | addr += numArgs; 126 | } 127 | 128 | if(ms) { 129 | ms = *addr++; 130 | if(ms == 255) ms = 500; 131 | HAL_Delay(ms); 132 | } 133 | } 134 | } 135 | 136 | static void ST7735_SetAddressWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) { 137 | // column address set 138 | ST7735_WriteCommand(ST7735_CASET); 139 | uint8_t data[] = { 0x00, x0 + ST7735_XSTART, 0x00, x1 + ST7735_XSTART }; 140 | ST7735_WriteData(data, sizeof(data)); 141 | 142 | // row address set 143 | ST7735_WriteCommand(ST7735_RASET); 144 | data[1] = y0 + ST7735_YSTART; 145 | data[3] = y1 + ST7735_YSTART; 146 | ST7735_WriteData(data, sizeof(data)); 147 | 148 | // write to RAM 149 | ST7735_WriteCommand(ST7735_RAMWR); 150 | } 151 | 152 | void ST7735_Init() { 153 | ST7735_Select(); 154 | ST7735_Reset(); 155 | ST7735_ExecuteCommandList(init_cmds1); 156 | ST7735_ExecuteCommandList(init_cmds2); 157 | ST7735_ExecuteCommandList(init_cmds3); 158 | ST7735_Unselect(); 159 | } 160 | 161 | void ST7735_DrawPixel(uint16_t x, uint16_t y, uint16_t color) { 162 | if((x >= ST7735_WIDTH) || (y >= ST7735_HEIGHT)) 163 | return; 164 | 165 | ST7735_Select(); 166 | 167 | ST7735_SetAddressWindow(x, y, x+1, y+1); 168 | uint8_t data[] = { color >> 8, color & 0xFF }; 169 | ST7735_WriteData(data, sizeof(data)); 170 | 171 | ST7735_Unselect(); 172 | } 173 | 174 | static void ST7735_WriteChar(uint16_t x, uint16_t y, char ch, FontDef font, uint16_t color, uint16_t bgcolor) { 175 | uint32_t i, b, j; 176 | 177 | ST7735_SetAddressWindow(x, y, x+font.width-1, y+font.height-1); 178 | 179 | for(i = 0; i < font.height; i++) { 180 | b = font.data[(ch - 32) * font.height + i]; 181 | for(j = 0; j < font.width; j++) { 182 | if((b << j) & 0x8000) { 183 | uint8_t data[] = { color >> 8, color & 0xFF }; 184 | ST7735_WriteData(data, sizeof(data)); 185 | } else { 186 | uint8_t data[] = { bgcolor >> 8, bgcolor & 0xFF }; 187 | ST7735_WriteData(data, sizeof(data)); 188 | } 189 | } 190 | } 191 | } 192 | 193 | /* 194 | Simpler (and probably slower) implementation: 195 | 196 | static void ST7735_WriteChar(uint16_t x, uint16_t y, char ch, FontDef font, uint16_t color) { 197 | uint32_t i, b, j; 198 | 199 | for(i = 0; i < font.height; i++) { 200 | b = font.data[(ch - 32) * font.height + i]; 201 | for(j = 0; j < font.width; j++) { 202 | if((b << j) & 0x8000) { 203 | ST7735_DrawPixel(x + j, y + i, color); 204 | } 205 | } 206 | } 207 | } 208 | */ 209 | 210 | void ST7735_WriteString(uint16_t x, uint16_t y, const char* str, FontDef font, uint16_t color, uint16_t bgcolor) { 211 | ST7735_Select(); 212 | 213 | while(*str) { 214 | if(x + font.width >= ST7735_WIDTH) { 215 | x = 0; 216 | y += font.height; 217 | if(y + font.height >= ST7735_HEIGHT) { 218 | break; 219 | } 220 | 221 | if(*str == ' ') { 222 | // skip spaces in the beginning of the new line 223 | str++; 224 | continue; 225 | } 226 | } 227 | 228 | ST7735_WriteChar(x, y, *str, font, color, bgcolor); 229 | x += font.width; 230 | str++; 231 | } 232 | 233 | ST7735_Unselect(); 234 | } 235 | 236 | void ST7735_FillRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color) { 237 | // clipping 238 | if((x >= ST7735_WIDTH) || (y >= ST7735_HEIGHT)) return; 239 | if((x + w - 1) >= ST7735_WIDTH) w = ST7735_WIDTH - x; 240 | if((y + h - 1) >= ST7735_HEIGHT) h = ST7735_HEIGHT - y; 241 | 242 | ST7735_Select(); 243 | ST7735_SetAddressWindow(x, y, x+w-1, y+h-1); 244 | 245 | uint8_t data[] = { color >> 8, color & 0xFF }; 246 | HAL_GPIO_WritePin(ST7735_DC_GPIO_Port, ST7735_DC_Pin, GPIO_PIN_SET); 247 | for(y = h; y > 0; y--) { 248 | for(x = w; x > 0; x--) { 249 | HAL_SPI_Transmit(&ST7735_SPI_PORT, data, sizeof(data), HAL_MAX_DELAY); 250 | } 251 | } 252 | 253 | ST7735_Unselect(); 254 | } 255 | 256 | void ST7735_FillScreen(uint16_t color) { 257 | ST7735_FillRectangle(0, 0, ST7735_WIDTH, ST7735_HEIGHT, color); 258 | } 259 | 260 | void ST7735_DrawImage(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint16_t* data) { 261 | if((x >= ST7735_WIDTH) || (y >= ST7735_HEIGHT)) return; 262 | if((x + w - 1) >= ST7735_WIDTH) return; 263 | if((y + h - 1) >= ST7735_HEIGHT) return; 264 | 265 | ST7735_Select(); 266 | ST7735_SetAddressWindow(x, y, x+w-1, y+h-1); 267 | ST7735_WriteData((uint8_t*)data, sizeof(uint16_t)*w*h); 268 | ST7735_Unselect(); 269 | } 270 | 271 | void ST7735_InvertColors(bool invert) { 272 | ST7735_Select(); 273 | ST7735_WriteCommand(invert ? ST7735_INVON : ST7735_INVOFF); 274 | ST7735_Unselect(); 275 | } 276 | 277 | 278 | -------------------------------------------------------------------------------- /st7735/st7735.h: -------------------------------------------------------------------------------- 1 | /* vim: set ai et ts=4 sw=4: */ 2 | #ifndef __ST7735_H__ 3 | #define __ST7735_H__ 4 | 5 | #include "fonts.h" 6 | #include 7 | 8 | #define ST7735_MADCTL_MY 0x80 9 | #define ST7735_MADCTL_MX 0x40 10 | #define ST7735_MADCTL_MV 0x20 11 | #define ST7735_MADCTL_ML 0x10 12 | #define ST7735_MADCTL_RGB 0x00 13 | #define ST7735_MADCTL_BGR 0x08 14 | #define ST7735_MADCTL_MH 0x04 15 | 16 | /*** Redefine if necessary ***/ 17 | #define ST7735_SPI_PORT hspi1 18 | extern SPI_HandleTypeDef ST7735_SPI_PORT; 19 | 20 | #define ST7735_RES_Pin GPIO_PIN_7 21 | #define ST7735_RES_GPIO_Port GPIOC 22 | #define ST7735_CS_Pin GPIO_PIN_6 23 | #define ST7735_CS_GPIO_Port GPIOB 24 | #define ST7735_DC_Pin GPIO_PIN_9 25 | #define ST7735_DC_GPIO_Port GPIOA 26 | 27 | // AliExpress/eBay 1.8" display, default orientation 28 | /* 29 | #define ST7735_IS_160X128 1 30 | #define ST7735_WIDTH 128 31 | #define ST7735_HEIGHT 160 32 | #define ST7735_XSTART 0 33 | #define ST7735_YSTART 0 34 | #define ST7735_ROTATION (ST7735_MADCTL_MX | ST7735_MADCTL_MY) 35 | */ 36 | 37 | // AliExpress/eBay 1.8" display, rotate right 38 | /* 39 | #define ST7735_IS_160X128 1 40 | #define ST7735_WIDTH 160 41 | #define ST7735_HEIGHT 128 42 | #define ST7735_XSTART 0 43 | #define ST7735_YSTART 0 44 | #define ST7735_ROTATION (ST7735_MADCTL_MY | ST7735_MADCTL_MV) 45 | */ 46 | 47 | // AliExpress/eBay 1.8" display, rotate left 48 | /* 49 | #define ST7735_IS_160X128 1 50 | #define ST7735_WIDTH 160 51 | #define ST7735_HEIGHT 128 52 | #define ST7735_XSTART 0 53 | #define ST7735_YSTART 0 54 | #define ST7735_ROTATION (ST7735_MADCTL_MX | ST7735_MADCTL_MV) 55 | */ 56 | 57 | // AliExpress/eBay 1.8" display, upside down 58 | /* 59 | #define ST7735_IS_160X128 1 60 | #define ST7735_WIDTH 128 61 | #define ST7735_HEIGHT 160 62 | #define ST7735_XSTART 0 63 | #define ST7735_YSTART 0 64 | #define ST7735_ROTATION (0) 65 | */ 66 | 67 | // WaveShare ST7735S-based 1.8" display, default orientation 68 | /* 69 | #define ST7735_IS_160X128 1 70 | #define ST7735_WIDTH 128 71 | #define ST7735_HEIGHT 160 72 | #define ST7735_XSTART 2 73 | #define ST7735_YSTART 1 74 | #define ST7735_ROTATION (ST7735_MADCTL_MX | ST7735_MADCTL_MY | ST7735_MADCTL_RGB) 75 | */ 76 | 77 | // WaveShare ST7735S-based 1.8" display, rotate right 78 | /* 79 | #define ST7735_IS_160X128 1 80 | #define ST7735_WIDTH 160 81 | #define ST7735_HEIGHT 128 82 | #define ST7735_XSTART 1 83 | #define ST7735_YSTART 2 84 | #define ST7735_ROTATION (ST7735_MADCTL_MY | ST7735_MADCTL_MV | ST7735_MADCTL_RGB) 85 | */ 86 | 87 | // WaveShare ST7735S-based 1.8" display, rotate left 88 | /* 89 | #define ST7735_IS_160X128 1 90 | #define ST7735_WIDTH 160 91 | #define ST7735_HEIGHT 128 92 | #define ST7735_XSTART 1 93 | #define ST7735_YSTART 2 94 | #define ST7735_ROTATION (ST7735_MADCTL_MX | ST7735_MADCTL_MV | ST7735_MADCTL_RGB) 95 | */ 96 | 97 | // WaveShare ST7735S-based 1.8" display, upside down 98 | /* 99 | #define ST7735_IS_160X128 1 100 | #define ST7735_WIDTH 128 101 | #define ST7735_HEIGHT 160 102 | #define ST7735_XSTART 2 103 | #define ST7735_YSTART 1 104 | #define ST7735_ROTATION (ST7735_MADCTL_RGB) 105 | */ 106 | 107 | // 1.44" display, default orientation 108 | /* 109 | #define ST7735_IS_128X128 1 110 | #define ST7735_WIDTH 128 111 | #define ST7735_HEIGHT 128 112 | #define ST7735_XSTART 2 113 | #define ST7735_YSTART 3 114 | #define ST7735_ROTATION (ST7735_MADCTL_MX | ST7735_MADCTL_MY | ST7735_MADCTL_BGR) 115 | */ 116 | 117 | // 1.44" display, rotate right 118 | /* 119 | #define ST7735_IS_128X128 1 120 | #define ST7735_WIDTH 128 121 | #define ST7735_HEIGHT 128 122 | #define ST7735_XSTART 3 123 | #define ST7735_YSTART 2 124 | #define ST7735_ROTATION (ST7735_MADCTL_MY | ST7735_MADCTL_MV | ST7735_MADCTL_BGR) 125 | */ 126 | 127 | // 1.44" display, rotate left 128 | #define ST7735_IS_128X128 1 129 | #define ST7735_WIDTH 128 130 | #define ST7735_HEIGHT 128 131 | #define ST7735_XSTART 1 132 | #define ST7735_YSTART 2 133 | #define ST7735_ROTATION (ST7735_MADCTL_MX | ST7735_MADCTL_MV | ST7735_MADCTL_BGR) 134 | 135 | // 1.44" display, upside down 136 | /* 137 | #define ST7735_IS_128X128 1 138 | #define ST7735_WIDTH 128 139 | #define ST7735_HEIGHT 128 140 | #define ST7735_XSTART 2 141 | #define ST7735_YSTART 1 142 | #define ST7735_ROTATION (ST7735_MADCTL_BGR) 143 | */ 144 | 145 | // mini 160x80 display (it's unlikely you want the default orientation) 146 | /* 147 | #define ST7735_IS_160X80 1 148 | #define ST7735_XSTART 26 149 | #define ST7735_YSTART 1 150 | #define ST7735_WIDTH 80 151 | #define ST7735_HEIGHT 160 152 | #define ST7735_ROTATION (ST7735_MADCTL_MX | ST7735_MADCTL_MY | ST7735_MADCTL_BGR) 153 | */ 154 | 155 | // mini 160x80, rotate left 156 | /* 157 | #define ST7735_IS_160X80 1 158 | #define ST7735_XSTART 1 159 | #define ST7735_YSTART 26 160 | #define ST7735_WIDTH 160 161 | #define ST7735_HEIGHT 80 162 | #define ST7735_ROTATION (ST7735_MADCTL_MX | ST7735_MADCTL_MV | ST7735_MADCTL_BGR) 163 | */ 164 | 165 | // mini 160x80, rotate right 166 | /* 167 | #define ST7735_IS_160X80 1 168 | #define ST7735_XSTART 1 169 | #define ST7735_YSTART 26 170 | #define ST7735_WIDTH 160 171 | #define ST7735_HEIGHT 80 172 | #define ST7735_ROTATION (ST7735_MADCTL_MY | ST7735_MADCTL_MV | ST7735_MADCTL_BGR) 173 | */ 174 | 175 | /****************************/ 176 | 177 | #define ST7735_NOP 0x00 178 | #define ST7735_SWRESET 0x01 179 | #define ST7735_RDDID 0x04 180 | #define ST7735_RDDST 0x09 181 | 182 | #define ST7735_SLPIN 0x10 183 | #define ST7735_SLPOUT 0x11 184 | #define ST7735_PTLON 0x12 185 | #define ST7735_NORON 0x13 186 | 187 | #define ST7735_INVOFF 0x20 188 | #define ST7735_INVON 0x21 189 | #define ST7735_DISPOFF 0x28 190 | #define ST7735_DISPON 0x29 191 | #define ST7735_CASET 0x2A 192 | #define ST7735_RASET 0x2B 193 | #define ST7735_RAMWR 0x2C 194 | #define ST7735_RAMRD 0x2E 195 | 196 | #define ST7735_PTLAR 0x30 197 | #define ST7735_COLMOD 0x3A 198 | #define ST7735_MADCTL 0x36 199 | 200 | #define ST7735_FRMCTR1 0xB1 201 | #define ST7735_FRMCTR2 0xB2 202 | #define ST7735_FRMCTR3 0xB3 203 | #define ST7735_INVCTR 0xB4 204 | #define ST7735_DISSET5 0xB6 205 | 206 | #define ST7735_PWCTR1 0xC0 207 | #define ST7735_PWCTR2 0xC1 208 | #define ST7735_PWCTR3 0xC2 209 | #define ST7735_PWCTR4 0xC3 210 | #define ST7735_PWCTR5 0xC4 211 | #define ST7735_VMCTR1 0xC5 212 | 213 | #define ST7735_RDID1 0xDA 214 | #define ST7735_RDID2 0xDB 215 | #define ST7735_RDID3 0xDC 216 | #define ST7735_RDID4 0xDD 217 | 218 | #define ST7735_PWCTR6 0xFC 219 | 220 | #define ST7735_GMCTRP1 0xE0 221 | #define ST7735_GMCTRN1 0xE1 222 | 223 | // Color definitions 224 | #define ST7735_BLACK 0x0000 225 | #define ST7735_BLUE 0x001F 226 | #define ST7735_RED 0xF800 227 | #define ST7735_GREEN 0x07E0 228 | #define ST7735_CYAN 0x07FF 229 | #define ST7735_MAGENTA 0xF81F 230 | #define ST7735_YELLOW 0xFFE0 231 | #define ST7735_WHITE 0xFFFF 232 | #define ST7735_COLOR565(r, g, b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)) 233 | 234 | // call before initializing any SPI devices 235 | void ST7735_Unselect(); 236 | 237 | void ST7735_Init(void); 238 | void ST7735_DrawPixel(uint16_t x, uint16_t y, uint16_t color); 239 | void ST7735_WriteString(uint16_t x, uint16_t y, const char* str, FontDef font, uint16_t color, uint16_t bgcolor); 240 | void ST7735_FillRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color); 241 | void ST7735_FillScreen(uint16_t color); 242 | void ST7735_DrawImage(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint16_t* data); 243 | void ST7735_InvertColors(bool invert); 244 | 245 | #endif // __ST7735_H__ 246 | -------------------------------------------------------------------------------- /startup_stm32f411xe.s: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file startup_stm32f411xe.s 4 | * @author MCD Application Team 5 | * @brief STM32F411xExx Devices vector table for GCC based toolchains. 6 | * This module performs: 7 | * - Set the initial SP 8 | * - Set the initial PC == Reset_Handler, 9 | * - Set the vector table entries with the exceptions ISR address 10 | * - Branches to main in the C library (which eventually 11 | * calls main()). 12 | * After Reset the Cortex-M4 processor is in Thread mode, 13 | * priority is Privileged, and the Stack is set to Main. 14 | ****************************************************************************** 15 | * @attention 16 | * 17 | *

© COPYRIGHT 2017 STMicroelectronics

18 | * 19 | * Redistribution and use in source and binary forms, with or without modification, 20 | * are permitted provided that the following conditions are met: 21 | * 1. Redistributions of source code must retain the above copyright notice, 22 | * this list of conditions and the following disclaimer. 23 | * 2. Redistributions in binary form must reproduce the above copyright notice, 24 | * this list of conditions and the following disclaimer in the documentation 25 | * and/or other materials provided with the distribution. 26 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 27 | * may be used to endorse or promote products derived from this software 28 | * without specific prior written permission. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 31 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 33 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 34 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 36 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 38 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 39 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | ****************************************************************************** 42 | */ 43 | 44 | .syntax unified 45 | .cpu cortex-m4 46 | .fpu softvfp 47 | .thumb 48 | 49 | .global g_pfnVectors 50 | .global Default_Handler 51 | 52 | /* start address for the initialization values of the .data section. 53 | defined in linker script */ 54 | .word _sidata 55 | /* start address for the .data section. defined in linker script */ 56 | .word _sdata 57 | /* end address for the .data section. defined in linker script */ 58 | .word _edata 59 | /* start address for the .bss section. defined in linker script */ 60 | .word _sbss 61 | /* end address for the .bss section. defined in linker script */ 62 | .word _ebss 63 | /* stack used for SystemInit_ExtMemCtl; always internal RAM used */ 64 | 65 | /** 66 | * @brief This is the code that gets called when the processor first 67 | * starts execution following a reset event. Only the absolutely 68 | * necessary set is performed, after which the application 69 | * supplied main() routine is called. 70 | * @param None 71 | * @retval : None 72 | */ 73 | 74 | .section .text.Reset_Handler 75 | .weak Reset_Handler 76 | .type Reset_Handler, %function 77 | Reset_Handler: 78 | ldr sp, =_estack /* set stack pointer */ 79 | 80 | /* Copy the data segment initializers from flash to SRAM */ 81 | movs r1, #0 82 | b LoopCopyDataInit 83 | 84 | CopyDataInit: 85 | ldr r3, =_sidata 86 | ldr r3, [r3, r1] 87 | str r3, [r0, r1] 88 | adds r1, r1, #4 89 | 90 | LoopCopyDataInit: 91 | ldr r0, =_sdata 92 | ldr r3, =_edata 93 | adds r2, r0, r1 94 | cmp r2, r3 95 | bcc CopyDataInit 96 | ldr r2, =_sbss 97 | b LoopFillZerobss 98 | /* Zero fill the bss segment. */ 99 | FillZerobss: 100 | movs r3, #0 101 | str r3, [r2], #4 102 | 103 | LoopFillZerobss: 104 | ldr r3, = _ebss 105 | cmp r2, r3 106 | bcc FillZerobss 107 | 108 | /* Call the clock system intitialization function.*/ 109 | bl SystemInit 110 | /* Call static constructors */ 111 | bl __libc_init_array 112 | /* Call the application's entry point.*/ 113 | bl main 114 | bx lr 115 | .size Reset_Handler, .-Reset_Handler 116 | 117 | /** 118 | * @brief This is the code that gets called when the processor receives an 119 | * unexpected interrupt. This simply enters an infinite loop, preserving 120 | * the system state for examination by a debugger. 121 | * @param None 122 | * @retval None 123 | */ 124 | .section .text.Default_Handler,"ax",%progbits 125 | Default_Handler: 126 | Infinite_Loop: 127 | b Infinite_Loop 128 | .size Default_Handler, .-Default_Handler 129 | /****************************************************************************** 130 | * 131 | * The minimal vector table for a Cortex M3. Note that the proper constructs 132 | * must be placed on this to ensure that it ends up at physical address 133 | * 0x0000.0000. 134 | * 135 | *******************************************************************************/ 136 | .section .isr_vector,"a",%progbits 137 | .type g_pfnVectors, %object 138 | .size g_pfnVectors, .-g_pfnVectors 139 | 140 | g_pfnVectors: 141 | .word _estack 142 | .word Reset_Handler 143 | .word NMI_Handler 144 | .word HardFault_Handler 145 | .word MemManage_Handler 146 | .word BusFault_Handler 147 | .word UsageFault_Handler 148 | .word 0 149 | .word 0 150 | .word 0 151 | .word 0 152 | .word SVC_Handler 153 | .word DebugMon_Handler 154 | .word 0 155 | .word PendSV_Handler 156 | .word SysTick_Handler 157 | 158 | /* External Interrupts */ 159 | .word WWDG_IRQHandler /* Window WatchDog */ 160 | .word PVD_IRQHandler /* PVD through EXTI Line detection */ 161 | .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ 162 | .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ 163 | .word FLASH_IRQHandler /* FLASH */ 164 | .word RCC_IRQHandler /* RCC */ 165 | .word EXTI0_IRQHandler /* EXTI Line0 */ 166 | .word EXTI1_IRQHandler /* EXTI Line1 */ 167 | .word EXTI2_IRQHandler /* EXTI Line2 */ 168 | .word EXTI3_IRQHandler /* EXTI Line3 */ 169 | .word EXTI4_IRQHandler /* EXTI Line4 */ 170 | .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ 171 | .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ 172 | .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ 173 | .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ 174 | .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ 175 | .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ 176 | .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ 177 | .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ 178 | .word 0 /* Reserved */ 179 | .word 0 /* Reserved */ 180 | .word 0 /* Reserved */ 181 | .word 0 /* Reserved */ 182 | .word EXTI9_5_IRQHandler /* External Line[9:5]s */ 183 | .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ 184 | .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ 185 | .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ 186 | .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ 187 | .word TIM2_IRQHandler /* TIM2 */ 188 | .word TIM3_IRQHandler /* TIM3 */ 189 | .word TIM4_IRQHandler /* TIM4 */ 190 | .word I2C1_EV_IRQHandler /* I2C1 Event */ 191 | .word I2C1_ER_IRQHandler /* I2C1 Error */ 192 | .word I2C2_EV_IRQHandler /* I2C2 Event */ 193 | .word I2C2_ER_IRQHandler /* I2C2 Error */ 194 | .word SPI1_IRQHandler /* SPI1 */ 195 | .word SPI2_IRQHandler /* SPI2 */ 196 | .word USART1_IRQHandler /* USART1 */ 197 | .word USART2_IRQHandler /* USART2 */ 198 | .word 0 /* Reserved */ 199 | .word EXTI15_10_IRQHandler /* External Line[15:10]s */ 200 | .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ 201 | .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ 202 | .word 0 /* Reserved */ 203 | .word 0 /* Reserved */ 204 | .word 0 /* Reserved */ 205 | .word 0 /* Reserved */ 206 | .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ 207 | .word 0 /* Reserved */ 208 | .word SDIO_IRQHandler /* SDIO */ 209 | .word TIM5_IRQHandler /* TIM5 */ 210 | .word SPI3_IRQHandler /* SPI3 */ 211 | .word 0 /* Reserved */ 212 | .word 0 /* Reserved */ 213 | .word 0 /* Reserved */ 214 | .word 0 /* Reserved */ 215 | .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ 216 | .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ 217 | .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ 218 | .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ 219 | .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ 220 | .word 0 /* Reserved */ 221 | .word 0 /* Reserved */ 222 | .word 0 /* Reserved */ 223 | .word 0 /* Reserved */ 224 | .word 0 /* Reserved */ 225 | .word 0 /* Reserved */ 226 | .word OTG_FS_IRQHandler /* USB OTG FS */ 227 | .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ 228 | .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ 229 | .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ 230 | .word USART6_IRQHandler /* USART6 */ 231 | .word I2C3_EV_IRQHandler /* I2C3 event */ 232 | .word I2C3_ER_IRQHandler /* I2C3 error */ 233 | .word 0 /* Reserved */ 234 | .word 0 /* Reserved */ 235 | .word 0 /* Reserved */ 236 | .word 0 /* Reserved */ 237 | .word 0 /* Reserved */ 238 | .word 0 /* Reserved */ 239 | .word 0 /* Reserved */ 240 | .word FPU_IRQHandler /* FPU */ 241 | .word 0 /* Reserved */ 242 | .word 0 /* Reserved */ 243 | .word SPI4_IRQHandler /* SPI4 */ 244 | .word SPI5_IRQHandler /* SPI5 */ 245 | 246 | /******************************************************************************* 247 | * 248 | * Provide weak aliases for each Exception handler to the Default_Handler. 249 | * As they are weak aliases, any function with the same name will override 250 | * this definition. 251 | * 252 | *******************************************************************************/ 253 | .weak NMI_Handler 254 | .thumb_set NMI_Handler,Default_Handler 255 | 256 | .weak HardFault_Handler 257 | .thumb_set HardFault_Handler,Default_Handler 258 | 259 | .weak MemManage_Handler 260 | .thumb_set MemManage_Handler,Default_Handler 261 | 262 | .weak BusFault_Handler 263 | .thumb_set BusFault_Handler,Default_Handler 264 | 265 | .weak UsageFault_Handler 266 | .thumb_set UsageFault_Handler,Default_Handler 267 | 268 | .weak SVC_Handler 269 | .thumb_set SVC_Handler,Default_Handler 270 | 271 | .weak DebugMon_Handler 272 | .thumb_set DebugMon_Handler,Default_Handler 273 | 274 | .weak PendSV_Handler 275 | .thumb_set PendSV_Handler,Default_Handler 276 | 277 | .weak SysTick_Handler 278 | .thumb_set SysTick_Handler,Default_Handler 279 | 280 | .weak WWDG_IRQHandler 281 | .thumb_set WWDG_IRQHandler,Default_Handler 282 | 283 | .weak PVD_IRQHandler 284 | .thumb_set PVD_IRQHandler,Default_Handler 285 | 286 | .weak TAMP_STAMP_IRQHandler 287 | .thumb_set TAMP_STAMP_IRQHandler,Default_Handler 288 | 289 | .weak RTC_WKUP_IRQHandler 290 | .thumb_set RTC_WKUP_IRQHandler,Default_Handler 291 | 292 | .weak FLASH_IRQHandler 293 | .thumb_set FLASH_IRQHandler,Default_Handler 294 | 295 | .weak RCC_IRQHandler 296 | .thumb_set RCC_IRQHandler,Default_Handler 297 | 298 | .weak EXTI0_IRQHandler 299 | .thumb_set EXTI0_IRQHandler,Default_Handler 300 | 301 | .weak EXTI1_IRQHandler 302 | .thumb_set EXTI1_IRQHandler,Default_Handler 303 | 304 | .weak EXTI2_IRQHandler 305 | .thumb_set EXTI2_IRQHandler,Default_Handler 306 | 307 | .weak EXTI3_IRQHandler 308 | .thumb_set EXTI3_IRQHandler,Default_Handler 309 | 310 | .weak EXTI4_IRQHandler 311 | .thumb_set EXTI4_IRQHandler,Default_Handler 312 | 313 | .weak DMA1_Stream0_IRQHandler 314 | .thumb_set DMA1_Stream0_IRQHandler,Default_Handler 315 | 316 | .weak DMA1_Stream1_IRQHandler 317 | .thumb_set DMA1_Stream1_IRQHandler,Default_Handler 318 | 319 | .weak DMA1_Stream2_IRQHandler 320 | .thumb_set DMA1_Stream2_IRQHandler,Default_Handler 321 | 322 | .weak DMA1_Stream3_IRQHandler 323 | .thumb_set DMA1_Stream3_IRQHandler,Default_Handler 324 | 325 | .weak DMA1_Stream4_IRQHandler 326 | .thumb_set DMA1_Stream4_IRQHandler,Default_Handler 327 | 328 | .weak DMA1_Stream5_IRQHandler 329 | .thumb_set DMA1_Stream5_IRQHandler,Default_Handler 330 | 331 | .weak DMA1_Stream6_IRQHandler 332 | .thumb_set DMA1_Stream6_IRQHandler,Default_Handler 333 | 334 | .weak ADC_IRQHandler 335 | .thumb_set ADC_IRQHandler,Default_Handler 336 | 337 | .weak EXTI9_5_IRQHandler 338 | .thumb_set EXTI9_5_IRQHandler,Default_Handler 339 | 340 | .weak TIM1_BRK_TIM9_IRQHandler 341 | .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler 342 | 343 | .weak TIM1_UP_TIM10_IRQHandler 344 | .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler 345 | 346 | .weak TIM1_TRG_COM_TIM11_IRQHandler 347 | .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler 348 | 349 | .weak TIM1_CC_IRQHandler 350 | .thumb_set TIM1_CC_IRQHandler,Default_Handler 351 | 352 | .weak TIM2_IRQHandler 353 | .thumb_set TIM2_IRQHandler,Default_Handler 354 | 355 | .weak TIM3_IRQHandler 356 | .thumb_set TIM3_IRQHandler,Default_Handler 357 | 358 | .weak TIM4_IRQHandler 359 | .thumb_set TIM4_IRQHandler,Default_Handler 360 | 361 | .weak I2C1_EV_IRQHandler 362 | .thumb_set I2C1_EV_IRQHandler,Default_Handler 363 | 364 | .weak I2C1_ER_IRQHandler 365 | .thumb_set I2C1_ER_IRQHandler,Default_Handler 366 | 367 | .weak I2C2_EV_IRQHandler 368 | .thumb_set I2C2_EV_IRQHandler,Default_Handler 369 | 370 | .weak I2C2_ER_IRQHandler 371 | .thumb_set I2C2_ER_IRQHandler,Default_Handler 372 | 373 | .weak SPI1_IRQHandler 374 | .thumb_set SPI1_IRQHandler,Default_Handler 375 | 376 | .weak SPI2_IRQHandler 377 | .thumb_set SPI2_IRQHandler,Default_Handler 378 | 379 | .weak USART1_IRQHandler 380 | .thumb_set USART1_IRQHandler,Default_Handler 381 | 382 | .weak USART2_IRQHandler 383 | .thumb_set USART2_IRQHandler,Default_Handler 384 | 385 | .weak EXTI15_10_IRQHandler 386 | .thumb_set EXTI15_10_IRQHandler,Default_Handler 387 | 388 | .weak RTC_Alarm_IRQHandler 389 | .thumb_set RTC_Alarm_IRQHandler,Default_Handler 390 | 391 | .weak OTG_FS_WKUP_IRQHandler 392 | .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler 393 | 394 | .weak DMA1_Stream7_IRQHandler 395 | .thumb_set DMA1_Stream7_IRQHandler,Default_Handler 396 | 397 | .weak SDIO_IRQHandler 398 | .thumb_set SDIO_IRQHandler,Default_Handler 399 | 400 | .weak TIM5_IRQHandler 401 | .thumb_set TIM5_IRQHandler,Default_Handler 402 | 403 | .weak SPI3_IRQHandler 404 | .thumb_set SPI3_IRQHandler,Default_Handler 405 | 406 | .weak DMA2_Stream0_IRQHandler 407 | .thumb_set DMA2_Stream0_IRQHandler,Default_Handler 408 | 409 | .weak DMA2_Stream1_IRQHandler 410 | .thumb_set DMA2_Stream1_IRQHandler,Default_Handler 411 | 412 | .weak DMA2_Stream2_IRQHandler 413 | .thumb_set DMA2_Stream2_IRQHandler,Default_Handler 414 | 415 | .weak DMA2_Stream3_IRQHandler 416 | .thumb_set DMA2_Stream3_IRQHandler,Default_Handler 417 | 418 | .weak DMA2_Stream4_IRQHandler 419 | .thumb_set DMA2_Stream4_IRQHandler,Default_Handler 420 | 421 | .weak OTG_FS_IRQHandler 422 | .thumb_set OTG_FS_IRQHandler,Default_Handler 423 | 424 | .weak DMA2_Stream5_IRQHandler 425 | .thumb_set DMA2_Stream5_IRQHandler,Default_Handler 426 | 427 | .weak DMA2_Stream6_IRQHandler 428 | .thumb_set DMA2_Stream6_IRQHandler,Default_Handler 429 | 430 | .weak DMA2_Stream7_IRQHandler 431 | .thumb_set DMA2_Stream7_IRQHandler,Default_Handler 432 | 433 | .weak USART6_IRQHandler 434 | .thumb_set USART6_IRQHandler,Default_Handler 435 | 436 | .weak I2C3_EV_IRQHandler 437 | .thumb_set I2C3_EV_IRQHandler,Default_Handler 438 | 439 | .weak I2C3_ER_IRQHandler 440 | .thumb_set I2C3_ER_IRQHandler,Default_Handler 441 | 442 | .weak FPU_IRQHandler 443 | .thumb_set FPU_IRQHandler,Default_Handler 444 | 445 | .weak SPI4_IRQHandler 446 | .thumb_set SPI4_IRQHandler,Default_Handler 447 | 448 | .weak SPI5_IRQHandler 449 | .thumb_set SPI5_IRQHandler,Default_Handler 450 | 451 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 452 | 453 | --------------------------------------------------------------------------------