├── read-write-cubemx-ver ├── .gitignore ├── cubefix.sh ├── sdcard │ └── sdcard.h ├── Inc │ ├── stm32f4xx_it.h │ ├── fatfs.h │ ├── user_diskio.h │ ├── main.h │ └── ffconf.h ├── Src │ ├── stm32f4xx_it.c │ ├── fatfs.c │ ├── stm32f4xx_hal_msp.c │ ├── user_diskio.c │ └── main.c ├── STM32F411RETx_FLASH.ld ├── main.ioc ├── Makefile └── mx.scratch ├── st7735-images-native-ver ├── .gitignore ├── cubefix.sh ├── st7735 │ ├── fonts.h │ ├── st7735.h │ └── st7735.c ├── fatfs │ ├── integer.h │ ├── 00readme.txt │ ├── diskio.h │ ├── diskio.c │ ├── ffsystem.c │ ├── 00history.txt │ └── ffconf.h ├── sdcard │ └── sdcard.h ├── Inc │ ├── stm32f4xx_it.h │ └── main.h ├── Src │ ├── stm32f4xx_it.c │ ├── stm32f4xx_hal_msp.c │ └── main.c ├── STM32F411RETx_FLASH.ld ├── main.ioc ├── Makefile └── mx.scratch ├── README.md └── LICENSE /read-write-cubemx-ver/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.backup 3 | .mxproject 4 | Src/*.tmp 5 | -------------------------------------------------------------------------------- /st7735-images-native-ver/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.backup 3 | .mxproject 4 | Src/*.tmp 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # stm32-fatfs-examples 2 | STM32: examples of usage of FatFs library 3 | 4 | See also: 5 | 6 | * https://github.com/afiskon/stm32-sdcard 7 | * https://github.com/afiskon/stm32-st7735 8 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/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,47d' Src/main.c 10 | -------------------------------------------------------------------------------- /st7735-images-native-ver/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,38d' Src/main.c 10 | -------------------------------------------------------------------------------- /st7735-images-native-ver/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-images-native-ver/fatfs/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #ifndef FF_INTEGER 6 | #define FF_INTEGER 7 | 8 | #ifdef _WIN32 /* FatFs development platform */ 9 | 10 | #include 11 | typedef unsigned __int64 QWORD; 12 | 13 | #else /* Embedded platform */ 14 | 15 | /* These types MUST be 16-bit or 32-bit */ 16 | typedef int INT; 17 | typedef unsigned int UINT; 18 | 19 | /* This type MUST be 8-bit */ 20 | typedef unsigned char BYTE; 21 | 22 | /* These types MUST be 16-bit */ 23 | typedef short SHORT; 24 | typedef unsigned short WORD; 25 | typedef unsigned short WCHAR; 26 | 27 | /* These types MUST be 32-bit */ 28 | typedef long LONG; 29 | typedef unsigned long DWORD; 30 | 31 | /* This type MUST be 64-bit (Remove this for ANSI C (C89) compatibility) */ 32 | typedef unsigned long long QWORD; 33 | 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /st7735-images-native-ver/fatfs/00readme.txt: -------------------------------------------------------------------------------- 1 | FatFs Module Source Files R0.13b 2 | 3 | 4 | FILES 5 | 6 | 00readme.txt This file. 7 | 00history.txt Revision history. 8 | ff.c FatFs module. 9 | ffconf.h Configuration file of FatFs module. 10 | ff.h Common include file for FatFs and application module. 11 | diskio.h Common include file for FatFs and disk I/O module. 12 | diskio.c An example of glue function to attach existing disk I/O module to FatFs. 13 | integer.h Integer type definitions for FatFs. 14 | ffunicode.c Optional Unicode utility functions. 15 | ffsystem.c An example of optional O/S related functions. 16 | 17 | 18 | Low level disk I/O module is not included in this archive because the FatFs 19 | module is only a generic file system layer and it does not depend on any specific 20 | storage device. You need to provide a low level disk I/O module written to 21 | control the storage device that attached to the target system. 22 | 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/sdcard/sdcard.h: -------------------------------------------------------------------------------- 1 | /* vim: set ai et ts=4 sw=4: */ 2 | #ifndef __SDCARD_H__ 3 | #define __SDCARD_H__ 4 | 5 | #include "stm32f4xx_hal.h" 6 | 7 | #define SDCARD_SPI_PORT hspi1 8 | #define SDCARD_CS_Pin GPIO_PIN_5 // Arduino shield: D4 9 | #define SDCARD_CS_GPIO_Port GPIOB 10 | 11 | extern SPI_HandleTypeDef SDCARD_SPI_PORT; 12 | 13 | // call before initializing any SPI devices 14 | void SDCARD_Unselect(); 15 | 16 | // all procedures return 0 on success, < 0 on failure 17 | 18 | int SDCARD_Init(); 19 | int SDCARD_GetBlocksNumber(uint32_t* num); 20 | int SDCARD_ReadSingleBlock(uint32_t blockNum, uint8_t* buff); // sizeof(buff) == 512! 21 | int SDCARD_WriteSingleBlock(uint32_t blockNum, const uint8_t* buff); // sizeof(buff) == 512! 22 | 23 | // Read Multiple Blocks 24 | int SDCARD_ReadBegin(uint32_t blockNum); 25 | int SDCARD_ReadData(uint8_t* buff); // sizeof(buff) == 512! 26 | int SDCARD_ReadEnd(); 27 | 28 | // Write Multiple Blocks 29 | int SDCARD_WriteBegin(uint32_t blockNum); 30 | int SDCARD_WriteData(const uint8_t* buff); // sizeof(buff) == 512! 31 | int SDCARD_WriteEnd(); 32 | 33 | // TODO: read lock flag? CMD13, SEND_STATUS 34 | 35 | #endif // __SDCARD_H__ 36 | -------------------------------------------------------------------------------- /st7735-images-native-ver/sdcard/sdcard.h: -------------------------------------------------------------------------------- 1 | /* vim: set ai et ts=4 sw=4: */ 2 | #ifndef __SDCARD_H__ 3 | #define __SDCARD_H__ 4 | 5 | #include "stm32f4xx_hal.h" 6 | 7 | #define SDCARD_SPI_PORT hspi1 8 | #define SDCARD_CS_Pin GPIO_PIN_5 // Arduino shield: D4 9 | #define SDCARD_CS_GPIO_Port GPIOB 10 | 11 | extern SPI_HandleTypeDef SDCARD_SPI_PORT; 12 | 13 | // call before initializing any SPI devices 14 | void SDCARD_Unselect(); 15 | 16 | // all procedures return 0 on success, < 0 on failure 17 | 18 | int SDCARD_Init(); 19 | int SDCARD_GetBlocksNumber(uint32_t* num); 20 | int SDCARD_ReadSingleBlock(uint32_t blockNum, uint8_t* buff); // sizeof(buff) == 512! 21 | int SDCARD_WriteSingleBlock(uint32_t blockNum, const uint8_t* buff); // sizeof(buff) == 512! 22 | 23 | // Read Multiple Blocks 24 | int SDCARD_ReadBegin(uint32_t blockNum); 25 | int SDCARD_ReadData(uint8_t* buff); // sizeof(buff) == 512! 26 | int SDCARD_ReadEnd(); 27 | 28 | // Write Multiple Blocks 29 | int SDCARD_WriteBegin(uint32_t blockNum); 30 | int SDCARD_WriteData(const uint8_t* buff); // sizeof(buff) == 512! 31 | int SDCARD_WriteEnd(); 32 | 33 | // TODO: read lock flag? CMD13, SEND_STATUS 34 | 35 | #endif // __SDCARD_H__ 36 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/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 | -------------------------------------------------------------------------------- /st7735-images-native-ver/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 | -------------------------------------------------------------------------------- /st7735-images-native-ver/fatfs/diskio.h: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------------------/ 2 | / Low level disk interface modlue include file (C)ChaN, 2014 / 3 | /-----------------------------------------------------------------------*/ 4 | 5 | #ifndef _DISKIO_DEFINED 6 | #define _DISKIO_DEFINED 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #include "integer.h" 13 | 14 | 15 | /* Status of Disk Functions */ 16 | typedef BYTE DSTATUS; 17 | 18 | /* Results of Disk Functions */ 19 | typedef enum { 20 | RES_OK = 0, /* 0: Successful */ 21 | RES_ERROR, /* 1: R/W Error */ 22 | RES_WRPRT, /* 2: Write Protected */ 23 | RES_NOTRDY, /* 3: Not Ready */ 24 | RES_PARERR /* 4: Invalid Parameter */ 25 | } DRESULT; 26 | 27 | 28 | /*---------------------------------------*/ 29 | /* Prototypes for disk control functions */ 30 | 31 | 32 | DSTATUS disk_initialize (BYTE pdrv); 33 | DSTATUS disk_status (BYTE pdrv); 34 | DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); 35 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); 36 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); 37 | 38 | 39 | /* Disk Status Bits (DSTATUS) */ 40 | 41 | #define STA_NOINIT 0x01 /* Drive not initialized */ 42 | #define STA_NODISK 0x02 /* No medium in the drive */ 43 | #define STA_PROTECT 0x04 /* Write protected */ 44 | 45 | 46 | /* Command code for disk_ioctrl fucntion */ 47 | 48 | /* Generic command (Used by FatFs) */ 49 | #define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */ 50 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */ 51 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */ 52 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */ 53 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */ 54 | 55 | /* Generic command (Not used by FatFs) */ 56 | #define CTRL_POWER 5 /* Get/Set power status */ 57 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ 58 | #define CTRL_EJECT 7 /* Eject media */ 59 | #define CTRL_FORMAT 8 /* Create physical format on the media */ 60 | 61 | /* MMC/SDC specific ioctl command */ 62 | #define MMC_GET_TYPE 10 /* Get card type */ 63 | #define MMC_GET_CSD 11 /* Get CSD */ 64 | #define MMC_GET_CID 12 /* Get CID */ 65 | #define MMC_GET_OCR 13 /* Get OCR */ 66 | #define MMC_GET_SDSTAT 14 /* Get SD status */ 67 | #define ISDIO_READ 55 /* Read data form SD iSDIO register */ 68 | #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ 69 | #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ 70 | 71 | /* ATA/CF specific ioctl command */ 72 | #define ATA_GET_REV 20 /* Get F/W revision */ 73 | #define ATA_GET_MODEL 21 /* Get model name */ 74 | #define ATA_GET_SN 22 /* Get serial number */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/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 | -------------------------------------------------------------------------------- /st7735-images-native-ver/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 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/Inc/fatfs.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file fatfs.h 4 | * @brief Header for fatfs applications 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 International N.V. 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted, provided that the following conditions are met: 17 | * 18 | * 1. Redistribution of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of other 24 | * contributors to this software may be used to endorse or promote products 25 | * derived from this software without specific written permission. 26 | * 4. This software, including modifications and/or derivative works of this 27 | * software, must execute solely and exclusively on microcontroller or 28 | * microprocessor devices manufactured by or for STMicroelectronics. 29 | * 5. Redistribution and use of this software other than as permitted under 30 | * this license is void and will automatically terminate your rights under 31 | * this license. 32 | * 33 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 34 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 35 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 36 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 37 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 38 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 40 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 41 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 42 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 43 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 44 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | ****************************************************************************** 47 | */ 48 | 49 | /* Define to prevent recursive inclusion -------------------------------------*/ 50 | #ifndef __fatfs_H 51 | #define __fatfs_H 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | #include "ff.h" 57 | #include "ff_gen_drv.h" 58 | #include "user_diskio.h" /* defines USER_Driver as external */ 59 | 60 | /* USER CODE BEGIN Includes */ 61 | 62 | /* USER CODE END Includes */ 63 | 64 | extern uint8_t retUSER; /* Return value for USER */ 65 | extern char USERPath[4]; /* USER logical drive path */ 66 | extern FATFS USERFatFS; /* File system object for USER logical drive */ 67 | extern FIL USERFile; /* File object for USER */ 68 | 69 | void MX_FATFS_Init(void); 70 | 71 | /* USER CODE BEGIN Prototypes */ 72 | 73 | /* USER CODE END Prototypes */ 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | #endif /*__fatfs_H */ 78 | 79 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 80 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/Inc/user_diskio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file user_diskio.h 4 | * @brief This file contains the common defines and functions prototypes for 5 | * the user_diskio driver. 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 International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | 50 | /* Define to prevent recursive inclusion -------------------------------------*/ 51 | #ifndef __USER_DISKIO_H 52 | #define __USER_DISKIO_H 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /* USER CODE BEGIN 0 */ 59 | 60 | /* Includes ------------------------------------------------------------------*/ 61 | /* Exported types ------------------------------------------------------------*/ 62 | /* Exported constants --------------------------------------------------------*/ 63 | /* Exported functions ------------------------------------------------------- */ 64 | extern Diskio_drvTypeDef USER_Driver; 65 | 66 | /* USER CODE END 0 */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __USER_DISKIO_H */ 73 | 74 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 75 | -------------------------------------------------------------------------------- /st7735-images-native-ver/fatfs/diskio.c: -------------------------------------------------------------------------------- 1 | #include "diskio.h" /* FatFs lower layer API */ 2 | #include "sdcard.h" 3 | 4 | /* Definitions of physical drive number for each drive */ 5 | #define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */ 6 | #define DEV_MMC 1 /* Example: Map MMC/SD card to physical drive 1 */ 7 | #define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */ 8 | 9 | 10 | /*-----------------------------------------------------------------------*/ 11 | /* Get Drive Status */ 12 | /*-----------------------------------------------------------------------*/ 13 | 14 | DSTATUS disk_status ( 15 | BYTE pdrv /* Physical drive nmuber to identify the drive */ 16 | ) 17 | { 18 | return 0; 19 | } 20 | 21 | 22 | 23 | /*-----------------------------------------------------------------------*/ 24 | /* Inidialize a Drive */ 25 | /*-----------------------------------------------------------------------*/ 26 | 27 | DSTATUS disk_initialize ( 28 | BYTE pdrv /* Physical drive nmuber to identify the drive */ 29 | ) 30 | { 31 | // already initialized in init() procedure 32 | return 0; 33 | } 34 | 35 | 36 | 37 | /*-----------------------------------------------------------------------*/ 38 | /* Read Sector(s) */ 39 | /*-----------------------------------------------------------------------*/ 40 | 41 | DRESULT disk_read ( 42 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ 43 | BYTE *buff, /* Data buffer to store read data */ 44 | DWORD sector, /* Start sector in LBA */ 45 | UINT count /* Number of sectors to read */ 46 | ) 47 | { 48 | if(SDCARD_ReadBegin(sector) < 0) { 49 | return RES_ERROR; 50 | } 51 | 52 | while(count > 0) { 53 | if(SDCARD_ReadData(buff) < 0) { 54 | return RES_ERROR; 55 | } 56 | buff += 512; 57 | count--; 58 | } 59 | 60 | if(SDCARD_ReadEnd() < 0) { 61 | return RES_ERROR; 62 | } 63 | 64 | return RES_OK; 65 | } 66 | 67 | 68 | 69 | /*-----------------------------------------------------------------------*/ 70 | /* Write Sector(s) */ 71 | /*-----------------------------------------------------------------------*/ 72 | 73 | DRESULT disk_write ( 74 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ 75 | const BYTE *buff, /* Data to be written */ 76 | DWORD sector, /* Start sector in LBA */ 77 | UINT count /* Number of sectors to write */ 78 | ) 79 | { 80 | if(SDCARD_WriteBegin(sector) < 0) { 81 | return RES_ERROR; 82 | } 83 | 84 | while(count > 0) { 85 | if(SDCARD_WriteData(buff) < 0) { 86 | return RES_ERROR; 87 | } 88 | 89 | buff += 512; 90 | count--; 91 | } 92 | 93 | if(SDCARD_WriteEnd() < 0) { 94 | return RES_ERROR; 95 | } 96 | 97 | return RES_OK; 98 | } 99 | 100 | /*-----------------------------------------------------------------------*/ 101 | /* Miscellaneous Functions */ 102 | /*-----------------------------------------------------------------------*/ 103 | 104 | DRESULT disk_ioctl ( 105 | BYTE pdrv, /* Physical drive nmuber (0..) */ 106 | BYTE cmd, /* Control code */ 107 | void *buff /* Buffer to send/receive control data */ 108 | ) 109 | { 110 | if(cmd == CTRL_SYNC) { 111 | return RES_OK; 112 | } else { 113 | // should never be called 114 | return RES_ERROR; 115 | } 116 | } 117 | 118 | /** 119 | * @brief Gets Time from RTC 120 | * @param None 121 | * @retval Time in DWORD 122 | */ 123 | 124 | /* 125 | DWORD get_fattime(void) 126 | { 127 | return 0; 128 | } 129 | */ 130 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/Src/fatfs.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file fatfs.c 4 | * @brief Code for fatfs applications 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 International N.V. 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted, provided that the following conditions are met: 17 | * 18 | * 1. Redistribution of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of other 24 | * contributors to this software may be used to endorse or promote products 25 | * derived from this software without specific written permission. 26 | * 4. This software, including modifications and/or derivative works of this 27 | * software, must execute solely and exclusively on microcontroller or 28 | * microprocessor devices manufactured by or for STMicroelectronics. 29 | * 5. Redistribution and use of this software other than as permitted under 30 | * this license is void and will automatically terminate your rights under 31 | * this license. 32 | * 33 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 34 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 35 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 36 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 37 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 38 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 40 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 41 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 42 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 43 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 44 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | ****************************************************************************** 47 | */ 48 | 49 | #include "fatfs.h" 50 | 51 | uint8_t retUSER; /* Return value for USER */ 52 | char USERPath[4]; /* USER logical drive path */ 53 | FATFS USERFatFS; /* File system object for USER logical drive */ 54 | FIL USERFile; /* File object for USER */ 55 | 56 | /* USER CODE BEGIN Variables */ 57 | 58 | /* USER CODE END Variables */ 59 | 60 | void MX_FATFS_Init(void) 61 | { 62 | /*## FatFS: Link the USER driver ###########################*/ 63 | retUSER = FATFS_LinkDriver(&USER_Driver, USERPath); 64 | 65 | /* USER CODE BEGIN Init */ 66 | /* additional user code for init */ 67 | /* USER CODE END Init */ 68 | } 69 | 70 | /** 71 | * @brief Gets Time from RTC 72 | * @param None 73 | * @retval Time in DWORD 74 | */ 75 | DWORD get_fattime(void) 76 | { 77 | /* USER CODE BEGIN get_fattime */ 78 | return 0; 79 | /* USER CODE END get_fattime */ 80 | } 81 | 82 | /* USER CODE BEGIN Application */ 83 | 84 | /* USER CODE END Application */ 85 | 86 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 87 | -------------------------------------------------------------------------------- /st7735-images-native-ver/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 TMS_Pin GPIO_PIN_13 57 | #define TMS_GPIO_Port GPIOA 58 | #define TCK_Pin GPIO_PIN_14 59 | #define TCK_GPIO_Port GPIOA 60 | #define SWO_Pin GPIO_PIN_3 61 | #define SWO_GPIO_Port GPIOB 62 | 63 | /* ########################## Assert Selection ############################## */ 64 | /** 65 | * @brief Uncomment the line below to expanse the "assert_param" macro in the 66 | * HAL drivers code 67 | */ 68 | /* #define USE_FULL_ASSERT 1U */ 69 | 70 | /* USER CODE BEGIN Private defines */ 71 | 72 | /* USER CODE END Private defines */ 73 | 74 | #ifdef __cplusplus 75 | extern "C" { 76 | #endif 77 | void _Error_Handler(char *, int); 78 | 79 | #define Error_Handler() _Error_Handler(__FILE__, __LINE__) 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /** 89 | * @} 90 | */ 91 | 92 | #endif /* __MAIN_H */ 93 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 94 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/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 International N.V. 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted, provided that the following conditions are met: 17 | * 18 | * 1. Redistribution of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of other 24 | * contributors to this software may be used to endorse or promote products 25 | * derived from this software without specific written permission. 26 | * 4. This software, including modifications and/or derivative works of this 27 | * software, must execute solely and exclusively on microcontroller or 28 | * microprocessor devices manufactured by or for STMicroelectronics. 29 | * 5. Redistribution and use of this software other than as permitted under 30 | * this license is void and will automatically terminate your rights under 31 | * this license. 32 | * 33 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 34 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 35 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 36 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 37 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 38 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 40 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 41 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 42 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 43 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 44 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | ****************************************************************************** 47 | */ 48 | /* Define to prevent recursive inclusion -------------------------------------*/ 49 | #ifndef __MAIN_H 50 | #define __MAIN_H 51 | /* Includes ------------------------------------------------------------------*/ 52 | 53 | /* Includes ------------------------------------------------------------------*/ 54 | /* USER CODE BEGIN Includes */ 55 | 56 | /* USER CODE END Includes */ 57 | 58 | /* Private define ------------------------------------------------------------*/ 59 | 60 | #define B1_Pin GPIO_PIN_13 61 | #define B1_GPIO_Port GPIOC 62 | #define USART_TX_Pin GPIO_PIN_2 63 | #define USART_TX_GPIO_Port GPIOA 64 | #define USART_RX_Pin GPIO_PIN_3 65 | #define USART_RX_GPIO_Port GPIOA 66 | #define TMS_Pin GPIO_PIN_13 67 | #define TMS_GPIO_Port GPIOA 68 | #define TCK_Pin GPIO_PIN_14 69 | #define TCK_GPIO_Port GPIOA 70 | #define SWO_Pin GPIO_PIN_3 71 | #define SWO_GPIO_Port GPIOB 72 | 73 | /* ########################## Assert Selection ############################## */ 74 | /** 75 | * @brief Uncomment the line below to expanse the "assert_param" macro in the 76 | * HAL drivers code 77 | */ 78 | /* #define USE_FULL_ASSERT 1U */ 79 | 80 | /* USER CODE BEGIN Private defines */ 81 | 82 | /* USER CODE END Private defines */ 83 | 84 | #ifdef __cplusplus 85 | extern "C" { 86 | #endif 87 | void _Error_Handler(char *, int); 88 | 89 | #define Error_Handler() _Error_Handler(__FILE__, __LINE__) 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | #endif /* __MAIN_H */ 103 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 104 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/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 | -------------------------------------------------------------------------------- /st7735-images-native-ver/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 | -------------------------------------------------------------------------------- /st7735-images-native-ver/fatfs/ffsystem.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /* Sample Code of OS Dependent Functions for FatFs */ 3 | /* (C)ChaN, 2017 */ 4 | /*------------------------------------------------------------------------*/ 5 | 6 | 7 | #include "ff.h" 8 | 9 | 10 | 11 | #if FF_USE_LFN == 3 /* Dynamic memory allocation */ 12 | 13 | /*------------------------------------------------------------------------*/ 14 | /* Allocate a memory block */ 15 | /*------------------------------------------------------------------------*/ 16 | 17 | void* ff_memalloc ( /* Returns pointer to the allocated memory block (null on not enough core) */ 18 | UINT msize /* Number of bytes to allocate */ 19 | ) 20 | { 21 | return malloc(msize); /* Allocate a new memory block with POSIX API */ 22 | } 23 | 24 | 25 | /*------------------------------------------------------------------------*/ 26 | /* Free a memory block */ 27 | /*------------------------------------------------------------------------*/ 28 | 29 | void ff_memfree ( 30 | void* mblock /* Pointer to the memory block to free (nothing to do for null) */ 31 | ) 32 | { 33 | free(mblock); /* Free the memory block with POSIX API */ 34 | } 35 | 36 | #endif 37 | 38 | 39 | 40 | #if FF_FS_REENTRANT /* Mutal exclusion */ 41 | 42 | /*------------------------------------------------------------------------*/ 43 | /* Create a Synchronization Object */ 44 | /*------------------------------------------------------------------------*/ 45 | /* This function is called in f_mount() function to create a new 46 | / synchronization object for the volume, such as semaphore and mutex. 47 | / When a 0 is returned, the f_mount() function fails with FR_INT_ERR. 48 | */ 49 | 50 | //const osMutexDef_t Mutex[FF_VOLUMES]; /* CMSIS-RTOS */ 51 | 52 | 53 | int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create the sync object */ 54 | BYTE vol, /* Corresponding volume (logical drive number) */ 55 | FF_SYNC_t* sobj /* Pointer to return the created sync object */ 56 | ) 57 | { 58 | /* Win32 */ 59 | *sobj = CreateMutex(NULL, FALSE, NULL); 60 | return (int)(*sobj != INVALID_HANDLE_VALUE); 61 | 62 | /* uITRON */ 63 | // T_CSEM csem = {TA_TPRI,1,1}; 64 | // *sobj = acre_sem(&csem); 65 | // return (int)(*sobj > 0); 66 | 67 | /* uC/OS-II */ 68 | // OS_ERR err; 69 | // *sobj = OSMutexCreate(0, &err); 70 | // return (int)(err == OS_NO_ERR); 71 | 72 | /* FreeRTOS */ 73 | // *sobj = xSemaphoreCreateMutex(); 74 | // return (int)(*sobj != NULL); 75 | 76 | /* CMSIS-RTOS */ 77 | // *sobj = osMutexCreate(Mutex + vol); 78 | // return (int)(*sobj != NULL); 79 | } 80 | 81 | 82 | /*------------------------------------------------------------------------*/ 83 | /* Delete a Synchronization Object */ 84 | /*------------------------------------------------------------------------*/ 85 | /* This function is called in f_mount() function to delete a synchronization 86 | / object that created with ff_cre_syncobj() function. When a 0 is returned, 87 | / the f_mount() function fails with FR_INT_ERR. 88 | */ 89 | 90 | int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to an error */ 91 | FF_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */ 92 | ) 93 | { 94 | /* Win32 */ 95 | return (int)CloseHandle(sobj); 96 | 97 | /* uITRON */ 98 | // return (int)(del_sem(sobj) == E_OK); 99 | 100 | /* uC/OS-II */ 101 | // OS_ERR err; 102 | // OSMutexDel(sobj, OS_DEL_ALWAYS, &err); 103 | // return (int)(err == OS_NO_ERR); 104 | 105 | /* FreeRTOS */ 106 | // vSemaphoreDelete(sobj); 107 | // return 1; 108 | 109 | /* CMSIS-RTOS */ 110 | // return (int)(osMutexDelete(sobj) == osOK); 111 | } 112 | 113 | 114 | /*------------------------------------------------------------------------*/ 115 | /* Request Grant to Access the Volume */ 116 | /*------------------------------------------------------------------------*/ 117 | /* This function is called on entering file functions to lock the volume. 118 | / When a 0 is returned, the file function fails with FR_TIMEOUT. 119 | */ 120 | 121 | int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */ 122 | FF_SYNC_t sobj /* Sync object to wait */ 123 | ) 124 | { 125 | /* Win32 */ 126 | return (int)(WaitForSingleObject(sobj, FF_FS_TIMEOUT) == WAIT_OBJECT_0); 127 | 128 | /* uITRON */ 129 | // return (int)(wai_sem(sobj) == E_OK); 130 | 131 | /* uC/OS-II */ 132 | // OS_ERR err; 133 | // OSMutexPend(sobj, FF_FS_TIMEOUT, &err)); 134 | // return (int)(err == OS_NO_ERR); 135 | 136 | /* FreeRTOS */ 137 | // return (int)(xSemaphoreTake(sobj, FF_FS_TIMEOUT) == pdTRUE); 138 | 139 | /* CMSIS-RTOS */ 140 | // return (int)(osMutexWait(sobj, FF_FS_TIMEOUT) == osOK); 141 | } 142 | 143 | 144 | /*------------------------------------------------------------------------*/ 145 | /* Release Grant to Access the Volume */ 146 | /*------------------------------------------------------------------------*/ 147 | /* This function is called on leaving file functions to unlock the volume. 148 | */ 149 | 150 | void ff_rel_grant ( 151 | FF_SYNC_t sobj /* Sync object to be signaled */ 152 | ) 153 | { 154 | /* Win32 */ 155 | ReleaseMutex(sobj); 156 | 157 | /* uITRON */ 158 | // sig_sem(sobj); 159 | 160 | /* uC/OS-II */ 161 | // OSMutexPost(sobj); 162 | 163 | /* FreeRTOS */ 164 | // xSemaphoreGive(sobj); 165 | 166 | /* CMSIS-RTOS */ 167 | // osMutexRelease(sobj); 168 | } 169 | 170 | #endif 171 | 172 | -------------------------------------------------------------------------------- /st7735-images-native-ver/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=SPI1 8 | Mcu.IP3=SYS 9 | Mcu.IP4=USART2 10 | Mcu.IPNb=5 11 | Mcu.Name=STM32F411R(C-E)Tx 12 | Mcu.Package=LQFP64 13 | Mcu.Pin0=PC13-ANTI_TAMP 14 | Mcu.Pin1=PC14-OSC32_IN 15 | Mcu.Pin10=PC7 16 | Mcu.Pin11=PA9 17 | Mcu.Pin12=PA13 18 | Mcu.Pin13=PA14 19 | Mcu.Pin14=PB3 20 | Mcu.Pin15=PB5 21 | Mcu.Pin16=PB6 22 | Mcu.Pin17=VP_SYS_VS_Systick 23 | Mcu.Pin2=PC15-OSC32_OUT 24 | Mcu.Pin3=PH0 - OSC_IN 25 | Mcu.Pin4=PH1 - OSC_OUT 26 | Mcu.Pin5=PA2 27 | Mcu.Pin6=PA3 28 | Mcu.Pin7=PA5 29 | Mcu.Pin8=PA6 30 | Mcu.Pin9=PA7 31 | Mcu.PinsNb=18 32 | Mcu.UserConstants= 33 | Mcu.UserName=STM32F411RETx 34 | MxCube.Version=4.23.0 35 | MxDb.Version=DB.4.0.230 36 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false 37 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false 38 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false 39 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false 40 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false 41 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:false\:false 42 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_0 43 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false 44 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:true 45 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false 46 | PA13.GPIOParameters=GPIO_Label 47 | PA13.GPIO_Label=TMS 48 | PA13.Locked=true 49 | PA13.Signal=SYS_JTMS-SWDIO 50 | PA14.GPIOParameters=GPIO_Label 51 | PA14.GPIO_Label=TCK 52 | PA14.Locked=true 53 | PA14.Signal=SYS_JTCK-SWCLK 54 | PA2.GPIOParameters=GPIO_Label 55 | PA2.GPIO_Label=USART_TX 56 | PA2.Locked=true 57 | PA2.Mode=Asynchronous 58 | PA2.Signal=USART2_TX 59 | PA3.GPIOParameters=GPIO_Label 60 | PA3.GPIO_Label=USART_RX 61 | PA3.Locked=true 62 | PA3.Mode=Asynchronous 63 | PA3.Signal=USART2_RX 64 | PA5.Mode=Full_Duplex_Master 65 | PA5.Signal=SPI1_SCK 66 | PA6.Mode=Full_Duplex_Master 67 | PA6.Signal=SPI1_MISO 68 | PA7.Mode=Full_Duplex_Master 69 | PA7.Signal=SPI1_MOSI 70 | PA9.Locked=true 71 | PA9.Signal=GPIO_Output 72 | PB3.GPIOParameters=GPIO_Label 73 | PB3.GPIO_Label=SWO 74 | PB3.Locked=true 75 | PB3.Signal=SYS_JTDO-SWO 76 | PB5.Locked=true 77 | PB5.Signal=GPIO_Output 78 | PB6.Locked=true 79 | PB6.Signal=GPIO_Output 80 | PC13-ANTI_TAMP.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI 81 | PC13-ANTI_TAMP.GPIO_Label=B1 [Blue PushButton] 82 | PC13-ANTI_TAMP.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING 83 | PC13-ANTI_TAMP.Locked=true 84 | PC13-ANTI_TAMP.Signal=GPXTI13 85 | PC14-OSC32_IN.Locked=true 86 | PC14-OSC32_IN.Signal=RCC_OSC32_IN 87 | PC15-OSC32_OUT.Locked=true 88 | PC15-OSC32_OUT.Signal=RCC_OSC32_OUT 89 | PC7.Locked=true 90 | PC7.Signal=GPIO_Output 91 | PCC.Checker=false 92 | PCC.Line=STM32F411 93 | PCC.MCU=STM32F411R(C-E)Tx 94 | PCC.PartNumber=STM32F411RETx 95 | PCC.Seq0=0 96 | PCC.Series=STM32F4 97 | PCC.Temperature=25 98 | PCC.Vdd=null 99 | PH0\ -\ OSC_IN.Locked=true 100 | PH0\ -\ OSC_IN.Signal=RCC_OSC_IN 101 | PH1\ -\ OSC_OUT.Locked=true 102 | PH1\ -\ OSC_OUT.Signal=RCC_OSC_OUT 103 | PinOutPanel.RotationAngle=0 104 | ProjectManager.AskForMigrate=true 105 | ProjectManager.BackupPrevious=false 106 | ProjectManager.CompilerOptimize=2 107 | ProjectManager.ComputerToolchain=false 108 | ProjectManager.CoupleFile=false 109 | ProjectManager.CustomerFirmwarePackage=/home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0 110 | ProjectManager.DefaultFWLocation=true 111 | ProjectManager.DeletePrevious=true 112 | ProjectManager.DeviceId=STM32F411RETx 113 | ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.18.0 114 | ProjectManager.FreePins=false 115 | ProjectManager.HalAssertFull=false 116 | ProjectManager.HeapSize=0x200 117 | ProjectManager.KeepUserCode=true 118 | ProjectManager.LastFirmware=true 119 | ProjectManager.LibraryCopy=2 120 | ProjectManager.PreviousToolchain= 121 | ProjectManager.ProjectBuild=false 122 | ProjectManager.ProjectFileName=main.ioc 123 | ProjectManager.ProjectName=main 124 | ProjectManager.StackSize=0x400 125 | ProjectManager.TargetToolchain=Makefile 126 | ProjectManager.ToolChainLocation= 127 | ProjectManager.UnderRoot=false 128 | 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 129 | RCC.48MHZClocksFreq_Value=84000000 130 | RCC.AHBFreq_Value=84000000 131 | RCC.APB1CLKDivider=RCC_HCLK_DIV2 132 | RCC.APB1Freq_Value=42000000 133 | RCC.APB1TimFreq_Value=84000000 134 | RCC.APB2Freq_Value=84000000 135 | RCC.APB2TimFreq_Value=84000000 136 | RCC.CortexFreq_Value=84000000 137 | RCC.EthernetFreq_Value=84000000 138 | RCC.FCLKCortexFreq_Value=84000000 139 | RCC.FLatency-AdvancedSettings=FLASH_LATENCY_2 140 | RCC.FamilyName=M 141 | RCC.HCLKFreq_Value=84000000 142 | RCC.HSE_VALUE=8000000 143 | RCC.HSI_VALUE=16000000 144 | RCC.I2SClocksFreq_Value=96000000 145 | 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,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLN,PLLP,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOInputMFreq_Value,VCOOutputFreq_Value,VcooutputI2S 146 | RCC.LSE_VALUE=32768 147 | RCC.LSI_VALUE=32000 148 | RCC.MCO2PinFreq_Value=84000000 149 | RCC.PLLCLKFreq_Value=84000000 150 | RCC.PLLN=336 151 | RCC.PLLP=RCC_PLLP_DIV4 152 | RCC.PLLQCLKFreq_Value=84000000 153 | RCC.RTCFreq_Value=32000 154 | RCC.RTCHSEDivFreq_Value=4000000 155 | RCC.SYSCLKFreq_VALUE=84000000 156 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 157 | RCC.VCOI2SOutputFreq_Value=192000000 158 | RCC.VCOInputFreq_Value=1000000 159 | RCC.VCOInputMFreq_Value=1000000 160 | RCC.VCOOutputFreq_Value=336000000 161 | RCC.VcooutputI2S=96000000 162 | SH.GPXTI13.0=GPIO_EXTI13 163 | SH.GPXTI13.ConfNb=1 164 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 165 | SPI1.CalculateBaudRate=5.25 MBits/s 166 | SPI1.Direction=SPI_DIRECTION_2LINES 167 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler 168 | SPI1.Mode=SPI_MODE_MASTER 169 | SPI1.VirtualType=VM_MASTER 170 | USART2.BaudRate=9600 171 | USART2.IPParameters=VirtualMode,BaudRate 172 | USART2.VirtualMode=VM_ASYNC 173 | VP_SYS_VS_Systick.Mode=SysTick 174 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 175 | board=NUCLEO-F411RE 176 | boardIOC=true 177 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/main.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | FATFS.IPParameters=_USE_STRFUNC,_USE_MKFS,_CODE_PAGE,_FS_EXFAT,_USE_LFN,_LFN_UNICODE 3 | FATFS._CODE_PAGE=437 4 | FATFS._FS_EXFAT=1 5 | FATFS._LFN_UNICODE=0 6 | FATFS._USE_LFN=2 7 | FATFS._USE_MKFS=0 8 | FATFS._USE_STRFUNC=0 9 | File.Version=6 10 | KeepUserPlacement=true 11 | Mcu.Family=STM32F4 12 | Mcu.IP0=FATFS 13 | Mcu.IP1=NVIC 14 | Mcu.IP2=RCC 15 | Mcu.IP3=SPI1 16 | Mcu.IP4=SYS 17 | Mcu.IP5=USART2 18 | Mcu.IPNb=6 19 | Mcu.Name=STM32F411R(C-E)Tx 20 | Mcu.Package=LQFP64 21 | Mcu.Pin0=PC13-ANTI_TAMP 22 | Mcu.Pin1=PC14-OSC32_IN 23 | Mcu.Pin10=PA13 24 | Mcu.Pin11=PA14 25 | Mcu.Pin12=PB3 26 | Mcu.Pin13=PB5 27 | Mcu.Pin14=VP_FATFS_VS_Generic 28 | Mcu.Pin15=VP_SYS_VS_Systick 29 | Mcu.Pin2=PC15-OSC32_OUT 30 | Mcu.Pin3=PH0 - OSC_IN 31 | Mcu.Pin4=PH1 - OSC_OUT 32 | Mcu.Pin5=PA2 33 | Mcu.Pin6=PA3 34 | Mcu.Pin7=PA5 35 | Mcu.Pin8=PA6 36 | Mcu.Pin9=PA7 37 | Mcu.PinsNb=16 38 | Mcu.UserConstants= 39 | Mcu.UserName=STM32F411RETx 40 | MxCube.Version=4.23.0 41 | MxDb.Version=DB.4.0.230 42 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false 43 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false 44 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false 45 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false 46 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false 47 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:false\:false 48 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_0 49 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false 50 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:true 51 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false 52 | PA13.GPIOParameters=GPIO_Label 53 | PA13.GPIO_Label=TMS 54 | PA13.Locked=true 55 | PA13.Signal=SYS_JTMS-SWDIO 56 | PA14.GPIOParameters=GPIO_Label 57 | PA14.GPIO_Label=TCK 58 | PA14.Locked=true 59 | PA14.Signal=SYS_JTCK-SWCLK 60 | PA2.GPIOParameters=GPIO_Label 61 | PA2.GPIO_Label=USART_TX 62 | PA2.Locked=true 63 | PA2.Mode=Asynchronous 64 | PA2.Signal=USART2_TX 65 | PA3.GPIOParameters=GPIO_Label 66 | PA3.GPIO_Label=USART_RX 67 | PA3.Locked=true 68 | PA3.Mode=Asynchronous 69 | PA3.Signal=USART2_RX 70 | PA5.Mode=Full_Duplex_Master 71 | PA5.Signal=SPI1_SCK 72 | PA6.Mode=Full_Duplex_Master 73 | PA6.Signal=SPI1_MISO 74 | PA7.Mode=Full_Duplex_Master 75 | PA7.Signal=SPI1_MOSI 76 | PB3.GPIOParameters=GPIO_Label 77 | PB3.GPIO_Label=SWO 78 | PB3.Locked=true 79 | PB3.Signal=SYS_JTDO-SWO 80 | PB5.Locked=true 81 | PB5.Signal=GPIO_Output 82 | PC13-ANTI_TAMP.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI 83 | PC13-ANTI_TAMP.GPIO_Label=B1 [Blue PushButton] 84 | PC13-ANTI_TAMP.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING 85 | PC13-ANTI_TAMP.Locked=true 86 | PC13-ANTI_TAMP.Signal=GPXTI13 87 | PC14-OSC32_IN.Locked=true 88 | PC14-OSC32_IN.Signal=RCC_OSC32_IN 89 | PC15-OSC32_OUT.Locked=true 90 | PC15-OSC32_OUT.Signal=RCC_OSC32_OUT 91 | PCC.Checker=false 92 | PCC.Line=STM32F411 93 | PCC.MCU=STM32F411R(C-E)Tx 94 | PCC.PartNumber=STM32F411RETx 95 | PCC.Seq0=0 96 | PCC.Series=STM32F4 97 | PCC.Temperature=25 98 | PCC.Vdd=null 99 | PH0\ -\ OSC_IN.Locked=true 100 | PH0\ -\ OSC_IN.Signal=RCC_OSC_IN 101 | PH1\ -\ OSC_OUT.Locked=true 102 | PH1\ -\ OSC_OUT.Signal=RCC_OSC_OUT 103 | PinOutPanel.RotationAngle=0 104 | ProjectManager.AskForMigrate=true 105 | ProjectManager.BackupPrevious=false 106 | ProjectManager.CompilerOptimize=2 107 | ProjectManager.ComputerToolchain=false 108 | ProjectManager.CoupleFile=false 109 | ProjectManager.CustomerFirmwarePackage=/home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0 110 | ProjectManager.DefaultFWLocation=true 111 | ProjectManager.DeletePrevious=true 112 | ProjectManager.DeviceId=STM32F411RETx 113 | ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.18.0 114 | ProjectManager.FreePins=false 115 | ProjectManager.HalAssertFull=false 116 | ProjectManager.HeapSize=0x200 117 | ProjectManager.KeepUserCode=true 118 | ProjectManager.LastFirmware=true 119 | ProjectManager.LibraryCopy=2 120 | ProjectManager.PreviousToolchain= 121 | ProjectManager.ProjectBuild=false 122 | ProjectManager.ProjectFileName=main.ioc 123 | ProjectManager.ProjectName=main 124 | ProjectManager.StackSize=0x400 125 | ProjectManager.TargetToolchain=Makefile 126 | ProjectManager.ToolChainLocation= 127 | ProjectManager.UnderRoot=false 128 | 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_FATFS_Init-FATFS-false-HAL 129 | RCC.48MHZClocksFreq_Value=84000000 130 | RCC.AHBFreq_Value=84000000 131 | RCC.APB1CLKDivider=RCC_HCLK_DIV2 132 | RCC.APB1Freq_Value=42000000 133 | RCC.APB1TimFreq_Value=84000000 134 | RCC.APB2Freq_Value=84000000 135 | RCC.APB2TimFreq_Value=84000000 136 | RCC.CortexFreq_Value=84000000 137 | RCC.EthernetFreq_Value=84000000 138 | RCC.FCLKCortexFreq_Value=84000000 139 | RCC.FLatency-AdvancedSettings=FLASH_LATENCY_2 140 | RCC.FamilyName=M 141 | RCC.HCLKFreq_Value=84000000 142 | RCC.HSE_VALUE=8000000 143 | RCC.HSI_VALUE=16000000 144 | RCC.I2SClocksFreq_Value=96000000 145 | 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,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLN,PLLP,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOInputMFreq_Value,VCOOutputFreq_Value,VcooutputI2S 146 | RCC.LSE_VALUE=32768 147 | RCC.LSI_VALUE=32000 148 | RCC.MCO2PinFreq_Value=84000000 149 | RCC.PLLCLKFreq_Value=84000000 150 | RCC.PLLN=336 151 | RCC.PLLP=RCC_PLLP_DIV4 152 | RCC.PLLQCLKFreq_Value=84000000 153 | RCC.RTCFreq_Value=32000 154 | RCC.RTCHSEDivFreq_Value=4000000 155 | RCC.SYSCLKFreq_VALUE=84000000 156 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 157 | RCC.VCOI2SOutputFreq_Value=192000000 158 | RCC.VCOInputFreq_Value=1000000 159 | RCC.VCOInputMFreq_Value=1000000 160 | RCC.VCOOutputFreq_Value=336000000 161 | RCC.VcooutputI2S=96000000 162 | SH.GPXTI13.0=GPIO_EXTI13 163 | SH.GPXTI13.ConfNb=1 164 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 165 | SPI1.CalculateBaudRate=5.25 MBits/s 166 | SPI1.Direction=SPI_DIRECTION_2LINES 167 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler 168 | SPI1.Mode=SPI_MODE_MASTER 169 | SPI1.VirtualType=VM_MASTER 170 | USART2.BaudRate=9600 171 | USART2.IPParameters=VirtualMode,BaudRate 172 | USART2.VirtualMode=VM_ASYNC 173 | VP_FATFS_VS_Generic.Mode=User_defined 174 | VP_FATFS_VS_Generic.Signal=FATFS_VS_Generic 175 | VP_SYS_VS_Systick.Mode=SysTick 176 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 177 | board=NUCLEO-F411RE 178 | boardIOC=true 179 | -------------------------------------------------------------------------------- /st7735-images-native-ver/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.23.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 | sdcard/sdcard.c \ 58 | st7735/st7735.c \ 59 | st7735/fonts.c \ 60 | Src/stm32f4xx_it.c \ 61 | Src/system_stm32f4xx.c \ 62 | Src/stm32f4xx_hal_msp.c \ 63 | fatfs/ff.c \ 64 | fatfs/diskio.c \ 65 | fatfs/ffunicode.c \ 66 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c \ 67 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \ 68 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \ 69 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \ 70 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \ 71 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \ 72 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \ 73 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \ 74 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \ 75 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \ 76 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \ 77 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \ 78 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \ 79 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \ 80 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c \ 81 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c 82 | 83 | # $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c 84 | # $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c 85 | 86 | # ASM sources 87 | ASM_SOURCES = \ 88 | startup_stm32f411xe.s 89 | 90 | 91 | ###################################### 92 | # firmware library 93 | ###################################### 94 | PERIFLIB_SOURCES = 95 | 96 | 97 | ####################################### 98 | # binaries 99 | ####################################### 100 | BINPATH=/usr/local/bin 101 | PREFIX=arm-none-eabi- 102 | CC = $(BINPATH)/$(PREFIX)gcc 103 | AS = $(BINPATH)/$(PREFIX)gcc -x assembler-with-cpp 104 | CP = $(BINPATH)/$(PREFIX)objcopy 105 | AR = $(BINPATH)/$(PREFIX)ar 106 | SZ = $(BINPATH)/$(PREFIX)size 107 | HEX = $(CP) -O ihex 108 | BIN = $(CP) -O binary -S 109 | 110 | ####################################### 111 | # CFLAGS 112 | ####################################### 113 | # cpu 114 | CPU = -mcpu=cortex-m4 115 | 116 | # fpu 117 | FPU = -mfpu=fpv4-sp-d16 118 | 119 | # float-abi 120 | FLOAT-ABI = -mfloat-abi=hard 121 | 122 | # mcu 123 | MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) 124 | 125 | # macros for gcc 126 | # AS defines 127 | AS_DEFS = 128 | 129 | # C defines 130 | C_DEFS = \ 131 | -DUSE_HAL_DRIVER \ 132 | -DSTM32F411xE 133 | 134 | 135 | # AS includes 136 | AS_INCLUDES = 137 | 138 | # C includes 139 | C_INCLUDES = \ 140 | -IInc \ 141 | -Isdcard \ 142 | -Ist7735 \ 143 | -Ifatfs \ 144 | -I$(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Inc \ 145 | -I$(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy \ 146 | -I$(FIRMWARE)/Drivers/CMSIS/Device/ST/STM32F4xx/Include \ 147 | -I$(FIRMWARE)/Drivers/CMSIS/Include 148 | 149 | 150 | # compile gcc flags 151 | ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 152 | 153 | CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 154 | 155 | ifeq ($(DEBUG), 1) 156 | CFLAGS += -g -gdwarf-2 157 | endif 158 | 159 | 160 | # Generate dependency information 161 | CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" 162 | 163 | 164 | ####################################### 165 | # LDFLAGS 166 | ####################################### 167 | # link script 168 | LDSCRIPT = STM32F411RETx_FLASH.ld 169 | 170 | # libraries 171 | LIBS = -lc -lm -lnosys 172 | LIBDIR = 173 | LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections 174 | 175 | # default action: build all 176 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin 177 | 178 | 179 | ####################################### 180 | # build the application 181 | ####################################### 182 | # list of objects 183 | OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) 184 | vpath %.c $(sort $(dir $(C_SOURCES))) 185 | # list of ASM program objects 186 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) 187 | vpath %.s $(sort $(dir $(ASM_SOURCES))) 188 | 189 | $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 190 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ 191 | 192 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) 193 | $(AS) -c $(CFLAGS) $< -o $@ 194 | 195 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile 196 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ 197 | $(SZ) $@ 198 | 199 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 200 | $(HEX) $< $@ 201 | 202 | $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 203 | $(BIN) $< $@ 204 | 205 | $(BUILD_DIR): 206 | mkdir $@ 207 | 208 | ####################################### 209 | # clean up 210 | ####################################### 211 | clean: 212 | -rm -fR .dep $(BUILD_DIR) 213 | 214 | flash: all 215 | st-flash --reset write build/$(TARGET).bin 0x8000000 216 | 217 | erase: 218 | st-flash --reset erase 219 | 220 | uart: 221 | screen /dev/ttyACM0 222 | 223 | ####################################### 224 | # dependencies 225 | ####################################### 226 | -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) 227 | 228 | # *** EOF *** 229 | -------------------------------------------------------------------------------- /st7735-images-native-ver/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_SPI_MspInit(SPI_HandleTypeDef* hspi) 79 | { 80 | 81 | GPIO_InitTypeDef GPIO_InitStruct; 82 | if(hspi->Instance==SPI1) 83 | { 84 | /* USER CODE BEGIN SPI1_MspInit 0 */ 85 | 86 | /* USER CODE END SPI1_MspInit 0 */ 87 | /* Peripheral clock enable */ 88 | __HAL_RCC_SPI1_CLK_ENABLE(); 89 | 90 | /**SPI1 GPIO Configuration 91 | PA5 ------> SPI1_SCK 92 | PA6 ------> SPI1_MISO 93 | PA7 ------> SPI1_MOSI 94 | */ 95 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; 96 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 97 | GPIO_InitStruct.Pull = GPIO_NOPULL; 98 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 99 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; 100 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 101 | 102 | /* USER CODE BEGIN SPI1_MspInit 1 */ 103 | 104 | /* USER CODE END SPI1_MspInit 1 */ 105 | } 106 | 107 | } 108 | 109 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) 110 | { 111 | 112 | if(hspi->Instance==SPI1) 113 | { 114 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ 115 | 116 | /* USER CODE END SPI1_MspDeInit 0 */ 117 | /* Peripheral clock disable */ 118 | __HAL_RCC_SPI1_CLK_DISABLE(); 119 | 120 | /**SPI1 GPIO Configuration 121 | PA5 ------> SPI1_SCK 122 | PA6 ------> SPI1_MISO 123 | PA7 ------> SPI1_MOSI 124 | */ 125 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); 126 | 127 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ 128 | 129 | /* USER CODE END SPI1_MspDeInit 1 */ 130 | } 131 | 132 | } 133 | 134 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) 135 | { 136 | 137 | GPIO_InitTypeDef GPIO_InitStruct; 138 | if(huart->Instance==USART2) 139 | { 140 | /* USER CODE BEGIN USART2_MspInit 0 */ 141 | 142 | /* USER CODE END USART2_MspInit 0 */ 143 | /* Peripheral clock enable */ 144 | __HAL_RCC_USART2_CLK_ENABLE(); 145 | 146 | /**USART2 GPIO Configuration 147 | PA2 ------> USART2_TX 148 | PA3 ------> USART2_RX 149 | */ 150 | GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin; 151 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 152 | GPIO_InitStruct.Pull = GPIO_PULLUP; 153 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 154 | GPIO_InitStruct.Alternate = GPIO_AF7_USART2; 155 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 156 | 157 | /* USER CODE BEGIN USART2_MspInit 1 */ 158 | 159 | /* USER CODE END USART2_MspInit 1 */ 160 | } 161 | 162 | } 163 | 164 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) 165 | { 166 | 167 | if(huart->Instance==USART2) 168 | { 169 | /* USER CODE BEGIN USART2_MspDeInit 0 */ 170 | 171 | /* USER CODE END USART2_MspDeInit 0 */ 172 | /* Peripheral clock disable */ 173 | __HAL_RCC_USART2_CLK_DISABLE(); 174 | 175 | /**USART2 GPIO Configuration 176 | PA2 ------> USART2_TX 177 | PA3 ------> USART2_RX 178 | */ 179 | HAL_GPIO_DeInit(GPIOA, USART_TX_Pin|USART_RX_Pin); 180 | 181 | /* USER CODE BEGIN USART2_MspDeInit 1 */ 182 | 183 | /* USER CODE END USART2_MspDeInit 1 */ 184 | } 185 | 186 | } 187 | 188 | /* USER CODE BEGIN 1 */ 189 | 190 | /* USER CODE END 1 */ 191 | 192 | /** 193 | * @} 194 | */ 195 | 196 | /** 197 | * @} 198 | */ 199 | 200 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 201 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/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 | Src/fatfs.c \ 58 | Src/user_diskio.c \ 59 | sdcard/sdcard.c \ 60 | Src/stm32f4xx_it.c \ 61 | Src/system_stm32f4xx.c \ 62 | Src/stm32f4xx_hal_msp.c \ 63 | $(FIRMWARE)/Middlewares/Third_Party/FatFs/src/ff.c \ 64 | $(FIRMWARE)/Middlewares/Third_Party/FatFs/src/diskio.c \ 65 | $(FIRMWARE)/Middlewares/Third_Party/FatFs/src/ff_gen_drv.c \ 66 | $(FIRMWARE)/Middlewares/Third_Party/FatFs/src/option/ccsbcs.c \ 67 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c \ 68 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \ 69 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \ 70 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \ 71 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \ 72 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \ 73 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \ 74 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \ 75 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \ 76 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \ 77 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \ 78 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \ 79 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \ 80 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \ 81 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c \ 82 | $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c 83 | 84 | # $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c 85 | # $(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c 86 | 87 | # ASM sources 88 | ASM_SOURCES = \ 89 | startup_stm32f411xe.s 90 | 91 | 92 | ###################################### 93 | # firmware library 94 | ###################################### 95 | PERIFLIB_SOURCES = 96 | 97 | 98 | ####################################### 99 | # binaries 100 | ####################################### 101 | BINPATH=/usr/bin 102 | PREFIX=arm-none-eabi- 103 | CC = $(BINPATH)/$(PREFIX)gcc 104 | AS = $(BINPATH)/$(PREFIX)gcc -x assembler-with-cpp 105 | CP = $(BINPATH)/$(PREFIX)objcopy 106 | AR = $(BINPATH)/$(PREFIX)ar 107 | SZ = $(BINPATH)/$(PREFIX)size 108 | HEX = $(CP) -O ihex 109 | BIN = $(CP) -O binary -S 110 | 111 | ####################################### 112 | # CFLAGS 113 | ####################################### 114 | # cpu 115 | CPU = -mcpu=cortex-m4 116 | 117 | # fpu 118 | FPU = -mfpu=fpv4-sp-d16 119 | 120 | # float-abi 121 | FLOAT-ABI = -mfloat-abi=hard 122 | 123 | # mcu 124 | MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) 125 | 126 | # macros for gcc 127 | # AS defines 128 | AS_DEFS = 129 | 130 | # C defines 131 | C_DEFS = \ 132 | -DUSE_HAL_DRIVER \ 133 | -DSTM32F411xE 134 | 135 | 136 | # AS includes 137 | AS_INCLUDES = 138 | 139 | # C includes 140 | C_INCLUDES = \ 141 | -IInc \ 142 | -Isdcard \ 143 | -I$(FIRMWARE)/Middlewares/Third_Party/FatFs/src \ 144 | -I$(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Inc \ 145 | -I$(FIRMWARE)/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy \ 146 | -I$(FIRMWARE)/Drivers/CMSIS/Device/ST/STM32F4xx/Include \ 147 | -I$(FIRMWARE)/Drivers/CMSIS/Include 148 | 149 | 150 | # compile gcc flags 151 | ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 152 | 153 | CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 154 | 155 | ifeq ($(DEBUG), 1) 156 | CFLAGS += -g -gdwarf-2 157 | endif 158 | 159 | 160 | # Generate dependency information 161 | CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" 162 | 163 | 164 | ####################################### 165 | # LDFLAGS 166 | ####################################### 167 | # link script 168 | LDSCRIPT = STM32F411RETx_FLASH.ld 169 | 170 | # libraries 171 | LIBS = -lc -lm -lnosys 172 | LIBDIR = 173 | LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections 174 | 175 | # default action: build all 176 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin 177 | 178 | 179 | ####################################### 180 | # build the application 181 | ####################################### 182 | # list of objects 183 | OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) 184 | vpath %.c $(sort $(dir $(C_SOURCES))) 185 | # list of ASM program objects 186 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) 187 | vpath %.s $(sort $(dir $(ASM_SOURCES))) 188 | 189 | $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 190 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ 191 | 192 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) 193 | $(AS) -c $(CFLAGS) $< -o $@ 194 | 195 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile 196 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ 197 | $(SZ) $@ 198 | 199 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 200 | $(HEX) $< $@ 201 | 202 | $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 203 | $(BIN) $< $@ 204 | 205 | $(BUILD_DIR): 206 | mkdir $@ 207 | 208 | ####################################### 209 | # clean up 210 | ####################################### 211 | clean: 212 | -rm -fR .dep $(BUILD_DIR) 213 | 214 | flash: all 215 | st-flash --reset write build/$(TARGET).bin 0x8000000 216 | 217 | erase: 218 | st-flash --reset erase 219 | 220 | uart: 221 | screen /dev/ttyACM0 222 | 223 | ####################################### 224 | # dependencies 225 | ####################################### 226 | -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) 227 | 228 | # *** EOF *** 229 | -------------------------------------------------------------------------------- /st7735-images-native-ver/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 | #define ST7735_IS_128X128 1 109 | #define ST7735_WIDTH 128 110 | #define ST7735_HEIGHT 128 111 | #define ST7735_XSTART 2 112 | #define ST7735_YSTART 3 113 | #define ST7735_ROTATION (ST7735_MADCTL_MX | ST7735_MADCTL_MY | ST7735_MADCTL_BGR) 114 | 115 | // 1.44" display, rotate right 116 | /* 117 | #define ST7735_IS_128X128 1 118 | #define ST7735_WIDTH 128 119 | #define ST7735_HEIGHT 128 120 | #define ST7735_XSTART 3 121 | #define ST7735_YSTART 2 122 | #define ST7735_ROTATION (ST7735_MADCTL_MY | ST7735_MADCTL_MV | ST7735_MADCTL_BGR) 123 | */ 124 | 125 | // 1.44" display, rotate left 126 | /* 127 | #define ST7735_IS_128X128 1 128 | #define ST7735_WIDTH 128 129 | #define ST7735_HEIGHT 128 130 | #define ST7735_XSTART 1 131 | #define ST7735_YSTART 2 132 | #define ST7735_ROTATION (ST7735_MADCTL_MX | ST7735_MADCTL_MV | ST7735_MADCTL_BGR) 133 | */ 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 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/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 International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | /* Includes ------------------------------------------------------------------*/ 50 | #include "stm32f4xx_hal.h" 51 | 52 | extern void _Error_Handler(char *, int); 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | /** 57 | * Initializes the Global MSP. 58 | */ 59 | void HAL_MspInit(void) 60 | { 61 | /* USER CODE BEGIN MspInit 0 */ 62 | 63 | /* USER CODE END MspInit 0 */ 64 | 65 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); 66 | 67 | /* System interrupt init*/ 68 | /* MemoryManagement_IRQn interrupt configuration */ 69 | HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); 70 | /* BusFault_IRQn interrupt configuration */ 71 | HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); 72 | /* UsageFault_IRQn interrupt configuration */ 73 | HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); 74 | /* SVCall_IRQn interrupt configuration */ 75 | HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0); 76 | /* DebugMonitor_IRQn interrupt configuration */ 77 | HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); 78 | /* PendSV_IRQn interrupt configuration */ 79 | HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); 80 | /* SysTick_IRQn interrupt configuration */ 81 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 82 | 83 | /* USER CODE BEGIN MspInit 1 */ 84 | 85 | /* USER CODE END MspInit 1 */ 86 | } 87 | 88 | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) 89 | { 90 | 91 | GPIO_InitTypeDef GPIO_InitStruct; 92 | if(hspi->Instance==SPI1) 93 | { 94 | /* USER CODE BEGIN SPI1_MspInit 0 */ 95 | 96 | /* USER CODE END SPI1_MspInit 0 */ 97 | /* Peripheral clock enable */ 98 | __HAL_RCC_SPI1_CLK_ENABLE(); 99 | 100 | /**SPI1 GPIO Configuration 101 | PA5 ------> SPI1_SCK 102 | PA6 ------> SPI1_MISO 103 | PA7 ------> SPI1_MOSI 104 | */ 105 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; 106 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 107 | GPIO_InitStruct.Pull = GPIO_NOPULL; 108 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 109 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; 110 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 111 | 112 | /* USER CODE BEGIN SPI1_MspInit 1 */ 113 | 114 | /* USER CODE END SPI1_MspInit 1 */ 115 | } 116 | 117 | } 118 | 119 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) 120 | { 121 | 122 | if(hspi->Instance==SPI1) 123 | { 124 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ 125 | 126 | /* USER CODE END SPI1_MspDeInit 0 */ 127 | /* Peripheral clock disable */ 128 | __HAL_RCC_SPI1_CLK_DISABLE(); 129 | 130 | /**SPI1 GPIO Configuration 131 | PA5 ------> SPI1_SCK 132 | PA6 ------> SPI1_MISO 133 | PA7 ------> SPI1_MOSI 134 | */ 135 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); 136 | 137 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ 138 | 139 | /* USER CODE END SPI1_MspDeInit 1 */ 140 | } 141 | 142 | } 143 | 144 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) 145 | { 146 | 147 | GPIO_InitTypeDef GPIO_InitStruct; 148 | if(huart->Instance==USART2) 149 | { 150 | /* USER CODE BEGIN USART2_MspInit 0 */ 151 | 152 | /* USER CODE END USART2_MspInit 0 */ 153 | /* Peripheral clock enable */ 154 | __HAL_RCC_USART2_CLK_ENABLE(); 155 | 156 | /**USART2 GPIO Configuration 157 | PA2 ------> USART2_TX 158 | PA3 ------> USART2_RX 159 | */ 160 | GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin; 161 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 162 | GPIO_InitStruct.Pull = GPIO_PULLUP; 163 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 164 | GPIO_InitStruct.Alternate = GPIO_AF7_USART2; 165 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 166 | 167 | /* USER CODE BEGIN USART2_MspInit 1 */ 168 | 169 | /* USER CODE END USART2_MspInit 1 */ 170 | } 171 | 172 | } 173 | 174 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) 175 | { 176 | 177 | if(huart->Instance==USART2) 178 | { 179 | /* USER CODE BEGIN USART2_MspDeInit 0 */ 180 | 181 | /* USER CODE END USART2_MspDeInit 0 */ 182 | /* Peripheral clock disable */ 183 | __HAL_RCC_USART2_CLK_DISABLE(); 184 | 185 | /**USART2 GPIO Configuration 186 | PA2 ------> USART2_TX 187 | PA3 ------> USART2_RX 188 | */ 189 | HAL_GPIO_DeInit(GPIOA, USART_TX_Pin|USART_RX_Pin); 190 | 191 | /* USER CODE BEGIN USART2_MspDeInit 1 */ 192 | 193 | /* USER CODE END USART2_MspDeInit 1 */ 194 | } 195 | 196 | } 197 | 198 | /* USER CODE BEGIN 1 */ 199 | 200 | /* USER CODE END 1 */ 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | /** 207 | * @} 208 | */ 209 | 210 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 211 | -------------------------------------------------------------------------------- /st7735-images-native-ver/mx.scratch: -------------------------------------------------------------------------------- 1 | 2 | 3 | /home/eax/projects/stm32/stm32-fatfs-examples/st7735-images-native-ver/\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 | Src/user_diskio.c 13 | Src/fatfs.c 14 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/option/syscall.c 15 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/option/ccsbcs.c 16 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/diskio.c 17 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/ff.c 18 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/ff_gen_drv.c 19 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/option/syscall.c 20 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/option/ccsbcs.c 21 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/diskio.c 22 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/ff.c 23 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/ff_gen_drv.c 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src 33 | 34 | 35 | 36 | 37 | 38 | main 39 | STM32F411RETx 40 | 0x200 41 | 0x400 42 | 43 | NUCLEO-F411RE 44 | 45 | true 46 | 47 | 48 | 0 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | USE_FULL_LL_DRIVER 67 | MBEDTLS_CONFIG_FILE="mbedtls_config.h" 68 | _TIMEVAL_DEFINED 69 | _SYS_TIME_H_ 70 | 71 | 72 | 73 | 74 | Inc 75 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Inc 76 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy 77 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include 78 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/CMSIS/Include 79 | 80 | 81 | 82 | 83 | 84 | false 85 | 86 | 87 | Drivers 88 | 89 | STM32F4xx_HAL_Driver 90 | 91 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c 92 | 93 | 94 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c 95 | 96 | 97 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c 98 | 99 | 100 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c 101 | 102 | 103 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c 104 | 105 | 106 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c 107 | 108 | 109 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c 110 | 111 | 112 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c 113 | 114 | 115 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c 116 | 117 | 118 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c 119 | 120 | 121 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c 122 | 123 | 124 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c 125 | 126 | 127 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c 128 | 129 | 130 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c 131 | 132 | 133 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c 134 | 135 | 136 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c 137 | 138 | 139 | 140 | CMSIS 141 | 142 | Src/system_stm32f4xx.c 143 | 144 | 145 | 146 | 147 | Application 148 | 149 | User 150 | 151 | Src/main.c 152 | 153 | 154 | 155 | Src/stm32f4xx_it.c 156 | 157 | 158 | 159 | Src/stm32f4xx_hal_msp.c 160 | 161 | 162 | 163 | 164 | 165 | Src 166 | 167 | main.c 168 | 169 | Src/main.c 170 | 171 | 172 | 173 | 174 | Src 175 | 176 | stm32f4xx_hal_msp.c 177 | 178 | Src/stm32f4xx_hal_msp.c 179 | 180 | 181 | 182 | 183 | Src 184 | 185 | stm32f4xx_it.c 186 | 187 | Src/stm32f4xx_it.c 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/Src/user_diskio.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file user_diskio.c 4 | * @brief This file includes a diskio driver skeleton to be completed by the user. 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 International N.V. 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted, provided that the following conditions are met: 17 | * 18 | * 1. Redistribution of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of other 24 | * contributors to this software may be used to endorse or promote products 25 | * derived from this software without specific written permission. 26 | * 4. This software, including modifications and/or derivative works of this 27 | * software, must execute solely and exclusively on microcontroller or 28 | * microprocessor devices manufactured by or for STMicroelectronics. 29 | * 5. Redistribution and use of this software other than as permitted under 30 | * this license is void and will automatically terminate your rights under 31 | * this license. 32 | * 33 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 34 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 35 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 36 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 37 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 38 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 40 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 41 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 42 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 43 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 44 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | ****************************************************************************** 47 | */ 48 | 49 | #ifdef USE_OBSOLETE_USER_CODE_SECTION_0 50 | /* 51 | * Warning: the user section 0 is no more in use (starting from CubeMx version 4.16.0) 52 | * To be suppressed in the future. 53 | * Kept to ensure backward compatibility with previous CubeMx versions when 54 | * migrating projects. 55 | * User code previously added there should be copied in the new user sections before 56 | * the section contents can be deleted. 57 | */ 58 | /* USER CODE BEGIN 0 */ 59 | /* USER CODE END 0 */ 60 | #endif 61 | 62 | /* USER CODE BEGIN DECL */ 63 | 64 | /* Includes ------------------------------------------------------------------*/ 65 | #include 66 | #include "ff_gen_drv.h" 67 | #include "sdcard.h" 68 | 69 | /* Private typedef -----------------------------------------------------------*/ 70 | /* Private define ------------------------------------------------------------*/ 71 | 72 | /* Private variables ---------------------------------------------------------*/ 73 | /* Disk status */ 74 | static volatile DSTATUS Stat = STA_NOINIT; 75 | 76 | /* USER CODE END DECL */ 77 | 78 | /* Private function prototypes -----------------------------------------------*/ 79 | DSTATUS USER_initialize (BYTE pdrv); 80 | DSTATUS USER_status (BYTE pdrv); 81 | DRESULT USER_read (BYTE pdrv, BYTE *buff, DWORD sector, UINT count); 82 | #if _USE_WRITE == 1 83 | DRESULT USER_write (BYTE pdrv, const BYTE *buff, DWORD sector, UINT count); 84 | #endif /* _USE_WRITE == 1 */ 85 | #if _USE_IOCTL == 1 86 | DRESULT USER_ioctl (BYTE pdrv, BYTE cmd, void *buff); 87 | #endif /* _USE_IOCTL == 1 */ 88 | 89 | Diskio_drvTypeDef USER_Driver = 90 | { 91 | USER_initialize, 92 | USER_status, 93 | USER_read, 94 | #if _USE_WRITE 95 | USER_write, 96 | #endif /* _USE_WRITE == 1 */ 97 | #if _USE_IOCTL == 1 98 | USER_ioctl, 99 | #endif /* _USE_IOCTL == 1 */ 100 | }; 101 | 102 | /* Private functions ---------------------------------------------------------*/ 103 | 104 | /** 105 | * @brief Initializes a Drive 106 | * @param pdrv: Physical drive number (0..) 107 | * @retval DSTATUS: Operation status 108 | */ 109 | DSTATUS USER_initialize ( 110 | BYTE pdrv /* Physical drive nmuber to identify the drive */ 111 | ) 112 | { 113 | /* USER CODE BEGIN INIT */ 114 | int code = SDCARD_Init(); 115 | if(code < 0) { 116 | return STA_NOINIT; 117 | } 118 | 119 | return 0; 120 | /* USER CODE END INIT */ 121 | } 122 | 123 | /** 124 | * @brief Gets Disk Status 125 | * @param pdrv: Physical drive number (0..) 126 | * @retval DSTATUS: Operation status 127 | */ 128 | DSTATUS USER_status ( 129 | BYTE pdrv /* Physical drive number to identify the drive */ 130 | ) 131 | { 132 | /* USER CODE BEGIN STATUS */ 133 | return 0; 134 | /* USER CODE END STATUS */ 135 | } 136 | 137 | /** 138 | * @brief Reads Sector(s) 139 | * @param pdrv: Physical drive number (0..) 140 | * @param *buff: Data buffer to store read data 141 | * @param sector: Sector address (LBA) 142 | * @param count: Number of sectors to read (1..128) 143 | * @retval DRESULT: Operation result 144 | */ 145 | DRESULT USER_read ( 146 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ 147 | BYTE *buff, /* Data buffer to store read data */ 148 | DWORD sector, /* Sector address in LBA */ 149 | UINT count /* Number of sectors to read */ 150 | ) 151 | { 152 | /* USER CODE BEGIN READ */ 153 | if(SDCARD_ReadBegin(sector) < 0) { 154 | return RES_ERROR; 155 | } 156 | 157 | while(count > 0) { 158 | if(SDCARD_ReadData(buff) < 0) { 159 | return RES_ERROR; 160 | } 161 | buff += 512; 162 | count--; 163 | } 164 | 165 | if(SDCARD_ReadEnd() < 0) { 166 | return RES_ERROR; 167 | } 168 | 169 | return RES_OK; 170 | /* USER CODE END READ */ 171 | } 172 | 173 | /** 174 | * @brief Writes Sector(s) 175 | * @param pdrv: Physical drive number (0..) 176 | * @param *buff: Data to be written 177 | * @param sector: Sector address (LBA) 178 | * @param count: Number of sectors to write (1..128) 179 | * @retval DRESULT: Operation result 180 | */ 181 | #if _USE_WRITE == 1 182 | DRESULT USER_write ( 183 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ 184 | const BYTE *buff, /* Data to be written */ 185 | DWORD sector, /* Sector address in LBA */ 186 | UINT count /* Number of sectors to write */ 187 | ) 188 | { 189 | /* USER CODE BEGIN WRITE */ 190 | if(SDCARD_WriteBegin(sector) < 0) { 191 | return RES_ERROR; 192 | } 193 | 194 | while(count > 0) { 195 | if(SDCARD_WriteData(buff) < 0) { 196 | return RES_ERROR; 197 | } 198 | 199 | buff += 512; 200 | count--; 201 | } 202 | 203 | if(SDCARD_WriteEnd() < 0) { 204 | return RES_ERROR; 205 | } 206 | 207 | return RES_OK; 208 | 209 | /* USER CODE END WRITE */ 210 | } 211 | #endif /* _USE_WRITE == 1 */ 212 | 213 | /** 214 | * @brief I/O control operation 215 | * @param pdrv: Physical drive number (0..) 216 | * @param cmd: Control code 217 | * @param *buff: Buffer to send/receive control data 218 | * @retval DRESULT: Operation result 219 | */ 220 | #if _USE_IOCTL == 1 221 | DRESULT USER_ioctl ( 222 | BYTE pdrv, /* Physical drive nmuber (0..) */ 223 | BYTE cmd, /* Control code */ 224 | void *buff /* Buffer to send/receive control data */ 225 | ) 226 | { 227 | /* USER CODE BEGIN IOCTL */ 228 | if(cmd == CTRL_SYNC) { 229 | return RES_OK; 230 | } else { 231 | // should never be called 232 | return RES_ERROR; 233 | } 234 | /* USER CODE END IOCTL */ 235 | } 236 | #endif /* _USE_IOCTL == 1 */ 237 | 238 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 239 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/mx.scratch: -------------------------------------------------------------------------------- 1 | 2 | 3 | /home/eax/projects/sandbox/stm32/stm32-fatfs/\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/Middlewares/Third_Party/FatFs/src 66 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/CMSIS/Include 67 | 68 | 69 | 70 | 71 | 72 | false 73 | 74 | 75 | Middlewares 76 | 77 | FatFs 78 | 79 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/option/syscall.c 80 | 81 | 82 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/option/ccsbcs.c 83 | 84 | 85 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/diskio.c 86 | 87 | 88 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/ff.c 89 | 90 | 91 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Middlewares/Third_Party/FatFs/src/ff_gen_drv.c 92 | 93 | 94 | 95 | 96 | Drivers 97 | 98 | STM32F4xx_HAL_Driver 99 | 100 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c 101 | 102 | 103 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c 104 | 105 | 106 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c 107 | 108 | 109 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c 110 | 111 | 112 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c 113 | 114 | 115 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c 116 | 117 | 118 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c 119 | 120 | 121 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c 122 | 123 | 124 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c 125 | 126 | 127 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c 128 | 129 | 130 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c 131 | 132 | 133 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c 134 | 135 | 136 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c 137 | 138 | 139 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c 140 | 141 | 142 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c 143 | 144 | 145 | /home/eax/STM32Cube/Repository/STM32Cube_FW_F4_V1.18.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c 146 | 147 | 148 | 149 | CMSIS 150 | 151 | Src/system_stm32f4xx.c 152 | 153 | 154 | 155 | 156 | Application 157 | 158 | User 159 | 160 | Src/main.c 161 | 162 | 163 | 164 | Src/user_diskio.c 165 | 166 | 167 | 168 | Src/fatfs.c 169 | 170 | 171 | 172 | Src/stm32f4xx_it.c 173 | 174 | 175 | 176 | Src/stm32f4xx_hal_msp.c 177 | 178 | 179 | 180 | 181 | 182 | Src 183 | 184 | user_diskio.c 185 | 186 | Src/user_diskio.c 187 | 188 | 189 | 190 | 191 | Src 192 | 193 | main.c 194 | 195 | Src/main.c 196 | 197 | 198 | 199 | 200 | Src 201 | 202 | stm32f4xx_hal_msp.c 203 | 204 | Src/stm32f4xx_hal_msp.c 205 | 206 | 207 | 208 | 209 | Src 210 | 211 | fatfs.c 212 | 213 | Src/fatfs.c 214 | 215 | 216 | 217 | 218 | Src 219 | 220 | stm32f4xx_it.c 221 | 222 | Src/stm32f4xx_it.c 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | -------------------------------------------------------------------------------- /st7735-images-native-ver/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-images-native-ver/fatfs/00history.txt: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | Revision history of FatFs module 3 | ---------------------------------------------------------------------------- 4 | 5 | R0.00 (February 26, 2006) 6 | 7 | Prototype. 8 | 9 | 10 | 11 | R0.01 (April 29, 2006) 12 | 13 | The first release. 14 | 15 | 16 | 17 | R0.02 (June 01, 2006) 18 | 19 | Added FAT12 support. 20 | Removed unbuffered mode. 21 | Fixed a problem on small (<32M) partition. 22 | 23 | 24 | 25 | R0.02a (June 10, 2006) 26 | 27 | Added a configuration option (_FS_MINIMUM). 28 | 29 | 30 | 31 | R0.03 (September 22, 2006) 32 | 33 | Added f_rename(). 34 | Changed option _FS_MINIMUM to _FS_MINIMIZE. 35 | 36 | 37 | 38 | R0.03a (December 11, 2006) 39 | 40 | Improved cluster scan algorithm to write files fast. 41 | Fixed f_mkdir() creates incorrect directory on FAT32. 42 | 43 | 44 | 45 | R0.04 (February 04, 2007) 46 | 47 | Added f_mkfs(). 48 | Supported multiple drive system. 49 | Changed some interfaces for multiple drive system. 50 | Changed f_mountdrv() to f_mount(). 51 | 52 | 53 | 54 | R0.04a (April 01, 2007) 55 | 56 | Supported multiple partitions on a physical drive. 57 | Added a capability of extending file size to f_lseek(). 58 | Added minimization level 3. 59 | Fixed an endian sensitive code in f_mkfs(). 60 | 61 | 62 | 63 | R0.04b (May 05, 2007) 64 | 65 | Added a configuration option _USE_NTFLAG. 66 | Added FSINFO support. 67 | Fixed DBCS name can result FR_INVALID_NAME. 68 | Fixed short seek (<= csize) collapses the file object. 69 | 70 | 71 | 72 | R0.05 (August 25, 2007) 73 | 74 | Changed arguments of f_read(), f_write() and f_mkfs(). 75 | Fixed f_mkfs() on FAT32 creates incorrect FSINFO. 76 | Fixed f_mkdir() on FAT32 creates incorrect directory. 77 | 78 | 79 | 80 | R0.05a (February 03, 2008) 81 | 82 | Added f_truncate() and f_utime(). 83 | Fixed off by one error at FAT sub-type determination. 84 | Fixed btr in f_read() can be mistruncated. 85 | Fixed cached sector is not flushed when create and close without write. 86 | 87 | 88 | 89 | R0.06 (April 01, 2008) 90 | 91 | Added fputc(), fputs(), fprintf() and fgets(). 92 | Improved performance of f_lseek() on moving to the same or following cluster. 93 | 94 | 95 | 96 | R0.07 (April 01, 2009) 97 | 98 | Merged Tiny-FatFs as a configuration option. (_FS_TINY) 99 | Added long file name feature. (_USE_LFN) 100 | Added multiple code page feature. (_CODE_PAGE) 101 | Added re-entrancy for multitask operation. (_FS_REENTRANT) 102 | Added auto cluster size selection to f_mkfs(). 103 | Added rewind option to f_readdir(). 104 | Changed result code of critical errors. 105 | Renamed string functions to avoid name collision. 106 | 107 | 108 | 109 | R0.07a (April 14, 2009) 110 | 111 | Septemberarated out OS dependent code on reentrant cfg. 112 | Added multiple sector size feature. 113 | 114 | 115 | 116 | R0.07c (June 21, 2009) 117 | 118 | Fixed f_unlink() can return FR_OK on error. 119 | Fixed wrong cache control in f_lseek(). 120 | Added relative path feature. 121 | Added f_chdir() and f_chdrive(). 122 | Added proper case conversion to extended character. 123 | 124 | 125 | 126 | R0.07e (November 03, 2009) 127 | 128 | Septemberarated out configuration options from ff.h to ffconf.h. 129 | Fixed f_unlink() fails to remove a sub-directory on _FS_RPATH. 130 | Fixed name matching error on the 13 character boundary. 131 | Added a configuration option, _LFN_UNICODE. 132 | Changed f_readdir() to return the SFN with always upper case on non-LFN cfg. 133 | 134 | 135 | 136 | R0.08 (May 15, 2010) 137 | 138 | Added a memory configuration option. (_USE_LFN = 3) 139 | Added file lock feature. (_FS_SHARE) 140 | Added fast seek feature. (_USE_FASTSEEK) 141 | Changed some types on the API, XCHAR->TCHAR. 142 | Changed .fname in the FILINFO structure on Unicode cfg. 143 | String functions support UTF-8 encoding files on Unicode cfg. 144 | 145 | 146 | 147 | R0.08a (August 16, 2010) 148 | 149 | Added f_getcwd(). (_FS_RPATH = 2) 150 | Added sector erase feature. (_USE_ERASE) 151 | Moved file lock semaphore table from fs object to the bss. 152 | Fixed f_mkfs() creates wrong FAT32 volume. 153 | 154 | 155 | 156 | R0.08b (January 15, 2011) 157 | 158 | Fast seek feature is also applied to f_read() and f_write(). 159 | f_lseek() reports required table size on creating CLMP. 160 | Extended format syntax of f_printf(). 161 | Ignores duplicated directory separators in given path name. 162 | 163 | 164 | 165 | R0.09 (September 06, 2011) 166 | 167 | f_mkfs() supports multiple partition to complete the multiple partition feature. 168 | Added f_fdisk(). 169 | 170 | 171 | 172 | R0.09a (August 27, 2012) 173 | 174 | Changed f_open() and f_opendir() reject null object pointer to avoid crash. 175 | Changed option name _FS_SHARE to _FS_LOCK. 176 | Fixed assertion failure due to OS/2 EA on FAT12/16 volume. 177 | 178 | 179 | 180 | R0.09b (January 24, 2013) 181 | 182 | Added f_setlabel() and f_getlabel(). 183 | 184 | 185 | 186 | R0.10 (October 02, 2013) 187 | 188 | Added selection of character encoding on the file. (_STRF_ENCODE) 189 | Added f_closedir(). 190 | Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO) 191 | Added forced mount feature with changes of f_mount(). 192 | Improved behavior of volume auto detection. 193 | Improved write throughput of f_puts() and f_printf(). 194 | Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write(). 195 | Fixed f_write() can be truncated when the file size is close to 4GB. 196 | Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect value on error. 197 | 198 | 199 | 200 | R0.10a (January 15, 2014) 201 | 202 | Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID) 203 | Added a configuration option of minimum sector size. (_MIN_SS) 204 | 2nd argument of f_rename() can have a drive number and it will be ignored. 205 | Fixed f_mount() with forced mount fails when drive number is >= 1. (appeared at R0.10) 206 | Fixed f_close() invalidates the file object without volume lock. 207 | Fixed f_closedir() returns but the volume lock is left acquired. (appeared at R0.10) 208 | Fixed creation of an entry with LFN fails on too many SFN collisions. (appeared at R0.07) 209 | 210 | 211 | 212 | R0.10b (May 19, 2014) 213 | 214 | Fixed a hard error in the disk I/O layer can collapse the directory entry. 215 | Fixed LFN entry is not deleted when delete/rename an object with lossy converted SFN. (appeared at R0.07) 216 | 217 | 218 | 219 | R0.10c (November 09, 2014) 220 | 221 | Added a configuration option for the platforms without RTC. (_FS_NORTC) 222 | Changed option name _USE_ERASE to _USE_TRIM. 223 | Fixed volume label created by Mac OS X cannot be retrieved with f_getlabel(). (appeared at R0.09b) 224 | Fixed a potential problem of FAT access that can appear on disk error. 225 | Fixed null pointer dereference on attempting to delete the root direcotry. (appeared at R0.08) 226 | 227 | 228 | 229 | R0.11 (February 09, 2015) 230 | 231 | Added f_findfirst(), f_findnext() and f_findclose(). (_USE_FIND) 232 | Fixed f_unlink() does not remove cluster chain of the file. (appeared at R0.10c) 233 | Fixed _FS_NORTC option does not work properly. (appeared at R0.10c) 234 | 235 | 236 | 237 | R0.11a (September 05, 2015) 238 | 239 | Fixed wrong media change can lead a deadlock at thread-safe configuration. 240 | Added code page 771, 860, 861, 863, 864, 865 and 869. (_CODE_PAGE) 241 | Removed some code pages actually not exist on the standard systems. (_CODE_PAGE) 242 | Fixed errors in the case conversion teble of code page 437 and 850 (ff.c). 243 | Fixed errors in the case conversion teble of Unicode (cc*.c). 244 | 245 | 246 | 247 | R0.12 (April 12, 2016) 248 | 249 | Added support for exFAT file system. (_FS_EXFAT) 250 | Added f_expand(). (_USE_EXPAND) 251 | Changed some members in FINFO structure and behavior of f_readdir(). 252 | Added an option _USE_CHMOD. 253 | Removed an option _WORD_ACCESS. 254 | Fixed errors in the case conversion table of Unicode (cc*.c). 255 | 256 | 257 | 258 | R0.12a (July 10, 2016) 259 | 260 | Added support for creating exFAT volume with some changes of f_mkfs(). 261 | Added a file open method FA_OPEN_APPEND. An f_lseek() following f_open() is no longer needed. 262 | f_forward() is available regardless of _FS_TINY. 263 | Fixed f_mkfs() creates wrong volume. (appeared at R0.12) 264 | Fixed wrong memory read in create_name(). (appeared at R0.12) 265 | Fixed compilation fails at some configurations, _USE_FASTSEEK and _USE_FORWARD. 266 | 267 | 268 | 269 | R0.12b (September 04, 2016) 270 | 271 | Made f_rename() be able to rename objects with the same name but case. 272 | Fixed an error in the case conversion teble of code page 866. (ff.c) 273 | Fixed writing data is truncated at the file offset 4GiB on the exFAT volume. (appeared at R0.12) 274 | Fixed creating a file in the root directory of exFAT volume can fail. (appeared at R0.12) 275 | Fixed f_mkfs() creating exFAT volume with too small cluster size can collapse unallocated memory. (appeared at R0.12) 276 | Fixed wrong object name can be returned when read directory at Unicode cfg. (appeared at R0.12) 277 | Fixed large file allocation/removing on the exFAT volume collapses allocation bitmap. (appeared at R0.12) 278 | Fixed some internal errors in f_expand() and f_lseek(). (appeared at R0.12) 279 | 280 | 281 | 282 | R0.12c (March 04, 2017) 283 | 284 | Improved write throughput at the fragmented file on the exFAT volume. 285 | Made memory usage for exFAT be able to be reduced as decreasing _MAX_LFN. 286 | Fixed successive f_getfree() can return wrong count on the FAT12/16 volume. (appeared at R0.12) 287 | Fixed configuration option _VOLUMES cannot be set 10. (appeared at R0.10c) 288 | 289 | 290 | 291 | R0.13 (May 21, 2017) 292 | 293 | Changed heading character of configuration keywords "_" to "FF_". 294 | Removed ASCII-only configuration, FF_CODE_PAGE = 1. Use FF_CODE_PAGE = 437 instead. 295 | Added f_setcp(), run-time code page configuration. (FF_CODE_PAGE = 0) 296 | Improved cluster allocation time on stretch a deep buried cluster chain. 297 | Improved processing time of f_mkdir() with large cluster size by using FF_USE_LFN = 3. 298 | Improved NoFatChain flag of the fragmented file to be set after it is truncated and got contiguous. 299 | Fixed archive attribute is left not set when a file on the exFAT volume is renamed. (appeared at R0.12) 300 | Fixed exFAT FAT entry can be collapsed when write or lseek operation to the existing file is done. (appeared at R0.12c) 301 | Fixed creating a file can fail when a new cluster allocation to the exFAT directory occures. (appeared at R0.12c) 302 | 303 | 304 | 305 | R0.13a (October 14, 2017) 306 | 307 | Added support for UTF-8 encoding on the API. (FF_LFN_UNICODE = 2) 308 | Added options for file name output buffer. (FF_LFN_BUF, FF_SFN_BUF). 309 | Added dynamic memory allocation option for working buffer of f_mkfs() and f_fdisk(). 310 | Fixed f_fdisk() and f_mkfs() create the partition table with wrong CHS parameters. (appeared at R0.09) 311 | Fixed f_unlink() can cause lost clusters at fragmented file on the exFAT volume. (appeared at R0.12c) 312 | Fixed f_setlabel() rejects some valid characters for exFAT volume. (appeared at R0.12) 313 | 314 | 315 | 316 | R0.13b (April 07, 2018) 317 | 318 | Added support for UTF-32 encoding on the API. (FF_LFN_UNICODE = 3) 319 | Added support for Unix style volume ID. (FF_STR_VOLUME_ID = 2) 320 | Fixed accesing any object on the exFAT root directory beyond the cluster boundary can fail. (appeared at R0.12c) 321 | Fixed f_setlabel() does not reject some invalid characters. (appeared at R0.09b) 322 | 323 | 324 | 325 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/Src/main.c: -------------------------------------------------------------------------------- 1 | /* Includes ------------------------------------------------------------------*/ 2 | #include "main.h" 3 | #include "stm32f4xx_hal.h" 4 | 5 | /* USER CODE BEGIN Includes */ 6 | /* vim: set ai et ts=4 sw=4: */ 7 | #include 8 | #include 9 | #include "fatfs.h" 10 | #include "ff.h" 11 | /* USER CODE END Includes */ 12 | 13 | /* Private variables ---------------------------------------------------------*/ 14 | SPI_HandleTypeDef hspi1; 15 | 16 | UART_HandleTypeDef huart2; 17 | 18 | /* USER CODE BEGIN PV */ 19 | /* Private variables ---------------------------------------------------------*/ 20 | 21 | /* USER CODE END PV */ 22 | 23 | /* Private function prototypes -----------------------------------------------*/ 24 | void SystemClock_Config(void); 25 | static void MX_GPIO_Init(void); 26 | static void MX_SPI1_Init(void); 27 | static void MX_USART2_UART_Init(void); 28 | 29 | /* USER CODE BEGIN PFP */ 30 | /* Private function prototypes -----------------------------------------------*/ 31 | 32 | /* USER CODE END PFP */ 33 | 34 | /* USER CODE BEGIN 0 */ 35 | 36 | void UART_Printf(const char* fmt, ...) { 37 | char buff[256]; 38 | va_list args; 39 | va_start(args, fmt); 40 | vsnprintf(buff, sizeof(buff), fmt, args); 41 | HAL_UART_Transmit(&huart2, (uint8_t*)buff, strlen(buff), HAL_MAX_DELAY); 42 | va_end(args); 43 | } 44 | 45 | void init() { 46 | FATFS fs; 47 | FRESULT res; 48 | UART_Printf("Ready!\r\n"); 49 | 50 | // mount the default drive 51 | res = f_mount(&fs, "", 0); 52 | if(res != FR_OK) { 53 | UART_Printf("f_mount() failed, res = %d\r\n", res); 54 | return; 55 | } 56 | 57 | UART_Printf("f_mount() done!\r\n"); 58 | 59 | uint32_t freeClust; 60 | FATFS* fs_ptr = &fs; 61 | res = f_getfree("", &freeClust, &fs_ptr); // Warning! This fills fs.n_fatent and fs.csize! 62 | if(res != FR_OK) { 63 | UART_Printf("f_getfree() failed, res = %d\r\n", res); 64 | return; 65 | } 66 | 67 | UART_Printf("f_getfree() done!\r\n"); 68 | 69 | uint32_t totalBlocks = (fs.n_fatent - 2) * fs.csize; 70 | uint32_t freeBlocks = freeClust * fs.csize; 71 | 72 | UART_Printf("Total blocks: %lu (%lu Mb)\r\n", totalBlocks, totalBlocks / 2000); 73 | UART_Printf("Free blocks: %lu (%lu Mb)\r\n", freeBlocks, freeBlocks / 2000); 74 | 75 | DIR dir; 76 | res = f_opendir(&dir, "/"); 77 | if(res != FR_OK) { 78 | UART_Printf("f_opendir() failed, res = %d\r\n", res); 79 | return; 80 | } 81 | 82 | FILINFO fileInfo; 83 | uint32_t totalFiles = 0; 84 | uint32_t totalDirs = 0; 85 | UART_Printf("--------\r\nRoot directory:\r\n"); 86 | for(;;) { 87 | res = f_readdir(&dir, &fileInfo); 88 | if((res != FR_OK) || (fileInfo.fname[0] == '\0')) { 89 | break; 90 | } 91 | 92 | if(fileInfo.fattrib & AM_DIR) { 93 | UART_Printf(" DIR %s\r\n", fileInfo.fname); 94 | totalDirs++; 95 | } else { 96 | UART_Printf(" FILE %s\r\n", fileInfo.fname); 97 | totalFiles++; 98 | } 99 | } 100 | 101 | UART_Printf("(total: %lu dirs, %lu files)\r\n--------\r\n", totalDirs, totalFiles); 102 | 103 | res = f_closedir(&dir); 104 | if(res != FR_OK) { 105 | UART_Printf("f_closedir() failed, res = %d\r\n", res); 106 | return; 107 | } 108 | 109 | UART_Printf("Writing to log.txt...\r\n"); 110 | 111 | char writeBuff[128]; 112 | snprintf(writeBuff, sizeof(writeBuff), "Total blocks: %lu (%lu Mb); Free blocks: %lu (%lu Mb)\r\n", 113 | totalBlocks, totalBlocks / 2000, 114 | freeBlocks, freeBlocks / 2000); 115 | 116 | FIL logFile; 117 | res = f_open(&logFile, "log.txt", FA_OPEN_APPEND | FA_WRITE); 118 | if(res != FR_OK) { 119 | UART_Printf("f_open() failed, res = %d\r\n", res); 120 | return; 121 | } 122 | 123 | unsigned int bytesToWrite = strlen(writeBuff); 124 | unsigned int bytesWritten; 125 | res = f_write(&logFile, writeBuff, bytesToWrite, &bytesWritten); 126 | if(res != FR_OK) { 127 | UART_Printf("f_write() failed, res = %d\r\n", res); 128 | return; 129 | } 130 | 131 | if(bytesWritten < bytesToWrite) { 132 | UART_Printf("WARNING! Disk is full, bytesToWrite = %lu, bytesWritten = %lu\r\n", bytesToWrite, bytesWritten); 133 | } 134 | 135 | res = f_close(&logFile); 136 | if(res != FR_OK) { 137 | UART_Printf("f_close() failed, res = %d\r\n", res); 138 | return; 139 | } 140 | 141 | UART_Printf("Reading file...\r\n"); 142 | FIL msgFile; 143 | res = f_open(&msgFile, "log.txt", FA_READ); 144 | if(res != FR_OK) { 145 | UART_Printf("f_open() failed, res = %d\r\n", res); 146 | return; 147 | } 148 | 149 | char readBuff[128]; 150 | unsigned int bytesRead; 151 | res = f_read(&msgFile, readBuff, sizeof(readBuff)-1, &bytesRead); 152 | if(res != FR_OK) { 153 | UART_Printf("f_read() failed, res = %d\r\n", res); 154 | return; 155 | } 156 | 157 | readBuff[bytesRead] = '\0'; 158 | UART_Printf("```\r\n%s\r\n```\r\n", readBuff); 159 | 160 | res = f_close(&msgFile); 161 | if(res != FR_OK) { 162 | UART_Printf("f_close() failed, res = %d\r\n", res); 163 | return; 164 | } 165 | 166 | // Unmount 167 | res = f_mount(NULL, "", 0); 168 | if(res != FR_OK) { 169 | UART_Printf("Unmount failed, res = %d\r\n", res); 170 | return; 171 | } 172 | 173 | UART_Printf("Done!\r\n"); 174 | } 175 | 176 | void loop() { 177 | HAL_Delay(500); 178 | } 179 | 180 | /* USER CODE END 0 */ 181 | 182 | int main(void) 183 | { 184 | 185 | /* USER CODE BEGIN 1 */ 186 | 187 | /* USER CODE END 1 */ 188 | 189 | /* MCU Configuration----------------------------------------------------------*/ 190 | 191 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 192 | HAL_Init(); 193 | 194 | /* USER CODE BEGIN Init */ 195 | 196 | /* USER CODE END Init */ 197 | 198 | /* Configure the system clock */ 199 | SystemClock_Config(); 200 | 201 | /* USER CODE BEGIN SysInit */ 202 | 203 | /* USER CODE END SysInit */ 204 | 205 | /* Initialize all configured peripherals */ 206 | MX_GPIO_Init(); 207 | MX_SPI1_Init(); 208 | MX_USART2_UART_Init(); 209 | MX_FATFS_Init(); 210 | 211 | /* USER CODE BEGIN 2 */ 212 | 213 | /* USER CODE END 2 */ 214 | 215 | /* Infinite loop */ 216 | /* USER CODE BEGIN WHILE */ 217 | init(); 218 | while (1) 219 | { 220 | loop(); 221 | /* USER CODE END WHILE */ 222 | 223 | /* USER CODE BEGIN 3 */ 224 | 225 | } 226 | /* USER CODE END 3 */ 227 | 228 | } 229 | 230 | /** System Clock Configuration 231 | */ 232 | void SystemClock_Config(void) 233 | { 234 | 235 | RCC_OscInitTypeDef RCC_OscInitStruct; 236 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 237 | 238 | /**Configure the main internal regulator output voltage 239 | */ 240 | __HAL_RCC_PWR_CLK_ENABLE(); 241 | 242 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); 243 | 244 | /**Initializes the CPU, AHB and APB busses clocks 245 | */ 246 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 247 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 248 | RCC_OscInitStruct.HSICalibrationValue = 16; 249 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 250 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; 251 | RCC_OscInitStruct.PLL.PLLM = 16; 252 | RCC_OscInitStruct.PLL.PLLN = 336; 253 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; 254 | RCC_OscInitStruct.PLL.PLLQ = 4; 255 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 256 | { 257 | _Error_Handler(__FILE__, __LINE__); 258 | } 259 | 260 | /**Initializes the CPU, AHB and APB busses clocks 261 | */ 262 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 263 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 264 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 265 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 266 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; 267 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 268 | 269 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) 270 | { 271 | _Error_Handler(__FILE__, __LINE__); 272 | } 273 | 274 | /**Configure the Systick interrupt time 275 | */ 276 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); 277 | 278 | /**Configure the Systick 279 | */ 280 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); 281 | 282 | /* SysTick_IRQn interrupt configuration */ 283 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 284 | } 285 | 286 | /* SPI1 init function */ 287 | static void MX_SPI1_Init(void) 288 | { 289 | 290 | /* SPI1 parameter configuration*/ 291 | hspi1.Instance = SPI1; 292 | hspi1.Init.Mode = SPI_MODE_MASTER; 293 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; 294 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 295 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 296 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 297 | hspi1.Init.NSS = SPI_NSS_SOFT; 298 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; 299 | hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; 300 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; 301 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 302 | hspi1.Init.CRCPolynomial = 10; 303 | if (HAL_SPI_Init(&hspi1) != HAL_OK) 304 | { 305 | _Error_Handler(__FILE__, __LINE__); 306 | } 307 | 308 | } 309 | 310 | /* USART2 init function */ 311 | static void MX_USART2_UART_Init(void) 312 | { 313 | 314 | huart2.Instance = USART2; 315 | huart2.Init.BaudRate = 9600; 316 | huart2.Init.WordLength = UART_WORDLENGTH_8B; 317 | huart2.Init.StopBits = UART_STOPBITS_1; 318 | huart2.Init.Parity = UART_PARITY_NONE; 319 | huart2.Init.Mode = UART_MODE_TX_RX; 320 | huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; 321 | huart2.Init.OverSampling = UART_OVERSAMPLING_16; 322 | if (HAL_UART_Init(&huart2) != HAL_OK) 323 | { 324 | _Error_Handler(__FILE__, __LINE__); 325 | } 326 | 327 | } 328 | 329 | /** Configure pins as 330 | * Analog 331 | * Input 332 | * Output 333 | * EVENT_OUT 334 | * EXTI 335 | */ 336 | static void MX_GPIO_Init(void) 337 | { 338 | 339 | GPIO_InitTypeDef GPIO_InitStruct; 340 | 341 | /* GPIO Ports Clock Enable */ 342 | __HAL_RCC_GPIOC_CLK_ENABLE(); 343 | __HAL_RCC_GPIOH_CLK_ENABLE(); 344 | __HAL_RCC_GPIOA_CLK_ENABLE(); 345 | __HAL_RCC_GPIOB_CLK_ENABLE(); 346 | 347 | /*Configure GPIO pin Output Level */ 348 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_RESET); 349 | 350 | /*Configure GPIO pin : B1_Pin */ 351 | GPIO_InitStruct.Pin = B1_Pin; 352 | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; 353 | GPIO_InitStruct.Pull = GPIO_NOPULL; 354 | HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); 355 | 356 | /*Configure GPIO pin : PB5 */ 357 | GPIO_InitStruct.Pin = GPIO_PIN_5; 358 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 359 | GPIO_InitStruct.Pull = GPIO_NOPULL; 360 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 361 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 362 | 363 | } 364 | 365 | /* USER CODE BEGIN 4 */ 366 | 367 | /* USER CODE END 4 */ 368 | 369 | /** 370 | * @brief This function is executed in case of error occurrence. 371 | * @param None 372 | * @retval None 373 | */ 374 | void _Error_Handler(char * file, int line) 375 | { 376 | /* USER CODE BEGIN Error_Handler_Debug */ 377 | /* User can add his own implementation to report the HAL error return state */ 378 | while(1) 379 | { 380 | } 381 | /* USER CODE END Error_Handler_Debug */ 382 | } 383 | 384 | #ifdef USE_FULL_ASSERT 385 | 386 | /** 387 | * @brief Reports the name of the source file and the source line number 388 | * where the assert_param error has occurred. 389 | * @param file: pointer to the source file name 390 | * @param line: assert_param error line source number 391 | * @retval None 392 | */ 393 | void assert_failed(uint8_t* file, uint32_t line) 394 | { 395 | /* USER CODE BEGIN 6 */ 396 | /* User can add his own implementation to report the file name and line number, 397 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 398 | /* USER CODE END 6 */ 399 | 400 | } 401 | 402 | #endif 403 | 404 | /** 405 | * @} 406 | */ 407 | 408 | /** 409 | * @} 410 | */ 411 | 412 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 413 | -------------------------------------------------------------------------------- /st7735-images-native-ver/fatfs/ffconf.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------/ 2 | / FatFs - Configuration file 3 | /---------------------------------------------------------------------------*/ 4 | 5 | #define FFCONF_DEF 63463 /* Revision ID */ 6 | 7 | /*---------------------------------------------------------------------------/ 8 | / Function Configurations 9 | /---------------------------------------------------------------------------*/ 10 | 11 | #define FF_FS_READONLY 0 12 | /* This option switches read-only configuration. (0:Read/Write or 1:Read-only) 13 | / Read-only configuration removes writing API functions, f_write(), f_sync(), 14 | / f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree() 15 | / and optional writing functions as well. */ 16 | 17 | 18 | #define FF_FS_MINIMIZE 0 19 | /* This option defines minimization level to remove some basic API functions. 20 | / 21 | / 0: Basic functions are fully enabled. 22 | / 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename() 23 | / are removed. 24 | / 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1. 25 | / 3: f_lseek() function is removed in addition to 2. */ 26 | 27 | 28 | #define FF_USE_STRFUNC 0 29 | /* This option switches string functions, f_gets(), f_putc(), f_puts() and f_printf(). 30 | / 31 | / 0: Disable string functions. 32 | / 1: Enable without LF-CRLF conversion. 33 | / 2: Enable with LF-CRLF conversion. */ 34 | 35 | 36 | #define FF_USE_FIND 0 37 | /* This option switches filtered directory read functions, f_findfirst() and 38 | / f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */ 39 | 40 | 41 | #define FF_USE_MKFS 0 42 | /* This option switches f_mkfs() function. (0:Disable or 1:Enable) */ 43 | 44 | 45 | #define FF_USE_FASTSEEK 0 46 | /* This option switches fast seek function. (0:Disable or 1:Enable) */ 47 | 48 | 49 | #define FF_USE_EXPAND 0 50 | /* This option switches f_expand function. (0:Disable or 1:Enable) */ 51 | 52 | 53 | #define FF_USE_CHMOD 0 54 | /* This option switches attribute manipulation functions, f_chmod() and f_utime(). 55 | / (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */ 56 | 57 | 58 | #define FF_USE_LABEL 0 59 | /* This option switches volume label functions, f_getlabel() and f_setlabel(). 60 | / (0:Disable or 1:Enable) */ 61 | 62 | 63 | #define FF_USE_FORWARD 0 64 | /* This option switches f_forward() function. (0:Disable or 1:Enable) */ 65 | 66 | 67 | /*---------------------------------------------------------------------------/ 68 | / Locale and Namespace Configurations 69 | /---------------------------------------------------------------------------*/ 70 | 71 | #define FF_CODE_PAGE 932 72 | /* This option specifies the OEM code page to be used on the target system. 73 | / Incorrect code page setting can cause a file open failure. 74 | / 75 | / 437 - U.S. 76 | / 720 - Arabic 77 | / 737 - Greek 78 | / 771 - KBL 79 | / 775 - Baltic 80 | / 850 - Latin 1 81 | / 852 - Latin 2 82 | / 855 - Cyrillic 83 | / 857 - Turkish 84 | / 860 - Portuguese 85 | / 861 - Icelandic 86 | / 862 - Hebrew 87 | / 863 - Canadian French 88 | / 864 - Arabic 89 | / 865 - Nordic 90 | / 866 - Russian 91 | / 869 - Greek 2 92 | / 932 - Japanese (DBCS) 93 | / 936 - Simplified Chinese (DBCS) 94 | / 949 - Korean (DBCS) 95 | / 950 - Traditional Chinese (DBCS) 96 | / 0 - Include all code pages above and configured by f_setcp() 97 | */ 98 | 99 | 100 | #define FF_USE_LFN 1 101 | #define FF_MAX_LFN 255 102 | /* The FF_USE_LFN switches the support for LFN (long file name). 103 | / 104 | / 0: Disable LFN. FF_MAX_LFN has no effect. 105 | / 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe. 106 | / 2: Enable LFN with dynamic working buffer on the STACK. 107 | / 3: Enable LFN with dynamic working buffer on the HEAP. 108 | / 109 | / To enable the LFN, ffunicode.c needs to be added to the project. The LFN function 110 | / requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and 111 | / additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled. 112 | / The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can 113 | / be in range of 12 to 255. It is recommended to be set 255 to fully support LFN 114 | / specification. 115 | / When use stack for the working buffer, take care on stack overflow. When use heap 116 | / memory for the working buffer, memory management functions, ff_memalloc() and 117 | / ff_memfree() in ffsystem.c, need to be added to the project. */ 118 | 119 | 120 | #define FF_LFN_UNICODE 2 121 | /* This option switches the character encoding on the API when LFN is enabled. 122 | / 123 | / 0: ANSI/OEM in current CP (TCHAR = char) 124 | / 1: Unicode in UTF-16 (TCHAR = WCHAR) 125 | / 2: Unicode in UTF-8 (TCHAR = char) 126 | / 3: Unicode in UTF-32 (TCHAR = DWORD) 127 | / 128 | / Also behavior of string I/O functions will be affected by this option. 129 | / When LFN is not enabled, this option has no effect. */ 130 | 131 | 132 | #define FF_LFN_BUF 255 133 | #define FF_SFN_BUF 12 134 | /* This set of options defines size of file name members in the FILINFO structure 135 | / which is used to read out directory items. These values should be suffcient for 136 | / the file names to read. The maximum possible length of the read file name depends 137 | / on character encoding. When LFN is not enabled, these options have no effect. */ 138 | 139 | 140 | #define FF_STRF_ENCODE 3 141 | /* When FF_LFN_UNICODE >= 1 with LFN enabled, string I/O functions, f_gets(), 142 | / f_putc(), f_puts and f_printf() convert the character encoding in it. 143 | / This option selects assumption of character encoding ON THE FILE to be 144 | / read/written via those functions. 145 | / 146 | / 0: ANSI/OEM in current CP 147 | / 1: Unicode in UTF-16LE 148 | / 2: Unicode in UTF-16BE 149 | / 3: Unicode in UTF-8 150 | */ 151 | 152 | 153 | #define FF_FS_RPATH 0 154 | /* This option configures support for relative path. 155 | / 156 | / 0: Disable relative path and remove related functions. 157 | / 1: Enable relative path. f_chdir() and f_chdrive() are available. 158 | / 2: f_getcwd() function is available in addition to 1. 159 | */ 160 | 161 | 162 | /*---------------------------------------------------------------------------/ 163 | / Drive/Volume Configurations 164 | /---------------------------------------------------------------------------*/ 165 | 166 | #define FF_VOLUMES 1 167 | /* Number of volumes (logical drives) to be used. (1-10) */ 168 | 169 | 170 | #define FF_STR_VOLUME_ID 0 171 | #define FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3" 172 | /* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings. 173 | / When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive 174 | / number in the path name. FF_VOLUME_STRS defines the volume ID strings for each 175 | / logical drives. Number of items must not be less than FF_VOLUMES. Valid 176 | / characters for the volume ID strings are A-Z, a-z and 0-9, however, they are 177 | / compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is 178 | / not defined, a user defined volume string table needs to be defined as: 179 | / 180 | / const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",... 181 | */ 182 | 183 | 184 | #define FF_MULTI_PARTITION 0 185 | /* This option switches support for multiple volumes on the physical drive. 186 | / By default (0), each logical drive number is bound to the same physical drive 187 | / number and only an FAT volume found on the physical drive will be mounted. 188 | / When this function is enabled (1), each logical drive number can be bound to 189 | / arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk() 190 | / funciton will be available. */ 191 | 192 | 193 | #define FF_MIN_SS 512 194 | #define FF_MAX_SS 512 195 | /* This set of options configures the range of sector size to be supported. (512, 196 | / 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and 197 | / harddisk. But a larger value may be required for on-board flash memory and some 198 | / type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured 199 | / for variable sector size mode and disk_ioctl() function needs to implement 200 | / GET_SECTOR_SIZE command. */ 201 | 202 | 203 | #define FF_USE_TRIM 0 204 | /* This option switches support for ATA-TRIM. (0:Disable or 1:Enable) 205 | / To enable Trim function, also CTRL_TRIM command should be implemented to the 206 | / disk_ioctl() function. */ 207 | 208 | 209 | #define FF_FS_NOFSINFO 0 210 | /* If you need to know correct free space on the FAT32 volume, set bit 0 of this 211 | / option, and f_getfree() function at first time after volume mount will force 212 | / a full FAT scan. Bit 1 controls the use of last allocated cluster number. 213 | / 214 | / bit0=0: Use free cluster count in the FSINFO if available. 215 | / bit0=1: Do not trust free cluster count in the FSINFO. 216 | / bit1=0: Use last allocated cluster number in the FSINFO if available. 217 | / bit1=1: Do not trust last allocated cluster number in the FSINFO. 218 | */ 219 | 220 | 221 | 222 | /*---------------------------------------------------------------------------/ 223 | / System Configurations 224 | /---------------------------------------------------------------------------*/ 225 | 226 | #define FF_FS_TINY 0 227 | /* This option switches tiny buffer configuration. (0:Normal or 1:Tiny) 228 | / At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes. 229 | / Instead of private sector buffer eliminated from the file object, common sector 230 | / buffer in the filesystem object (FATFS) is used for the file data transfer. */ 231 | 232 | 233 | #define FF_FS_EXFAT 1 234 | /* This option switches support for exFAT filesystem. (0:Disable or 1:Enable) 235 | / To enable exFAT, also LFN needs to be enabled. 236 | / Note that enabling exFAT discards ANSI C (C89) compatibility. */ 237 | 238 | 239 | #define FF_FS_NORTC 1 240 | #define FF_NORTC_MON 1 241 | #define FF_NORTC_MDAY 1 242 | #define FF_NORTC_YEAR 2018 243 | /* The option FF_FS_NORTC switches timestamp functiton. If the system does not have 244 | / any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable 245 | / the timestamp function. Every object modified by FatFs will have a fixed timestamp 246 | / defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time. 247 | / To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be 248 | / added to the project to read current time form real-time clock. FF_NORTC_MON, 249 | / FF_NORTC_MDAY and FF_NORTC_YEAR have no effect. 250 | / These options have no effect at read-only configuration (FF_FS_READONLY = 1). */ 251 | 252 | 253 | #define FF_FS_LOCK 0 254 | /* The option FF_FS_LOCK switches file lock function to control duplicated file open 255 | / and illegal operation to open objects. This option must be 0 when FF_FS_READONLY 256 | / is 1. 257 | / 258 | / 0: Disable file lock function. To avoid volume corruption, application program 259 | / should avoid illegal open, remove and rename to the open objects. 260 | / >0: Enable file lock function. The value defines how many files/sub-directories 261 | / can be opened simultaneously under file lock control. Note that the file 262 | / lock control is independent of re-entrancy. */ 263 | 264 | 265 | #define FF_FS_REENTRANT 0 266 | #define FF_FS_TIMEOUT 1000 267 | #define FF_SYNC_t HANDLE 268 | /* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs 269 | / module itself. Note that regardless of this option, file access to different 270 | / volume is always re-entrant and volume control functions, f_mount(), f_mkfs() 271 | / and f_fdisk() function, are always not re-entrant. Only file/directory access 272 | / to the same volume is under control of this function. 273 | / 274 | / 0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect. 275 | / 1: Enable re-entrancy. Also user provided synchronization handlers, 276 | / ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj() 277 | / function, must be added to the project. Samples are available in 278 | / option/syscall.c. 279 | / 280 | / The FF_FS_TIMEOUT defines timeout period in unit of time tick. 281 | / The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*, 282 | / SemaphoreHandle_t and etc. A header file for O/S definitions needs to be 283 | / included somewhere in the scope of ff.h. */ 284 | 285 | /* #include // O/S definitions */ 286 | 287 | 288 | 289 | /*--- End of configuration options ---*/ 290 | -------------------------------------------------------------------------------- /st7735-images-native-ver/Src/main.c: -------------------------------------------------------------------------------- 1 | /* Includes ------------------------------------------------------------------*/ 2 | #include "main.h" 3 | #include "stm32f4xx_hal.h" 4 | 5 | /* USER CODE BEGIN Includes */ 6 | /* vim: set ai et ts=4 sw=4: */ 7 | #include 8 | #include 9 | #include "sdcard.h" 10 | #include "st7735.h" 11 | #include "ff.h" 12 | /* USER CODE END Includes */ 13 | 14 | /* Private variables ---------------------------------------------------------*/ 15 | SPI_HandleTypeDef hspi1; 16 | 17 | UART_HandleTypeDef huart2; 18 | 19 | /* USER CODE BEGIN PV */ 20 | /* Private variables ---------------------------------------------------------*/ 21 | 22 | /* USER CODE END PV */ 23 | 24 | /* Private function prototypes -----------------------------------------------*/ 25 | void SystemClock_Config(void); 26 | static void MX_GPIO_Init(void); 27 | static void MX_SPI1_Init(void); 28 | static void MX_USART2_UART_Init(void); 29 | 30 | /* USER CODE BEGIN PFP */ 31 | /* Private function prototypes -----------------------------------------------*/ 32 | 33 | /* USER CODE END PFP */ 34 | 35 | /* USER CODE BEGIN 0 */ 36 | 37 | FATFS fs; 38 | 39 | void UART_Printf(const char* fmt, ...) { 40 | char buff[256]; 41 | va_list args; 42 | va_start(args, fmt); 43 | vsnprintf(buff, sizeof(buff), fmt, args); 44 | HAL_UART_Transmit(&huart2, (uint8_t*)buff, strlen(buff), HAL_MAX_DELAY); 45 | va_end(args); 46 | } 47 | 48 | int displayImage(const char* fname) { 49 | UART_Printf("Openning %s...\r\n", fname); 50 | FIL file; 51 | FRESULT res = f_open(&file, fname, FA_READ); 52 | if(res != FR_OK) { 53 | UART_Printf("f_open() failed, res = %d\r\n", res); 54 | return -1; 55 | } 56 | 57 | UART_Printf("File opened, reading...\r\n"); 58 | 59 | unsigned int bytesRead; 60 | uint8_t header[34]; 61 | res = f_read(&file, header, sizeof(header), &bytesRead); 62 | if(res != FR_OK) { 63 | UART_Printf("f_read() failed, res = %d\r\n", res); 64 | f_close(&file); 65 | return -2; 66 | } 67 | 68 | if((header[0] != 0x42) || (header[1] != 0x4D)) { 69 | UART_Printf("Wrong BMP signature: 0x%02X 0x%02X\r\n", header[0], header[1]); 70 | f_close(&file); 71 | return -3; 72 | } 73 | 74 | uint32_t imageOffset = header[10] | (header[11] << 8) | (header[12] << 16) | (header[13] << 24); 75 | uint32_t imageWidth = header[18] | (header[19] << 8) | (header[20] << 16) | (header[21] << 24); 76 | uint32_t imageHeight = header[22] | (header[23] << 8) | (header[24] << 16) | (header[25] << 24); 77 | uint16_t imagePlanes = header[26] | (header[27] << 8); 78 | uint16_t imageBitsPerPixel = header[28] | (header[29] << 8); 79 | uint32_t imageCompression = header[30] | (header[31] << 8) | (header[32] << 16) | (header[33] << 24); 80 | 81 | UART_Printf( 82 | "--- Image info ---\r\n" 83 | "Pixels offset: %lu\r\n" 84 | "WxH: %lux%lu\r\n" 85 | "Planes: %d\r\n" 86 | "Bits per pixel: %d\r\n" 87 | "Compression: %d\r\n" 88 | "------------------\r\n", 89 | imageOffset, imageWidth, imageHeight, imagePlanes, imageBitsPerPixel, imageCompression); 90 | 91 | if((imageWidth != ST7735_WIDTH) || (imageHeight != ST7735_HEIGHT)) { 92 | UART_Printf("Wrong BMP size, %dx%d expected\r\n", ST7735_WIDTH, ST7735_HEIGHT); 93 | f_close(&file); 94 | return -4; 95 | } 96 | 97 | if((imagePlanes != 1) || (imageBitsPerPixel != 24) || (imageCompression != 0)) { 98 | UART_Printf("Unsupported image format\r\n"); 99 | f_close(&file); 100 | return -5; 101 | } 102 | 103 | res = f_lseek(&file, imageOffset); 104 | if(res != FR_OK) { 105 | UART_Printf("f_lseek() failed, res = %d\r\n", res); 106 | f_close(&file); 107 | return -6; 108 | } 109 | 110 | // row size is aligned to 4 bytes 111 | uint8_t imageRow[(ST7735_WIDTH * 3 + 3) & ~3]; 112 | for(uint32_t y = 0; y < imageHeight; y++) { 113 | uint32_t rowIdx = 0; 114 | res = f_read(&file, imageRow, sizeof(imageRow), &bytesRead); 115 | if(res != FR_OK) { 116 | UART_Printf("f_read() failed, res = %d\r\n", res); 117 | f_close(&file); 118 | return -7; 119 | } 120 | 121 | for(uint32_t x = 0; x < imageWidth; x++) { 122 | uint8_t b = imageRow[rowIdx++]; 123 | uint8_t g = imageRow[rowIdx++]; 124 | uint8_t r = imageRow[rowIdx++]; 125 | uint16_t color565 = ST7735_COLOR565(r, g, b); 126 | ST7735_DrawPixel(x, imageHeight - y - 1, color565); 127 | } 128 | } 129 | 130 | res = f_close(&file); 131 | if(res != FR_OK) { 132 | UART_Printf("f_close() failed, res = %d\r\n", res); 133 | return -8; 134 | } 135 | 136 | return 0; 137 | } 138 | 139 | int init() { 140 | // unselect all SPI devices first 141 | SDCARD_Unselect(); 142 | ST7735_Unselect(); 143 | 144 | // initialize SD-card as fast as possible, it glitches otherwise 145 | // (this is important only if SPI bus is shared by multiple devices) 146 | int code = SDCARD_Init(); 147 | if(code < 0) { 148 | UART_Printf("SDCARD_Init() failed, code = %d\r\n", code); 149 | return -1; 150 | } 151 | 152 | ST7735_Init(); 153 | ST7735_FillScreen(ST7735_BLACK); 154 | 155 | // mount the default drive 156 | FRESULT res = f_mount(&fs, "", 0); 157 | if(res != FR_OK) { 158 | UART_Printf("f_mount() failed, res = %d\r\n", res); 159 | return -2; 160 | } 161 | UART_Printf("f_mount() done!\r\n"); 162 | 163 | return 0; 164 | } 165 | 166 | void loop() { 167 | displayImage("parrot.bmp"); 168 | HAL_Delay(5000); 169 | displayImage("dolphin.bmp"); 170 | HAL_Delay(5000); 171 | displayImage("monkey.bmp"); 172 | HAL_Delay(5000); 173 | } 174 | 175 | /* USER CODE END 0 */ 176 | 177 | int main(void) 178 | { 179 | 180 | /* USER CODE BEGIN 1 */ 181 | 182 | /* USER CODE END 1 */ 183 | 184 | /* MCU Configuration----------------------------------------------------------*/ 185 | 186 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 187 | HAL_Init(); 188 | 189 | /* USER CODE BEGIN Init */ 190 | 191 | /* USER CODE END Init */ 192 | 193 | /* Configure the system clock */ 194 | SystemClock_Config(); 195 | 196 | /* USER CODE BEGIN SysInit */ 197 | 198 | /* USER CODE END SysInit */ 199 | 200 | /* Initialize all configured peripherals */ 201 | MX_GPIO_Init(); 202 | MX_SPI1_Init(); 203 | MX_USART2_UART_Init(); 204 | 205 | /* USER CODE BEGIN 2 */ 206 | 207 | /* USER CODE END 2 */ 208 | 209 | /* Infinite loop */ 210 | /* USER CODE BEGIN WHILE */ 211 | int code = init(); 212 | if(code < 0) { 213 | UART_Printf("init() failed with code %d, terminating.\r\n", code); 214 | return 0; 215 | } 216 | 217 | while (1) 218 | { 219 | loop(); 220 | /* USER CODE END WHILE */ 221 | 222 | /* USER CODE BEGIN 3 */ 223 | 224 | } 225 | /* USER CODE END 3 */ 226 | 227 | } 228 | 229 | /** System Clock Configuration 230 | */ 231 | void SystemClock_Config(void) 232 | { 233 | 234 | RCC_OscInitTypeDef RCC_OscInitStruct; 235 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 236 | 237 | /**Configure the main internal regulator output voltage 238 | */ 239 | __HAL_RCC_PWR_CLK_ENABLE(); 240 | 241 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); 242 | 243 | /**Initializes the CPU, AHB and APB busses clocks 244 | */ 245 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 246 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 247 | RCC_OscInitStruct.HSICalibrationValue = 16; 248 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 249 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; 250 | RCC_OscInitStruct.PLL.PLLM = 16; 251 | RCC_OscInitStruct.PLL.PLLN = 336; 252 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; 253 | RCC_OscInitStruct.PLL.PLLQ = 4; 254 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 255 | { 256 | _Error_Handler(__FILE__, __LINE__); 257 | } 258 | 259 | /**Initializes the CPU, AHB and APB busses clocks 260 | */ 261 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 262 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 263 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 264 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 265 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; 266 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 267 | 268 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) 269 | { 270 | _Error_Handler(__FILE__, __LINE__); 271 | } 272 | 273 | /**Configure the Systick interrupt time 274 | */ 275 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); 276 | 277 | /**Configure the Systick 278 | */ 279 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); 280 | 281 | /* SysTick_IRQn interrupt configuration */ 282 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 283 | } 284 | 285 | /* SPI1 init function */ 286 | static void MX_SPI1_Init(void) 287 | { 288 | 289 | /* SPI1 parameter configuration*/ 290 | hspi1.Instance = SPI1; 291 | hspi1.Init.Mode = SPI_MODE_MASTER; 292 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; 293 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 294 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 295 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 296 | hspi1.Init.NSS = SPI_NSS_SOFT; 297 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; 298 | hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; 299 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; 300 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 301 | hspi1.Init.CRCPolynomial = 10; 302 | if (HAL_SPI_Init(&hspi1) != HAL_OK) 303 | { 304 | _Error_Handler(__FILE__, __LINE__); 305 | } 306 | 307 | } 308 | 309 | /* USART2 init function */ 310 | static void MX_USART2_UART_Init(void) 311 | { 312 | 313 | huart2.Instance = USART2; 314 | huart2.Init.BaudRate = 9600; 315 | huart2.Init.WordLength = UART_WORDLENGTH_8B; 316 | huart2.Init.StopBits = UART_STOPBITS_1; 317 | huart2.Init.Parity = UART_PARITY_NONE; 318 | huart2.Init.Mode = UART_MODE_TX_RX; 319 | huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; 320 | huart2.Init.OverSampling = UART_OVERSAMPLING_16; 321 | if (HAL_UART_Init(&huart2) != HAL_OK) 322 | { 323 | _Error_Handler(__FILE__, __LINE__); 324 | } 325 | 326 | } 327 | 328 | /** Configure pins as 329 | * Analog 330 | * Input 331 | * Output 332 | * EVENT_OUT 333 | * EXTI 334 | */ 335 | static void MX_GPIO_Init(void) 336 | { 337 | 338 | GPIO_InitTypeDef GPIO_InitStruct; 339 | 340 | /* GPIO Ports Clock Enable */ 341 | __HAL_RCC_GPIOC_CLK_ENABLE(); 342 | __HAL_RCC_GPIOH_CLK_ENABLE(); 343 | __HAL_RCC_GPIOA_CLK_ENABLE(); 344 | __HAL_RCC_GPIOB_CLK_ENABLE(); 345 | 346 | /*Configure GPIO pin Output Level */ 347 | HAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_RESET); 348 | 349 | /*Configure GPIO pin Output Level */ 350 | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_RESET); 351 | 352 | /*Configure GPIO pin Output Level */ 353 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5|GPIO_PIN_6, GPIO_PIN_RESET); 354 | 355 | /*Configure GPIO pin : B1_Pin */ 356 | GPIO_InitStruct.Pin = B1_Pin; 357 | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; 358 | GPIO_InitStruct.Pull = GPIO_NOPULL; 359 | HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); 360 | 361 | /*Configure GPIO pin : PC7 */ 362 | GPIO_InitStruct.Pin = GPIO_PIN_7; 363 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 364 | GPIO_InitStruct.Pull = GPIO_NOPULL; 365 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 366 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 367 | 368 | /*Configure GPIO pin : PA9 */ 369 | GPIO_InitStruct.Pin = GPIO_PIN_9; 370 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 371 | GPIO_InitStruct.Pull = GPIO_NOPULL; 372 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 373 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 374 | 375 | /*Configure GPIO pins : PB5 PB6 */ 376 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; 377 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 378 | GPIO_InitStruct.Pull = GPIO_NOPULL; 379 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 380 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 381 | 382 | } 383 | 384 | /* USER CODE BEGIN 4 */ 385 | 386 | /* USER CODE END 4 */ 387 | 388 | /** 389 | * @brief This function is executed in case of error occurrence. 390 | * @param None 391 | * @retval None 392 | */ 393 | void _Error_Handler(char * file, int line) 394 | { 395 | /* USER CODE BEGIN Error_Handler_Debug */ 396 | /* User can add his own implementation to report the HAL error return state */ 397 | while(1) 398 | { 399 | } 400 | /* USER CODE END Error_Handler_Debug */ 401 | } 402 | 403 | #ifdef USE_FULL_ASSERT 404 | 405 | /** 406 | * @brief Reports the name of the source file and the source line number 407 | * where the assert_param error has occurred. 408 | * @param file: pointer to the source file name 409 | * @param line: assert_param error line source number 410 | * @retval None 411 | */ 412 | void assert_failed(uint8_t* file, uint32_t line) 413 | { 414 | /* USER CODE BEGIN 6 */ 415 | /* User can add his own implementation to report the file name and line number, 416 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 417 | /* USER CODE END 6 */ 418 | 419 | } 420 | 421 | #endif 422 | 423 | /** 424 | * @} 425 | */ 426 | 427 | /** 428 | * @} 429 | */ 430 | 431 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 432 | -------------------------------------------------------------------------------- /read-write-cubemx-ver/Inc/ffconf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * FatFs - Generic FAT file system module R0.12c (C)ChaN, 2017 4 | ****************************************************************************** 5 | * This notice applies to any and all portions of this file 6 | * that are not between comment pairs USER CODE BEGIN and 7 | * USER CODE END. Other portions of this file, whether 8 | * inserted by the user or by software development tools 9 | * are owned by their respective copyright owners. 10 | * 11 | * Copyright (c) 2018 STMicroelectronics International N.V. 12 | * All rights reserved. 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted, provided that the following conditions are met: 16 | * 17 | * 1. Redistribution 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 other 23 | * contributors to this software may be used to endorse or promote products 24 | * derived from this software without specific written permission. 25 | * 4. This software, including modifications and/or derivative works of this 26 | * software, must execute solely and exclusively on microcontroller or 27 | * microprocessor devices manufactured by or for STMicroelectronics. 28 | * 5. Redistribution and use of this software other than as permitted under 29 | * this license is void and will automatically terminate your rights under 30 | * this license. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 35 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 36 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 37 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 38 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 39 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 40 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 41 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 42 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 43 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 | * 45 | ****************************************************************************** 46 | */ 47 | 48 | #ifndef _FFCONF 49 | #define _FFCONF 68300 /* Revision ID */ 50 | 51 | /*-----------------------------------------------------------------------------/ 52 | / Additional user header to be used 53 | /-----------------------------------------------------------------------------*/ 54 | #include "stm32f4xx_hal.h" 55 | 56 | /*-----------------------------------------------------------------------------/ 57 | / Function Configurations 58 | /-----------------------------------------------------------------------------*/ 59 | 60 | #define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */ 61 | /* This option switches read-only configuration. (0:Read/Write or 1:Read-only) 62 | / Read-only configuration removes writing API functions, f_write(), f_sync(), 63 | / f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree() 64 | / and optional writing functions as well. */ 65 | 66 | #define _FS_MINIMIZE 0 /* 0 to 3 */ 67 | /* This option defines minimization level to remove some basic API functions. 68 | / 69 | / 0: All basic functions are enabled. 70 | / 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename() 71 | / are removed. 72 | / 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1. 73 | / 3: f_lseek() function is removed in addition to 2. */ 74 | 75 | #define _USE_STRFUNC 0 /* 0:Disable or 1-2:Enable */ 76 | /* This option switches string functions, f_gets(), f_putc(), f_puts() and 77 | / f_printf(). 78 | / 79 | / 0: Disable string functions. 80 | / 1: Enable without LF-CRLF conversion. 81 | / 2: Enable with LF-CRLF conversion. */ 82 | 83 | #define _USE_FIND 0 84 | /* This option switches filtered directory read functions, f_findfirst() and 85 | / f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */ 86 | 87 | #define _USE_MKFS 0 88 | /* This option switches f_mkfs() function. (0:Disable or 1:Enable) */ 89 | 90 | #define _USE_FASTSEEK 1 91 | /* This option switches fast seek feature. (0:Disable or 1:Enable) */ 92 | 93 | #define _USE_EXPAND 0 94 | /* This option switches f_expand function. (0:Disable or 1:Enable) */ 95 | 96 | #define _USE_CHMOD 0 97 | /* This option switches attribute manipulation functions, f_chmod() and f_utime(). 98 | / (0:Disable or 1:Enable) Also _FS_READONLY needs to be 0 to enable this option. */ 99 | 100 | #define _USE_LABEL 0 101 | /* This option switches volume label functions, f_getlabel() and f_setlabel(). 102 | / (0:Disable or 1:Enable) */ 103 | 104 | #define _USE_FORWARD 0 105 | /* This option switches f_forward() function. (0:Disable or 1:Enable) */ 106 | 107 | /*-----------------------------------------------------------------------------/ 108 | / Locale and Namespace Configurations 109 | /-----------------------------------------------------------------------------*/ 110 | 111 | #define _CODE_PAGE 437 112 | /* This option specifies the OEM code page to be used on the target system. 113 | / Incorrect setting of the code page can cause a file open failure. 114 | / 115 | / 1 - ASCII (No extended character. Non-LFN cfg. only) 116 | / 437 - U.S. 117 | / 720 - Arabic 118 | / 737 - Greek 119 | / 771 - KBL 120 | / 775 - Baltic 121 | / 850 - Latin 1 122 | / 852 - Latin 2 123 | / 855 - Cyrillic 124 | / 857 - Turkish 125 | / 860 - Portuguese 126 | / 861 - Icelandic 127 | / 862 - Hebrew 128 | / 863 - Canadian French 129 | / 864 - Arabic 130 | / 865 - Nordic 131 | / 866 - Russian 132 | / 869 - Greek 2 133 | / 932 - Japanese (DBCS) 134 | / 936 - Simplified Chinese (DBCS) 135 | / 949 - Korean (DBCS) 136 | / 950 - Traditional Chinese (DBCS) 137 | */ 138 | 139 | #define _USE_LFN 2 /* 0 to 3 */ 140 | #define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */ 141 | /* The _USE_LFN switches the support of long file name (LFN). 142 | / 143 | / 0: Disable support of LFN. _MAX_LFN has no effect. 144 | / 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe. 145 | / 2: Enable LFN with dynamic working buffer on the STACK. 146 | / 3: Enable LFN with dynamic working buffer on the HEAP. 147 | / 148 | / To enable the LFN, Unicode handling functions (option/unicode.c) must be added 149 | / to the project. The working buffer occupies (_MAX_LFN + 1) * 2 bytes and 150 | / additional 608 bytes at exFAT enabled. _MAX_LFN can be in range from 12 to 255. 151 | / It should be set 255 to support full featured LFN operations. 152 | / When use stack for the working buffer, take care on stack overflow. When use heap 153 | / memory for the working buffer, memory management functions, ff_memalloc() and 154 | / ff_memfree(), must be added to the project. */ 155 | 156 | #define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */ 157 | /* This option switches character encoding on the API. (0:ANSI/OEM or 1:UTF-16) 158 | / To use Unicode string for the path name, enable LFN and set _LFN_UNICODE = 1. 159 | / This option also affects behavior of string I/O functions. */ 160 | 161 | #define _STRF_ENCODE 3 162 | /* When _LFN_UNICODE == 1, this option selects the character encoding ON THE FILE to 163 | / be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf(). 164 | / 165 | / 0: ANSI/OEM 166 | / 1: UTF-16LE 167 | / 2: UTF-16BE 168 | / 3: UTF-8 169 | / 170 | / This option has no effect when _LFN_UNICODE == 0. */ 171 | 172 | #define _FS_RPATH 0 /* 0 to 2 */ 173 | /* This option configures support of relative path. 174 | / 175 | / 0: Disable relative path and remove related functions. 176 | / 1: Enable relative path. f_chdir() and f_chdrive() are available. 177 | / 2: f_getcwd() function is available in addition to 1. 178 | */ 179 | 180 | /*---------------------------------------------------------------------------/ 181 | / Drive/Volume Configurations 182 | /----------------------------------------------------------------------------*/ 183 | 184 | #define _VOLUMES 1 185 | /* Number of volumes (logical drives) to be used. */ 186 | 187 | /* USER CODE BEGIN Volumes */ 188 | #define _STR_VOLUME_ID 0 /* 0:Use only 0-9 for drive ID, 1:Use strings for drive ID */ 189 | #define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3" 190 | /* _STR_VOLUME_ID switches string support of volume ID. 191 | / When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive 192 | / number in the path name. _VOLUME_STRS defines the drive ID strings for each 193 | / logical drives. Number of items must be equal to _VOLUMES. Valid characters for 194 | / the drive ID strings are: A-Z and 0-9. */ 195 | /* USER CODE END Volumes */ 196 | 197 | #define _MULTI_PARTITION 0 /* 0:Single partition, 1:Multiple partition */ 198 | /* This option switches support of multi-partition on a physical drive. 199 | / By default (0), each logical drive number is bound to the same physical drive 200 | / number and only an FAT volume found on the physical drive will be mounted. 201 | / When multi-partition is enabled (1), each logical drive number can be bound to 202 | / arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk() 203 | / funciton will be available. */ 204 | #define _MIN_SS 512 /* 512, 1024, 2048 or 4096 */ 205 | #define _MAX_SS 512 /* 512, 1024, 2048 or 4096 */ 206 | /* These options configure the range of sector size to be supported. (512, 1024, 207 | / 2048 or 4096) Always set both 512 for most systems, all type of memory cards and 208 | / harddisk. But a larger value may be required for on-board flash memory and some 209 | / type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured 210 | / to variable sector size and GET_SECTOR_SIZE command must be implemented to the 211 | / disk_ioctl() function. */ 212 | 213 | #define _USE_TRIM 0 214 | /* This option switches support of ATA-TRIM. (0:Disable or 1:Enable) 215 | / To enable Trim function, also CTRL_TRIM command should be implemented to the 216 | / disk_ioctl() function. */ 217 | 218 | #define _FS_NOFSINFO 0 /* 0,1,2 or 3 */ 219 | /* If you need to know correct free space on the FAT32 volume, set bit 0 of this 220 | / option, and f_getfree() function at first time after volume mount will force 221 | / a full FAT scan. Bit 1 controls the use of last allocated cluster number. 222 | / 223 | / bit0=0: Use free cluster count in the FSINFO if available. 224 | / bit0=1: Do not trust free cluster count in the FSINFO. 225 | / bit1=0: Use last allocated cluster number in the FSINFO if available. 226 | / bit1=1: Do not trust last allocated cluster number in the FSINFO. 227 | */ 228 | 229 | /*---------------------------------------------------------------------------/ 230 | / System Configurations 231 | /----------------------------------------------------------------------------*/ 232 | 233 | #define _FS_TINY 0 /* 0:Normal or 1:Tiny */ 234 | /* This option switches tiny buffer configuration. (0:Normal or 1:Tiny) 235 | / At the tiny configuration, size of file object (FIL) is reduced _MAX_SS bytes. 236 | / Instead of private sector buffer eliminated from the file object, common sector 237 | / buffer in the file system object (FATFS) is used for the file data transfer. */ 238 | 239 | #define _FS_EXFAT 1 240 | /* This option switches support of exFAT file system. (0:Disable or 1:Enable) 241 | / When enable exFAT, also LFN needs to be enabled. (_USE_LFN >= 1) 242 | / Note that enabling exFAT discards C89 compatibility. */ 243 | 244 | #define _FS_NORTC 0 245 | #define _NORTC_MON 6 246 | #define _NORTC_MDAY 4 247 | #define _NORTC_YEAR 2015 248 | /* The option _FS_NORTC switches timestamp functiton. If the system does not have 249 | / any RTC function or valid timestamp is not needed, set _FS_NORTC = 1 to disable 250 | / the timestamp function. All objects modified by FatFs will have a fixed timestamp 251 | / defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR in local time. 252 | / To enable timestamp function (_FS_NORTC = 0), get_fattime() function need to be 253 | / added to the project to get current time form real-time clock. _NORTC_MON, 254 | / _NORTC_MDAY and _NORTC_YEAR have no effect. 255 | / These options have no effect at read-only configuration (_FS_READONLY = 1). */ 256 | 257 | #define _FS_LOCK 2 /* 0:Disable or >=1:Enable */ 258 | /* The option _FS_LOCK switches file lock function to control duplicated file open 259 | / and illegal operation to open objects. This option must be 0 when _FS_READONLY 260 | / is 1. 261 | / 262 | / 0: Disable file lock function. To avoid volume corruption, application program 263 | / should avoid illegal open, remove and rename to the open objects. 264 | / >0: Enable file lock function. The value defines how many files/sub-directories 265 | / can be opened simultaneously under file lock control. Note that the file 266 | / lock control is independent of re-entrancy. */ 267 | 268 | #define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */ 269 | #define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */ 270 | #define _SYNC_t osSemaphoreId 271 | /* The option _FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs 272 | / module itself. Note that regardless of this option, file access to different 273 | / volume is always re-entrant and volume control functions, f_mount(), f_mkfs() 274 | / and f_fdisk() function, are always not re-entrant. Only file/directory access 275 | / to the same volume is under control of this function. 276 | / 277 | / 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect. 278 | / 1: Enable re-entrancy. Also user provided synchronization handlers, 279 | / ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj() 280 | / function, must be added to the project. Samples are available in 281 | / option/syscall.c. 282 | / 283 | / The _FS_TIMEOUT defines timeout period in unit of time tick. 284 | / The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*, 285 | / SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be 286 | / included somewhere in the scope of ff.h. */ 287 | 288 | /* define the ff_malloc ff_free macros as standard malloc free */ 289 | #if !defined(ff_malloc) && !defined(ff_free) 290 | #include 291 | #define ff_malloc malloc 292 | #define ff_free free 293 | #endif 294 | 295 | #endif /* _FFCONF */ 296 | --------------------------------------------------------------------------------