/**************************************************************************//**
 * @file     isp_user.h
 * @brief    ISP Command header file
 * @version  0x34
 * @date     14, June, 2017
 *
 * @note
 * SPDX-License-Identifier: Apache-2.0
 * Copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
 ******************************************************************************/
#ifndef ISP_USER_H
#define ISP_USER_H

#define FW_VERSION                          0x32

#include "fmc_user.h"

#define CMD_UPDATE_APROM                0x000000A0
#define CMD_UPDATE_CONFIG               0x000000A1
#define CMD_READ_CONFIG                 0x000000A2
#define CMD_ERASE_ALL                       0x000000A3
#define CMD_SYNC_PACKNO                 0x000000A4
#define CMD_GET_FWVER                       0x000000A6
#define CMD_RUN_APROM                       0x000000AB
#define CMD_RUN_LDROM                       0x000000AC
#define CMD_RESET                               0x000000AD
#define CMD_CONNECT                         0x000000AE
#define CMD_DISCONNECT                  0x000000AF

#define CMD_GET_DEVICEID                0x000000B1

#define CMD_UPDATE_DATAFLASH        0x000000C3

#define CMD_RESEND_PACKET       0x000000FF

#define V6M_AIRCR_VECTKEY_DATA  0x05FA0000UL
#define V6M_AIRCR_SYSRESETREQ       0x00000004UL

extern void GetDataFlashInfo(uint32_t *addr, uint32_t *size);
extern uint32_t GetApromSize(void);
extern int ParseCmd(unsigned char *buffer, uint8_t len);
extern uint32_t g_apromSize, g_dataFlashAddr, g_dataFlashSize;

//extern __align(4) uint8_t usb_rcvbuf[];
//extern __align(4) uint8_t usb_sendbuf[];
//extern __align(4) uint8_t response_buff[64];

#ifdef __ICCARM__
#pragma data_alignment=4
extern uint8_t usb_rcvbuf[];
extern uint8_t usb_sendbuf[];
extern uint8_t response_buff[64];
#else
extern __attribute__((aligned(4))) uint8_t usb_rcvbuf[];
extern __attribute__((aligned(4))) uint8_t usb_sendbuf[];
extern __attribute__((aligned(4))) uint8_t response_buff[64];
#endif

extern uint8_t volatile bUsbDataReady;
#endif  // #ifndef ISP_USER_H
