⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.c

📁 ATMEL at91系列arm的官方驱动
💻 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               : init.c
//* Object                  : init data value
//*
//* 1.0 02/05/99 JPP        : Creation
//*-----------------------------------------------------------------------------

/*----- Files to be included Definition -----*/
#include <windows.h>
#include <stdio.h>
#include "global_def.h"
#include "ReadFile.h"
#include "ComUsart.h"
#include "flash_49BV.h"
#include "send.h"
#include "scheduler.h"

/*----- Types and Constants Definition -----*/
extern FileName workFile;               // file description
extern ComLoader ComUsed;               // COM description
extern COMMCONFIG  commConfig;          // COM user parameters (dwSize = 0 when none)
extern FlashDef FlashTable;             // Flash descriton
extern send_state send_mes;             // send
extern scheduler_data schedule;         // Schedule
//* --------------------------------------------------------------------------
//* Function Name        : init_send
//* Object               : init Com
//* Input Parameters     : none
//* Output Parameters    : none
//* Functions called     : Windows     : sprintf
//*                        Application : openCom
//* --------------------------------------------------------------------------
void init_schedule(void)
{
        schedule.state =SYNCRHO_NOK;

        schedule.add_rerror= 0;
}

//* --------------------------------------------------------------------------
//* Function Name        : init_send
//* Object               : init Global parametre
//* Input Parameters     : none
//* Output Parameters    : none
//* Functions called     : none
//* --------------------------------------------------------------------------
void init_send(void)
{
    send_mes.len =MAX_DATA_LEN;
    send_mes.error.current_error= 0x00;
    send_mes.curent_add = FlashTable.add;
    // set the target values
    send_mes.chip           = 0;
    send_mes.manufacturer   = 0;
    send_mes.type           = 0;
    send_mes.cd             = 0;
    send_mes.version        = 0;
    send_mes.addr           = 0;

    // set the get error
    send_mes.error.Nak_Reply     = 0;
    send_mes.error.Unknown_Reply = 0;
    send_mes.error.Error_Reply   = 0;

}
//* --------------------------------------------------------------------------
//* Function Name        : init_com
//* Object               : init Com
//* Input Parameters     : none
//* Output Parameters    : none
//* Functions called     : Windows     : sprintf
//*                        Application : openCom
//* --------------------------------------------------------------------------
void init_com(void)
{
    openCom(&ComUsed.name[0],ComUsed.baud[0]);
}

//* --------------------------------------------------------------------------
//* Function Name        : init_file
//* Object               : Set the file
//* Input Parameters     : none
//* Output Parameters    : none
//* Functions called     : Windows     : dialog box , GetOpenFileName,memset
//*                        Application : readBinFile
//* --------------------------------------------------------------------------
void init_file(HWND hwnd)
{
    int len;

    // set the filter
    len=sprintf(&workFile.filter[0],"Bin Files (*.bin)");
    sprintf(&workFile.filter[len+1],"*.bin");
    // Set dialogue box
    workFile.ofn.lStructSize = sizeof(OPENFILENAME);
    workFile.ofn.hwndOwner = hwnd;
    workFile.ofn.Flags = OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY;
    workFile.ofn.lpstrFile= &workFile.File[0];
    workFile.ofn.nMaxFile=sizeof(workFile.File);
    workFile.ofn.lpstrFilter = &workFile.filter [0];
    workFile.ofn.lpstrFileTitle=&workFile.FileTitle[0];
    workFile.ofn.nMaxFileTitle=sizeof(workFile.FileTitle);
    workFile.ofn.lpstrInitialDir=&workFile.InitialDir[0];
    workFile.ofn.lpstrTitle=&workFile.Title[0];
    workFile.ofn.lpstrDefExt=&workFile.DefExt[0];

    readBinFile(workFile.ofn);
}
//* --------------------------------------------------------------------------
//* Function Name        : init_all
//* Object               : init Com
//* Input Parameters     : none
//* Output Parameters    : none
//* Functions called     : openCom
//* --------------------------------------------------------------------------
void init_all(HWND hwnd)
{

    init_com();
    init_file(hwnd);
    init_send();    // need to known FlashTable.add
    init_schedule();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -