summaryrefslogtreecommitdiff
path: root/boot_loader/bl_flash.h
diff options
context:
space:
mode:
authorYuval Adam <yuval@y3xz.com>2015-03-13 12:24:52 +0200
committerYuval Adam <yuval@y3xz.com>2015-03-13 12:24:52 +0200
commit4085ae3ddfbbf10c8ccbd3dccd43452c40a1fe40 (patch)
treeac63581949a49511136e7e9e47d265bfb4119b26 /boot_loader/bl_flash.h
parent788db64b8642bf31de6930d18a62177c64163ee0 (diff)
Add bootloader, nfclib and sensorlib
Diffstat (limited to 'boot_loader/bl_flash.h')
-rw-r--r--boot_loader/bl_flash.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/boot_loader/bl_flash.h b/boot_loader/bl_flash.h
new file mode 100644
index 0000000..4a23f00
--- /dev/null
+++ b/boot_loader/bl_flash.h
@@ -0,0 +1,127 @@
+//*****************************************************************************
+//
+// bl_flash.h - Flash programming functions used by the boot loader.
+//
+// Copyright (c) 2006-2014 Texas Instruments Incorporated. All rights reserved.
+// Software License Agreement
+//
+// Texas Instruments (TI) is supplying this software for use solely and
+// exclusively on TI's microcontroller products. The software is owned by
+// TI and/or its suppliers, and is protected under applicable copyright
+// laws. You may not combine this software with "viral" open-source
+// software in order to form a larger program.
+//
+// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
+// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
+// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
+// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+// DAMAGES, FOR ANY REASON WHATSOEVER.
+//
+// This is part of revision 2.1.0.12573 of the Tiva Firmware Development Package.
+//
+//*****************************************************************************
+
+#ifndef __BL_FLASH_H__
+#define __BL_FLASH_H__
+
+#include "driverlib/rom.h"
+
+//*****************************************************************************
+//
+// Basic functions for erasing and programming internal flash.
+//
+//*****************************************************************************
+extern void BLInternalFlashErase(uint32_t ui32Address);
+extern void BLInternalFlashProgram(uint32_t ui32DstAddr, uint8_t *pui8SrcData,
+ uint32_t ui32Length);
+extern uint32_t BLInternalFlashSizeGet(void);
+extern uint32_t BLInternalFlashStartAddrCheck(uint32_t ui32Addr,
+ uint32_t ui32ImgSize);
+extern uint32_t BLInternalFlashErrorCheck(void);
+extern void BLInternalFlashErrorClear(void);
+
+//*****************************************************************************
+//
+// If the user has not specified which flash programming functions to use,
+// default to the basic, internal flash functions on Sandstorm, Fury and
+// DustDevil parts or the ROM-resident function for Tempest-class parts.
+//
+//*****************************************************************************
+#ifndef BL_FLASH_ERASE_FN_HOOK
+#define BL_FLASH_ERASE_FN_HOOK(ui32Address) \
+ { \
+ HWREG(FLASH_FMA) = (ui32Address); \
+ HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_ERASE; \
+ while(HWREG(FLASH_FMC) & FLASH_FMC_ERASE) \
+ { \
+ } \
+ }
+#else
+extern void BL_FLASH_ERASE_FN_HOOK(uint32_t ui32Address);
+#endif
+
+#ifndef BL_FLASH_PROGRAM_FN_HOOK
+#ifdef ROM_FlashProgram
+#define BL_FLASH_PROGRAM_FN_HOOK(ui32DstAddr, pui8SrcData, ui32Length) \
+ ROM_FlashProgram((uint32_t *)pui8SrcData, ui32DstAddr, \
+ (((ui32Length) + 3) & ~3))
+#else
+#define BL_FLASH_PROGRAM_FN_HOOK(ui32DstAddr, pui8SrcData, ui32Length) \
+ { \
+ uint32_t ui32FlashProgLoop; \
+ \
+ for(ui32FlashProgLoop = 0; ui32FlashProgLoop < (ui32Length); \
+ ui32FlashProgLoop += 4) \
+ { \
+ HWREG(FLASH_FMA) = (ui32DstAddr) + ui32FlashProgLoop; \
+ HWREG(FLASH_FMD) = *(uint32_t *)((pui8SrcData) + \
+ ui32FlashProgLoop); \
+ HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_WRITE; \
+ while(HWREG(FLASH_FMC) & FLASH_FMC_WRITE) \
+ { \
+ } \
+ } \
+ }
+#endif
+#else
+extern uint32_t BL_FLASH_PROGRAM_FN_HOOK(uint32_t ui32DstAddr,
+ uint8_t *pui8SrcData,
+ uint32_t ui32Length);
+#endif
+
+#ifndef BL_FLASH_CL_ERR_FN_HOOK
+#define BL_FLASH_CL_ERR_FN_HOOK() HWREG(FLASH_FCMISC) = FLASH_FCMISC_AMISC
+#else
+extern void BL_FLASH_CL_ERR_FN_HOOK(void);
+#endif
+
+#ifndef BL_FLASH_ERROR_FN_HOOK
+#define BL_FLASH_ERROR_FN_HOOK() (HWREG(FLASH_FCRIS) & FLASH_FCRIS_ARIS)
+#else
+extern uint32_t BL_FLASH_ERROR_FN_HOOK(void);
+#endif
+
+#ifndef BL_FLASH_SIZE_FN_HOOK
+#define BL_FLASH_SIZE_FN_HOOK() \
+ (((HWREG(SYSCTL_DC0) & SYSCTL_DC0_FLASHSZ_M) + 1) << 11)
+#else
+extern uint32_t BL_FLASH_SIZE_FN_HOOK(void);
+#endif
+
+#ifndef BL_FLASH_END_FN_HOOK
+#define BL_FLASH_END_FN_HOOK() \
+ (((HWREG(SYSCTL_DC0) & SYSCTL_DC0_FLASHSZ_M) + 1) << 11)
+#else
+extern uint32_t BL_FLASH_END_FN_HOOK(void);
+#endif
+
+#ifndef BL_FLASH_AD_CHECK_FN_HOOK
+#define BL_FLASH_AD_CHECK_FN_HOOK(ui32Addr, ui32Size) \
+ BLInternalFlashStartAddrCheck((ui32Addr), (ui32Size))
+#else
+extern uint32_t BL_FLASH_AD_CHECK_FN_HOOK(uint32_t ui32Address,
+ uint32_t ui32Length);
+#endif
+
+#endif // __BL_FLASH_H__