2014-09-12 16:01:33 +02:00
|
|
|
/*
|
2017-10-25 13:39:20 +02:00
|
|
|
* Licensed under the GNU General Public License version 2 with exceptions. See
|
|
|
|
* LICENSE file in the project root for full license information
|
2014-09-12 16:01:33 +02:00
|
|
|
*/
|
|
|
|
|
2015-05-18 16:54:09 +02:00
|
|
|
/** \file
|
2014-09-12 16:01:33 +02:00
|
|
|
* \brief
|
2015-05-18 16:54:09 +02:00
|
|
|
* Headerfile for esc_foe.c
|
2014-09-12 16:01:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __esc_foe__
|
|
|
|
#define __esc_foe__
|
|
|
|
|
2015-05-20 13:13:54 +02:00
|
|
|
#include <cc.h>
|
|
|
|
|
2014-09-12 16:01:33 +02:00
|
|
|
/** Maximum number of characters allowed in a file name. */
|
|
|
|
#define FOE_FN_MAX 15
|
|
|
|
|
|
|
|
typedef struct foe_writefile_cfg foe_writefile_cfg_t;
|
|
|
|
struct foe_writefile_cfg
|
|
|
|
{
|
|
|
|
/** Name of file to receive from master */
|
|
|
|
const char * name;
|
|
|
|
/** Size of file,sizeof data we can recv */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint32_t max_data;
|
2014-09-12 16:01:33 +02:00
|
|
|
/** Where to store the data initially */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint32_t dest_start_address;
|
2014-09-12 16:01:33 +02:00
|
|
|
/** Current address during write of file */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint32_t address_offset;
|
2017-10-25 13:58:55 +02:00
|
|
|
/** Calculated size of file received */
|
|
|
|
uint32_t total_size;
|
|
|
|
/** FoE password */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint32_t filepass;
|
2017-10-25 13:58:55 +02:00
|
|
|
/** Pointer to application foe write function */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint32_t (*write_function) (foe_writefile_cfg_t * self, uint8_t * data);
|
2014-09-12 16:01:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct foe_cfg
|
|
|
|
{
|
|
|
|
/** Allocate static in caller func to fit buffer_size */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint8_t * fbuffer;
|
2014-09-12 16:01:33 +02:00
|
|
|
/** Write this to fill-up, ex. 0xFF for "non write" */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint8_t empty_write;
|
2014-09-12 16:01:33 +02:00
|
|
|
/** Buffer size before we flush to destination */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint32_t buffer_size;
|
2014-09-12 16:01:33 +02:00
|
|
|
/** Number of files used in firmware update */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint32_t n_files;
|
2014-09-12 16:01:33 +02:00
|
|
|
/** Pointer to files configured to be used by FoE */
|
|
|
|
foe_writefile_cfg_t * files;
|
|
|
|
} foe_cfg_t;
|
|
|
|
|
2015-05-18 16:54:09 +02:00
|
|
|
typedef struct CC_PACKED
|
2014-09-12 16:01:33 +02:00
|
|
|
{
|
|
|
|
/** Current FoE state, ex. Waiting for ACK, Waiting for DATA */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint8_t foestate;
|
2014-09-12 16:01:33 +02:00
|
|
|
/** Current file buffer position, evaluated against foe file buffer size
|
|
|
|
* when to flush
|
|
|
|
*/
|
2015-05-21 10:41:13 +02:00
|
|
|
uint16_t fbufposition;
|
2014-09-12 16:01:33 +02:00
|
|
|
/** Frame number in read or write sequence */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint32_t foepacket;
|
2014-09-12 16:01:33 +02:00
|
|
|
/** Current position in file to be handled by FoE request */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint32_t fposition;
|
2014-09-12 16:01:33 +02:00
|
|
|
/** Previous position in file to be handled by FoE request */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint32_t fprevposition;
|
2014-09-12 16:01:33 +02:00
|
|
|
/** End position of allocated disk space for FoE requested file */
|
2015-05-21 10:41:13 +02:00
|
|
|
uint32_t fend;
|
2014-09-12 16:01:33 +02:00
|
|
|
} _FOEvar;
|
|
|
|
|
|
|
|
/* Initializes FoE state. */
|
|
|
|
void FOE_config (foe_cfg_t * cfg, foe_writefile_cfg_t * cfg_files);
|
|
|
|
void FOE_init (void);
|
|
|
|
void ESC_foeprocess (void);
|
|
|
|
|
|
|
|
#endif
|