Compare commits
11 Commits
cae559a7be
...
praktikum
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0c1ce3e07 | ||
|
|
559860f969 | ||
|
|
0a6f487746 | ||
|
|
53b79389bf | ||
|
|
66f32e30c0 | ||
|
|
e23b2f4109 | ||
|
|
47f75e5b40 | ||
|
|
e242231814 | ||
|
|
4da90cfabe | ||
|
|
67c0c2c90e | ||
|
|
f18a2e4fb5 |
4
Debug/ps7/Aufgabe7/draw.bak
Normal file
4
Debug/ps7/Aufgabe7/draw.bak
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
var.draw acceleBuffer
|
||||||
|
var.draw gyroBuffer
|
||||||
|
var.draw angleBuffer
|
||||||
|
var.draw pidArray
|
||||||
4
Debug/ps7/Aufgabe7/draw.cmm
Normal file
4
Debug/ps7/Aufgabe7/draw.cmm
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
var.draw accelBuffer
|
||||||
|
var.draw gyroBuffer
|
||||||
|
var.draw angleBuffer
|
||||||
|
var.draw pidArray
|
||||||
50
Debug/ps7/Aufgabe7/windowSetting.bak
Normal file
50
Debug/ps7/Aufgabe7/windowSetting.bak
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// T32_PORT38791 Tue Nov 18 20:10:58 2025
|
||||||
|
|
||||||
|
B::
|
||||||
|
|
||||||
|
TOOLBAR ON
|
||||||
|
STATUSBAR ON
|
||||||
|
FramePOS 273.86,-1.875,,,Maximized
|
||||||
|
WinPAGE.RESet
|
||||||
|
|
||||||
|
WinPAGE.Create P000
|
||||||
|
WinCLEAR
|
||||||
|
|
||||||
|
WinPOS 136.43 0.0 77. 12. 26. 1. W001
|
||||||
|
WinTABS 13. 0. 0. 0. 0. 0. 0. 0. 0. 23.
|
||||||
|
wl.Break.List
|
||||||
|
|
||||||
|
WinPOS 136.43 18.25 77. 38. 0. 0. W002
|
||||||
|
wl.Var.Watch %Hex %Decimal
|
||||||
|
|
||||||
|
VAR.ADDWATCH OSPrioCur
|
||||||
|
|
||||||
|
WinPOS 218.29 0.0 50. 26. 0. 0. W003
|
||||||
|
wl.Register /SPOTLIGHT
|
||||||
|
|
||||||
|
WinPOS 0.0 48.75 132. 8. 41. 1. W004
|
||||||
|
WinTABS 41. 31.
|
||||||
|
wl.Symbol.browse \\*\*\*
|
||||||
|
|
||||||
|
WinPOS 218.29 30.5 50. 26. 5. 0. W006
|
||||||
|
wl.Frame /Locals
|
||||||
|
|
||||||
|
WinPOS 1.4286 0.0 132. 42. 16. 1. W000
|
||||||
|
WinTABS 10. 10. 25.
|
||||||
|
wl.List.auto
|
||||||
|
|
||||||
|
WinPOS 149.43 13.563 116. 17. 16. 2. W005
|
||||||
|
wl.var.draw accelBuffer
|
||||||
|
|
||||||
|
WinPOS 148.86 36.0 116. 17. 16. 2. W007
|
||||||
|
wl.var.draw gyroBuffer
|
||||||
|
|
||||||
|
WinPOS 30.0 13.125 116. 17. 16. 2. W008
|
||||||
|
wl.var.draw angleBuffer
|
||||||
|
|
||||||
|
WinPOS 29.429 35.938 116. 17. 16. 2. W010
|
||||||
|
wl.var.draw pidArray
|
||||||
|
|
||||||
|
WinPAGE.select P000
|
||||||
|
|
||||||
|
ENDDO
|
||||||
13
Makefile
13
Makefile
@@ -25,12 +25,11 @@ OUT_DIR = ./out
|
|||||||
|
|
||||||
TARGET := $(APP)_$(ARCH)_core$(CORE)
|
TARGET := $(APP)_$(ARCH)_core$(CORE)
|
||||||
TARGET_DIR := $(SRC_DIR)/APP/$(APP)/$(ARCH)/core$(CORE)/
|
TARGET_DIR := $(SRC_DIR)/APP/$(APP)/$(ARCH)/core$(CORE)/
|
||||||
$(info TARGET_DIR : ${TARGET_DIR})
|
|
||||||
|
|
||||||
OBJ_DIR = ./$(OUT_DIR)/$(TARGET)
|
OBJ_DIR = ./$(OUT_DIR)/$(TARGET)
|
||||||
|
|
||||||
# Load specific config for compiler, linker, ...
|
# Load specific config for compiler, linker, ...
|
||||||
include $(TARGET_DIR)/build/config.mk
|
-include $(TARGET_DIR)/build/config.mk
|
||||||
|
|
||||||
#Output files: elf, map and list-file
|
#Output files: elf, map and list-file
|
||||||
EXECUTABLE=$(OBJ_DIR)/../$(TARGET).elf
|
EXECUTABLE=$(OBJ_DIR)/../$(TARGET).elf
|
||||||
@@ -43,13 +42,11 @@ LDSCRIPT = -T$(TARGET_DIR)/linker/lscript.ld
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
#Include source-files:
|
#Include source-files:
|
||||||
$(info TARGET_DIR : ${TARGET_DIR})
|
|
||||||
INC = -I.
|
|
||||||
include $(TARGET_DIR)/build/includes.mk
|
|
||||||
|
|
||||||
SRC =
|
SRC =
|
||||||
include $(TARGET_DIR)/build/sources.mk
|
-include $(TARGET_DIR)/build/sources.mk
|
||||||
|
|
||||||
|
INC = -I./
|
||||||
|
-include $(TARGET_DIR)/build/includes.mk
|
||||||
|
|
||||||
# C source files
|
# C source files
|
||||||
CFILES = $(filter %.c, $(SRC))
|
CFILES = $(filter %.c, $(SRC))
|
||||||
@@ -63,7 +60,7 @@ OBJ = $(SOBJ) $(COBJ)
|
|||||||
$(info CFILES : ${CFILES})
|
$(info CFILES : ${CFILES})
|
||||||
|
|
||||||
# Flags
|
# Flags
|
||||||
CFLAGS = $(MCFLAGS) $(DEBUG) $(OPTIMIZE) -MP -MMD -std=gnu11
|
CFLAGS = $(MCFLAGS) $(DEBUG) $(OPTIMIZE) -MP -MMD -std=gnu11 -DGT_CPU_CYCLE_SCALE=1.33
|
||||||
ASFLAGS = $(MCFLAGS) $(DEBUG) $(OPTIMIZE) -MP -MMD -x assembler-with-cpp
|
ASFLAGS = $(MCFLAGS) $(DEBUG) $(OPTIMIZE) -MP -MMD -x assembler-with-cpp
|
||||||
ODFLAGS = --source --all-headers --demangle --line-numbers --wide
|
ODFLAGS = --source --all-headers --demangle --line-numbers --wide
|
||||||
|
|
||||||
|
|||||||
42
antworten
Normal file
42
antworten
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
aufgabe 5
|
||||||
|
|
||||||
|
|
||||||
|
CPU_Init()
|
||||||
|
|
||||||
|
initialisiert die CPU, zb Stack growth direction
|
||||||
|
|
||||||
|
Mem_init() richtet memory partitionen ein für kernel speicher. muss aufgerufen werden laut code commentar
|
||||||
|
|
||||||
|
OS_Init erstellt 2 Taks, einen IDLE und einen Monitoring Task
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OS_InitMisc() is called to initialize miscellaneous variables. It performs various initialization tasks related to miscellaneous features and options within the uC/OS-II kernel. The actions that are performed are:
|
||||||
|
a) Clear the 32-bit OS System clock.
|
||||||
|
b) Clear the interrupt nesting counter.
|
||||||
|
c) Clear the scheduling lock counter.
|
||||||
|
d) Clear the number of tasks.
|
||||||
|
e) Indicate the OS that the multitasking has not started.
|
||||||
|
f) Clear the context switch counter.
|
||||||
|
g) Let know the kernel that Statistic task is not ready.
|
||||||
|
h) Initialize the OSSafetyCriticalStartFlag(Related to windows) to FALSE indicating safety functionality is not yet enabled or active.
|
||||||
|
i) Initialize the task register ID.
|
||||||
|
|
||||||
|
OS_InitRdyList() is called to initialize the ready list. The ready list is the task of priorities maintained by the kernel. It keeps tracks of which tasks are ready to run based on the priority levels. It is called to ensure that the ready list is in clean state before the scheduler starts scheduling. All the values in the ready table is set to 0 by this function. The Ready table size is defined by the macro OS_RDY_TBL_SIZE in uC/OS-II . It is defined as:
|
||||||
|
#define OS_RDY_TBL_SIZE ((OS_LOWEST/PRIO) / 8u +1u). The OS_LOWEST is 63 that can be found in os_cfg_r.h of uC/OS-II source code.
|
||||||
|
|
||||||
|
OS_InitTCBList() is called to initialize the free list of OS_TCBs. The initialization process typically involves setting up the necessary data structures and variables to manage the free list. This includes linking the TCBs together in the list and configuring any associated fields or flags within the TCBs.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OSStart() is then called to start multitasking and give control to µC/OS-II. It is very important that you create at least one task before calling OSStart(). Failure to do this will certainly make your application crash. In fact, you may always want to create only one task if you are planning on using the CPU usage statistic task.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OSTaskCreateExt() komplizierte Fkt um Tasks zu erstellen mit 9 Argumenten, wie Prio und Interrupt foo
|
||||||
|
|
||||||
|
|
||||||
|
OSTaskStackInit() nur OSTaskStckInit() gefunden, which is responsible for setting up the task stack.
|
||||||
|
|
||||||
|
OS_TCBInit entnimmt einen OS_TCB aus dem Pool, initialisiert die relevanten Felder abhängig von den aktivierten Features (z. B. erweiterte Task-Felder, Event-Pointer, Delete-Flag) und ruft dabei – mit wieder aktivierten Interrupts – die Hook-Funktionen OSTCBInitHook und OSTaskCreateHook auf. Anschließend werden die Interrupts kurz deaktiviert, der TCB an den Anfang der verketteten Task-Liste eingefügt und der Task als “ready” markiert. Zuletzt gibt die Funktion einen Statuscode zurück, der den erfolgreichen Abschluss der Initialisierung signalisiert.
|
||||||
12
aufg6_tabelle_soll_ist.txt
Normal file
12
aufg6_tabelle_soll_ist.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
i delay soll zeit
|
||||||
|
0 1 0.1ms 0.067ms
|
||||||
|
1 2 0.2ms 0.142ms
|
||||||
|
2 4 0.4ms 0.292ms
|
||||||
|
3 8 0.8ms 0.592ms
|
||||||
|
4 16 1.6ms 1.193ms
|
||||||
|
5 32 3.2ms 2.394ms
|
||||||
|
6 64 6.4ms 4.797ms
|
||||||
|
7 128 12.8ms 9.601ms
|
||||||
|
8 256 25.6ms 19.211ms
|
||||||
|
9 512 51.2ms 38.430ms
|
||||||
|
|
||||||
2601
feedgnuplot
Executable file
2601
feedgnuplot
Executable file
File diff suppressed because it is too large
Load Diff
@@ -21,14 +21,13 @@ INC += -I"$(SRC_DIR)/ucos_v1_42/ucos/drivers/ucos_emacps/src"
|
|||||||
INC += -I"$(SRC_DIR)/ucos_v1_42/ucos/drivers/ucos_scuc/src"
|
INC += -I"$(SRC_DIR)/ucos_v1_42/ucos/drivers/ucos_scuc/src"
|
||||||
INC += -I"$(SRC_DIR)/ucos_v1_42/ucos/drivers/ucos_ttcps/src"
|
INC += -I"$(SRC_DIR)/ucos_v1_42/ucos/drivers/ucos_ttcps/src"
|
||||||
|
|
||||||
|
INC += -I"$(SRC_DIR)/ucos_v1_42/ucos/components/ucos_standalone/src/cortexa9"
|
||||||
INC += -I"$(SRC_DIR)/ucos_v1_42/ucos/components/ucos_standalone/src/cortexa9/gcc"
|
INC += -I"$(SRC_DIR)/ucos_v1_42/ucos/components/ucos_standalone/src/cortexa9/gcc"
|
||||||
INC += -I"$(SRC_DIR)/ucos_v1_42/ucos/components/ucos_standalone/src/common"
|
INC += -I"$(SRC_DIR)/ucos_v1_42/ucos/components/ucos_standalone/src/common"
|
||||||
|
|
||||||
INC += -I"$(SRC_DIR)/Xilinx/libsrc/ipipsu_v2_3/src/"
|
INC += -I"$(SRC_DIR)/Xilinx/libsrc/ipipsu_v2_3/src/"
|
||||||
INC += -I"$(SRC_DIR)/Modules/MMU"
|
INC += -I"$(SRC_DIR)/Modules/MMU"
|
||||||
|
|
||||||
INC += -I"$(SRC_DIR)/Xilinx/include/"
|
|
||||||
|
|
||||||
|
|
||||||
INC += -I"$(SRC_DIR)/Xilinx/libsrc/ipipsu_v2_3/src/"
|
INC += -I"$(SRC_DIR)/Xilinx/libsrc/ipipsu_v2_3/src/"
|
||||||
|
|
||||||
|
|||||||
@@ -27,28 +27,22 @@ void InitDoneCallback(void * p_arg) {
|
|||||||
(void) p_arg;
|
(void) p_arg;
|
||||||
UCOS_Print("OS started!\r\n");
|
UCOS_Print("OS started!\r\n");
|
||||||
|
|
||||||
//OSTaskCreateExt(timer_Task,
|
OSTaskCreateExt(timer_Task,
|
||||||
// 0,
|
0,
|
||||||
// &TimerStk[TIMER_STK_SIZE-1],
|
&TimerStk[TIMER_STK_SIZE-1],
|
||||||
// TIMER_PRIO,
|
TIMER_PRIO,
|
||||||
// TIMER_PRIO,
|
TIMER_PRIO,
|
||||||
// &TimerStk[0],
|
&TimerStk[0],
|
||||||
// TIMER_STK_SIZE,
|
TIMER_STK_SIZE,
|
||||||
// 0,
|
0,
|
||||||
// 0
|
0
|
||||||
// );
|
);
|
||||||
|
|
||||||
timer_Init();
|
|
||||||
|
|
||||||
uint16_t melody[][2] = {{440, 500}, {440, 500}, {440, 500}, {349, 350}, {523, 150}, {440, 500}, {349, 350}, {523, 150}, {440, 1000}, {659, 500}, {659, 500}, {659, 500}, {698, 350}, {523, 150}, {415, 500}, {349, 350}, {523, 150}, {440, 1000}};
|
uint16_t melody[][2] = {{440, 500}, {440, 500}, {440, 500}, {349, 350}, {523, 150}, {440, 500}, {349, 350}, {523, 150}, {440, 1000}, {659, 500}, {659, 500}, {659, 500}, {698, 350}, {523, 150}, {415, 500}, {349, 350}, {523, 150}, {440, 1000}};
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
for(uint8_t i=0; i<(sizeof(melody)/sizeof(melody[0])); i++){
|
for(uint8_t i=0; i<(sizeof(melody)/sizeof(melody[0])); i++){
|
||||||
CPU_SR cpu_sr;
|
|
||||||
OS_ENTER_CRITICAL();
|
|
||||||
pidValue = melody[i][0];
|
pidValue = melody[i][0];
|
||||||
OS_EXIT_CRITICAL();
|
|
||||||
timer_Task(0);
|
|
||||||
OSTimeDly(melody[i][1]);
|
OSTimeDly(melody[i][1]);
|
||||||
}
|
}
|
||||||
//for(int16_t i = -1000; i<=1000; i++){
|
//for(int16_t i = -1000; i<=1000; i++){
|
||||||
|
|||||||
@@ -28,26 +28,31 @@ XTtcPs xttcps[2];
|
|||||||
XGpioPs xgpiops;
|
XGpioPs xgpiops;
|
||||||
XGpioPs_Config* gpioCfg;
|
XGpioPs_Config* gpioCfg;
|
||||||
|
|
||||||
extern int16_t pidValue;
|
extern int32_t pidValue;
|
||||||
|
|
||||||
void timer_Task(void *pdata) {
|
void timer_Task(void *pdata) {
|
||||||
if(pidValue){
|
while(1)
|
||||||
uint16_t interval = 1.337*(64000/abs(pidValue));
|
|
||||||
uint8_t direction = pidValue<0;
|
|
||||||
//UCOS_Printf("%d %d\r\n", direction, interval);
|
|
||||||
//UCOS_Printf("counter value: %d\r\n", XTtcPs_GetCounterValue(&xttcps));
|
|
||||||
timer_Stop(0);
|
|
||||||
timer_Stop(1);
|
|
||||||
timer_Set_Interval_Length(0,interval);
|
|
||||||
timer_Set_Interval_Length(1,interval);
|
|
||||||
timer_Start(0);
|
|
||||||
timer_Start(1);
|
|
||||||
motor_Set_Moving_Direction(54, direction);
|
|
||||||
motor_Set_Moving_Direction(55, !direction);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
timer_Stop(0);
|
if(pidValue){
|
||||||
|
uint16_t interval = 1.337*(64000/abs(pidValue));
|
||||||
|
uint8_t direction = pidValue<0;
|
||||||
|
//UCOS_Printf("%d %d\r\n", direction, interval);
|
||||||
|
//UCOS_Printf("counter value: %d\r\n", XTtcPs_GetCounterValue(&xttcps));
|
||||||
|
timer_Stop(0);
|
||||||
|
timer_Stop(1);
|
||||||
|
timer_Set_Interval_Length(0,interval);
|
||||||
|
timer_Set_Interval_Length(1,interval);
|
||||||
|
timer_Start(0);
|
||||||
|
timer_Start(1);
|
||||||
|
motor_Set_Moving_Direction(54, direction);
|
||||||
|
motor_Set_Moving_Direction(55, !direction);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timer_Stop(0);
|
||||||
|
timer_Stop(1);
|
||||||
|
}
|
||||||
|
OSTimeDly(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,9 +61,7 @@ int timer_Init(){
|
|||||||
UCOS_Print("Setting up Timer!\r\n");
|
UCOS_Print("Setting up Timer!\r\n");
|
||||||
|
|
||||||
timer_Dual_Timer_Setup();
|
timer_Dual_Timer_Setup();
|
||||||
|
|
||||||
timer_gpio_Init();
|
timer_gpio_Init();
|
||||||
motor_Set_Moving_Direction(54, 1);
|
|
||||||
|
|
||||||
UCOS_Print("Done!\r\n");
|
UCOS_Print("Done!\r\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -20,10 +20,10 @@
|
|||||||
void InitDoneCallback(void * p_arg) {
|
void InitDoneCallback(void * p_arg) {
|
||||||
(void) p_arg;
|
(void) p_arg;
|
||||||
UCOS_Print("OS started!\r\n");
|
UCOS_Print("OS started!\r\n");
|
||||||
|
mpu9250_Imu_Init(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
||||||
MMUInit();
|
MMUInit();
|
||||||
UCOSStartup(InitDoneCallback);
|
UCOSStartup(InitDoneCallback);
|
||||||
while (1)
|
while (1)
|
||||||
|
|||||||
BIN
src/APP/Aufgabe4/ps7/core0/src/.imu.c.swp
Normal file
BIN
src/APP/Aufgabe4/ps7/core0/src/.imu.c.swp
Normal file
Binary file not shown.
@@ -18,6 +18,7 @@
|
|||||||
#include "ucos_ii.h"
|
#include "ucos_ii.h"
|
||||||
#include "ucos_bsp.h"
|
#include "ucos_bsp.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
/**
|
/**
|
||||||
* Global variables
|
* Global variables
|
||||||
*/
|
*/
|
||||||
@@ -26,6 +27,18 @@
|
|||||||
static int16_t _imu_accMaxData[3]={0,0,0}; //x, y, z
|
static int16_t _imu_accMaxData[3]={0,0,0}; //x, y, z
|
||||||
static int16_t _imu_accMinData[3]={0,0,0}; //x, y, z
|
static int16_t _imu_accMinData[3]={0,0,0}; //x, y, z
|
||||||
|
|
||||||
|
float imu_current_angle;
|
||||||
|
|
||||||
|
int16_t accelData[3];
|
||||||
|
int16_t gyroData[3];
|
||||||
|
|
||||||
|
int16_t accelBuffer[5000];
|
||||||
|
int16_t gyroBuffer[5000];
|
||||||
|
int16_t angleBuffer[5000];
|
||||||
|
|
||||||
|
static XIicPs Iic;
|
||||||
|
XIicPs_Config *Config;
|
||||||
|
OS_EVENT * iic_sem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Prototypes
|
* Function Prototypes
|
||||||
@@ -43,15 +56,75 @@ static void mpu9250_Get_Acc_Min_Max();
|
|||||||
* Read sensor data and calculate angle
|
* Read sensor data and calculate angle
|
||||||
*/
|
*/
|
||||||
int mpu9250_CalculateAngle(void *pdata){
|
int mpu9250_CalculateAngle(void *pdata){
|
||||||
|
static uint16_t i=0;
|
||||||
|
|
||||||
|
mpu9250_Read_Data(59, 6, (u8*)accelData);
|
||||||
|
mpu9250_Read_Data(67, 6, (u8*)gyroData);
|
||||||
|
|
||||||
|
int16_t accelX = (int16_t)((accelData[0]&0xFF)<<8 | (accelData[0]&0xFF00)>>8);
|
||||||
|
int16_t accelZ = (int16_t)((accelData[2]&0xFF)<<8 | (accelData[2]&0xFF00)>>8);
|
||||||
|
double accelAngle = atan2(accelX,accelZ)*180/PI;
|
||||||
|
double gyroAngleD = (int16_t)((gyroData[1]&0xFF)<<8 | (gyroData[1]&0xFF00)>>8);
|
||||||
|
|
||||||
|
accelBuffer[i] = accelAngle;
|
||||||
|
gyroBuffer[i] = gyroAngleD;
|
||||||
|
|
||||||
|
imu_current_angle = 0.98*(imu_current_angle - (0.012*250*gyroAngleD/INT16_MAX)) + 0.02*accelAngle;
|
||||||
|
//current_angle = current_angle - gyroBuffer[i];
|
||||||
|
//UCOS_Printf("%d %d %d\n", current_angle, accelBuffer[i], gyroBuffer[i]);
|
||||||
|
angleBuffer[i] = imu_current_angle;
|
||||||
|
i=(i+1)%(sizeof(angleBuffer)/sizeof(angleBuffer[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize I2C and MPU
|
* Initialize I2C and MPU
|
||||||
*/
|
*/
|
||||||
int mpu9250_Imu_Init(void *pdata){
|
int mpu9250_Imu_Init(void *pdata){
|
||||||
|
mpu9250_Iic_Init();
|
||||||
|
mpu9250_Write_Reg(29, 5); // accel dlpf 10Hz
|
||||||
|
mpu9250_Write_Reg(26, 5); // gyro dlpf 10Hz
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void iic_isr_recv(){
|
||||||
|
OSSemPost(iic_sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t mpu9250_Iic_Init(){
|
||||||
|
Config = XIicPs_LookupConfig(IIC_DEVICE_ID) ;
|
||||||
|
XIicPs_CfgInitialize(&Iic, Config, Config->BaseAddress);
|
||||||
|
iic_sem = OSSemCreate(1);
|
||||||
|
|
||||||
|
s32 err;
|
||||||
|
|
||||||
|
err = XIicPs_SelfTest(&Iic);
|
||||||
|
if(err == XST_SUCCESS)
|
||||||
|
UCOS_Printf("i2c selftest succcess\r\n");
|
||||||
|
else
|
||||||
|
UCOS_Printf("i2c selftest fail\r\n");
|
||||||
|
|
||||||
|
err = XIicPs_SetSClk(&Iic, 400000);
|
||||||
|
if(err != XST_SUCCESS)
|
||||||
|
UCOS_Printf("failed to set i2c speed\r\n");
|
||||||
|
|
||||||
|
Iic.StatusHandler = iic_isr_recv;
|
||||||
|
UCOS_IntVectSet(XPS_I2C1_INT_ID, 0, 0, XIicPs_MasterInterruptHandler, &Iic);
|
||||||
|
UCOS_IntSrcEn(XPS_I2C1_INT_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t mpu9250_Write_Reg(uint8_t iic_address, uint8_t data){
|
||||||
|
uint8_t tx_buf[] = {iic_address, data};
|
||||||
|
uint8_t err;
|
||||||
|
OSSemPend(iic_sem, 0, &err);
|
||||||
|
XIicPs_MasterSend(&Iic, tx_buf, sizeof(tx_buf), MPU9250_AD);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int8_t mpu9250_Read_Data(uint8_t iic_address, uint8_t length, u8 RecvBuffer []){
|
||||||
|
uint8_t err;
|
||||||
|
OSSemPend(iic_sem, 0, &err);
|
||||||
|
XIicPs_MasterSend(&Iic, &iic_address, 1, MPU9250_AD);
|
||||||
|
OSSemPend(iic_sem, 0, &err);
|
||||||
|
XIicPs_MasterRecv(&Iic, RecvBuffer, length, MPU9250_AD);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
void InitDoneCallback(void * p_arg) {
|
void InitDoneCallback(void * p_arg) {
|
||||||
(void) p_arg;
|
(void) p_arg;
|
||||||
UCOS_Print("OS started!\r\n");
|
//UCOS_Print("OS started!\r\n");
|
||||||
GT_Init();
|
GT_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
#include <string.h> /* memset */
|
#include <string.h> /* memset */
|
||||||
|
|
||||||
#define TASK_A_PRIO 11
|
#define TASK_A_PRIO 10
|
||||||
#define TASK_B_PRIO
|
#define TASK_B_PRIO 11
|
||||||
#define TASK_C_PRIO
|
#define TASK_C_PRIO 12
|
||||||
#define TASK_D_PRIO
|
#define TASK_D_PRIO 13
|
||||||
#define TASK_E_PRIO
|
#define TASK_E_PRIO 14
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ GT_TASK_EXT_T GT_AllTasks[GT_NUM_OF_TASKS] = {
|
|||||||
/* Period Jitter Distance BCET WCET */
|
/* Period Jitter Distance BCET WCET */
|
||||||
{20, 0, 0, {5, 10}},
|
{20, 0, 0, {5, 10}},
|
||||||
{10, 0, 0, {1, 2}},
|
{10, 0, 0, {1, 2}},
|
||||||
{100, 0, 0, {2, 2}},
|
{100, 0, 0, {2, 2}},
|
||||||
{50, 0, 0, {2, 10}},
|
{50, 0, 0, {2, 10}},
|
||||||
{200, 0, 0, {2, 5}},
|
{200, 0, 0, {2, 5}},
|
||||||
};
|
};
|
||||||
@@ -72,26 +72,151 @@ void _taskFinished(void){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void task0_start(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task1_start(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task2_start(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task3_start(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task4_start(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
|
||||||
|
void task0_act(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task1_act(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task2_act(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task3_act(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task4_act(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
|
||||||
|
void task0_switch(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task1_switch(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task2_switch(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task3_switch(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task4_switch(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
|
||||||
|
void task0_end(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task1_end(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task2_end(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task3_end(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
void task4_end(){
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
|
||||||
void GT_TaskActivationHook(GT_TASK_T *pMyOwnTask) {
|
void GT_TaskActivationHook(GT_TASK_T *pMyOwnTask) {
|
||||||
|
if(pMyOwnTask == >_Tasks[0]){
|
||||||
|
task0_act();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[1]){
|
||||||
|
task1_act();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[2]){
|
||||||
|
task2_act();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[3]){
|
||||||
|
task3_act();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[4]){
|
||||||
|
task4_act();
|
||||||
|
}
|
||||||
//call _taskActivated
|
//call _taskActivated
|
||||||
}
|
}
|
||||||
|
|
||||||
void GT_TaskStartHook(GT_TASK_T *pMyOwnTask) {
|
void GT_TaskStartHook(GT_TASK_T *pMyOwnTask) {
|
||||||
|
if(pMyOwnTask == >_Tasks[0]){
|
||||||
|
task0_start();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[1]){
|
||||||
|
task1_start();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[2]){
|
||||||
|
task2_start();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[3]){
|
||||||
|
task3_start();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[4]){
|
||||||
|
task4_start();
|
||||||
|
}
|
||||||
//call _taskStarted
|
//call _taskStarted
|
||||||
}
|
}
|
||||||
|
|
||||||
void GT_TaskEndHook(GT_TASK_T *pMyOwnTask){
|
void GT_TaskEndHook(GT_TASK_T *pMyOwnTask){
|
||||||
|
if(pMyOwnTask == >_Tasks[0]){
|
||||||
|
task0_end();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[1]){
|
||||||
|
task1_end();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[2]){
|
||||||
|
task2_end();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[3]){
|
||||||
|
task3_end();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[4]){
|
||||||
|
task4_end();
|
||||||
|
}
|
||||||
|
|
||||||
//Call _taskFinished
|
//Call _taskFinished
|
||||||
}
|
}
|
||||||
|
|
||||||
void GT_TaskInitHook(GT_TASK_T *pMyOwnTask){
|
void GT_TaskInitHook(GT_TASK_T *pMyOwnTask){
|
||||||
if(pMyOwnTask->Id == 4){
|
//if(pMyOwnTask->Id == 4){
|
||||||
UCOS_Print("Init Task\n");
|
// UCOS_Print("Init Task\n");
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GT_TaskSwHook(GT_TASK_T *pMyOwnTask) {
|
void GT_TaskSwHook(GT_TASK_T *pMyOwnTask) {
|
||||||
//call Task scheduled or not
|
//call Task scheduled or not
|
||||||
|
if(pMyOwnTask == >_Tasks[0]){
|
||||||
|
task0_switch();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[1]){
|
||||||
|
task1_switch();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[2]){
|
||||||
|
task2_switch();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[3]){
|
||||||
|
task3_switch();
|
||||||
|
}
|
||||||
|
if(pMyOwnTask == >_Tasks[4]){
|
||||||
|
task4_switch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GT_TaskMissHook(GT_TASK_T *pMyOwnTask){
|
void GT_TaskMissHook(GT_TASK_T *pMyOwnTask){
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#define GT_USE_NP_REGIONS 1
|
#define GT_USE_NP_REGIONS 1
|
||||||
#define GT_USE_NP_MEAS 1
|
#define GT_USE_NP_MEAS 1
|
||||||
#define GT_NUM_OF_TASKS 3
|
#define GT_NUM_OF_TASKS 4
|
||||||
#define GT_REPORT_CONSOLE 0
|
#define GT_REPORT_CONSOLE 0
|
||||||
#define GT_REPORT_SVC 0
|
#define GT_REPORT_SVC 0
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ void InitDoneCallback(void * p_arg) {
|
|||||||
(void) p_arg;
|
(void) p_arg;
|
||||||
UCOS_Print("OS started!\r\n");
|
UCOS_Print("OS started!\r\n");
|
||||||
GT_Init();
|
GT_Init();
|
||||||
|
uint8_t err;
|
||||||
|
OSTaskNameSet(31, "IMU Task", &err);
|
||||||
|
OSTaskNameSet(32, "Timer Task", &err);
|
||||||
|
OSTaskNameSet(33, "PID Task", &err);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ GT_TASK_EXT_T GT_AllTasks[GT_NUM_OF_TASKS] = {
|
|||||||
{50, 0, 0, {1, 1}},
|
{50, 0, 0, {1, 1}},
|
||||||
{120, 0, 0, {2, 4}},
|
{120, 0, 0, {2, 4}},
|
||||||
{50, 0, 0, {3, 5}},
|
{50, 0, 0, {3, 5}},
|
||||||
//{50, 0, 0, {3, 5}},
|
{50, 0, 0, {3, 5}},
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -41,10 +41,10 @@ GT_TASK_EXT_T GT_AllTasks[GT_NUM_OF_TASKS] = {
|
|||||||
GT_TASK_T GT_Tasks[GT_NUM_OF_TASKS] =
|
GT_TASK_T GT_Tasks[GT_NUM_OF_TASKS] =
|
||||||
{
|
{
|
||||||
/*Type Activation Type Id Prio init Function Task Function TaskArg WL/Runable Internal External */
|
/*Type Activation Type Id Prio init Function Task Function TaskArg WL/Runable Internal External */
|
||||||
{ GT_TASK_EXT , GT_ACT_INT , 0, 32, your-timer-taskinitfunction ,your-timer_Task , NULL, GT_RUNABLE_NULL, GT_INTERNAL_NULL, (void *)>_AllTasks[0]},
|
{ GT_TASK_EXT , GT_ACT_INT , 0, 32, timer_Init, timer_Task , NULL, GT_RUNABLE_NULL, GT_INTERNAL_NULL, (void *)>_AllTasks[0]},
|
||||||
{ GT_TASK_EXT , GT_ACT_INT , 1, 31, your-imu-taskinitfunction ,your-imu_Task , NULL, GT_RUNABLE_NULL, GT_INTERNAL_NULL, (void *)>_AllTasks[1]},
|
{ GT_TASK_EXT , GT_ACT_INT , 1, 31, mpu9250_Imu_Init, mpu9250_CalculateAngle , NULL, GT_RUNABLE_NULL, GT_INTERNAL_NULL, (void *)>_AllTasks[1]},
|
||||||
{ GT_TASK_EXT , GT_ACT_INT , 2, 33, your-pid-taskinitfunction ,your-pid_Task , NULL, GT_RUNABLE_NULL, GT_INTERNAL_NULL, (void *)>_AllTasks[2]},
|
{ GT_TASK_EXT , GT_ACT_INT , 2, 33, pid_Init, pid_Task , NULL, GT_RUNABLE_NULL, GT_INTERNAL_NULL, (void *)>_AllTasks[2]},
|
||||||
//{ GT_TASK_DEF , GT_ACT_INT , 3, 33, _GT_GetNextActivation, _GT_GetTaskCet, NULL ,NULL , NULL, 20, GT_RUNABLE_NULL, GT_INTERNAL_NULL, (void *)>_AllTasks[3]},
|
{ GT_TASK_DEF , GT_ACT_INT , 3, 33, NULL, NULL , NULL, GT_RUNABLE_NULL, GT_INTERNAL_NULL, (void *)>_AllTasks[3]},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user