-
Notifications
You must be signed in to change notification settings - Fork 2
/
at86rf212.hpp
105 lines (90 loc) · 2.3 KB
/
at86rf212.hpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* at86rf212 c++ wrapper
*
* Copyright 2016 Ryan Kurte
*/
#pragma once
#include "at86rf212_if.hpp"
namespace AT86RF212
{
#include "at86rf212.h"
#include "at86rf212_defs.h"
class At86rf212
{
public:
// Init using C style driver interface
int init(struct at86rf212_driver_s *driver, void *driver_ctx)
{
return at86rf212_init(&(this->device), driver, driver_ctx);
}
// Init using C++ style driver interface
int init(AT86RF212::DriverInterface* driver_ctx)
{
struct at86rf212_driver_s *driver = AT86RF212::DriverWrapper::GetWrapper();
return at86rf212_init(&(this->device), driver, (void*)driver_ctx);
}
// Close device
int close()
{
return at86rf212_close(&(this->device));
}
int set_short_address(uint16_t address)
{
return at86rf212_set_short_address(&(this->device), address);
}
int set_pan_id(uint16_t pan_id)
{
return at86rf212_set_pan_id(&(this->device), pan_id);
}
int set_state(uint8_t state)
{
return at86rf212_set_state(&(this->device), state);
}
int set_state_blocking(uint8_t state)
{
return at86rf212_set_state_blocking(&(this->device), state);
}
int get_state(uint8_t *state)
{
return at86rf212_get_state(&(this->device), state);
}
int set_channel(uint8_t channel)
{
return at86rf212_set_channel(&(this->device), channel);
}
int get_channel(uint8_t *channel)
{
return at86rf212_get_channel(&(this->device), channel);
}
int start_tx(uint8_t length, uint8_t* data)
{
return at86rf212_start_tx(&(this->device), length, data);
}
int check_tx()
{
return at86rf212_check_tx(&(this->device));
}
int start_rx()
{
return at86rf212_start_rx(&(this->device));
}
int check_rx()
{
return at86rf212_check_rx(&(this->device));
}
int get_rx(uint8_t* length, uint8_t* data)
{
return at86rf212_get_rx(&(this->device), length, data);
}
int read_reg(uint8_t reg, uint8_t* val)
{
return at86rf212_read_reg(&(this->device), reg, val);
}
int write_reg(uint8_t reg, uint8_t val)
{
return at86rf212_write_reg(&(this->device), reg, val);
}
private:
struct at86rf212_s device;
};
};