Statistics
| Branch: | Tag: | Revision:

amiro-os / devices / LightRing / global.hpp @ ab2f0120

History | View | Annotate | Download (2.305 KB)

1 58fe0e0b Thomas Schöpping
#ifndef AMIRO_GLOBAL_HPP_
2
#define AMIRO_GLOBAL_HPP_
3
4
#include <hal.h>
5
6
#include <board.h>
7
#include <amiro/bus/i2c/HWI2CDriver.hpp>
8
#include <amiro/bus/spi/HWSPIDriver.hpp>
9
#include <amiro/leds/tlc5947.hpp>
10
#include <amiro/eeprom/at24.hpp>
11
#include <amiro/FileSystemInputOutput/FSIOLightRing.hpp>
12
#include <LightRing.h>
13
#include <amiro/Lidar.h>
14
#include <amiro/radio/a2500r24a.hpp>
15
#include <amiro/serial_reset/serial_can_mux.hpp>
16
#include <userthread.hpp>
17
18
namespace amiro {
19
20
class Global final
21
{
22
public:
23
  I2CConfig i2c2_config{
24
    /* I2C mode                 */ OPMODE_I2C,
25
    /* frequency                */ 400000,
26
    /* I2C fast mode duty cycle */ FAST_DUTY_CYCLE_2
27
  };
28
29
  SerialConfig sd1_config{
30
    /* speed        */ 115200,
31
    /* CR1 register */ 0,
32
    /* CR2 register */ 0,
33
    /* CR3 register */ 0
34
  };
35
  SerialConfig sd2_config{
36
    /* speed        */ 19200,
37
    /* CR1 register */ 0,
38
    /* CR2 register */ 0,
39
    /* CR3 register */ 0
40
  };
41
42
  SPIConfig spi1_config{
43
    /* callback function pointer   */ NULL,
44
    /* chip select line port       */ GPIOC,
45
    /* chip select line pad number */ GPIOC_LIGHT_XLAT,
46
    /* initialzation data          */ SPI_CR1_BR_0 | SPI_CR1_BR_1
47
  };
48
  SPIConfig spi2_config{
49
    /* callback function pointer   */ NULL,
50
    /* chip select line port       */ GPIOB,
51
    /* chip select line pad number */ GPIOB_WL_SS_N,
52
    /* initialzation data          */ SPI_CR1_BR_0
53
  };
54
55
  /**
56
   * @brief I2C Bus 2
57
   * Conected devices:
58
   *   AT24Cxx
59
   */
60
  HWI2CDriver HW_I2C2;
61
62
  HWSPIDriver HW_SPI1;
63
  HWSPIDriver HW_SPI2;
64
65
  TLC5947 tlc5947;
66
67
  AT24 at24c01;
68
  fileSystemIo::FSIOLightRing memory;
69
70
  LightRing robot;
71
72
  SerialCanMux sercanmux1;
73
74
  Lidar lidar;
75
76
  A2500R24A a2500r24a;
77
78
  UserThread userThread;
79
80
  uint8_t shellTermID;
81
82
public:
83
  Global() :
84
    HW_I2C2(&I2CD2),
85
    HW_SPI1(&SPID1, &spi1_config), HW_SPI2(&SPID2, &spi2_config),
86
    tlc5947(&HW_SPI1, GPIOA, GPIOA_LIGHT_BLANK),
87
    at24c01(0x400u / 0x08u, 0x08u, 500u, &HW_I2C2),
88
    memory(at24c01, /*BMSV*/ 1, /*bmsv*/ 2, /*HMV*/ 1, /*hmv*/ 0),
89
    robot(&CAND1, &tlc5947, &memory),
90
    sercanmux1(&SD1, &CAND1, CAN::LIGHT_RING_ID),
91
    lidar(CAN::LIGHT_RING_ID, Lidar::SETUP::POWER_ONLY),
92
    a2500r24a(&HW_SPI2),
93
    userThread()
94
  {
95
    return;
96
  }
97
98
  ~Global()
99
  {
100
    return;
101
  }
102
};
103
104
} // end of namespace amiro
105
106
#endif /* AMIRO_GLOBAL_HPP_ */