Bootloadable_1.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*******************************************************************************
  2. * File Name: Bootloadable_1.c
  3. * Version 1.20
  4. *
  5. * Description:
  6. * Provides an API for the Bootloadable application. The API includes a
  7. * single function for starting bootloader.
  8. *
  9. ********************************************************************************
  10. * Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.
  11. * You may use this file only in accordance with the license, terms, conditions,
  12. * disclaimers, and limitations in the end user license agreement accompanying
  13. * the software package with which this file was provided.
  14. *******************************************************************************/
  15. #include "Bootloadable_1.h"
  16. /*******************************************************************************
  17. * Function Name: Bootloadable_1_Load
  18. ********************************************************************************
  19. * Summary:
  20. * Begins the bootloading algorithm, downloading a new ACD image from the host.
  21. *
  22. * Parameters:
  23. * None
  24. *
  25. * Returns:
  26. * This method will never return. It will load a new application and reset
  27. * the device.
  28. *
  29. *******************************************************************************/
  30. void Bootloadable_1_Load(void)
  31. {
  32. /* Schedule Bootloader to start after reset */
  33. Bootloadable_1_SET_RUN_TYPE(Bootloadable_1_START_BTLDR);
  34. CySoftwareReset();
  35. }
  36. /*******************************************************************************
  37. * Function Name: Bootloadable_1_SetFlashByte
  38. ********************************************************************************
  39. * Summary:
  40. * Sets byte at specified address in Flash.
  41. *
  42. * Parameters:
  43. * None
  44. *
  45. * Returns:
  46. * None
  47. *
  48. *******************************************************************************/
  49. void Bootloadable_1_SetFlashByte(uint32 address, uint8 runType)
  50. {
  51. uint32 flsAddr = address - CYDEV_FLASH_BASE;
  52. uint8 rowData[CYDEV_FLS_ROW_SIZE];
  53. #if !(CY_PSOC4)
  54. uint8 arrayId = (uint8)(flsAddr / CYDEV_FLS_SECTOR_SIZE);
  55. #endif /* !(CY_PSOC4) */
  56. uint16 rowNum = (uint16)((flsAddr % CYDEV_FLS_SECTOR_SIZE) / CYDEV_FLS_ROW_SIZE);
  57. uint32 baseAddr = address - (address % CYDEV_FLS_ROW_SIZE);
  58. uint16 idx;
  59. for (idx = 0u; idx < CYDEV_FLS_ROW_SIZE; idx++)
  60. {
  61. rowData[idx] = Bootloadable_1_GET_CODE_DATA(baseAddr + idx);
  62. }
  63. rowData[address % CYDEV_FLS_ROW_SIZE] = runType;
  64. #if(CY_PSOC4)
  65. (void) CySysFlashWriteRow((uint32)rowNum, rowData);
  66. #else
  67. (void) CyWriteRowData(arrayId, rowNum, rowData);
  68. #endif /* (CY_PSOC4) */
  69. }
  70. /* [] END OF FILE */