#define S_FILE_DATA_OFFSET 0x200000
+#define TIME_DIV_FREESCALE 0.3
//----------------------------------------------------------------
// JTAG
#define DSP5680XX_JTAG_CORE_TAP_IRLEN 4
#define DSP5680XX_JTAG_MASTER_TAP_IRLEN 8
-#define JTAG_STATUS_MASK 0x03
+#define JTAG_STATUS_MASK 0x0F
#define JTAG_STATUS_NORMAL 0x01
#define JTAG_STATUS_STOPWAIT 0x05
* This value was calculated using a spreadsheet tool available on the Freescale website under FAQ 25464.
*
*/
-#define HFM_CLK_DEFAULT 0x40
+#define HFM_CLK_DEFAULT 0x27
+/* 0x27 according to freescale cfg, but 0x40 according to freescale spreadsheet... */
#define HFM_FLASH_BASE_ADDR 0x0
#define HFM_SIZE_BYTES 0x4000 // bytes
#define HFM_SIZE_WORDS 0x2000 // words
#define SIM_CMD_RESET 0x10
//----------------------------------------------------------------
+/**
+ * ----------------------------------------------------------------
+ * ERROR codes - enable automatic parsing of output
+ * ----------------------------------------------------------------
+ */
+#define DSP5680XX_ERROR_UNKNOWN_OR_ERROR_OPENOCD -100
+#define DSP5680XX_ERROR_JTAG_COMM -1
+#define DSP5680XX_ERROR_JTAG_RESET -2
+#define DSP5680XX_ERROR_JTAG_INVALID_TAP -3
+#define DSP5680XX_ERROR_JTAG_DR_LEN_OVERFLOW -4
+#define DSP5680XX_ERROR_INVALID_IR_LEN -5
+#define DSP5680XX_ERROR_JTAG_TAP_ENABLE_MASTER -6
+#define DSP5680XX_ERROR_JTAG_TAP_ENABLE_CORE -7
+#define DSP5680XX_ERROR_JTAG_TAP_FIND_MASTER -8
+#define DSP5680XX_ERROR_JTAG_TAP_FIND_CORE -9
+#define DSP5680XX_ERROR_JTAG_DRSCAN -10
+#define DSP5680XX_ERROR_JTAG_IRSCAN -11
+#define DSP5680XX_ERROR_ENTER_DEBUG_MODE -12
+#define DSP5680XX_ERROR_RESUME -13
+#define DSP5680XX_ERROR_WRITE_WITH_TARGET_RUNNING -14
+#define DSP5680XX_ERROR_INVALID_DATA_SIZE_UNIT -15
+#define DSP5680XX_ERROR_PROTECT_CHECK_INVALID_ARGS -16
+#define DSP5680XX_ERROR_FM_BUSY -17
+#define DSP5680XX_ERROR_FM_CMD_TIMED_OUT -18
+#define DSP5680XX_ERROR_FM_EXEC -19
+#define DSP5680XX_ERROR_FM_SET_CLK -20
+#define DSP5680XX_ERROR_FLASHING_INVALID_WORD_COUNT -21
+#define DSP5680XX_ERROR_FLASHING_CRC -22
+#define DSP5680XX_ERROR_FLASHING -23
+#define DSP5680XX_ERROR_NOT_IMPLEMENTED_STEP -24
+#define DSP5680XX_ERROR_HALT -25
+#define DSP5680XX_ERROR_EXIT_DEBUG_MODE -26
+#define DSP5680XX_ERROR_TARGET_RUNNING -27
+#define DSP5680XX_ERROR_NOT_IN_DEBUG -28
+/**
+ * ----------------------------------------------------------------
+ */
+
struct dsp5680xx_common{
//TODO
uint32_t stored_pc;
int flush;
+bool debug_mode_enabled;
};
extern struct dsp5680xx_common dsp5680xx_context;
* @param buffer
* @param address Word addressing.
* @param count In bytes.
+ * @param verify_flash Execute a CRC check after flashing.
*
* @return
*/
-int dsp5680xx_f_wr(struct target * target, uint8_t *buffer, uint32_t address, uint32_t count);
+int dsp5680xx_f_wr(struct target * target, uint8_t *buffer, uint32_t address, uint32_t count, int is_flash_lock);
/**
* The FM has the funcionality of checking if the flash array is erased. This function executes it. It does not support individual sector analysis.