SingingCat
0
application
include
networkif.h
1
#ifndef NETWORKIF_H
2
#define NETWORKIF_H 1
3
4
#include "main-header.h"
5
#include "stdint.h"
6
7
// various bits defining the status
8
// was it probed?
9
#define STATUS_PROBED 0
10
// did probe succeed?
11
#define STATUS_PROBE_SUCCESS 1
12
// was it successfully initialised
13
#define STATUS_INITIALISED 2
14
// is it ready to transmit? (the device sets and clears this)
15
#define STATUS_READY_TO_TRANSMIT 3
16
17
// a registered network device
18
typedef
struct
network_context
{
19
struct
networkif
* nif;
20
uint8_t status;
21
uint8_t source;
22
MCULIB_HANDLE mculib_handle;
23
}
_network_context_t
;
24
25
// an instance of a network device
26
typedef
struct
networkif
{
27
int (*probe)(
struct
network_context
*nc);
// return 0 if device exists
28
int (*init)(
struct
network_context
*nc);
// return 0 if device was initialised
29
int (*loop)(
struct
network_context
*nc);
// return 0
30
int (*transmit)(
struct
network_context
*nc,
const
uint8_t *buf, uint16_t size);
// return 0 if data was transmitted
31
int (*stop)(
struct
network_context
*nc);
32
void (*info)(
struct
network_context
*nc);
// print info
33
int (*busy)(
struct
network_context
*nc);
// returns != 0 if device is currently busy sending stuff
34
}
_networkif
;
35
36
37
38
void
init_nic_registry();
39
void
register_nic(
struct
networkif
*nif,
int
SOURCE);
40
void
init_all_nics();
41
void
print_all_nics();
42
void
process_nic_event_loop();
43
int
stop_nic_by_type(
int
source);
44
int
start_nic_by_type(
int
source);
45
int
isready_by_type(
int
source);
// is this device ready to transmit (generally. it might still be busy)
46
int
isonline_by_type(
int
source);
// is this device ready to transmit or expected to be able to transmit shortly?
47
void
nic_set_transmit_status(
struct
network_context
*nctx,
int
status);
48
int
nic_is_busy(
int
source);
// calls nic->busy()
49
struct
network_context
*nic_by_type(
int
source);
50
struct
network_context
*nic_by_index(
int
index);
51
52
#endif
network_context
Definition:
networkif.h:18
networkif
Definition:
networkif.h:26
Generated on Tue May 28 2024 19:13:43 for SingingCat by
1.9.4