Line 67... |
Line 67... |
#include "debugprint.h"
|
#include "debugprint.h"
|
#ifdef DEBUG_LEVEL_ERROR
|
#ifdef DEBUG_LEVEL_ERROR
|
#include "ser.h"
|
#include "ser.h"
|
#endif
|
#endif
|
|
|
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
|
|
#define WATCHDOG_TIME 100 /**< time until the watchdog times out, 100 equals 1 second */
|
#define WATCHDOG_TIME 100 /**< time until the watchdog times out, 100 equals 1 second */
|
|
|
/* Global variables */
|
|
|
/* Global variables --------------------------------------------------------- */
|
|
|
|
/** watchdog counter variable (UNUSED) */
|
volatile uint8_t watchdog_count = WATCHDOG_TIME;
|
volatile uint8_t watchdog_count = WATCHDOG_TIME;
|
|
|
|
/** the filesize of an fpga configuration file, read from the bit file header */
|
idata int32_t file_size;
|
idata int32_t file_size;
|
|
|
|
/** stores the current used addres for spi flash access */
|
xdata uint32_t flash_adress;
|
xdata uint32_t flash_adress;
|
|
/** general pointer to pass the place where to read data to different
|
|
functions (normally endpoint buffer) */
|
xdata unsigned char *buffer;
|
xdata unsigned char *buffer;
|
xdata TMC_Response_Queue response_queue;
|
|
|
xdata TMC_Response_Queue response_queue; /**< buffer to hold the TMC response */
|
|
|
|
|
/** \brief with executing this function, we confirm that we handled the
|
/** \brief with executing this function, we confirm that we handled the
|
* endpoint 0 data and that we are ready to get new data (rearm the endpoint).
|
* endpoint 0 data and that we are ready to get new data (rearm the endpoint).
|
*/
|
*/
|
Line 112... |
Line 122... |
}
|
}
|
#endif
|
#endif
|
|
|
|
|
#ifdef USB_DFU_SUPPORT
|
#ifdef USB_DFU_SUPPORT
|
/** \brief this function writes the new firmware data in endpoint 0 to the I2C eeprom
|
/** \brief this function writes the new firmware data in endpoint 0 to the I2C \
|
* \note this function is only available when the DFU (device firware upgrade) class
|
* eeprom.
|
* support is enabled.
|
* \note this function is only available when the DFU (device firware upgrade) \
|
|
* class support is enabled.
|
*/
|
*/
|
uint8_t app_firmware_write (void)
|
uint8_t app_firmware_write (void)
|
{
|
{
|
static uint16_t eeprom_offset;
|
static uint16_t eeprom_offset;
|
|
|
Line 141... |
Line 152... |
|
|
|
|
/** \brief analyze the header from the fpga configuration file and compares the
|
/** \brief analyze the header from the fpga configuration file and compares the
|
* the fpga type with the on board fpga and returs the configuration file size.
|
* the fpga type with the on board fpga and returs the configuration file size.
|
*
|
*
|
* \param[in] xdata unsigned char *buffer pointer to the buffer to read from
|
* \param[in] *offset pointer to the offset, buffer[offset]
|
* (normally endpoint buffer)
|
|
* \param[in] idata uint16_t *offset pointer to the offset, buffer[offset]
|
|
* is the current position, anything before this is already consumed.
|
* is the current position, anything before this is already consumed.
|
* \param[in] idata uint16_t *byte_count pointer to the length of the whole
|
* \param[in] *byte_count pointer to the length of the whole buffer.
|
* buffer.
|
|
* \return returns non-zero if successful, else 0
|
* \return returns non-zero if successful, else 0
|
*/
|
*/
|
uint8_t app_check_fpga_type_from_header(/*xdata unsigned char *buffer,*/ \
|
uint8_t app_check_fpga_type_from_header(idata uint16_t *offset, \
|
idata uint16_t *offset, \
|
|
idata uint16_t *byte_count)
|
idata uint16_t *byte_count)
|
{
|
{
|
static xdata Fpga_Info fpga_file_header;
|
static xdata Fpga_Info fpga_file_header;
|
xdata char fpga_type[FPGA_TYPE_LEN];
|
xdata char fpga_type[FPGA_TYPE_LEN];
|
static int8_t continue_analyse;
|
static int8_t continue_analyse;
|
Line 215... |
Line 222... |
}
|
}
|
|
|
|
|
/** \brief function to configure an fpga with data from usb
|
/** \brief function to configure an fpga with data from usb
|
*
|
*
|
* \param[in] xdata unsigned char *buffer pointer to the buffer to read from
|
* \param[in] *offset pointer to the offset, buffer[offset]
|
* (normally endpoint buffer)
|
|
* \param[in] idata uint16_t *offset pointer to the offset, buffer[offset]
|
|
* is the current position, anything before this is already consumed.
|
* is the current position, anything before this is already consumed.
|
* \param[in] idata uint16_t *byte_count pointer to the length of the whole
|
* \param[in] *byte_count pointer to the length of the whole buffer.
|
* buffer.
|
|
* \return returns non-zero if successful, else 0
|
* \return returns non-zero if successful, else 0
|
*/
|
*/
|
uint8_t app_configure_fpga(/* xdata unsigned char *buffer,*/ \
|
uint8_t app_configure_fpga(idata uint16_t *offset, \
|
idata uint16_t *offset, \
|
|
idata uint16_t *byte_count)
|
idata uint16_t *byte_count)
|
{
|
{
|
/* Is this the first part of configuration? */
|
/* Is this the first part of configuration? */
|
if(usb_tmc_transfer.nbytes_rxd == 0) {
|
if(usb_tmc_transfer.nbytes_rxd == 0) {
|
/* setup all stuff */
|
/* setup all stuff */
|
Line 274... |
Line 277... |
}
|
}
|
|
|
|
|
/** \brief function to write an fpga configuration from usb to the spi flash
|
/** \brief function to write an fpga configuration from usb to the spi flash
|
*
|
*
|
* \detail The SPI flash is big enough to hold store two different fpga
|
* The SPI flash is big enough to hold store two different fpga
|
* configuration files. To handle this, we split the SPI flash address
|
* configuration files. To handle this, we split the SPI flash address
|
* space simply at the half. \n
|
* space simply at the half. \n
|
* The data structure in the SPI flash is really simple:\n
|
* The data structure in the SPI flash is really simple:\n
|
* \li 32bit file size value (little endian, as used by the fx2)
|
* \li 32bit file size value (little endian, as used by the fx2)
|
* \li binary data from the fpga configuration file
|
* \li binary data from the fpga configuration file
|
*
|
*
|
* \param[in] xdata unsigned char *buffer pointer to the buffer to read from
|
* \param[in] *offset pointer to the offset, buffer[offset]
|
* (normally endpoint buffer)
|
|
* \param[in] idata uint16_t *offset pointer to the offset, buffer[offset]
|
|
* is the current position, anything before this is already consumed.
|
* is the current position, anything before this is already consumed.
|
* \param[in] idata uint16_t *byte_count pointer to the length of the whole
|
* \param[in] *byte_count pointer to the length of the whole buffer.
|
* buffer.
|
|
* \return returns non-zero if successful, else 0
|
* \return returns non-zero if successful, else 0
|
*/
|
*/
|
uint8_t app_write_conf_to_flash(/* xdata unsigned char *buffer,*/ \
|
uint8_t app_write_conf_to_flash(idata uint16_t *offset, \
|
idata uint16_t *offset, \
|
|
idata uint16_t *byte_count)
|
idata uint16_t *byte_count)
|
{
|
{
|
idata uint16_t length;
|
idata uint16_t length;
|
xdata uint32_t local_uint32_var;
|
xdata uint32_t local_uint32_var;
|
xdata unsigned char *local_buffer_ptr;
|
xdata unsigned char *local_buffer_ptr;
|
Line 377... |
Line 376... |
return 1;
|
return 1;
|
}
|
}
|
|
|
|
|
/** \brief erases the desired file slot in spi flash
|
/** \brief erases the desired file slot in spi flash
|
* \detail send the erase command for one spi flash memory block and loop
|
*
|
|
* send the erase command for one spi flash memory block and loop
|
* through the main_loop untill we finished erasing the whole fpga
|
* through the main_loop untill we finished erasing the whole fpga
|
* configuration file slot.
|
* configuration file slot.
|
*
|
*
|
* \param[in] xdata unsigned char *buffer pointer to the buffer to read from
|
* \param[in] *offset pointer to the offset, buffer[offset]
|
* (normally endpoint buffer)
|
|
* \param[in] idata uint16_t *offset pointer to the offset, buffer[offset]
|
|
* is the current position, anything before this is already consumed.
|
* is the current position, anything before this is already consumed.
|
* \return returns non-zero if successful, else 0
|
* \return returns non-zero if successful, else 0
|
*
|
*
|
* \todo uncomment this function after finishing debuging, else no space left!
|
* \todo uncomment this function after finishing debuging, else no space left!
|
*/
|
*/
|
uint8_t app_gecko3com_flash_delete(/* uint8_t *buffer,*/ idata uint16_t *offset) {
|
uint8_t app_gecko3com_flash_delete(idata uint16_t *offset) {
|
|
|
xdata uint32_t flash_adress;
|
xdata uint32_t flash_adress;
|
xdata uint32_t local_uint32_var;
|
xdata uint32_t local_uint32_var;
|
char slot;
|
char slot;
|
|
|