Statistics
| Branch: | Tag: | Revision:

amiro-os / components / radio / a2500r24a.cpp @ b8b3a9c9

History | View | Annotate | Download (1.227 KB)

1
#include <string.h>
2

    
3
#include <amiro/util/util.h>
4
#include <amiro/bus/spi/HWSPIDriver.hpp>
5
#include <amiro/radio/a2500r24a.hpp>
6

    
7
namespace amiro {
8

    
9
A2500R24A::A2500R24A(HWSPIDriver *driver)
10
    : driver(driver) {
11

    
12
}
13

    
14
A2500R24A::~A2500R24A() {
15

    
16
}
17

    
18
chibios_rt::EvtSource*
19
A2500R24A::getEventSource() {
20
  return &this->eventSource;
21
}
22

    
23
msg_t A2500R24A::main() {
24

    
25
  while (!this->shouldTerminate()) {
26

    
27
    updateSensorData();
28

    
29
    this->eventSource.broadcastFlags(0);
30

    
31
    this->waitAnyEventTimeout(ALL_EVENTS, MS2ST(200));
32

    
33
  }
34
  return RDY_OK;
35
}
36

    
37
void A2500R24A::updateSensorData() {
38

    
39
}
40

    
41
msg_t A2500R24A::configure(A2500R24AConfig *config) {
42

    
43
  return RDY_OK;
44

    
45
}
46

    
47
uint8_t A2500R24A::getCheck() {
48

    
49
  const size_t buffer_size = 1 /* addressing */
50
                              + 1; /* who am i */
51
  uint8_t buffer[buffer_size];
52

    
53
  // Exchange the data with the A2500R24A radio chip
54
  // Specify the adress and the mode
55
  buffer[0] =  offsetof(A2500R24A::registerStatus, PARTNUM) | A2500R24A::SPI_READ | A2500R24A::SPI_STATUS_ACCESS;
56
  this->driver->exchange(buffer, buffer, buffer_size);
57
  // Check
58
  if (buffer[1] == A2500R24A::A2500R24A_PARTNUM) {
59
          return A2500R24A::CHECK_OK;
60
  } else {
61
          return A2500R24A::CHECK_FAIL;
62
  }
63

    
64
}
65

    
66
} /* amiro */