📄 getinifile.c
字号:
//*-----------------------------------------------------------------------------
//* ATMEL Microcontroller Software Support - ROUSSET -
//*-----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*-----------------------------------------------------------------------------
//* File Name : GetIniFile.c
//* Object : Read loader.ini file and set the Global variable
//*
//* 1.0 02/05/99 JPP : Creation
//*-----------------------------------------------------------------------------
//*----- Files to be included Definition -----*/
#include <windows.h>
#include <stdio.h>
//*----- Types and Constants Definition -----*/
// COM port
//*----- External Prototy -----*/
#include "GlobalVar.h"
#include "desc_flash_8011.h"
#define FLASH_START_ADDRESS 0x01000000 //* Standart Start Address
#define PGM_START_ADDRESS 0x01000000
#define FLASH_MANUFACTURER_CODE 0x001F
#define FLASH_DEVICE_CODE 0x00C0
#define NB_SECTOR 40
//*----------------------------------------------------------------------------
//* Function Name : getinitfile
//* Object : Read loader.ini file
//* Input Parameters : Address of message, Len
//* Output Parameters : FALSE or TRUE
//* Functions called : CloseHandle
//*----------------------------------------------------------------------------
void getinitfile(void)
{
unsigned char initFileName[256];
unsigned char message[256];
int cmpt;
int totalsector;
//* set the file name
sprintf(initFileName,"%s\\LOADER.INI",currentDirectory);
//* Get mode
// enable 1 disable 0
State.debug = GetPrivateProfileInt("MODE","Debug",0,initFileName);
State.Manual = GetPrivateProfileInt("MODE","Manual",0,initFileName);
State.Synchronization= GetPrivateProfileInt("MODE","Synchronization",1,initFileName);
State.Send_speed = GetPrivateProfileInt("MODE","Send_speed",1,initFileName);
send_mes.error.Consecutive_Repeat=GetPrivateProfileInt("MODE","Consecutive_Repeat",10,initFileName);
send_mes.error.Cumulative_Repeat=GetPrivateProfileInt("MODE","Cumulative_Repeat",100,initFileName);
//* Get com Status
GetPrivateProfileString("COM","Name","COM1",ComUsed.name,sizeof(ComUsed.name)-1,initFileName);
ComUsed.baud[COM_BAUD_INIT] = GetPrivateProfileInt("COM","Synchronization_baud",1200,initFileName);
ComUsed.baud[COM_BAUD_LOAD] = GetPrivateProfileInt("COM","Transfer_baud",115200,initFileName);
ComUsed.cd = GetPrivateProfileInt("COM","Target_CD",18,initFileName);
ComUsed.hCom=INVALID_HANDLE_VALUE; //* Handle to COM deviceHANDLE ComUsed.baud[COM_BAUD_CURRENT]=0;
//* Get File Status
GetPrivateProfileString("FILE","Name","",workFile.File,sizeof(workFile.File)-1,initFileName);
//* Get scehdule Status TRUE by default
schedule.send_reset = GetPrivateProfileInt("SCHEDULE","Send_reset",1,initFileName);
//* Get FLASH Status
GetPrivateProfileString("FLASH","Name","AT49BV8011",FlashTable.name,sizeof(FlashTable.name)-1,initFileName);
FlashTable.type = GetPrivateProfileInt("FLASH","Type",FLASH_DEVICE_CODE,initFileName);
FlashTable.manufacturer = GetPrivateProfileInt("FLASH","Manufacturer",FLASH_MANUFACTURER_CODE,initFileName);
FlashTable.add =GetPrivateProfileInt("FLASH","base_address",FLASH_START_ADDRESS,initFileName);
FlashTable.load_add = GetPrivateProfileInt("FLASH","Load_address",FLASH_START_ADDRESS,initFileName);
FlashTable.sector_nb = GetPrivateProfileInt("FLASH","Sector",AT49BV8011_NB_SECTOR,initFileName);
//* get Flash organization
for ( cmpt =0 , totalsector =0 ;
(totalsector < FlashTable.sector_nb) ;
cmpt++ )
{
sprintf(message,"Sect_type%d",cmpt);
FlashTable.org[cmpt].sector_number = GetPrivateProfileInt("FLASH",message,OrgAT49BV8011[cmpt].sector_number,initFileName);
totalsector+=FlashTable.org[cmpt].sector_number;
sprintf(message,"Size_type%d",cmpt);
FlashTable.org[cmpt].sector_size = GetPrivateProfileInt("FLASH",message,OrgAT49BV8011[cmpt].sector_size,initFileName) * KILO_BYTES;
}
// init the Erase sector table;
at91_init_flash_table(&FlashTable);
//*Get repeat send
}
//* End of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -