sitara_depot/components/free_rtos/ethernet/eth.hpp

145 lines
2.7 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* eth.hpp
*
* Created on: 6 мар. 2023 г.
* Author: sychev
*/
#ifndef FREE_RTOS_ETHERNET_ETH_HPP_
#define FREE_RTOS_ETHERNET_ETH_HPP_
#include "free_rtos/ethernet/eth_task_settings.hpp"
#include "free_rtos/ethernet/eth_rx_flow.hpp"
#include "free_rtos/ethernet/eth_tx_flow.hpp"
#include "free_rtos/semaphore/semaphore.hpp"
#include "free_rtos/ethernet/eth_frame.h"
#include "free_rtos/task/task.hpp"
#include <networking/enet/core/include/core/enet_per.h>
#include <networking/enet/utils/include/enet_apputils.h>
#include <networking/enet/core/include/per/icssg.h>
#include <cstdint>
#include <string>
#include "free_rtos/ethernet/eth_types.h"
#include "free_rtos/ethernet_ip/eth_stack.hpp"
namespace free_rtos {
class Eth {
public:
typedef enum {
e_ethInstSwitch = 1,
e_ethInstDualMac_1,
e_ethInstDualMac_2
}TEthInstId;
struct Settings {
uint32_t id;
/* Peripheral type */
Enet_Type enetType;
/* Peripheral instance */
TEthInstId instId;
/* Peripheral's MAC ports to use */
Enet_MacPort macPort[e_ethMacTotal];
UBaseType_t rxTaskPriority[e_ethMacTotal];
UBaseType_t rxTaskStackSize[e_ethMacTotal];
/* Number of MAC ports in macPorts array */
uint32_t macPortNum;
/* Name of this port to be used for logging */
std::string name;
uint32_t vlan_id;
EthStack::Settings eth_stack_sett;
};
Eth();
bool Init(Settings& sett);
bool Open();
void ioctl_callback();
void link_task();
EthUdpServerIface * getUdpServerPtr() {return eth_stack_.getUdpServerPtr(); }
EthTxFlowIface * getTxFlowPtr() { return &tx_flow_; }
EthStackIface * getEthStackPtr() {return &eth_stack_;}
private:
enum TaskPriority {
e_linkTaskPriority = 2
};
bool host_init();
private:
enum SignalsId {
e_signalIoctl,
e_signalTotal
};
enum TasksId {
e_taskLink,
e_taskTotal
};
uint32_t id_;
std::string name_;
uint32_t core_id_;
Enet_Type enetType_;
uint32_t instId_;
Enet_MacPort macPort_[e_ethMacTotal];
UBaseType_t rxTaskPriority_[e_ethMacTotal];
UBaseType_t rxTaskStackSize_[e_ethMacTotal];
uint32_t macPortNum_;
EnetPer_AttachCoreOutArgs attachInfo_;
EnetApp_HandleInfo handleInfo_;
EthTxFlow tx_flow_; ///
EthRxFlow rx_flow_[e_ethMacTotal];
Semaphore sem_[e_signalTotal];
Task task_[e_taskTotal];
bool linkUp_[e_ethMacTotal];
bool host_ready_;
TEthFrameMacAddr hostMacAddr_;
uint32_t vlan_id_;
EthStack eth_stack_;
};
}
#endif /* FREE_RTOS_ETHERNET_ETH_HPP_ */