eBoard ①⑧⑨
Written for SIA 2017/2018
eagle_I2CInOut.h
Go to the documentation of this file.
1 #ifndef EAGLE_EBOARD_HELPLIB_I2CINOUT
2 #define EAGLE_EBOARD_HELPLIB_I2CINOUT
3 
12 //=====================================================================================================================================================
13 // Macro Definitions
14 //=====================================================================================================================================================
15 
16  //To avoid not_found issues
18  #define DIGITAL_IN 0x0
19  #define DIGITAL_IN_INV 0x1
21  #define DIGITAL_IN_PULLUP 0x2
23  #define DIGITAL_IN_PULLUP_INV 0x3
25  #define DIGITAL_OUT 0x4
27  #define DIGITAL_OUT_INV 0x5
29  #define DIGITAL_OUT_LOW 0x6
31  #define DIGITAL_OUT_HIGH 0x7
33  #define ANALOG_IN_8_BIT 0x8
35  #define ANALOG_IN_10_BIT 0x9
37  #define ANALOG_IN_MEAN_8_BIT 0xA
39  #define ANALOG_IN_MEAN_10_BIT 0xB
41  #define COUNTER_8_BIT 0xC
43  #define COUNTER_16_BIT 0xD
45  #define COUNTER_RISE_8_BIT 0xE
47  #define COUNTER_RISE_16_BIT 0xF
49  #define PWM_SLOW 0x8
51  #define PWM_FAST 0x9
53  #define FREQ_LOW 0xA
55  #define FREQ_HIGH 0xB
57  #define COUNTER_B_DIR 0xC
59  #define COUNTER_B_DIR_PULLUP 0xD
61  #define COUNTER_MEAN_8_BIT 0xE
63  #define COUNTER_MEAN_16_BIT 0xF
65 
66 //=====================================================================================================================================================
67 // I2CInOut
68 //=====================================================================================================================================================
69 
70  //-------------------------------------------------------------------------------------------------------------------------------------------------
71  // class
72  //-------------------------------------------------------------------------------------------------------------------------------------------------
73 
97  struct I2CInOut{
104  #if EBOARD_USE_UTILITY > 0x0
105  inline void read(void);
108  inline void changeAddress(optVAL_t);
110  inline void changeModes(optVAL_t,optVAL_t,optVAL_t);
111  #endif
112 
116  inline void write(void);
117 
119  optVAL_t A; //if you've used uint16_t values you'll have to replace it here
120  //we only have B - DiOut and C - AO [OUT]
125  };
126 
128 
129  //-------------------------------------------------------------------------------------------------------------------------------------------------
130  // definitions
131  //-------------------------------------------------------------------------------------------------------------------------------------------------
132 
134  this->A=0x0;this->B=0x0;this->C=0x0;
135  }
136  #if EBOARD_USE_UTILITY > 0x0
137  void I2CInOut::read(void) {}
138  void I2CInOut::changeAddress(optVAL_t){}
139  void I2CInOut::changeModes(optVAL_t,optVAL_t,optVAL_t) {}
140  #endif
141  void I2CInOut::write(void){
142  setPin(PIN_MOTOR_DIR,((this->B)!=0x0));
143  writePWM(this->C);
144  }
146 #endif
void writePWM(optVAL_t val)
write a clamped pwm value to an output pin
optVAL_t C
storing value for C-pin [MOTOR SPE]
This is the SoccerBoard ghost struct :D.
void setPin(optVAL_t idx, optVAL_t mode=OUTPUT)
[COPY&PASTE] set a pin to a certain mode => checkPin() will return true then
void write(void)
this will write values stored in B and C
optVAL_t B
storing value for B-pin [MOTOR DIR]
I2CInOut(SoccerBoard &, optVAL_t, optVAL_t, optVAL_t, optVAL_t)
The constructor.
#define PIN_MOTOR_DIR
Definition: eBoard.h:569
[COPY&PASTE] This is the I2CInOut ghost struct :D
int optVAL_t
Definition: eBoard.h:137
optVAL_t A
storing value for A-pin ( I prevent errors!)