amiro-blt / Target / Source / file.h @ 1446566f
History | View | Annotate | Download (5.54 KB)
1 | 69661903 | Thomas Schöpping | /************************************************************************************//** |
---|---|---|---|
2 | * \file Source\file.h
|
||
3 | * \brief Bootloader file system interface header file.
|
||
4 | * \ingroup Core
|
||
5 | * \internal
|
||
6 | *----------------------------------------------------------------------------------------
|
||
7 | * C O P Y R I G H T
|
||
8 | *----------------------------------------------------------------------------------------
|
||
9 | * Copyright (c) 2013 by Feaser http://www.feaser.com All rights reserved
|
||
10 | *
|
||
11 | *----------------------------------------------------------------------------------------
|
||
12 | * L I C E N S E
|
||
13 | *----------------------------------------------------------------------------------------
|
||
14 | * This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
|
||
15 | * modify it under the terms of the GNU General Public License as published by the Free
|
||
16 | * Software Foundation, either version 3 of the License, or (at your option) any later
|
||
17 | * version.
|
||
18 | *
|
||
19 | * OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||
20 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
21 | * PURPOSE. See the GNU General Public License for more details.
|
||
22 | *
|
||
23 | * You should have received a copy of the GNU General Public License along with OpenBLT.
|
||
24 | * If not, see <http://www.gnu.org/licenses/>.
|
||
25 | *
|
||
26 | * A special exception to the GPL is included to allow you to distribute a combined work
|
||
27 | * that includes OpenBLT without being obliged to provide the source code for any
|
||
28 | * proprietary components. The exception text is included at the bottom of the license
|
||
29 | * file <license.html>.
|
||
30 | *
|
||
31 | * \endinternal
|
||
32 | ****************************************************************************************/
|
||
33 | #ifndef FILE_H
|
||
34 | #define FILE_H
|
||
35 | |||
36 | #if (BOOT_FILE_SYS_ENABLE > 0) |
||
37 | /****************************************************************************************
|
||
38 | * Include files
|
||
39 | ****************************************************************************************/
|
||
40 | #include "ff.h" /* FATFS file system library */ |
||
41 | |||
42 | |||
43 | /****************************************************************************************
|
||
44 | * Defines
|
||
45 | ****************************************************************************************/
|
||
46 | /** \brief Error code for not being able to open the firmware file. */
|
||
47 | #define FILE_ERROR_CANNOT_OPEN_FIRMWARE_FILE (1) |
||
48 | /** \brief Error code for not being able to read from the firmware file. */
|
||
49 | #define FILE_ERROR_CANNOT_READ_FROM_FILE (2) |
||
50 | /** \brief Error code because in incorrect checksum was found in the firmware file. */
|
||
51 | #define FILE_ERROR_INVALID_CHECKSUM_IN_FILE (3) |
||
52 | /** \brief Error code because the file pointers read pointer could not be rewinded. */
|
||
53 | #define FILE_ERROR_REWINDING_FILE_READ_POINTER (4) |
||
54 | /** \brief Error code because an error occurred during the memory erase operation. */
|
||
55 | #define FILE_ERROR_CANNOT_ERASE_MEMORY (5) |
||
56 | /** \brief Error code because an error occurred during the memory write operation. */
|
||
57 | #define FILE_ERROR_CANNOT_PROGRAM_MEMORY (6) |
||
58 | /** \brief Error code because the program's checksum could not be written to memory. */
|
||
59 | #define FILE_ERROR_CANNOT_WRITE_CHECKSUM (7) |
||
60 | |||
61 | /** \brief Maximum number of characters that can be on a line in the firmware file. */
|
||
62 | #define MAX_CHARS_PER_LINE (256) |
||
63 | /** \brief Maximum number of data bytes that can be on a line in the firmware file
|
||
64 | * (S-record).
|
||
65 | */
|
||
66 | #define MAX_DATA_BYTES_PER_LINE (MAX_CHARS_PER_LINE/2) |
||
67 | /** \brief Return code in case an invalid checksum was detected on an S-record line. */
|
||
68 | #define ERROR_SREC_INVALID_CHECKSUM (-1) |
||
69 | |||
70 | |||
71 | /****************************************************************************************
|
||
72 | * Type definitions
|
||
73 | ****************************************************************************************/
|
||
74 | /** \brief Enumeration for the different S-record line types. */
|
||
75 | typedef enum |
||
76 | { |
||
77 | LINE_TYPE_S1, /**< 16-bit address line */
|
||
78 | LINE_TYPE_S2, /**< 24-bit address line */
|
||
79 | LINE_TYPE_S3, /**< 32-bit address line */
|
||
80 | LINE_TYPE_UNSUPPORTED /**< unsupported line */
|
||
81 | } tSrecLineType; |
||
82 | |||
83 | /** \brief Structure type for grouping the parsing results of an S-record line. */
|
||
84 | typedef struct |
||
85 | { |
||
86 | blt_char line[MAX_CHARS_PER_LINE]; /**< string buffer for the line chars */
|
||
87 | blt_int8u data[MAX_DATA_BYTES_PER_LINE]; /**< array for S1, S2 or S3 data bytes*/
|
||
88 | blt_addr address; /**< address on S1, S2 or S3 line */
|
||
89 | } tSrecLineParseObject; |
||
90 | |||
91 | |||
92 | /****************************************************************************************
|
||
93 | * Function prototypes
|
||
94 | ****************************************************************************************/
|
||
95 | void FileInit(void); |
||
96 | void FileTask(void); |
||
97 | blt_bool FileIsIdle(void);
|
||
98 | blt_bool FileHandleFirmwareUpdateRequest(void);
|
||
99 | /* functions for reading data from a Motorola S-record file. */
|
||
100 | tSrecLineType FileSrecGetLineType(const blt_char *line);
|
||
101 | blt_bool FileSrecVerifyChecksum(const blt_char *line);
|
||
102 | blt_int16s FileSrecParseLine(const blt_char *line, blt_addr *address, blt_int8u *data);
|
||
103 | |||
104 | #endif /* BOOT_FILE_SYS_ENABLE > 0 */ |
||
105 | |||
106 | |||
107 | #endif /* FILE_H */ |
||
108 | /*********************************** end of file.h *************************************/
|