progress on 3
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#Startup file
|
||||
SRC += $(SRC_DIR)/ucos_v1_42/ucos/bsp/src/$(ARCH)/asm_vectors.S
|
||||
-include $(SRC_DIR)/ucos_v1_42/ucos/bsp/src/$(ARCH)/subdir.mk
|
||||
-include $(SRC_DIR)/ucos_v1_42/ucos/bsp/src/subdir.mk
|
||||
include $(SRC_DIR)/ucos_v1_42/ucos/bsp/src/$(ARCH)/subdir.mk
|
||||
include $(SRC_DIR)/ucos_v1_42/ucos/bsp/src/subdir.mk
|
||||
|
||||
-include $(SRC_DIR)/ucos_v1_42/micrium_source/uC-LIB/subdir.mk
|
||||
include $(SRC_DIR)/ucos_v1_42/micrium_source/uC-LIB/subdir.mk
|
||||
|
||||
SRC += $(SRC_DIR)/ucos_v1_42/ucos/components/ucos_osii/src/bsp/$(ARCH)/ucos_osii_bsp.c
|
||||
SRC += $(SRC_DIR)/ucos_v1_42/ucos/components/ucos_common/src/$(ARCH)/cpu_bsp.c
|
||||
@@ -29,10 +29,10 @@ SRC += $(SRC_DIR)/ucos_v1_42/ucos/drivers/ucos_scuc/src/ucos_scuc.c
|
||||
SRC += $(SRC_DIR)/ucos_v1_42/ucos/drivers/ucos_l2cachec/src/ucos_l2cachec.c
|
||||
SRC += $(SRC_DIR)/ucos_v1_42/ucos/drivers/ucos_emacps/src/ucos_emacps.c
|
||||
|
||||
-include $(SRC_DIR)/ucos_v1_42/ucos/components/ucos_standalone/src/cortexa9/subdir.mk
|
||||
include $(SRC_DIR)/ucos_v1_42/ucos/components/ucos_standalone/src/cortexa9/subdir.mk
|
||||
|
||||
SRC += $(SRC_DIR)/ucos_v1_42/micrium_source/uC-Common/KAL/uCOS-II/kal.c
|
||||
SRC += $(SRC_DIR)/ucos_v1_42/micrium_source/uC-Common/Collections/slist.c
|
||||
SRC += $(SRC_DIR)/ucos_v1_42/micrium_source/uC-Common/Auth/auth.c
|
||||
|
||||
-include $(SRC_DIR)/ucos_v1_42/micrium_source/uCOS-II/Source/subdir.mk
|
||||
include $(SRC_DIR)/ucos_v1_42/micrium_source/uCOS-II/Source/subdir.mk
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
int timer_Task(void *pdata);
|
||||
void timer_Task(void *pdata);
|
||||
int timer_Init();
|
||||
|
||||
#endif /* SRC_APP_AUFGABE3_PS7_CORE0_CFG_TTC_TIMER_H_ */
|
||||
|
||||
@@ -17,21 +17,58 @@
|
||||
#include "xil_printf.h"
|
||||
#include "ttc_timer.h"
|
||||
|
||||
#define TIMER_PRIO 32
|
||||
#define TIMER_STK_SIZE 32000
|
||||
static OS_STK TimerStk[TIMER_STK_SIZE];
|
||||
|
||||
int16_t pidValue = 0;
|
||||
|
||||
void InitDoneCallback(void * p_arg) {
|
||||
(void) p_arg;
|
||||
CPU_SR cpu_sr;
|
||||
OS_ENTER_CRITICAL();
|
||||
// This is a critcal section. Usefull for accessing global variables shared between tasks
|
||||
OS_EXIT_CRITICAL();
|
||||
UCOS_Print("OS started!\r\n");
|
||||
|
||||
//OSTaskCreateExt(timer_Task,
|
||||
// 0,
|
||||
// &TimerStk[TIMER_STK_SIZE-1],
|
||||
// TIMER_PRIO,
|
||||
// TIMER_PRIO,
|
||||
// &TimerStk[0],
|
||||
// TIMER_STK_SIZE,
|
||||
// 0,
|
||||
// 0
|
||||
// );
|
||||
|
||||
timer_Init();
|
||||
|
||||
while(1){
|
||||
for(int16_t i = -1000; i<=1000; i++){
|
||||
CPU_SR cpu_sr;
|
||||
OS_ENTER_CRITICAL();
|
||||
// This is a critcal section. Usefull for accessing global variables shared between tasks
|
||||
pidValue = i;
|
||||
OS_EXIT_CRITICAL();
|
||||
timer_Task(0);
|
||||
//UCOS_Printf("pid: %d\r\n", pidValue);
|
||||
OSTimeDly(1);
|
||||
}
|
||||
for(int16_t i = 1000; i>=-1000; i--){
|
||||
CPU_SR cpu_sr;
|
||||
OS_ENTER_CRITICAL();
|
||||
// This is a critcal section. Usefull for accessing global variables shared between tasks
|
||||
pidValue = i;
|
||||
timer_Task(0);
|
||||
OS_EXIT_CRITICAL();
|
||||
//UCOS_Printf("pid: %d\r\n", pidValue);
|
||||
OSTimeDly(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
MMUInit();
|
||||
UCOSStartup(InitDoneCallback);
|
||||
while (1)
|
||||
;
|
||||
while (1);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,6 @@
|
||||
#include "xgpiops.h"
|
||||
#include "pid.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static void timer_Start(uint32_t Id);
|
||||
static void timer_Stop(uint32_t Id);
|
||||
static void timer_Set_Interval_Length(uint32_t Id, uint16_t intervalLength);
|
||||
@@ -26,26 +23,62 @@ static void motor_Set_Steering_Direction(uint8_t steeringDirection, int16_t *mot
|
||||
static void motor_Set_Moving_Direction (u32 pin, int16_t value);
|
||||
static void timer_gpio_Init();
|
||||
|
||||
int timer_Task(void *pdata) {
|
||||
XTtcPs xttcps;
|
||||
XTtcPs_Config* TimerSetup;
|
||||
|
||||
return 0;
|
||||
XGpioPs xgpiops;
|
||||
XGpioPs_Config* gpioCfg;
|
||||
|
||||
extern int16_t pidValue;
|
||||
|
||||
void timer_Task(void *pdata) {
|
||||
if(pidValue){
|
||||
uint16_t interval = 64;//(64000/abs(pidValue));
|
||||
uint8_t direction = pidValue<0;
|
||||
//UCOS_Printf("%d %d\r\n", direction, interval);
|
||||
timer_Stop(1);
|
||||
timer_Set_Interval_Length(1,interval);
|
||||
timer_Start(1);
|
||||
motor_Set_Moving_Direction(54, direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
timer_Stop(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* * * intializes and starts two timers with respective puls generation on gpio pins * * */
|
||||
int timer_Init(void *pdata){
|
||||
int timer_Init(){
|
||||
UCOS_Print("Setting up Timer!\r\n");
|
||||
TimerSetup = XTtcPs_LookupConfig(XPAR_PS7_TTC_0_DEVICE_ID);
|
||||
XTtcPs_CfgInitialize(&xttcps, TimerSetup, TimerSetup->BaseAddress);
|
||||
XTtcPs_SetOptions(&xttcps, XTTCPS_OPTION_INTERVAL_MODE | XTTCPS_OPTION_MATCH_MODE);
|
||||
XTtcPs_SetPrescaler(&xttcps, 8);
|
||||
XTtcPs_SetMatchValue(&xttcps, 0, 1);
|
||||
XTtcPs_SetInterval(&xttcps, 2);
|
||||
|
||||
timer_gpio_Init();
|
||||
motor_Set_Moving_Direction(54, 1);
|
||||
|
||||
UCOS_Print("Done!\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* * * checks the desired moving direction and sets the direction pin for the steppers * * */
|
||||
static void motor_Set_Moving_Direction (uint32_t pin, int16_t value) {
|
||||
|
||||
XGpioPs_WritePin(&xgpiops, pin, value);;
|
||||
}
|
||||
|
||||
/* * * init gpio, connects IRQ to gpio * * */
|
||||
static void timer_gpio_Init(){
|
||||
gpioCfg = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID);
|
||||
XGpioPs_CfgInitialize(&xgpiops, gpioCfg, gpioCfg->BaseAddr);
|
||||
|
||||
XGpioPs_SetDirectionPin(&xgpiops, 54, 1);
|
||||
XGpioPs_SetOutputEnablePin(&xgpiops, 54, 1);
|
||||
|
||||
XGpioPs_SetDirectionPin(&xgpiops, 55, 1);
|
||||
XGpioPs_SetOutputEnablePin(&xgpiops, 55, 1);
|
||||
}
|
||||
|
||||
/* * * * * * sets up two timers by calling timer_Setup() for each wheel, connects and activates an interrupt to one of timers * * */
|
||||
@@ -62,16 +95,17 @@ static int timer_Setup(int DeviceID)
|
||||
|
||||
/* * * starts timer number "Id" * * */
|
||||
static void timer_Start(uint32_t Id){
|
||||
|
||||
XTtcPs_Start(&xttcps);
|
||||
}
|
||||
|
||||
/* * * stops timer number "Id" * * */
|
||||
static void timer_Stop(uint32_t Id){
|
||||
|
||||
XTtcPs_Stop(&xttcps);
|
||||
}
|
||||
|
||||
|
||||
/* * * sets new interval length and the correct matchvalue * * */
|
||||
static void timer_Set_Interval_Length(uint32_t Id, uint16_t interval_length){
|
||||
|
||||
XTtcPs_SetMatchValue(&xttcps, 0, interval_length/2);
|
||||
XTtcPs_SetInterval(&xttcps, interval_length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user