2014-11-09 15:06:25 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Freie Universität Berlin
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
2017-01-18 13:00:05 +01:00
|
|
|
#ifndef IAP_H
|
|
|
|
#define IAP_H
|
2010-11-29 19:19:59 +01:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2014-11-21 21:00:52 +01:00
|
|
|
#ifdef __cplusplus
|
2014-10-13 10:53:20 +02:00
|
|
|
extern "C" {
|
2014-11-21 21:00:52 +01:00
|
|
|
#endif
|
|
|
|
|
2010-11-29 19:19:59 +01:00
|
|
|
/* IAP-Commands */
|
2014-07-31 20:46:28 +02:00
|
|
|
#define PREPARE_SECTOR_FOR_WRITE_OPERATION (50)
|
|
|
|
#define COPY_RAM_TO_FLASH (51)
|
|
|
|
#define ERASE_SECTOR (52)
|
|
|
|
#define BLANK_CHECK_SECTOR (53)
|
|
|
|
#define READ_PART_ID (54)
|
|
|
|
#define READ_BOOT_CODE_VERSION (55)
|
|
|
|
#define COMPARE (56)
|
2010-11-29 19:19:59 +01:00
|
|
|
|
|
|
|
/* IAP status codes */
|
|
|
|
#define CMD_SUCCESS (0)
|
|
|
|
#define INVALID_COMMAND (1)
|
|
|
|
#define SRC_ADDR_ERROR (2)
|
|
|
|
#define DST_ADDR_ERROR (3)
|
|
|
|
#define SRC_ADDR_NOT_MAPPED (4)
|
|
|
|
#define DST_ADDR_NOT_MAPPED (5)
|
|
|
|
#define COUNT_ERROR (6)
|
|
|
|
#define INVALID_SECTOR (7)
|
|
|
|
#define SECTOR_NOT_BLANK (8)
|
|
|
|
#define SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION (9)
|
|
|
|
#define COMPARE_ERROR (10)
|
|
|
|
#define BUSY (11)
|
|
|
|
|
2010-12-01 16:26:48 +01:00
|
|
|
#define INVALID_ADDRESS (0xFF)
|
|
|
|
|
2010-11-29 19:19:59 +01:00
|
|
|
/* IAP start location on flash */
|
|
|
|
#define IAP_LOCATION (0x7FFFFFF1)
|
|
|
|
|
|
|
|
/* PLL */
|
2018-02-05 11:39:41 +01:00
|
|
|
#define PLLCON_PLLE (0x01) /**< PLL Enable */
|
|
|
|
#define PLLCON_PLLD (0x00) /**< PLL Disable */
|
|
|
|
#define PLLCON_PLLC (0x03) /**< PLL Connect */
|
|
|
|
#define PLLSTAT_PLOCK (0x0400) /**< PLL Lock Status */
|
2010-11-29 19:19:59 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @brief: Converts 'addr' to sector number
|
|
|
|
* @note: Sector table (Users Manual P. 610)
|
2013-06-21 03:52:57 +02:00
|
|
|
*
|
2014-07-31 20:46:28 +02:00
|
|
|
* @param addr Flash address
|
2013-06-21 03:52:57 +02:00
|
|
|
*
|
2010-11-29 19:19:59 +01:00
|
|
|
* @return Sector number. 0xFF on error
|
|
|
|
*/
|
2010-12-03 22:22:58 +01:00
|
|
|
uint8_t iap_get_sector(uint32_t addr);
|
2010-11-29 19:19:59 +01:00
|
|
|
|
2014-11-21 21:00:52 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-01-18 15:07:35 +01:00
|
|
|
#endif /* IAP_H */
|