added xmc4 HAL driver

pull/13/head
Sascha Ittner 2016-08-26 17:42:35 +02:00
parent 24bdcc5c98
commit 31f390bca0
3 changed files with 697 additions and 0 deletions

View File

@ -0,0 +1,235 @@
/*
* SOES Simple Open EtherCAT Slave
*
* File : esc_hw.c
* Version : 0.9.2
* Date : 22-02-2010
* Copyright (C) 2007-2013 Arthur Ketels
* Copyright (C) 2012-2013 rt-labs
*
* SOES is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* SOES is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* As a special exception, if other files instantiate templates or use macros
* or inline functions from this file, or you compile this file and link it
* with other works to produce a work based on this file, this file does not
* by itself cause the resulting work to be covered by the GNU General Public
* License. However the source code for this file must still be made available
* in accordance with section (3) of the GNU General Public License.
*
* This exception does not invalidate any other reasons why a work based on
* this file might be covered by the GNU General Public License.
*
* The EtherCAT Technology, the trade name and logo "EtherCAT" are the intellectual
* property of, and protected by Beckhoff Automation GmbH.
*/
/** \file
* \brief
* ESC hardware layer functions.
*
* Function to read and write commands to the ESC. Used to read/write ESC
* registers and memory.
*/
#include "esc.h"
#include "esc_eep.h"
#include "xmc_gpio.h"
#include "xmc_ecat.h"
/* ESC to PHY interconnect setup */
#define ECAT_MDO P0_12
#define ECAT_MCLK P3_3
#define ECAT_CLK25 P1_13
#define ECAT_PHY_RESET P2_10
#define ECAT_LED_RUN P1_11
#define ECAT_LED_ERR P1_10
#define ECAT_P0_LINK_STATUS P1_15
#define ECAT_P0_LED_LINK_ACT P1_12
#define ECAT_P0_RXD3 P5_7
#define ECAT_P0_RXD2 P5_2
#define ECAT_P0_RXD1 P5_1
#define ECAT_P0_RXD0 P1_4
#define ECAT_P0_RX_DV P1_9
#define ECAT_P0_RX_CLK P1_1
#define ECAT_P0_RX_ERR P2_6
#define ECAT_P0_TXD3 P1_2
#define ECAT_P0_TXD2 P1_8
#define ECAT_P0_TXD1 P1_7
#define ECAT_P0_TXD0 P1_6
#define ECAT_P0_TX_EN P1_3
#define ECAT_P0_TX_CLK P1_0
#define ECAT_P1_LINK_STATUS P15_3
#define ECAT_P1_LED_LINK_ACT P0_11
#define ECAT_P1_RXD3 P14_14
#define ECAT_P1_RXD2 P14_13
#define ECAT_P1_RXD1 P14_12
#define ECAT_P1_RXD0 P14_7
#define ECAT_P1_RX_DV P14_15
#define ECAT_P1_RX_CLK P14_6
#define ECAT_P1_RX_ERR P15_2
#define ECAT_P1_TXD3 P0_3
#define ECAT_P1_TXD2 P0_2
#define ECAT_P1_TXD1 P3_2
#define ECAT_P1_TXD0 P3_1
#define ECAT_P1_TX_EN P3_0
#define ECAT_P1_TX_CLK P0_10
#define ESCADDR(x) (((uint8_t *) ECAT0_BASE) + x)
static const XMC_ECAT_PORT_CTRL_t port_control = {
.common = {
.mdio = XMC_ECAT_PORT_CTRL_MDIO_P0_12
},
.port0 = {
.rxd0 = XMC_ECAT_PORT0_CTRL_RXD0_P1_4,
.rxd1 = XMC_ECAT_PORT0_CTRL_RXD1_P5_1,
.rxd2 = XMC_ECAT_PORT0_CTRL_RXD2_P5_2,
.rxd3 = XMC_ECAT_PORT0_CTRL_RXD3_P5_7,
.rx_clk = XMC_ECAT_PORT0_CTRL_RX_CLK_P1_1,
.rx_dv = XMC_ECAT_PORT0_CTRL_RX_DV_P1_9,
.rx_err = XMC_ECAT_PORT0_CTRL_RX_ERR_P2_6,
.link = XMC_ECAT_PORT0_CTRL_LINK_P1_15,
.tx_clk = XMC_ECAT_PORT0_CTRL_TX_CLK_P1_0
},
.port1 = {
.rxd0 = XMC_ECAT_PORT1_CTRL_RXD0_P14_7,
.rxd1 = XMC_ECAT_PORT1_CTRL_RXD1_P14_12,
.rxd2 = XMC_ECAT_PORT1_CTRL_RXD2_P14_13,
.rxd3 = XMC_ECAT_PORT1_CTRL_RXD3_P14_14,
.rx_clk = XMC_ECAT_PORT1_CTRL_RX_CLK_P14_6,
.rx_dv = XMC_ECAT_PORT1_CTRL_RX_DV_P14_15,
.rx_err = XMC_ECAT_PORT1_CTRL_RX_ERR_P15_2,
.link = XMC_ECAT_PORT1_CTRL_LINK_P15_3,
.tx_clk = XMC_ECAT_PORT1_CTRL_TX_CLK_P0_10
}
};
static const XMC_GPIO_CONFIG_t gpio_config_input = {
.mode = XMC_GPIO_MODE_INPUT_TRISTATE,
.output_level = 0,
.output_strength = 0
};
static void init_input(XMC_GPIO_PORT_t *const port, const uint8_t pin)
{
XMC_GPIO_Init(port, pin, &gpio_config_input);
}
static void init_output(XMC_GPIO_PORT_t *const port, const uint8_t pin,
uint32_t function, XMC_GPIO_OUTPUT_STRENGTH_t strength)
{
XMC_GPIO_CONFIG_t config;
config.mode = (XMC_GPIO_MODE_t)((uint32_t)XMC_GPIO_MODE_OUTPUT_PUSH_PULL | function);
config.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW;
config.output_strength = strength;
XMC_GPIO_Init(port, pin, &config);
}
#define init_output_sharp(pin, function) init_output(pin, function, XMC_GPIO_OUTPUT_STRENGTH_STRONG_SHARP_EDGE);
#define init_output_soft(pin, function) init_output(pin, function, XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE);
/** ESC read function used by the Slave stack.
*
* @param[in] address = address of ESC register to read
* @param[out] buf = pointer to buffer to read in
* @param[in] len = number of bytes to read
*/
void ESC_read (uint16_t address, void *buf, uint16_t len)
{
ESCvar.ALevent = etohs ((uint16_t)ECAT0->AL_EVENT_REQ);
memcpy (buf, ESCADDR(address), len);
}
/** ESC write function used by the Slave stack.
*
* @param[in] address = address of ESC register to write
* @param[out] buf = pointer to buffer to write from
* @param[in] len = number of bytes to write
*/
void ESC_write (uint16_t address, void *buf, uint16_t len)
{
ESCvar.ALevent = etohs ((uint16_t)ECAT0->AL_EVENT_REQ);
memcpy(ESCADDR(address), buf, len);
}
void ESC_reset (void)
{
/* disable ESC to force reset */
XMC_ECAT_Disable();
/* initialize EEPROM emulation */
EEP_init();
}
void ESC_init (const void * arg)
{
XMC_ECAT_CONFIG_t ecat_config;
/* configure inputs */
init_input(ECAT_P0_LINK_STATUS);
init_input(ECAT_P0_RXD3);
init_input(ECAT_P0_RXD2);
init_input(ECAT_P0_RXD1);
init_input(ECAT_P0_RXD0);
init_input(ECAT_P0_RX_DV);
init_input(ECAT_P0_RX_CLK);
init_input(ECAT_P0_RX_ERR);
init_input(ECAT_P0_TX_CLK);
init_input(ECAT_P1_LINK_STATUS);
init_input(ECAT_P1_RXD3);
init_input(ECAT_P1_RXD2);
init_input(ECAT_P1_RXD1);
init_input(ECAT_P1_RXD0);
init_input(ECAT_P1_RX_DV);
init_input(ECAT_P1_RX_CLK);
init_input(ECAT_P1_RX_ERR);
init_input(ECAT_P1_TX_CLK);
init_input(ECAT_MDO);
XMC_ECAT_SetPortControl(port_control);
/* read config from emulated EEPROM */
memset(&ecat_config, 0, sizeof(XMC_ECAT_CONFIG_t));
EEP_read (0, (uint8_t *) &ecat_config, sizeof(XMC_ECAT_CONFIG_t));
XMC_ECAT_Init(&ecat_config);
/* configure outputs */
init_output_sharp(ECAT_P0_TXD3, P1_2_AF_ECAT0_P0_TXD3);
init_output_sharp(ECAT_P0_TXD2, P1_8_AF_ECAT0_P0_TXD2);
init_output_sharp(ECAT_P0_TXD1, P1_7_AF_ECAT0_P0_TXD1);
init_output_sharp(ECAT_P0_TXD0, P1_6_AF_ECAT0_P0_TXD0);
init_output_sharp(ECAT_P0_TX_EN, P1_3_AF_ECAT0_P0_TX_ENA);
init_output_sharp(ECAT_P1_TXD3, P0_3_AF_ECAT0_P1_TXD3);
init_output_sharp(ECAT_P1_TXD2, P0_2_AF_ECAT0_P1_TXD2);
init_output_sharp(ECAT_P1_TXD1, P3_2_AF_ECAT0_P1_TXD1);
init_output_sharp(ECAT_P1_TXD0, P3_1_AF_ECAT0_P1_TXD0);
init_output_sharp(ECAT_P1_TX_EN, P3_0_AF_ECAT0_P1_TX_ENA);
init_output_sharp(ECAT_CLK25, P1_13_AF_ECAT0_PHY_CLK25);
init_output_sharp(ECAT_MCLK, P3_3_AF_ECAT0_MCLK);
init_output_soft(ECAT_P0_LED_LINK_ACT, P1_12_AF_ECAT0_P0_LED_LINK_ACT);
init_output_soft(ECAT_P1_LED_LINK_ACT, P0_11_AF_ECAT0_P1_LED_LINK_ACT);
init_output_soft(ECAT_LED_RUN, P1_11_AF_ECAT0_LED_RUN);
init_output_soft(ECAT_LED_ERR, P1_10_AF_ECAT0_LED_ERR);
XMC_GPIO_SetHardwareControl(ECAT_MDO, P0_12_HWCTRL_ECAT0_MDO);
init_output_soft(ECAT_PHY_RESET, P2_10_AF_ECAT0_PHY_RESET);
}

View File

@ -0,0 +1,369 @@
/*
* SOES Simple Open EtherCAT Slave
*
* File : esc_hw_eep.c
* Version : 1.0.0
* Date : 26-08-2016
* Copyright (C) 2016 Sascha Ittner
*
* SOES is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* SOES is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* As a special exception, if other files instantiate templates or use macros
* or inline functions from this file, or you compile this file and link it
* with other works to produce a work based on this file, this file does not
* by itself cause the resulting work to be covered by the GNU General Public
* License. However the source code for this file must still be made available
* in accordance with section (3) of the GNU General Public License.
*
* This exception does not invalidate any other reasons why a work based on
* this file might be covered by the GNU General Public License.
*
* The EtherCAT Technology, the trade name and logo "EtherCAT" are the intellectual
* property of, and protected by Beckhoff Automation GmbH.
*/
/** \file
* \brief
* ESC hardware specific EEPROM emulation functions.
*/
#include "cc.h"
#include "esc.h"
#include "esc_hw_eep.h"
#include <string.h>
#include "sii_eeprom.h"
#if EEP_BYTES_PER_BLOCK > EEP_BYTES_PER_SECTOR
#error EEP_BYTES_PER_BLOCK needs to fit into EEP_BYTES_PER_SECTOR
#endif
static const XMC_FCE_t fce_config =
{
.kernel_ptr = EPP_FCE_CRC32,
.fce_cfg_update.config_refin = XMC_FCE_REFIN_RESET,
.fce_cfg_update.config_refout = XMC_FCE_REFOUT_RESET,
.fce_cfg_update.config_xsel = XMC_FCE_INVSEL_RESET,
.seedvalue = 0
};
static uint8_t eep_buf[EEP_EMU_BYTES];
static uint8_t eep_buf_dirty;
static uint32_t eep_last_write;
static uint8_t eep_write_req;
static eep_block_t *eep_curr_block;
static eep_block_t *eep_next_block;
static uint32_t *eep_write_src;
static uint32_t *eep_write_dst;
static uint32_t eep_write_page;
static eep_block_t eep_write_buf;
static void init_flash_data(void);
static void find_latest_block(eep_block_t *addr);
static eep_block_t *get_next_block(eep_block_t *block);
static eep_block_t *cleanup_unused_sect(eep_block_t *block);
static int32_t is_sector_empty(uint32_t *addr);
static uint32_t crc32(const uint8_t *data, uint32_t length);
#ifdef EEP_DEFAULT_BTN
static const XMC_GPIO_CONFIG_t gpio_config_btn = {
.mode = XMC_GPIO_MODE_INPUT_INVERTED_PULL_UP,
.output_level = 0,
.output_strength = 0
};
#define EEP_DEFAULT_BTN_INIT() XMC_GPIO_Init(EEP_DEFAULT_BTN, &gpio_config_btn)
#define EEP_DEFAULT_BTN_STATE() XMC_GPIO_GetInput(EEP_DEFAULT_BTN)
#else
#define EEP_DEFAULT_BTN_INIT() { }
#define EEP_DEFAULT_BTN_STATE() 0
#endif
#ifdef EEP_BUSY_LED
static const XMC_GPIO_CONFIG_t gpio_config_led = {
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW,
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE
};
#define EEP_BUSY_LED_INIT() XMC_GPIO_Init(EEP_BUSY_LED, &gpio_config_led)
#define EEP_BUSY_LED_ON() XMC_GPIO_SetOutputHigh(EEP_BUSY_LED)
#define EEP_BUSY_LED_OFF() XMC_GPIO_SetOutputLow(EEP_BUSY_LED)
#else
#define EEP_BUSY_LED_INIT() { }
#define EEP_BUSY_LED_ON() { }
#define EEP_BUSY_LED_OFF() { }
#endif
/** Initialize EEPROM emulation (load default data, validate checksums, ...).
*
*/
void EEP_init (void)
{
/* initialize write buffer */
memset(&eep_write_buf, 0, EEP_BYTES_PER_BLOCK);
/* configure I/Os */
EEP_DEFAULT_BTN_INIT();
EEP_BUSY_LED_INIT();
/* Enable FCE module */
XMC_FCE_Enable();
/* Initialize the FCE Configuration */
XMC_FCE_Init(&fce_config);
/* try to find latest block in both sectors */
eep_curr_block = NULL;
if (!EEP_DEFAULT_BTN_STATE()) {
find_latest_block((eep_block_t *) EEP_SECTOR_A);
find_latest_block((eep_block_t *) EEP_SECTOR_B);
}
EEP_BUSY_LED_ON();
/* no valid block found -> initialize flash with default data */
if (eep_curr_block == NULL) {
init_flash_data();
}
/* cleanup unused block */
cleanup_unused_sect(eep_curr_block);
/* copy data from block to emu buffer */
memcpy(eep_buf, eep_curr_block->data, EEP_EMU_BYTES);
EEP_BUSY_LED_OFF();
/* initialize state variables */
eep_buf_dirty = 0;
eep_last_write = 0;
eep_write_req = 0;
eep_next_block = NULL;
}
/** EEPROM emulation controller side periodic task.
*
*/
void EEP_hw_process (void)
{
/* check for dirty buffer and set write */
if (eep_buf_dirty) {
int32_t idle_time = ((int32_t) ESCvar.Time) - ((int32_t) eep_last_write);
if (idle_time > EEP_IDLE_TIMEOUT) {
eep_buf_dirty = 0;
eep_write_req = 1;
}
}
/* check for write process */
if (eep_next_block != NULL) {
/* write flash page */
XMC_FLASH_ProgramPage(eep_write_dst, eep_write_src);
eep_write_src += XMC_FLASH_WORDS_PER_PAGE;
eep_write_dst += XMC_FLASH_WORDS_PER_PAGE;
/* update counter */
eep_write_page++;
/* check for finished job */
if (eep_write_page >= EEP_PAGES_PER_BLOCK) {
/* update block pointer and reset write state */
eep_curr_block = eep_next_block;
eep_next_block = NULL;
EEP_BUSY_LED_OFF();
}
return;
}
/* start write of new block */
if (eep_write_req) {
EEP_BUSY_LED_ON();
/* get next block */
eep_next_block = get_next_block(eep_curr_block);
/* copy data */
memcpy(eep_write_buf.data, eep_buf, EEP_EMU_BYTES);
/* setup header */
eep_write_buf.header.seq = eep_curr_block->header.seq + 1;
eep_write_buf.header.crc = crc32 (eep_write_buf.data, EEP_DATA_BYTES);
/* initialize write position */
eep_write_src = (uint32_t *) &eep_write_buf;
eep_write_dst = (uint32_t *) eep_next_block;
eep_write_page = 0;
/* reset write request */
eep_write_req = 0;
}
}
/** EEPROM read function
*
* @param[in] addr = EEPROM byte address
* @param[out] data = pointer to buffer of output data
* @param[in] count = number of bytes to read
* @return 0 on OK, 1 on error
*/
int8_t EEP_read (uint32_t addr, uint8_t *data, uint16_t count)
{
if (addr >= EEP_EMU_BYTES) {
return 1;
}
/* read data from ram buffer */
memcpy(data, eep_buf + addr, count);
return 0;
}
/** EEPROM write function
*
* @param[in] addr = EEPROM byte address
* @param[out] data = pointer to buffer of input data
* @param[in] count = number of bytes to write
* @return 0 on OK, 1 on error
*/
int8_t EEP_write (uint32_t addr, uint8_t *data, uint16_t count)
{
if (addr >= EEP_EMU_BYTES) {
return 1;
}
/* write data to ram buffer */
memcpy(eep_buf + addr, data, count);
/* mark buffer as dirty */
eep_buf_dirty = 1;
eep_write_req = 0;
eep_last_write = ESCvar.Time;
return 0;
}
static void init_flash_data(void)
{
uint32_t i;
const uint32_t *src;
uint32_t *dst;
/* erase both sectors */
XMC_FLASH_EraseSector(EEP_SECTOR_A);
XMC_FLASH_EraseSector(EEP_SECTOR_B);
/* copy default data to write buffer */
memcpy(eep_write_buf.data, SII_EE_DEFLT, (SII_EE_DEFLT_SIZE < EEP_EMU_BYTES) ? SII_EE_DEFLT_SIZE : EEP_EMU_BYTES);
/* setup header data */
eep_write_buf.header.seq = 0;
eep_write_buf.header.crc = crc32 (eep_write_buf.data, EEP_DATA_BYTES);
/* write pages */
src = (const uint32_t *) &eep_write_buf;
dst = EEP_SECTOR_A;
for (i = 0; i < EEP_PAGES_PER_BLOCK; i++) {
XMC_FLASH_ProgramPage(dst, src);
src += XMC_FLASH_WORDS_PER_PAGE;
dst += XMC_FLASH_WORDS_PER_PAGE;
}
/* set current block */
eep_curr_block = (eep_block_t *) EEP_SECTOR_A;
}
static void find_latest_block(eep_block_t *addr)
{
uint32_t blk, crc;
for (blk = 0; blk < EPP_BLOCKS_PER_SECT; blk++, addr++) {
/* check crc, skip invalid blocks */
crc = crc32 (addr->data, EEP_DATA_BYTES);
if (addr->header.crc != crc) {
continue;
}
/* check sequence number and update last pointer */
if (eep_curr_block == NULL || (addr->header.seq - eep_curr_block->header.seq) > 0) {
eep_curr_block = addr;
}
}
}
static eep_block_t *get_next_block(eep_block_t *block)
{
/* simple case: new block fits in current sector */
uint32_t sect_offset = ((uint32_t)block) & (EEP_BYTES_PER_SECTOR - 1);
if ((sect_offset + EEP_BYTES_PER_BLOCK) < EEP_BYTES_PER_SECTOR) {
return block + 1;
}
/* use other sector */
return cleanup_unused_sect(block);
}
static eep_block_t *cleanup_unused_sect(eep_block_t *block)
{
/* get other sector */
uint32_t *sect_addr = (uint32_t *) (((uint32_t)block) & ~(EEP_BYTES_PER_SECTOR - 1));
if (sect_addr == EEP_SECTOR_A) {
sect_addr = EEP_SECTOR_B;
} else {
sect_addr = EEP_SECTOR_A;
}
/* check if sector is empty, erase if not */
if (!is_sector_empty(sect_addr)) {
XMC_FLASH_EraseSector(sect_addr);
}
return (eep_block_t *) sect_addr;
}
static int32_t is_sector_empty(uint32_t *addr)
{
uint32_t i;
/* check for all bytes erased */
for (i=0; i<EEP_BYTES_PER_SECTOR; i+=sizeof(uint32_t), addr++) {
if (*addr != 0) {
return 0;
}
}
return 1;
}
static uint32_t crc32(const uint8_t *data, uint32_t length)
{
uint32_t crc;
XMC_FCE_InitializeSeedValue(&fce_config, 0xffffffff);
XMC_FCE_CalculateCRC32(&fce_config, (const uint32_t *) data, length & ~3L, &crc);
XMC_FCE_GetCRCResult(&fce_config, &crc);
return crc;
}

View File

@ -0,0 +1,93 @@
/*
* SOES Simple Open EtherCAT Slave
*
* File : esc_hw_eep.h
* Version : 1.0.0
* Date : 26-08-2016
* Copyright (C) 2016 Sascha Ittner
*
* SOES is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* SOES is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* As a special exception, if other files instantiate templates or use macros
* or inline functions from this file, or you compile this file and link it
* with other works to produce a work based on this file, this file does not
* by itself cause the resulting work to be covered by the GNU General Public
* License. However the source code for this file must still be made available
* in accordance with section (3) of the GNU General Public License.
*
* This exception does not invalidate any other reasons why a work based on
* this file might be covered by the GNU General Public License.
*
* The EtherCAT Technology, the trade name and logo "EtherCAT" are the intellectual
* property of, and protected by Beckhoff Automation GmbH.
*/
/** \file
* \brief
* ESC hardware specifoc EEPROM emulation functions.
*/
#ifndef __esc_hw_eep__
#define __esc_hw_eep__
#include "cc.h"
#include "esc_eep.h"
#include "xmc_gpio.h"
#include "xmc_flash.h"
#include "xmc_fce.h"
/* if defined: reload default EEPROM content if pulled low */
#define EEP_DEFAULT_BTN P3_4
/* if defined: flash BUSY indicator */
#define EEP_BUSY_LED P4_0
/* used CRC32 kernel for checksum calculation */
#define EPP_FCE_CRC32 XMC_FCE_CRC32_0
/* idle timeout in ns before actual flash write will be issued */
#define EEP_IDLE_TIMEOUT 100000000
/* Packes per emulated EEPROM block*/
#define EEP_PAGES_PER_BLOCK 16
/* flash sector select */
#define EEP_BYTES_PER_SECTOR 0x04000
#define EEP_SECTOR_A XMC_FLASH_SECTOR_6
#define EEP_SECTOR_B XMC_FLASH_SECTOR_7
/* block header */
typedef struct CC_PACKED
{
int32_t seq;
uint32_t crc;
} eep_header_t;
/* calulate resulting sizes */
#define EEP_BYTES_PER_BLOCK (EEP_PAGES_PER_BLOCK * XMC_FLASH_BYTES_PER_PAGE)
#define EPP_BLOCKS_PER_SECT (EEP_BYTES_PER_SECTOR / EEP_BYTES_PER_BLOCK)
#define EEP_DATA_BYTES (EEP_BYTES_PER_BLOCK - sizeof(eep_header_t))
/* eeprom size increments in steps of 0x80 bytes */
#define EEP_EMU_BYTES (EEP_DATA_BYTES & ~0x7f)
/* block structure */
typedef struct CC_PACKED
{
eep_header_t header;
uint8_t data[EEP_DATA_BYTES];
} eep_block_t;
/* periodic task */
void EEP_hw_process (void);
#endif