2019-01-30 11:07:46 +01:00
|
|
|
|
|
|
|
#include <cc.h>
|
2017-10-25 20:28:13 +02:00
|
|
|
#include <kern.h>
|
|
|
|
#include <xmc4.h>
|
|
|
|
#include <bsp.h>
|
|
|
|
#include "esc_hw.h"
|
2019-01-30 11:07:46 +01:00
|
|
|
#include "esc.h"
|
|
|
|
#include "ecat_slv.h"
|
2017-10-25 20:28:13 +02:00
|
|
|
#include "config.h"
|
2019-01-30 11:07:46 +01:00
|
|
|
#include "utypes.h"
|
2017-10-25 20:28:13 +02:00
|
|
|
|
|
|
|
/**
|
2019-01-30 11:07:46 +01:00
|
|
|
* This function is called when to get input values
|
2017-10-25 20:28:13 +02:00
|
|
|
*/
|
2019-01-30 11:07:46 +01:00
|
|
|
void cb_get_inputs()
|
2017-10-25 20:28:13 +02:00
|
|
|
{
|
|
|
|
Rb.Buttons.Button1 = gpio_get(GPIO_BUTTON1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-01-30 11:07:46 +01:00
|
|
|
* This function is called when to set outputs values
|
2017-10-25 20:28:13 +02:00
|
|
|
*/
|
2019-01-30 11:07:46 +01:00
|
|
|
void cb_set_outputs()
|
2017-10-25 20:28:13 +02:00
|
|
|
{
|
|
|
|
gpio_set(GPIO_LED1, Wb.LEDgroup0.LED0);
|
|
|
|
gpio_set(GPIO_LED2, Wb.LEDgroup1.LED1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Optional: Hook called after state change for application specific
|
|
|
|
* actions for specific state changes.
|
|
|
|
*/
|
|
|
|
void post_state_change_hook (uint8_t * as, uint8_t * an)
|
|
|
|
{
|
|
|
|
/* Add specific step change hooks here */
|
2019-01-30 11:07:46 +01:00
|
|
|
if ((*as == SAFEOP_TO_OP))
|
2017-10-25 20:28:13 +02:00
|
|
|
{
|
2019-01-30 11:07:46 +01:00
|
|
|
ESC_ALeventmaskwrite(ESC_ALeventmaskread() | ESCREG_ALEVENT_WD);
|
2017-10-25 20:28:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-30 11:07:46 +01:00
|
|
|
void safe_out(void)
|
2017-10-25 20:28:13 +02:00
|
|
|
{
|
2019-01-30 11:07:46 +01:00
|
|
|
rprintp("safe out\n");
|
|
|
|
return;
|
2017-10-25 20:28:13 +02:00
|
|
|
}
|
|
|
|
|
2019-01-30 11:07:46 +01:00
|
|
|
/* Setup of DC */
|
|
|
|
uint16_t dc_checker(void)
|
2017-10-25 20:28:13 +02:00
|
|
|
{
|
2019-01-30 11:07:46 +01:00
|
|
|
/* Indicate we run DC */
|
|
|
|
ESCvar.dcsync = 1;
|
|
|
|
/* Fetch the sync counter limit SDO10F1*/
|
|
|
|
ESCvar.synccounterlimit = Mb.ErrorSettings.SyncErrorCounterLimit;
|
|
|
|
return 0;
|
2017-10-25 20:28:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Configuration parameters for SOES
|
|
|
|
* SM and Mailbox parameters comes from the
|
|
|
|
* generated config.h
|
|
|
|
*/
|
2019-01-30 11:07:46 +01:00
|
|
|
int main(void)
|
2017-10-25 20:28:13 +02:00
|
|
|
{
|
2019-01-30 11:07:46 +01:00
|
|
|
esc_cfg_t config =
|
2017-10-25 20:28:13 +02:00
|
|
|
{
|
2019-01-30 11:07:46 +01:00
|
|
|
.user_arg = NULL,
|
|
|
|
.use_interrupt = 1,
|
|
|
|
.watchdog_cnt = INT32_MAX, /* Use HW SM watchdog instead */
|
|
|
|
.mbxsize = MBXSIZE,
|
|
|
|
.mbxsizeboot = MBXSIZEBOOT,
|
|
|
|
.mbxbuffers = MBXBUFFERS,
|
|
|
|
.rxpdosaddress = &Wb,
|
|
|
|
.txpdosaddress = &Rb,
|
|
|
|
.mb[0] = {MBX0_sma, MBX0_sml, MBX0_sme, MBX0_smc, 0},
|
|
|
|
.mb[1] = {MBX1_sma, MBX1_sml, MBX1_sme, MBX1_smc, 0},
|
|
|
|
.mb_boot[0] = {MBX0_sma_b, MBX0_sml_b, MBX0_sme_b, MBX0_smc_b, 0},
|
|
|
|
.mb_boot[1] = {MBX1_sma_b, MBX1_sml_b, MBX1_sme_b, MBX1_smc_b, 0},
|
|
|
|
.pdosm[0] = {SM2_sma, 0, 0, SM2_smc, SM2_act},
|
|
|
|
.pdosm[1] = {SM3_sma, 0, 0, SM3_smc, SM3_act},
|
|
|
|
.pre_state_change_hook = NULL,
|
|
|
|
.post_state_change_hook = post_state_change_hook,
|
|
|
|
.application_hook = NULL,
|
|
|
|
.safeoutput_override = safe_out,
|
|
|
|
.pre_object_download_hook = NULL,
|
|
|
|
.post_object_download_hook = NULL,
|
|
|
|
.rxpdo_override = NULL,
|
|
|
|
.txpdo_override = NULL,
|
|
|
|
.esc_hw_interrupt_enable = ESC_interrupt_enable,
|
|
|
|
.esc_hw_interrupt_disable = ESC_interrupt_disable,
|
|
|
|
.esc_hw_eep_handler = ESC_eep_handler,
|
|
|
|
.esc_check_dc_handler = dc_checker
|
|
|
|
};
|
2017-10-25 20:28:13 +02:00
|
|
|
|
|
|
|
rprintf("Hello Main\n");
|
2019-01-30 11:07:46 +01:00
|
|
|
ecat_slv_init(&config);
|
2017-10-25 20:28:13 +02:00
|
|
|
return 0;
|
|
|
|
}
|