-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBootloadable.c
More file actions
84 lines (70 loc) · 2.65 KB
/
Bootloadable.c
File metadata and controls
84 lines (70 loc) · 2.65 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
/*******************************************************************************
* File Name: Bootloadable.c
* 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.
*******************************************************************************/
#include "Bootloadable.h"
/*******************************************************************************
* Function Name: Bootloadable_Load
********************************************************************************
* Summary:
* Begins the bootloading algorithm, downloading a new ACD image from the host.
*
* Parameters:
* None
*
* Returns:
* This method will never return. It will load a new application and reset
* the device.
*
*******************************************************************************/
void Bootloadable_Load(void)
{
/* Schedule Bootloader to start after reset */
Bootloadable_SET_RUN_TYPE(Bootloadable_START_BTLDR);
CySoftwareReset();
}
/*******************************************************************************
* Function Name: Bootloadable_SetFlashByte
********************************************************************************
* Summary:
* Sets byte at specified address in Flash.
*
* Parameters:
* None
*
* Returns:
* None
*
*******************************************************************************/
void Bootloadable_SetFlashByte(uint32 address, uint8 runType)
{
uint32 flsAddr = address - CYDEV_FLASH_BASE;
uint8 rowData[CYDEV_FLS_ROW_SIZE];
#if !(CY_PSOC4)
uint8 arrayId = (uint8)(flsAddr / CYDEV_FLS_SECTOR_SIZE);
#endif /* !(CY_PSOC4) */
uint16 rowNum = (uint16)((flsAddr % CYDEV_FLS_SECTOR_SIZE) / CYDEV_FLS_ROW_SIZE);
uint32 baseAddr = address - (address % CYDEV_FLS_ROW_SIZE);
uint16 idx;
for (idx = 0u; idx < CYDEV_FLS_ROW_SIZE; idx++)
{
rowData[idx] = Bootloadable_GET_CODE_DATA(baseAddr + idx);
}
rowData[address % CYDEV_FLS_ROW_SIZE] = runType;
#if(CY_PSOC4)
(void) CySysFlashWriteRow((uint32)rowNum, rowData);
#else
(void) CyWriteRowData(arrayId, rowNum, rowData);
#endif /* (CY_PSOC4) */
}
/* [] END OF FILE */