jianghuai/SYSTEM/common.h

81 lines
3.0 KiB
C
Raw Permalink Normal View History

2024-05-07 01:36:09 +00:00
/*******************************************************************************
** <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>: common.h
** <EFBFBD><EFBFBD><EFBFBD> 1.0
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RealView MDK-ARM 4.14
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD>: wuguoyana
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 2011-04-29
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD>: common<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>: string.h<EFBFBD><EFBFBD>stdio.h<EFBFBD><EFBFBD>stm32f10x.h<EFBFBD><EFBFBD>ymodem.h
** <EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><EFBFBD> 2011-04-29 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
*******************************************************************************/
/* <20><>ֹ<EFBFBD>ض<EFBFBD><D8B6><EFBFBD> ----------------------------------------------------------------*/
#ifndef _COMMON_H
#define _COMMON_H
/* <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> *****************************************************************/
#include "stdio.h"
#include "string.h"
#include "stm32f10x.h"
#include "fileSys.h"
extern void Delay(__IO uint32_t nCount);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -----------------------------------------------------------------*/
typedef void (*pFunction)(void);
//* <20><> ------------------------------------------------------------------------*/
#define CMD_STRING_SIZE 128
#define ApplicationAddress 0x8008000
#if defined (STM32F10X_MD) || defined (STM32F10X_MD_VL)
#define PAGE_SIZE (0x400) /* 1 Kbyte */
#define FLASH_SIZE (0x20000) /* 128 KBytes */
#elif defined STM32F10X_CL
#define PAGE_SIZE (0x800) /* 2 Kbytes */
#define FLASH_SIZE (0x40000) /* 256 KBytes */
#elif defined STM32F10X_HD || defined (STM32F10X_HD_VL)
#define PAGE_SIZE (0x800) /* 2 Kbytes */
#define FLASH_SIZE (0x80000) /* 512 KBytes */
#elif defined STM32F10X_XL
#define PAGE_SIZE (0x800) /* 2 Kbytes */
#define FLASH_SIZE (0x100000) /* 1 MByte */
#else
#error "Please select first the STM32 device to be used (in stm32f10x.h)"
#endif
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4>ļ<EFBFBD><C4BC><EFBFBD>С
#define FLASH_IMAGE_SIZE (uint32_t) (FLASH_SIZE - (ApplicationAddress - 0x08000000))
#define IS_AF(c) ((c >= 'A') && (c <= 'F'))
#define IS_af(c) ((c >= 'a') && (c <= 'f'))
#define IS_09(c) ((c >= '0') && (c <= '9'))
#define ISVALIDHEX(c) IS_AF(c) || IS_af(c) || IS_09(c)
#define ISVALIDDEC(c) IS_09(c)
#define CONVERTDEC(c) (c - '0')
#define CONVERTHEX_alpha(c) (IS_AF(c) ? (c - 'A'+10) : (c - 'a'+10))
#define CONVERTHEX(c) (IS_09(c) ? (c - '0') : CONVERTHEX_alpha(c))
#define SerialPutString(x) Serial_PutString((uint8_t*)(x))
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ------------------------------------------------------------------*/
void Int2Str(uint8_t* str,int32_t intnum);
uint32_t Str2Int(uint8_t *inputstr,int32_t *intnum);
uint32_t GetIntegerInput(int32_t * num);
uint32_t SerialKeyPressed(uint8_t *key);
uint8_t GetKey(void);
void SerialPutChar(uint8_t c);
void Serial_PutString(uint8_t *s);
void GetInputString(uint8_t * buffP);
uint32_t FLASH_PagesMask(__IO uint32_t Size);
void FLASH_DisableWriteProtectionPages(void);
void Main_Menu(void);
void SerialDownload(void);
void SerialUpload(void);
#endif /* _COMMON_H */
/*******************************<2A>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>***************************************/