forked from ROMEO/obsw
no allocations anymore; lwip TODO
This commit is contained in:
parent
e0527bf91b
commit
baa7b8a96d
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,9 +1,6 @@
|
||||
[submodule "FreeRTOS-Kernel"]
|
||||
path = FreeRTOS-Kernel
|
||||
url = https://github.com/FreeRTOS/FreeRTOS-Kernel
|
||||
[submodule "fsfw"]
|
||||
path = fsfw
|
||||
url = https://egit.irs.uni-stuttgart.de/fsfw/fsfw
|
||||
[submodule "contrib/lwip"]
|
||||
path = contrib/lwip
|
||||
url = https://git.savannah.gnu.org/git/lwip.git
|
||||
|
@ -59,13 +59,14 @@ set(lwip_SRCS
|
||||
${LWIP_DIR}/src/apps/tftp/tftp.c
|
||||
${LWIP_DIR}/contrib/ports/freertos/sys_arch.c
|
||||
)
|
||||
add_library(lwip ${lwip_SRCS})
|
||||
target_include_directories(lwip PUBLIC ${LWIP_INCLUDE_DIRS})
|
||||
#add_library(lwip ${lwip_SRCS})
|
||||
#target_include_directories(lwip PUBLIC ${LWIP_INCLUDE_DIRS})
|
||||
|
||||
#target_compile_options(${TARGET_NAME} PUBLIC -g -O0 -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard)
|
||||
|
||||
# Add freeRTOS
|
||||
set(FREERTOS_PORT GCC_ARM_CA9 CACHE STRING "")
|
||||
set(FREERTOS_HEAP 2 CACHE STRING "")
|
||||
add_library(freertos_config INTERFACE)
|
||||
target_include_directories(freertos_config SYSTEM
|
||||
INTERFACE ${FreeRTOS_CONFIG_PATH}) # The config file directory
|
||||
@ -82,18 +83,7 @@ add_subdirectory(${FreeRTOS_PATH})
|
||||
|
||||
add_subdirectory(bsp_z7)
|
||||
|
||||
#set(FSFW_OSAL freertos CACHE STRING "FSFW OSAL")
|
||||
set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig")
|
||||
set(COMMON_CONFIG_PATH "common/config")
|
||||
set(FSFW_ADDITIONAL_INC_PATHS
|
||||
"${COMMON_CONFIG_PATH}" "${CMAKE_CURRENT_BINARY_DIR}" "contrib/"
|
||||
CACHE STRING "FSFW configuration paths")
|
||||
|
||||
set(FSFW_OSAL freertos CACHE STRING "FSFW OSAL")
|
||||
|
||||
set(FSFW_ADD_MONITORING ON)
|
||||
|
||||
add_subdirectory(fsfw)
|
||||
add_subdirectory(common)
|
||||
|
||||
add_subdirectory(${MISSION_PATH})
|
||||
@ -104,15 +94,14 @@ add_subdirectory(mission_rust)
|
||||
# ##############################################################################
|
||||
|
||||
# Add libraries for all sources.
|
||||
target_link_libraries(lwip PUBLIC freertos_kernel)
|
||||
target_link_libraries(fsfw PUBLIC lwip)
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC fsfw lwip mission_rust)
|
||||
#target_link_libraries(lwip PUBLIC freertos_kernel)
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC freertos_kernel mission_rust)
|
||||
|
||||
target_include_directories(
|
||||
${TARGET_NAME} PUBLIC ${BSP_PATH})
|
||||
|
||||
|
||||
target_link_options(${TARGET_NAME} PRIVATE -Wl,--start-group,-lgcc,-lc,--end-group -Wl,-Map=${TARGET_NAME}.map -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -Wl,-build-id=none -T${CMAKE_SOURCE_DIR}/${FreeRTOS_CONFIG_PATH}/lscript.ld -specs=${CMAKE_SOURCE_DIR}/${FreeRTOS_CONFIG_PATH}/Xilinx.spec)
|
||||
target_link_options(${TARGET_NAME} PRIVATE -Wl,--cref -Wl,-Map=${TARGET_NAME}.map -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -Wl,-build-id=none -T${CMAKE_SOURCE_DIR}/${FreeRTOS_CONFIG_PATH}/lscript.ld -specs=${CMAKE_SOURCE_DIR}/${FreeRTOS_CONFIG_PATH}/Xilinx.spec )
|
||||
|
||||
# Removed unused sections.
|
||||
target_link_options(${TARGET_NAME} PRIVATE "-Wl,--gc-sections")
|
||||
|
@ -1,3 +1,2 @@
|
||||
add_subdirectory(freeRTOS)
|
||||
add_subdirectory(ps7_cortexa9_0)
|
||||
add_subdirectory(objects)
|
||||
add_subdirectory(ps7_cortexa9_0)
|
@ -77,23 +77,23 @@
|
||||
#define configUSE_TICK_HOOK 1
|
||||
#define configMAX_PRIORITIES ( 7 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 250 ) /* Large in case configUSE_TASK_FPU_SUPPORT is 2 in which case all tasks have an FPU context. */
|
||||
#define configTOTAL_HEAP_SIZE ( 20 * 1024 * 1024 )
|
||||
#define configTOTAL_HEAP_SIZE ( 0 )
|
||||
#define configMAX_TASK_NAME_LEN ( 10 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 8
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||
#define configUSE_APPLICATION_TASK_TAG 0
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configUSE_QUEUE_SETS 1
|
||||
#define configSUPPORT_STATIC_ALLOCATION 0
|
||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||
#define configSUPPORT_DYNAMIC_ALLOCATION 0
|
||||
|
||||
/* Include the query-heap CLI command to query the free heap space. */
|
||||
#define configINCLUDE_QUERY_HEAP_COMMAND 1
|
||||
#define configINCLUDE_QUERY_HEAP_COMMAND 0
|
||||
|
||||
/* Co-routine definitions. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
@ -128,11 +128,6 @@ to exclude the API function. */
|
||||
#define INCLUDE_xTaskGetHandle 1
|
||||
#define INCLUDE_xSemaphoreGetMutexHolder 1
|
||||
|
||||
/* This demo makes use of one or more example stats formatting functions. These
|
||||
format the raw data provided by the uxTaskGetSystemState() function in to human
|
||||
readable ASCII form. See the notes in the implementation of vTaskList() within
|
||||
FreeRTOS/Source/tasks.c for limitations. */
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
|
||||
|
||||
/* The private watchdog is used to generate run time stats. */
|
||||
#include "xscuwdt.h"
|
||||
@ -184,7 +179,7 @@ Zynq MPU. */
|
||||
#define configUNIQUE_INTERRUPT_PRIORITIES 32
|
||||
|
||||
/* Newlib support*/
|
||||
#define configUSE_NEWLIB_REENTRANT 1 // Required for thread-safety of newlib sprintf, strtok, etc...
|
||||
//#define configUSE_NEWLIB_REENTRANT 1 // Required for thread-safety of newlib sprintf, strtok, etc...
|
||||
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
|
@ -11,7 +11,7 @@
|
||||
/*******************************************************************/
|
||||
|
||||
_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x2000;
|
||||
_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x01400000;
|
||||
/* _HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x01400000; */
|
||||
|
||||
_ABORT_STACK_SIZE = DEFINED(_ABORT_STACK_SIZE) ? _ABORT_STACK_SIZE : 1024;
|
||||
_SUPERVISOR_STACK_SIZE = DEFINED(_SUPERVISOR_STACK_SIZE) ? _SUPERVISOR_STACK_SIZE : 2048;
|
||||
@ -244,7 +244,7 @@ _SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 );
|
||||
|
||||
/* Generate Stack and Heap definitions */
|
||||
|
||||
.heap (NOLOAD) : {
|
||||
/* .heap (NOLOAD) : {
|
||||
. = ALIGN(16);
|
||||
_heap = .;
|
||||
HeapBase = .;
|
||||
@ -253,6 +253,7 @@ _SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 );
|
||||
_heap_end = .;
|
||||
HeapLimit = .;
|
||||
} > ps7_ddr_0_S_AXI_BASEADDR
|
||||
*/
|
||||
|
||||
.stack (NOLOAD) : {
|
||||
. = ALIGN(16);
|
||||
|
@ -1,3 +0,0 @@
|
||||
target_sources(
|
||||
${TARGET_NAME} PRIVATE
|
||||
ObjectFactory.cpp)
|
@ -1,66 +0,0 @@
|
||||
#include "ObjectFactory.h"
|
||||
|
||||
#include <fsfw/objectmanager/frameworkObjects.h>
|
||||
#include <fsfw/storagemanager/PoolManager.h>
|
||||
#include <fsfw/tmtc/TmManager.h>
|
||||
#include <mission/controller/PrintController.h>
|
||||
|
||||
#include "fsfw/events/EventManager.h"
|
||||
#include "fsfw/health/HealthTable.h"
|
||||
#include "fsfw/internalerror/InternalErrorReporter.h"
|
||||
#include "fsfw/tmtc/UdpTmTcBridge.h"
|
||||
#include "systemObjects.h"
|
||||
|
||||
namespace objects {
|
||||
enum commonObjects : object_id_t {
|
||||
|
||||
/* 0x63 ('C') for core objects */
|
||||
CCSDS_DISTRIBUTOR = 0x63000000,
|
||||
PUS_DISTRIBUTOR = 0x63000001,
|
||||
TM_FUNNEL = 0x63000002,
|
||||
CFDP_DISTRIBUTOR = 0x63000003,
|
||||
CFDP_HANDLER = 0x63000004,
|
||||
PUS_TM_FUNNEL = 0x63000005,
|
||||
CFDP_TM_FUNNEL = 0x64000006,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// void Factory::setStaticFrameworkObjectIds() {
|
||||
// // MonitoringReportContent<float>::timeStamperId = objects::TIME_STAMPER;
|
||||
// // MonitoringReportContent<double>::timeStamperId = objects::TIME_STAMPER;
|
||||
// // MonitoringReportContent<uint32_t>::timeStamperId = objects::TIME_STAMPER;
|
||||
// // MonitoringReportContent<int32_t>::timeStamperId = objects::TIME_STAMPER;
|
||||
// // MonitoringReportContent<int16_t>::timeStamperId = objects::TIME_STAMPER;
|
||||
// // MonitoringReportContent<uint16_t>::timeStamperId = objects::TIME_STAMPER;
|
||||
|
||||
// // PusServiceBase::PUS_DISTRIBUTOR = objects::PUS_DISTRIBUTOR;
|
||||
// // PusServiceBase::PACKET_DESTINATION = objects::PUS_TM_FUNNEL;
|
||||
|
||||
// // CommandingServiceBase::defaultPacketSource = objects::PUS_DISTRIBUTOR;
|
||||
// // CommandingServiceBase::defaultPacketDestination = objects::PUS_TM_FUNNEL;
|
||||
|
||||
// // VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION;
|
||||
// }
|
||||
|
||||
void ObjectFactory::produce(void *args) {
|
||||
//Factory::setStaticFrameworkObjectIds();
|
||||
|
||||
|
||||
|
||||
{
|
||||
LocalPool::LocalPoolConfig poolCfg = {{100, 16}, {50, 32}, {40, 64},
|
||||
{30, 128}, {20, 1024}, {10, 2048}};
|
||||
new PoolManager(objects::IPC_STORE, poolCfg);
|
||||
}
|
||||
|
||||
new EventManager(objects::EVENT_MANAGER, 20);
|
||||
new HealthTable(objects::HEALTH_TABLE);
|
||||
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
|
||||
|
||||
new TmManager(objects::TM_MANAGER);
|
||||
|
||||
new UdpTmTcBridgeNew(130,7777,0,0);
|
||||
|
||||
new PrintController(123);
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace ObjectFactory {
|
||||
void produce(void* args);
|
||||
} // namespace ObjectFactory
|
@ -1,4 +0,0 @@
|
||||
target_sources(
|
||||
${TARGET_NAME} PRIVATE
|
||||
ServoCommInterface.cpp
|
||||
SerialTCPCookie.cpp)
|
@ -1,8 +0,0 @@
|
||||
#include "SerialTCPCookie.h"
|
||||
|
||||
SerialTCPCookie::SerialTCPCookie(const char* host, uint16_t port, bool flush, size_t bufferSize)
|
||||
: host(host), port(port), flush(flush), bufferSize(bufferSize), socket(-1) {
|
||||
buffer = new uint8_t[bufferSize];
|
||||
}
|
||||
|
||||
SerialTCPCookie::~SerialTCPCookie() { delete buffer; }
|
@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
#include <stddef.h>
|
||||
|
||||
class SerialTCPCookie : public CookieIF {
|
||||
public:
|
||||
SerialTCPCookie(const char* host, uint16_t port, bool flush, size_t bufferSize);
|
||||
virtual ~SerialTCPCookie();
|
||||
|
||||
const char* const host;
|
||||
const uint16_t port;
|
||||
const bool flush;
|
||||
uint8_t *buffer;
|
||||
const size_t bufferSize;
|
||||
int socket;
|
||||
};
|
@ -1,138 +0,0 @@
|
||||
#include "ServoCommInterface.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h> // POSIX.1-2001 does not require the inclusion of <sys/types.h>, and this header file is not required on Linux. However, some historical (BSD) implementations required this header file, and portable applications are probably wise to include it.
|
||||
#include <unistd.h>
|
||||
#include <utility>
|
||||
|
||||
#include "SerialTCPCookie.h"
|
||||
|
||||
ServoCommInterface::ServoCommInterface(object_id_t setObjectId) : SystemObject(setObjectId) {}
|
||||
|
||||
ReturnValue_t ServoCommInterface::initializeInterface(CookieIF *cookie) {
|
||||
SerialTCPCookie *tcpCookie = dynamic_cast<SerialTCPCookie *>(cookie);
|
||||
if (tcpCookie != nullptr) {
|
||||
return initializeInterface(tcpCookie);
|
||||
}
|
||||
return DeviceCommunicationIF::INVALID_COOKIE_TYPE;
|
||||
}
|
||||
|
||||
ReturnValue_t ServoCommInterface::sendMessage(CookieIF *cookie, const uint8_t *sendData,
|
||||
size_t sendLen) {
|
||||
SerialTCPCookie *tcpCookie = dynamic_cast<SerialTCPCookie *>(cookie);
|
||||
if (tcpCookie != nullptr) {
|
||||
return sendMessage(tcpCookie, sendData, sendLen);
|
||||
}
|
||||
return DeviceCommunicationIF::INVALID_COOKIE_TYPE;
|
||||
}
|
||||
|
||||
ReturnValue_t ServoCommInterface::sendMessage(SerialTCPCookie *cookie, const uint8_t *sendData,
|
||||
size_t sendLen) {
|
||||
if (cookie->socket == -1) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
ssize_t result = send(cookie->socket, sendData, sendLen, 0);
|
||||
|
||||
if (result < 0){
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
if (std::cmp_not_equal(result, sendLen)) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ServoCommInterface::getSendSuccess(CookieIF *cookie) { return returnvalue::OK; }
|
||||
|
||||
ReturnValue_t ServoCommInterface::requestReceiveMessage(CookieIF *cookie, size_t requestLen) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ServoCommInterface::readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||
size_t *size) {
|
||||
SerialTCPCookie *tcpCookie = dynamic_cast<SerialTCPCookie *>(cookie);
|
||||
if (tcpCookie != nullptr) {
|
||||
return readReceivedMessage(tcpCookie, buffer, size);
|
||||
}
|
||||
return DeviceCommunicationIF::INVALID_COOKIE_TYPE;
|
||||
}
|
||||
|
||||
ReturnValue_t ServoCommInterface::readReceivedMessage(SerialTCPCookie *cookie, uint8_t **buffer,
|
||||
size_t *size) {
|
||||
if (cookie->socket == -1) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
ssize_t result = recv(cookie->socket, cookie->buffer, cookie->bufferSize, 0);
|
||||
|
||||
if (result <= -1) {
|
||||
*size = 0;
|
||||
if (errno == EAGAIN or errno == EWOULDBLOCK) {
|
||||
//no data
|
||||
return returnvalue::OK;
|
||||
}
|
||||
// TODO wrap errno
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
if (result == 0) {
|
||||
// peer shut down
|
||||
close(cookie->socket);
|
||||
cookie->socket = -1;
|
||||
return returnvalue::FAILED; // TODO connection closed
|
||||
}
|
||||
|
||||
*size = result;
|
||||
*buffer = cookie->buffer;
|
||||
|
||||
|
||||
if (std::cmp_greater_equal(result, cookie->bufferSize) and cookie->flush) {
|
||||
// we do not know if there is more data in the socket, so we read until we get no more
|
||||
uint8_t ignore[10];
|
||||
while (recv(cookie->socket, ignore, sizeof(ignore), 0) > 0) {
|
||||
}
|
||||
//ignore any fault here as previous read was ok. next call will catch it
|
||||
}
|
||||
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ServoCommInterface::initializeInterface(SerialTCPCookie *cookie) {
|
||||
cookie->socket = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
if (cookie->socket == -1) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
sockaddr_in6 serverAddr;
|
||||
serverAddr.sin6_family = AF_INET6;
|
||||
serverAddr.sin6_port = htons(cookie->port);
|
||||
|
||||
int retval =inet_pton(AF_INET6, cookie->host, &serverAddr.sin6_addr);
|
||||
if (retval == 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "IpCommInterface::initializeInterface: Invalid IP!" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
retval = connect(cookie->socket, (struct sockaddr *)&serverAddr, sizeof(serverAddr));
|
||||
|
||||
if (retval == -1) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "IpCommInterface::initializeInterface: connection failed with " << errno
|
||||
<< std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
fcntl(cookie->socket, F_SETFL, O_NONBLOCK);
|
||||
|
||||
return returnvalue::OK;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
|
||||
#include "SerialTCPCookie.h"
|
||||
|
||||
class ServoCommInterface : public DeviceCommunicationIF, public SystemObject {
|
||||
public:
|
||||
ServoCommInterface(object_id_t setObjectId);
|
||||
|
||||
virtual ~ServoCommInterface() {}
|
||||
|
||||
ReturnValue_t initializeInterface(CookieIF *cookie) override;
|
||||
|
||||
ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) override;
|
||||
|
||||
ReturnValue_t getSendSuccess(CookieIF *cookie) override;
|
||||
|
||||
ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override;
|
||||
|
||||
ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) override;
|
||||
|
||||
private:
|
||||
ReturnValue_t initializeInterface(SerialTCPCookie *cookie);
|
||||
ReturnValue_t sendMessage(SerialTCPCookie *cookie, const uint8_t *sendData, size_t sendLen);
|
||||
ReturnValue_t readReceivedMessage(SerialTCPCookie *cookie, uint8_t **buffer, size_t *size);
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <fsfw/introspection/ClasslessEnum.h>
|
||||
|
||||
FSFW_CLASSLESS_ENUM(SystemObjects, uint32_t, ((SERVO_FRONT_LEFT, "Servo front left"))
|
||||
((SERVO_FRONT_RIGHT, "Servo front right"))
|
||||
((SERVO_BACK_LEFT, "Servo back left"))
|
||||
((SERVO_BACK_RIGHT,"Servo back right"))
|
||||
((MOTOR_AXLE_LEFT, "Motors left axle"))
|
||||
((MOTOR_AXLE_RIGHT, "Motors right axle"))
|
||||
((MOTOR_AXLE_BACK, "Motors back axle"))
|
||||
((STEERING_CONTROLLER, "Steering Controller"))
|
||||
((COMM_IF, 123, "CommIF")))
|
@ -6,7 +6,7 @@ target_sources(${TARGET_NAME} PUBLIC
|
||||
src/asm_vectors.S
|
||||
src/open.c
|
||||
src/xil_exception.c
|
||||
src/sbrk.c
|
||||
#src/sbrk.c
|
||||
src/xl2cc_counter.c
|
||||
src/xil_cache.c
|
||||
src/xil_spinlock.c
|
||||
@ -48,5 +48,5 @@ target_sources(${TARGET_NAME} PUBLIC
|
||||
src/outbyte.c
|
||||
src/unlink.c
|
||||
src/abort.c
|
||||
src/_sbrk.c
|
||||
#src/_sbrk.c
|
||||
)
|
1
fsfw
1
fsfw
@ -1 +0,0 @@
|
||||
Subproject commit 9110fd27285c8f6ec145617b168d4cf29a04dc5e
|
@ -1 +1 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE main.cpp testIp.cpp malloc_lock.c controller/PrintController.cpp)
|
||||
target_sources(${TARGET_NAME} PRIVATE main.c)
|
@ -1,33 +0,0 @@
|
||||
#include "PrintController.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
PrintController::PrintController(object_id_t setObjectId)
|
||||
: SystemObject(setObjectId) {}
|
||||
|
||||
ReturnValue_t PrintController::initialize() {
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
XGpioPs_Config config;
|
||||
config.DeviceId = 4; // chosen by fair dice throw
|
||||
config.BaseAddr = XPS_GPIO_BASEADDR;
|
||||
s32 returncode = XGpioPs_CfgInitialize(&gpio, &config, XPS_GPIO_BASEADDR);
|
||||
if (returncode != 0) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
XGpioPs_SetDirection(&gpio, 0, (1 << 7));
|
||||
XGpioPs_SetOutputEnable(&gpio, 0, (1 << 7));
|
||||
XGpioPs_WritePin(&gpio, 7, 1);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PrintController::performOperation(uint8_t operationCode) {
|
||||
printf("running\n");
|
||||
static int pinvalue = 1;
|
||||
pinvalue = pinvalue ^ 1;
|
||||
XGpioPs_WritePin(&gpio, 7, pinvalue);
|
||||
return returnvalue::OK;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <xgpiops.h>
|
||||
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
||||
|
||||
|
||||
class PrintController: public SystemObject, public ExecutableObjectIF {
|
||||
public:
|
||||
PrintController(object_id_t setObjectId);
|
||||
virtual ~PrintController() = default;
|
||||
|
||||
ReturnValue_t initialize() override;
|
||||
|
||||
ReturnValue_t performOperation(uint8_t operationCode) override;
|
||||
|
||||
private:
|
||||
XGpioPs gpio;
|
||||
};
|
@ -62,9 +62,7 @@
|
||||
|
||||
/* Standard includes. */
|
||||
#include <limits.h>
|
||||
extern "C" {
|
||||
#include <stdio.h>
|
||||
}
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include "FreeRTOS.h"
|
||||
@ -84,34 +82,12 @@ extern "C" {
|
||||
|
||||
/* Xilinx includes. */
|
||||
// #include "platform.h"
|
||||
extern "C" {
|
||||
#include "xil_exception.h"
|
||||
#include "xparameters.h"
|
||||
#include "xscugic.h"
|
||||
#include "xscutimer.h"
|
||||
#include "xuartps_hw.h"
|
||||
}
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||
#include <fsfw/ipc/CommandMessageCleaner.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/objectmanager/frameworkObjects.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
#include <objects/systemObjects.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
void messagetypes::clearMissionMessage(CommandMessage* message){};
|
||||
|
||||
#include <objects/ObjectFactory.h>
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
ServiceInterfaceStream sif::debug("DEBUG", false);
|
||||
ServiceInterfaceStream sif::info("INFO", false);
|
||||
ServiceInterfaceStream sif::warning("WARNING", false);
|
||||
ServiceInterfaceStream sif::error("ERROR", false, true, true);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Configure the hardware as necessary to run this demo.
|
||||
@ -153,26 +129,26 @@ int main(void) {
|
||||
/* Configure the hardware ready to run the demo. */
|
||||
prvSetupHardware();
|
||||
|
||||
printf("Booting Software\n");
|
||||
// printf("Booting Software\n");
|
||||
|
||||
malloc_mutex = xSemaphoreCreateRecursiveMutex();
|
||||
if (malloc_mutex == NULL) {
|
||||
printf("Could not obtaiin malloc mutex, bye...\n");
|
||||
exit(-1);
|
||||
}
|
||||
int taskParameters = 0;
|
||||
|
||||
int taskParameters =0;
|
||||
static const uint16_t stackSizeWords = 512;
|
||||
StaticTask_t xTaskBuffer;
|
||||
StackType_t xStack[stackSizeWords];
|
||||
|
||||
xTaskCreate(
|
||||
xTaskCreateStatic(
|
||||
mission, /* The function that implements the task. */
|
||||
"init", /* The text name assigned to the task - for debug only as it is not used by the
|
||||
kernel. */
|
||||
10240, /* The size of the stack to allocate to the task. */
|
||||
&taskParameters, /* The parameter passed to the task - not used in this simple case. */
|
||||
"init", /* The text name assigned to the task - for debug only as it is
|
||||
not used by the kernel. */
|
||||
stackSizeWords, /* The size of the stack to allocate to the task. */
|
||||
&taskParameters, /* The parameter passed to the task - not used in this
|
||||
simple case. */
|
||||
4, /* The priority assigned to the task. */
|
||||
nullptr); /* The task handle is not required, so NULL is passed. */
|
||||
xStack, &xTaskBuffer);
|
||||
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* If all is well, the scheduler will now be running, and the following
|
||||
line will never be reached. If the following line does execute, then
|
||||
there was either insufficient FreeRTOS heap memory available for the idle
|
||||
@ -189,53 +165,19 @@ int main(void) {
|
||||
|
||||
void testIp();
|
||||
|
||||
extern "C" {
|
||||
void rust_main(double i);
|
||||
}
|
||||
|
||||
void mission(void *){
|
||||
void mission(void *) {
|
||||
|
||||
printf("Starting Mission\n");
|
||||
// printf("Starting Mission\n");
|
||||
|
||||
rust_main(123456879123456789);
|
||||
|
||||
testIp();
|
||||
// testIp();
|
||||
|
||||
sif::debug << "OStreams working" << std::endl;
|
||||
// printf("Started Tasks, deleting init task\n");
|
||||
|
||||
ObjectManager* objManager = ObjectManager::instance();
|
||||
objManager->setObjectFactoryFunction(ObjectFactory::produce, nullptr);
|
||||
|
||||
printf("Created Objects\n");
|
||||
|
||||
objManager->initialize();
|
||||
|
||||
printf("Initialized Objects\n");
|
||||
|
||||
TaskFactory* taskFactory = TaskFactory::instance();
|
||||
if (taskFactory == nullptr) {
|
||||
printf("Ooopsie\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TaskPriority currPrio;
|
||||
|
||||
TaskDeadlineMissedFunction deadlineMissedFunc = nullptr;
|
||||
|
||||
currPrio = 2;
|
||||
|
||||
PeriodicTaskIF* controllerTask = taskFactory->createPeriodicTask(
|
||||
"controller", currPrio, 1024, 1, nullptr);
|
||||
controllerTask->addComponent(123);
|
||||
controllerTask->addComponent(130);
|
||||
|
||||
printf("Created Tasks\n");
|
||||
|
||||
controllerTask->startTask();
|
||||
|
||||
printf("Started Tasks, deleting init task\n");
|
||||
|
||||
vTaskDelete(nullptr);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
@ -318,12 +260,11 @@ void vApplicationIdleHook(void) {
|
||||
management options. If there is a lot of heap memory free then the
|
||||
configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
|
||||
RAM. */
|
||||
xFreeHeapSpace = xPortGetFreeHeapSize();
|
||||
xMinimumEverFreeHeapSpace = xPortGetMinimumEverFreeHeapSize();
|
||||
// xFreeHeapSpace = xPortGetFreeHeapSize();
|
||||
// xMinimumEverFreeHeapSpace = xPortGetMinimumEverFreeHeapSize();
|
||||
|
||||
/* Remove compiler warning about xFreeHeapSpace being set but never used. */
|
||||
(void)xFreeHeapSpace;
|
||||
(void)xMinimumEverFreeHeapSpace;
|
||||
// /* Remove compiler warning about xFreeHeapSpace being set but never used.
|
||||
// */ (void)xFreeHeapSpace; (void)xMinimumEverFreeHeapSpace;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
@ -444,11 +385,9 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
|
||||
application must provide an implementation of vApplicationGetTimerTaskMemory()
|
||||
to provide the memory that is used by the Timer service task. */
|
||||
|
||||
extern "C" {
|
||||
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
|
||||
StackType_t **ppxTimerTaskStackBuffer,
|
||||
uint32_t *pulTimerTaskStackSize);
|
||||
}
|
||||
|
||||
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
|
||||
StackType_t **ppxTimerTaskStackBuffer,
|
@ -1,19 +0,0 @@
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#include "semphr.h"
|
||||
|
||||
SemaphoreHandle_t malloc_mutex = NULL;
|
||||
|
||||
void __malloc_lock(struct _reent *r) {
|
||||
// if the mutex is not initialized yet, no task have been started either
|
||||
if (malloc_mutex != NULL) {
|
||||
xSemaphoreTakeRecursive(malloc_mutex, portMAX_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
void __malloc_unlock(struct _reent *r) {
|
||||
// if the mutex is not initialized yet, no task have been started either
|
||||
if (malloc_mutex != NULL) {
|
||||
xSemaphoreGiveRecursive(malloc_mutex);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user