common cmake files moved to example_common

This commit is contained in:
2022-05-29 18:41:33 +02:00
parent ff569dd02c
commit c564fa37fd
9 changed files with 161 additions and 19 deletions

View File

@ -21,7 +21,7 @@ ReturnValue_t STM32TestTask::initialize() {
ReturnValue_t STM32TestTask::performPeriodicAction() {
if (blinkyLed) {
#if OBSW_ETHERNET_USE_LEDS == 0
#if OBSW_ETHERNET_USE_LED1_LED2 == 0
BSP_LED_Toggle(LED1);
BSP_LED_Toggle(LED2);
#endif

View File

@ -1,12 +1,11 @@
#include "TmTcLwIpUdpBridge.h"
#include <OBSWConfig.h>
#include <fsfw/ipc/MutexGuard.h>
#include <fsfw/serialize/EndianConverter.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include "app_ethernet.h"
#include "ethernetif.h"
#include "udp_config.h"
TmTcLwIpUdpBridge::TmTcLwIpUdpBridge(object_id_t objectId,
@ -56,7 +55,7 @@ ReturnValue_t TmTcLwIpUdpBridge::udp_server_init() {
ReturnValue_t TmTcLwIpUdpBridge::performOperation(uint8_t operationCode) {
TmTcBridge::performOperation();
#if TCPIP_RECV_WIRETAPPING == 1
#if OBSW_TCPIP_UDP_WIRETAPPING == 1
if (connectFlag) {
uint32_t ipAddress = ((ip4_addr *)&lastAdd)->addr;
int ipAddress1 = (ipAddress & 0xFF000000) >> 24;
@ -90,7 +89,7 @@ ReturnValue_t TmTcLwIpUdpBridge::sendTm(const uint8_t *data, size_t dataLen) {
if ((p_tx != nullptr) && (lastAdd.addr != IPADDR_TYPE_ANY) &&
(upcb != nullptr)) {
/* copy data to pbuf */
err_t err = pbuf_take(p_tx, (char *)data, dataLen);
err_t err = pbuf_take(p_tx, (const char *)data, dataLen);
if (err != ERR_OK) {
pbuf_free(p_tx);
return err;
@ -143,7 +142,7 @@ void TmTcLwIpUdpBridge::udp_server_receive_callback(void *arg,
udpBridge->lastPort = port;
if (not udpBridge->comLinkUp()) {
udpBridge->registerCommConnect();
#if TCPIP_RECV_WIRETAPPING == 1
#if OBSW_TCPIP_UDP_WIRETAPPING == 1
udpBridge->connectFlag = true;
#endif
/* This should have already been done, but we will still do it */
@ -155,8 +154,8 @@ void TmTcLwIpUdpBridge::udp_server_receive_callback(void *arg,
char *data = reinterpret_cast<char *>(p_tx->payload);
*(data + p_tx->len) = '\0';
#if TCPIP_RECV_WIRETAPPING == 1
udpBridge->printData(p, data);
#if OBSW_TCPIP_UDP_WIRETAPPING == 1
udpBridge->printData(reinterpret_cast<uint8_t *>(p->payload), p->len);
#endif
store_address_t storeId;

View File

@ -1,12 +1,12 @@
#ifndef BSP_STM32_RTEMS_NETWORKING_TMTCUDPBRIDGE_H_
#define BSP_STM32_RTEMS_NETWORKING_TMTCUDPBRIDGE_H_
#include <fsfw/tmtcservices/TmTcBridge.h>
#include "fsfw/tmtcservices/TmTcBridge.h"
#include "commonConfig.h"
#include <lwip/ip_addr.h>
#include <lwip/udp.h>
#define TCPIP_RECV_WIRETAPPING 0
/**
* This bridge is used to forward TMTC packets received via LwIP UDP to the
* internal software bus.
@ -63,7 +63,7 @@ private:
bool physicalConnection = false;
MutexIF *bridgeLock = nullptr;
#if TCPIP_RECV_WIRETAPPING == 1
#if OBSW_TCPIP_UDP_WIRETAPPING == 1
bool connectFlag = false;
#endif

View File

@ -1,7 +1,5 @@
#include "UdpTcLwIpPollingTask.h"
#include <hardware_init.h>
#include "TmTcLwIpUdpBridge.h"
#include "app_dhcp.h"
#include "app_ethernet.h"

View File

@ -1,5 +1,4 @@
#ifndef BSP_STM32_RTEMS_EMACPOLLINGTASK_H_
#define BSP_STM32_RTEMS_EMACPOLLINGTASK_H_
#pragma once
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
@ -36,5 +35,3 @@ private:
TmTcLwIpUdpBridge *udpBridge = nullptr;
struct netif *gnetif = nullptr;
};
#endif /* BSP_STM32_RTEMS_EMACPOLLINGTASK_H_ */

View File

@ -597,6 +597,67 @@ void ethernet_link_check_state(struct netif *netif) {
}
}
void HAL_ETH_RxAllocateCallback(uint8_t **buff)
{
struct pbuf_custom *p = LWIP_MEMPOOL_ALLOC(RX_POOL);
if (p)
{
/* Get the buff from the struct pbuf address. */
*buff = (uint8_t *)p + offsetof(RxBuff_t, buff);
p->custom_free_function = pbuf_free_custom;
/* Initialize the struct pbuf.
* This must be performed whenever a buffer's allocated because it may be
* changed by lwIP or the app, e.g., pbuf_free decrements ref. */
pbuf_alloced_custom(PBUF_RAW, 0, PBUF_REF, p, *buff, ETH_RX_BUFFER_SIZE);
}
else
{
RxAllocStatus = RX_ALLOC_ERROR;
*buff = NULL;
}
}
void HAL_ETH_RxLinkCallback(void **pStart, void **pEnd, uint8_t *buff, uint16_t Length)
{
struct pbuf **ppStart = (struct pbuf **)pStart;
struct pbuf **ppEnd = (struct pbuf **)pEnd;
struct pbuf *p = NULL;
/* Get the struct pbuf from the buff address. */
p = (struct pbuf *)(buff - offsetof(RxBuff_t, buff));
p->next = NULL;
p->tot_len = 0;
p->len = Length;
/* Chain the buffer. */
if (!*ppStart)
{
/* The first buffer of the packet. */
*ppStart = p;
}
else
{
/* Chain the buffer to the end of the packet. */
(*ppEnd)->next = p;
}
*ppEnd = p;
/* Update the total length of all the buffers of the chain. Each pbuf in the chain should have its tot_len
* set to its own length, plus the length of all the following pbufs in the chain. */
for (p = *ppStart; p != NULL; p = p->next)
{
p->tot_len += Length;
}
/* Invalidate data cache because Rx DMA's writing to physical memory makes it stale. */
SCB_InvalidateDCache_by_Addr((uint32_t *)buff, Length);
}
void HAL_ETH_TxFreeCallback(uint32_t * buff)
{
pbuf_free((struct pbuf *)buff);
}
ETH_HandleTypeDef *getEthernetHandle() { return &EthHandle; }
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/