init commit
SPI FLASH only, I2C eeprom later
This commit is contained in:
77
GENERAL/flash_general.h
Normal file
77
GENERAL/flash_general.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*********************************UART**************************************
|
||||
Данный файл содержит объявления базовых функции и дефайны для инициализации
|
||||
UART.
|
||||
***************************************************************************/
|
||||
#ifndef __UART_GENERAL_H_
|
||||
#define __UART_GENERAL_H_
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////---USER SETTINGS---/////////////////////////
|
||||
#define HAL_UART_MODULE_ENABLED // need to uncomment these defines in stm32f4xx_hal_conf.h
|
||||
#define HAL_USART_MODULE_ENABLED // also need to add hal_uart.c (source code)
|
||||
|
||||
//#define USE_USART1
|
||||
//#define USE_USART2
|
||||
//#define USE_USART3
|
||||
//#define USE_UART4
|
||||
//#define USE_UART5
|
||||
//#define USE_USART6
|
||||
/* note: used uart defines in modbus.h */
|
||||
|
||||
/////////////////////////---USER SETTINGS---/////////////////////////
|
||||
#include "periph_general.h"
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////---DEFINES---////////////////////////////
|
||||
/**
|
||||
* @brief Analog for HAL define. Remade with pointer to structure.
|
||||
* @note @ref __HAL_LINKDMA.
|
||||
*/
|
||||
#define __USER_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
|
||||
do{ \
|
||||
(__HANDLE__)->__PPP_DMA_FIELD__ = (__DMA_HANDLE__); \
|
||||
(__DMA_HANDLE__)->Parent = (__HANDLE__);} while(0U)
|
||||
|
||||
|
||||
////////////////////////////---DEFINES---////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
///////////////////////---STRUCTURES & ENUMS---//////////////////////
|
||||
typedef struct // struct with settings for custom function
|
||||
{
|
||||
UART_HandleTypeDef huart;
|
||||
|
||||
GPIO_TypeDef *GPIOx;
|
||||
uint16_t GPIO_PIN_RX;
|
||||
uint16_t GPIO_PIN_TX;
|
||||
|
||||
DMA_Stream_TypeDef *DMAChannel; // DMAChannel = 0 if doesnt need
|
||||
uint32_t DMA_CHANNEL_X; // DMAChannel = 0 if doesnt need
|
||||
|
||||
|
||||
}UART_SettingsTypeDef;
|
||||
///////////////////////---STRUCTURES & ENUMS---//////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////---FUNCTIONS---///////////////////////////
|
||||
/**
|
||||
* @brief Initialize UART with UART_SettingsTypeDef structure.
|
||||
* @param suart - указатель на структуру с настройками UART.
|
||||
* @return HAL status.
|
||||
* @note Данная структура содержит хендл ЮАРТ и настройки перефирии (GPIO)
|
||||
*/
|
||||
/* functions for reading bytes/halswords/words */
|
||||
uint8_t FLASH_Read_Byte(uint32_t add);
|
||||
uint16_t FLASH_Read_HalfWord(uint32_t add);
|
||||
uint32_t FLASH_Read_Word(uint32_t add);
|
||||
/* functions for writing bytes/halswords/words */
|
||||
HAL_StatusTypeDef FLASH_Write_Byte(uint32_t Address, uint8_t Data);
|
||||
HAL_StatusTypeDef FLASH_Write_HalfWord(uint32_t Address, uint16_t Data);
|
||||
HAL_StatusTypeDef FLASH_Write_Word(uint32_t Address, uint32_t Data);
|
||||
///////////////////////////---FUNCTIONS---///////////////////////////
|
||||
|
||||
#endif // __UART_GENERAL_H_
|
||||
Reference in New Issue
Block a user