-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBootloadable.h
More file actions
155 lines (117 loc) · 6.17 KB
/
Bootloadable.h
File metadata and controls
155 lines (117 loc) · 6.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*******************************************************************************
* File Name: Bootloadable.h
* Version 1.20
*
* Description:
* Provides an API for the Bootloadable application. The API includes a
* single function for starting bootloader.
*
********************************************************************************
* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.
* You may use this file only in accordance with the license, terms, conditions,
* disclaimers, and limitations in the end user license agreement accompanying
* the software package with which this file was provided.
********************************************************************************/
#ifndef CY_BOOTLOADABLE_Bootloadable_H
#define CY_BOOTLOADABLE_Bootloadable_H
#include "cydevice_trm.h"
#include "CyFlash.h"
/* Check to see if required defines such as CY_PSOC5LP are available */
/* They are defined starting with cy_boot v3.0 */
#if !defined (CY_PSOC5LP)
#error Component Bootloadable_v1_20 requires cy_boot v3.0 or later
#endif /* !defined (CY_PSOC5LP) */
#ifndef CYDEV_FLASH_BASE
#define CYDEV_FLASH_BASE CYDEV_FLS_BASE
#define CYDEV_FLASH_SIZE CYDEV_FLS_SIZE
#endif /* CYDEV_FLASH_BASE */
#if(CY_PSOC3)
#define Bootloadable_GET_CODE_DATA(idx) (*((uint8 CYCODE *) (idx)))
#else
#define Bootloadable_GET_CODE_DATA(idx) (*((uint8 *)(CYDEV_FLASH_BASE + (idx))))
#endif /* (CY_PSOC3) */
/*******************************************************************************
* This variable is used by Bootloader/Bootloadable components to schedule what
* application will be started after software reset.
*******************************************************************************/
#if (CY_PSOC4)
#if defined(__ARMCC_VERSION)
__attribute__ ((section(".bootloaderruntype"), zero_init))
#elif defined (__GNUC__)
__attribute__ ((section(".bootloaderruntype")))
#elif defined (__ICCARM__)
#pragma location=".bootloaderruntype"
#endif /* defined(__ARMCC_VERSION) */
extern volatile uint32 cyBtldrRunType;
#endif /* (CY_PSOC4) */
/*******************************************************************************
* Get the reason of the device reset
*******************************************************************************/
#if(CY_PSOC4)
#define Bootloadable_RES_CAUSE_RESET_SOFT (0x10u)
#define Bootloadable_GET_RUN_TYPE \
(((CY_GET_REG32(CYREG_RES_CAUSE) & Bootloadable_RES_CAUSE_RESET_SOFT) > 0u) \
? (cyBtldrRunType) \
: 0u)
#else
#define Bootloadable_GET_RUN_TYPE (CY_GET_REG8(CYREG_RESET_SR0) & \
(Bootloadable_START_BTLDR | Bootloadable_START_APP))
#endif /* (CY_PSOC4) */
/*******************************************************************************
* Schedule Bootloader/Bootloadable to be run after software reset
*******************************************************************************/
#if(CY_PSOC4)
#define Bootloadable_SET_RUN_TYPE(x) (cyBtldrRunType = (x))
#else
#define Bootloadable_SET_RUN_TYPE(x) CY_SET_REG8(CYREG_RESET_SR0, (x))
#endif /* (CY_PSOC4) */
/***************************************
* Function Prototypes
***************************************/
extern void Bootloadable_Load(void) ;
/*******************************************************************************
* Following code are OBSOLETE and must not be used starting from version 1.10
*******************************************************************************/
#define CYBTDLR_SET_RUN_TYPE(x) Bootloadable_SET_RUN_TYPE(x)
/*******************************************************************************
* Following code are OBSOLETE and must not be used starting from version 1.20
*******************************************************************************/
#define Bootloadable_START_APP (0x80u)
#define Bootloadable_START_BTLDR (0x40u)
#define Bootloadable_META_DATA_SIZE (64u)
#define Bootloadable_META_APP_CHECKSUM_OFFSET (0u)
#if(CY_PSOC3)
#define Bootloadable_APP_ADDRESS uint16
#define Bootloadable_GET_CODE_WORD(idx) (*((uint32 CYCODE *) (idx)))
/* Offset by 2 from 32 bit start because only need 16 bits */
#define Bootloadable_META_APP_ADDR_OFFSET (3u)
#define Bootloadable_META_APP_BL_LAST_ROW_OFFSET (7u)
#define Bootloadable_META_APP_BYTE_LEN_OFFSET (11u)
#define Bootloadable_META_APP_RUN_TYPE_OFFSET (15u)
#else
#define Bootloadable_APP_ADDRESS uint32
#define Bootloadable_GET_CODE_WORD(idx) (*((uint32 *)(CYDEV_FLASH_BASE + (idx))))
#define Bootloadable_META_APP_ADDR_OFFSET (1u)
#define Bootloadable_META_APP_BL_LAST_ROW_OFFSET (5u)
#define Bootloadable_META_APP_BYTE_LEN_OFFSET (9u)
#define Bootloadable_META_APP_RUN_TYPE_OFFSET (13u)
#endif /* (CY_PSOC3) */
#define Bootloadable_META_APP_ACTIVE_OFFSET (16u)
#define Bootloadable_META_APP_VERIFIED_OFFSET (17u)
#define Bootloadable_META_APP_BL_BUILD_VER_OFFSET (18u)
#define Bootloadable_META_APP_ID_OFFSET (20u)
#define Bootloadable_META_APP_VER_OFFSET (22u)
#define Bootloadable_META_APP_CUST_ID_OFFSET (24u)
#define Bootloadable_SetFlashRunType(runType) \
Bootloadable_SetFlashByte(Bootloadable_MD_APP_RUN_ADDR(0), (runType))
void Bootloadable_SetFlashByte(uint32 address, uint8 runType) ;
#if(CY_PSOC4)
#define Bootloadable_SOFTWARE_RESET CY_SET_REG32(CYREG_CM0_AIRCR, 0x05FA0004u)
#else
#define Bootloadable_SOFTWARE_RESET CY_SET_REG8(CYREG_RESET_CR2, 0x01u)
#endif /* (CY_PSOC4) */
#if(CY_PSOC4)
extern uint8 appRunType;
#endif /* (CY_PSOC4) */
#endif /* CY_BOOTLOADABLE_Bootloadable_H */
/* [] END OF FILE */