OP-1516 fixed boundf mistake
[librepilot.git] / flight / pios / inc / pios_iap.h
blob0c85ec6bafb80bb08d6039f0c97525618176d32e
1 /**
2 ******************************************************************************
3 * @addtogroup PIOS PIOS Core hardware abstraction layer
4 * @{
5 * @addtogroup PIOS_IAP In-Application-Programming Module
6 * @brief In-Application-Programming Module
7 * @{
9 * @file pios_iap.c
10 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
11 * @brief IAP functions
12 * @see The GNU Public License (GPL) Version 3
14 *****************************************************************************/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * for more details.
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 /* Project Includes */
32 #ifndef PIOS_IAP_H
33 #define PIOS_IAP_H
36 /****************************************************************************************
37 * Header files
38 ****************************************************************************************/
39 #include <pios_bkp.h>
41 /*****************************************************************************************
42 * Public Definitions/Macros
43 ****************************************************************************************/
44 #define MAGIC_REG_1 PIOS_BKP_RESERVED_1
45 #define MAGIC_REG_2 PIOS_BKP_RESERVED_2
46 #define IAP_BOOTCOUNT PIOS_BKP_RESERVED_3
47 #define IAP_CMD1 PIOS_BKP_RESERVED_5
48 #define IAP_CMD2 PIOS_BKP_RESERVED_6
49 #define IAP_CMD3 PIOS_BKP_RESERVED_7
51 #define PIOS_IAP_CLEAR_FLASH_CMD_0 0xFA5F
52 #define PIOS_IAP_CLEAR_FLASH_CMD_1 0x0001
53 #define PIOS_IAP_CLEAR_FLASH_CMD_2 0x0000
55 #define PIOS_IAP_CMD_COUNT 3
57 /****************************************************************************************
58 * Public Functions
59 ****************************************************************************************/
60 void PIOS_IAP_Init(void);
61 uint32_t PIOS_IAP_CheckRequest(void);
62 void PIOS_IAP_SetRequest1(void);
63 void PIOS_IAP_SetRequest2(void);
64 void PIOS_IAP_ClearRequest(void);
65 uint16_t PIOS_IAP_ReadBootCount(void);
66 void PIOS_IAP_WriteBootCount(uint16_t);
68 /**
69 * @brief Return one of the IAP command values passed from bootloader.
70 * @param number: the index of the command value (0..2).
71 * @retval the selected command value.
73 uint32_t PIOS_IAP_ReadBootCmd(uint8_t number);
75 /**
76 * @brief Write one of the IAP command values to be passed to firmware from bootloader.
77 * @param number: the index of the command value (0..2).
78 * @param value: value to be written.
80 void PIOS_IAP_WriteBootCmd(uint8_t number, uint32_t value);
81 /****************************************************************************************
82 * Public Data
83 ****************************************************************************************/
85 #endif /* PIOS_IAP_H */