Max OS 0.3
Loading...
Searching...
No Matches
ethernet.h
Go to the documentation of this file.
1
9#ifndef MAXOS_DRIVERS_ETHERNET_ETHERNET_H
10#define MAXOS_DRIVERS_ETHERNET_ETHERNET_H
11
12#include <cstdint>
13#include <drivers/driver.h>
14#include <common/vector.h>
15#include <common/eventHandler.h>
16
17
18namespace MaxOS::drivers::ethernet {
19
21 typedef uint64_t MediaAccessControlAddress;
22
28 BEFORE_SEND,
29 DATA_SENT,
30 DATA_RECEIVED
31 };
32
37 class BeforeSendEvent : public common::Event<EthernetDriverEvents> {
38 public:
39 uint8_t* buffer;
40 uint32_t size;
41 BeforeSendEvent(uint8_t* buffer, uint32_t size);
43 };
44
49 class DataSentEvent : public common::Event<EthernetDriverEvents> {
50 public:
51 uint8_t* buffer;
52 uint32_t size;
53 DataSentEvent(uint8_t* buffer, uint32_t size);
55 };
56
61 class DataReceivedEvent : public common::Event<EthernetDriverEvents> {
62 public:
63 uint8_t* buffer;
64 uint32_t size;
65 DataReceivedEvent(uint8_t* buffer, uint32_t size);
67 };
68
73 class EthernetDriverEventHandler : public common::EventHandler<EthernetDriverEvents> {
74 public:
77
79
80 virtual void before_send(uint8_t* buffer, uint32_t size);
81 virtual void data_sent(uint8_t* buffer, uint32_t size);
82 virtual bool data_received(uint8_t* buffer, uint32_t size);
83 };
84
89 class EthernetDriver : public Driver, public common::EventManager<EthernetDriverEvents> {
90 protected:
91 virtual void do_send(uint8_t* buffer, uint32_t size);
92 void fire_data_received(uint8_t* buffer, uint32_t size);
93 void fire_data_sent(uint8_t* buffer, uint32_t size);
94
95 public:
98
99 static MediaAccessControlAddress create_media_access_control_address(uint8_t digit1, uint8_t digit2, uint8_t digit3, uint8_t digit4, uint8_t digit5, uint8_t digit6);
101
102 void send(uint8_t* buffer, uint32_t size);
103 };
104
105}
106
107
108#endif //MAXOS_DRIVERS_ETHERNET_ETHERNET_H
Used to handle an event.
Manages the m_handlers for a type of event, raises events and calls the m_handlers.
Used to store information about an event, has a type and a return value.
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
base class for all drivers, handles the activation, deactivation, initialisation and reset of the dri...
Definition driver.h:27
Event that is triggered before data is sent, holds the buffer and size of the data.
Definition ethernet.h:37
uint32_t size
The size of the buffer to be sent.
Definition ethernet.h:40
uint8_t * buffer
The buffer to be sent.
Definition ethernet.h:39
Event that is triggered when data is received, holds the buffer and size of the data.
Definition ethernet.h:61
Event that is triggered when data is sent, holds the buffer and size of the data.
Definition ethernet.h:49
uint8_t * buffer
The buffer that was sent.
Definition ethernet.h:51
uint32_t size
The size of the buffer that was sent.
Definition ethernet.h:52
Handles the events that are triggered by the Ethernet Driver.
Definition ethernet.h:73
virtual void before_send(uint8_t *buffer, uint32_t size)
Handle before send event.
Definition ethernet.cpp:39
common::Event< EthernetDriverEvents > * on_event(common::Event< EthernetDriverEvents > *event) override
Handle an event.
Definition ethernet.cpp:57
virtual void data_sent(uint8_t *buffer, uint32_t size)
Handle data sent event.
Definition ethernet.cpp:48
virtual bool data_received(uint8_t *buffer, uint32_t size)
Handle data received event.
Definition ethernet.cpp:29
Driver for the Ethernet Controller, manages the sending and receiving of data, the mac address,...
Definition ethernet.h:89
static MediaAccessControlAddress create_media_access_control_address(uint8_t digit1, uint8_t digit2, uint8_t digit3, uint8_t digit4, uint8_t digit5, uint8_t digit6)
Create a Media Access Control Address.
Definition ethernet.cpp:165
virtual MediaAccessControlAddress get_media_access_control_address()
Get the MAC address.
Definition ethernet.cpp:89
void send(uint8_t *buffer, uint32_t size)
send data to the network via the driver backend
Definition ethernet.cpp:99
void fire_data_received(uint8_t *buffer, uint32_t size)
Handle the recieved data.
Definition ethernet.cpp:122
virtual void do_send(uint8_t *buffer, uint32_t size)
(Device Side) send the data
Definition ethernet.cpp:113
void fire_data_sent(uint8_t *buffer, uint32_t size)
send data
Definition ethernet.cpp:148
Defines a base Driver class and DriverManager for managing drivers.
EthernetDriverEvents
Events that can be triggered by the Ethernet Driver.
Definition ethernet.h:27
uint64_t MediaAccessControlAddress
Used to make MAC addresses more readable.
Definition ethernet.h:21
Defines classes for handling events and event managers.
Defines a Vector class for dynamically storing an array of elements.