-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradio.h
59 lines (49 loc) · 2.13 KB
/
radio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef __ORCHARD_RADIO_H__
#define __ORCHARD_RADIO_H__
#include <stddef.h>
#include <stdint.h>
struct _KRadioDevice;
typedef struct _KRadioDevice KRadioDevice;
extern KRadioDevice KRADIO1;
#define radioDevice &KRADIO1
#define RADIO_NETWORK_MAX_LENGTH 8
#define RADIO_BROADCAST_ADDRESS 255
typedef struct _RadioPacket {
uint8_t length; /* Total length of packet, including length field */
uint8_t dst; /* Address of intended recipient */
uint8_t src; /* Address of device sending packet */
uint8_t prot; /* Subsystem packet is intended for */
uint8_t payload[0]; /* Actual contents of packet */
} RadioPacket;
enum radio_protocols {
radio_prot_paging = 1,
radio_prot_dut_to_peer = 6,
radio_prot_peer_to_dut = 7,
};
extern KRadioDevice KRADIO1;
void radioInit(void);
void radioStart(KRadioDevice *radio);
void radioStop(KRadioDevice *radio);
void radioPoll(KRadioDevice *radio);
uint8_t radioRead(KRadioDevice *radio, uint8_t addr);
void radioWrite(KRadioDevice *radio, uint8_t addr, uint8_t val);
int radioDump(KRadioDevice *radio, uint8_t addr, void *bfr, int count);
int radioTemperature(KRadioDevice *radio);
void radioSetNetwork(KRadioDevice *radio, const uint8_t *id, uint8_t len);
void radioSend(KRadioDevice *radio, uint8_t dest, uint8_t prot,
size_t len, const void *payload);
void radioSetAddress(KRadioDevice *radio, uint8_t addr);
uint8_t radioAddress(KRadioDevice *radio);
void radioSetDefaultHandler(KRadioDevice *radio,
void (*handler)(uint8_t prot,
uint8_t src,
uint8_t dst,
uint8_t length,
const void *data));
void radioSetHandler(KRadioDevice *radio, uint8_t prot,
void (*handler)(uint8_t prot,
uint8_t src,
uint8_t dst,
uint8_t length,
const void *data));
#endif /* __ORCHARD_RADIO_H__ */