first commit
This commit is contained in:
4
S100App/ALLCustomSfr.sfr
Normal file
4
S100App/ALLCustomSfr.sfr
Normal file
@@ -0,0 +1,4 @@
|
||||
[Sfr]
|
||||
|
||||
|
||||
[SfrGroupInfo]
|
||||
2338
S100App/App.dep
Normal file
2338
S100App/App.dep
Normal file
File diff suppressed because it is too large
Load Diff
2317
S100App/App.ewd
Normal file
2317
S100App/App.ewd
Normal file
File diff suppressed because it is too large
Load Diff
2013
S100App/App.ewp
Normal file
2013
S100App/App.ewp
Normal file
File diff suppressed because it is too large
Load Diff
10
S100App/App.eww
Normal file
10
S100App/App.eww
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\App.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
4
S100App/AppCustomSfr.sfr
Normal file
4
S100App/AppCustomSfr.sfr
Normal file
@@ -0,0 +1,4 @@
|
||||
[Sfr]
|
||||
|
||||
|
||||
[SfrGroupInfo]
|
||||
40
S100App/Inc/APP_Version.h
Normal file
40
S100App/Inc/APP_Version.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
||||
File Name : APP_Version.h
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : bure & Celery
|
||||
Data: 2015/08/03
|
||||
History:
|
||||
2015/08/03 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __VERSION_H
|
||||
#define __VERSION_H
|
||||
|
||||
#define M_VER 'V','0'
|
||||
#define S_VER '0','1'
|
||||
#define OEM_TYPE "0"
|
||||
#define APP_BASE 0x0800C000
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifdef TYPE_DS201
|
||||
#define PRODUCT_INFO "DS201"
|
||||
#define SCH_VER "1.7B"
|
||||
#elif TYPE_DS202
|
||||
#include "DS202V1_6.h"
|
||||
#define FLASH_PAGE 0x0800
|
||||
#elif TYPE_DS203
|
||||
#define PRODUCT_INFO "DS203"
|
||||
#define SCH_VER "2.70"
|
||||
#elif TYPE_S100
|
||||
#define PRODUCT_INFO "TS100"
|
||||
#include "S100V0_1.h"
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#define DFU_VER {M_VER,'.',S_VER,LCD_M, 0}
|
||||
#define uint8_t unsigned char
|
||||
#define uint16_t short unsigned int
|
||||
#define uint32_t unsigned int
|
||||
#endif /* VERSION_H */
|
||||
/********************************* END OF FILE ******************************/
|
||||
59
S100App/Inc/Bios.h
Normal file
59
S100App/Inc/Bios.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
||||
File Name : Bios.h
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : bure & Celery
|
||||
Data: 2015/08/03
|
||||
History:
|
||||
2015/08/03 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __BIOS_H
|
||||
#define __BIOS_H
|
||||
|
||||
#include "STM32F10x.h"
|
||||
|
||||
extern volatile u32 gTime[];
|
||||
|
||||
#define USB_DN_OUT() GPIOA->CRH = (GPIOA->CRH & 0xFFFF3FFF) | 0x00003000
|
||||
#define USB_DP_OUT() GPIOA->CRH = (GPIOA->CRH & 0xFFF3FFFF) | 0x00030000
|
||||
|
||||
#define USB_DN_EN() GPIOA->CRH = (GPIOA->CRH & 0xFFFFBFFF) | 0x0000B000
|
||||
#define USB_DP_EN() GPIOA->CRH = (GPIOA->CRH & 0xFFFBFFFF) | 0x000B0000
|
||||
|
||||
#define USB_DP_PD() GPIOA->CRH = (GPIOA->CRH & 0xFFF3FFFF) | 0x00030000
|
||||
|
||||
#define USB_DN_HIGH() GPIOA->BSRR = GPIO_Pin_11
|
||||
#define USB_DP_HIGH() GPIOA->BSRR = GPIO_Pin_12
|
||||
|
||||
#define USB_DN_LOW() GPIOA->BRR = GPIO_Pin_11
|
||||
#define USB_DP_LOW() GPIOA->BRR = GPIO_Pin_12
|
||||
|
||||
#define LOW 0
|
||||
#define HIGH 1
|
||||
|
||||
#define BLINK 1 // Bit0 : 0/1 <20><>ʾ/<2F><>˸״̬<D7B4><CCAC>־
|
||||
#define WAIT_TIMES 100000
|
||||
|
||||
|
||||
#define SECTOR_SIZE 512
|
||||
#define SECTOR_CNT 4096
|
||||
#define HEAT_T 200
|
||||
|
||||
u32 Get_HeatingTime(void);
|
||||
void Set_HeatingTime(u32 heating_time);
|
||||
u16 Get_AdcValue(u8 i);
|
||||
void Init_Gtime(void);
|
||||
void Delay_Ms(u32 ms);
|
||||
void Delay_HalfMs(u32 ms);
|
||||
void USB_Port(u8 state);
|
||||
void NVIC_Config(u16 tab_offset);
|
||||
void RCC_Config(void);
|
||||
void GPIO_Config(void);
|
||||
void Ad_Init(void);
|
||||
void Init_Timer2(void);
|
||||
void Init_Timer3(void);
|
||||
void TIM2_ISR(void);
|
||||
void TIM3_ISR(void);
|
||||
#endif
|
||||
/********************************* END OF FILE ********************************/
|
||||
72
S100App/Inc/CTRL.h
Normal file
72
S100App/Inc/CTRL.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : CTRL.h
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/07
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
#ifndef _CTRL_H
|
||||
#define _CTRL_H
|
||||
|
||||
#include "STM32F10x.h"
|
||||
#include "Bios.h"
|
||||
|
||||
#define TEMPSHOW_TIMER gTime[0]/*TEMPSHOW_TIMER*/
|
||||
#define HEATING_TIMER gTime[1]/*HEATING_TIMER*/
|
||||
#define ENTER_WAIT_TIMER gTime[2]/*ENTER_WAIT_TIMER*/
|
||||
#define EFFECTIVE_KEY_TIMER gTime[3]/*EFFECTIVE_KEY_TIMER*/
|
||||
#define LEAVE_WAIT_TIMER gTime[4]/*LEAVE_WAIT_TIMER*/
|
||||
#define G6_TIMER gTime[5]/*SWITCH_SHOW_TIMER*/
|
||||
#define UI_TIMER gTime[6]/*UI_TIMER ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
#define KD_TIMER gTime[7]/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ*/
|
||||
//------------------------------ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>------------------------------------//
|
||||
#define KEY_ST(KEY_PIN) GPIO_ReadInputDataBit(GPIOA, KEY_PIN)
|
||||
#define NO_KEY 0x0
|
||||
#define KEY_V1 0x0100
|
||||
#define KEY_V2 0x0040
|
||||
#define KEY_CN 0X8000
|
||||
#define KEY_V3 0X0140
|
||||
|
||||
typedef enum WORK_STATUS {
|
||||
IDLE = 1,
|
||||
THERMOMETER,
|
||||
TEMP_CTR,
|
||||
WAIT,
|
||||
TEMP_SET,
|
||||
CONFIG ,
|
||||
MODE_CNG,
|
||||
ALARM,
|
||||
} WORK_STATUS;
|
||||
|
||||
typedef enum WARNING_STATUS {
|
||||
NORMAL_TEMP = 1,
|
||||
HIGH_TEMP,
|
||||
SEN_ERR,
|
||||
HIGH_VOLTAGE,
|
||||
LOW_VOLTAGE,
|
||||
} WARNING_STATUS;
|
||||
|
||||
typedef struct {
|
||||
u8 ver[16];
|
||||
s16 t_standby; // 200<30><30>C=1800 2520,<2C><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
s16 t_work; // 350<35><30>C=3362, <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
s16 t_step; //<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
|
||||
u32 wait_time; //3*60*100 3 mintute
|
||||
u32 idle_time; //6*60*100 6 minute
|
||||
} DEVICE_INFO_SYS;
|
||||
|
||||
extern DEVICE_INFO_SYS device_info;
|
||||
void Set_PrevTemp(s16 Temp);
|
||||
u8 Get_CtrlStatus(void);
|
||||
void Set_CtrlStatus(u8 status);
|
||||
s16 Get_TempVal(void);
|
||||
u16 Get_HtFlag(void);
|
||||
void System_Init(void);
|
||||
void Pid_Init(void);
|
||||
u16 Pid_Realize(s16 temp);
|
||||
u32 Heating_Time(s16 temp,s16 wk_temp);
|
||||
void Status_Tran(void);
|
||||
#endif
|
||||
/******************************** END OF FILE *********************************/
|
||||
97
S100App/Inc/Disk.h
Normal file
97
S100App/Inc/Disk.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : Disk.h
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/08/03
|
||||
History:
|
||||
2015/08/03 :
|
||||
*******************************************************************************/
|
||||
#ifndef __DISK_H
|
||||
#define __DISK_H
|
||||
|
||||
#include "stm32f10x_lib.h"
|
||||
#include "stm32f10x_flash.h"
|
||||
#include "USB_scsi.h"
|
||||
#include "USB_regs.h"
|
||||
#include "USB_conf.h"
|
||||
#include "USB_bot.h"
|
||||
#include "USB_mem.h"
|
||||
#include "USB_lib.h"
|
||||
#include "USB_pwr.h"
|
||||
|
||||
#define SECTOR_SIZE 512
|
||||
#define SECTOR_CNT 4096
|
||||
|
||||
#define FAT1_SECTOR &gDisk_buff[0x000]
|
||||
#define FAT2_SECTOR &gDisk_buff[0x200]
|
||||
#define ROOT_SECTOR &gDisk_buff[0x400]
|
||||
#define VOLUME_BASE &gDisk_buff[0x416]
|
||||
#define OTHER_FILES &gDisk_buff[0x420]
|
||||
#define FILE_SECTOR &gDisk_buff[0x600]
|
||||
#define Root (u8*)ROOT_SECTOR
|
||||
|
||||
|
||||
//#define APP_BASE 0x0800C000
|
||||
|
||||
#define HEX 0
|
||||
#define BIN 2
|
||||
#define SET 1
|
||||
|
||||
#define RDY 0
|
||||
#define NOT 2
|
||||
#define END 3
|
||||
#define ERR 4
|
||||
|
||||
#define DATA_SEG 0x00
|
||||
#define DATA_END 0x01
|
||||
#define EXT_ADDR 0x04
|
||||
|
||||
#define TXFR_IDLE 0
|
||||
#define TXFR_ONGOING 1
|
||||
|
||||
//#define FAT_DATA 0x00FFFFF8
|
||||
#define VOLUME 0x40DD8D18 //0x3E645C29
|
||||
|
||||
#define BUFF 0 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
#define V32_BASE SECTOR_SIZE // V32 <20>ܹ<EFBFBD> 8*4=32 <20>ֽ<EFBFBD>
|
||||
#define W_ADDR 0
|
||||
#define ADDR 1
|
||||
#define H_ADDR 2
|
||||
#define OFFSET 3
|
||||
#define SEC_CNT 4
|
||||
#define COUNT 5
|
||||
#define RD_CNT 6
|
||||
#define WR_CNT 7
|
||||
|
||||
#define VAR_BASE V32_BASE + 32 // VAR <20>ܹ<EFBFBD> 9+17=26 <20>ֽ<EFBFBD>
|
||||
#define USB_ST 0
|
||||
#define SEG_KIND 1
|
||||
#define SEG_LEN 2
|
||||
#define SEG_SUM 3
|
||||
#define SEG_TMP 4
|
||||
#define SEG_ST 5
|
||||
#define DATA_CNT 6
|
||||
#define F_TYPE 7
|
||||
#define F_FLAG 8
|
||||
#define SEG_DATA 9 // ͨ<>Ű<EFBFBD><C5B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 9~26 <20><>17<31>ֽ<EFBFBD>
|
||||
|
||||
|
||||
u8 Cal_Val(u8 str[],u8 k,u8 flag);
|
||||
void Disk_BuffInit(void);
|
||||
u8 ReWrite_All(void);
|
||||
u8 Config_Analysis(void);
|
||||
void Disk_BuffInit(void);
|
||||
void Disk_SecWrite(u8* pbuffer, u32 disk_addr);
|
||||
void Close_File(void);
|
||||
void Write_Memory(u32 w_offset, u32 w_length);
|
||||
void Read_Memory (u32 r_offset, u32 r_length);
|
||||
void Set_Ver(u8 str[],u8 i);
|
||||
void Erase(void);
|
||||
char * Get_Line(char *dst,char *src, int n,int m);
|
||||
void Upper(u8* str, u16 len);
|
||||
u8* SearchFile(u8* pfilename, u16* pfilelen,u16* root_addr);
|
||||
u8 ReWriteFlsash(void);
|
||||
#endif
|
||||
/********************************* END OF FILE ******************************/
|
||||
53
S100App/Inc/Ext_Flash.h
Normal file
53
S100App/Inc/Ext_Flash.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
||||
File Name : EXT_Flash.h
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : bure
|
||||
Data:
|
||||
History:
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __EXT_FLASH_H
|
||||
#define __EXT_FLASH_H
|
||||
//#include "stm32f10x_lib.h"
|
||||
#include "STM32F10x.h"
|
||||
|
||||
extern u8 flash_mode;
|
||||
#define FLASH_2M 1
|
||||
#define FLASH_8M 2
|
||||
//#define W25Q64BV
|
||||
|
||||
#define WREN 0x06 // Write enable instruction
|
||||
#define READ 0x03 // Read from Memory instruction
|
||||
#define RDSR 0x05 // Read Status Register instruction
|
||||
#define PP 0x02 // Write to Memory instruction
|
||||
#define PE 0xDB // Page Erase instruction
|
||||
#define PW 0x0A // Page write instruction
|
||||
#define DP 0xB9 // Deep power-down instruction
|
||||
#define RDP 0xAB // Release from deep power-down instruction
|
||||
//----W25Q64BV----------------------------------------------------------------//
|
||||
#define CHIPE 0xC7 // Chip All Erase instruction
|
||||
#define BE64 0xD8 // Block 32k Erase instruction
|
||||
#define BE32 0x52 // Block 64k Erase instruction
|
||||
#define SE 0x20 // Sector 4K Erase instruction
|
||||
#define Dummy_Byte 0xA5
|
||||
#define EXT_FLASH_PageSize 256
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
#define WIP_Flag 0x01 // Write In Progress (WIP) flag
|
||||
|
||||
|
||||
#define ExtFlash_CS_LOW() GPIO_ResetBits(GPIOB, GPIO_Pin_7)
|
||||
#define ExtFlash_CS_HIGH() GPIO_SetBits(GPIOB, GPIO_Pin_7)
|
||||
|
||||
void ExtFlash_PageWR(u8* pBuffer, u32 WriteAddr);
|
||||
void ExtFlash_PageRD(u8* pBuffer, u32 ReadAddr, u16 Lenght);
|
||||
void MAL_GetStatus (void);
|
||||
u8 ExtFlash_ReadByte(void);
|
||||
u8 ExtFlash_SendByte(u8 byte);
|
||||
void ExtFlash_WriteEnable(void);
|
||||
void ExtFlash_WaitForWriteEnd(void);
|
||||
void ExtFlash_PageProg(u8* pBuffer, u32 WriteAddr,u8 CMD);
|
||||
#endif
|
||||
|
||||
/********************************* END OF FILE ******************************/
|
||||
28
S100App/Inc/FAT12.h
Normal file
28
S100App/Inc/FAT12.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
||||
File Name : FAT12.h
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : bure
|
||||
Data:
|
||||
History:
|
||||
*******************************************************************************/
|
||||
#ifndef __FAT12_H
|
||||
#define __FAT12_H
|
||||
|
||||
#include "stm32f10x_lib.h"
|
||||
|
||||
|
||||
u8 ReadFileSec(u8* Buffer, u16* Cluster);
|
||||
u8 ReadDiskData(u8* pBuffer, u32 ReadAddr, u16 Lenght);
|
||||
u8 NextCluster(u16* Cluster);
|
||||
u8 ProgFileSec(u8* Buffer, u16* Cluster);
|
||||
u8 ProgDiskPage(u8* Buffer, u32 ProgAddr);
|
||||
u8 SeekBlank(u8* Buffer, u16* Cluster);
|
||||
u8 SetCluster(u8* Buffer, u16* Cluster);
|
||||
u8 OpenFileRd(u8* Buffer, u8* FileName, u16* Cluster, u32* pDirAddr);
|
||||
u8 OpenFileWr(u8* Buffer, u8* FileName, u16* Cluster, u32* pDirAddr);
|
||||
u8 CloseFile(u8* Buffer, u32 Lenght, u16* Cluster, u32* pDirAddr);
|
||||
void ExtFlash_PageWrite(u8* pBuffer, u32 WriteAddr, u8 Mode);
|
||||
|
||||
#endif
|
||||
/********************************* END OF FILE ********************************/
|
||||
29
S100App/Inc/Flash.h
Normal file
29
S100App/Inc/Flash.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
||||
File Name : Flash.h
|
||||
Version : Author : bure
|
||||
*******************************************************************************/
|
||||
#ifndef __EXT_FLASH_H
|
||||
#define __EXT_FLASH_H
|
||||
|
||||
#define PAGESIZE 256
|
||||
|
||||
#define WREN 0x06 // Write enable instruction
|
||||
#define READ 0x03 // Read from Memory instruction
|
||||
#define RDSR 0x05 // Read Status Register instruction
|
||||
#define PP 0x02 // Write to Memory instruction
|
||||
#define PW 0x0A // Page write instruction
|
||||
|
||||
#define OK 0 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define SEC_ERR 1 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
||||
#define TMAX 100000 // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
|
||||
#define WIP_Flag 0x01 // Write In Progress (WIP) flag
|
||||
#define Dummy_Byte 0xA5
|
||||
|
||||
u8 FLASH_Prog(u32 Address, u16 Data);
|
||||
void FLASH_Erase(u32 Address);
|
||||
void ExtFlashPageWR(u8* pBuffer, u32 WriteAddr);
|
||||
void ExtFlashDataRD(u8* pBuffer, u32 ReadAddr, u16 Lenght);
|
||||
#endif
|
||||
|
||||
/********************************* END OF FILE ******************************/
|
||||
49
S100App/Inc/HARDWARE.h
Normal file
49
S100App/Inc/HARDWARE.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : CTRL.h
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/07
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
#ifndef _HARDWARE_H
|
||||
#define _HARDWARE_H
|
||||
|
||||
#include "STM32F10x.h"
|
||||
|
||||
#define SI_COE 8//56
|
||||
#define SI_THRESHOLD 60
|
||||
|
||||
typedef enum VOL_CLASS {
|
||||
H_ALARM = 0,
|
||||
VOL_24,
|
||||
VOL_19,
|
||||
VOL_12,
|
||||
VOL_5,
|
||||
L_ALARM,
|
||||
} VOL_CLASS;
|
||||
|
||||
extern s32 gZerop_ad;
|
||||
extern u8 gCalib_flag;
|
||||
extern u32 gTurn_offv;
|
||||
|
||||
u32 Get_gKey(void);
|
||||
void Set_gKey(u32 key);
|
||||
void Set_LongKeyFlag(u32 flag);
|
||||
void Zero_Calibration(void);
|
||||
int Read_Vb(u8 flag);
|
||||
void Scan_Key(void);
|
||||
u32 Get_SlAvg(u32 avg_data);
|
||||
int Get_TempSlAvg(int avg_data);
|
||||
u32 Get_AvgAd(void);
|
||||
int Get_SensorTmp(void);
|
||||
u16 Get_ThermometerTemp(void);
|
||||
s16 Get_Temp(s16 wk_temp);
|
||||
u32 Clear_Watchdog(void);
|
||||
u32 Start_Watchdog(u32 ms);
|
||||
u8 Get_AlarmType(void);
|
||||
void Set_AlarmType(u8 type);
|
||||
u32 Get_CalFlag(void);
|
||||
#endif
|
||||
/******************************** END OF FILE *********************************/
|
||||
21
S100App/Inc/I2C.h
Normal file
21
S100App/Inc/I2C.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : I2C.h
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/08/03
|
||||
History:
|
||||
2015/08/03 :
|
||||
*******************************************************************************/
|
||||
#ifndef __I2C_H
|
||||
#define __I2C_H
|
||||
|
||||
#define I2C_TX 1
|
||||
#define I2C_RX 2
|
||||
|
||||
void I2C_Configuration(void);
|
||||
void Delay_uS(u32 us);
|
||||
void I2C_PageWrite(u8* pbuf, u8 numbyte,u8 deviceaddr );
|
||||
void I2C_PageRead(u8* pbuf, u8 numbyte,u8 deviceaddr, u8 readaddr);
|
||||
#endif
|
||||
/******************************** END OF FILE *********************************/
|
||||
31
S100App/Inc/Interrupt.h
Normal file
31
S100App/Inc/Interrupt.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. *******************/
|
||||
/* Brief : Interrupt Service Routines Author : bure */
|
||||
/******************************************************************************/
|
||||
#ifndef __INTERRUPT_H
|
||||
#define __INTERRUPT_H
|
||||
|
||||
void NMI_Handler(void);
|
||||
void HardFault_Handler(void);
|
||||
void MemManage_Handler(void);
|
||||
void BusFault_Handler(void);
|
||||
void UsageFault_Handler(void);
|
||||
void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
|
||||
void WWDG_IRQHandler(void);
|
||||
void PVD_IRQHandler(void);
|
||||
void TAMPER_STAMP_IRQHandler(void);
|
||||
void RTC_WKUP_IRQHandler(void);
|
||||
void FLASH_IRQHandler(void);
|
||||
|
||||
void USB_LP_CAN1_RX0_IRQHandler(void);
|
||||
void I2C1_EV_IRQHandler(void);
|
||||
void I2C1_ER_IRQHandler(void);
|
||||
void TIM2_IRQHandler(void);
|
||||
void TIM3_IRQHandler(void);
|
||||
|
||||
#endif /* __INTERRUPT_H */
|
||||
|
||||
/********************************* END OF FILE ******************************/
|
||||
85
S100App/Inc/MMA8652FC.h
Normal file
85
S100App/Inc/MMA8652FC.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : MMA8652FC.h
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/07
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
#ifndef __MMA8652FC__H
|
||||
#define __MMA8652FC__H
|
||||
|
||||
//--------------MMA8652 <20><><EFBFBD>岿<EFBFBD><E5B2BF>----------------------------------------------//
|
||||
|
||||
#define DEVICE_ADDR 0X1D
|
||||
//--------------MMA8652 <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-------------------------------------------//
|
||||
#define STATUS_REG 0x00
|
||||
#define X_MSB_REG 0X01
|
||||
#define X_LSB_REG 0X02
|
||||
#define Y_MSB_REG 0X03
|
||||
#define Y_LSB_REG 0X04
|
||||
#define Z_MSB_REG 0X05
|
||||
#define Z_LSB_REG 0X06
|
||||
|
||||
#define TRIG_CFG 0X0A
|
||||
#define SYSMOD 0X0B
|
||||
#define INT_SOURCE 0X0C
|
||||
#define DEVICE_ID 0X0D
|
||||
|
||||
#define XYZ_DATA_CFG_REG 0X0E
|
||||
|
||||
|
||||
#define CTRL_REG1 0X2A //
|
||||
#define CTRL_REG2 0X2B //System Control 2 register
|
||||
#define CTRL_REG3 0X2C //
|
||||
#define CTRL_REG4 0X2D //Interrupt Enable register
|
||||
#define CTRL_REG5 0X2E //
|
||||
|
||||
//-----STATUS_REG(0X00)-----Bit Define----------------------------------------//
|
||||
#define ZYXDR_BIT 0X08
|
||||
//----XYZ_DATA_CFG_REG(0xE)-Bit Define----------------------------------------//
|
||||
#define FS_MASK 0x03
|
||||
#define FULL_SCALE_2G 0x00 //2g=0x0,4g=0x1,8g=0x2
|
||||
#define FULL_SCALE_4G 0x01
|
||||
#define FULL_SCALE_8G 0x02
|
||||
//---------CTRL_REG1(0X2A)Bit Define------------------------------------------//
|
||||
#define ACTIVE_MASK 1<<0 //bit0
|
||||
#define DR_MASK 0x38 //bit D5,D4,D3
|
||||
#define FHZ800 0x0 //800hz
|
||||
#define FHZ400 0x1 //400hz
|
||||
#define FHZ200 0x2 //200hz
|
||||
#define FHZ100 0x3 //100hz
|
||||
#define FHZ50 0x4 //50hz
|
||||
#define FHZ2 0x5 //12.5hz
|
||||
#define FHZ1 0x6 //6.25hz
|
||||
#define FHZ0 0x7 //1.563hz
|
||||
#define DataRateValue FHZ100
|
||||
//---------CTRL_REG2(0X2B)Bit Define------------------------------------------//
|
||||
#define MODS_MASK 0x03 //Oversampling Mode 4
|
||||
#define Normal_Mode 0x0 //Normal=0,Low Noise Low Power MODS=1,
|
||||
//HI RESOLUTION=2,LOW POWER MODS = 11
|
||||
//----CTRL_REG4---Interrupt Enable BIT ---------------------------------------//
|
||||
//0 interrupt is disabled (default)
|
||||
//1 interrupt is enabled
|
||||
#define INT_EN_ASLP 1<<7 //Auto-SLEEP/WAKE Interrupt Enable
|
||||
#define INT_EN_FIFO 1<<6 //FIFO Interrupt Enable
|
||||
#define INT_EN_TRANS 1<<5 //Transient Interrupt Enable
|
||||
#define INT_EN_LNDPRT 1<<4 //Orientation(Landscape/Portrait)Interrupt Enable
|
||||
#define INT_EN_PULSE 1<<3 //Pulse Detection Interrupt Enable
|
||||
#define INT_EN_FF_MT 1<<2 //Freefall/Motion Interrupt Enable
|
||||
#define INT_EN_DRDY 1<<0 //Data Ready Interrupt Enable
|
||||
|
||||
u16 Get_MmaShift(void);
|
||||
void Set_MmaShift(u16 shift);
|
||||
u16 Get_MmaActive(void);
|
||||
void MMA865x_Standby(void);
|
||||
void MMA865x_Active(void);
|
||||
u16 Cheak_XYData(u16 x0,u16 y0,u16 x1,u16 y1);
|
||||
u16 Update_X(void);
|
||||
u16 Update_Y(void);
|
||||
u16 Update_Z(void);
|
||||
void Check_Accelerated(void);
|
||||
void StartUp_Accelerated(void);
|
||||
#endif
|
||||
/******************************** END OF FILE *********************************/
|
||||
33
S100App/Inc/Oled.h
Normal file
33
S100App/Inc/Oled.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : Oled.h
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/07
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
#ifndef _OLED_SSD1306_H
|
||||
#define _OLED_SSD1306_H
|
||||
|
||||
#define DEVICEADDR_OLED 0x3c
|
||||
|
||||
void Sc_Pt(u8 Co);
|
||||
void Oled_DisplayOn(void);
|
||||
void Oled_DisplayOff(void);
|
||||
u8* Oled_DrawArea(u8 x0,u8 y0,u8 wide, u8 high,u8* ptr);
|
||||
void Set_ShowPos(u8 x,u8 y);
|
||||
|
||||
u8* Show_posi(u8 posi,u8* ptr,u8 word_width);
|
||||
void Clean_Char(int k,u8 wide);
|
||||
void Write_Command(u8 Data);
|
||||
void Write_Data(u8 Data);
|
||||
void GPIO_Init_OLED(void);
|
||||
void Init_Oled(void);
|
||||
u8* Data_Command(u8 len,u8* ptr);
|
||||
void Reg_Command(u8 posi,u8 flag);
|
||||
void Clear_Screen(void);
|
||||
void Write_InitCommand_data(u32 Com_len,u8* data);
|
||||
void Display_BG(void);
|
||||
#endif
|
||||
/******************************** END OF FILE *********************************/
|
||||
81
S100App/Inc/S100V0_1.h
Normal file
81
S100App/Inc/S100V0_1.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
||||
Brief : <20>ײ<EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Author : bure
|
||||
*******************************************************************************/
|
||||
#include "STM32F10x.h"
|
||||
|
||||
#define PRODUCT_INFO "TS100"
|
||||
#define MCU_TYPE "STM32F103T8"
|
||||
#define ADC_TYPE "MCU's ADC"
|
||||
#define FPGA_TYPE "None"
|
||||
#define SCH_VER "2.46"
|
||||
// #define SSD1316 1
|
||||
// #define MFTSEEED "Manufacturer"
|
||||
// #define MFTMINI "Manufacturer"
|
||||
|
||||
#define SPIx SPI1
|
||||
#define FLASH_PAGE 0x0400
|
||||
//--------------------------- key <20><><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD><EFBFBD>ź<EFBFBD> ------------------------------//
|
||||
#define KEY1_PIN GPIO_Pin_9 //PA8
|
||||
#define KEY2_PIN GPIO_Pin_6 //PA6
|
||||
#define KEY_1 !(GPIOA->IDR & KEY1_PIN)
|
||||
#define KEY_2 !(GPIOA->IDR & KEY2_PIN)
|
||||
#define KEY_DFU KEY_1
|
||||
#define KEY_ON 0
|
||||
|
||||
#define I2C1_DMA_CHANNEL_TX DMA1_Channel6
|
||||
#define I2C1_DMA_CHANNEL_RX DMA1_Channel7
|
||||
|
||||
#define I2C2_DMA_CHANNEL_TX DMA1_Channel4
|
||||
#define I2C2_DMA_CHANNEL_RX DMA1_Channel5
|
||||
|
||||
#define I2C1_DR_Address 0x40005410
|
||||
#define I2C2_DR_Address 0x40005810
|
||||
|
||||
|
||||
#define SERIAL_NO1 (*(u32*)0x1FFFF7E8)
|
||||
#define SERIAL_NO2 (*(u32*)0x1FFFF7EC)
|
||||
#define SERIAL_NO3 (*(u32*)0x1FFFF7F0)
|
||||
|
||||
//--------------------------- OLED <20><><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD><EFBFBD>ź<EFBFBD> ------------------------------//
|
||||
#define OLED_RST_PIN GPIO_Pin_8 //PA9
|
||||
#define OLED_RST() GPIO_ResetBits(GPIOA, OLED_RST_PIN)
|
||||
#define OLED_ACT() GPIO_SetBits (GPIOA, OLED_RST_PIN)
|
||||
|
||||
//------------------------------ <20><><EFBFBD>ȿ<EFBFBD><C8BF><EFBFBD><EFBFBD>ź<EFBFBD> --------------------------------//
|
||||
#define HEAT_PIN GPIO_Pin_4 //PA15(JTDI)
|
||||
|
||||
#define HEAT_OFF() GPIOB->BRR = HEAT_PIN//GPIO_ResetBits(GPIOB, HEAT_PIN)
|
||||
#define HEAT_ON() GPIOB->BSRR = HEAT_PIN//GPIO_SetBits (GPIOB, HEAT_PIN)
|
||||
|
||||
//---------------------<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>--VB---------------------------------------//
|
||||
#define VB_PIN GPIO_Pin_1 //PB1(Ai9)
|
||||
//----------------------------ADX345 INT1,INT2--------------------------------//
|
||||
#define INT1_PIN GPIO_Pin_5 //PB5
|
||||
#define INT2_PIN GPIO_Pin_3 //PB3
|
||||
//------------------------------ GPIO <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD> -------------------------------//
|
||||
|
||||
#define GPIOA_OUTPUT() GPIOA->ODR = 0xFFFF;
|
||||
#define GPIOA_L_DEF() GPIOA->CRL = 0x08888888; /* Ai7 K2 xxx xxx xxx xxx xxx xxx */
|
||||
#define GPIOA_H_DEF() GPIOA->CRH = 0x8BBBB883; /* xxx SWC SWD D+ D- xxx K1 nCR */
|
||||
|
||||
#define GPIOB_OUTPUT() GPIOB->ODR = 0xFFFF;
|
||||
#define GPIOB_L_DEF() GPIOB->CRL = 0x44838800; /* SDA SCL It1 Po It2 xxx Ai9 Ai8 */
|
||||
#define GPIOB_H_DEF() GPIOB->CRH = 0x88888888; /* xxx xxx xxx xxx xxx xxx xxx xxx */
|
||||
|
||||
|
||||
//--------------------------------- RCC <20><><EFBFBD><EFBFBD> ---------------------------------//
|
||||
|
||||
#define RCC_PLL_EN() RCC->CR |= 0x01000000;// PLL En
|
||||
|
||||
#define RCC_CFGR_CFG() RCC->CFGR |= 0x0068840A;/*RCC peripheral clock config
|
||||
|||||||+--Bits3~0 = 1010 PLL used as sys clock
|
||||
||||||+---Bits7~4 = 0000 AHB clock = SYSCLK
|
||||
|||||+----Bits10~8 = 100 PCLK1=HCLK divided by 2
|
||||
||||++----Bits13~11 = 000 PCLK2=HCLK
|
||||
||||+-----Bits15~14 = 10 ADC prescaler PCLK2 divided by 6
|
||||
|||+------Bit17~16 = 00 HSI/2 clock selected as PLL input clock
|
||||
||++------Bits21~18 = 1010 PLL input clock x12
|
||||
||+-------Bit22 = 1 USB prescaler is PLL clock
|
||||
++--------Bits31~27 Reserved*/
|
||||
|
||||
/******************************** END OF FILE *********************************/
|
||||
46
S100App/Inc/UI.h
Normal file
46
S100App/Inc/UI.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : UI.h
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/07
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
#ifndef _UI_H
|
||||
#define _UI_H
|
||||
|
||||
#include "STM32F10x.h"
|
||||
|
||||
u32 Get_UpdataFlag(void);
|
||||
void Set_UpdataFlag(u32 Cont);
|
||||
void APP_Init(void);
|
||||
u32 Calculation_TWork(u8 Flag);
|
||||
void Temp_SetProc(void);
|
||||
void Display_Temp(u8 x,s16 Temp);
|
||||
void Show_Notice(void);
|
||||
void Show_Warning(void);
|
||||
void Show_MiniTS(void);
|
||||
void Show_TempDown(s16 Temp,s16 Dst_Temp);
|
||||
void Set_TemperatureShowFlag(u8 flag);
|
||||
s16 TemperatureShow_Change(u8 flag ,s16 Tmp);
|
||||
u8 Get_TemperatureShowFlag(void);
|
||||
void Show_Ver(u8 ver[],u8 flag);
|
||||
void Show_Triangle(u8 empty,u8 fill);
|
||||
void Shift_Char(u8* ptr,u8 pos);
|
||||
void Show_Set(void);
|
||||
void Show_OrderChar(u8* ptr,u8 num,u8 width);
|
||||
u8 Reverse_Bin8(u8 data);
|
||||
void Show_ReverseChar(u8* ptr,u8 num,u8 width,u8 direction);
|
||||
u8 Show_TempReverse(u8 num,u8 width,u8 direction);
|
||||
void Show_HeatingIcon(u32 ht_flag,u16 active);
|
||||
void Display_Str(u8 x, char* str);
|
||||
void Display_Str10(u8 x, char* str);
|
||||
void Clear_Pervious(u16 data);
|
||||
void Print_Integer(s32 data,u8 posi);
|
||||
u8 Roll_Num(u16 Step,u8 Flag);
|
||||
void OLed_Display(void);
|
||||
void Show_Cal(u8 flag);
|
||||
void Show_Config(void);
|
||||
#endif
|
||||
/******************************** END OF FILE *********************************/
|
||||
73
S100App/Inc/USB_bot.h
Normal file
73
S100App/Inc/USB_bot.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/******************** (C) COPYRIGHT 2013 e-Design Co., Ltd. ********************
|
||||
File Name : USB_bot.h
|
||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#ifndef __USB_BOT_H
|
||||
#define __USB_BOT_H
|
||||
|
||||
typedef struct _Bulk_Only_CBW
|
||||
{
|
||||
u32 dSignature;
|
||||
u32 dTag;
|
||||
u32 dDataLength;
|
||||
u8 bmFlags;
|
||||
u8 bLUN;
|
||||
u8 bCBLength;
|
||||
u8 CB[16];
|
||||
}
|
||||
Bulk_Only_CBW;
|
||||
|
||||
/* Bulk-only Command Status Wrapper */
|
||||
typedef struct _Bulk_Only_CSW
|
||||
{
|
||||
u32 dSignature;
|
||||
u32 dTag;
|
||||
u32 dDataResidue;
|
||||
u8 bStatus;
|
||||
}
|
||||
Bulk_Only_CSW;
|
||||
|
||||
#define BOT_IDLE 0 /* Idle state */
|
||||
#define BOT_DATA_OUT 1 /* Data Out state */
|
||||
#define BOT_DATA_IN 2 /* Data In state */
|
||||
#define BOT_DATA_IN_LAST 3 /* Last Data In Last */
|
||||
#define BOT_CSW_Send 4 /* Command Status Wrapper */
|
||||
#define BOT_ERROR 5 /* error state */
|
||||
|
||||
#define BOT_CBW_SIGNATURE 0x43425355
|
||||
#define BOT_CSW_SIGNATURE 0x53425355
|
||||
#define BOT_CBW_PACKET_LENGTH 31
|
||||
|
||||
#define CSW_DATA_LENGTH 0x000D
|
||||
|
||||
/* CSW Status Definitions */
|
||||
#define CSW_CMD_PASSED 0x00
|
||||
#define CSW_CMD_FAILED 0x01
|
||||
#define CSW_PHASE_ERROR 0x02
|
||||
|
||||
#define SEND_CSW_DISABLE 0
|
||||
#define SEND_CSW_ENABLE 1
|
||||
|
||||
#define DIR_IN 0
|
||||
#define DIR_OUT 1
|
||||
#define BOTH_DIR 2
|
||||
|
||||
#define BULK_MAX_PACKET_SIZE 0x00000040
|
||||
|
||||
extern u8 Bot_State;
|
||||
extern u16 Data_Len;
|
||||
extern u8 Bot_State;
|
||||
extern Bulk_Only_CBW CBW;
|
||||
extern Bulk_Only_CSW CSW;
|
||||
extern u8 Bulk_Buff[];
|
||||
|
||||
void Mass_Storage_In (void);
|
||||
void Mass_Storage_Out (void);
|
||||
void CBW_Decode(void);
|
||||
void Transfer_Data_Request(u8* Data_Pointer, u16 Data_Len);
|
||||
void Set_CSW (u8 CSW_Status, u8 Send_Permission);
|
||||
void Bot_Abort(u8 Direction);
|
||||
|
||||
#endif
|
||||
/********************************* END OF FILE ******************************/
|
||||
|
||||
73
S100App/Inc/USB_conf.h
Normal file
73
S100App/Inc/USB_conf.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
|
||||
* File Name : usb_conf.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V2.2.1
|
||||
* Date : 09/22/2008
|
||||
* Description : Mass Storage Demo configuration header
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USB_CONF_H
|
||||
#define __USB_CONF_H
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/* EP_NUM */
|
||||
/* defines how many endpoints are used by the device */
|
||||
/*-------------------------------------------------------------*/
|
||||
#define EP_NUM (3)
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/* -------------- Buffer Description Table -----------------*/
|
||||
/*-------------------------------------------------------------*/
|
||||
/* buffer table base address */
|
||||
|
||||
#define BTABLE_ADDRESS (0x00)
|
||||
|
||||
/* EP0 */
|
||||
/* rx/tx buffer base address */
|
||||
#define ENDP0_RXADDR (0x18)
|
||||
#define ENDP0_TXADDR (0x58)
|
||||
|
||||
/* EP1 */
|
||||
/* tx buffer base address */
|
||||
#define ENDP1_TXADDR (0x98)
|
||||
|
||||
/* EP2 */
|
||||
/* Rx buffer base address */
|
||||
#define ENDP2_RXADDR (0xD8)
|
||||
|
||||
|
||||
/* ISTR events */
|
||||
/* IMR_MSK */
|
||||
/* mask defining which events has to be handled */
|
||||
/* by the device application software */
|
||||
#define IMR_MSK (CNTR_CTRM | CNTR_RESETM)
|
||||
|
||||
/* CTR service routines */
|
||||
/* associated to defined endpoints */
|
||||
//#define EP1_IN_Callback NOP_Process
|
||||
#define EP2_IN_Callback NOP_Process
|
||||
#define EP3_IN_Callback NOP_Process
|
||||
#define EP4_IN_Callback NOP_Process
|
||||
#define EP5_IN_Callback NOP_Process
|
||||
#define EP6_IN_Callback NOP_Process
|
||||
#define EP7_IN_Callback NOP_Process
|
||||
|
||||
|
||||
#define EP1_OUT_Callback NOP_Process
|
||||
//#define EP2_OUT_Callback NOP_Process
|
||||
#define EP3_OUT_Callback NOP_Process
|
||||
#define EP4_OUT_Callback NOP_Process
|
||||
#define EP5_OUT_Callback NOP_Process
|
||||
#define EP6_OUT_Callback NOP_Process
|
||||
#define EP7_OUT_Callback NOP_Process
|
||||
|
||||
#endif /* __USB_CONF_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
|
||||
35
S100App/Inc/USB_desc.h
Normal file
35
S100App/Inc/USB_desc.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
||||
File Name : USB_desc.h
|
||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#ifndef __USB_DESC_H
|
||||
#define __USB_DESC_H
|
||||
|
||||
#ifdef STM32F30X
|
||||
#include "STM32F30x.h"
|
||||
#else
|
||||
#include "STM32F10x.h"
|
||||
#endif
|
||||
|
||||
#define MASS_SIZ_DEVICE_DESC 18
|
||||
#define MASS_SIZ_CONFIG_DESC 32
|
||||
|
||||
#define MASS_SIZ_STRING_LANGID 4
|
||||
#define MASS_SIZ_STRING_VENDOR 38
|
||||
#define MASS_SIZ_STRING_PRODUCT 38
|
||||
#define MASS_SIZ_STRING_SERIAL 26
|
||||
#define MASS_SIZ_STRING_INTERFACE 16
|
||||
|
||||
extern const u8 MASS_DeviceDescriptor[MASS_SIZ_DEVICE_DESC];
|
||||
extern const u8 MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC];
|
||||
|
||||
extern const u8 MASS_StringLangID[MASS_SIZ_STRING_LANGID];
|
||||
extern const u8 MASS_StringVendor[MASS_SIZ_STRING_VENDOR];
|
||||
extern const u8 MASS_StringProduct[MASS_SIZ_STRING_PRODUCT];
|
||||
extern u8 MASS_StringSerial[MASS_SIZ_STRING_SERIAL];
|
||||
extern const u8 MASS_StringInterface[MASS_SIZ_STRING_INTERFACE];
|
||||
|
||||
#endif
|
||||
/********************************* END OF FILE ******************************/
|
||||
|
||||
|
||||
64
S100App/Inc/USB_istr.h
Normal file
64
S100App/Inc/USB_istr.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
||||
File Name : USB_istr.h
|
||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#ifndef __USB_ISTR_H
|
||||
#define __USB_ISTR_H
|
||||
|
||||
#include "usb_conf.h"
|
||||
|
||||
void CTR_HP(void);
|
||||
void USB_Istr(void);
|
||||
|
||||
/* function prototypes Automatically built defining related macros */
|
||||
|
||||
#ifdef CTR_CALLBACK
|
||||
void CTR_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef DOVR_CALLBACK
|
||||
void DOVR_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef ERR_CALLBACK
|
||||
void ERR_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef WKUP_CALLBACK
|
||||
void WKUP_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef SUSP_CALLBACK
|
||||
void SUSP_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef RESET_CALLBACK
|
||||
void RESET_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef SOF_CALLBACK
|
||||
void SOF_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef ESOF_CALLBACK
|
||||
void ESOF_Callback(void);
|
||||
#endif
|
||||
|
||||
void EP1_IN_Callback(void);
|
||||
void EP2_IN_Callback(void);
|
||||
void EP3_IN_Callback(void);
|
||||
void EP4_IN_Callback(void);
|
||||
void EP5_IN_Callback(void);
|
||||
void EP6_IN_Callback(void);
|
||||
void EP7_IN_Callback(void);
|
||||
|
||||
void EP1_OUT_Callback(void);
|
||||
void EP2_OUT_Callback(void);
|
||||
void EP3_OUT_Callback(void);
|
||||
void EP4_OUT_Callback(void);
|
||||
void EP5_OUT_Callback(void);
|
||||
void EP6_OUT_Callback(void);
|
||||
void EP7_OUT_Callback(void);
|
||||
|
||||
#endif
|
||||
/********************************* END OF FILE ******************************/
|
||||
51
S100App/Inc/USB_prop.h
Normal file
51
S100App/Inc/USB_prop.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
||||
File Name : USB_prop.h
|
||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#ifndef __usb_prop_H
|
||||
#define __usb_prop_H
|
||||
|
||||
#include "USB_core.h"
|
||||
|
||||
#ifdef STM32F30X
|
||||
#include "STM32F30x.h"
|
||||
#elif STM32F10X_HD
|
||||
#include "STM32F10x.h"
|
||||
#endif
|
||||
|
||||
#define Mass_Storage_GetConfiguration NOP_Process
|
||||
/* #define Mass_Storage_SetConfiguration NOP_Process*/
|
||||
#define Mass_Storage_GetInterface NOP_Process
|
||||
#define Mass_Storage_SetInterface NOP_Process
|
||||
#define Mass_Storage_GetStatus NOP_Process
|
||||
/* #define Mass_Storage_ClearFeature NOP_Process*/
|
||||
#define Mass_Storage_SetEndPointFeature NOP_Process
|
||||
#define Mass_Storage_SetDeviceFeature NOP_Process
|
||||
/*#define Mass_Storage_SetDeviceAddress NOP_Process*/
|
||||
|
||||
/* MASS Storage Requests*/
|
||||
#define GET_MAX_LUN 0xFE
|
||||
#define MASS_STORAGE_RESET 0xFF
|
||||
#define LUN_DATA_LENGTH 1
|
||||
|
||||
extern u32 Max_Lun;
|
||||
|
||||
void MASS_init(void);
|
||||
void MASS_Reset(void);
|
||||
void Mass_Storage_SetConfiguration(void);
|
||||
void Mass_Storage_ClearFeature(void);
|
||||
void Mass_Storage_SetDeviceAddress (void);
|
||||
void MASS_Status_In (void);
|
||||
void MASS_Status_Out (void);
|
||||
RESULT MASS_Data_Setup(u8);
|
||||
RESULT MASS_NoData_Setup(u8);
|
||||
RESULT MASS_Get_Interface_Setting(u8 Interface, u8 AlternateSetting);
|
||||
u8 *MASS_GetDeviceDescriptor(u16 );
|
||||
u8 *MASS_GetConfigDescriptor(u16);
|
||||
u8 *MASS_GetStringDescriptor(u16);
|
||||
u8 *Get_Max_Lun(u16 Length);
|
||||
void Get_SerialNum(void);
|
||||
|
||||
#endif
|
||||
/********************************* END OF FILE ******************************/
|
||||
|
||||
42
S100App/Inc/USB_pwr.h
Normal file
42
S100App/Inc/USB_pwr.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
||||
File Name : USB_pwr.h
|
||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#ifndef __USB_PWR_H
|
||||
#define __USB_PWR_H
|
||||
|
||||
#include "usb_core.h"
|
||||
|
||||
typedef enum _RESUME_STATE
|
||||
{
|
||||
RESUME_EXTERNAL,
|
||||
RESUME_INTERNAL,
|
||||
RESUME_LATER,
|
||||
RESUME_WAIT,
|
||||
RESUME_START,
|
||||
RESUME_ON,
|
||||
RESUME_OFF,
|
||||
RESUME_ESOF
|
||||
} RESUME_STATE;
|
||||
|
||||
typedef enum _DEVICE_STATE
|
||||
{
|
||||
UNCONNECTED,
|
||||
ATTACHED,
|
||||
POWERED,
|
||||
SUSPENDED,
|
||||
ADDRESSED,
|
||||
CONFIGURED
|
||||
} DEVICE_STATE;
|
||||
|
||||
void Suspend(void);
|
||||
void Resume_Init(void);
|
||||
void Resume(RESUME_STATE eResumeSetVal);
|
||||
RESULT PowerOn(void);
|
||||
RESULT PowerOff(void);
|
||||
|
||||
extern vu32 bDeviceState; /* USB device status */
|
||||
extern vu8 fSuspendEnabled; /* true when suspend is possible */
|
||||
|
||||
#endif
|
||||
/********************************* END OF FILE ******************************/
|
||||
125
S100App/Inc/USB_scsi.h
Normal file
125
S100App/Inc/USB_scsi.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
||||
File Name : USB_scsi.h
|
||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#ifndef __USB_SCSI_H
|
||||
#define __USB_SCSI_H
|
||||
|
||||
#ifdef STM32F30X
|
||||
#include "STM32F30x.h"
|
||||
#else
|
||||
#include "STM32F10x.h"
|
||||
#endif
|
||||
|
||||
/* SCSI Commands */
|
||||
#define SCSI_FORMAT_UNIT 0x04
|
||||
#define SCSI_INQUIRY 0x12
|
||||
#define SCSI_MODE_SELECT6 0x15
|
||||
#define SCSI_MODE_SELECT10 0x55
|
||||
#define SCSI_MODE_SENSE6 0x1A
|
||||
#define SCSI_MODE_SENSE10 0x5A
|
||||
#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1E
|
||||
#define SCSI_READ6 0x08
|
||||
#define SCSI_READ10 0x28
|
||||
#define SCSI_READ12 0xA8
|
||||
#define SCSI_READ16 0x88
|
||||
|
||||
#define SCSI_READ_CAPACITY10 0x25
|
||||
#define SCSI_READ_CAPACITY16 0x9E
|
||||
|
||||
#define SCSI_REQUEST_SENSE 0x03
|
||||
#define SCSI_START_STOP_UNIT 0x1B
|
||||
#define SCSI_TEST_UNIT_READY 0x00
|
||||
#define SCSI_WRITE6 0x0A
|
||||
#define SCSI_WRITE10 0x2A
|
||||
#define SCSI_WRITE12 0xAA
|
||||
#define SCSI_WRITE16 0x8A
|
||||
|
||||
#define SCSI_VERIFY10 0x2F
|
||||
#define SCSI_VERIFY12 0xAF
|
||||
#define SCSI_VERIFY16 0x8F
|
||||
|
||||
#define SCSI_SEND_DIAGNOSTIC 0x1D
|
||||
#define SCSI_READ_FORMAT_CAPACITIES 0x23
|
||||
|
||||
#define NO_SENSE 0
|
||||
#define RECOVERED_ERROR 1
|
||||
#define NOT_READY 2
|
||||
#define MEDIUM_ERROR 3
|
||||
#define HARDWARE_ERROR 4
|
||||
#define ILLEGAL_REQUEST 5
|
||||
#define UNIT_ATTENTION 6
|
||||
#define DATA_PROTECT 7
|
||||
#define BLANK_CHECK 8
|
||||
#define VENDOR_SPECIFIC 9
|
||||
#define COPY_ABORTED 10
|
||||
#define ABORTED_COMMAND 11
|
||||
#define VOLUME_OVERFLOW 13
|
||||
#define MISCOMPARE 14
|
||||
|
||||
|
||||
#define INVALID_COMMAND 0x20
|
||||
#define INVALID_FIELED_IN_COMMAND 0x24
|
||||
#define PARAMETER_LIST_LENGTH_ERROR 0x1A
|
||||
#define INVALID_FIELD_IN_PARAMETER_LIST 0x26
|
||||
#define ADDRESS_OUT_OF_RANGE 0x21
|
||||
#define MEDIUM_NOT_PRESENT 0x3A
|
||||
#define MEDIUM_HAVE_CHANGED 0x28
|
||||
|
||||
#define READ_FORMAT_CAPACITY_DATA_LEN 0x0C
|
||||
#define READ_CAPACITY10_DATA_LEN 0x08
|
||||
#define MODE_SENSE10_DATA_LEN 0x08
|
||||
#define MODE_SENSE6_DATA_LEN 0x04
|
||||
#define REQUEST_SENSE_DATA_LEN 0x12
|
||||
#define STANDARD_INQUIRY_DATA_LEN 0x24 // 0x24
|
||||
#define BLKVFY 0x04
|
||||
|
||||
extern u8 Page00_Inquiry_Data[];
|
||||
extern u8 Standard_Inquiry_Data[];
|
||||
extern u8 Mode_Sense6_data[];
|
||||
extern u8 Mode_Sense10_data[];
|
||||
extern u8 Scsi_Sense_Data[];
|
||||
extern u8 ReadCapacity10_Data[];
|
||||
|
||||
extern u8 Bot_State;
|
||||
|
||||
void SCSI_Inquiry_Cmd(void);
|
||||
void SCSI_ReadFormatCapacity_Cmd(void);
|
||||
void SCSI_ReadCapacity10_Cmd(void);
|
||||
void SCSI_RequestSense_Cmd (void);
|
||||
void SCSI_Start_Stop_Unit_Cmd(void);
|
||||
void SCSI_ModeSense6_Cmd (void);
|
||||
void SCSI_ModeSense10_Cmd (void);
|
||||
void SCSI_Write10_Cmd(u32 LBA , u32 BlockNbr);
|
||||
void SCSI_Read10_Cmd(u32 LBA , u32 BlockNbr);
|
||||
void SCSI_Verify10_Cmd(void);
|
||||
|
||||
void SCSI_Invalid_Cmd(void);
|
||||
void SCSI_Valid_Cmd(void);
|
||||
u8 SCSI_Address_Management(u8 Cmd , u32 LBA , u32 BlockNbr);
|
||||
|
||||
void Set_Scsi_Sense_Data(u8 Sens_Key, u8 Asc);
|
||||
void SCSI_TestUnitReady_Cmd (void);
|
||||
void SCSI_Format_Cmd (void);
|
||||
|
||||
#define SCSI_Prevent_Removal_Cmd SCSI_Valid_Cmd
|
||||
|
||||
// Invalid (Unsupported) commands
|
||||
#define SCSI_READ_CAPACITY16_Cmd SCSI_Invalid_Cmd
|
||||
|
||||
//#define SCSI_FormatUnit_Cmd SCSI_Invalid_Cmd
|
||||
#define SCSI_Write6_Cmd SCSI_Invalid_Cmd
|
||||
#define SCSI_Write16_Cmd SCSI_Invalid_Cmd
|
||||
#define SCSI_Write12_Cmd SCSI_Invalid_Cmd
|
||||
#define SCSI_Read6_Cmd SCSI_Invalid_Cmd
|
||||
#define SCSI_Read12_Cmd SCSI_Invalid_Cmd
|
||||
#define SCSI_Read16_Cmd SCSI_Invalid_Cmd
|
||||
#define SCSI_Send_Diagnostic_Cmd SCSI_Invalid_Cmd
|
||||
#define SCSI_Mode_Select6_Cmd SCSI_Invalid_Cmd
|
||||
#define SCSI_Mode_Select10_Cmd SCSI_Invalid_Cmd
|
||||
#define SCSI_Verify12_Cmd SCSI_Invalid_Cmd
|
||||
#define SCSI_Verify16_Cmd SCSI_Invalid_Cmd
|
||||
|
||||
#endif
|
||||
/********************************* END OF FILE ******************************/
|
||||
|
||||
404
S100App/Inc/WordLib.h
Normal file
404
S100App/Inc/WordLib.h
Normal file
@@ -0,0 +1,404 @@
|
||||
#ifndef _WORDLIB_H
|
||||
#define _WORDLIB_H
|
||||
|
||||
const u8 wordlib[] = { //16*16 <20><><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD>
|
||||
0x00,0x00,0x00,0xF8,0xFE,0x03,0x01,0x01,0x01,0x03,0xFE,0xFC,0xF0,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x3F,0x7F,0xE0,0x80,0x80,0x80,0xC0,0x7F,0x3F,0x07,0x00,0x00,0x00,/*"0",0*/
|
||||
0x00,0x00,0x00,0x08,0x04,0x04,0x06,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x00,0x00,0x00,0x00,/*"1",1*/
|
||||
0x00,0x00,0x00,0x06,0x07,0x01,0x01,0x01,0x81,0xC3,0x7F,0x3E,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0xE0,0xF0,0xD8,0xCC,0xC6,0xC3,0xC0,0xC0,0xE0,0x00,0x00,0x00,0x00,/*"2",2*/
|
||||
0x00,0x00,0x00,0x06,0x07,0x81,0x81,0x81,0xC1,0x63,0x3F,0x1E,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0xE0,0xC0,0x80,0x80,0x81,0x81,0xC3,0x7F,0x3E,0x00,0x00,0x00,0x00,/*"3",3*/
|
||||
0x00,0x00,0x00,0x00,0xC0,0x60,0x38,0x0C,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x06,0x07,0x05,0x04,0x04,0x84,0xFF,0xFF,0xC4,0x84,0x06,0x00,0x00,0x00,/*"4",4*/
|
||||
0x00,0x00,0x00,0xFF,0xFF,0x83,0x83,0x83,0x83,0x83,0x83,0x03,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0xE0,0xC0,0x80,0x80,0x80,0x80,0xC1,0x7F,0x3F,0x08,0x00,0x00,0x00,/*"5",5*/
|
||||
0x00,0x00,0x00,0xE0,0xF8,0x9C,0x8E,0xC2,0xC3,0xC1,0x81,0x81,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x3F,0x7F,0xC0,0x80,0x80,0x80,0x80,0xC1,0x7F,0x3F,0x00,0x00,0x00,/*"6",6*/
|
||||
0x00,0x00,0x00,0x0F,0x03,0x03,0x03,0x03,0x83,0xE3,0x3B,0x0F,0x03,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x80,0xE0,0x78,0x1E,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,/*"7",7*/
|
||||
0x00,0x00,0x18,0x7E,0x7E,0xC3,0x81,0x81,0x81,0x81,0x67,0x7E,0x3C,0x00,0x00,0x00,
|
||||
0x00,0x00,0x1C,0x7E,0xFF,0xC1,0x80,0x80,0x80,0x81,0xE3,0x7F,0x3C,0x00,0x00,0x00,/*"8",8*/
|
||||
0x00,0x00,0x78,0xFE,0xC6,0x03,0x01,0x01,0x01,0x03,0x9E,0xFC,0xF0,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,0x01,0x83,0x83,0xC3,0x61,0x71,0x3F,0x0F,0x01,0x00,0x00,0x00,/*"9",9*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",10*/
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x01,0x01,0x01,0x00,//"+",11
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,//"-",12
|
||||
|
||||
0x0E,0x11,0x11,0x0E,0xE0,0xF8,0x0C,0x06,0x03,0x01,0x01,0x01,0x01,0x02,0x1E,0x00,
|
||||
0x00,0x00,0x00,0x00,0x0F,0x3F,0x70,0xC0,0x80,0x80,0x80,0x80,0x80,0x40,0x20,0x00,/*"<22><>",13*/
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,//":",14
|
||||
|
||||
0x08,0x14,0x22,0x14,0x08,0x02,0x02,0xFE,0x06,0x02,0x02,0x02,0xC2,0x02,0x06,0x1E,
|
||||
0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xFF,0x81,0x81,0x01,0x01,0x03,0x00,0x00,0x00,/*"<22>H",15*/
|
||||
|
||||
0xC0,0x30,0x08,0x04,0x04,0x02,0xFA,0xAA,0xFA,0x02,0x04,0x04,0x08,0x30,0xC0,0x00,
|
||||
0x07,0x18,0x20,0x40,0x58,0xA4,0xDB,0xDE,0xDB,0xA4,0x58,0x40,0x20,0x18,0x07,0x00,/*"<22>¶ȼ<C2B6>",16*/
|
||||
};
|
||||
|
||||
const u8 Maplib[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,
|
||||
0x98,0xBF,0xBF,0x98,0x88,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x60,0x60,0x60,0x60,0x60,0x60,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
|
||||
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
|
||||
0x90,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x70,0xF8,0x88,0x84,0x82,0x82,0x83,
|
||||
0x83,0x83,0x83,0x83,0x83,0x82,0x82,0x82,0x82,0x83,0x83,0x83,0x83,0x83,0x83,0x82,
|
||||
0x82,0x82,0x82,0x82,0x86,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,
|
||||
0x84,0x84,0x84,0x84,0x84,0x84,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,/*"C:\Users\888\Desktop\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.BMP",0*/
|
||||
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,
|
||||
0xB0,0xFE,0xFE,0xB0,0x90,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x60,0x60,0x60,0x60,0x60,0x60,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
|
||||
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
|
||||
0x90,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x70,0xF8,0x88,0x84,0x82,0x82,0x83,
|
||||
0x83,0x83,0x83,0x83,0x83,0x82,0x82,0x82,0x82,0x83,0x83,0x83,0x83,0x83,0x83,0x82,
|
||||
0x82,0x82,0x82,0x82,0x86,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,
|
||||
0x84,0x84,0x84,0x84,0x84,0x84,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,/*"C:\Users\888\Desktop\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.BMP",0*/
|
||||
|
||||
// 0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0x00,0x00,0xF0,0xF0,0xF0,0x00,0x00,0xF0,0xF0,0x00,//"<22><>ͷ"2//
|
||||
// 0x01,0x03,0x07,0x0F,0x1F,0x3F,0x00,0x00,0x0F,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,
|
||||
0x00,0xF0,0xF0,0x00,0x00,0xF0,0xF0,0xF0,0x00,0x00,0xFC,0xF8,0xF0,0xE0,0xC0,0x80, ///"<22><>ͷ"7///
|
||||
0x00,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x0F,0x00,0x00,0x3F,0x1F,0x0F,0x07,0x03,0x01,
|
||||
// 0x00,0xF8,0xF8,0x00,0x00,0xF8,0xF8,0xF8,0xF8,0x00,0x00,0xFE,0xFE,0xF8,0xE0,0x80,
|
||||
// 0x00,0x1F,0x1F,0x00,0x00,0x1F,0x1F,0x1F,0x1F,0x00,0x00,0x7F,0x7F,0x1F,0x07,0x01 //"<22><>ͷ8"//
|
||||
};
|
||||
|
||||
const u8 Maplib1[] = {/* 14 * 16*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",15*/
|
||||
0x00,0x01,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x81,0xC6,0x7E,0x38,
|
||||
0x00,0x80,0xFF,0xFF,0x81,0x81,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,/*"P",0*/
|
||||
0x00,0x20,0x20,0x20,0xE0,0xE0,0x00,0x80,0x40,0x40,0x20,0x60,0xC0,0x40,
|
||||
0x00,0x80,0x80,0x80,0xFF,0xFF,0x81,0x80,0x80,0x80,0x00,0x00,0x00,0x00,/*"r",1*/
|
||||
0x00,0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x20,0x40,0x40,0x80,0x00,0x00,
|
||||
0x00,0x00,0x3F,0x7F,0x44,0x84,0x84,0x84,0x84,0x84,0x84,0x47,0x27,0x00,/*"e",2*/
|
||||
0x00,0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x20,0x40,0x40,0xC0,0x00,0x00,
|
||||
0x00,0x00,0x20,0xC3,0x82,0x86,0x84,0x84,0x8C,0x8C,0x88,0x78,0x30,0x00,/*"s",3*/
|
||||
0x00,0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x20,0x40,0x40,0xC0,0x00,0x00,
|
||||
0x00,0x00,0x20,0xC3,0x82,0x86,0x84,0x84,0x8C,0x8C,0x88,0x78,0x30,0x00,/*"s",4*/
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0x60,0x20,0x10,0x18,0x0C,0x86,
|
||||
0xE0,0xE0,0xE0,0xEC,0xFC,0xF2,0xF3,0xF1,0xF0,0xF8,0xEC,0xE4,0xE4,0xE2,0xE3,0x01,/*"C:\Users\888\Desktop\sssss.BMP",0*/
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x40,0x20,0x30,0x18,0x0C,
|
||||
0xC0,0xC0,0xC0,0xD8,0xF8,0xE4,0xE6,0xE3,0xE1,0xF1,0xD8,0xC8,0xC8,0xC4,0xC6,0x03,/*"C:\Users\888\Desktop\sssss.BMP",0*/
|
||||
|
||||
0xFC,0xFC,0xFC,0x00,0x00,0x00,0x00,0xC0,0x38,0x26,0x25,0x01,0x01,0x01,0x01,0x01,
|
||||
0x01,0x01,0x01,0x02,0x7F,0x7F,0x7F,0x06,0x09,0x09,0x09,0x09,0x09,0x09,0x39,0x48,
|
||||
0x48,0x48,0x48,0x30,0x10,0x08,0x08,0x04,/*"C:\Users\888\Desktop\<5C><><EFBFBD><EFBFBD>.BMP",0*/
|
||||
|
||||
0xFC,0xFC,0x00,0x00,0x00,0x00,0xC0,0x38,0x26,0x25,0x01,0x01,0x01,0x01,0x01,0x01,
|
||||
0x01,0x01,0x02,0x02,0x7F,0x7F,0x06,0x09,0x09,0x09,0x09,0x09,0x09,0x39,0x48,0x48,
|
||||
0x48,0x48,0x30,0x10,0x08,0x08,0x04,0x04,/*"C:\Users\888\Desktop\<5C><><EFBFBD><EFBFBD>.BMP",0*/
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0x60,0x30,0x18,0x0C,0x86,
|
||||
0x00,0xE0,0xE0,0xEC,0xF4,0xF6,0xF6,0xFB,0xF5,0xE8,0xE8,0xE4,0xE2,0xE2,0xE1,0x00,/*"δ<><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>",0*/
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x60,0x30,0x18,0x0C,
|
||||
0x00,0xC0,0xC0,0xD8,0xE8,0xEC,0xEC,0xF6,0xEB,0xD1,0xD1,0xC8,0xC4,0xC4,0xC2,0x01,/*"δ<><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>",0*/
|
||||
|
||||
0xFE,0xFE,0xFE,0x80,0x40,0x40,0x60,0x58,0x54,0x02,0x02,0x02,0x02,0x02,0x02,0x84,
|
||||
0x3F,0x3F,0x3F,0x00,0x01,0x01,0x01,0x01,0x01,0x07,0x05,0x05,0x06,0x02,0x01,0x00,/*"δ<><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>",0*/
|
||||
|
||||
0xFE,0xFE,0x80,0x40,0x40,0x60,0x58,0x54,0x02,0x02,0x02,0x02,0x02,0x02,0x84,0x84,
|
||||
0x3F,0x3F,0x00,0x01,0x01,0x01,0x01,0x01,0x07,0x05,0x05,0x06,0x02,0x01,0x00,0x00,/*"δ<><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>",0*/
|
||||
};
|
||||
|
||||
const u8 MiniTS[] = {/*16*16*/
|
||||
0x01,0xF9,0xFF,0x3F,0xFF,0xF0,0x80,0x00,0x80,0xF0,0x7E,0xFF,0xFF,0xFF,0x01,0x01,
|
||||
0x80,0xFF,0xFF,0x80,0x83,0x1F,0xFF,0xF8,0x3F,0x87,0x80,0xFF,0xFF,0xFF,0x80,0x80,/*"M",0*/
|
||||
0x00,0x00,0x00,0x20,0x20,0x20,0x63,0xE3,0xE3,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x80,0x00,0x00,0x00,/*"i",1*/
|
||||
0x00,0x20,0xE0,0xE0,0xE0,0xC0,0x40,0x60,0x20,0x20,0x60,0xC0,0xC0,0x00,0x00,0x00,
|
||||
0x00,0x80,0xFF,0xFF,0xFF,0x80,0x80,0x00,0x00,0x80,0x80,0xFF,0xFF,0x80,0x80,0x00,/*"n",2*/
|
||||
0x00,0x00,0x00,0x20,0x20,0x20,0x63,0xE3,0xE3,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x80,0x00,0x00,0x00,/*"i",3*/
|
||||
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"-",4*/
|
||||
0x00,0x06,0x07,0x03,0x01,0x01,0xFF,0xFF,0xFF,0x01,0x01,0x01,0x03,0x0F,0x0C,0x00,
|
||||
0x00,0x00,0x00,0x00,0x80,0x80,0xFF,0xFF,0xFF,0x80,0x80,0x00,0x00,0x00,0x00,0x00,/*"T",5*/
|
||||
0x00,0x00,0x00,0x80,0xC0,0x40,0x60,0x20,0x20,0x60,0x40,0xC0,0x80,0x00,0x00,0x00,
|
||||
0x00,0x0E,0x3F,0x7F,0xE1,0x80,0x80,0x80,0x80,0x80,0xC0,0x71,0x7F,0x3F,0x00,0x00,/*"o",6*/
|
||||
0x00,0x00,0x00,0x80,0xC0,0x40,0x60,0x20,0x20,0x60,0x40,0xC0,0x80,0x00,0x00,0x00,
|
||||
0x00,0x0E,0x3F,0x7F,0xE1,0x80,0x80,0x80,0x80,0x80,0xC0,0x71,0x7F,0x3F,0x00,0x00,/*"o",7*/
|
||||
0x00,0x00,0x00,0x01,0x01,0x01,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x80,0x00,0x00,0x00,/*"l",8*/
|
||||
0x00,0x00,0x00,0x80,0xC0,0x40,0x60,0x20,0x20,0x60,0x40,0xC0,0xC0,0x00,0x00,0x00,
|
||||
0x00,0x00,0x20,0xE3,0xC3,0x86,0x86,0x84,0x8C,0x8C,0x8C,0xF8,0x78,0x30,0x00,0x00,/*"s",9*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",10*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",11*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",12*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",13*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",14*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",15*/
|
||||
};
|
||||
//const u8 Arrow[] = {/*16*16*/
|
||||
// 0x00,0x03,0x0E,0x18,0x60,0xC3,0x06,0x18,0x70,0xC0,0x00,0x00,0x00,0x80,0x60,0x38,
|
||||
// 0x0C,0x83,0xC1,0x30,0x0C,0x07,0x01,0x00,/*"<22><>",0*/
|
||||
|
||||
// 0x00,0x00,0xC0,0x60,0x18,0x0C,0xC3,0x71,0x18,0x06,0x03,0x00,0x00,0x01,0x03,0x0C,
|
||||
// 0x30,0x61,0x87,0x0C,0x30,0xE0,0x80,0x00,/*"<22><>",0*/
|
||||
|
||||
// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",0*/
|
||||
//};
|
||||
const u8 Triangle[] = {/*16*16*/
|
||||
0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0xFE,0x00,0x00,0x00,
|
||||
0x00,0x00,0x01,0x01,0x02,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x3F,0x00,0x00,0x00,/*"<22><><EFBFBD><EFBFBD>",0*/
|
||||
|
||||
0x00,0x00,0xFE,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x80,0x80,0x00,
|
||||
0x00,0x00,0x3F,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x01,0x01,0x00,0x00,0x00,/*"<22>ҡ<EFBFBD>",0*/
|
||||
|
||||
0x00,0x80,0x80,0xC0,0xC0,0x60,0x60,0x30,0x30,0x18,0x18,0x0C,0x0C,0xFE,0x00,0x00,
|
||||
0x00,0x01,0x01,0x03,0x03,0x06,0x06,0x0C,0x0C,0x18,0x18,0x30,0x30,0x7F,0x00,0x00,/*"<22>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD>",0*/
|
||||
|
||||
0x00,0x00,0xFE,0x0C,0x0C,0x18,0x18,0x30,0x30,0x60,0x60,0xC0,0xC0,0x80,0x80,0x00,
|
||||
0x00,0x00,0x7F,0x30,0x30,0x18,0x18,0x0C,0x0C,0x06,0x06,0x03,0x03,0x01,0x01,0x00,/*"<22>Ӵ<EFBFBD><D3B4>ҡ<EFBFBD>",0*/
|
||||
|
||||
0x80,0x80,0xC0,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFE,0x00,0x00,0x00,
|
||||
0x00,0x00,0x01,0x01,0x03,0x03,0x07,0x07,0x0F,0x0F,0x1F,0x1F,0x3F,0x00,0x00,0x00,/*"<22><><EFBFBD><EFBFBD>",1*/
|
||||
|
||||
0x00,0x00,0xFE,0xFC,0xFC,0xF8,0xF8,0xF0,0xF0,0xE0,0xE0,0xC0,0xC0,0x80,0x80,0x00,
|
||||
0x00,0x00,0x3F,0x1F,0x1F,0x0F,0x0F,0x07,0x07,0x03,0x03,0x01,0x01,0x00,0x00,0x00,/*"<22>ҡ<EFBFBD>",1*/
|
||||
};
|
||||
|
||||
const u8 IhIcon[] = {
|
||||
0x00,0xF0,0xFE,0xFF,0xF0,0x00,
|
||||
0x00,0x7F,0x7F,0x7F,0x7F,0x00,/*"<22><><EFBFBD><EFBFBD>",0*/
|
||||
|
||||
0xFF,0x0F,0xE1,0xE0,0x0F,0xFF,
|
||||
0xFF,0x80,0xBF,0xBF,0x80,0xFF,/*"<22><><EFBFBD><EFBFBD>",0*/
|
||||
};
|
||||
const u8 TempIcon[] = {/*16*16*/
|
||||
0x10,0x18,0x8C,0xC6,0x63,0x63,0xC6,0x8C,0x18,0x10,
|
||||
0x42,0x63,0x31,0x18,0x0C,0x0C,0x18,0x31,0x63,0x42,/*"10*16",0*/
|
||||
|
||||
0x00,0xF0,0x1E,0x1F,0xF0,0x00,
|
||||
0x00,0xFF,0x80,0x80,0xFF,0x00,/*"6*16",0*/
|
||||
|
||||
0x42,0xC6,0x8C,0x18,0x30,0x30,0x18,0x8C,0xC6,0x42,
|
||||
0x08,0x18,0x31,0x63,0xC6,0xC6,0x63,0x31,0x18,0x08,/*"10*16",1*/
|
||||
|
||||
0x8C,0x8C,0xC6,0xC6,0x8C,0x8C,0xC6,0xC6,0x8C,0x8C,
|
||||
0x31,0x31,0x18,0x18,0x31,0x31,0x18,0x18,0x31,0x31,/*"10*16",2*/
|
||||
|
||||
|
||||
0x00,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x00,
|
||||
0x00,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x00,/*"<22>¶<EFBFBD>ƽ<EFBFBD><C6BD>",0*/
|
||||
|
||||
0x80,0xC0,0x60,0x30,0x98,0xCC,0x66,0x33,0x33,0x66,0xCC,0x98,0x30,0x60,0xC0,0x80,
|
||||
0x88,0xCC,0x66,0x33,0x19,0x0C,0x06,0x03,0x03,0x06,0x0C,0x19,0x33,0x66,0xCC,0x88,/*"<22><><EFBFBD><EFBFBD>",0*/
|
||||
|
||||
0x11,0x33,0x66,0xCC,0x98,0x30,0x60,0xC0,0xC0,0x60,0x30,0x98,0xCC,0x66,0x33,0x11,
|
||||
0x01,0x03,0x06,0x0C,0x19,0x33,0x66,0xCC,0xCC,0x66,0x33,0x19,0x0C,0x06,0x03,0x01,/*"<22><><EFBFBD><EFBFBD>",0*/
|
||||
};
|
||||
|
||||
const u8 Warning[] = {/*10*16*/
|
||||
0x01,0xFF,0x00,0xE1,0x1F,0xE0,0x00,0xFF,0x01,0x00,0x00,0x01,0x1E,0x01,0x00,0x01,
|
||||
0x1E,0x01,0x00,0x00,/*"W",0*/
|
||||
0x00,0x60,0x10,0x10,0x90,0x90,0xE0,0x00,0x00,0x00,0x00,0x0E,0x11,0x11,0x10,0x08,
|
||||
0x1F,0x18,0x00,0x00,/*"a",1*/
|
||||
0x10,0x10,0xF0,0x40,0x20,0x10,0x10,0x30,0x00,0x00,0x10,0x10,0x1F,0x10,0x10,0x00,
|
||||
0x00,0x00,0x00,0x00,/*"r",2*/
|
||||
0x10,0xF0,0x20,0x10,0x10,0x10,0x10,0xE0,0x00,0x00,0x10,0x1F,0x10,0x00,0x00,0x00,
|
||||
0x10,0x1F,0x10,0x00,/*"n",3*/
|
||||
0x00,0x00,0x10,0x13,0xF3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x1F,0x10,
|
||||
0x10,0x00,0x00,0x00,/*"i",4*/
|
||||
0x10,0xF0,0x20,0x10,0x10,0x10,0x10,0xE0,0x00,0x00,0x10,0x1F,0x10,0x00,0x00,0x00,
|
||||
0x10,0x1F,0x10,0x00,/*"n",5*/
|
||||
0x00,0xE0,0x10,0x10,0x10,0x10,0xF0,0x10,0x00,0x00,0x00,0x7D,0x8A,0x8A,0x8A,0x8A,
|
||||
0x91,0x70,0x00,0x00,/*"g",6*/
|
||||
|
||||
0x00,0x00,0x00,0x80,0xE0,0xF8,0xFE,0x07,0x07,0xFE,0xF8,0xE0,0x80,0x00,0x00,0x00,
|
||||
0x10,0x1C,0x1F,0x1F,0x1F,0x1F,0x1F,0x12,0x12,0x1F,0x1F,0x1F,0x1F,0x1F,0x1C,0x10,/*"C:\Users\888\Desktop\attention.bmp",0*/
|
||||
};
|
||||
const u8 SenErr[] = {/*10*16*/
|
||||
0x00,0x1C,0x22,0x21,0x41,0x41,0x41,0x82,0x07,0x00,0x00,0x1E,0x08,0x10,0x10,0x10,
|
||||
0x10,0x08,0x07,0x00,/*"S",0*/
|
||||
0x00,0xC0,0xA0,0x90,0x90,0x90,0x90,0xA0,0xC0,0x00,0x00,0x07,0x08,0x10,0x10,0x10,
|
||||
0x10,0x08,0x04,0x00,/*"e",1*/
|
||||
0x10,0xF0,0x20,0x10,0x10,0x10,0x10,0xE0,0x00,0x00,0x10,0x1F,0x10,0x00,0x00,0x00,
|
||||
0x10,0x1F,0x10,0x00,/*"n",2*/
|
||||
0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,/*"-",3*/
|
||||
0x01,0xFF,0x21,0x21,0x21,0x21,0xF9,0x03,0x04,0x00,0x10,0x1F,0x10,0x10,0x10,0x10,
|
||||
0x10,0x18,0x04,0x00,/*"E",4*/
|
||||
0x00,0x10,0x10,0xF0,0x40,0x20,0x10,0x10,0x30,0x00,0x00,0x10,0x10,0x1F,0x10,0x10,
|
||||
0x00,0x00,0x00,0x00,/*"r",5*/
|
||||
0x00,0x10,0x10,0xF0,0x40,0x20,0x10,0x10,0x30,0x00,0x00,0x10,0x10,0x1F,0x10,0x10,
|
||||
0x00,0x00,0x00,0x00,/*"r",6*/
|
||||
|
||||
};
|
||||
const u8 HighVt[] = {/*10*16*/
|
||||
0x01,0xFF,0x41,0x40,0x40,0x40,0x41,0xFF,0x01,0x00,0x10,0x1F,0x10,0x00,0x00,0x00,
|
||||
0x10,0x1F,0x10,0x00,/*"H",0*/
|
||||
0x00,0x00,0x10,0x13,0xF3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x1F,0x10,
|
||||
0x10,0x00,0x00,0x00,/*"i",1*/
|
||||
0x00,0x00,0xE0,0x10,0x10,0x10,0x10,0xF0,0x10,0x00,0x00,0x60,0x9D,0x8A,0x8A,0x8A,
|
||||
0x8A,0x91,0x70,0x00,/*"g",2*/
|
||||
0x01,0xFF,0x20,0x10,0x10,0x10,0x10,0xE0,0x00,0x00,0x10,0x1F,0x10,0x00,0x00,0x00,
|
||||
0x10,0x1F,0x10,0x00,/*"h",3*/
|
||||
0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,/*"-",3*/
|
||||
0x01,0x07,0x79,0x80,0x00,0x80,0x79,0x07,0x01,0x00,0x00,0x00,0x00,0x07,0x1C,0x07,
|
||||
0x00,0x00,0x00,0x00,/*"V",5*/
|
||||
0x00,0x00,0x10,0x10,0xFE,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x10,
|
||||
0x10,0x08,0x00,0x00,/*"t",6*/
|
||||
};
|
||||
const u8 LowVot[] = {/*10*16*/
|
||||
0x01,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x1F,0x10,0x10,0x10,0x10,
|
||||
0x10,0x18,0x04,0x00,/*"L",0*/
|
||||
0x00,0xC0,0x20,0x10,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0x07,0x08,0x10,0x10,0x10,
|
||||
0x10,0x08,0x07,0x00,/*"o",1*/
|
||||
0x10,0xF0,0x00,0x10,0xF0,0x10,0x00,0xF0,0x10,0x00,0x00,0x03,0x1C,0x03,0x00,0x03,
|
||||
0x1C,0x03,0x00,0x00,/*"w",2*/
|
||||
0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,/*"-",3*/
|
||||
0x01,0x07,0x79,0x80,0x00,0x80,0x79,0x07,0x01,0x00,0x00,0x00,0x00,0x07,0x1C,0x07,
|
||||
0x00,0x00,0x00,0x00,/*"V",4*/
|
||||
0x00,0xC0,0x20,0x10,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0x07,0x08,0x10,0x10,0x10,
|
||||
0x10,0x08,0x07,0x00,/*"o",5*/
|
||||
0x00,0x00,0x10,0x10,0xFE,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x10,
|
||||
0x10,0x08,0x00,0x00,/*"t",6*/
|
||||
};
|
||||
|
||||
const u8 Cal_UnDone[] = { /*16*16 Cal_Ud*/
|
||||
0xE0,0x18,0x04,0x02,0x12,0x21,0x41,0x81,0x81,0x41,0x22,0x12,0x04,0x18,0xE0,0x00,
|
||||
0x03,0x0C,0x10,0x20,0x28,0x44,0x42,0x41,0x41,0x42,0x24,0x28,0x10,0x0C,0x03,0x00,/*"Уʧ<D7BC><CAA7>.BMP",0*/
|
||||
|
||||
0xF0,0x0C,0x02,0x01,0x01,0x01,0x01,0x02,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x03,0x0C,0x08,0x10,0x10,0x10,0x10,0x08,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"C",0*/
|
||||
0x00,0x60,0x10,0x10,0x90,0x90,0x90,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x0E,0x11,0x11,0x10,0x10,0x08,0x1F,0x10,0x18,0x00,0x00,0x00,0x00,0x00,0x00,/*"a",1*/
|
||||
0x00,0x01,0x01,0x01,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x10,0x10,0x10,0x1F,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"l",2*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,/*"_",3*/
|
||||
0x00,0x01,0x07,0x19,0xE0,0xB0,0x0D,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x10,0x18,0x17,0x00,0x01,0x16,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"X",4*/
|
||||
|
||||
};
|
||||
|
||||
const u8 Cal_Done[] = {/*16*16 Cal_Dn*/
|
||||
0xE0,0x18,0x64,0xE2,0x82,0x01,0x01,0x01,0x01,0x01,0x82,0xE2,0x64,0x18,0xE0,0x00,
|
||||
0x03,0x0C,0x10,0x21,0x27,0x4E,0x58,0x50,0x58,0x4E,0x27,0x21,0x10,0x0C,0x03,0x00,/*"У<D0A3>ɹ<EFBFBD>.BMP",0*/
|
||||
|
||||
0xF0,0x0C,0x02,0x01,0x01,0x01,0x01,0x02,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x03,0x0C,0x08,0x10,0x10,0x10,0x10,0x08,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"C",0*/
|
||||
0x00,0x60,0x10,0x10,0x90,0x90,0x90,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x0E,0x11,0x11,0x10,0x10,0x08,0x1F,0x10,0x18,0x00,0x00,0x00,0x00,0x00,0x00,/*"a",1*/
|
||||
0x00,0x01,0x01,0x01,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x10,0x10,0x10,0x1F,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"l",2*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,/*"_",3*/
|
||||
0x01,0x07,0x79,0x80,0x00,0x80,0x79,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x07,0x1C,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"V",4*/
|
||||
|
||||
};
|
||||
|
||||
const u8 Number12[] = {/*12*16*/
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x10,0x20,
|
||||
0x20,0x10,0x0F,0x00,0x00,0x00,0x00,0x00,/*"0",0*/
|
||||
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,
|
||||
0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,/*"1",1*/
|
||||
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x28,0x24,
|
||||
0x22,0x21,0x30,0x00,0x00,0x00,0x00,0x00,/*"2",2*/
|
||||
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x20,0x20,
|
||||
0x20,0x11,0x0E,0x00,0x00,0x00,0x00,0x00,/*"3",3*/
|
||||
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x04,0x24,
|
||||
0x24,0x3F,0x24,0x00,0x00,0x00,0x00,0x00,/*"4",4*/
|
||||
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x21,0x20,
|
||||
0x20,0x11,0x0E,0x00,0x00,0x00,0x00,0x00,/*"5",5*/
|
||||
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x11,0x20,
|
||||
0x20,0x11,0x0E,0x00,0x00,0x00,0x00,0x00,/*"6",6*/
|
||||
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"7",7*/
|
||||
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x21,
|
||||
0x21,0x22,0x1C,0x00,0x00,0x00,0x00,0x00,/*"8",8*/
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x22,
|
||||
0x22,0x11,0x0F,0x00,0x00,0x00,0x00,0x00,/*"9",9*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*".",10*/
|
||||
};
|
||||
|
||||
const u8 Number10[] = { /*10*16*/
|
||||
0x00,0xE0,0x18,0x04,0x04,0x04,0x04,0x18,0xE0,0x00,0x00,0x0F,0x30,0x40,0x40,0x40,
|
||||
0x40,0x30,0x0F,0x00,/*"0",0*/
|
||||
0x00,0x00,0x08,0x08,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x7F,0x40,
|
||||
0x40,0x00,0x00,0x00,/*"1",1*/
|
||||
0x00,0x78,0x04,0x04,0x04,0x04,0x04,0x88,0x70,0x00,0x00,0x60,0x50,0x48,0x44,0x42,
|
||||
0x41,0x40,0x70,0x00,/*"2",2*/
|
||||
0x00,0x38,0x04,0x04,0x84,0x84,0xC8,0x30,0x00,0x00,0x00,0x38,0x40,0x40,0x40,0x40,
|
||||
0x40,0x21,0x1E,0x00,/*"3",3*/
|
||||
0x00,0x00,0x80,0x60,0x10,0x08,0xFE,0x00,0x00,0x00,0x00,0x07,0x04,0x04,0x44,0x44,
|
||||
0x7F,0x44,0x44,0x00,/*"4",4*/
|
||||
0x00,0x00,0xFC,0x04,0x84,0x84,0x84,0x04,0x04,0x00,0x00,0x38,0x41,0x41,0x40,0x40,
|
||||
0x40,0x21,0x1E,0x00,/*"5",5*/
|
||||
0x00,0xC0,0x30,0x88,0x84,0x84,0x84,0x04,0x18,0x00,0x00,0x0F,0x31,0x40,0x40,0x40,
|
||||
0x40,0x21,0x1E,0x00,/*"6",6*/
|
||||
0x00,0x1C,0x04,0x04,0x84,0x44,0x34,0x0C,0x04,0x00,0x00,0x00,0x00,0x7E,0x01,0x00,
|
||||
0x00,0x00,0x00,0x00,/*"7",7*/
|
||||
0x00,0x70,0x88,0x04,0x04,0x04,0x04,0x88,0x70,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,
|
||||
0x41,0x22,0x1C,0x00,/*"8",8*/
|
||||
0x00,0xF0,0x08,0x04,0x04,0x04,0x04,0x18,0xE0,0x00,0x00,0x30,0x41,0x42,0x42,0x42,
|
||||
0x22,0x19,0x07,0x00,/*"9",9*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,/*" ",10*/
|
||||
0x1C,0x1C,0xC0,0x30,0x08,0x04,0x04,0x04,0x08,0x30,0x00,0x00,0x07,0x18,0x20,0x40,
|
||||
0x40,0x40,0x20,0x10,/*"<22><>",11*/
|
||||
0x1C,0x12,0x0C,0x02,0x02,0xFE,0x82,0x82,0xE2,0x02,0x00,0x00,0x00,0x00,0x40,0x7F,
|
||||
0x40,0x00,0x03,0x00,/*"<22>H",12*/
|
||||
|
||||
};
|
||||
|
||||
const u8 Guide[] = { /*16*16*/
|
||||
0x00,0x00,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x18,0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<5C><><EFBFBD><EFBFBD>.BMP",0*/
|
||||
0x00,0x00,0x30,0x60,0xC0,0x80,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x18,0x0C,0x06,0x03,0x19,0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,/*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<5C><><EFBFBD><EFBFBD>.BMP",0*/
|
||||
0x00,0x00,0x30,0x60,0xC0,0x80,0x30,0x60,0xC0,0x80,0x30,0x60,0xC0,0x80,0x00,0x00,
|
||||
0x00,0x00,0x18,0x0C,0x06,0x03,0x19,0x0C,0x06,0x03,0x19,0x0C,0x06,0x03,0x01,0x00,/*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<5C><><EFBFBD><EFBFBD>.BMP",0*/
|
||||
0x00,0x00,0x18,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*">",0*/
|
||||
0x00,0x00,0x18,0x30,0x60,0xC0,0x98,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x0C,0x06,0x03,0x01,0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,/*">>",0*/
|
||||
0x00,0x00,0x18,0x30,0x60,0xC0,0x98,0x30,0x60,0xC0,0x98,0x30,0x60,0xC0,0x80,0x00,
|
||||
0x00,0x00,0x0C,0x06,0x03,0x01,0x0C,0x06,0x03,0x01,0x0C,0x06,0x03,0x01,0x00,0x00,/*">>>",0*/
|
||||
};
|
||||
const u8 Config[] = { /*16*16*/
|
||||
0x00,0x00,0x00,0xC0,0xF0,0x38,0x08,0x04,0x04,0x04,0x04,0x08,0x08,0x1C,0x00,0x00,
|
||||
0x00,0x00,0x00,0x0F,0x1F,0x30,0x60,0x40,0x40,0x40,0x40,0x20,0x30,0x08,0x00,0x00,/*"C",0*/
|
||||
0x00,0x00,0x00,0xC0,0xF0,0x18,0x0C,0x04,0x04,0x04,0x0C,0x18,0xF0,0xC0,0x00,0x00,
|
||||
0x00,0x00,0x00,0x07,0x1F,0x30,0x60,0x40,0x40,0x40,0x60,0x30,0x1F,0x07,0x00,0x00,/*"O",1*/
|
||||
0x00,0x00,0x00,0x04,0xFC,0x1C,0x38,0xE0,0xC0,0x00,0x00,0x04,0xFC,0x04,0x00,0x00,
|
||||
0x00,0x00,0x00,0x40,0x7F,0x40,0x00,0x00,0x01,0x07,0x1E,0x38,0x7F,0x00,0x00,0x00,/*"N",2*/
|
||||
0x00,0x00,0x00,0x04,0xFC,0xFC,0x84,0x84,0x84,0x84,0xE4,0x04,0x0C,0x10,0x00,0x00,
|
||||
0x00,0x00,0x00,0x40,0x7F,0x7F,0x40,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,/*"F",3*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0xFC,0xFC,0x04,0x04,0x04,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x7F,0x40,0x40,0x40,0x00,0x00,0x00,/*"I",4*/
|
||||
0x00,0x00,0x00,0xC0,0xF0,0x38,0x08,0x04,0x04,0x04,0x04,0x0C,0x1C,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x07,0x1F,0x38,0x60,0x40,0x40,0x42,0x42,0x3E,0x3E,0x02,0x02,0x00,/*"G",5*/
|
||||
};
|
||||
#endif
|
||||
85
S100App/Inc/stm32f10x_conf.h
Normal file
85
S100App/Inc/stm32f10x_conf.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f10x_conf.h
|
||||
* @author MCD Application Team
|
||||
* @version V4.0.0
|
||||
* @date 21-January-2013
|
||||
* @brief Library configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F10x_CONF_H
|
||||
#define __STM32F10x_CONF_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Uncomment the line below to enable peripheral header file inclusion */
|
||||
#include "stm32f10x_adc.h"
|
||||
#include "stm32f10x_bkp.h"
|
||||
#include "stm32f10x_can.h"
|
||||
#include "stm32f10x_crc.h"
|
||||
#include "stm32f10x_dac.h"
|
||||
#include "stm32f10x_dbgmcu.h"
|
||||
#include "stm32f10x_dma.h"
|
||||
#include "stm32f10x_exti.h"
|
||||
#include "stm32f10x_flash.h"
|
||||
#include "stm32f10x_fsmc.h"
|
||||
#include "stm32f10x_gpio.h"
|
||||
#include "stm32f10x_i2c.h"
|
||||
#include "stm32f10x_iwdg.h"
|
||||
#include "stm32f10x_pwr.h"
|
||||
#include "stm32f10x_rcc.h"
|
||||
#include "stm32f10x_rtc.h"
|
||||
#include "stm32f10x_sdio.h"
|
||||
#include "stm32f10x_spi.h"
|
||||
#include "stm32f10x_tim.h"
|
||||
#include "stm32f10x_usart.h"
|
||||
#include "stm32f10x_wwdg.h"
|
||||
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Uncomment the line below to expanse the "assert_param" macro in the
|
||||
Standard Peripheral Library drivers code */
|
||||
/* #define USE_FULL_ASSERT 1 */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name : assert_param
|
||||
* Description : The assert_param macro is used for function's parameters check.
|
||||
* Input : - expr: If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t* file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#endif /* __STM32F10x_CONF_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
31
S100App/STM32F103_APP.icf
Normal file
31
S100App/STM32F103_APP.icf
Normal file
@@ -0,0 +1,31 @@
|
||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x08004000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08004000;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0800BFFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20004FFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,
|
||||
block CSTACK, block HEAP };
|
||||
237
S100App/Src/2FAT12.c
Normal file
237
S100App/Src/2FAT12.c
Normal file
@@ -0,0 +1,237 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
||||
File Name : 2FAT12.c
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : bure & Celery
|
||||
Data: 2015/08/03
|
||||
History:
|
||||
2015/08/03 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
#include <string.h>
|
||||
#include "FAT12.h"
|
||||
#include "BIOS.h"
|
||||
|
||||
|
||||
#define FAT_LEN 0x1800
|
||||
#define FAT1_BASE 0x00001000 // FAT1<54><31><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
||||
#define FAT2_BASE 0x00002800 // FAT2<54><32><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
||||
#define ROOT_BASE 0x00004000 // <20><>Ŀ¼<C4BF><C2BC>ʼ<EFBFBD><CABC>ַ
|
||||
#define FILE_BASE 0x00008000 // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
||||
#define SEC_LEN 0x200 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define FAT1_SEC 0x0C // FAT1<54><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define FAT2_SEC 0x0C // FAT2<54><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
#define OK 0 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define SEC_ERR 1 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
||||
#define FAT_ERR 2 // FAT<41><54><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
||||
#define OVER 3 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define NEW 4 // <20><>Ŀ¼<C4BF><C2BC>
|
||||
#define END 0xFFF // <20><><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>
|
||||
|
||||
#define OW 0 // <20><>д(<28><><EFBFBD>ݴ<EFBFBD>0<EFBFBD><30>1<EFBFBD><31>д)
|
||||
#define RW 1 // <20><>д
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>Ӵغź<C5BA>
|
||||
*******************************************************************************/
|
||||
u8 NextCluster(u16* pCluster)
|
||||
{
|
||||
u16 FatNum;
|
||||
u32 Addr = FAT1_BASE +(*pCluster + *pCluster/2);
|
||||
|
||||
*(pCluster+1)= *pCluster; // <20><><EFBFBD><EFBFBD>ǰһ<C7B0><D2BB><EFBFBD>غ<EFBFBD>
|
||||
// *(pCluster+1)= 0;
|
||||
if((*pCluster >= END)||(*pCluster < 2)) return OK;
|
||||
if(ReadDiskData((u8*)&FatNum, Addr, 2)!= OK) return SEC_ERR;
|
||||
*pCluster = (*pCluster & 1)?(FatNum >>4):(FatNum & 0x0FFF); // ָ<><D6B8><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
|
||||
return OK;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>(512 Bytes), <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
|
||||
*******************************************************************************/
|
||||
u8 ReadFileSec(u8* pBuffer, u16* pCluster)
|
||||
{
|
||||
u32 ReadAddr = FILE_BASE + SEC_LEN*(*pCluster-2);
|
||||
|
||||
if(ReadDiskData(pBuffer, ReadAddr, 256)!=OK) return SEC_ERR; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
pBuffer += 256;
|
||||
ReadAddr += 256;
|
||||
if(ReadDiskData(pBuffer, ReadAddr, 256)!=OK) return SEC_ERR; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(NextCluster(pCluster)!=0) return FAT_ERR; // ȡ<><C8A1>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
|
||||
return OK;
|
||||
}
|
||||
/*******************************************************************************
|
||||
д<>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>(512 Bytes)<29><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ǰFAT<41><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
|
||||
*******************************************************************************/
|
||||
u8 ProgFileSec(u8* pBuffer, u16* pCluster)
|
||||
{
|
||||
u16 Tmp;
|
||||
u32 ProgAddr = FILE_BASE + SEC_LEN*(*pCluster-2);
|
||||
|
||||
if(ProgDiskPage(pBuffer, ProgAddr)!= OK) return SEC_ERR; // дǰ<D0B4><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
pBuffer += 256;
|
||||
ProgAddr += 256;
|
||||
if(ProgDiskPage(pBuffer, ProgAddr)!= OK) return SEC_ERR; // д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Tmp = *pCluster;
|
||||
switch(Tmp) {
|
||||
case 0: // <20><><EFBFBD>дغ<D0B4>
|
||||
case 1: // <20><><EFBFBD>дغ<D0B4>
|
||||
if(SeekBlank (pBuffer, pCluster )!= OK) return OVER;
|
||||
if(SetCluster(pBuffer, pCluster )!= OK) return SEC_ERR;
|
||||
*(pCluster+1) = Tmp;
|
||||
return OK;
|
||||
case END: // <20><><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>
|
||||
default :
|
||||
if(NextCluster(pCluster)!= OK) return FAT_ERR; // ȡ<><C8A1>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
<20><><EFBFBD>ҿ<EFBFBD><D2BF>дغţ<D8BA><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>дغż<D8BA><C5BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>дغ<D0B4>
|
||||
*******************************************************************************/
|
||||
u8 SeekBlank(u8* pBuffer, u16* pCluster)
|
||||
{
|
||||
u16 Offset, Tmp, i, n = 0;
|
||||
u32 SecAddr;
|
||||
|
||||
for(i=0; i<4096; i++) {
|
||||
Offset = i + i/2;
|
||||
if((Offset%256)== 0) {
|
||||
SecAddr = FAT1_BASE +(Offset &(~0xFF));
|
||||
if(ReadDiskData(pBuffer, SecAddr, 258)!= 0) return SEC_ERR;
|
||||
}
|
||||
Offset %= 256;
|
||||
Tmp = pBuffer[Offset] + pBuffer[Offset+1] <<8;
|
||||
Tmp = (i & 1)?(Tmp >>4):(Tmp & 0xFFF);
|
||||
if(Tmp == 0) {
|
||||
*pCluster++ = i;
|
||||
n++;
|
||||
if(n > 1) return OK;
|
||||
}
|
||||
}
|
||||
*(pCluster+1)= 0xFFF;
|
||||
return OK;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>д<EFBFBD><D0B4>FAT<41><54><EFBFBD><EFBFBD>ǰ<EFBFBD>غ<EFBFBD><D8BA><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ǰ<EFBFBD>غ<EFBFBD>Ϊԭ<CEAA><D4AD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
|
||||
*******************************************************************************/
|
||||
u8 SetCluster(u8* pBuffer, u16* pCluster)
|
||||
{
|
||||
u16 Offset, Tmp, i, k;
|
||||
u32 SecAddr;
|
||||
|
||||
i = *pCluster; // <20><>ȡԭ<C8A1><D4AD>ǰ<EFBFBD>غ<EFBFBD>
|
||||
k = *(pCluster+1); // <20><>ȡ<EFBFBD><C8A1>һ<EFBFBD>غ<EFBFBD>
|
||||
*pCluster = k;
|
||||
Offset = i + i/2;
|
||||
SecAddr = FAT1_BASE +(Offset &(~0xFF));
|
||||
Tmp = Offset & 0xFF;
|
||||
if(ReadDiskData(pBuffer, SecAddr, 256)!= 0) return SEC_ERR;
|
||||
if(i & 1) pBuffer[Tmp]=((k<<4)& 0xF0)+(pBuffer[Tmp]& 0x0F);
|
||||
else pBuffer[Tmp]= k;
|
||||
if(Tmp++ < 256) {
|
||||
if(i & 1) pBuffer[Tmp]= k>>4;
|
||||
else pBuffer[Tmp]=((k>>8)& 0x0F)+(pBuffer[Tmp]& 0xF0);
|
||||
if(ProgDiskPage(pBuffer, SecAddr)!= 0) return SEC_ERR;
|
||||
} else {
|
||||
if(ProgDiskPage(pBuffer, SecAddr)!= 0) return SEC_ERR;
|
||||
SecAddr += 256;
|
||||
if(ReadDiskData(pBuffer, SecAddr, 256)!= 0) return SEC_ERR;
|
||||
if(i & 1) pBuffer[0]= k>>4;
|
||||
else pBuffer[0]=((k>>8)& 0x0F)+(pBuffer[0]& 0xF0);
|
||||
if(ProgDiskPage(pBuffer, SecAddr)!= 0) return SEC_ERR;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
/*******************************************************************************
|
||||
|
||||
*******************************************************************************/
|
||||
u8 SearchFile(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr,u32* flag)
|
||||
{
|
||||
u16 i, n;
|
||||
|
||||
*pCluster = 0;
|
||||
for(*pDirAddr=ROOT_BASE; *pDirAddr<FILE_BASE; ) {
|
||||
if(ReadDiskData(pBuffer, *pDirAddr, 256)!= OK) return SEC_ERR;
|
||||
for(n=0; n<256; n+=32) {
|
||||
for(i=0; i<4; i++) {
|
||||
if(pBuffer[n + i]!= 0) {
|
||||
if(pBuffer[n + i]!= pFileName[i]) break;
|
||||
if(i == 3) { // <20>ҵ<EFBFBD><D2B5>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
*pCluster = *(u16*)(pBuffer + n + 0x1A); // <20>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
|
||||
return OK;
|
||||
}
|
||||
} else return NEW; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>
|
||||
}
|
||||
*pDirAddr += 32;
|
||||
}
|
||||
}
|
||||
return OVER;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<20><>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غż<D8BA>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7> 0<>غż<D8BA><C5BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>ַ
|
||||
*******************************************************************************/
|
||||
u8 OpenFileRd(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr)
|
||||
{
|
||||
u16 i, n;
|
||||
|
||||
*pCluster = 0;
|
||||
for(*pDirAddr=ROOT_BASE; *pDirAddr<FILE_BASE; ) {
|
||||
if(ReadDiskData(pBuffer, *pDirAddr, 256)!= OK) return SEC_ERR;
|
||||
for(n=0; n<256; n+=32) {
|
||||
for(i=0; i<11; i++) {
|
||||
if(pBuffer[n + i]!= 0) {
|
||||
if(pBuffer[n + i]!= pFileName[i]) break;
|
||||
if(i == 10) { // <20>ҵ<EFBFBD><D2B5>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
*pCluster = *(u16*)(pBuffer + n + 0x1A); // <20>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
|
||||
return OK;
|
||||
}
|
||||
} else return NEW; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>
|
||||
}
|
||||
*pDirAddr += 32;
|
||||
}
|
||||
}
|
||||
return OVER;
|
||||
}
|
||||
/*******************************************************************************
|
||||
дģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غż<D8BA>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>ַ
|
||||
*******************************************************************************/
|
||||
u8 OpenFileWr(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr)
|
||||
{
|
||||
u16 i, n;
|
||||
|
||||
i = OpenFileRd(pBuffer, pFileName, pCluster, pDirAddr);
|
||||
if(i != NEW) return i;
|
||||
else { // <20><>ǰ<EFBFBD><C7B0>Ϊ<EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC>
|
||||
if(SeekBlank(pBuffer, pCluster)!= OK) return OVER; // <20><>FAT<41><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
n =*pDirAddr & 0xFF; // nΪ<6E><CEAA>ǰҳĿ¼<C4BF><C2BC>
|
||||
if(ReadDiskData(pBuffer,(*pDirAddr)-n, 256)!= OK) return SEC_ERR;
|
||||
for(i=0; i<11; i++) pBuffer[n + i]= pFileName[i]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC>
|
||||
*(u16*)(pBuffer + n + 0x1A)= *pCluster;
|
||||
if(ProgDiskPage(pBuffer,(*pDirAddr)-n)!= OK) return SEC_ERR;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
<20>ر<EFBFBD><D8B1>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>FAT<41><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>Ŀ¼<C4BF><EFBFBD><EEA3AC><EFBFBD><EFBFBD>FAT1<54><31>FAT2
|
||||
*******************************************************************************/
|
||||
u8 CloseFile(u8* pBuffer, u32 Lenght, u16* pCluster, u32* pDirAddr)
|
||||
{
|
||||
u16 n;
|
||||
|
||||
// *pCluster = *(pCluster+1); // <20><>ȡǰһ<C7B0><D2BB><EFBFBD>غ<EFBFBD>
|
||||
*(pCluster+1) = 0xFFF;
|
||||
SetCluster(pBuffer, pCluster);
|
||||
if(ReadDiskData(pBuffer, (*pDirAddr &(~0xFF)), 256)!= OK) return SEC_ERR;
|
||||
*(u8* )(pBuffer +(*pDirAddr & 0xFF)+ 0x0B)= 0x20;
|
||||
*(u32*)(pBuffer +(*pDirAddr & 0xFF)+ 0x1C)= Lenght;
|
||||
if(ProgDiskPage(pBuffer, (*pDirAddr &(~0xFF)))!= OK) return SEC_ERR;
|
||||
for(n=0; n<FAT1_SEC; n++) {
|
||||
if(ReadDiskData(pBuffer, FAT1_BASE+n*256, 256)!= OK) return SEC_ERR;
|
||||
if(ProgDiskPage(pBuffer, FAT2_BASE+n*256 )!= OK) return SEC_ERR;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
/******************************** END OF FILE *********************************/
|
||||
381
S100App/Src/Bios.c
Normal file
381
S100App/Src/Bios.c
Normal file
@@ -0,0 +1,381 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : Bios.c
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/07
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
|
||||
#include "APP_Version.h"
|
||||
#include "usb_lib.h"
|
||||
#include "Bios.h"
|
||||
#include "HARDWARE.h"
|
||||
#include "I2C.h"
|
||||
#include "CTRL.h"
|
||||
|
||||
/******************************************************************************/
|
||||
#define ADC1_DR_Address ((u32)0x4001244C)
|
||||
|
||||
vu8 gSk = 0;//
|
||||
vu32 gTimeOut,gMs_timeout;
|
||||
volatile u32 gTime[8];
|
||||
vu16 ADC1ConvertedValue[2];
|
||||
vu32 gHeat_cnt=0;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_AdcValue
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡADC ת<><D7AA><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>AD
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
u16 Get_AdcValue(u8 i)
|
||||
{
|
||||
return ADC1ConvertedValue[i];
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_HeatingTime
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:heating_time <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Set_HeatingTime(u32 heating_time)
|
||||
{
|
||||
gHeat_cnt = heating_time;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_HeatingTime
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
*******************************************************************************/
|
||||
u32 Get_HeatingTime(void)
|
||||
{
|
||||
return gHeat_cnt;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Init_GTIME
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Init_Gtime(void)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for(i = 0; i < 8; i++) gTime[i] = 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Delay_Ms
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʱ<EFBFBD>ȴ<EFBFBD><C8B4>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Delay_Ms(u32 ms)
|
||||
{
|
||||
gMs_timeout = ms*20;
|
||||
while(gMs_timeout); // {if(Scan_key()!=0)break;}
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Delay_HalfMs
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:ÿ<><C3BF>λΪ0.5<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʱ<EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>0.5<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Delay_HalfMs(u32 ms)
|
||||
{
|
||||
gMs_timeout = ms*10;
|
||||
while(gMs_timeout); // {if(Scan_key()!=0)break;}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: USB_Port
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD> USB <20>豸 IO <20>˿<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:State = ENABLE / DISABLE
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void USB_Port(u8 state)
|
||||
{
|
||||
USB_DN_LOW();
|
||||
USB_DP_LOW();
|
||||
if(state == DISABLE) {
|
||||
USB_DN_OUT();
|
||||
USB_DP_OUT();
|
||||
} else {
|
||||
USB_DN_EN();
|
||||
USB_DP_EN();
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RCC_Config
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:ʱ<>ӳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void RCC_Config(void)
|
||||
{
|
||||
RCC_DeInit();
|
||||
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
|
||||
FLASH_SetLatency(FLASH_Latency_1); // Flash 1 wait state for 48MHz
|
||||
RCC_CFGR_CFG();
|
||||
RCC_PLL_EN();
|
||||
RCC_HSICmd(ENABLE);
|
||||
RCC_PLLCmd(ENABLE);
|
||||
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {}
|
||||
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
|
||||
while(RCC_GetSYSCLKSource() != 0x08) {}
|
||||
|
||||
RCC_AHBPeriphClockCmd (RCC_AHBPeriph_SRAM | RCC_AHBPeriph_DMA1 | RCC_AHBPeriph_DMA2 |
|
||||
RCC_AHBPeriph_FLITF, // Enable DMA1 clock ???
|
||||
ENABLE);
|
||||
RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
|
||||
RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2 ,//| RCC_APB2Periph_ADC3, //RCC_APB2Periph_TIM1,
|
||||
ENABLE );
|
||||
RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3,
|
||||
ENABLE);
|
||||
|
||||
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_Div1); // USBCLK = 48MHz
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: NVIC_Config
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A>жϳ<D0B6>ʼ<EFBFBD><CABC>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:tab_offset
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void NVIC_Config(u16 tab_offset)
|
||||
{
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
|
||||
NVIC_SetVectorTable(NVIC_VectTab_FLASH, tab_offset);
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
||||
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: GPIO_Config
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>GPIO
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void GPIO_Config(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
GPIOA_OUTPUT();
|
||||
GPIOA_L_DEF();
|
||||
GPIOA_H_DEF();
|
||||
|
||||
GPIOB_OUTPUT();
|
||||
GPIOB_L_DEF();
|
||||
GPIOB_H_DEF();
|
||||
|
||||
//------ PA7<41><37>Ϊģ<CEAA><C4A3>ͨ<EFBFBD><CDA8>Ai7<69><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ----------------------------------------//
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
//------ OLED_RST_PIN(PB9) ------------------------------------------------------------//
|
||||
GPIO_InitStructure.GPIO_Pin = OLED_RST_PIN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
//------- <20><><EFBFBD>ȿ<EFBFBD><C8BF><EFBFBD>λ PB4--------------------------------------------------------//
|
||||
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST,ENABLE); // PB4=JNTRST
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = HEAT_PIN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
//------ PB0<42><30>Ϊģ<CEAA><C4A3>ͨ<EFBFBD><CDA8>Ai8<69><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ---------------------------------------//
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
//---------- INPUT Voltage Detection Pin VB PB1(Ai9) ---------------------------------------//
|
||||
GPIO_InitStructure.GPIO_Pin = VB_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
//-------- K1 = PA8, K2 = PA6 ----------------------------------------------------------//
|
||||
GPIO_InitStructure.GPIO_Pin = KEY1_PIN | KEY2_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Ad_Init
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>ʼ<EFBFBD><CABC> AD
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Ad_Init(void)
|
||||
{
|
||||
u32 timeout = 10*0x1000;
|
||||
ADC_InitTypeDef ADC_InitStructure;
|
||||
DMA_InitTypeDef DMA_InitStructure;
|
||||
|
||||
/* DMA1 channel1 configuration ---------------------------------------------*/
|
||||
DMA_DeInit(DMA1_Channel1);
|
||||
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
|
||||
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)ADC1ConvertedValue;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
|
||||
DMA_InitStructure.DMA_BufferSize = 2;
|
||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
|
||||
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
|
||||
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
|
||||
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
|
||||
|
||||
/* Enable DMA1 channel1 */
|
||||
DMA_Cmd(DMA1_Channel1, ENABLE);
|
||||
// ADC1 configuration ------------------------------------------------------//
|
||||
ADC_DeInit(ADC1);
|
||||
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
|
||||
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
|
||||
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
|
||||
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
|
||||
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
|
||||
ADC_InitStructure.ADC_NbrOfChannel = 2;
|
||||
ADC_Init(ADC1, &ADC_InitStructure);
|
||||
|
||||
// ADC2 configuration ------------------------------------------------------//
|
||||
ADC_DeInit(ADC2);
|
||||
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
|
||||
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
|
||||
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
|
||||
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
|
||||
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
|
||||
ADC_InitStructure.ADC_NbrOfChannel = 1;
|
||||
ADC_Init(ADC2, &ADC_InitStructure);
|
||||
|
||||
// ADC1,2 regular channel7 channel9 and channel8 configuration ----------//
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 2, ADC_SampleTime_239Cycles5); //28 or 55
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 1, ADC_SampleTime_239Cycles5); //28 or 55
|
||||
ADC_RegularChannelConfig(ADC2, ADC_Channel_9, 1, ADC_SampleTime_55Cycles5); //28 or 55
|
||||
|
||||
/* Enable ADC1 DMA */
|
||||
ADC_DMACmd(ADC1, ENABLE);
|
||||
|
||||
ADC_Cmd(ADC1, ENABLE); /* Enable ADC1 */
|
||||
ADC_Cmd(ADC2, ENABLE); /* Enable ADC2 */
|
||||
|
||||
ADC_ResetCalibration(ADC1); /* Enable ADC1 reset calibaration register */
|
||||
while(ADC_GetResetCalibrationStatus(ADC1)) if(!timeout--) return ; /* Check the end of ADC1 reset calibration register */
|
||||
|
||||
ADC_ResetCalibration(ADC2); /* Enable ADC2 reset calibaration register */
|
||||
timeout = 10*0x1000;
|
||||
while(ADC_GetResetCalibrationStatus(ADC2)) if(!timeout--) return ; /* Check the end of ADC2 reset calibration register */
|
||||
|
||||
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
|
||||
ADC_SoftwareStartConvCmd(ADC2, ENABLE);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Init_Timer2
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>ʼ<EFBFBD><CABC> <20><>ʱ<EFBFBD><CAB1>2
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Init_Timer2(void)
|
||||
{
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
|
||||
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = 48-1; // (48MHz)/48 = 1MHz
|
||||
TIM_TimeBaseStructure.TIM_Period = 10000-1; // Interrupt per 10mS
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
TIM_TimeBaseInit (TIM2, &TIM_TimeBaseStructure);
|
||||
TIM_ARRPreloadConfig(TIM2, ENABLE);
|
||||
TIM_ITConfig (TIM2, TIM_IT_Update, ENABLE);
|
||||
TIM_Cmd (TIM2, ENABLE);
|
||||
|
||||
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Init_Timer3
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>ʼ<EFBFBD><CABC> <20><>ʱ<EFBFBD><CAB1>3
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Init_Timer3(void)
|
||||
{
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
|
||||
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = 48-1; //(48MHz)/48 = 1MHz
|
||||
TIM_TimeBaseStructure.TIM_Period = 50-1; // Interrupt per 50us
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV2;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
TIM_TimeBaseInit (TIM3, &TIM_TimeBaseStructure);
|
||||
TIM_ARRPreloadConfig(TIM3, ENABLE);
|
||||
TIM_ITConfig (TIM3, TIM_IT_Update, ENABLE);
|
||||
TIM_Cmd (TIM3, ENABLE);
|
||||
|
||||
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: TIM2_ISR
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>ʱ<EFBFBD><CAB1>2<EFBFBD>жϺ<D0B6><CFBA><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void TIM2_ISR(void)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update); // Clear interrupt flag
|
||||
for(i=0; i<8; i++) if(gTime[i] > 0) gTime[i]--;
|
||||
|
||||
if(++gSk%4==0) Scan_Key();
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: TIM3_ISR
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>ʱ<EFBFBD><CAB1>3<EFBFBD>жϺ<D0B6><CFBA><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void TIM3_ISR(void)
|
||||
{
|
||||
static u8 heat_flag = 0;
|
||||
|
||||
TIM_ClearITPendingBit(TIM3, TIM_IT_Update); // Clear interrupt flag
|
||||
|
||||
if(gTimeOut > 0) gTimeOut--;
|
||||
if(gMs_timeout > 0) gMs_timeout--;
|
||||
|
||||
if(gHeat_cnt > 0) {
|
||||
gHeat_cnt--;
|
||||
if(heat_flag) HEAT_OFF();
|
||||
else HEAT_ON();
|
||||
|
||||
heat_flag = ~heat_flag;
|
||||
}
|
||||
if(gHeat_cnt == 0) {
|
||||
HEAT_OFF();
|
||||
heat_flag = 0;
|
||||
}
|
||||
}
|
||||
/******************************** END OF FILE *********************************/
|
||||
425
S100App/Src/CTRL.c
Normal file
425
S100App/Src/CTRL.c
Normal file
@@ -0,0 +1,425 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : CTRL.c
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/08/03
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
2015/08/03 <20>Ż<EFBFBD><C5BB>ƶ<EFBFBD><C6B6>ж<EFBFBD>
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "CTRL.h"
|
||||
#include "Bios.h"
|
||||
#include "UI.h"
|
||||
#include "HARDWARE.h"
|
||||
#include "S100V0_1.h"
|
||||
#include "Disk.h"
|
||||
#include "MMA8652FC.h"
|
||||
|
||||
#define HEATINGCYCLE 30
|
||||
/******************************************************************************/
|
||||
DEVICE_INFO_SYS device_info;
|
||||
/******************************************************************************/
|
||||
|
||||
u8 gCtrl_status = 1;
|
||||
u16 gHt_flag = 0;
|
||||
vs16 gTemp_data = 250;//25<32><35>
|
||||
s16 gPrev_temp = 250; // ǰһ<C7B0><D2BB><EFBFBD>¶<EFBFBD>ֵ
|
||||
u8 gIs_restartkey = 0;/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־*/
|
||||
u8 gPre_status = 1;
|
||||
|
||||
const DEVICE_INFO_SYS info_def = {
|
||||
"2.11", //Ver
|
||||
2000, //T_Standby; // 200<30><30>C=1800 2520,<2C><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
3000, // T_Work; // 350<35><30>C=3362, <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
100, //T_Step;
|
||||
3*60*100, //Wait_Time; //3*60*100 3 mintute
|
||||
6*60*100 // Idle_Time; //6*60*100 6 minute
|
||||
};
|
||||
struct _pid {
|
||||
s16 settemp; //<2F><><EFBFBD><EFBFBD><EFBFBD>趨<EFBFBD>¶<EFBFBD>
|
||||
s16 actualtemp; //<2F><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>¶<EFBFBD>
|
||||
s16 err; //<2F><><EFBFBD><EFBFBD><EFBFBD>¶Ȳ<C2B6>ֵ
|
||||
s16 err_last; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>¶Ȳ<C2B6>ֵ
|
||||
s32 ht_time; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
u16 kp,ki,kd; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><CEA2>ϵ<EFBFBD><CFB5>
|
||||
s32 integral; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
} pid;
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_Ctrl_Status
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1>ǰ״̬
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><>ǰ״̬
|
||||
*******************************************************************************/
|
||||
u8 Get_CtrlStatus(void)
|
||||
{
|
||||
return gCtrl_status;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_CtrlStatus
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>õ<EFBFBD>ǰ״̬
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:status <20><><EFBFBD>õ<EFBFBD>״̬
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><>
|
||||
*******************************************************************************/
|
||||
void Set_CtrlStatus(u8 status)
|
||||
{
|
||||
gCtrl_status = status;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_PrevTemp
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>ǰһ<C7B0>¶<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:temp ǰһ<C7B0>¶<EFBFBD>ֵ
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><>
|
||||
*******************************************************************************/
|
||||
void Set_PrevTemp(s16 temp)
|
||||
{
|
||||
gPrev_temp = temp;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_HtFlag
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ȱ<EFBFBD>־,<2C><><EFBFBD>ȱ<EFBFBD>־<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><>ǰ<EFBFBD><C7B0><EFBFBD>ȱ<EFBFBD>־
|
||||
*******************************************************************************/
|
||||
u16 Get_HtFlag(void)
|
||||
{
|
||||
return gHt_flag;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_TempVal
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD>¶ȵ<C2B6>ֵ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><>ǰ<EFBFBD>¶<EFBFBD>
|
||||
*******************************************************************************/
|
||||
s16 Get_TempVal(void)
|
||||
{
|
||||
return gTemp_data;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: System_Init
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ϵͳ<CFB5><CDB3>ʼ<EFBFBD><CABC>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void System_Init(void)
|
||||
{
|
||||
memcpy((void*)&device_info,(void*)&info_def,sizeof(device_info));
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: PID_init
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: PID<49><44><EFBFBD>ݳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Pid_Init(void)
|
||||
{
|
||||
pid.settemp = 0;
|
||||
pid.actualtemp = 0;
|
||||
pid.err = 0;
|
||||
pid.err_last = 0;
|
||||
pid.integral = 0;
|
||||
pid.ht_time = 0;
|
||||
pid.kp = 15;
|
||||
pid.ki = 2;
|
||||
pid.kd = 1;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Pid_Realize
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: PID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:temp<6D><70>ǰ<EFBFBD>¶<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>λ/50us
|
||||
*******************************************************************************/
|
||||
u16 Pid_Realize(s16 temp)
|
||||
{
|
||||
u8 index = 0,index1 = 1;
|
||||
s16 d_err = 0;
|
||||
|
||||
pid.actualtemp = temp;
|
||||
pid.err = pid.settemp - pid.actualtemp; //<2F>²<EFBFBD>
|
||||
|
||||
if(pid.err >= 500) index = 0;
|
||||
else {
|
||||
index = 1;
|
||||
pid.integral += pid.err;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>
|
||||
if(pid.settemp < pid.actualtemp) {
|
||||
d_err = pid.actualtemp - pid.settemp;
|
||||
if(d_err > 20){
|
||||
pid.integral = 0; //<2F><><EFBFBD><EFBFBD>5<EFBFBD><35>
|
||||
index1 = 0;
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
if(pid.err <= 30) index1 = 0;
|
||||
else index1 = 1;
|
||||
pid.ht_time = pid.kp * pid.err + pid.ki * index * pid.integral + pid.kd * (pid.err - pid.err_last)*index1;
|
||||
pid.err_last = pid.err;
|
||||
|
||||
if(pid.ht_time <= 0) pid.ht_time = 0;
|
||||
else if(pid.ht_time > 30*200) pid.ht_time = 30*200;
|
||||
|
||||
return pid.ht_time;
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Heating_Time
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:temp<6D><70>ǰ<EFBFBD>¶ȣ<C2B6>wk_temp <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>λ/50us
|
||||
*******************************************************************************/
|
||||
u32 Heating_Time(s16 temp,s16 wk_temp)
|
||||
{
|
||||
u32 heat_timecnt;
|
||||
|
||||
pid.settemp = wk_temp;
|
||||
if(wk_temp > temp) {
|
||||
if(wk_temp - temp >= 18)gHt_flag = 0;//<2F><><EFBFBD><EFBFBD>
|
||||
else gHt_flag = 2;//<2F><><EFBFBD><EFBFBD>
|
||||
} else {
|
||||
if(temp - wk_temp <= 18)gHt_flag = 2;//<2F><><EFBFBD><EFBFBD>
|
||||
else gHt_flag = 1;//<2F><><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
heat_timecnt = Pid_Realize(temp);//Sub_data * 1000;
|
||||
|
||||
return heat_timecnt;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Status_Tran
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD><C2B6>жϵȿ<CFB5><C8BF><EFBFBD>״̬ת<CCAC><D7AA>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>: NULL
|
||||
*******************************************************************************/
|
||||
void Status_Tran(void)//״̬ת<CCAC><D7AA>
|
||||
{
|
||||
static u16 init_waitingtime = 0;//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>־λ: 0=> δ<><CEB4>ʼ<EFBFBD><CABC>,1=><3E>ѳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
static u8 back_prestatus = 0;
|
||||
s16 heat_timecnt = 0,wk_temp;
|
||||
u16 mma_active;
|
||||
|
||||
switch (Get_CtrlStatus()) {
|
||||
case IDLE:
|
||||
switch(Get_gKey()) {
|
||||
case KEY_V1:
|
||||
if(gIs_restartkey != 1) {
|
||||
if(Read_Vb(1) < 4) {
|
||||
Set_CtrlStatus(TEMP_CTR);
|
||||
init_waitingtime = 0;
|
||||
TEMPSHOW_TIMER = 0;
|
||||
UI_TIMER = 0;
|
||||
G6_TIMER = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KEY_V2:
|
||||
if(gIs_restartkey != 1) {
|
||||
Set_CtrlStatus(THERMOMETER);
|
||||
UI_TIMER = 0;
|
||||
Set_LongKeyFlag(1);
|
||||
}
|
||||
break;
|
||||
case KEY_CN|KEY_V3:
|
||||
break;
|
||||
}
|
||||
if(gIs_restartkey && (KD_TIMER == 0)) {
|
||||
gIs_restartkey = 0;
|
||||
Set_gKey(NO_KEY);
|
||||
}
|
||||
if(Read_Vb(1) == 0){
|
||||
if(Get_UpdataFlag() == 1) Set_UpdataFlag(0);
|
||||
Set_CtrlStatus(ALARM);
|
||||
}
|
||||
if(gPre_status != WAIT && gPre_status != IDLE){
|
||||
G6_TIMER = device_info.idle_time;
|
||||
Set_gKey(NO_KEY);
|
||||
gPre_status = IDLE;
|
||||
}
|
||||
break;
|
||||
case TEMP_CTR:
|
||||
switch(Get_gKey()) {
|
||||
case KEY_CN|KEY_V1:
|
||||
case KEY_CN|KEY_V2:
|
||||
Set_HeatingTime(0);
|
||||
Set_CtrlStatus(TEMP_SET);
|
||||
HEATING_TIMER = 0;
|
||||
EFFECTIVE_KEY_TIMER = 500;
|
||||
break;
|
||||
case KEY_CN|KEY_V3:
|
||||
Set_HeatingTime(0);
|
||||
Set_LongKeyFlag(0);
|
||||
Set_CtrlStatus(IDLE);
|
||||
gPre_status = TEMP_CTR;
|
||||
gIs_restartkey = 1;
|
||||
KD_TIMER = 50; //
|
||||
break;
|
||||
}
|
||||
|
||||
if(Read_Vb(1) >= 4) {
|
||||
Set_HeatingTime(0);
|
||||
Set_LongKeyFlag(0);
|
||||
Set_CtrlStatus(IDLE);
|
||||
gPre_status = TEMP_CTR;
|
||||
gIs_restartkey = 1;
|
||||
KD_TIMER = 50; // 2<><32>
|
||||
}
|
||||
|
||||
wk_temp = device_info.t_work;
|
||||
if(HEATING_TIMER == 0) {
|
||||
gTemp_data = Get_Temp(wk_temp);
|
||||
heat_timecnt = Heating_Time(gTemp_data,wk_temp); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
Set_HeatingTime(heat_timecnt);
|
||||
HEATING_TIMER = HEATINGCYCLE;
|
||||
}
|
||||
if(Get_HeatingTime() == 0) {
|
||||
HEATING_TIMER = 0;
|
||||
}
|
||||
|
||||
|
||||
mma_active = Get_MmaShift();
|
||||
if(mma_active == 0) { //MMA_active = 0 ==> static ,MMA_active = 1 ==>move
|
||||
if(init_waitingtime == 0) {
|
||||
init_waitingtime = 1;
|
||||
ENTER_WAIT_TIMER = device_info.wait_time;
|
||||
}
|
||||
if((init_waitingtime != 0) && (ENTER_WAIT_TIMER == 0)) {
|
||||
gHt_flag = 0;
|
||||
UI_TIMER = 0;
|
||||
Set_HeatingTime(0);
|
||||
Set_gKey(0);
|
||||
G6_TIMER = device_info.idle_time;
|
||||
Set_CtrlStatus(WAIT);
|
||||
}
|
||||
} else {
|
||||
init_waitingtime = 0;
|
||||
}
|
||||
if(Get_AlarmType() > NORMAL_TEMP) { //////////////////<2F><><EFBFBD><EFBFBD>
|
||||
if(Get_UpdataFlag() == 1) Set_UpdataFlag(0);
|
||||
Set_CtrlStatus(ALARM);
|
||||
}
|
||||
break;
|
||||
case WAIT:
|
||||
wk_temp = device_info.t_standby;
|
||||
if(device_info.t_standby > device_info.t_work) { //<2F><><EFBFBD><EFBFBD><EFBFBD>¶ȱȹ<C8B1><C8B9><EFBFBD><EFBFBD>¶ȸ<C2B6>
|
||||
wk_temp = device_info.t_work;
|
||||
}
|
||||
if(HEATING_TIMER == 0) {
|
||||
gTemp_data = Get_Temp(wk_temp);
|
||||
heat_timecnt = Heating_Time(gTemp_data,wk_temp); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
Set_HeatingTime(heat_timecnt);
|
||||
HEATING_TIMER = 30;
|
||||
}
|
||||
|
||||
if(Read_Vb(1) >= 4) {
|
||||
Set_HeatingTime(0);
|
||||
Set_LongKeyFlag(0);
|
||||
Set_CtrlStatus(IDLE);
|
||||
G6_TIMER = device_info.idle_time;
|
||||
gPre_status = WAIT;
|
||||
gIs_restartkey = 1;
|
||||
KD_TIMER = 50; // 2<><32>
|
||||
}
|
||||
|
||||
if(G6_TIMER == 0) { //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Set_HeatingTime(0);
|
||||
Set_LongKeyFlag(0);
|
||||
gIs_restartkey = 1;
|
||||
KD_TIMER = 200; // 2<><32>
|
||||
gPre_status = WAIT;
|
||||
Set_CtrlStatus(IDLE);
|
||||
}
|
||||
|
||||
mma_active = Get_MmaShift();
|
||||
if(mma_active == 1 || Get_gKey() != 0) {
|
||||
UI_TIMER = 0;
|
||||
G6_TIMER = 0;
|
||||
init_waitingtime = 0;
|
||||
Set_CtrlStatus(TEMP_CTR);
|
||||
}
|
||||
|
||||
if(Get_AlarmType() > NORMAL_TEMP) { //////////////////<2F><><EFBFBD><EFBFBD>
|
||||
if(Get_UpdataFlag() == 1) Set_UpdataFlag(0);
|
||||
Set_CtrlStatus(ALARM);
|
||||
}
|
||||
break;
|
||||
case TEMP_SET:
|
||||
if(EFFECTIVE_KEY_TIMER == 0) {
|
||||
Set_CtrlStatus(TEMP_CTR);
|
||||
TEMPSHOW_TIMER = 0;
|
||||
}
|
||||
break;
|
||||
case THERMOMETER:
|
||||
if(KD_TIMER > 0) {
|
||||
Set_gKey(NO_KEY);
|
||||
break;
|
||||
}
|
||||
switch(Get_gKey()) {
|
||||
case KEY_CN|KEY_V1:
|
||||
case KEY_CN|KEY_V2:
|
||||
back_prestatus = 1;
|
||||
break;
|
||||
case KEY_CN|KEY_V3:
|
||||
Zero_Calibration();
|
||||
if(Get_CalFlag() == 1) {
|
||||
Disk_BuffInit();
|
||||
Config_Analysis(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>U<EFBFBD><55>
|
||||
}
|
||||
KD_TIMER = 200; //20150717 <20><EFBFBD>
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(back_prestatus == 1) {
|
||||
back_prestatus = 0;
|
||||
Set_HeatingTime(0);
|
||||
Set_CtrlStatus(IDLE);
|
||||
gPre_status = THERMOMETER;
|
||||
gIs_restartkey = 1;
|
||||
Set_LongKeyFlag(0);
|
||||
KD_TIMER = 50; //
|
||||
}
|
||||
break;
|
||||
case ALARM:
|
||||
switch(Get_AlarmType()) {
|
||||
case HIGH_TEMP:
|
||||
case SEN_ERR:
|
||||
wk_temp = device_info.t_work;
|
||||
gTemp_data = Get_Temp(wk_temp);
|
||||
if(Get_AlarmType() == NORMAL_TEMP) {
|
||||
Set_CtrlStatus(TEMP_CTR);
|
||||
Set_UpdataFlag(0);
|
||||
}
|
||||
break;
|
||||
case HIGH_VOLTAGE:
|
||||
case LOW_VOLTAGE:
|
||||
if(Read_Vb(1) >= 1 && Read_Vb(1) <= 3) {
|
||||
Set_HeatingTime(0);
|
||||
Set_LongKeyFlag(0);
|
||||
gIs_restartkey = 1;
|
||||
UI_TIMER = 2; // 2<><32>
|
||||
gPre_status = THERMOMETER;
|
||||
Set_CtrlStatus(IDLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(Get_HeatingTime != 0) {
|
||||
Set_HeatingTime(0) ; //<2F><><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
||||
HEAT_OFF();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************** END OF FILE *********************************/
|
||||
801
S100App/Src/Disk.c
Normal file
801
S100App/Src/Disk.c
Normal file
@@ -0,0 +1,801 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : Disk.c
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/07
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "APP_Version.h"
|
||||
#include "Disk.h"
|
||||
#include "Bios.h"
|
||||
#include "Flash.h"
|
||||
#include "Oled.h"
|
||||
#include "UI.h"
|
||||
#include "CTRL.h"
|
||||
#include "HARDWARE.h"
|
||||
|
||||
#define Delay_mS Delay_Ms
|
||||
void Disk_SecWrite(u8* pBuffer, u32 DiskAddr);
|
||||
void Disk_SecRead (u8* pBuffer, u32 DiskAddr);
|
||||
void Soft_Delay(void);
|
||||
|
||||
uc8 BOOT_SEC[512] = {0xEB, 0x3C, 0x90, 0x4D, 0x53, 0x44, 0x4F, 0x53,
|
||||
0x35, 0x2E, 0x30, 0x00, 0x02, 0x01, 0x08, 0x00,
|
||||
0x02, 0x00, 0x02, 0x50, 0x00, 0xF8, 0x0c, 0x00,
|
||||
0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0xA2,
|
||||
0x98, 0xE4, 0x6C, 0x4E, 0x4F, 0x20, 0x4E, 0x41,
|
||||
0x4D, 0x45, 0x20, 0x20, 0x20, 0x20, 0x46, 0x41,
|
||||
0x54, 0x31, 0x32, 0x20, 0x20, 0x20, 0x33, 0xC9,
|
||||
0x8E, 0xD1, 0xBC, 0xF0, 0x7B, 0x8E, 0xD9, 0xB8,
|
||||
0x00, 0x20, 0x8E, 0xC0, 0xFC, 0xBD, 0x00, 0x7C,
|
||||
0x38, 0x4E, 0x24, 0x7D, 0x24, 0x8B, 0xC1, 0x99,
|
||||
0xE8, 0x3C, 0x01, 0x72, 0x1C, 0x83, 0xEB, 0x3A,
|
||||
0x66, 0xA1, 0x1C, 0x7C, 0x26, 0x66, 0x3B, 0x07,
|
||||
0x26, 0x8A, 0x57, 0xFC, 0x75, 0x06, 0x80, 0xCA,
|
||||
0x02, 0x88, 0x56, 0x02, 0x80, 0xC3, 0x10, 0x73,
|
||||
0xEB, 0x33, 0xC9, 0x8A, 0x46, 0x10, 0x98, 0xF7,
|
||||
0x66, 0x16, 0x03, 0x46, 0x1C, 0x13, 0x56, 0x1E,
|
||||
0x03, 0x46, 0x0E, 0x13, 0xD1, 0x8B, 0x76, 0x11,
|
||||
0x60, 0x89, 0x46, 0xFC, 0x89, 0x56, 0xFE, 0xB8,
|
||||
0x20, 0x00, 0xF7, 0xE6, 0x8B, 0x5E, 0x0B, 0x03,
|
||||
0xC3, 0x48, 0xF7, 0xF3, 0x01, 0x46, 0xFC, 0x11,
|
||||
0x4E, 0xFE, 0x61, 0xBF, 0x00, 0x00, 0xE8, 0xE6,
|
||||
0x00, 0x72, 0x39, 0x26, 0x38, 0x2D, 0x74, 0x17,
|
||||
0x60, 0xB1, 0x0B, 0xBE, 0xA1, 0x7D, 0xF3, 0xA6,
|
||||
0x61, 0x74, 0x32, 0x4E, 0x74, 0x09, 0x83, 0xC7,
|
||||
0x20, 0x3B, 0xFB, 0x72, 0xE6, 0xEB, 0xDC, 0xA0,
|
||||
0xFB, 0x7D, 0xB4, 0x7D, 0x8B, 0xF0, 0xAC, 0x98,
|
||||
0x40, 0x74, 0x0C, 0x48, 0x74, 0x13, 0xB4, 0x0E,
|
||||
0xBB, 0x07, 0x00, 0xCD, 0x10, 0xEB, 0xEF, 0xA0,
|
||||
0xFD, 0x7D, 0xEB, 0xE6, 0xA0, 0xFC, 0x7D, 0xEB,
|
||||
0xE1, 0xCD, 0x16, 0xCD, 0x19, 0x26, 0x8B, 0x55,
|
||||
0x1A, 0x52, 0xB0, 0x01, 0xBB, 0x00, 0x00, 0xE8,
|
||||
0x3B, 0x00, 0x72, 0xE8, 0x5B, 0x8A, 0x56, 0x24,
|
||||
0xBE, 0x0B, 0x7C, 0x8B, 0xFC, 0xC7, 0x46, 0xF0,
|
||||
0x3D, 0x7D, 0xC7, 0x46, 0xF4, 0x29, 0x7D, 0x8C,
|
||||
0xD9, 0x89, 0x4E, 0xF2, 0x89, 0x4E, 0xF6, 0xC6,
|
||||
0x06, 0x96, 0x7D, 0xCB, 0xEA, 0x03, 0x00, 0x00,
|
||||
0x20, 0x0F, 0xB6, 0xC8, 0x66, 0x8B, 0x46, 0xF8,
|
||||
0x66, 0x03, 0x46, 0x1C, 0x66, 0x8B, 0xD0, 0x66,
|
||||
0xC1, 0xEA, 0x10, 0xEB, 0x5E, 0x0F, 0xB6, 0xC8,
|
||||
0x4A, 0x4A, 0x8A, 0x46, 0x0D, 0x32, 0xE4, 0xF7,
|
||||
0xE2, 0x03, 0x46, 0xFC, 0x13, 0x56, 0xFE, 0xEB,
|
||||
0x4A, 0x52, 0x50, 0x06, 0x53, 0x6A, 0x01, 0x6A,
|
||||
0x10, 0x91, 0x8B, 0x46, 0x18, 0x96, 0x92, 0x33,
|
||||
0xD2, 0xF7, 0xF6, 0x91, 0xF7, 0xF6, 0x42, 0x87,
|
||||
0xCA, 0xF7, 0x76, 0x1A, 0x8A, 0xF2, 0x8A, 0xE8,
|
||||
0xC0, 0xCC, 0x02, 0x0A, 0xCC, 0xB8, 0x01, 0x02,
|
||||
0x80, 0x7E, 0x02, 0x0E, 0x75, 0x04, 0xB4, 0x42,
|
||||
0x8B, 0xF4, 0x8A, 0x56, 0x24, 0xCD, 0x13, 0x61,
|
||||
0x61, 0x72, 0x0B, 0x40, 0x75, 0x01, 0x42, 0x03,
|
||||
0x5E, 0x0B, 0x49, 0x75, 0x06, 0xF8, 0xC3, 0x41,
|
||||
0xBB, 0x00, 0x00, 0x60, 0x66, 0x6A, 0x00, 0xEB,
|
||||
0xB0, 0x4E, 0x54, 0x4C, 0x44, 0x52, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x0D, 0x0A, 0x52, 0x65,
|
||||
0x6D, 0x6F, 0x76, 0x65, 0x20, 0x64, 0x69, 0x73,
|
||||
0x6B, 0x73, 0x20, 0x6F, 0x72, 0x20, 0x6F, 0x74,
|
||||
0x68, 0x65, 0x72, 0x20, 0x6D, 0x65, 0x64, 0x69,
|
||||
0x61, 0x2E, 0xFF, 0x0D, 0x0A, 0x44, 0x69, 0x73,
|
||||
0x6B, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0xFF,
|
||||
0x0D, 0x0A, 0x50, 0x72, 0x65, 0x73, 0x73, 0x20,
|
||||
0x61, 0x6E, 0x79, 0x20, 0x6B, 0x65, 0x79, 0x20,
|
||||
0x74, 0x6F, 0x20, 0x72, 0x65, 0x73, 0x74, 0x61,
|
||||
0x72, 0x74, 0x0D, 0x0A, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xAC, 0xCB, 0xD8, 0x55, 0xAA
|
||||
};
|
||||
|
||||
static u8 gDisk_buff[0x2600];
|
||||
static u32 gDisk_var[(512 + 32 + 28)/4]; // <20><><EFBFBD>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
static u32 *gV32 = (u32*)&gDisk_var[512/4];
|
||||
static u8 *gVar = (u8*) &gDisk_var[512/4 + 8];
|
||||
|
||||
static u8 *gBuff = (u8*) &gDisk_var[0];
|
||||
const u8 gFat_data[]= {0xF8,0xFF,0xFF,0xFF,0xFF,0xFF};//{0xF8,0XFF,0XFF,0xff,0X0f};//
|
||||
|
||||
const char *gKey_words[] = {"T_Standby","T_Work","Wait_Time","Idle_Time","T_Step","Turn_Off_v","TempShowFlag","ZeroP_Ad"};
|
||||
const char *gDef_set[] = {"T_Standby=200","T_Work=300","Wait_Time=180", "Idle_Time=360","T_Step=10","Turn_Off_v=10",
|
||||
"TempShowFlag=0","ZeroP_Ad=239"};
|
||||
const char *gSet_range[] = {" #(100~400)\r\n"," #(100~400)\r\n"," #(60~9999)\r\n"," #(300~9999)\r\n",
|
||||
" #(5~25)\r\n"," #(9~12)\r\n"," #(0,1)\r\n"," #ReadOnly\r\n"};
|
||||
|
||||
static u8 gFile_con[512];
|
||||
#define CONFIG_CONT 8
|
||||
u8 gRewriteflag[16];
|
||||
|
||||
#define ROW_CONT 35
|
||||
#define FILE_CONT 254
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Soft_Delay
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʱ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Soft_Delay()
|
||||
{
|
||||
int i,j;
|
||||
for(i = 0 ; i < 1000 ; i++)
|
||||
for(j = 0; j < 100; j++);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_Ver
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ֵ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:str <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>k <20><><EFBFBD><EFBFBD>ָʾ
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Set_Ver(u8 str[],u8 k)
|
||||
{
|
||||
s16 set_ver;
|
||||
|
||||
switch(k) {
|
||||
case 0:
|
||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
||||
device_info.t_standby = set_ver * 10;
|
||||
break;
|
||||
case 1:
|
||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
||||
device_info.t_work = set_ver * 10;
|
||||
break;
|
||||
case 2:
|
||||
if(str[3] <= '9' && str[3] >= '0') { //4λ<34><CEBB>
|
||||
set_ver = (str[0] - 48) * 1000 + (str[1] - 48) * 100 + (str[2] - 48) * 10 + (str[3] - 48);
|
||||
} else if(str[2] <= '9' && str[2] >= '0') { //3λ<33><CEBB>
|
||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
||||
} else if(str[1] <= '9' && str[1] >= '0') { //2λ<32><CEBB>
|
||||
set_ver = (str[0] - 48) * 10 + (str[1] - 48);
|
||||
}
|
||||
device_info.wait_time = set_ver * 100;
|
||||
break;
|
||||
case 3:
|
||||
if(str[3] <= '9' && str[3] >= '0') { //4λ<34><CEBB>
|
||||
set_ver = (str[0] - 48) * 1000 + (str[1] - 48) * 100 + (str[2] - 48) * 10 + (str[3] - 48);
|
||||
} else if(str[2] <= '9' && str[2] >= '0') { //3λ<33><CEBB>
|
||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
||||
}
|
||||
device_info.idle_time = set_ver * 100;
|
||||
break;
|
||||
case 4:
|
||||
if(str[1] <= '9' && str[1] >= '0') { //2λ<32><CEBB>
|
||||
set_ver = (str[0] - 48) * 10 + (str[1] - 48);
|
||||
} else {
|
||||
set_ver = str[0] - 48;
|
||||
}
|
||||
device_info.t_step = set_ver * 10;
|
||||
break;
|
||||
case 5:
|
||||
if(str[3] <= '9' && str[3] >= '0') { //4λ<34><CEBB>
|
||||
set_ver = (str[0] - 48) * 1000 + (str[1] - 48) * 100 + (str[2] - 48) * 10 + (str[3] - 48);
|
||||
} else if(str[2] <= '9' && str[2] >= '0') { //3λ<33><CEBB>
|
||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
||||
} else if(str[1] <= '9' && str[1] >= '0') { //2λ<32><CEBB>
|
||||
set_ver = (str[0] - 48) * 10 + (str[1] - 48);
|
||||
} else {
|
||||
set_ver = str[0] - 48;
|
||||
}
|
||||
gTurn_offv = set_ver * 10;
|
||||
break;
|
||||
case 6:
|
||||
set_ver = str[0] - 48;
|
||||
Set_TemperatureShowFlag(set_ver);
|
||||
break;
|
||||
case 7:
|
||||
if(str[2] <= '9' && str[2] >= '0') { //3λ<33><CEBB>
|
||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
||||
} else if(str[1] <= '9' && str[1] >= '0') { //2λ<32><CEBB>
|
||||
set_ver = (str[0] - 48) * 10 + (str[1] - 48);
|
||||
} else {
|
||||
set_ver = str[0] - 48;
|
||||
}
|
||||
if(!gCalib_flag) gZerop_ad = set_ver;
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Cal_Val
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:str <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>k <20><><EFBFBD><EFBFBD>ָʾ flag <20><><EFBFBD><EFBFBD>УAD<41><44>־
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>0<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD> 1<>Ϸ<EFBFBD>
|
||||
*******************************************************************************/
|
||||
u8 Cal_Val(u8 str[],u8 k,u8 flag)
|
||||
{
|
||||
u16 set_ver;
|
||||
|
||||
switch(k) {
|
||||
case 0:
|
||||
case 1:
|
||||
if(str[2] > '9' || str[2] < '0' || //<2F><>λû<CEBB><C3BB>
|
||||
str[1] > '9' || str[1] < '0' || //ʮλû<CEBB><C3BB>
|
||||
str[0] > '4' || str[0] <= '0' || //<2F><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>4 С<><D0A1>0
|
||||
(str[0] == '4' && (str[1] != '0' || str[2] != '0')))
|
||||
return 0;
|
||||
break;
|
||||
case 2:
|
||||
if(str[3] <= '9' && str[3] >= '0') {//4λ<34><CEBB>
|
||||
if((str[2] > '9' && str[2] < '0') || (str[1] > '9' && str[1] < '0'))//ʮλ<CAAE><CEBB>λΪ<CEBB><CEAA>
|
||||
return 0;
|
||||
} else if(str[2] <= '9' && str[2] >= '0') { //3λ<33><CEBB>
|
||||
if(str[1] > '9' && str[1] < '0')//ʮλΪ<CEBB><CEAA>
|
||||
return 0;
|
||||
} else if(str[1] <= '9' && str[1] >= '0'){//<2F><>λ<EFBFBD><CEBB>
|
||||
if(str[0] >'9' || str[0] < '6')//<2F><>λΪ<CEBB><CEAA> С<><D0A1>60
|
||||
return 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(str[3] <= '9' && str[3] >= '0') {//4λ<34><CEBB>
|
||||
if((str[2] > '9' && str[2] < '0') || (str[1] > '9' && str[1] < '0'))//ʮλ<CAAE><CEBB>λΪ<CEBB><CEAA>
|
||||
return 0;
|
||||
} else if(str[2] <= '9' && str[2] >= '0') { //3λ<33><CEBB>
|
||||
if(str[0] >'9' || str[0] < '3')//ʮλΪ<CEBB><CEAA> С<><D0A1>300
|
||||
return 0;
|
||||
} else {//<2F><>λ<EFBFBD><CEBB>
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 4://T_Step=10 #(5~25)
|
||||
if(str[1] <= '5' && str[1] >= '0'){//<2F><>λ<EFBFBD><CEBB>
|
||||
if(str[0] >'2' || str[0] < '0')//<2F><>λΪ<CEBB><CEAA> С<><D0A1>60
|
||||
return 0;
|
||||
} else {
|
||||
if(str[0] < '5' && (str[0] != '1')){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5://Turn_Off_v=10 #(9~12)
|
||||
if(str[1] <= '2' && str[1] >= '0'){//<2F><>λ<EFBFBD><CEBB>
|
||||
if(str[0] >'9' || str[0] < '0')//<2F><>λΪ<CEBB><CEAA> С<><D0A1>60
|
||||
return 0;
|
||||
} else {
|
||||
if(str[0] < '9'){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 6://TempShowFlag=0 #(0,1)
|
||||
if(str[0] != '1' && str[0] != '0')
|
||||
return 0;
|
||||
break;
|
||||
case 7:
|
||||
if(str[2] <= '9' && str[2] >= '0') { //3λ<33><CEBB>
|
||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
||||
}else if(str[1] <= '9' && str[1] >= '0') { //2λ<32><CEBB>
|
||||
set_ver = (str[0] - 48) * 10 + (str[1] - 48);
|
||||
} else {
|
||||
set_ver = str[0] - 48;
|
||||
}
|
||||
if(flag == 1){
|
||||
if(set_ver != gZerop_ad) return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Disk_BuffInit
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Disk_BuffInit(void)
|
||||
{
|
||||
memcpy(gDisk_buff, (u8*)APP_BASE,0x2600);
|
||||
memset(gRewriteflag,0,16);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Upper
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:СдתΪ<D7AA><CEAA>д
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:str<74><72>Ҫת<D2AA><D7AA><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>len <20>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Upper(u8* str, u16 len)
|
||||
{
|
||||
u16 i;
|
||||
for(i = 0; i < len; i++)
|
||||
if(str[i] >= 'a' && str[i] <= 'z')
|
||||
str[i] -= 32;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: SearchFile
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:pfilename <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>pfilelen<65>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ȣ<EFBFBD>root_addr <20><><EFBFBD>ҿ<EFBFBD>ʼ<EFBFBD><CABC>ַ
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ڵ<EFBFBD>ַ
|
||||
*******************************************************************************/
|
||||
u8* SearchFile(u8* pfilename, u16* pfilelen,u16* root_addr)
|
||||
{
|
||||
u16 n,sector;
|
||||
u8 str_name[11];
|
||||
u8* pdiraddr;
|
||||
|
||||
pdiraddr = ROOT_SECTOR;
|
||||
|
||||
for(n = 0; n < 16; n++) {
|
||||
memcpy(str_name,pdiraddr,11);
|
||||
Upper(str_name,11);
|
||||
if(memcmp(str_name,pfilename,11) == 0) {
|
||||
memcpy((u8*)pfilelen,pdiraddr + 0x1C,2);
|
||||
memcpy((u8*)§or,pdiraddr + 0x1A,2);
|
||||
return (u8*)FILE_SECTOR + (sector - 2) * 512;
|
||||
}
|
||||
|
||||
pdiraddr += 32;
|
||||
root_addr++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const u8 LOGO[] = {
|
||||
0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF,
|
||||
0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0x00 ,0x00 ,0x00 ,0x7F ,0xC0 ,0x00 ,0x00,
|
||||
|
||||
0x00 ,0x00 ,0x00 ,0x01 ,0xC0 ,0xFF ,0xFF ,0xFF ,0x80 ,0x1F ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFD,
|
||||
0x80 ,0xFF ,0xFF ,0xFF ,0x80 ,0x1F ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFD ,0xFF ,0x00 ,0x00 ,0x00,
|
||||
|
||||
0x7F ,0x9F ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFD ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xCF ,0xFF ,0xFF,
|
||||
0xFF ,0xFF ,0xFF ,0xFD ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xF7 ,0xFF ,0xFF ,0xF0 ,0x00 ,0x03 ,0xFD,
|
||||
|
||||
0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xF8 ,0x00 ,0x00 ,0x07 ,0xFF ,0xFC ,0x01 ,0xFF ,0xFF ,0xFF ,0xFF,
|
||||
0xFF ,0xFE ,0x07 ,0x81 ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0x9F ,0xFF,
|
||||
|
||||
0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0x0F ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF,
|
||||
0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFE ,0x07 ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF,
|
||||
|
||||
0xFF ,0xFF ,0x9F ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0x9F ,0xFF,
|
||||
0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0x9F ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Config_Analysis
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
u8 Config_Analysis(void)
|
||||
{
|
||||
u32 i,j,k,m,flag;
|
||||
u16 file_len;
|
||||
u8 t_p[CONFIG_CONT][ROW_CONT];
|
||||
u8 str[FILE_CONT];
|
||||
u8 is_illegality = 0;
|
||||
u8* p_file;
|
||||
u16 root_addr;
|
||||
|
||||
root_addr = 0;
|
||||
m = 0;
|
||||
j = 0;
|
||||
|
||||
if(p_file = SearchFile("CONFIG TXT",&file_len,&root_addr)){
|
||||
memset(t_p, 0x00, CONFIG_CONT * ROW_CONT);
|
||||
memcpy((u8*)gFile_con,p_file,512);
|
||||
for(k = 0; k < CONFIG_CONT; k++) { //ȡ<><C8A1>CONFIG_CONT <20><>
|
||||
j = 0;
|
||||
for(i = m; i < strlen((char *)gFile_con); i++) { //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
if(gFile_con[i] == 0x0D && gFile_con[i + 1] == 0x0A) break;
|
||||
else {
|
||||
if(j < ROW_CONT) t_p[k][j++] = gFile_con[i];
|
||||
m++;
|
||||
}
|
||||
}
|
||||
t_p[k][j] = '\0';
|
||||
m = i + 2;
|
||||
}
|
||||
for(k = 0; k < CONFIG_CONT; k++) { //<2F><><EFBFBD><EFBFBD>CONFIG_CONT <20><>
|
||||
if(memcmp(t_p[k],gKey_words[k],strlen(gKey_words[k])) == 0) { //<2F>ҵ<EFBFBD><D2B5>ؼ<EFBFBD><D8BC><EFBFBD>
|
||||
flag = 0;
|
||||
for(i = strlen(gKey_words[k]); i < strlen((char *)t_p[k]); i++) { //<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD>Ƿ<EFBFBD><C7B7>Ϸ<EFBFBD>
|
||||
if(t_p[k][i] >= '0' && t_p[k][i] <= '9') {
|
||||
if(t_p[k][i] == '0') {
|
||||
if(k == 6){
|
||||
flag = 1;
|
||||
break;
|
||||
}else {
|
||||
flag = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
flag = 1;
|
||||
break;
|
||||
} else if((t_p[k][i] != 0x20) && (t_p[k][i] != 0x3d)) {//<2F>ո<EFBFBD><D5B8>ϵȺ<CFB5>
|
||||
flag = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(flag && Cal_Val(t_p[k] + i,k,0)) { //<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD>Ϸ<EFBFBD>
|
||||
Set_Ver(t_p[k] + i,k);
|
||||
if(k == 0) sprintf((char *)t_p[k],"T_Standby=%d",device_info.t_standby/10);
|
||||
else if (k == 1) sprintf((char *)t_p[k],"T_Work=%d", device_info.t_work/10);
|
||||
else if (k == 2) sprintf((char *)t_p[k],"Wait_Time=%d",device_info.wait_time/100);
|
||||
else if (k == 3) sprintf((char *)t_p[k],"Idle_Time=%d",device_info.idle_time/100);
|
||||
else if (k == 4) sprintf((char *)t_p[k],"T_Step=%d",device_info.t_step/10);
|
||||
else if (k == 5) sprintf((char *)t_p[k],"Turn_Off_v=%d",gTurn_offv/10);
|
||||
else if (k == 6) sprintf((char *)t_p[k],"TempShowFlag=%d",Get_TemperatureShowFlag());
|
||||
else if (k == 7) sprintf((char *)t_p[k],"ZeroP_Ad=%d",gZerop_ad);
|
||||
} else {//<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Ϸ<EFBFBD>
|
||||
memset(t_p[k],0,strlen((char *)t_p[k]));
|
||||
memcpy(t_p[k],gDef_set[k],strlen((char *)gDef_set[k]));
|
||||
is_illegality = 1;
|
||||
}
|
||||
} else {//ľ<><C4BE><EFBFBD>ҵ<EFBFBD><D2B5>ؼ<EFBFBD><D8BC><EFBFBD>
|
||||
memcpy(t_p[k],gDef_set[k],strlen((char *)gDef_set[k]));
|
||||
is_illegality = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_illegality || gCalib_flag){
|
||||
memset(str, 0x00, FILE_CONT);
|
||||
m = 0;
|
||||
for(k = 0; k < CONFIG_CONT; k++) {
|
||||
strcat((char *)str,(char *)t_p[k]);
|
||||
strcat((char *)str,(char *)gSet_range[k]);
|
||||
}
|
||||
m = strlen((char *)str);
|
||||
|
||||
if(m < 256) {
|
||||
gDisk_buff[0x400 + root_addr*32 + 0x1C] = m;//strlen((char *)str);//<2F>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||
gDisk_buff[0x400 + root_addr*32 + 0x1D] = 0;
|
||||
} else {
|
||||
gDisk_buff[0x400 + root_addr*32 + 0x1C] = m % 256;
|
||||
gDisk_buff[0x400 + root_addr*32 + 0x1D] = m / 256;
|
||||
}
|
||||
|
||||
gRewriteflag[(p_file - ROOT_SECTOR + 0x200) / 0x400] = 1;
|
||||
memcpy(p_file, str,strlen((char *)str));
|
||||
ReWriteFlsash();
|
||||
}
|
||||
} else {
|
||||
if(p_file = SearchFile("LOGOIN BMP",&file_len,&root_addr)){
|
||||
memcpy(str,p_file,254);
|
||||
memset(gDisk_buff, 0x00, 0x2600);
|
||||
memcpy(ROOT_SECTOR + 32, "LOGOIN BMP",0xC);
|
||||
memcpy(FILE_SECTOR + 512, str,254);
|
||||
gDisk_buff[0x40B + 32] = 0x0; //<2F><><EFBFBD><EFBFBD>
|
||||
*(u32*)(VOLUME_BASE + 32) = VOLUME;
|
||||
gDisk_buff[0x41A + 32] = 0x03;//<2F>غ<EFBFBD>
|
||||
gDisk_buff[0x41C + 32] = 254;//<2F>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||
} else {
|
||||
memset(gDisk_buff, 0x00, 0x2600);
|
||||
}
|
||||
|
||||
memcpy(ROOT_SECTOR, "CONFIG TXT",0xC);
|
||||
memcpy(FAT1_SECTOR, gFat_data,6);
|
||||
memcpy(FAT2_SECTOR, gFat_data,6);
|
||||
|
||||
m = 0;
|
||||
for(k = 0; k < CONFIG_CONT; k++) {
|
||||
memcpy(FILE_SECTOR + m, gDef_set[k],strlen((char *)gDef_set[k]));
|
||||
m += strlen((char *)gDef_set[k]);
|
||||
memcpy(FILE_SECTOR + m, gSet_range[k],strlen((char *)gSet_range[k]));
|
||||
m += strlen((char *)gSet_range[k]);
|
||||
}
|
||||
|
||||
gDisk_buff[0x40B] = 0x0; //<2F><><EFBFBD><EFBFBD>
|
||||
*(u32*)VOLUME_BASE = VOLUME;
|
||||
gDisk_buff[0x41A] = 0x02;//<2F>غ<EFBFBD>
|
||||
gDisk_buff[0x41C] = m;//<2F>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||
ReWrite_All();
|
||||
}
|
||||
|
||||
gVar[F_TYPE] = HEX;
|
||||
gVar[F_FLAG] = RDY;
|
||||
gVar[SEG_ST] = 0;
|
||||
gV32[OFFSET] = 0;
|
||||
gV32[COUNT] = 0;
|
||||
gV32[WR_CNT] = 0;
|
||||
gV32[RD_CNT] = 0;
|
||||
return 0;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Disk_SecWrite
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:PC <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʱд<CAB1><D0B4><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:pbuffer <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> diskaddr <20><>ַ
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Disk_SecWrite(u8* pbuffer, u32 diskaddr)//PC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD>
|
||||
{
|
||||
u8 is_illegality = 0;
|
||||
u32 i,j,k,m,flag;
|
||||
u8 t_p[CONFIG_CONT][ROW_CONT];
|
||||
u8 str[FILE_CONT];
|
||||
u8 ver[20];
|
||||
static u16 Config_flag = 0;
|
||||
|
||||
if(diskaddr == 0x1000) { // Write FAT1 sector
|
||||
if(memcmp(pbuffer,(u8*)FAT1_SECTOR, 512)) {
|
||||
memcpy((u8*)FAT1_SECTOR, pbuffer, 512);
|
||||
gRewriteflag[0] = 1;
|
||||
}
|
||||
} else if(diskaddr == 0x2800) { // Write FAT2 sector
|
||||
if(memcmp(pbuffer,(u8*)FAT2_SECTOR, 512)) {
|
||||
memcpy((u8*)FAT2_SECTOR, pbuffer, 512);
|
||||
gRewriteflag[0] = 1;
|
||||
}
|
||||
} else if(diskaddr == 0x4000) { // Write DIR sector
|
||||
if(memcmp(pbuffer,(u8*)ROOT_SECTOR, 512)) {
|
||||
memcpy((u8*)ROOT_SECTOR, pbuffer, 512);
|
||||
gRewriteflag[1] = 1;
|
||||
for(i = 0;i < 16;i++){
|
||||
memcpy((u8*)ver,(u8*)(pbuffer),12);
|
||||
if(memcmp(ver,"CONFIG TXT",11) == 0){
|
||||
Config_flag = pbuffer[0x1A];
|
||||
break;
|
||||
}
|
||||
pbuffer += 32;
|
||||
}
|
||||
}
|
||||
} else if(diskaddr >= 0x8000 && diskaddr <= 0xA000) { // Write FILE sector
|
||||
if(memcmp(pbuffer,(u8*)(FILE_SECTOR + (diskaddr - 0x8000)), 512)) {
|
||||
memcpy((u8*)(FILE_SECTOR + (diskaddr - 0x8000)), pbuffer, 512);
|
||||
}
|
||||
if((((diskaddr - 0x8000)/0x200) + 2) == Config_flag){
|
||||
// /*
|
||||
m = 0;
|
||||
memset(t_p, 0x00, CONFIG_CONT * ROW_CONT);
|
||||
memcpy((u8*)(gFile_con), pbuffer, 512);
|
||||
|
||||
for(k = 0; k < CONFIG_CONT; k++) { //ȡ<><C8A1>4 <20><>
|
||||
j = 0;
|
||||
for(i = m; i < strlen((char *)gFile_con); i++) { //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
if(gFile_con[i] == 0x0D && gFile_con[i + 1] == 0x0A) break;
|
||||
else {
|
||||
if(j < ROW_CONT) t_p[k][j++] = gFile_con[i];
|
||||
m++;
|
||||
}
|
||||
}
|
||||
t_p[k][j] = '\0';
|
||||
m = i + 2;
|
||||
}
|
||||
|
||||
for(k = 0; k < CONFIG_CONT; k++) { //<2F><><EFBFBD><EFBFBD>k <20><>
|
||||
if(memcmp(t_p[k],gKey_words[k],strlen(gKey_words[k])) == 0) { //<2F>ҵ<EFBFBD><D2B5>ؼ<EFBFBD><D8BC><EFBFBD>
|
||||
flag = 0;
|
||||
for(i = strlen(gKey_words[k]); i < strlen((char *)t_p[k]); i++) { //<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD>Ƿ<EFBFBD><C7B7>Ϸ<EFBFBD>
|
||||
if(t_p[k][i] >= '0' && t_p[k][i] <= '9') {
|
||||
if(t_p[k][i] == '0') {
|
||||
if(k == 6){
|
||||
flag = 1;
|
||||
break;
|
||||
}else {
|
||||
flag = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
flag = 1;
|
||||
break;
|
||||
} else if((t_p[k][i] != 0x20) && (t_p[k][i] != 0x3d)) {//<2F>ո<EFBFBD><D5B8>ϵȺ<CFB5>
|
||||
flag = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if((!flag) || (!Cal_Val(t_p[k] + i,k,1))) {
|
||||
is_illegality = 1;//<2F><><EFBFBD>Ϸ<EFBFBD>
|
||||
return ;
|
||||
}else{
|
||||
Set_Ver(t_p[k] + i,k);
|
||||
|
||||
memset(t_p[k],0,strlen((char *)t_p[k]));
|
||||
if(k == 0) sprintf((char *)t_p[k],"T_Standby=%d",device_info.t_standby/10);
|
||||
else if (k == 1) sprintf((char *)t_p[k],"T_Work=%d", device_info.t_work/10);
|
||||
else if (k == 2) sprintf((char *)t_p[k],"Wait_Time=%d",device_info.wait_time/100);
|
||||
else if (k == 3) sprintf((char *)t_p[k],"Idle_Time=%d",device_info.idle_time/100);
|
||||
else if (k == 4) sprintf((char *)t_p[k],"T_Step=%d",device_info.t_step/10);
|
||||
else if (k == 5) sprintf((char *)t_p[k],"Turn_Off_v=%d",gTurn_offv/10);
|
||||
else if (k == 6) sprintf((char *)t_p[k],"TempShowFlag=%d",Get_TemperatureShowFlag());
|
||||
else if (k == 7) sprintf((char *)t_p[k],"ZeroP_Ad=%d",gZerop_ad);
|
||||
}
|
||||
} else {//ľ<><C4BE><EFBFBD>ҵ<EFBFBD><D2B5>ؼ<EFBFBD><D8BC><EFBFBD>
|
||||
memcpy(t_p[k],gDef_set[k],strlen((char *)gDef_set[k]));
|
||||
is_illegality = 0;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_illegality) {
|
||||
memset(str,0,FILE_CONT);
|
||||
for(k = 0; k < CONFIG_CONT; k++) {
|
||||
strcat((char *)str,(char *)t_p[k]);
|
||||
strcat((char *)str,(char *)gSet_range[k]);
|
||||
}
|
||||
m = strlen((char *)str);
|
||||
|
||||
if(m < 256) {
|
||||
gDisk_buff[0x400 + (Config_flag - 2)*32 + 0x1C] = m;//strlen((char *)str);//<2F>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||
gDisk_buff[0x400 + (Config_flag - 2)*32 + 0x1D] = 0;
|
||||
} else {
|
||||
gDisk_buff[0x400 + (Config_flag - 2)*32 + 0x1C] = m % 256;
|
||||
gDisk_buff[0x400 + (Config_flag - 2)*32 + 0x1D] = m / 256;
|
||||
}
|
||||
|
||||
memcpy((u8*)(FILE_SECTOR),(u8*)str,512);
|
||||
gRewriteflag[1] = 1;
|
||||
gRewriteflag[((diskaddr - 0x8000 + 0x200) / 0x400) + 1] = 1;
|
||||
ReWriteFlsash();
|
||||
return ;
|
||||
} else{
|
||||
return ;
|
||||
}
|
||||
} else {
|
||||
gRewriteflag[((diskaddr - 0x8000 + 0x200) / 0x400) + 1] = 1;
|
||||
}//*/
|
||||
}
|
||||
|
||||
ReWriteFlsash();
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Disk_SecRead
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:PC <20><>ȡ<EFBFBD>ļ<EFBFBD>ʱд<CAB1><D0B4><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:pbuffer <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> diskaddr <20><>ַ
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Disk_SecRead(u8* pbuffer, u32 disk_addr)
|
||||
{
|
||||
Soft_Delay();
|
||||
if(disk_addr == 0x0000) { // Read BOOT sector
|
||||
memcpy(pbuffer, BOOT_SEC, 512);
|
||||
} else if(disk_addr == 0x1000) { // Read FAT1 sector
|
||||
memcpy(pbuffer, FAT1_SECTOR, 512);
|
||||
} else if(disk_addr == 0x2800) { // Read FAT2 sector
|
||||
memcpy(pbuffer, FAT2_SECTOR, 512);
|
||||
} else if(disk_addr == 0x4000) { // Read DIR sector
|
||||
memcpy(pbuffer, (u8*)(ROOT_SECTOR), 512);
|
||||
} else if(disk_addr >= 0x8000 && disk_addr <= 0xA000) { // Read FILE sector
|
||||
memcpy(pbuffer, (u8*)(APP_BASE + 0x600 + (disk_addr - 0x8000)), 512);
|
||||
} else {
|
||||
memset(pbuffer, 0, 512);//
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ReWriteFlsash
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:дFlash
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A>Ƿ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>־
|
||||
*******************************************************************************/
|
||||
u8 ReWriteFlsash(void)
|
||||
{
|
||||
u32 i,j;
|
||||
u8 result;
|
||||
u16 *f_buff;
|
||||
|
||||
FLASH_Unlock();
|
||||
for(i = 0; i < 16; i++) {
|
||||
if(gRewriteflag[i]) {
|
||||
gRewriteflag[i] = 0;
|
||||
FLASH_Erase(APP_BASE + i * 0x400);
|
||||
f_buff = (u16*)&gDisk_buff[i * 0x400];
|
||||
for(j = 0; j < 0x400; j += 2) {
|
||||
result = FLASH_Prog((u32)(APP_BASE + i*0x400 + j),*f_buff++);
|
||||
if(result != FLASH_COMPLETE){
|
||||
FLASH_Lock();
|
||||
return ERR;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
FLASH_Lock();
|
||||
return RDY;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ReWrite_All
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>flash<73><68><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A>Ƿ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>־
|
||||
*******************************************************************************/
|
||||
u8 ReWrite_All(void)
|
||||
{
|
||||
u16 i;
|
||||
u8 result;
|
||||
u16 *f_buff = (u16*)gDisk_buff;
|
||||
|
||||
FLASH_Unlock();
|
||||
for(i = 0; i < 9; i++)FLASH_Erase(APP_BASE + i*0x400);
|
||||
for(i = 0; i < 0X2600; i += 2) {
|
||||
result = FLASH_Prog((u32)(APP_BASE + i),*f_buff++);
|
||||
if(result != FLASH_COMPLETE) return ERR;
|
||||
}
|
||||
FLASH_Lock();
|
||||
return RDY;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Erase
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʽ<EFBFBD><CABD>Flash
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Erase(void)
|
||||
{
|
||||
u16 i;
|
||||
FLASH_Unlock();
|
||||
for(i = 0; i < 9; i++)FLASH_Erase(APP_BASE + i*0x400);
|
||||
|
||||
FLASH_Lock();
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Read_Memory
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>microSD<53><44><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:r_offset ƫ<><C6AB> r_length<74><68><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Read_Memory(u32 r_offset, u32 r_length)
|
||||
{
|
||||
static u32 offset, length, block_offset;
|
||||
|
||||
if (gVar[USB_ST] == TXFR_IDLE ) {
|
||||
offset = r_offset * SECTOR_SIZE;
|
||||
length = r_length * SECTOR_SIZE;
|
||||
gVar[USB_ST] = TXFR_ONGOING;
|
||||
}
|
||||
if (gVar[USB_ST] == TXFR_ONGOING ) {
|
||||
if (!gV32[RD_CNT]) {
|
||||
Disk_SecRead(gBuff, offset);
|
||||
UserToPMABufferCopy(gBuff, ENDP1_TXADDR, BULK_MAX_PACKET_SIZE);
|
||||
gV32[RD_CNT] = SECTOR_SIZE - BULK_MAX_PACKET_SIZE;
|
||||
block_offset = BULK_MAX_PACKET_SIZE;
|
||||
} else {
|
||||
UserToPMABufferCopy(gBuff + block_offset, ENDP1_TXADDR, BULK_MAX_PACKET_SIZE);
|
||||
gV32[RD_CNT] -= BULK_MAX_PACKET_SIZE;
|
||||
block_offset += BULK_MAX_PACKET_SIZE;
|
||||
}
|
||||
SetEPTxCount(ENDP1, BULK_MAX_PACKET_SIZE);
|
||||
SetEPTxStatus(ENDP1, EP_TX_VALID);
|
||||
offset += BULK_MAX_PACKET_SIZE;
|
||||
length -= BULK_MAX_PACKET_SIZE;
|
||||
|
||||
CSW.dDataResidue -= BULK_MAX_PACKET_SIZE;
|
||||
}
|
||||
if (length == 0) {
|
||||
gV32[RD_CNT] = 0;
|
||||
block_offset = 0;
|
||||
offset = 0;
|
||||
Bot_State = BOT_DATA_IN_LAST;
|
||||
gVar[USB_ST] = TXFR_IDLE;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Write_Memory
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>microSD<53><44><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:r_offset ƫ<><C6AB> r_length<74><68><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Write_Memory (u32 w_offset, u32 w_length)
|
||||
{
|
||||
static u32 offset, length;
|
||||
u32 idx, temp = gV32[WR_CNT] + 64;
|
||||
|
||||
if (gVar[USB_ST] == TXFR_IDLE ) {
|
||||
offset = w_offset * SECTOR_SIZE;
|
||||
length = w_length * SECTOR_SIZE;
|
||||
gVar[USB_ST] = TXFR_ONGOING;
|
||||
}
|
||||
if (gVar[USB_ST] == TXFR_ONGOING ) {
|
||||
for (idx = 0 ; gV32[WR_CNT] < temp; gV32[WR_CNT]++)
|
||||
*(u8 *)(gBuff + gV32[WR_CNT]) = Bulk_Buff[idx++];
|
||||
|
||||
offset += Data_Len;
|
||||
length -= Data_Len;
|
||||
|
||||
if (!(length % SECTOR_SIZE)) {
|
||||
gV32[WR_CNT] = 0;
|
||||
Disk_SecWrite(gBuff, offset - SECTOR_SIZE);
|
||||
}
|
||||
|
||||
CSW.dDataResidue -= Data_Len;
|
||||
SetEPRxStatus(ENDP2, EP_RX_VALID); /* enable the next transaction*/
|
||||
}
|
||||
if ((length == 0) || (Bot_State == BOT_CSW_Send)) {
|
||||
gV32[WR_CNT] = 0;
|
||||
Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
||||
gVar[USB_ST] = TXFR_IDLE;
|
||||
}
|
||||
}
|
||||
/********************************* END OF FILE ******************************/
|
||||
198
S100App/Src/Ext_Flash.c
Normal file
198
S100App/Src/Ext_Flash.c
Normal file
@@ -0,0 +1,198 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
||||
File Name : EXT_Flash.c
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : bure
|
||||
Data:
|
||||
History:
|
||||
*******************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "Ext_Flash.h"
|
||||
#include "BIOS.h"
|
||||
|
||||
|
||||
#define OK 0 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define SEC_ERR 1 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
||||
#define TMAX 100000 // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
|
||||
u32 Mass_Memory_Size;
|
||||
u32 Mass_Block_Size;
|
||||
u32 Mass_Block_Count;
|
||||
u32 Tout;
|
||||
|
||||
|
||||
u8 flash_mode;
|
||||
|
||||
void ExtFLASH_SectorErase(u32 SectorAddr);
|
||||
|
||||
/*******************************************************************************
|
||||
SPI_FLASH_SectorErase : Sector Erases the specified FLASH Page.(4k/sector)
|
||||
*******************************************************************************/
|
||||
void ExtFLASH_SectorErase(u32 SectorAddr)
|
||||
{
|
||||
ExtFlash_WriteEnable();
|
||||
ExtFlash_CS_LOW();
|
||||
ExtFlash_SendByte(SE);
|
||||
ExtFlash_SendByte((SectorAddr & 0xFF0000) >> 16); //Send high address byte
|
||||
ExtFlash_SendByte((SectorAddr & 0xFF00) >> 8); //Send medium address byte
|
||||
ExtFlash_SendByte(SectorAddr & 0xFF); //Send low address byte
|
||||
ExtFlash_CS_HIGH();
|
||||
ExtFlash_WaitForWriteEnd(); // Wait the end of Flash writing
|
||||
}
|
||||
|
||||
|
||||
void ExtFlash_PageWR(u8* pBuffer, u32 WriteAddr)
|
||||
{
|
||||
u32 addr,i,j;
|
||||
u8* ptr;
|
||||
u8 page=0,flag=0,write_mode;
|
||||
u8 buffer[256];
|
||||
|
||||
flag=0;
|
||||
if(flash_mode==FLASH_8M) {
|
||||
addr=WriteAddr & 0xFFF000;
|
||||
page=16;
|
||||
} else {
|
||||
page=1;
|
||||
addr=WriteAddr & 0xFFFF00;
|
||||
}
|
||||
while(page>0) {
|
||||
ExtFlash_PageRD((u8*)&buffer,addr, 256);
|
||||
for(j=0; j<255; j++) {
|
||||
if(buffer[j++]!=0xff) {
|
||||
flag=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
addr+=256;
|
||||
page--;
|
||||
}
|
||||
if(flash_mode==FLASH_8M) {
|
||||
page=16;
|
||||
addr=WriteAddr & 0xFFF000;
|
||||
if(flag==1)ExtFLASH_SectorErase(addr);
|
||||
write_mode=PP;
|
||||
} else {
|
||||
page=1;
|
||||
addr=WriteAddr & 0xFFFF00;
|
||||
if(flag==1)write_mode=PW;
|
||||
else write_mode=PP;
|
||||
}
|
||||
ptr=pBuffer;
|
||||
for(i=0; i<page; i++) {
|
||||
ExtFlash_PageProg(ptr, addr,write_mode);
|
||||
addr+=256;
|
||||
ptr+=256;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
дFLASHҳ(256 Bytes)<29><> Mode=0: <20><>0<EFBFBD><30>1<EFBFBD><31><EFBFBD>ݸ<EFBFBD>д Mode=1: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д
|
||||
*******************************************************************************/
|
||||
void ExtFlash_PageProg(u8* pBuffer, u32 WriteAddr,u8 CMD)
|
||||
{
|
||||
u16 Lenght = 256;
|
||||
|
||||
ExtFlash_CS_HIGH();
|
||||
ExtFlash_WaitForWriteEnd();
|
||||
ExtFlash_WriteEnable();
|
||||
ExtFlash_CS_LOW();
|
||||
ExtFlash_SendByte(CMD);
|
||||
ExtFlash_SendByte((WriteAddr & 0xFF0000) >> 16);
|
||||
ExtFlash_SendByte((WriteAddr & 0xFF00) >> 8);
|
||||
ExtFlash_SendByte(WriteAddr & 0xFF);
|
||||
while(Lenght--) { // while there is data to be written on the FLASH
|
||||
ExtFlash_SendByte((*pBuffer));
|
||||
pBuffer++;
|
||||
}
|
||||
ExtFlash_CS_HIGH();
|
||||
ExtFlash_WaitForWriteEnd();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
SPI_FLASH_BufferRead
|
||||
*******************************************************************************/
|
||||
void ExtFlash_PageRD(u8* pBuffer, u32 ReadAddr, u16 Lenght)
|
||||
{
|
||||
ExtFlash_CS_HIGH();
|
||||
ExtFlash_WaitForWriteEnd();
|
||||
ExtFlash_CS_LOW();
|
||||
ExtFlash_SendByte(READ);
|
||||
ExtFlash_SendByte((ReadAddr & 0xFF0000) >> 16);
|
||||
ExtFlash_SendByte((ReadAddr& 0xFF00) >> 8);
|
||||
ExtFlash_SendByte(ReadAddr & 0xFF);
|
||||
|
||||
while(Lenght--) { // while there is data to be read
|
||||
*pBuffer = (ExtFlash_SendByte(Dummy_Byte));
|
||||
pBuffer++;
|
||||
}
|
||||
ExtFlash_CS_HIGH();
|
||||
}
|
||||
/*******************************************************************************
|
||||
SPI_FLASH_ReadByte
|
||||
*******************************************************************************/
|
||||
u8 ExtFlash_ReadByte(void)
|
||||
{
|
||||
return (ExtFlash_SendByte(Dummy_Byte));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
SPI_FLASH_SendByte
|
||||
*******************************************************************************/
|
||||
u8 ExtFlash_SendByte(u8 byte)
|
||||
{
|
||||
Tout = 0;
|
||||
while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_TXE) == RESET) {
|
||||
if(Tout++ > TMAX) return 255;
|
||||
}
|
||||
SPI_I2S_SendData(SPI3, byte);
|
||||
Tout = 0;
|
||||
while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_RXNE) == RESET) {
|
||||
if(Tout++ > TMAX) return 255;
|
||||
}
|
||||
return SPI_I2S_ReceiveData(SPI3);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SPI_FLASH_WriteEnable
|
||||
*******************************************************************************/
|
||||
void ExtFlash_WriteEnable(void)
|
||||
{
|
||||
ExtFlash_CS_LOW();
|
||||
ExtFlash_SendByte(WREN);
|
||||
ExtFlash_CS_HIGH();
|
||||
}
|
||||
/*******************************************************************************
|
||||
SPI_FLASH_WaitForWriteEnd
|
||||
*******************************************************************************/
|
||||
void ExtFlash_WaitForWriteEnd(void)
|
||||
{
|
||||
u8 FLASH_Status = 0;
|
||||
|
||||
ExtFlash_CS_LOW();
|
||||
ExtFlash_SendByte(RDSR);
|
||||
Tout = 0;
|
||||
do {
|
||||
FLASH_Status = ExtFlash_SendByte(Dummy_Byte);
|
||||
if(Tout++ > TMAX) return;
|
||||
} while((FLASH_Status & WIP_Flag) == SET); // Write in progress
|
||||
ExtFlash_CS_HIGH();
|
||||
}
|
||||
/*******************************************************************************
|
||||
MAL_GetStatus
|
||||
*******************************************************************************/
|
||||
void MAL_GetStatus (void)
|
||||
{
|
||||
if(flash_mode==FLASH_8M) {
|
||||
Mass_Block_Count = 2048; //FLASH_SIZE/FLASH_PAGE_SIZE;
|
||||
Mass_Block_Size = 512*8; //FLASH_PAGE_SIZE; 4096
|
||||
Mass_Memory_Size = 512*4096*4 ; //FLASH_SIZE; 0x800000;
|
||||
} else {
|
||||
Mass_Block_Count = 4096; //FLASH_SIZE/FLASH_PAGE_SIZE; 4096
|
||||
Mass_Block_Size = 512; //FLASH_PAGE_SIZE;
|
||||
Mass_Memory_Size = 512*4096 ; //FLASH_SIZE; 0x200000;
|
||||
}
|
||||
}
|
||||
|
||||
/********************************* END OF FILE ******************************/
|
||||
32
S100App/Src/Flash.c
Normal file
32
S100App/Src/Flash.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
||||
File Name : Flash.c
|
||||
Version : Author : bure
|
||||
*******************************************************************************/
|
||||
#include "APP_Version.h"
|
||||
#include "Flash.h"
|
||||
#include "Bios.h"
|
||||
|
||||
u8 ExtFlashSendByte(u8 byte);
|
||||
void ExtFlashWaitForWriteEnd(void);
|
||||
|
||||
/*******************************************************************************
|
||||
FLASH_Prog:
|
||||
*******************************************************************************/
|
||||
u8 FLASH_Prog(u32 Address, u16 Data)
|
||||
{
|
||||
if(FLASH_WaitForLastOperation(WAIT_TIMES)!=FLASH_TIMEOUT)
|
||||
FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_PGERR|FLASH_FLAG_WRPRTERR);
|
||||
return FLASH_ProgramHalfWord(Address, Data);
|
||||
}
|
||||
/*******************************************************************************
|
||||
FLASH_Erase:
|
||||
*******************************************************************************/
|
||||
void FLASH_Erase(u32 Address)
|
||||
{
|
||||
if(Address%FLASH_PAGE == 0) { // FLASH Page start (1K/Page)
|
||||
if(FLASH_WaitForLastOperation(WAIT_TIMES)!=FLASH_TIMEOUT)
|
||||
FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_PGERR|FLASH_FLAG_WRPRTERR);
|
||||
FLASH_ErasePage(Address); // FLASH Page erase
|
||||
}
|
||||
}
|
||||
/********************************* END OF FILE ******************************/
|
||||
383
S100App/Src/HARDWARE.c
Normal file
383
S100App/Src/HARDWARE.c
Normal file
@@ -0,0 +1,383 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : CTRL.c
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/07
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
2015/07/20 <20>Ӵ<EFBFBD><D3B4>¶ȱ<C2B6><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "APP_Version.h"
|
||||
#include "HARDWARE.h"
|
||||
#include "CTRL.h"
|
||||
#include "bios.h"
|
||||
#include "HARDWARE.h"
|
||||
#include "UI.h"
|
||||
/******************************************************************************/
|
||||
#define CAL_AD 250
|
||||
const u32 gVol[] = {3900,2760,1720,584};
|
||||
const u16 gRate[] = {300,150,90,40};
|
||||
s32 gZerop_ad = 239;
|
||||
u32 gTurn_offv = 100;
|
||||
u8 gCalib_flag = 0;
|
||||
vu16 gMeas_cnt= 0;/* Measure*/
|
||||
u32 gKey_in;
|
||||
u8 gLongkey_flag = 0;
|
||||
u8 gAlarm_type = 1;
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_CalFlag
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡУ״̬
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:У״̬<D7B4><CCAC>־
|
||||
*******************************************************************************/
|
||||
u32 Get_CalFlag(void)
|
||||
{
|
||||
return gCalib_flag;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_gKey
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>״̬
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>״̬
|
||||
*******************************************************************************/
|
||||
u32 Get_gKey(void)
|
||||
{
|
||||
return gKey_in;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_gKey
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ð<EFBFBD><C3B0><EFBFBD>״̬
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:Ҫ<><D2AA><EFBFBD>õİ<C3B5><C4B0><EFBFBD>״̬
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Set_gKey(u32 key)
|
||||
{
|
||||
gKey_in = key;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_LongKeyFlag
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:0 :<3A><><EFBFBD><EFBFBD><EFBFBD>Գ<EFBFBD><D4B3><EFBFBD><EFBFBD><EFBFBD> 1: <20><><EFBFBD>Գ<EFBFBD><D4B3><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Set_LongKeyFlag(u32 flag)
|
||||
{
|
||||
gLongkey_flag = flag;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_AlarmType
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
0:<3A><><EFBFBD><EFBFBD>
|
||||
1:sen - err
|
||||
2:<3A><><EFBFBD><EFBFBD>
|
||||
3:<3A><>ѹ
|
||||
*******************************************************************************/
|
||||
u8 Get_AlarmType(void)
|
||||
{
|
||||
return gAlarm_type;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_AlarmType
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
0:<3A><><EFBFBD><EFBFBD>
|
||||
1:sen - err
|
||||
2:<3A><><EFBFBD><EFBFBD>
|
||||
3:<3A><>ѹ
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Set_AlarmType(u8 type)
|
||||
{
|
||||
gAlarm_type = type;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Read_Vb
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1>Դ<EFBFBD><D4B4>ѹֵ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>־
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
int Read_Vb(u8 flag)
|
||||
{
|
||||
u32 tmp,i,sum = 0;
|
||||
|
||||
for(i = 0; i < 10; i++) {
|
||||
tmp = ADC_GetConversionValue(ADC2);
|
||||
sum += tmp;
|
||||
}
|
||||
tmp = sum/10;
|
||||
if(tmp >= (gVol[0] + gVol[0]/100)) {
|
||||
gAlarm_type = HIGH_VOLTAGE;
|
||||
return H_ALARM; //<2F><><EFBFBD><EFBFBD>3500
|
||||
}
|
||||
tmp = (tmp*10/144);//<2F><>ѹvb = 3.3 * 85 *ad / 40950
|
||||
|
||||
for(i = 0; i < 4; i++) {
|
||||
if(i == 2) {
|
||||
if(flag == 0 ) {
|
||||
if(tmp >= gRate[i])break;
|
||||
} else {
|
||||
if(tmp >= gTurn_offv)break;
|
||||
}
|
||||
} else {
|
||||
if(tmp >= gRate[i])break;
|
||||
}
|
||||
}
|
||||
return (i+1);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Scan_Key
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(50msÿ<73><C3BF>)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Scan_Key(void)
|
||||
{
|
||||
static u32 p_cnt = 0,key_statuslast = 0;
|
||||
u32 key_state = 0;
|
||||
|
||||
if((~GPIOA->IDR) & 0x0200) key_state |= KEY_V1; //KEY_V1
|
||||
if((~GPIOA->IDR) & 0x0040) key_state |= KEY_V2; //KEY_V2
|
||||
|
||||
if(key_state == 0) return ;
|
||||
|
||||
if(gLongkey_flag == 1) { //LongKey_flag :<3A><><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||||
if(key_statuslast == key_state) {
|
||||
p_cnt++;
|
||||
if(p_cnt > 21) Set_gKey(KEY_CN | key_state);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
} else {
|
||||
p_cnt = 0;
|
||||
key_statuslast = key_state;
|
||||
Set_gKey(key_state);
|
||||
}
|
||||
} else {
|
||||
p_cnt = 0;
|
||||
key_statuslast = key_state;
|
||||
Set_gKey(key_state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_SlAvg
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>ֵ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:avg_data ƽ<><C6BD><EFBFBD><EFBFBD>ADֵ
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>ֵ
|
||||
*******************************************************************************/
|
||||
u32 Get_SlAvg(u32 avg_data)
|
||||
{
|
||||
static u32 sum_avg = 0;
|
||||
static u8 init_flag = 0;
|
||||
u16 si_avg = sum_avg/SI_COE,abs;
|
||||
|
||||
if(init_flag == 0) { /*<2A><>һ<EFBFBD><D2BB><EFBFBD>ϵ<EFBFBD>*/
|
||||
sum_avg = SI_COE * avg_data;
|
||||
init_flag = 1;
|
||||
return sum_avg/SI_COE;
|
||||
}
|
||||
if (avg_data > si_avg) abs = avg_data - si_avg;
|
||||
else abs = si_avg - avg_data;
|
||||
|
||||
if(abs > SI_THRESHOLD) sum_avg = SI_COE * avg_data;
|
||||
else sum_avg += avg_data - sum_avg/SI_COE;
|
||||
|
||||
return sum_avg/SI_COE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_AvgAd
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD>ADƽ<44><C6BD>ֵ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:ADƽ<44><C6BD>ֵ
|
||||
*******************************************************************************/
|
||||
u32 Get_AvgAd(void)
|
||||
{
|
||||
static u32 ad_sum = 0;
|
||||
static u32 max = 0,min = 5000;
|
||||
u32 ad_value,avg_data,slide_data;
|
||||
|
||||
Set_HeatingTime(0);
|
||||
HEAT_OFF();
|
||||
Delay_HalfMs(25);
|
||||
gMeas_cnt = 10;
|
||||
|
||||
while(gMeas_cnt > 0) {
|
||||
ad_value = Get_AdcValue(0);//Read_Tmp();
|
||||
ad_sum += ad_value;
|
||||
if(ad_value > max) max = ad_value;
|
||||
if(ad_value < min) min = ad_value;
|
||||
|
||||
if(gMeas_cnt == 1) {
|
||||
ad_sum = ad_sum - max - min;
|
||||
avg_data = ad_sum / 8;
|
||||
|
||||
slide_data = Get_SlAvg(avg_data);
|
||||
ad_sum = 0;
|
||||
min = 5000;
|
||||
max = 0;
|
||||
}
|
||||
gMeas_cnt--;
|
||||
}
|
||||
return slide_data;//gSlide_data;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_TempSlAvg
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD>¶Ȼ<C2B6><C8BB><EFBFBD>ƽ<EFBFBD><C6BD>ֵ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:avg_data <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>ƽ<EFBFBD><C6BD>ֵ
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD>¶Ȼ<C2B6><C8BB><EFBFBD>ƽ<EFBFBD><C6BD>ֵ
|
||||
*******************************************************************************/
|
||||
int Get_TempSlAvg(int avg_data)
|
||||
{
|
||||
static int sum_avg = 0;
|
||||
static u8 init_flag = 0;
|
||||
|
||||
if(init_flag == 0) { /*<2A><>һ<EFBFBD><D2BB><EFBFBD>ϵ<EFBFBD>*/
|
||||
sum_avg = 8 * avg_data;
|
||||
init_flag = 1;
|
||||
return sum_avg/8;
|
||||
}
|
||||
|
||||
sum_avg += avg_data - sum_avg/8;
|
||||
|
||||
return sum_avg/8;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_SensorTmp
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
*******************************************************************************/
|
||||
int Get_SensorTmp(void)
|
||||
{
|
||||
static u32 ad_sum = 0;
|
||||
static u32 max = 0,min = 5000;
|
||||
u32 ad_value,avg_data,slide_data;
|
||||
int sensor_temp = 0;
|
||||
|
||||
gMeas_cnt = 10;
|
||||
|
||||
while(gMeas_cnt > 0) {
|
||||
ad_value = Get_AdcValue(1);
|
||||
ad_sum += ad_value;
|
||||
if(ad_value > max) max = ad_value;
|
||||
if(ad_value < min) min = ad_value;
|
||||
|
||||
if(gMeas_cnt == 1) {
|
||||
ad_sum = ad_sum - max - min;
|
||||
avg_data = ad_sum / 8;
|
||||
|
||||
slide_data = Get_TempSlAvg(avg_data);
|
||||
sensor_temp = (250 + (3300*slide_data/4096)-750);//(25 + ((10*(33*gSlide_data)/4096)-75));
|
||||
ad_sum = 0;
|
||||
min = 5000;
|
||||
max = 0;
|
||||
}
|
||||
gMeas_cnt--;
|
||||
}
|
||||
return sensor_temp;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Zero_Calibration
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:У<D0A3><D7BC><EFBFBD><EFBFBD>AD
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Zero_Calibration(void)
|
||||
{
|
||||
u32 zerop;
|
||||
int cool_tmp;
|
||||
|
||||
zerop = Get_AvgAd();
|
||||
cool_tmp = Get_SensorTmp();
|
||||
|
||||
if(zerop >= 400) {
|
||||
gCalib_flag = 2;
|
||||
} else {
|
||||
if(cool_tmp < 300) {
|
||||
gZerop_ad = zerop;
|
||||
gCalib_flag = 1;
|
||||
} else {
|
||||
gCalib_flag = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_Temp
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>ȶ<EFBFBD><C8B6>¶<EFBFBD>,<2C><><EFBFBD><EFBFBD>AD<41><44><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:wk_temp <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:ʵ<><CAB5><EFBFBD>¶<EFBFBD>
|
||||
*******************************************************************************/
|
||||
s16 Get_Temp(s16 wk_temp)
|
||||
{
|
||||
int ad_value,cool_tmp,compensation = 0;
|
||||
static u16 cnt = 0,h_cnt = 0;
|
||||
s16 rl_temp = 0;
|
||||
|
||||
ad_value = Get_AvgAd();
|
||||
cool_tmp = Get_SensorTmp();
|
||||
|
||||
if(ad_value == 4095) h_cnt++;
|
||||
else {
|
||||
h_cnt = 0;
|
||||
if(ad_value > 3800 && ad_value < 4095) cnt++; //20150720<32><EFBFBD>
|
||||
else cnt = 0;
|
||||
}
|
||||
if(h_cnt >= 60&& cnt == 0) gAlarm_type = SEN_ERR; //Sen-err
|
||||
if(h_cnt == 0 && cnt >= 10) gAlarm_type = HIGH_TEMP; //<2F><><EFBFBD><EFBFBD>
|
||||
if(h_cnt < 60 && cnt < 10) gAlarm_type = NORMAL_TEMP;
|
||||
|
||||
compensation = 80 + 150 * (wk_temp - 1000) / 3000;
|
||||
if(wk_temp == 1000) compensation -= 10;
|
||||
|
||||
if(wk_temp != 0) {
|
||||
if(ad_value > (compensation + gZerop_ad)) ad_value -= compensation;
|
||||
}
|
||||
if(cool_tmp > 400) cool_tmp = 400;
|
||||
rl_temp = (ad_value * 1000 + 806 * cool_tmp - gZerop_ad * 1000)/806;
|
||||
|
||||
return rl_temp;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Start_Watchdog
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>Ź<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:ms <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>1
|
||||
*******************************************************************************/
|
||||
u32 Start_Watchdog(u32 ms)
|
||||
{
|
||||
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
|
||||
|
||||
/* IWDG counter clock: 40KHz(LSI) / 32 = 1.25 KHz (min:0.8ms -- max:3276.8ms */
|
||||
IWDG_SetPrescaler(IWDG_Prescaler_32);
|
||||
|
||||
/* Set counter reload value to XXms */
|
||||
IWDG_SetReload(ms*10/8);
|
||||
|
||||
/* Reload IWDG counter */
|
||||
IWDG_ReloadCounter();
|
||||
|
||||
/* Enable IWDG (the LSI oscillator will be enabled by hardware) */
|
||||
IWDG_Enable();
|
||||
return 1;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Clear_Watchdog
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ÿ<EFBFBD><C3BF>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>1
|
||||
*******************************************************************************/
|
||||
u32 Clear_Watchdog(void)
|
||||
{
|
||||
IWDG_ReloadCounter();
|
||||
return 1;
|
||||
}
|
||||
/******************************** END OF FILE *********************************/
|
||||
229
S100App/Src/I2C.c
Normal file
229
S100App/Src/I2C.c
Normal file
@@ -0,0 +1,229 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : I2C.c
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/20
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
2015/07/21 I2C_DELAYTIME = 2;
|
||||
*******************************************************************************/
|
||||
|
||||
#include "stm32f10x.h"
|
||||
#include "I2C.h"
|
||||
#include "Bios.h"
|
||||
#include "oled.h"
|
||||
#include "S100V0_1.h"
|
||||
|
||||
// --------- <20><><EFBFBD><EFBFBD>I2C<32>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD>-------- //
|
||||
#define SDA GPIO_Pin_7
|
||||
#define SCL GPIO_Pin_6
|
||||
|
||||
#define HIGH 1
|
||||
#define LOW 0
|
||||
|
||||
#define SDA_VAL GPIO_ReadInputDataBit(GPIOB, SDA)
|
||||
#define SCL_VAL GPIO_ReadInputDataBit(GPIOB, SCL)
|
||||
|
||||
#define I2C_MORE 1
|
||||
#define I2C_LAST 0
|
||||
#define I2C_TIMEOUT 255
|
||||
|
||||
#define FAILURE 0
|
||||
#define SUCCEED 1
|
||||
#define I2C_DELAYTIME 2
|
||||
|
||||
static void Sim_I2C_Set(u8 pin, u8 status);
|
||||
static void Sim_I2C_Stop(void);
|
||||
static void Sim_I2C_Start(void);
|
||||
static u8 Sim_I2C_RD_Byte(u8 more);
|
||||
static u8 Sim_I2C_WR_Byte(u8 data);
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Delay_uS
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:us
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Delay_uS(u32 us)
|
||||
{
|
||||
while(us) us--;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: I2C_Configuration
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD>I2C
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void I2C_Configuration(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
I2C_InitTypeDef I2C_InitStructure;
|
||||
|
||||
GPIO_Init_OLED();
|
||||
/* PB6,7 SCL and SDA */
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
/* I2C1 configuration ------------------------------------------------------*/
|
||||
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
|
||||
I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
|
||||
I2C_InitStructure.I2C_OwnAddress1 = DEVICEADDR_OLED;
|
||||
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
|
||||
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
|
||||
I2C_InitStructure.I2C_ClockSpeed = 100000;//100k
|
||||
I2C_Init(I2C1, &I2C_InitStructure);
|
||||
I2C_Cmd(I2C1, ENABLE);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: I2C_Configuration
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD>I2C
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Sim_I2C_Set(u8 pin, u8 status)
|
||||
{
|
||||
if(status == HIGH) GPIO_SetBits (GPIOB, pin);
|
||||
if(status == LOW) GPIO_ResetBits(GPIOB, pin);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sim_I2C_Start
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>ʼ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Sim_I2C_Start(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); // I2C_PIN_EN();
|
||||
GPIO_InitStructure.GPIO_Pin = SCL | SDA;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init (GPIOB, &GPIO_InitStructure);
|
||||
|
||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
||||
Sim_I2C_Set(SDA, HIGH); // SDA float, set as output high
|
||||
Sim_I2C_Set(SCL, HIGH); // SCL high
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
Sim_I2C_Set(SDA, LOW); // SDA high->low while sclk high, S state occur...
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sim_I2C_Stop
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ֹͣ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Sim_I2C_Stop(void)
|
||||
{
|
||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
||||
Sim_I2C_Set(SDA, LOW); // SDA low
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
Sim_I2C_Set(SCL, HIGH); // SCL high
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
Sim_I2C_Set(SDA, HIGH); // SDA low->high while sclk high, P state occur
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sim_I2C_WR_Byte
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>I2Cд<43><D0B4>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:dataҪд<D2AA><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
u8 Sim_I2C_WR_Byte(u8 data)
|
||||
{
|
||||
u8 i = 8;
|
||||
|
||||
while(i--) { //send out a bit by sda line.
|
||||
Sim_I2C_Set(SCL, LOW); // sclk low
|
||||
if(data & 0x80) Sim_I2C_Set(SDA, HIGH); // send bit is 1
|
||||
else Sim_I2C_Set(SDA, LOW); // send bit is 0
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
Sim_I2C_Set(SCL, HIGH); // SCL high
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
data <<=1; // left shift 1 bit, MSB send first.
|
||||
}
|
||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
||||
Sim_I2C_Set(SDA, HIGH); // SDA set as input
|
||||
for(i=I2C_TIMEOUT; i!=0; i--) { // wait for sda low to receive ack
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
if (!SDA_VAL) {
|
||||
Sim_I2C_Set(SCL, HIGH); // SCL high
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
Sim_I2C_Set(SCL, LOW); // SCL_LOW();
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
return SUCCEED;
|
||||
}
|
||||
}
|
||||
return FAILURE;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sim_I2C_RD_Byte
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>I2C<32><43><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:more
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
u8 Sim_I2C_RD_Byte(u8 more)
|
||||
{
|
||||
u8 i = 8, byte = 0;
|
||||
|
||||
Sim_I2C_Set(SDA, HIGH); // SDA set as input
|
||||
while(i--) {
|
||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
Sim_I2C_Set(SCL, HIGH); // SCL high
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
byte <<=1; //recv a bit
|
||||
if (SDA_VAL) byte |= 0x01;
|
||||
}
|
||||
Sim_I2C_Set(SCL, LOW);
|
||||
if(!more) Sim_I2C_Set(SDA, HIGH); //last byte, send nack.
|
||||
else Sim_I2C_Set(SDA, LOW); //send ack
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
Sim_I2C_Set(SCL, HIGH); // SCL_HIGH();
|
||||
Delay_uS(I2C_DELAYTIME);
|
||||
Sim_I2C_Set(SCL, LOW);
|
||||
return byte;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: I2C_PageWrite
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><> <20><>ַ deviceaddr д<><D0B4>numbyte<74><65><EFBFBD>ֽڵ<D6BD><DAB5><EFBFBD><EFBFBD>ݣ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>pbuf
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:pbuf д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>numbyte Ϊд<CEAA><D0B4><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>deviceaddrΪд<CEAA><D0B4><EFBFBD>ĵ<EFBFBD>ַ
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void I2C_PageWrite(u8* pbuf, u8 numbyte,u8 deviceaddr )
|
||||
{
|
||||
Sim_I2C_Start();
|
||||
Sim_I2C_WR_Byte(deviceaddr<<1);
|
||||
while(numbyte--) Sim_I2C_WR_Byte(*pbuf++);
|
||||
Sim_I2C_Stop();
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: I2C_PageRead
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>I2C<32><43><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: pbuf <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ŵ<EFBFBD>ַ numbyteΪ<65><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
|
||||
deviceaddr<64>豸<EFBFBD><E8B1B8>ַ readaddr<64><72>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
void I2C_PageRead(u8* pbuf, u8 numbyte,u8 deviceaddr, u8 readaddr)
|
||||
{
|
||||
Sim_I2C_Start();
|
||||
Sim_I2C_WR_Byte(deviceaddr<<1);
|
||||
Sim_I2C_WR_Byte(readaddr);
|
||||
Sim_I2C_Start();
|
||||
Sim_I2C_WR_Byte((deviceaddr<<1)|1);
|
||||
|
||||
while(numbyte--) {
|
||||
if(numbyte) *pbuf++ = Sim_I2C_RD_Byte(I2C_MORE);
|
||||
else *pbuf++ = Sim_I2C_RD_Byte(I2C_LAST);
|
||||
}
|
||||
Sim_I2C_Stop();
|
||||
}
|
||||
/******************************** END OF FILE *********************************/
|
||||
79
S100App/Src/Interrupt.c
Normal file
79
S100App/Src/Interrupt.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. *******************/
|
||||
/* Brief : Interrupt Service Routines Author : bure */
|
||||
/******************************************************************************/
|
||||
#include "Interrupt.h"
|
||||
#include "usb_istr.h"
|
||||
#include "Bios.h"
|
||||
#include "I2C.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/* Processor Exceptions Handlers */
|
||||
/******************************************************************************/
|
||||
|
||||
void NMI_Handler(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
while (1);
|
||||
}
|
||||
|
||||
void MemManage_Handler(void)
|
||||
{
|
||||
while (1);
|
||||
}
|
||||
|
||||
void BusFault_Handler(void)
|
||||
{
|
||||
while (1);
|
||||
}
|
||||
|
||||
void UsageFault_Handler(void)
|
||||
{
|
||||
while (1);
|
||||
}
|
||||
|
||||
void SVC_Handler(void) {}
|
||||
|
||||
void DebugMon_Handler(void) {}
|
||||
|
||||
void PendSV_Handler(void) {}
|
||||
|
||||
void SysTick_Handler(void) {}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Peripherals Interrupt Handlers */
|
||||
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
|
||||
/* available peripheral interrupt handler's name please refer to the startup */
|
||||
/* file (startup_stm32f30x.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
void USB_LP_CAN1_RX0_IRQHandler(void)
|
||||
{
|
||||
USB_Istr();
|
||||
}
|
||||
/*
|
||||
void I2C1_EV_IRQHandler(void)
|
||||
{
|
||||
I2C1_EV_ISR();
|
||||
}
|
||||
|
||||
void I2C1_ER_IRQHandler(void)
|
||||
{
|
||||
I2C1_ER_ISR();
|
||||
}
|
||||
*/
|
||||
void TIM2_IRQHandler(void)
|
||||
{
|
||||
TIM2_ISR();
|
||||
}
|
||||
|
||||
void TIM3_IRQHandler(void)
|
||||
{
|
||||
TIM3_ISR();
|
||||
}
|
||||
|
||||
/********************************* END OF FILE ******************************/
|
||||
|
||||
268
S100App/Src/MMA8652FC.c
Normal file
268
S100App/Src/MMA8652FC.c
Normal file
@@ -0,0 +1,268 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : MMA8652FC.c
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/07
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "APP_Version.h"
|
||||
#include "Bios.h"
|
||||
#include "Oled.h"
|
||||
#include "MMA8652FC.h"
|
||||
#include "I2C.h"
|
||||
#include "CTRL.h"
|
||||
#include "UI.h"
|
||||
//------------------------------------------------------------------//
|
||||
|
||||
static int IIC_RegWrite(u8 reg,u8 data);
|
||||
static int IIC_RegRead(u8 reg);
|
||||
static int Read_ZYXDr(void);
|
||||
|
||||
u16 gactive = 0,gShift = 0;
|
||||
u8 gMmatxdata;
|
||||
|
||||
typedef struct {
|
||||
u8 hi;
|
||||
u8 lo;
|
||||
} DRByte;
|
||||
typedef struct {
|
||||
DRByte Byte;
|
||||
|
||||
} DR_Value;
|
||||
|
||||
DR_Value gX_value,gY_value,gZ_value;
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_MmaActive
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1><EFBFBD>ٶȴ<D9B6><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ٶȴ<D9B6><C8B4><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
*******************************************************************************/
|
||||
u16 Get_MmaActive(void)
|
||||
{
|
||||
return gactive;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_MmaActive
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:XXXXXXXXXXXXXXXXXXXXXX
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:XXXXXXXXXXXXXXXXXXXXXX
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:XXXXXXXXXXXXXXXXXXXXXX
|
||||
*******************************************************************************/
|
||||
u16 Get_MmaShift(void)
|
||||
{
|
||||
return gShift;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_MmaActive
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:XXXXXXXXXXXXXXXXXXXXXX
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:XXXXXXXXXXXXXXXXXXXXXX
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:XXXXXXXXXXXXXXXXXXXXXX
|
||||
*******************************************************************************/
|
||||
void Set_MmaShift(u16 shift)
|
||||
{
|
||||
gShift = shift;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: IIC_RegWrite
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>Reg<65><67>ַд<D6B7><D0B4>Data
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:Reg <20><><EFBFBD><EFBFBD><EFBFBD>еĵ<D0B5>ַ<EFBFBD><D6B7>Data<74><61><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>: <20>ɹ<EFBFBD><C9B9><EFBFBD>
|
||||
*******************************************************************************/
|
||||
int IIC_RegWrite(u8 reg,u8 data)
|
||||
{
|
||||
u8 tx_data[20];
|
||||
|
||||
tx_data[0]=reg;
|
||||
tx_data[1]=data;
|
||||
I2C_PageWrite(tx_data,2,DEVICE_ADDR);
|
||||
return 1;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: IIC_RegRead
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Reg<65><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:Reg <20><><EFBFBD><EFBFBD><EFBFBD>еĵ<D0B5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>gMmatxdata<74><61>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>: <20>ɹ<EFBFBD><C9B9><EFBFBD>
|
||||
*******************************************************************************/
|
||||
int IIC_RegRead(u8 reg)
|
||||
{
|
||||
u8 tx_data[20];
|
||||
tx_data[0] = reg;
|
||||
|
||||
I2C_PageRead(tx_data, 1, DEVICE_ADDR, reg);
|
||||
gMmatxdata = tx_data[0];
|
||||
return 1;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: MMA865x_Standby
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void MMA865x_Standby(void)
|
||||
{
|
||||
//Put the sensor into Standby Mode by clearing
|
||||
// the Active bit of the System Control 1 Register
|
||||
IIC_RegWrite(CTRL_REG1, 0); //(IIC_RegRead(CTRL_REG1) & ~ ACTIVE_MASK)
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: MMA865x_Active
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void MMA865x_Active(void)
|
||||
{
|
||||
// Put the sensor into Active Mode by setting the
|
||||
// Active bit of the System Control 1 Register
|
||||
IIC_RegWrite(CTRL_REG1,ACTIVE_MASK );//(IIC_RegRead(CTRL_REG1) | ACTIVE_MASK)
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: IIC_RegRead
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Reg<65><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void StartUp_Accelerated(void)
|
||||
{
|
||||
//------<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬-----------------------//
|
||||
MMA865x_Standby();
|
||||
//---- <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>Χ4g----------------------//
|
||||
IIC_RegWrite(XYZ_DATA_CFG_REG,FULL_SCALE_8G );//(IIC_RegRead(XYZ_DATA_CFG_REG) & ~FS_MASK)
|
||||
//--- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>100HZ------------------------------------//
|
||||
IIC_RegWrite(CTRL_REG1, DataRateValue); //IIC_RegRead(CTRL_REG1)|
|
||||
//----<2D><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ------------------------------------------------------//
|
||||
IIC_RegWrite(CTRL_REG2, 0);//(IIC_RegRead(CTRL_REG2) & ~MODS_MASK)
|
||||
//---------<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ------------------------------------//
|
||||
MMA865x_Active();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Read_ZYXDr
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡXYZ<59><5A><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:x,y,z<>ķ<EFBFBD><C4B7><EFBFBD>
|
||||
*******************************************************************************/
|
||||
int Read_ZYXDr(void)
|
||||
{
|
||||
u8 reg_flag;
|
||||
u8 ptr,i;
|
||||
u8 value[6];
|
||||
|
||||
memset((u8*)&gX_value,0,6);
|
||||
//Poll the ZYXDR status bit and wait for it to set
|
||||
if(IIC_RegRead(STATUS_REG)) {
|
||||
reg_flag = gMmatxdata ;
|
||||
if((reg_flag & ZYXDR_BIT) !=0) {
|
||||
//Read 12/10-bit XYZ results using a 6 byte IIC access
|
||||
ptr=X_MSB_REG;
|
||||
for(i=0; i<6; i++) {
|
||||
if(IIC_RegRead(ptr++)==0)break;
|
||||
value[i]=gMmatxdata ;
|
||||
//Copy and save each result as a 16-bit left-justified value
|
||||
gX_value.Byte.hi = value[0];
|
||||
gX_value.Byte.lo = value[1];
|
||||
gY_value.Byte.hi = value[2];
|
||||
gY_value.Byte.lo = value[3];
|
||||
gZ_value.Byte.hi = value[4];
|
||||
gZ_value.Byte.lo = value[5];
|
||||
return 1;
|
||||
}
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Cheak_XYData
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>x<EFBFBD><78>y<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD>仯
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:ǰһxy<78><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>xy<78><79><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A>Ƿ<EFBFBD><C7B7>ƶ<EFBFBD>
|
||||
*******************************************************************************/
|
||||
u16 Cheak_XYData(u16 x0,u16 y0,u16 x1,u16 y1)
|
||||
{
|
||||
u16 active = 0;
|
||||
gShift = 0;
|
||||
|
||||
if((x1 > (x0 + 16)) || (x1 < (x0 - 16))) active = 1;
|
||||
if((y1 > (y0 + 16)) || (y1 < (y0 - 16))) active = 1;
|
||||
|
||||
if((x1 > (x0 + 32)) || (x1 < (x0 - 32))) gShift = 1;
|
||||
if((y1 > (y0 + 32)) || (y1 < (y0 - 32))) gShift = 1;
|
||||
|
||||
return active;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Update_X
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>x
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
u16 Update_X(void)
|
||||
{
|
||||
u16 value,x;
|
||||
|
||||
value = ((gX_value.Byte.hi<<8) | (gX_value.Byte.lo & 0xf0 ))>>4;
|
||||
if(gX_value.Byte.hi>0x7f) x = (~value+1) & 0xfff;
|
||||
else x = value & 0xfff;
|
||||
|
||||
return x;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Update_Y
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>y
|
||||
*******************************************************************************/
|
||||
u16 Update_Y(void)
|
||||
{
|
||||
u16 value,y;
|
||||
|
||||
value = ((gY_value.Byte.hi<<8) | (gY_value.Byte.lo & 0xf0 ))>>4;
|
||||
if(gY_value.Byte.hi>0x7f) y = (~value+1) & 0xfff;
|
||||
else y = value & 0xfff;
|
||||
|
||||
return y;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Update_z
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>z
|
||||
*******************************************************************************/
|
||||
u16 Update_Z(void)
|
||||
{
|
||||
u16 value,z;
|
||||
|
||||
value = ((gZ_value.Byte.hi<<8) | (gZ_value.Byte.lo & 0xf0 ))>>4;
|
||||
if(gZ_value.Byte.hi>0x7f) z = (~value+1) & 0xfff;
|
||||
else z = value & 0xfff;
|
||||
|
||||
return z;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Check_Accelerated
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶȴ<D9B6><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ƶ<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Check_Accelerated(void)
|
||||
{
|
||||
static u16 x0 = 0,y0 = 0;
|
||||
u16 x1,y1;
|
||||
|
||||
if(Read_ZYXDr()) { /*<2A><><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
x1 = Update_X();
|
||||
y1 = Update_Y();
|
||||
} else x1 = x0;
|
||||
y1 = y0;
|
||||
gactive = Cheak_XYData(x0,y0,x1,y1);/*<2A><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ƶ<EFBFBD>*/
|
||||
|
||||
x0 = x1;
|
||||
y0 = y1;
|
||||
}
|
||||
/******************************** END OF FILE *********************************/
|
||||
69
S100App/Src/Main.c
Normal file
69
S100App/Src/Main.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : main.c
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/07
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "APP_Version.h"
|
||||
#include "Disk.h"
|
||||
#include "Bios.h"
|
||||
#include "USB_lib.h"
|
||||
#include "I2C.h"
|
||||
#include "Flash.h"
|
||||
#include "MMA8652FC.h"
|
||||
#include "UI.h"
|
||||
#include "OLed.h"
|
||||
#include "CTRL.h"
|
||||
#include "HARDWARE.h"
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: main
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ѭ<EFBFBD><D1AD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void main(void)
|
||||
{
|
||||
RCC_Config();
|
||||
NVIC_Config(0x4000);
|
||||
Init_Timer2();
|
||||
Init_Timer3();
|
||||
GPIO_Config();
|
||||
USB_Port(DISABLE);
|
||||
Delay_Ms(200);
|
||||
USB_Port(ENABLE);
|
||||
USB_Init();
|
||||
I2C_Configuration();
|
||||
|
||||
Ad_Init();
|
||||
if (Get_CtrlStatus() != CONFIG) StartUp_Accelerated();
|
||||
|
||||
System_Init();
|
||||
Init_Oled();
|
||||
Clear_Screen();
|
||||
Init_Gtime();
|
||||
APP_Init();
|
||||
|
||||
Disk_BuffInit();
|
||||
Config_Analysis(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>U<EFBFBD><55>
|
||||
|
||||
Pid_Init();
|
||||
Set_gKey(NO_KEY);
|
||||
Start_Watchdog(3000);
|
||||
|
||||
while (1) {
|
||||
Clear_Watchdog();
|
||||
if (Get_CtrlStatus() != CONFIG && LEAVE_WAIT_TIMER == 0) {
|
||||
Check_Accelerated();
|
||||
LEAVE_WAIT_TIMER = 50;
|
||||
}
|
||||
OLed_Display(); //<2F><>ʾCtrl_status
|
||||
Status_Tran(); //<2F><><EFBFBD>ݵ<EFBFBD>ǰ״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD><CFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ת<EFBFBD><D7AA>
|
||||
}
|
||||
}
|
||||
/******************************** END OF FILE *********************************/
|
||||
319
S100App/Src/Oled.c
Normal file
319
S100App/Src/Oled.c
Normal file
@@ -0,0 +1,319 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
||||
File Name : Oled.c
|
||||
Version : S100 APP Ver 2.11
|
||||
Description:
|
||||
Author : Celery
|
||||
Data: 2015/07/07
|
||||
History:
|
||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "APP_Version.h"
|
||||
#include "Oled.h"
|
||||
#include "Bios.h"
|
||||
#include "I2C.h"
|
||||
#include "HARDWARE.h"
|
||||
#include "DISK.h"
|
||||
#include "UI.h"
|
||||
|
||||
|
||||
const u8 Mini[] = {/*12*16*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFE,
|
||||
0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFE,0xFE,0xFC,0x78,
|
||||
0x30,0x80,0xC0,0xC0,0x00,0x18,0x9C,0xCE,0xE6,0xF0,0xF8,0xFC,0xFE,0xFE,0xFC,0xF8,
|
||||
0xF0,0xE0,0xC0,0xE0,0xF0,0xF8,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x0F,0x07,0x03,0x01,0x03,0x07,0x0F,0x1F,
|
||||
0x3F,0x7F,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x03,0x07,0x07,0x03,0x19,0x1C,0x0E,
|
||||
0x67,0x73,0x39,0x1C,0x0E,0x07,0x03,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0x7F,0x3F,
|
||||
0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\LOGOIN.BMP.bmp",0*/
|
||||
};
|
||||
const u8 Seeed[] = {/*12*16*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x80,0x00,0x00,0xC0,0xF8,0x38,0x04,0x00,
|
||||
0x04,0x38,0xF8,0xC0,0x00,0x00,0x80,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x30,
|
||||
0x10,0x10,0x10,0x10,0x10,0x20,0x00,0x00,0x80,0xC0,0x60,0x30,0x10,0x10,0x10,0x30,
|
||||
0x60,0xC0,0x80,0x00,0x00,0x80,0xC0,0x60,0x30,0x10,0x10,0x10,0x30,0x60,0xC0,0x80,
|
||||
0x00,0x80,0xC0,0x60,0x30,0x10,0x10,0x10,0x30,0x60,0xC0,0x80,0x00,0x00,0x80,0xC0,
|
||||
0x40,0x20,0x20,0x20,0x20,0x40,0xC0,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0F,0x1C,0x38,0x23,0x6F,0x5C,0x00,0x00,
|
||||
0x00,0x5C,0x6F,0x23,0x38,0x1C,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x23,
|
||||
0x42,0x42,0x42,0x42,0x42,0x22,0x1C,0x00,0x07,0x1E,0x32,0x22,0x42,0x42,0x42,0x42,
|
||||
0x62,0x32,0x03,0x00,0x00,0x07,0x1E,0x32,0x22,0x42,0x42,0x42,0x42,0x22,0x32,0x03,
|
||||
0x00,0x07,0x1E,0x32,0x22,0x42,0x42,0x42,0x42,0x62,0x32,0x03,0x00,0x00,0x0F,0x18,
|
||||
0x10,0x20,0x20,0x20,0x20,0x10,0x18,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\LOGOIN.ddMP.bmp",0*/
|
||||
};
|
||||
#ifdef SSD1316
|
||||
u8 gOled_param[50] = { 0x80,0xAE,0x80,0x00,0x80,0x10,0x80,0x40,0x80,0xB0,0x80,
|
||||
0x81,0x80,0xFF,0x80,0xA0,0x80,0xA6,0x80,0xA8,0x80,0x1F,
|
||||
0x80,0xC8,0x80,0xD3,0x80,0x00,0x80,0xD5,0x80,0x80,0x80,
|
||||
0xD9,0x80,0x22,0x80,0xDA,0x80,0x12,0x80,0xDB,0x80,0x40,
|
||||
0x80,0x8D,0x80,0x14,0x80,0xAF,
|
||||
};
|
||||
#else
|
||||
u8 gOled_param[46] = { 0x80,0xAE,0x80,0xD5,0x80,0x52,0x80,0xA8,0x80,0x0f,0x80,
|
||||
0xC0,0x80,0xD3,0x80,0x00,0x80,0x40,0x80,0xA0,0x80,0x8D,
|
||||
0x80,0x14,0x80,0xDA,0x80,0x02,0x80,0x81,0x80,0x33,0x80,
|
||||
0xD9,0x80,0xF1,0x80,0xDB,0x80,0x30,0x80,0xA4,0x80,0XA6,
|
||||
0x80,0xAF
|
||||
};
|
||||
#endif
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sc_Pt
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>Ļ<EFBFBD>Աȶ<D4B1>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:Co<43><6F>Ļ<EFBFBD>ԱȶȲ<C8B6><C8B2><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Sc_Pt(u8 Co) //<2F><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>
|
||||
{
|
||||
u8 pt[4] = {0x80,0x81,0x80,Co};
|
||||
|
||||
I2C_PageWrite(pt,4,DEVICEADDR_OLED);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Oled_DisplayOn
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>OLED<45><44>ʾ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Oled_DisplayOn(void)
|
||||
{
|
||||
u8 data[6] = {0x80,0X8D,0x80,0X14,0x80,0XAF};
|
||||
|
||||
I2C_PageWrite(data,6,DEVICEADDR_OLED);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Oled_DisplayOff
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A>ر<EFBFBD>OLED<45><44>ʾ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Oled_DisplayOff(void)
|
||||
{
|
||||
u8 data[6] = {0x80,0X8D,0x80,0X10,0x80,0XAE};
|
||||
|
||||
I2C_PageWrite(data,6,DEVICEADDR_OLED);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Data_Command
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>ʾ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>봫<EFBFBD><EBB4AB>OLED
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:wide <20><>,ptr <20><>ָ<EFBFBD><D6B8>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><>һ<EFBFBD><D2BB>ָ<EFBFBD><D6B8>
|
||||
*******************************************************************************/
|
||||
u8* Data_Command(u8 wide,u8* ptr)
|
||||
{
|
||||
int i;
|
||||
u8 tx_data[128];
|
||||
|
||||
tx_data[0] = 0x40;
|
||||
wide += 1;
|
||||
for(i = 1; i < wide; i++) tx_data[i] = *ptr++;
|
||||
I2C_PageWrite(tx_data,wide,DEVICEADDR_OLED);
|
||||
return ptr;
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_ShowPos
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:Ҫ<><D2AA>ʾ<EFBFBD><CABE><EFBFBD>ݵ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:x:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,y:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0,8,16,24)
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Set_ShowPos(u8 x,u8 y)
|
||||
{
|
||||
u8 pos_param[8] = { 0x80,0xB0,0x80,0x21,0x80,0x20,0x80,0x7F };
|
||||
|
||||
pos_param[5] = x + 32;
|
||||
pos_param[1] += y;
|
||||
|
||||
I2C_PageWrite(pos_param,8,DEVICEADDR_OLED);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Oled_DrawArea
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʾһ<CABE><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: x0:<3A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
y0:<3A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0,8,16,24)
|
||||
wide:<3A><>ʾ<EFBFBD><CABE><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>
|
||||
high:<3A><>ʾ<EFBFBD><CABE><EFBFBD>ݸ߶<DDB8>
|
||||
ptr:<3A><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>ָ<EFBFBD><D6B8>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><>һ<EFBFBD><D2BB>ָ<EFBFBD><D6B8>
|
||||
*******************************************************************************/
|
||||
u8* Oled_DrawArea(u8 x0,u8 y0,u8 wide, u8 high,u8* ptr)
|
||||
{
|
||||
u8 m,n,y;
|
||||
|
||||
n = y0 + high;
|
||||
if(y0 % 8 == 0) m = y0 / 8;
|
||||
else m = y0 / 8 + 1;
|
||||
|
||||
if(n % 8 == 0) y = n / 8;
|
||||
else y = n / 8 + 1;
|
||||
|
||||
for(; m < y; m++) {
|
||||
Set_ShowPos(x0,m);
|
||||
ptr = Data_Command(wide,ptr);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Clean_Char
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wideλ<65><CEBB>Ϊk<CEAA><6B><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>wideΪ<65><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Clean_Char(int k,u8 wide)
|
||||
{
|
||||
int i;
|
||||
u8 tx_data[128];
|
||||
|
||||
memset(&tx_data[0],0,wide);
|
||||
for(i = 0; i < 2; i++) {
|
||||
Oled_DrawArea(k,i * 8,wide,8,tx_data);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: GPIO_Init_OLED
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʼ<EFBFBD><CABC>LED<45>˿<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void GPIO_Init_OLED(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = OLED_RST_PIN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Init_Oled
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʼ<EFBFBD><CABC>LED<45><44><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Init_Oled(void)
|
||||
{
|
||||
u8 param_len;
|
||||
|
||||
OLED_RST();
|
||||
Delay_Ms(2);
|
||||
OLED_ACT();
|
||||
Delay_Ms(2);
|
||||
|
||||
#ifdef SSD1316
|
||||
param_len = 50;
|
||||
#else
|
||||
param_len = 46;
|
||||
#endif
|
||||
|
||||
I2C_PageWrite((u8 *)gOled_param,param_len,DEVICEADDR_OLED);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Clear_Screen
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Clear_Screen(void)
|
||||
{
|
||||
u8 tx_data[128];
|
||||
u8 i,wd;
|
||||
|
||||
#ifdef SSD1316
|
||||
wd = 32;
|
||||
#else
|
||||
wd = 16;
|
||||
#endif
|
||||
|
||||
memset(&tx_data[0],0,128);
|
||||
for(i = 0; i < wd / 8; i++) {
|
||||
Oled_DrawArea(0,i * 8,128,8,tx_data);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Display_BG
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ΪLOGOIN.BMP<4D><50>ͼƬ
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
||||
*******************************************************************************/
|
||||
void Display_BG(void)
|
||||
{
|
||||
u8 i,j,k,m,n,p,ch,Palette = 1;
|
||||
u8* bmpfile;
|
||||
u16 filelen;
|
||||
u16* Root_addr = 0;
|
||||
u8 *ptr = 0;
|
||||
u8 g_au8TxData[128];
|
||||
|
||||
if(bmpfile = SearchFile("LOGOIN BMP",&filelen,Root_addr)) {
|
||||
if(bmpfile[0] == 'B' && bmpfile[1] == 'M' ) {
|
||||
if((bmpfile[0x36] == 0xFF) && (bmpfile[0x37] == 0xFF) && (bmpfile[0x38] == 0xFF)) {
|
||||
Palette = 0;
|
||||
}
|
||||
memset(&g_au8TxData[1],0,127);
|
||||
p = 0x1;
|
||||
for(i = 15; i >= 8; i--) {
|
||||
m = 0;
|
||||
for(j = 0; j < 12; j++) {
|
||||
ch = bmpfile[0x3E + i * 12 + j];
|
||||
n = 0x80;
|
||||
for(k = 0; k < 8; k++) {
|
||||
if(Palette) {
|
||||
if(!(ch & n)) g_au8TxData[m + 1] |= p;
|
||||
} else {
|
||||
if((ch & n)) g_au8TxData[m + 1] |= p;
|
||||
}
|
||||
m++;
|
||||
n >>= 1;
|
||||
}
|
||||
}
|
||||
p <<= 1;
|
||||
}
|
||||
Oled_DrawArea(0,0,96,8,g_au8TxData);
|
||||
Clear_Watchdog();
|
||||
|
||||
memset(&g_au8TxData[1],0,127);
|
||||
p = 0x1;
|
||||
for(i = 0; i < 8; i++) {
|
||||
m = 0;
|
||||
for(j = 0; j < 12; j++) {
|
||||
ch = bmpfile[0x3E + (7 - i) * 12 + j];
|
||||
n = 0x80;
|
||||
for(k = 0; k < 8; k++) {
|
||||
if(Palette) {
|
||||
if(!(ch & n)) g_au8TxData[m + 1] |= p;
|
||||
} else {
|
||||
if((ch & n)) g_au8TxData[m + 1] |= p;
|
||||
}
|
||||
m++;
|
||||
n >>= 1;
|
||||
}
|
||||
}
|
||||
p <<= 1;
|
||||
}
|
||||
Oled_DrawArea(0,8,96,8,g_au8TxData);
|
||||
Delay_Ms(1000);
|
||||
Clear_Watchdog();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
#ifdef MFTSEEED
|
||||
ptr = (u8*)Seeed;
|
||||
#else
|
||||
ptr = (u8*)Mini;
|
||||
#endif
|
||||
Oled_DrawArea(0,0,96,16,ptr);
|
||||
Delay_Ms(1000);
|
||||
Clear_Watchdog();
|
||||
}
|
||||
}
|
||||
|
||||
/******************************** END OF FILE *********************************/
|
||||
|
||||
641
S100App/Src/STM32F103_Startup.s
Normal file
641
S100App/Src/STM32F103_Startup.s
Normal file
@@ -0,0 +1,641 @@
|
||||
;******************** (C) COPYRIGHT 2012 STMicroelectronics ********************
|
||||
;* File Name : startup_stm32f10x_hd.s
|
||||
;* Author : MCD Application Team
|
||||
;* Version : V3.6.1
|
||||
;* Date : 09-March-2012
|
||||
;* Description : STM32F10x High Density Devices vector table for EWARM
|
||||
;* toolchain.
|
||||
;* This module performs:
|
||||
;* - Set the initial SP
|
||||
;* - Configure the clock system and the external SRAM
|
||||
;* mounted on STM3210E-EVAL board to be used as data
|
||||
;* memory (optional, to be enabled by user)
|
||||
;* - Set the initial PC == __iar_program_start,
|
||||
;* - Set the vector table entries with the exceptions ISR address,
|
||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
||||
;* priority is Privileged, and the Stack is set to Main.
|
||||
;********************************************************************************
|
||||
;*
|
||||
;* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
;* You may not use this file except in compliance with the License.
|
||||
;* You may obtain a copy of the License at:
|
||||
;*
|
||||
;* http://www.st.com/software_license_agreement_liberty_v2
|
||||
;*
|
||||
;* Unless required by applicable law or agreed to in writing, software
|
||||
;* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
;* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
;* See the License for the specific language governing permissions and
|
||||
;* limitations under the License.
|
||||
;*
|
||||
;*******************************************************************************
|
||||
;
|
||||
;
|
||||
; The modules in this file are included in the libraries, and may be replaced
|
||||
; by any user-defined modules that define the PUBLIC symbol _program_start or
|
||||
; a user defined start symbol.
|
||||
; To override the cstartup defined in the library, simply add your modified
|
||||
; version to the workbench project.
|
||||
;
|
||||
; The vector table is normally located at address 0.
|
||||
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
|
||||
; The name "__vector_table" has special meaning for C-SPY:
|
||||
; it is where the SP start value is found, and the NVIC vector
|
||||
; table register (VTOR) is initialized to this address if != 0.
|
||||
;
|
||||
; Cortex-M version
|
||||
;
|
||||
#define APP_MODE // #define DFU_MODE //
|
||||
|
||||
MODULE ?cstartup
|
||||
|
||||
;; Forward declaration of sections.
|
||||
SECTION CSTACK:DATA:NOROOT(3)
|
||||
|
||||
SECTION .intvec:CODE:NOROOT(2)
|
||||
|
||||
EXTERN __iar_program_start
|
||||
EXTERN SystemInit
|
||||
PUBLIC __vector_table
|
||||
|
||||
DATA
|
||||
|
||||
__vector_table
|
||||
DCD sfe(CSTACK)
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
|
||||
DCD 0 ; Reserved
|
||||
DCD 0;//__Dev_SN ; 0x08000020
|
||||
DCD 0;//__Ident ; 0x08000024
|
||||
DCD 0;//__Chk_SYS ; 0x08000028
|
||||
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0;//__Info ; 0x08000034
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window Watchdog
|
||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
||||
DCD TAMPER_IRQHandler ; Tamper
|
||||
DCD RTC_IRQHandler ; RTC
|
||||
DCD FLASH_IRQHandler ; Flash
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
||||
DCD ADC1_2_IRQHandler ; ADC1 & ADC2
|
||||
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
|
||||
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
|
||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
||||
DCD TIM1_BRK_IRQHandler ; TIM1 Break
|
||||
DCD TIM1_UP_IRQHandler ; TIM1 Update
|
||||
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
|
||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
||||
DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line
|
||||
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
|
||||
DCD TIM8_BRK_IRQHandler ; TIM8 Break
|
||||
DCD TIM8_UP_IRQHandler ; TIM8 Update
|
||||
DCD TIM8_TRG_COM_IRQHandler ; TIM8 Trigger and Commutation
|
||||
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
|
||||
#ifdef APP_MODE
|
||||
DCD ADC3_IRQHandler ; ADC3
|
||||
DCD FSMC_IRQHandler ; FSMC
|
||||
DCD SDIO_IRQHandler ; SDIO
|
||||
DCD TIM5_IRQHandler ; TIM5
|
||||
DCD SPI3_IRQHandler ; SPI3
|
||||
DCD UART4_IRQHandler ; UART4
|
||||
DCD UART5_IRQHandler ; UART5
|
||||
DCD TIM6_IRQHandler ; TIM6
|
||||
DCD TIM7_IRQHandler ; TIM7
|
||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1
|
||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2
|
||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3
|
||||
DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5
|
||||
#endif
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
/*
|
||||
#ifdef DFU_MODE
|
||||
EXPORT LIC_REC
|
||||
LIC_REC DCD 0xFFFFFFFF
|
||||
|
||||
THUMB
|
||||
|
||||
#ifdef DFU_MODE
|
||||
; 0x08000100 <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> DFU <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||
;------------------------------
|
||||
IMPORT Dev_SN
|
||||
EXPORT __Dev_SN
|
||||
__Dev_SN
|
||||
B.W Dev_SN
|
||||
;------------------------------
|
||||
IMPORT Ident
|
||||
EXPORT __Ident
|
||||
__Ident
|
||||
B.W Ident
|
||||
;------------------------------
|
||||
IMPORT Lic_ok
|
||||
EXPORT __Chk_SYS
|
||||
__Chk_SYS
|
||||
B.W Lic_ok
|
||||
;------------------------------
|
||||
IMPORT Lic_Gen
|
||||
EXPORT __Lic_Gen
|
||||
__Lic_Gen
|
||||
B.W Lic_Gen
|
||||
;------------------------------
|
||||
IMPORT LCD_Init
|
||||
EXPORT __LCD_Init
|
||||
__LCD_Init
|
||||
B.W LCD_Init
|
||||
;------------------------------
|
||||
IMPORT Direction
|
||||
EXPORT __Direction
|
||||
__Direction
|
||||
B.W Direction
|
||||
;------------------------------
|
||||
IMPORT SetBlock
|
||||
EXPORT __SetBlock
|
||||
__SetBlock
|
||||
B.W SetBlock
|
||||
;------------------------------
|
||||
IMPORT SetPosi
|
||||
EXPORT __SetPosi
|
||||
__SetPosi
|
||||
B.W SetPosi
|
||||
;------------------------------
|
||||
IMPORT SetPixel
|
||||
EXPORT __SetPixel
|
||||
__SetPixel
|
||||
B.W SetPixel
|
||||
;------------------------------
|
||||
IMPORT SendPixels
|
||||
EXPORT __SendPixels
|
||||
__SendPixels
|
||||
B.W SendPixels
|
||||
;------------------------------
|
||||
IMPORT ReadPixel
|
||||
EXPORT __ReadPixel
|
||||
__ReadPixel
|
||||
B.W ReadPixel
|
||||
;------------------------------
|
||||
IMPORT Get_TAB_8x14
|
||||
EXPORT __Font_8x14
|
||||
__Font_8x14
|
||||
B.W Get_TAB_8x14
|
||||
;------------------------------
|
||||
IMPORT DispLogo
|
||||
EXPORT __DispLogo
|
||||
__DispLogo
|
||||
B.W DispLogo
|
||||
;------------------------------
|
||||
IMPORT DispStr
|
||||
EXPORT __DispStr
|
||||
__DispStr
|
||||
B.W DispStr
|
||||
;------------------------------
|
||||
IMPORT Info
|
||||
EXPORT __Info
|
||||
__Info
|
||||
B.W Info
|
||||
;------------------------------
|
||||
IMPORT Ctrl
|
||||
EXPORT __Ctrl
|
||||
__Ctrl
|
||||
B.W Ctrl
|
||||
;------------------------------
|
||||
IMPORT FLASH_Prog
|
||||
EXPORT __FLASH_Prog
|
||||
__FLASH_Prog
|
||||
B.W FLASH_Prog
|
||||
;------------------------------
|
||||
IMPORT FLASH_Erase
|
||||
EXPORT __FLASH_Erase
|
||||
__FLASH_Erase
|
||||
B.W FLASH_Erase
|
||||
;------------------------------
|
||||
IMPORT ExtFlashSecWr
|
||||
EXPORT __ExtFlashSecWr
|
||||
__ExtFlashSecWr
|
||||
B.W ExtFlashSecWr
|
||||
;------------------------------
|
||||
IMPORT ExtFlashDataRd
|
||||
EXPORT __ExtFlashDataRd
|
||||
__ExtFlashDataRd
|
||||
B.W ExtFlashDataRd
|
||||
;------------------------------
|
||||
IMPORT I2C_Write
|
||||
EXPORT __I2C_Write
|
||||
__I2C_Write
|
||||
; B.W I2C_Write
|
||||
;------------------------------
|
||||
IMPORT I2C_Read
|
||||
EXPORT __I2C_Read
|
||||
__I2C_Read
|
||||
; B.W I2C_Read
|
||||
;------------------------------
|
||||
NOP.W
|
||||
|
||||
EXPORT LCD_WR_Ctrl
|
||||
LCD_WR_Ctrl
|
||||
MOVW R1, #0x1400
|
||||
MOVT R1, #0x4001
|
||||
MOV R2, #0x1000
|
||||
STR R2, [R1, #0x14]
|
||||
MOVS R3, #0x60000000
|
||||
STRH R0, [R3]
|
||||
STR R2, [R1, #0x10]
|
||||
BX LR
|
||||
|
||||
#endif
|
||||
*/
|
||||
;;
|
||||
;; Default interrupt handlers.
|
||||
;;
|
||||
PUBWEAK Reset_Handler
|
||||
SECTION .text:CODE:REORDER(2)
|
||||
Reset_Handler
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__iar_program_start
|
||||
BX R0
|
||||
|
||||
PUBWEAK NMI_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
NMI_Handler
|
||||
B NMI_Handler
|
||||
|
||||
PUBWEAK HardFault_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
HardFault_Handler
|
||||
B HardFault_Handler
|
||||
|
||||
PUBWEAK MemManage_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
MemManage_Handler
|
||||
B MemManage_Handler
|
||||
|
||||
PUBWEAK BusFault_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
BusFault_Handler
|
||||
B BusFault_Handler
|
||||
|
||||
PUBWEAK UsageFault_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
UsageFault_Handler
|
||||
B UsageFault_Handler
|
||||
|
||||
PUBWEAK SVC_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
SVC_Handler
|
||||
B SVC_Handler
|
||||
|
||||
PUBWEAK DebugMon_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DebugMon_Handler
|
||||
B DebugMon_Handler
|
||||
|
||||
PUBWEAK PendSV_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
PendSV_Handler
|
||||
B PendSV_Handler
|
||||
|
||||
PUBWEAK SysTick_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
SysTick_Handler
|
||||
B SysTick_Handler
|
||||
|
||||
PUBWEAK WWDG_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
WWDG_IRQHandler
|
||||
B WWDG_IRQHandler
|
||||
|
||||
PUBWEAK PVD_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
PVD_IRQHandler
|
||||
B PVD_IRQHandler
|
||||
|
||||
PUBWEAK TAMPER_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TAMPER_IRQHandler
|
||||
B TAMPER_IRQHandler
|
||||
|
||||
PUBWEAK RTC_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
RTC_IRQHandler
|
||||
B RTC_IRQHandler
|
||||
|
||||
PUBWEAK FLASH_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
FLASH_IRQHandler
|
||||
B FLASH_IRQHandler
|
||||
|
||||
PUBWEAK RCC_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
RCC_IRQHandler
|
||||
B RCC_IRQHandler
|
||||
|
||||
PUBWEAK EXTI0_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
EXTI0_IRQHandler
|
||||
B EXTI0_IRQHandler
|
||||
|
||||
PUBWEAK EXTI1_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
EXTI1_IRQHandler
|
||||
B EXTI1_IRQHandler
|
||||
|
||||
PUBWEAK EXTI2_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
EXTI2_IRQHandler
|
||||
B EXTI2_IRQHandler
|
||||
|
||||
PUBWEAK EXTI3_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
EXTI3_IRQHandler
|
||||
B EXTI3_IRQHandler
|
||||
|
||||
PUBWEAK EXTI4_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
EXTI4_IRQHandler
|
||||
B EXTI4_IRQHandler
|
||||
|
||||
PUBWEAK DMA1_Channel1_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DMA1_Channel1_IRQHandler
|
||||
B DMA1_Channel1_IRQHandler
|
||||
|
||||
PUBWEAK DMA1_Channel2_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DMA1_Channel2_IRQHandler
|
||||
B DMA1_Channel2_IRQHandler
|
||||
|
||||
PUBWEAK DMA1_Channel3_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DMA1_Channel3_IRQHandler
|
||||
B DMA1_Channel3_IRQHandler
|
||||
|
||||
PUBWEAK DMA1_Channel4_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DMA1_Channel4_IRQHandler
|
||||
B DMA1_Channel4_IRQHandler
|
||||
|
||||
PUBWEAK DMA1_Channel5_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DMA1_Channel5_IRQHandler
|
||||
B DMA1_Channel5_IRQHandler
|
||||
|
||||
PUBWEAK DMA1_Channel6_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DMA1_Channel6_IRQHandler
|
||||
B DMA1_Channel6_IRQHandler
|
||||
|
||||
PUBWEAK DMA1_Channel7_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DMA1_Channel7_IRQHandler
|
||||
B DMA1_Channel7_IRQHandler
|
||||
|
||||
PUBWEAK ADC1_2_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
ADC1_2_IRQHandler
|
||||
B ADC1_2_IRQHandler
|
||||
|
||||
PUBWEAK USB_HP_CAN1_TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
USB_HP_CAN1_TX_IRQHandler
|
||||
B USB_HP_CAN1_TX_IRQHandler
|
||||
|
||||
PUBWEAK USB_LP_CAN1_RX0_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
USB_LP_CAN1_RX0_IRQHandler
|
||||
B USB_LP_CAN1_RX0_IRQHandler
|
||||
|
||||
PUBWEAK CAN1_RX1_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
CAN1_RX1_IRQHandler
|
||||
B CAN1_RX1_IRQHandler
|
||||
|
||||
PUBWEAK CAN1_SCE_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
CAN1_SCE_IRQHandler
|
||||
B CAN1_SCE_IRQHandler
|
||||
|
||||
PUBWEAK EXTI9_5_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
EXTI9_5_IRQHandler
|
||||
B EXTI9_5_IRQHandler
|
||||
|
||||
PUBWEAK TIM1_BRK_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM1_BRK_IRQHandler
|
||||
B TIM1_BRK_IRQHandler
|
||||
|
||||
PUBWEAK TIM1_UP_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM1_UP_IRQHandler
|
||||
B TIM1_UP_IRQHandler
|
||||
|
||||
PUBWEAK TIM1_TRG_COM_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM1_TRG_COM_IRQHandler
|
||||
B TIM1_TRG_COM_IRQHandler
|
||||
|
||||
PUBWEAK TIM1_CC_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM1_CC_IRQHandler
|
||||
B TIM1_CC_IRQHandler
|
||||
|
||||
PUBWEAK TIM2_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM2_IRQHandler
|
||||
B TIM2_IRQHandler
|
||||
|
||||
PUBWEAK TIM3_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM3_IRQHandler
|
||||
B TIM3_IRQHandler
|
||||
|
||||
PUBWEAK TIM4_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM4_IRQHandler
|
||||
B TIM4_IRQHandler
|
||||
|
||||
PUBWEAK I2C1_EV_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
I2C1_EV_IRQHandler
|
||||
B I2C1_EV_IRQHandler
|
||||
|
||||
PUBWEAK I2C1_ER_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
I2C1_ER_IRQHandler
|
||||
B I2C1_ER_IRQHandler
|
||||
|
||||
PUBWEAK I2C2_EV_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
I2C2_EV_IRQHandler
|
||||
B I2C2_EV_IRQHandler
|
||||
|
||||
PUBWEAK I2C2_ER_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
I2C2_ER_IRQHandler
|
||||
B I2C2_ER_IRQHandler
|
||||
|
||||
PUBWEAK SPI1_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
SPI1_IRQHandler
|
||||
B SPI1_IRQHandler
|
||||
|
||||
PUBWEAK SPI2_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
SPI2_IRQHandler
|
||||
B SPI2_IRQHandler
|
||||
|
||||
PUBWEAK USART1_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
USART1_IRQHandler
|
||||
B USART1_IRQHandler
|
||||
|
||||
PUBWEAK USART2_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
USART2_IRQHandler
|
||||
B USART2_IRQHandler
|
||||
|
||||
PUBWEAK USART3_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
USART3_IRQHandler
|
||||
B USART3_IRQHandler
|
||||
|
||||
PUBWEAK EXTI15_10_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
EXTI15_10_IRQHandler
|
||||
B EXTI15_10_IRQHandler
|
||||
|
||||
PUBWEAK RTCAlarm_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
RTCAlarm_IRQHandler
|
||||
B RTCAlarm_IRQHandler
|
||||
|
||||
PUBWEAK USBWakeUp_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
USBWakeUp_IRQHandler
|
||||
B USBWakeUp_IRQHandler
|
||||
|
||||
PUBWEAK TIM8_BRK_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM8_BRK_IRQHandler
|
||||
B TIM8_BRK_IRQHandler
|
||||
|
||||
PUBWEAK TIM8_UP_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM8_UP_IRQHandler
|
||||
B TIM8_UP_IRQHandler
|
||||
|
||||
PUBWEAK TIM8_TRG_COM_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM8_TRG_COM_IRQHandler
|
||||
B TIM8_TRG_COM_IRQHandler
|
||||
|
||||
PUBWEAK TIM8_CC_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM8_CC_IRQHandler
|
||||
B TIM8_CC_IRQHandler
|
||||
|
||||
PUBWEAK ADC3_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
ADC3_IRQHandler
|
||||
B ADC3_IRQHandler
|
||||
|
||||
PUBWEAK FSMC_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
FSMC_IRQHandler
|
||||
B FSMC_IRQHandler
|
||||
|
||||
PUBWEAK SDIO_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
SDIO_IRQHandler
|
||||
B SDIO_IRQHandler
|
||||
|
||||
PUBWEAK TIM5_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM5_IRQHandler
|
||||
B TIM5_IRQHandler
|
||||
|
||||
PUBWEAK SPI3_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
SPI3_IRQHandler
|
||||
B SPI3_IRQHandler
|
||||
|
||||
PUBWEAK UART4_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
UART4_IRQHandler
|
||||
B UART4_IRQHandler
|
||||
|
||||
PUBWEAK UART5_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
UART5_IRQHandler
|
||||
B UART5_IRQHandler
|
||||
|
||||
PUBWEAK TIM6_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM6_IRQHandler
|
||||
B TIM6_IRQHandler
|
||||
|
||||
PUBWEAK TIM7_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
TIM7_IRQHandler
|
||||
B TIM7_IRQHandler
|
||||
|
||||
PUBWEAK DMA2_Channel1_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DMA2_Channel1_IRQHandler
|
||||
B DMA2_Channel1_IRQHandler
|
||||
|
||||
PUBWEAK DMA2_Channel2_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DMA2_Channel2_IRQHandler
|
||||
B DMA2_Channel2_IRQHandler
|
||||
|
||||
PUBWEAK DMA2_Channel3_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DMA2_Channel3_IRQHandler
|
||||
B DMA2_Channel3_IRQHandler
|
||||
|
||||
PUBWEAK DMA2_Channel4_5_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DMA2_Channel4_5_IRQHandler
|
||||
B DMA2_Channel4_5_IRQHandler
|
||||
|
||||
|
||||
END
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
157
S100App/Src/STM32F103_System.c
Normal file
157
S100App/Src/STM32F103_System.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file system_stm32f10x.c
|
||||
* @author MCD Application Team
|
||||
* @version V3.6.1
|
||||
* @date 09-March-2012
|
||||
* @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File.
|
||||
*
|
||||
* 1. This file provides two functions and one global variable to be called from
|
||||
* user application:
|
||||
* - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
|
||||
* factors, AHB/APBx prescalers and Flash settings).
|
||||
* This function is called at startup just after reset and
|
||||
* before branch to main program. This call is made inside
|
||||
* the "startup_stm32f10x_xx.s" file.
|
||||
*
|
||||
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
|
||||
* by the user application to setup the SysTick
|
||||
* timer or configure other parameters.
|
||||
*
|
||||
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
|
||||
* be called whenever the core clock is changed
|
||||
* during program execution.
|
||||
*
|
||||
* 2. After each device reset the HSI (8 MHz) is used as system clock source.
|
||||
* Then SystemInit() function is called, in "startup_stm32f10x_xx.s" file, to
|
||||
* configure the system clock before to branch to main program.
|
||||
*
|
||||
* 3. If the system clock source selected by user fails to startup, the SystemInit()
|
||||
* function will do nothing and HSI still used as system clock source. User can
|
||||
* add some code to deal with this issue inside the SetSysClock() function.
|
||||
*
|
||||
* 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depedning on
|
||||
* the product used), refer to "HSE_VALUE" define in "stm32f10x.h" file.
|
||||
* When HSE is used as system clock source, directly or through PLL, and you
|
||||
* are using different crystal you have to adapt the HSE value to your own
|
||||
* configuration.
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
|
||||
#define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field.
|
||||
This value must be a multiple of 0x200. */
|
||||
|
||||
static void SetSysClockTo72MHz(void);
|
||||
|
||||
/*******************************************************************************
|
||||
* Clock Definitions
|
||||
*******************************************************************************/
|
||||
u32 SystemCoreClock = 72000000; // 72MHz System Clock Frequency
|
||||
u8 AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
void SystemInit (void)
|
||||
{
|
||||
RCC->CR |= 0x00000001;// Set HSION bit
|
||||
RCC->CFGR &= 0xF8FF0000;// Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits
|
||||
RCC->CR &= 0xFEF6FFFF;// Reset HSEON, CSSON and PLLON bits
|
||||
RCC->CR &= 0xFFFBFFFF;// Reset HSEBYP bit
|
||||
RCC->CFGR &= 0xFF80FFFF;// Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits
|
||||
RCC->CIR = 0x009F0000;// Disable all interrupts and clear pending bits
|
||||
|
||||
/* Configure the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers */
|
||||
/* Configure the Flash Latency cycles and enable prefetch buffer */
|
||||
SetSysClockTo72MHz();
|
||||
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
|
||||
}
|
||||
|
||||
void SystemCoreClockUpdate (void)
|
||||
{
|
||||
u32 tmp = 0, pllmull = 0, pllsource = 0;
|
||||
|
||||
/* Get SYSCLK source -------------------------------------------------------*/
|
||||
tmp = RCC->CFGR & RCC_CFGR_SWS;
|
||||
switch(tmp){
|
||||
case 0x00: // HSI used as system clock
|
||||
SystemCoreClock = 8000000; // HSI_VALUE;
|
||||
break;
|
||||
case 0x04: // HSE used as system clock
|
||||
SystemCoreClock = 8000000; // HSE_VALUE;
|
||||
break;
|
||||
case 0x08: // PLL used as system clock
|
||||
// Get PLL clock source and multiplication factor
|
||||
pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
|
||||
pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
|
||||
pllmull = ( pllmull >> 18) + 2;
|
||||
// HSI oscillator clock divided by 2 selected as PLL clock entry
|
||||
if (pllsource == 0x00) SystemCoreClock = (HSI_VALUE >> 1) * pllmull;
|
||||
break;
|
||||
default:
|
||||
SystemCoreClock = HSI_VALUE;
|
||||
break;
|
||||
}
|
||||
|
||||
// Compute HCLK clock frequency
|
||||
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];// Get HCLK prescaler
|
||||
SystemCoreClock >>= tmp; // HCLK clock frequency
|
||||
}
|
||||
|
||||
static void SetSysClockTo72MHz(void)
|
||||
{
|
||||
u32 StartUpCounter = 0, HSEStatus = 0;
|
||||
|
||||
// SYSCLK, HCLK, PCLK2 and PCLK1 configuration
|
||||
RCC->CR |= ((u32)RCC_CR_HSEON);/* Enable HSE */
|
||||
do { // Wait till HSE is ready and if Time out is reached exit
|
||||
HSEStatus = RCC->CR & RCC_CR_HSERDY;
|
||||
StartUpCounter++;
|
||||
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
|
||||
|
||||
if ((RCC->CR & RCC_CR_HSERDY) != RESET) HSEStatus = 0x01;
|
||||
else HSEStatus = 0x00;
|
||||
|
||||
if (HSEStatus == 0x01){
|
||||
FLASH->ACR |= FLASH_ACR_PRFTBE;/* Enable Prefetch Buffer */
|
||||
/* Flash 2 wait state */
|
||||
FLASH->ACR &= (u32)((u32)~FLASH_ACR_LATENCY);
|
||||
FLASH->ACR |= (u32)FLASH_ACR_LATENCY_2;
|
||||
RCC->CFGR |= RCC_CFGR_HPRE_DIV1;/* HCLK = SYSCLK */
|
||||
RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;/* PCLK2 = HCLK */
|
||||
RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;/* PCLK1 = HCLK */
|
||||
/* PLL configuration: PLLCLK = HSE * 9 = 72 MHz */
|
||||
RCC->CFGR &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL);
|
||||
RCC->CFGR |= (u32)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL9);
|
||||
RCC->CR |= RCC_CR_PLLON;/* Enable PLL */
|
||||
while((RCC->CR & RCC_CR_PLLRDY) == 0){}/* Wait till PLL is ready */
|
||||
/* Select PLL as system clock source */
|
||||
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
|
||||
RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
|
||||
|
||||
|
||||
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08)
|
||||
{}/* Wait till PLL is used as system clock source */
|
||||
}
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
1110
S100App/Src/UI.c
Normal file
1110
S100App/Src/UI.c
Normal file
File diff suppressed because it is too large
Load Diff
269
S100App/Src/USB_bot.c
Normal file
269
S100App/Src/USB_bot.c
Normal file
@@ -0,0 +1,269 @@
|
||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
||||
File Name : USB_bot.c
|
||||
Version : STM32_USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#include "USB_scsi.h"
|
||||
#include "USB_regs.h"
|
||||
#include "USB_mem.h"
|
||||
#include "USB_conf.h"
|
||||
#include "USB_bot.h"
|
||||
#include "USB_prop.h"
|
||||
|
||||
u8 Bot_State;
|
||||
u8 Bulk_Buff[BULK_MAX_PACKET_SIZE]; // Data_ data buffer
|
||||
u16 Data_Len;
|
||||
Bulk_Only_CBW CBW;
|
||||
Bulk_Only_CSW CSW;
|
||||
u32 SCSI_LBA , SCSI_BlkLen;
|
||||
|
||||
/*******************************************************************************
|
||||
Mass_Storage_In: Mass Storage IN transfer.
|
||||
*******************************************************************************/
|
||||
void Mass_Storage_In (void)
|
||||
{
|
||||
switch (Bot_State)
|
||||
{
|
||||
case BOT_CSW_Send:
|
||||
case BOT_ERROR:
|
||||
Bot_State = BOT_IDLE;
|
||||
SetEPRxStatus(ENDP2, EP_RX_VALID);/* enable the Endpoint to recive the next cmd*/
|
||||
break;
|
||||
case BOT_DATA_IN:
|
||||
switch (CBW.CB[0])
|
||||
{
|
||||
case SCSI_READ10:
|
||||
SCSI_Read10_Cmd(SCSI_LBA , SCSI_BlkLen);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BOT_DATA_IN_LAST:
|
||||
Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
||||
SetEPRxStatus(ENDP2, EP_RX_VALID);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
Mass_Storage_Out: Mass Storage OUT transfer.
|
||||
*******************************************************************************/
|
||||
void Mass_Storage_Out (void)
|
||||
{
|
||||
u8 CMD;
|
||||
CMD = CBW.CB[0];
|
||||
Data_Len = GetEPRxCount(ENDP2);
|
||||
|
||||
PMAToUserBufferCopy(Bulk_Buff, ENDP2_RXADDR, Data_Len);
|
||||
|
||||
switch (Bot_State)
|
||||
{
|
||||
case BOT_IDLE:
|
||||
CBW_Decode();
|
||||
break;
|
||||
case BOT_DATA_OUT:
|
||||
if (CMD == SCSI_WRITE10)
|
||||
{
|
||||
SCSI_Write10_Cmd(SCSI_LBA , SCSI_BlkLen);
|
||||
break;
|
||||
}
|
||||
Bot_Abort(DIR_OUT);
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
||||
Set_CSW (CSW_PHASE_ERROR, SEND_CSW_DISABLE);
|
||||
break;
|
||||
default:
|
||||
Bot_Abort(BOTH_DIR);
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
||||
Set_CSW (CSW_PHASE_ERROR, SEND_CSW_DISABLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
CBW_Decode: Decode the received CBW and call the related SCSI command
|
||||
*******************************************************************************/
|
||||
void CBW_Decode(void)
|
||||
{
|
||||
u32 Counter;
|
||||
|
||||
for (Counter = 0; Counter < Data_Len; Counter++)
|
||||
{
|
||||
*((u8 *)&CBW + Counter) = Bulk_Buff[Counter];
|
||||
}
|
||||
CSW.dTag = CBW.dTag;
|
||||
CSW.dDataResidue = CBW.dDataLength;
|
||||
if (Data_Len != BOT_CBW_PACKET_LENGTH)
|
||||
{
|
||||
Bot_Abort(BOTH_DIR);
|
||||
// reset the CBW.dSignature to desible the clear feature until receiving a Mass storage reset
|
||||
CBW.dSignature = 0;
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, PARAMETER_LIST_LENGTH_ERROR);
|
||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((CBW.CB[0] == SCSI_READ10 ) || (CBW.CB[0] == SCSI_WRITE10 ))
|
||||
{
|
||||
// Calculate Logical Block Address
|
||||
SCSI_LBA = (CBW.CB[2] << 24) | (CBW.CB[3] << 16) | (CBW.CB[4] << 8) | CBW.CB[5];
|
||||
// Calculate the Number of Blocks to transfer
|
||||
SCSI_BlkLen = (CBW.CB[7] << 8) | CBW.CB[8];
|
||||
}
|
||||
|
||||
if (CBW.dSignature == BOT_CBW_SIGNATURE)
|
||||
{
|
||||
// Valid CBW
|
||||
if ((CBW.bLUN > Max_Lun) || (CBW.bCBLength < 1) || (CBW.bCBLength > 16))
|
||||
{
|
||||
Bot_Abort(BOTH_DIR);
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (CBW.CB[0])
|
||||
{
|
||||
case SCSI_REQUEST_SENSE:
|
||||
SCSI_RequestSense_Cmd ();
|
||||
break;
|
||||
case SCSI_INQUIRY:
|
||||
SCSI_Inquiry_Cmd();
|
||||
break;
|
||||
case SCSI_START_STOP_UNIT:
|
||||
SCSI_Start_Stop_Unit_Cmd();
|
||||
break;
|
||||
case SCSI_ALLOW_MEDIUM_REMOVAL:
|
||||
SCSI_Start_Stop_Unit_Cmd();
|
||||
break;
|
||||
case SCSI_MODE_SENSE6:
|
||||
SCSI_ModeSense6_Cmd ();
|
||||
break;
|
||||
case SCSI_MODE_SENSE10:
|
||||
SCSI_ModeSense10_Cmd ();
|
||||
break;
|
||||
case SCSI_READ_FORMAT_CAPACITIES:
|
||||
SCSI_ReadFormatCapacity_Cmd();
|
||||
break;
|
||||
case SCSI_READ_CAPACITY10:
|
||||
SCSI_ReadCapacity10_Cmd();
|
||||
break;
|
||||
case SCSI_TEST_UNIT_READY:
|
||||
SCSI_TestUnitReady_Cmd();
|
||||
break;
|
||||
case SCSI_READ10:
|
||||
SCSI_Read10_Cmd(SCSI_LBA , SCSI_BlkLen);
|
||||
break;
|
||||
case SCSI_WRITE10:
|
||||
SCSI_Write10_Cmd(SCSI_LBA , SCSI_BlkLen);
|
||||
break;
|
||||
case SCSI_VERIFY10:
|
||||
SCSI_Verify10_Cmd();
|
||||
break;
|
||||
//Unsupported command
|
||||
case SCSI_MODE_SELECT10:
|
||||
SCSI_Mode_Select10_Cmd();
|
||||
break;
|
||||
case SCSI_MODE_SELECT6:
|
||||
SCSI_Mode_Select6_Cmd();
|
||||
break;
|
||||
|
||||
case SCSI_SEND_DIAGNOSTIC:
|
||||
SCSI_Send_Diagnostic_Cmd();
|
||||
break;
|
||||
case SCSI_READ6:
|
||||
SCSI_Read6_Cmd();
|
||||
break;
|
||||
case SCSI_READ12:
|
||||
SCSI_Read12_Cmd();
|
||||
break;
|
||||
case SCSI_READ16:
|
||||
SCSI_Read16_Cmd();
|
||||
break;
|
||||
case SCSI_READ_CAPACITY16:
|
||||
SCSI_READ_CAPACITY16_Cmd();
|
||||
break;
|
||||
case SCSI_WRITE6:
|
||||
SCSI_Write6_Cmd();
|
||||
break;
|
||||
case SCSI_WRITE12:
|
||||
SCSI_Write12_Cmd();
|
||||
break;
|
||||
case SCSI_WRITE16:
|
||||
SCSI_Write16_Cmd();
|
||||
break;
|
||||
case SCSI_VERIFY12:
|
||||
SCSI_Verify12_Cmd();
|
||||
break;
|
||||
case SCSI_VERIFY16:
|
||||
SCSI_Verify16_Cmd();
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
Bot_Abort(BOTH_DIR);
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_COMMAND);
|
||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid CBW
|
||||
Bot_Abort(BOTH_DIR);
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_COMMAND);
|
||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
Transfer_Data_Request: Send the request response to the PC HOST.
|
||||
Input : u8* Data_Address : point to the data to transfer.
|
||||
u16 Data_Length : the nember of Bytes to transfer.
|
||||
*******************************************************************************/
|
||||
void Transfer_Data_Request(u8* Data_Pointer, u16 Data_Len)
|
||||
{
|
||||
UserToPMABufferCopy(Data_Pointer, ENDP1_TXADDR, Data_Len);
|
||||
SetEPTxCount(ENDP1, Data_Len);
|
||||
SetEPTxStatus(ENDP1, EP_TX_VALID);
|
||||
Bot_State = BOT_DATA_IN_LAST;
|
||||
CSW.dDataResidue -= Data_Len;
|
||||
CSW.bStatus = CSW_CMD_PASSED;
|
||||
}
|
||||
/*******************************************************************************
|
||||
Set_CSW: Set the SCW with the needed fields.
|
||||
Input : u8 CSW_Status this filed can be CSW_CMD_PASSED,CSW_CMD_FAILED,
|
||||
or CSW_PHASE_ERROR.
|
||||
*******************************************************************************/
|
||||
void Set_CSW (u8 CSW_Status, u8 Send_Permission)
|
||||
{
|
||||
CSW.dSignature = BOT_CSW_SIGNATURE;
|
||||
CSW.bStatus = CSW_Status;
|
||||
UserToPMABufferCopy(((u8 *)& CSW), ENDP1_TXADDR, CSW_DATA_LENGTH);
|
||||
SetEPTxCount(ENDP1, CSW_DATA_LENGTH);
|
||||
Bot_State = BOT_ERROR;
|
||||
if (Send_Permission){
|
||||
Bot_State = BOT_CSW_Send;
|
||||
SetEPTxStatus(ENDP1, EP_TX_VALID);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
Bot_Abort: Stall the needed Endpoint according to the selected direction.
|
||||
Input : Endpoint direction IN, OUT or both directions
|
||||
*******************************************************************************/
|
||||
void Bot_Abort(u8 Direction)
|
||||
{
|
||||
switch (Direction){
|
||||
case DIR_IN :
|
||||
SetEPTxStatus(ENDP1, EP_TX_STALL);
|
||||
break;
|
||||
case DIR_OUT :
|
||||
SetEPRxStatus(ENDP2, EP_RX_STALL);
|
||||
break;
|
||||
case BOTH_DIR :
|
||||
SetEPTxStatus(ENDP1, EP_TX_STALL);
|
||||
SetEPRxStatus(ENDP2, EP_RX_STALL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/********************************* END OF FILE ******************************/
|
||||
109
S100App/Src/USB_desc.c
Normal file
109
S100App/Src/USB_desc.c
Normal file
@@ -0,0 +1,109 @@
|
||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
||||
File Name : USB_desc.c
|
||||
Version : STM32_USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#include "USB_desc.h"
|
||||
|
||||
const u8 MASS_DeviceDescriptor[MASS_SIZ_DEVICE_DESC] ={
|
||||
0x12, /* bLength */
|
||||
0x01, /* bDescriptorType */
|
||||
0x00, /* bcdUSB, version 2.00 */
|
||||
0x02,
|
||||
0x00, /* bDeviceClass : each interface define the device class */
|
||||
0x00, /* bDeviceSubClass */
|
||||
0x00, /* bDeviceProtocol */
|
||||
0x40, /* bMaxPacketSize0 0x40 = 64 */
|
||||
0x83, /* idVendor (0483) */
|
||||
0x04,
|
||||
0x20, /* idProduct */
|
||||
0x57,
|
||||
0x00, /* bcdDevice 2.00*/
|
||||
0x02,
|
||||
1, /* index of string Manufacturer */
|
||||
/**/
|
||||
2, /* index of string descriptor of product*/
|
||||
/* */
|
||||
3, /* */
|
||||
/* */
|
||||
/* */
|
||||
0x01 /*bNumConfigurations */
|
||||
};
|
||||
const u8 MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC] ={
|
||||
0x09, /* bLength: Configuation Descriptor size */
|
||||
0x02, /* bDescriptorType: Configuration */
|
||||
MASS_SIZ_CONFIG_DESC,
|
||||
0x00,
|
||||
0x01, /* bNumInterfaces: 1 interface */
|
||||
0x01, /* bConfigurationValue: */
|
||||
/* Configuration value */
|
||||
0x00, /* iConfiguration: */
|
||||
/* Index of string descriptor */
|
||||
/* describing the configuration */
|
||||
0xC0, /* bmAttributes: */
|
||||
/* bus powered */
|
||||
0x32, /* MaxPower 100 mA */
|
||||
|
||||
/******************** Descriptor of Mass Storage interface ********************/
|
||||
/* 09 */
|
||||
0x09, /* bLength: Interface Descriptor size */
|
||||
0x04, /* bDescriptorType: */
|
||||
/* Interface descriptor type */
|
||||
0x00, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x02, /* bNumEndpoints*/
|
||||
0x08, /* bInterfaceClass: MASS STORAGE Class */
|
||||
0x06, /* bInterfaceSubClass : SCSI transparent*/
|
||||
0x50, /* nInterfaceProtocol */
|
||||
4, /* iInterface: */
|
||||
/* 18 */
|
||||
0x07, /*Endpoint descriptor length = 7*/
|
||||
0x05, /*Endpoint descriptor type */
|
||||
0x81, /*Endpoint address (IN, address 1) */
|
||||
0x02, /*Bulk endpoint type */
|
||||
0x40, /*Maximum packet size (64 bytes) */
|
||||
0x00,
|
||||
0x00, /*Polling interval in milliseconds */
|
||||
/* 25 */
|
||||
0x07, /*Endpoint descriptor length = 7 */
|
||||
0x05, /*Endpoint descriptor type */
|
||||
0x02, /*Endpoint address (OUT, address 2) */
|
||||
0x02, /*Bulk endpoint type */
|
||||
0x40, /*Maximum packet size (64 bytes) */
|
||||
0x00,
|
||||
0x00 /*Polling interval in milliseconds*/
|
||||
/*32*/
|
||||
};
|
||||
const u8 MASS_StringLangID[MASS_SIZ_STRING_LANGID] ={
|
||||
MASS_SIZ_STRING_LANGID,
|
||||
0x03,
|
||||
0x09,
|
||||
0x04
|
||||
}; // LangID = 0x0409: U.S. English //
|
||||
const u8 MASS_StringVendor[MASS_SIZ_STRING_VENDOR] ={
|
||||
MASS_SIZ_STRING_VENDOR, // Size of manufaturer string //
|
||||
0x03, // bDescriptorType = String descriptor //
|
||||
// Manufacturer: "STMicroelectronics" //
|
||||
'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0,
|
||||
'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0,
|
||||
'c', 0, 's', 0
|
||||
};
|
||||
const u8 MASS_StringProduct[MASS_SIZ_STRING_PRODUCT] ={
|
||||
MASS_SIZ_STRING_PRODUCT,
|
||||
0x03,
|
||||
// Product name: "STM32F10x:USB Mass Storage" //
|
||||
'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'M', 0, 'a', 0, 's', 0,
|
||||
's', 0, ' ', 0, 'S', 0, 't', 0, 'o', 0, 'r', 0, 'a', 0, 'g', 0, 'e', 0
|
||||
};
|
||||
u8 MASS_StringSerial[MASS_SIZ_STRING_SERIAL] ={
|
||||
MASS_SIZ_STRING_SERIAL,
|
||||
0x03,
|
||||
// Serial number//
|
||||
'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, '1', 0, '0', 0
|
||||
};
|
||||
const u8 MASS_StringInterface[MASS_SIZ_STRING_INTERFACE] ={
|
||||
MASS_SIZ_STRING_INTERFACE,
|
||||
0x03,
|
||||
// Interface 0: "ST Mass" //
|
||||
'S', 0, 'T', 0, ' ', 0, 'M', 0, 'a', 0, 's', 0, 's', 0
|
||||
};
|
||||
/********************************* END OF FILE ******************************/
|
||||
138
S100App/Src/USB_istr.c
Normal file
138
S100App/Src/USB_istr.c
Normal file
@@ -0,0 +1,138 @@
|
||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
||||
File Name : USB_istr.c
|
||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#include "USB_type.h"
|
||||
#include "USB_regs.h"
|
||||
#include "USB_pwr.h"
|
||||
#include "USB_istr.h"
|
||||
#include "USB_init.h"
|
||||
#include "USB_int.h"
|
||||
#include "USB_bot.h"
|
||||
|
||||
volatile u16 wIstr; /* ISTR register last read value */
|
||||
volatile u8 bIntPackSOF = 0; /* SOFs received between 2 consecutive packets */
|
||||
|
||||
void (*pEpInt_IN[7])(void) ={
|
||||
EP1_IN_Callback,
|
||||
EP2_IN_Callback,
|
||||
EP3_IN_Callback,
|
||||
EP4_IN_Callback,
|
||||
EP5_IN_Callback,
|
||||
EP6_IN_Callback,
|
||||
EP7_IN_Callback,
|
||||
};
|
||||
void (*pEpInt_OUT[7])(void) ={
|
||||
EP1_OUT_Callback,
|
||||
EP2_OUT_Callback,
|
||||
EP3_OUT_Callback,
|
||||
EP4_OUT_Callback,
|
||||
EP5_OUT_Callback,
|
||||
EP6_OUT_Callback,
|
||||
EP7_OUT_Callback,
|
||||
};
|
||||
/*******************************************************************************
|
||||
USB_Istr: ISTR events interrupt service routine
|
||||
*******************************************************************************/
|
||||
void USB_Istr(void)
|
||||
{
|
||||
wIstr = _GetISTR();
|
||||
#if (IMR_MSK & ISTR_RESET)
|
||||
if (wIstr & ISTR_RESET & wInterrupt_Mask){
|
||||
// _SetISTR((u16)CLR_RESET);
|
||||
Device_Property.Reset();
|
||||
_SetISTR((u16)CLR_RESET);
|
||||
//#ifdef RESET_CALLBACK
|
||||
// RESET_Callback();
|
||||
//#endif
|
||||
}
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
#if (IMR_MSK & ISTR_DOVR)
|
||||
if (wIstr & ISTR_DOVR & wInterrupt_Mask){
|
||||
_SetISTR((u16)CLR_DOVR);
|
||||
//#ifdef DOVR_CALLBACK
|
||||
// DOVR_Callback();
|
||||
//#endif
|
||||
}
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
#if (IMR_MSK & ISTR_ERR)
|
||||
if (wIstr & ISTR_ERR & wInterrupt_Mask){
|
||||
_SetISTR((u16)CLR_ERR);
|
||||
//#ifdef ERR_CALLBACK
|
||||
// ERR_Callback();
|
||||
//#endif
|
||||
}
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
#if (IMR_MSK & ISTR_WKUP)
|
||||
if (wIstr & ISTR_WKUP & wInterrupt_Mask){
|
||||
// _SetISTR((u16)CLR_WKUP);
|
||||
Resume(RESUME_EXTERNAL);
|
||||
_SetISTR((u16)CLR_WKUP);
|
||||
//#ifdef WKUP_CALLBACK
|
||||
// WKUP_Callback();
|
||||
//#endif
|
||||
}
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
#if (IMR_MSK & ISTR_SUSP)
|
||||
if (wIstr & ISTR_SUSP & wInterrupt_Mask){ // check if SUSPEND is possible
|
||||
if (fSuspendEnabled) Suspend();
|
||||
else Resume(RESUME_LATER); // if not possible then resume after xx ms
|
||||
_SetISTR((u16)CLR_SUSP); // clear of the ISTR bit must be done after setting of CNTR_FSUSP
|
||||
//#ifdef SUSP_CALLBACK
|
||||
// SUSP_Callback();
|
||||
//#endif
|
||||
}
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
#if (IMR_MSK & ISTR_SOF)
|
||||
if (wIstr & ISTR_SOF & wInterrupt_Mask){
|
||||
_SetISTR((u16)CLR_SOF);
|
||||
bIntPackSOF++;
|
||||
//#ifdef SOF_CALLBACK
|
||||
// SOF_Callback();
|
||||
//#endif
|
||||
}
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
#if (IMR_MSK & ISTR_ESOF)
|
||||
if (wIstr & ISTR_ESOF & wInterrupt_Mask){
|
||||
// _SetISTR((u16)CLR_ESOF); // resume handling timing is made with ESOFs
|
||||
Resume(RESUME_ESOF); // request without change of the machine state
|
||||
_SetISTR((u16)CLR_ESOF); // resume handling timing is made with ESOFs
|
||||
//#ifdef ESOF_CALLBACK
|
||||
// ESOF_Callback();
|
||||
//#endif
|
||||
}
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
#if (IMR_MSK & ISTR_CTR)
|
||||
if (wIstr & ISTR_CTR & wInterrupt_Mask){
|
||||
/* servicing of the endpoint correct transfer interrupt */
|
||||
/* clear of the CTR flag into the sub */
|
||||
CTR_LP();
|
||||
//#ifdef CTR_CALLBACK
|
||||
// CTR_Callback();
|
||||
//#endif
|
||||
}
|
||||
#endif
|
||||
} /* USB_Istr */
|
||||
/*******************************************************************************
|
||||
EP1_IN_Callback: EP1 IN Callback Routine
|
||||
*******************************************************************************/
|
||||
void EP1_IN_Callback(void)
|
||||
{
|
||||
Mass_Storage_In();
|
||||
}
|
||||
/*******************************************************************************
|
||||
EP2_OUT_Callback: EP2 OUT Callback Routine.
|
||||
*******************************************************************************/
|
||||
void EP2_OUT_Callback(void)
|
||||
{
|
||||
Mass_Storage_Out();
|
||||
}
|
||||
/********************************* END OF FILE ******************************/
|
||||
|
||||
262
S100App/Src/USB_prop.c
Normal file
262
S100App/Src/USB_prop.c
Normal file
@@ -0,0 +1,262 @@
|
||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
||||
File Name : USB_prop.c
|
||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#include "USB_desc.h"
|
||||
#include "USB_pwr.h"
|
||||
#include "USB_bot.h"
|
||||
#include "USB_prop.h"
|
||||
#include "USB_lib.h"
|
||||
#include "Bios.h"
|
||||
#include "APP_Version.h"
|
||||
|
||||
u32 Max_Lun = 0;
|
||||
|
||||
DEVICE Device_Table ={ EP_NUM, 1 };
|
||||
DEVICE_PROP Device_Property ={
|
||||
MASS_init,
|
||||
MASS_Reset,
|
||||
MASS_Status_In,
|
||||
MASS_Status_Out,
|
||||
MASS_Data_Setup,
|
||||
MASS_NoData_Setup,
|
||||
MASS_Get_Interface_Setting,
|
||||
MASS_GetDeviceDescriptor,
|
||||
MASS_GetConfigDescriptor,
|
||||
MASS_GetStringDescriptor,
|
||||
0,
|
||||
0x40 // MAX PACKET SIZE
|
||||
};
|
||||
USER_STANDARD_REQUESTS User_Standard_Requests ={
|
||||
Mass_Storage_GetConfiguration,
|
||||
Mass_Storage_SetConfiguration,
|
||||
Mass_Storage_GetInterface,
|
||||
Mass_Storage_SetInterface,
|
||||
Mass_Storage_GetStatus,
|
||||
Mass_Storage_ClearFeature,
|
||||
Mass_Storage_SetEndPointFeature,
|
||||
Mass_Storage_SetDeviceFeature,
|
||||
Mass_Storage_SetDeviceAddress
|
||||
};
|
||||
ONE_DESCRIPTOR Device_Descriptor ={
|
||||
(u8*)MASS_DeviceDescriptor,
|
||||
MASS_SIZ_DEVICE_DESC
|
||||
};
|
||||
ONE_DESCRIPTOR Config_Descriptor ={
|
||||
(u8*)MASS_ConfigDescriptor,
|
||||
MASS_SIZ_CONFIG_DESC
|
||||
};
|
||||
ONE_DESCRIPTOR String_Descriptor[5] ={
|
||||
{(u8*)MASS_StringLangID, MASS_SIZ_STRING_LANGID},
|
||||
{(u8*)MASS_StringVendor, MASS_SIZ_STRING_VENDOR},
|
||||
{(u8*)MASS_StringProduct, MASS_SIZ_STRING_PRODUCT},
|
||||
{(u8*)MASS_StringSerial, MASS_SIZ_STRING_SERIAL},
|
||||
{(u8*)MASS_StringInterface, MASS_SIZ_STRING_INTERFACE},
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
MASS_init: Mass Storage init routine.
|
||||
*******************************************************************************/
|
||||
void MASS_init()
|
||||
{
|
||||
Get_SerialNum(); // Update the serial number string descriptor with the data from the unique ID
|
||||
pInformation->Current_Configuration = 0;
|
||||
PowerOn(); // Connect the device
|
||||
_SetISTR(0); // USB interrupts initialization. clear pending interrupts
|
||||
wInterrupt_Mask = IMR_MSK;
|
||||
_SetCNTR(wInterrupt_Mask); // set interrupts mask
|
||||
bDeviceState = UNCONNECTED;
|
||||
}
|
||||
/*******************************************************************************
|
||||
MASS_Reset: Mass Storage reset routine.
|
||||
*******************************************************************************/
|
||||
void MASS_Reset()
|
||||
{
|
||||
Device_Info.Current_Configuration = 0; // Set the device as not configured
|
||||
pInformation->Current_Feature = MASS_ConfigDescriptor[7]; // Current Feature initialization
|
||||
SetBTABLE(BTABLE_ADDRESS);
|
||||
// Initialize Endpoint 0
|
||||
SetEPType(ENDP0, EP_CONTROL);
|
||||
SetEPTxStatus(ENDP0, EP_TX_NAK);
|
||||
SetEPRxAddr(ENDP0, ENDP0_RXADDR);
|
||||
SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
|
||||
SetEPTxAddr(ENDP0, ENDP0_TXADDR);
|
||||
Clear_Status_Out(ENDP0);
|
||||
SetEPRxValid(ENDP0);
|
||||
//Initialize Endpoint 1
|
||||
SetEPType(ENDP1, EP_BULK);
|
||||
SetEPTxAddr(ENDP1, ENDP1_TXADDR);
|
||||
SetEPTxStatus(ENDP1, EP_TX_NAK);
|
||||
SetEPRxStatus(ENDP1, EP_RX_DIS);
|
||||
// Initialize Endpoint 2
|
||||
SetEPType(ENDP2, EP_BULK);
|
||||
SetEPRxAddr(ENDP2, ENDP2_RXADDR);
|
||||
SetEPRxCount(ENDP2, Device_Property.MaxPacketSize);
|
||||
SetEPRxStatus(ENDP2, EP_RX_VALID);
|
||||
SetEPTxStatus(ENDP2, EP_TX_DIS);
|
||||
|
||||
SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
|
||||
SetEPRxValid(ENDP0);
|
||||
// Set the device to response on default address
|
||||
SetDeviceAddress(0);
|
||||
|
||||
bDeviceState = ATTACHED;
|
||||
|
||||
CBW.dSignature = BOT_CBW_SIGNATURE;
|
||||
Bot_State = BOT_IDLE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
Mass_Storage_SetConfiguration: Handle the SetConfiguration request.
|
||||
*******************************************************************************/
|
||||
void Mass_Storage_SetConfiguration(void)
|
||||
{
|
||||
if (pInformation->Current_Configuration != 0){
|
||||
bDeviceState = CONFIGURED; // Device configured
|
||||
ClearDTOG_TX(ENDP1);
|
||||
ClearDTOG_RX(ENDP2);
|
||||
Bot_State = BOT_IDLE; // set the Bot state machine to the IDLE state
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
Mass_Storage_ClearFeature: Handle the ClearFeature request.
|
||||
*******************************************************************************/
|
||||
void Mass_Storage_ClearFeature(void)
|
||||
{
|
||||
/* when the host send a CBW with invalid signature or invalid length the two
|
||||
Endpoints (IN & OUT) shall stall until receiving a Mass Storage Reset */
|
||||
if (CBW.dSignature != BOT_CBW_SIGNATURE)
|
||||
Bot_Abort(BOTH_DIR);
|
||||
}
|
||||
/*******************************************************************************
|
||||
Mass_Storage_SetConfiguration: Udpade the device state to addressed.
|
||||
*******************************************************************************/
|
||||
void Mass_Storage_SetDeviceAddress (void)
|
||||
{
|
||||
bDeviceState = ADDRESSED;
|
||||
}
|
||||
/*******************************************************************************
|
||||
MASS_Status_In: Mass Storage Status IN routine.
|
||||
*******************************************************************************/
|
||||
void MASS_Status_In(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*******************************************************************************
|
||||
MASS_Status_Out: Mass Storage Status OUT routine.
|
||||
*******************************************************************************/
|
||||
void MASS_Status_Out(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*******************************************************************************
|
||||
MASS_Data_Setup: Handle the data class specific requests.
|
||||
*******************************************************************************/
|
||||
RESULT MASS_Data_Setup(u8 RequestNo)
|
||||
{
|
||||
u8* (*CopyRoutine)(u16);
|
||||
|
||||
CopyRoutine = NULL;
|
||||
if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
|
||||
&& (RequestNo == GET_MAX_LUN) && (pInformation->USBwValue == 0)
|
||||
&& (pInformation->USBwIndex == 0) && (pInformation->USBwLength == 0x01))
|
||||
{
|
||||
CopyRoutine = Get_Max_Lun;
|
||||
} else return USB_UNSUPPORT;
|
||||
if (CopyRoutine == NULL) return USB_UNSUPPORT;
|
||||
pInformation->Ctrl_Info.CopyData = CopyRoutine;
|
||||
pInformation->Ctrl_Info.Usb_wOffset = 0;
|
||||
(*CopyRoutine)(0);
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
/*******************************************************************************
|
||||
MASS_NoData_Setup: Handle the no data class specific requests.
|
||||
*******************************************************************************/
|
||||
RESULT MASS_NoData_Setup(u8 RequestNo)
|
||||
{
|
||||
if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
|
||||
&& (RequestNo == MASS_STORAGE_RESET) && (pInformation->USBwValue == 0)
|
||||
&& (pInformation->USBwIndex == 0) && (pInformation->USBwLength == 0x00))
|
||||
{
|
||||
ClearDTOG_TX(ENDP1); // Initialize Endpoint 1
|
||||
ClearDTOG_RX(ENDP2); // Initialize Endpoint 2
|
||||
CBW.dSignature = BOT_CBW_SIGNATURE; // intialise the CBW signature to enable the clear feature
|
||||
Bot_State = BOT_IDLE;
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
/*******************************************************************************
|
||||
MASS_Get_Interface_Setting: Test the interface and the alternate setting
|
||||
according to the supported one.
|
||||
*******************************************************************************/
|
||||
RESULT MASS_Get_Interface_Setting(u8 Interface, u8 AlternateSetting)
|
||||
{
|
||||
if (AlternateSetting > 0) return USB_UNSUPPORT;// in this application we don't have AlternateSetting
|
||||
else if (Interface > 0) return USB_UNSUPPORT; // in this application we have only 1 interfaces
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
/*******************************************************************************
|
||||
MASS_GetDeviceDescriptor: Get the device descriptor.
|
||||
*******************************************************************************/
|
||||
u8 *MASS_GetDeviceDescriptor(u16 Length)
|
||||
{
|
||||
return Standard_GetDescriptorData(Length, &Device_Descriptor );
|
||||
}
|
||||
/*******************************************************************************
|
||||
MASS_GetConfigDescriptor: Get the configuration descriptor.
|
||||
*******************************************************************************/
|
||||
u8 *MASS_GetConfigDescriptor(u16 Length)
|
||||
{
|
||||
return Standard_GetDescriptorData(Length, &Config_Descriptor );
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
MASS_GetStringDescriptor: Get the string descriptors according to
|
||||
the needed index.
|
||||
*******************************************************************************/
|
||||
u8 *MASS_GetStringDescriptor(u16 Length)
|
||||
{
|
||||
u8 wValue0 = pInformation->USBwValue0;
|
||||
if (wValue0 > 5) return NULL;
|
||||
else return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]);
|
||||
}
|
||||
/*******************************************************************************
|
||||
Get_Max_Lun: Handle the Get Max Lun request.
|
||||
*******************************************************************************/
|
||||
u8 *Get_Max_Lun(u16 Length)
|
||||
{
|
||||
if (Length == 0){
|
||||
pInformation->Ctrl_Info.Usb_wLength = LUN_DATA_LENGTH;
|
||||
return 0;
|
||||
} else return((u8*)(&Max_Lun));
|
||||
}
|
||||
/*******************************************************************************
|
||||
Get_SerialNum : Create the serial number string descriptor.
|
||||
*******************************************************************************/
|
||||
void Get_SerialNum(void)
|
||||
{
|
||||
u32 Device_Serial0, Device_Serial1, Device_Serial2;
|
||||
|
||||
Device_Serial0 = SERIAL_NO1;
|
||||
Device_Serial1 = SERIAL_NO2;
|
||||
Device_Serial2 = SERIAL_NO3;
|
||||
|
||||
if (Device_Serial0 != 0){
|
||||
MASS_StringSerial[ 2] = (u8)( Device_Serial0 & 0x000000FF);
|
||||
MASS_StringSerial[ 4] = (u8)((Device_Serial0 & 0x0000FF00) >> 8);
|
||||
MASS_StringSerial[ 6] = (u8)((Device_Serial0 & 0x00FF0000) >> 16);
|
||||
MASS_StringSerial[ 8] = (u8)((Device_Serial0 & 0xFF000000) >> 24);
|
||||
|
||||
MASS_StringSerial[10] = (u8)( Device_Serial1 & 0x000000FF);
|
||||
MASS_StringSerial[12] = (u8)((Device_Serial1 & 0x0000FF00) >> 8);
|
||||
MASS_StringSerial[14] = (u8)((Device_Serial1 & 0x00FF0000) >> 16);
|
||||
MASS_StringSerial[16] = (u8)((Device_Serial1 & 0xFF000000) >> 24);
|
||||
|
||||
MASS_StringSerial[18] = (u8)( Device_Serial2 & 0x000000FF);
|
||||
MASS_StringSerial[20] = (u8)((Device_Serial2 & 0x0000FF00) >> 8);
|
||||
MASS_StringSerial[22] = (u8)((Device_Serial2 & 0x00FF0000) >> 16);
|
||||
MASS_StringSerial[24] = (u8)((Device_Serial2 & 0xFF000000) >> 24);
|
||||
}
|
||||
}
|
||||
/********************************* END OF FILE ******************************/
|
||||
152
S100App/Src/USB_pwr.c
Normal file
152
S100App/Src/USB_pwr.c
Normal file
@@ -0,0 +1,152 @@
|
||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
||||
File Name : USB_pwr.c
|
||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#include "USB_lib.h"
|
||||
#include "USB_conf.h"
|
||||
#include "USB_pwr.h"
|
||||
|
||||
vu32 bDeviceState = UNCONNECTED; // USB device status
|
||||
vu8 fSuspendEnabled = TRUE; // true when suspend is possible
|
||||
|
||||
struct{
|
||||
volatile RESUME_STATE eState;
|
||||
volatile u8 bESOFcnt;
|
||||
} ResumeS;
|
||||
|
||||
/*******************************************************************************
|
||||
PowerOn Return : USB_SUCCESS
|
||||
|
||||
*******************************************************************************/
|
||||
RESULT PowerOn(void)
|
||||
{
|
||||
u16 wRegVal;
|
||||
|
||||
/*** CNTR_PWDN = 0 ***/
|
||||
wRegVal = CNTR_FRES;
|
||||
_SetCNTR(wRegVal);
|
||||
/*** CNTR_FRES = 0 ***/
|
||||
wInterrupt_Mask = 0;
|
||||
_SetCNTR(wInterrupt_Mask);
|
||||
/*** Clear pending interrupts ***/
|
||||
_SetISTR(0);
|
||||
/*** Set interrupt mask ***/
|
||||
wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM;
|
||||
_SetCNTR(wInterrupt_Mask);
|
||||
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
/*******************************************************************************
|
||||
PowerOff: handles switch-off conditions Return : USB_SUCCESS
|
||||
*******************************************************************************/
|
||||
RESULT PowerOff()
|
||||
{
|
||||
/* disable all ints and force USB reset */
|
||||
_SetCNTR(CNTR_FRES);
|
||||
/* clear interrupt status register */
|
||||
_SetISTR(0);
|
||||
/* Disable the Pull-Up*/
|
||||
// USB_Cable_Config(DISABLE);
|
||||
/* switch-off device */
|
||||
_SetCNTR(CNTR_FRES + CNTR_PDWN);
|
||||
/* sw variables reset */
|
||||
/* ... */
|
||||
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
/*******************************************************************************
|
||||
Suspend: sets suspend mode operating conditions
|
||||
Return : USB_SUCCESS.
|
||||
*******************************************************************************/
|
||||
void Suspend(void)
|
||||
{
|
||||
u16 wCNTR;
|
||||
/* suspend preparation */
|
||||
/* macrocell enters suspend mode */
|
||||
wCNTR = _GetCNTR();
|
||||
wCNTR |= CNTR_FSUSP;
|
||||
_SetCNTR(wCNTR);
|
||||
/* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */
|
||||
/* power reduction */
|
||||
/* ... on connected devices */
|
||||
/* force low-power mode in the macrocell */
|
||||
wCNTR = _GetCNTR();
|
||||
wCNTR |= CNTR_LPMODE;
|
||||
_SetCNTR(wCNTR);
|
||||
}
|
||||
/*******************************************************************************
|
||||
Resume_Init: Handles wake-up restoring normal operations
|
||||
* Return : USB_SUCCESS.
|
||||
*******************************************************************************/
|
||||
void Resume_Init(void)
|
||||
{
|
||||
u16 wCNTR;
|
||||
/* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */
|
||||
/* restart the clocks */
|
||||
/* CNTR_LPMODE = 0 */
|
||||
wCNTR = _GetCNTR();
|
||||
wCNTR &= (~CNTR_LPMODE);
|
||||
_SetCNTR(wCNTR);
|
||||
/* restore full power */
|
||||
/* ... on connected devices */
|
||||
/* reset FSUSP bit */
|
||||
_SetCNTR(IMR_MSK);
|
||||
/* reverse suspend preparation */
|
||||
/* ... */
|
||||
}
|
||||
/*******************************************************************************
|
||||
Resume: This is the state machine handling resume operations and
|
||||
timing sequence. The control is based on the Resume structure
|
||||
variables and on the ESOF interrupt calling this subroutine
|
||||
without changing machine state.
|
||||
Input: a state machine value (RESUME_STATE)
|
||||
RESUME_ESOF doesn't change ResumeS.eState allowing
|
||||
decrementing of the ESOF counter in different states.
|
||||
*******************************************************************************/
|
||||
void Resume(RESUME_STATE eResumeSetVal)
|
||||
{
|
||||
u16 wCNTR;
|
||||
|
||||
if (eResumeSetVal != RESUME_ESOF) ResumeS.eState = eResumeSetVal;
|
||||
switch (ResumeS.eState){
|
||||
case RESUME_EXTERNAL:
|
||||
Resume_Init();
|
||||
ResumeS.eState = RESUME_OFF;
|
||||
break;
|
||||
case RESUME_INTERNAL:
|
||||
Resume_Init();
|
||||
ResumeS.eState = RESUME_START;
|
||||
break;
|
||||
case RESUME_LATER:
|
||||
ResumeS.bESOFcnt = 2;
|
||||
ResumeS.eState = RESUME_WAIT;
|
||||
break;
|
||||
case RESUME_WAIT:
|
||||
ResumeS.bESOFcnt--;
|
||||
if (ResumeS.bESOFcnt == 0)
|
||||
ResumeS.eState = RESUME_START;
|
||||
break;
|
||||
case RESUME_START:
|
||||
wCNTR = _GetCNTR();
|
||||
wCNTR |= CNTR_RESUME;
|
||||
_SetCNTR(wCNTR);
|
||||
ResumeS.eState = RESUME_ON;
|
||||
ResumeS.bESOFcnt = 10;
|
||||
break;
|
||||
case RESUME_ON:
|
||||
ResumeS.bESOFcnt--;
|
||||
if (ResumeS.bESOFcnt == 0){
|
||||
wCNTR = _GetCNTR();
|
||||
wCNTR &= (~CNTR_RESUME);
|
||||
_SetCNTR(wCNTR);
|
||||
ResumeS.eState = RESUME_OFF;
|
||||
}
|
||||
break;
|
||||
case RESUME_OFF:
|
||||
case RESUME_ESOF:
|
||||
default:
|
||||
ResumeS.eState = RESUME_OFF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/********************************* END OF FILE ******************************/
|
||||
230
S100App/Src/USB_scsi.c
Normal file
230
S100App/Src/USB_scsi.c
Normal file
@@ -0,0 +1,230 @@
|
||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
||||
File Name : USB_scsi.c
|
||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
||||
*******************************************************************************/
|
||||
#include "USB_scsi.h"
|
||||
#include "USB_bot.h"
|
||||
#include "USB_regs.h"
|
||||
#include "usb_lib.h"
|
||||
#include "Disk.h"
|
||||
|
||||
u8 Page00_Inquiry_Data[] ={ 0, 0, 0, 0, 0};
|
||||
u8 Mode_Sense6_data[] ={0x03, 0x00, 0x00, 0x00};
|
||||
u8 Mode_Sense10_data[] ={0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
u8 Scsi_Sense_Data[] ={0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
u8 ReadCapacity10_Data[] ={ 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
u8 ReadFormatCapacity[] ={ 0, 0, 0, 8, 0, 0, 0, 0, 2, 0, 0, 0};
|
||||
|
||||
#ifdef DFU_MODE
|
||||
uc8 Disk_Inquiry_Str[] ={0x00, 0x80, 0x02, 0x02, 36-4, 0x00, 0x00, 0x00,
|
||||
'V', 'i', 'r', 't', 'u', 'a', 'l', ' ',
|
||||
'D', 'F', 'U', ' ', 'D', 'i', 's', 'k',
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
||||
' ', ' ', ' ', ' ', };
|
||||
#else
|
||||
uc8 Disk_Inquiry_Str[] ={0x00, 0x80, 0x02, 0x02, 36-4, 0x00, 0x00, 0x00,
|
||||
'M', 'i', 'n', 'i', ' ', 'D', 'S', 'O',
|
||||
'D', 'i', 's', 'k', ' ', ' ', ' ', ' ',
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
||||
' ', ' ', ' ', ' ', };
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
SCSI_Inquiry_Cmd: SCSI Inquiry Command routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_Inquiry_Cmd(void)
|
||||
{
|
||||
u8* Inquiry_Data;
|
||||
u16 Inquiry_Data_Length;
|
||||
|
||||
if (CBW.CB[1] & 0x01){ // Evpd is set
|
||||
Inquiry_Data = Page00_Inquiry_Data;
|
||||
Inquiry_Data_Length = 5;
|
||||
} else {
|
||||
Inquiry_Data = (u8*)Disk_Inquiry_Str;
|
||||
if (CBW.CB[4] <= STANDARD_INQUIRY_DATA_LEN) Inquiry_Data_Length = CBW.CB[4];
|
||||
else Inquiry_Data_Length = STANDARD_INQUIRY_DATA_LEN;
|
||||
}
|
||||
Transfer_Data_Request(Inquiry_Data, Inquiry_Data_Length);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_ReadFormatCapacity_Cmd: SCSI ReadFormatCapacity Command routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_ReadFormatCapacity_Cmd(void)
|
||||
{
|
||||
ReadFormatCapacity[ 4] = (u8)(SECTOR_SIZE >> 24);
|
||||
ReadFormatCapacity[ 5] = (u8)(SECTOR_SIZE >> 16);
|
||||
ReadFormatCapacity[ 6] = (u8)(SECTOR_SIZE >> 8);
|
||||
ReadFormatCapacity[ 7] = (u8)(SECTOR_SIZE);
|
||||
|
||||
ReadFormatCapacity[ 9] = (u8)(SECTOR_SIZE >> 16);
|
||||
ReadFormatCapacity[10] = (u8)(SECTOR_SIZE >> 8);
|
||||
ReadFormatCapacity[11] = (u8)(SECTOR_SIZE);
|
||||
|
||||
Transfer_Data_Request(ReadFormatCapacity, READ_FORMAT_CAPACITY_DATA_LEN);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_ReadCapacity10_Cmd: SCSI ReadCapacity10 Command routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_ReadCapacity10_Cmd(void)
|
||||
{
|
||||
ReadCapacity10_Data[0] = (u8)(SECTOR_CNT - 1 >> 24);
|
||||
ReadCapacity10_Data[1] = (u8)(SECTOR_CNT - 1 >> 16);
|
||||
ReadCapacity10_Data[2] = (u8)(SECTOR_CNT - 1 >> 8);
|
||||
ReadCapacity10_Data[3] = (u8)(SECTOR_CNT - 1);
|
||||
|
||||
ReadCapacity10_Data[4] = (u8)(SECTOR_SIZE >> 24);
|
||||
ReadCapacity10_Data[5] = (u8)(SECTOR_SIZE >> 16);
|
||||
ReadCapacity10_Data[6] = (u8)(SECTOR_SIZE >> 8);
|
||||
ReadCapacity10_Data[7] = (u8)(SECTOR_SIZE);
|
||||
|
||||
Transfer_Data_Request(ReadCapacity10_Data, READ_CAPACITY10_DATA_LEN);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_ModeSense6_Cmd: SCSI ModeSense6 Command routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_ModeSense6_Cmd (void)
|
||||
{
|
||||
Transfer_Data_Request(Mode_Sense6_data, MODE_SENSE6_DATA_LEN);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_ModeSense10_Cmd: SCSI ModeSense10 Command routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_ModeSense10_Cmd (void)
|
||||
{
|
||||
Transfer_Data_Request(Mode_Sense10_data, MODE_SENSE10_DATA_LEN);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_RequestSense_Cmd: SCSI RequestSense Command routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_RequestSense_Cmd (void)
|
||||
{
|
||||
u8 Request_Sense_data_Length;
|
||||
|
||||
if (CBW.CB[4] <= REQUEST_SENSE_DATA_LEN) Request_Sense_data_Length = CBW.CB[4];
|
||||
else Request_Sense_data_Length = REQUEST_SENSE_DATA_LEN;
|
||||
|
||||
Transfer_Data_Request(Scsi_Sense_Data, Request_Sense_data_Length);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
Set_Scsi_Sense_Data: Set Scsi Sense Data routine.
|
||||
*******************************************************************************/
|
||||
void Set_Scsi_Sense_Data(u8 Sens_Key, u8 Asc)
|
||||
{
|
||||
Scsi_Sense_Data[2] = Sens_Key;
|
||||
Scsi_Sense_Data[12] = Asc;
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_Start_Stop_Unit_Cmd: SCSI Start_Stop_Unit Command routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_Start_Stop_Unit_Cmd(void)
|
||||
{
|
||||
Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_Read10_Cmd: SCSI Read10 Command routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_Read10_Cmd(u32 LBA , u32 BlockNbr)
|
||||
{
|
||||
if (Bot_State == BOT_IDLE){
|
||||
if (!(SCSI_Address_Management(SCSI_READ10, LBA, BlockNbr))) return;//address out of range
|
||||
if ((CBW.bmFlags & 0x80) != 0){
|
||||
Bot_State = BOT_DATA_IN;
|
||||
Read_Memory(LBA , BlockNbr);
|
||||
} else {
|
||||
Bot_Abort(BOTH_DIR);
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_ENABLE);
|
||||
}
|
||||
return;
|
||||
} else if (Bot_State == BOT_DATA_IN) Read_Memory(LBA , BlockNbr);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_Write10_Cmd: SCSI Write10 Command routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_Write10_Cmd(u32 LBA , u32 BlockNbr)
|
||||
{
|
||||
if (Bot_State == BOT_IDLE){
|
||||
if (!(SCSI_Address_Management(SCSI_WRITE10 , LBA, BlockNbr))) return;//address out of range
|
||||
if ((CBW.bmFlags & 0x80) == 0){
|
||||
Bot_State = BOT_DATA_OUT;
|
||||
SetEPRxStatus(ENDP2, EP_RX_VALID);
|
||||
} else {
|
||||
Bot_Abort(DIR_IN);
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
||||
}
|
||||
return;
|
||||
} else if (Bot_State == BOT_DATA_OUT) Write_Memory(LBA , BlockNbr);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_Verify10_Cmd: SCSI Verify10 Command routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_Verify10_Cmd(void)
|
||||
{
|
||||
if ((CBW.dDataLength == 0) && !(CBW.CB[1] & BLKVFY)){ // BLKVFY not set
|
||||
Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
||||
} else {
|
||||
Bot_Abort(BOTH_DIR);
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_Valid_Cmd: Valid Commands routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_Valid_Cmd(void)
|
||||
{
|
||||
if (CBW.dDataLength != 0){
|
||||
Bot_Abort(BOTH_DIR);
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_COMMAND);
|
||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
||||
} else Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_Valid_Cmd: Valid Commands routine.
|
||||
*******************************************************************************/
|
||||
void SCSI_TestUnitReady_Cmd(void)
|
||||
{
|
||||
Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_Invalid_Cmd: Invalid Commands routine
|
||||
*******************************************************************************/
|
||||
void SCSI_Invalid_Cmd(void)
|
||||
{
|
||||
if (CBW.dDataLength == 0) Bot_Abort(DIR_IN);
|
||||
else{
|
||||
if ((CBW.bmFlags & 0x80) != 0) Bot_Abort(DIR_IN);
|
||||
else Bot_Abort(BOTH_DIR);
|
||||
}
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_COMMAND);
|
||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
||||
}
|
||||
/*******************************************************************************
|
||||
SCSI_Address_Management: Test the received address.
|
||||
Input: Cmd the command can be SCSI_READ10 or SCSI_WRITE10.
|
||||
Return: Read\Write status (bool).
|
||||
*******************************************************************************/
|
||||
u8 SCSI_Address_Management(u8 Cmd , u32 LBA , u32 BlockNbr)
|
||||
{
|
||||
|
||||
if ((LBA + BlockNbr) > SECTOR_CNT){
|
||||
if (Cmd == SCSI_WRITE10) Bot_Abort(BOTH_DIR);
|
||||
Bot_Abort(DIR_IN);
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, ADDRESS_OUT_OF_RANGE);
|
||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
||||
return (FALSE);
|
||||
}
|
||||
if (CBW.dDataLength != BlockNbr * SECTOR_SIZE){
|
||||
if (Cmd == SCSI_WRITE10) Bot_Abort(BOTH_DIR);
|
||||
else Bot_Abort(DIR_IN);
|
||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
/********************************* END OF FILE ******************************/
|
||||
152
S100App/Src/_APP_Startup.s
Normal file
152
S100App/Src/_APP_Startup.s
Normal file
@@ -0,0 +1,152 @@
|
||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
||||
S100 APP Ver 30.10 startup Author : bure
|
||||
*******************************************************************************/
|
||||
|
||||
MODULE ?cstartup
|
||||
|
||||
SECTION CSTACK:DATA:NOROOT(3)
|
||||
SECTION INTVEC:CODE:NOROOT(2)
|
||||
|
||||
EXTERN __iar_program_start
|
||||
|
||||
PUBLIC __vector_table
|
||||
|
||||
DATA
|
||||
__vector_table
|
||||
DCD sfe(CSTACK)
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
THUMB
|
||||
EXPORT DFU_Func_ptr
|
||||
DFU_Func_ptr
|
||||
B.W 0;LCD_Init
|
||||
B.W 0;ClrScrn
|
||||
B.W 0;SetBlock
|
||||
B.W 0;SetPosi
|
||||
B.W 0;SetPixel
|
||||
B.W 0;ReadPixel
|
||||
B.W 0;SetPixels
|
||||
B.W 0;SendPixels
|
||||
|
||||
B.W 0;Direction
|
||||
B.W 0;GetChar8x14
|
||||
B.W 0;DispLogo
|
||||
B.W 0;DispStr
|
||||
B.W 0;Dev_SN
|
||||
B.W 0;Lic_Gen
|
||||
B.W 0;Ident
|
||||
B.W 0;Chk_SYS
|
||||
|
||||
B.W 0;Lic_ok
|
||||
B.W 0;DeviceInfo
|
||||
B.W 0;Delay_mS
|
||||
|
||||
DATA
|
||||
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
|
||||
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
|
||||
DCD DEFAULT_ISR;//CAN_RX1_IRQHandler;
|
||||
DCD DEFAULT_ISR;
|
||||
DCD DEFAULT_ISR;
|
||||
DCD DEFAULT_ISR;
|
||||
DCD DEFAULT_ISR;
|
||||
DCD DEFAULT_ISR;
|
||||
DCD DEFAULT_ISR;
|
||||
DCD DEFAULT_ISR;
|
||||
DCD DEFAULT_ISR;
|
||||
DCD DEFAULT_ISR;
|
||||
DCD DEFAULT_ISR;
|
||||
DCD I2C1_EV_IRQHandler;
|
||||
DCD I2C1_ER_IRQHandler;
|
||||
|
||||
THUMB
|
||||
|
||||
IMPORT RCC_Config
|
||||
IMPORT CTR_HP
|
||||
IMPORT USB_Istr
|
||||
IMPORT DEFAULT_ISR
|
||||
IMPORT I2C1_EV_IRQHandler
|
||||
IMPORT I2C1_ER_IRQHandler
|
||||
PUBWEAK Reset_Handler
|
||||
SECTION .text:CODE:REORDER(2)
|
||||
Reset_Handler
|
||||
LDR R0, =RCC_Config
|
||||
BLX R0
|
||||
LDR R0, =__iar_program_start
|
||||
BX R0
|
||||
|
||||
PUBWEAK NMI_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
NMI_Handler
|
||||
B NMI_Handler
|
||||
|
||||
PUBWEAK HardFault_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
HardFault_Handler
|
||||
B HardFault_Handler
|
||||
|
||||
PUBWEAK MemManage_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
MemManage_Handler
|
||||
B MemManage_Handler
|
||||
|
||||
PUBWEAK BusFault_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
BusFault_Handler
|
||||
B BusFault_Handler
|
||||
|
||||
PUBWEAK UsageFault_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
UsageFault_Handler
|
||||
B UsageFault_Handler
|
||||
|
||||
PUBWEAK SVC_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
SVC_Handler
|
||||
B SVC_Handler
|
||||
|
||||
PUBWEAK DebugMon_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
DebugMon_Handler
|
||||
B DebugMon_Handler
|
||||
|
||||
PUBWEAK PendSV_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
PendSV_Handler
|
||||
B PendSV_Handler
|
||||
|
||||
PUBWEAK SysTick_Handler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
SysTick_Handler
|
||||
B SysTick_Handler
|
||||
|
||||
PUBWEAK USB_HP_CAN1_TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
USB_HP_CAN1_TX_IRQHandler
|
||||
B CTR_HP ; USB_HP_CAN1_TX_IRQHandler
|
||||
|
||||
PUBWEAK USB_LP_CAN1_RX0_IRQHandler
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
USB_LP_CAN1_RX0_IRQHandler
|
||||
B USB_Istr ; USB_LP_CAN1_RX0_IRQHandler
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
END
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
Reference in New Issue
Block a user