|
|
|
@ -23,10 +23,12 @@ |
|
|
|
#define LED_BLUE_PORT PORTC |
|
|
|
#define LED_BLUE_PORT PORTC |
|
|
|
#define LED_BLUE_PIN 2U |
|
|
|
#define LED_BLUE_PIN 2U |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* number of splitflaps that are connected / used. max 4. */ |
|
|
|
|
|
|
|
#define NUM_SF_USED 2 |
|
|
|
|
|
|
|
|
|
|
|
/* vars */ |
|
|
|
/* vars */ |
|
|
|
static McuLED_Handle_t LED_blue; |
|
|
|
static McuLED_Handle_t LED_blue; |
|
|
|
static SF_Handle_t splitflap0, splitflap1; |
|
|
|
static SF_Handle_t splitflap[NUM_SF_USED]; |
|
|
|
static uint32_t taskParameter1 = 5; |
|
|
|
static uint32_t taskParameter1 = 5; |
|
|
|
static TaskHandle_t appTaskHandle = NULL; |
|
|
|
static TaskHandle_t appTaskHandle = NULL; |
|
|
|
|
|
|
|
|
|
|
|
@ -46,9 +48,17 @@ void App_Init(void){ |
|
|
|
LED_blue = McuLED_InitLed(&config); |
|
|
|
LED_blue = McuLED_InitLed(&config); |
|
|
|
|
|
|
|
|
|
|
|
configureSplitflaps(); |
|
|
|
configureSplitflaps(); |
|
|
|
MultiSplitFlap_Init(2); |
|
|
|
MultiSplitFlap_Init(NUM_SF_USED); |
|
|
|
MultiSplitFlap_AddFlap(splitflap0); |
|
|
|
MultiSplitFlap_AddFlap(splitflap[0]); |
|
|
|
MultiSplitFlap_AddFlap(splitflap1); |
|
|
|
#if (NUM_SF_USED > 1) |
|
|
|
|
|
|
|
MultiSplitFlap_AddFlap(splitflap[1]); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#if (NUM_SF_USED > 2) |
|
|
|
|
|
|
|
MultiSplitFlap_AddFlap(splitflap[2]); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#if (NUM_SF_USED > 3) |
|
|
|
|
|
|
|
MultiSplitFlap_AddFlap(splitflap[3]); |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* App Task */ |
|
|
|
/* App Task */ |
|
|
|
@ -120,9 +130,9 @@ static void App_Task(void* pv){ |
|
|
|
while(1){ |
|
|
|
while(1){ |
|
|
|
for(int i = 0; i < sizeof(letters)/sizeof(letters[0]); i++){ |
|
|
|
for(int i = 0; i < sizeof(letters)/sizeof(letters[0]); i++){ |
|
|
|
McuWait_Waitms(1000); |
|
|
|
McuWait_Waitms(1000); |
|
|
|
McuLog_info("Moving to letter '%s', position is %i", letters[i], (int)SF_GetMotorPosition(splitflap0)); |
|
|
|
McuLog_info("Moving to letter '%s', position is %i", letters[i], (int)SF_GetMotorPosition(splitflap[0])); |
|
|
|
SF_MoveToFlap(splitflap0, letters[i]); |
|
|
|
SF_MoveToFlap(splitflap[0], letters[i]); |
|
|
|
McuLog_info("Position after move is is %i", (int)SF_GetMotorPosition(splitflap0)); |
|
|
|
McuLog_info("Position after move is is %i", (int)SF_GetMotorPosition(splitflap[0])); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -190,8 +200,9 @@ void configureSplitflaps(void){ |
|
|
|
sf0Config.motorConfig = motor0Config; |
|
|
|
sf0Config.motorConfig = motor0Config; |
|
|
|
|
|
|
|
|
|
|
|
/* instanciate splitflap 0 */ |
|
|
|
/* instanciate splitflap 0 */ |
|
|
|
splitflap0 = SF_Init(&sf0Config); |
|
|
|
splitflap[0] = SF_Init(&sf0Config); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if (NUM_SF_USED > 1) |
|
|
|
/* SPLITFLAP 1 */ |
|
|
|
/* SPLITFLAP 1 */ |
|
|
|
/* configure the motor */ |
|
|
|
/* configure the motor */ |
|
|
|
McuULN2003_Config_t motor1Config; |
|
|
|
McuULN2003_Config_t motor1Config; |
|
|
|
@ -210,7 +221,7 @@ void configureSplitflaps(void){ |
|
|
|
motor1Config.hw[3].pin = STEPPER_MOTOR1_IN4_PIN; |
|
|
|
motor1Config.hw[3].pin = STEPPER_MOTOR1_IN4_PIN; |
|
|
|
motor1Config.inverted = true; |
|
|
|
motor1Config.inverted = true; |
|
|
|
|
|
|
|
|
|
|
|
/* configure magnetic sensor for motor 0 */ |
|
|
|
/* configure magnetic sensor for motor 1 */ |
|
|
|
McuGPIO_Config_t magSensor1Config; |
|
|
|
McuGPIO_Config_t magSensor1Config; |
|
|
|
McuGPIO_GetDefaultConfig(&magSensor1Config); |
|
|
|
McuGPIO_GetDefaultConfig(&magSensor1Config); |
|
|
|
magSensor1Config.hw.gpio = MAG_MOTOR1_GPIO; |
|
|
|
magSensor1Config.hw.gpio = MAG_MOTOR1_GPIO; |
|
|
|
@ -219,7 +230,7 @@ void configureSplitflaps(void){ |
|
|
|
magSensor1Config.isInput = true; |
|
|
|
magSensor1Config.isInput = true; |
|
|
|
magSensor1Config.hw.pull = McuGPIO_PULL_UP; |
|
|
|
magSensor1Config.hw.pull = McuGPIO_PULL_UP; |
|
|
|
|
|
|
|
|
|
|
|
/* create config instance for splitflap 0 */ |
|
|
|
/* create config instance for splitflap 1 */ |
|
|
|
SF_Config_t sf1Config; |
|
|
|
SF_Config_t sf1Config; |
|
|
|
sf1Config.setupIdentifier = 1; |
|
|
|
sf1Config.setupIdentifier = 1; |
|
|
|
sf1Config.hardwareIdentifier = 20; // default value
|
|
|
|
sf1Config.hardwareIdentifier = 20; // default value
|
|
|
|
@ -227,5 +238,84 @@ void configureSplitflaps(void){ |
|
|
|
sf1Config.motorConfig = motor1Config; |
|
|
|
sf1Config.motorConfig = motor1Config; |
|
|
|
|
|
|
|
|
|
|
|
/* instanciate splitflap 1 */ |
|
|
|
/* instanciate splitflap 1 */ |
|
|
|
splitflap1 = SF_Init(&sf1Config); |
|
|
|
splitflap[1] = SF_Init(&sf1Config); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if (NUM_SF_USED > 2) |
|
|
|
|
|
|
|
/* SPLITFLAP 2 */ |
|
|
|
|
|
|
|
/* configure the motor */ |
|
|
|
|
|
|
|
McuULN2003_Config_t motor2Config; |
|
|
|
|
|
|
|
McuULN2003_GetDefaultConfig(&motor2Config); |
|
|
|
|
|
|
|
motor2Config.hw[0].gpio = STEPPER_MOTOR2_IN1_GPIO; |
|
|
|
|
|
|
|
motor2Config.hw[0].port = STEPPER_MOTOR2_IN1_PORT; |
|
|
|
|
|
|
|
motor2Config.hw[0].pin = STEPPER_MOTOR2_IN1_PIN; |
|
|
|
|
|
|
|
motor2Config.hw[1].gpio = STEPPER_MOTOR2_IN2_GPIO; |
|
|
|
|
|
|
|
motor2Config.hw[1].port = STEPPER_MOTOR2_IN2_PORT; |
|
|
|
|
|
|
|
motor2Config.hw[1].pin = STEPPER_MOTOR2_IN2_PIN; |
|
|
|
|
|
|
|
motor2Config.hw[2].gpio = STEPPER_MOTOR2_IN3_GPIO; |
|
|
|
|
|
|
|
motor2Config.hw[2].port = STEPPER_MOTOR2_IN3_PORT; |
|
|
|
|
|
|
|
motor2Config.hw[2].pin = STEPPER_MOTOR2_IN3_PIN; |
|
|
|
|
|
|
|
motor2Config.hw[3].gpio = STEPPER_MOTOR2_IN4_GPIO; |
|
|
|
|
|
|
|
motor2Config.hw[3].port = STEPPER_MOTOR2_IN4_PORT; |
|
|
|
|
|
|
|
motor2Config.hw[3].pin = STEPPER_MOTOR2_IN4_PIN; |
|
|
|
|
|
|
|
motor2Config.inverted = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* configure magnetic sensor for motor 2 */ |
|
|
|
|
|
|
|
McuGPIO_Config_t magSensor2Config; |
|
|
|
|
|
|
|
McuGPIO_GetDefaultConfig(&magSensor2Config); |
|
|
|
|
|
|
|
magSensor2Config.hw.gpio = MAG_MOTOR2_GPIO; |
|
|
|
|
|
|
|
magSensor2Config.hw.port = MAG_MOTOR2_PORT; |
|
|
|
|
|
|
|
magSensor2Config.hw.pin = MAG_MOTOR2_PIN; |
|
|
|
|
|
|
|
magSensor2Config.isInput = true; |
|
|
|
|
|
|
|
magSensor2Config.hw.pull = McuGPIO_PULL_UP; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* create config instance for splitflap 2 */ |
|
|
|
|
|
|
|
SF_Config_t sf2Config; |
|
|
|
|
|
|
|
sf2Config.setupIdentifier = 1; |
|
|
|
|
|
|
|
sf2Config.hardwareIdentifier = 20; // default value
|
|
|
|
|
|
|
|
sf2Config.magSensorConfig = magSensor2Config; |
|
|
|
|
|
|
|
sf2Config.motorConfig = motor2Config; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* instanciate splitflap 2 */ |
|
|
|
|
|
|
|
splitflap[2] = SF_Init(&sf2Config); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if (NUM_SF_USED > 3) |
|
|
|
|
|
|
|
/* SPLITFLAP 3 */ |
|
|
|
|
|
|
|
/* configure the motor */ |
|
|
|
|
|
|
|
McuULN2003_Config_t motor3Config; |
|
|
|
|
|
|
|
McuULN2003_GetDefaultConfig(&motor3Config); |
|
|
|
|
|
|
|
motor3Config.hw[0].gpio = STEPPER_MOTOR3_IN1_GPIO; |
|
|
|
|
|
|
|
motor3Config.hw[0].port = STEPPER_MOTOR3_IN1_PORT; |
|
|
|
|
|
|
|
motor3Config.hw[0].pin = STEPPER_MOTOR3_IN1_PIN; |
|
|
|
|
|
|
|
motor3Config.hw[1].gpio = STEPPER_MOTOR3_IN2_GPIO; |
|
|
|
|
|
|
|
motor3Config.hw[1].port = STEPPER_MOTOR3_IN2_PORT; |
|
|
|
|
|
|
|
motor3Config.hw[1].pin = STEPPER_MOTOR3_IN2_PIN; |
|
|
|
|
|
|
|
motor3Config.hw[2].gpio = STEPPER_MOTOR3_IN3_GPIO; |
|
|
|
|
|
|
|
motor3Config.hw[2].port = STEPPER_MOTOR3_IN3_PORT; |
|
|
|
|
|
|
|
motor3Config.hw[2].pin = STEPPER_MOTOR3_IN3_PIN; |
|
|
|
|
|
|
|
motor3Config.hw[3].gpio = STEPPER_MOTOR3_IN4_GPIO; |
|
|
|
|
|
|
|
motor3Config.hw[3].port = STEPPER_MOTOR3_IN4_PORT; |
|
|
|
|
|
|
|
motor3Config.hw[3].pin = STEPPER_MOTOR3_IN4_PIN; |
|
|
|
|
|
|
|
motor3Config.inverted = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* configure magnetic sensor for motor 3 */ |
|
|
|
|
|
|
|
McuGPIO_Config_t magSensor3Config; |
|
|
|
|
|
|
|
McuGPIO_GetDefaultConfig(&magSensor3Config); |
|
|
|
|
|
|
|
magSensor3Config.hw.gpio = MAG_MOTOR3_GPIO; |
|
|
|
|
|
|
|
magSensor3Config.hw.port = MAG_MOTOR3_PORT; |
|
|
|
|
|
|
|
magSensor3Config.hw.pin = MAG_MOTOR3_PIN; |
|
|
|
|
|
|
|
magSensor3Config.isInput = true; |
|
|
|
|
|
|
|
magSensor3Config.hw.pull = McuGPIO_PULL_UP; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* create config instance for splitflap 3 */ |
|
|
|
|
|
|
|
SF_Config_t sf3Config; |
|
|
|
|
|
|
|
sf3Config.setupIdentifier = 1; |
|
|
|
|
|
|
|
sf3Config.hardwareIdentifier = 20; // default value
|
|
|
|
|
|
|
|
sf3Config.magSensorConfig = magSensor3Config; |
|
|
|
|
|
|
|
sf3Config.motorConfig = motor3Config; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* instanciate splitflap 3 */ |
|
|
|
|
|
|
|
splitflap[3] = SF_Init(&sf3Config); |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|